3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-19 05:35:47 +00:00

WIP migration to twine

This commit is contained in:
Emil J. Tywoniak 2026-06-18 21:54:57 +02:00
parent 0c450ce8c8
commit bffe7a6e57
7 changed files with 62 additions and 32 deletions

View file

@ -2097,8 +2097,10 @@ namespace {
void check()
{
if (!cell->type.begins_with("$") || cell->type.begins_with("$__") || cell->type.begins_with("$paramod") || cell->type.begins_with("$fmcombine") ||
cell->type.begins_with("$verific$") || cell->type.begins_with("$array:") || cell->type.begins_with("$extern:"))
std::string type_str = cell->type.str();
std::string_view type_sv = type_str;
if (!type_sv.starts_with("$") || type_sv.starts_with("$__") || type_sv.starts_with("$paramod") || type_sv.starts_with("$fmcombine") ||
type_sv.starts_with("$verific$") || type_sv.starts_with("$array:") || type_sv.starts_with("$extern:"))
return;
if (cell->type_impl == TW($buf)) {
@ -5258,8 +5260,10 @@ void RTLIL::Cell::check()
void RTLIL::Cell::fixup_parameters(bool set_a_signed, bool set_b_signed)
{
if (!type.begins_with("$") || type.begins_with("$_") || type.begins_with("$paramod") || type.begins_with("$fmcombine") ||
type.begins_with("$verific$") || type.begins_with("$array:") || type.begins_with("$extern:"))
std::string type_str = type.str();
std::string_view type_sv = type_str;
if (!type_sv.starts_with("$") || type_sv.starts_with("$_") || type_sv.starts_with("$paramod") || type_sv.starts_with("$fmcombine") ||
type_sv.starts_with("$verific$") || type_sv.starts_with("$array:") || type_sv.starts_with("$extern:"))
return;
if (type == TW($buf) || type == TW($mux) || type == TW($pmux) || type == TW($bmux) || type == TW($bwmux) || type == TW($bweqx)) {

View file

@ -549,7 +549,7 @@ struct RTLIL::IdString
template<typename T> struct compare_ptr_by_name {
bool operator()(const T *a, const T *b) const {
return (a == nullptr || b == nullptr) ? (a < b) : (a->name < b->name);
return (a == nullptr || b == nullptr) ? (a < b) : (a->name.ref() < b->name.ref());
}
};

View file

@ -229,11 +229,33 @@ struct TwinePool {
}
}, (*this)[ref].data);
}
void append_str(TwineRef ref, std::string& out) const {
if (ref == Twine::Null)
return;
if (twine_is_public(ref))
out += '\\';
std::visit([&](const auto& val) {
using T = std::decay_t<decltype(val)>;
if constexpr (std::is_same_v<T, std::monostate>) {
} else if constexpr (std::is_same_v<T, std::string>) {
out += val;
} else if constexpr (std::is_same_v<T, std::vector<TwineRef>>) {
for (size_t i = 0; i < val.size(); ++i) {
if (i > 0)
out += '|';
append_str(val[i], out);
}
} else if constexpr (std::is_same_v<T, Twine::Suffix>) {
append_str(val.prefix, out);
out += val.tail;
}
}, (*this)[ref].data);
}
// Escaped form: leading '\' for public name handles, content otherwise.
std::string str(TwineRef ref) const {
std::ostringstream os;
print(ref, os);
return os.str();
std::string out;
append_str(ref, out);
return out;
}
// Name content without the publicity escape.