Skip to content

Commit

Permalink
cleanup: overload extra_args for brevity and less magic int literals,…
Browse files Browse the repository at this point in the history
… fixes opt_demorgan warning
  • Loading branch information
widlarizer committed Apr 2, 2024
1 parent 7159a98 commit 030d478
Show file tree
Hide file tree
Showing 57 changed files with 66 additions and 247 deletions.
5 changes: 5 additions & 0 deletions kernel/register.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ void Pass::cmd_error(const std::vector<std::string> &args, size_t argidx, std::s
msg.c_str(), command_text.c_str(), error_pos, "");
}

void Pass::extra_args(std::vector<std::string> args, RTLIL::Design *design)
{
extra_args(args, 1, design, false);
}

void Pass::extra_args(std::vector<std::string> args, size_t argidx, RTLIL::Design *design, bool select)
{
for (; argidx < args.size(); argidx++)
Expand Down
6 changes: 2 additions & 4 deletions kernel/yosys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1478,8 +1478,7 @@ struct ShellPass : public Pass {
log("Press Ctrl-D or type 'exit' to leave the interactive shell.\n");
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override {
extra_args(args, 1, design, false);
void execute(std::vector<std::string> args, RTLIL::Design *design) override { extra_args(args, design);
shell(design);
}
} ShellPass;
Expand All @@ -1496,8 +1495,7 @@ struct HistoryPass : public Pass {
log("from executed scripts.\n");
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override {
extra_args(args, 1, design, false);
void execute(std::vector<std::string> args, RTLIL::Design *design) override { extra_args(args, design);
#ifdef YOSYS_ENABLE_READLINE
for(HIST_ENTRY **list = history_list(); *list != NULL; list++)
log("%s\n", (*list)->line);
Expand Down
3 changes: 1 addition & 2 deletions passes/cmds/autoname.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ struct AutonamePass : public Pass {
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
extra_args(args, 1, design);
{ extra_args(args, design);

log_header(design, "Executing AUTONAME pass.\n");

Expand Down
3 changes: 1 addition & 2 deletions passes/cmds/blackbox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ struct BlackboxPass : public Pass {
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
extra_args(args, 1, design);
{ extra_args(args, design);

for (auto module : design->selected_whole_modules_warn(true))
{
Expand Down
3 changes: 1 addition & 2 deletions passes/cmds/clean_zerowidth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ struct CleanZeroWidthPass : public Pass {
}

void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
extra_args(args, 1, design);
{ extra_args(args, design);

CellTypes ct;
ct.setup();
Expand Down
9 changes: 1 addition & 8 deletions passes/cmds/future.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,7 @@ struct FuturePass : public Pass {
FutureOptions options;

log_header(design, "Executing FUTURE pass.\n");

size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++) {

break;
}

extra_args(args, argidx, design);
extra_args(args, design);

for (auto module : design->selected_modules()) {
FutureWorker worker(module, options);
Expand Down
4 changes: 1 addition & 3 deletions passes/cmds/printattrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ struct PrintAttrsPass : public Pass {
}

void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
size_t argidx = 1;
extra_args(args, argidx, design);
{ extra_args(args, design);

unsigned int indent = 0;
for (auto mod : design->selected_modules())
Expand Down
3 changes: 1 addition & 2 deletions passes/cmds/scatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ struct ScatterPass : public Pass {
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
CellTypes ct(design);
extra_args(args, 1, design);
CellTypes ct(design); extra_args(args, design);

for (auto module : design->selected_modules())
{
Expand Down
4 changes: 1 addition & 3 deletions passes/cmds/select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1712,9 +1712,7 @@ struct LsPass : public Pass {
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
size_t argidx = 1;
extra_args(args, argidx, design);
{ extra_args(args, design);

if (design->selected_active_module.empty())
{
Expand Down
13 changes: 2 additions & 11 deletions passes/cmds/sta.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,8 @@ struct StaPass : public Pass {
{
log_header(design, "Executing STA pass (static timing analysis).\n");

/*
size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++) {
if (args[argidx] == "-TODO") {
continue;
}
break;
}
*/

extra_args(args, 1, design);
// TODO: there was a commented out -TODO argument
extra_args(args, design);

for (Module *module : design->selected_modules())
{
Expand Down
7 changes: 1 addition & 6 deletions passes/equiv/equiv_mark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,7 @@ struct EquivMarkPass : public Pass {
void execute(std::vector<std::string> args, Design *design) override
{
log_header(design, "Executing EQUIV_MARK pass.\n");

size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++) {
break;
}
extra_args(args, argidx, design);
extra_args(args, design);

for (auto module : design->selected_whole_modules_warn()) {
EquivMarkWorker worker(module);
Expand Down
7 changes: 1 addition & 6 deletions passes/equiv/equiv_purge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,7 @@ struct EquivPurgePass : public Pass {
void execute(std::vector<std::string> args, Design *design) override
{
log_header(design, "Executing EQUIV_PURGE pass.\n");

size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++) {
break;
}
extra_args(args, argidx, design);
extra_args(args, design);

for (auto module : design->selected_whole_modules_warn()) {
EquivPurgeWorker worker(module);
Expand Down
3 changes: 1 addition & 2 deletions passes/fsm/fsm_extract.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ struct FsmExtractPass : public Pass {
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing FSM_EXTRACT pass (extracting FSM from design).\n");
extra_args(args, 1, design);
log_header(design, "Executing FSM_EXTRACT pass (extracting FSM from design).\n"); extra_args(args, design);

CellTypes ct(design);

Expand Down
3 changes: 1 addition & 2 deletions passes/fsm/fsm_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ struct FsmInfoPass : public Pass {
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing FSM_INFO pass (dumping all available information on FSM cells).\n");
extra_args(args, 1, design);
log_header(design, "Executing FSM_INFO pass (dumping all available information on FSM cells).\n"); extra_args(args, design);

for (auto mod : design->selected_modules())
for (auto cell : mod->selected_cells())
Expand Down
3 changes: 1 addition & 2 deletions passes/fsm/fsm_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ struct FsmMapPass : public Pass {
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing FSM_MAP pass (mapping FSMs to basic logic).\n");
extra_args(args, 1, design);
log_header(design, "Executing FSM_MAP pass (mapping FSMs to basic logic).\n"); extra_args(args, design);

for (auto mod : design->selected_modules()) {
std::vector<RTLIL::Cell*> fsm_cells;
Expand Down
3 changes: 1 addition & 2 deletions passes/fsm/fsm_opt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ struct FsmOptPass : public Pass {
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing FSM_OPT pass (simple optimizations of FSMs).\n");
extra_args(args, 1, design);
log_header(design, "Executing FSM_OPT pass (simple optimizations of FSMs).\n"); extra_args(args, design);

for (auto mod : design->selected_modules())
for (auto cell : mod->selected_cells())
Expand Down
12 changes: 1 addition & 11 deletions passes/hierarchy/uniquify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,7 @@ struct UniquifyPass : public Pass {
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing UNIQUIFY pass (creating unique copies of modules).\n");

size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++)
{
// if (args[argidx] == "-check") {
// flag_check = true;
// continue;
// }
break;
}
extra_args(args, argidx, design);
extra_args(args, design);

bool did_something = true;
int count = 0;
Expand Down
7 changes: 1 addition & 6 deletions passes/memory/memory_bmux2rom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ struct MemoryBmux2RomPass : public Pass {
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing MEMORY_BMUX2ROM pass (converting muxes to ROMs).\n");

size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++) {
break;
}
extra_args(args, argidx, design);
extra_args(args, design);

for (auto module : design->selected_modules()) {
for (auto cell : module->selected_cells()) {
Expand Down
3 changes: 1 addition & 2 deletions passes/memory/memory_collect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ struct MemoryCollectPass : public Pass {
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override {
log_header(design, "Executing MEMORY_COLLECT pass (generating $mem cells).\n");
extra_args(args, 1, design);
log_header(design, "Executing MEMORY_COLLECT pass (generating $mem cells).\n"); extra_args(args, design);
for (auto module : design->selected_modules()) {
if (module->has_processes_warn())
continue;
Expand Down
3 changes: 1 addition & 2 deletions passes/memory/memory_memx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ struct MemoryMemxPass : public Pass {
}

void execute(std::vector<std::string> args, RTLIL::Design *design) override {
log_header(design, "Executing MEMORY_MEMX pass (emit soft logic for out-of-bounds handling).\n");
extra_args(args, 1, design);
log_header(design, "Executing MEMORY_MEMX pass (emit soft logic for out-of-bounds handling).\n"); extra_args(args, design);

for (auto module : design->selected_modules())
for (auto &mem : Mem::get_selected_memories(module))
Expand Down
7 changes: 1 addition & 6 deletions passes/memory/memory_narrow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ struct MemoryNarrowPass : public Pass {
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing MEMORY_NARROW pass (splitting up wide memory ports).\n");

size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++) {
break;
}
extra_args(args, argidx, design);
extra_args(args, design);

for (auto module : design->selected_modules()) {
if (module->has_processes_warn())
Expand Down
3 changes: 1 addition & 2 deletions passes/memory/memory_unpack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ struct MemoryUnpackPass : public Pass {
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override {
log_header(design, "Executing MEMORY_UNPACK pass (generating $memrd/$memwr cells form $mem cells).\n");
extra_args(args, 1, design);
log_header(design, "Executing MEMORY_UNPACK pass (generating $memrd/$memwr cells form $mem cells).\n"); extra_args(args, design);
for (auto module : design->selected_modules()) {
for (auto &mem : Mem::get_selected_memories(module)) {
if (mem.packed) {
Expand Down
3 changes: 1 addition & 2 deletions passes/opt/muxpack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ struct MuxpackPass : public Pass {
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing MUXPACK pass ($mux cell cascades to $pmux).\n");

extra_args(args, 1, design);
extra_args(args, design);

int mux_count = 0;
int pmux_count = 0;
Expand Down
4 changes: 1 addition & 3 deletions passes/opt/opt_demorgan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ struct OptDemorganPass : public Pass {
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing OPT_DEMORGAN pass (push inverters through $reduce_* cells).\n");

int argidx = 0;
extra_args(args, argidx, design);
extra_args(args, design);

unsigned int cells_changed = 0;
for (auto module : design->selected_modules())
Expand Down
3 changes: 1 addition & 2 deletions passes/opt/opt_ffinv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ struct OptFfInvPass : public Pass {
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing OPT_FFINV pass (push inverters through FFs).\n");

extra_args(args, 1, design);
extra_args(args, design);

int total_count = 0;
for (auto module : design->selected_modules())
Expand Down
3 changes: 1 addition & 2 deletions passes/opt/opt_mem_feedback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ struct OptMemFeedbackPass : public Pass {
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override {
log_header(design, "Executing OPT_MEM_FEEDBACK pass (finding memory read-to-write feedback paths).\n");
extra_args(args, 1, design);
log_header(design, "Executing OPT_MEM_FEEDBACK pass (finding memory read-to-write feedback paths).\n"); extra_args(args, design);
OptMemFeedbackWorker worker(design);

for (auto module : design->selected_modules())
Expand Down
3 changes: 1 addition & 2 deletions passes/opt/opt_mem_priority.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ struct OptMemPriorityPass : public Pass {
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override {
log_header(design, "Executing OPT_MEM_PRIORITY pass (removing unnecessary memory write priority relations).\n");
extra_args(args, 1, design);
log_header(design, "Executing OPT_MEM_PRIORITY pass (removing unnecessary memory write priority relations).\n"); extra_args(args, design);

ModWalker modwalker(design);

Expand Down
3 changes: 1 addition & 2 deletions passes/opt/opt_muxtree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,7 @@ struct OptMuxtreePass : public Pass {
}
void execute(vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing OPT_MUXTREE pass (detect dead branches in mux trees).\n");
extra_args(args, 1, design);
log_header(design, "Executing OPT_MUXTREE pass (detect dead branches in mux trees).\n"); extra_args(args, design);

int total_count = 0;
for (auto module : design->selected_whole_modules_warn()) {
Expand Down
3 changes: 1 addition & 2 deletions passes/opt/opt_share.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ struct OptSharePass : public Pass {
{

log_header(design, "Executing OPT_SHARE pass.\n");

extra_args(args, 1, design);
extra_args(args, design);
for (auto module : design->selected_modules()) {
SigMap sigmap(module);

Expand Down
4 changes: 1 addition & 3 deletions passes/opt/rmports.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ struct RmportsPassPass : public Pass {
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing RMPORTS pass (remove ports with no connections).\n");

size_t argidx = 1;
extra_args(args, argidx, design);
extra_args(args, design);

// The set of ports we removed
dict<IdString, pool<IdString>> removed_ports;
Expand Down
3 changes: 1 addition & 2 deletions passes/pmgen/peepopt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ struct PeepoptPass : public Pass {
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing PEEPOPT pass (run peephole optimizers).\n");

extra_args(args, 1, design);
extra_args(args, design);

for (auto module : design->selected_modules())
{
Expand Down
Loading

0 comments on commit 030d478

Please sign in to comment.