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/cp/tree.c | |
parent | 7b262a51ea2310bdb6cc901de00f04b0e7be0a4e (diff) | |
download | gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.tar.gz |
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/cp/tree.c')
-rw-r--r-- | gcc/cp/tree.c | 85 |
1 files changed, 45 insertions, 40 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5b11d5cc8f0..9008cdb4da9 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "tm.h" #include "tree.h" +#include "tree-hasher.h" #include "stor-layout.h" #include "print-tree.h" #include "tree-iterator.h" @@ -40,9 +41,7 @@ along with GCC; see the file COPYING3. If not see static tree bot_manip (tree *, int *, void *); static tree bot_replace (tree *, int *, void *); -static int list_hash_eq (const void *, const void *); static hashval_t list_hash_pieces (tree, tree, tree); -static hashval_t list_hash (const void *); static tree build_target_expr (tree, tree, tsubst_flags_t); static tree count_trees_r (tree *, int *, void *); static tree verify_stmt_tree_r (tree *, int *, void *); @@ -722,13 +721,26 @@ rvalue (tree expr) } +struct cplus_array_info +{ + tree type; + tree domain; +}; + +struct cplus_array_hasher : ggc_hasher<tree> +{ + typedef cplus_array_info *compare_type; + + static hashval_t hash (tree t); + static bool equal (tree, cplus_array_info *); +}; + /* Hash an ARRAY_TYPE. K is really of type `tree'. */ -static hashval_t -cplus_array_hash (const void* k) +hashval_t +cplus_array_hasher::hash (tree t) { hashval_t hash; - const_tree const t = (const_tree) k; hash = TYPE_UID (TREE_TYPE (t)); if (TYPE_DOMAIN (t)) @@ -736,26 +748,18 @@ cplus_array_hash (const void* k) return hash; } -typedef struct cplus_array_info { - tree type; - tree domain; -} cplus_array_info; - /* Compare two ARRAY_TYPEs. K1 is really of type `tree', K2 is really of type `cplus_array_info*'. */ -static int -cplus_array_compare (const void * k1, const void * k2) +bool +cplus_array_hasher::equal (tree t1, cplus_array_info *t2) { - const_tree const t1 = (const_tree) k1; - const cplus_array_info *const t2 = (const cplus_array_info*) k2; - return (TREE_TYPE (t1) == t2->type && TYPE_DOMAIN (t1) == t2->domain); } /* Hash table containing dependent array types, which are unsuitable for the language-independent type hash table. */ -static GTY ((param_is (union tree_node))) htab_t cplus_array_htab; +static GTY (()) hash_table<cplus_array_hasher> *cplus_array_htab; /* Build an ARRAY_TYPE without laying it out. */ @@ -813,13 +817,11 @@ build_cplus_array_type (tree elt_type, tree index_type) { /* Since type_hash_canon calls layout_type, we need to use our own hash table. */ - void **e; cplus_array_info cai; hashval_t hash; if (cplus_array_htab == NULL) - cplus_array_htab = htab_create_ggc (61, &cplus_array_hash, - &cplus_array_compare, NULL); + cplus_array_htab = hash_table<cplus_array_hasher>::create_ggc (61); hash = TYPE_UID (elt_type); if (index_type) @@ -827,7 +829,7 @@ build_cplus_array_type (tree elt_type, tree index_type) cai.type = elt_type; cai.domain = index_type; - e = htab_find_slot_with_hash (cplus_array_htab, &cai, hash, INSERT); + tree *e = cplus_array_htab->find_slot_with_hash (&cai, hash, INSERT); if (*e) /* We have found the type: we're done. */ return (tree) *e; @@ -1641,14 +1643,6 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt) /* Hashing of lists so that we don't make duplicates. The entry point is `list_hash_canon'. */ -/* Now here is the hash table. When recording a list, it is added - to the slot whose index is the hash code mod the table size. - Note that the hash table is used for several kinds of lists. - While all these live in the same table, they are completely independent, - and the hash code is computed differently for each of these. */ - -static GTY ((param_is (union tree_node))) htab_t list_hash_table; - struct list_proxy { tree purpose; @@ -1656,15 +1650,28 @@ struct list_proxy tree chain; }; +struct list_hasher : ggc_hasher<tree> +{ + typedef list_proxy *compare_type; + + static hashval_t hash (tree); + static bool equal (tree, list_proxy *); +}; + +/* Now here is the hash table. When recording a list, it is added + to the slot whose index is the hash code mod the table size. + Note that the hash table is used for several kinds of lists. + While all these live in the same table, they are completely independent, + and the hash code is computed differently for each of these. */ + +static GTY (()) hash_table<list_hasher> *list_hash_table; + /* Compare ENTRY (an entry in the hash table) with DATA (a list_proxy for a node we are thinking about adding). */ -static int -list_hash_eq (const void* entry, const void* data) +bool +list_hasher::equal (tree t, list_proxy *proxy) { - const_tree const t = (const_tree) entry; - const struct list_proxy *const proxy = (const struct list_proxy *) data; - return (TREE_VALUE (t) == proxy->value && TREE_PURPOSE (t) == proxy->purpose && TREE_CHAIN (t) == proxy->chain); @@ -1695,10 +1702,9 @@ list_hash_pieces (tree purpose, tree value, tree chain) /* Hash an already existing TREE_LIST. */ -static hashval_t -list_hash (const void* p) +hashval_t +list_hasher::hash (tree t) { - const_tree const t = (const_tree) p; return list_hash_pieces (TREE_PURPOSE (t), TREE_VALUE (t), TREE_CHAIN (t)); @@ -1712,7 +1718,7 @@ tree hash_tree_cons (tree purpose, tree value, tree chain) { int hashcode = 0; - void **slot; + tree *slot; struct list_proxy proxy; /* Hash the list node. */ @@ -1723,8 +1729,7 @@ hash_tree_cons (tree purpose, tree value, tree chain) proxy.value = value; proxy.chain = chain; /* See if it is already in the table. */ - slot = htab_find_slot_with_hash (list_hash_table, &proxy, hashcode, - INSERT); + slot = list_hash_table->find_slot_with_hash (&proxy, hashcode, INSERT); /* If not, create a new node. */ if (!*slot) *slot = tree_cons (purpose, value, chain); @@ -3670,7 +3675,7 @@ cp_save_expr (tree expr) void init_tree (void) { - list_hash_table = htab_create_ggc (31, list_hash, list_hash_eq, NULL); + list_hash_table = hash_table<list_hasher>::create_ggc (61); } /* Returns the kind of special function that DECL (a FUNCTION_DECL) |