MLIR  19.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
mlir::AbstractAttribute Class Reference

This class contains all of the static information common to all instances of a registered Attribute. More...

#include "mlir/IR/AttributeSupport.h"

Public Types

using HasTraitFn = llvm::unique_function< bool(TypeID) const >
 
using WalkImmediateSubElementsFn = function_ref< void(Attribute, function_ref< void(Attribute)>, function_ref< void(Type)>)>
 
using ReplaceImmediateSubElementsFn = function_ref< Attribute(Attribute, ArrayRef< Attribute >, ArrayRef< Type >)>
 

Public Member Functions

DialectgetDialect () const
 Return the dialect this attribute was registered to. More...
 
template<typename T >
T::Concept * getInterface () const
 Returns an instance of the concept object for the given interface if it was registered to this attribute, null otherwise. More...
 
bool hasInterface (TypeID interfaceID) const
 Returns true if the attribute has the interface with the given ID registered. More...
 
template<template< typename T > class Trait>
bool hasTrait () const
 Returns true if the attribute has a particular trait. More...
 
bool hasTrait (TypeID traitID) const
 Returns true if the attribute has a particular trait. More...
 
void walkImmediateSubElements (Attribute attr, function_ref< void(Attribute)> walkAttrsFn, function_ref< void(Type)> walkTypesFn) const
 Walk the immediate sub-elements of this attribute. More...
 
Attribute replaceImmediateSubElements (Attribute attr, ArrayRef< Attribute > replAttrs, ArrayRef< Type > replTypes) const
 Replace the immediate sub-elements of this attribute. More...
 
TypeID getTypeID () const
 Return the unique identifier representing the concrete attribute class. More...
 
StringRef getName () const
 Return the unique name representing the type. More...
 

Static Public Member Functions

static const AbstractAttributelookup (TypeID typeID, MLIRContext *context)
 Look up the specified abstract attribute in the MLIRContext and return a reference to it. More...
 
static std::optional< std::reference_wrapper< const AbstractAttribute > > lookup (StringRef name, MLIRContext *context)
 Look up the specified abstract attribute in the MLIRContext and return a reference to it if it exists. More...
 
template<typename T >
static AbstractAttribute get (Dialect &dialect)
 This method is used by Dialect objects when they register the list of attributes they contain. More...
 
static AbstractAttribute get (Dialect &dialect, detail::InterfaceMap &&interfaceMap, HasTraitFn &&hasTrait, WalkImmediateSubElementsFn walkImmediateSubElementsFn, ReplaceImmediateSubElementsFn replaceImmediateSubElementsFn, TypeID typeID, StringRef name)
 This method is used by Dialect objects to register attributes with custom TypeIDs. More...
 

Friends

template<typename ConcreteT , typename BaseT , typename StorageT , typename UniquerT , template< typename T > class... Traits>
class detail::StorageUserBase
 Give StorageUserBase access to the mutable lookup. More...
 

Detailed Description

This class contains all of the static information common to all instances of a registered Attribute.

Definition at line 29 of file AttributeSupport.h.

Member Typedef Documentation

◆ HasTraitFn

using mlir::AbstractAttribute::HasTraitFn = llvm::unique_function<bool(TypeID) const>

Definition at line 31 of file AttributeSupport.h.

◆ ReplaceImmediateSubElementsFn

Definition at line 34 of file AttributeSupport.h.

◆ WalkImmediateSubElementsFn

Definition at line 32 of file AttributeSupport.h.

Member Function Documentation

◆ get() [1/2]

template<typename T >
static AbstractAttribute mlir::AbstractAttribute::get ( Dialect dialect)
inlinestatic

This method is used by Dialect objects when they register the list of attributes they contain.

Definition at line 49 of file AttributeSupport.h.

Referenced by mlir::ExtensibleDialect::registerDynamicAttr().

◆ get() [2/2]

static AbstractAttribute mlir::AbstractAttribute::get ( Dialect dialect,
detail::InterfaceMap &&  interfaceMap,
HasTraitFn &&  hasTrait,
WalkImmediateSubElementsFn  walkImmediateSubElementsFn,
ReplaceImmediateSubElementsFn  replaceImmediateSubElementsFn,
TypeID  typeID,
StringRef  name 
)
inlinestatic

This method is used by Dialect objects to register attributes with custom TypeIDs.

The use of this method is in general discouraged in favor of 'get<CustomAttribute>(dialect)'.

Definition at line 61 of file AttributeSupport.h.

References hasTrait().

◆ getDialect()

Dialect& mlir::AbstractAttribute::getDialect ( ) const
inline

Return the dialect this attribute was registered to.

Definition at line 72 of file AttributeSupport.h.

◆ getInterface()

template<typename T >
T::Concept* mlir::AbstractAttribute::getInterface ( ) const
inline

Returns an instance of the concept object for the given interface if it was registered to this attribute, null otherwise.

This should not be used directly.

Definition at line 78 of file AttributeSupport.h.

References mlir::detail::InterfaceMap::lookup().

Referenced by mlir::AttributeInterface< ConcreteType, Traits >::getInterfaceFor().

◆ getName()

StringRef mlir::AbstractAttribute::getName ( ) const
inline

Return the unique name representing the type.

Definition at line 111 of file AttributeSupport.h.

Referenced by mlir::irdl::BaseAttrConstraint::verify().

◆ getTypeID()

TypeID mlir::AbstractAttribute::getTypeID ( ) const
inline

Return the unique identifier representing the concrete attribute class.

Definition at line 108 of file AttributeSupport.h.

◆ hasInterface()

bool mlir::AbstractAttribute::hasInterface ( TypeID  interfaceID) const
inline

Returns true if the attribute has the interface with the given ID registered.

Definition at line 84 of file AttributeSupport.h.

References mlir::detail::InterfaceMap::contains().

◆ hasTrait() [1/2]

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

Returns true if the attribute has a particular trait.

Definition at line 90 of file AttributeSupport.h.

Referenced by get(), and mlir::Attribute::hasTrait().

◆ hasTrait() [2/2]

bool mlir::AbstractAttribute::hasTrait ( TypeID  traitID) const
inline

Returns true if the attribute has a particular trait.

Definition at line 95 of file AttributeSupport.h.

◆ lookup() [1/2]

std::optional< std::reference_wrapper< const AbstractAttribute > > AbstractAttribute::lookup ( StringRef  name,
MLIRContext context 
)
static

Look up the specified abstract attribute in the MLIRContext and return a reference to it if it exists.

Definition at line 757 of file MLIRContext.cpp.

References mlir::MLIRContext::getImpl().

◆ lookup() [2/2]

const AbstractAttribute & AbstractAttribute::lookup ( TypeID  typeID,
MLIRContext context 
)
static

Look up the specified abstract attribute in the MLIRContext and return a reference to it.

Get the dialect that registered the attribute with the provided typeid.

Definition at line 741 of file MLIRContext.cpp.

Referenced by mlir::detail::DistinctAttributeUniquer::get().

◆ replaceImmediateSubElements()

Attribute AbstractAttribute::replaceImmediateSubElements ( Attribute  attr,
ArrayRef< Attribute replAttrs,
ArrayRef< Type replTypes 
) const

Replace the immediate sub-elements of this attribute.

Definition at line 26 of file Attributes.cpp.

Referenced by mlir::Attribute::replaceImmediateSubElements().

◆ walkImmediateSubElements()

void AbstractAttribute::walkImmediateSubElements ( Attribute  attr,
function_ref< void(Attribute)>  walkAttrsFn,
function_ref< void(Type)>  walkTypesFn 
) const

Walk the immediate sub-elements of this attribute.

Definition at line 19 of file Attributes.cpp.

Referenced by mlir::Attribute::walkImmediateSubElements().

Friends And Related Function Documentation

◆ detail::StorageUserBase

template<typename ConcreteT , typename BaseT , typename StorageT , typename UniquerT , template< typename T > class... Traits>
friend class detail::StorageUserBase
friend

Give StorageUserBase access to the mutable lookup.

Definition at line 128 of file AttributeSupport.h.


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