[llvm] r362899 - [bindings/go] Add wrappers for atomic operations.
Ayke van Laethem via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 9 03:06:36 PDT 2019
Author: aykevl
Date: Sun Jun 9 03:06:35 2019
New Revision: 362899
URL: http://llvm.org/viewvc/llvm-project?rev=362899&view=rev
Log:
[bindings/go] Add wrappers for atomic operations.
This patch adds Go bindings for atomic operations in LLVM.
Differential Revision: https://reviews.llvm.org/D61034
Modified:
llvm/trunk/bindings/go/llvm/ir.go
Modified: llvm/trunk/bindings/go/llvm/ir.go
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/ir.go?rev=362899&r1=362898&r2=362899&view=diff
==============================================================================
--- llvm/trunk/bindings/go/llvm/ir.go (original)
+++ llvm/trunk/bindings/go/llvm/ir.go Sun Jun 9 03:06:35 2019
@@ -65,6 +65,8 @@ type (
C C.LLVMAttributeRef
}
Opcode C.LLVMOpcode
+ AtomicRMWBinOp C.LLVMAtomicRMWBinOp
+ AtomicOrdering C.LLVMAtomicOrdering
TypeKind C.LLVMTypeKind
Linkage C.LLVMLinkage
Visibility C.LLVMVisibility
@@ -192,6 +194,30 @@ const (
InsertValue Opcode = C.LLVMInsertValue
)
+const (
+ AtomicRMWBinOpXchg AtomicRMWBinOp = C.LLVMAtomicRMWBinOpXchg
+ AtomicRMWBinOpAdd AtomicRMWBinOp = C.LLVMAtomicRMWBinOpAdd
+ AtomicRMWBinOpSub AtomicRMWBinOp = C.LLVMAtomicRMWBinOpSub
+ AtomicRMWBinOpAnd AtomicRMWBinOp = C.LLVMAtomicRMWBinOpAnd
+ AtomicRMWBinOpNand AtomicRMWBinOp = C.LLVMAtomicRMWBinOpNand
+ AtomicRMWBinOpOr AtomicRMWBinOp = C.LLVMAtomicRMWBinOpOr
+ AtomicRMWBinOpXor AtomicRMWBinOp = C.LLVMAtomicRMWBinOpXor
+ AtomicRMWBinOpMax AtomicRMWBinOp = C.LLVMAtomicRMWBinOpMax
+ AtomicRMWBinOpMin AtomicRMWBinOp = C.LLVMAtomicRMWBinOpMin
+ AtomicRMWBinOpUMax AtomicRMWBinOp = C.LLVMAtomicRMWBinOpUMax
+ AtomicRMWBinOpUMin AtomicRMWBinOp = C.LLVMAtomicRMWBinOpUMin
+)
+
+const (
+ AtomicOrderingNotAtomic AtomicOrdering = C.LLVMAtomicOrderingNotAtomic
+ AtomicOrderingUnordered AtomicOrdering = C.LLVMAtomicOrderingUnordered
+ AtomicOrderingMonotonic AtomicOrdering = C.LLVMAtomicOrderingMonotonic
+ AtomicOrderingAcquire AtomicOrdering = C.LLVMAtomicOrderingAcquire
+ AtomicOrderingRelease AtomicOrdering = C.LLVMAtomicOrderingRelease
+ AtomicOrderingAcquireRelease AtomicOrdering = C.LLVMAtomicOrderingAcquireRelease
+ AtomicOrderingSequentiallyConsistent AtomicOrdering = C.LLVMAtomicOrderingSequentiallyConsistent
+)
+
//-------------------------------------------------------------------------
// llvm.TypeKind
//-------------------------------------------------------------------------
@@ -1044,6 +1070,26 @@ func (v Value) IsGlobalConstant() bool
func (v Value) SetGlobalConstant(gc bool) { C.LLVMSetGlobalConstant(v.C, boolToLLVMBool(gc)) }
func (v Value) IsVolatile() bool { return C.LLVMGetVolatile(v.C) != 0 }
func (v Value) SetVolatile(volatile bool) { C.LLVMSetVolatile(v.C, boolToLLVMBool(volatile)) }
+func (v Value) Ordering() AtomicOrdering { return AtomicOrdering(C.LLVMGetOrdering(v.C)) }
+func (v Value) SetOrdering(ordering AtomicOrdering) {
+ C.LLVMSetOrdering(v.C, C.LLVMAtomicOrdering(ordering))
+}
+func (v Value) IsAtomicSingleThread() bool { return C.LLVMIsAtomicSingleThread(v.C) != 0 }
+func (v Value) SetAtomicSingleThread(singleThread bool) {
+ C.LLVMSetAtomicSingleThread(v.C, boolToLLVMBool(singleThread))
+}
+func (v Value) CmpXchgSuccessOrdering() AtomicOrdering {
+ return AtomicOrdering(C.LLVMGetCmpXchgSuccessOrdering(v.C))
+}
+func (v Value) SetCmpXchgSuccessOrdering(ordering AtomicOrdering) {
+ C.LLVMSetCmpXchgSuccessOrdering(v.C, C.LLVMAtomicOrdering(ordering))
+}
+func (v Value) CmpXchgFailureOrdering() AtomicOrdering {
+ return AtomicOrdering(C.LLVMGetCmpXchgFailureOrdering(v.C))
+}
+func (v Value) SetCmpXchgFailureOrdering(ordering AtomicOrdering) {
+ C.LLVMSetCmpXchgFailureOrdering(v.C, C.LLVMAtomicOrdering(ordering))
+}
// Operations on aliases
func AddAlias(m Module, t Type, aliasee Value, name string) (v Value) {
@@ -1632,6 +1678,14 @@ func (b Builder) CreateGlobalStringPtr(s
v.C = C.LLVMBuildGlobalStringPtr(b.C, cstr, cname)
return
}
+func (b Builder) CreateAtomicRMW(op AtomicRMWBinOp, ptr, val Value, ordering AtomicOrdering, singleThread bool) (v Value) {
+ v.C = C.LLVMBuildAtomicRMW(b.C, C.LLVMAtomicRMWBinOp(op), ptr.C, val.C, C.LLVMAtomicOrdering(ordering), boolToLLVMBool(singleThread))
+ return
+}
+func (b Builder) CreateAtomicCmpXchg(ptr, cmp, newVal Value, successOrdering, failureOrdering AtomicOrdering, singleThread bool) (v Value) {
+ v.C = C.LLVMBuildAtomicCmpXchg(b.C, ptr.C, cmp.C, newVal.C, C.LLVMAtomicOrdering(successOrdering), C.LLVMAtomicOrdering(failureOrdering), boolToLLVMBool(singleThread))
+ return
+}
// Casts
func (b Builder) CreateTrunc(val Value, t Type, name string) (v Value) {
More information about the llvm-commits
mailing list