Cleanup build relation.

2010-01-20  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-dependences.c (build_pairwise_constraint): Renamed
	ppl_build_relation.  Moved...
	(dr_equality_constraints): Use ppl_build_relation.
	(build_pairwise_scheduling_equality): Same.
	(build_pairwise_scheduling_inequality): Same.
	* graphite-ppl.c (ppl_build_relation): ...here.
	* graphite-ppl.h (ppl_build_relation): Declared.

From-SVN: r156541
This commit is contained in:
Sebastian Pop 2010-02-06 17:40:45 +00:00 committed by Sebastian Pop
parent 26bda00088
commit 429ba74090
4 changed files with 66 additions and 78 deletions

View File

@ -1,3 +1,13 @@
2010-01-20 Sebastian Pop <sebastian.pop@amd.com>
* graphite-dependences.c (build_pairwise_constraint): Renamed
ppl_build_relation. Moved...
(dr_equality_constraints): Use ppl_build_relation.
(build_pairwise_scheduling_equality): Same.
(build_pairwise_scheduling_inequality): Same.
* graphite-ppl.c (ppl_build_relation): ...here.
* graphite-ppl.h (ppl_build_relation): Declared.
2010-01-14 Sebastian Pop <sebastian.pop@amd.com>
PR middle-end/42681

View File

@ -190,93 +190,29 @@ map_dr_into_dep_poly (graphite_dim_t dim,
return res;
}
/* Builds a constraints of the form "POS1 - POS2 CSTR_TYPE C" */
static ppl_Constraint_t
build_pairwise_constraint (graphite_dim_t dim,
graphite_dim_t pos1, graphite_dim_t pos2,
int c, enum ppl_enum_Constraint_Type cstr_type)
{
ppl_Linear_Expression_t expr;
ppl_Constraint_t cstr;
ppl_Coefficient_t coef;
Value v, v_op, v_c;
value_init (v);
value_init (v_op);
value_init (v_c);
value_set_si (v, 1);
value_set_si (v_op, -1);
value_set_si (v_c, c);
ppl_new_Coefficient (&coef);
ppl_new_Linear_Expression_with_dimension (&expr, dim);
ppl_assign_Coefficient_from_mpz_t (coef, v);
ppl_Linear_Expression_add_to_coefficient (expr, pos1, coef);
ppl_assign_Coefficient_from_mpz_t (coef, v_op);
ppl_Linear_Expression_add_to_coefficient (expr, pos2, coef);
ppl_assign_Coefficient_from_mpz_t (coef, v_c);
ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
ppl_new_Constraint (&cstr, expr, cstr_type);
ppl_delete_Linear_Expression (expr);
ppl_delete_Coefficient (coef);
value_clear (v);
value_clear (v_op);
value_clear (v_c);
return cstr;
}
/* Builds subscript equality constraints. */
static ppl_Pointset_Powerset_C_Polyhedron_t
dr_equality_constraints (graphite_dim_t dim,
graphite_dim_t pos, graphite_dim_t nb_subscripts)
{
ppl_Polyhedron_t subscript_equalities;
ppl_Polyhedron_t eqs;
ppl_Pointset_Powerset_C_Polyhedron_t res;
Value v, v_op;
graphite_dim_t i;
value_init (v);
value_init (v_op);
value_set_si (v, 1);
value_set_si (v_op, -1);
ppl_new_C_Polyhedron_from_space_dimension (&eqs, dim, 0);
ppl_new_C_Polyhedron_from_space_dimension (&subscript_equalities, dim, 0);
for (i = 0; i < nb_subscripts; i++)
{
ppl_Linear_Expression_t expr;
ppl_Constraint_t cstr;
ppl_Coefficient_t coef;
ppl_new_Coefficient (&coef);
ppl_new_Linear_Expression_with_dimension (&expr, dim);
ppl_assign_Coefficient_from_mpz_t (coef, v);
ppl_Linear_Expression_add_to_coefficient (expr, pos + i, coef);
ppl_assign_Coefficient_from_mpz_t (coef, v_op);
ppl_Linear_Expression_add_to_coefficient (expr, pos + i + nb_subscripts,
coef);
ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
ppl_Polyhedron_add_constraint (subscript_equalities, cstr);
ppl_delete_Linear_Expression (expr);
ppl_Constraint_t cstr
= ppl_build_relation (dim, pos + i, pos + i + nb_subscripts,
0, PPL_CONSTRAINT_TYPE_EQUAL);
ppl_Polyhedron_add_constraint (eqs, cstr);
ppl_delete_Constraint (cstr);
ppl_delete_Coefficient (coef);
}
ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
(&res, subscript_equalities);
value_clear (v);
value_clear (v_op);
ppl_delete_Polyhedron (subscript_equalities);
ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&res, eqs);
ppl_delete_Polyhedron (eqs);
return res;
}
@ -292,8 +228,8 @@ build_pairwise_scheduling_equality (graphite_dim_t dim,
ppl_new_C_Polyhedron_from_space_dimension (&equalities, dim, 0);
cstr = build_pairwise_constraint (dim, pos, pos + offset, 0,
PPL_CONSTRAINT_TYPE_EQUAL);
cstr = ppl_build_relation (dim, pos, pos + offset, 0,
PPL_CONSTRAINT_TYPE_EQUAL);
ppl_Polyhedron_add_constraint (equalities, cstr);
ppl_delete_Constraint (cstr);
@ -317,11 +253,11 @@ build_pairwise_scheduling_inequality (graphite_dim_t dim,
ppl_new_C_Polyhedron_from_space_dimension (&equalities, dim, 0);
if (direction)
cstr = build_pairwise_constraint (dim, pos, pos + offset, -1,
PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
cstr = ppl_build_relation (dim, pos, pos + offset, -1,
PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
else
cstr = build_pairwise_constraint (dim, pos, pos + offset, 1,
PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
cstr = ppl_build_relation (dim, pos, pos + offset, 1,
PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
ppl_Polyhedron_add_constraint (equalities, cstr);
ppl_delete_Constraint (cstr);

View File

@ -700,5 +700,45 @@ ppl_min_for_le_polyhedron (ppl_Polyhedron_t pol,
ppl_delete_Coefficient (denom);
}
/* Builds a constraint in dimension DIM relating dimensions POS1 to
POS2 as "POS1 - POS2 CSTR_TYPE C" */
ppl_Constraint_t
ppl_build_relation (int dim, int pos1, int pos2, int c,
enum ppl_enum_Constraint_Type cstr_type)
{
ppl_Linear_Expression_t expr;
ppl_Constraint_t cstr;
ppl_Coefficient_t coef;
Value v, v_op, v_c;
value_init (v);
value_init (v_op);
value_init (v_c);
value_set_si (v, 1);
value_set_si (v_op, -1);
value_set_si (v_c, c);
ppl_new_Coefficient (&coef);
ppl_new_Linear_Expression_with_dimension (&expr, dim);
ppl_assign_Coefficient_from_mpz_t (coef, v);
ppl_Linear_Expression_add_to_coefficient (expr, pos1, coef);
ppl_assign_Coefficient_from_mpz_t (coef, v_op);
ppl_Linear_Expression_add_to_coefficient (expr, pos2, coef);
ppl_assign_Coefficient_from_mpz_t (coef, v_c);
ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
ppl_new_Constraint (&cstr, expr, cstr_type);
ppl_delete_Linear_Expression (expr);
ppl_delete_Coefficient (coef);
value_clear (v);
value_clear (v_op);
value_clear (v_c);
return cstr;
}
#endif

View File

@ -50,6 +50,8 @@ void ppl_max_for_le_pointset (ppl_Pointset_Powerset_C_Polyhedron_t,
ppl_Linear_Expression_t, Value);
void ppl_min_for_le_polyhedron (ppl_Polyhedron_t, ppl_Linear_Expression_t,
Value);
ppl_Constraint_t ppl_build_relation (int, int, int, int,
enum ppl_enum_Constraint_Type);
/* Assigns to RES the value of the INTEGER_CST T. */