[mlir] ODS: temporarily disbale external model in presence of extra class declarations
authorAlex Zinenko <zinenko@google.com>
Wed, 16 Jun 2021 10:12:36 +0000 (12:12 +0200)
committerAlex Zinenko <zinenko@google.com>
Wed, 16 Jun 2021 10:18:56 +0000 (12:18 +0200)
Default implementations of interfaces may rely on extra class
declarations, which aren't currently generated in the external model,
that in turn may rely on functions defined in the main Attribute/Type
class, which wouldn't be available on the external model.

mlir/tools/mlir-tblgen/OpInterfacesGen.cpp

index 3fdaf6d..d4b4cd1 100644 (file)
@@ -241,10 +241,17 @@ void InterfaceGenerator::emitModelDecl(Interface &interface) {
     os << "  };\n";
   }
 
-  // Emit the template for the external model.
   os << "  template<typename ConcreteModel, typename " << valueTemplate
      << ">\n";
   os << "  class ExternalModel : public FallbackModel<ConcreteModel> {\n";
+
+  // Emit the template for the external model if there are no extra class
+  // declarations.
+  if (interface.getExtraClassDeclaration()) {
+    os << "  };\n";
+    return;
+  }
+
   os << "  public:\n";
 
   // Emit declarations for methods that have default implementations. Other
@@ -338,6 +345,9 @@ void InterfaceGenerator::emitModelMethodsDef(Interface &interface) {
   }
 
   // Emit default implementations for the external model.
+  if (interface.getExtraClassDeclaration())
+    return;
+
   for (auto &method : interface.getMethods()) {
     if (!method.getDefaultImplementation())
       continue;