Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/rsz/src/ConcreteSwapArithModules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,14 @@ bool ConcreteSwapArithModules::hasArithOperatorProperty(
return false;
}

bool ConcreteSwapArithModules::doSwapInstances(
const std::set<dbModInst*>& insts,
const std::string& target)
bool ConcreteSwapArithModules::doSwapInstances(std::set<dbModInst*>& insts,
const std::string& target)
{
int swapped_count = 0;

// Create a new inst set since old insts are destroyed
std::set<dbModInst*> swappedInsts;

for (dbModInst* inst : insts) {
dbModule* old_master = inst->getMaster();
if (!old_master) {
Expand Down Expand Up @@ -271,11 +273,18 @@ bool ConcreteSwapArithModules::doSwapInstances(
inst->getName(),
old_name,
new_name);
inst->swapMaster(new_master);
swapped_count++;
dbModInst* new_inst = inst->swapMaster(new_master);

if (new_inst) {
swapped_count++;
swappedInsts.insert(new_inst);
}
}
}

insts.clear();
insts.insert(swappedInsts.begin(), swappedInsts.end());

logger_->info(RSZ,
160,
"{} arithmetic instances have swapped to improve '{}' target",
Expand Down
2 changes: 1 addition & 1 deletion src/rsz/src/ConcreteSwapArithModules.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ConcreteSwapArithModules : public SwapArithModules
const std::string& target,
float slack_threshold,
std::set<dbModInst*>& insts) override;
bool doSwapInstances(const std::set<dbModInst*>& insts,
bool doSwapInstances(std::set<dbModInst*>& insts,
const std::string& target) override;

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/rsz/src/SwapArithModules.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SwapArithModules : public sta::dbStaState
float slack_threshold,
std::set<dbModInst*>& insts)
= 0;
virtual bool doSwapInstances(const std::set<dbModInst*>& insts,
virtual bool doSwapInstances(std::set<dbModInst*>& insts,
const std::string& target)
= 0;

Expand Down