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