Skip to content

Commit a6171cc

Browse files
kazutakahiratarlavaee
authored andcommitted
[Target] Use range-based for loops (NFC) (llvm#146253)
1 parent 9233842 commit a6171cc

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

llvm/lib/Target/Sparc/SparcISelLowering.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,11 +1044,9 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
10441044
// The InGlue in necessary since all emitted instructions must be
10451045
// stuck together.
10461046
SDValue InGlue;
1047-
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
1048-
Register Reg = RegsToPass[i].first;
1049-
if (!isTailCall)
1050-
Reg = toCallerWindow(Reg);
1051-
Chain = DAG.getCopyToReg(Chain, dl, Reg, RegsToPass[i].second, InGlue);
1047+
for (const auto [OrigReg, N] : RegsToPass) {
1048+
Register Reg = isTailCall ? OrigReg : toCallerWindow(OrigReg);
1049+
Chain = DAG.getCopyToReg(Chain, dl, Reg, N, InGlue);
10521050
InGlue = Chain.getValue(1);
10531051
}
10541052

@@ -1069,11 +1067,9 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
10691067
Ops.push_back(Callee);
10701068
if (hasStructRetAttr)
10711069
Ops.push_back(DAG.getTargetConstant(SRetArgSize, dl, MVT::i32));
1072-
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
1073-
Register Reg = RegsToPass[i].first;
1074-
if (!isTailCall)
1075-
Reg = toCallerWindow(Reg);
1076-
Ops.push_back(DAG.getRegister(Reg, RegsToPass[i].second.getValueType()));
1070+
for (const auto [OrigReg, N] : RegsToPass) {
1071+
Register Reg = isTailCall ? OrigReg : toCallerWindow(OrigReg);
1072+
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
10771073
}
10781074

10791075
// Add a register mask operand representing the call-preserved registers.
@@ -1375,9 +1371,8 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
13751371
// necessary since all emitted instructions must be stuck together in order
13761372
// to pass the live physical registers.
13771373
SDValue InGlue;
1378-
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
1379-
Chain = DAG.getCopyToReg(Chain, DL,
1380-
RegsToPass[i].first, RegsToPass[i].second, InGlue);
1374+
for (const auto [Reg, N] : RegsToPass) {
1375+
Chain = DAG.getCopyToReg(Chain, DL, Reg, N, InGlue);
13811376
InGlue = Chain.getValue(1);
13821377
}
13831378

@@ -1395,9 +1390,8 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
13951390
SmallVector<SDValue, 8> Ops;
13961391
Ops.push_back(Chain);
13971392
Ops.push_back(Callee);
1398-
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
1399-
Ops.push_back(DAG.getRegister(RegsToPass[i].first,
1400-
RegsToPass[i].second.getValueType()));
1393+
for (const auto [Reg, N] : RegsToPass)
1394+
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
14011395

14021396
// Add a register mask operand representing the call-preserved registers.
14031397
const SparcRegisterInfo *TRI = Subtarget->getRegisterInfo();

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,9 +2387,8 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
23872387
}
23882388

23892389
// Build a sequence of copy-to-reg nodes, chained and glued together.
2390-
for (unsigned I = 0, E = RegsToPass.size(); I != E; ++I) {
2391-
Chain = DAG.getCopyToReg(Chain, DL, RegsToPass[I].first,
2392-
RegsToPass[I].second, Glue);
2390+
for (const auto [Reg, N] : RegsToPass) {
2391+
Chain = DAG.getCopyToReg(Chain, DL, Reg, N, Glue);
23932392
Glue = Chain.getValue(1);
23942393
}
23952394

@@ -2400,9 +2399,8 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
24002399

24012400
// Add argument registers to the end of the list so that they are
24022401
// known live into the call.
2403-
for (unsigned I = 0, E = RegsToPass.size(); I != E; ++I)
2404-
Ops.push_back(DAG.getRegister(RegsToPass[I].first,
2405-
RegsToPass[I].second.getValueType()));
2402+
for (const auto [Reg, N] : RegsToPass)
2403+
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
24062404

24072405
// Add a register mask operand representing the call-preserved registers.
24082406
const TargetRegisterInfo *TRI = Subtarget.getRegisterInfo();

0 commit comments

Comments
 (0)