Skip to content

Commit e1dc3d4

Browse files
River707memfrob
authored andcommitted
[mlir][ASM] Refactor how attribute/type aliases are specified.
Previously they were separated into "instance" and "kind" aliases, and also required that the dialect know ahead of time all of the instances that would have a corresponding alias. This approach was very clunky and not ergonomic to interact with. The new approach is to provide the dialect with an instance of an attribute/type to provide an alias for, fully replacing the original split approach. Differential Revision: https://reviews.llvm.org/D89354
1 parent e0f899c commit e1dc3d4

13 files changed

+331
-286
lines changed

mlir/include/mlir/IR/OpImplementation.h

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -801,21 +801,17 @@ class OpAsmDialectInterface
801801
public:
802802
OpAsmDialectInterface(Dialect *dialect) : Base(dialect) {}
803803

804-
/// Hooks for getting identifier aliases for symbols. The identifier is used
805-
/// in place of the symbol when printing textual IR.
806-
///
807-
/// Hook for defining Attribute kind aliases. This will generate an alias for
808-
/// all attributes of the given kind in the form : <alias>[0-9]+. These
809-
/// aliases must not contain `.`.
810-
virtual void getAttributeKindAliases(
811-
SmallVectorImpl<std::pair<TypeID, StringRef>> &aliases) const {}
812-
/// Hook for defining Attribute aliases. These aliases must not contain `.` or
813-
/// end with a numeric digit([0-9]+).
814-
virtual void getAttributeAliases(
815-
SmallVectorImpl<std::pair<Attribute, StringRef>> &aliases) const {}
816-
/// Hook for defining Type aliases.
817-
virtual void
818-
getTypeAliases(SmallVectorImpl<std::pair<Type, StringRef>> &aliases) const {}
804+
/// Hooks for getting an alias identifier alias for a given symbol, that is
805+
/// not necessarily a part of this dialect. The identifier is used in place of
806+
/// the symbol when printing textual IR. These aliases must not contain `.` or
807+
/// end with a numeric digit([0-9]+). Returns success if an alias was
808+
/// provided, failure otherwise.
809+
virtual LogicalResult getAlias(Attribute attr, raw_ostream &os) const {
810+
return failure();
811+
}
812+
virtual LogicalResult getAlias(Type type, raw_ostream &os) const {
813+
return failure();
814+
}
819815

820816
/// Get a special name to use when printing the given operation. See
821817
/// OpAsmInterface.td#getAsmResultNames for usage details and documentation.

0 commit comments

Comments
 (0)