1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

Expose the fence instruction via the C API.

llvm-svn: 195173
This commit is contained in:
Filip Pizlo 2013-11-20 00:07:49 +00:00
parent 5054946d57
commit d0169a8474
3 changed files with 30 additions and 18 deletions

View File

@ -2663,7 +2663,9 @@ LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
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);

View File

@ -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,

View File

@ -2219,6 +2219,29 @@ LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val,
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(LLVMBuilderRef B,LLVMAtomicRMWBinOp op,
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));
}