[Mlir-commits] [mlir] [mlir] Add OpAsmTypeInterface for pretty-print (PR #121187)

River Riddle llvmlistbot at llvm.org
Mon Jan 13 09:34:12 PST 2025


================
@@ -50,10 +50,27 @@ def OpAsmOpInterface : OpInterface<"OpAsmOpInterface"> {
         ```mlir
           %first_result, %middle_results:2, %0 = "my.op" ...
         ```
+
+        The default implementation uses `OpAsmTypeInterface` to get the name for
+        each result from its type.
+
+        If not all of the result types have `OpAsmTypeInterface`, the default implementation
+        does nothing, as the packing behavior should be decided by the operation itself.
       }],
       "void", "getAsmResultNames",
       (ins "::mlir::OpAsmSetValueNameFn":$setNameFn),
-      "", "return;"
+      "", [{
+        bool hasOpAsmTypeInterface = llvm::all_of($_op->getResults(), [&](Value result) {
----------------
River707 wrote:

Can you split this into a different PR? It'd be nice to add the TypeInterface by itself before using it for value names.

I also think it'd be better to move this new "default" behavior to the OpAsmPrinter file, not the interface here.

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


More information about the Mlir-commits mailing list