mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
rename PushMatcherNode -> ScopeMatcherNode to more accurately
reflect what it does. Switch the sense of the Next and the Check arms to be more logical. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97093 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -219,7 +219,7 @@ GetVBR(unsigned Val, const unsigned char *MatcherTable, unsigned &Idx) {
|
|||||||
|
|
||||||
|
|
||||||
enum BuiltinOpcodes {
|
enum BuiltinOpcodes {
|
||||||
OPC_Push, OPC_Push2,
|
OPC_Scope, OPC_Scope2,
|
||||||
OPC_RecordNode,
|
OPC_RecordNode,
|
||||||
OPC_RecordChild0, OPC_RecordChild1, OPC_RecordChild2, OPC_RecordChild3,
|
OPC_RecordChild0, OPC_RecordChild1, OPC_RecordChild2, OPC_RecordChild3,
|
||||||
OPC_RecordChild4, OPC_RecordChild5, OPC_RecordChild6, OPC_RecordChild7,
|
OPC_RecordChild4, OPC_RecordChild5, OPC_RecordChild6, OPC_RecordChild7,
|
||||||
@@ -372,7 +372,7 @@ SDNode *SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
|||||||
assert(MatcherIndex < TableSize && "Invalid index");
|
assert(MatcherIndex < TableSize && "Invalid index");
|
||||||
BuiltinOpcodes Opcode = (BuiltinOpcodes)MatcherTable[MatcherIndex++];
|
BuiltinOpcodes Opcode = (BuiltinOpcodes)MatcherTable[MatcherIndex++];
|
||||||
switch (Opcode) {
|
switch (Opcode) {
|
||||||
case OPC_Push: {
|
case OPC_Scope: {
|
||||||
unsigned NumToSkip = MatcherTable[MatcherIndex++];
|
unsigned NumToSkip = MatcherTable[MatcherIndex++];
|
||||||
MatchScope NewEntry;
|
MatchScope NewEntry;
|
||||||
NewEntry.FailIndex = MatcherIndex+NumToSkip;
|
NewEntry.FailIndex = MatcherIndex+NumToSkip;
|
||||||
@@ -386,7 +386,7 @@ SDNode *SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
|||||||
MatchScopes.push_back(NewEntry);
|
MatchScopes.push_back(NewEntry);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OPC_Push2: {
|
case OPC_Scope2: {
|
||||||
unsigned NumToSkip = GetInt2(MatcherTable, MatcherIndex);
|
unsigned NumToSkip = GetInt2(MatcherTable, MatcherIndex);
|
||||||
MatchScope NewEntry;
|
MatchScope NewEntry;
|
||||||
NewEntry.FailIndex = MatcherIndex+NumToSkip;
|
NewEntry.FailIndex = MatcherIndex+NumToSkip;
|
||||||
|
@@ -1972,7 +1972,7 @@ void DAGISelEmitter::run(raw_ostream &OS) {
|
|||||||
if (Matcher == 0)
|
if (Matcher == 0)
|
||||||
Matcher = N;
|
Matcher = N;
|
||||||
else
|
else
|
||||||
Matcher = new PushMatcherNode(N, Matcher);
|
Matcher = new ScopeMatcherNode(N, Matcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matcher = OptimizeMatcher(Matcher);
|
Matcher = OptimizeMatcher(Matcher);
|
||||||
|
@@ -24,10 +24,10 @@ void MatcherNode::printNext(raw_ostream &OS, unsigned indent) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const {
|
void ScopeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
|
||||||
OS.indent(indent) << "Push\n";
|
OS.indent(indent) << "Scope\n";
|
||||||
printNext(OS, indent+2);
|
Check->print(OS, indent+2);
|
||||||
Failure->print(OS, indent);
|
printNext(OS, indent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const {
|
void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const {
|
||||||
|
@@ -39,7 +39,7 @@ class MatcherNode {
|
|||||||
public:
|
public:
|
||||||
enum KindTy {
|
enum KindTy {
|
||||||
// Matcher state manipulation.
|
// Matcher state manipulation.
|
||||||
Push, // Push a checking scope.
|
Scope, // Push a checking scope.
|
||||||
RecordNode, // Record the current node.
|
RecordNode, // Record the current node.
|
||||||
RecordChild, // Record a child of the current node.
|
RecordChild, // Record a child of the current node.
|
||||||
RecordMemRef, // Record the memref in the current node.
|
RecordMemRef, // Record the memref in the current node.
|
||||||
@@ -100,24 +100,24 @@ protected:
|
|||||||
void printNext(raw_ostream &OS, unsigned indent) const;
|
void printNext(raw_ostream &OS, unsigned indent) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// PushMatcherNode - This pushes a failure scope on the stack and evaluates
|
/// ScopeMatcherNode - This pushes a failure scope on the stack and evaluates
|
||||||
/// 'Next'. If 'Next' fails to match, it pops its scope and attempts to
|
/// 'Check'. If 'Check' fails to match, it pops its scope and continues on to
|
||||||
/// match 'Failure'.
|
/// 'Next'.
|
||||||
class PushMatcherNode : public MatcherNode {
|
class ScopeMatcherNode : public MatcherNode {
|
||||||
OwningPtr<MatcherNode> Failure;
|
OwningPtr<MatcherNode> Check;
|
||||||
public:
|
public:
|
||||||
PushMatcherNode(MatcherNode *next = 0, MatcherNode *failure = 0)
|
ScopeMatcherNode(MatcherNode *check = 0, MatcherNode *next = 0)
|
||||||
: MatcherNode(Push), Failure(failure) {
|
: MatcherNode(Scope), Check(check) {
|
||||||
setNext(next);
|
setNext(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
MatcherNode *getFailure() { return Failure.get(); }
|
MatcherNode *getCheck() { return Check.get(); }
|
||||||
const MatcherNode *getFailure() const { return Failure.get(); }
|
const MatcherNode *getCheck() const { return Check.get(); }
|
||||||
void setFailure(MatcherNode *N) { Failure.reset(N); }
|
void setCheck(MatcherNode *N) { Check.reset(N); }
|
||||||
OwningPtr<MatcherNode> &getFailurePtr() { return Failure; }
|
OwningPtr<MatcherNode> &getCheckPtr() { return Check; }
|
||||||
|
|
||||||
static inline bool classof(const MatcherNode *N) {
|
static inline bool classof(const MatcherNode *N) {
|
||||||
return N->getKind() == Push;
|
return N->getKind() == Scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void print(raw_ostream &OS, unsigned indent = 0) const;
|
virtual void print(raw_ostream &OS, unsigned indent = 0) const;
|
||||||
|
@@ -155,7 +155,7 @@ EmitMatcher(const MatcherNode *N, unsigned Indent, formatted_raw_ostream &OS) {
|
|||||||
OS.PadToColumn(Indent*2);
|
OS.PadToColumn(Indent*2);
|
||||||
|
|
||||||
switch (N->getKind()) {
|
switch (N->getKind()) {
|
||||||
case MatcherNode::Push: assert(0 && "Should be handled by caller");
|
case MatcherNode::Scope: assert(0 && "Should be handled by caller");
|
||||||
case MatcherNode::RecordNode:
|
case MatcherNode::RecordNode:
|
||||||
OS << "OPC_RecordNode,";
|
OS << "OPC_RecordNode,";
|
||||||
OS.PadToColumn(CommentIndent) << "// "
|
OS.PadToColumn(CommentIndent) << "// "
|
||||||
@@ -388,8 +388,8 @@ EmitMatcherList(const MatcherNode *N, unsigned Indent, unsigned CurrentIdx,
|
|||||||
Histogram.resize(N->getKind()+1);
|
Histogram.resize(N->getKind()+1);
|
||||||
Histogram[N->getKind()]++;
|
Histogram[N->getKind()]++;
|
||||||
|
|
||||||
// Push is a special case since it is binary.
|
// Scope is a special case since it is binary.
|
||||||
if (const PushMatcherNode *PMN = dyn_cast<PushMatcherNode>(N)) {
|
if (const ScopeMatcherNode *SMN = dyn_cast<ScopeMatcherNode>(N)) {
|
||||||
// We need to encode the child and the offset of the failure code before
|
// We need to encode the child and the offset of the failure code before
|
||||||
// emitting either of them. Handle this by buffering the output into a
|
// emitting either of them. Handle this by buffering the output into a
|
||||||
// string while we get the size.
|
// string while we get the size.
|
||||||
@@ -398,7 +398,7 @@ EmitMatcherList(const MatcherNode *N, unsigned Indent, unsigned CurrentIdx,
|
|||||||
{
|
{
|
||||||
raw_svector_ostream OS(TmpBuf);
|
raw_svector_ostream OS(TmpBuf);
|
||||||
formatted_raw_ostream FOS(OS);
|
formatted_raw_ostream FOS(OS);
|
||||||
NextSize = EmitMatcherList(cast<PushMatcherNode>(N)->getNext(),
|
NextSize = EmitMatcherList(cast<ScopeMatcherNode>(N)->getCheck(),
|
||||||
Indent+1, CurrentIdx+2, FOS);
|
Indent+1, CurrentIdx+2, FOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +408,7 @@ EmitMatcherList(const MatcherNode *N, unsigned Indent, unsigned CurrentIdx,
|
|||||||
TmpBuf.clear();
|
TmpBuf.clear();
|
||||||
raw_svector_ostream OS(TmpBuf);
|
raw_svector_ostream OS(TmpBuf);
|
||||||
formatted_raw_ostream FOS(OS);
|
formatted_raw_ostream FOS(OS);
|
||||||
NextSize = EmitMatcherList(cast<PushMatcherNode>(N)->getNext(),
|
NextSize = EmitMatcherList(cast<ScopeMatcherNode>(N)->getCheck(),
|
||||||
Indent+1, CurrentIdx+3, FOS);
|
Indent+1, CurrentIdx+3, FOS);
|
||||||
if (NextSize > 65535) {
|
if (NextSize > 65535) {
|
||||||
errs() <<
|
errs() <<
|
||||||
@@ -421,14 +421,14 @@ EmitMatcherList(const MatcherNode *N, unsigned Indent, unsigned CurrentIdx,
|
|||||||
OS.PadToColumn(Indent*2);
|
OS.PadToColumn(Indent*2);
|
||||||
|
|
||||||
if (NextSize < 256)
|
if (NextSize < 256)
|
||||||
OS << "OPC_Push, " << NextSize << ",\n";
|
OS << "OPC_Scope, " << NextSize << ",\n";
|
||||||
else
|
else
|
||||||
OS << "OPC_Push2, " << (NextSize&255) << ", " << (NextSize>>8) << ",\n";
|
OS << "OPC_Scope2, " << (NextSize&255) << ", " << (NextSize>>8) <<",\n";
|
||||||
OS << TmpBuf.str();
|
OS << TmpBuf.str();
|
||||||
|
|
||||||
Size += 2+NextSize;
|
Size += 2+NextSize;
|
||||||
CurrentIdx += 2+NextSize;
|
CurrentIdx += 2+NextSize;
|
||||||
N = PMN->getFailure();
|
N = SMN->getNext();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,7 +514,7 @@ void MatcherTableEmitter::EmitHistogram(formatted_raw_ostream &OS) {
|
|||||||
for (unsigned i = 0, e = Histogram.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Histogram.size(); i != e; ++i) {
|
||||||
OS << " // #";
|
OS << " // #";
|
||||||
switch ((MatcherNode::KindTy)i) {
|
switch ((MatcherNode::KindTy)i) {
|
||||||
case MatcherNode::Push: OS << "OPC_Push"; break;
|
case MatcherNode::Scope: OS << "OPC_Scope"; break;
|
||||||
case MatcherNode::RecordNode: OS << "OPC_RecordNode"; break;
|
case MatcherNode::RecordNode: OS << "OPC_RecordNode"; break;
|
||||||
case MatcherNode::RecordChild: OS << "OPC_RecordChild"; break;
|
case MatcherNode::RecordChild: OS << "OPC_RecordChild"; break;
|
||||||
case MatcherNode::RecordMemRef: OS << "OPC_RecordMemRef"; break;
|
case MatcherNode::RecordMemRef: OS << "OPC_RecordMemRef"; break;
|
||||||
|
@@ -14,14 +14,14 @@
|
|||||||
#include "DAGISelMatcher.h"
|
#include "DAGISelMatcher.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static void ContractNodes(OwningPtr<MatcherNode> &Matcher) {
|
static void ContractNodes(OwningPtr<MatcherNode> &MatcherPtr) {
|
||||||
// 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 = MatcherPtr.get();
|
||||||
if (N == 0) return;
|
if (N == 0) return;
|
||||||
|
|
||||||
// If we have a push node, walk down both edges.
|
// If we have a scope node, walk down both edges.
|
||||||
if (PushMatcherNode *Push = dyn_cast<PushMatcherNode>(N))
|
if (ScopeMatcherNode *Push = dyn_cast<ScopeMatcherNode>(N))
|
||||||
ContractNodes(Push->getFailurePtr());
|
ContractNodes(Push->getCheckPtr());
|
||||||
|
|
||||||
// If we found a movechild node with a node that comes in a 'foochild' form,
|
// If we found a movechild node with a node that comes in a 'foochild' form,
|
||||||
// transform it.
|
// transform it.
|
||||||
@@ -35,25 +35,24 @@ static void ContractNodes(OwningPtr<MatcherNode> &Matcher) {
|
|||||||
|
|
||||||
if (New) {
|
if (New) {
|
||||||
// Insert the new node.
|
// Insert the new node.
|
||||||
New->setNext(Matcher.take());
|
New->setNext(MatcherPtr.take());
|
||||||
Matcher.reset(New);
|
MatcherPtr.reset(New);
|
||||||
// Remove the old one.
|
// Remove the old one.
|
||||||
MC->setNext(MC->getNext()->takeNext());
|
MC->setNext(MC->getNext()->takeNext());
|
||||||
return ContractNodes(Matcher);
|
return ContractNodes(MatcherPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MoveChildMatcherNode *MC = dyn_cast<MoveChildMatcherNode>(N))
|
if (MoveChildMatcherNode *MC = dyn_cast<MoveChildMatcherNode>(N))
|
||||||
if (MoveParentMatcherNode *MP =
|
if (MoveParentMatcherNode *MP =
|
||||||
dyn_cast<MoveParentMatcherNode>(MC->getNext())) {
|
dyn_cast<MoveParentMatcherNode>(MC->getNext())) {
|
||||||
Matcher.reset(MP->takeNext());
|
MatcherPtr.reset(MP->takeNext());
|
||||||
return ContractNodes(Matcher);
|
return ContractNodes(MatcherPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContractNodes(N->getNextPtr());
|
ContractNodes(N->getNextPtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MatcherNode *llvm::OptimizeMatcher(MatcherNode *Matcher) {
|
MatcherNode *llvm::OptimizeMatcher(MatcherNode *Matcher) {
|
||||||
OwningPtr<MatcherNode> MatcherPtr(Matcher);
|
OwningPtr<MatcherNode> MatcherPtr(Matcher);
|
||||||
ContractNodes(MatcherPtr);
|
ContractNodes(MatcherPtr);
|
||||||
|
Reference in New Issue
Block a user