}
-void EmitNodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
- OS.indent(indent) << "EmitNode: " << OpcodeName << ": <todo flags> ";
+void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned indent) const {
+ OS.indent(indent);
+ OS << (isSelectNodeTo() ? "SelectNodeTo: " : "EmitNode: ")
+ << OpcodeName << ": <todo flags> ";
for (unsigned i = 0, e = VTs.size(); i != e; ++i)
OS << ' ' << getEnumName(VTs[i]);
return HashUnsigneds(ChainNodes.begin(), ChainNodes.end());
}
-bool EmitNodeMatcher::isEqualImpl(const Matcher *m) const {
- const EmitNodeMatcher *M = cast<EmitNodeMatcher>(m);
+bool EmitNodeMatcherCommon::isEqualImpl(const Matcher *m) const {
+ const EmitNodeMatcherCommon *M = cast<EmitNodeMatcherCommon>(m);
return M->OpcodeName == OpcodeName && M->VTs == VTs &&
M->Operands == Operands && M->HasChain == HasChain &&
M->HasFlag == HasFlag && M->HasMemRefs == HasMemRefs &&
M->NumFixedArityOperands == NumFixedArityOperands;
}
-unsigned EmitNodeMatcher::getHashImpl() const {
+unsigned EmitNodeMatcherCommon::getHashImpl() const {
return (HashString(OpcodeName) << 4) | Operands.size();
}
EmitNode, // Create a DAG node
EmitNodeXForm, // Run a SDNodeXForm
MarkFlagResults, // Indicate which interior nodes have flag results.
- CompleteMatch // Finish a match and update the results.
+ CompleteMatch, // Finish a match and update the results.
+ SelectNodeTo // Build a node, finish a match and update results.
};
const KindTy Kind;
}
};
-/// EmitNodeMatcher - This signals a successful match and generates a node.
-class EmitNodeMatcher : public Matcher {
+/// EmitNodeMatcherCommon - Common class shared between EmitNode and
+/// SelectNodeTo.
+class EmitNodeMatcherCommon : public Matcher {
std::string OpcodeName;
const SmallVector<MVT::SimpleValueType, 3> VTs;
const SmallVector<unsigned, 6> Operands;
/// operands in the root of the pattern. The rest are appended to this node.
int NumFixedArityOperands;
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)
- : Matcher(EmitNode), OpcodeName(opcodeName),
+ EmitNodeMatcherCommon(const std::string &opcodeName,
+ const MVT::SimpleValueType *vts, unsigned numvts,
+ const unsigned *operands, unsigned numops,
+ bool hasChain, bool hasFlag, bool hasmemrefs,
+ int numfixedarityoperands, bool isSelectNodeTo)
+ : Matcher(isSelectNodeTo ? SelectNodeTo : EmitNode), OpcodeName(opcodeName),
VTs(vts, vts+numvts), Operands(operands, operands+numops),
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(); }
int getNumFixedArityOperands() const { return NumFixedArityOperands; }
static inline bool classof(const Matcher *N) {
- return N->getKind() == EmitNode;
+ return N->getKind() == EmitNode || N->getKind() == SelectNodeTo;
}
private:
virtual unsigned getHashImpl() const;
};
+/// EmitNodeMatcher - This signals a successful match and generates a node.
+class EmitNodeMatcher : public EmitNodeMatcherCommon {
+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)
+ : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain,
+ hasFlag, hasmemrefs, numfixedarityoperands, false)
+ {}
+
+ static inline bool classof(const Matcher *N) {
+ return N->getKind() == EmitNode;
+ }
+
+};
+
+class SelectNodeToMatcher : public EmitNodeMatcherCommon {
+ const PatternToMatch &Pattern;
+public:
+ SelectNodeToMatcher(const std::string &opcodeName,
+ const MVT::SimpleValueType *vts, unsigned numvts,
+ const unsigned *operands, unsigned numops,
+ bool hasChain, bool hasFlag, bool hasmemrefs,
+ int numfixedarityoperands, const PatternToMatch &pattern)
+ : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain,
+ hasFlag, hasmemrefs, numfixedarityoperands, true),
+ Pattern(pattern) {
+ }
+
+ const PatternToMatch &getPattern() const { return Pattern; }
+
+ static inline bool classof(const Matcher *N) {
+ return N->getKind() == SelectNodeTo;
+ }
+};
+
/// MarkFlagResultsMatcher - This node indicates which non-root nodes in the
/// pattern produce flags. This allows CompleteMatchMatcher to update them
/// with the output flag of the resultant code.
}
virtual unsigned getHashImpl() const;
};
-
+
} // end namespace llvm
#endif
return 3;
}
- case Matcher::EmitNode: {
- const EmitNodeMatcher *EN = cast<EmitNodeMatcher>(N);
- OS << "OPC_EmitNode, TARGET_OPCODE(" << EN->getOpcodeName() << "), 0";
+ case Matcher::EmitNode:
+ case Matcher::SelectNodeTo: {
+ const EmitNodeMatcherCommon *EN = cast<EmitNodeMatcherCommon>(N);
+ OS << (EN->isSelectNodeTo() ? "OPC_EmitNode" : "OPC_SelectNodeTo");
+ OS << ", TARGET_OPCODE(" << EN->getOpcodeName() << "), 0";
if (EN->hasChain()) OS << "|OPFL_Chain";
if (EN->hasFlag()) OS << "|OPFL_Flag";
case Matcher::EmitMergeInputChains: OS << "OPC_EmitMergeInputChains"; break;
case Matcher::EmitCopyToReg: OS << "OPC_EmitCopyToReg"; break;
case Matcher::EmitNode: OS << "OPC_EmitNode"; break;
+ case Matcher::SelectNodeTo: OS << "OPC_SelectNodeTo"; break;
case Matcher::EmitNodeXForm: OS << "OPC_EmitNodeXForm"; break;
case Matcher::MarkFlagResults: OS << "OPC_MarkFlagResults"; break;
case Matcher::CompleteMatch: OS << "OPC_CompleteMatch"; break;