On Tue, Jul 8, 2014 at 5:01 AM, <tsaund...@mozilla.com> wrote: > From: Trevor Saunders <tsaund...@mozilla.com> > > Hi, > > just $subject > bootstrapped + regtested on x86_64-unknown-linux-gnu, ok?
Ok. Thanks, Richard. > Trev > > gcc/ > > * graphite-htab.h: Use hash_map instead of hash_table. > * graphite-clast-to-gimple.c: Adjust. > * passes.c: Use hash_map instead of hash_table. > * sese.c: Likewise. > * sese.h: Remove now unused code. > > diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c > index 71507a0..296b893 100644 > --- a/gcc/graphite-clast-to-gimple.c > +++ b/gcc/graphite-clast-to-gimple.c > @@ -1012,34 +1012,16 @@ build_iv_mapping (vec<tree> iv_map, struct > clast_user_stmt *user_stmt, > mpz_clear (bound_two); > } > > -/* Construct bb_pbb_def with BB and PBB. */ > - > -static bb_pbb_def * > -new_bb_pbb_def (basic_block bb, poly_bb_p pbb) > -{ > - bb_pbb_def *bb_pbb_p; > - > - bb_pbb_p = XNEW (bb_pbb_def); > - bb_pbb_p->bb = bb; > - bb_pbb_p->pbb = pbb; > - > - return bb_pbb_p; > -} > - > /* Mark BB with it's relevant PBB via hashing table BB_PBB_MAPPING. */ > > static void > mark_bb_with_pbb (poly_bb_p pbb, basic_block bb, > bb_pbb_htab_type *bb_pbb_mapping) > { > - bb_pbb_def tmp; > - bb_pbb_def **x; > - > - tmp.bb = bb; > - x = bb_pbb_mapping->find_slot (&tmp, INSERT); > - > - if (x && !*x) > - *x = new_bb_pbb_def (bb, pbb); > + bool existed; > + poly_bb_p &e = bb_pbb_mapping->get_or_insert (bb, &existed); > + if (!existed) > + e = pbb; > } > > /* Find BB's related poly_bb_p in hash table BB_PBB_MAPPING. */ > @@ -1047,14 +1029,9 @@ mark_bb_with_pbb (poly_bb_p pbb, basic_block bb, > poly_bb_p > find_pbb_via_hash (bb_pbb_htab_type *bb_pbb_mapping, basic_block bb) > { > - bb_pbb_def tmp; > - bb_pbb_def **slot; > - > - tmp.bb = bb; > - slot = bb_pbb_mapping->find_slot (&tmp, NO_INSERT); > - > - if (slot && *slot) > - return ((bb_pbb_def *) *slot)->pbb; > + poly_bb_p *pbb = bb_pbb_mapping->get (bb); > + if (pbb) > + return *pbb; > > return NULL; > } > diff --git a/gcc/graphite-htab.h b/gcc/graphite-htab.h > index 69fd05a..b1fd81e 100644 > --- a/gcc/graphite-htab.h > +++ b/gcc/graphite-htab.h > @@ -21,43 +21,33 @@ along with GCC; see the file COPYING3. If not see > #ifndef GCC_GRAPHITE_HTAB_H > #define GCC_GRAPHITE_HTAB_H > > -#include "hash-table.h" > - > -/* Stores BB's related PBB. */ > - > -struct bb_pbb_def > -{ > - basic_block bb; > - poly_bb_p pbb; > -}; > +#include "hash-map.h" > > /* Hashtable helpers. */ > > -struct bb_pbb_hasher : typed_free_remove <bb_pbb_def> > +struct bb_pbb_hasher : default_hashmap_traits > { > - typedef bb_pbb_def value_type; > - typedef bb_pbb_def compare_type; > - static inline hashval_t hash (const value_type *); > - static inline bool equal (const value_type *, const compare_type *); > + static inline hashval_t hash (const basic_block); > + static inline bool equal_keys (const basic_block, const basic_block); > }; > > -/* Hash function for data base element BB_PBB. */ > +/* Hash function. */ > > inline hashval_t > -bb_pbb_hasher::hash (const value_type *bb_pbb) > +bb_pbb_hasher::hash (const basic_block bb) > { > - return (hashval_t)(bb_pbb->bb->index); > + return (hashval_t)(bb->index); > } > > /* Compare data base element PB1 and PB2. */ > > inline bool > -bb_pbb_hasher::equal (const value_type *bp1, const compare_type *bp2) > +bb_pbb_hasher::equal_keys (const basic_block a, const basic_block b) > { > - return (bp1->bb->index == bp2->bb->index); > + return (a->index == b->index); > } > > -typedef hash_table<bb_pbb_hasher> bb_pbb_htab_type; > +typedef hash_map<basic_block, poly_bb_p, bb_pbb_hasher> bb_pbb_htab_type; > > poly_bb_p find_pbb_via_hash (bb_pbb_htab_type *, basic_block); > bool loop_is_parallel_p (loop_p, bb_pbb_htab_type *, int); > diff --git a/gcc/passes.c b/gcc/passes.c > index 91b644e..0533687 100644 > --- a/gcc/passes.c > +++ b/gcc/passes.c > @@ -84,6 +84,7 @@ along with GCC; see the file COPYING3. If not see > #include "pass_manager.h" > #include "tree-ssa-live.h" /* For remove_unused_locals. */ > #include "tree-cfgcleanup.h" > +#include "hash-map.h" > > using namespace gcc; > > @@ -687,64 +688,47 @@ pass_manager::register_dump_files (opt_pass *pass) > while (pass); > } > > -struct pass_registry > -{ > - const char* unique_name; > - opt_pass *pass; > -}; > - > /* Helper for pass_registry hash table. */ > > -struct pass_registry_hasher : typed_noop_remove <pass_registry> > +struct pass_registry_hasher : default_hashmap_traits > { > - typedef pass_registry value_type; > - typedef pass_registry compare_type; > - static inline hashval_t hash (const value_type *); > - static inline bool equal (const value_type *, const compare_type *); > + static inline hashval_t hash (const char *); > + static inline bool equal_keys (const char *, const char *); > }; > > /* Pass registry hash function. */ > > inline hashval_t > -pass_registry_hasher::hash (const value_type *s) > +pass_registry_hasher::hash (const char *name) > { > - return htab_hash_string (s->unique_name); > + return htab_hash_string (name); > } > > /* Hash equal function */ > > inline bool > -pass_registry_hasher::equal (const value_type *s1, const compare_type *s2) > +pass_registry_hasher::equal_keys (const char *s1, const char *s2) > { > - return !strcmp (s1->unique_name, s2->unique_name); > + return !strcmp (s1, s2); > } > > -static hash_table<pass_registry_hasher> *name_to_pass_map; > +static hash_map<const char *, opt_pass *, pass_registry_hasher> > + *name_to_pass_map; > > /* Register PASS with NAME. */ > > static void > register_pass_name (opt_pass *pass, const char *name) > { > - struct pass_registry **slot; > - struct pass_registry pr; > - > if (!name_to_pass_map) > - name_to_pass_map = new hash_table<pass_registry_hasher> (256); > - > - pr.unique_name = name; > - slot = name_to_pass_map->find_slot (&pr, INSERT); > - if (!*slot) > - { > - struct pass_registry *new_pr; > + name_to_pass_map > + = new hash_map<const char *, opt_pass *, pass_registry_hasher> (256); > > - new_pr = XCNEW (struct pass_registry); > - new_pr->unique_name = xstrdup (name); > - new_pr->pass = pass; > - *slot = new_pr; > - } > - else > + if (name_to_pass_map->get (name)) > return; /* Ignore plugin passes. */ > + > + const char *unique_name = xstrdup (name); > + name_to_pass_map->put (unique_name, pass); > } > > /* Map from pass id to canonicalized pass name. */ > @@ -754,15 +738,13 @@ static vec<char_ptr> pass_tab = vNULL; > > /* Callback function for traversing NAME_TO_PASS_MAP. */ > > -int > -passes_pass_traverse (pass_registry **p, void *data ATTRIBUTE_UNUSED) > +bool > +passes_pass_traverse (const char *const &name, opt_pass *const &pass, void *) > { > - opt_pass *pass = (*p)->pass; > - > gcc_assert (pass->static_pass_number > 0); > gcc_assert (pass_tab.exists ()); > > - pass_tab[pass->static_pass_number] = (*p)->unique_name; > + pass_tab[pass->static_pass_number] = name; > > return 1; > } > @@ -864,15 +846,11 @@ pass_manager::dump_passes () const > static opt_pass * > get_pass_by_name (const char *name) > { > - struct pass_registry **slot, pr; > - > - pr.unique_name = name; > - slot = name_to_pass_map->find_slot (&pr, NO_INSERT); > - > - if (!slot || !*slot) > - return NULL; > + opt_pass **p = name_to_pass_map->get (name); > + if (p) > + return *p; > > - return (*slot)->pass; > + return NULL; > } > > > diff --git a/gcc/sese.c b/gcc/sese.c > index 8191cb9..735248c 100644 > --- a/gcc/sese.c > +++ b/gcc/sese.c > @@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see > #include "config.h" > #include "system.h" > #include "coretypes.h" > -#include "hash-table.h" > +#include "hash-map.h" > #include "tree.h" > #include "tree-pretty-print.h" > #include "basic-block.h" > @@ -53,56 +53,37 @@ along with GCC; see the file COPYING3. If not see > #include "sese.h" > #include "tree-ssa-propagate.h" > > -/* Print to stderr the element ELT. */ > +/* Helper function for debug_rename_map. */ > > -static void > -debug_rename_elt (rename_map_elt elt) > +bool > +debug_rename_map_1 (tree_node *const &old_name, tree_node *const &expr, > + void *) > { > fprintf (stderr, "("); > - print_generic_expr (stderr, elt->old_name, 0); > + print_generic_expr (stderr, old_name, 0); > fprintf (stderr, ", "); > - print_generic_expr (stderr, elt->expr, 0); > + print_generic_expr (stderr, expr, 0); > fprintf (stderr, ")\n"); > -} > - > -/* Helper function for debug_rename_map. */ > - > -int > -debug_rename_map_1 (rename_map_elt_s **slot, void *s ATTRIBUTE_UNUSED) > -{ > - struct rename_map_elt_s *entry = *slot; > - debug_rename_elt (entry); > - return 1; > + return true; > } > > > /* Hashtable helpers. */ > > -struct rename_map_hasher : typed_free_remove <rename_map_elt_s> > +struct rename_map_hasher : default_hashmap_traits > { > - typedef rename_map_elt_s value_type; > - typedef rename_map_elt_s compare_type; > - static inline hashval_t hash (const value_type *); > - static inline bool equal (const value_type *, const compare_type *); > + static inline hashval_t hash (tree); > }; > > /* Computes a hash function for database element ELT. */ > > inline hashval_t > -rename_map_hasher::hash (const value_type *elt) > +rename_map_hasher::hash (tree old_name) > { > - return SSA_NAME_VERSION (elt->old_name); > + return SSA_NAME_VERSION (old_name); > } > > -/* Compares database elements E1 and E2. */ > - > -inline bool > -rename_map_hasher::equal (const value_type *elt1, const compare_type *elt2) > -{ > - return (elt1->old_name == elt2->old_name); > -} > - > -typedef hash_table<rename_map_hasher> rename_map_type; > +typedef hash_map<tree, tree, rename_map_hasher> rename_map_type; > > > /* Print to stderr all the elements of RENAME_MAP. */ > @@ -112,26 +93,6 @@ debug_rename_map (rename_map_type *rename_map) > { > rename_map->traverse <void *, debug_rename_map_1> (NULL); > } > - > -/* Computes a hash function for database element ELT. */ > - > -hashval_t > -rename_map_elt_info (const void *elt) > -{ > - return SSA_NAME_VERSION (((const struct rename_map_elt_s *) > elt)->old_name); > -} > - > -/* Compares database elements E1 and E2. */ > - > -int > -eq_rename_map_elts (const void *e1, const void *e2) > -{ > - const struct rename_map_elt_s *elt1 = (const struct rename_map_elt_s *) e1; > - const struct rename_map_elt_s *elt2 = (const struct rename_map_elt_s *) e2; > - > - return (elt1->old_name == elt2->old_name); > -} > - > > > /* Record LOOP as occurring in REGION. */ > @@ -418,15 +379,10 @@ get_false_edge_from_guard_bb (basic_block bb) > static tree > get_rename (rename_map_type *rename_map, tree old_name) > { > - struct rename_map_elt_s tmp; > - rename_map_elt_s **slot; > - > gcc_assert (TREE_CODE (old_name) == SSA_NAME); > - tmp.old_name = old_name; > - slot = rename_map->find_slot (&tmp, NO_INSERT); > - > - if (slot && *slot) > - return (*slot)->expr; > + tree *expr = rename_map->get (old_name); > + if (expr) > + return *expr; > > return NULL_TREE; > } > @@ -436,21 +392,10 @@ get_rename (rename_map_type *rename_map, tree old_name) > static void > set_rename (rename_map_type *rename_map, tree old_name, tree expr) > { > - struct rename_map_elt_s tmp; > - rename_map_elt_s **slot; > - > if (old_name == expr) > return; > > - tmp.old_name = old_name; > - slot = rename_map->find_slot (&tmp, INSERT); > - > - if (!slot) > - return; > - > - free (*slot); > - > - *slot = new_rename_map_elt (old_name, expr); > + rename_map->put (old_name, expr); > } > > /* Renames the scalar uses of the statement COPY, using the > diff --git a/gcc/sese.h b/gcc/sese.h > index af919f8..e2a6d45 100644 > --- a/gcc/sese.h > +++ b/gcc/sese.h > @@ -249,31 +249,6 @@ if_region_get_condition_block (ifsese if_region) > return if_region_entry (if_region)->dest; > } > > -/* Structure containing the mapping between the old names and the new > - names used after block copy in the new loop context. */ > -typedef struct rename_map_elt_s > -{ > - tree old_name, expr; > -} *rename_map_elt; > - > - > -extern hashval_t rename_map_elt_info (const void *); > -extern int eq_rename_map_elts (const void *, const void *); > - > -/* Constructs a new SCEV_INFO_STR structure for VAR and INSTANTIATED_BELOW. > */ > - > -static inline rename_map_elt > -new_rename_map_elt (tree old_name, tree expr) > -{ > - rename_map_elt res; > - > - res = XNEW (struct rename_map_elt_s); > - res->old_name = old_name; > - res->expr = expr; > - > - return res; > -} > - > /* Free and compute again all the dominators information. */ > > static inline void > -- > 2.0.1 >