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

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 00:12:20 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc12fd71cff4: [TableGen][GlobalISel] Fix unused variable warnings (authored by Pierre-vh).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156208/new/

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.544229.patch
Type: text/x-patch
Size: 2397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230726/36088012/attachment.bin>


More information about the llvm-commits mailing list