Commit f98df77c by Trevor Saunders Committed by Trevor Saunders

convert some hash_table to hash_map

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.

From-SVN: r212382
parent 677f36a6
2014-07-08 Trevor Saunders <tsaunders@mozilla.com>
* 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.
2014-07-08 Sriraman Tallam <tmsriram@google.com> 2014-07-08 Sriraman Tallam <tmsriram@google.com>
PR target/61599 PR target/61599
......
...@@ -1012,34 +1012,16 @@ build_iv_mapping (vec<tree> iv_map, struct clast_user_stmt *user_stmt, ...@@ -1012,34 +1012,16 @@ build_iv_mapping (vec<tree> iv_map, struct clast_user_stmt *user_stmt,
mpz_clear (bound_two); 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. */ /* Mark BB with it's relevant PBB via hashing table BB_PBB_MAPPING. */
static void static void
mark_bb_with_pbb (poly_bb_p pbb, basic_block bb, mark_bb_with_pbb (poly_bb_p pbb, basic_block bb,
bb_pbb_htab_type *bb_pbb_mapping) bb_pbb_htab_type *bb_pbb_mapping)
{ {
bb_pbb_def tmp; bool existed;
bb_pbb_def **x; poly_bb_p &e = bb_pbb_mapping->get_or_insert (bb, &existed);
if (!existed)
tmp.bb = bb; e = pbb;
x = bb_pbb_mapping->find_slot (&tmp, INSERT);
if (x && !*x)
*x = new_bb_pbb_def (bb, pbb);
} }
/* Find BB's related poly_bb_p in hash table BB_PBB_MAPPING. */ /* 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, ...@@ -1047,14 +1029,9 @@ mark_bb_with_pbb (poly_bb_p pbb, basic_block bb,
poly_bb_p poly_bb_p
find_pbb_via_hash (bb_pbb_htab_type *bb_pbb_mapping, basic_block bb) find_pbb_via_hash (bb_pbb_htab_type *bb_pbb_mapping, basic_block bb)
{ {
bb_pbb_def tmp; poly_bb_p *pbb = bb_pbb_mapping->get (bb);
bb_pbb_def **slot; if (pbb)
return *pbb;
tmp.bb = bb;
slot = bb_pbb_mapping->find_slot (&tmp, NO_INSERT);
if (slot && *slot)
return ((bb_pbb_def *) *slot)->pbb;
return NULL; return NULL;
} }
......
...@@ -21,43 +21,33 @@ along with GCC; see the file COPYING3. If not see ...@@ -21,43 +21,33 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_GRAPHITE_HTAB_H #ifndef GCC_GRAPHITE_HTAB_H
#define GCC_GRAPHITE_HTAB_H #define GCC_GRAPHITE_HTAB_H
#include "hash-table.h" #include "hash-map.h"
/* Stores BB's related PBB. */
struct bb_pbb_def
{
basic_block bb;
poly_bb_p pbb;
};
/* Hashtable helpers. */ /* 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; static inline hashval_t hash (const basic_block);
typedef bb_pbb_def compare_type; static inline bool equal_keys (const basic_block, const basic_block);
static inline hashval_t hash (const value_type *);
static inline bool equal (const value_type *, const compare_type *);
}; };
/* Hash function for data base element BB_PBB. */ /* Hash function. */
inline hashval_t 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. */ /* Compare data base element PB1 and PB2. */
inline bool 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); 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); bool loop_is_parallel_p (loop_p, bb_pbb_htab_type *, int);
......
...@@ -84,6 +84,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -84,6 +84,7 @@ along with GCC; see the file COPYING3. If not see
#include "pass_manager.h" #include "pass_manager.h"
#include "tree-ssa-live.h" /* For remove_unused_locals. */ #include "tree-ssa-live.h" /* For remove_unused_locals. */
#include "tree-cfgcleanup.h" #include "tree-cfgcleanup.h"
#include "hash-map.h"
using namespace gcc; using namespace gcc;
...@@ -687,64 +688,47 @@ pass_manager::register_dump_files (opt_pass *pass) ...@@ -687,64 +688,47 @@ pass_manager::register_dump_files (opt_pass *pass)
while (pass); while (pass);
} }
struct pass_registry
{
const char* unique_name;
opt_pass *pass;
};
/* Helper for pass_registry hash table. */ /* 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; static inline hashval_t hash (const char *);
typedef pass_registry compare_type; static inline bool equal_keys (const char *, const char *);
static inline hashval_t hash (const value_type *);
static inline bool equal (const value_type *, const compare_type *);
}; };
/* Pass registry hash function. */ /* Pass registry hash function. */
inline hashval_t 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 */ /* Hash equal function */
inline bool 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. */ /* Register PASS with NAME. */
static void static void
register_pass_name (opt_pass *pass, const char *name) register_pass_name (opt_pass *pass, const char *name)
{ {
struct pass_registry **slot;
struct pass_registry pr;
if (!name_to_pass_map) if (!name_to_pass_map)
name_to_pass_map = new hash_table<pass_registry_hasher> (256); name_to_pass_map
= new hash_map<const char *, opt_pass *, pass_registry_hasher> (256);
pr.unique_name = name;
slot = name_to_pass_map->find_slot (&pr, INSERT);
if (!*slot)
{
struct pass_registry *new_pr;
new_pr = XCNEW (struct pass_registry); if (name_to_pass_map->get (name))
new_pr->unique_name = xstrdup (name);
new_pr->pass = pass;
*slot = new_pr;
}
else
return; /* Ignore plugin passes. */ 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. */ /* Map from pass id to canonicalized pass name. */
...@@ -754,15 +738,13 @@ static vec<char_ptr> pass_tab = vNULL; ...@@ -754,15 +738,13 @@ static vec<char_ptr> pass_tab = vNULL;
/* Callback function for traversing NAME_TO_PASS_MAP. */ /* Callback function for traversing NAME_TO_PASS_MAP. */
int bool
passes_pass_traverse (pass_registry **p, void *data ATTRIBUTE_UNUSED) 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->static_pass_number > 0);
gcc_assert (pass_tab.exists ()); gcc_assert (pass_tab.exists ());
pass_tab[pass->static_pass_number] = (*p)->unique_name; pass_tab[pass->static_pass_number] = name;
return 1; return 1;
} }
...@@ -864,15 +846,11 @@ pass_manager::dump_passes () const ...@@ -864,15 +846,11 @@ pass_manager::dump_passes () const
static opt_pass * static opt_pass *
get_pass_by_name (const char *name) get_pass_by_name (const char *name)
{ {
struct pass_registry **slot, pr; opt_pass **p = name_to_pass_map->get (name);
if (p)
pr.unique_name = name; return *p;
slot = name_to_pass_map->find_slot (&pr, NO_INSERT);
if (!slot || !*slot)
return NULL;
return (*slot)->pass; return NULL;
} }
......
...@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h" #include "config.h"
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "hash-table.h" #include "hash-map.h"
#include "tree.h" #include "tree.h"
#include "tree-pretty-print.h" #include "tree-pretty-print.h"
#include "basic-block.h" #include "basic-block.h"
...@@ -53,56 +53,37 @@ along with GCC; see the file COPYING3. If not see ...@@ -53,56 +53,37 @@ along with GCC; see the file COPYING3. If not see
#include "sese.h" #include "sese.h"
#include "tree-ssa-propagate.h" #include "tree-ssa-propagate.h"
/* Print to stderr the element ELT. */ /* Helper function for debug_rename_map. */
static void bool
debug_rename_elt (rename_map_elt elt) debug_rename_map_1 (tree_node *const &old_name, tree_node *const &expr,
void *)
{ {
fprintf (stderr, "("); fprintf (stderr, "(");
print_generic_expr (stderr, elt->old_name, 0); print_generic_expr (stderr, old_name, 0);
fprintf (stderr, ", "); fprintf (stderr, ", ");
print_generic_expr (stderr, elt->expr, 0); print_generic_expr (stderr, expr, 0);
fprintf (stderr, ")\n"); fprintf (stderr, ")\n");
} return true;
/* 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;
} }
/* Hashtable helpers. */ /* 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; static inline hashval_t hash (tree);
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 *);
}; };
/* Computes a hash function for database element ELT. */ /* Computes a hash function for database element ELT. */
inline hashval_t 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. */ typedef hash_map<tree, tree, rename_map_hasher> rename_map_type;
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;
/* Print to stderr all the elements of RENAME_MAP. */ /* Print to stderr all the elements of RENAME_MAP. */
...@@ -112,26 +93,6 @@ debug_rename_map (rename_map_type *rename_map) ...@@ -112,26 +93,6 @@ debug_rename_map (rename_map_type *rename_map)
{ {
rename_map->traverse <void *, debug_rename_map_1> (NULL); 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. */ /* Record LOOP as occurring in REGION. */
...@@ -418,15 +379,10 @@ get_false_edge_from_guard_bb (basic_block bb) ...@@ -418,15 +379,10 @@ get_false_edge_from_guard_bb (basic_block bb)
static tree static tree
get_rename (rename_map_type *rename_map, tree old_name) 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); gcc_assert (TREE_CODE (old_name) == SSA_NAME);
tmp.old_name = old_name; tree *expr = rename_map->get (old_name);
slot = rename_map->find_slot (&tmp, NO_INSERT); if (expr)
return *expr;
if (slot && *slot)
return (*slot)->expr;
return NULL_TREE; return NULL_TREE;
} }
...@@ -436,21 +392,10 @@ get_rename (rename_map_type *rename_map, tree old_name) ...@@ -436,21 +392,10 @@ get_rename (rename_map_type *rename_map, tree old_name)
static void static void
set_rename (rename_map_type *rename_map, tree old_name, tree expr) 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) if (old_name == expr)
return; return;
tmp.old_name = old_name; rename_map->put (old_name, expr);
slot = rename_map->find_slot (&tmp, INSERT);
if (!slot)
return;
free (*slot);
*slot = new_rename_map_elt (old_name, expr);
} }
/* Renames the scalar uses of the statement COPY, using the /* Renames the scalar uses of the statement COPY, using the
......
...@@ -249,31 +249,6 @@ if_region_get_condition_block (ifsese if_region) ...@@ -249,31 +249,6 @@ if_region_get_condition_block (ifsese if_region)
return if_region_entry (if_region)->dest; 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. */ /* Free and compute again all the dominators information. */
static inline void static inline void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment