[llvm] 01ac6fc - [TableGen] Use range-based for loops. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 6 19:14:27 PST 2025
Author: Craig Topper
Date: 2025-02-06T19:14:10-08:00
New Revision: 01ac6fc9099f814517cf8ab405f3f6b646ca09d1
URL: https://github.com/llvm/llvm-project/commit/01ac6fc9099f814517cf8ab405f3f6b646ca09d1
DIFF: https://github.com/llvm/llvm-project/commit/01ac6fc9099f814517cf8ab405f3f6b646ca09d1.diff
LOG: [TableGen] Use range-based for loops. NFC
Added:
Modified:
llvm/utils/TableGen/DAGISelMatcherOpt.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
index 42cc5655c3baeb..400534290a0912 100644
--- a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
@@ -362,13 +362,13 @@ static void FactorScope(std::unique_ptr<Matcher> &MatcherPtr) {
// Check to see if all of the leading entries are now opcode checks. If so,
// we can convert this Scope to be a OpcodeSwitch instead.
bool AllOpcodeChecks = true, AllTypeChecks = true;
- for (unsigned i = 0, e = OptionsToMatch.size(); i != e; ++i) {
+ for (Matcher *Optn : OptionsToMatch) {
// Check to see if this breaks a series of CheckOpcodeMatchers.
- if (AllOpcodeChecks && !isa<CheckOpcodeMatcher>(OptionsToMatch[i])) {
+ if (AllOpcodeChecks && !isa<CheckOpcodeMatcher>(Optn)) {
#if 0
if (i > 3) {
errs() << "FAILING OPC #" << i << "\n";
- OptionsToMatch[i]->dump();
+ Optn->dump();
}
#endif
AllOpcodeChecks = false;
@@ -377,7 +377,7 @@ static void FactorScope(std::unique_ptr<Matcher> &MatcherPtr) {
// Check to see if this breaks a series of CheckTypeMatcher's.
if (AllTypeChecks) {
CheckTypeMatcher *CTM = cast_or_null<CheckTypeMatcher>(
- FindNodeWithKind(OptionsToMatch[i], Matcher::CheckType));
+ FindNodeWithKind(Optn, Matcher::CheckType));
if (!CTM ||
// iPTR checks could alias any other case without us knowing, don't
// bother with them.
@@ -386,12 +386,11 @@ static void FactorScope(std::unique_ptr<Matcher> &MatcherPtr) {
CTM->getResNo() != 0 ||
// If the CheckType isn't at the start of the list, see if we can move
// it there.
- !CTM->canMoveBefore(OptionsToMatch[i])) {
+ !CTM->canMoveBefore(Optn)) {
#if 0
if (i > 3 && AllTypeChecks) {
errs() << "FAILING TYPE #" << i << "\n";
- OptionsToMatch[i]->dump();
- }
+ Optn->dump(); }
#endif
AllTypeChecks = false;
}
@@ -402,8 +401,8 @@ static void FactorScope(std::unique_ptr<Matcher> &MatcherPtr) {
if (AllOpcodeChecks) {
StringSet<> Opcodes;
SmallVector<std::pair<const SDNodeInfo *, Matcher *>, 8> Cases;
- for (unsigned i = 0, e = OptionsToMatch.size(); i != e; ++i) {
- CheckOpcodeMatcher *COM = cast<CheckOpcodeMatcher>(OptionsToMatch[i]);
+ for (Matcher *Optn : OptionsToMatch) {
+ CheckOpcodeMatcher *COM = cast<CheckOpcodeMatcher>(Optn);
assert(Opcodes.insert(COM->getOpcode().getEnumName()).second &&
"Duplicate opcodes not factored?");
Cases.emplace_back(&COM->getOpcode(), COM->takeNext());
@@ -418,12 +417,12 @@ static void FactorScope(std::unique_ptr<Matcher> &MatcherPtr) {
if (AllTypeChecks) {
DenseMap<unsigned, unsigned> TypeEntry;
SmallVector<std::pair<MVT::SimpleValueType, Matcher *>, 8> Cases;
- for (unsigned i = 0, e = OptionsToMatch.size(); i != e; ++i) {
- Matcher *M = FindNodeWithKind(OptionsToMatch[i], Matcher::CheckType);
+ for (Matcher *Optn : OptionsToMatch) {
+ Matcher *M = FindNodeWithKind(Optn, Matcher::CheckType);
assert(M && isa<CheckTypeMatcher>(M) && "Unknown Matcher type");
auto *CTM = cast<CheckTypeMatcher>(M);
- Matcher *MatcherWithoutCTM = OptionsToMatch[i]->unlinkNode(CTM);
+ Matcher *MatcherWithoutCTM = Optn->unlinkNode(CTM);
MVT::SimpleValueType CTMTy = CTM->getType();
delete CTM;
More information about the llvm-commits
mailing list