diff options
author | gatecat <gatecat@ds0.me> | 2021-06-03 09:04:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 09:04:34 +0100 |
commit | a3d8b4f9d198226ec0903e34a8d290b376b45c0b (patch) | |
tree | ada2c6a5d48e766fa523e633aaa28179baea3273 /mistral/archdefs.h | |
parent | 589ca8ded5da2012e4388a3ec4c8fae74dff75e4 (diff) | |
parent | dcbb322447a7fb59cabe197ec1dd2307acfa3681 (diff) | |
download | nextpnr-a3d8b4f9d198226ec0903e34a8d290b376b45c0b.tar.gz nextpnr-a3d8b4f9d198226ec0903e34a8d290b376b45c0b.tar.bz2 nextpnr-a3d8b4f9d198226ec0903e34a8d290b376b45c0b.zip |
Merge pull request #718 from YosysHQ/gatecat/hashlib
Moving from unordered_{map, set} to hashlib
Diffstat (limited to 'mistral/archdefs.h')
-rw-r--r-- | mistral/archdefs.h | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/mistral/archdefs.h b/mistral/archdefs.h index 60bdcfeb..8b4256ab 100644 --- a/mistral/archdefs.h +++ b/mistral/archdefs.h @@ -20,15 +20,16 @@ #ifndef MISTRAL_ARCHDEFS_H #define MISTRAL_ARCHDEFS_H -#include <boost/functional/hash.hpp> - #include "base_clusterinfo.h" #include "cyclonev.h" +#include "hashlib.h" #include "idstring.h" #include "nextpnr_assertions.h" #include "nextpnr_namespaces.h" +#include <limits> + NEXTPNR_NAMESPACE_BEGIN using mistral::CycloneV; @@ -84,6 +85,7 @@ struct BelId bool operator==(const BelId &other) const { return pos == other.pos && z == other.z; } bool operator!=(const BelId &other) const { return pos != other.pos || z != other.z; } bool operator<(const BelId &other) const { return pos < other.pos || (pos == other.pos && z < other.z); } + unsigned int hash() const { return mkhash(pos, z); } }; static constexpr auto invalid_rnode = std::numeric_limits<CycloneV::rnode_t>::max(); @@ -104,6 +106,7 @@ struct WireId bool operator==(const WireId &other) const { return node == other.node; } bool operator!=(const WireId &other) const { return node != other.node; } bool operator<(const WireId &other) const { return node < other.node; } + unsigned int hash() const { return unsigned(node); } }; struct PipId @@ -115,6 +118,7 @@ struct PipId bool operator==(const PipId &other) const { return src == other.src && dst == other.dst; } bool operator!=(const PipId &other) const { return src != other.src || dst != other.dst; } bool operator<(const PipId &other) const { return dst < other.dst || (dst == other.dst && src < other.src); } + unsigned int hash() const { return mkhash(src, dst); } }; typedef IdString DecalId; @@ -199,38 +203,11 @@ struct ArchCellInfo : BaseClusterInfo } ffInfo; }; - std::unordered_map<IdString, ArchPinInfo> pin_data; + dict<IdString, ArchPinInfo> pin_data; CellPinState get_pin_state(IdString pin) const; }; NEXTPNR_NAMESPACE_END -namespace std { -template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelId> -{ - std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX BelId &bel) const noexcept - { - return hash<uint32_t>()((static_cast<uint32_t>(bel.pos) << 16) | bel.z); - } -}; - -template <> struct hash<NEXTPNR_NAMESPACE_PREFIX WireId> -{ - std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX WireId &wire) const noexcept - { - return hash<uint32_t>()(wire.node); - } -}; - -template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PipId> -{ - std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PipId &pip) const noexcept - { - return hash<uint64_t>()((uint64_t(pip.dst) << 32) | pip.src); - } -}; - -} // namespace std - #endif |