MLIR  15.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
mlir::Attribute Class Reference

Attributes are known-constant values of operations. More...

#include "mlir/IR/Attributes.h"

+ Inheritance diagram for mlir::Attribute:
+ Collaboration diagram for mlir::Attribute:

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 ()
 
 Attribute (const ImplType *impl)
 
 Attribute (const Attribute &other)=default
 
Attributeoperator= (const Attribute &other)=default
 
bool operator== (Attribute other) const
 
bool operator!= (Attribute other) const
 
 operator bool () const
 
bool operator! () const
 
template<typename U >
bool isa () const
 
template<typename First , typename Second , typename... Rest>
bool isa () const
 
template<typename First , typename... Rest>
bool isa_and_nonnull () const
 
template<typename U >
dyn_cast () const
 
template<typename U >
dyn_cast_or_null () const
 
template<typename U >
cast () const
 
TypeID getTypeID ()
 Return a unique identifier for the concrete attribute type. More...
 
Type getType () const
 Return the type of this attribute. More...
 
MLIRContextgetContext () const
 Return the context this attribute belongs to. More...
 
DialectgetDialect () const
 Get the dialect this attribute is registered to. More...
 
void print (raw_ostream &os) const
 Print the attribute. More...
 
void dump () const
 
const voidgetAsOpaquePointer () const
 Get an opaque pointer to the attribute. More...
 
template<template< typename T > class Trait>
bool hasTrait ()
 Returns true if the type was registered with a particular trait. More...
 
const AbstractTygetAbstractAttribute () const
 Return the abstract descriptor for this attribute. More...
 

Static Public Member Functions

static bool classof (Attribute)
 
static Attribute getFromOpaquePointer (const void *ptr)
 Construct an attribute from the opaque pointer representation. More...
 

Protected Attributes

ImplTypeimpl {nullptr}
 

Friends

::llvm::hash_code hash_value (Attribute arg)
 

Detailed Description

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 24 of file Attributes.h.

Member Typedef Documentation

◆ AbstractTy

Definition at line 34 of file Attributes.h.

◆ AttrBase

template<typename ConcreteType , typename BaseType , typename StorageType , template< typename T > class... Traits>
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.

◆ ImplType

Definition at line 32 of file Attributes.h.

◆ ValueType

Definition at line 33 of file Attributes.h.

Constructor & Destructor Documentation

◆ Attribute() [1/3]

constexpr mlir::Attribute::Attribute ( )
inline

Definition at line 36 of file Attributes.h.

Referenced by Attribute(), and getFromOpaquePointer().

◆ Attribute() [2/3]

mlir::Attribute::Attribute ( const ImplType impl)
inline

Definition at line 37 of file Attributes.h.

References Attribute(), and operator=().

◆ Attribute() [3/3]

mlir::Attribute::Attribute ( const Attribute other)
default

Member Function Documentation

◆ cast()

template<typename U >
U mlir::Attribute::cast ( ) const

◆ classof()

static bool mlir::Attribute::classof ( Attribute  )
inlinestatic

Definition at line 59 of file Attributes.h.

◆ dump()

void Attribute::dump ( ) const

Definition at line 3022 of file AsmPrinter.cpp.

References print().

Referenced by getDialect().

◆ dyn_cast()

template<typename U >
U mlir::Attribute::dyn_cast ( ) const

Definition at line 124 of file Attributes.h.

Referenced by applyTilingToAll(), mlir::tosa::buildQTypeFromMinMax(), mlir::SplatElementsAttr::classof(), mlir::BoolAttr::classof(), mlir::FlatSymbolRefAttr::classof(), collapseGenericOpIterationDims(), mlir::quant::UniformQuantizedPerAxisValueConverter::convert(), convertBoolAttr(), convertToLaunchFuncOp(), createDeviceFunctionCall(), eachHasOnlyOneOfTypes(), extractCompositeElement(), foldTransferInBoundsAttribute(), getCanonicalSliceResultType(), getElementType(), mlir::LLVM::detail::getLLVMConstant(), getScalarOrSplatBoolAttr(), mlir::linalg::LinalgTransformationFilter::hasReplacementFilter(), mlir::vector::isBroadcastableTo(), isEqualOffsetSizeOrStride(), mlir::StructuredGenerator< StructuredOpInterface >::IteratorType::isOfType(), isValidQuantizationSpec(), isZeroAttribute(), joinShapes(), mlir::detail::attr_value_binder< AttrClass, ValueType, typename >::match(), mlir::detail::constant_float_op_binder::match(), mlir::detail::constant_int_op_binder::match(), CanonicalizeContractAdd< AddOpType >::matchAndRewrite(), operator!(), mlir::AsmParser::parseAttribute(), parseBound(), mlir::AsmParser::parseCustomAttributeWithFallback(), mlir::DataLayoutSpecAttr::print(), print(), mlir::AsmPrinter::Impl::printAttribute(), printConstantOp(), mlir::AsmPrinter::Impl::printDenseElementsAttr(), mlir::ExtensibleDialect::printIfDynamicAttr(), printOperation(), printTransferAttrs(), mlir::spirv::Serializer::printValueIDMap(), processParallelLoop(), mlir::ShapeAdaptor::ShapeAdaptor(), unpackOperandVector(), verifyConstantType(), verifyRegionAttribute(), and walkSubElementsImpl().

◆ dyn_cast_or_null()

template<typename U >
U mlir::Attribute::dyn_cast_or_null ( ) const

◆ getAbstractAttribute()

const AbstractTy& mlir::Attribute::getAbstractAttribute ( ) const
inline

Return the abstract descriptor for this attribute.

Definition at line 96 of file Attributes.h.

Referenced by hasTrait().

◆ getAsOpaquePointer()

const void* mlir::Attribute::getAsOpaquePointer ( ) const
inline

Get an opaque pointer to the attribute.

Definition at line 81 of file Attributes.h.

References impl.

Referenced by llvm::PointerLikeTypeTraits< mlir::Attribute >::getAsVoidPointer(), and hasSameElementsOrSplat().

◆ getContext()

MLIRContext * Attribute::getContext ( ) const

◆ getDialect()

Dialect Attribute::getDialect ( ) const
inline

Get the dialect this attribute is registered to.

Definition at line 72 of file Attributes.h.

References dump(), and print().

Referenced by mlir::detail::isSupportedMemorySpace(), mlir::AsmPrinter::Impl::printAttribute(), and mlir::AsmPrinter::Impl::printDialectAttribute().

◆ getFromOpaquePointer()

static Attribute mlir::Attribute::getFromOpaquePointer ( const void ptr)
inlinestatic

Construct an attribute from the opaque pointer representation.

Definition at line 83 of file Attributes.h.

References Attribute(), and hash_value.

Referenced by mlir::DiagnosticArgument::getAsAttribute(), and llvm::PointerLikeTypeTraits< mlir::Attribute >::getFromVoidPointer().

◆ getType()

Type mlir::Attribute::getType ( ) const
inline

◆ getTypeID()

TypeID mlir::Attribute::getTypeID ( )
inline

Return a unique identifier for the concrete attribute type.

This is used to support dynamic type casting.

Definition at line 63 of file Attributes.h.

Referenced by mlir::DynamicAttr::isa().

◆ hasTrait()

template<template< typename T > class Trait>
bool mlir::Attribute::hasTrait ( )
inline

Returns true if the type was registered with a particular trait.

Definition at line 91 of file Attributes.h.

References getAbstractAttribute(), and mlir::AbstractAttribute::hasTrait().

Referenced by mlir::DynamicAttr::classof().

◆ isa() [1/2]

template<typename U >
bool mlir::Attribute::isa ( ) const

◆ isa() [2/2]

template<typename First , typename Second , typename... Rest>
bool mlir::Attribute::isa ( ) const

Definition at line 115 of file Attributes.h.

◆ isa_and_nonnull()

template<typename First , typename... Rest>
bool mlir::Attribute::isa_and_nonnull ( ) const

Definition at line 120 of file Attributes.h.

References isa().

Referenced by operator!().

◆ operator bool()

mlir::Attribute::operator bool ( ) const
inlineexplicit

Definition at line 45 of file Attributes.h.

References impl.

◆ operator!()

bool mlir::Attribute::operator! ( ) const
inline

Definition at line 47 of file Attributes.h.

References cast(), dyn_cast(), dyn_cast_or_null(), isa(), and isa_and_nonnull().

◆ operator!=()

bool mlir::Attribute::operator!= ( Attribute  other) const
inline

Definition at line 44 of file Attributes.h.

◆ operator=()

Attribute& mlir::Attribute::operator= ( const Attribute other)
default

Referenced by Attribute().

◆ operator==()

bool mlir::Attribute::operator== ( Attribute  other) const
inline

Definition at line 43 of file Attributes.h.

References impl.

◆ print()

void Attribute::print ( raw_ostream &  os) const

Print the attribute.

Definition at line 3018 of file AsmPrinter.cpp.

References mlir::AsmPrinter::Impl::printAttribute().

Referenced by getDialect(), and mlir::operator<<().

Friends And Related Function Documentation

◆ hash_value

::llvm::hash_code hash_value ( Attribute  arg)
friend

Definition at line 135 of file Attributes.h.

Referenced by mlir::Location::dump(), getFromOpaquePointer(), and mlir::hash_value().

Member Data Documentation

◆ impl

ImplType* mlir::Attribute::impl {nullptr}
protected

The documentation for this class was generated from the following files: