mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #3975 from rmlarsen/optmerge
This commit is contained in:
commit
3e22791810
|
@ -90,6 +90,12 @@ template<> struct hash_ops<uint32_t> : hash_int_ops
|
|||
return a;
|
||||
}
|
||||
};
|
||||
template<> struct hash_ops<uint64_t> : hash_int_ops
|
||||
{
|
||||
static inline unsigned int hash(uint64_t a) {
|
||||
return mkhash((unsigned int)(a), (unsigned int)(a >> 32));
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct hash_ops<std::string> {
|
||||
static inline bool cmp(const std::string &a, const std::string &b) {
|
||||
|
|
|
@ -308,10 +308,14 @@ namespace RTLIL
|
|||
bool operator!=(const char *rhs) const { return strcmp(c_str(), rhs) != 0; }
|
||||
|
||||
char operator[](size_t i) const {
|
||||
const char *p = c_str();
|
||||
const char *p = c_str();
|
||||
#ifndef NDEBUG
|
||||
for (; i != 0; i--, p++)
|
||||
log_assert(*p != 0);
|
||||
return *p;
|
||||
#else
|
||||
return *(p + i);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string substr(size_t pos = 0, size_t len = std::string::npos) const {
|
||||
|
|
|
@ -41,7 +41,6 @@ struct OptMergeWorker
|
|||
|
||||
CellTypes ct;
|
||||
int total_count;
|
||||
SHA1 checksum;
|
||||
|
||||
static void sort_pmux_conn(dict<RTLIL::IdString, RTLIL::SigSpec> &conn)
|
||||
{
|
||||
|
@ -78,7 +77,7 @@ struct OptMergeWorker
|
|||
return str;
|
||||
}
|
||||
|
||||
std::string hash_cell_parameters_and_connections(const RTLIL::Cell *cell)
|
||||
uint64_t hash_cell_parameters_and_connections(const RTLIL::Cell *cell)
|
||||
{
|
||||
vector<string> hash_conn_strings;
|
||||
std::string hash_string = cell->type.str() + "\n";
|
||||
|
@ -149,8 +148,7 @@ struct OptMergeWorker
|
|||
for (auto it : hash_conn_strings)
|
||||
hash_string += it;
|
||||
|
||||
checksum.update(hash_string);
|
||||
return checksum.final();
|
||||
return std::hash<std::string>{}(hash_string);
|
||||
}
|
||||
|
||||
bool compare_cell_parameters_and_connections(const RTLIL::Cell *cell1, const RTLIL::Cell *cell2)
|
||||
|
@ -268,13 +266,13 @@ struct OptMergeWorker
|
|||
}
|
||||
|
||||
did_something = false;
|
||||
dict<std::string, RTLIL::Cell*> sharemap;
|
||||
dict<uint64_t, RTLIL::Cell*> sharemap;
|
||||
for (auto cell : cells)
|
||||
{
|
||||
if ((!mode_share_all && !ct.cell_known(cell->type)) || !cell->known())
|
||||
continue;
|
||||
|
||||
auto hash = hash_cell_parameters_and_connections(cell);
|
||||
uint64_t hash = hash_cell_parameters_and_connections(cell);
|
||||
auto r = sharemap.insert(std::make_pair(hash, cell));
|
||||
if (!r.second) {
|
||||
if (compare_cell_parameters_and_connections(cell, r.first->second)) {
|
||||
|
|
|
@ -29,13 +29,6 @@
|
|||
|
||||
USING_YOSYS_NAMESPACE
|
||||
|
||||
template<> struct hashlib::hash_ops<uint64_t> : hashlib::hash_int_ops
|
||||
{
|
||||
static inline unsigned int hash(uint64_t a) {
|
||||
return mkhash((unsigned int)(a), (unsigned int)(a >> 32));
|
||||
}
|
||||
};
|
||||
|
||||
PRIVATE_NAMESPACE_BEGIN
|
||||
|
||||
// xorshift128 params
|
||||
|
|
Loading…
Reference in New Issue