MLIR
20.0.0git
|
An attribute that associates a referenced attribute with a unique identifier. More...
#include "mlir/IR/BuiltinAttributes.h"
Public Member Functions | |
Attribute | getReferencedAttr () const |
Returns the referenced attribute. More... | |
Public Member Functions inherited from mlir::detail::StorageUserBase< DistinctAttr, Attribute, detail::DistinctAttrStorage, detail::DistinctAttributeUniquer > | |
ImplType * | getImpl () const |
Utility for easy access to the storage instance. More... | |
Public Member Functions inherited from mlir::Attribute | |
constexpr | Attribute ()=default |
Attribute (const ImplType *impl) | |
Attribute (const Attribute &other)=default | |
Attribute & | operator= (const Attribute &other)=default |
bool | operator== (Attribute other) const |
bool | operator!= (Attribute other) const |
operator bool () const | |
bool | operator! () const |
template<typename... Tys> | |
bool | isa () const |
Casting utility functions. More... | |
template<typename... Tys> | |
bool | isa_and_nonnull () const |
template<typename U > | |
U | dyn_cast () const |
template<typename U > | |
U | dyn_cast_or_null () const |
template<typename U > | |
U | cast () const |
TypeID | getTypeID () |
Return a unique identifier for the concrete attribute type. More... | |
MLIRContext * | getContext () const |
Return the context this attribute belongs to. More... | |
Dialect & | getDialect () const |
Get the dialect this attribute is registered to. More... | |
void | print (raw_ostream &os, bool elideType=false) const |
Print the attribute. More... | |
void | print (raw_ostream &os, AsmState &state, bool elideType=false) const |
void | dump () const |
void | printStripped (raw_ostream &os) const |
Print the attribute without dialect wrapping. More... | |
void | printStripped (raw_ostream &os, AsmState &state) const |
const void * | getAsOpaquePointer () const |
Get an opaque pointer to the attribute. More... | |
template<typename InterfaceT > | |
bool | hasPromiseOrImplementsInterface () |
Returns true if InterfaceT has been promised by the dialect or implemented. More... | |
template<template< typename T > class Trait> | |
bool | hasTrait () |
Returns true if the type was registered with a particular trait. More... | |
const AbstractTy & | getAbstractAttribute () const |
Return the abstract descriptor for this attribute. More... | |
void | walkImmediateSubElements (function_ref< void(Attribute)> walkAttrsFn, function_ref< void(Type)> walkTypesFn) const |
Walk all of the immediately nested sub-attributes and sub-types. More... | |
auto | replaceImmediateSubElements (ArrayRef< Attribute > replAttrs, ArrayRef< Type > replTypes) const |
Replace the immediately nested sub-attributes and sub-types with those provided. More... | |
template<WalkOrder Order = WalkOrder::PostOrder, typename... WalkFns> | |
auto | walk (WalkFns &&...walkFns) |
Walk this attribute and all attibutes/types nested within using the provided walk functions. More... | |
template<typename... ReplacementFns> | |
auto | replace (ReplacementFns &&...replacementFns) |
Recursively replace all of the nested sub-attributes and sub-types using the provided map functions. More... | |
ImplType * | getImpl () const |
Return the internal Attribute implementation. More... | |
Static Public Member Functions | |
static DistinctAttr | create (Attribute referencedAttr) |
Creates a distinct attribute that associates a referenced attribute with a unique identifier. More... | |
Static Public Member Functions inherited from mlir::detail::StorageUserBase< DistinctAttr, Attribute, detail::DistinctAttrStorage, detail::DistinctAttributeUniquer > | |
static TypeID | getTypeID () |
Return a unique identifier for the concrete type. More... | |
static bool | classof (T val) |
Provide an implementation of 'classof' that compares the type id of the provided value with that of the concrete type. More... | |
static detail::InterfaceMap | getInterfaceMap () |
Returns an interface map for the interfaces registered to this storage user. More... | |
static HasTraitFn | getHasTraitFn () |
Returns the function that returns true if the given Trait ID matches the IDs of any of the traits defined by the storage user. More... | |
static auto | getWalkImmediateSubElementsFn () |
Returns a function that walks immediate sub elements of a given instance of the storage user. More... | |
static auto | getReplaceImmediateSubElementsFn () |
Returns a function that replaces immediate sub elements of a given instance of the storage user. More... | |
static void | attachInterface (MLIRContext &context) |
Attach the given models as implementations of the corresponding interfaces for the concrete storage user class. More... | |
static DistinctAttr | get (MLIRContext *ctx, Args &&...args) |
Get or create a new ConcreteT instance within the ctx. More... | |
static DistinctAttr | getChecked (const Location &loc, Args &&...args) |
Get or create a new ConcreteT instance within the ctx, defined at the given, potentially unknown, location. More... | |
static DistinctAttr | getChecked (function_ref< InFlightDiagnostic()> emitErrorFn, MLIRContext *ctx, Args... args) |
Get or create a new ConcreteT instance within the ctx. More... | |
static DistinctAttr | getFromOpaquePointer (const void *ptr) |
Get an instance of the concrete type from a void pointer. More... | |
Static Public Member Functions inherited from mlir::Attribute | |
static Attribute | getFromOpaquePointer (const void *ptr) |
Construct an attribute from the opaque pointer representation. More... | |
Static Public Attributes | |
static constexpr StringLiteral | name = "builtin.distinct" |
Additional Inherited Members | |
Public Types inherited from mlir::detail::StorageUserBase< DistinctAttr, Attribute, detail::DistinctAttrStorage, detail::DistinctAttributeUniquer > | |
using | Base = StorageUserBase< DistinctAttr, Attribute, detail::DistinctAttrStorage, detail::DistinctAttributeUniquer, Traits... > |
Utility declarations for the concrete attribute class. More... | |
using | ImplType = detail::DistinctAttrStorage |
using | HasTraitFn = bool(*)(TypeID) |
Public Types inherited from mlir::Attribute | |
template<typename ConcreteType , typename BaseType , typename StorageType , template< typename T > class... Traits> | |
using | AttrBase = detail::StorageUserBase< ConcreteType, BaseType, StorageType, detail::AttributeUniquer, Traits... > |
Utility class for implementing attributes. More... | |
using | ImplType = AttributeStorage |
using | ValueType = void |
using | AbstractTy = AbstractAttribute |
Protected Member Functions inherited from mlir::detail::StorageUserBase< DistinctAttr, Attribute, detail::DistinctAttrStorage, detail::DistinctAttributeUniquer > | |
LogicalResult | mutate (Args &&...args) |
Mutate the current storage instance. More... | |
Static Protected Member Functions inherited from mlir::detail::StorageUserBase< DistinctAttr, Attribute, detail::DistinctAttrStorage, detail::DistinctAttributeUniquer > | |
static LogicalResult | verifyInvariants (Args... args) |
Default implementation that just returns success. More... | |
Protected Attributes inherited from mlir::Attribute | |
ImplType * | impl {nullptr} |
An attribute that associates a referenced attribute with a unique identifier.
Every call to the create function allocates a new distinct attribute instance. The address of the attribute instance serves as a temporary identifier. Similar to the names of SSA values, the final identifiers are generated during pretty printing. This delayed numbering ensures the printed identifiers are deterministic even if multiple distinct attribute instances are created in-parallel.
Examples:
#distinct = distinct[0]<42.0 : f32> #distinct1 = distinct[1]<42.0 : f32> #distinct2 = distinct[2]<array<i32: 10, 42>>
NOTE: The distinct attribute cannot be defined using ODS since it uses a custom distinct attribute uniquer that cannot be set from ODS.
Definition at line 1034 of file BuiltinAttributes.h.
|
static |
Creates a distinct attribute that associates a referenced attribute with a unique identifier.
Definition at line 1782 of file BuiltinAttributes.cpp.
References mlir::get(), and mlir::Attribute::getContext().
Referenced by addScopeToFunction(), mlirDisctinctAttrCreate(), and mlir::detail::Parser::parseDistinctAttr().
Attribute DistinctAttr::getReferencedAttr | ( | ) | const |
Returns the referenced attribute.
Definition at line 1786 of file BuiltinAttributes.cpp.
References mlir::Attribute::getImpl().
|
staticconstexpr |
Definition at line 1048 of file BuiltinAttributes.h.