From 3d45ce0fbcd729a305b41394f47c06006739fb3d Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Tue, 21 Jul 2026 12:53:38 +0200 Subject: [PATCH] sigmap: take the signorm index's map directly instead of via connections() --- kernel/rtlil.h | 4 ++++ kernel/rtlil_bufnorm.cc | 16 ++++++++++++++++ kernel/sigtools.h | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index d30b71bc3..827e3972b 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -144,6 +144,8 @@ namespace RTLIL struct PortBit; }; +struct SigMap; + // TODO clean up? extern int64_t signorm_ns; @@ -3077,6 +3079,8 @@ public: const pool &fanout(SigBit bit); const dict> &signorm_fanout() const; + const SigMap *signorm_sigmap(); + // Equivalent to `connect(lhs, rhs)` followed by `sigNormalize()` for the // merge implied by this single connection: updates the sigmap, promotes // the driven side as canonical, and re-normalizes any existing fanout diff --git a/kernel/rtlil_bufnorm.cc b/kernel/rtlil_bufnorm.cc index 2a7612e47..68395727a 100644 --- a/kernel/rtlil_bufnorm.cc +++ b/kernel/rtlil_bufnorm.cc @@ -278,6 +278,7 @@ struct RTLIL::SigNormIndex signorm_restore_ns += time_ns; ++signorm_restore_count; } + }; @@ -422,6 +423,21 @@ const std::vector &RTLIL::Module::connections() const return connections_; } +const SigMap *RTLIL::Module::signorm_sigmap() +{ + if (sig_norm_index == nullptr) + return nullptr; + + int64_t start = PerformanceTimer::query(); + sig_norm_index->flush_connections(); + int64_t time_ns = PerformanceTimer::query() - start; + Pass::subtract_from_current_runtime_ns(time_ns); + signorm_restore_ns += time_ns; + ++signorm_restore_count; + + return &sig_norm_index->sigmap; +} + void RTLIL::Module::new_connections(const std::vector &new_conn) { if (sig_norm_index != nullptr) { diff --git a/kernel/sigtools.h b/kernel/sigtools.h index 59be817d8..9c71dfab7 100644 --- a/kernel/sigtools.h +++ b/kernel/sigtools.h @@ -301,6 +301,11 @@ struct SigMap final : public SigMapView // Rebuild SigMap for all connections in module void set(RTLIL::Module *module) { + if (const SigMap *index_sigmap = module->signorm_sigmap()) { + database = index_sigmap->database; + return; + } + int bitcount = 0; for (auto &it : module->connections()) bitcount += it.first.size();