3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-11-03 13:07:58 +00:00

Create RTLIL::OwningIdString and use it in a few places

This commit is contained in:
Robert O'Callahan 2025-10-09 23:28:10 +00:00
parent 2ca7b2f7d7
commit b3f79ed8e7
2 changed files with 13 additions and 2 deletions

View file

@ -42,7 +42,7 @@ std::vector<uint32_t> RTLIL::IdString::global_refcount_storage_;
std::vector<int> RTLIL::IdString::global_free_idx_list_;
#endif
#define X(_id) const RTLIL::IdString RTLIL::IDInternal::_id(RTLIL::StaticId::_id);
#define X(_id) const RTLIL::OwningIdString RTLIL::IDInternal::_id(RTLIL::StaticId::_id);
#include "kernel/constids.inc"
#undef X

View file

@ -121,6 +121,7 @@ namespace RTLIL
struct Binding;
struct IdString;
struct StaticIdString;
struct OwningIdString;
typedef std::pair<SigSpec, SigSpec> SigSig;
@ -459,6 +460,16 @@ public:
}
};
struct RTLIL::OwningIdString : public RTLIL::IdString {
inline OwningIdString() { }
inline OwningIdString(const char *str) : IdString(str) { }
inline OwningIdString(const IdString &str) : IdString(str) { }
inline OwningIdString(IdString &&str) : IdString(str) { }
inline OwningIdString(const std::string &str) : IdString(str) { }
inline OwningIdString(std::string_view str) : IdString(str) { }
inline OwningIdString(StaticId id) : IdString(id) { }
};
namespace hashlib {
template <>
struct hash_ops<RTLIL::IdString> {
@ -493,7 +504,7 @@ inline bool RTLIL::IdString::operator!=(const RTLIL::StaticIdString &rhs) const
namespace RTLIL {
namespace IDInternal {
#define X(_id) extern const IdString _id;
#define X(_id) extern const OwningIdString _id;
#include "kernel/constids.inc"
#undef X
}