aboutsummaryrefslogtreecommitdiffstats
path: root/passes/opt
diff options
context:
space:
mode:
authorEddie Hung <eddie@fpgeh.com>2020-02-19 10:45:10 -0800
committerEddie Hung <eddie@fpgeh.com>2020-02-19 10:45:10 -0800
commit1d401a7991f4c0f133b7355acc400132da1aa4a0 (patch)
tree2064e3fcb06fcab66bf4d3d968ea050e8773b702 /passes/opt
parentd20c1dac73e344dda73ec2b526ffb764efc9fdd8 (diff)
downloadyosys-1d401a7991f4c0f133b7355acc400132da1aa4a0.tar.gz
yosys-1d401a7991f4c0f133b7355acc400132da1aa4a0.tar.bz2
yosys-1d401a7991f4c0f133b7355acc400132da1aa4a0.zip
clean: ignore specify-s inside cells when determining whether to keep
Diffstat (limited to 'passes/opt')
-rw-r--r--passes/opt/opt_clean.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/passes/opt/opt_clean.cc b/passes/opt/opt_clean.cc
index 2f69b3d4c..f5bb40050 100644
--- a/passes/opt/opt_clean.cc
+++ b/passes/opt/opt_clean.cc
@@ -51,20 +51,26 @@ struct keep_cache_t
if (cache.count(module))
return cache.at(module);
- cache[module] = true;
- if (!module->get_bool_attribute(ID::keep)) {
- bool found_keep = false;
+ bool found_keep = false;
+ if (module->get_bool_attribute(ID::keep))
+ found_keep = true;
+ else
for (auto cell : module->cells())
- if (query(cell)) found_keep = true;
- cache[module] = found_keep;
- }
+ if (query(cell, true /* ignore_specify */)) {
+ found_keep = true;
+ break;
+ }
+ cache[module] = found_keep;
- return cache[module];
+ return found_keep;
}
- bool query(Cell *cell)
+ bool query(Cell *cell, bool ignore_specify = false)
{
- if (cell->type.in(ID($memwr), ID($meminit), ID($assert), ID($assume), ID($live), ID($fair), ID($cover), ID($specify2), ID($specify3), ID($specrule)))
+ if (cell->type.in(ID($memwr), ID($meminit), ID($assert), ID($assume), ID($live), ID($fair), ID($cover)))
+ return true;
+
+ if (!ignore_specify && cell->type.in(ID($specify2), ID($specify3), ID($specrule)))
return true;
if (cell->has_keep_attr())