[PATCH] D156393: [RISCV] Fix getMaxPushPopReg like getLibCallID
Jim Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 26 22:30:54 PDT 2023
Jim created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
Jim requested review of this revision.
Herald added subscribers: llvm-commits, wangpc, eopXD, MaskRay.
Herald added a project: LLVM.
Remove PGPR register class, if saved gpr is in ra, s0, ..., s11,
frame index would be assigned a negative number (-1 for ra, -2 for s0, ...)
by RISCVRegisterInfo::hasReservedSpillSlot like save/restore libcalls.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156393
Files:
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
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
@@ -165,15 +165,6 @@
def SR07 : GPRRegisterClass<(add (sequence "X%u", 8, 9),
(sequence "X%u", 18, 23))>;
-// Registers saveable by PUSH/POP instruction in Zcmp extension
-def PGPR : RegisterClass<"RISCV", [XLenVT], 32, (add
- (sequence "X%u", 8, 9),
- (sequence "X%u", 18, 27),
- X1
- )> {
- let RegInfos = XLenRI;
-}
-
// Floating point registers
let RegAltNameIndices = [ABIRegAltName] in {
def F0_H : RISCVReg16<0, "f0", ["ft0"]>, DwarfRegNum<[32]>;
Index: llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -132,7 +132,7 @@
}
// Frame indexes representing locations of CSRs which are given a fixed location
-// by save/restore libcalls.
+// by save/restore libcalls or Zcmp Push/Pop.
static const std::pair<unsigned, int> FixedCSRFIMap[] = {
{/*ra*/ RISCV::X1, -1},
{/*s0*/ RISCV::X8, -2},
Index: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -267,9 +267,10 @@
Register MaxPushPopReg = RISCV::NoRegister;
PushPopRegs = 0;
for (auto &CS : CSI) {
- Register Reg = CS.getReg();
- if (RISCV::PGPRRegClass.contains(Reg)) {
- MaxPushPopReg = std::max(MaxPushPopReg.id(), Reg.id());
+ // RISCVRegisterInfo::hasReservedSpillSlot assigns negative frame indexes to
+ // registers which can be saved by Push.
+ if (CS.getFrameIdx() < 0) {
+ MaxPushPopReg = std::max(MaxPushPopReg.id(), CS.getReg().id());
PushPopRegs += 1;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156393.544607.patch
Type: text/x-patch
Size: 1981 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230727/33cf96c3/attachment.bin>
More information about the llvm-commits
mailing list