From 3e871d4d963e42a0be8a2d82b0c345f2f741fcb7 Mon Sep 17 00:00:00 2001 From: crowl Date: Tue, 23 Apr 2013 22:00:12 +0000 Subject: This patch extracts approved portions of the hash_table patches to the cxx-conversion branch for files not under gcc/config. Update various hash tables from htab_t to hash_table. Modify types and calls to match. * tree-ssa-coalesce.c'coalesce_list_d.list from htab_t to hash_table. Fold coalesce_pair_map_hash and coalesce_pair_map_eq into new struct coalesce_pair_hasher. Removed struct coalesce_pair_iterator, as did not meet the hash_table iterator interface and it provided no significant code reduction. This leads to a change in the implementation of FOR_EACH_PARTITION_PAIR. * statistics.c'statistics_hashes Fold hash_statistics_eq into new struct stats_counter_hasher. * hash-table.h'hash_table Add documentation. Add nested class iterator and methods to hash_table. Add FOR_EACH_HASH_TABLE_ELEMENT implemented with those iterators. Change uses of FOR_EACH_HTAB_ELEMENT to FOR_EACH_HASH_TABLE_ELEMENT. * tree-ssa-sccvn.c'vn_tables_s.nary Fold vn_nary_op_hash, vn_nary_op_eq into new struct vn_nary_op_hasher. Add typedef vn_nary_op_table_type. Add typedef vn_nary_op_iterator_type. * tree-ssa-sccvn.c'vn_tables_s.phis Fold vn_phi_hash, free_phi into new struct vn_phi_hasher. Add typedef vn_phi_table_type. Add typedef vn_phi_iterator_type. * tree-ssa-sccvn.c'vn_tables_s.references Fold vn_reference_hash, vn_reference_op_eq, free_reference into new struct vn_reference_hasher. Add typedef vn_reference_table_type. Add typedef vn_reference_iterator_type. * tree-ssa-sccvn.c'constant_value_ids Fold vn_constant_hash, vn_constant_eq into new struct vn_constant_hasher. * tree-into-ssa.c'var_infos Fold var_info_hash, var_info_eq into new struct var_info_hasher. * tree-vectorizer.h'_loop_vec_info::peeling_htab * tree-vectorizer.h New struct peel_info_hasher. * tree-vect-loop.c Update dependent calls and types to match. * tree-vect-data-refs.c Fold vect_peeling_hash and vect_peeling_hash_eq into struct peel_info_hasher. * tree-ssa-reassoc.c'undistribute_ops_list::ctable Fold oecount_hash and oecount_eq into new struct oecount_hasher. * tree-ssa-loop-im.c'memory_accesses.refs Fold memref_hash and memref_eq into new struct mem_ref_hasher. Tested on x86_64. Index: gcc/ChangeLog 2013-04-23 Lawrence Crowl * Makefile.in: Update as needed below. * hash-table.h (class hash_table): Correct many methods with parameter types compare_type to the correct value_type. (Correct code was unlikely to notice the change.) (hash_table::elements_with_deleted) New. (class hashtable::iterator): New. (hashtable::begin()): New. (hashtable::end()): New. (FOR_EACH_HASH_TABLE_ELEMENT): New. * statistics.c (statistics_hashes): Change type to hash_table. Update dependent calls and types. * tree-into-ssa.c (var_infos): Change type to hash_table. Update dependent calls and types. * tree-ssa-coalesce.c (struct coalesce_list_d.list): Change type to hash_table. Update dependent calls and types. * tree-ssa-loop-im.c (struct mem_ref.refs): Change type to hash_table. Update dependent calls and types. * tree-ssa-reassoc.c (undistribute_ops_list::ctable): Change type to hash_table. Update dependent calls and types. * tree-ssa-sccvn.c (vn_tables_s::nary): Change type to hash_table. Update dependent calls and types. (vn_tables_s::phis): Likewise. (vn_tables_s::references): Likewise. * tree-ssa-sccvn.h (vn_nary_op_eq): Update parameter and return types. (vn_reference_eq): Update parameter and return types. * tree-ssa-structalias.c (pointer_equiv_class_table): Change type to hash_table. Update dependent calls and types. (location_equiv_class_table): Likewise. * tree-vect-data-refs.c: Consequential changes for making peeling a hash_table. * tree-vect-loop.c (new_loop_vec_info): Dependent hash_table update. (destroy_loop_vec_info): Dependent hash_table update. * tree-vectorizer.h (peeling_htab): Change type to hash_table. Update dependent calls and types. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198213 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-im.c | 62 +++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'gcc/tree-ssa-loop-im.c') diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index 188af0012a7..90e4d361e2f 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "tree-pass.h" #include "flags.h" -#include "hashtab.h" +#include "hash-table.h" #include "tree-affine.h" #include "pointer-set.h" #include "tree-ssa-propagate.h" @@ -133,6 +133,32 @@ typedef struct mem_ref and its subloops. */ #define LOOP_DEP_BIT(loopnum, storedp) (2 * (loopnum) + (storedp ? 1 : 0)) +/* Mem_ref hashtable helpers. */ + +struct mem_ref_hasher : typed_noop_remove +{ + typedef mem_ref value_type; + typedef tree_node compare_type; + static inline hashval_t hash (const value_type *); + static inline bool equal (const value_type *, const compare_type *); +}; + +/* A hash function for struct mem_ref object OBJ. */ + +inline hashval_t +mem_ref_hasher::hash (const value_type *mem) +{ + return mem->hash; +} + +/* An equality function for struct mem_ref object MEM1 with + memory reference OBJ2. */ + +inline bool +mem_ref_hasher::equal (const value_type *mem1, const compare_type *obj2) +{ + return operand_equal_p (mem1->mem.ref, (const_tree) obj2, 0); +} /* Description of memory accesses in loops. */ @@ -140,7 +166,7 @@ typedef struct mem_ref static struct { /* The hash table of memory references accessed in loops. */ - htab_t refs; + hash_table refs; /* The list of memory references. */ vec refs_list; @@ -646,7 +672,7 @@ mem_ref_in_stmt (gimple stmt) gcc_assert (!store); hash = iterative_hash_expr (*mem, 0); - ref = (mem_ref_p) htab_find_with_hash (memory_accesses.refs, *mem, hash); + ref = memory_accesses.refs.find_with_hash (*mem, hash); gcc_assert (ref != NULL); return ref; @@ -1411,27 +1437,6 @@ force_move_till (tree ref, tree *index, void *data) return true; } -/* A hash function for struct mem_ref object OBJ. */ - -static hashval_t -memref_hash (const void *obj) -{ - const struct mem_ref *const mem = (const struct mem_ref *) obj; - - return mem->hash; -} - -/* An equality function for struct mem_ref object OBJ1 with - memory reference OBJ2. */ - -static int -memref_eq (const void *obj1, const void *obj2) -{ - const struct mem_ref *const mem1 = (const struct mem_ref *) obj1; - - return operand_equal_p (mem1->mem.ref, (const_tree) obj2, 0); -} - /* A function to free the mem_ref object OBJ. */ static void @@ -1502,7 +1507,7 @@ gather_mem_refs_stmt (struct loop *loop, gimple stmt) { tree *mem = NULL; hashval_t hash; - PTR *slot; + mem_ref **slot; mem_ref_p ref; bool is_stored; unsigned id; @@ -1526,8 +1531,7 @@ gather_mem_refs_stmt (struct loop *loop, gimple stmt) else { hash = iterative_hash_expr (*mem, 0); - slot = htab_find_slot_with_hash (memory_accesses.refs, - *mem, hash, INSERT); + slot = memory_accesses.refs.find_slot_with_hash (*mem, hash, INSERT); if (*slot) { ref = (mem_ref_p) *slot; @@ -2553,7 +2557,7 @@ tree_ssa_lim_initialize (void) alloc_aux_for_edges (0); - memory_accesses.refs = htab_create (100, memref_hash, memref_eq, NULL); + memory_accesses.refs.create (100); memory_accesses.refs_list.create (100); /* Allocate a special, unanalyzable mem-ref with ID zero. */ memory_accesses.refs_list.quick_push @@ -2596,7 +2600,7 @@ tree_ssa_lim_finalize (void) bitmap_obstack_release (&lim_bitmap_obstack); pointer_map_destroy (lim_aux_data_map); - htab_delete (memory_accesses.refs); + memory_accesses.refs.dispose (); FOR_EACH_VEC_ELT (memory_accesses.refs_list, i, ref) memref_free (ref); -- cgit v1.2.1