MLIR
20.0.0git
|
Attributes are known-constant values of operations. More...
#include "mlir/IR/Attributes.h"
Public Types | |
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 |
Public Member Functions | |
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 Attribute | getFromOpaquePointer (const void *ptr) |
Construct an attribute from the opaque pointer representation. More... | |
Protected Attributes | |
ImplType * | impl {nullptr} |
Friends | |
::llvm::hash_code | hash_value (Attribute arg) |
Attributes are known-constant values of operations.
Instances of the Attribute class are references to immortal key-value pairs with immutable, uniqued keys owned by MLIRContext. As such, an Attribute is a thin wrapper around an underlying storage pointer. Attributes are usually passed by value.
Definition at line 25 of file Attributes.h.
Definition at line 35 of file Attributes.h.
using mlir::Attribute::AttrBase = detail::StorageUserBase<ConcreteType, BaseType, StorageType, detail::AttributeUniquer, Traits...> |
Utility class for implementing attributes.
Definition at line 30 of file Attributes.h.
Definition at line 33 of file Attributes.h.
using mlir::Attribute::ValueType = void |
Definition at line 34 of file Attributes.h.
|
constexprdefault |
Referenced by getFromOpaquePointer().
|
inline |
Definition at line 38 of file Attributes.h.
|
default |
U mlir::Attribute::cast |
Definition at line 194 of file Attributes.h.
void Attribute::dump | ( | ) | const |
Definition at line 3788 of file AsmPrinter.cpp.
U mlir::Attribute::dyn_cast |
Definition at line 184 of file Attributes.h.
U mlir::Attribute::dyn_cast_or_null |
Definition at line 189 of file Attributes.h.
|
inline |
Return the abstract descriptor for this attribute.
Definition at line 115 of file Attributes.h.
Referenced by mlir::AttributeInterface< ConcreteType, Traits >::getInterfaceFor(), hasTrait(), replaceImmediateSubElements(), mlir::irdl::BaseAttrConstraint::verify(), and walkImmediateSubElements().
|
inline |
Get an opaque pointer to the attribute.
Definition at line 91 of file Attributes.h.
References impl.
Referenced by llvm::PointerLikeTypeTraits< mlir::Attribute >::getAsVoidPointer().
MLIRContext * Attribute::getContext | ( | ) | const |
Return the context this attribute belongs to.
Definition at line 37 of file Attributes.cpp.
Referenced by mlir::NamedAttrList::append(), mlir::DistinctAttr::create(), emitDiag(), mlir::Operation::getContext(), mlir::OperationState::getContext(), injectGpuIndexOperations(), mlirAttributeGetType(), mlir::function_interface_impl::removeArgAttr(), mlir::function_interface_impl::removeResultAttr(), mlir::NamedAttrList::set(), mlir::function_interface_impl::setArgAttr(), and mlir::function_interface_impl::setResultAttr().
|
inline |
Get the dialect this attribute is registered to.
Definition at line 76 of file Attributes.h.
Referenced by mlir::AttributeInterface< ConcreteType, Traits >::getInterfaceFor(), hasPromiseOrImplementsInterface(), and mlir::detail::isSupportedMemorySpace().
|
inlinestatic |
Construct an attribute from the opaque pointer representation.
Definition at line 93 of file Attributes.h.
References Attribute().
Referenced by mlir::DiagnosticArgument::getAsAttribute(), llvm::PointerLikeTypeTraits< mlir::Attribute >::getFromVoidPointer(), and mlir::DenseElementsAttr::AttributeElementIterator::operator*().
|
inline |
Return the internal Attribute implementation.
Definition at line 162 of file Attributes.h.
References impl.
Referenced by llvm::CastInfo< To, From, std::enable_if_t< std::is_same_v< mlir::Attribute, std::remove_const_t< From > >||std::is_base_of_v< mlir::Attribute, From > > >::doCast(), llvm::CastInfo< To, From, std::enable_if_t< std::is_same_v< mlir::Location, std::remove_const_t< From > >||std::is_base_of_v< mlir::Location, From > > >::doCast(), and mlir::DistinctAttr::getReferencedAttr().
|
inline |
Return a unique identifier for the concrete attribute type.
This is used to support dynamic type casting.
Definition at line 70 of file Attributes.h.
Referenced by getBases(), mlir::AttributeInterface< ConcreteType, Traits >::getInterfaceFor(), hasPromiseOrImplementsInterface(), mlir::DynamicAttr::isa(), and mlir::irdl::BaseAttrConstraint::verify().
|
inline |
Returns true if InterfaceT
has been promised by the dialect or implemented.
Definition at line 102 of file Attributes.h.
References getDialect(), getTypeID(), and mlir::dialect_extension_detail::hasPromisedInterface().
|
inline |
Returns true if the type was registered with a particular trait.
Definition at line 110 of file Attributes.h.
References getAbstractAttribute(), and mlir::AbstractAttribute::hasTrait().
Referenced by mlir::DynamicAttr::classof(), and mlir::LocationAttr::classof().
bool mlir::Attribute::isa |
Casting utility functions.
These are deprecated and will be removed, please prefer using the llvm
namespace variants instead.
Definition at line 174 of file Attributes.h.
bool mlir::Attribute::isa_and_nonnull |
Definition at line 179 of file Attributes.h.
|
inlineexplicit |
Definition at line 46 of file Attributes.h.
References impl.
|
inline |
Definition at line 48 of file Attributes.h.
|
inline |
Definition at line 45 of file Attributes.h.
|
inline |
Definition at line 44 of file Attributes.h.
References impl.
void Attribute::print | ( | raw_ostream & | os, |
AsmState & | state, | ||
bool | elideType = false |
||
) | const |
Definition at line 3781 of file AsmPrinter.cpp.
void Attribute::print | ( | raw_ostream & | os, |
bool | elideType = false |
||
) | const |
Print the attribute.
If elideType
is set, the attribute is printed without a trailing colon type if it has one.
Definition at line 3772 of file AsmPrinter.cpp.
Referenced by mlir::operator<<(), mlir::detail::DenseArrayAttrImpl< T >::print(), and mlir::dataflow::ConstantValue::print().
void Attribute::printStripped | ( | raw_ostream & | os | ) | const |
Print the attribute without dialect wrapping.
Definition at line 3814 of file AsmPrinter.cpp.
void Attribute::printStripped | ( | raw_ostream & | os, |
AsmState & | state | ||
) | const |
Definition at line 3793 of file AsmPrinter.cpp.
|
inline |
Recursively replace all of the nested sub-attributes and sub-types using the provided map functions.
Returns nullptr in the case of failure. See AttrTypeReplacer
for information on the support replacement function types.
Definition at line 154 of file Attributes.h.
References mlir::detail::AttrTypeReplacerBase< Concrete >::addReplacement(), and mlir::AttrTypeReplacer::replace().
|
inline |
Replace the immediately nested sub-attributes and sub-types with those provided.
The order of the provided elements is derived from the order of the elements returned by the callbacks of walkImmediateSubElements
. The element at index 0 would replace the very first attribute given by walkImmediateSubElements
. On success, the new instance with the values replaced is returned. If replacement fails, nullptr is returned.
Definition at line 133 of file Attributes.h.
References getAbstractAttribute(), and mlir::AbstractAttribute::replaceImmediateSubElements().
|
inline |
Walk this attribute and all attibutes/types nested within using the provided walk functions.
See AttrTypeWalker
for information on the supported walk function types.
Definition at line 143 of file Attributes.h.
References mlir::AttrTypeWalker::addWalk(), and mlir::AttrTypeWalker::walk().
|
inline |
Walk all of the immediately nested sub-attributes and sub-types.
This method does not recurse into sub elements.
Definition at line 121 of file Attributes.h.
References getAbstractAttribute(), and mlir::AbstractAttribute::walkImmediateSubElements().
|
friend |
Definition at line 198 of file Attributes.h.
|
protected |
Definition at line 165 of file Attributes.h.
Referenced by getAsOpaquePointer(), getImpl(), mlir::DenseElementsAttr::getRawData(), mlir::DenseElementsAttr::getRawStringData(), mlir::DenseElementsAttr::getType(), mlir::DenseElementsAttr::isSplat(), operator bool(), and operator==().