[all-commits] [llvm/llvm-project] 07c157: [mlir] load dialect in parser for optional paramet...

Jeremy Kun via All-commits all-commits at lists.llvm.org
Sun Jul 7 09:44:28 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 07c157a43534744bff8b9cf03a5ec8d19717ba72
      https://github.com/llvm/llvm-project/commit/07c157a43534744bff8b9cf03a5ec8d19717ba72
  Author: Jeremy Kun <jkun at google.com>
  Date:   2024-07-07 (Sun, 07 Jul 2024)

  Changed paths:
    M mlir/include/mlir/IR/DialectImplementation.h
    M mlir/test/IR/parser.mlir
    A mlir/test/IR/parser_dialect_loading.mlir
    M mlir/test/lib/Dialect/Test/TestAttrDefs.td
    M mlir/test/lib/Dialect/Test/TestOps.td
    M mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
    M mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp

  Log Message:
  -----------
  [mlir] load dialect in parser for optional parameters (#96667)

https://github.com/llvm/llvm-project/pull/96242 fixed an issue where the
auto-generated parsers were not loading dialects whose namespaces are
not present in the textual IR. This required the attribute parameter to
be a tablegen def with its dialect information attached.

This fails when using parameter wrapper classes like
`OptionalParameter`. This came up because `RingAttr` uses
`OptionalParameter` for its second and third attributes.
`OptionalParameter` takes as input the C++ type as a string instead of
the tablegen def, and so it doesn't have a dialect member value to
trigger the fix from https://github.com/llvm/llvm-project/pull/96242.
The docs on this topic say the appropriate solution as overloading
`FieldParser` for a particular type.

This PR updates `FieldParser` for generic attributes to load the dialect
on demand. This requires `mlir-tblgen` to emit a `dialectName` static
field on the generated attribute class, and check for it with template
metaprogramming, since not all attribute types go through `mlir-tblgen`.

---------

Co-authored-by: Jeremy Kun <j2kun at users.noreply.github.com>
Co-authored-by: Oleksandr "Alex" Zinenko <ftynse at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list