aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_misc.cpp')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_misc.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index f307c26d4f7..79d10293e80 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -804,3 +804,33 @@ lp_is_function(LLVMValueRef v)
return llvm::isa<llvm::Function>(llvm::unwrap(v));
#endif
}
+
+#if HAVE_LLVM < 0x309
+static llvm::AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
+ switch (Ordering) {
+ case LLVMAtomicOrderingNotAtomic: return llvm::AtomicOrdering::NotAtomic;
+ case LLVMAtomicOrderingUnordered: return llvm::AtomicOrdering::Unordered;
+ case LLVMAtomicOrderingMonotonic: return llvm::AtomicOrdering::Monotonic;
+ case LLVMAtomicOrderingAcquire: return llvm::AtomicOrdering::Acquire;
+ case LLVMAtomicOrderingRelease: return llvm::AtomicOrdering::Release;
+ case LLVMAtomicOrderingAcquireRelease:
+ return llvm::AtomicOrdering::AcquireRelease;
+ case LLVMAtomicOrderingSequentiallyConsistent:
+ return llvm::AtomicOrdering::SequentiallyConsistent;
+ }
+
+ llvm_unreachable("Invalid LLVMAtomicOrdering value!");
+}
+
+LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
+ LLVMValueRef Cmp, LLVMValueRef New,
+ LLVMAtomicOrdering SuccessOrdering,
+ LLVMAtomicOrdering FailureOrdering,
+ LLVMBool SingleThread)
+{
+ /* LLVM 3.8 doesn't have a second ordering and uses old SynchronizationScope enum */
+ return llvm::wrap(llvm::unwrap(B)->CreateAtomicCmpXchg(llvm::unwrap(Ptr), llvm::unwrap(Cmp),
+ llvm::unwrap(New), mapFromLLVMOrdering(SuccessOrdering),
+ SingleThread ? llvm::SynchronizationScope::SingleThread : llvm::SynchronizationScope::CrossThread));
+}
+#endif