[clang] [llvm] [SPARC] Support reserving arbitrary general purpose registers (PR #74927)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 13 22:25:44 PST 2024
================
@@ -98,9 +96,34 @@ BitVector SparcRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
for (unsigned n = 0; n < 31; n++)
Reserved.set(SP::ASR1 + n);
+ for (size_t i = 0; i < SP::IntRegsRegClass.getNumRegs() / 4; ++i) {
+ // Mark both single register and register pairs.
+ if (MF.getSubtarget<SparcSubtarget>().isGRegisterReserved(i)) {
+ Reserved.set(SP::G0 + i);
+ Reserved.set(SP::G0_G1 + i / 2);
+ }
+ if (MF.getSubtarget<SparcSubtarget>().isORegisterReserved(i)) {
+ Reserved.set(SP::O0 + i);
+ Reserved.set(SP::O0_O1 + i / 2);
+ }
+ if (MF.getSubtarget<SparcSubtarget>().isLRegisterReserved(i)) {
+ Reserved.set(SP::L0 + i);
+ Reserved.set(SP::L0_L1 + i / 2);
+ }
+ if (MF.getSubtarget<SparcSubtarget>().isIRegisterReserved(i)) {
+ Reserved.set(SP::I0 + i);
+ Reserved.set(SP::I0_I1 + i / 2);
+ }
+ }
+
return Reserved;
----------------
s-barannikov wrote:
Right, my mistake, I wrote from memory.
It should be asserted that it returns true, iirc.
Please see how other backends use it.
https://github.com/llvm/llvm-project/pull/74927
More information about the llvm-commits
mailing list