diff options
author | Trevor Saunders <tsaunders@mozilla.com> | 2014-10-12 22:22:53 +0000 |
---|---|---|
committer | Trevor Saunders <tbsaunde@gcc.gnu.org> | 2014-10-12 22:22:53 +0000 |
commit | 2a22f99cb12d82712dd93cfef808b1cef543601b (patch) | |
tree | c828063f153ceb609ce5c7d44ea9f00391b32950 /gcc/function.c | |
parent | 7b262a51ea2310bdb6cc901de00f04b0e7be0a4e (diff) | |
download | gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.zip gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.tar.gz gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.tar.bz2 |
move many gc hashtab to hash_table
gcc/
* asan.c, cfgloop.c, cfgloop.h, cgraph.c, cgraph.h,
config/darwin.c, config/m32c/m32c.c, config/mep/mep.c,
config/mips/mips.c, config/rs6000/rs6000.c, dwarf2out.c,
function.c, function.h, gimple-ssa.h, libfuncs.h, optabs.c,
output.h, rtl.h, sese.c, symtab.c, tree-cfg.c, tree-dfa.c,
tree-ssa.c, varasm.c: Use hash-table instead of hashtab.
* doc/gty.texi (for_user): Document new option.
* gengtype.c (create_user_defined_type): Don't try to get a struct for
char.
(walk_type): Don't error out on for_user option.
(write_func_for_structure): Emit user marking routines if requested by
for_user option.
(write_local_func_for_structure): Likewise.
(main): Mark types with for_user option as used.
* ggc.h (gt_pch_nx): Add overload for unsigned int.
* hash-map.h (hash_map::hash_entry::pch_nx_helper): AddOverloads.
* hash-table.h (ggc_hasher): New struct.
(hash_table::create_ggc): New function.
(gt_pch_nx): New overload for hash_table.
java/
* class.c, decl.c, except.c, expr.c, java-tree.h, lang.c: Use
hash_table instead of hashtab.
objc/
* objc-act.c: use hash_table instead of hashtab.
cp/
* cp-gimplify.c, cp-tree.h, decl.c, mangle.c, name-lookup.c,
pt.c, semantics.c, tree.c, typeck2.c: Use hash_table instead of
hashtab.
fortran/
* trans-decl.c, trans.c, trans.h: Use hash_table instead of hashtab.
c-family/
* c-common.c: Use hash_table instead of hashtab.
From-SVN: r216127
Diffstat (limited to 'gcc/function.c')
-rw-r--r-- | gcc/function.c | 92 |
1 files changed, 39 insertions, 53 deletions
diff --git a/gcc/function.c b/gcc/function.c index ac50f4a..71b5f0d 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -108,7 +108,7 @@ static GTY((if_marked ("ggc_marked_p"), param_is (struct rtx_def))) htab_t epilogue_insn_hash; -htab_t types_used_by_vars_hash = NULL; +hash_table<used_type_hasher> *types_used_by_vars_hash = NULL; vec<tree, va_gc> *types_used_by_cur_var_decl; /* Forward declarations. */ @@ -540,18 +540,24 @@ struct GTY(()) temp_slot { HOST_WIDE_INT full_size; }; -/* A table of addresses that represent a stack slot. The table is a mapping - from address RTXen to a temp slot. */ -static GTY((param_is(struct temp_slot_address_entry))) htab_t temp_slot_address_table; -static size_t n_temp_slots_in_use; - -/* Entry for the above hash table. */ -struct GTY(()) temp_slot_address_entry { +/* Entry for the below hash table. */ +struct GTY((for_user)) temp_slot_address_entry { hashval_t hash; rtx address; struct temp_slot *temp_slot; }; +struct temp_address_hasher : ggc_hasher<temp_slot_address_entry *> +{ + static hashval_t hash (temp_slot_address_entry *); + static bool equal (temp_slot_address_entry *, temp_slot_address_entry *); +}; + +/* A table of addresses that represent a stack slot. The table is a mapping + from address RTXen to a temp slot. */ +static GTY(()) hash_table<temp_address_hasher> *temp_slot_address_table; +static size_t n_temp_slots_in_use; + /* Removes temporary slot TEMP from LIST. */ static void @@ -634,21 +640,17 @@ temp_slot_address_compute_hash (struct temp_slot_address_entry *t) } /* Return the hash value for an address -> temp slot mapping. */ -static hashval_t -temp_slot_address_hash (const void *p) +hashval_t +temp_address_hasher::hash (temp_slot_address_entry *t) { - const struct temp_slot_address_entry *t; - t = (const struct temp_slot_address_entry *) p; return t->hash; } /* Compare two address -> temp slot mapping entries. */ -static int -temp_slot_address_eq (const void *p1, const void *p2) +bool +temp_address_hasher::equal (temp_slot_address_entry *t1, + temp_slot_address_entry *t2) { - const struct temp_slot_address_entry *t1, *t2; - t1 = (const struct temp_slot_address_entry *) p1; - t2 = (const struct temp_slot_address_entry *) p2; return exp_equiv_p (t1->address, t2->address, 0, true); } @@ -656,24 +658,21 @@ temp_slot_address_eq (const void *p1, const void *p2) static void insert_temp_slot_address (rtx address, struct temp_slot *temp_slot) { - void **slot; struct temp_slot_address_entry *t = ggc_alloc<temp_slot_address_entry> (); t->address = address; t->temp_slot = temp_slot; t->hash = temp_slot_address_compute_hash (t); - slot = htab_find_slot_with_hash (temp_slot_address_table, t, t->hash, INSERT); - *slot = t; + *temp_slot_address_table->find_slot_with_hash (t, t->hash, INSERT) = t; } /* Remove an address -> temp slot mapping entry if the temp slot is not in use anymore. Callback for remove_unused_temp_slot_addresses. */ -static int -remove_unused_temp_slot_addresses_1 (void **slot, void *data ATTRIBUTE_UNUSED) +int +remove_unused_temp_slot_addresses_1 (temp_slot_address_entry **slot, void *) { - const struct temp_slot_address_entry *t; - t = (const struct temp_slot_address_entry *) *slot; + const struct temp_slot_address_entry *t = *slot; if (! t->temp_slot->in_use) - htab_clear_slot (temp_slot_address_table, slot); + temp_slot_address_table->clear_slot (slot); return 1; } @@ -683,11 +682,10 @@ remove_unused_temp_slot_addresses (void) { /* Use quicker clearing if there aren't any active temp slots. */ if (n_temp_slots_in_use) - htab_traverse (temp_slot_address_table, - remove_unused_temp_slot_addresses_1, - NULL); + temp_slot_address_table->traverse + <void *, remove_unused_temp_slot_addresses_1> (NULL); else - htab_empty (temp_slot_address_table); + temp_slot_address_table->empty (); } /* Find the temp slot corresponding to the object at address X. */ @@ -703,8 +701,7 @@ find_temp_slot_from_address (rtx x) tmp.address = x; tmp.temp_slot = NULL; tmp.hash = temp_slot_address_compute_hash (&tmp); - t = (struct temp_slot_address_entry *) - htab_find_with_hash (temp_slot_address_table, &tmp, tmp.hash); + t = temp_slot_address_table->find_with_hash (&tmp, tmp.hash); if (t) return t->temp_slot; @@ -1195,12 +1192,9 @@ init_temp_slots (void) /* Set up the table to map addresses to temp slots. */ if (! temp_slot_address_table) - temp_slot_address_table = htab_create_ggc (32, - temp_slot_address_hash, - temp_slot_address_eq, - NULL); + temp_slot_address_table = hash_table<temp_address_hasher>::create_ggc (32); else - htab_empty (temp_slot_address_table); + temp_slot_address_table->empty (); } /* Functions and data structures to keep track of the values hard regs @@ -6145,24 +6139,17 @@ hash_types_used_by_vars_entry (const struct types_used_by_vars_entry *entry) /* Hash function of the types_used_by_vars_entry hash table. */ hashval_t -types_used_by_vars_do_hash (const void *x) +used_type_hasher::hash (types_used_by_vars_entry *entry) { - const struct types_used_by_vars_entry *entry = - (const struct types_used_by_vars_entry *) x; - return hash_types_used_by_vars_entry (entry); } /*Equality function of the types_used_by_vars_entry hash table. */ -int -types_used_by_vars_eq (const void *x1, const void *x2) +bool +used_type_hasher::equal (types_used_by_vars_entry *e1, + types_used_by_vars_entry *e2) { - const struct types_used_by_vars_entry *e1 = - (const struct types_used_by_vars_entry *) x1; - const struct types_used_by_vars_entry *e2 = - (const struct types_used_by_vars_entry *)x2; - return (e1->var_decl == e2->var_decl && e1->type == e2->type); } @@ -6173,16 +6160,15 @@ types_used_by_var_decl_insert (tree type, tree var_decl) { if (type != NULL && var_decl != NULL) { - void **slot; + types_used_by_vars_entry **slot; struct types_used_by_vars_entry e; e.var_decl = var_decl; e.type = type; if (types_used_by_vars_hash == NULL) - types_used_by_vars_hash = - htab_create_ggc (37, types_used_by_vars_do_hash, - types_used_by_vars_eq, NULL); - slot = htab_find_slot_with_hash (types_used_by_vars_hash, &e, - hash_types_used_by_vars_entry (&e), INSERT); + types_used_by_vars_hash + = hash_table<used_type_hasher>::create_ggc (37); + + slot = types_used_by_vars_hash->find_slot (&e, INSERT); if (*slot == NULL) { struct types_used_by_vars_entry *entry; |