llvm.org GIT mirror llvm / d1edfbf
[bindings/go] Add wrappers for atomic operations. This patch adds Go bindings for atomic operations in LLVM. Differential Revision: https://reviews.llvm.org/D61034 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362899 91177308-0d34-0410-b5e6-96231b3b80d8 Ayke van Laethem a month ago
1 changed file(s) with 54 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
6464 C C.LLVMAttributeRef
6565 }
6666 Opcode C.LLVMOpcode
67 AtomicRMWBinOp C.LLVMAtomicRMWBinOp
68 AtomicOrdering C.LLVMAtomicOrdering
6769 TypeKind C.LLVMTypeKind
6870 Linkage C.LLVMLinkage
6971 Visibility C.LLVMVisibility
189191 ShuffleVector Opcode = C.LLVMShuffleVector
190192 ExtractValue Opcode = C.LLVMExtractValue
191193 InsertValue Opcode = C.LLVMInsertValue
194 )
195
196 const (
197 AtomicRMWBinOpXchg AtomicRMWBinOp = C.LLVMAtomicRMWBinOpXchg
198 AtomicRMWBinOpAdd AtomicRMWBinOp = C.LLVMAtomicRMWBinOpAdd
199 AtomicRMWBinOpSub AtomicRMWBinOp = C.LLVMAtomicRMWBinOpSub
200 AtomicRMWBinOpAnd AtomicRMWBinOp = C.LLVMAtomicRMWBinOpAnd
201 AtomicRMWBinOpNand AtomicRMWBinOp = C.LLVMAtomicRMWBinOpNand
202 AtomicRMWBinOpOr AtomicRMWBinOp = C.LLVMAtomicRMWBinOpOr
203 AtomicRMWBinOpXor AtomicRMWBinOp = C.LLVMAtomicRMWBinOpXor
204 AtomicRMWBinOpMax AtomicRMWBinOp = C.LLVMAtomicRMWBinOpMax
205 AtomicRMWBinOpMin AtomicRMWBinOp = C.LLVMAtomicRMWBinOpMin
206 AtomicRMWBinOpUMax AtomicRMWBinOp = C.LLVMAtomicRMWBinOpUMax
207 AtomicRMWBinOpUMin AtomicRMWBinOp = C.LLVMAtomicRMWBinOpUMin
208 )
209
210 const (
211 AtomicOrderingNotAtomic AtomicOrdering = C.LLVMAtomicOrderingNotAtomic
212 AtomicOrderingUnordered AtomicOrdering = C.LLVMAtomicOrderingUnordered
213 AtomicOrderingMonotonic AtomicOrdering = C.LLVMAtomicOrderingMonotonic
214 AtomicOrderingAcquire AtomicOrdering = C.LLVMAtomicOrderingAcquire
215 AtomicOrderingRelease AtomicOrdering = C.LLVMAtomicOrderingRelease
216 AtomicOrderingAcquireRelease AtomicOrdering = C.LLVMAtomicOrderingAcquireRelease
217 AtomicOrderingSequentiallyConsistent AtomicOrdering = C.LLVMAtomicOrderingSequentiallyConsistent
192218 )
193219
194220 //-------------------------------------------------------------------------
10431069 func (v Value) SetGlobalConstant(gc bool) { C.LLVMSetGlobalConstant(v.C, boolToLLVMBool(gc)) }
10441070 func (v Value) IsVolatile() bool { return C.LLVMGetVolatile(v.C) != 0 }
10451071 func (v Value) SetVolatile(volatile bool) { C.LLVMSetVolatile(v.C, boolToLLVMBool(volatile)) }
1072 func (v Value) Ordering() AtomicOrdering { return AtomicOrdering(C.LLVMGetOrdering(v.C)) }
1073 func (v Value) SetOrdering(ordering AtomicOrdering) {
1074 C.LLVMSetOrdering(v.C, C.LLVMAtomicOrdering(ordering))
1075 }
1076 func (v Value) IsAtomicSingleThread() bool { return C.LLVMIsAtomicSingleThread(v.C) != 0 }
1077 func (v Value) SetAtomicSingleThread(singleThread bool) {
1078 C.LLVMSetAtomicSingleThread(v.C, boolToLLVMBool(singleThread))
1079 }
1080 func (v Value) CmpXchgSuccessOrdering() AtomicOrdering {
1081 return AtomicOrdering(C.LLVMGetCmpXchgSuccessOrdering(v.C))
1082 }
1083 func (v Value) SetCmpXchgSuccessOrdering(ordering AtomicOrdering) {
1084 C.LLVMSetCmpXchgSuccessOrdering(v.C, C.LLVMAtomicOrdering(ordering))
1085 }
1086 func (v Value) CmpXchgFailureOrdering() AtomicOrdering {
1087 return AtomicOrdering(C.LLVMGetCmpXchgFailureOrdering(v.C))
1088 }
1089 func (v Value) SetCmpXchgFailureOrdering(ordering AtomicOrdering) {
1090 C.LLVMSetCmpXchgFailureOrdering(v.C, C.LLVMAtomicOrdering(ordering))
1091 }
10461092
10471093 // Operations on aliases
10481094 func AddAlias(m Module, t Type, aliasee Value, name string) (v Value) {
16311677 v.C = C.LLVMBuildGlobalStringPtr(b.C, cstr, cname)
16321678 return
16331679 }
1680 func (b Builder) CreateAtomicRMW(op AtomicRMWBinOp, ptr, val Value, ordering AtomicOrdering, singleThread bool) (v Value) {
1681 v.C = C.LLVMBuildAtomicRMW(b.C, C.LLVMAtomicRMWBinOp(op), ptr.C, val.C, C.LLVMAtomicOrdering(ordering), boolToLLVMBool(singleThread))
1682 return
1683 }
1684 func (b Builder) CreateAtomicCmpXchg(ptr, cmp, newVal Value, successOrdering, failureOrdering AtomicOrdering, singleThread bool) (v Value) {
1685 v.C = C.LLVMBuildAtomicCmpXchg(b.C, ptr.C, cmp.C, newVal.C, C.LLVMAtomicOrdering(successOrdering), C.LLVMAtomicOrdering(failureOrdering), boolToLLVMBool(singleThread))
1686 return
1687 }
16341688
16351689 // Casts
16361690 func (b Builder) CreateTrunc(val Value, t Type, name string) (v Value) {