When matching patterns that have a complex pattern as their root, make
authorChris Lattner <sabre@nondot.org>
Mon, 22 Feb 2010 22:18:05 +0000 (22:18 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 22 Feb 2010 22:18:05 +0000 (22:18 +0000)
sure to only run the complex pattern on nodes where the target opts in.
This patch only handles targets with one opcode specified so far, but
fixes 16 failures, only 34 left.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96813 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/DAGISelMatcherGen.cpp

index 1ba3391235ca4b68a2f825e64e6cff406919604c..c9138538cad70f2265d9cdccc8e81127058a1e5e 100644 (file)
@@ -239,9 +239,24 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
       errs() << "We expect complex pattern uses to have names: " << *N << "\n";
       exit(1);
     }
-    
+
     // 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) {
+        StringRef OpName = CGP.getSDNodeInfo(OpNodes[0]).getEnumName();
+        AddMatcherNode(new CheckOpcodeMatcherNode(OpName));
+      } else if (!OpNodes.empty()) {
+        for (unsigned j = 0, e = OpNodes.size(); j != e; j++) {
+          // .getOpcodeName(OpNodes[j], CGP)
+        }
+      }
+    }
+    
     AddMatcherNode(new CheckComplexPatMatcherNode(CP));
     
     // If the complex pattern has a chain, then we need to keep track of the