diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2015-06-25 17:16:59 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2015-06-25 17:16:59 +0000 |
commit | 0ef08bc588a22e4a98adfc92dd63e753ebc27d3d (patch) | |
tree | 5f307e170e4efeb85e02b752e687e921eae3eedf | |
parent | 9654754bd9ab263c3d2a6e04bbd1a4dc36f9f280 (diff) | |
download | gcc-0ef08bc588a22e4a98adfc92dd63e753ebc27d3d.zip gcc-0ef08bc588a22e4a98adfc92dd63e753ebc27d3d.tar.gz gcc-0ef08bc588a22e4a98adfc92dd63e753ebc27d3d.tar.bz2 |
hash-map-traits.h (unbounded_hashmap_traits): New class.
gcc/
* hash-map-traits.h (unbounded_hashmap_traits): New class.
(unbounded_int_hashmap_traits): Likewise.
* cfgexpand.c (part_traits): Use unbounded_int_hashmap_traits.
From-SVN: r224975
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cfgexpand.c | 20 | ||||
-rw-r--r-- | gcc/hash-map-traits.h | 80 |
3 files changed, 87 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 68b7b02..70f14f6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2015-06-25 Richard Sandiford <richard.sandiford@arm.com> + * hash-map-traits.h (unbounded_hashmap_traits): New class. + (unbounded_int_hashmap_traits): Likewise. + * cfgexpand.c (part_traits): Use unbounded_int_hashmap_traits. + +2015-06-25 Richard Sandiford <richard.sandiford@arm.com> + * ipa-icf.h (symbol_compare_hash): New class. (symbol_compare_hashmap_traits): Use it. * mem-stats.h (mem_alloc_description::mem_location_hash): New class. diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 6b79b1d..a2b9977 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -610,25 +610,7 @@ stack_var_cmp (const void *a, const void *b) return 0; } -struct part_traits : default_hashmap_traits -{ - template<typename T> - static bool - is_deleted (T &e) - { return e.m_value == reinterpret_cast<void *> (1); } - - template<typename T> static bool is_empty (T &e) { return e.m_value == NULL; } - template<typename T> - static void - mark_deleted (T &e) - { e.m_value = reinterpret_cast<T> (1); } - - template<typename T> - static void - mark_empty (T &e) - { e.m_value = NULL; } -}; - +struct part_traits : unbounded_int_hashmap_traits <size_t, bitmap> {}; typedef hash_map<size_t, bitmap, part_traits> part_hashmap; /* If the points-to solution *PI points to variables that are in a partition diff --git a/gcc/hash-map-traits.h b/gcc/hash-map-traits.h index 669a637..9cab0ec 100644 --- a/gcc/hash-map-traits.h +++ b/gcc/hash-map-traits.h @@ -174,4 +174,84 @@ simple_hashmap_traits <H>::mark_deleted (T &entry) H::mark_deleted (entry.m_key); } +/* Implement traits for a hash_map with values of type Value for cases + in which the key cannot represent empty and deleted slots. Instead + record empty and deleted entries in Value. Derived classes must + implement the hash and equal_keys functions. */ + +template <typename Value> +struct unbounded_hashmap_traits +{ + template <typename T> static inline void remove (T &); + template <typename T> static inline bool is_empty (const T &); + template <typename T> static inline bool is_deleted (const T &); + template <typename T> static inline void mark_empty (T &); + template <typename T> static inline void mark_deleted (T &); +}; + +template <typename Value> +template <typename T> +inline void +unbounded_hashmap_traits <Value>::remove (T &entry) +{ + default_hash_traits <Value>::remove (entry.m_value); +} + +template <typename Value> +template <typename T> +inline bool +unbounded_hashmap_traits <Value>::is_empty (const T &entry) +{ + return default_hash_traits <Value>::is_empty (entry.m_value); +} + +template <typename Value> +template <typename T> +inline bool +unbounded_hashmap_traits <Value>::is_deleted (const T &entry) +{ + return default_hash_traits <Value>::is_deleted (entry.m_value); +} + +template <typename Value> +template <typename T> +inline void +unbounded_hashmap_traits <Value>::mark_empty (T &entry) +{ + default_hash_traits <Value>::mark_empty (entry.m_value); +} + +template <typename Value> +template <typename T> +inline void +unbounded_hashmap_traits <Value>::mark_deleted (T &entry) +{ + default_hash_traits <Value>::mark_deleted (entry.m_value); +} + +/* Implement traits for a hash_map from integer type Key to Value in + cases where Key has no spare values for recording empty and deleted + slots. */ + +template <typename Key, typename Value> +struct unbounded_int_hashmap_traits : unbounded_hashmap_traits <Value> +{ + static inline hashval_t hash (Key); + static inline bool equal_keys (Key, Key); +}; + +template <typename Key, typename Value> +inline hashval_t +unbounded_int_hashmap_traits <Key, Value>::hash (Key k) +{ + return k; +} + +template <typename Key, typename Value> +inline bool +unbounded_int_hashmap_traits <Key, Value>::equal_keys (Key k1, Key k2) +{ + return k1 == k2; +} + #endif // HASH_MAP_TRAITS_H |