[Mlir-commits] [mlir] [mlir] load dialects for non-namespaced attrs (PR #94838)

Jeremy Kun llvmlistbot at llvm.org
Sat Jun 15 19:37:28 PDT 2024


j2kun wrote:

> generated parser not loading the dialect on the fly

@joker-eph could you point me to where this parser is generated? Should it be loading the dialect in the parser for `IntPolynomialAttr`, or for the container attribute?

I tried this and it didn't seem to do anything

```
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -711,12 +711,16 @@ void DefGenerator::emitTypeDefList(ArrayRef<AttrOrTypeDef> defs) {
 /// {0}: the dialect fully qualified class name.
 /// {1}: the optional code for the dynamic attribute parser dispatch.
 /// {2}: the optional code for the dynamic attribute printer dispatch.
 static const char *const dialectDefaultAttrPrinterParserDispatch = R"(
 /// Parse an attribute registered to this dialect.
 ::mlir::Attribute {0}::parseAttribute(::mlir::DialectAsmParser &parser,
                                       ::mlir::Type type) const {{
   ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
   ::llvm::StringRef attrTag;
+  getContext()->getOrLoadDialect<{0}>();
   {{
     ::mlir::Attribute attr;
     auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
```

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


More information about the Mlir-commits mailing list