From a5028a64634f995630e93390c5c23374a09a450f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 25 Feb 2010 06:53:39 +0000 Subject: [PATCH] factor the print method better. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97125 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelMatcher.cpp | 101 +++++++++++------------------- utils/TableGen/DAGISelMatcher.h | 68 ++++++++++---------- 2 files changed, 69 insertions(+), 100 deletions(-) diff --git a/utils/TableGen/DAGISelMatcher.cpp b/utils/TableGen/DAGISelMatcher.cpp index 4b1ae82f97d..e01292801c6 100644 --- a/utils/TableGen/DAGISelMatcher.cpp +++ b/utils/TableGen/DAGISelMatcher.cpp @@ -16,176 +16,148 @@ using namespace llvm; void Matcher::dump() const { - print(errs()); + print(errs(), 0); } -void Matcher::printNext(raw_ostream &OS, unsigned indent) const { +void Matcher::print(raw_ostream &OS, unsigned indent) const { + printImpl(OS, indent); if (Next) return Next->print(OS, indent); } -void ScopeMatcher::print(raw_ostream &OS, unsigned indent) const { +void ScopeMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "Scope\n"; Check->print(OS, indent+2); - printNext(OS, indent); } -void RecordMatcher::print(raw_ostream &OS, unsigned indent) const { +void RecordMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "Record\n"; - printNext(OS, indent); } -void RecordChildMatcher::print(raw_ostream &OS, unsigned indent) const { +void RecordChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "RecordChild: " << ChildNo << '\n'; - printNext(OS, indent); } -void RecordMemRefMatcher::print(raw_ostream &OS, unsigned indent) const { +void RecordMemRefMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "RecordMemRef\n"; - printNext(OS, indent); } -void CaptureFlagInputMatcher::print(raw_ostream &OS, unsigned indent) const{ +void CaptureFlagInputMatcher::printImpl(raw_ostream &OS, unsigned indent) const{ OS.indent(indent) << "CaptureFlagInput\n"; - printNext(OS, indent); } -void MoveChildMatcher::print(raw_ostream &OS, unsigned indent) const { +void MoveChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "MoveChild " << ChildNo << '\n'; - printNext(OS, indent); } -void MoveParentMatcher::print(raw_ostream &OS, unsigned indent) const { +void MoveParentMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "MoveParent\n"; - printNext(OS, indent); } -void CheckSameMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckSameMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckSame " << MatchNumber << '\n'; - printNext(OS, indent); } void CheckPatternPredicateMatcher:: -print(raw_ostream &OS, unsigned indent) const { +printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n'; - printNext(OS, indent); } -void CheckPredicateMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckPredicateMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckPredicate " << PredName << '\n'; - printNext(OS, indent); } -void CheckOpcodeMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n'; - printNext(OS, indent); } -void CheckMultiOpcodeMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckMultiOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const{ OS.indent(indent) << "CheckMultiOpcode \n"; - printNext(OS, indent); } -void CheckTypeMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n'; - printNext(OS, indent); } -void CheckChildTypeMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckChildTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckChildType " << ChildNo << " " << getEnumName(Type) << '\n'; - printNext(OS, indent); } -void CheckIntegerMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckIntegerMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckInteger " << Value << '\n'; - printNext(OS, indent); } -void CheckCondCodeMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckCondCodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n'; - printNext(OS, indent); } -void CheckValueTypeMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckValueTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n'; - printNext(OS, indent); } -void CheckComplexPatMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckComplexPatMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n'; - printNext(OS, indent); } -void CheckAndImmMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckAndImmMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckAndImm " << Value << '\n'; - printNext(OS, indent); } -void CheckOrImmMatcher::print(raw_ostream &OS, unsigned indent) const { +void CheckOrImmMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckOrImm " << Value << '\n'; - printNext(OS, indent); } -void CheckFoldableChainNodeMatcher::print(raw_ostream &OS, +void CheckFoldableChainNodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckFoldableChainNode\n"; - printNext(OS, indent); } -void CheckChainCompatibleMatcher::print(raw_ostream &OS, +void CheckChainCompatibleMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckChainCompatible " << PreviousOp << "\n"; - printNext(OS, indent); } -void EmitIntegerMatcher::print(raw_ostream &OS, unsigned indent) const { +void EmitIntegerMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "EmitInteger " << Val << " VT=" << VT << '\n'; - printNext(OS, indent); } void EmitStringIntegerMatcher:: -print(raw_ostream &OS, unsigned indent) const { +printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "EmitStringInteger " << Val << " VT=" << VT << '\n'; - printNext(OS, indent); } -void EmitRegisterMatcher::print(raw_ostream &OS, unsigned indent) const { +void EmitRegisterMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "EmitRegister "; if (Reg) OS << Reg->getName(); else OS << "zero_reg"; OS << " VT=" << VT << '\n'; - printNext(OS, indent); } void EmitConvertToTargetMatcher:: -print(raw_ostream &OS, unsigned indent) const { +printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "EmitConvertToTarget " << Slot << '\n'; - printNext(OS, indent); } void EmitMergeInputChainsMatcher:: -print(raw_ostream &OS, unsigned indent) const { +printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "EmitMergeInputChains \n"; - printNext(OS, indent); } -void EmitCopyToRegMatcher::print(raw_ostream &OS, unsigned indent) const { +void EmitCopyToRegMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "EmitCopyToReg \n"; - printNext(OS, indent); } -void EmitNodeXFormMatcher::print(raw_ostream &OS, unsigned indent) const { +void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "EmitNodeXForm " << NodeXForm->getName() << " Slot=" << Slot << '\n'; - printNext(OS, indent); } -void EmitNodeMatcher::print(raw_ostream &OS, unsigned indent) const { +void EmitNodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "EmitNode: " << OpcodeName << ": "; for (unsigned i = 0, e = VTs.size(); i != e; ++i) @@ -194,19 +166,16 @@ void EmitNodeMatcher::print(raw_ostream &OS, unsigned indent) const { for (unsigned i = 0, e = Operands.size(); i != e; ++i) OS << Operands[i] << ' '; OS << ")\n"; - printNext(OS, indent); } -void MarkFlagResultsMatcher::print(raw_ostream &OS, unsigned indent) const { +void MarkFlagResultsMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "MarkFlagResults \n"; - printNext(OS, indent); } -void CompleteMatchMatcher::print(raw_ostream &OS, unsigned indent) const { +void CompleteMatchMatcher::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CompleteMatch \n"; OS.indent(indent) << "Src = " << *Pattern.getSrcPattern() << "\n"; OS.indent(indent) << "Dst = " << *Pattern.getDstPattern() << "\n"; - printNext(OS, indent); } // getHashImpl Implementation. diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index 68132219bce..0bc44e7473c 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/utils/TableGen/DAGISelMatcher.h @@ -103,10 +103,10 @@ public: return (getHashImpl() << 4) ^ getKind(); } - virtual void print(raw_ostream &OS, unsigned indent = 0) const = 0; + void print(raw_ostream &OS, unsigned indent = 0) const; void dump() const; protected: - void printNext(raw_ostream &OS, unsigned indent) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const = 0; virtual bool isEqualImpl(const Matcher *M) const = 0; virtual unsigned getHashImpl() const = 0; }; @@ -132,7 +132,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return false; } virtual unsigned getHashImpl() const { return 0; } }; @@ -153,7 +153,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return true; } virtual unsigned getHashImpl() const { return 0; } }; @@ -179,7 +179,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->getChildNo() == getChildNo(); } @@ -196,7 +196,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return true; } virtual unsigned getHashImpl() const { return 0; } }; @@ -213,7 +213,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return true; } virtual unsigned getHashImpl() const { return 0; } }; @@ -232,7 +232,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->getChildNo() == getChildNo(); } @@ -250,7 +250,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return true; } virtual unsigned getHashImpl() const { return 0; } }; @@ -271,7 +271,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->getMatchNumber() == getMatchNumber(); } @@ -294,7 +294,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->getPredicate() == Predicate; } @@ -316,7 +316,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->PredName == PredName; } @@ -339,7 +339,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->OpcodeName == OpcodeName; } @@ -362,7 +362,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->OpcodeNames == OpcodeNames; } @@ -386,7 +386,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(this)->Type == Type; } @@ -410,7 +410,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->ChildNo == ChildNo && cast(M)->Type == Type; @@ -434,7 +434,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->Value == Value; } @@ -456,7 +456,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->CondCodeName == CondCodeName; } @@ -478,7 +478,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->TypeName == TypeName; } @@ -502,7 +502,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return &cast(M)->Pattern == &Pattern; } @@ -526,7 +526,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->Value == Value; } @@ -548,7 +548,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->Value == Value; } @@ -567,7 +567,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return true; } virtual unsigned getHashImpl() const { return 0; } }; @@ -587,7 +587,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(this)->PreviousOp == PreviousOp; } @@ -610,7 +610,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->Val == Val && cast(M)->VT == VT; @@ -635,7 +635,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->Val == Val && cast(M)->VT == VT; @@ -661,7 +661,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->Reg == Reg && cast(M)->VT == VT; @@ -687,7 +687,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->Slot == Slot; } @@ -716,7 +716,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->ChainNodes == ChainNodes; } @@ -741,7 +741,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->SrcSlot == SrcSlot && cast(M)->DestPhysReg == DestPhysReg; @@ -770,7 +770,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->Slot == Slot && cast(M)->NodeXForm == NodeXForm; @@ -826,7 +826,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const; virtual unsigned getHashImpl() const; }; @@ -852,7 +852,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->FlagResultNodes == FlagResultNodes; } @@ -880,7 +880,7 @@ public: } private: - virtual void print(raw_ostream &OS, unsigned indent = 0) const; + virtual void printImpl(raw_ostream &OS, unsigned indent) const; virtual bool isEqualImpl(const Matcher *M) const { return cast(M)->Results == Results && &cast(M)->Pattern == &Pattern; -- 2.34.1