+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!");
+}
+
+static LLVMAtomicOrdering mapToLLVMOrdering(AtomicOrdering Ordering) {
+ switch (Ordering) {
+ case NotAtomic: return LLVMAtomicOrderingNotAtomic;
+ case Unordered: return LLVMAtomicOrderingUnordered;
+ case Monotonic: return LLVMAtomicOrderingMonotonic;
+ case Acquire: return LLVMAtomicOrderingAcquire;
+ case Release: return LLVMAtomicOrderingRelease;
+ case AcquireRelease: return LLVMAtomicOrderingAcquireRelease;
+ case SequentiallyConsistent:
+ return LLVMAtomicOrderingSequentiallyConsistent;
+ }
+
+ llvm_unreachable("Invalid AtomicOrdering value!");
+}
+
+LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering Ordering,
+ LLVMBool isSingleThread, const char *Name) {
+ return wrap(
+ unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering),
+ isSingleThread ? SingleThread : CrossThread,
+ Name));
+}
+