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
extern bool
lp_is_function(LLVMValueRef v);
+/* LLVM 3.9 introduces this, provide our own for earlier */
+#if HAVE_LLVM < 0x309
+LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
+ LLVMValueRef Cmp, LLVMValueRef New,
+ LLVMAtomicOrdering SuccessOrdering,
+ LLVMAtomicOrdering FailureOrdering,
+ LLVMBool SingleThread);
+#endif
+
#ifdef __cplusplus
}
#endif