1. Feb 02, 2024
    • Markus Böck's avatar
      [mlir] Start moving some builtin type formats to the dialect · e67e980c
      Markus Böck authored
      Most types and attributes in the builtin dialect are parsed and printed using special-purpose printers and parsers for that type. They also use the low-level `Printer` rather than the `AsmPrinter`, making the implementations inconsistent compared to all other dialects in MLIR.
      
      This PR starts moving some builtin types to be parsed using the usual `print` and `parse` methods like all other MLIR dialects. This has the following advantages:
      * The implementation now looks like any other dialect's types
      * It is now possible to use `assemblyFormat` for builtin types and attributes
      * The code can be easily moved to other dialects if desired
      * Arguably better layering and less code
      * As a side-effect, it is now also possible to write `!builtin.<type>` for any types moved
      
      A future benefit would include being able to print types and attributes in stripped format as well (e.g. `<f32>` vs `complex<f32>`), just like all other dialect types and attributes. This is currently explicitly disabled as it causes a LOT of changes in IR syntax and I believe some ambiguities in the parser.
      
      For the purpose of reviewing and incremental development, this PR only moves `tuple`, `tensor`, `none`, `memref` and `complex`. The plan is to eventually move all attributes and types where the current syntax can be implemented within the dialect.
      
      For backwards compatibility with the existing syntax, the builtin dialect is special-cased in the printer where the `builtin.` prefix is omitted.
      e67e980c
    • Markus Böck's avatar
      clang-format · f9f2f00d
      Markus Böck authored
      f9f2f00d
    • Markus Böck's avatar
      [mlir] Add `Print(Attr|Type)Qualified` trait · 94c47995
      Markus Böck authored
      This PR adds a new trait to attributes and types that force the use of the qualified syntax for attributes and types. More concretely, any attribute or type with the trait must be parsed and printed with the `dialect.mnemonic` prefix.
      
      The motivation for this PR is the dependent PR where it is used to retain backwards-compatibility of syntax, but downstream projects may also use the trait if the subjectively prefer the verbose syntax.
      94c47995
  2. Feb 01, 2024