-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[Target] Use range-based for loops (NFC) #146253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20250628_range_for_llvm_Target
Jun 29, 2025
Merged
[Target] Use range-based for loops (NFC) #146253
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20250628_range_for_llvm_Target
Jun 29, 2025
+14
−22
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-backend-systemz @llvm/pr-subscribers-backend-sparc Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/146253.diff 2 Files Affected:
diff --git a/llvm/lib/Target/Sparc/SparcISelLowering.cpp b/llvm/lib/Target/Sparc/SparcISelLowering.cpp
index 85ad6c9aad914..8f33e528470e8 100644
--- a/llvm/lib/Target/Sparc/SparcISelLowering.cpp
+++ b/llvm/lib/Target/Sparc/SparcISelLowering.cpp
@@ -1044,11 +1044,9 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
// The InGlue in necessary since all emitted instructions must be
// stuck together.
SDValue InGlue;
- for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
- Register Reg = RegsToPass[i].first;
- if (!isTailCall)
- Reg = toCallerWindow(Reg);
- Chain = DAG.getCopyToReg(Chain, dl, Reg, RegsToPass[i].second, InGlue);
+ for (const auto [OrigReg, N] : RegsToPass) {
+ Register Reg = isTailCall ? OrigReg : toCallerWindow(OrigReg);
+ Chain = DAG.getCopyToReg(Chain, dl, Reg, N, InGlue);
InGlue = Chain.getValue(1);
}
@@ -1069,11 +1067,9 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
Ops.push_back(Callee);
if (hasStructRetAttr)
Ops.push_back(DAG.getTargetConstant(SRetArgSize, dl, MVT::i32));
- for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
- Register Reg = RegsToPass[i].first;
- if (!isTailCall)
- Reg = toCallerWindow(Reg);
- Ops.push_back(DAG.getRegister(Reg, RegsToPass[i].second.getValueType()));
+ for (const auto [OrigReg, N] : RegsToPass) {
+ Register Reg = isTailCall ? OrigReg : toCallerWindow(OrigReg);
+ Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
}
// Add a register mask operand representing the call-preserved registers.
@@ -1375,9 +1371,8 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
// necessary since all emitted instructions must be stuck together in order
// to pass the live physical registers.
SDValue InGlue;
- for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
- Chain = DAG.getCopyToReg(Chain, DL,
- RegsToPass[i].first, RegsToPass[i].second, InGlue);
+ for (const auto [Reg, N] : RegsToPass) {
+ Chain = DAG.getCopyToReg(Chain, DL, Reg, N, InGlue);
InGlue = Chain.getValue(1);
}
@@ -1395,9 +1390,8 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
SmallVector<SDValue, 8> Ops;
Ops.push_back(Chain);
Ops.push_back(Callee);
- for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
- Ops.push_back(DAG.getRegister(RegsToPass[i].first,
- RegsToPass[i].second.getValueType()));
+ for (const auto [Reg, N] : RegsToPass)
+ Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
// Add a register mask operand representing the call-preserved registers.
const SparcRegisterInfo *TRI = Subtarget->getRegisterInfo();
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 831618c4eff5f..beb28c8f29780 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -2387,9 +2387,8 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
}
// Build a sequence of copy-to-reg nodes, chained and glued together.
- for (unsigned I = 0, E = RegsToPass.size(); I != E; ++I) {
- Chain = DAG.getCopyToReg(Chain, DL, RegsToPass[I].first,
- RegsToPass[I].second, Glue);
+ for (const auto [Reg, N] : RegsToPass) {
+ Chain = DAG.getCopyToReg(Chain, DL, Reg, N, Glue);
Glue = Chain.getValue(1);
}
@@ -2400,9 +2399,8 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
// Add argument registers to the end of the list so that they are
// known live into the call.
- for (unsigned I = 0, E = RegsToPass.size(); I != E; ++I)
- Ops.push_back(DAG.getRegister(RegsToPass[I].first,
- RegsToPass[I].second.getValueType()));
+ for (const auto [Reg, N] : RegsToPass)
+ Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
// Add a register mask operand representing the call-preserved registers.
const TargetRegisterInfo *TRI = Subtarget.getRegisterInfo();
|
arsenm
approved these changes
Jun 29, 2025
rlavaee
pushed a commit
to rlavaee/llvm-project
that referenced
this pull request
Jul 1, 2025
rlavaee
pushed a commit
to rlavaee/llvm-project
that referenced
this pull request
Jul 1, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.