[llvm] [LLVM] Add a C API for creating instructions with custom syncscopes. (PR #104775)
Tim Besard via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 08:00:39 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(),
----------------
maleadt wrote:
Hmm, it seems weird to me to have a minor variant of an API taking different arguments like that. It'd be kinda awkward to wrap in LLVM.jl, where we support multiple versions of LLVM. Wouldn't it be better to keep the APIs similar and defer to `LLVMSetAlignment` for setting alignment?
https://github.com/llvm/llvm-project/pull/104775
More information about the llvm-commits
mailing list