[all-commits] [llvm/llvm-project] 629460: [mlir] Improve syntax of `distinct[n]<unit>`

Markus Böck via All-commits all-commits at lists.llvm.org
Thu Jul 13 23:27:23 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 629460a9b2e577a68d839b51f21351a03035d9ee
  Author: Markus Böck <markus.bock+llvm at nextsilicon.com>
  Date:   2023-07-14 (Fri, 14 Jul 2023)

  Changed paths:
    M mlir/lib/AsmParser/AttributeParser.cpp
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/IR/BuiltinDialect.cpp
    M mlir/test/IR/distinct-attr.mlir

  Log Message:
  [mlir] Improve syntax of `distinct[n]<unit>`

In cases where memory is of less of a concern (e.g. small attributes where all instances have to be distinct by definition), using `DistinctAttr` with a unit attribute is a useful and conscious way of generating deterministic unique IDs.
The syntax as is however, makes them less useful to use, as it 1) always prints `<unit>` at the back and 2) always aliases them leading to not very useful `#distinct = distinct[n]<unit>` lines in the printer output.

This patch fixes that by special casing `UnitAttr` to simply elide the `unit` attribute in the back and not printing it as alias in that case.

Differential Revision: https://reviews.llvm.org/D155162

More information about the All-commits mailing list