change the scope node to include a list of children to be checked
instead of to have a chained series of scope nodes.  This makes
the generated table smaller, improves the efficiency of the
interpreter, and make the factoring optimization much more 
reasonable to implement.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97160 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp
index fbf3f86..5e2b07d 100644
--- a/utils/TableGen/DAGISelEmitter.cpp
+++ b/utils/TableGen/DAGISelEmitter.cpp
@@ -1945,8 +1945,6 @@
   }
   
 #ifdef ENABLE_NEW_ISEL
-  Matcher *TheMatcher = 0;
-
   // Add all the patterns to a temporary list so we can sort them.
   std::vector<const PatternToMatch*> Patterns;
   for (CodeGenDAGPatterns::ptm_iterator I = CGP.ptm_begin(), E = CGP.ptm_end();
@@ -1960,20 +1958,13 @@
                    PatternSortingPredicate2(CGP));
   
   
-  // Walk the patterns backwards (since we append to the front of the generated
-  // code), building a matcher for each and adding it to the matcher for the
-  // whole target.
-  while (!Patterns.empty()) {
-    const PatternToMatch &Pattern = *Patterns.back();
-    Patterns.pop_back();
-    
-    Matcher *N = ConvertPatternToMatcher(Pattern, CGP);
-    
-    if (TheMatcher == 0)
-      TheMatcher = N;
-    else
-      TheMatcher = new ScopeMatcher(N, TheMatcher);
-  }
+  // Convert each pattern into Matcher's.
+  std::vector<Matcher*> PatternMatchers;
+  for (unsigned i = 0, e = Patterns.size(); i != e; ++i)
+    PatternMatchers.push_back(ConvertPatternToMatcher(*Patterns[i], CGP));
+  
+  Matcher *TheMatcher = new ScopeMatcher(&PatternMatchers[0],
+                                         PatternMatchers.size());
 
   TheMatcher = OptimizeMatcher(TheMatcher);
   //Matcher->dump();