From d33acfe65ffc21c59f5a0740222838fc05b655ba Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Tue, 24 Feb 2026 13:03:16 +0100 Subject: [PATCH] opt_clean: refactor --- passes/opt/opt_clean/Makefile.inc | 15 ++++++++++----- passes/opt/opt_clean/cells_all.cc | 9 +-------- passes/opt/opt_clean/cells_temp.cc | 9 +-------- passes/opt/opt_clean/inits.cc | 9 +-------- passes/opt/opt_clean/opt_clean.cc | 12 +----------- passes/opt/opt_clean/{shared.h => opt_clean.h} | 4 ---- passes/opt/opt_clean/wires.cc | 10 +--------- 7 files changed, 15 insertions(+), 53 deletions(-) rename passes/opt/opt_clean/{shared.h => opt_clean.h} (97%) diff --git a/passes/opt/opt_clean/Makefile.inc b/passes/opt/opt_clean/Makefile.inc index 86b7cd913..b4bb5b070 100644 --- a/passes/opt/opt_clean/Makefile.inc +++ b/passes/opt/opt_clean/Makefile.inc @@ -1,5 +1,10 @@ -OBJS += passes/opt/opt_clean/cells_all.o -OBJS += passes/opt/opt_clean/cells_temp.o -OBJS += passes/opt/opt_clean/wires.o -OBJS += passes/opt/opt_clean/inits.o -OBJS += passes/opt/opt_clean/opt_clean.o \ No newline at end of file +OPT_CLEAN_OBJS = +OPT_CLEAN_OBJS += passes/opt/opt_clean/cells_all.o +OPT_CLEAN_OBJS += passes/opt/opt_clean/cells_temp.o +OPT_CLEAN_OBJS += passes/opt/opt_clean/wires.o +OPT_CLEAN_OBJS += passes/opt/opt_clean/inits.o +OPT_CLEAN_OBJS += passes/opt/opt_clean/opt_clean.o + +$(OPT_CLEAN_OBJS): passes/opt/opt_clean/opt_clean.h + +OBJS += $(OPT_CLEAN_OBJS) diff --git a/passes/opt/opt_clean/cells_all.cc b/passes/opt/opt_clean/cells_all.cc index 160d2d32d..353ada180 100644 --- a/passes/opt/opt_clean/cells_all.cc +++ b/passes/opt/opt_clean/cells_all.cc @@ -17,15 +17,8 @@ * */ -#include "kernel/register.h" -#include "kernel/sigtools.h" -#include "kernel/log.h" -#include "kernel/celltypes.h" #include "kernel/ffinit.h" -#include "kernel/threading.h" -#include "kernel/yosys_common.h" -#include "passes/opt/opt_clean/keep_cache.h" -#include "passes/opt/opt_clean/shared.h" +#include "passes/opt/opt_clean/opt_clean.h" YOSYS_NAMESPACE_BEGIN diff --git a/passes/opt/opt_clean/cells_temp.cc b/passes/opt/opt_clean/cells_temp.cc index 9643e0443..b325b68d9 100644 --- a/passes/opt/opt_clean/cells_temp.cc +++ b/passes/opt/opt_clean/cells_temp.cc @@ -17,14 +17,7 @@ * */ -#include "kernel/register.h" -#include "kernel/sigtools.h" -#include "kernel/log.h" -#include "kernel/celltypes.h" -#include "kernel/ffinit.h" -#include "kernel/threading.h" -#include "kernel/yosys_common.h" -#include "passes/opt/opt_clean/shared.h" +#include "passes/opt/opt_clean/opt_clean.h" USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN diff --git a/passes/opt/opt_clean/inits.cc b/passes/opt/opt_clean/inits.cc index b2d1674b2..bd0756561 100644 --- a/passes/opt/opt_clean/inits.cc +++ b/passes/opt/opt_clean/inits.cc @@ -17,14 +17,7 @@ * */ -#include "kernel/register.h" -#include "kernel/sigtools.h" -#include "kernel/log.h" -#include "kernel/celltypes.h" -#include "kernel/ffinit.h" -#include "kernel/threading.h" -#include "kernel/yosys_common.h" -#include "passes/opt/opt_clean/shared.h" +#include "passes/opt/opt_clean/opt_clean.h" USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN diff --git a/passes/opt/opt_clean/opt_clean.cc b/passes/opt/opt_clean/opt_clean.cc index ac861bfc6..a53085fc2 100644 --- a/passes/opt/opt_clean/opt_clean.cc +++ b/passes/opt/opt_clean/opt_clean.cc @@ -18,22 +18,12 @@ */ #include "kernel/register.h" -#include "kernel/sigtools.h" #include "kernel/log.h" -#include "kernel/celltypes.h" -#include "kernel/ffinit.h" -#include "kernel/threading.h" -#include -#include -#include -#include "passes/opt/opt_clean/shared.h" -#include "passes/opt/opt_clean/keep_cache.h" +#include "passes/opt/opt_clean/opt_clean.h" USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN -using RTLIL::id2cstr; - void rmunused_module(RTLIL::Module *module, bool rminit, CleanRunContext &clean_ctx) { if (clean_ctx.flags.verbose) diff --git a/passes/opt/opt_clean/shared.h b/passes/opt/opt_clean/opt_clean.h similarity index 97% rename from passes/opt/opt_clean/shared.h rename to passes/opt/opt_clean/opt_clean.h index 89f74e8ad..710911b85 100644 --- a/passes/opt/opt_clean/shared.h +++ b/passes/opt/opt_clean/opt_clean.h @@ -18,10 +18,7 @@ */ #include "kernel/rtlil.h" -#include "kernel/sigtools.h" #include "kernel/threading.h" -#include "kernel/celltypes.h" -#include "kernel/yosys_common.h" #include "passes/opt/opt_clean/keep_cache.h" #ifndef OPT_CLEAN_SHARED_H @@ -29,7 +26,6 @@ YOSYS_NAMESPACE_BEGIN - struct AnalysisContext { SigMap assign_map; const RTLIL::Module *mod; diff --git a/passes/opt/opt_clean/wires.cc b/passes/opt/opt_clean/wires.cc index c2e3c0110..55836457b 100644 --- a/passes/opt/opt_clean/wires.cc +++ b/passes/opt/opt_clean/wires.cc @@ -17,15 +17,7 @@ * */ -#include "kernel/register.h" -#include "kernel/sigtools.h" -#include "kernel/log.h" -#include "kernel/celltypes.h" -#include "kernel/ffinit.h" -#include "kernel/threading.h" -#include "kernel/yosys_common.h" -#include "passes/opt/opt_clean/shared.h" -#include "passes/opt/opt_clean/parallel.h" +#include "passes/opt/opt_clean/opt_clean.h" USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN