[Mlir-commits] [mlir] [mlir] load dialect in parser for optional parameters (PR #96667)

Jeremy Kun llvmlistbot at llvm.org
Fri Jun 28 15:22:56 PDT 2024


================
@@ -63,6 +78,9 @@ struct FieldParser<
     AttributeT, std::enable_if_t<std::is_base_of<Attribute, AttributeT>::value,
                                  AttributeT>> {
   static FailureOr<AttributeT> parse(AsmParser &parser) {
+    if constexpr (HasStaticDialectName<AttributeT>::value) {
+      parser.getContext()->getOrLoadDialect(AttributeT::dialectName);
+    }
----------------
j2kun wrote:

You mean a diagnostic? It seems that quite a few builtin attributes have this property (BoolAttr, e.g.,), so I'm not sure what one could do if they saw such a diagnostic... If we want to ensure all attributes have a dialectName string for this purpose, we could add it as a virtual method on `Attribute`. I don't have a strong opinion, I just tried to do the least invasive solution I could manage.

https://github.com/llvm/llvm-project/pull/96667


More information about the Mlir-commits mailing list