[llvm] r287520 - [TableGen][ISel] Do a better job of factoring ScopeMatchers created during creation of SwitchTypeMatcher.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 20 20:07:59 PST 2016


Author: ctopper
Date: Sun Nov 20 22:07:58 2016
New Revision: 287520

URL: http://llvm.org/viewvc/llvm-project?rev=287520&view=rev
Log:
[TableGen][ISel] Do a better job of factoring ScopeMatchers created during creation of SwitchTypeMatcher.

Previously we were factoring when the ScopeMatcher was initially created, but it might get more Matchers added to it later. Delay factoring until we have fully created/populated the ScopeMatchers.

This reduces X86 isel tables by 154 bytes.

Modified:
    llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp

Modified: llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp?rev=287520&r1=287519&r2=287520&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp Sun Nov 20 22:07:58 2016
@@ -414,9 +414,7 @@ static void FactorNodes(std::unique_ptr<
         }
         
         Matcher *Entries[2] = { PrevMatcher, MatcherWithoutCTM };
-        std::unique_ptr<Matcher> Case(new ScopeMatcher(Entries));
-        FactorNodes(Case);
-        Cases[Entry-1].second = Case.release();
+        Cases[Entry-1].second = new ScopeMatcher(Entries);
         continue;
       }
       
@@ -424,6 +422,16 @@ static void FactorNodes(std::unique_ptr<
       Cases.push_back(std::make_pair(CTMTy, MatcherWithoutCTM));
     }
     
+    // Make sure we recursively factor any scopes we may have created.
+    for (auto &M : Cases) {
+      if (ScopeMatcher *SM = dyn_cast<ScopeMatcher>(M.second)) {
+        std::unique_ptr<Matcher> Scope(SM);
+        FactorNodes(Scope);
+        M.second = Scope.release();
+        assert(M.second && "null matcher");
+      }
+    }
+
     if (Cases.size() != 1) {
       MatcherPtr.reset(new SwitchTypeMatcher(Cases));
     } else {




More information about the llvm-commits mailing list