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:
......
...@@ -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