[Mlir-commits] [mlir] [mlir] Enable setting alias on AsmState. (PR #153776)

Jacques Pienaar llvmlistbot at llvm.org
Mon Aug 18 01:32:12 PDT 2025


================
@@ -560,6 +560,15 @@ class AsmState {
            FallbackAsmResourceMap *map = nullptr);
   ~AsmState();
 
+  /// Add an alias for the given attribute. The alias will be used as a
+  /// suggestion when printing. The final alias may be modified to resolve
+  /// conflicts.
+  void addAlias(Attribute attr, StringRef alias);
+
+  /// Add an alias for the given type. The alias will be used as a suggestion
+  /// when printing. The final alias may be modified to resolve conflicts.
+  void addAlias(Type type, StringRef alias);
+
----------------
jpienaar wrote:

The application here in fact does. E.g., the type itself & dialect doesn't know the use, but the application does. So, as an upstream example, you have a tensor of size of quantized type with loads of params. The dialect and generic hooks can't do much as this is just regular tensor from builtin dialect. But in the application, it knows the user considers it the "jtensor" (to pick a name) that is used everywhere. The builtin dialect assigns no special meaning to it, its only in the application/user context where it has one. So enables giving concise & application relevant aliases even where no generic ones apply. And here it is often the mapping from entry function signature that captures this mapping, so it is easy to populate mapping.

Its not something generic for the type that is, so a type attribute interface would not match. That being said, I did consider creating a aliasinghelper dialect with interface and injecting, but this would then require mutating map before printing (in a thread safe manner) and I don't think one can override that of another dialect like this (could be wrong, this may only be true for those with final alias set).

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


More information about the Mlir-commits mailing list