llvm.org GIT mirror llvm / d93969c
Add an OtherPreserved field to the CalleeSaved TableGen class. This field specifies registers that are preserved across function calls, but that should not be included in the generates SaveList array. This can be used ot generate regmasks for architectures that save registers through other means, like SPARC's register windows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189084 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 6 years ago
5 changed file(s) with 32 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
142142 /// returning from getCallPreservedMask().
143143 class CalleeSavedRegs {
144144 dag SaveList = saves;
145
146 // Registers that are also preserved across function calls, but should not be
147 // included in the generated FOO_SaveList array. These registers will be
148 // included in the FOO_RegMask bit mask. This can be used for registers that
149 // are saved automatically, like the SPARC register windows.
150 dag OtherPreserved;
145151 }
116116 // arguments whether they are passed in registers or not.
117117 CCCustom<"CC_Sparc64_Full">
118118 ]>;
119
120 // Callee-saved registers are handled by the register window mechanism.
121 def CSR : CalleeSavedRegs<(add)> {
122 let OtherPreserved = (add (sequence "I%u", 0, 7),
123 (sequence "L%u", 0, 7));
124 }
3939
4040 const uint16_t* SparcRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF)
4141 const {
42 static const uint16_t CalleeSavedRegs[] = { 0 };
43 return CalleeSavedRegs;
42 return CSR_SaveList;
43 }
44
45 const uint32_t*
46 SparcRegisterInfo::getCallPreservedMask(CallingConv::ID CC) const {
47 return CSR_RegMask;
4448 }
4549
4650 BitVector SparcRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
3131
3232 /// Code Generation virtual methods...
3333 const uint16_t *getCalleeSavedRegs(const MachineFunction *MF = 0) const;
34 const uint32_t* getCallPreservedMask(CallingConv::ID CC) const;
3435
3536 BitVector getReservedRegs(const MachineFunction &MF) const;
3637
13131313 OS << "0 };\n";
13141314
13151315 // Emit the *_RegMask bit mask of call-preserved registers.
1316 BitVector Covered = RegBank.computeCoveredRegisters(*Regs);
1317
1318 // Check for an optional OtherPreserved set.
1319 // Add those registers to RegMask, but not to SaveList.
1320 if (DagInit *OPDag =
1321 dyn_cast(CSRSet->getValueInit("OtherPreserved"))) {
1322 SetTheory::RecSet OPSet;
1323 RegBank.getSets().evaluate(OPDag, OPSet, CSRSet->getLoc());
1324 Covered |= RegBank.computeCoveredRegisters(
1325 ArrayRef(OPSet.begin(), OPSet.end()));
1326 }
1327
13161328 OS << "static const uint32_t " << CSRSet->getName()
13171329 << "_RegMask[] = { ";
1318 printBitVectorAsHex(OS, RegBank.computeCoveredRegisters(*Regs), 32);
1330 printBitVectorAsHex(OS, Covered, 32);
13191331 OS << "};\n";
13201332 }
13211333 OS << "\n\n";