3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-20 22:25:49 +00:00

Merge upstream in

This commit is contained in:
Akash Levy 2025-09-09 05:50:48 -07:00
parent 36b753285c
commit 1b3375d8df
117 changed files with 1890 additions and 984 deletions

View file

@ -31,6 +31,7 @@
#include <algorithm>
#include <optional>
#include <set>
#include <string_view>
YOSYS_NAMESPACE_BEGIN
@ -39,7 +40,7 @@ RTLIL::IdString::destruct_guard_t RTLIL::IdString::destruct_guard;
std::vector<char*> RTLIL::IdString::global_id_storage_;
std::unordered_map<std::string_view, int> RTLIL::IdString::global_id_index_;
#ifndef YOSYS_NO_IDS_REFCNT
std::vector<int> RTLIL::IdString::global_refcount_storage_;
std::vector<uint32_t> RTLIL::IdString::global_refcount_storage_;
std::vector<int> RTLIL::IdString::global_free_idx_list_;
#endif
#ifdef YOSYS_USE_STICKY_IDS
@ -47,10 +48,45 @@ int RTLIL::IdString::last_created_idx_[8];
int RTLIL::IdString::last_created_idx_ptr_;
#endif
#define X(_id) IdString RTLIL::ID::_id;
#define X(N) const RTLIL::IdString RTLIL::ID::N(RTLIL::StaticId::N);
#include "kernel/constids.inc"
#undef X
static void populate(std::string_view name)
{
if (name[1] == '$') {
// Skip prepended '\'
name = name.substr(1);
}
RTLIL::IdString::global_id_index_.insert({name, GetSize(RTLIL::IdString::global_id_storage_)});
RTLIL::IdString::global_id_storage_.push_back(const_cast<char*>(name.data()));
}
void RTLIL::IdString::prepopulate()
{
int size = static_cast<short>(RTLIL::StaticId::STATIC_ID_END);
global_id_storage_.reserve(size);
RTLIL::IdString::global_id_storage_.push_back(const_cast<char*>(""));
global_id_index_.reserve(size);
global_refcount_storage_.resize(size, 1);
#define X(N) populate("\\" #N);
#include "kernel/constids.inc"
#undef X
}
static constexpr bool check_well_known_id_order()
{
int size = sizeof(IdTable) / sizeof(IdTable[0]);
for (int i = 1; i < size; ++i)
if (IdTable[i - 1].name >= IdTable[i].name)
return false;
return true;
}
// Ensure the statically allocated IdStrings in kernel/constids.inc are unique
// and in sorted ascii order, as required by the ID macro.
static_assert(check_well_known_id_order());
dict<std::string, std::string> RTLIL::constpad;
const pool<IdString> &RTLIL::builtin_ff_cell_types() {
@ -2805,7 +2841,7 @@ RTLIL::IdString RTLIL::Module::uniquify(RTLIL::IdString name, int &index)
}
while (1) {
RTLIL::IdString new_name = stringf("%s_%d", name.c_str(), index);
RTLIL::IdString new_name = stringf("%s_%d", name, index);
if (count_id(new_name) == 0)
return new_name;
index++;