[llvm] [RISCV][GISel] Add manual isel for s8/s16/s32 load/store for the GPR bank. (PR #161995)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 4 21:50:59 PDT 2025
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/RISCV/GISel/RISCVInstructionSelector.cpp
``````````
: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/RISCV/GISel/RISCVInstructionSelector.cpp b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
index 89e7234d7..b702d4d9c 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
@@ -868,13 +868,11 @@ bool RISCVInstructionSelector::select(MachineInstr &MI) {
return false;
#ifndef NDEBUG
- const RegisterBank &PtrRB =
- *RBI.getRegBank(PtrReg, *MRI, TRI);
+ const RegisterBank &PtrRB = *RBI.getRegBank(PtrReg, *MRI, TRI);
// Check that the pointer register is valid.
assert(PtrRB.getID() == RISCV::GPRBRegBankID &&
"Load/Store pointer operand isn't a GPR");
- assert(PtrTy.isPointer() &&
- "Load/Store pointer operand isn't a pointer");
+ assert(PtrTy.isPointer() && "Load/Store pointer operand isn't a pointer");
#endif
// Can only handle AddressSpace 0.
@@ -886,13 +884,12 @@ bool RISCVInstructionSelector::select(MachineInstr &MI) {
if (isStrongerThanMonotonic(Order)) {
assert(MemSizeInBytes <= 8 && "Unexpected mem size!");
- static constexpr unsigned LoadOpcodes[] = {
- RISCV::LB_AQ, RISCV::LH_AQ, RISCV::LW_AQ, RISCV::LD_AQ
- };
- static constexpr unsigned StoreOpcodes[] = {
- RISCV::SB_RL, RISCV::SH_RL, RISCV::SW_RL, RISCV::SD_RL
- };
- ArrayRef<unsigned> Opcodes = isa<GLoad>(LdSt) ? LoadOpcodes : StoreOpcodes;
+ static constexpr unsigned LoadOpcodes[] = {RISCV::LB_AQ, RISCV::LH_AQ,
+ RISCV::LW_AQ, RISCV::LD_AQ};
+ static constexpr unsigned StoreOpcodes[] = {RISCV::SB_RL, RISCV::SH_RL,
+ RISCV::SW_RL, RISCV::SD_RL};
+ ArrayRef<unsigned> Opcodes =
+ isa<GLoad>(LdSt) ? LoadOpcodes : StoreOpcodes;
MI.setDesc(TII.get(Opcodes[Log2_32(MemSizeInBytes)]));
return constrainSelectedInstRegOperands(MI, TII, TRI, RBI);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/161995
More information about the llvm-commits
mailing list