MLIR 22.0.0git
mlir::detail::StorageUniquerImpl Struct Reference

This is the implementation of the StorageUniquer class. More...

Public Types

using BaseStorage = StorageUniquer::BaseStorage
using StorageAllocator = StorageUniquer::StorageAllocator

Public Member Functions

bool hasParametricStorage (TypeID id)
 Check if an instance of a parametric storage class exists.
BaseStoragegetOrCreate (TypeID id, unsigned hashValue, function_ref< bool(const BaseStorage *)> isEqual, function_ref< BaseStorage *(StorageAllocator &)> ctorFn)
 Get or create an instance of a parametric type.
LogicalResult mutate (TypeID id, BaseStorage *storage, function_ref< LogicalResult(StorageAllocator &)> mutationFn)
 Run a mutation function on the provided storage object in a thread-safe way.
StorageAllocatorgetThreadSafeAllocator ()
 Return an allocator that can be used to safely allocate instances on the current thread.
BaseStoragegetSingleton (TypeID id)
 Get or create an instance of a singleton storage class.
bool hasSingleton (TypeID id) const
 Check if an instance of a singleton storage class exists.

Public Attributes

StorageAllocator allocator
 Main allocator used for uniquing singleton instances, and other state when thread safety is guaranteed.
DenseMap< TypeID, std::unique_ptr< ParametricStorageUniquer > > parametricUniquers
 Map of type ids to the storage uniquer to use for registered objects.
DenseMap< TypeID, BaseStorage * > singletonInstances
 Map of type ids to a singleton instance when the storage class is a singleton.
bool threadingIsEnabled = true
 Flag specifying if multi-threading is enabled within the uniquer.

Detailed Description

This is the implementation of the StorageUniquer class.

Definition at line 251 of file StorageUniquer.cpp.

Member Typedef Documentation

◆ BaseStorage

◆ StorageAllocator

Member Function Documentation

◆ getOrCreate()

BaseStorage * mlir::detail::StorageUniquerImpl::getOrCreate ( TypeID id,
unsigned hashValue,
function_ref< bool(const BaseStorage *)> isEqual,
function_ref< BaseStorage *(StorageAllocator &)> ctorFn )
inline

Get or create an instance of a parametric type.

Definition at line 264 of file StorageUniquer.cpp.

References getThreadSafeAllocator(), parametricUniquers, and threadingIsEnabled.

◆ getSingleton()

BaseStorage * mlir::detail::StorageUniquerImpl::getSingleton ( TypeID id)
inline

Get or create an instance of a singleton storage class.

Definition at line 318 of file StorageUniquer.cpp.

References singletonInstances.

◆ getThreadSafeAllocator()

StorageAllocator & mlir::detail::StorageUniquerImpl::getThreadSafeAllocator ( )
inline

Return an allocator that can be used to safely allocate instances on the current thread.

Definition at line 290 of file StorageUniquer.cpp.

References allocator, and threadingIsEnabled.

Referenced by getOrCreate(), and mutate().

◆ hasParametricStorage()

bool mlir::detail::StorageUniquerImpl::hasParametricStorage ( TypeID id)
inline

Check if an instance of a parametric storage class exists.

Definition at line 260 of file StorageUniquer.cpp.

References parametricUniquers.

◆ hasSingleton()

bool mlir::detail::StorageUniquerImpl::hasSingleton ( TypeID id) const
inline

Check if an instance of a singleton storage class exists.

Definition at line 325 of file StorageUniquer.cpp.

References singletonInstances.

◆ mutate()

LogicalResult mlir::detail::StorageUniquerImpl::mutate ( TypeID id,
BaseStorage * storage,
function_ref< LogicalResult(StorageAllocator &)> mutationFn )
inline

Run a mutation function on the provided storage object in a thread-safe way.

Definition at line 278 of file StorageUniquer.cpp.

References getThreadSafeAllocator(), parametricUniquers, and threadingIsEnabled.

Member Data Documentation

◆ allocator

StorageAllocator mlir::detail::StorageUniquerImpl::allocator

Main allocator used for uniquing singleton instances, and other state when thread safety is guaranteed.

Definition at line 345 of file StorageUniquer.cpp.

Referenced by getThreadSafeAllocator().

◆ parametricUniquers

DenseMap<TypeID, std::unique_ptr<ParametricStorageUniquer> > mlir::detail::StorageUniquerImpl::parametricUniquers

Map of type ids to the storage uniquer to use for registered objects.

Definition at line 349 of file StorageUniquer.cpp.

Referenced by getOrCreate(), hasParametricStorage(), and mutate().

◆ singletonInstances

DenseMap<TypeID, BaseStorage *> mlir::detail::StorageUniquerImpl::singletonInstances

Map of type ids to a singleton instance when the storage class is a singleton.

Definition at line 353 of file StorageUniquer.cpp.

Referenced by getSingleton(), and hasSingleton().

◆ threadingIsEnabled

bool mlir::detail::StorageUniquerImpl::threadingIsEnabled = true

Flag specifying if multi-threading is enabled within the uniquer.

Definition at line 356 of file StorageUniquer.cpp.

Referenced by getOrCreate(), getThreadSafeAllocator(), and mutate().


The documentation for this struct was generated from the following file: