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) {
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 {
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.
mlir::Operation * getOp() const
Item(mlir::Operation *op)
Item(mlir::Operation *op, size_t port)
This stores lookup tables to make manipulating and working with the IR more efficient.
mlir::Operation * getDefinition(mlir::Attribute attr) const override
Lookup a definition for 'symbol' in the cache.
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
Item lookupInner(InnerRefAttr attr) const
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void operator++() override
CacheItem operator*() override
bool operator==(CacheIteratorImpl *other) override
HwSymbolCacheIteratorImpl(Iterator it)