13#ifndef CIRCT_DIALECT_HW_SYMCACHE_H
14#define CIRCT_DIALECT_HW_SYMCACHE_H
36 mlir::Operation *
getOp()
const {
return op; }
46 auto key = InnerRefAttr::get(modSymbol, name);
58 assert(
isFrozen &&
"cannot read from this cache until it is frozen");
62 assert(!it->second.hasPort() &&
"Module names should never be ports");
63 return it->second.getOp();
67 mlir::StringAttr name)
const {
68 return lookupInner(InnerRefAttr::get(modSymbol, name));
79 static constexpr size_t invalidPort = std::numeric_limits<size_t>::max();
81 assert(
isFrozen &&
"cannot read from this cache until it is frozen");
98 return {
it->getFirst(),
it->getSecond().getOp()};
110 std::make_unique<HwSymbolCacheIteratorImpl>(
symbolCache.begin()));
114 std::make_unique<HwSymbolCacheIteratorImpl>(
symbolCache.end()));
assert(baseType &&"element must be base type")
Base symbol cache class to allow for cache lookup through a pointer to some abstract cache.
virtual mlir::Operation * getDefinition(mlir::Attribute symbol) const =0
Lookup a definition for 'symbol' in the cache.
std::pair< mlir::Attribute, mlir::Operation * > CacheItem
Iterator support through a pointer to some abstract cache.
Item(mlir::Operation *op)
mlir::Operation * getOp() const
Item(mlir::Operation *op, size_t port)
This stores lookup tables to make manipulating and working with the IR more efficient.
decltype(symbolCache)::iterator Iterator
HWSymbolCache::Item getInnerDefinition(InnerRefAttr inner) const
void freeze()
Mark the cache as frozen, which allows it to be shared across threads.
void addDefinition(mlir::Attribute key, mlir::Operation *op) override
Defines 'op' as associated with the 'symbol' in the cache.
HWSymbolCache::Item getInnerDefinition(mlir::StringAttr modSymbol, mlir::StringAttr name) const
SymbolCacheBase::Iterator end() override
static constexpr size_t invalidPort
llvm::DenseMap< mlir::Attribute, Item > symbolCache
This stores a lookup table from symbol attribute to the item that defines it.
SymbolCacheBase::Iterator begin() override
mlir::Operation * getDefinition(mlir::Attribute attr) const override
Lookup a definition for 'symbol' in the cache.
Item lookupInner(InnerRefAttr attr) const
void addDefinition(mlir::StringAttr modSymbol, mlir::StringAttr name, mlir::Operation *op, size_t port=invalidPort)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void operator++() override
CacheItem operator*() override
bool operator==(CacheIteratorImpl *other) override
HwSymbolCacheIteratorImpl(Iterator it)