From: Chris Lattner Date: Mon, 1 Mar 2010 02:24:17 +0000 (+0000) Subject: enhance RecordNode and RecordChild comments to indicate what X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0cebe6181af8a2cf5e6cf9497cda4c47b426a0f8;p=oota-llvm.git enhance RecordNode and RecordChild comments to indicate what slot they're recording into, no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97433 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index 2f26b924d74..657c41e5e11 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/utils/TableGen/DAGISelMatcher.h @@ -186,11 +186,16 @@ class RecordMatcher : public Matcher { /// WhatFor - This is a string indicating why we're recording this. This /// should only be used for comment generation not anything semantic. std::string WhatFor; + + /// ResultNo - The slot number in the RecordedNodes vector that this will be, + /// just printed as a comment. + unsigned ResultNo; public: - RecordMatcher(const std::string &whatfor) - : Matcher(RecordNode), WhatFor(whatfor) {} + RecordMatcher(const std::string &whatfor, unsigned resultNo) + : Matcher(RecordNode), WhatFor(whatfor), ResultNo(resultNo) {} const std::string &getWhatFor() const { return WhatFor; } + unsigned getResultNo() const { return ResultNo; } static inline bool classof(const Matcher *N) { return N->getKind() == RecordNode; @@ -212,13 +217,20 @@ class RecordChildMatcher : public Matcher { /// WhatFor - This is a string indicating why we're recording this. This /// should only be used for comment generation not anything semantic. std::string WhatFor; + + /// ResultNo - The slot number in the RecordedNodes vector that this will be, + /// just printed as a comment. + unsigned ResultNo; public: - RecordChildMatcher(unsigned childno, const std::string &whatfor) - : Matcher(RecordChild), ChildNo(childno), WhatFor(whatfor) {} + RecordChildMatcher(unsigned childno, const std::string &whatfor, + unsigned resultNo) + : Matcher(RecordChild), ChildNo(childno), WhatFor(whatfor), + ResultNo(resultNo) {} unsigned getChildNo() const { return ChildNo; } const std::string &getWhatFor() const { return WhatFor; } - + unsigned getResultNo() const { return ResultNo; } + static inline bool classof(const Matcher *N) { return N->getKind() == RecordChild; } diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp index 133157f0cc5..5b435fe4bae 100644 --- a/utils/TableGen/DAGISelMatcherEmitter.cpp +++ b/utils/TableGen/DAGISelMatcherEmitter.cpp @@ -183,14 +183,16 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx, case Matcher::RecordNode: OS << "OPC_RecordNode,"; - OS.PadToColumn(CommentIndent) << "// " + OS.PadToColumn(CommentIndent) << "// #" + << cast(N)->getResultNo() << " = " << cast(N)->getWhatFor() << '\n'; return 1; case Matcher::RecordChild: OS << "OPC_RecordChild" << cast(N)->getChildNo() << ','; - OS.PadToColumn(CommentIndent) << "// " + OS.PadToColumn(CommentIndent) << "// #" + << cast(N)->getResultNo() << " = " << cast(N)->getWhatFor() << '\n'; return 1; diff --git a/utils/TableGen/DAGISelMatcherGen.cpp b/utils/TableGen/DAGISelMatcherGen.cpp index d1984883059..5a253e8d202 100644 --- a/utils/TableGen/DAGISelMatcherGen.cpp +++ b/utils/TableGen/DAGISelMatcherGen.cpp @@ -225,7 +225,8 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) { // If we have a physreg reference like (mul gpr:$src, EAX) then we need to // record the register if (LeafRec->isSubClassOf("Register")) { - AddMatcher(new RecordMatcher("physreg input "+LeafRec->getName())); + AddMatcher(new RecordMatcher("physreg input "+LeafRec->getName(), + NextRecordedOperandNo)); PhysRegInputs.push_back(std::make_pair(LeafRec, NextRecordedOperandNo++)); return; } @@ -360,7 +361,8 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N, if (N->NodeHasProperty(SDNPHasChain, CGP)) { // Record the node and remember it in our chained nodes list. AddMatcher(new RecordMatcher("'" + N->getOperator()->getName() + - "' chained node")); + "' chained node", + NextRecordedOperandNo)); // Remember all of the input chains our pattern will match. MatchedChainNodes.push_back(NextRecordedOperandNo++); @@ -436,7 +438,8 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N, // Record the node and remember it in our chained nodes list. AddMatcher(new RecordMatcher("'" + N->getOperator()->getName() + - "' flag output node")); + "' flag output node", + NextRecordedOperandNo)); // Remember all of the nodes with output flags our pattern will match. MatchedFlagResultNodes.push_back(NextRecordedOperandNo++); } @@ -474,8 +477,8 @@ void MatcherGen::EmitMatchCode(const TreePatternNode *N, unsigned &VarMapEntry = VariableMap[N->getName()]; if (VarMapEntry == 0) { // If it is a named node, we must emit a 'Record' opcode. + AddMatcher(new RecordMatcher("$" + N->getName(), NextRecordedOperandNo)); VarMapEntry = ++NextRecordedOperandNo; - AddMatcher(new RecordMatcher("$" + N->getName())); } else { // If we get here, this is a second reference to a specific name. Since // we already have checked that the first reference is valid, we don't diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp index 11818279052..f8dfe6d82c5 100644 --- a/utils/TableGen/DAGISelMatcherOpt.cpp +++ b/utils/TableGen/DAGISelMatcherOpt.cpp @@ -43,7 +43,8 @@ static void ContractNodes(OwningPtr &MatcherPtr, if (MoveChildMatcher *MC = dyn_cast(N)) { Matcher *New = 0; if (RecordMatcher *RM = dyn_cast(MC->getNext())) - New = new RecordChildMatcher(MC->getChildNo(), RM->getWhatFor()); + New = new RecordChildMatcher(MC->getChildNo(), RM->getWhatFor(), + RM->getResultNo()); if (CheckTypeMatcher *CT= dyn_cast(MC->getNext())) New = new CheckChildTypeMatcher(MC->getChildNo(), CT->getType());