diff --git a/kernel/celltypes.h b/kernel/celltypes.h index 11640c25f..f08a695e9 100644 --- a/kernel/celltypes.h +++ b/kernel/celltypes.h @@ -303,24 +303,24 @@ struct CellTypes cell_types.clear(); } - bool cell_known(RTLIL::IdString type) const + bool cell_known(const RTLIL::IdString &type) const { return cell_types.count(type) != 0; } - bool cell_output(RTLIL::IdString type, RTLIL::IdString port) const + bool cell_output(const RTLIL::IdString &type, const RTLIL::IdString &port) const { auto it = cell_types.find(type); return it != cell_types.end() && it->second.outputs.count(port) != 0; } - bool cell_input(RTLIL::IdString type, RTLIL::IdString port) const + bool cell_input(const RTLIL::IdString &type, const RTLIL::IdString &port) const { auto it = cell_types.find(type); return it != cell_types.end() && it->second.inputs.count(port) != 0; } - bool cell_evaluable(RTLIL::IdString type) const + bool cell_evaluable(const RTLIL::IdString &type) const { auto it = cell_types.find(type); return it != cell_types.end() && it->second.is_evaluable; diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 9c53e6687..39530baea 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -188,6 +188,12 @@ template struct hash_ops> { return h; } HASH_TOP_LOOP_FST (const std::pair &a) HASH_TOP_LOOP_SND + [[nodiscard]] static inline Hasher hash(const P &p, const Q &q) { + Hasher h; + h = hash_ops

::hash_into(p, h); + h = hash_ops::hash_into(q, h); + return h; + } }; template struct hash_ops> { diff --git a/kernel/rtlil.h b/kernel/rtlil.h index e0de79ea9..c81a0c00a 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -411,7 +411,7 @@ struct RTLIL::IdString // often one needs to check if a given IdString is part of a list (for example a list // of cell types). the following functions helps with that. template - bool in(Args... args) const { + bool in(const Args &... args) const { return (... || in(args)); } @@ -430,10 +430,10 @@ namespace hashlib { static inline bool cmp(const RTLIL::IdString &a, const RTLIL::IdString &b) { return a == b; } - [[nodiscard]] static inline Hasher hash(const RTLIL::IdString id) { + [[nodiscard]] static inline Hasher hash(const RTLIL::IdString &id) { return id.hash_top(); } - [[nodiscard]] static inline Hasher hash_into(const RTLIL::IdString id, Hasher h) { + [[nodiscard]] static inline Hasher hash_into(const RTLIL::IdString &id, Hasher h) { return id.hash_into(h); } }; diff --git a/kernel/yosys_common.h b/kernel/yosys_common.h index bc92e7869..943aa4f05 100644 --- a/kernel/yosys_common.h +++ b/kernel/yosys_common.h @@ -285,7 +285,7 @@ RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std: // // sed -i.orig -r 's/"\\\\([a-zA-Z0-9_]+)"/ID(\1)/g; s/"(\$[a-zA-Z0-9_]+)"/ID(\1)/g;' // -#define ID(_id) ([]() { const char *p = "\\" #_id, *q = p[1] == '$' ? p+1 : p; \ +#define ID(_id) ([]() -> const RTLIL::IdString & { const char *p = "\\" #_id, *q = p[1] == '$' ? p+1 : p; \ static const YOSYS_NAMESPACE_PREFIX RTLIL::IdString id(q); return id; })() namespace ID = RTLIL::ID; diff --git a/passes/opt/opt_merge.cc b/passes/opt/opt_merge.cc index ba8168e74..6c81ee241 100644 --- a/passes/opt/opt_merge.cc +++ b/passes/opt/opt_merge.cc @@ -107,7 +107,7 @@ struct OptMergeWorker for (const auto& [port, sig] : cell->connections()) { if (cell->output(port)) continue; - comm.eat(hash_ops>::hash({port, assign_map(sig)})); + comm.eat(hash_ops>::hash(port, assign_map(sig))); } h = comm.hash_into(h); if (RTLIL::builtin_ff_cell_types().count(cell->type))