summaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorTrevor Saunders <tsaunders@mozilla.com>2014-10-12 22:22:53 +0000
committerTrevor Saunders <tbsaunde@gcc.gnu.org>2014-10-12 22:22:53 +0000
commit2a22f99cb12d82712dd93cfef808b1cef543601b (patch)
treec828063f153ceb609ce5c7d44ea9f00391b32950 /gcc/c-family
parent7b262a51ea2310bdb6cc901de00f04b0e7be0a4e (diff)
downloadgcc-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/c-family')
-rw-r--r--gcc/c-family/ChangeLog4
-rw-r--r--gcc/c-family/c-common.c28
2 files changed, 22 insertions, 10 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index e5ca891b899..e579619245e 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,7 @@
+2014-10-12 Trevor Saunders <tsaunders@mozilla.com>
+
+ * c-common.c: Use hash_table instead of hashtab.
+
2014-10-06 Edward Smith-Rowland <3dw4rd@verizon.net>
* c-family/c-cppbuiltin.c: Move __cpp_attribute_deprecated to the
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index e69d128a2cd..23163f51d67 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -4803,23 +4803,28 @@ c_apply_type_quals_to_decl (int type_quals, tree decl)
}
}
+struct c_type_hasher : ggc_hasher<tree>
+{
+ static hashval_t hash (tree);
+ static bool equal (tree, tree);
+};
+
/* Hash function for the problem of multiple type definitions in
different files. This must hash all types that will compare
equal via comptypes to the same value. In practice it hashes
on some of the simple stuff and leaves the details to comptypes. */
-static hashval_t
-c_type_hash (const void *p)
+hashval_t
+c_type_hasher::hash (tree t)
{
int n_elements;
int shift, size;
- const_tree const t = (const_tree) p;
tree t2;
switch (TREE_CODE (t))
{
/* For pointers, hash on pointee type plus some swizzling. */
case POINTER_TYPE:
- return c_type_hash (TREE_TYPE (t)) ^ 0x3003003;
+ return hash (TREE_TYPE (t)) ^ 0x3003003;
/* Hash on number of elements and total size. */
case ENUMERAL_TYPE:
shift = 3;
@@ -4851,7 +4856,13 @@ c_type_hash (const void *p)
return ((size << 24) | (n_elements << shift));
}
-static GTY((param_is (union tree_node))) htab_t type_hash_table;
+bool
+c_type_hasher::equal (tree t1, tree t2)
+{
+ return lang_hooks.types_compatible_p (t1, t2);
+}
+
+static GTY(()) hash_table<c_type_hasher> *type_hash_table;
/* Return the typed-based alias set for T, which may be an expression
or a type. Return -1 if we don't do anything special. */
@@ -4860,7 +4871,6 @@ alias_set_type
c_common_get_alias_set (tree t)
{
tree u;
- PTR *slot;
/* For VLAs, use the alias set of the element type rather than the
default of alias set 0 for types compared structurally. */
@@ -4953,10 +4963,8 @@ c_common_get_alias_set (tree t)
/* Look up t in hash table. Only one of the compatible types within each
alias set is recorded in the table. */
if (!type_hash_table)
- type_hash_table = htab_create_ggc (1021, c_type_hash,
- (htab_eq) lang_hooks.types_compatible_p,
- NULL);
- slot = htab_find_slot (type_hash_table, t, INSERT);
+ type_hash_table = hash_table<c_type_hasher>::create_ggc (1021);
+ tree *slot = type_hash_table->find_slot (t, INSERT);
if (*slot != NULL)
{
TYPE_ALIAS_SET (t) = TYPE_ALIAS_SET ((tree)*slot);