mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-23 17:15:33 +00:00
Converting "share" to dict<> and pool<> complete
This commit is contained in:
parent
9ff3a9f30d
commit
cfe0817697
3 changed files with 62 additions and 36 deletions
|
@ -76,6 +76,17 @@ template<> struct hash_ops<std::string> {
|
|||
}
|
||||
};
|
||||
|
||||
template<typename P, typename Q> struct hash_ops<std::pair<P, Q>> {
|
||||
bool cmp(std::pair<P, Q> a, std::pair<P, Q> b) const {
|
||||
return a == b;
|
||||
}
|
||||
unsigned int hash(std::pair<P, Q> a) const {
|
||||
hash_ops<P> p_ops;
|
||||
hash_ops<Q> q_ops;
|
||||
return mkhash(p_ops.hash(a.first), q_ops.hash(a.second));
|
||||
}
|
||||
};
|
||||
|
||||
struct hash_cstr_ops {
|
||||
bool cmp(const char *a, const char *b) const {
|
||||
for (int i = 0; a[i] || b[i]; i++)
|
||||
|
|
|
@ -219,8 +219,8 @@ namespace RTLIL
|
|||
return index_;
|
||||
}
|
||||
|
||||
// The following is a helper key_compare class. Instead of for example pool<Cell*>
|
||||
// use pool<Cell*, IdString::compare_ptr_by_name<Cell>> if the order of cells in the
|
||||
// The following is a helper key_compare class. Instead of for example std::set<Cell*>
|
||||
// use std::set<Cell*, IdString::compare_ptr_by_name<Cell>> if the order of cells in the
|
||||
// set has an influence on the algorithm.
|
||||
|
||||
template<typename T> struct compare_ptr_by_name {
|
||||
|
@ -450,6 +450,13 @@ struct RTLIL::Const
|
|||
std::string decode_string() const;
|
||||
|
||||
inline int size() const { return bits.size(); }
|
||||
|
||||
inline unsigned int hash() const {
|
||||
unsigned int h = 5381;
|
||||
for (auto b : bits)
|
||||
mkhash(h, b);
|
||||
return h;
|
||||
}
|
||||
};
|
||||
|
||||
struct RTLIL::SigChunk
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue