@@ -2908,6 +2908,61 @@ LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op,
2908
2908
mapFromLLVMOrdering (ordering), singleThread ? SingleThread : CrossThread));
2909
2909
}
2910
2910
2911
+ LLVMValueRef LLVMBuildAtomicCmpXchg (LLVMBuilderRef B, LLVMValueRef Ptr ,
2912
+ LLVMValueRef Cmp, LLVMValueRef New,
2913
+ LLVMAtomicOrdering SuccessOrdering,
2914
+ LLVMAtomicOrdering FailureOrdering,
2915
+ LLVMBool singleThread) {
2916
+
2917
+ return wrap (unwrap (B)->CreateAtomicCmpXchg (unwrap (Ptr ), unwrap (Cmp),
2918
+ unwrap (New), mapFromLLVMOrdering (SuccessOrdering),
2919
+ mapFromLLVMOrdering (FailureOrdering),
2920
+ singleThread ? SingleThread : CrossThread));
2921
+ }
2922
+
2923
+
2924
+ LLVMBool LLVMIsAtomicSingleThread (LLVMValueRef AtomicInst) {
2925
+ Value *P = unwrap<Value>(AtomicInst);
2926
+
2927
+ if (AtomicRMWInst *I = dyn_cast<AtomicRMWInst>(P))
2928
+ return I->getSynchScope () == SingleThread;
2929
+ return cast<AtomicCmpXchgInst>(P)->getSynchScope () == SingleThread;
2930
+ }
2931
+
2932
+ void LLVMSetAtomicSingleThread (LLVMValueRef AtomicInst, LLVMBool NewValue) {
2933
+ Value *P = unwrap<Value>(AtomicInst);
2934
+ SynchronizationScope Sync = NewValue ? SingleThread : CrossThread;
2935
+
2936
+ if (AtomicRMWInst *I = dyn_cast<AtomicRMWInst>(P))
2937
+ return I->setSynchScope (Sync);
2938
+ return cast<AtomicCmpXchgInst>(P)->setSynchScope (Sync);
2939
+ }
2940
+
2941
+ LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering (LLVMValueRef CmpXchgInst) {
2942
+ Value *P = unwrap<Value>(CmpXchgInst);
2943
+ return mapToLLVMOrdering (cast<AtomicCmpXchgInst>(P)->getSuccessOrdering ());
2944
+ }
2945
+
2946
+ void LLVMSetCmpXchgSuccessOrdering (LLVMValueRef CmpXchgInst,
2947
+ LLVMAtomicOrdering Ordering) {
2948
+ Value *P = unwrap<Value>(CmpXchgInst);
2949
+ AtomicOrdering O = mapFromLLVMOrdering (Ordering);
2950
+
2951
+ return cast<AtomicCmpXchgInst>(P)->setSuccessOrdering (O);
2952
+ }
2953
+
2954
+ LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering (LLVMValueRef CmpXchgInst) {
2955
+ Value *P = unwrap<Value>(CmpXchgInst);
2956
+ return mapToLLVMOrdering (cast<AtomicCmpXchgInst>(P)->getFailureOrdering ());
2957
+ }
2958
+
2959
+ void LLVMSetCmpXchgFailureOrdering (LLVMValueRef CmpXchgInst,
2960
+ LLVMAtomicOrdering Ordering) {
2961
+ Value *P = unwrap<Value>(CmpXchgInst);
2962
+ AtomicOrdering O = mapFromLLVMOrdering (Ordering);
2963
+
2964
+ return cast<AtomicCmpXchgInst>(P)->setFailureOrdering (O);
2965
+ }
2911
2966
2912
2967
/* ===-- Module providers --------------------------------------------------===*/
2913
2968
0 commit comments