From 3a674688607d07e53bfa3656b9b240e8ae0f69d9 Mon Sep 17 00:00:00 2001 From: Akash Levy Date: Tue, 4 Mar 2025 23:47:48 -0800 Subject: [PATCH] Use ordered set for src attrs when flattening --- kernel/rtlil.cc | 11 ++++++----- kernel/rtlil.h | 6 +++--- passes/techmap/techmap.cc | 3 ++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 8f3a72e6f..a83c2fa31 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -30,6 +30,7 @@ #include #include #include +#include YOSYS_NAMESPACE_BEGIN @@ -688,7 +689,7 @@ string RTLIL::AttrObject::get_string_attribute(const RTLIL::IdString &id) const return value; } -void RTLIL::AttrObject::set_strpool_attribute(const RTLIL::IdString& id, const pool &data) +void RTLIL::AttrObject::set_strpool_attribute(const RTLIL::IdString& id, const std::set &data) { string attrval; for (const auto &s : data) { @@ -699,17 +700,17 @@ void RTLIL::AttrObject::set_strpool_attribute(const RTLIL::IdString& id, const p set_string_attribute(id, attrval); } -void RTLIL::AttrObject::add_strpool_attribute(const RTLIL::IdString& id, const pool &data) +void RTLIL::AttrObject::add_strpool_attribute(const RTLIL::IdString& id, const std::set &data) { - pool union_data = get_strpool_attribute(id); + 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); } -pool RTLIL::AttrObject::get_strpool_attribute(const RTLIL::IdString &id) const +std::set RTLIL::AttrObject::get_strpool_attribute(const RTLIL::IdString &id) const { - pool data; + std::set data; if (attributes.count(id) != 0) for (auto s : split_tokens(get_string_attribute(id), "|")) data.insert(s); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 6826aca5a..29e915d0c 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -855,9 +855,9 @@ struct RTLIL::AttrObject void set_string_attribute(const RTLIL::IdString& id, string value); string get_string_attribute(const RTLIL::IdString &id) const; - void set_strpool_attribute(const RTLIL::IdString& id, const pool &data); - void add_strpool_attribute(const RTLIL::IdString& id, const pool &data); - pool get_strpool_attribute(const RTLIL::IdString &id) const; + void set_strpool_attribute(const RTLIL::IdString& id, const std::set &data); + void add_strpool_attribute(const RTLIL::IdString& id, const std::set &data); + std::set get_strpool_attribute(const RTLIL::IdString &id) const; void set_src_attribute(const std::string &src) { set_string_attribute(ID::src, src); diff --git a/passes/techmap/techmap.cc b/passes/techmap/techmap.cc index 0268ecd3b..1c3d24516 100644 --- a/passes/techmap/techmap.cc +++ b/passes/techmap/techmap.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include "simplemap.h" @@ -156,7 +157,7 @@ struct TechmapWorker } std::string orig_cell_name; - pool extra_src_attrs = cell->get_strpool_attribute(ID::src); + std::set extra_src_attrs = cell->get_strpool_attribute(ID::src); orig_cell_name = cell->name.str(); for (auto tpl_cell : tpl->cells())