Use interators instead of counters for loops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75046 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2009-07-08 20:57:27 +00:00
parent 3046470919
commit 058a024eb7

View File

@ -163,25 +163,27 @@ void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) {
FFI->setHasCalls(HasCalls); FFI->setHasCalls(HasCalls);
FFI->setMaxCallFrameSize(MaxCallFrameSize); FFI->setMaxCallFrameSize(MaxCallFrameSize);
for (unsigned i = 0, e = FrameSDOps.size(); i != e; ++i) { for (std::vector<MachineBasicBlock::iterator>::iterator
MachineBasicBlock::iterator I = FrameSDOps[i]; i = FrameSDOps.begin(), e = FrameSDOps.end(); i != e; ++i) {
// If call frames are not being included as part of the stack frame, MachineBasicBlock::iterator I = *i;
// and there is no dynamic allocation (therefore referencing frame slots
// off sp), leave the pseudo ops alone. We'll eliminate them later. // If call frames are not being included as part of the stack frame, and
// there is no dynamic allocation (therefore referencing frame slots off
// sp), leave the pseudo ops alone. We'll eliminate them later.
if (RegInfo->hasReservedCallFrame(Fn) || RegInfo->hasFP(Fn)) if (RegInfo->hasReservedCallFrame(Fn) || RegInfo->hasFP(Fn))
RegInfo->eliminateCallFramePseudoInstr(Fn, *I->getParent(), I); RegInfo->eliminateCallFramePseudoInstr(Fn, *I->getParent(), I);
} }
// Now figure out which *callee saved* registers are modified by the current // Now figure out which *callee saved* registers are modified by the current
// 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 TargetRegisterClass * const *CSRegClasses =
const TargetRegisterClass* const *CSRegClasses =
RegInfo->getCalleeSavedRegClasses(&Fn); RegInfo->getCalleeSavedRegClasses(&Fn);
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];
if (Fn.getRegInfo().isPhysRegUsed(Reg)) { if (Fn.getRegInfo().isPhysRegUsed(Reg)) {
// If the reg is modified, save it! // If the reg is modified, save it!
CSI.push_back(CalleeSavedInfo(Reg, CSRegClasses[i])); CSI.push_back(CalleeSavedInfo(Reg, CSRegClasses[i]));
} else { } else {
for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg); for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg);
@ -203,9 +205,10 @@ void PEI::calculateCalleeSavedRegisters(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 = CSI.size(); i != e; ++i) { for (std::vector<CalleeSavedInfo>::iterator
unsigned Reg = CSI[i].getReg(); I = CSI.begin(), E = CSI.end(); I != E; ++I) {
const TargetRegisterClass *RC = CSI[i].getRegClass(); unsigned Reg = I->getReg();
const TargetRegisterClass *RC = I->getRegClass();
// 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.
@ -215,13 +218,14 @@ void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) {
++FixedSlot; ++FixedSlot;
int FrameIdx; int FrameIdx;
if (FixedSlot == FixedSpillSlots+NumFixedSpillSlots) { if (FixedSlot == FixedSpillSlots + NumFixedSpillSlots) {
// Nope, just spill it anywhere convenient. // Nope, just spill it anywhere convenient.
unsigned Align = RC->getAlignment(); unsigned Align = RC->getAlignment();
unsigned StackAlign = TFI->getStackAlignment(); unsigned StackAlign = TFI->getStackAlignment();
// We may not be able to sastify the desired alignment specification of
// the TargetRegisterClass if the stack alignment is smaller. // We may not be able to satisfy the desired alignment specification of
// Use the min. // the TargetRegisterClass if the stack alignment is smaller. Use the
// min.
Align = std::min(Align, StackAlign); Align = std::min(Align, StackAlign);
FrameIdx = FFI->CreateStackObject(RC->getSize(), Align); FrameIdx = FFI->CreateStackObject(RC->getSize(), Align);
if ((unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx; if ((unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx;
@ -230,7 +234,8 @@ void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) {
// Spill it to the stack where we must. // Spill it to the stack where we must.
FrameIdx = FFI->CreateFixedObject(RC->getSize(), FixedSlot->second); FrameIdx = FFI->CreateFixedObject(RC->getSize(), FixedSlot->second);
} }
CSI[i].setFrameIdx(FrameIdx);
I->setFrameIdx(FrameIdx);
} }
FFI->setCalleeSavedInfo(CSI); FFI->setCalleeSavedInfo(CSI);