[PATCH] D29709: [globalisel] Separate the SelectionDAG importer from the emitter. NFC

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 11:38:28 PST 2017


dsanders updated this revision to Diff 88027.
dsanders added a comment.

Rebased to trunk.


https://reviews.llvm.org/D29709

Files:
  utils/TableGen/GlobalISelEmitter.cpp


Index: utils/TableGen/GlobalISelEmitter.cpp
===================================================================
--- utils/TableGen/GlobalISelEmitter.cpp
+++ utils/TableGen/GlobalISelEmitter.cpp
@@ -45,7 +45,8 @@
 #define DEBUG_TYPE "gisel-emitter"
 
 STATISTIC(NumPatternTotal, "Total number of patterns");
-STATISTIC(NumPatternSkipped, "Number of patterns skipped");
+STATISTIC(NumPatternImported, "Number of patterns imported from SelectionDAG");
+STATISTIC(NumPatternImportsSkipped, "Number of SelectionDAG imports skipped");
 STATISTIC(NumPatternEmitted, "Number of patterns emitted");
 
 static cl::opt<bool> WarnOnSkippedPatterns(
@@ -55,7 +56,6 @@
     cl::init(false));
 
 namespace {
-class RuleMatcher;
 
 //===- Helper functions ---------------------------------------------------===//
 
@@ -322,7 +322,7 @@
     return *static_cast<Kind *>(Actions.back().get());
   }
 
-  void emit(raw_ostream &OS) {
+  void emit(raw_ostream &OS) const {
     if (Matchers.empty())
       llvm_unreachable("Unexpected empty matcher!");
 
@@ -516,6 +516,7 @@
   }
 
   // We're done with this pattern!  It's eligible for GISel emission; return it.
+  ++NumPatternImported;
   return std::move(M);
 }
 
@@ -530,6 +531,7 @@
         "(MachineInstr &I) const {\n  const MachineRegisterInfo &MRI = "
         "I.getParent()->getParent()->getRegInfo();\n\n";
 
+  std::vector<RuleMatcher> Rules;
   // Look through the SelectionDAG patterns we found, possibly emitting some.
   for (const PatternToMatch &Pat : CGP.ptms()) {
     ++NumPatternTotal;
@@ -544,11 +546,15 @@
       } else {
         consumeError(std::move(Err));
       }
-      ++NumPatternSkipped;
+      ++NumPatternImportsSkipped;
       continue;
     }
 
-    MatcherOrErr->emit(OS);
+    Rules.push_back(std::move(MatcherOrErr.get()));
+  }
+
+  for (const auto &Rule : Rules) {
+    Rule.emit(OS);
     ++NumPatternEmitted;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29709.88027.patch
Type: text/x-patch
Size: 1893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170210/d0def8ba/attachment.bin>


More information about the llvm-commits mailing list