13#ifndef CIRCT_DIALECT_HW_SYMCACHE_H
14#define CIRCT_DIALECT_HW_SYMCACHE_H
35 mlir::Operation *
getOp()
const {
return op; }
44 mlir::Operation *op,
size_t port = ~0ULL) {
45 auto key = InnerRefAttr::get(modSymbol, name);
57 assert(
isFrozen &&
"cannot read from this cache until it is frozen");
61 assert(!it->second.hasPort() &&
"Module names should never be ports");
62 return it->second.getOp();
66 mlir::StringAttr name)
const {
67 return lookupInner(InnerRefAttr::get(modSymbol, name));
79 assert(
isFrozen &&
"cannot read from this cache until it is frozen");
96 return {
it->getFirst(),
it->getSecond().getOp()};
108 std::make_unique<HwSymbolCacheIteratorImpl>(
symbolCache.begin()));
112 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
llvm::DenseMap< mlir::Attribute, Item > symbolCache
This stores a lookup table from symbol attribute to the item that defines it.
void addDefinition(mlir::StringAttr modSymbol, mlir::StringAttr name, mlir::Operation *op, size_t port=~0ULL)
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
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void operator++() override
CacheItem operator*() override
bool operator==(CacheIteratorImpl *other) override
HwSymbolCacheIteratorImpl(Iterator it)