|
MLIR 24.0.0git
|
A utility class to get or create instances of "storage classes". More...
#include "mlir/Support/StorageUniquer.h"
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. | |
| template<typename Storage> | |
| void | registerParametricStorageType (TypeID id) |
| Register a new parametric storage class, this is necessary to create instances of this class type. | |
| template<typename Storage> | |
| void | registerParametricStorageType () |
| Utility override when the storage type represents the type id. | |
| 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. | |
| 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. | |
| template<typename Storage, typename... Args> | |
| Storage * | get (function_ref< void(Storage *)> initFn, TypeID id, Args &&...args) |
| Gets a uniqued instance of 'Storage'. | |
| template<typename Storage, typename... Args> | |
| Storage * | get (function_ref< void(Storage *)> initFn, Args &&...args) |
| Utility override when the storage type represents the type id. | |
| template<typename Storage> | |
| Storage * | get (TypeID id) |
| Gets a uniqued instance of 'Storage' which is a singleton storage type. | |
| template<typename Storage> | |
| Storage * | get () |
| Utility override when the storage type represents the type id. | |
| bool | isSingletonStorageInitialized (TypeID id) |
| Test if there is a singleton storage uniquer initialized for the provided TypeID. | |
| bool | isParametricStorageInitialized (TypeID id) |
| Test if there is a parametric storage uniquer initialized for the provided TypeID. | |
| void | beginTransientScope () |
| Begins a transient scope. | |
| void | endTransientScope () |
| Ends the transient scope and resets back to the base state, freeing all transiently allocated storage instances and clearing transient lookup tables. | |
| bool | isInTransientScope () const |
| Returns true if the uniquer is currently in a transient scope. | |
| 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. | |
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.
| StorageUniquer::StorageUniquer | ( | ) |
Definition at line 528 of file StorageUniquer.cpp.
|
default |
| void StorageUniquer::beginTransientScope | ( | ) |
Begins a transient scope.
All subsequent allocations and uniquing registrations will be recorded in a transient layer. Precondition: The uniquer must not already be in a transient scope.
Definition at line 536 of file StorageUniquer.cpp.
Referenced by mlir::MLIRContext::beginTransientScope().
Set the flag specifying if multi-threading is disabled within the uniquer.
Definition at line 532 of file StorageUniquer.cpp.
| void StorageUniquer::endTransientScope | ( | ) |
Ends the transient scope and resets back to the base state, freeing all transiently allocated storage instances and clearing transient lookup tables.
Precondition: The uniquer must be in a transient scope.
Definition at line 538 of file StorageUniquer.cpp.
Referenced by mlir::MLIRContext::endTransientScope().
|
inline |
Utility override when the storage type represents the type id.
Definition at line 235 of file StorageUniquer.h.
References get(), and mlir::TypeID::get().
|
inline |
Utility override when the storage type represents the type id.
Definition at line 222 of file StorageUniquer.h.
References get(), and mlir::TypeID::get().
|
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::GenericLatticeAnchorBase< ConcreteT, Value >::get(), mlir::pdl_to_pdl_interp::PredicateBase< ConcreteT, BaseT, Key, Kind >::get(), 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::detail::AttributeUniquer::getWithTypeID(), mlir::detail::AttributeUniquer::getWithTypeID(), mlir::detail::TypeUniquer::getWithTypeID(), mlir::detail::TypeUniquer::getWithTypeID(), mlir::AffineExpr::operator%(), and mlir::AffineExpr::operator*().
|
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.
| bool StorageUniquer::isInTransientScope | ( | ) | const |
Returns true if the uniquer is currently in a transient scope.
Definition at line 540 of file StorageUniquer.cpp.
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 575 of file StorageUniquer.cpp.
Referenced by mlir::detail::AttributeUniquer::getWithTypeID(), and mlir::detail::TypeUniquer::getWithTypeID().
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 570 of file StorageUniquer.cpp.
Referenced by mlir::detail::AttributeUniquer::getWithTypeID(), and mlir::detail::TypeUniquer::getWithTypeID().
|
inline |
Changes the mutable component of 'storage' by forwarding the trailing arguments to the 'mutate' function of the derived class.
Note: When in a transient scope, any storage memory allocated during mutation will come from the transient allocator. Mutating base storage instances (allocated before the transient scope) while in a transient scope is not supported as that transient memory will be freed on scope exit.
Definition at line 271 of file StorageUniquer.h.
Referenced by mlir::detail::AttributeUniquer::mutate(), and mlir::detail::TypeUniquer::mutate().
|
inline |
Utility override when the storage type represents the type id.
Definition at line 160 of file StorageUniquer.h.
References mlir::TypeID::get(), and registerParametricStorageType().
Referenced by mlir::pdl_to_pdl_interp::PredicateUniquer::PredicateUniquer(), and registerParametricStorageType().
|
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.
Referenced by mlir::detail::AttributeUniquer::registerAttribute(), and mlir::detail::TypeUniquer::registerType().
|
inline |
Utility override when the storage type represents the type id.
Definition at line 185 of file StorageUniquer.h.
|
inline |
Definition at line 180 of file StorageUniquer.h.
References registerSingletonStorageType().
|
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::pdl_to_pdl_interp::PredicateUniquer::PredicateUniquer(), mlir::detail::AttributeUniquer::registerAttribute(), registerSingletonStorageType(), and mlir::detail::TypeUniquer::registerType().