CIRCT 24.0.0git
Loading...
Searching...
No Matches
circt::hw::HWSymbolCache Class Reference

This stores lookup tables to make manipulating and working with the IR more efficient. More...

#include <HWSymCache.h>

Inheritance diagram for circt::hw::HWSymbolCache:
Collaboration diagram for circt::hw::HWSymbolCache:

Classes

class  Item
struct  HwSymbolCacheIteratorImpl

Public Member Functions

void addDefinition (mlir::StringAttr modSymbol, mlir::StringAttr name, mlir::Operation *op, size_t port=invalidPort)
void addDefinition (mlir::Attribute key, mlir::Operation *op) override
 Defines 'op' as associated with the 'symbol' in the cache.
mlir::Operation * getDefinition (mlir::Attribute attr) const override
 Lookup a definition for 'symbol' in the cache.
HWSymbolCache::Item getInnerDefinition (mlir::StringAttr modSymbol, mlir::StringAttr name) const
HWSymbolCache::Item getInnerDefinition (InnerRefAttr inner) const
void freeze ()
 Mark the cache as frozen, which allows it to be shared across threads.
SymbolCacheBase::Iterator begin () override
SymbolCacheBase::Iterator end () override
mlir::Operation * getDefinition (mlir::FlatSymbolRefAttr symbol) const
 Lookup a definition for 'symbol' in the cache.
Public Member Functions inherited from circt::SymbolCacheBase
virtual ~SymbolCacheBase ()
 Virtual method anchor.
void addSymbol (mlir::SymbolOpInterface op)
 Adds the symbol-defining 'op' to the cache.
void addDefinitions (mlir::Operation *top)
 Populate the symbol cache with all symbol-defining operations within the 'top' operation.
mlir::Operation * getDefinition (mlir::FlatSymbolRefAttr symbol) const
 Lookup a definition for 'symbol' in the cache.

Private Types

using Iterator = decltype(symbolCache)::iterator

Private Member Functions

Item lookupInner (InnerRefAttr attr) const

Private Attributes

bool isFrozen = false
llvm::DenseMap< mlir::Attribute, Item > symbolCache
 This stores a lookup table from symbol attribute to the item that defines it.

Static Private Attributes

static constexpr size_t invalidPort = std::numeric_limits<size_t>::max()

Additional Inherited Members

Public Types inherited from circt::SymbolCacheBase
using CacheItem = std::pair<mlir::Attribute, mlir::Operation *>
 Iterator support through a pointer to some abstract cache.

Detailed Description

This stores lookup tables to make manipulating and working with the IR more efficient.

There are two phases to this object: the "building" phase in which it is "write only" and then the "using" phase which is read-only (and thus can be used by multiple threads). The "freeze" method transitions between the two states.

Definition at line 28 of file HWSymCache.h.

Member Typedef Documentation

◆ Iterator

using circt::hw::HWSymbolCache::Iterator = decltype(symbolCache)::iterator
private

Definition at line 94 of file HWSymCache.h.

Member Function Documentation

◆ addDefinition() [1/2]

void circt::hw::HWSymbolCache::addDefinition ( mlir::Attribute symbol,
mlir::Operation * op )
inlineoverridevirtual

Defines 'op' as associated with the 'symbol' in the cache.

Implements circt::SymbolCacheBase.

Definition at line 50 of file HWSymCache.h.

References assert(), isFrozen, and symbolCache.

◆ addDefinition() [2/2]

void circt::hw::HWSymbolCache::addDefinition ( mlir::StringAttr modSymbol,
mlir::StringAttr name,
mlir::Operation * op,
size_t port = invalidPort )
inline

Definition at line 44 of file HWSymCache.h.

References invalidPort, and symbolCache.

◆ begin()

SymbolCacheBase::Iterator circt::hw::HWSymbolCache::begin ( )
inlineoverridevirtual

Implements circt::SymbolCacheBase.

Definition at line 108 of file HWSymCache.h.

References symbolCache.

◆ end()

SymbolCacheBase::Iterator circt::hw::HWSymbolCache::end ( )
inlineoverridevirtual

Implements circt::SymbolCacheBase.

Definition at line 112 of file HWSymCache.h.

References symbolCache.

◆ freeze()

void circt::hw::HWSymbolCache::freeze ( )
inline

Mark the cache as frozen, which allows it to be shared across threads.

Definition at line 76 of file HWSymCache.h.

References isFrozen.

◆ getDefinition() [1/2]

mlir::Operation * circt::hw::HWSymbolCache::getDefinition ( mlir::Attribute symbol) const
inlineoverridevirtual

Lookup a definition for 'symbol' in the cache.

Implements circt::SymbolCacheBase.

Definition at line 57 of file HWSymCache.h.

References assert(), isFrozen, and symbolCache.

Referenced by circt::msft::getHierPathTopModule().

◆ getDefinition() [2/2]

mlir::Operation * circt::SymbolCacheBase::getDefinition ( mlir::FlatSymbolRefAttr symbol) const
inline

Lookup a definition for 'symbol' in the cache.

Definition at line 45 of file SymCache.h.

◆ getInnerDefinition() [1/2]

HWSymbolCache::Item circt::hw::HWSymbolCache::getInnerDefinition ( InnerRefAttr inner) const
inline

Definition at line 71 of file HWSymCache.h.

References lookupInner().

◆ getInnerDefinition() [2/2]

HWSymbolCache::Item circt::hw::HWSymbolCache::getInnerDefinition ( mlir::StringAttr modSymbol,
mlir::StringAttr name ) const
inline

Definition at line 66 of file HWSymCache.h.

References lookupInner().

◆ lookupInner()

Item circt::hw::HWSymbolCache::lookupInner ( InnerRefAttr attr) const
inlineprivate

Definition at line 80 of file HWSymCache.h.

References assert(), invalidPort, isFrozen, and symbolCache.

Referenced by getInnerDefinition(), and getInnerDefinition().

Member Data Documentation

◆ invalidPort

size_t circt::hw::HWSymbolCache::invalidPort = std::numeric_limits<size_t>::max()
staticconstexprprivate

◆ isFrozen

bool circt::hw::HWSymbolCache::isFrozen = false
private

Definition at line 86 of file HWSymCache.h.

Referenced by addDefinition(), freeze(), getDefinition(), and lookupInner().

◆ symbolCache

llvm::DenseMap<mlir::Attribute, Item> circt::hw::HWSymbolCache::symbolCache
private

This stores a lookup table from symbol attribute to the item that defines it.

Definition at line 90 of file HWSymCache.h.

Referenced by addDefinition(), addDefinition(), begin(), end(), getDefinition(), and lookupInner().


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