mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-15 21:38:45 +00:00
opt_expr: don't give up on opt when out of effort
This commit is contained in:
parent
fcb3ded9fe
commit
888e01290b
|
@ -491,6 +491,14 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
||||||
handle_clkpol_celltype_swap(cell, "$_DLATCHSR_??N_", "$_DLATCHSR_??P_", ID::R, assign_map, invert_map);
|
handle_clkpol_celltype_swap(cell, "$_DLATCHSR_??N_", "$_DLATCHSR_??P_", ID::R, assign_map, invert_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Cell*> module_cells = module->cells();
|
||||||
|
auto iterator = [&](auto&& replace_cell) {
|
||||||
|
if (sort_fails >= effort) {
|
||||||
|
// log("Running on unsorted")
|
||||||
|
for (auto cell : module_cells)
|
||||||
|
if (design->selected(module, cell) && yosys_celltypes.cell_evaluable(cell->type))
|
||||||
|
replace_cell(cell);
|
||||||
|
} else {
|
||||||
TopoSort<RTLIL::Cell*, RTLIL::IdString::compare_ptr_by_name<RTLIL::Cell>> cells;
|
TopoSort<RTLIL::Cell*, RTLIL::IdString::compare_ptr_by_name<RTLIL::Cell>> cells;
|
||||||
dict<RTLIL::SigBit, Cell*> outbit_to_cell;
|
dict<RTLIL::SigBit, Cell*> outbit_to_cell;
|
||||||
|
|
||||||
|
@ -522,8 +530,12 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
|
||||||
log("Effort of %d exceeded, no longer attempting toposort on module %s.\n",
|
log("Effort of %d exceeded, no longer attempting toposort on module %s.\n",
|
||||||
effort, log_id(module));
|
effort, log_id(module));
|
||||||
}
|
}
|
||||||
|
for (auto cell : cells.sorted) {
|
||||||
for (auto cell : cells.sorted)
|
replace_cell(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
iterator([&](auto& cell)
|
||||||
{
|
{
|
||||||
#define ACTION_DO(_p_, _s_) do { cover("opt.opt_expr.action_" S__LINE__); replace_cell(assign_map, module, cell, input.as_string(), _p_, _s_); goto next_cell; } while (0)
|
#define ACTION_DO(_p_, _s_) do { cover("opt.opt_expr.action_" S__LINE__); replace_cell(assign_map, module, cell, input.as_string(), _p_, _s_); goto next_cell; } while (0)
|
||||||
#define ACTION_DO_Y(_v_) ACTION_DO(ID::Y, RTLIL::SigSpec(RTLIL::State::S ## _v_))
|
#define ACTION_DO_Y(_v_) ACTION_DO(ID::Y, RTLIL::SigSpec(RTLIL::State::S ## _v_))
|
||||||
|
@ -2203,7 +2215,7 @@ skip_alu_split:
|
||||||
#undef ACTION_DO_Y
|
#undef ACTION_DO_Y
|
||||||
#undef FOLD_1ARG_CELL
|
#undef FOLD_1ARG_CELL
|
||||||
#undef FOLD_2ARG_CELL
|
#undef FOLD_2ARG_CELL
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void replace_const_connections(RTLIL::Module *module) {
|
void replace_const_connections(RTLIL::Module *module) {
|
||||||
|
@ -2272,7 +2284,6 @@ struct OptExprPass : public Pass {
|
||||||
bool do_fine = false;
|
bool do_fine = false;
|
||||||
bool keepdc = false;
|
bool keepdc = false;
|
||||||
int effort = 5;
|
int effort = 5;
|
||||||
|
|
||||||
log_header(design, "Executing OPT_EXPR pass (perform const folding).\n");
|
log_header(design, "Executing OPT_EXPR pass (perform const folding).\n");
|
||||||
log_push();
|
log_push();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue