diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-25 19:00:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-25 19:00:39 +0000 |
commit | d6c84720df0b63e34081e0c7890f3074d8b110b9 (patch) | |
tree | f46552db5b37742ed3f49f1084681468b7222756 /utils/TableGen/DAGISelMatcherOpt.cpp | |
parent | 2333655ed04637ffd049b9299685a0752aab8e8d (diff) | |
download | external_llvm-d6c84720df0b63e34081e0c7890f3074d8b110b9.zip external_llvm-d6c84720df0b63e34081e0c7890f3074d8b110b9.tar.gz external_llvm-d6c84720df0b63e34081e0c7890f3074d8b110b9.tar.bz2 |
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
Diffstat (limited to 'utils/TableGen/DAGISelMatcherOpt.cpp')
-rw-r--r-- | utils/TableGen/DAGISelMatcherOpt.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp index 002637b..9a6edd3 100644 --- a/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/utils/TableGen/DAGISelMatcherOpt.cpp @@ -21,9 +21,15 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr) { Matcher *N = MatcherPtr.get(); if (N == 0) return; - // If we have a scope node, walk down both edges. - if (ScopeMatcher *Push = dyn_cast<ScopeMatcher>(N)) - ContractNodes(Push->getCheckPtr()); + // If we have a scope node, walk down all of the children. + if (ScopeMatcher *Scope = dyn_cast<ScopeMatcher>(N)) { + for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) { + OwningPtr<Matcher> Child(Scope->takeChild(i)); + ContractNodes(Child); + Scope->resetChild(i, Child.take()); + } + return; + } // If we found a movechild node with a node that comes in a 'foochild' form, // transform it. @@ -61,32 +67,31 @@ static void FactorNodes(OwningPtr<Matcher> &MatcherPtr) { if (N == 0) return; // If this is not a push node, just scan for one. - if (!isa<ScopeMatcher>(N)) + ScopeMatcher *Scope = dyn_cast<ScopeMatcher>(N); + if (Scope == 0) return FactorNodes(N->getNextPtr()); - // Okay, pull together the series of linear push nodes into a vector so we can + // Okay, pull together the children of the scope node into a vector so we can // inspect it more easily. While we're at it, bucket them up by the hash // code of their first predicate. SmallVector<Matcher*, 32> OptionsToMatch; typedef DenseMap<unsigned, std::vector<Matcher*> > HashTableTy; HashTableTy MatchersByHash; - Matcher *CurNode = N; - for (; ScopeMatcher *PMN = dyn_cast<ScopeMatcher>(CurNode); - CurNode = PMN->getNext()) { + for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) { // Factor the subexpression. - FactorNodes(PMN->getCheckPtr()); - if (Matcher *Check = PMN->getCheck()) { - OptionsToMatch.push_back(Check); - MatchersByHash[Check->getHash()].push_back(Check); + OwningPtr<Matcher> Child(Scope->takeChild(i)); + FactorNodes(Child); + + // FIXME: Eventually don't pass ownership back to the scope node. + Scope->resetChild(i, Child.take()); + + if (Matcher *N = Scope->getChild(i)) { + OptionsToMatch.push_back(N); + MatchersByHash[N->getHash()].push_back(N); } } - if (CurNode) { - OptionsToMatch.push_back(CurNode); - MatchersByHash[CurNode->getHash()].push_back(CurNode); - } - SmallVector<Matcher*, 32> NewOptionsToMatch; |