From 429ba7409063a0877d79d76dfa2eff7e44b3b6d9 Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Sat, 6 Feb 2010 17:40:45 +0000 Subject: Cleanup build relation. 2010-01-20 Sebastian Pop * 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 --- gcc/graphite-ppl.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'gcc/graphite-ppl.c') diff --git a/gcc/graphite-ppl.c b/gcc/graphite-ppl.c index b47e24a4ab4..38faebd6beb 100644 --- a/gcc/graphite-ppl.c +++ b/gcc/graphite-ppl.c @@ -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 -- cgit v1.2.1