summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-24 19:52:48 +0000
committerChris Lattner <sabre@nondot.org>2010-02-24 19:52:48 +0000
commit22c48b384cdb691150f520c78dcecb6134e5edb0 (patch)
tree9693120a1f0ab2550a69b5aa5bc8dc40b93506ee /utils
parente177c9a9bcd84ca654427b869900c858a9a48e1a (diff)
downloadllvm-22c48b384cdb691150f520c78dcecb6134e5edb0.tar.gz
llvm-22c48b384cdb691150f520c78dcecb6134e5edb0.tar.bz2
llvm-22c48b384cdb691150f520c78dcecb6134e5edb0.tar.xz
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
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/DAGISelMatcherOpt.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp
index d3658202a6..408bd63e33 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<MatcherNode> &Matcher) {
+static void ContractNodes(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());
+ 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<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);
- }
+ if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(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<MoveChildMatcherNode>(N))
+ if (MoveParentMatcherNode *MP =
+ dyn_cast<MoveParentMatcherNode>(MC->getNext())) {
+ Matcher.reset(MP->takeNext());
+ return ContractNodes(Matcher);
+ }
+
+ ContractNodes(N->getNextPtr());
}
MatcherNode *llvm::OptimizeMatcher(MatcherNode *Matcher) {
OwningPtr<MatcherNode> MatcherPtr(Matcher);
- FormRecordChildNodes(MatcherPtr);
+ ContractNodes(MatcherPtr);
return MatcherPtr.take();
}