Commit 7a521ff2 by Tobias Grosser Committed by Tobias Grosser

Do not abuse sese for codegeneration

CLooG automatically frees the names list, so sharing SESE_PARAMS_NAMES
between gloog() and debug_generated_program() leads to freeing them
twice. As both SESE_PARAM_NAMES and SESE_PARAMS_INDEX are code
generation data structures remove them and the functions working on them
from sese.h and put them in clast-to-gimple.

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

	* graphite-clast-to-gimple.c (clast_name_index, new_clast_name_index,
	clast_name_to_index, save_clast_name_index, debug_clast_name_index,
	debug_clast_name_indexes_1, debug_clast_name_indexes,
	clast_name_index_elt_info, eq_clast_name_indexes): Moved from sese.h.
	(clast_name_to_gcc, clast_to_gcc_expression,
	clast_to_gcc_expression_red, gcc_type_for_clast_expr,
	gcc_type_for_clast_eq, graphite_translate_clast_equation,
	graphite_create_guard_cond_expr, graphite_create_new_loop,
	translate_clast): Add params_index.
	(initialize_cloog_names): Create parameter strings from scratch, do
	not reference other strings.
	(create_params_index): New.
	(gloog): Initialize params_index.
	* graphite-scop-detection (free_scops_1): Removed.
	(limit_scops): Use normal free_scops.
	* graphite-sese-to-poly.c (save_var_names): Removed.
	(parameter_index_in_region): Do not initialize SESE_PARAM_NAMES
	and SESE_PARAMS_INDEX.
	* sese.c (new_sese, free_sese): Dito.
	* sese.h (struct sese): Remove params_index, params_names.
	(SESE_PARAMS_INDEX, SESE_PARAMS_NAMES): Removed.

From-SVN: r154844
parent f7ce0951
2009-11-21 Tobias Grosser <grosser@fim.uni-passau.de>
* graphite-clast-to-gimple.c (clast_name_index, new_clast_name_index,
clast_name_to_index, save_clast_name_index, debug_clast_name_index,
debug_clast_name_indexes_1, debug_clast_name_indexes,
clast_name_index_elt_info, eq_clast_name_indexes): Moved from sese.h.
(clast_name_to_gcc, clast_to_gcc_expression,
clast_to_gcc_expression_red, gcc_type_for_clast_expr,
gcc_type_for_clast_eq, graphite_translate_clast_equation,
graphite_create_guard_cond_expr, graphite_create_new_loop,
translate_clast): Add params_index.
(initialize_cloog_names): Create parameter strings from scratch, do
not reference other strings.
(create_params_index): New.
(gloog): Initialize params_index.
* graphite-scop-detection (free_scops_1): Removed.
(limit_scops): Use normal free_scops.
* graphite-sese-to-poly.c (save_var_names): Removed.
(parameter_index_in_region): Do not initialize SESE_PARAM_NAMES
and SESE_PARAMS_INDEX.
* sese.c (new_sese, free_sese): Dito.
* sese.h (struct sese): Remove params_index, params_names.
(SESE_PARAMS_INDEX, SESE_PARAMS_NAMES): Removed.
2009-11-20 Sebastian Pop <sebastian.pop@amd.com> 2009-11-20 Sebastian Pop <sebastian.pop@amd.com>
Revert the following patch from 2009-09-14: Revert the following patch from 2009-09-14:
......
...@@ -66,6 +66,106 @@ graphite_verify (void) ...@@ -66,6 +66,106 @@ graphite_verify (void)
#endif #endif
} }
/* Stores the INDEX in a vector for a given clast NAME. */
typedef struct clast_name_index {
int index;
const char *name;
} *clast_name_index_p;
/* Returns a pointer to a new element of type clast_name_index_p built
from NAME and INDEX. */
static inline clast_name_index_p
new_clast_name_index (const char *name, int index)
{
clast_name_index_p res = XNEW (struct clast_name_index);
res->name = name;
res->index = index;
return res;
}
/* For a given clast NAME, returns -1 if it does not correspond to any
parameter, or otherwise, returns the index in the PARAMS or
SCATTERING_DIMENSIONS vector. */
static inline int
clast_name_to_index (const char *name, htab_t index_table)
{
struct clast_name_index tmp;
PTR *slot;
tmp.name = name;
slot = htab_find_slot (index_table, &tmp, NO_INSERT);
if (slot && *slot)
return ((struct clast_name_index *) *slot)->index;
return -1;
}
/* Records in INDEX_TABLE the INDEX for NAME. */
static inline void
save_clast_name_index (htab_t index_table, const char *name, int index)
{
struct clast_name_index tmp;
PTR *slot;
tmp.name = name;
slot = htab_find_slot (index_table, &tmp, INSERT);
if (slot)
*slot = new_clast_name_index (name, index);
}
/* Print to stderr the element ELT. */
static inline void
debug_clast_name_index (clast_name_index_p elt)
{
fprintf (stderr, "(index = %d, name = %s)\n", elt->index, elt->name);
}
/* Helper function for debug_rename_map. */
static inline int
debug_clast_name_indexes_1 (void **slot, void *s ATTRIBUTE_UNUSED)
{
struct clast_name_index *entry = (struct clast_name_index *) *slot;
debug_clast_name_index (entry);
return 1;
}
/* Print to stderr all the elements of MAP. */
void
debug_clast_name_indexes (htab_t map)
{
htab_traverse (map, debug_clast_name_indexes_1, NULL);
}
/* Computes a hash function for database element ELT. */
static inline hashval_t
clast_name_index_elt_info (const void *elt)
{
return htab_hash_pointer (((const struct clast_name_index *) elt)->name);
}
/* Compares database elements E1 and E2. */
static inline int
eq_clast_name_indexes (const void *e1, const void *e2)
{
const struct clast_name_index *elt1 = (const struct clast_name_index *) e1;
const struct clast_name_index *elt2 = (const struct clast_name_index *) e2;
return (elt1->name == elt2->name);
}
/* For a given loop DEPTH in the loop nest of the original black box /* For a given loop DEPTH in the loop nest of the original black box
PBB, return the old induction variable associated to that loop. */ PBB, return the old induction variable associated to that loop. */
...@@ -95,11 +195,10 @@ newivs_to_depth_to_newiv (VEC (tree, heap) *newivs, int depth) ...@@ -95,11 +195,10 @@ newivs_to_depth_to_newiv (VEC (tree, heap) *newivs, int depth)
static tree static tree
clast_name_to_gcc (const char *name, sese region, VEC (tree, heap) *newivs, clast_name_to_gcc (const char *name, sese region, VEC (tree, heap) *newivs,
htab_t newivs_index) htab_t newivs_index, htab_t params_index)
{ {
int index; int index;
VEC (tree, heap) *params = SESE_PARAMS (region); VEC (tree, heap) *params = SESE_PARAMS (region);
htab_t params_index = SESE_PARAMS_INDEX (region);
if (params && params_index) if (params && params_index)
{ {
...@@ -128,7 +227,7 @@ max_precision_type (tree e1, tree e2) ...@@ -128,7 +227,7 @@ max_precision_type (tree e1, tree e2)
static tree static tree
clast_to_gcc_expression (tree, struct clast_expr *, sese, VEC (tree, heap) *, clast_to_gcc_expression (tree, struct clast_expr *, sese, VEC (tree, heap) *,
htab_t); 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. */
...@@ -137,17 +236,17 @@ static tree ...@@ -137,17 +236,17 @@ 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,
sese region, VEC (tree, heap) *newivs, sese region, VEC (tree, heap) *newivs,
htab_t newivs_index) 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], region, newivs,
newivs_index); 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], region,
newivs, newivs_index); newivs, newivs_index, params_index);
res = fold_build2 (op, type, res, t); res = fold_build2 (op, type, res, t);
} }
...@@ -160,7 +259,7 @@ clast_to_gcc_expression_red (tree type, enum tree_code op, ...@@ -160,7 +259,7 @@ clast_to_gcc_expression_red (tree type, enum tree_code op,
static tree static tree
clast_to_gcc_expression (tree type, struct clast_expr *e, clast_to_gcc_expression (tree type, struct clast_expr *e,
sese region, VEC (tree, heap) *newivs, sese region, VEC (tree, heap) *newivs,
htab_t newivs_index) htab_t newivs_index, htab_t params_index)
{ {
switch (e->type) switch (e->type)
{ {
...@@ -173,21 +272,21 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ...@@ -173,21 +272,21 @@ clast_to_gcc_expression (tree type, struct clast_expr *e,
if (value_one_p (t->val)) if (value_one_p (t->val))
{ {
tree name = clast_name_to_gcc (t->var, region, newivs, tree name = clast_name_to_gcc (t->var, region, newivs,
newivs_index); newivs_index, params_index);
return fold_convert (type, name); return fold_convert (type, name);
} }
else if (value_mone_p (t->val)) else if (value_mone_p (t->val))
{ {
tree name = clast_name_to_gcc (t->var, region, newivs, tree name = clast_name_to_gcc (t->var, region, newivs,
newivs_index); newivs_index, params_index);
name = fold_convert (type, name); name = fold_convert (type, name);
return fold_build1 (NEGATE_EXPR, type, name); return fold_build1 (NEGATE_EXPR, type, name);
} }
else else
{ {
tree name = clast_name_to_gcc (t->var, region, newivs, tree name = clast_name_to_gcc (t->var, region, newivs,
newivs_index); newivs_index, params_index);
tree cst = gmp_cst_to_tree (type, t->val); tree cst = gmp_cst_to_tree (type, t->val);
name = fold_convert (type, name); name = fold_convert (type, name);
return fold_build2 (MULT_EXPR, type, cst, name); return fold_build2 (MULT_EXPR, type, cst, name);
...@@ -206,15 +305,17 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ...@@ -206,15 +305,17 @@ 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); r, region, newivs, newivs_index, params_index);
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, region,
newivs, newivs_index); 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, region,
newivs, newivs_index); newivs, newivs_index,
params_index);
default: default:
gcc_unreachable (); gcc_unreachable ();
...@@ -227,7 +328,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ...@@ -227,7 +328,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, region, newivs,
newivs_index); 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)
...@@ -261,7 +362,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ...@@ -261,7 +362,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e,
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, sese region, VEC (tree, heap) *newivs,
htab_t newivs_index) htab_t newivs_index, htab_t params_index)
{ {
switch (e->type) switch (e->type)
{ {
...@@ -271,7 +372,7 @@ gcc_type_for_clast_expr (struct clast_expr *e, ...@@ -271,7 +372,7 @@ gcc_type_for_clast_expr (struct clast_expr *e,
if (t->var) if (t->var)
return TREE_TYPE (clast_name_to_gcc (t->var, region, newivs, return TREE_TYPE (clast_name_to_gcc (t->var, region, newivs,
newivs_index)); newivs_index, params_index));
else else
return NULL_TREE; return NULL_TREE;
} }
...@@ -282,14 +383,15 @@ gcc_type_for_clast_expr (struct clast_expr *e, ...@@ -282,14 +383,15 @@ gcc_type_for_clast_expr (struct clast_expr *e,
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], region, newivs,
newivs_index); newivs_index, params_index);
else else
{ {
int i; int i;
for (i = 0; i < r->n; i++) for (i = 0; i < r->n; i++)
{ {
tree type = gcc_type_for_clast_expr (r->elts[i], region, tree type = gcc_type_for_clast_expr (r->elts[i], region,
newivs, newivs_index); newivs, newivs_index,
params_index);
if (type) if (type)
return type; return type;
} }
...@@ -302,7 +404,7 @@ gcc_type_for_clast_expr (struct clast_expr *e, ...@@ -302,7 +404,7 @@ gcc_type_for_clast_expr (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;
return gcc_type_for_clast_expr (lhs, region, newivs, return gcc_type_for_clast_expr (lhs, region, newivs,
newivs_index); newivs_index, params_index);
} }
default: default:
...@@ -317,14 +419,15 @@ gcc_type_for_clast_expr (struct clast_expr *e, ...@@ -317,14 +419,15 @@ 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, sese region, VEC (tree, heap) *newivs,
htab_t newivs_index) htab_t newivs_index, htab_t params_index)
{ {
tree type = gcc_type_for_clast_expr (cleq->LHS, region, newivs, tree type = gcc_type_for_clast_expr (cleq->LHS, region, newivs,
newivs_index); newivs_index, params_index);
if (type) if (type)
return type; return type;
return gcc_type_for_clast_expr (cleq->RHS, region, newivs, newivs_index); return gcc_type_for_clast_expr (cleq->RHS, region, newivs, newivs_index,
params_index);
} }
/* Translates a clast equation CLEQ to a tree. */ /* Translates a clast equation CLEQ to a tree. */
...@@ -333,14 +436,15 @@ static tree ...@@ -333,14 +436,15 @@ static tree
graphite_translate_clast_equation (sese region, graphite_translate_clast_equation (sese region,
struct clast_equation *cleq, struct clast_equation *cleq,
VEC (tree, heap) *newivs, VEC (tree, heap) *newivs,
htab_t newivs_index) 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, region, newivs, newivs_index,
params_index);
tree lhs = clast_to_gcc_expression (type, cleq->LHS, region, newivs, tree lhs = clast_to_gcc_expression (type, cleq->LHS, region, newivs,
newivs_index); newivs_index, params_index);
tree rhs = clast_to_gcc_expression (type, cleq->RHS, region, newivs, tree rhs = clast_to_gcc_expression (type, cleq->RHS, region, newivs,
newivs_index); newivs_index, params_index);
if (cleq->sign == 0) if (cleq->sign == 0)
comp = EQ_EXPR; comp = EQ_EXPR;
...@@ -359,7 +463,7 @@ graphite_translate_clast_equation (sese region, ...@@ -359,7 +463,7 @@ graphite_translate_clast_equation (sese region,
static tree static tree
graphite_create_guard_cond_expr (sese region, struct clast_guard *stmt, graphite_create_guard_cond_expr (sese region, struct clast_guard *stmt,
VEC (tree, heap) *newivs, VEC (tree, heap) *newivs,
htab_t newivs_index) htab_t newivs_index, htab_t params_index)
{ {
tree cond = NULL; tree cond = NULL;
int i; int i;
...@@ -367,7 +471,8 @@ graphite_create_guard_cond_expr (sese region, struct clast_guard *stmt, ...@@ -367,7 +471,8 @@ graphite_create_guard_cond_expr (sese region, struct clast_guard *stmt,
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 (region, &stmt->eq[i],
newivs, newivs_index); 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);
...@@ -384,10 +489,10 @@ static edge ...@@ -384,10 +489,10 @@ static edge
graphite_create_new_guard (sese region, edge entry_edge, graphite_create_new_guard (sese region, edge entry_edge,
struct clast_guard *stmt, struct clast_guard *stmt,
VEC (tree, heap) *newivs, VEC (tree, heap) *newivs,
htab_t newivs_index) 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 (region, stmt, newivs,
newivs_index); 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;
} }
...@@ -460,13 +565,13 @@ static struct loop * ...@@ -460,13 +565,13 @@ static struct loop *
graphite_create_new_loop (sese region, edge entry_edge, graphite_create_new_loop (sese region, edge entry_edge,
struct clast_for *stmt, struct clast_for *stmt,
loop_p outer, VEC (tree, heap) **newivs, loop_p outer, VEC (tree, heap) **newivs,
htab_t newivs_index) htab_t newivs_index, htab_t params_index)
{ {
tree type = gcc_type_for_iv_of_clast_loop (stmt); tree type = gcc_type_for_iv_of_clast_loop (stmt);
tree lb = clast_to_gcc_expression (type, stmt->LB, region, *newivs, tree lb = clast_to_gcc_expression (type, stmt->LB, region, *newivs,
newivs_index); newivs_index, params_index);
tree ub = clast_to_gcc_expression (type, stmt->UB, region, *newivs, tree ub = clast_to_gcc_expression (type, stmt->UB, region, *newivs,
newivs_index); newivs_index, params_index);
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");
tree iv, iv_after_increment; tree iv, iv_after_increment;
...@@ -488,7 +593,8 @@ graphite_create_new_loop (sese region, edge entry_edge, ...@@ -488,7 +593,8 @@ graphite_create_new_loop (sese region, edge entry_edge,
static void static void
build_iv_mapping (htab_t map, sese region, build_iv_mapping (htab_t map, sese region,
VEC (tree, heap) *newivs, htab_t newivs_index, VEC (tree, heap) *newivs, htab_t newivs_index,
struct clast_user_stmt *user_stmt) struct clast_user_stmt *user_stmt,
htab_t params_index)
{ {
struct clast_stmt *t; struct clast_stmt *t;
int index = 0; int index = 0;
...@@ -500,10 +606,10 @@ build_iv_mapping (htab_t map, sese region, ...@@ -500,10 +606,10 @@ build_iv_mapping (htab_t 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, region, newivs,
newivs_index); newivs_index, params_index);
tree old_name = pbb_to_depth_to_oldiv (pbb, index); tree old_name = pbb_to_depth_to_oldiv (pbb, index);
tree e = clast_to_gcc_expression (type, expr, region, newivs, tree e = clast_to_gcc_expression (type, expr, region, newivs,
newivs_index); newivs_index, params_index);
set_rename (map, old_name, e); set_rename (map, old_name, e);
} }
} }
...@@ -626,7 +732,8 @@ static edge ...@@ -626,7 +732,8 @@ static edge
translate_clast (sese region, struct loop *context_loop, translate_clast (sese region, struct loop *context_loop,
struct clast_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, int level,
htab_t params_index)
{ {
if (!stmt) if (!stmt)
return next_e; return next_e;
...@@ -634,7 +741,7 @@ translate_clast (sese region, struct loop *context_loop, ...@@ -634,7 +741,7 @@ translate_clast (sese region, struct loop *context_loop,
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, return translate_clast (region, context_loop, stmt->next, next_e,
rename_map, newivs, newivs_index, rename_map, newivs, newivs_index,
bb_pbb_mapping, level); bb_pbb_mapping, level, params_index);
if (CLAST_STMT_IS_A (stmt, stmt_user)) if (CLAST_STMT_IS_A (stmt, stmt_user))
{ {
...@@ -648,7 +755,7 @@ translate_clast (sese region, struct loop *context_loop, ...@@ -648,7 +755,7 @@ translate_clast (sese region, struct loop *context_loop,
return next_e; return next_e;
build_iv_mapping (rename_map, region, *newivs, newivs_index, build_iv_mapping (rename_map, region, *newivs, newivs_index,
(struct clast_user_stmt *) stmt); (struct clast_user_stmt *) stmt, 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;
...@@ -658,7 +765,7 @@ translate_clast (sese region, struct loop *context_loop, ...@@ -658,7 +765,7 @@ translate_clast (sese region, struct loop *context_loop,
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); bb_pbb_mapping, level, params_index);
} }
if (CLAST_STMT_IS_A (stmt, stmt_for)) if (CLAST_STMT_IS_A (stmt, stmt_for))
...@@ -666,7 +773,8 @@ translate_clast (sese region, struct loop *context_loop, ...@@ -666,7 +773,8 @@ translate_clast (sese region, struct loop *context_loop,
struct clast_for *stmtfor = (struct clast_for *)stmt; struct clast_for *stmtfor = (struct clast_for *)stmt;
struct loop *loop struct loop *loop
= graphite_create_new_loop (region, next_e, stmtfor, = graphite_create_new_loop (region, next_e, stmtfor,
context_loop, newivs, newivs_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;
...@@ -678,7 +786,7 @@ translate_clast (sese region, struct loop *context_loop, ...@@ -678,7 +786,7 @@ translate_clast (sese region, struct loop *context_loop,
next_e = translate_clast next_e = translate_clast
(region, loop, ((struct clast_for *) stmt)->body, (region, loop, ((struct clast_for *) stmt)->body,
single_succ_edge (loop->header), rename_map, newivs, single_succ_edge (loop->header), rename_map, newivs,
newivs_index, bb_pbb_mapping, level + 1); 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);
...@@ -695,14 +803,15 @@ translate_clast (sese region, struct loop *context_loop, ...@@ -695,14 +803,15 @@ translate_clast (sese region, struct loop *context_loop,
graphite_verify (); graphite_verify ();
return translate_clast (region, context_loop, stmt->next, last_e, return translate_clast (region, context_loop, stmt->next, last_e,
rename_map, newivs, newivs_index, rename_map, newivs, newivs_index,
bb_pbb_mapping, level); bb_pbb_mapping, level, params_index);
} }
if (CLAST_STMT_IS_A (stmt, stmt_guard)) if (CLAST_STMT_IS_A (stmt, stmt_guard))
{ {
edge last_e = graphite_create_new_guard (region, next_e, edge last_e = graphite_create_new_guard (region, next_e,
((struct clast_guard *) stmt), ((struct clast_guard *) stmt),
*newivs, newivs_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);
...@@ -714,7 +823,7 @@ translate_clast (sese region, struct loop *context_loop, ...@@ -714,7 +823,7 @@ translate_clast (sese region, struct loop *context_loop,
next_e = translate_clast (region, context_loop, next_e = translate_clast (region, context_loop,
((struct clast_guard *) stmt)->then, ((struct clast_guard *) stmt)->then,
true_e, rename_map, newivs, newivs_index, true_e, rename_map, newivs, newivs_index,
bb_pbb_mapping, level); bb_pbb_mapping, 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);
...@@ -724,7 +833,7 @@ translate_clast (sese region, struct loop *context_loop, ...@@ -724,7 +833,7 @@ translate_clast (sese region, struct loop *context_loop,
return translate_clast (region, context_loop, stmt->next, last_e, return translate_clast (region, context_loop, stmt->next, last_e,
rename_map, newivs, newivs_index, rename_map, newivs, newivs_index,
bb_pbb_mapping, level); bb_pbb_mapping, level, params_index);
} }
if (CLAST_STMT_IS_A (stmt, stmt_block)) if (CLAST_STMT_IS_A (stmt, stmt_block))
...@@ -732,12 +841,12 @@ translate_clast (sese region, struct loop *context_loop, ...@@ -732,12 +841,12 @@ translate_clast (sese region, struct loop *context_loop,
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); bb_pbb_mapping, level, params_index);
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); bb_pbb_mapping, level, params_index);
} }
gcc_unreachable (); gcc_unreachable ();
...@@ -890,14 +999,30 @@ initialize_cloog_names (scop_p scop, CloogProgram *prog) ...@@ -890,14 +999,30 @@ initialize_cloog_names (scop_p scop, CloogProgram *prog)
int i; int i;
int nb_iterators = scop_max_loop_depth (scop); int nb_iterators = scop_max_loop_depth (scop);
int nb_scattering = cloog_program_nb_scattdims (prog); int nb_scattering = cloog_program_nb_scattdims (prog);
int nb_parameters = VEC_length (tree, SESE_PARAMS (region));
char **iterators = XNEWVEC (char *, nb_iterators * 2); char **iterators = XNEWVEC (char *, nb_iterators * 2);
char **scattering = XNEWVEC (char *, nb_scattering); char **scattering = XNEWVEC (char *, nb_scattering);
char **parameters= XNEWVEC (char *, nb_parameters);
cloog_program_set_names (prog, cloog_names_malloc ()); cloog_program_set_names (prog, cloog_names_malloc ());
cloog_names_set_nb_parameters (cloog_program_names (prog),
VEC_length (tree, SESE_PARAMS (region))); for (i = 0; i < nb_parameters; i++)
cloog_names_set_parameters (cloog_program_names (prog), {
SESE_PARAMS_NAMES (region)); tree param = VEC_index (tree, SESE_PARAMS(region), i);
const char *name = get_name (param);
int len;
if (!name)
name = "T";
len = strlen (name);
len += 17;
parameters[i] = XNEWVEC (char, len + 1);
snprintf (parameters[i], len, "%s_%d", name, SSA_NAME_VERSION (param));
}
cloog_names_set_nb_parameters (cloog_program_names (prog), nb_parameters);
cloog_names_set_parameters (cloog_program_names (prog), parameters);
for (i = 0; i < nb_iterators; i++) for (i = 0; i < nb_iterators; i++)
{ {
...@@ -1144,6 +1269,20 @@ debug_generated_program (scop_p scop) ...@@ -1144,6 +1269,20 @@ debug_generated_program (scop_p scop)
print_generated_program (stderr, scop); print_generated_program (stderr, scop);
} }
/* Add CLooG names to parameter index. The index is used to translate back from
* CLooG names to GCC trees. */
static void
create_params_index (htab_t index_table, CloogProgram *prog) {
CloogNames* names = cloog_program_names (prog);
int nb_parameters = cloog_names_nb_parameters (names);
char **parameters = cloog_names_parameters (names);
int i;
for (i = 0; i < nb_parameters; i++)
save_clast_name_index (index_table, parameters[i], i);
}
/* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for /* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for
the given SCOP. Return true if code generation succeeded. the given SCOP. Return true if code generation succeeded.
BB_PBB_MAPPING is a basic_block and it's related poly_bb_p mapping. BB_PBB_MAPPING is a basic_block and it's related poly_bb_p mapping.
...@@ -1157,7 +1296,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ...@@ -1157,7 +1296,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
loop_p context_loop; loop_p context_loop;
sese region = SCOP_REGION (scop); sese region = SCOP_REGION (scop);
ifsese if_region = NULL; ifsese if_region = NULL;
htab_t rename_map, newivs_index; htab_t rename_map, newivs_index, params_index;
cloog_prog_clast pc; cloog_prog_clast pc;
timevar_push (TV_GRAPHITE_CODE_GEN); timevar_push (TV_GRAPHITE_CODE_GEN);
...@@ -1179,20 +1318,23 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ...@@ -1179,20 +1318,23 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
if_region->region->exit->src, if_region->region->exit->src,
if_region->false_region->exit, if_region->false_region->exit,
if_region->true_region->exit); if_region->true_region->exit);
recompute_all_dominators (); recompute_all_dominators ();
graphite_verify (); graphite_verify ();
context_loop = SESE_ENTRY (region)->src->loop_father; context_loop = SESE_ENTRY (region)->src->loop_father;
compute_cloog_iv_types (pc.stmt); compute_cloog_iv_types (pc.stmt);
rename_map = htab_create (10, rename_map_elt_info, eq_rename_map_elts, free); rename_map = htab_create (10, rename_map_elt_info, eq_rename_map_elts, free);
newivs_index = htab_create (10, clast_name_index_elt_info, newivs_index = htab_create (10, clast_name_index_elt_info,
eq_clast_name_indexes, free); eq_clast_name_indexes, free);
params_index = htab_create (10, clast_name_index_elt_info,
eq_clast_name_indexes, free);
create_params_index (params_index, pc.prog);
new_scop_exit_edge = translate_clast (region, context_loop, pc.stmt, new_scop_exit_edge = translate_clast (region, context_loop, pc.stmt,
if_region->true_region->entry, if_region->true_region->entry,
rename_map, &newivs, newivs_index, rename_map, &newivs, newivs_index,
bb_pbb_mapping, 1); bb_pbb_mapping, 1, params_index);
graphite_verify (); graphite_verify ();
sese_adjust_liveout_phis (region, rename_map, sese_adjust_liveout_phis (region, rename_map,
if_region->region->exit->src, if_region->region->exit->src,
...@@ -1207,6 +1349,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ...@@ -1207,6 +1349,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
htab_delete (rename_map); htab_delete (rename_map);
htab_delete (newivs_index); htab_delete (newivs_index);
htab_delete (params_index);
VEC_free (tree, heap, newivs); VEC_free (tree, heap, newivs);
cloog_clast_free (pc.stmt); cloog_clast_free (pc.stmt);
cloog_program_free (pc.prog); cloog_program_free (pc.prog);
......
...@@ -1207,24 +1207,6 @@ print_graphite_statistics (FILE* file, VEC (scop_p, heap) *scops) ...@@ -1207,24 +1207,6 @@ print_graphite_statistics (FILE* file, VEC (scop_p, heap) *scops)
print_graphite_scop_statistics (file, scop); print_graphite_scop_statistics (file, scop);
} }
/* Version of free_scops special cased for limit_scops. */
static void
free_scops_1 (VEC (scop_p, heap) **scops)
{
int i;
scop_p scop;
for (i = 0; VEC_iterate (scop_p, *scops, i, scop); i++)
{
sese region = SCOP_REGION (scop);
free (SESE_PARAMS_NAMES (region));
SESE_PARAMS_NAMES (region) = 0;
}
free_scops (*scops);
}
/* We limit all SCoPs to SCoPs, that are completely surrounded by a loop. /* We limit all SCoPs to SCoPs, that are completely surrounded by a loop.
Example: Example:
...@@ -1278,7 +1260,7 @@ limit_scops (VEC (scop_p, heap) **scops) ...@@ -1278,7 +1260,7 @@ limit_scops (VEC (scop_p, heap) **scops)
} }
} }
free_scops_1 (scops); free_scops (*scops);
*scops = VEC_alloc (scop_p, heap, 3); *scops = VEC_alloc (scop_p, heap, 3);
create_sese_edges (regions); create_sese_edges (regions);
......
...@@ -746,26 +746,6 @@ scan_tree_for_params_int (tree cst, ppl_Linear_Expression_t expr, Value k) ...@@ -746,26 +746,6 @@ scan_tree_for_params_int (tree cst, ppl_Linear_Expression_t expr, Value k)
ppl_delete_Coefficient (coef); ppl_delete_Coefficient (coef);
} }
/* Saves in NV at index I a new name for variable P. */
static void
save_var_name (char **nv, int i, tree p)
{
const char *name = get_name (SSA_NAME_VAR (p));
if (name)
{
int len = strlen (name) + 16;
nv[i] = XNEWVEC (char, len);
snprintf (nv[i], len, "%s_%d", name, SSA_NAME_VERSION (p));
}
else
{
nv[i] = XNEWVEC (char, 16);
snprintf (nv[i], 2 + 16, "T_%d", SSA_NAME_VERSION (p));
}
}
/* When parameter NAME is in REGION, returns its index in SESE_PARAMS. /* When parameter NAME is in REGION, returns its index in SESE_PARAMS.
Otherwise returns -1. */ Otherwise returns -1. */
...@@ -802,9 +782,6 @@ parameter_index_in_region (tree name, sese region) ...@@ -802,9 +782,6 @@ parameter_index_in_region (tree name, sese region)
gcc_assert (SESE_ADD_PARAMS (region)); gcc_assert (SESE_ADD_PARAMS (region));
i = VEC_length (tree, SESE_PARAMS (region)); i = VEC_length (tree, SESE_PARAMS (region));
save_var_name (SESE_PARAMS_NAMES (region), i, name);
save_clast_name_index (SESE_PARAMS_INDEX (region),
SESE_PARAMS_NAMES (region)[i], i);
VEC_safe_push (tree, heap, SESE_PARAMS (region), name); VEC_safe_push (tree, heap, SESE_PARAMS (region), name);
return i; return i;
} }
......
...@@ -332,9 +332,6 @@ new_sese (edge entry, edge exit) ...@@ -332,9 +332,6 @@ new_sese (edge entry, edge exit)
SESE_LOOP_NEST (region) = VEC_alloc (loop_p, heap, 3); SESE_LOOP_NEST (region) = VEC_alloc (loop_p, heap, 3);
SESE_ADD_PARAMS (region) = true; SESE_ADD_PARAMS (region) = true;
SESE_PARAMS (region) = VEC_alloc (tree, heap, 3); SESE_PARAMS (region) = VEC_alloc (tree, heap, 3);
SESE_PARAMS_INDEX (region) = htab_create (10, clast_name_index_elt_info,
eq_clast_name_indexes, free);
SESE_PARAMS_NAMES (region) = XNEWVEC (char *, num_ssa_names);
return region; return region;
} }
...@@ -350,11 +347,6 @@ free_sese (sese region) ...@@ -350,11 +347,6 @@ free_sese (sese region)
VEC_free (tree, heap, SESE_PARAMS (region)); VEC_free (tree, heap, SESE_PARAMS (region));
VEC_free (loop_p, heap, SESE_LOOP_NEST (region)); VEC_free (loop_p, heap, SESE_LOOP_NEST (region));
if (SESE_PARAMS_INDEX (region))
htab_delete (SESE_PARAMS_INDEX (region));
/* Do not free SESE_PARAMS_NAMES: CLooG does that. */
XDELETE (region); XDELETE (region);
} }
......
...@@ -32,12 +32,6 @@ typedef struct sese_s ...@@ -32,12 +32,6 @@ typedef struct sese_s
/* Parameters used within the SCOP. */ /* Parameters used within the SCOP. */
VEC (tree, heap) *params; VEC (tree, heap) *params;
/* Used to quickly retrieve the index of a parameter in PARAMS. */
htab_t params_index;
/* Store the names of the parameters that are passed to CLooG. */
char **params_names;
/* Loops completely contained in the SCOP. */ /* Loops completely contained in the SCOP. */
bitmap loops; bitmap loops;
VEC (loop_p, heap) *loop_nest; VEC (loop_p, heap) *loop_nest;
...@@ -53,8 +47,6 @@ typedef struct sese_s ...@@ -53,8 +47,6 @@ typedef struct sese_s
#define SESE_EXIT(S) (S->exit) #define SESE_EXIT(S) (S->exit)
#define SESE_EXIT_BB(S) (S->exit->dest) #define SESE_EXIT_BB(S) (S->exit->dest)
#define SESE_PARAMS(S) (S->params) #define SESE_PARAMS(S) (S->params)
#define SESE_PARAMS_INDEX(S) (S->params_index)
#define SESE_PARAMS_NAMES(S) (S->params_names)
#define SESE_LOOPS(S) (S->loops) #define SESE_LOOPS(S) (S->loops)
#define SESE_LOOP_NEST(S) (S->loop_nest) #define SESE_LOOP_NEST(S) (S->loop_nest)
#define SESE_ADD_PARAMS(S) (S->add_params) #define SESE_ADD_PARAMS(S) (S->add_params)
...@@ -222,105 +214,6 @@ block_before_sese (sese sese) ...@@ -222,105 +214,6 @@ block_before_sese (sese sese)
return SESE_ENTRY (sese)->src; return SESE_ENTRY (sese)->src;
} }
/* Stores the INDEX in a vector for a given clast NAME. */
typedef struct clast_name_index {
int index;
const char *name;
} *clast_name_index_p;
/* Returns a pointer to a new element of type clast_name_index_p built
from NAME and INDEX. */
static inline clast_name_index_p
new_clast_name_index (const char *name, int index)
{
clast_name_index_p res = XNEW (struct clast_name_index);
res->name = name;
res->index = index;
return res;
}
/* For a given clast NAME, returns -1 if it does not correspond to any
parameter, or otherwise, returns the index in the PARAMS or
SCATTERING_DIMENSIONS vector. */
static inline int
clast_name_to_index (const char *name, htab_t index_table)
{
struct clast_name_index tmp;
PTR *slot;
tmp.name = name;
slot = htab_find_slot (index_table, &tmp, NO_INSERT);
if (slot && *slot)
return ((struct clast_name_index *) *slot)->index;
return -1;
}
/* Records in INDEX_TABLE the INDEX for NAME. */
static inline void
save_clast_name_index (htab_t index_table, const char *name, int index)
{
struct clast_name_index tmp;
PTR *slot;
tmp.name = name;
slot = htab_find_slot (index_table, &tmp, INSERT);
if (slot)
*slot = new_clast_name_index (name, index);
}
/* Print to stderr the element ELT. */
static inline void
debug_clast_name_index (clast_name_index_p elt)
{
fprintf (stderr, "(index = %d, name = %s)\n", elt->index, elt->name);
}
/* Helper function for debug_rename_map. */
static inline int
debug_clast_name_indexes_1 (void **slot, void *s ATTRIBUTE_UNUSED)
{
struct clast_name_index *entry = (struct clast_name_index *) *slot;
debug_clast_name_index (entry);
return 1;
}
/* Print to stderr all the elements of MAP. */
static inline void
debug_clast_name_indexes (htab_t map)
{
htab_traverse (map, debug_clast_name_indexes_1, NULL);
}
/* Computes a hash function for database element ELT. */
static inline hashval_t
clast_name_index_elt_info (const void *elt)
{
return htab_hash_pointer (((const struct clast_name_index *) elt)->name);
}
/* Compares database elements E1 and E2. */
static inline int
eq_clast_name_indexes (const void *e1, const void *e2)
{
const struct clast_name_index *elt1 = (const struct clast_name_index *) e1;
const struct clast_name_index *elt2 = (const struct clast_name_index *) e2;
return (elt1->name == elt2->name);
}
/* A single entry single exit specialized for conditions. */ /* A single entry single exit specialized for conditions. */
......
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