diff mbox

[09/12] Remove all but one use of default_hashmap_traits

Message ID 877fqua32q.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford June 23, 2015, 2:53 p.m. UTC
After the previous patches in the series, there are three remaining hash
traits that use the key to represent empty and deleted entries.  This patch
makes them use simple_hashmap_traits.


gcc/
	* 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.
	(mem_alloc_description::mem_alloc_hashmap_traits): Use it.
	(mem_alloc_description::reverse_mem_map_t): Remove redundant
	default_hashmap_traits.
	* sanopt.c (sanopt_tree_triplet_hash): New class.
	(sanopt_tree_triplet_map_traits): Use it.

Comments

Jeff Law June 25, 2015, 4:40 p.m. UTC | #1
On 06/23/2015 08:53 AM, Richard Sandiford wrote:
> After the previous patches in the series, there are three remaining hash
> traits that use the key to represent empty and deleted entries.  This patch
> makes them use simple_hashmap_traits.
>
>
> gcc/
> 	* 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.
> 	(mem_alloc_description::mem_alloc_hashmap_traits): Use it.
> 	(mem_alloc_description::reverse_mem_map_t): Remove redundant
> 	default_hashmap_traits.
> 	* sanopt.c (sanopt_tree_triplet_hash): New class.
> 	(sanopt_tree_triplet_map_traits): Use it.
OK.
jeff
diff mbox

Patch

Index: gcc/ipa-icf.h
===================================================================
--- gcc/ipa-icf.h	2015-06-23 15:52:24.937095524 +0100
+++ gcc/ipa-icf.h	2015-06-23 15:52:24.929095617 +0100
@@ -87,10 +87,10 @@  enum sem_item_type
 
 /* Hash traits for symbol_compare_collection map.  */
 
-struct symbol_compare_hashmap_traits: default_hashmap_traits
+struct symbol_compare_hash : nofree_ptr_hash <symbol_compare_collection>
 {
   static hashval_t
-  hash (const symbol_compare_collection *v)
+  hash (value_type v)
   {
     inchash::hash hstate;
     hstate.add_int (v->m_references.length ());
@@ -107,8 +107,7 @@  struct symbol_compare_hashmap_traits: de
   }
 
   static bool
-  equal_keys (const symbol_compare_collection *a,
-	      const symbol_compare_collection *b)
+  equal (value_type a, value_type b)
   {
     if (a->m_references.length () != b->m_references.length ()
 	|| a->m_interposables.length () != b->m_interposables.length ())
@@ -126,6 +125,8 @@  struct symbol_compare_hashmap_traits: de
     return true;
   }
 };
+typedef simple_hashmap_traits <symbol_compare_hash>
+  symbol_compare_hashmap_traits;
 
 
 /* Semantic item usage pair.  */
Index: gcc/mem-stats.h
===================================================================
--- gcc/mem-stats.h	2015-06-23 15:52:24.937095524 +0100
+++ gcc/mem-stats.h	2015-06-23 15:52:24.929095617 +0100
@@ -238,10 +238,10 @@  struct mem_usage_pair
 class mem_alloc_description
 {
 public:
-  struct mem_alloc_hashmap_traits: default_hashmap_traits
+  struct mem_location_hash : nofree_ptr_hash <mem_location>
   {
     static hashval_t
-    hash (const mem_location *l)
+    hash (value_type l)
     {
 	inchash::hash hstate;
 
@@ -253,18 +253,18 @@  struct mem_usage_pair
     }
 
     static bool
-    equal_keys (const mem_location *l1, const mem_location *l2)
+    equal (value_type l1, value_type l2)
     {
       return l1->m_filename == l2->m_filename
 	&& l1->m_function == l2->m_function
 	&& l1->m_line == l2->m_line;
     }
   };
+  typedef simple_hashmap_traits<mem_location_hash> mem_alloc_hashmap_traits;
 
   /* Internal class type definitions.  */
   typedef hash_map <mem_location *, T *, mem_alloc_hashmap_traits> mem_map_t;
-  typedef hash_map <const void *, mem_usage_pair<T>, default_hashmap_traits>
-    reverse_mem_map_t;
+  typedef hash_map <const void *, mem_usage_pair<T> > reverse_mem_map_t;
   typedef hash_map <const void *, std::pair<T *, size_t> > reverse_object_map_t;
   typedef std::pair <mem_location *, T *> mem_list_t;
 
Index: gcc/sanopt.c
===================================================================
--- gcc/sanopt.c	2015-06-23 15:52:24.937095524 +0100
+++ gcc/sanopt.c	2015-06-23 15:52:24.929095617 +0100
@@ -109,8 +109,11 @@  struct sanopt_tree_triplet
 
 /* Traits class for tree triplet hash maps below.  */
 
-struct sanopt_tree_triplet_map_traits : default_hashmap_traits
+struct sanopt_tree_triplet_hash : typed_noop_remove <sanopt_tree_triplet>
 {
+  typedef sanopt_tree_triplet value_type;
+  typedef sanopt_tree_triplet compare_type;
+
   static inline hashval_t
   hash (const sanopt_tree_triplet &ref)
   {
@@ -122,41 +125,39 @@  struct sanopt_tree_triplet_map_traits :
   }
 
   static inline bool
-  equal_keys (const sanopt_tree_triplet &ref1, const sanopt_tree_triplet &ref2)
+  equal (const sanopt_tree_triplet &ref1, const sanopt_tree_triplet &ref2)
   {
     return operand_equal_p (ref1.t1, ref2.t1, 0)
 	   && operand_equal_p (ref1.t2, ref2.t2, 0)
 	   && operand_equal_p (ref1.t3, ref2.t3, 0);
   }
 
-  template<typename T>
   static inline void
-  mark_deleted (T &e)
+  mark_deleted (sanopt_tree_triplet &ref)
   {
-    e.m_key.t1 = reinterpret_cast<T *> (1);
+    ref.t1 = reinterpret_cast<tree> (1);
   }
 
-  template<typename T>
   static inline void
-  mark_empty (T &e)
+  mark_empty (sanopt_tree_triplet &ref)
   {
-    e.m_key.t1 = NULL;
+    ref.t1 = NULL;
   }
 
-  template<typename T>
   static inline bool
-  is_deleted (T &e)
+  is_deleted (const sanopt_tree_triplet &ref)
   {
-    return e.m_key.t1 == (void *) 1;
+    return ref.t1 == (void *) 1;
   }
 
-  template<typename T>
   static inline bool
-  is_empty (T &e)
+  is_empty (const sanopt_tree_triplet &ref)
   {
-    return e.m_key.t1 == NULL;
+    return ref.t1 == NULL;
   }
 };
+typedef simple_hashmap_traits <sanopt_tree_triplet_hash>
+  sanopt_tree_triplet_map_traits;
 
 /* This is used to carry various hash maps and variables used
    in sanopt_optimize_walker.  */