aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2021-06-02 12:09:40 +0100
committergatecat <gatecat@ds0.me>2021-06-02 15:05:20 +0100
commitdcbb322447a7fb59cabe197ec1dd2307acfa3681 (patch)
treeada2c6a5d48e766fa523e633aaa28179baea3273 /common
parent897e2c2fdc43bcf097aa8805c424c4443bcefad5 (diff)
downloadnextpnr-dcbb322447a7fb59cabe197ec1dd2307acfa3681.tar.gz
nextpnr-dcbb322447a7fb59cabe197ec1dd2307acfa3681.tar.bz2
nextpnr-dcbb322447a7fb59cabe197ec1dd2307acfa3681.zip
Remove redundant code after hashlib move
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to 'common')
-rw-r--r--common/base_arch.h6
-rw-r--r--common/hash_table.h63
-rw-r--r--common/idstring.h10
-rw-r--r--common/idstringlist.h14
-rw-r--r--common/nextpnr_base_types.h15
-rw-r--r--common/placer1.cc13
-rw-r--r--common/util.h36
7 files changed, 3 insertions, 154 deletions
diff --git a/common/base_arch.h b/common/base_arch.h
index c7d9f380..457e6582 100644
--- a/common/base_arch.h
+++ b/common/base_arch.h
@@ -148,7 +148,7 @@ template <typename R> struct BaseArch : ArchAPI<R>
virtual char getNameDelimiter() const override { return ' '; }
// Bel methods
- virtual uint32_t getBelChecksum(BelId bel) const override { return uint32_t(std::hash<BelId>()(bel)); }
+ virtual uint32_t getBelChecksum(BelId bel) const override { return bel.hash(); }
virtual void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) override
{
NPNR_ASSERT(bel != BelId());
@@ -196,7 +196,7 @@ template <typename R> struct BaseArch : ArchAPI<R>
{
return empty_if_possible<typename R::WireAttrsRangeT>();
}
- virtual uint32_t getWireChecksum(WireId wire) const override { return uint32_t(std::hash<WireId>()(wire)); }
+ virtual uint32_t getWireChecksum(WireId wire) const override { return wire.hash(); }
virtual void bindWire(WireId wire, NetInfo *net, PlaceStrength strength) override
{
@@ -244,7 +244,7 @@ template <typename R> struct BaseArch : ArchAPI<R>
{
return empty_if_possible<typename R::PipAttrsRangeT>();
}
- virtual uint32_t getPipChecksum(PipId pip) const override { return uint32_t(std::hash<PipId>()(pip)); }
+ virtual uint32_t getPipChecksum(PipId pip) const override { return pip.hash(); }
virtual void bindPip(PipId pip, NetInfo *net, PlaceStrength strength) override
{
NPNR_ASSERT(pip != PipId());
diff --git a/common/hash_table.h b/common/hash_table.h
deleted file mode 100644
index 21ca8887..00000000
--- a/common/hash_table.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * nextpnr -- Next Generation Place and Route
- *
- * Copyright (C) 2021 Symbiflow Authors
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifndef HASH_TABLE_H
-#define HASH_TABLE_H
-
-#if defined(USE_ABSEIL)
-#include <absl/container/flat_hash_map.h>
-#include <absl/container/flat_hash_set.h>
-#else
-#include <unordered_map>
-#include <unordered_set>
-#endif
-
-#include <boost/functional/hash.hpp>
-
-#include "nextpnr_namespaces.h"
-
-NEXTPNR_NAMESPACE_BEGIN
-
-namespace HashTables {
-#if defined(USE_ABSEIL)
-template <typename Key, typename Value, typename Hash = std::hash<Key>>
-using HashMap = absl::flat_hash_map<Key, Value, Hash>;
-template <typename Value, typename Hash = std::hash<Value>> using HashSet = absl::flat_hash_set<Value, Hash>;
-#else
-template <typename Key, typename Value, typename Hash = std::hash<Key>>
-using HashMap = std::unordered_map<Key, Value, Hash>;
-template <typename Value, typename Hash = std::hash<Value>> using HashSet = std::unordered_set<Value, Hash>;
-#endif
-
-}; // namespace HashTables
-
-struct PairHash
-{
- template <typename T1, typename T2> std::size_t operator()(const std::pair<T1, T2> &idp) const noexcept
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, std::hash<T1>()(idp.first));
- boost::hash_combine(seed, std::hash<T2>()(idp.second));
- return seed;
- }
-};
-
-NEXTPNR_NAMESPACE_END
-
-#endif /* HASH_TABLE_H */
diff --git a/common/idstring.h b/common/idstring.h
index aba40ae6..5a7719fa 100644
--- a/common/idstring.h
+++ b/common/idstring.h
@@ -62,14 +62,4 @@ struct IdString
NEXTPNR_NAMESPACE_END
-namespace std {
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX IdString>
-{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX IdString &obj) const noexcept
- {
- return std::hash<int>()(obj.index);
- }
-};
-} // namespace std
-
#endif /* IDSTRING_H */
diff --git a/common/idstringlist.h b/common/idstringlist.h
index 753b408c..f101ecca 100644
--- a/common/idstringlist.h
+++ b/common/idstringlist.h
@@ -80,18 +80,4 @@ struct IdStringList
NEXTPNR_NAMESPACE_END
-namespace std {
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX IdStringList>
-{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX IdStringList &obj) const noexcept
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, hash<size_t>()(obj.size()));
- for (auto &id : obj)
- boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(id));
- return seed;
- }
-};
-} // namespace std
-
#endif /* IDSTRING_LIST_H */
diff --git a/common/nextpnr_base_types.h b/common/nextpnr_base_types.h
index ba1af68c..1707559b 100644
--- a/common/nextpnr_base_types.h
+++ b/common/nextpnr_base_types.h
@@ -130,19 +130,4 @@ enum PlaceStrength
NEXTPNR_NAMESPACE_END
-namespace std {
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX Loc>
-{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX Loc &obj) const noexcept
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, hash<int>()(obj.x));
- boost::hash_combine(seed, hash<int>()(obj.y));
- boost::hash_combine(seed, hash<int>()(obj.z));
- return seed;
- }
-};
-
-} // namespace std
-
#endif /* NEXTPNR_BASE_TYPES_H */
diff --git a/common/placer1.cc b/common/placer1.cc
index e8c6aa64..a832e08f 100644
--- a/common/placer1.cc
+++ b/common/placer1.cc
@@ -46,19 +46,6 @@
#include "timing.h"
#include "util.h"
-namespace std {
-template <> struct hash<std::pair<NEXTPNR_NAMESPACE_PREFIX IdString, std::size_t>>
-{
- std::size_t operator()(const std::pair<NEXTPNR_NAMESPACE_PREFIX IdString, std::size_t> &idp) const noexcept
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(idp.first));
- boost::hash_combine(seed, hash<std::size_t>()(idp.second));
- return seed;
- }
-};
-} // namespace std
-
NEXTPNR_NAMESPACE_BEGIN
class SAPlacer
diff --git a/common/util.h b/common/util.h
index b3e8cbf0..542bd395 100644
--- a/common/util.h
+++ b/common/util.h
@@ -102,42 +102,6 @@ bool bool_or_default(const Container &ct, const KeyType &key, bool def = false)
return bool(int_or_default(ct, key, int(def)));
};
-// Wrap an unordered_map, and allow it to be iterated over sorted by key
-template <typename K, typename V> std::map<K, V *> sorted(const std::unordered_map<K, std::unique_ptr<V>> &orig)
-{
- std::map<K, V *> retVal;
- for (auto &item : orig)
- retVal.emplace(std::make_pair(item.first, item.second.get()));
- return retVal;
-};
-
-// Wrap an unordered_map, and allow it to be iterated over sorted by key
-template <typename K, typename V> std::map<K, V &> sorted_ref(std::unordered_map<K, V> &orig)
-{
- std::map<K, V &> retVal;
- for (auto &item : orig)
- retVal.emplace(std::make_pair(item.first, std::ref(item.second)));
- return retVal;
-};
-
-// Wrap an unordered_map, and allow it to be iterated over sorted by key
-template <typename K, typename V> std::map<K, const V &> sorted_cref(const std::unordered_map<K, V> &orig)
-{
- std::map<K, const V &> retVal;
- for (auto &item : orig)
- retVal.emplace(std::make_pair(item.first, std::ref(item.second)));
- return retVal;
-};
-
-// Wrap an unordered_set, and allow it to be iterated over sorted by key
-template <typename K> std::set<K> sorted(const std::unordered_set<K> &orig)
-{
- std::set<K> retVal;
- for (auto &item : orig)
- retVal.insert(item);
- return retVal;
-};
-
// Return a net if port exists, or nullptr
inline const NetInfo *get_net_or_empty(const CellInfo *cell, const IdString port)
{