twine: remove LeafIdString since it was designed to cope with lack of content hashing

This commit is contained in:
Emil J. Tywoniak
2026-10-02 18:42:02 +02:00
parent 090ac110a8
commit ea4634ecee
65 changed files with 194 additions and 233 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ struct AigMaker
int inport(IdString portname, int portbit = 0, bool inverter = false)
{
if (portbit >= GetSize(cell->getPort(portname))) {
LeafIdString signed_param = cell->twines().find(
IdString signed_param = cell->twines().find(
cell->twines().str(portname) + "_SIGNED");
if (signed_param != IdString::Null && cell->parameters.count(signed_param) && cell->getParam(signed_param).as_bool())
return inport(portname, GetSize(cell->getPort(portname))-1, inverter);
+3 -3
View File
@@ -105,7 +105,7 @@ static bool is_free(RTLIL::IdString type)
unsigned int max_inp_width(RTLIL::Cell *cell)
{
unsigned int max = 0;
RTLIL::LeafIdString input_width_params[] = {
RTLIL::IdString input_width_params[] = {
ID::WIDTH,
ID::A_WIDTH,
ID::B_WIDTH,
@@ -115,7 +115,7 @@ unsigned int max_inp_width(RTLIL::Cell *cell)
if (cell->type == ID($bmux))
return cell->getParam(ID::WIDTH).as_int() << cell->getParam(ID::S_WIDTH).as_int();
for (RTLIL::LeafIdString param : input_width_params)
for (RTLIL::IdString param : input_width_params)
if (cell->hasParam(param))
max = std::max(max, (unsigned int)cell->getParam(param).as_int());
return max;
@@ -124,7 +124,7 @@ unsigned int max_inp_width(RTLIL::Cell *cell)
unsigned int port_width_sum(RTLIL::Cell *cell)
{
unsigned int sum = 0;
RTLIL::LeafIdString port_width_params[] = {
RTLIL::IdString port_width_params[] = {
ID::WIDTH, ID::A_WIDTH, ID::B_WIDTH, ID::S_WIDTH, ID::Y_WIDTH,
};
+1 -1
View File
@@ -169,7 +169,7 @@ struct FfData : FfTypeData {
Const val_init;
// The FF data width in bits.
int width;
dict<LeafIdString, Const> attributes;
dict<IdString, Const> attributes;
FfData(Module *module = nullptr, FfInitVals *initvals = nullptr, IdString name = IdString()) : module(module), initvals(initvals), cell(nullptr), name(name) {
width = 0;
+1 -1
View File
@@ -246,7 +246,7 @@ private:
return handle_alu(g, factory.bitwise_or(p, g), g.width(), false, ci, factory.constant(Const(State::S0, 1))).at(ID(CO));
}
public:
std::variant<dict<IdString, Node>, Node> handle(IdString cellName, IdString cellType, dict<LeafIdString, Const> parameters, dict<IdString, Node> inputs)
std::variant<dict<IdString, Node>, Node> handle(IdString cellName, IdString cellType, dict<IdString, Const> parameters, dict<IdString, Node> inputs)
{
int a_width = parameters.at(ID(A_WIDTH), Const(-1)).as_int();
int b_width = parameters.at(ID(B_WIDTH), Const(-1)).as_int();
+27 -27
View File
@@ -637,12 +637,12 @@ RTLIL::Const RTLIL::Const::extract(int offset, int len, RTLIL::State padding) co
}
#undef check /* check(condition) for Const */
bool RTLIL::AttrObject::has_attribute(RTLIL::LeafIdString id) const
bool RTLIL::AttrObject::has_attribute(RTLIL::IdString id) const
{
return attributes.count(id);
}
void RTLIL::AttrObject::set_bool_attribute(RTLIL::LeafIdString id, bool value)
void RTLIL::AttrObject::set_bool_attribute(RTLIL::IdString id, bool value)
{
if (value)
attributes[id] = RTLIL::Const(1);
@@ -650,7 +650,7 @@ void RTLIL::AttrObject::set_bool_attribute(RTLIL::LeafIdString id, bool value)
attributes.erase(id);
}
bool RTLIL::AttrObject::get_bool_attribute(RTLIL::LeafIdString id) const
bool RTLIL::AttrObject::get_bool_attribute(RTLIL::IdString id) const
{
const auto it = attributes.find(id);
if (it == attributes.end())
@@ -658,7 +658,7 @@ bool RTLIL::AttrObject::get_bool_attribute(RTLIL::LeafIdString id) const
return it->second.as_bool();
}
void RTLIL::AttrObject::set_string_attribute(RTLIL::LeafIdString id, string value)
void RTLIL::AttrObject::set_string_attribute(RTLIL::IdString id, string value)
{
if (value.empty())
attributes.erase(id);
@@ -666,7 +666,7 @@ void RTLIL::AttrObject::set_string_attribute(RTLIL::LeafIdString id, string valu
attributes[id] = value;
}
string RTLIL::AttrObject::get_string_attribute(RTLIL::LeafIdString id) const
string RTLIL::AttrObject::get_string_attribute(RTLIL::IdString id) const
{
std::string value;
const auto it = attributes.find(id);
@@ -675,7 +675,7 @@ string RTLIL::AttrObject::get_string_attribute(RTLIL::LeafIdString id) const
return value;
}
void RTLIL::AttrObject::set_strpool_attribute(RTLIL::LeafIdString id, const pool<string> &data)
void RTLIL::AttrObject::set_strpool_attribute(RTLIL::IdString id, const pool<string> &data)
{
string attrval;
for (const auto &s : data) {
@@ -686,7 +686,7 @@ void RTLIL::AttrObject::set_strpool_attribute(RTLIL::LeafIdString id, const pool
set_string_attribute(id, attrval);
}
void RTLIL::AttrObject::add_strpool_attribute(RTLIL::LeafIdString id, const pool<string> &data)
void RTLIL::AttrObject::add_strpool_attribute(RTLIL::IdString id, const pool<string> &data)
{
pool<string> union_data = get_strpool_attribute(id);
union_data.insert(data.begin(), data.end());
@@ -694,7 +694,7 @@ void RTLIL::AttrObject::add_strpool_attribute(RTLIL::LeafIdString id, const pool
set_strpool_attribute(id, union_data);
}
void RTLIL::Design::absorb_attrs(RTLIL::AttrObject *obj, dict<LeafIdString, RTLIL::Const> &&buf)
void RTLIL::Design::absorb_attrs(RTLIL::AttrObject *obj, dict<IdString, RTLIL::Const> &&buf)
{
obj->attributes = std::move(buf);
}
@@ -817,7 +817,7 @@ size_t RTLIL::Design::gc_twines()
pool<string> RTLIL::AttrObject::get_strpool_attribute(RTLIL::LeafIdString id) const
pool<string> RTLIL::AttrObject::get_strpool_attribute(RTLIL::IdString id) const
{
pool<string> data;
if (attributes.count(id) != 0)
@@ -842,7 +842,7 @@ vector<string> RTLIL::AttrObject::get_hdlname_attribute() const
return split_tokens(get_string_attribute(ID::hdlname), " ");
}
void RTLIL::AttrObject::set_intvec_attribute(RTLIL::LeafIdString id, const vector<int> &data)
void RTLIL::AttrObject::set_intvec_attribute(RTLIL::IdString id, const vector<int> &data)
{
std::stringstream attrval;
for (auto &i : data) {
@@ -853,7 +853,7 @@ void RTLIL::AttrObject::set_intvec_attribute(RTLIL::LeafIdString id, const vecto
attributes[id] = RTLIL::Const(attrval.str());
}
vector<int> RTLIL::AttrObject::get_intvec_attribute(RTLIL::LeafIdString id) const
vector<int> RTLIL::AttrObject::get_intvec_attribute(RTLIL::IdString id) const
{
vector<int> data;
auto it = attributes.find(id);
@@ -1425,7 +1425,7 @@ bool RTLIL::Module::reprocess_if_necessary(RTLIL::Design *)
return false;
}
RTLIL::IdString RTLIL::Module::derive(RTLIL::Design*, const dict<RTLIL::LeafIdString, RTLIL::Const> &, bool mayfail)
RTLIL::IdString RTLIL::Module::derive(RTLIL::Design*, const dict<RTLIL::IdString, RTLIL::Const> &, bool mayfail)
{
if (mayfail)
return IdString::Null;
@@ -1433,7 +1433,7 @@ RTLIL::IdString RTLIL::Module::derive(RTLIL::Design*, const dict<RTLIL::LeafIdSt
}
RTLIL::IdString RTLIL::Module::derive(RTLIL::Design*, const dict<RTLIL::LeafIdString, RTLIL::Const> &, const dict<RTLIL::IdString, RTLIL::Module*> &, const dict<RTLIL::IdString, RTLIL::IdString> &, bool mayfail)
RTLIL::IdString RTLIL::Module::derive(RTLIL::Design*, const dict<RTLIL::IdString, RTLIL::Const> &, const dict<RTLIL::IdString, RTLIL::Module*> &, const dict<RTLIL::IdString, RTLIL::IdString> &, bool mayfail)
{
if (mayfail)
return IdString::Null;
@@ -1466,7 +1466,7 @@ namespace {
{
const RTLIL::Module *module;
RTLIL::Cell *cell;
pool<LeafIdString> expected_params;
pool<IdString> expected_params;
pool<IdString> expected_ports;
InternalCellChecker(const RTLIL::Module *module, RTLIL::Cell *cell) : module(module), cell(cell) { }
@@ -1483,7 +1483,7 @@ namespace {
cell_name, cell->type.str(), __FILE__, linenr, buf.str());
}
int param(RTLIL::LeafIdString name)
int param(RTLIL::IdString name)
{
auto it = cell->parameters.find(name);
if (it == cell->parameters.end())
@@ -1492,7 +1492,7 @@ namespace {
return it->second.as_int();
}
int param_bool(RTLIL::LeafIdString name)
int param_bool(RTLIL::IdString name)
{
int v = param(name);
if (GetSize(cell->parameters.at(name)) > 32)
@@ -1502,7 +1502,7 @@ namespace {
return v;
}
int param_bool(RTLIL::LeafIdString name, bool expected)
int param_bool(RTLIL::IdString name, bool expected)
{
int v = param_bool(name);
if (v != expected)
@@ -1510,14 +1510,14 @@ namespace {
return v;
}
void param_bits(RTLIL::LeafIdString name, int width)
void param_bits(RTLIL::IdString name, int width)
{
param(name);
if (GetSize(cell->parameters.at(name)) != width)
error(__LINE__);
}
std::string param_string(RTLIL::LeafIdString name)
std::string param_string(RTLIL::IdString name)
{
param(name);
return cell->parameters.at(name).decode_string();
@@ -2450,7 +2450,7 @@ void RTLIL::Module::sort()
}
#ifndef NDEBUG
static void check_id_keys(const dict<RTLIL::LeafIdString, RTLIL::Const> &keyed)
static void check_id_keys(const dict<RTLIL::IdString, RTLIL::Const> &keyed)
{
for (auto &it : keyed)
log_assert(!it.first.empty());
@@ -2601,7 +2601,7 @@ void RTLIL::Module::cloneInto(RTLIL::Module *new_mod) const
TwinePool &dst_twines = new_mod->twines();
new_mod->avail_parameters.clear();
for (LeafIdString param : avail_parameters)
for (IdString param : avail_parameters)
new_mod->avail_parameters(dst_twines.copy_from(design->twines, param));
new_mod->parameter_default_values.clear();
for (auto &it : parameter_default_values)
@@ -3059,8 +3059,8 @@ void RTLIL::Module::fixup_ports()
}
}
void RTLIL::copy_attr_dict(dict<LeafIdString, RTLIL::Const> &dst,
const dict<LeafIdString, RTLIL::Const> &src,
void RTLIL::copy_attr_dict(dict<IdString, RTLIL::Const> &dst,
const dict<IdString, RTLIL::Const> &src,
const RTLIL::Design *src_design, RTLIL::Design *dst_design)
{
if (!src_design || !dst_design || src_design == dst_design) {
@@ -4364,22 +4364,22 @@ RTLIL::PortDir RTLIL::Cell::port_dir(RTLIL::IdString portname) const
return PortDir::PD_UNKNOWN;
}
bool RTLIL::Cell::hasParam(RTLIL::LeafIdString paramname) const
bool RTLIL::Cell::hasParam(RTLIL::IdString paramname) const
{
return parameters.count(paramname) != 0;
}
void RTLIL::Cell::unsetParam(RTLIL::LeafIdString paramname)
void RTLIL::Cell::unsetParam(RTLIL::IdString paramname)
{
parameters.erase(paramname);
}
void RTLIL::Cell::setParam(RTLIL::LeafIdString paramname, RTLIL::Const value)
void RTLIL::Cell::setParam(RTLIL::IdString paramname, RTLIL::Const value)
{
parameters[paramname] = std::move(value);
}
const RTLIL::Const &RTLIL::Cell::getParam(RTLIL::LeafIdString paramname) const
const RTLIL::Const &RTLIL::Cell::getParam(RTLIL::IdString paramname) const
{
const auto &it = parameters.find(paramname);
if (it != parameters.end())
+24 -24
View File
@@ -125,11 +125,11 @@ struct SigMap;
namespace RTLIL { using YOSYS_NAMESPACE_PREFIX ID; }
namespace RTLIL { using YOSYS_NAMESPACE_PREFIX IdString; }
namespace RTLIL { using YOSYS_NAMESPACE_PREFIX LeafIdString; }
namespace RTLIL { using YOSYS_NAMESPACE_PREFIX IdString; }
namespace RTLIL {
void copy_attr_dict(dict<LeafIdString, RTLIL::Const> &dst,
const dict<LeafIdString, RTLIL::Const> &src,
void copy_attr_dict(dict<IdString, RTLIL::Const> &dst,
const dict<IdString, RTLIL::Const> &src,
const RTLIL::Design *src_design, RTLIL::Design *dst_design);
extern dict<std::string, std::string> constpad;
@@ -633,24 +633,24 @@ public:
struct RTLIL::AttrObject
{
dict<RTLIL::LeafIdString, RTLIL::Const> attributes;
dict<RTLIL::IdString, RTLIL::Const> attributes;
bool has_attribute(RTLIL::LeafIdString id) const;
bool has_attribute(RTLIL::IdString id) const;
void set_bool_attribute(RTLIL::LeafIdString id, bool value=true);
bool get_bool_attribute(RTLIL::LeafIdString id) const;
void set_bool_attribute(RTLIL::IdString id, bool value=true);
bool get_bool_attribute(RTLIL::IdString id) const;
[[deprecated("Use Module::get_blackbox_attribute() instead.")]]
bool get_blackbox_attribute(bool ignore_wb=false) const {
return get_bool_attribute(ID::blackbox) || (!ignore_wb && get_bool_attribute(ID::whitebox));
}
void set_string_attribute(RTLIL::LeafIdString id, string value);
string get_string_attribute(RTLIL::LeafIdString id) const;
void set_string_attribute(RTLIL::IdString id, string value);
string get_string_attribute(RTLIL::IdString id) const;
void set_strpool_attribute(RTLIL::LeafIdString id, const pool<string> &data);
void add_strpool_attribute(RTLIL::LeafIdString id, const pool<string> &data);
pool<string> get_strpool_attribute(RTLIL::LeafIdString id) const;
void set_strpool_attribute(RTLIL::IdString id, const pool<string> &data);
void add_strpool_attribute(RTLIL::IdString id, const pool<string> &data);
pool<string> get_strpool_attribute(RTLIL::IdString id) const;
void set_src_attribute(const std::string &src) {
set_string_attribute(ID::src, src);
@@ -662,8 +662,8 @@ struct RTLIL::AttrObject
void set_hdlname_attribute(const vector<string> &hierarchy);
vector<string> get_hdlname_attribute() const;
void set_intvec_attribute(RTLIL::LeafIdString id, const vector<int> &data);
vector<int> get_intvec_attribute(RTLIL::LeafIdString id) const;
void set_intvec_attribute(RTLIL::IdString id, const vector<int> &data);
vector<int> get_intvec_attribute(RTLIL::IdString id) const;
};
struct RTLIL::NamedObject : public RTLIL::AttrObject
@@ -1311,7 +1311,7 @@ struct RTLIL::Design
return twines.str(obj->name_);
}
void absorb_attrs(RTLIL::AttrObject *obj, dict<LeafIdString, RTLIL::Const> &&buf);
void absorb_attrs(RTLIL::AttrObject *obj, dict<IdString, RTLIL::Const> &&buf);
size_t gc_twines();
@@ -1500,15 +1500,15 @@ public:
std::vector<RTLIL::SigSig> connections_;
idict<RTLIL::LeafIdString> avail_parameters;
dict<RTLIL::LeafIdString, RTLIL::Const> parameter_default_values;
idict<RTLIL::IdString> avail_parameters;
dict<RTLIL::IdString, RTLIL::Const> parameter_default_values;
dict<RTLIL::IdString, RTLIL::Memory*> memories;
dict<RTLIL::IdString, RTLIL::Process*> processes;
Module();
virtual ~Module();
virtual RTLIL::IdString derive(RTLIL::Design *design, const dict<RTLIL::LeafIdString, RTLIL::Const> &parameters, bool mayfail = false);
virtual RTLIL::IdString derive(RTLIL::Design *design, const dict<RTLIL::LeafIdString, RTLIL::Const> &parameters, const dict<RTLIL::IdString, RTLIL::Module*> &interfaces, const dict<RTLIL::IdString, RTLIL::IdString> &modports, bool mayfail = false);
virtual RTLIL::IdString derive(RTLIL::Design *design, const dict<RTLIL::IdString, RTLIL::Const> &parameters, bool mayfail = false);
virtual RTLIL::IdString derive(RTLIL::Design *design, const dict<RTLIL::IdString, RTLIL::Const> &parameters, const dict<RTLIL::IdString, RTLIL::Module*> &interfaces, const dict<RTLIL::IdString, RTLIL::IdString> &modports, bool mayfail = false);
virtual size_t count_id(RTLIL::IdString id);
virtual void expand_interfaces(RTLIL::Design *design, const dict<RTLIL::IdString, RTLIL::Module *> &local_interfaces);
virtual bool reprocess_if_necessary(RTLIL::Design *design);
@@ -2018,7 +2018,7 @@ public:
IdString type_impl;
YS_NO_UNIQUE_ADDRESS RTLIL::IdFieldMasq<Cell, &Cell::type_impl> type;
dict<RTLIL::IdString, RTLIL::SigSpec> connections_;
dict<RTLIL::LeafIdString, RTLIL::Const> parameters;
dict<RTLIL::IdString, RTLIL::Const> parameters;
// access cell ports
bool hasPort(RTLIL::IdString portname) const;
@@ -2034,10 +2034,10 @@ public:
bool output(RTLIL::IdString portname) const;
PortDir port_dir(RTLIL::IdString portname) const;
bool hasParam(RTLIL::LeafIdString paramname) const;
void unsetParam(RTLIL::LeafIdString paramname);
void setParam(RTLIL::LeafIdString paramname, RTLIL::Const value);
const RTLIL::Const &getParam(RTLIL::LeafIdString paramname) const;
bool hasParam(RTLIL::IdString paramname) const;
void unsetParam(RTLIL::IdString paramname);
void setParam(RTLIL::IdString paramname, RTLIL::Const value);
const RTLIL::Const &getParam(RTLIL::IdString paramname) const;
template<typename N, YS_NAME_STRING(N)> bool hasParam(N name) const
{ return hasParam(module->twines().add(std::move(name))); }
+4 -4
View File
@@ -101,7 +101,7 @@ bool scopeinfo_has_attribute(const RTLIL::Cell *scopeinfo, ScopeinfoAttrs attrs,
{
log_assert(scopeinfo->type == ID($scopeinfo));
TwinePool &twines = scopeinfo->twines();
LeafIdString key = twines.find(attr_prefix(attrs) + twines.unescaped_str(id));
IdString key = twines.find(attr_prefix(attrs) + twines.unescaped_str(id));
return key != IdString::Null && scopeinfo->has_attribute(key);
}
@@ -109,7 +109,7 @@ RTLIL::Const scopeinfo_get_attribute(const RTLIL::Cell *scopeinfo, ScopeinfoAttr
{
log_assert(scopeinfo->type == ID($scopeinfo));
TwinePool &twines = scopeinfo->twines();
LeafIdString key = twines.find(attr_prefix(attrs) + twines.unescaped_str(id));
IdString key = twines.find(attr_prefix(attrs) + twines.unescaped_str(id));
if (key == IdString::Null)
return RTLIL::Const();
auto found = scopeinfo->attributes.find(key);
@@ -118,9 +118,9 @@ RTLIL::Const scopeinfo_get_attribute(const RTLIL::Cell *scopeinfo, ScopeinfoAttr
return found->second;
}
dict<RTLIL::LeafIdString, RTLIL::Const> scopeinfo_attributes(const RTLIL::Cell *scopeinfo, ScopeinfoAttrs attrs)
dict<RTLIL::IdString, RTLIL::Const> scopeinfo_attributes(const RTLIL::Cell *scopeinfo, ScopeinfoAttrs attrs)
{
dict<RTLIL::LeafIdString, RTLIL::Const> attributes;
dict<RTLIL::IdString, RTLIL::Const> attributes;
const char *prefix = attr_prefix(attrs);
size_t prefix_len = strlen(prefix);
+1 -1
View File
@@ -444,7 +444,7 @@ bool scopeinfo_has_attribute(const RTLIL::Cell *scopeinfo, ScopeinfoAttrs attrs,
RTLIL::Const scopeinfo_get_attribute(const RTLIL::Cell *scopeinfo, ScopeinfoAttrs attrs, RTLIL::IdString id);
// Get all attribute from the flattened module or flattened cell corresponding to a $scopeinfo cell.
dict<RTLIL::LeafIdString, RTLIL::Const> scopeinfo_attributes(const RTLIL::Cell *scopeinfo, ScopeinfoAttrs attrs);
dict<RTLIL::IdString, RTLIL::Const> scopeinfo_attributes(const RTLIL::Cell *scopeinfo, ScopeinfoAttrs attrs);
YOSYS_NAMESPACE_END
+4 -4
View File
@@ -278,7 +278,7 @@ static int tcl_get_attr(ClientData, Tcl_Interp *interp, int argc, const char *ar
if (!obj)
ERROR("object not found")
LeafIdString attr_twine = yosys_design->twines.find(attr_id);
IdString attr_twine = yosys_design->twines.find(attr_id);
if (string_flag) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(obj->get_string_attribute(attr_twine).c_str(), -1));
@@ -400,7 +400,7 @@ static int tcl_set_attr(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *const
if (!obj)
ERROR("object not found")
LeafIdString attr_twine = yosys_design->twines.add(std::string(attr_id));
IdString attr_twine = yosys_design->twines.add(std::string(attr_id));
if (string_flag) {
obj->set_string_attribute(attr_twine, Tcl_GetString(objv[i++]));
@@ -469,7 +469,7 @@ static int tcl_get_param(ClientData, Tcl_Interp *interp, int argc, const char *a
if (!cell)
ERROR("object not found")
LeafIdString param_twine = yosys_design->twines.find(param_id);
IdString param_twine = yosys_design->twines.find(param_id);
if (!cell->hasParam(param_twine))
ERROR("parameter missing")
@@ -518,7 +518,7 @@ static int tcl_set_param(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *cons
if (!cell)
ERROR("object not found")
LeafIdString param_twine = yosys_design->twines.add(std::string(param_id));
IdString param_twine = yosys_design->twines.add(std::string(param_id));
if (string_flag) {
cell->setParam(param_twine, Const(std::string(Tcl_GetString(objv[i++]))));
+6 -9
View File
@@ -136,8 +136,6 @@ public:
constexpr NullIdString::operator IdString() const { return IdString(); }
constexpr bool NullIdString::operator==(IdString ref) const { return ref.empty(); }
using LeafIdString = IdString;
namespace hashlib {
template<>
struct hash_ops<IdString> {
@@ -165,7 +163,7 @@ enum : short {
struct ID {
// Static ids are name handles: non-'$' constids were '\'-escaped publics,
// so their handles carry the publicity bit baked in at compile time.
#define X(N) static constexpr LeafIdString N = LeafIdString(IdString(IDX_##N)).tag((#N)[0] != '$');
#define X(N) static constexpr IdString N = IdString(IDX_##N).tag((#N)[0] != '$');
#include "kernel/constids.inc"
#undef X
@@ -175,7 +173,7 @@ struct ID {
#undef X
};
static constexpr LeafIdString lookup(std::string_view name)
static constexpr IdString lookup(std::string_view name)
{
int low = 0, high = STATIC_TWINE_END;
while (high - low >= 2) {
@@ -189,18 +187,17 @@ struct ID {
if (name != static_names[low])
throw "unknown twine id";
return LeafIdString(IdString(low)).tag(name[0] != '$');
return IdString(low).tag(name[0] != '$');
}
static constexpr bool is_static(IdString ref) {
return ref.untag().raw() < STATIC_TWINE_END;
}
// All static twines are leaves
static constexpr LeafIdString static_leaf(size_t raw) {
static constexpr IdString static_ref(size_t raw) {
if (!is_static(IdString(raw)))
throw "not a static twine id";
return LeafIdString(IdString(raw));
return IdString(raw);
}
// Static IdString can be constructed without a design pointer
@@ -208,7 +205,7 @@ struct ID {
static std::string unescaped_str(IdString ref);
};
template<size_t Raw> inline constexpr LeafIdString constid = ID::static_leaf(Raw);
template<size_t Raw> inline constexpr IdString constid = ID::static_ref(Raw);
#define ID(id) (YOSYS_NAMESPACE_PREFIX constid<YOSYS_NAMESPACE_PREFIX ID::lookup(#id).raw()>)