[llvm-commits] [llvm] r97051 - /llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
Chris Lattner
sabre at nondot.org
Wed Feb 24 11:52:48 PST 2010
Author: lattner
Date: Wed Feb 24 13:52:48 2010
New Revision: 97051
URL: http://llvm.org/viewvc/llvm-project?rev=97051&view=rev
Log:
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.
Modified:
llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
Modified: llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp?rev=97051&r1=97050&r2=97051&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp Wed Feb 24 13:52:48 2010
@@ -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();
}
More information about the llvm-commits
mailing list