MLIR  16.0.0git
Classes | Public Member Functions | List of all members
mlir::StorageUniquer Class Reference

A utility class to get or create instances of "storage classes". More...

#include "mlir/Support/StorageUniquer.h"

+ Inheritance diagram for mlir::StorageUniquer:

Classes

class  BaseStorage
 This class acts as the base storage that all storage classes must derived from. More...
 
class  StorageAllocator
 This is a utility allocator used to allocate memory for instances of derived types. More...
 

Public Member Functions

 StorageUniquer ()
 
 ~StorageUniquer ()
 
void disableMultithreading (bool disable=true)
 Set the flag specifying if multi-threading is disabled within the uniquer. More...
 
template<typename Storage >
void registerParametricStorageType (TypeID id)
 Register a new parametric storage class, this is necessary to create instances of this class type. More...
 
template<typename Storage >
void registerParametricStorageType ()
 Utility override when the storage type represents the type id. More...
 
template<typename Storage >
void registerSingletonStorageType (TypeID id, function_ref< void(Storage *)> initFn)
 Register a new singleton storage class, this is necessary to get the singletone instance. More...
 
template<typename Storage >
void registerSingletonStorageType (TypeID id)
 
template<typename Storage >
void registerSingletonStorageType (function_ref< void(Storage *)> initFn={})
 Utility override when the storage type represents the type id. More...
 
template<typename Storage , typename... Args>
Storage * get (function_ref< void(Storage *)> initFn, TypeID id, Args &&...args)
 Gets a uniqued instance of 'Storage'. More...
 
template<typename Storage , typename... Args>
Storage * get (function_ref< void(Storage *)> initFn, Args &&...args)
 Utility override when the storage type represents the type id. More...
 
template<typename Storage >
Storage * get (TypeID id)
 Gets a uniqued instance of 'Storage' which is a singleton storage type. More...
 
template<typename Storage >
Storage * get ()
 Utility override when the storage type represents the type id. More...
 
bool isSingletonStorageInitialized (TypeID id)
 Test if there is a singleton storage uniquer initialized for the provided TypeID. More...
 
bool isParametricStorageInitialized (TypeID id)
 Test if there is a parametric storage uniquer initialized for the provided TypeID. More...
 
template<typename Storage , typename... Args>
LogicalResult mutate (TypeID id, Storage *storage, Args &&...args)
 Changes the mutable component of 'storage' by forwarding the trailing arguments to the 'mutate' function of the derived class. More...
 

Detailed Description

A utility class to get or create instances of "storage classes".

These storage classes must derive from 'StorageUniquer::BaseStorage'.

For non-parametric storage classes, i.e. singleton classes, nothing else is needed. Instances of these classes can be created by calling get without trailing arguments.

Otherwise, the parametric storage classes may be created with get, and must respect the following:

Storage classes may have an optional mutable component, which must not take part in the unique immutable key. In this case, storage classes may be mutated with mutate and must additionally respect the following:

All storage classes must be registered with the uniquer via registerParametricStorageType or registerSingletonStorageType using an appropriate unique TypeID for the storage class.

Definition at line 82 of file StorageUniquer.h.

Constructor & Destructor Documentation

◆ StorageUniquer()

StorageUniquer::StorageUniquer ( )

Definition at line 334 of file StorageUniquer.cpp.

References ~StorageUniquer().

◆ ~StorageUniquer()

StorageUniquer::~StorageUniquer ( )
default

Referenced by StorageUniquer().

Member Function Documentation

◆ disableMultithreading()

void StorageUniquer::disableMultithreading ( bool  disable = true)

Set the flag specifying if multi-threading is disabled within the uniquer.

Definition at line 338 of file StorageUniquer.cpp.

◆ get() [1/4]

template<typename Storage , typename... Args>
Storage* mlir::StorageUniquer::get ( function_ref< void(Storage *)>  initFn,
TypeID  id,
Args &&...  args 
)
inline

Gets a uniqued instance of 'Storage'.

'id' is the type id used when registering the storage instance. 'initFn' is an optional parameter that can be used to initialize a newly inserted storage instance. This function is used for derived types that have complex storage or uniquing constraints.

Definition at line 195 of file StorageUniquer.h.

Referenced by mlir::AffineExpr::ceilDiv(), mlir::AffineExpr::floorDiv(), mlir::pdll::ast::AttributeType::get(), mlir::pdll::ast::ConstraintType::get(), mlir::pdll::ast::OperationType::get(), mlir::pdll::ast::RangeType::get(), mlir::pdll::ast::RewriteType::get(), mlir::pdll::ast::TupleType::get(), mlir::pdll::ast::TypeType::get(), mlir::pdll::ast::ValueType::get(), mlir::getAffineConstantExpr(), mlir::detail::TypeUniquer::getWithTypeID(), mlir::detail::AttributeUniquer::getWithTypeID(), mlir::AffineExpr::operator%(), mlir::AffineExpr::operator*(), and mlir::AffineExpr::operator+().

◆ get() [2/4]

template<typename Storage , typename... Args>
Storage* mlir::StorageUniquer::get ( function_ref< void(Storage *)>  initFn,
Args &&...  args 
)
inline

Utility override when the storage type represents the type id.

Definition at line 222 of file StorageUniquer.h.

◆ get() [3/4]

template<typename Storage >
Storage* mlir::StorageUniquer::get ( TypeID  id)
inline

Gets a uniqued instance of 'Storage' which is a singleton storage type.

'id' is the type id used when registering the storage instance.

Definition at line 230 of file StorageUniquer.h.

◆ get() [4/4]

template<typename Storage >
Storage* mlir::StorageUniquer::get ( )
inline

Utility override when the storage type represents the type id.

Definition at line 235 of file StorageUniquer.h.

◆ isParametricStorageInitialized()

bool StorageUniquer::isParametricStorageInitialized ( TypeID  id)

Test if there is a parametric storage uniquer initialized for the provided TypeID.

Test is the parametric storage is initialized.

This is only useful for debugging/diagnostic purpose: the uniquer is initialized when a dialect is loaded.

Definition at line 371 of file StorageUniquer.cpp.

Referenced by mlir::detail::TypeUniquer::getWithTypeID(), and mlir::detail::AttributeUniquer::getWithTypeID().

◆ isSingletonStorageInitialized()

bool StorageUniquer::isSingletonStorageInitialized ( TypeID  id)

Test if there is a singleton storage uniquer initialized for the provided TypeID.

Test is the storage singleton is initialized.

This is only useful for debugging/diagnostic purpose: the uniquer is initialized when a dialect is loaded.

Definition at line 366 of file StorageUniquer.cpp.

Referenced by mlir::detail::TypeUniquer::getWithTypeID(), and mlir::detail::AttributeUniquer::getWithTypeID().

◆ mutate()

template<typename Storage , typename... Args>
LogicalResult mlir::StorageUniquer::mutate ( TypeID  id,
Storage *  storage,
Args &&...  args 
)
inline

Changes the mutable component of 'storage' by forwarding the trailing arguments to the 'mutate' function of the derived class.

Definition at line 252 of file StorageUniquer.h.

References value.

Referenced by mlir::detail::TypeUniquer::mutate(), and mlir::detail::AttributeUniquer::mutate().

◆ registerParametricStorageType() [1/2]

template<typename Storage >
void mlir::StorageUniquer::registerParametricStorageType ( TypeID  id)
inline

Register a new parametric storage class, this is necessary to create instances of this class type.

id is the type identifier that will be used to identify this type when creating instances of it via 'get'.

Definition at line 149 of file StorageUniquer.h.

References value.

Referenced by mlir::pdll::ast::Context::Context(), mlir::detail::AttributeUniquer::registerAttribute(), mlir::DataFlowAnalysis::registerPointKind(), and mlir::detail::TypeUniquer::registerType().

◆ registerParametricStorageType() [2/2]

template<typename Storage >
void mlir::StorageUniquer::registerParametricStorageType ( )
inline

Utility override when the storage type represents the type id.

Definition at line 160 of file StorageUniquer.h.

◆ registerSingletonStorageType() [1/3]

template<typename Storage >
void mlir::StorageUniquer::registerSingletonStorageType ( TypeID  id,
function_ref< void(Storage *)>  initFn 
)
inline

Register a new singleton storage class, this is necessary to get the singletone instance.

id is the type identifier that will be used to access the singleton instance via 'get'. An optional initialization function may also be provided to initialize the newly created storage instance, and used when the singleton instance is created.

Definition at line 169 of file StorageUniquer.h.

Referenced by mlir::pdll::ast::Context::Context(), mlir::detail::AttributeUniquer::registerAttribute(), and mlir::detail::TypeUniquer::registerType().

◆ registerSingletonStorageType() [2/3]

template<typename Storage >
void mlir::StorageUniquer::registerSingletonStorageType ( TypeID  id)
inline

Definition at line 180 of file StorageUniquer.h.

◆ registerSingletonStorageType() [3/3]

template<typename Storage >
void mlir::StorageUniquer::registerSingletonStorageType ( function_ref< void(Storage *)>  initFn = {})
inline

Utility override when the storage type represents the type id.

Definition at line 185 of file StorageUniquer.h.


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