- // Handle complex pattern.
- const ComplexPattern &CP = CGP.getComplexPattern(LeafRec);
-
- // If we're at the root of the pattern, we have to check that the opcode
- // is a one of the ones requested to be matched.
- if (N == Pattern.getSrcPattern()) {
- const std::vector<Record*> &OpNodes = CP.getRootNodes();
- if (OpNodes.size() == 1) {
- AddMatcher(new CheckOpcodeMatcher(CGP.getSDNodeInfo(OpNodes[0])));
- } else if (!OpNodes.empty()) {
- SmallVector<const SDNodeInfo*, 4> OpNames;
- for (unsigned i = 0, e = OpNodes.size(); i != e; i++)
- OpNames.push_back(&CGP.getSDNodeInfo(OpNodes[i]));
- AddMatcher(new CheckMultiOpcodeMatcher(OpNames.data(), OpNames.size()));
- }
- }
-
- // Emit a CheckComplexPat operation, which does the match (aborting if it
- // fails) and pushes the matched operands onto the recorded nodes list.
- AddMatcher(new CheckComplexPatMatcher(CP));
-
- // Record the right number of operands.
- NextRecordedOperandNo += CP.getNumOperands();
- if (CP.hasProperty(SDNPHasChain))
- ++NextRecordedOperandNo; // Chained node operand.
-
- // If the complex pattern has a chain, then we need to keep track of the
- // fact that we just recorded a chain input. The chain input will be
- // matched as the last operand of the predicate if it was successful.
- if (CP.hasProperty(SDNPHasChain)) {
- // It is the last operand recorded.
- assert(NextRecordedOperandNo > 1 &&
- "Should have recorded input/result chains at least!");
- MatchedChainNodes.push_back(NextRecordedOperandNo-1);
-
- // If we need to check chains, do so, see comment for
- // "NodeHasProperty(SDNPHasChain" below.
- if (MatchedChainNodes.size() > 1) {
- // FIXME2: This is broken, we should eliminate this nonsense completely,
- // but we want to produce the same selections that the old matcher does
- // for now.
- unsigned PrevOp = MatchedChainNodes[MatchedChainNodes.size()-2];
- AddMatcher(new CheckChainCompatibleMatcher(PrevOp));
- }
- }
-
- // TODO: Complex patterns can't have output flags, if they did, we'd want
- // to record them.