ipa-icf.h (symbol_compare_hash): New class.

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.

From-SVN: r224974
This commit is contained in:
Richard Sandiford 2015-06-25 17:16:51 +00:00 committed by Richard Sandiford
parent e0702244b8
commit 9654754bd9
4 changed files with 36 additions and 23 deletions

View File

@ -1,3 +1,14 @@
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.
(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.
2015-06-25 Richard Sandiford <richard.sandiford@arm.com> 2015-06-25 Richard Sandiford <richard.sandiford@arm.com>
* gengtype-parse.c (require_template_declaration): Allow '+' in * gengtype-parse.c (require_template_declaration): Allow '+' in

View File

@ -87,10 +87,10 @@ public:
/* Hash traits for symbol_compare_collection map. */ /* 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 static hashval_t
hash (const symbol_compare_collection *v) hash (value_type v)
{ {
inchash::hash hstate; inchash::hash hstate;
hstate.add_int (v->m_references.length ()); hstate.add_int (v->m_references.length ());
@ -107,8 +107,7 @@ struct symbol_compare_hashmap_traits: default_hashmap_traits
} }
static bool static bool
equal_keys (const symbol_compare_collection *a, equal (value_type a, value_type b)
const symbol_compare_collection *b)
{ {
if (a->m_references.length () != b->m_references.length () if (a->m_references.length () != b->m_references.length ()
|| a->m_interposables.length () != b->m_interposables.length ()) || a->m_interposables.length () != b->m_interposables.length ())
@ -126,6 +125,8 @@ struct symbol_compare_hashmap_traits: default_hashmap_traits
return true; return true;
} }
}; };
typedef simple_hashmap_traits <symbol_compare_hash>
symbol_compare_hashmap_traits;
/* Semantic item usage pair. */ /* Semantic item usage pair. */

View File

@ -238,10 +238,10 @@ template <class T>
class mem_alloc_description class mem_alloc_description
{ {
public: public:
struct mem_alloc_hashmap_traits: default_hashmap_traits struct mem_location_hash : nofree_ptr_hash <mem_location>
{ {
static hashval_t static hashval_t
hash (const mem_location *l) hash (value_type l)
{ {
inchash::hash hstate; inchash::hash hstate;
@ -253,18 +253,18 @@ public:
} }
static bool 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 return l1->m_filename == l2->m_filename
&& l1->m_function == l2->m_function && l1->m_function == l2->m_function
&& l1->m_line == l2->m_line; && l1->m_line == l2->m_line;
} }
}; };
typedef simple_hashmap_traits<mem_location_hash> mem_alloc_hashmap_traits;
/* Internal class type definitions. */ /* Internal class type definitions. */
typedef hash_map <mem_location *, T *, mem_alloc_hashmap_traits> mem_map_t; 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> typedef hash_map <const void *, mem_usage_pair<T> > reverse_mem_map_t;
reverse_mem_map_t;
typedef hash_map <const void *, std::pair<T *, size_t> > reverse_object_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; typedef std::pair <mem_location *, T *> mem_list_t;

View File

@ -107,8 +107,11 @@ struct sanopt_tree_triplet
/* Traits class for tree triplet hash maps below. */ /* 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 static inline hashval_t
hash (const sanopt_tree_triplet &ref) hash (const sanopt_tree_triplet &ref)
{ {
@ -120,41 +123,39 @@ struct sanopt_tree_triplet_map_traits : default_hashmap_traits
} }
static inline bool 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) return operand_equal_p (ref1.t1, ref2.t1, 0)
&& operand_equal_p (ref1.t2, ref2.t2, 0) && operand_equal_p (ref1.t2, ref2.t2, 0)
&& operand_equal_p (ref1.t3, ref2.t3, 0); && operand_equal_p (ref1.t3, ref2.t3, 0);
} }
template<typename T>
static inline void 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 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 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 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 /* This is used to carry various hash maps and variables used
in sanopt_optimize_walker. */ in sanopt_optimize_walker. */