On Thu, Aug 11, 2011 at 01:16:45PM -0500, Sebastian Pop wrote: > + if (1) > + { > + /* For now remove the isl_id's from the context before > + translating to CLooG: this code will be removed when the > + domain will also contain isl_id's. */ > + isl_set *context = isl_set_project_out (isl_set_copy (scop->context), > + isl_dim_set, 0, number_of_loops > ()); > + isl_printer *p = isl_printer_to_str (scop->ctx); > + char *str; > + > + p = isl_printer_set_output_format (p, ISL_FORMAT_EXT_POLYLIB); > + p = isl_printer_print_set (p, context); > + isl_set_free (context); > + > + str = isl_printer_get_str (p); > + context = isl_set_read_from_str (scop->ctx, str, > + scop_nb_params (scop)); > + free (str); > + isl_printer_free (p);
Hmm.... are you saying you would like a isl_set_reset_dim_id? > @@ -415,4 +416,40 @@ openscop_read_polyhedron_matrix (FILE *file, > ppl_Polyhedron_t *ph, > } > } > > +/* Prints an isl_set S to stderr. */ > + > +DEBUG_FUNCTION void > +debug_isl_set (isl_set *s) You could use isl_set_dump. It's not documented because I don't want people to depend on the output, but for debugging it should be just fine. > @@ -1040,6 +1041,9 @@ free_scop (scop_p scop) > if (SCOP_CONTEXT (scop)) > ppl_delete_Pointset_Powerset_C_Polyhedron (SCOP_CONTEXT (scop)); > > + if (scop->context) > + isl_set_free (scop->context); > + isl_set_free will handle NULL input just fine. > +static isl_pw_aff * > +extract_affine_chrec (scop_p s, tree e) > +{ > + isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e)); > + isl_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e)); > + isl_dim *dim = isl_dim_set_alloc (s->ctx, 0, number_of_loops ()); > + isl_local_space *ls = isl_local_space_from_dim (dim); > + isl_aff *loop = isl_aff_set_coefficient_si > + (isl_aff_zero (ls), isl_dim_set, CHREC_VARIABLE (e), 1); > + > + return isl_pw_aff_add (lhs, > + isl_pw_aff_mul (rhs, isl_pw_aff_from_aff (loop))); You should test that at least one of your arguments is constant. Alternatively, if you want to construct polynomials, you should use isl_pw_qpolynomials instead. > + isl_set *inner = isl_set_copy (outer); > + isl_dim *d = isl_set_get_dim (scop->context); > + isl_id *id = isl_id_for_loop (scop, loop); > + int pos = isl_dim_find_dim_by_id (d, isl_dim_set, id); This is dangerous. You cannot depend on non-parameters keeping their ids across operations. Don't you already know the position somehow? When you are using PPL, you must keep track of this information, no? > + > + /* FIXME: This function will be renamed isl_map_insert_dims and > + documented in a later version of ISL (current ISL is 0.07). */ Since you are using isl_ids, 0.07 won't work for you. > + /* Make the dimension of LB and UB to be exactly NBS. */ > + lb = isl_pw_aff_drop_dims (lb, isl_dim_set, 0, nbl - 1); > + ub = isl_pw_aff_drop_dims (ub, isl_dim_set, 0, nbl - 1); > + lb = isl_pw_aff_add_dims (lb, isl_dim_set, nbs - 1); > + ub = isl_pw_aff_add_dims (ub, isl_dim_set, nbs - 1); This looks fishy. Are you sure the expressions don't depend on the set variables? > + { > + isl_dim *dc = isl_set_get_dim (scop->context); > + int nb_in = isl_dim_size (dc, isl_dim_set); > + int nb_out = 1 + DR_NUM_DIMENSIONS (dr); > + int nbp = scop_nb_params (scop); > + isl_dim *dim = isl_dim_alloc (scop->ctx, nbp, nb_in, nb_out); > + int i; > + > + for (i = 0; i < nbp; i++) > + dim = isl_dim_set_dim_id (dim, isl_dim_param, i, > + isl_dim_get_dim_id (dc, isl_dim_param, i)); > + for (i = 0; i < nb_in; i++) > + dim = isl_dim_set_dim_id (dim, isl_dim_in, i, > + isl_dim_get_dim_id (dc, isl_dim_set, i)); This is dangerous too. Why don't you derive dim directly from dc instead of creating a fresh dim and then trying to copy some information? skimo