[llvm] [LLVM] Add a C API for creating instructions with custom syncscopes. (PR #104775)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 07:19:42 PDT 2024


================
@@ -4309,6 +4332,22 @@ LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op,
       singleThread ? SyncScope::SingleThread : SyncScope::System));
 }
 
+LLVMValueRef LLVMBuildAtomicRMWSyncScope(LLVMBuilderRef B,
+                                         LLVMAtomicRMWBinOp op,
+                                         LLVMValueRef PTR, LLVMValueRef Val,
+                                         LLVMAtomicOrdering ordering,
+                                         unsigned SSID) {
+  AtomicRMWInst::BinOp intop = mapFromLLVMRMWBinOp(op);
+
+  SmallVector<StringRef> SSNs;
+  unwrap(B)->getContext().getSyncScopeNames(SSNs);
+  assert(SSID < SSNs.size() && "Invalid SyncScopeID");
+
+  return wrap(unwrap(B)->CreateAtomicRMW(intop, unwrap(PTR), unwrap(Val),
+                                         MaybeAlign(),
----------------
nikic wrote:

Might as well not repeat past mistakes and also require an alignment argument for the new functions?

https://github.com/llvm/llvm-project/pull/104775


More information about the llvm-commits mailing list