MLIR  19.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 83 of file StorageUniquer.h.

Constructor & Destructor Documentation

◆ StorageUniquer()

StorageUniquer::StorageUniquer ( )

Definition at line 361 of file StorageUniquer.cpp.

◆ ~StorageUniquer()

StorageUniquer::~StorageUniquer ( )
default

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 365 of file StorageUniquer.cpp.

◆ get() [1/4]

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

Utility override when the storage type represents the type id.

Definition at line 236 of file StorageUniquer.h.

◆ 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 223 of file StorageUniquer.h.

◆ get() [3/4]

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

◆ get() [4/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 231 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 398 of file StorageUniquer.cpp.

Referenced by mlir::detail::AttributeUniquer::getWithTypeID(), and mlir::detail::TypeUniquer::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 393 of file StorageUniquer.cpp.

Referenced by mlir::detail::AttributeUniquer::getWithTypeID(), and mlir::detail::TypeUniquer::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 253 of file StorageUniquer.h.

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

◆ registerParametricStorageType() [1/2]

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

Utility override when the storage type represents the type id.

Definition at line 161 of file StorageUniquer.h.

◆ registerParametricStorageType() [2/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 150 of file StorageUniquer.h.

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

◆ registerSingletonStorageType() [1/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 186 of file StorageUniquer.h.

◆ registerSingletonStorageType() [2/3]

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

Definition at line 181 of file StorageUniquer.h.

◆ registerSingletonStorageType() [3/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 170 of file StorageUniquer.h.

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


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