[llvm] r195173 - Expose the fence instruction via the C API.
Filip Pizlo
fpizlo at apple.com
Tue Nov 19 16:07:49 PST 2013
Author: fpizlo
Date: Tue Nov 19 18:07:49 2013
New Revision: 195173
URL: http://llvm.org/viewvc/llvm-project?rev=195173&view=rev
Log:
Expose the fence instruction via the C API.
Modified:
llvm/trunk/include/llvm-c/Core.h
llvm/trunk/include/llvm/IR/IRBuilder.h
llvm/trunk/lib/IR/Core.cpp
Modified: llvm/trunk/include/llvm-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=195173&r1=195172&r2=195173&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Tue Nov 19 18:07:49 2013
@@ -2663,7 +2663,9 @@ LLVMValueRef LLVMBuildIsNotNull(LLVMBuil
const char *Name);
LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
LLVMValueRef RHS, const char *Name);
-LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op,
+LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
+ LLVMBool singleThread, const char *Name);
+LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
LLVMValueRef PTR, LLVMValueRef Val,
LLVMAtomicOrdering ordering,
LLVMBool singleThread);
Modified: llvm/trunk/include/llvm/IR/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IRBuilder.h?rev=195173&r1=195172&r2=195173&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/IRBuilder.h Tue Nov 19 18:07:49 2013
@@ -915,8 +915,9 @@ public:
return SI;
}
FenceInst *CreateFence(AtomicOrdering Ordering,
- SynchronizationScope SynchScope = CrossThread) {
- return Insert(new FenceInst(Context, Ordering, SynchScope));
+ SynchronizationScope SynchScope = CrossThread,
+ const Twine &Name = "") {
+ return Insert(new FenceInst(Context, Ordering, SynchScope), Name);
}
AtomicCmpXchgInst *CreateAtomicCmpXchg(Value *Ptr, Value *Cmp, Value *New,
AtomicOrdering Ordering,
Modified: llvm/trunk/lib/IR/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=195173&r1=195172&r2=195173&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Core.cpp (original)
+++ llvm/trunk/lib/IR/Core.cpp Tue Nov 19 18:07:49 2013
@@ -2219,6 +2219,29 @@ LLVMValueRef LLVMBuildStore(LLVMBuilderR
return wrap(unwrap(B)->CreateStore(unwrap(Val), unwrap(PointerVal)));
}
+static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
+ switch (Ordering) {
+ case LLVMAtomicOrderingNotAtomic: return NotAtomic;
+ case LLVMAtomicOrderingUnordered: return Unordered;
+ case LLVMAtomicOrderingMonotonic: return Monotonic;
+ case LLVMAtomicOrderingAcquire: return Acquire;
+ case LLVMAtomicOrderingRelease: return Release;
+ case LLVMAtomicOrderingAcquireRelease: return AcquireRelease;
+ case LLVMAtomicOrderingSequentiallyConsistent:
+ return SequentiallyConsistent;
+ }
+
+ llvm_unreachable("Invalid LLVMAtomicOrdering value!");
+}
+
+LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering Ordering,
+ LLVMBool isSingleThread, const char *Name) {
+ return wrap(
+ unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering),
+ isSingleThread ? SingleThread : CrossThread,
+ Name));
+}
+
LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
LLVMValueRef *Indices, unsigned NumIndices,
const char *Name) {
@@ -2476,22 +2499,8 @@ LLVMValueRef LLVMBuildAtomicRMW(LLVMBuil
case LLVMAtomicRMWBinOpUMax: intop = AtomicRMWInst::UMax; break;
case LLVMAtomicRMWBinOpUMin: intop = AtomicRMWInst::UMin; break;
}
- AtomicOrdering intordering;
- switch (ordering) {
- case LLVMAtomicOrderingNotAtomic: intordering = NotAtomic; break;
- case LLVMAtomicOrderingUnordered: intordering = Unordered; break;
- case LLVMAtomicOrderingMonotonic: intordering = Monotonic; break;
- case LLVMAtomicOrderingAcquire: intordering = Acquire; break;
- case LLVMAtomicOrderingRelease: intordering = Release; break;
- case LLVMAtomicOrderingAcquireRelease:
- intordering = AcquireRelease;
- break;
- case LLVMAtomicOrderingSequentiallyConsistent:
- intordering = SequentiallyConsistent;
- break;
- }
return wrap(unwrap(B)->CreateAtomicRMW(intop, unwrap(PTR), unwrap(Val),
- intordering, singleThread ? SingleThread : CrossThread));
+ mapFromLLVMOrdering(ordering), singleThread ? SingleThread : CrossThread));
}
More information about the llvm-commits
mailing list