llvm.org GIT mirror llvm / 2c000da
[bindings/go] Add Go bindings to LLVMGetIndices Summary: This instruction is useful for inspecting extractvalue/insertvalue in IR. Unlike most other operations, indices cannot be inspected using the generic Value.Opcode() function so a specialized function needs to be added. Reviewers: whitequark, pcc Reviewed By: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53883 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346388 91177308-0d34-0410-b5e6-96231b3b80d8 whitequark 10 months ago
1 changed file(s) with 13 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
12571257 return
12581258 }
12591259
1260 // Operations on aggregates
1261 func (v Value) Indices() []uint32 {
1262 num := C.LLVMGetNumIndices(v.C)
1263 indicesPtr := C.LLVMGetIndices(v.C)
1264 // https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
1265 rawIndices := (*[1 << 30]C.uint)(unsafe.Pointer(indicesPtr))[:num:num]
1266 indices := make([]uint32, num)
1267 for i := range indices {
1268 indices[i] = uint32(rawIndices[i])
1269 }
1270 return indices
1271 }
1272
12601273 //-------------------------------------------------------------------------
12611274 // llvm.Builder
12621275 //-------------------------------------------------------------------------