[PATCH] D153974: [RISCV] Don't include X1 in the X0_PD register pair
Alex Bradbury via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 07:21:12 PDT 2023
asb updated this revision to Diff 542013.
asb edited the summary of this revision.
asb added a comment.
Updated to incorporate suggested fixes from @craig.topper that means unwanted codegen changes are avoided.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153974/new/
https://reviews.llvm.org/D153974
Files:
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
llvm/lib/Target/RISCV/RISCVRegisterInfo.td
Index: llvm/lib/Target/RISCV/RISCVRegisterInfo.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -535,8 +535,23 @@
def GPRF32 : RegisterClass<"RISCV", [f32], 32, (add GPR)>;
} // RegInfos = XLenRI
+// Dummy zero register for use in the register pair containing X0 (as X1 is
+// not read to or written when the X0 register pair is used).
+def DUMMY_REG_PAIR_WITH_X0 : RISCVReg<0, "0">;
+
+// Must add DUMMY_REG_PAIR_WITH_X0 to a separate register class to prevent the
+// register's existence from changing codegen (due to the regPressureSetLimit
+// for the GPR register class being altered).
+def GPRAll : GPRRegisterClass<(add GPR, DUMMY_REG_PAIR_WITH_X0)>;
+
let RegAltNameIndices = [ABIRegAltName] in {
- foreach I = 0-15 in {
+ def X0_PD : RISCVRegWithSubRegs<0, X0.AsmName,
+ [X0, DUMMY_REG_PAIR_WITH_X0],
+ X0.AltNames> {
+ let SubRegIndices = [sub_32, sub_32_hi];
+ let CoveredBySubRegs = 1;
+ }
+ foreach I = 1-15 in {
defvar Index = !shl(I, 1);
defvar Reg = !cast<Register>("X"#Index);
defvar RegP1 = !cast<Register>("X"#!add(Index,1));
Index: llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -103,6 +103,10 @@
if (TFI->hasBP(MF))
markSuperRegs(Reserved, RISCVABI::getBPReg()); // bp
+ // Additionally reserve dummy register used to form the register pair
+ // beginning with 'x0' for instructions that take register pairs.
+ markSuperRegs(Reserved, RISCV::DUMMY_REG_PAIR_WITH_X0);
+
// V registers for code generation. We handle them manually.
markSuperRegs(Reserved, RISCV::VL);
markSuperRegs(Reserved, RISCV::VTYPE);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153974.542013.patch
Type: text/x-patch
Size: 1935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230719/619df63b/attachment.bin>
More information about the llvm-commits
mailing list