[all-commits] [llvm/llvm-project] 3c64f8: [mlir] Add OpAsmTypeInterface for pretty-print (#1...

Hongren Zheng via All-commits all-commits at lists.llvm.org
Mon Jan 27 21:32:02 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3c64f86314fbf9a3cd578419f16e621a4de57eaa
      https://github.com/llvm/llvm-project/commit/3c64f86314fbf9a3cd578419f16e621a4de57eaa
  Author: Hongren Zheng <i at zenithal.me>
  Date:   2025-01-28 (Tue, 28 Jan 2025)

  Changed paths:
    M mlir/include/mlir/IR/CMakeLists.txt
    M mlir/include/mlir/IR/OpAsmInterface.td
    M mlir/include/mlir/IR/OpImplementation.h
    M mlir/lib/IR/AsmPrinter.cpp
    A mlir/test/IR/op-asm-interface.mlir
    M mlir/test/lib/Dialect/Test/TestOpDefs.cpp
    M mlir/test/lib/Dialect/Test/TestOps.td
    M mlir/test/lib/Dialect/Test/TestTypeDefs.td
    M mlir/test/lib/Dialect/Test/TestTypes.cpp

  Log Message:
  -----------
  [mlir] Add OpAsmTypeInterface for pretty-print (#121187)

See
https://discourse.llvm.org/t/rfc-introduce-opasm-type-attr-interface-for-pretty-print-in-asmprinter/83792
for detailed introduction.

This PR acts as the first part of it
* Add `OpAsmTypeInterface` and `getAsmName` API for deducing ASM name
from type
* Add default impl in `OpAsmOpInterface` to respect this API when
available.

The `OpAsmAttrInterface` / hooking into Alias system part should be
another PR, using a `getAlias` API.

### Discussion

* Instead of using `StringRef getAsmName()` as the API, I use `void
getAsmName(OpAsmSetNameFn)`, as returning StringRef might be unsafe
(std::string constructed inside then returned a _ref_; and this aligns
with the design of `getAsmResultNames`.
* On the result packing of an op, the current approach is that when not
all of the result types are `OpAsmTypeInterface`, then do nothing (old
default impl)

### Review 

Cc @j2kun and @Alexanderviand-intel for downstream; Cc @River707 and
@joker-eph for relevent commit history; Cc @ftynse for discourse.



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