MLIR  14.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:
Inheritance graph
[legend]
Collaboration diagram for mlir::Attribute:
Collaboration graph
[legend]

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 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
 

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

Member Typedef Documentation

◆ AbstractTy

Definition at line 37 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 33 of file Attributes.h.

◆ ImplType

Definition at line 35 of file Attributes.h.

◆ ValueType

Definition at line 36 of file Attributes.h.

Constructor & Destructor Documentation

◆ Attribute() [1/3]

constexpr mlir::Attribute::Attribute ( )
inline

Definition at line 39 of file Attributes.h.

Referenced by Attribute(), and getFromOpaquePointer().

◆ Attribute() [2/3]

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

Definition at line 40 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 60 of file Attributes.h.

◆ dump()

void Attribute::dump ( ) const

Definition at line 2737 of file AsmPrinter.cpp.

References print().

Referenced by getDialect().

◆ dyn_cast()

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

◆ 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 97 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 82 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 73 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 84 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 64 of file Attributes.h.

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

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

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

◆ operator bool()

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

Definition at line 48 of file Attributes.h.

References impl.

◆ operator!()

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

Definition at line 50 of file Attributes.h.

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

◆ operator!=()

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

Definition at line 47 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 46 of file Attributes.h.

References impl.

◆ print()

void Attribute::print ( raw_ostream &  os) const

Print the attribute.

Definition at line 2733 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 131 of file Attributes.h.

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

Member Data Documentation

◆ impl

ImplType* mlir::Attribute::impl
protected

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