projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Go bindings: expose the Metadata type.
[oota-llvm.git]
/
bindings
/
go
/
llvm
/
ir.go
diff --git
a/bindings/go/llvm/ir.go
b/bindings/go/llvm/ir.go
index 7834f5c2c348957d82003f00defc94281dd4853d..af246fe2e65b3882e673be85cb64096c56ab02c9 100644
(file)
--- a/
bindings/go/llvm/ir.go
+++ b/
bindings/go/llvm/ir.go
@@
-55,6
+55,9
@@
type (
Use struct {
C C.LLVMUseRef
}
Use struct {
C C.LLVMUseRef
}
+ Metadata struct {
+ C C.LLVMMetadataRef
+ }
Attribute uint64
Opcode C.LLVMOpcode
TypeKind C.LLVMTypeKind
Attribute uint64
Opcode C.LLVMOpcode
TypeKind C.LLVMTypeKind
@@
-80,6
+83,9
@@
func (c Use) IsNil() bool { return c.C == nil }
// helpers
func llvmTypeRefPtr(t *Type) *C.LLVMTypeRef { return (*C.LLVMTypeRef)(unsafe.Pointer(t)) }
func llvmValueRefPtr(t *Value) *C.LLVMValueRef { return (*C.LLVMValueRef)(unsafe.Pointer(t)) }
// helpers
func llvmTypeRefPtr(t *Type) *C.LLVMTypeRef { return (*C.LLVMTypeRef)(unsafe.Pointer(t)) }
func llvmValueRefPtr(t *Value) *C.LLVMValueRef { return (*C.LLVMValueRef)(unsafe.Pointer(t)) }
+func llvmMetadataRefPtr(t *Metadata) *C.LLVMMetadataRef {
+ return (*C.LLVMMetadataRef)(unsafe.Pointer(t))
+}
func llvmBasicBlockRefPtr(t *BasicBlock) *C.LLVMBasicBlockRef {
return (*C.LLVMBasicBlockRef)(unsafe.Pointer(t))
}
func llvmBasicBlockRefPtr(t *BasicBlock) *C.LLVMBasicBlockRef {
return (*C.LLVMBasicBlockRef)(unsafe.Pointer(t))
}
@@
-99,6
+105,15
@@
func llvmValueRefs(values []Value) (*C.LLVMValueRef, C.unsigned) {
return pt, ptlen
}
return pt, ptlen
}
+func llvmMetadataRefs(mds []Metadata) (*C.LLVMMetadataRef, C.unsigned) {
+ var pt *C.LLVMMetadataRef
+ ptlen := C.unsigned(len(mds))
+ if ptlen > 0 {
+ pt = llvmMetadataRefPtr(&mds[0])
+ }
+ return pt, ptlen
+}
+
//-------------------------------------------------------------------------
// llvm.Attribute
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// llvm.Attribute
//-------------------------------------------------------------------------
@@
-421,10
+436,10
@@
func (m Module) SetInlineAsm(asm string) {
C.LLVMSetModuleInlineAsm(m.C, casm)
}
C.LLVMSetModuleInlineAsm(m.C, casm)
}
-func (m Module) AddNamedMetadataOperand(name string, operand
Value
) {
+func (m Module) AddNamedMetadataOperand(name string, operand
Metadata
) {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
- C.LLVMAddNamedMetadataOperand(m.C, cname, operand.C)
+ C.LLVMAddNamedMetadataOperand
2
(m.C, cname, operand.C)
}
func (m Module) Context() (c Context) {
}
func (m Module) Context() (c Context) {
@@
-628,8
+643,8
@@
func (v Value) Metadata(kind int) (rv Value) {
rv.C = C.LLVMGetMetadata(v.C, C.unsigned(kind))
return
}
rv.C = C.LLVMGetMetadata(v.C, C.unsigned(kind))
return
}
-func (v Value) SetMetadata(kind int, node
Value
) {
- C.LLVMSetMetadata(v.C, C.unsigned(kind), node.C)
+func (v Value) SetMetadata(kind int, node
Metadata
) {
+ C.LLVMSetMetadata
2
(v.C, C.unsigned(kind), node.C)
}
// Conversion functions.
}
// Conversion functions.
@@
-723,26
+738,15
@@
func (v Value) IsUndef() bool { return C.LLVMIsUndef(v.C) != 0 }
func ConstPointerNull(t Type) (v Value) { v.C = C.LLVMConstPointerNull(t.C); return }
// Operations on metadata
func ConstPointerNull(t Type) (v Value) { v.C = C.LLVMConstPointerNull(t.C); return }
// Operations on metadata
-func (c Context) MDString(str string) (v Value) {
- cstr := C.CString(str)
- defer C.free(unsafe.Pointer(cstr))
- v.C = C.LLVMMDStringInContext(c.C, cstr, C.unsigned(len(str)))
- return
-}
-func MDString(str string) (v Value) {
+func (c Context) MDString(str string) (md Metadata) {
cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr))
cstr := C.CString(str)
defer C.free(unsafe.Pointer(cstr))
- v.C = C.LLVMMDString(cstr, C.unsigned(len(str)))
- return
-}
-func (c Context) MDNode(vals []Value) (v Value) {
- ptr, nvals := llvmValueRefs(vals)
- v.C = C.LLVMMDNodeInContext(c.C, ptr, nvals)
+ md.C = C.LLVMMDString2(c.C, cstr, C.unsigned(len(str)))
return
}
return
}
-func
MDNode(vals []Value) (v Value
) {
- ptr, nvals := llvm
ValueRefs(val
s)
-
v.C = C.LLVMMDNode(
ptr, nvals)
+func
(c Context) MDNode(mds []Metadata) (md Metadata
) {
+ ptr, nvals := llvm
MetadataRefs(md
s)
+
md.C = C.LLVMMDNode2(c.C,
ptr, nvals)
return
}
return
}
@@
-1188,8
+1192,9
@@
func (b Builder) InsertWithName(instr Value, name string) {
func (b Builder) Dispose() { C.LLVMDisposeBuilder(b.C) }
// Metadata
func (b Builder) Dispose() { C.LLVMDisposeBuilder(b.C) }
// Metadata
-func (b Builder) SetCurrentDebugLocation(v Value) { C.LLVMSetCurrentDebugLocation(b.C, v.C) }
-func (b Builder) CurrentDebugLocation() (v Value) { v.C = C.LLVMGetCurrentDebugLocation(b.C); return }
+func (b Builder) SetCurrentDebugLocation(line, col uint, scope, inlinedAt Metadata) {
+ C.LLVMSetCurrentDebugLocation2(b.C, C.unsigned(line), C.unsigned(col), scope.C, inlinedAt.C)
+}
func (b Builder) SetInstDebugLocation(v Value) { C.LLVMSetInstDebugLocation(b.C, v.C) }
func (b Builder) InsertDeclare(module Module, storage Value, md Value) Value {
f := module.NamedFunction("llvm.dbg.declare")
func (b Builder) SetInstDebugLocation(v Value) { C.LLVMSetInstDebugLocation(b.C, v.C) }
func (b Builder) InsertDeclare(module Module, storage Value, md Value) Value {
f := module.NamedFunction("llvm.dbg.declare")