diff options
| author | Craig Topper <craig.topper@gmail.com> | 2016-11-22 07:00:06 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2016-11-22 07:00:06 +0000 |
| commit | 3dc066754c3b3299b82747402ce7579d7a659871 (patch) | |
| tree | b401be8de4ffa6c9280ae7819c7eec89059124d6 /llvm/utils | |
| parent | 07ce9a0bcc0b341e8a42c7a233a01c056fa79e5c (diff) | |
| download | bcm5719-llvm-3dc066754c3b3299b82747402ce7579d7a659871.tar.gz bcm5719-llvm-3dc066754c3b3299b82747402ce7579d7a659871.zip | |
[TableGen][ISel] When factoring ScopeMatcher, if the child of the ScopeMatcher we're working on is also a ScopeMatcher, merge all its children into the one we're working on.
There were several cases in X86 where we were unable to fully factor a ScopeMatcher but created nested ScopeMatchers for some portions of it. Then we created a SwitchType that split it up and further factored it so that we ended up with something like this:
SwitchType
Scope
Scope
Sequence of matchers
Some other sequence of matchers
EndScope
Another sequence of matchers
EndScope
...Next type
This change turns it into this:
SwitchType
Scope
Sequence of matchers
Some other sequence of matchers
Another sequence of matchers
EndScope
...Next type
Several other in-tree targets had similar nested scopes like this. Overall this doesn't save many bytes, but makes the isel output a little more regular.
llvm-svn: 287624
Diffstat (limited to 'llvm/utils')
| -rw-r--r-- | llvm/utils/TableGen/DAGISelMatcherOpt.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp index 74370c077f8..783b35e745f 100644 --- a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp @@ -200,8 +200,15 @@ static void FactorNodes(std::unique_ptr<Matcher> &MatcherPtr) { std::unique_ptr<Matcher> Child(Scope->takeChild(i)); FactorNodes(Child); - if (Matcher *N = Child.release()) - OptionsToMatch.push_back(N); + if (Child) { + // If the child is a ScopeMatcher we can just merge its contents. + if (auto *SM = dyn_cast<ScopeMatcher>(Child.get())) { + for (unsigned j = 0, e = SM->getNumChildren(); j != e; ++j) + OptionsToMatch.push_back(SM->takeChild(j)); + } else { + OptionsToMatch.push_back(Child.release()); + } + } } SmallVector<Matcher*, 32> NewOptionsToMatch; |

