From 8117ab228e747aab0c7014d6e5b11b52cbaefde2 Mon Sep 17 00:00:00 2001 From: Akash Levy Date: Wed, 5 Mar 2025 03:28:19 -0800 Subject: [PATCH] Use set for strpool_attribute to maintain ordering, but keep some backwards compatibility --- kernel/hashlib.h | 6 ++++++ kernel/rtlil.cc | 8 ++++++++ kernel/rtlil.h | 1 + passes/techmap/techmap.cc | 3 +-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 6e3eb32a4..5a316a636 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -1001,6 +1002,11 @@ public: { } + pool(std::set other) { + for (auto it : other) + insert(it); + } + pool(const pool &other) { entries = other.entries; diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index a83c2fa31..6bc18a3d1 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -708,6 +708,14 @@ void RTLIL::AttrObject::add_strpool_attribute(const RTLIL::IdString& id, const s set_strpool_attribute(id, union_data); } +void RTLIL::AttrObject::add_strpool_attribute(const RTLIL::IdString& id, const pool &data) +{ + std::set union_data = get_strpool_attribute(id); + union_data.insert(data.begin(), data.end()); + if (!union_data.empty()) + set_strpool_attribute(id, union_data); +} + std::set RTLIL::AttrObject::get_strpool_attribute(const RTLIL::IdString &id) const { std::set data; diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 29e915d0c..318bb7e37 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -857,6 +857,7 @@ struct RTLIL::AttrObject void set_strpool_attribute(const RTLIL::IdString& id, const std::set &data); void add_strpool_attribute(const RTLIL::IdString& id, const std::set &data); + void add_strpool_attribute(const RTLIL::IdString& id, const pool &data); std::set get_strpool_attribute(const RTLIL::IdString &id) const; void set_src_attribute(const std::string &src) { diff --git a/passes/techmap/techmap.cc b/passes/techmap/techmap.cc index 1c3d24516..0268ecd3b 100644 --- a/passes/techmap/techmap.cc +++ b/passes/techmap/techmap.cc @@ -26,7 +26,6 @@ #include #include #include -#include #include "simplemap.h" @@ -157,7 +156,7 @@ struct TechmapWorker } std::string orig_cell_name; - std::set extra_src_attrs = cell->get_strpool_attribute(ID::src); + pool extra_src_attrs = cell->get_strpool_attribute(ID::src); orig_cell_name = cell->name.str(); for (auto tpl_cell : tpl->cells())