mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-23 11:49:46 +00:00
[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
This commit is contained in:
parent
9ac4c44c94
commit
2c000da033
@ -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
|
||||
//-------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user