Using design->selected_modules() in opt_*
authorClifford Wolf <clifford@clifford.at>
Tue, 3 Feb 2015 22:45:01 +0000 (23:45 +0100)
committerClifford Wolf <clifford@clifford.at>
Tue, 3 Feb 2015 22:45:01 +0000 (23:45 +0100)
passes/opt/opt_clean.cc
passes/opt/opt_const.cc
passes/opt/opt_muxtree.cc
passes/opt/opt_reduce.cc
passes/opt/opt_share.cc

index 98f83dffcb3267de728f861607ad33d775c917f6..447b7870fce52d4eaf133658a901568bb3b9db23 100644 (file)
@@ -347,17 +347,10 @@ struct OptCleanPass : public Pass {
                ct_reg.setup_internals_mem();
                ct_reg.setup_stdcells_mem();
 
-               for (auto mod : design->modules()) {
-                       if (!design->selected_whole_module(mod->name)) {
-                               if (design->selected(mod))
-                                       log("Skipping module %s as it is only partially selected.\n", id2cstr(mod->name));
+               for (auto module : design->selected_whole_modules_warn()) {
+                       if (module->has_processes_warn())
                                continue;
-                       }
-                       if (!mod->processes.empty()) {
-                               log("Skipping module %s as it contains processes.\n", mod->name.c_str());
-                       } else {
-                               rmunused_module(mod, purge_mode, true);
-                       }
+                       rmunused_module(module, purge_mode, true);
                }
 
                ct.clear();
@@ -411,12 +404,13 @@ struct CleanPass : public Pass {
                count_rm_cells = 0;
                count_rm_wires = 0;
 
-               for (auto mod : design->modules()) {
-                       if (design->selected_whole_module(mod->name) && mod->processes.empty())
-                               do {
-                                       design->scratchpad_unset("opt.did_something");
-                                       rmunused_module(mod, purge_mode, false);
-                               } while (design->scratchpad_get_bool("opt.did_something"));
+               for (auto mod : design->selected_whole_modules()) {
+                       if (mod->has_processes())
+                               continue;
+                       do {
+                               design->scratchpad_unset("opt.did_something");
+                               rmunused_module(mod, purge_mode, false);
+                       } while (design->scratchpad_get_bool("opt.did_something"));
                }
 
                if (count_rm_cells > 0 || count_rm_wires > 0)
index 55da987af89cff5a1222d5ff5b64ae37744f8593..1758a34fa05019f03741f43c3b05c3b1745974f0 100644 (file)
@@ -1002,7 +1002,7 @@ struct OptConstPass : public Pass {
                }
                extra_args(args, argidx, design);
 
-               for (auto module : design->modules())
+               for (auto module : design->selected_modules())
                {
                        if (undriven)
                                replace_undriven(design, module);
index 94e29eca9e5cadc124b75c193c96eaa5181eac1e..982870745066bc52effe3f2340fc5dd4e7b63287 100644 (file)
@@ -468,15 +468,10 @@ struct OptMuxtreePass : public Pass {
                extra_args(args, 1, design);
 
                int total_count = 0;
-               for (auto mod : design->modules()) {
-                       if (!design->selected_whole_module(mod)) {
-                               if (design->selected(mod))
-                                       log("Skipping module %s as it is only partially selected.\n", log_id(mod));
+               for (auto module : design->selected_whole_modules_warn()) {
+                       if (module->has_processes_warn())
                                continue;
-                       }
-                       if (mod->has_processes_warn())
-                               continue;
-                       OptMuxtreeWorker worker(design, mod);
+                       OptMuxtreeWorker worker(design, module);
                        total_count += worker.removed_count;
                }
                if (total_count)
index 3e324cceff9a16516f21624d196dd443ab3efd37..5c36eb26ba51e1a10f1b300516ead10cff2a90ee 100644 (file)
@@ -371,16 +371,13 @@ struct OptReducePass : public Pass {
                extra_args(args, argidx, design);
 
                int total_count = 0;
-               for (auto &mod_it : design->modules_) {
-                       if (!design->selected(mod_it.second))
-                               continue;
-                       do {
-                               OptReduceWorker worker(design, mod_it.second, do_fine);
+               for (auto module : design->selected_modules())
+                       while (1) {
+                               OptReduceWorker worker(design, module, do_fine);
                                total_count += worker.total_count;
                                if (worker.total_count == 0)
                                        break;
-                       } while (1);
-               }
+                       }
 
                if (total_count)
                        design->scratchpad_set_bool("opt.did_something", true);
index 66e29b66a5bc8f910a11cd66eb35e6053ff362e0..cce97d65bfa3dcb6b95c2b681df03f9c35309d4c 100644 (file)
@@ -314,10 +314,8 @@ struct OptSharePass : public Pass {
                extra_args(args, argidx, design);
 
                int total_count = 0;
-               for (auto &mod_it : design->modules_) {
-                       if (!design->selected(mod_it.second))
-                               continue;
-                       OptShareWorker worker(design, mod_it.second, mode_nomux);
+               for (auto module : design->selected_modules()) {
+                       OptShareWorker worker(design, module, mode_nomux);
                        total_count += worker.total_count;
                }