fix a long standing wart: all the ComplexPattern's were being
[oota-llvm.git] / utils / TableGen / DAGISelMatcherEmitter.cpp
index dfbfe80c0a1d0771fb9b4c69944629c7c4b2dcb7..5117737c5f00a20ed32d47215f21acb67efd27c6 100644 (file)
@@ -649,7 +649,13 @@ void MatcherTableEmitter::EmitPredicateFunctions(formatted_raw_ostream &OS) {
       OS << "    Result.resize(NextRes+" << NumOps << ");\n";
       OS << "    return "  << P.getSelectFunc();
 
-      OS << "(Root, N";
+      OS << "(";
+      // If the complex pattern wants the root of the match, pass it in as the
+      // first argument.
+      if (P.hasProperty(SDNPWantRoot))
+        OS << "Root, ";
+      
+      OS << "N";
       for (unsigned i = 0; i != NumOps; ++i)
         OS << ", Result[NextRes+" << i << ']';
       OS << ");\n";