mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-26 05:00:39 +00:00
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
This commit is contained in:
parent
e86097af55
commit
6281cda673
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user