CIRCT  19.0.0git
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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:
Inheritance graph
[legend]
Collaboration diagram for circt::hw::HWSymbolCache:
Collaboration graph
[legend]

Classes

struct  HwSymbolCacheIteratorImpl
 
class  Item
 

Public Member Functions

void addDefinition (mlir::StringAttr modSymbol, mlir::StringAttr name, mlir::Operation *op, size_t port=~0ULL)
 
void addDefinition (mlir::Attribute key, mlir::Operation *op) override
 Defines 'op' as associated with the 'symbol' in the cache. More...
 
mlir::Operation * getDefinition (mlir::Attribute attr) const override
 Lookup a definition for 'symbol' in the cache. More...
 
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. More...
 
SymbolCacheBase::Iterator begin () override
 
SymbolCacheBase::Iterator end () override
 
virtual mlir::Operation * getDefinition (mlir::Attribute symbol) const=0
 Lookup a definition for 'symbol' in the cache. More...
 
mlir::Operation * getDefinition (mlir::FlatSymbolRefAttr symbol) const
 Lookup a definition for 'symbol' in the cache. More...
 
- Public Member Functions inherited from circt::SymbolCacheBase
virtual ~SymbolCacheBase ()
 Virtual method anchor. More...
 
void addSymbol (mlir::SymbolOpInterface op)
 Adds the symbol-defining 'op' to the cache. More...
 
void addDefinitions (mlir::Operation *top)
 Populate the symbol cache with all symbol-defining operations within the 'top' operation. More...
 
mlir::Operation * getDefinition (mlir::FlatSymbolRefAttr symbol) const
 Lookup a definition for 'symbol' in the cache. More...
 

Private Types

using Iterator = decltype(symbolCache)::iterator
 

Private Member Functions

Item lookupInner (InnerRefAttr attr) const
 

Private Attributes

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

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. More...
 

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 27 of file HWSymCache.h.

Member Typedef Documentation

◆ Iterator

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

Definition at line 92 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 49 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 = ~0ULL 
)
inline

◆ begin()

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

Implements circt::SymbolCacheBase.

Definition at line 106 of file HWSymCache.h.

References symbolCache.

◆ end()

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

Implements circt::SymbolCacheBase.

Definition at line 110 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 75 of file HWSymCache.h.

References isFrozen.

Referenced by circt::ExportVerilog::SharedEmitterState::gatherFiles(), and circt::msft::TclEmitter::populate().

◆ getDefinition() [1/3]

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 56 of file HWSymCache.h.

References assert(), isFrozen, and symbolCache.

Referenced by circt::msft::TclEmitter::getDefinition(), circt::msft::getHierPathTopModule(), and circt::msft::TclEmitter::populate().

◆ getDefinition() [2/3]

virtual mlir::Operation* circt::SymbolCacheBase::getDefinition

Lookup a definition for 'symbol' in the cache.

◆ getDefinition() [3/3]

mlir::Operation* circt::SymbolCacheBase::getDefinition
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 70 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 65 of file HWSymCache.h.

References circt::calyx::direction::get(), and lookupInner().

◆ lookupInner()

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

Definition at line 78 of file HWSymCache.h.

References assert(), isFrozen, and symbolCache.

Referenced by getInnerDefinition().

Member Data Documentation

◆ isFrozen

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

Definition at line 84 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 88 of file HWSymCache.h.

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


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