[mlir][tblgen] Reverting fatality of assemblyFormat with skipDefaultBuilders=1
authorwren romano <2998727+wrengr@users.noreply.github.com>
Wed, 6 Jul 2022 22:42:53 +0000 (15:42 -0700)
committerwren romano <2998727+wrengr@users.noreply.github.com>
Thu, 7 Jul 2022 01:07:39 +0000 (18:07 -0700)
Per @rriddle, we do not want to require `skipDefaultBuilders=0` per se; that is, even though the `assemblyFormat`-generated parser requires a builder with the same prototype as the default-builder, that prototype could instead be implemented via custom `builders`.  This differential reduces the FatalError introduced in D128555 to a non-fatal Warning instead, so that users can still be informed of the error condition (rather than waiting for the C++ compiler to fail).

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D129234

mlir/lib/TableGen/AttrOrTypeDef.cpp

index 67dc24b2335cde26a95db4616866be0b81636a40..477e624ba2a516eaaafaeceefe0c0fd5fbaf3da9 100644 (file)
@@ -81,11 +81,13 @@ AttrOrTypeDef::AttrOrTypeDef(const llvm::Record *def) : def(def) {
                     "'assemblyFormat' or 'hasCustomAssemblyFormat' can only be "
                     "used when 'mnemonic' is set");
   }
-  // Assembly format parser requires default builders to be generated.
+  // Assembly format parser requires builders with the same prototype
+  // as the default-builders.
+  // TODO: attempt to detect when a custom builder matches the prototype.
   if (hasDeclarativeFormat && skipDefaultBuilders()) {
-    PrintFatalError(
-        getLoc(),
-        "'assemblyFormat' requires 'skipDefaultBuilders' to be false");
+    PrintWarning(getLoc(),
+                 "using 'assemblyFormat' with 'skipDefaultBuilders=1' may "
+                 "result in C++ compilation errors");
   }
   // Assembly format printer requires accessors to be generated.
   if (hasDeclarativeFormat && !genAccessors()) {