From 63043901ea9471232c630273d9788ef7c9e17e66 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Fri, 19 Jun 2026 11:36:51 +0200 Subject: [PATCH] twine: switch to std::deque from forked plf::colony --- .gitmodules | 3 --- kernel/twine.h | 34 ++++++++++++++-------------------- libs/plf_colony | 1 - 3 files changed, 14 insertions(+), 24 deletions(-) delete mode 160000 libs/plf_colony diff --git a/.gitmodules b/.gitmodules index d59194376..9f18be11e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,6 +5,3 @@ [submodule "cxxopts"] path = libs/cxxopts url = https://github.com/jarro2783/cxxopts -[submodule "libs/plf_colony"] - path = libs/plf_colony - url = git@github.com:mattreecebentley/plf_colony.git diff --git a/kernel/twine.h b/kernel/twine.h index 2ea55c238..8f9372061 100644 --- a/kernel/twine.h +++ b/kernel/twine.h @@ -6,9 +6,9 @@ #include -#include "libs/plf_colony/plf_colony.h" #include #include +#include #include #include #include @@ -164,7 +164,7 @@ void twine_prepopulate(); struct TwinePool { static std::vector globals_; - plf::colony backing; + std::deque backing; std::unordered_set index; // Indices of monostate, kept sorted std::vector free_list; @@ -172,12 +172,8 @@ struct TwinePool { const Twine& operator[] (TwineRef ref) const { ref = twine_untag(ref); if (ref < STATIC_TWINE_END) { - // if (yosys_xtrace) - // std::cout << "#X# accessing " << (size_t)ref << " from globals\n"; return globals_[ref]; } else { - // if (yosys_xtrace) - // std::cout << "#X# accessing " << (size_t)ref << " from colony of size " << backing.size() << "\n"; return backing[ref - STATIC_TWINE_END]; } } @@ -293,9 +289,8 @@ struct TwinePool { for (TwineRef ref = 0; ref < STATIC_TWINE_END; ref++) index.insert(ref); free_list.clear(); - for (auto it = backing.begin(); it != backing.end(); ++it) { - size_t idx = backing.get_index(it); - if (it->is_dead()) + for (size_t idx = 0; idx < backing.size(); ++idx) { + if (backing[idx].is_dead()) free_list.push_back(idx); else index.insert(STATIC_TWINE_END + idx); @@ -350,8 +345,8 @@ struct TwinePool { backing[idx] = std::move(t); ref = STATIC_TWINE_END + idx; } else { - auto colony_it = backing.insert(std::move(t)); - ref = STATIC_TWINE_END + backing.get_index(colony_it); + ref = STATIC_TWINE_END + backing.size(); + backing.push_back(std::move(t)); } index.insert(ref); if (yosys_xtrace) { @@ -430,14 +425,13 @@ struct TwinePool { for (TwineRef ref : roots) mark_live(ref, live); size_t erased = 0; - for (auto it = backing.begin(); it != backing.end(); ++it) { - if (it->is_dead()) + for (size_t idx = 0; idx < backing.size(); ++idx) { + if (backing[idx].is_dead()) continue; - size_t idx = backing.get_index(it); if (!live.count(STATIC_TWINE_END + idx)) { index.erase(STATIC_TWINE_END + idx); free_list.push_back(idx); - *it = Twine{}; + backing[idx] = Twine{}; erased++; } } @@ -461,8 +455,8 @@ struct TwinePool { void dump(std::ostream& os = std::cout) const { os << "--- TwinePool Dump (" << backing.size() << " nodes) ---\n"; - for (auto it = backing.begin(); it != backing.end(); ++it) { - TwineRef ref = STATIC_TWINE_END + backing.get_index(it); + for (size_t idx = 0; idx < backing.size(); ++idx) { + TwineRef ref = STATIC_TWINE_END + idx; os << ref << " -> "; dump(ref, os); os << '\n'; @@ -716,10 +710,10 @@ struct TwineSearch { TwineSearch(const TwinePool* pool) : pool(pool), index(0, DeepTwineHash{pool}, DeepTwineEq{pool}) { for (TwineRef ref = 0; ref < STATIC_TWINE_END; ref++) index.insert(ref); - for (auto it = pool->backing.begin(); it != pool->backing.end(); ++it) { - if (it->is_dead()) + for (size_t idx = 0; idx < pool->backing.size(); ++idx) { + if (pool->backing[idx].is_dead()) continue; - index.insert(STATIC_TWINE_END + pool->backing.get_index(it)); + index.insert(STATIC_TWINE_END + idx); } } // Escaped-name aware. Resolves both statics and locals by content. diff --git a/libs/plf_colony b/libs/plf_colony deleted file mode 160000 index bdc219742..000000000 --- a/libs/plf_colony +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bdc219742d116b569c2a44956ba0aba5f3ef5717