Skip to content

Commit

Permalink
[mlir][ASM] Refactor how attribute/type aliases are specified.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
River707 committed Oct 30, 2020
1 parent 1455259 commit a463ea5
Show file tree
Hide file tree
Showing 13 changed files with 331 additions and 286 deletions.
26 changes: 11 additions & 15 deletions mlir/include/mlir/IR/OpImplementation.h
Expand Up @@ -801,21 +801,17 @@ class OpAsmDialectInterface
public:
OpAsmDialectInterface(Dialect *dialect) : Base(dialect) {}

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

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

0 comments on commit a463ea5

Please sign in to comment.