aboutsummaryrefslogtreecommitdiff
path: root/gcc/symtab.c
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/symtab.c
parent7b262a51ea2310bdb6cc901de00f04b0e7be0a4e (diff)
downloadgcc-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/symtab.c')
-rw-r--r--gcc/symtab.c80
1 files changed, 28 insertions, 52 deletions
diff --git a/gcc/symtab.c b/gcc/symtab.c
index f23bd83..d99546f 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -83,15 +83,6 @@ symbol_table::decl_assembler_name_hash (const_tree asmname)
}
-/* Returns a hash code for P. */
-
-hashval_t
-symbol_table::hash_node_by_assembler_name (const void *p)
-{
- const symtab_node *n = (const symtab_node *) p;
- return (hashval_t) decl_assembler_name_hash (DECL_ASSEMBLER_NAME (n->decl));
-}
-
/* Compare ASMNAME with the DECL_ASSEMBLER_NAME of DECL. */
bool
@@ -150,14 +141,6 @@ symbol_table::decl_assembler_name_equal (tree decl, const_tree asmname)
/* Returns nonzero if P1 and P2 are equal. */
-int
-symbol_table::eq_assembler_name (const void *p1, const void *p2)
-{
- const symtab_node *n1 = (const symtab_node *) p1;
- const_tree name = (const_tree)p2;
- return (decl_assembler_name_equal (n1->decl, name));
-}
-
/* Insert NODE to assembler name hash. */
void
@@ -170,19 +153,18 @@ symbol_table::insert_to_assembler_name_hash (symtab_node *node,
&& !node->next_sharing_asm_name);
if (assembler_name_hash)
{
- void **aslot;
+ symtab_node **aslot;
cgraph_node *cnode;
tree decl = node->decl;
tree name = DECL_ASSEMBLER_NAME (node->decl);
- aslot = htab_find_slot_with_hash (assembler_name_hash, name,
- decl_assembler_name_hash (name),
- INSERT);
+ hashval_t hash = decl_assembler_name_hash (name);
+ aslot = assembler_name_hash->find_slot_with_hash (name, hash, INSERT);
gcc_assert (*aslot != node);
node->next_sharing_asm_name = (symtab_node *)*aslot;
if (*aslot != NULL)
- ((symtab_node *)*aslot)->previous_sharing_asm_name = node;
+ (*aslot)->previous_sharing_asm_name = node;
*aslot = node;
/* Update also possible inline clones sharing a decl. */
@@ -217,13 +199,13 @@ symbol_table::unlink_from_assembler_name_hash (symtab_node *node,
else
{
tree name = DECL_ASSEMBLER_NAME (node->decl);
- void **slot;
- slot = htab_find_slot_with_hash (assembler_name_hash, name,
- decl_assembler_name_hash (name),
- NO_INSERT);
+ symtab_node **slot;
+ hashval_t hash = decl_assembler_name_hash (name);
+ slot = assembler_name_hash->find_slot_with_hash (name, hash,
+ NO_INSERT);
gcc_assert (*slot == node);
if (!node->next_sharing_asm_name)
- htab_clear_slot (assembler_name_hash, slot);
+ assembler_name_hash->clear_slot (slot);
else
*slot = node->next_sharing_asm_name;
}
@@ -256,9 +238,7 @@ symbol_table::symtab_initialize_asm_name_hash (void)
symtab_node *node;
if (!assembler_name_hash)
{
- assembler_name_hash =
- htab_create_ggc (10, hash_node_by_assembler_name, eq_assembler_name,
- NULL);
+ assembler_name_hash = hash_table<asmname_hasher>::create_ggc (10);
FOR_EACH_SYMBOL (node)
insert_to_assembler_name_hash (node, false);
}
@@ -322,20 +302,17 @@ resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution)
/* Hash sections by their names. */
-static hashval_t
-hash_section_hash_entry (const void *p)
+hashval_t
+section_name_hasher::hash (section_hash_entry *n)
{
- const section_hash_entry *n = (const section_hash_entry *) p;
return htab_hash_string (n->name);
}
/* Return true if section P1 name equals to P2. */
-static int
-eq_sections (const void *p1, const void *p2)
+bool
+section_name_hasher::equal (section_hash_entry *n1, const char *name)
{
- const section_hash_entry *n1 = (const section_hash_entry *) p1;
- const char *name = (const char *)p2;
return n1->name == name || !strcmp (n1->name, name);
}
@@ -936,16 +913,16 @@ symtab_node *
symtab_node::get_for_asmname (const_tree asmname)
{
symtab_node *node;
- void **slot;
symtab->symtab_initialize_asm_name_hash ();
- slot = htab_find_slot_with_hash (symtab->assembler_name_hash, asmname,
- symtab->decl_assembler_name_hash (asmname),
- NO_INSERT);
+ hashval_t hash = symtab->decl_assembler_name_hash (asmname);
+ symtab_node **slot
+ = symtab->assembler_name_hash->find_slot_with_hash (asmname, hash,
+ NO_INSERT);
if (slot)
{
- node = (symtab_node *) *slot;
+ node = *slot;
return node;
}
return NULL;
@@ -1382,7 +1359,7 @@ void
symtab_node::set_section_for_node (const char *section)
{
const char *current = get_section ();
- void **slot;
+ section_hash_entry **slot;
if (current == section
|| (current && section
@@ -1394,11 +1371,11 @@ symtab_node::set_section_for_node (const char *section)
x_section->ref_count--;
if (!x_section->ref_count)
{
- slot = htab_find_slot_with_hash (symtab->section_hash, x_section->name,
- htab_hash_string (x_section->name),
- INSERT);
+ hashval_t hash = htab_hash_string (x_section->name);
+ slot = symtab->section_hash->find_slot_with_hash (x_section->name,
+ hash, INSERT);
ggc_free (x_section);
- htab_clear_slot (symtab->section_hash, slot);
+ symtab->section_hash->clear_slot (slot);
}
x_section = NULL;
}
@@ -1408,11 +1385,10 @@ symtab_node::set_section_for_node (const char *section)
return;
}
if (!symtab->section_hash)
- symtab->section_hash = htab_create_ggc (10, hash_section_hash_entry,
- eq_sections, NULL);
- slot = htab_find_slot_with_hash (symtab->section_hash, section,
- htab_hash_string (section),
- INSERT);
+ symtab->section_hash = hash_table<section_name_hasher>::create_ggc (10);
+ slot = symtab->section_hash->find_slot_with_hash (section,
+ htab_hash_string (section),
+ INSERT);
if (*slot)
x_section = (section_hash_entry *)*slot;
else