From effc52fedccca3659f225f3c72f07abc19eeec44 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 23 Sep 2025 03:25:16 +0000 Subject: [PATCH] Make `ID::` constants be `StaticIdString`s for better optimization. Their internal indexes will be known at compile time, like we already support for the `ID()` macro. --- kernel/rtlil.cc | 2 +- kernel/rtlil.h | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 7d53fdd32..35776746d 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -46,7 +46,7 @@ int RTLIL::IdString::last_created_idx_[8]; int RTLIL::IdString::last_created_idx_ptr_; #endif -#define X(N) const RTLIL::IdString RTLIL::ID::N(RTLIL::StaticId::N); +#define X(_id) const RTLIL::IdString RTLIL::IDInternal::_id(RTLIL::StaticId::_id); #include "kernel/constids.inc" #undef X diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 096d1dfcf..88594859a 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -495,9 +495,14 @@ inline bool RTLIL::IdString::operator!=(const RTLIL::StaticIdString &rhs) const } namespace RTLIL { - namespace ID { + namespace IDInternal { #define X(_id) extern const IdString _id; #include "kernel/constids.inc" +#undef X + } + namespace ID { +#define X(_id) constexpr StaticIdString _id(StaticId::_id, IDInternal::_id); +#include "kernel/constids.inc" #undef X } } @@ -508,7 +513,7 @@ struct IdTableEntry { }; constexpr IdTableEntry IdTable[] = { -#define X(_id) {#_id, RTLIL::StaticIdString(RTLIL::StaticId::_id, RTLIL::ID::_id)}, +#define X(_id) {#_id, ID::_id}, #include "kernel/constids.inc" #undef X };