aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/cilk.c
diff options
context:
space:
mode:
authorTrevor Saunders <tsaunders@mozilla.com>2014-08-02 11:34:54 +0000
committerTrevor Saunders <tbsaunde@gcc.gnu.org>2014-08-02 11:34:54 +0000
commitb787e7a2c2c9be2f548d4c76ec324b71859851a4 (patch)
treeb20f9df1d7e2cb3a642d2fab604f827c7d23712a /gcc/c-family/cilk.c
parent6e2830c3dbe0d4972519ddd44bd1b15b2b274ba2 (diff)
downloadgcc-b787e7a2c2c9be2f548d4c76ec324b71859851a4.zip
gcc-b787e7a2c2c9be2f548d4c76ec324b71859851a4.tar.gz
gcc-b787e7a2c2c9be2f548d4c76ec324b71859851a4.tar.bz2
convert many uses of pointer_map to hash_map
gcc/c-family/ * cilk.c: Use hash_map instead of pointer_map. gcc/c/ * c-typeck.c: Use hash_map instead of pointer_map. gcc/cp/ * optimize.c, semantics.c: Use hash_map instead of pointer_map. gcc/ * hash-map.h (default_hashmap_traits::mark_key_deleted): Fix cast. (hash_map::remove): New method. (hash_map::traverse): New method. * cgraph.h, except.c, except.h, gimple-ssa-strength-reduction.c, ipa-utils.c, lto-cgraph.c, lto-streamer.h, omp-low.c, predict.c, tree-cfg.c, tree-cfgcleanup.c, tree-eh.c, tree-eh.h, tree-inline.c, tree-inline.h, tree-nested.c, tree-sra.c, tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c, tree-ssa-reassoc.c, tree-ssa-structalias.c, tree-ssa.c, tree-ssa.h, var-tracking.c: Use hash_map instead of pointer_map. From-SVN: r213517
Diffstat (limited to 'gcc/c-family/cilk.c')
-rw-r--r--gcc/c-family/cilk.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
index b864bb1..e0d1141 100644
--- a/gcc/c-family/cilk.c
+++ b/gcc/c-family/cilk.c
@@ -64,7 +64,7 @@ struct wrapper_data
/* Containing function. */
tree context;
/* Disposition of all variables in the inner statement. */
- struct pointer_map_t *decl_map;
+ hash_map<tree, tree> *decl_map;
/* True if this function needs a static chain. */
bool nested;
/* Arguments to be passed to wrapper function, currently a list. */
@@ -335,12 +335,11 @@ create_cilk_helper_decl (struct wrapper_data *wd)
/* A function used by walk tree to find wrapper parms. */
-static bool
-wrapper_parm_cb (const void *key0, void **val0, void *data)
+bool
+wrapper_parm_cb (tree const &key0, tree *val0, wrapper_data *wd)
{
- struct wrapper_data *wd = (struct wrapper_data *) data;
- tree arg = * (tree *)&key0;
- tree val = (tree)*val0;
+ tree arg = key0;
+ tree val = *val0;
tree parm;
if (val == error_mark_node || val == arg)
@@ -387,7 +386,7 @@ build_wrapper_type (struct wrapper_data *wd)
wd->parms = NULL_TREE;
wd->argtypes = void_list_node;
- pointer_map_traverse (wd->decl_map, wrapper_parm_cb, wd);
+ wd->decl_map->traverse<wrapper_data *, wrapper_parm_cb> (wd);
gcc_assert (wd->type != CILK_BLOCK_FOR);
/* Now build a function.
@@ -452,25 +451,22 @@ copy_decl_for_cilk (tree decl, copy_body_data *id)
/* Copy all local variables. */
-static bool
-for_local_cb (const void *k_v, void **vp, void *p)
+bool
+for_local_cb (tree const &k, tree *vp, copy_body_data *id)
{
- tree k = *(tree *) &k_v;
- tree v = (tree) *vp;
+ tree v = *vp;
if (v == error_mark_node)
- *vp = copy_decl_no_change (k, (copy_body_data *) p);
+ *vp = copy_decl_no_change (k, id);
return true;
}
/* Copy all local declarations from a _Cilk_spawned function's body. */
-static bool
-wrapper_local_cb (const void *k_v, void **vp, void *data)
+bool
+wrapper_local_cb (tree const &key, tree *vp, copy_body_data *id)
{
- copy_body_data *id = (copy_body_data *) data;
- tree key = *(tree *) &k_v;
- tree val = (tree) *vp;
+ tree val = *vp;
if (val == error_mark_node)
*vp = copy_decl_for_cilk (key, id);
@@ -514,8 +510,11 @@ cilk_outline (tree inner_fn, tree *stmt_p, void *w)
insert_decl_map (&id, wd->block, DECL_INITIAL (inner_fn));
/* We don't want the private variables any more. */
- pointer_map_traverse (wd->decl_map, nested ? for_local_cb : wrapper_local_cb,
- &id);
+ if (nested)
+ wd->decl_map->traverse<copy_body_data *, for_local_cb> (&id);
+ else
+ wd->decl_map->traverse<copy_body_data *, wrapper_local_cb> (&id);
+
walk_tree (stmt_p, copy_tree_body_r, (void *) &id, NULL);
/* See if this function can throw or calls something that should
@@ -576,7 +575,7 @@ init_wd (struct wrapper_data *wd, enum cilk_block_type type)
wd->type = type;
wd->fntype = NULL_TREE;
wd->context = current_function_decl;
- wd->decl_map = pointer_map_create ();
+ wd->decl_map = new hash_map<tree, tree>;
/* _Cilk_for bodies are always nested. Others start off as
normal functions. */
wd->nested = (type == CILK_BLOCK_FOR);
@@ -590,7 +589,7 @@ init_wd (struct wrapper_data *wd, enum cilk_block_type type)
static void
free_wd (struct wrapper_data *wd)
{
- pointer_map_destroy (wd->decl_map);
+ delete wd->decl_map;
wd->nested = false;
wd->arglist = NULL_TREE;
wd->argtypes = NULL_TREE;
@@ -618,12 +617,11 @@ free_wd (struct wrapper_data *wd)
(var, ???) -- Pure output argument, handled similarly to above.
*/
-static bool
-declare_one_free_variable (const void *var0, void **map0,
- void *data ATTRIBUTE_UNUSED)
+bool
+declare_one_free_variable (tree const &var0, tree *map0, wrapper_data &)
{
- const_tree var = (const_tree) var0;
- tree map = (tree)*map0;
+ const_tree var = var0;
+ tree map = *map0;
tree var_type = TREE_TYPE (var), arg_type;
bool by_reference;
tree parm;
@@ -713,7 +711,7 @@ create_cilk_wrapper (tree exp, tree *args_out)
}
else
extract_free_variables (exp, &wd, ADD_READ);
- pointer_map_traverse (wd.decl_map, declare_one_free_variable, &wd);
+ wd.decl_map->traverse<wrapper_data &, declare_one_free_variable> (wd);
wd.block = TREE_BLOCK (exp);
if (!wd.block)
wd.block = DECL_INITIAL (current_function_decl);
@@ -884,9 +882,7 @@ cilk_install_body_pedigree_operations (tree frame_ptr)
static void
add_variable (struct wrapper_data *wd, tree var, enum add_variable_type how)
{
- void **valp;
-
- valp = pointer_map_contains (wd->decl_map, (void *) var);
+ tree *valp = wd->decl_map->get (var);
if (valp)
{
tree val = (tree) *valp;
@@ -907,7 +903,7 @@ add_variable (struct wrapper_data *wd, tree var, enum add_variable_type how)
if (how != ADD_WRITE)
return;
/* This variable might have been entered as read but is now written. */
- *valp = (void *) var;
+ *valp = var;
wd->nested = true;
return;
}
@@ -971,7 +967,7 @@ add_variable (struct wrapper_data *wd, tree var, enum add_variable_type how)
break;
}
}
- *pointer_map_insert (wd->decl_map, (void *) var) = val;
+ wd->decl_map->put (var, val);
}
}