summaryrefslogtreecommitdiffstats
path: root/llvm/bindings/go
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2018-11-08 04:04:04 +0000
committerwhitequark <whitequark@whitequark.org>2018-11-08 04:04:04 +0000
commitac067b93b87b0e8dbad78063670a125004774c1a (patch)
tree598e12211642888eb562b197fbad0b41a6c8027b /llvm/bindings/go
parentc07f8c14f9d8011d8c7869b9123c4c81a6529898 (diff)
downloadbcm5719-llvm-ac067b93b87b0e8dbad78063670a125004774c1a.tar.gz
bcm5719-llvm-ac067b93b87b0e8dbad78063670a125004774c1a.zip
[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 llvm-svn: 346388
Diffstat (limited to 'llvm/bindings/go')
-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