[llvm] 6082a50 - [RISCV] Mark all registers marked isConstant as reserved (#96002)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 23 15:44:44 PDT 2024
Author: Francis Visoiu Mistrih
Date: 2024-06-23T15:44:41-07:00
New Revision: 6082a50a9835907f5f90f1967e21dcd7f5ab30f1
URL: https://github.com/llvm/llvm-project/commit/6082a50a9835907f5f90f1967e21dcd7f5ab30f1
DIFF: https://github.com/llvm/llvm-project/commit/6082a50a9835907f5f90f1967e21dcd7f5ab30f1.diff
LOG: [RISCV] Mark all registers marked isConstant as reserved (#96002)
This makes use of the information from TableGen instead of duplicating
it in the code.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
index caa5dbc15f8bd..760d12103c36d 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -104,14 +104,17 @@ BitVector RISCVRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
BitVector Reserved(getNumRegs());
auto &Subtarget = MF.getSubtarget<RISCVSubtarget>();
- // Mark any registers requested to be reserved as such
for (size_t Reg = 0; Reg < getNumRegs(); Reg++) {
+ // Mark any GPRs requested to be reserved as such
if (Subtarget.isRegisterReservedByUser(Reg))
markSuperRegs(Reserved, Reg);
+
+ // Mark all the registers defined as constant in TableGen as reserved.
+ if (isConstantPhysReg(Reg))
+ markSuperRegs(Reserved, Reg);
}
// Use markSuperRegs to ensure any register aliases are also reserved
- markSuperRegs(Reserved, RISCV::X0); // zero
markSuperRegs(Reserved, RISCV::X2); // sp
markSuperRegs(Reserved, RISCV::X3); // gp
markSuperRegs(Reserved, RISCV::X4); // tp
@@ -136,7 +139,6 @@ BitVector RISCVRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
markSuperRegs(Reserved, RISCV::VTYPE);
markSuperRegs(Reserved, RISCV::VXSAT);
markSuperRegs(Reserved, RISCV::VXRM);
- markSuperRegs(Reserved, RISCV::VLENB); // vlenb (constant)
// Floating point environment registers.
markSuperRegs(Reserved, RISCV::FRM);
More information about the llvm-commits
mailing list