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/fortran | |
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/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/fortran/trans-decl.c | 70 | ||||
-rw-r--r-- | gcc/fortran/trans.c | 2 | ||||
-rw-r--r-- | gcc/fortran/trans.h | 12 |
4 files changed, 45 insertions, 43 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e6ffc27..a2a1cf1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2014-10-12 Trevor Saunders <tsaunders@mozilla.com> + + * trans-decl.c, trans.c, trans.h: Use hash_table instead of hashtab. + 2014-10-11 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> PR fortran/48979 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 92b350e..d168bdc 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -4228,72 +4228,62 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) gfc_add_init_cleanup (block, gfc_finish_block (&tmpblock), NULL_TREE); } -static GTY ((param_is (struct module_htab_entry))) htab_t module_htab; - -/* Hash and equality functions for module_htab. */ - -static hashval_t -module_htab_do_hash (const void *x) +struct module_hasher : ggc_hasher<module_htab_entry *> { - return htab_hash_string (((const struct module_htab_entry *)x)->name); -} + typedef const char *compare_type; -static int -module_htab_eq (const void *x1, const void *x2) -{ - return strcmp ((((const struct module_htab_entry *)x1)->name), - (const char *)x2) == 0; -} + static hashval_t hash (module_htab_entry *s) { return htab_hash_string (s); } + static bool + equal (module_htab_entry *a, const char *b) + { + return !strcmp (a->name, b); + } +}; + +static GTY (()) hash_table<module_hasher> *module_htab; /* Hash and equality functions for module_htab's decls. */ -static hashval_t -module_htab_decls_hash (const void *x) +hashval_t +module_decl_hasher::hash (tree t) { - const_tree t = (const_tree) x; const_tree n = DECL_NAME (t); if (n == NULL_TREE) n = TYPE_NAME (TREE_TYPE (t)); return htab_hash_string (IDENTIFIER_POINTER (n)); } -static int -module_htab_decls_eq (const void *x1, const void *x2) +bool +module_decl_hasher::equal (tree t1, const char *x2) { - const_tree t1 = (const_tree) x1; const_tree n1 = DECL_NAME (t1); if (n1 == NULL_TREE) n1 = TYPE_NAME (TREE_TYPE (t1)); - return strcmp (IDENTIFIER_POINTER (n1), (const char *) x2) == 0; + return strcmp (IDENTIFIER_POINTER (n1), x2) == 0; } struct module_htab_entry * gfc_find_module (const char *name) { - void **slot; - if (! module_htab) - module_htab = htab_create_ggc (10, module_htab_do_hash, - module_htab_eq, NULL); + module_htab = hash_table<module_hasher>::create_ggc (10); - slot = htab_find_slot_with_hash (module_htab, name, - htab_hash_string (name), INSERT); + module_htab_entry **slot + = module_htab->find_slot_with_hash (name, htab_hash_string (name), INSERT); if (*slot == NULL) { module_htab_entry *entry = ggc_cleared_alloc<module_htab_entry> (); entry->name = gfc_get_string (name); - entry->decls = htab_create_ggc (10, module_htab_decls_hash, - module_htab_decls_eq, NULL); - *slot = (void *) entry; + entry->decls = hash_table<module_decl_hasher>::create_ggc (10); + *slot = entry; } - return (struct module_htab_entry *) *slot; + return *slot; } void gfc_module_add_decl (struct module_htab_entry *entry, tree decl) { - void **slot; const char *name; if (DECL_NAME (decl)) @@ -4303,10 +4293,11 @@ gfc_module_add_decl (struct module_htab_entry *entry, tree decl) gcc_assert (TREE_CODE (decl) == TYPE_DECL); name = IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))); } - slot = htab_find_slot_with_hash (entry->decls, name, - htab_hash_string (name), INSERT); + tree *slot + = entry->decls->find_slot_with_hash (name, htab_hash_string (name), + INSERT); if (*slot == NULL) - *slot = (void *) decl; + *slot = decl; } static struct module_htab_entry *cur_module; @@ -4485,14 +4476,13 @@ gfc_trans_use_stmts (gfc_namespace * ns) for (rent = use_stmt->rename; rent; rent = rent->next) { tree decl, local_name; - void **slot; if (rent->op != INTRINSIC_NONE) continue; - slot = htab_find_slot_with_hash (entry->decls, rent->use_name, - htab_hash_string (rent->use_name), - INSERT); + hashval_t hash = htab_hash_string (rent->use_name); + tree *slot = entry->decls->find_slot_with_hash (rent->use_name, hash, + INSERT); if (*slot == NULL) { gfc_symtree *st; @@ -4547,7 +4537,7 @@ gfc_trans_use_stmts (gfc_namespace * ns) else { *slot = error_mark_node; - htab_clear_slot (entry->decls, slot); + entry->decls->clear_slot (slot); continue; } *slot = decl; diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index dbaa7d7..b707023 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -1963,7 +1963,7 @@ gfc_generate_module_code (gfc_namespace * ns) entry = gfc_find_module (ns->proc_name->name); if (entry->namespace_decl) /* Buggy sourcecode, using a module before defining it? */ - htab_empty (entry->decls); + entry->decls->empty (); entry->namespace_decl = ns->proc_name->backend_decl; gfc_generate_module_vars (ns); diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index 70719e4..465661c 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -575,10 +575,18 @@ void gfc_generate_module_vars (gfc_namespace *); /* Get the appropriate return statement for a procedure. */ tree gfc_generate_return (void); -struct GTY(()) module_htab_entry { +struct module_decl_hasher : ggc_hasher<tree_node *> +{ + typedef const char *compare_type; + + static hashval_t hash (tree); + static bool equal (tree, const char *); +}; + +struct GTY((for_user)) module_htab_entry { const char *name; tree namespace_decl; - htab_t GTY ((param_is (union tree_node))) decls; + hash_table<module_decl_hasher> *GTY (()) decls; }; struct module_htab_entry *gfc_find_module (const char *); |