forked from OSchip/llvm-project
[llvm] Use range-based for loops (NFC)
This commit is contained in:
parent
b72b56016a
commit
ea5421bd0d
|
@ -1172,8 +1172,8 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF,
|
|||
// Describe where callee saved registers were saved, at fixed offsets from
|
||||
// CFA.
|
||||
const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo();
|
||||
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
||||
unsigned Reg = CSI[I].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
if (Reg == PPC::LR || Reg == PPC::LR8 || Reg == PPC::RM) continue;
|
||||
|
||||
// This is a bit of a hack: CR2LT, CR2GT, CR2EQ and CR2UN are just
|
||||
|
@ -1204,15 +1204,15 @@ void PPCFrameLowering::emitPrologue(MachineFunction &MF,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (CSI[I].isSpilledToReg()) {
|
||||
unsigned SpilledReg = CSI[I].getDstReg();
|
||||
if (I.isSpilledToReg()) {
|
||||
unsigned SpilledReg = I.getDstReg();
|
||||
unsigned CFIRegister = MF.addFrameInst(MCCFIInstruction::createRegister(
|
||||
nullptr, MRI->getDwarfRegNum(Reg, true),
|
||||
MRI->getDwarfRegNum(SpilledReg, true)));
|
||||
BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
|
||||
.addCFIIndex(CFIRegister);
|
||||
} else {
|
||||
int64_t Offset = MFI.getObjectOffset(CSI[I].getFrameIdx());
|
||||
int64_t Offset = MFI.getObjectOffset(I.getFrameIdx());
|
||||
// We have changed the object offset above but we do not want to change
|
||||
// the actual offsets in the CFI instruction so we have to undo the
|
||||
// offset change here.
|
||||
|
@ -2085,15 +2085,15 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
|
|||
SmallVector<CalleeSavedInfo, 18> FPRegs;
|
||||
SmallVector<CalleeSavedInfo, 18> VRegs;
|
||||
|
||||
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
|
||||
unsigned Reg = CSI[i].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
assert((!MF.getInfo<PPCFunctionInfo>()->mustSaveTOC() ||
|
||||
(Reg != PPC::X2 && Reg != PPC::R2)) &&
|
||||
"Not expecting to try to spill R2 in a function that must save TOC");
|
||||
if (PPC::GPRCRegClass.contains(Reg)) {
|
||||
HasGPSaveArea = true;
|
||||
|
||||
GPRegs.push_back(CSI[i]);
|
||||
GPRegs.push_back(I);
|
||||
|
||||
if (Reg < MinGPR) {
|
||||
MinGPR = Reg;
|
||||
|
@ -2101,7 +2101,7 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
|
|||
} else if (PPC::G8RCRegClass.contains(Reg)) {
|
||||
HasG8SaveArea = true;
|
||||
|
||||
G8Regs.push_back(CSI[i]);
|
||||
G8Regs.push_back(I);
|
||||
|
||||
if (Reg < MinG8R) {
|
||||
MinG8R = Reg;
|
||||
|
@ -2109,7 +2109,7 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
|
|||
} else if (PPC::F8RCRegClass.contains(Reg)) {
|
||||
HasFPSaveArea = true;
|
||||
|
||||
FPRegs.push_back(CSI[i]);
|
||||
FPRegs.push_back(I);
|
||||
|
||||
if (Reg < MinFPR) {
|
||||
MinFPR = Reg;
|
||||
|
@ -2123,7 +2123,7 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
|
|||
// alignment requirements, so overload the save area for both cases.
|
||||
HasVRSaveArea = true;
|
||||
|
||||
VRegs.push_back(CSI[i]);
|
||||
VRegs.push_back(I);
|
||||
|
||||
if (Reg < MinVR) {
|
||||
MinVR = Reg;
|
||||
|
@ -2395,8 +2395,8 @@ bool PPCFrameLowering::spillCalleeSavedRegisters(
|
|||
}
|
||||
});
|
||||
|
||||
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
|
||||
unsigned Reg = CSI[i].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
|
||||
// CR2 through CR4 are the nonvolatile CR fields.
|
||||
bool IsCRField = PPC::CR2 <= Reg && Reg <= PPC::CR4;
|
||||
|
@ -2439,11 +2439,11 @@ bool PPCFrameLowering::spillCalleeSavedRegisters(
|
|||
MBB.insert(MI, addFrameReference(BuildMI(*MF, DL, TII.get(PPC::STW))
|
||||
.addReg(PPC::R12,
|
||||
getKillRegState(true)),
|
||||
CSI[i].getFrameIdx()));
|
||||
I.getFrameIdx()));
|
||||
}
|
||||
} else {
|
||||
if (CSI[i].isSpilledToReg()) {
|
||||
unsigned Dst = CSI[i].getDstReg();
|
||||
if (I.isSpilledToReg()) {
|
||||
unsigned Dst = I.getDstReg();
|
||||
|
||||
if (Spilled[Dst])
|
||||
continue;
|
||||
|
@ -2478,9 +2478,9 @@ bool PPCFrameLowering::spillCalleeSavedRegisters(
|
|||
if (Subtarget.needsSwapsForVSXMemOps() &&
|
||||
!MF->getFunction().hasFnAttribute(Attribute::NoUnwind))
|
||||
TII.storeRegToStackSlotNoUpd(MBB, MI, Reg, !IsLiveIn,
|
||||
CSI[i].getFrameIdx(), RC, TRI);
|
||||
I.getFrameIdx(), RC, TRI);
|
||||
else
|
||||
TII.storeRegToStackSlot(MBB, MI, Reg, !IsLiveIn, CSI[i].getFrameIdx(),
|
||||
TII.storeRegToStackSlot(MBB, MI, Reg, !IsLiveIn, I.getFrameIdx(),
|
||||
RC, TRI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,8 +270,8 @@ bool SystemZELFFrameLowering::spillCalleeSavedRegisters(
|
|||
|
||||
// Make sure all call-saved GPRs are included as operands and are
|
||||
// marked as live on entry.
|
||||
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
||||
unsigned Reg = CSI[I].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
if (SystemZ::GR64BitRegClass.contains(Reg))
|
||||
addSavedGPR(MBB, MIB, Reg, true);
|
||||
}
|
||||
|
@ -283,16 +283,16 @@ bool SystemZELFFrameLowering::spillCalleeSavedRegisters(
|
|||
}
|
||||
|
||||
// Save FPRs/VRs in the normal TargetInstrInfo way.
|
||||
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
||||
unsigned Reg = CSI[I].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
if (SystemZ::FP64BitRegClass.contains(Reg)) {
|
||||
MBB.addLiveIn(Reg);
|
||||
TII->storeRegToStackSlot(MBB, MBBI, Reg, true, CSI[I].getFrameIdx(),
|
||||
TII->storeRegToStackSlot(MBB, MBBI, Reg, true, I.getFrameIdx(),
|
||||
&SystemZ::FP64BitRegClass, TRI);
|
||||
}
|
||||
if (SystemZ::VR128BitRegClass.contains(Reg)) {
|
||||
MBB.addLiveIn(Reg);
|
||||
TII->storeRegToStackSlot(MBB, MBBI, Reg, true, CSI[I].getFrameIdx(),
|
||||
TII->storeRegToStackSlot(MBB, MBBI, Reg, true, I.getFrameIdx(),
|
||||
&SystemZ::VR128BitRegClass, TRI);
|
||||
}
|
||||
}
|
||||
|
@ -313,13 +313,13 @@ bool SystemZELFFrameLowering::restoreCalleeSavedRegisters(
|
|||
DebugLoc DL = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
|
||||
|
||||
// Restore FPRs/VRs in the normal TargetInstrInfo way.
|
||||
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
||||
unsigned Reg = CSI[I].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
if (SystemZ::FP64BitRegClass.contains(Reg))
|
||||
TII->loadRegFromStackSlot(MBB, MBBI, Reg, CSI[I].getFrameIdx(),
|
||||
TII->loadRegFromStackSlot(MBB, MBBI, Reg, I.getFrameIdx(),
|
||||
&SystemZ::FP64BitRegClass, TRI);
|
||||
if (SystemZ::VR128BitRegClass.contains(Reg))
|
||||
TII->loadRegFromStackSlot(MBB, MBBI, Reg, CSI[I].getFrameIdx(),
|
||||
TII->loadRegFromStackSlot(MBB, MBBI, Reg, I.getFrameIdx(),
|
||||
&SystemZ::VR128BitRegClass, TRI);
|
||||
}
|
||||
|
||||
|
@ -345,8 +345,8 @@ bool SystemZELFFrameLowering::restoreCalleeSavedRegisters(
|
|||
MIB.addImm(RestoreGPRs.GPROffset);
|
||||
|
||||
// Do a second scan adding regs as being defined by instruction
|
||||
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
||||
unsigned Reg = CSI[I].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
if (Reg != RestoreGPRs.LowGPR && Reg != RestoreGPRs.HighGPR &&
|
||||
SystemZ::GR64BitRegClass.contains(Reg))
|
||||
MIB.addReg(Reg, RegState::ImplicitDefine);
|
||||
|
@ -965,24 +965,24 @@ bool SystemZXPLINKFrameLowering::spillCalleeSavedRegisters(
|
|||
// Make sure all call-saved GPRs are included as operands and are
|
||||
// marked as live on entry.
|
||||
auto &GRRegClass = SystemZ::GR64BitRegClass;
|
||||
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
||||
unsigned Reg = CSI[I].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
if (GRRegClass.contains(Reg))
|
||||
addSavedGPR(MBB, MIB, Reg, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Spill FPRs to the stack in the normal TargetInstrInfo way
|
||||
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
|
||||
unsigned Reg = CSI[I].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
if (SystemZ::FP64BitRegClass.contains(Reg)) {
|
||||
MBB.addLiveIn(Reg);
|
||||
TII->storeRegToStackSlot(MBB, MBBI, Reg, true, CSI[I].getFrameIdx(),
|
||||
TII->storeRegToStackSlot(MBB, MBBI, Reg, true, I.getFrameIdx(),
|
||||
&SystemZ::FP64BitRegClass, TRI);
|
||||
}
|
||||
if (SystemZ::VR128BitRegClass.contains(Reg)) {
|
||||
MBB.addLiveIn(Reg);
|
||||
TII->storeRegToStackSlot(MBB, MBBI, Reg, true, CSI[I].getFrameIdx(),
|
||||
TII->storeRegToStackSlot(MBB, MBBI, Reg, true, I.getFrameIdx(),
|
||||
&SystemZ::VR128BitRegClass, TRI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,13 +465,11 @@ void X86FrameLowering::emitCalleeSavedFrameMoves(
|
|||
|
||||
// Add callee saved registers to move list.
|
||||
const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo();
|
||||
if (CSI.empty()) return;
|
||||
|
||||
// Calculate offsets.
|
||||
for (std::vector<CalleeSavedInfo>::const_iterator
|
||||
I = CSI.begin(), E = CSI.end(); I != E; ++I) {
|
||||
int64_t Offset = MFI.getObjectOffset(I->getFrameIdx());
|
||||
unsigned Reg = I->getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
int64_t Offset = MFI.getObjectOffset(I.getFrameIdx());
|
||||
unsigned Reg = I.getReg();
|
||||
unsigned DwarfReg = MRI->getDwarfRegNum(Reg, true);
|
||||
|
||||
if (IsPrologue) {
|
||||
|
@ -2652,8 +2650,8 @@ bool X86FrameLowering::restoreCalleeSavedRegisters(
|
|||
DebugLoc DL = MBB.findDebugLoc(MI);
|
||||
|
||||
// Reload XMMs from stack frame.
|
||||
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
|
||||
unsigned Reg = CSI[i].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
if (X86::GR64RegClass.contains(Reg) ||
|
||||
X86::GR32RegClass.contains(Reg))
|
||||
continue;
|
||||
|
@ -2664,13 +2662,13 @@ bool X86FrameLowering::restoreCalleeSavedRegisters(
|
|||
VT = STI.hasBWI() ? MVT::v64i1 : MVT::v16i1;
|
||||
|
||||
const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg, VT);
|
||||
TII.loadRegFromStackSlot(MBB, MI, Reg, CSI[i].getFrameIdx(), RC, TRI);
|
||||
TII.loadRegFromStackSlot(MBB, MI, Reg, I.getFrameIdx(), RC, TRI);
|
||||
}
|
||||
|
||||
// POP GPRs.
|
||||
unsigned Opc = STI.is64Bit() ? X86::POP64r : X86::POP32r;
|
||||
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
|
||||
unsigned Reg = CSI[i].getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
if (!X86::GR64RegClass.contains(Reg) &&
|
||||
!X86::GR32RegClass.contains(Reg))
|
||||
continue;
|
||||
|
|
|
@ -427,19 +427,19 @@ bool XCoreFrameLowering::spillCalleeSavedRegisters(
|
|||
if (MI != MBB.end() && !MI->isDebugInstr())
|
||||
DL = MI->getDebugLoc();
|
||||
|
||||
for (auto it = CSI.begin(); it != CSI.end(); ++it) {
|
||||
unsigned Reg = it->getReg();
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
unsigned Reg = I.getReg();
|
||||
assert(Reg != XCore::LR && !(Reg == XCore::R10 && hasFP(*MF)) &&
|
||||
"LR & FP are always handled in emitPrologue");
|
||||
|
||||
// Add the callee-saved register as live-in. It's killed at the spill.
|
||||
MBB.addLiveIn(Reg);
|
||||
const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg);
|
||||
TII.storeRegToStackSlot(MBB, MI, Reg, true, it->getFrameIdx(), RC, TRI);
|
||||
TII.storeRegToStackSlot(MBB, MI, Reg, true, I.getFrameIdx(), RC, TRI);
|
||||
if (emitFrameMoves) {
|
||||
auto Store = MI;
|
||||
--Store;
|
||||
XFI->getSpillLabels().push_back(std::make_pair(Store, *it));
|
||||
XFI->getSpillLabels().push_back(std::make_pair(Store, I));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue