summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/bindings/go/llvm/ir.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/bindings/go/llvm/ir.go b/llvm/bindings/go/llvm/ir.go
index cad21814cd7..1872a2ffe51 100644
--- a/llvm/bindings/go/llvm/ir.go
+++ b/llvm/bindings/go/llvm/ir.go
@@ -1258,6 +1258,19 @@ func InlineAsm(t Type, asmString, constraints string, hasSideEffects, isAlignSta
return
}
+// Operations on aggregates
+func (v Value) Indices() []uint32 {
+ num := C.LLVMGetNumIndices(v.C)
+ indicesPtr := C.LLVMGetIndices(v.C)
+ // https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
+ rawIndices := (*[1 << 30]C.uint)(unsafe.Pointer(indicesPtr))[:num:num]
+ indices := make([]uint32, num)
+ for i := range indices {
+ indices[i] = uint32(rawIndices[i])
+ }
+ return indices
+}
+
//-------------------------------------------------------------------------
// llvm.Builder
//-------------------------------------------------------------------------
OpenPOWER on IntegriCloud