Commit 9016166f by Tobias Grosser Committed by Tobias Grosser

Simplify translate_clast_* methods

2009-11-23  Tobias Grosser  <grosser@fim.uni-passau.de>

	* graphite-clast-to-gimple.c (translate_clast_user,
	translate_clast_for, translate_clast_guard): Simplify and move common
	elements to translate_clast().
	(translate_clast): Simplify and get common elements.

From-SVN: r154847
parent cdc90f92
2009-11-23 Tobias Grosser <grosser@fim.uni-passau.de> 2009-11-23 Tobias Grosser <grosser@fim.uni-passau.de>
* graphite-clast-to-gimple.c (translate_clast_user, * graphite-clast-to-gimple.c (translate_clast_user,
translate_clast_for, translate_clast_guard): Simplify and move common
elements to translate_clast().
(translate_clast): Simplify and get common elements.
2009-11-23 Tobias Grosser <grosser@fim.uni-passau.de>
* graphite-clast-to-gimple.c (translate_clast_user,
translate_clast_for, translate_clast_guard): Split out of translate_clast_for, translate_clast_guard): Split out of
translate_clast. translate_clast.
......
...@@ -733,33 +733,27 @@ translate_clast (sese, loop_p, struct clast_stmt *, edge, htab_t, ...@@ -733,33 +733,27 @@ translate_clast (sese, loop_p, struct clast_stmt *, edge, htab_t,
- PARAMS_INDEX connects the cloog parameters with the gimple parameters in - PARAMS_INDEX connects the cloog parameters with the gimple parameters in
the sese region. */ the sese region. */
static edge static edge
translate_clast_user (sese region, struct loop *context_loop, translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e,
struct clast_stmt *stmt, edge next_e,
htab_t rename_map, VEC (tree, heap) **newivs, htab_t rename_map, VEC (tree, heap) **newivs,
htab_t newivs_index, htab_t bb_pbb_mapping, int level, htab_t newivs_index, htab_t bb_pbb_mapping,
htab_t params_index) htab_t params_index)
{ {
gimple_bb_p gbb; gimple_bb_p gbb;
basic_block new_bb; basic_block new_bb;
CloogStatement *cs = ((struct clast_user_stmt*) stmt)->statement; poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (stmt->statement);
poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (cs);
gbb = PBB_BLACK_BOX (pbb); gbb = PBB_BLACK_BOX (pbb);
if (GBB_BB (gbb) == ENTRY_BLOCK_PTR) if (GBB_BB (gbb) == ENTRY_BLOCK_PTR)
return next_e; return next_e;
build_iv_mapping (rename_map, region, *newivs, newivs_index, build_iv_mapping (rename_map, region, *newivs, newivs_index, stmt,
(struct clast_user_stmt*) stmt, params_index); params_index);
next_e = copy_bb_and_scalar_dependences (GBB_BB (gbb), region, next_e = copy_bb_and_scalar_dependences (GBB_BB (gbb), region,
next_e, rename_map); next_e, rename_map);
new_bb = next_e->src; new_bb = next_e->src;
mark_bb_with_pbb (pbb, new_bb, bb_pbb_mapping); mark_bb_with_pbb (pbb, new_bb, bb_pbb_mapping);
recompute_all_dominators ();
update_ssa (TODO_update_ssa); update_ssa (TODO_update_ssa);
graphite_verify (); return next_e;
return translate_clast (region, context_loop, stmt->next, next_e,
rename_map, newivs, newivs_index,
bb_pbb_mapping, level, params_index);
} }
/* Translates a clast for statement STMT to gimple. /* Translates a clast for statement STMT to gimple.
...@@ -773,16 +767,14 @@ translate_clast_user (sese region, struct loop *context_loop, ...@@ -773,16 +767,14 @@ translate_clast_user (sese region, struct loop *context_loop,
- PARAMS_INDEX connects the cloog parameters with the gimple parameters in - PARAMS_INDEX connects the cloog parameters with the gimple parameters in
the sese region. */ the sese region. */
static edge static edge
translate_clast_for (sese region, loop_p context_loop, struct clast_stmt *stmt, translate_clast_for (sese region, loop_p context_loop, struct clast_for *stmt,
edge next_e, htab_t rename_map, VEC (tree, heap) **newivs, edge next_e, htab_t rename_map, VEC (tree, heap) **newivs,
htab_t newivs_index, htab_t bb_pbb_mapping, int level, htab_t newivs_index, htab_t bb_pbb_mapping, int level,
htab_t params_index) htab_t params_index)
{ {
struct clast_for *stmtfor = (struct clast_for *)stmt; struct loop *loop = graphite_create_new_loop (region, next_e, stmt,
struct loop *loop context_loop, newivs,
= graphite_create_new_loop (region, next_e, stmtfor, newivs_index, params_index);
context_loop, newivs, newivs_index,
params_index);
edge last_e = single_exit (loop); edge last_e = single_exit (loop);
edge to_body = single_succ_edge (loop->header); edge to_body = single_succ_edge (loop->header);
basic_block after = to_body->dest; basic_block after = to_body->dest;
...@@ -791,10 +783,9 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_stmt *stmt, ...@@ -791,10 +783,9 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_stmt *stmt,
last_e = single_succ_edge (split_edge (last_e)); last_e = single_succ_edge (split_edge (last_e));
/* Translate the body of the loop. */ /* Translate the body of the loop. */
next_e = translate_clast next_e = translate_clast (region, loop, stmt->body, to_body, rename_map,
(region, loop, ((struct clast_for *) stmt)->body, newivs, newivs_index, bb_pbb_mapping, level + 1,
single_succ_edge (loop->header), rename_map, newivs, params_index);
newivs_index, bb_pbb_mapping, level + 1, params_index);
redirect_edge_succ_nodup (next_e, after); redirect_edge_succ_nodup (next_e, after);
set_immediate_dominator (CDI_DOMINATORS, next_e->dest, next_e->src); set_immediate_dominator (CDI_DOMINATORS, next_e->dest, next_e->src);
...@@ -807,11 +798,7 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_stmt *stmt, ...@@ -807,11 +798,7 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_stmt *stmt,
get_scattering_level (level))) get_scattering_level (level)))
loop->can_be_parallel = true; loop->can_be_parallel = true;
recompute_all_dominators (); return last_e;
graphite_verify ();
return translate_clast (region, context_loop, stmt->next, last_e,
rename_map, newivs, newivs_index,
bb_pbb_mapping, level, params_index);
} }
/* Translates a clast guard statement STMT to gimple. /* Translates a clast guard statement STMT to gimple.
...@@ -826,36 +813,33 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_stmt *stmt, ...@@ -826,36 +813,33 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_stmt *stmt,
the sese region. */ the sese region. */
static edge static edge
translate_clast_guard (sese region, loop_p context_loop, translate_clast_guard (sese region, loop_p context_loop,
struct clast_stmt *stmt, edge next_e, htab_t rename_map, struct clast_guard *stmt, edge next_e,
VEC (tree, heap) **newivs, htab_t newivs_index, htab_t rename_map, VEC (tree, heap) **newivs,
htab_t bb_pbb_mapping, int level, htab_t params_index) htab_t newivs_index, htab_t bb_pbb_mapping, int level,
htab_t params_index)
{ {
edge last_e = graphite_create_new_guard (region, next_e, edge last_e = graphite_create_new_guard (region, next_e, stmt, *newivs,
((struct clast_guard *) stmt), newivs_index, params_index);
*newivs, newivs_index,
params_index);
edge true_e = get_true_edge_from_guard_bb (next_e->dest); edge true_e = get_true_edge_from_guard_bb (next_e->dest);
edge false_e = get_false_edge_from_guard_bb (next_e->dest); edge false_e = get_false_edge_from_guard_bb (next_e->dest);
edge exit_true_e = single_succ_edge (true_e->dest); edge exit_true_e = single_succ_edge (true_e->dest);
edge exit_false_e = single_succ_edge (false_e->dest); edge exit_false_e = single_succ_edge (false_e->dest);
htab_t before_guard = htab_create (10, rename_map_elt_info, htab_t before_guard = htab_create (10, rename_map_elt_info,
eq_rename_map_elts, free); eq_rename_map_elts, free);
htab_traverse (rename_map, copy_renames, before_guard); htab_traverse (rename_map, copy_renames, before_guard);
next_e = translate_clast (region, context_loop,
((struct clast_guard *) stmt)->then, next_e = translate_clast (region, context_loop, stmt->then, true_e,
true_e, rename_map, newivs, newivs_index, rename_map, newivs, newivs_index, bb_pbb_mapping,
bb_pbb_mapping, level, params_index); level, params_index);
insert_guard_phis (last_e->src, exit_true_e, exit_false_e, insert_guard_phis (last_e->src, exit_true_e, exit_false_e,
before_guard, rename_map); before_guard, rename_map);
htab_delete (before_guard); htab_delete (before_guard);
recompute_all_dominators ();
graphite_verify ();
return translate_clast (region, context_loop, stmt->next, last_e, return last_e;
rename_map, newivs, newivs_index,
bb_pbb_mapping, level, params_index);
} }
/* Translates a CLAST statement STMT to GCC representation in the /* Translates a CLAST statement STMT to GCC representation in the
...@@ -876,39 +860,39 @@ translate_clast (sese region, loop_p context_loop, struct clast_stmt *stmt, ...@@ -876,39 +860,39 @@ translate_clast (sese region, loop_p context_loop, struct clast_stmt *stmt,
return next_e; return next_e;
if (CLAST_STMT_IS_A (stmt, stmt_root)) if (CLAST_STMT_IS_A (stmt, stmt_root))
return translate_clast (region, context_loop, stmt->next, next_e, ; /* Do nothing. */
rename_map, newivs, newivs_index,
bb_pbb_mapping, level, params_index);
if (CLAST_STMT_IS_A (stmt, stmt_user)) else if (CLAST_STMT_IS_A (stmt, stmt_user))
return translate_clast_user (region, context_loop, stmt, next_e, next_e = translate_clast_user (region, (struct clast_user_stmt *) stmt,
rename_map, newivs, newivs_index, next_e, rename_map, newivs, newivs_index,
bb_pbb_mapping, level, params_index); bb_pbb_mapping, params_index);
if (CLAST_STMT_IS_A (stmt, stmt_for)) else if (CLAST_STMT_IS_A (stmt, stmt_for))
return translate_clast_for (region, context_loop, stmt, next_e, next_e = translate_clast_for (region, context_loop,
(struct clast_for *) stmt, next_e,
rename_map, newivs, newivs_index, rename_map, newivs, newivs_index,
bb_pbb_mapping, level, params_index); bb_pbb_mapping, level, params_index);
if (CLAST_STMT_IS_A (stmt, stmt_guard)) else if (CLAST_STMT_IS_A (stmt, stmt_guard))
return translate_clast_guard (region, context_loop, stmt, next_e, next_e = translate_clast_guard (region, context_loop,
(struct clast_guard *) stmt, next_e,
rename_map, newivs, newivs_index, rename_map, newivs, newivs_index,
bb_pbb_mapping, level, params_index); bb_pbb_mapping, level, params_index);
if (CLAST_STMT_IS_A (stmt, stmt_block)) else if (CLAST_STMT_IS_A (stmt, stmt_block))
{
next_e = translate_clast (region, context_loop, next_e = translate_clast (region, context_loop,
((struct clast_block *) stmt)->body, ((struct clast_block *) stmt)->body,
next_e, rename_map, newivs, newivs_index, next_e, rename_map, newivs, newivs_index,
bb_pbb_mapping, level, params_index); bb_pbb_mapping, level, params_index);
else
gcc_unreachable();
recompute_all_dominators (); recompute_all_dominators ();
graphite_verify (); graphite_verify ();
return translate_clast (region, context_loop, stmt->next, next_e, return translate_clast (region, context_loop, stmt->next, next_e,
rename_map, newivs, newivs_index, rename_map, newivs, newivs_index,
bb_pbb_mapping, level, params_index); bb_pbb_mapping, level, params_index);
}
gcc_unreachable ();
} }
/* Returns the first cloog name used in EXPR. */ /* Returns the first cloog name used in EXPR. */
......
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