mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
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
This commit is contained in:
parent
e177c9a9bc
commit
22c48b384c
@ -14,35 +14,41 @@
|
|||||||
#include "DAGISelMatcher.h"
|
#include "DAGISelMatcher.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
static void ContractNodes(OwningPtr<MatcherNode> &Matcher) {
|
||||||
static void FormRecordChildNodes(OwningPtr<MatcherNode> &Matcher) {
|
|
||||||
// If we reached the end of the chain, we're done.
|
// If we reached the end of the chain, we're done.
|
||||||
MatcherNode *N = Matcher.get();
|
MatcherNode *N = Matcher.get();
|
||||||
if (N == 0) return;
|
if (N == 0) return;
|
||||||
|
|
||||||
// If we have a push node, walk down both edges.
|
// If we have a push node, walk down both edges.
|
||||||
if (PushMatcherNode *Push = dyn_cast<PushMatcherNode>(N))
|
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 (MoveChildMatcherNode *MC = dyn_cast<MoveChildMatcherNode>(N)) {
|
||||||
if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(MC->getNext()))
|
if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(MC->getNext())) {
|
||||||
if (MoveParentMatcherNode *MP =
|
MatcherNode *New
|
||||||
dyn_cast<MoveParentMatcherNode>(RM->getNext())) {
|
= new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor());
|
||||||
MatcherNode *New
|
New->setNext(Matcher.take());
|
||||||
= new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor());
|
Matcher.reset(New);
|
||||||
New->setNext(MP->takeNext());
|
MC->setNext(RM->takeNext());
|
||||||
Matcher.reset(New);
|
return ContractNodes(Matcher);
|
||||||
return FormRecordChildNodes(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) {
|
MatcherNode *llvm::OptimizeMatcher(MatcherNode *Matcher) {
|
||||||
OwningPtr<MatcherNode> MatcherPtr(Matcher);
|
OwningPtr<MatcherNode> MatcherPtr(Matcher);
|
||||||
FormRecordChildNodes(MatcherPtr);
|
ContractNodes(MatcherPtr);
|
||||||
return MatcherPtr.take();
|
return MatcherPtr.take();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user