forked from OSchip/llvm-project
- Fixing naming inconsistency: calleesave -> calleesaved.
- Make use of spillCalleeSavedRegisters() and restoreCalleeSavedRegisters(). llvm-svn: 32822
This commit is contained in:
parent
07140c22c7
commit
92484c2aa4
|
@ -46,7 +46,8 @@ namespace {
|
||||||
|
|
||||||
// Allow the target machine to make some adjustments to the function
|
// Allow the target machine to make some adjustments to the function
|
||||||
// e.g. UsedPhysRegs before calculateCalleeSavedRegisters.
|
// e.g. UsedPhysRegs before calculateCalleeSavedRegisters.
|
||||||
Fn.getTarget().getRegisterInfo()->processFunctionBeforeCalleeSaveScan(Fn);
|
Fn.getTarget().getRegisterInfo()
|
||||||
|
->processFunctionBeforeCalleeSavedScan(Fn);
|
||||||
|
|
||||||
// Scan the function for modified callee saved registers and insert spill
|
// Scan the function for modified callee saved registers and insert spill
|
||||||
// code for any callee saved registers that are modified. Also calculate
|
// code for any callee saved registers that are modified. Also calculate
|
||||||
|
@ -80,7 +81,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// MinCSFrameIndex, MaxCSFrameIndex - Keeps the range of callee save
|
// MinCSFrameIndex, MaxCSFrameIndex - Keeps the range of callee saved
|
||||||
// stack frame indexes.
|
// stack frame indexes.
|
||||||
unsigned MinCSFrameIndex, MaxCSFrameIndex;
|
unsigned MinCSFrameIndex, MaxCSFrameIndex;
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) {
|
||||||
const TargetFrameInfo *TFI = Fn.getTarget().getFrameInfo();
|
const TargetFrameInfo *TFI = Fn.getTarget().getFrameInfo();
|
||||||
|
|
||||||
// Get the callee saved register list...
|
// Get the callee saved register list...
|
||||||
const unsigned *CSRegs = RegInfo->getCalleeSaveRegs();
|
const unsigned *CSRegs = RegInfo->getCalleeSavedRegs();
|
||||||
|
|
||||||
// Get the function call frame set-up and tear-down instruction opcode
|
// Get the function call frame set-up and tear-down instruction opcode
|
||||||
int FrameSetupOpcode = RegInfo->getCallFrameSetupOpcode();
|
int FrameSetupOpcode = RegInfo->getCallFrameSetupOpcode();
|
||||||
|
@ -151,7 +152,7 @@ void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) {
|
||||||
//
|
//
|
||||||
const bool *PhysRegsUsed = Fn.getUsedPhysregs();
|
const bool *PhysRegsUsed = Fn.getUsedPhysregs();
|
||||||
const TargetRegisterClass* const *CSRegClasses =
|
const TargetRegisterClass* const *CSRegClasses =
|
||||||
RegInfo->getCalleeSaveRegClasses();
|
RegInfo->getCalleeSavedRegClasses();
|
||||||
std::vector<CalleeSavedInfo> CSI;
|
std::vector<CalleeSavedInfo> CSI;
|
||||||
for (unsigned i = 0; CSRegs[i]; ++i) {
|
for (unsigned i = 0; CSRegs[i]; ++i) {
|
||||||
unsigned Reg = CSRegs[i];
|
unsigned Reg = CSRegs[i];
|
||||||
|
@ -174,7 +175,7 @@ void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) {
|
||||||
|
|
||||||
unsigned NumFixedSpillSlots;
|
unsigned NumFixedSpillSlots;
|
||||||
const std::pair<unsigned,int> *FixedSpillSlots =
|
const std::pair<unsigned,int> *FixedSpillSlots =
|
||||||
TFI->getCalleeSaveSpillSlots(NumFixedSpillSlots);
|
TFI->getCalleeSavedSpillSlots(NumFixedSpillSlots);
|
||||||
|
|
||||||
// Now that we know which registers need to be saved and restored, allocate
|
// Now that we know which registers need to be saved and restored, allocate
|
||||||
// stack slots for them.
|
// stack slots for them.
|
||||||
|
@ -228,11 +229,14 @@ void PEI::saveCalleeSavedRegisters(MachineFunction &Fn) {
|
||||||
// code into the entry block.
|
// code into the entry block.
|
||||||
MachineBasicBlock *MBB = Fn.begin();
|
MachineBasicBlock *MBB = Fn.begin();
|
||||||
MachineBasicBlock::iterator I = MBB->begin();
|
MachineBasicBlock::iterator I = MBB->begin();
|
||||||
|
if (!RegInfo->spillCalleeSavedRegisters(*MBB, I, CSI)) {
|
||||||
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
|
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
|
||||||
// Insert the spill to the stack frame.
|
// Insert the spill to the stack frame.
|
||||||
RegInfo->storeRegToStackSlot(*MBB, I, CSI[i].getReg(), CSI[i].getFrameIdx(),
|
RegInfo->storeRegToStackSlot(*MBB, I, CSI[i].getReg(),
|
||||||
|
CSI[i].getFrameIdx(),
|
||||||
CSI[i].getRegClass());
|
CSI[i].getRegClass());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add code to restore the callee-save registers in each exiting block.
|
// Add code to restore the callee-save registers in each exiting block.
|
||||||
const TargetInstrInfo &TII = *Fn.getTarget().getInstrInfo();
|
const TargetInstrInfo &TII = *Fn.getTarget().getInstrInfo();
|
||||||
|
@ -255,6 +259,7 @@ void PEI::saveCalleeSavedRegisters(MachineFunction &Fn) {
|
||||||
|
|
||||||
// Restore all registers immediately before the return and any terminators
|
// Restore all registers immediately before the return and any terminators
|
||||||
// that preceed it.
|
// that preceed it.
|
||||||
|
if (!RegInfo->restoreCalleeSavedRegisters(*MBB, I, CSI)) {
|
||||||
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
|
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
|
||||||
RegInfo->loadRegFromStackSlot(*MBB, I, CSI[i].getReg(),
|
RegInfo->loadRegFromStackSlot(*MBB, I, CSI[i].getReg(),
|
||||||
CSI[i].getFrameIdx(),
|
CSI[i].getFrameIdx(),
|
||||||
|
@ -272,6 +277,7 @@ void PEI::saveCalleeSavedRegisters(MachineFunction &Fn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// calculateFrameObjectOffsets - Calculate actual frame offsets for all of the
|
/// calculateFrameObjectOffsets - Calculate actual frame offsets for all of the
|
||||||
|
@ -319,7 +325,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// First assign frame offsets to stack objects that are used to spill
|
// First assign frame offsets to stack objects that are used to spill
|
||||||
// callee save registers.
|
// callee saved registers.
|
||||||
if (StackGrowsDown) {
|
if (StackGrowsDown) {
|
||||||
for (unsigned i = 0, e = FFI->getObjectIndexEnd(); i != e; ++i) {
|
for (unsigned i = 0, e = FFI->getObjectIndexEnd(); i != e; ++i) {
|
||||||
if (i < MinCSFrameIndex || i > MaxCSFrameIndex)
|
if (i < MinCSFrameIndex || i > MaxCSFrameIndex)
|
||||||
|
@ -356,7 +362,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then assign frame offsets to stack objects that are not used to spill
|
// Then assign frame offsets to stack objects that are not used to spill
|
||||||
// callee save registers.
|
// callee saved registers.
|
||||||
for (unsigned i = 0, e = FFI->getObjectIndexEnd(); i != e; ++i) {
|
for (unsigned i = 0, e = FFI->getObjectIndexEnd(); i != e; ++i) {
|
||||||
if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
|
if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue