diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-28 02:41:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-28 02:41:25 +0000 |
commit | 6281cda6737bcda0e924318ddcce28392001691e (patch) | |
tree | 64517cb7065b497cd9de5775c003444220652181 /utils/TableGen | |
parent | e86097af5598e44727875f00e492d43c978239be (diff) | |
download | external_llvm-6281cda6737bcda0e924318ddcce28392001691e.zip external_llvm-6281cda6737bcda0e924318ddcce28392001691e.tar.gz external_llvm-6281cda6737bcda0e924318ddcce28392001691e.tar.bz2 |
enhance EmitNodeMatcher to keep track of the recorded slot numbers
it will populate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r-- | utils/TableGen/DAGISelMatcher.cpp | 2 | ||||
-rw-r--r-- | utils/TableGen/DAGISelMatcher.h | 11 | ||||
-rw-r--r-- | utils/TableGen/DAGISelMatcherEmitter.cpp | 16 | ||||
-rw-r--r-- | utils/TableGen/DAGISelMatcherGen.cpp | 3 | ||||
-rw-r--r-- | utils/TableGen/DAGISelMatcherOpt.cpp | 5 |
5 files changed, 26 insertions, 11 deletions
diff --git a/utils/TableGen/DAGISelMatcher.cpp b/utils/TableGen/DAGISelMatcher.cpp index d6f4f78..d939edb 100644 --- a/utils/TableGen/DAGISelMatcher.cpp +++ b/utils/TableGen/DAGISelMatcher.cpp @@ -172,7 +172,7 @@ void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, unsigned indent) const { void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned indent) const { OS.indent(indent); - OS << (isSelectNodeTo() ? "SelectNodeTo: " : "EmitNode: ") + OS << (isa<SelectNodeToMatcher>(this) ? "SelectNodeTo: " : "EmitNode: ") << OpcodeName << ": <todo flags> "; for (unsigned i = 0, e = VTs.size(); i != e; ++i) diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index 3d73262..b91b591 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/utils/TableGen/DAGISelMatcher.h @@ -893,8 +893,6 @@ public: HasChain(hasChain), HasFlag(hasFlag), HasMemRefs(hasmemrefs), NumFixedArityOperands(numfixedarityoperands) {} - bool isSelectNodeTo() const { return getKind() == SelectNodeTo; } - const std::string &getOpcodeName() const { return OpcodeName; } unsigned getNumVTs() const { return VTs.size(); } @@ -926,15 +924,18 @@ private: /// EmitNodeMatcher - This signals a successful match and generates a node. class EmitNodeMatcher : public EmitNodeMatcherCommon { + unsigned FirstResultSlot; public: EmitNodeMatcher(const std::string &opcodeName, const MVT::SimpleValueType *vts, unsigned numvts, const unsigned *operands, unsigned numops, bool hasChain, bool hasFlag, bool hasmemrefs, - int numfixedarityoperands) + int numfixedarityoperands, unsigned firstresultslot) : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain, - hasFlag, hasmemrefs, numfixedarityoperands, false) - {} + hasFlag, hasmemrefs, numfixedarityoperands, false), + FirstResultSlot(firstresultslot) {} + + unsigned getFirstResultSlot() const { return FirstResultSlot; } static inline bool classof(const Matcher *N) { return N->getKind() == EmitNode; diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp index 84e33f3..942a612 100644 --- a/utils/TableGen/DAGISelMatcherEmitter.cpp +++ b/utils/TableGen/DAGISelMatcherEmitter.cpp @@ -392,7 +392,7 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx, case Matcher::EmitNode: case Matcher::SelectNodeTo: { const EmitNodeMatcherCommon *EN = cast<EmitNodeMatcherCommon>(N); - OS << (EN->isSelectNodeTo() ? "OPC_EmitNode" : "OPC_SelectNodeTo"); + OS << (isa<EmitNodeMatcher>(EN) ? "OPC_EmitNode" : "OPC_SelectNodeTo"); OS << ", TARGET_OPCODE(" << EN->getOpcodeName() << "), 0"; if (EN->hasChain()) OS << "|OPFL_Chain"; @@ -413,6 +413,20 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx, // is too large to represent with a byte. NumOperandBytes += EmitVBRValue(EN->getOperand(i), OS); } + + // Print the result #'s for EmitNode. + if (const EmitNodeMatcher *E = dyn_cast<EmitNodeMatcher>(EN)) { + if (EN->getVT(0) != MVT::Flag && EN->getVT(0) != MVT::Other) { + OS.PadToColumn(CommentIndent) << "// Results = "; + unsigned First = E->getFirstResultSlot(); + for (unsigned i = 0, e = EN->getNumVTs(); i != e; ++i) { + if (EN->getVT(0) == MVT::Flag || EN->getVT(0) == MVT::Other) + break; + OS << "#" << First+i << " "; + } + } + } + OS << '\n'; return 6+EN->getNumVTs()+NumOperandBytes; } diff --git a/utils/TableGen/DAGISelMatcherGen.cpp b/utils/TableGen/DAGISelMatcherGen.cpp index ee38507..18735de 100644 --- a/utils/TableGen/DAGISelMatcherGen.cpp +++ b/utils/TableGen/DAGISelMatcherGen.cpp @@ -749,7 +749,8 @@ EmitResultInstructionAsOperand(const TreePatternNode *N, ResultVTs.data(), ResultVTs.size(), InstOps.data(), InstOps.size(), NodeHasChain, TreeHasInFlag, - NodeHasMemRefs, NumFixedArityOperands)); + NodeHasMemRefs, NumFixedArityOperands, + NextRecordedOperandNo)); // The non-chain and non-flag results of the newly emitted node get recorded. for (unsigned i = 0, e = ResultVTs.size(); i != e; ++i) { diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp index 7953457..12c4c1b 100644 --- a/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/utils/TableGen/DAGISelMatcherOpt.cpp @@ -66,10 +66,9 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr) { // Turn EmitNode->CompleteMatch into SelectNodeTo if we can. if (EmitNodeMatcher *EN = dyn_cast<EmitNodeMatcher>(N)) - if (CompleteMatchMatcher *CM = cast<CompleteMatchMatcher>(EN->getNext())) { + if (CompleteMatchMatcher *CM = + dyn_cast<CompleteMatchMatcher>(EN->getNext())) { (void)CM; - - } ContractNodes(N->getNextPtr()); |