Commit cf7eab7d by Sebastian Pop Committed by Sebastian Pop

Cleanup function params using a struct.

2011-07-21  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-clast-to-gimple.c (struct ivs_params): New.
	(clast_name_to_gcc): Use ivs_params to pass around parameters.
	(clast_to_gcc_expression): Same.
	(clast_to_gcc_expression_red): Same.
	(gcc_type_for_clast_term): Same.
	(gcc_type_for_clast_expr): Same.
	(gcc_type_for_clast_red): Same.
	(gcc_type_for_clast_bin): Same.
	(gcc_type_for_clast_eq): Same.
	(graphite_translate_clast_equation): Same.
	(graphite_create_guard_cond_expr): Same.
	(graphite_create_new_guard): Same.
	(graphite_create_new_loop): Same.
	(build_iv_mapping): Same.
	(translate_clast_user): Same.
	(graphite_create_new_loop_guard): Same.
	(translate_clast): Same.
	(translate_clast_for_loop): Same.
	(translate_clast_for): Same.
	(translate_clast_guard): Same.
	(initialize_cloog_names): Fix typo.
	(gloog): Initialize an ivs_params struct, pass it to translate_clast.

From-SVN: r176599
parent 7b1e9596
2011-07-21 Sebastian Pop <sebastian.pop@amd.com> 2011-07-21 Sebastian Pop <sebastian.pop@amd.com>
* graphite-clast-to-gimple.c (struct ivs_params): New.
(clast_name_to_gcc): Use ivs_params to pass around parameters.
(clast_to_gcc_expression): Same.
(clast_to_gcc_expression_red): Same.
(gcc_type_for_clast_term): Same.
(gcc_type_for_clast_expr): Same.
(gcc_type_for_clast_red): Same.
(gcc_type_for_clast_bin): Same.
(gcc_type_for_clast_eq): Same.
(graphite_translate_clast_equation): Same.
(graphite_create_guard_cond_expr): Same.
(graphite_create_new_guard): Same.
(graphite_create_new_loop): Same.
(build_iv_mapping): Same.
(translate_clast_user): Same.
(graphite_create_new_loop_guard): Same.
(translate_clast): Same.
(translate_clast_for_loop): Same.
(translate_clast_for): Same.
(translate_clast_guard): Same.
(initialize_cloog_names): Fix typo.
(gloog): Initialize an ivs_params struct, pass it to translate_clast.
2011-07-21 Sebastian Pop <sebastian.pop@amd.com>
* graphite-clast-to-gimple.c (struct clast_name_index): Add level. * graphite-clast-to-gimple.c (struct clast_name_index): Add level.
(new_clast_name_index): Add level parameter. (new_clast_name_index): Add level parameter.
(clast_name_to_level): New. (clast_name_to_level): New.
......
...@@ -171,29 +171,39 @@ eq_clast_name_indexes (const void *e1, const void *e2) ...@@ -171,29 +171,39 @@ eq_clast_name_indexes (const void *e1, const void *e2)
/* NEWIVS_INDEX binds CLooG's scattering name to the index of the tree
induction variable in NEWIVS.
PARAMS_INDEX binds CLooG's parameter name to the index of the tree
parameter in PARAMS. */
typedef struct ivs_params {
VEC (tree, heap) *params, **newivs;
htab_t newivs_index, params_index;
sese region;
} *ivs_params_p;
/* Returns the tree variable from the name NAME that was given in /* Returns the tree variable from the name NAME that was given in
Cloog representation. */ Cloog representation. */
static tree static tree
clast_name_to_gcc (clast_name_p name, sese region, VEC (tree, heap) *newivs, clast_name_to_gcc (clast_name_p name, ivs_params_p ip)
htab_t newivs_index, htab_t params_index)
{ {
int index; int index;
VEC (tree, heap) *params = SESE_PARAMS (region);
if (params && params_index) if (ip->params && ip->params_index)
{ {
index = clast_name_to_index (name, params_index); index = clast_name_to_index (name, ip->params_index);
if (index >= 0) if (index >= 0)
return VEC_index (tree, params, index); return VEC_index (tree, ip->params, index);
} }
gcc_assert (newivs && newivs_index); gcc_assert (*(ip->newivs) && ip->newivs_index);
index = clast_name_to_index (name, newivs_index); index = clast_name_to_index (name, ip->newivs_index);
gcc_assert (index >= 0); gcc_assert (index >= 0);
return VEC_index (tree, newivs, index); return VEC_index (tree, *(ip->newivs), index);
} }
/* Returns the signed maximal precision type for expressions TYPE1 and TYPE2. */ /* Returns the signed maximal precision type for expressions TYPE1 and TYPE2. */
...@@ -250,27 +260,22 @@ max_precision_type (tree type1, tree type2) ...@@ -250,27 +260,22 @@ max_precision_type (tree type1, tree type2)
} }
static tree static tree
clast_to_gcc_expression (tree, struct clast_expr *, sese, VEC (tree, heap) *, clast_to_gcc_expression (tree, struct clast_expr *, ivs_params_p);
htab_t, htab_t);
/* Converts a Cloog reduction expression R with reduction operation OP /* Converts a Cloog reduction expression R with reduction operation OP
to a GCC expression tree of type TYPE. */ to a GCC expression tree of type TYPE. */
static tree static tree
clast_to_gcc_expression_red (tree type, enum tree_code op, clast_to_gcc_expression_red (tree type, enum tree_code op,
struct clast_reduction *r, struct clast_reduction *r, ivs_params_p ip)
sese region, VEC (tree, heap) *newivs,
htab_t newivs_index, htab_t params_index)
{ {
int i; int i;
tree res = clast_to_gcc_expression (type, r->elts[0], region, newivs, tree res = clast_to_gcc_expression (type, r->elts[0], ip);
newivs_index, params_index);
tree operand_type = (op == POINTER_PLUS_EXPR) ? sizetype : type; tree operand_type = (op == POINTER_PLUS_EXPR) ? sizetype : type;
for (i = 1; i < r->n; i++) for (i = 1; i < r->n; i++)
{ {
tree t = clast_to_gcc_expression (operand_type, r->elts[i], region, tree t = clast_to_gcc_expression (operand_type, r->elts[i], ip);
newivs, newivs_index, params_index);
res = fold_build2 (op, type, res, t); res = fold_build2 (op, type, res, t);
} }
...@@ -281,9 +286,7 @@ clast_to_gcc_expression_red (tree type, enum tree_code op, ...@@ -281,9 +286,7 @@ clast_to_gcc_expression_red (tree type, enum tree_code op,
type TYPE. */ type TYPE. */
static tree static tree
clast_to_gcc_expression (tree type, struct clast_expr *e, clast_to_gcc_expression (tree type, struct clast_expr *e, ivs_params_p ip)
sese region, VEC (tree, heap) *newivs,
htab_t newivs_index, htab_t params_index)
{ {
switch (e->type) switch (e->type)
{ {
...@@ -295,8 +298,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ...@@ -295,8 +298,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e,
{ {
if (mpz_cmp_si (t->val, 1) == 0) if (mpz_cmp_si (t->val, 1) == 0)
{ {
tree name = clast_name_to_gcc (t->var, region, newivs, tree name = clast_name_to_gcc (t->var, ip);
newivs_index, params_index);
if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type)) if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type))
name = fold_convert (sizetype, name); name = fold_convert (sizetype, name);
...@@ -307,8 +309,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ...@@ -307,8 +309,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e,
else if (mpz_cmp_si (t->val, -1) == 0) else if (mpz_cmp_si (t->val, -1) == 0)
{ {
tree name = clast_name_to_gcc (t->var, region, newivs, tree name = clast_name_to_gcc (t->var, ip);
newivs_index, params_index);
if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type)) if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type))
name = fold_convert (sizetype, name); name = fold_convert (sizetype, name);
...@@ -319,8 +320,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ...@@ -319,8 +320,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e,
} }
else else
{ {
tree name = clast_name_to_gcc (t->var, region, newivs, tree name = clast_name_to_gcc (t->var, ip);
newivs_index, params_index);
tree cst = gmp_cst_to_tree (type, t->val); tree cst = gmp_cst_to_tree (type, t->val);
if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type)) if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type))
...@@ -348,17 +348,13 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ...@@ -348,17 +348,13 @@ clast_to_gcc_expression (tree type, struct clast_expr *e,
case clast_red_sum: case clast_red_sum:
return clast_to_gcc_expression_red return clast_to_gcc_expression_red
(type, POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR : PLUS_EXPR, (type, POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR : PLUS_EXPR,
r, region, newivs, newivs_index, params_index); r, ip);
case clast_red_min: case clast_red_min:
return clast_to_gcc_expression_red (type, MIN_EXPR, r, region, return clast_to_gcc_expression_red (type, MIN_EXPR, r, ip);
newivs, newivs_index,
params_index);
case clast_red_max: case clast_red_max:
return clast_to_gcc_expression_red (type, MAX_EXPR, r, region, return clast_to_gcc_expression_red (type, MAX_EXPR, r, ip);
newivs, newivs_index,
params_index);
default: default:
gcc_unreachable (); gcc_unreachable ();
...@@ -370,8 +366,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ...@@ -370,8 +366,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e,
{ {
struct clast_binary *b = (struct clast_binary *) e; struct clast_binary *b = (struct clast_binary *) e;
struct clast_expr *lhs = (struct clast_expr *) b->LHS; struct clast_expr *lhs = (struct clast_expr *) b->LHS;
tree tl = clast_to_gcc_expression (type, lhs, region, newivs, tree tl = clast_to_gcc_expression (type, lhs, ip);
newivs_index, params_index);
tree tr = gmp_cst_to_tree (type, b->RHS); tree tr = gmp_cst_to_tree (type, b->RHS);
switch (b->type) switch (b->type)
...@@ -448,47 +443,40 @@ gcc_type_for_value (mpz_t val) ...@@ -448,47 +443,40 @@ gcc_type_for_value (mpz_t val)
static tree static tree
gcc_type_for_clast_term (struct clast_term *t, gcc_type_for_clast_term (struct clast_term *t,
sese region, VEC (tree, heap) *newivs, ivs_params_p ip)
htab_t newivs_index, htab_t params_index)
{ {
gcc_assert (t->expr.type == clast_expr_term); gcc_assert (t->expr.type == clast_expr_term);
if (!t->var) if (!t->var)
return gcc_type_for_value (t->val); return gcc_type_for_value (t->val);
return TREE_TYPE (clast_name_to_gcc (t->var, region, newivs, return TREE_TYPE (clast_name_to_gcc (t->var, ip));
newivs_index, params_index));
} }
static tree static tree
gcc_type_for_clast_expr (struct clast_expr *, sese, gcc_type_for_clast_expr (struct clast_expr *, ivs_params_p);
VEC (tree, heap) *, htab_t, htab_t);
/* Return the type for the clast_reduction R used in STMT. */ /* Return the type for the clast_reduction R used in STMT. */
static tree static tree
gcc_type_for_clast_red (struct clast_reduction *r, sese region, gcc_type_for_clast_red (struct clast_reduction *r,
VEC (tree, heap) *newivs, ivs_params_p ip)
htab_t newivs_index, htab_t params_index)
{ {
int i; int i;
tree type = NULL_TREE; tree type = NULL_TREE;
if (r->n == 1) if (r->n == 1)
return gcc_type_for_clast_expr (r->elts[0], region, newivs, return gcc_type_for_clast_expr (r->elts[0], ip);
newivs_index, params_index);
switch (r->type) switch (r->type)
{ {
case clast_red_sum: case clast_red_sum:
case clast_red_min: case clast_red_min:
case clast_red_max: case clast_red_max:
type = gcc_type_for_clast_expr (r->elts[0], region, newivs, type = gcc_type_for_clast_expr (r->elts[0], ip);
newivs_index, params_index);
for (i = 1; i < r->n; i++) for (i = 1; i < r->n; i++)
type = max_precision_type (type, gcc_type_for_clast_expr type = max_precision_type (type, gcc_type_for_clast_expr
(r->elts[i], region, newivs, (r->elts[i], ip));
newivs_index, params_index));
return type; return type;
...@@ -503,12 +491,9 @@ gcc_type_for_clast_red (struct clast_reduction *r, sese region, ...@@ -503,12 +491,9 @@ gcc_type_for_clast_red (struct clast_reduction *r, sese region,
/* Return the type for the clast_binary B used in STMT. */ /* Return the type for the clast_binary B used in STMT. */
static tree static tree
gcc_type_for_clast_bin (struct clast_binary *b, gcc_type_for_clast_bin (struct clast_binary *b, ivs_params_p ip)
sese region, VEC (tree, heap) *newivs,
htab_t newivs_index, htab_t params_index)
{ {
tree l = gcc_type_for_clast_expr ((struct clast_expr *) b->LHS, region, tree l = gcc_type_for_clast_expr ((struct clast_expr *) b->LHS, ip);
newivs, newivs_index, params_index);
tree r = gcc_type_for_value (b->RHS); tree r = gcc_type_for_value (b->RHS);
return max_signed_precision_type (l, r); return max_signed_precision_type (l, r);
} }
...@@ -518,22 +503,18 @@ gcc_type_for_clast_bin (struct clast_binary *b, ...@@ -518,22 +503,18 @@ gcc_type_for_clast_bin (struct clast_binary *b,
static tree static tree
gcc_type_for_clast_expr (struct clast_expr *e, gcc_type_for_clast_expr (struct clast_expr *e,
sese region, VEC (tree, heap) *newivs, ivs_params_p ip)
htab_t newivs_index, htab_t params_index)
{ {
switch (e->type) switch (e->type)
{ {
case clast_expr_term: case clast_expr_term:
return gcc_type_for_clast_term ((struct clast_term *) e, region, return gcc_type_for_clast_term ((struct clast_term *) e, ip);
newivs, newivs_index, params_index);
case clast_expr_red: case clast_expr_red:
return gcc_type_for_clast_red ((struct clast_reduction *) e, region, return gcc_type_for_clast_red ((struct clast_reduction *) e, ip);
newivs, newivs_index, params_index);
case clast_expr_bin: case clast_expr_bin:
return gcc_type_for_clast_bin ((struct clast_binary *) e, region, return gcc_type_for_clast_bin ((struct clast_binary *) e, ip);
newivs, newivs_index, params_index);
default: default:
gcc_unreachable (); gcc_unreachable ();
...@@ -546,31 +527,23 @@ gcc_type_for_clast_expr (struct clast_expr *e, ...@@ -546,31 +527,23 @@ gcc_type_for_clast_expr (struct clast_expr *e,
static tree static tree
gcc_type_for_clast_eq (struct clast_equation *cleq, gcc_type_for_clast_eq (struct clast_equation *cleq,
sese region, VEC (tree, heap) *newivs, ivs_params_p ip)
htab_t newivs_index, htab_t params_index)
{ {
tree l = gcc_type_for_clast_expr (cleq->LHS, region, newivs, tree l = gcc_type_for_clast_expr (cleq->LHS, ip);
newivs_index, params_index); tree r = gcc_type_for_clast_expr (cleq->RHS, ip);
tree r = gcc_type_for_clast_expr (cleq->RHS, region, newivs,
newivs_index, params_index);
return max_precision_type (l, r); return max_precision_type (l, r);
} }
/* Translates a clast equation CLEQ to a tree. */ /* Translates a clast equation CLEQ to a tree. */
static tree static tree
graphite_translate_clast_equation (sese region, graphite_translate_clast_equation (struct clast_equation *cleq,
struct clast_equation *cleq, ivs_params_p ip)
VEC (tree, heap) *newivs,
htab_t newivs_index, htab_t params_index)
{ {
enum tree_code comp; enum tree_code comp;
tree type = gcc_type_for_clast_eq (cleq, region, newivs, newivs_index, tree type = gcc_type_for_clast_eq (cleq, ip);
params_index); tree lhs = clast_to_gcc_expression (type, cleq->LHS, ip);
tree lhs = clast_to_gcc_expression (type, cleq->LHS, region, newivs, tree rhs = clast_to_gcc_expression (type, cleq->RHS, ip);
newivs_index, params_index);
tree rhs = clast_to_gcc_expression (type, cleq->RHS, region, newivs,
newivs_index, params_index);
if (cleq->sign == 0) if (cleq->sign == 0)
comp = EQ_EXPR; comp = EQ_EXPR;
...@@ -587,18 +560,15 @@ graphite_translate_clast_equation (sese region, ...@@ -587,18 +560,15 @@ graphite_translate_clast_equation (sese region,
/* Creates the test for the condition in STMT. */ /* Creates the test for the condition in STMT. */
static tree static tree
graphite_create_guard_cond_expr (sese region, struct clast_guard *stmt, graphite_create_guard_cond_expr (struct clast_guard *stmt,
VEC (tree, heap) *newivs, ivs_params_p ip)
htab_t newivs_index, htab_t params_index)
{ {
tree cond = NULL; tree cond = NULL;
int i; int i;
for (i = 0; i < stmt->n; i++) for (i = 0; i < stmt->n; i++)
{ {
tree eq = graphite_translate_clast_equation (region, &stmt->eq[i], tree eq = graphite_translate_clast_equation (&stmt->eq[i], ip);
newivs, newivs_index,
params_index);
if (cond) if (cond)
cond = fold_build2 (TRUTH_AND_EXPR, TREE_TYPE (eq), cond, eq); cond = fold_build2 (TRUTH_AND_EXPR, TREE_TYPE (eq), cond, eq);
...@@ -612,13 +582,10 @@ graphite_create_guard_cond_expr (sese region, struct clast_guard *stmt, ...@@ -612,13 +582,10 @@ graphite_create_guard_cond_expr (sese region, struct clast_guard *stmt,
/* Creates a new if region corresponding to Cloog's guard. */ /* Creates a new if region corresponding to Cloog's guard. */
static edge static edge
graphite_create_new_guard (sese region, edge entry_edge, graphite_create_new_guard (edge entry_edge, struct clast_guard *stmt,
struct clast_guard *stmt, ivs_params_p ip)
VEC (tree, heap) *newivs,
htab_t newivs_index, htab_t params_index)
{ {
tree cond_expr = graphite_create_guard_cond_expr (region, stmt, newivs, tree cond_expr = graphite_create_guard_cond_expr (stmt, ip);
newivs_index, params_index);
edge exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr); edge exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);
return exit_edge; return exit_edge;
} }
...@@ -720,11 +687,9 @@ gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for, int level, ...@@ -720,11 +687,9 @@ gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for, int level,
vector and is of type TYPE. */ vector and is of type TYPE. */
static struct loop * static struct loop *
graphite_create_new_loop (edge entry_edge, graphite_create_new_loop (edge entry_edge, struct clast_for *stmt,
struct clast_for *stmt, loop_p outer, tree type, tree lb, tree ub,
loop_p outer, VEC (tree, heap) **newivs, int level, ivs_params_p ip)
htab_t newivs_index,
tree type, tree lb, tree ub, int level)
{ {
tree stride = gmp_cst_to_tree (type, stmt->stride); tree stride = gmp_cst_to_tree (type, stmt->stride);
tree ivvar = create_tmp_var (type, "graphite_IV"); tree ivvar = create_tmp_var (type, "graphite_IV");
...@@ -735,9 +700,9 @@ graphite_create_new_loop (edge entry_edge, ...@@ -735,9 +700,9 @@ graphite_create_new_loop (edge entry_edge,
add_referenced_var (ivvar); add_referenced_var (ivvar);
save_clast_name_index (newivs_index, stmt->iterator, save_clast_name_index (ip->newivs_index, stmt->iterator,
VEC_length (tree, *newivs), level); VEC_length (tree, *(ip->newivs)), level);
VEC_safe_push (tree, heap, *newivs, iv); VEC_safe_push (tree, heap, *(ip->newivs), iv);
return loop; return loop;
} }
...@@ -745,10 +710,8 @@ graphite_create_new_loop (edge entry_edge, ...@@ -745,10 +710,8 @@ graphite_create_new_loop (edge entry_edge,
induction variables of the loops around GBB in SESE. */ induction variables of the loops around GBB in SESE. */
static void static void
build_iv_mapping (VEC (tree, heap) *iv_map, sese region, build_iv_mapping (VEC (tree, heap) *iv_map, struct clast_user_stmt *user_stmt,
VEC (tree, heap) *newivs, htab_t newivs_index, ivs_params_p ip)
struct clast_user_stmt *user_stmt,
htab_t params_index)
{ {
struct clast_stmt *t; struct clast_stmt *t;
int depth = 0; int depth = 0;
...@@ -760,11 +723,9 @@ build_iv_mapping (VEC (tree, heap) *iv_map, sese region, ...@@ -760,11 +723,9 @@ build_iv_mapping (VEC (tree, heap) *iv_map, sese region,
{ {
struct clast_expr *expr = (struct clast_expr *) struct clast_expr *expr = (struct clast_expr *)
((struct clast_assignment *)t)->RHS; ((struct clast_assignment *)t)->RHS;
tree type = gcc_type_for_clast_expr (expr, region, newivs, tree type = gcc_type_for_clast_expr (expr, ip);
newivs_index, params_index); tree new_name = clast_to_gcc_expression (type, expr, ip);
tree new_name = clast_to_gcc_expression (type, expr, region, newivs, loop_p old_loop = gbb_loop_at_index (gbb, ip->region, depth);
newivs_index, params_index);
loop_p old_loop = gbb_loop_at_index (gbb, region, depth);
VEC_replace (tree, iv_map, old_loop->num, new_name); VEC_replace (tree, iv_map, old_loop->num, new_name);
} }
...@@ -855,17 +816,13 @@ dependency_in_loop_p (loop_p loop, htab_t bb_pbb_mapping, int level) ...@@ -855,17 +816,13 @@ dependency_in_loop_p (loop_p loop, htab_t bb_pbb_mapping, int level)
/* Translates a clast user statement STMT to gimple. /* Translates a clast user statement STMT to gimple.
- REGION is the sese region we used to generate the scop.
- NEXT_E is the edge where new generated code should be attached. - NEXT_E is the edge where new generated code should be attached.
- CONTEXT_LOOP is the loop in which the generated code will be placed - CONTEXT_LOOP is the loop in which the generated code will be placed
- BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. */
- PARAMS_INDEX connects the cloog parameters with the gimple parameters in
the sese region. */
static edge static edge
translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e, translate_clast_user (struct clast_user_stmt *stmt, edge next_e,
VEC (tree, heap) **newivs, htab_t bb_pbb_mapping, ivs_params_p ip)
htab_t newivs_index, htab_t bb_pbb_mapping,
htab_t params_index)
{ {
int i, nb_loops; int i, nb_loops;
basic_block new_bb; basic_block new_bb;
...@@ -881,8 +838,8 @@ translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e, ...@@ -881,8 +838,8 @@ translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e,
for (i = 0; i < nb_loops; i++) for (i = 0; i < nb_loops; i++)
VEC_quick_push (tree, iv_map, NULL_TREE); VEC_quick_push (tree, iv_map, NULL_TREE);
build_iv_mapping (iv_map, region, *newivs, newivs_index, stmt, params_index); build_iv_mapping (iv_map, stmt, ip);
next_e = copy_bb_and_scalar_dependences (GBB_BB (gbb), region, next_e = copy_bb_and_scalar_dependences (GBB_BB (gbb), ip->region,
next_e, iv_map); next_e, iv_map);
VEC_free (tree, heap, iv_map); VEC_free (tree, heap, iv_map);
...@@ -897,24 +854,18 @@ translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e, ...@@ -897,24 +854,18 @@ translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e,
count is zero (lb > ub). */ count is zero (lb > ub). */
static edge static edge
graphite_create_new_loop_guard (sese region, edge entry_edge, graphite_create_new_loop_guard (edge entry_edge, struct clast_for *stmt,
struct clast_for *stmt, int level, tree *type, tree *lb, tree *ub,
VEC (tree, heap) *newivs, ivs_params_p ip)
htab_t newivs_index, htab_t params_index,
int level, tree *type, tree *lb, tree *ub)
{ {
tree cond_expr; tree cond_expr;
edge exit_edge; edge exit_edge;
tree lb_type = gcc_type_for_clast_expr (stmt->LB, region, newivs, tree lb_type = gcc_type_for_clast_expr (stmt->LB, ip);
newivs_index, params_index); tree ub_type = gcc_type_for_clast_expr (stmt->UB, ip);
tree ub_type = gcc_type_for_clast_expr (stmt->UB, region, newivs,
newivs_index, params_index);
*type = gcc_type_for_iv_of_clast_loop (stmt, level, lb_type, ub_type); *type = gcc_type_for_iv_of_clast_loop (stmt, level, lb_type, ub_type);
*lb = clast_to_gcc_expression (*type, stmt->LB, region, newivs, *lb = clast_to_gcc_expression (*type, stmt->LB, ip);
newivs_index, params_index); *ub = clast_to_gcc_expression (*type, stmt->UB, ip);
*ub = clast_to_gcc_expression (*type, stmt->UB, region, newivs,
newivs_index, params_index);
/* When ub is simply a constant or a parameter, use lb <= ub. */ /* When ub is simply a constant or a parameter, use lb <= ub. */
if (TREE_CODE (*ub) == INTEGER_CST || TREE_CODE (*ub) == SSA_NAME) if (TREE_CODE (*ub) == INTEGER_CST || TREE_CODE (*ub) == SSA_NAME)
...@@ -941,29 +892,20 @@ graphite_create_new_loop_guard (sese region, edge entry_edge, ...@@ -941,29 +892,20 @@ graphite_create_new_loop_guard (sese region, edge entry_edge,
} }
static edge static edge
translate_clast (sese, loop_p, struct clast_stmt *, edge, translate_clast (loop_p, struct clast_stmt *, edge, htab_t, int, ivs_params_p);
VEC (tree, heap) **, htab_t, htab_t, int, htab_t);
/* Create the loop for a clast for statement. /* Create the loop for a clast for statement.
- REGION is the sese region we used to generate the scop.
- NEXT_E is the edge where new generated code should be attached. - NEXT_E is the edge where new generated code should be attached.
- BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. */
- PARAMS_INDEX connects the cloog parameters with the gimple parameters in
the sese region. */
static edge static edge
translate_clast_for_loop (sese region, loop_p context_loop, translate_clast_for_loop (loop_p context_loop, struct clast_for *stmt,
struct clast_for *stmt, edge next_e, edge next_e, htab_t bb_pbb_mapping, int level,
VEC (tree, heap) **newivs, tree type, tree lb, tree ub, ivs_params_p ip)
htab_t newivs_index, htab_t bb_pbb_mapping,
int level, htab_t params_index, tree type,
tree lb, tree ub)
{ {
struct loop *loop = graphite_create_new_loop (next_e, stmt, struct loop *loop = graphite_create_new_loop (next_e, stmt, context_loop,
context_loop, newivs, type, lb, ub, level, ip);
newivs_index,
type, lb, ub, level);
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;
...@@ -972,9 +914,8 @@ translate_clast_for_loop (sese region, loop_p context_loop, ...@@ -972,9 +914,8 @@ translate_clast_for_loop (sese region, loop_p context_loop,
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 (region, loop, stmt->body, to_body, next_e = translate_clast (loop, stmt->body, to_body, bb_pbb_mapping,
newivs, newivs_index, bb_pbb_mapping, level + 1, level + 1, ip);
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);
...@@ -989,51 +930,38 @@ translate_clast_for_loop (sese region, loop_p context_loop, ...@@ -989,51 +930,38 @@ translate_clast_for_loop (sese region, loop_p context_loop,
protecting the loop, if it is executed zero times. In this guard we create protecting the loop, if it is executed zero times. In this guard we create
the real loop structure. the real loop structure.
- REGION is the sese region we used to generate the scop.
- NEXT_E is the edge where new generated code should be attached. - NEXT_E is the edge where new generated code should be attached.
- BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. */
- PARAMS_INDEX connects the cloog parameters with the gimple parameters in
the sese region. */
static edge static edge
translate_clast_for (sese region, loop_p context_loop, struct clast_for *stmt, translate_clast_for (loop_p context_loop, struct clast_for *stmt, edge next_e,
edge next_e, VEC (tree, heap) **newivs, htab_t bb_pbb_mapping, int level, ivs_params_p ip)
htab_t newivs_index, htab_t bb_pbb_mapping, int level,
htab_t params_index)
{ {
tree type, lb, ub; tree type, lb, ub;
edge last_e = graphite_create_new_loop_guard (region, next_e, stmt, *newivs, edge last_e = graphite_create_new_loop_guard (next_e, stmt, level, &type,
newivs_index, params_index, &lb, &ub, ip);
level, &type, &lb, &ub);
edge true_e = get_true_edge_from_guard_bb (next_e->dest); edge true_e = get_true_edge_from_guard_bb (next_e->dest);
translate_clast_for_loop (region, context_loop, stmt, true_e, newivs, translate_clast_for_loop (context_loop, stmt, true_e, bb_pbb_mapping, level,
newivs_index, bb_pbb_mapping, level, type, lb, ub, ip);
params_index, type, lb, ub);
return last_e; return last_e;
} }
/* Translates a clast guard statement STMT to gimple. /* Translates a clast guard statement STMT to gimple.
- REGION is the sese region we used to generate the scop.
- NEXT_E is the edge where new generated code should be attached. - NEXT_E is the edge where new generated code should be attached.
- CONTEXT_LOOP is the loop in which the generated code will be placed - CONTEXT_LOOP is the loop in which the generated code will be placed
- BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. */
- PARAMS_INDEX connects the cloog parameters with the gimple parameters in
the sese region. */
static edge static edge
translate_clast_guard (sese region, loop_p context_loop, translate_clast_guard (loop_p context_loop, struct clast_guard *stmt,
struct clast_guard *stmt, edge next_e, edge next_e, htab_t bb_pbb_mapping, int level,
VEC (tree, heap) **newivs, ivs_params_p ip)
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, stmt, *newivs, edge last_e = graphite_create_new_guard (next_e, stmt, ip);
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);
translate_clast (region, context_loop, stmt->then, true_e, translate_clast (context_loop, stmt->then, true_e, bb_pbb_mapping, level, ip);
newivs, newivs_index, bb_pbb_mapping,
level, params_index);
return last_e; return last_e;
} }
...@@ -1043,11 +971,10 @@ translate_clast_guard (sese region, loop_p context_loop, ...@@ -1043,11 +971,10 @@ translate_clast_guard (sese region, loop_p context_loop,
- NEXT_E is the edge where new generated code should be attached. - NEXT_E is the edge where new generated code should be attached.
- CONTEXT_LOOP is the loop in which the generated code will be placed - CONTEXT_LOOP is the loop in which the generated code will be placed
- BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. */ - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. */
static edge static edge
translate_clast (sese region, loop_p context_loop, struct clast_stmt *stmt, translate_clast (loop_p context_loop, struct clast_stmt *stmt, edge next_e,
edge next_e, VEC (tree, heap) **newivs, htab_t bb_pbb_mapping, int level, ivs_params_p ip)
htab_t newivs_index, htab_t bb_pbb_mapping, int level,
htab_t params_index)
{ {
if (!stmt) if (!stmt)
return next_e; return next_e;
...@@ -1056,36 +983,28 @@ translate_clast (sese region, loop_p context_loop, struct clast_stmt *stmt, ...@@ -1056,36 +983,28 @@ translate_clast (sese region, loop_p context_loop, struct clast_stmt *stmt,
; /* Do nothing. */ ; /* Do nothing. */
else if (CLAST_STMT_IS_A (stmt, stmt_user)) else if (CLAST_STMT_IS_A (stmt, stmt_user))
next_e = translate_clast_user (region, (struct clast_user_stmt *) stmt, next_e = translate_clast_user ((struct clast_user_stmt *) stmt,
next_e, newivs, newivs_index, next_e, bb_pbb_mapping, ip);
bb_pbb_mapping, params_index);
else if (CLAST_STMT_IS_A (stmt, stmt_for)) else if (CLAST_STMT_IS_A (stmt, stmt_for))
next_e = translate_clast_for (region, context_loop, next_e = translate_clast_for (context_loop, (struct clast_for *) stmt,
(struct clast_for *) stmt, next_e, next_e, bb_pbb_mapping, level, ip);
newivs, newivs_index,
bb_pbb_mapping, level, params_index);
else if (CLAST_STMT_IS_A (stmt, stmt_guard)) else if (CLAST_STMT_IS_A (stmt, stmt_guard))
next_e = translate_clast_guard (region, context_loop, next_e = translate_clast_guard (context_loop, (struct clast_guard *) stmt,
(struct clast_guard *) stmt, next_e, next_e, bb_pbb_mapping, level, ip);
newivs, newivs_index,
bb_pbb_mapping, level, params_index);
else 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 (context_loop, ((struct clast_block *) stmt)->body,
((struct clast_block *) stmt)->body, next_e, bb_pbb_mapping, level, ip);
next_e, newivs, newivs_index,
bb_pbb_mapping, level, params_index);
else else
gcc_unreachable(); 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 (context_loop, stmt->next, next_e, bb_pbb_mapping,
newivs, newivs_index, level, ip);
bb_pbb_mapping, level, params_index);
} }
/* Free the SCATTERING domain list. */ /* Free the SCATTERING domain list. */
...@@ -1124,7 +1043,7 @@ initialize_cloog_names (scop_p scop, CloogProgram *prog) ...@@ -1124,7 +1043,7 @@ initialize_cloog_names (scop_p scop, CloogProgram *prog)
for (i = 0; i < nb_parameters; i++) for (i = 0; i < nb_parameters; i++)
{ {
tree param = VEC_index (tree, SESE_PARAMS(region), i); tree param = VEC_index (tree, SESE_PARAMS (region), i);
const char *name = get_name (param); const char *name = get_name (param);
int len; int len;
...@@ -1461,6 +1380,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ...@@ -1461,6 +1380,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
ifsese if_region = NULL; ifsese if_region = NULL;
htab_t newivs_index, params_index; htab_t newivs_index, params_index;
cloog_prog_clast pc; cloog_prog_clast pc;
struct ivs_params ip;
timevar_push (TV_GRAPHITE_CODE_GEN); timevar_push (TV_GRAPHITE_CODE_GEN);
gloog_error = false; gloog_error = false;
...@@ -1493,10 +1413,14 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ...@@ -1493,10 +1413,14 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
create_params_index (params_index, pc.prog); create_params_index (params_index, pc.prog);
translate_clast (region, context_loop, pc.stmt, ip.newivs = &newivs;
if_region->true_region->entry, ip.newivs_index = newivs_index;
&newivs, newivs_index, ip.params = SESE_PARAMS (region);
bb_pbb_mapping, 0, params_index); ip.params_index = params_index;
ip.region = region;
translate_clast (context_loop, pc.stmt, if_region->true_region->entry,
bb_pbb_mapping, 0, &ip);
graphite_verify (); graphite_verify ();
scev_reset (); scev_reset ();
recompute_all_dominators (); recompute_all_dominators ();
......
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