3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-09-11 04:01:28 +00:00

Add a compile time check that kernel/constids.inc is sorted

This is an invariant now required by the ID macro, so it's better to
have an actual check and not rely on a comment at the top of
kernel/constids.inc.
This commit is contained in:
Jannis Harder 2025-09-08 11:49:21 +02:00
parent 6921a2cc3e
commit 6a1d8abf7c

View file

@ -72,6 +72,19 @@ void RTLIL::IdString::prepopulate()
#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() {