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

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Fri Jun 28 14:44:16 PDT 2024


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

I wonder if it would be possible to get the TypeID of the attribute class (there should be a static method) and somehow use it to find the dialect instead of relying on the textual name. Not sure if it is possible, I suspect we populate attribute TypeID maps when loading the dialect and here the dialect hasn't been loaded yet...

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


More information about the Mlir-commits mailing list