@@ -886,6 +886,9 @@ new_poly_bb (scop_p scop, void *black_box)
PBB_DOMAIN (pbb) = NULL;
pbb->domain = NULL;
+ pbb->schedule = NULL;
+ pbb->transformed = NULL;
+ pbb->saved = NULL;
PBB_SCOP (pbb) = scop;
pbb_set_black_box (pbb, black_box);
PBB_TRANSFORMED (pbb) = NULL;
@@ -911,6 +914,9 @@ free_poly_bb (poly_bb_p pbb)
ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
isl_set_free (pbb->domain);
+ isl_map_free (pbb->schedule);
+ isl_map_free (pbb->transformed);
+ isl_map_free (pbb->saved);
if (PBB_TRANSFORMED (pbb))
poly_scattering_free (PBB_TRANSFORMED (pbb));
@@ -407,6 +407,16 @@ build_scop_bbs (scop_p scop)
sbitmap_free (visited);
}
+/* Return an ISL identifier for the polyhedral basic block PBB. */
+
+static isl_id *
+isl_id_for_pbb (scop_p s, poly_bb_p pbb)
+{
+ char name[50];
+ snprintf (name, sizeof (name), "S_%d", pbb_index (pbb));
+ return isl_id_alloc (s->ctx, name, pbb);
+}
+
/* Converts the STATIC_SCHEDULE of PBB into a scattering polyhedron.
We generate SCATTERING_DIMENSIONS scattering dimensions.
@@ -441,7 +451,8 @@ build_scop_bbs (scop_p scop)
| 0 0 1 0 0 0 0 0 -5 = 0 */
static void
-build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
+build_pbb_scattering_polyhedrons (isl_aff *static_sched,
+ ppl_Linear_Expression_t static_schedule,
poly_bb_p pbb, int scattering_dimensions)
{
int i;
@@ -452,9 +463,11 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
ppl_Coefficient_t c;
ppl_dimension_type dim = scattering_dimensions + nb_iterators + nb_params;
mpz_t v;
+ isl_int val;
gcc_assert (scattering_dimensions >= used_scattering_dimensions);
+ isl_int_init (val);
mpz_init (v);
ppl_new_Coefficient (&c);
PBB_TRANSFORMED (pbb) = poly_scattering_new ();
@@ -463,6 +476,15 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
PBB_NB_SCATTERING_TRANSFORM (pbb) = scattering_dimensions;
+ {
+ isl_dim *dc = isl_set_get_dim (scop->context);
+ isl_dim *dm = isl_dim_add (isl_dim_from_domain (dc),
+ isl_dim_out, scattering_dimensions);
+ pbb->schedule = isl_map_universe (dm);
+ pbb->schedule = isl_map_set_tuple_id (pbb->schedule, isl_dim_out,
+ isl_id_for_pbb (scop, pbb));
+ }
+
for (i = 0; i < scattering_dimensions; i++)
{
ppl_Constraint_t cstr;
@@ -481,6 +503,20 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
mpz_neg (v, v);
ppl_assign_Coefficient_from_mpz_t (c, v);
ppl_Linear_Expression_add_to_inhomogeneous (expr, c);
+
+ {
+ isl_constraint *c = isl_equality_alloc
+ (isl_map_get_dim (pbb->schedule));
+
+ if (0 != isl_aff_get_coefficient (static_sched, isl_dim_set,
+ i / 2, &val))
+ gcc_unreachable ();
+
+ isl_int_neg (val, val);
+ c = isl_constraint_set_constant (c, val);
+ c = isl_constraint_set_coefficient_si (c, isl_dim_out, i, 1);
+ pbb->schedule = isl_map_add_constraint (pbb->schedule, c);
+ }
}
/* Iterations of this loop. */
@@ -492,6 +528,9 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
ppl_assign_Coefficient_from_mpz_t (c, v);
ppl_Linear_Expression_add_to_coefficient
(expr, scattering_dimensions + loop, c);
+
+ pbb->schedule = isl_map_equate (pbb->schedule, isl_dim_in, loop,
+ isl_dim_out, i);
}
ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
@@ -500,10 +539,12 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
ppl_delete_Constraint (cstr);
}
+ isl_int_clear (val);
mpz_clear (v);
ppl_delete_Coefficient (c);
PBB_ORIGINAL (pbb) = poly_scattering_copy (PBB_TRANSFORMED (pbb));
+ pbb->transformed = isl_map_copy (pbb->schedule);
}
/* Build for BB the static schedule.
@@ -551,6 +592,8 @@ build_scop_scattering (scop_p scop)
ppl_Linear_Expression_t static_schedule;
ppl_Coefficient_t c;
mpz_t v;
+ isl_dim *dc = isl_set_get_dim (scop->context);
+ isl_aff *static_sched = isl_aff_zero (isl_local_space_from_dim (dc));
mpz_init (v);
ppl_new_Coefficient (&c);
@@ -564,6 +607,8 @@ build_scop_scattering (scop_p scop)
ppl_assign_Coefficient_from_mpz_t (c, v);
ppl_Linear_Expression_add_to_coefficient (static_schedule, 0, c);
+ static_sched = isl_aff_add_coefficient_si (static_sched, isl_dim_set, 0, -1);
+
FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
{
gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
@@ -587,11 +632,14 @@ build_scop_scattering (scop_p scop)
ppl_assign_Linear_Expression_from_Linear_Expression (static_schedule,
common);
- build_pbb_scattering_polyhedrons (common, pbb, nb_scat_dims);
-
+ static_sched = isl_aff_add_coefficient_si (static_sched, isl_dim_set,
+ prefix, 1);
+ build_pbb_scattering_polyhedrons (static_sched, common, pbb,
+ nb_scat_dims);
ppl_delete_Linear_Expression (common);
}
+ isl_aff_free (static_sched);
mpz_clear (v);
ppl_delete_Coefficient (c);
ppl_delete_Linear_Expression (static_schedule);