[llvm] [RISCV] Mark all registers marked isConstant as reserved (PR #96002)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 15:31:28 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Francis Visoiu Mistrih (francisvm)
<details>
<summary>Changes</summary>
This makes use of the information from TableGen instead of duplicating it in the code.
---
Full diff: https://github.com/llvm/llvm-project/pull/96002.diff
1 Files Affected:
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (+4-3)
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
index caa5dbc15f8bd..349433a29a36b 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -104,14 +104,16 @@ 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 registers 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 +138,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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/96002
More information about the llvm-commits
mailing list