From 164dd0f6b298e416bd1ef882f21a4d0b5acfd039 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Thu, 12 Mar 2020 12:54:30 -0700 Subject: [PATCH] kernel: Use constids.inc for global/constant IdStrings --- kernel/constids.inc | 27 +++++++++++++++++++++++++++ kernel/rtlil.cc | 10 ++++------ kernel/rtlil.h | 8 +++----- kernel/yosys.cc | 9 +++------ 4 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 kernel/constids.inc diff --git a/kernel/constids.inc b/kernel/constids.inc new file mode 100644 index 000000000..18be12229 --- /dev/null +++ b/kernel/constids.inc @@ -0,0 +1,27 @@ +X(A) +X(B) +X(S) +X(Y) +X(keep) +X(src) +X(whitebox) +X(blackbox) +X(allconst) +X(allseq) +X(anyconst) +X(anyseq) +X(defaultvalue) +X(fsm_encoding) +X(full_case) +X(gclk) +X(initial_top) +X(is_interface) +X(mem2reg) +X(noblackbox) +X(nolatches) +X(nomem2reg) +X(nosync) +X(parallel_case) +X(top) +X(wand) +X(wor) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index d04524387..83e324535 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -41,12 +41,10 @@ int RTLIL::IdString::last_created_idx_[8]; int RTLIL::IdString::last_created_idx_ptr_; #endif -IdString RTLIL::ID::A; -IdString RTLIL::ID::B; -IdString RTLIL::ID::Y; -IdString RTLIL::ID::keep; -IdString RTLIL::ID::whitebox; -IdString RTLIL::ID::blackbox; +#define X(_id) IdString RTLIL::ID::_id; +#include "constids.inc" +#undef X + dict RTLIL::constpad; RTLIL::Const::Const() diff --git a/kernel/rtlil.h b/kernel/rtlil.h index a1754c8bd..7c1523f0b 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -370,11 +370,9 @@ namespace RTLIL }; namespace ID { - // defined in rtlil.cc, initialized in yosys.cc - extern IdString A, B, Y; - extern IdString keep; - extern IdString whitebox; - extern IdString blackbox; +#define X(_id) extern IdString _id; +#include "constids.inc" +#undef X }; extern dict constpad; diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 6d64e2e90..380f7030b 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -515,12 +515,9 @@ void yosys_setup() return; already_setup = true; - RTLIL::ID::A = "\\A"; - RTLIL::ID::B = "\\B"; - RTLIL::ID::Y = "\\Y"; - RTLIL::ID::keep = "\\keep"; - RTLIL::ID::whitebox = "\\whitebox"; - RTLIL::ID::blackbox = "\\blackbox"; +#define X(_id) RTLIL::ID::_id = "\\" # _id; +#include "constids.inc" +#undef X #ifdef WITH_PYTHON PyImport_AppendInittab((char*)"libyosys", INIT_MODULE); -- 2.30.2