Improved SigMap performance

This commit is contained in:
Clifford Wolf 2015-10-28 11:21:55 +01:00
parent e69efec588
commit 1e32e4bdae
3 changed files with 16 additions and 5 deletions

View File

@ -93,6 +93,9 @@ creates a bijective map from K to the integers. For example:
It is not possible to remove elements from an idict. It is not possible to remove elements from an idict.
Finally mfp<K> implements a merge-find set data structure (aka. disjoint-set or
unionfind) over the type K ("mfp" = merge-find-promote).
2. Standard STL data types 2. Standard STL data types
In Yosys we use std::vector<T> and std::string whenever applicable. When In Yosys we use std::vector<T> and std::string whenever applicable. When

View File

@ -985,6 +985,11 @@ public:
parents[i] = -1; parents[i] = -1;
} }
int lookup(const K &a) const
{
return ifind((*this)(a));
}
const K &find(const K &a) const const K &find(const K &a) const
{ {
return (*this)[ifind((*this)(a))]; return (*this)[ifind((*this)(a))];

View File

@ -253,18 +253,21 @@ struct SigMap
for (int i = 0; i < GetSize(from); i++) for (int i = 0; i < GetSize(from); i++)
{ {
RTLIL::SigBit bf = database.find(from[i]); int bfi = database.lookup(from[i]);
RTLIL::SigBit bt = database.find(to[i]); int bti = database.lookup(to[i]);
const RTLIL::SigBit &bf = database[bfi];
const RTLIL::SigBit &bt = database[bti];
if (bf.wire || bt.wire) if (bf.wire || bt.wire)
{ {
database.merge(bf, bt); database.imerge(bfi, bti);
if (bf.wire == nullptr) if (bf.wire == nullptr)
database.promote(bf); database.ipromote(bfi);
if (bt.wire == nullptr) if (bt.wire == nullptr)
database.promote(bt); database.ipromote(bti);
} }
} }
} }