diff options
author | crowl <crowl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-04-26 00:28:35 +0000 |
---|---|---|
committer | crowl <crowl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-04-26 00:28:35 +0000 |
commit | d9dd21a8b41029862ef23f68421a4b5bcfe72183 (patch) | |
tree | 5115f0a81b7cea52ab7997ce3322160f2baf2374 /gcc/cselib.c | |
parent | 0aeec17dae90b4fd400009f1e83e85e07ee5bb92 (diff) | |
download | gcc-d9dd21a8b41029862ef23f68421a4b5bcfe72183.tar.gz |
This patch is the main part of a consolodation 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-parloops.c'reduction
* tree-parloops.c'name_to_copy
Fold reduction_info_hash and reduction_info_eq into new struct
reduction_hasher. Fold name_to_copy_elt_eq and name_to_copy_elt_hash
into new struct name_to_copy_hasher.
* trans-mem.c'tm_log
Fold tm_log_hash, tm_log_eq, tm_log_free into new struct log_entry_hasher.
* trans-mem.c'tm_memopt_value_numbers
Fold tm_memop_hash, tm_memop_eq into new struct tm_memop_hasher.
* tree-ssa-strlen.c'decl_to_stridxlist_htab
Fold decl_to_stridxlist_hash into new struct stridxlist_hasher.
* tree-ssa-loop-ivopts.c'ivopts_data::inv_expr_tab
Fold htab_inv_expr_hash and htab_inv_expr_eq into new struct
iv_inv_expr_hasher.
* tree-ssa-uncprop.c'equiv
Equiv renamed to val_ssa_equiv because of name ambiguity with local variables.
Fold equiv_hash, equiv_eq and equiv_free into new struct val_ssa_equiv_hasher.
Renamed variables equiv_hash_elt to an_equiv_elt because of name ambiguity
with struct type. Changed equiv_hash_elt_p to an_equiv_elt_p to match.
* tree-ssa-phiopt.c'seen_ssa_names
Fold name_to_bb_hash and name_to_bb_eq into new struct ssa_names_hasher.
* tree-ssa-structalias.c'pointer_equiv_class_table
* tree-ssa-structalias.c'location_equiv_class_table
Fold equiv_class_label_hash and equiv_class_label_eq into new
struct equiv_class_hasher.
* tree-ssa-structalias.c'shared_bitmap_table
Fold shared_bitmap_hash and shared_bitmap_eq into new struct
shared_bitmap_hasher.
* tree-ssa-live.c'var_map_base_init::tree_to_index
New struct tree_int_map_hasher.
* tree-sra.c'candidates
Fold uid_decl_map_hash and uid_decl_map_eq into new struct
uid_decl_hasher. This change moves the definitions from tree-ssa.c
into tree-sra.c and removes the declarations from tree-flow.h
tree-browser.c
Remove stale declaration of removed TB_parent_eq.
Fix template parameter for base class to match value_type.
gimple.h
Use gimplify_hasher::hash rather than gimple_tree_hash in the
assertion check.
Change return values to match return type. (I.e. no conversions.)
* graphite-clast-to-gimple.c'ivs_params::newivs_index
* graphite-clast-to-gimple.c'ivs_params::params_index
* graphite-clast-to-gimple.c'print_generated_program::params_index
* graphite-clast-to-gimple.c'gloog::newivs_index
* graphite-clast-to-gimple.c'gloog::params_index
* graphite.c graphite_transform_loops::bb_pbb_mapping
* sese.c copy_bb_and_scalar_dependences::rename_map
Move hash table declarations to a new graphite-htab.h, because they
are used in few places.
Remove unused:
htab_t scop::original_pddrs
SCOP_ORIGINAL_PDDRS
Remove unused:
insert_loop_close_phis
insert_guard_phis
debug_ivtype_map
ivtype_map_elt_info
new_ivtype_map_elt
* gimplify.c'gimplify_ctx::temp_htab
Move struct gimple_temp_hash_elt and struct gimplify_ctx to a new
gimplify-ctx.h, because they are used few places.
* cselib.c'cselib_hash_table
* gcse.c'pre_ldst_table
* gimple-ssa-strength-reduction.c'base_cand_map
* haifa-sched.c'delay_htab
* haifa-sched.c'delay_htab_i2
* ira-color.c'allocno_hard_regs_htab
* ira-costs.c'cost_classes_htab
* loop-invariant.c'merge_identical_invariants::eq
* loop-iv.c'bivs
* loop-unroll.c'opt_info::insns_to_split
* loop-unroll.c'opt_info::insns_with_var_to_expand
* passes.c'name_to_pass_map
* plugin.c'event_tab
* postreload-gcse.c'expr_table
* store-motion.c'store_motion_mems_table
* tree-cfg.c'discriminator_per_locus
* tree-scalar-evolution.c'resolve_mixers::cache
* tree-ssa-dom.c'avail_exprs
Remove unused:
dse.c bitmap clear_alias_sets
dse.c bitmap disqualified_clear_alias_sets
dse.c alloc_pool clear_alias_mode_pool
dse.c dse_step2_spill
dse.c dse_step5_spill
graphds.h htab_t graph::indices
* attribs.c'scoped_attributes::attribute_hash
* bitmap.c'bitmap_desc_hash
* dwarf2cfi.c'trace_index
* dwarf2out.c'break_out_includes::cu_hash_table
* dwarf2out.c'copy_decls_for_unworthy_types::decl_table
* dwarf2out.c'optimize_external_refs::map
* dwarf2out.c'output_comp_unit::extern_map
* dwarf2out.c'output_comdat_type_unit::extern_map
* dwarf2out.c'output_macinfo::macinfo_htab
* dwarf2out.c'optimize_location_lists::htab
* dwarf2out.c'dwarf2out_finish::comdat_type_table
* except.c'ehspec_hash_type
* except.c'assign_filter_values::ttypes
* except.c'assign_filter_values::ehspec
* except.c'sjlj_assign_call_site_values::ar_hash
* except.c'convert_to_eh_region_ranges::ar_hash
* trans-mem.c'tm_new_mem_hash
* tree-browser.c'TB_up_ht
* tree-eh.c'finally_tree
Move the declaration of hash_table <alloc_pool_hasher> alloc_pool_hash
in alloc-pool.c to after the method definitions for its parameter
class.
* ggc-common.c'loc_hash
* ggc-common.c'ptr_hash
Add a new hash_table method elements_with_deleted to meet the needs of
gcc-common.c.
Correct many methods with parameter types compare_type to the correct
value_type. (Correct code was unlikely to notice the change, but
incorrect code will.)
* tree-complex.c'complex_variable_components
* tree-parloops.c'eliminate_local_variables_stmt::decl_address
* tree-parloops.c'separate_decls_in_region::decl_copies
Move hash table declarations to a new tree-hasher.h, to resolve
compilation dependences and because they are used in few places.
* lto-streamer.h'output_block::string_hash_table
* lto-streamer-in.c'file_name_hash_table
* lto-streamer.c'tree_htab
The struct string_slot moves from data-streamer.h to lto-streamer.h to
resolve compilation dependences.
Tested on x86_64.
Index: gcc/ChangeLog
2013-04-25 Lawrence Crowl <crowl@google.com>
* Makefile.in: Update as needed below.
* alloc-pool.c (static hash_table <alloc_pool_hasher> alloc_pool_hash):
Move declaration to after the type's method definitons.
* attribs.c (htab_t scoped_attributes::attribute_hash):
Change type to hash_table. Update dependent calls and types.
* bitmap.c (htab_t bitmap_desc_hash):
Change type to hash_table. Update dependent calls and types.
* cselib.c (htab_t cselib_hash_table):
Change type to hash_table. Update dependent calls and types.
* data-streamer.h (struct string_slot): Move to lto-streamer.h.
(hash_string_slot_node): Move implementation into lto-streamer.h
struct string_slot_hasher.
(eq_string_slot_node): Likewise.
* data-streamer-out.c: Update output_block::string_hash_table
dependent calls and types.
* dwarf2cfi.c (htab_t trace_index):
Change type to hash_table. Update dependent calls and types.
* dwarf2out.c (htab_t break_out_includes::cu_hash_table):
Change type to hash_table. Update dependent calls and types.
(htab_t copy_decls_for_unworthy_types::decl_table): Likewise.
(htab_t optimize_external_refs::map): Likewise.
(htab_t output_comp_unit::extern_map): Likewise.
(htab_t output_comdat_type_unit::extern_map): Likewise.
(htab_t output_macinfo::macinfo_htab): Likewise.
(htab_t optimize_location_lists::htab): Likewise.
(htab_t dwarf2out_finish::comdat_type_table): Likewise.
* except.c (htab_t ehspec_hash_type):
Change type to hash_table. Update dependent calls and types.
(assign_filter_values::ttypes): Likewise.
(assign_filter_values::ehspec): Likewise.
(sjlj_assign_call_site_values::ar_hash): Likewise.
(convert_to_eh_region_ranges::ar_hash): Likewise.
* gcse.c (htab_t pre_ldst_table):
Change type to hash_table. Update dependent calls and types.
* ggc-common.c (htab_t saving_htab):
Change type to hash_table. Update dependent calls and types.
(htab_t loc_hash): Likewise.
(htab_t ptr_hash): Likewise.
(call_count): Rename ggc_call_count.
(call_alloc): Rename ggc_call_alloc.
(loc_descriptor): Rename make_loc_descriptor.
(add_statistics): Rename ggc_add_statistics.
* ggc-common.c (saving_htab):
Change type to hash_table. Update dependent calls and types.
* gimple.h (struct gimplify_ctx): Move to gimplify-ctx.h.
(push_gimplify_context): Likewise.
(pop_gimplify_context): Likewise.
(struct gimple_temp_hash_elt): Added.
(struct gimplify_hasher): Likewise.
(struct gimplify_ctx.temp_htab):
Change type to hash_table. Update dependent calls and types.
* gimple-fold.c: Include gimplify-ctx.h.
* gimple-ssa-strength-reduction.c (htab_t base_cand_map):
Change type to hash_table. Update dependent calls and types.
(base_cand_dump_callback): Rename to ssa_base_cand_dump_callback to
avoid potential global name collision.
* gimplify.c: Include gimplify-ctx.h.
(struct gimple_temp_hash_elt): Move to gimplify-ctx.h.
(htab_t gimplify_ctx::temp_htab):
Update dependent calls and types for new type hash_table.
(gimple_tree_hash): Move into gimplify_hasher in gimplify-ctx.h.
(gimple_tree_eq): Move into gimplify_hasher in gimplify-ctx.h.
* gimplify-ctx.h: New.
(struct gimple_temp_hash_elt): Move from gimplify.c.
(class gimplify_hasher): New.
(struct gimplify_ctx): Move from gimple.h.
(htab_t gimplify_ctx::temp_htab):
Change type to hash_table. Update dependent calls and types.
* graphite-clast-to-gimple.c: Include graphite-htab.h.
(htab_t ivs_params::newivs_index):
Change type to hash_table. Update dependent calls and types.
(htab_t ivs_params::params_index): Likewise.
(htab_t print_generated_program::params_index): Likewise.
(htab_t gloog::newivs_index): Likewise.
(htab_t gloog::params_index): Likewise.
* graphite.c: Include graphite-htab.h.
4htab_t graphite_transform_loops::bb_pbb_mapping):
Change type to hash_table. Update dependent calls and types.
* graphite-clast-to-gimple.h: (extern gloog) Move to graphite-htab.h.
(bb_pbb_map_hash): Fold into bb_pbb_htab_type in graphite-htab.h.
(eq_bb_pbb_map): Fold into bb_pbb_htab_type in graphite-htab.h.
* graphite-dependences.c: Include graphite-htab.h.
(loop_is_parallel_p): Change hash table type of parameter.
* graphite-htab.h: New.
(typedef hash_table <bb_pbb_hasher> bb_pbb_htab_type): New.
(extern find_pbb_via_hash): Move from graphite-poly.h.
(extern loop_is_parallel_p): Move from graphite-poly.h.
(extern get_loop_body_pbbs): Move from graphite-poly.h.
* graphite-poly.h (extern find_pbb_via_hash): Move to graphite-htab.h.
(extern loop_is_parallel_p): Move to graphite-htab.h.
(extern get_loop_body_pbbs): Move to graphite-htab.h.
* haifa-sched.c (htab_t delay_htab):
Change type to hash_table. Update dependent calls and types.
(htab_t delay_htab_i2): Likewise.
* ira-color.c (htab_t allocno_hard_regs_htab):
Change type to hash_table. Update dependent calls and types.
* ira-costs.c (htab_t cost_classes_htab):
Change type to hash_table. Update dependent calls and types.
* loop-invariant.c (htab_t merge_identical_invariants::eq):
Change type to hash_table. Update dependent calls and types.
* loop-iv.c (htab_t bivs):
Change type to hash_table. Update dependent calls and types.
* loop-unroll.c (htab_t opt_info::insns_to_split):
Change type to hash_table. Update dependent calls and types.
(htab_t opt_info::insns_with_var_to_expand): Likewise.
* lto-streamer.h (struct string_slot): Move from data-streamer.h
(struct string_slot_hasher): New.
(htab_t output_block::string_hash_table):
Change type to hash_table. Update dependent calls and types.
* lto-streamer-in.c (freeing_string_slot_hasher): New.
(htab_t file_name_hash_table):
Change type to hash_table. Update dependent calls and types.
* lto-streamer-out.c: Update output_block::string_hash_table dependent
calls and types.
* lto-streamer.c (htab_t tree_htab):
Change type to hash_table. Update dependent calls and types.
* omp-low.c: Include gimplify-ctx.h.
* passes.c (htab_t name_to_pass_map):
Change type to hash_table. Update dependent calls and types.
(pass_traverse): Rename to passes_pass_traverse.
* plugin.c (htab_t event_tab):
Change type to hash_table. Update dependent calls and types.
* postreload-gcse.c (htab_t expr_table):
Change type to hash_table. Update dependent calls and types.
(dump_hash_table_entry): Rename dump_expr_hash_table_entry.
* sese.c (debug_rename_map_1): Make extern.
(htab_t copy_bb_and_scalar_dependences::rename_map):
Change type to hash_table. Update dependent calls and types.
* sese.h (extern debug_rename_map): Move to .c file.
* store-motion.c (htab_t store_motion_mems_table):
Change type to hash_table. Update dependent calls and types.
* trans-mem.c (htab_t tm_new_mem_hash):
Change type to hash_table. Update dependent calls and types.
* tree-browser.c (htab_t TB_up_ht):
Change type to hash_table. Update dependent calls and types.
* tree-cfg.c (htab_t discriminator_per_locus):
Change type to hash_table. Update dependent calls and types.
* tree-complex.c: Include tree-hasher.h
(htab_t complex_variable_components):
Change type to hash_table. Update dependent calls and types.
* tree-eh.c (htab_t finally_tree):
Change type to hash_table. Update dependent calls and types.
* tree-flow.h (extern int_tree_map_hash): Moved into tree-hasher
struct int_tree_hasher.
(extern int_tree_map_eq): Likewise.
(uid_decl_map_hash): Removed.
(extern decl_tree_map_eq): Likewise.
* tree-hasher.h: New.
(struct int_tree_hasher): New.
(typedef int_tree_htab_type): New.
* tree-inline.c: Include gimplify-ctx.h.
* tree-mudflap.c: Include gimplify-ctx.h.
* tree-parloops.c: Include tree-hasher.h.
(htab_t eliminate_local_variables_stmt::decl_address):
Change type to hash_table. Update dependent calls and types.
(htab_t separate_decls_in_region::decl_copies): Likewise.
* tree-scalar-evolution.c (htab_t resolve_mixers::cache):
Change type to hash_table. Update dependent calls and types.
* tree-sra.c (candidates):
Change type to hash_table. Update dependent calls and types.
* tree-ssa.c (int_tree_map_eq): Moved into struct int_tree_hasher
in tree-flow.h.
(int_tree_map_hash): Likewise.
* tree-ssa-dom.c (htab_t avail_exprs):
Change type to hash_table. Update dependent calls and types.
* tree-ssa-live.c (var_map_base_init::tree_to_index):
Change type to hash_table. Update dependent calls and types.
* tree-ssa-loop-ivopts.c (struct ivopts_data.inv_expr_tab):
Change type to hash_table. Update dependent calls and types.
* tree-ssa-phiopt.c (seen_ssa_names):
Change type to hash_table. Update dependent calls and types.
* tree-ssa-strlen.c (decl_to_stridxlist_htab):
Change type to hash_table. Update dependent calls and types.
* tree-ssa-uncprop.c (equiv):
Change type to hash_table. Update dependent calls and types.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198329 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cselib.c')
-rw-r--r-- | gcc/cselib.c | 178 |
1 files changed, 88 insertions, 90 deletions
diff --git a/gcc/cselib.c b/gcc/cselib.c index dcad97417d8..589e41ed3df 100644 --- a/gcc/cselib.c +++ b/gcc/cselib.c @@ -34,7 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "emit-rtl.h" #include "diagnostic-core.h" #include "ggc.h" -#include "hashtab.h" +#include "hash-table.h" #include "dumpfile.h" #include "cselib.h" #include "valtrack.h" @@ -49,18 +49,18 @@ struct elt_list { cselib_val *elt; }; +/* See the documentation of cselib_find_slot below. */ +static enum machine_mode find_slot_memmode; + static bool cselib_record_memory; static bool cselib_preserve_constants; static bool cselib_any_perm_equivs; -static int entry_and_rtx_equal_p (const void *, const void *); -static hashval_t get_value_hash (const void *); +static inline void promote_debug_loc (struct elt_loc_list *l); static struct elt_list *new_elt_list (struct elt_list *, cselib_val *); static void new_elt_loc_list (cselib_val *, rtx); static void unchain_one_value (cselib_val *); static void unchain_one_elt_list (struct elt_list **); static void unchain_one_elt_loc_list (struct elt_loc_list **); -static int discard_useless_locs (void **, void *); -static int discard_useless_values (void **, void *); static void remove_useless_values (void); static int rtx_equal_for_cselib_1 (rtx, rtx, enum machine_mode); static unsigned int cselib_hash_rtx (rtx, int, enum machine_mode); @@ -91,8 +91,61 @@ static rtx cselib_expand_value_rtx_1 (rtx, struct expand_value_data *, int); this involves walking the table entries for a given value and comparing the locations of the entries with the rtx we are looking up. */ +struct cselib_hasher : typed_noop_remove <cselib_val> +{ + typedef cselib_val value_type; + typedef rtx_def compare_type; + static inline hashval_t hash (const value_type *); + static inline bool equal (const value_type *, const compare_type *); +}; + +/* The hash function for our hash table. The value is always computed with + cselib_hash_rtx when adding an element; this function just extracts the + hash value from a cselib_val structure. */ + +inline hashval_t +cselib_hasher::hash (const value_type *v) +{ + return v->hash; +} + +/* The equality test for our hash table. The first argument V is a table + element (i.e. a cselib_val), while the second arg X is an rtx. We know + that all callers of htab_find_slot_with_hash will wrap CONST_INTs into a + CONST of an appropriate mode. */ + +inline bool +cselib_hasher::equal (const value_type *v, const compare_type *x_arg) +{ + struct elt_loc_list *l; + rtx x = CONST_CAST_RTX (x_arg); + enum machine_mode mode = GET_MODE (x); + + gcc_assert (!CONST_SCALAR_INT_P (x) && GET_CODE (x) != CONST_FIXED); + + if (mode != GET_MODE (v->val_rtx)) + return false; + + /* Unwrap X if necessary. */ + if (GET_CODE (x) == CONST + && (CONST_SCALAR_INT_P (XEXP (x, 0)) + || GET_CODE (XEXP (x, 0)) == CONST_FIXED)) + x = XEXP (x, 0); + + /* We don't guarantee that distinct rtx's have different hash values, + so we need to do a comparison. */ + for (l = v->locs; l; l = l->next) + if (rtx_equal_for_cselib_1 (l->loc, x, find_slot_memmode)) + { + promote_debug_loc (l); + return true; + } + + return false; +} + /* A table that enables us to look up elts by their value. */ -static htab_t cselib_hash_table; +static hash_table <cselib_hasher> cselib_hash_table; /* This is a global so we don't have to pass this through every function. It is used in new_elt_loc_list to set SETTING_INSN. */ @@ -432,13 +485,13 @@ invariant_or_equiv_p (cselib_val *v) /* Remove from hash table all VALUEs except constants, function invariants and VALUE equivalences. */ -static int -preserve_constants_and_equivs (void **x, void *info ATTRIBUTE_UNUSED) +int +preserve_constants_and_equivs (cselib_val **x, void *info ATTRIBUTE_UNUSED) { - cselib_val *v = (cselib_val *)*x; + cselib_val *v = *x; if (!invariant_or_equiv_p (v)) - htab_clear_slot (cselib_hash_table, x); + cselib_hash_table.clear_slot (x); return 1; } @@ -478,10 +531,10 @@ cselib_reset_table (unsigned int num) } if (cselib_preserve_constants) - htab_traverse (cselib_hash_table, preserve_constants_and_equivs, NULL); + cselib_hash_table.traverse <void *, preserve_constants_and_equivs> (NULL); else { - htab_empty (cselib_hash_table); + cselib_hash_table.empty (); gcc_checking_assert (!cselib_any_perm_equivs); } @@ -502,73 +555,23 @@ cselib_get_next_uid (void) return next_uid; } -/* See the documentation of cselib_find_slot below. */ -static enum machine_mode find_slot_memmode; - /* Search for X, whose hashcode is HASH, in CSELIB_HASH_TABLE, INSERTing if requested. When X is part of the address of a MEM, MEMMODE should specify the mode of the MEM. While searching the table, MEMMODE is held in FIND_SLOT_MEMMODE, so that autoinc RTXs in X can be resolved. */ -static void ** +static cselib_val ** cselib_find_slot (rtx x, hashval_t hash, enum insert_option insert, enum machine_mode memmode) { - void **slot; + cselib_val **slot; find_slot_memmode = memmode; - slot = htab_find_slot_with_hash (cselib_hash_table, x, hash, insert); + slot = cselib_hash_table.find_slot_with_hash (x, hash, insert); find_slot_memmode = VOIDmode; return slot; } -/* The equality test for our hash table. The first argument ENTRY is a table - element (i.e. a cselib_val), while the second arg X is an rtx. We know - that all callers of htab_find_slot_with_hash will wrap CONST_INTs into a - CONST of an appropriate mode. */ - -static int -entry_and_rtx_equal_p (const void *entry, const void *x_arg) -{ - struct elt_loc_list *l; - const cselib_val *const v = (const cselib_val *) entry; - rtx x = CONST_CAST_RTX ((const_rtx)x_arg); - enum machine_mode mode = GET_MODE (x); - - gcc_assert (!CONST_SCALAR_INT_P (x) && GET_CODE (x) != CONST_FIXED); - - if (mode != GET_MODE (v->val_rtx)) - return 0; - - /* Unwrap X if necessary. */ - if (GET_CODE (x) == CONST - && (CONST_SCALAR_INT_P (XEXP (x, 0)) - || GET_CODE (XEXP (x, 0)) == CONST_FIXED)) - x = XEXP (x, 0); - - /* We don't guarantee that distinct rtx's have different hash values, - so we need to do a comparison. */ - for (l = v->locs; l; l = l->next) - if (rtx_equal_for_cselib_1 (l->loc, x, find_slot_memmode)) - { - promote_debug_loc (l); - return 1; - } - - return 0; -} - -/* The hash function for our hash table. The value is always computed with - cselib_hash_rtx when adding an element; this function just extracts the - hash value from a cselib_val structure. */ - -static hashval_t -get_value_hash (const void *entry) -{ - const cselib_val *const v = (const cselib_val *) entry; - return v->hash; -} - /* Return true if X contains a VALUE rtx. If ONLY_USELESS is set, we only return true for values which point to a cselib_val whose value element has been set to zero, which implies the cselib_val will be @@ -603,10 +606,10 @@ references_value_p (const_rtx x, int only_useless) values (i.e. values without any location). Called through htab_traverse. */ -static int -discard_useless_locs (void **x, void *info ATTRIBUTE_UNUSED) +int +discard_useless_locs (cselib_val **x, void *info ATTRIBUTE_UNUSED) { - cselib_val *v = (cselib_val *)*x; + cselib_val *v = *x; struct elt_loc_list **p = &v->locs; bool had_locs = v->locs != NULL; rtx setting_insn = v->locs ? v->locs->setting_insn : NULL; @@ -632,10 +635,10 @@ discard_useless_locs (void **x, void *info ATTRIBUTE_UNUSED) /* If X is a value with no locations, remove it from the hashtable. */ -static int -discard_useless_values (void **x, void *info ATTRIBUTE_UNUSED) +int +discard_useless_values (cselib_val **x, void *info ATTRIBUTE_UNUSED) { - cselib_val *v = (cselib_val *)*x; + cselib_val *v = *x; if (v->locs == 0 && !PRESERVED_VALUE_P (v->val_rtx)) { @@ -643,7 +646,7 @@ discard_useless_values (void **x, void *info ATTRIBUTE_UNUSED) cselib_discard_hook (v); CSELIB_VAL_PTR (v->val_rtx) = NULL; - htab_clear_slot (cselib_hash_table, x); + cselib_hash_table.clear_slot (x); unchain_one_value (v); n_useless_values--; } @@ -664,7 +667,7 @@ remove_useless_values (void) do { values_became_useless = 0; - htab_traverse (cselib_hash_table, discard_useless_locs, 0); + cselib_hash_table.traverse <void *, discard_useless_locs> (NULL); } while (values_became_useless); @@ -683,7 +686,7 @@ remove_useless_values (void) n_debug_values -= n_useless_debug_values; n_useless_debug_values = 0; - htab_traverse (cselib_hash_table, discard_useless_values, 0); + cselib_hash_table.traverse <void *, discard_useless_values> (NULL); gcc_assert (!n_useless_values); } @@ -1352,7 +1355,7 @@ cselib_lookup_mem (rtx x, int create) { enum machine_mode mode = GET_MODE (x); enum machine_mode addr_mode; - void **slot; + cselib_val **slot; cselib_val *addr; cselib_val *mem_elt; struct elt_list *l; @@ -1958,7 +1961,7 @@ static cselib_val * cselib_lookup_1 (rtx x, enum machine_mode mode, int create, enum machine_mode memmode) { - void **slot; + cselib_val **slot; cselib_val *e; unsigned int hashval; @@ -2069,7 +2072,7 @@ cselib_lookup_1 (rtx x, enum machine_mode mode, /* We have to fill the slot before calling cselib_subst_to_values: the hash table is inconsistent until we do so, and cselib_subst_to_values will need to do lookups. */ - *slot = (void *) e; + *slot = e; new_elt_loc_list (e, cselib_subst_to_values (x, memmode)); return e; } @@ -2695,9 +2698,7 @@ cselib_process_insn (rtx insn) quadratic behavior for very large hashtables with very few useless elements. */ && ((unsigned int)n_useless_values - > (cselib_hash_table->n_elements - - cselib_hash_table->n_deleted - - n_debug_values) / 4)) + > (cselib_hash_table.elements () - n_debug_values) / 4)) remove_useless_values (); } @@ -2738,8 +2739,7 @@ cselib_init (int record_what) } used_regs = XNEWVEC (unsigned int, cselib_nregs); n_used_regs = 0; - cselib_hash_table = htab_create (31, get_value_hash, - entry_and_rtx_equal_p, NULL); + cselib_hash_table.create (31); next_uid = 1; } @@ -2758,23 +2758,21 @@ cselib_finish (void) free_alloc_pool (cselib_val_pool); free_alloc_pool (value_pool); cselib_clear_table (); - htab_delete (cselib_hash_table); + cselib_hash_table.dispose (); free (used_regs); used_regs = 0; - cselib_hash_table = 0; n_useless_values = 0; n_useless_debug_values = 0; n_debug_values = 0; next_uid = 0; } -/* Dump the cselib_val *X to FILE *info. */ +/* Dump the cselib_val *X to FILE *OUT. */ -static int -dump_cselib_val (void **x, void *info) +int +dump_cselib_val (cselib_val **x, FILE *out) { - cselib_val *v = (cselib_val *)*x; - FILE *out = (FILE *)info; + cselib_val *v = *x; bool need_lf = true; print_inline_rtx (out, v->val_rtx, 0); @@ -2849,7 +2847,7 @@ void dump_cselib_table (FILE *out) { fprintf (out, "cselib hash table:\n"); - htab_traverse (cselib_hash_table, dump_cselib_val, out); + cselib_hash_table.traverse <FILE *, dump_cselib_val> (out); if (first_containing_mem != &dummy_val) { fputs ("first mem ", out); |