From b837d1923826a45554502cbcb7f4b9ed56673da0 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Thu, 25 Jun 2015 17:15:35 +0000 Subject: [PATCH] gcc/ * hash-map-traits.h: Include hash-traits.h. (simple_hashmap_traits): New class. * mem-stats.h (hash_map): Change the default traits to simple_hashmap_traits >. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224966 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++ gcc/hash-map-traits.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/mem-stats.h | 2 +- 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 49f8515cede..fdfe9d0a8db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2015-06-25 Richard Sandiford + * hash-map-traits.h: Include hash-traits.h. + (simple_hashmap_traits): New class. + * mem-stats.h (hash_map): Change the default traits to + simple_hashmap_traits >. + +2015-06-25 Richard Sandiford + * hash-table.h: Update comments. 2015-06-25 Richard Sandiford diff --git a/gcc/hash-map-traits.h b/gcc/hash-map-traits.h index ce9c4a74b40..669a6379702 100644 --- a/gcc/hash-map-traits.h +++ b/gcc/hash-map-traits.h @@ -23,6 +23,8 @@ along with GCC; see the file COPYING3. If not see /* Bacause mem-stats.h uses default hashmap traits, we have to put the class to this separate header file. */ +#include "hash-traits.h" + /* implement default behavior for traits when types allow it. */ struct default_hashmap_traits @@ -101,4 +103,75 @@ private: } }; +/* Implement hash_map traits for a key with hash traits H. Empty and + deleted map entries are represented as empty and deleted keys. */ + +template +struct simple_hashmap_traits +{ + static inline hashval_t hash (const typename H::value_type &); + static inline bool equal_keys (const typename H::value_type &, + const typename H::value_type &); + template static inline void remove (T &); + template static inline bool is_empty (const T &); + template static inline bool is_deleted (const T &); + template static inline void mark_empty (T &); + template static inline void mark_deleted (T &); +}; + +template +inline hashval_t +simple_hashmap_traits ::hash (const typename H::value_type &h) +{ + return H::hash (h); +} + +template +inline bool +simple_hashmap_traits ::equal_keys (const typename H::value_type &k1, + const typename H::value_type &k2) +{ + return H::equal (k1, k2); +} + +template +template +inline void +simple_hashmap_traits ::remove (T &entry) +{ + H::remove (entry.m_key); +} + +template +template +inline bool +simple_hashmap_traits ::is_empty (const T &entry) +{ + return H::is_empty (entry.m_key); +} + +template +template +inline bool +simple_hashmap_traits ::is_deleted (const T &entry) +{ + return H::is_deleted (entry.m_key); +} + +template +template +inline void +simple_hashmap_traits ::mark_empty (T &entry) +{ + H::mark_empty (entry.m_key); +} + +template +template +inline void +simple_hashmap_traits ::mark_deleted (T &entry) +{ + H::mark_deleted (entry.m_key); +} + #endif // HASH_MAP_TRAITS_H diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h index 6d3d79c7f10..63277b302ce 100644 --- a/gcc/mem-stats.h +++ b/gcc/mem-stats.h @@ -3,7 +3,7 @@ /* Forward declaration. */ template + typename Traits = simple_hashmap_traits > > class hash_map; #define LOCATION_LINE_EXTRA_SPACE 30 -- 2.11.4.GIT