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/config/mep/mep.c | |
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/config/mep/mep.c')
-rw-r--r-- | gcc/config/mep/mep.c | 77 |
1 files changed, 30 insertions, 47 deletions
diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c index 1c0e80b..03ecc96 100644 --- a/gcc/config/mep/mep.c +++ b/gcc/config/mep/mep.c @@ -4061,69 +4061,53 @@ mep_can_inline_p (tree caller, tree callee) struct GTY(()) pragma_entry { int used; int flag; - const char *funcname; }; -typedef struct pragma_entry pragma_entry; -/* Hash table of farcall-tagged sections. */ -static GTY((param_is (pragma_entry))) htab_t pragma_htab; - -static int -pragma_entry_eq (const void *p1, const void *p2) +struct pragma_traits : default_hashmap_traits { - const pragma_entry *old = (const pragma_entry *) p1; - const char *new_name = (const char *) p2; - - return strcmp (old->funcname, new_name) == 0; -} + static hashval_t hash (const char *s) { return htab_hash_string (s); } + static bool + equal_keys (const char *a, const char *b) + { + return strcmp (a, b) == 0; + } +}; -static hashval_t -pragma_entry_hash (const void *p) -{ - const pragma_entry *old = (const pragma_entry *) p; - return htab_hash_string (old->funcname); -} +/* Hash table of farcall-tagged sections. */ +static GTY(()) hash_map<const char *, pragma_entry, pragma_traits> * + pragma_htab; static void mep_note_pragma_flag (const char *funcname, int flag) { - pragma_entry **slot; - if (!pragma_htab) - pragma_htab = htab_create_ggc (31, pragma_entry_hash, - pragma_entry_eq, NULL); - - slot = (pragma_entry **) - htab_find_slot_with_hash (pragma_htab, funcname, - htab_hash_string (funcname), INSERT); + pragma_htab + = hash_map<const char *, pragma_entry, pragma_traits>::create_ggc (31); - if (!*slot) + bool existed; + const char *name = ggc_strdup (funcname); + pragma_entry *slot = &pragma_htab->get_or_insert (name, &existed); + if (!existed) { - *slot = ggc_alloc<pragma_entry> (); - (*slot)->flag = 0; - (*slot)->used = 0; - (*slot)->funcname = ggc_strdup (funcname); + slot->flag = 0; + slot->used = 0; } - (*slot)->flag |= flag; + slot->flag |= flag; } static bool mep_lookup_pragma_flag (const char *funcname, int flag) { - pragma_entry **slot; - if (!pragma_htab) return false; if (funcname[0] == '@' && funcname[2] == '.') funcname += 3; - slot = (pragma_entry **) - htab_find_slot_with_hash (pragma_htab, funcname, - htab_hash_string (funcname), NO_INSERT); - if (slot && *slot && ((*slot)->flag & flag)) + pragma_entry *slot = pragma_htab->get (funcname); + if (slot && (slot->flag & flag)) { - (*slot)->used |= flag; + slot->used |= flag; return true; } return false; @@ -4153,14 +4137,13 @@ mep_note_pragma_disinterrupt (const char *funcname) mep_note_pragma_flag (funcname, FUNC_DISINTERRUPT); } -static int -note_unused_pragma_disinterrupt (void **slot, void *data ATTRIBUTE_UNUSED) +bool +note_unused_pragma_disinterrupt (const char *const &s, const pragma_entry &e, + void *) { - const pragma_entry *d = (const pragma_entry *)(*slot); - - if ((d->flag & FUNC_DISINTERRUPT) - && !(d->used & FUNC_DISINTERRUPT)) - warning (0, "\"#pragma disinterrupt %s\" not used", d->funcname); + if ((e.flag & FUNC_DISINTERRUPT) + && !(e.used & FUNC_DISINTERRUPT)) + warning (0, "\"#pragma disinterrupt %s\" not used", s); return 1; } @@ -4168,7 +4151,7 @@ void mep_file_cleanups (void) { if (pragma_htab) - htab_traverse (pragma_htab, note_unused_pragma_disinterrupt, NULL); + pragma_htab->traverse<void *, note_unused_pragma_disinterrupt> (NULL); } /* These three functions provide a bridge between the pramgas that |