3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-24 01:25:33 +00:00

Revert "Merge upstream"

This reverts commit c58a50f880, reversing
changes made to a1c3c98773.
This commit is contained in:
Akash Levy 2025-01-21 05:28:36 -08:00
parent c58a50f880
commit e73d51dbf0
15 changed files with 49 additions and 110 deletions

View file

@ -61,9 +61,19 @@ namespace legacy {
}
};
/**
* Hash a type with an accumulator in a record or array context
*/
template<typename T>
struct hash_ops;
/**
* Hash a single instance in isolation.
* Can have explicit specialization, but the default redirects to hash_ops
*/
template<typename T>
struct hash_top_ops;
inline unsigned int mkhash_xorshift(unsigned int a) {
if (sizeof(a) == 4) {
a ^= a << 13;
@ -137,14 +147,15 @@ private:
using Hasher = HasherDJB32;
// Boilerplate compressor for trivially implementing
// top-level hash method with hash_into
#define HASH_TOP_LOOP_FST [[nodiscard]] static inline Hasher hash
#define HASH_TOP_LOOP_SND { \
Hasher h; \
h = hash_into(a, h); \
return h; \
}
template<typename T>
struct hash_top_ops {
static inline bool cmp(const T &a, const T &b) {
return hash_ops<T>::cmp(a, b);
}
static inline Hasher hash(const T &a) {
return hash_ops<T>::hash_into(a, Hasher());
}
};
template<typename T>
struct hash_ops {
@ -172,7 +183,6 @@ struct hash_ops {
return a.hash_into(h);
}
}
HASH_TOP_LOOP_FST (const T &a) HASH_TOP_LOOP_SND
};
template<typename P, typename Q> struct hash_ops<std::pair<P, Q>> {
@ -184,7 +194,6 @@ template<typename P, typename Q> struct hash_ops<std::pair<P, Q>> {
h = hash_ops<Q>::hash_into(a.second, h);
return h;
}
HASH_TOP_LOOP_FST (std::pair<P, Q> a) HASH_TOP_LOOP_SND
};
template<typename... T> struct hash_ops<std::tuple<T...>> {
@ -202,7 +211,6 @@ template<typename... T> struct hash_ops<std::tuple<T...>> {
h = element_ops_t::hash_into(std::get<I>(a), h);
return h;
}
HASH_TOP_LOOP_FST (std::tuple<T...> a) HASH_TOP_LOOP_SND
};
template<typename T> struct hash_ops<std::vector<T>> {
@ -215,7 +223,6 @@ template<typename T> struct hash_ops<std::vector<T>> {
h.eat(k);
return h;
}
HASH_TOP_LOOP_FST (std::vector<T> a) HASH_TOP_LOOP_SND
};
template<typename T, size_t N> struct hash_ops<std::array<T, N>> {
@ -227,7 +234,6 @@ template<typename T, size_t N> struct hash_ops<std::array<T, N>> {
h = hash_ops<T>::hash_into(k, h);
return h;
}
HASH_TOP_LOOP_FST (std::array<T, N> a) HASH_TOP_LOOP_SND
};
struct hash_cstr_ops {
@ -239,7 +245,6 @@ struct hash_cstr_ops {
h.hash32(*(a++));
return h;
}
HASH_TOP_LOOP_FST (const char *a) HASH_TOP_LOOP_SND
};
template <> struct hash_ops<char*> : hash_cstr_ops {};
@ -251,7 +256,6 @@ struct hash_ptr_ops {
[[nodiscard]] static inline Hasher hash_into(const void *a, Hasher h) {
return hash_ops<uintptr_t>::hash_into((uintptr_t)a, h);
}
HASH_TOP_LOOP_FST (const void *a) HASH_TOP_LOOP_SND
};
struct hash_obj_ops {
@ -266,8 +270,6 @@ struct hash_obj_ops {
h.eat(0);
return h;
}
template<typename T>
HASH_TOP_LOOP_FST (const T *a) HASH_TOP_LOOP_SND
};
/**
* If you find yourself using this function, think hard
@ -278,7 +280,7 @@ struct hash_obj_ops {
template<typename T>
[[nodiscard]]
Hasher::hash_t run_hash(const T& obj) {
return hash_ops<T>::hash(obj).yield();
return hash_top_ops<T>::hash(obj).yield();
}
/** Refer to docs/source/yosys_internals/hashing.rst */
@ -350,10 +352,10 @@ inline unsigned int hashtable_size(unsigned int min_size)
throw std::length_error("hash table exceeded maximum size.");
}
template<typename K, typename T, typename OPS = hash_ops<K>> class dict;
template<typename K, int offset = 0, typename OPS = hash_ops<K>> class idict;
template<typename K, typename OPS = hash_ops<K>> class pool;
template<typename K, typename OPS = hash_ops<K>> class mfp;
template<typename K, typename T, typename OPS = hash_top_ops<K>> class dict;
template<typename K, int offset = 0, typename OPS = hash_top_ops<K>> class idict;
template<typename K, typename OPS = hash_top_ops<K>> class pool;
template<typename K, typename OPS = hash_top_ops<K>> class mfp;
template<typename K, typename T, typename OPS>
class dict {

View file

@ -1221,7 +1221,7 @@ struct LicensePass : public Pass {
log(" | |\n");
log(" | yosys -- Yosys Open SYnthesis Suite |\n");
log(" | |\n");
log(" | Copyright (C) 2012 - 2025 Claire Xenia Wolf <claire@yosyshq.com> |\n");
log(" | Copyright (C) 2012 - 2024 Claire Xenia Wolf <claire@yosyshq.com> |\n");
log(" | |\n");
log(" | Permission to use, copy, modify, and/or distribute this software for any |\n");
log(" | purpose with or without fee is hereby granted, provided that the above |\n");

View file

@ -398,16 +398,13 @@ struct RTLIL::IdString
namespace hashlib {
template <>
struct hash_ops<RTLIL::IdString> {
struct hash_top_ops<RTLIL::IdString> {
static inline bool cmp(const RTLIL::IdString &a, const RTLIL::IdString &b) {
return a == b;
}
[[nodiscard]] static inline Hasher hash(const RTLIL::IdString id) {
static inline Hasher hash(const RTLIL::IdString id) {
return id.hash_top();
}
[[nodiscard]] static inline Hasher hash_into(const RTLIL::IdString id, Hasher h) {
return id.hash_into(h);
}
};
};
@ -929,16 +926,13 @@ struct RTLIL::SigBit
namespace hashlib {
template <>
struct hash_ops<RTLIL::SigBit> {
struct hash_top_ops<RTLIL::SigBit> {
static inline bool cmp(const RTLIL::SigBit &a, const RTLIL::SigBit &b) {
return a == b;
}
[[nodiscard]] static inline Hasher hash(const RTLIL::SigBit sb) {
static inline Hasher hash(const RTLIL::SigBit sb) {
return sb.hash_top();
}
[[nodiscard]] static inline Hasher hash_into(const RTLIL::SigBit sb, Hasher h) {
return sb.hash_into(h);
}
};
};

View file

@ -337,14 +337,12 @@ template<typename O>
std::vector<IdString> parse_hdlname(const O* object)
{
std::vector<IdString> path;
if (!object->name.isPublic())
return path;
for (auto const &item : object->get_hdlname_attribute())
path.push_back("\\" + item);
if (path.empty() && object->name.isPublic())
if (path.empty())
path.push_back(object->name);
if (!path.empty() && !(object->name.isPublic() || object->name.begins_with("$paramod") || object->name.begins_with("$abstract"))) {
path.pop_back();
path.push_back(object->name);
}
return path;
}
@ -353,22 +351,17 @@ std::pair<std::vector<IdString>, IdString> parse_scopename(const O* object)
{
std::vector<IdString> path;
IdString trailing = object->name;
if (object->name.isPublic() || object->name.begins_with("$paramod") || object->name.begins_with("$abstract")) {
if (object->name.isPublic()) {
for (auto const &item : object->get_hdlname_attribute())
path.push_back("\\" + item);
if (!path.empty()) {
trailing = path.back();
path.pop_back();
}
} else if (object->has_attribute(ID::hdlname)) {
for (auto const &item : object->get_hdlname_attribute())
path.push_back("\\" + item);
if (!path.empty()) {
path.pop_back();
}
} else {
for (auto const &item : split_tokens(object->get_string_attribute(ID(scopename)), " "))
path.push_back("\\" + item);
}
return {path, trailing};
}

View file

@ -144,7 +144,7 @@ void yosys_banner()
log("\n");
log(" /----------------------------------------------------------------------------\\\n");
log(" | yosys -- Yosys Open SYnthesis Suite |\n");
log(" | Copyright (C) 2012 - 2025 Claire Xenia Wolf <claire@yosyshq.com> |\n");
log(" | Copyright (C) 2012 - 2024 Claire Xenia Wolf <claire@yosyshq.com> |\n");
log(" | Distributed under an ISC-like license, type \"license\" to see terms |\n");
log(" \\----------------------------------------------------------------------------/\n");
log(" %s\n", yosys_version_str);