From ecc19c2c083f7e3ed7da95557731ded803d2cb1d Mon Sep 17 00:00:00 2001 From: gatecat Date: Wed, 2 Jun 2021 10:01:36 +0100 Subject: Using hashlib in arches Signed-off-by: gatecat --- common/base_arch.h | 12 ++++++------ common/hashlib.h | 9 +++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/base_arch.h b/common/base_arch.h index fbafee99..c7d9f380 100644 --- a/common/base_arch.h +++ b/common/base_arch.h @@ -441,23 +441,23 @@ template struct BaseArch : ArchAPI // -------------------------------------------------------------- // These structures are used to provide default implementations of bel/wire/pip binding. Arches might want to - // replace them with their own, for example to use faster access structures than unordered_map. Arches might also + // replace them with their own, for example to use faster access structures than dict. Arches might also // want to add extra checks around these functions - std::unordered_map base_bel2cell; - std::unordered_map base_wire2net; - std::unordered_map base_pip2net; + dict base_bel2cell; + dict base_wire2net; + dict base_pip2net; // For the default cell/bel bucket implementations std::vector cell_types; std::vector bel_buckets; - std::unordered_map> bucket_bels; + dict> bucket_bels; // Arches that want to use the default cell types and bel buckets *must* call these functions in their constructor bool cell_types_initialised = false; bool bel_buckets_initialised = false; void init_cell_types() { - std::unordered_set bel_types; + pool bel_types; for (auto bel : this->getBels()) bel_types.insert(this->getBelType(bel)); std::copy(bel_types.begin(), bel_types.end(), std::back_inserter(cell_types)); diff --git a/common/hashlib.h b/common/hashlib.h index 30fefc65..063df78f 100644 --- a/common/hashlib.h +++ b/common/hashlib.h @@ -74,6 +74,15 @@ template <> struct hash_ops : hash_int_ops static inline unsigned int hash(int64_t a) { return mkhash((unsigned int)(a), (unsigned int)(a >> 32)); } }; +template <> struct hash_ops : hash_int_ops +{ + static inline unsigned int hash(uint32_t a) { return a; } +}; +template <> struct hash_ops : hash_int_ops +{ + static inline unsigned int hash(uint64_t a) { return mkhash((unsigned int)(a), (unsigned int)(a >> 32)); } +}; + template <> struct hash_ops { static inline bool cmp(const std::string &a, const std::string &b) { return a == b; } -- cgit v1.2.3