From bd8227f5298f0ab7b96203a6d3875e5d26573376 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 18 Feb 2010 02:53:41 +0000 Subject: [PATCH] rename the child field to 'next'. This is not a parent/child relationship, this is a linear list relationship. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96561 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelMatcher.cpp | 42 ++++++++++++------------ utils/TableGen/DAGISelMatcher.h | 18 +++++----- utils/TableGen/DAGISelMatcherEmitter.cpp | 24 +++++++------- utils/TableGen/DAGISelMatcherGen.cpp | 6 ++-- 4 files changed, 46 insertions(+), 44 deletions(-) diff --git a/utils/TableGen/DAGISelMatcher.cpp b/utils/TableGen/DAGISelMatcher.cpp index c6d18ce7dd2..8b8c9bf98a1 100644 --- a/utils/TableGen/DAGISelMatcher.cpp +++ b/utils/TableGen/DAGISelMatcher.cpp @@ -22,98 +22,98 @@ void EmitNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "EmitNode: Dst = " << *Pattern.getDstPattern() << "\n"; } -void MatcherNode::printChild(raw_ostream &OS, unsigned indent) const { - if (Child) - return Child->print(OS, indent); - OS.indent(indent) << "\n"; +void MatcherNode::printNext(raw_ostream &OS, unsigned indent) const { + if (Next) + return Next->print(OS, indent); + OS.indent(indent) << "\n"; } void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "Push\n"; - printChild(OS, indent+2); + printNext(OS, indent+2); Failure->print(OS, indent); } void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "Record\n"; - printChild(OS, indent); + printNext(OS, indent); } void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "MoveChild " << ChildNo << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "MoveParent\n"; - printChild(OS, indent); + printNext(OS, indent); } void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckSame " << MatchNumber << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckPatternPredicateMatcherNode:: print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckPredicate " << PredName << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckInteger " << Value << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckAndImm " << Value << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckOrImm " << Value << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckFoldableChainNode\n"; - printChild(OS, indent); + printNext(OS, indent); } void CheckChainCompatibleMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckChainCompatibleMatcherNode " << PreviousOp << "\n"; - printChild(OS, indent); + printNext(OS, indent); } diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index 4eb11010de9..41fbcb4c84a 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/utils/TableGen/DAGISelMatcher.h @@ -31,7 +31,9 @@ void EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &OS); /// MatcherNode - Base class for all the the DAG ISel Matcher representation /// nodes. class MatcherNode { - OwningPtr Child; + // The next matcher node that is executed after this one. Null if this is the + // last stage of a match. + OwningPtr Next; public: enum KindTy { EmitNode, @@ -63,16 +65,16 @@ public: KindTy getKind() const { return Kind; } - MatcherNode *getChild() { return Child.get(); } - const MatcherNode *getChild() const { return Child.get(); } - void setChild(MatcherNode *C) { Child.reset(C); } + MatcherNode *getNext() { return Next.get(); } + const MatcherNode *getNext() const { return Next.get(); } + void setNext(MatcherNode *C) { Next.reset(C); } static inline bool classof(const MatcherNode *) { return true; } virtual void print(raw_ostream &OS, unsigned indent = 0) const = 0; void dump() const; protected: - void printChild(raw_ostream &OS, unsigned indent) const; + void printNext(raw_ostream &OS, unsigned indent) const; }; /// EmitNodeMatcherNode - This signals a successful match and generates a node. @@ -93,14 +95,14 @@ public: /// PushMatcherNode - This pushes a failure scope on the stack and evaluates -/// 'child'. If 'child' fails to match, it pops its scope and attempts to +/// 'Next'. If 'Next' fails to match, it pops its scope and attempts to /// match 'Failure'. class PushMatcherNode : public MatcherNode { OwningPtr Failure; public: - PushMatcherNode(MatcherNode *child = 0, MatcherNode *failure = 0) + PushMatcherNode(MatcherNode *next = 0, MatcherNode *failure = 0) : MatcherNode(Push), Failure(failure) { - setChild(child); + setNext(next); } MatcherNode *getFailure() { return Failure.get(); } diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp index ea134fe9d2f..5d468194d79 100644 --- a/utils/TableGen/DAGISelMatcherEmitter.cpp +++ b/utils/TableGen/DAGISelMatcherEmitter.cpp @@ -76,7 +76,7 @@ class MatcherTableEmitter { public: MatcherTableEmitter(formatted_raw_ostream &os) : OS(os) {} - unsigned EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent); + unsigned EmitMatcherList(const MatcherNode *N, unsigned Indent); void EmitPredicateFunctions(); private: @@ -217,9 +217,9 @@ EmitMatcher(const MatcherNode *N, unsigned Indent) { return 0; } -/// EmitMatcherAndChildren - Emit the bytes for the specified matcher subtree. +/// EmitMatcherList - Emit the bytes for the specified matcher subtree. unsigned MatcherTableEmitter:: -EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent) { +EmitMatcherList(const MatcherNode *N, unsigned Indent) { unsigned Size = 0; while (N) { // Push is a special case since it is binary. @@ -228,25 +228,25 @@ EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent) { // emitting either of them. Handle this by buffering the output into a // string while we get the size. SmallString<128> TmpBuf; - unsigned ChildSize; + unsigned NextSize; { raw_svector_ostream OS(TmpBuf); formatted_raw_ostream FOS(OS); - ChildSize = - EmitMatcherAndChildren(cast(N)->getChild(),Indent+1); + NextSize = EmitMatcherList(cast(N)->getNext(), + Indent+1); } - if (ChildSize > 255) { + if (NextSize > 255) { errs() << "Tblgen internal error: can't handle predicate this complex yet\n"; exit(1); } OS.PadToColumn(Indent*2); - OS << "OPC_Push, " << ChildSize << ",\n"; + OS << "OPC_Push, " << NextSize << ",\n"; OS << TmpBuf.str(); - Size += 2 + ChildSize; + Size += 2 + NextSize; N = PMN->getFailure(); continue; @@ -254,9 +254,9 @@ EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent) { Size += EmitMatcher(N, Indent); - // If there are children of this node, iterate to them, otherwise we're + // If there are other nodes in this list, iterate to them, otherwise we're // done. - N = N->getChild(); + N = N->getNext(); } return Size; } @@ -311,7 +311,7 @@ void llvm::EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &O) { MatcherTableEmitter MatcherEmitter(OS); OS << " static const unsigned char MatcherTable[] = {\n"; - unsigned TotalSize = MatcherEmitter.EmitMatcherAndChildren(Matcher, 2); + unsigned TotalSize = MatcherEmitter.EmitMatcherList(Matcher, 2); OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n"; OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n"; OS << "\n"; diff --git a/utils/TableGen/DAGISelMatcherGen.cpp b/utils/TableGen/DAGISelMatcherGen.cpp index abe0d2a6f84..53f248e6923 100644 --- a/utils/TableGen/DAGISelMatcherGen.cpp +++ b/utils/TableGen/DAGISelMatcherGen.cpp @@ -38,7 +38,7 @@ namespace { MatcherNode *Matcher; /// CurPredicate - As we emit matcher nodes, this points to the latest check - /// which should have future checks stuck into its child position. + /// which should have future checks stuck into its Next position. MatcherNode *CurPredicate; public: MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp); @@ -109,7 +109,7 @@ void MatcherGen::InferPossibleTypes() { /// AddMatcherNode - Add a matcher node to the current graph we're building. void MatcherGen::AddMatcherNode(MatcherNode *NewNode) { if (CurPredicate != 0) - CurPredicate->setChild(NewNode); + CurPredicate->setNext(NewNode); else Matcher = NewNode; CurPredicate = NewNode; @@ -389,7 +389,7 @@ MatcherNode *llvm::ConvertPatternToMatcher(const PatternToMatch &Pattern, // Link it into the pattern. if (MatcherNode *Pred = Gen.GetCurPredicate()) { - Pred->setChild(Result); + Pred->setNext(Result); return Gen.GetMatcher(); } -- 2.34.1