Skip to content

Commit bad5a74

Browse files
[PowerPC] Use range-based for loops (NFC) (#146221)
1 parent 402baea commit bad5a74

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

llvm/lib/Target/PowerPC/PPCFrameLowering.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,8 +2170,8 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
21702170
// The Floating-point register save area is right below the back chain word
21712171
// of the previous stack frame.
21722172
if (HasFPSaveArea) {
2173-
for (unsigned i = 0, e = FPRegs.size(); i != e; ++i) {
2174-
int FI = FPRegs[i].getFrameIdx();
2173+
for (const CalleeSavedInfo &FPReg : FPRegs) {
2174+
int FI = FPReg.getFrameIdx();
21752175

21762176
MFI.setObjectOffset(FI, LowerBound + MFI.getObjectOffset(FI));
21772177
}
@@ -2219,18 +2219,18 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
22192219
if (HasGPSaveArea || HasG8SaveArea) {
22202220
// Move general register save area spill slots down, taking into account
22212221
// the size of the Floating-point register save area.
2222-
for (unsigned i = 0, e = GPRegs.size(); i != e; ++i) {
2223-
if (!GPRegs[i].isSpilledToReg()) {
2224-
int FI = GPRegs[i].getFrameIdx();
2222+
for (const CalleeSavedInfo &GPReg : GPRegs) {
2223+
if (!GPReg.isSpilledToReg()) {
2224+
int FI = GPReg.getFrameIdx();
22252225
MFI.setObjectOffset(FI, LowerBound + MFI.getObjectOffset(FI));
22262226
}
22272227
}
22282228

22292229
// Move general register save area spill slots down, taking into account
22302230
// the size of the Floating-point register save area.
2231-
for (unsigned i = 0, e = G8Regs.size(); i != e; ++i) {
2232-
if (!G8Regs[i].isSpilledToReg()) {
2233-
int FI = G8Regs[i].getFrameIdx();
2231+
for (const CalleeSavedInfo &G8Reg : G8Regs) {
2232+
if (!G8Reg.isSpilledToReg()) {
2233+
int FI = G8Reg.getFrameIdx();
22342234
MFI.setObjectOffset(FI, LowerBound + MFI.getObjectOffset(FI));
22352235
}
22362236
}
@@ -2272,8 +2272,8 @@ void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
22722272
assert(LowerBound <= 0 && "Expect LowerBound have a non-positive value!");
22732273
LowerBound &= ~(15);
22742274

2275-
for (unsigned i = 0, e = VRegs.size(); i != e; ++i) {
2276-
int FI = VRegs[i].getFrameIdx();
2275+
for (const CalleeSavedInfo &VReg : VRegs) {
2276+
int FI = VReg.getFrameIdx();
22772277

22782278
MFI.setObjectOffset(FI, LowerBound + MFI.getObjectOffset(FI));
22792279
}

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4445,11 +4445,11 @@ SDValue PPCTargetLowering::LowerFormalArguments_32SVR4(
44454445
// The fixed integer arguments of a variadic function are stored to the
44464446
// VarArgsFrameIndex on the stack so that they may be loaded by
44474447
// dereferencing the result of va_next.
4448-
for (unsigned GPRIndex = 0; GPRIndex != NumGPArgRegs; ++GPRIndex) {
4448+
for (MCPhysReg GPArgReg : GPArgRegs) {
44494449
// Get an existing live-in vreg, or add a new one.
4450-
Register VReg = MF.getRegInfo().getLiveInVirtReg(GPArgRegs[GPRIndex]);
4450+
Register VReg = MF.getRegInfo().getLiveInVirtReg(GPArgReg);
44514451
if (!VReg)
4452-
VReg = MF.addLiveIn(GPArgRegs[GPRIndex], &PPC::GPRCRegClass);
4452+
VReg = MF.addLiveIn(GPArgReg, &PPC::GPRCRegClass);
44534453

44544454
SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, PtrVT);
44554455
SDValue Store =
@@ -4549,13 +4549,13 @@ SDValue PPCTargetLowering::LowerFormalArguments_64SVR4(
45494549
unsigned NumBytes = LinkageSize;
45504550
unsigned AvailableFPRs = Num_FPR_Regs;
45514551
unsigned AvailableVRs = Num_VR_Regs;
4552-
for (unsigned i = 0, e = Ins.size(); i != e; ++i) {
4553-
if (Ins[i].Flags.isNest())
4552+
for (const ISD::InputArg &In : Ins) {
4553+
if (In.Flags.isNest())
45544554
continue;
45554555

4556-
if (CalculateStackSlotUsed(Ins[i].VT, Ins[i].ArgVT, Ins[i].Flags,
4557-
PtrByteSize, LinkageSize, ParamAreaSize,
4558-
NumBytes, AvailableFPRs, AvailableVRs))
4556+
if (CalculateStackSlotUsed(In.VT, In.ArgVT, In.Flags, PtrByteSize,
4557+
LinkageSize, ParamAreaSize, NumBytes,
4558+
AvailableFPRs, AvailableVRs))
45594559
HasParameterArea = true;
45604560
}
45614561

@@ -5766,9 +5766,8 @@ buildCallOperands(SmallVectorImpl<SDValue> &Ops,
57665766

57675767
// Add argument registers to the end of the list so that they are known live
57685768
// into the call.
5769-
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
5770-
Ops.push_back(DAG.getRegister(RegsToPass[i].first,
5771-
RegsToPass[i].second.getValueType()));
5769+
for (const auto [Reg, N] : RegsToPass)
5770+
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
57725771

57735772
// We cannot add R2/X2 as an operand here for PATCHPOINT, because there is
57745773
// no way to mark dependencies as implicit here.
@@ -6191,9 +6190,8 @@ SDValue PPCTargetLowering::LowerCall_32SVR4(
61916190
// Build a sequence of copy-to-reg nodes chained together with token chain
61926191
// and flag operands which copy the outgoing args into the appropriate regs.
61936192
SDValue InGlue;
6194-
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
6195-
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
6196-
RegsToPass[i].second, InGlue);
6193+
for (const auto [Reg, N] : RegsToPass) {
6194+
Chain = DAG.getCopyToReg(Chain, dl, Reg, N, InGlue);
61976195
InGlue = Chain.getValue(1);
61986196
}
61996197

@@ -6805,9 +6803,8 @@ SDValue PPCTargetLowering::LowerCall_64SVR4(
68056803
// Build a sequence of copy-to-reg nodes chained together with token chain
68066804
// and flag operands which copy the outgoing args into the appropriate regs.
68076805
SDValue InGlue;
6808-
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
6809-
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
6810-
RegsToPass[i].second, InGlue);
6806+
for (const auto [Reg, N] : RegsToPass) {
6807+
Chain = DAG.getCopyToReg(Chain, dl, Reg, N, InGlue);
68116808
InGlue = Chain.getValue(1);
68126809
}
68136810

0 commit comments

Comments
 (0)