[llvm-branch-commits] [llvm] [Draft][SPIRV] Lower load/store atomic to OpAtomicLoad/OpAtomicStore (PR #185696)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Mar 10 10:26:23 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index 3097a70cc..40ac75897 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -1664,8 +1664,8 @@ bool SPIRVInstructionSelector::selectLoad(Register ResVReg,
if (I.getNumMemOperands()) {
const MachineMemOperand *MemOp = *I.memoperands_begin();
if (MemOp->isAtomic()) {
- uint32_t Scope = static_cast<uint32_t>(getMemScope(
- Context, MemOp->getSyncScopeID()));
+ uint32_t Scope =
+ static_cast<uint32_t>(getMemScope(Context, MemOp->getSyncScopeID()));
Register ScopeReg = buildI32Constant(Scope, I);
AtomicOrdering AO = MemOp->getSuccessOrdering();
@@ -1673,11 +1673,11 @@ bool SPIRVInstructionSelector::selectLoad(Register ResVReg,
Register MemSemReg = buildI32Constant(MemSem, I);
auto Load = MIRBuilder.buildInstr(SPIRV::OpAtomicLoad)
- .addDef(ResVReg)
- .addUse(GR.getSPIRVTypeID(ResType))
- .addUse(Ptr)
- .addUse(ScopeReg)
- .addUse(MemSemReg);
+ .addDef(ResVReg)
+ .addUse(GR.getSPIRVTypeID(ResType))
+ .addUse(Ptr)
+ .addUse(ScopeReg)
+ .addUse(MemSemReg);
Load.constrainAllUses(TII, TRI, RBI);
return true;
}
@@ -1741,8 +1741,8 @@ bool SPIRVInstructionSelector::selectStore(MachineInstr &I) const {
if (I.getNumMemOperands()) {
const MachineMemOperand *MemOp = *I.memoperands_begin();
if (MemOp->isAtomic()) {
- uint32_t Scope = static_cast<uint32_t>(getMemScope(
- Context, MemOp->getSyncScopeID()));
+ uint32_t Scope =
+ static_cast<uint32_t>(getMemScope(Context, MemOp->getSyncScopeID()));
Register ScopeReg = buildI32Constant(Scope, I);
AtomicOrdering AO = MemOp->getSuccessOrdering();
@@ -1750,18 +1750,16 @@ bool SPIRVInstructionSelector::selectStore(MachineInstr &I) const {
Register MemSemReg = buildI32Constant(MemSem, I);
auto Store = MIRBuilder.buildInstr(SPIRV::OpAtomicStore)
- .addUse(Ptr)
- .addUse(ScopeReg)
- .addUse(MemSemReg)
- .addUse(StoreVal);
+ .addUse(Ptr)
+ .addUse(ScopeReg)
+ .addUse(MemSemReg)
+ .addUse(StoreVal);
Store.constrainAllUses(TII, TRI, RBI);
return true;
}
}
- auto MIB = MIRBuilder.buildInstr(SPIRV::OpStore)
- .addUse(Ptr)
- .addUse(StoreVal);
+ auto MIB = MIRBuilder.buildInstr(SPIRV::OpStore).addUse(Ptr).addUse(StoreVal);
if (!I.getNumMemOperands()) {
assert(I.getOpcode() == TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS ||
I.getOpcode() ==
``````````
</details>
https://github.com/llvm/llvm-project/pull/185696
More information about the llvm-branch-commits
mailing list