From 22c48b384cdb691150f520c78dcecb6134e5edb0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 24 Feb 2010 19:52:48 +0000 Subject: split the movechild/record/moveparent -> recordchild optzn into a movechild/record -> recordchild/movechild and movechild/moveparent -> noop xforms. This slightly shrinks the tables (x86 to 117454) and enables adding future improvements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97051 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelMatcherOpt.cpp | 38 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'utils/TableGen/DAGISelMatcherOpt.cpp') diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp index d365820..408bd63 100644 --- a/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/utils/TableGen/DAGISelMatcherOpt.cpp @@ -14,35 +14,41 @@ #include "DAGISelMatcher.h" using namespace llvm; - -static void FormRecordChildNodes(OwningPtr &Matcher) { +static void ContractNodes(OwningPtr &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(N)) - FormRecordChildNodes(Push->getFailurePtr()); + ContractNodes(Push->getFailurePtr()); - // If we found a movechild node, check to see if our pattern matches. + // If we found a movechild node with a node that comes in a 'foochild' form, + // transform it. if (MoveChildMatcherNode *MC = dyn_cast(N)) { - if (RecordMatcherNode *RM = dyn_cast(MC->getNext())) - if (MoveParentMatcherNode *MP = - dyn_cast(RM->getNext())) { - MatcherNode *New - = new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor()); - New->setNext(MP->takeNext()); - Matcher.reset(New); - return FormRecordChildNodes(Matcher); - } + if (RecordMatcherNode *RM = dyn_cast(MC->getNext())) { + MatcherNode *New + = new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor()); + New->setNext(Matcher.take()); + Matcher.reset(New); + MC->setNext(RM->takeNext()); + return ContractNodes(Matcher); + } } - - FormRecordChildNodes(N->getNextPtr()); + + if (MoveChildMatcherNode *MC = dyn_cast(N)) + if (MoveParentMatcherNode *MP = + dyn_cast(MC->getNext())) { + Matcher.reset(MP->takeNext()); + return ContractNodes(Matcher); + } + + ContractNodes(N->getNextPtr()); } MatcherNode *llvm::OptimizeMatcher(MatcherNode *Matcher) { OwningPtr MatcherPtr(Matcher); - FormRecordChildNodes(MatcherPtr); + ContractNodes(MatcherPtr); return MatcherPtr.take(); } -- cgit v1.1