mirror of https://github.com/llvm/circt.git
[NFC][SeqToSV] Fix constant caching in FIR mem loweringi
This commit is contained in:
parent
02f0bff91b
commit
74683f60cb
|
@ -307,14 +307,15 @@ void FirMemLowering::lowerMemoriesInModule(
|
|||
LLVM_DEBUG(llvm::dbgs() << "Lowering " << mems.size() << " memories in "
|
||||
<< module.getName() << "\n");
|
||||
|
||||
hw::ConstantOp constOneOp;
|
||||
DenseMap<unsigned, Value> constOneOps;
|
||||
auto constOne = [&](unsigned width = 1) {
|
||||
if (!constOneOp) {
|
||||
auto it = constOneOps.try_emplace(width, Value{});
|
||||
if (it.second) {
|
||||
auto builder = OpBuilder::atBlockBegin(module.getBodyBlock());
|
||||
constOneOp = builder.create<hw::ConstantOp>(
|
||||
it.first->second = builder.create<hw::ConstantOp>(
|
||||
module.getLoc(), builder.getIntegerType(width), 1);
|
||||
}
|
||||
return constOneOp;
|
||||
return it.first->second;
|
||||
};
|
||||
auto valueOrOne = [&](Value value, unsigned width = 1) {
|
||||
return value ? value : constOne(width);
|
||||
|
|
Loading…
Reference in New Issue