From 2a22f99cb12d82712dd93cfef808b1cef543601b Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Sun, 12 Oct 2014 22:22:53 +0000 Subject: 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 --- gcc/config/m32c/m32c.c | 59 +++++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 42 deletions(-) (limited to 'gcc/config/m32c') diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c index 71723c8..fc89821 100644 --- a/gcc/config/m32c/m32c.c +++ b/gcc/config/m32c/m32c.c @@ -3035,66 +3035,41 @@ m32c_insert_attributes (tree node ATTRIBUTE_UNUSED, } -struct GTY(()) pragma_entry { - const char *varname; - unsigned address; +struct pragma_traits : default_hashmap_traits +{ + static hashval_t hash (const char *str) { return htab_hash_string (str); } + static bool + equal_keys (const char *a, const char *b) + { + return !strcmp (a, b); + } }; -typedef struct pragma_entry pragma_entry; /* Hash table of pragma info. */ -static GTY((param_is (pragma_entry))) htab_t pragma_htab; - -static int -pragma_entry_eq (const void *p1, const void *p2) -{ - const pragma_entry *old = (const pragma_entry *) p1; - const char *new_name = (const char *) p2; - - return strcmp (old->varname, new_name) == 0; -} - -static hashval_t -pragma_entry_hash (const void *p) -{ - const pragma_entry *old = (const pragma_entry *) p; - return htab_hash_string (old->varname); -} +static GTY(()) hash_map *pragma_htab; void m32c_note_pragma_address (const char *varname, unsigned address) { - pragma_entry **slot; - if (!pragma_htab) - pragma_htab = htab_create_ggc (31, pragma_entry_hash, - pragma_entry_eq, NULL); + pragma_htab + = hash_map::create_ggc (31); - slot = (pragma_entry **) - htab_find_slot_with_hash (pragma_htab, varname, - htab_hash_string (varname), INSERT); - - if (!*slot) - { - *slot = ggc_alloc (); - (*slot)->varname = ggc_strdup (varname); - } - (*slot)->address = address; + const char *name = ggc_strdup (varname); + unsigned int *slot = &pragma_htab->get_or_insert (name); + *slot = address; } static bool m32c_get_pragma_address (const char *varname, unsigned *address) { - pragma_entry **slot; - if (!pragma_htab) return false; - slot = (pragma_entry **) - htab_find_slot_with_hash (pragma_htab, varname, - htab_hash_string (varname), NO_INSERT); - if (slot && *slot) + unsigned int *slot = pragma_htab->get (varname); + if (slot) { - *address = (*slot)->address; + *address = *slot; return true; } return false; -- cgit v1.1