mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-23 09:05:32 +00:00
Merge pull request #3946 from rmlarsen/toposort
Speed up TopoSort by 2.7-3.3x.
This commit is contained in:
commit
d21c464ae4
5 changed files with 102 additions and 52 deletions
|
@ -582,7 +582,7 @@ struct GliftPass : public Pass {
|
|||
for (auto cell : module->selected_cells()) {
|
||||
RTLIL::Module *tpl = design->module(cell->type);
|
||||
if (tpl != nullptr) {
|
||||
if (topo_modules.database.count(tpl) == 0)
|
||||
if (!topo_modules.has_node(tpl))
|
||||
worklist.push_back(tpl);
|
||||
topo_modules.edge(tpl, module);
|
||||
non_top_modules.insert(cell->type);
|
||||
|
|
|
@ -424,13 +424,19 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
|||
for (auto &bit : sig)
|
||||
outbit_to_cell[bit].insert(cell);
|
||||
}
|
||||
cells.node(cell);
|
||||
cells.node(cell);
|
||||
}
|
||||
|
||||
for (auto &it_right : cell_to_inbit)
|
||||
for (auto &it_sigbit : it_right.second)
|
||||
for (auto &it_left : outbit_to_cell[it_sigbit])
|
||||
cells.edge(it_left, it_right.first);
|
||||
// Build the graph for the topological sort.
|
||||
for (auto &it_right : cell_to_inbit) {
|
||||
const int r_index = cells.node(it_right.first);
|
||||
for (auto &it_sigbit : it_right.second) {
|
||||
for (auto &it_left : outbit_to_cell[it_sigbit]) {
|
||||
const int l_index = cells.node(it_left);
|
||||
cells.edge(l_index, r_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cells.sort();
|
||||
|
||||
|
|
|
@ -1032,7 +1032,7 @@ struct ShareWorker
|
|||
}
|
||||
|
||||
bool found_scc = !toposort.sort();
|
||||
topo_cell_drivers = std::move(toposort.database);
|
||||
topo_cell_drivers = toposort.get_database();
|
||||
|
||||
if (found_scc && toposort.analyze_loops)
|
||||
for (auto &loop : toposort.loops) {
|
||||
|
|
|
@ -312,7 +312,7 @@ struct FlattenPass : public Pass {
|
|||
for (auto cell : module->selected_cells()) {
|
||||
RTLIL::Module *tpl = design->module(cell->type);
|
||||
if (tpl != nullptr) {
|
||||
if (topo_modules.database.count(tpl) == 0)
|
||||
if (!topo_modules.has_node(tpl))
|
||||
worklist.insert(tpl);
|
||||
topo_modules.edge(tpl, module);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue