diff options
author | Reid Kleckner <rnk@google.com> | 2018-03-14 18:33:53 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2018-03-14 18:33:53 +0000 |
commit | 862ea57eb623ed81688236bf6393df56f67d8c7b (patch) | |
tree | 0c1f5c35aae4534f30fecb5ade0f44e0ce8952d9 /bindings | |
parent | 6f801c6c330d6f63a5b05d6b13d4cfb7cdae60a3 (diff) |
[LLVM-C] [bindings/go] Add C and Golang bindings for COMDAT
Patch by Ben Clayton
Differential Revision: https://reviews.llvm.org/D44086
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327551 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/go/llvm/ir.go | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/bindings/go/llvm/ir.go b/bindings/go/llvm/ir.go index 71b11a6668e..0a379e47dc6 100644 --- a/bindings/go/llvm/ir.go +++ b/bindings/go/llvm/ir.go @@ -15,6 +15,7 @@ package llvm /* #include "llvm-c/Core.h" +#include "llvm-c/Comdat.h" #include "IRBindings.h" #include <stdlib.h> */ @@ -37,6 +38,9 @@ type ( Value struct { C C.LLVMValueRef } + Comdat struct { + C C.LLVMComdatRef + } BasicBlock struct { C C.LLVMBasicBlockRef } @@ -61,14 +65,15 @@ type ( Attribute struct { C C.LLVMAttributeRef } - Opcode C.LLVMOpcode - TypeKind C.LLVMTypeKind - Linkage C.LLVMLinkage - Visibility C.LLVMVisibility - CallConv C.LLVMCallConv - IntPredicate C.LLVMIntPredicate - FloatPredicate C.LLVMRealPredicate - LandingPadClause C.LLVMLandingPadClauseTy + Opcode C.LLVMOpcode + TypeKind C.LLVMTypeKind + Linkage C.LLVMLinkage + Visibility C.LLVMVisibility + CallConv C.LLVMCallConv + ComdatSelectionKind C.LLVMComdatSelectionKind + IntPredicate C.LLVMIntPredicate + FloatPredicate C.LLVMRealPredicate + LandingPadClause C.LLVMLandingPadClauseTy ) func (c Context) IsNil() bool { return c.C == nil } @@ -249,6 +254,18 @@ const ( ) //------------------------------------------------------------------------- +// llvm.ComdatSelectionKind +//------------------------------------------------------------------------- + +const ( + AnyComdatSelectionKind ComdatSelectionKind = C.LLVMAnyComdatSelectionKind + ExactMatchComdatSelectionKind ComdatSelectionKind = C.LLVMExactMatchComdatSelectionKind + LargestComdatSelectionKind ComdatSelectionKind = C.LLVMLargestComdatSelectionKind + NoDuplicatesComdatSelectionKind ComdatSelectionKind = C.LLVMNoDuplicatesComdatSelectionKind + SameSizeComdatSelectionKind ComdatSelectionKind = C.LLVMSameSizeComdatSelectionKind +) + +//------------------------------------------------------------------------- // llvm.IntPredicate //------------------------------------------------------------------------- @@ -1029,6 +1046,25 @@ func AddAlias(m Module, t Type, aliasee Value, name string) (v Value) { return } +// Operations on comdat +func (m Module) Comdat(name string) (c Comdat) { + cname := C.CString(name) + defer C.free(unsafe.Pointer(cname)) + c.C = C.LLVMGetOrInsertComdat(m.C, cname) + return +} + +func (v Value) Comdat() (c Comdat) { c.C = C.LLVMGetComdat(v.C); return } +func (v Value) SetComdat(c Comdat) { C.LLVMSetComdat(v.C, c.C) } + +func (c Comdat) SelectionKind() ComdatSelectionKind { + return ComdatSelectionKind(C.LLVMGetComdatSelectionKind(c.C)) +} + +func (c Comdat) SetSelectionKind(k ComdatSelectionKind) { + C.LLVMSetComdatSelectionKind(c.C, (C.LLVMComdatSelectionKind)(k)) +} + // Operations on functions func AddFunction(m Module, name string, ft Type) (v Value) { cname := C.CString(name) |