llvm.org GIT mirror llvm / b216751
[RISCV][NFC] Rename callee saved regs 'CSR' to CSR_ILP32_LP64 and minor RISCVRegisterInfo refactoring The CSR renaming further prepares the way for an upcoming patch adding support for more RISC-V ABIs. Modify RISCVRegisterInfo::getCalleeSavedRegs and RISCVRegisterInfo::getReservedRegs to do MF->getSubtarget<RISCVSubtarget>() once rather than multiple times. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356123 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Bradbury 1 year, 8 months ago
2 changed file(s) with 10 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
1212 // The RISC-V calling convention is handled with custom code in
1313 // RISCVISelLowering.cpp (CC_RISCV).
1414
15 def CSR : CalleeSavedRegs<(add X1, X3, X4, X8, X9, (sequence "X%u", 18, 27))>;
15 def CSR_ILP32_LP64
16 : CalleeSavedRegs<(add X1, X3, X4, X8, X9, (sequence "X%u", 18, 27))>;
1617
1718 // Needed for implementation of RISCVRegisterInfo::getNoPreservedMask()
1819 def CSR_NoRegs : CalleeSavedRegs<(add)>;
3131
3232 const MCPhysReg *
3333 RISCVRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
34 auto &Subtarget = MF->getSubtarget();
3435 if (MF->getFunction().hasFnAttribute("interrupt")) {
35 if (MF->getSubtarget().hasStdExtD())
36 if (Subtarget.hasStdExtD())
3637 return CSR_XLEN_F64_Interrupt_SaveList;
37 if (MF->getSubtarget().hasStdExtF())
38 if (Subtarget..hasStdExtF())
3839 return CSR_XLEN_F32_Interrupt_SaveList;
3940 return CSR_Interrupt_SaveList;
4041 }
41 return CSR_SaveList;
42 return CSR_ILP32_LP64_SaveList;
4243 }
4344
4445 BitVector RISCVRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
117118 const uint32_t *
118119 RISCVRegisterInfo::getCallPreservedMask(const MachineFunction & MF,
119120 CallingConv::ID /*CC*/) const {
121 auto &Subtarget = MF->getSubtarget();
120122 if (MF.getFunction().hasFnAttribute("interrupt")) {
121 if (MF.getSubtarget().hasStdExtD())
123 if (Subtarget.hasStdExtD())
122124 return CSR_XLEN_F64_Interrupt_RegMask;
123 if (MF.getSubtarget().hasStdExtF())
125 if (Subtarget.hasStdExtF())
124126 return CSR_XLEN_F32_Interrupt_RegMask;
125127 return CSR_Interrupt_RegMask;
126128 }
127 return CSR_RegMask;
129 return CSR_ILP32_LP64_RegMask;
128130 }