return 0;
}
- virtual bool CheckComplexPattern(SDNode *Root, SDValue N, unsigned PatternNo,
+ virtual bool CheckComplexPattern(SDNode *Root, SDNode *Parent, SDValue N,
+ unsigned PatternNo,
SmallVectorImpl<SDValue> &Result) {
assert(0 && "Tblgen should generate the implementation of this!");
return false;
unsigned CPNum = MatcherTable[MatcherIndex++];
unsigned RecNo = MatcherTable[MatcherIndex++];
assert(RecNo < RecordedNodes.size() && "Invalid CheckComplexPat");
- if (!CheckComplexPattern(NodeToMatch, RecordedNodes[RecNo], CPNum,
+ SDNode *Parent = 0;
+ if (NodeStack.size() > 1)
+ Parent = NodeStack[NodeStack.size()-2].getNode();
+
+ if (!CheckComplexPattern(NodeToMatch, Parent, RecordedNodes[RecNo], CPNum,
RecordedNodes))
break;
continue;
// Emit CompletePattern matchers.
// FIXME: This should be const.
if (!ComplexPatterns.empty()) {
- OS << "bool CheckComplexPattern(SDNode *Root, SDValue N,\n";
+ OS << "bool CheckComplexPattern(SDNode *Root, SDNode *Parent, SDValue N,\n";
OS << " unsigned PatternNo, SmallVectorImpl<SDValue> &Result) {\n";
OS << " unsigned NextRes = Result.size();\n";
OS << " switch (PatternNo) {\n";
if (P.hasProperty(SDNPWantRoot))
OS << "Root, ";
+ // If the complex pattern wants the parent of the operand being matched,
+ // pass it in as the next argument.
+ if (P.hasProperty(SDNPWantParent))
+ OS << "Parent, ";
+
OS << "N";
for (unsigned i = 0; i != NumOps; ++i)
OS << ", Result[NextRes+" << i << ']';