diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-24 07:31:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-24 07:31:45 +0000 |
commit | 19b5a7590b784f19875b9880ea8838c393431656 (patch) | |
tree | a72bfb5c816b6e8751d7e9b76b904b1ff53f4871 /utils/TableGen/DAGISelMatcherOpt.cpp | |
parent | 91c6a822baaba3cb2def94224115e57b84805347 (diff) | |
download | external_llvm-19b5a7590b784f19875b9880ea8838c393431656.zip external_llvm-19b5a7590b784f19875b9880ea8838c393431656.tar.gz external_llvm-19b5a7590b784f19875b9880ea8838c393431656.tar.bz2 |
implement a simple proof-of-concept optimization for
the new isel: fold movechild+record+moveparent into a
single recordchild N node. This shrinks the X86 table
from 125443 to 117502 bytes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/DAGISelMatcherOpt.cpp')
-rw-r--r-- | utils/TableGen/DAGISelMatcherOpt.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp index 7859f36..d365820 100644 --- a/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/utils/TableGen/DAGISelMatcherOpt.cpp @@ -14,6 +14,35 @@ #include "DAGISelMatcher.h" using namespace llvm; -void llvm::OptimizeMatcher(const MatcherNode *Matcher) { - // Nothing yet. + +static void FormRecordChildNodes(OwningPtr<MatcherNode> &Matcher) { + // If we reached the end of the chain, we're done. + MatcherNode *N = Matcher.get(); + if (N == 0) return; + + // If we have a push node, walk down both edges. + if (PushMatcherNode *Push = dyn_cast<PushMatcherNode>(N)) + FormRecordChildNodes(Push->getFailurePtr()); + + // If we found a movechild node, check to see if our pattern matches. + if (MoveChildMatcherNode *MC = dyn_cast<MoveChildMatcherNode>(N)) { + if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(MC->getNext())) + if (MoveParentMatcherNode *MP = + dyn_cast<MoveParentMatcherNode>(RM->getNext())) { + MatcherNode *New + = new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor()); + New->setNext(MP->takeNext()); + Matcher.reset(New); + return FormRecordChildNodes(Matcher); + } + } + + FormRecordChildNodes(N->getNextPtr()); +} + + +MatcherNode *llvm::OptimizeMatcher(MatcherNode *Matcher) { + OwningPtr<MatcherNode> MatcherPtr(Matcher); + FormRecordChildNodes(MatcherPtr); + return MatcherPtr.take(); } |