start filling in the switch stmt
authorChris Lattner <sabre@nondot.org>
Fri, 23 Sep 2005 19:36:15 +0000 (19:36 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 23 Sep 2005 19:36:15 +0000 (19:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23412 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/DAGISelEmitter.cpp
utils/TableGen/DAGISelEmitter.h

index d0aac0b51a21cbd6f442755600387df57ed26dbd..a5ec845eb0de14f911cc5bb0685cf88def40fc47 100644 (file)
@@ -1001,8 +1001,24 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
      << "  case ISD::AssertZext:\n"
      << "    return Select(N->getOperand(0));\n";
     
-
+  // Group the patterns by their top-level opcodes.
+  std::map<Record*, std::vector<PatternToMatch*> > PatternsByOpcode;
+  for (unsigned i = 0, e = PatternsToMatch.size(); i != e; ++i)
+    PatternsByOpcode[PatternsToMatch[i].first->getOperator()]
+      .push_back(&PatternsToMatch[i]);
+  
+  for (std::map<Record*, std::vector<PatternToMatch*> >::iterator
+       PBOI = PatternsByOpcode.begin(), E = PatternsByOpcode.end(); PBOI != E;
+       ++PBOI) {
+    const SDNodeInfo &OpcodeInfo = getSDNodeInfo(PBOI->first);
+    std::vector<PatternToMatch*> &Patterns = PBOI->second;
+    
+    OS << "  case " << OpcodeInfo.getEnumName() << ":\n";
+    
+    OS << "    break;\n";
+  }
   
+
   OS << "  } // end of big switch.\n\n"
      << "  std::cerr << \"Cannot yet select: \";\n"
      << "  N->dump();\n"
index de223b1cb6b25d01836639eca5b02a52dfa7a407..b2f5db11f844525a348d12d5e77a35304fb22a9f 100644 (file)
@@ -325,7 +325,8 @@ class DAGISelEmitter : public TableGenBackend {
   /// PatternsToMatch - All of the things we are matching on the DAG.  The first
   /// value is the pattern to match, the second pattern is the result to
   /// emit.
-  std::vector<std::pair<TreePatternNode*, TreePatternNode*> > PatternsToMatch;
+  typedef std::pair<TreePatternNode*, TreePatternNode*> PatternToMatch;
+  std::vector<PatternToMatch> PatternsToMatch;
 public:
   DAGISelEmitter(RecordKeeper &R) : Records(R) {}