[PATCH] D156208: [TableGen][GlobalISel] Fix unused variable warnings

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 23:34:13 PDT 2023


Pierre-vh created this revision.
Pierre-vh added a reviewer: arsenm.
Herald added a project: All.
Pierre-vh requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156208

Files:
  llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp


Index: llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp
===================================================================
--- llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp
+++ llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp
@@ -59,6 +59,14 @@
                        "]->getOperand(" + to_string(OM.getOpIdx()) + ")");
 }
 
+template <typename Container> auto keys(Container &&C) {
+  return map_range(C, [](auto &Entry) -> auto & { return Entry.first; });
+}
+
+template <typename Container> auto values(Container &&C) {
+  return map_range(C, [](auto &Entry) -> auto & { return Entry.second; });
+}
+
 //===- MatchData Handling -------------------------------------------------===//
 
 /// Represents MatchData defined by the match stage and required by the apply
@@ -785,7 +793,7 @@
 
 bool CombineRuleBuilder::buildOperandsTable() {
   // Walk each instruction pattern
-  for (auto &[_, P] : MatchPats) {
+  for (auto &P : values(MatchPats)) {
     auto *IP = dyn_cast<InstructionPattern>(P.get());
     if (!IP)
       continue;
@@ -806,7 +814,7 @@
     }
   }
 
-  for (auto &[_, P] : ApplyPats) {
+  for (auto &P : values(ApplyPats)) {
     auto *IP = dyn_cast<InstructionPattern>(P.get());
     if (!IP)
       continue;
@@ -1019,7 +1027,7 @@
     return false;
 
   // Emit remaining patterns
-  for (auto &[_, Pat] : MatchPats) {
+  for (auto &Pat : values(MatchPats)) {
     if (SeenPats.contains(Pat.get()))
       continue;
 
@@ -1058,7 +1066,7 @@
     IM.addPredicate<InstructionOpcodeMatcher>(CGI);
 
     // Emit remaining patterns.
-    for (auto &[_, Pat] : MatchPats) {
+    for (auto &Pat : values(MatchPats)) {
       if (Pat.get() == &AOP)
         continue;
 
@@ -1087,7 +1095,7 @@
 }
 
 bool CombineRuleBuilder::emitApplyPatterns(CodeExpansions &CE, RuleMatcher &M) {
-  for (auto &[_, Pat] : ApplyPats) {
+  for (auto &Pat : values(ApplyPats)) {
     switch (Pat->getKind()) {
     case Pattern::K_AnyOpcode:
     case Pattern::K_Inst:
@@ -1371,7 +1379,7 @@
     // (GICXXPred_Invalid + 1).
     unsigned ExpectedID = 0;
     (void)ExpectedID;
-    for (const auto &[ID, _] : AllCombineRules) {
+    for (const auto &ID : keys(AllCombineRules)) {
       assert(ExpectedID++ == ID && "combine rules are not ordered!");
       OS << "  " << getIsEnabledPredicateEnumName(ID) << EnumeratorSeparator;
       EnumeratorSeparator = ",\n";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156208.543835.patch
Type: text/x-patch
Size: 2397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230725/b2b3694b/attachment.bin>


More information about the llvm-commits mailing list