[PATCH] D53883: [bindings/go] Add Go bindings to LLVMGetIndices
whitequark via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 7 20:06:30 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346388: [bindings/go] Add Go bindings to LLVMGetIndices (authored by whitequark, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D53883?vs=171766&id=173116#toc
Repository:
rL LLVM
https://reviews.llvm.org/D53883
Files:
llvm/trunk/bindings/go/llvm/ir.go
Index: llvm/trunk/bindings/go/llvm/ir.go
===================================================================
--- llvm/trunk/bindings/go/llvm/ir.go
+++ llvm/trunk/bindings/go/llvm/ir.go
@@ -1258,6 +1258,19 @@
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
//-------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53883.173116.patch
Type: text/x-patch
Size: 803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181108/aa1f9fa5/attachment.bin>
More information about the llvm-commits
mailing list