mirror of
https://github.com/RPCS3/llvm.git
synced 2025-03-03 08:07:51 +00:00
Now that we have getCalleeSaveRegClasses() info, use it to pass the register
class into the spill/reload methods. Targets can now rely on that argument. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23556 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2f9dbe8ee6
commit
80a4f169b4
@ -70,7 +70,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<unsigned> RegsToSave;
|
std::vector<std::pair<unsigned, const TargetRegisterClass*> > RegsToSave;
|
||||||
std::vector<int> StackSlots;
|
std::vector<int> StackSlots;
|
||||||
|
|
||||||
void calculateCallerSavedRegisters(MachineFunction &Fn);
|
void calculateCallerSavedRegisters(MachineFunction &Fn);
|
||||||
@ -136,15 +136,18 @@ void PEI::calculateCallerSavedRegisters(MachineFunction &Fn) {
|
|||||||
// function, thus needing to be saved and restored in the prolog/epilog.
|
// function, thus needing to be saved and restored in the prolog/epilog.
|
||||||
//
|
//
|
||||||
const bool *PhysRegsUsed = Fn.getUsedPhysregs();
|
const bool *PhysRegsUsed = Fn.getUsedPhysregs();
|
||||||
|
const TargetRegisterClass* const *CSRegClasses =
|
||||||
|
RegInfo->getCalleeSaveRegClasses();
|
||||||
for (unsigned i = 0; CSRegs[i]; ++i) {
|
for (unsigned i = 0; CSRegs[i]; ++i) {
|
||||||
unsigned Reg = CSRegs[i];
|
unsigned Reg = CSRegs[i];
|
||||||
if (PhysRegsUsed[Reg]) {
|
if (PhysRegsUsed[Reg]) {
|
||||||
RegsToSave.push_back(Reg); // If the reg is modified, save it!
|
// If the reg is modified, save it!
|
||||||
|
RegsToSave.push_back(std::make_pair(Reg, CSRegClasses[i]));
|
||||||
} else {
|
} else {
|
||||||
for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg);
|
for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg);
|
||||||
*AliasSet; ++AliasSet) { // Check alias registers too.
|
*AliasSet; ++AliasSet) { // Check alias registers too.
|
||||||
if (PhysRegsUsed[*AliasSet]) {
|
if (PhysRegsUsed[*AliasSet]) {
|
||||||
RegsToSave.push_back(Reg);
|
RegsToSave.push_back(std::make_pair(Reg, CSRegClasses[i]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +164,7 @@ void PEI::calculateCallerSavedRegisters(MachineFunction &Fn) {
|
|||||||
// 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.
|
||||||
for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) {
|
for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) {
|
||||||
unsigned Reg = RegsToSave[i];
|
unsigned Reg = RegsToSave[i].first;
|
||||||
|
|
||||||
// Check to see if this physreg must be spilled to a particular stack slot
|
// Check to see if this physreg must be spilled to a particular stack slot
|
||||||
// on this target.
|
// on this target.
|
||||||
@ -200,8 +203,8 @@ void PEI::saveCallerSavedRegisters(MachineFunction &Fn) {
|
|||||||
MachineBasicBlock::iterator I = MBB->begin();
|
MachineBasicBlock::iterator I = MBB->begin();
|
||||||
for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) {
|
for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) {
|
||||||
// Insert the spill to the stack frame.
|
// Insert the spill to the stack frame.
|
||||||
RegInfo->storeRegToStackSlot(*MBB, I, RegsToSave[i], StackSlots[i],
|
RegInfo->storeRegToStackSlot(*MBB, I, RegsToSave[i].first, StackSlots[i],
|
||||||
0 /*FIXME*/);
|
RegsToSave[i].second);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add code to restore the callee-save registers in each exiting block.
|
// Add code to restore the callee-save registers in each exiting block.
|
||||||
@ -226,8 +229,8 @@ void PEI::saveCallerSavedRegisters(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.
|
||||||
for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) {
|
for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) {
|
||||||
RegInfo->loadRegFromStackSlot(*MBB, I, RegsToSave[i], StackSlots[i],
|
RegInfo->loadRegFromStackSlot(*MBB, I, RegsToSave[i].first,
|
||||||
0 /*FIXME*/);
|
StackSlots[i], RegsToSave[i].second);
|
||||||
assert(I != MBB->begin() &&
|
assert(I != MBB->begin() &&
|
||||||
"loadRegFromStackSlot didn't insert any code!");
|
"loadRegFromStackSlot didn't insert any code!");
|
||||||
// Insert in reverse order. loadRegFromStackSlot can insert multiple
|
// Insert in reverse order. loadRegFromStackSlot can insert multiple
|
||||||
|
Loading…
x
Reference in New Issue
Block a user