summaryrefslogtreecommitdiffstats
path: root/llvm/utils
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2016-11-21 04:07:58 +0000
committerCraig Topper <craig.topper@gmail.com>2016-11-21 04:07:58 +0000
commit5e87d5264f1fb7c94aeb9bb893c1247dc0ddb188 (patch)
tree41963e3f883f7baba6069ee42c27e79a0653ea78 /llvm/utils
parent0dfc09372f6a070d1c0b16ef6d89df1eb5b4805d (diff)
downloadbcm5719-llvm-5e87d5264f1fb7c94aeb9bb893c1247dc0ddb188.tar.gz
bcm5719-llvm-5e87d5264f1fb7c94aeb9bb893c1247dc0ddb188.zip
[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. llvm-svn: 287520
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/TableGen/DAGISelMatcherOpt.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
index ad385fac043..74370c077f8 100644
--- a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
@@ -414,9 +414,7 @@ static void FactorNodes(std::unique_ptr<Matcher> &MatcherPtr) {
}
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<Matcher> &MatcherPtr) {
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 {
OpenPOWER on IntegriCloud