}
private:
- std::vector<unsigned> RegsToSave;
+ std::vector<std::pair<unsigned, const TargetRegisterClass*> > RegsToSave;
std::vector<int> StackSlots;
void calculateCallerSavedRegisters(MachineFunction &Fn);
// function, thus needing to be saved and restored in the prolog/epilog.
//
const bool *PhysRegsUsed = Fn.getUsedPhysregs();
+ const TargetRegisterClass* const *CSRegClasses =
+ RegInfo->getCalleeSaveRegClasses();
for (unsigned i = 0; CSRegs[i]; ++i) {
unsigned Reg = CSRegs[i];
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 {
for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg);
*AliasSet; ++AliasSet) { // Check alias registers too.
if (PhysRegsUsed[*AliasSet]) {
- RegsToSave.push_back(Reg);
+ RegsToSave.push_back(std::make_pair(Reg, CSRegClasses[i]));
break;
}
}
// Now that we know which registers need to be saved and restored, allocate
// stack slots for them.
for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) {
- unsigned Reg = RegsToSave[i];
+ unsigned Reg = RegsToSave[i].first;
+ const TargetRegisterClass *RC = RegsToSave[i].second;
// Check to see if this physreg must be spilled to a particular stack slot
// on this target.
int FrameIdx;
if (FixedSlot == FixedSpillSlots+NumFixedSpillSlots) {
// Nope, just spill it anywhere convenient.
- FrameIdx = FFI->CreateStackObject(RegInfo->getSpillSize(Reg)/8,
- RegInfo->getSpillAlignment(Reg)/8);
+ FrameIdx = FFI->CreateStackObject(RC->getSize(), RC->getAlignment());
} else {
// Spill it to the stack where we must.
- FrameIdx = FFI->CreateFixedObject(RegInfo->getSpillSize(Reg)/8,
- FixedSlot->second);
+ FrameIdx = FFI->CreateFixedObject(RC->getSize(), FixedSlot->second);
}
StackSlots.push_back(FrameIdx);
}
MachineBasicBlock::iterator I = MBB->begin();
for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) {
// Insert the spill to the stack frame.
- RegInfo->storeRegToStackSlot(*MBB, I, RegsToSave[i], StackSlots[i],
- 0 /*FIXME*/);
+ RegInfo->storeRegToStackSlot(*MBB, I, RegsToSave[i].first, StackSlots[i],
+ RegsToSave[i].second);
}
// Add code to restore the callee-save registers in each exiting block.
// Restore all registers immediately before the return and any terminators
// that preceed it.
for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) {
- RegInfo->loadRegFromStackSlot(*MBB, I, RegsToSave[i], StackSlots[i],
- 0 /*FIXME*/);
+ RegInfo->loadRegFromStackSlot(*MBB, I, RegsToSave[i].first,
+ StackSlots[i], RegsToSave[i].second);
assert(I != MBB->begin() &&
"loadRegFromStackSlot didn't insert any code!");
// Insert in reverse order. loadRegFromStackSlot can insert multiple