diff options
Diffstat (limited to 'isl_output.c')
-rw-r--r-- | isl_output.c | 506 |
1 files changed, 395 insertions, 111 deletions
diff --git a/isl_output.c b/isl_output.c index 8ebe10ef..a0a57877 100644 --- a/isl_output.c +++ b/isl_output.c @@ -30,6 +30,7 @@ #include <isl_val_private.h> #include <isl/ast_build.h> #include <isl_sort.h> +#include <isl_output_private.h> static const char *s_to[2] = { " -> ", " \\to " }; static const char *s_and[2] = { " and ", " \\wedge " }; @@ -174,7 +175,10 @@ static int count_same_name(__isl_keep isl_space *dim, return count; } -static __isl_give isl_printer *print_name(__isl_keep isl_space *dim, +/* Print the name of the variable of type "type" and position "pos" + * in "space" to "p". + */ +static __isl_give isl_printer *print_name(__isl_keep isl_space *space, __isl_take isl_printer *p, enum isl_dim_type type, unsigned pos, int latex) { @@ -182,7 +186,8 @@ static __isl_give isl_printer *print_name(__isl_keep isl_space *dim, char buffer[20]; int primes; - name = type == isl_dim_div ? NULL : isl_space_get_dim_name(dim, type, pos); + name = type == isl_dim_div ? NULL + : isl_space_get_dim_name(space, type, pos); if (!name) { const char *prefix; @@ -190,14 +195,14 @@ static __isl_give isl_printer *print_name(__isl_keep isl_space *dim, prefix = s_param_prefix[latex]; else if (type == isl_dim_div) prefix = s_div_prefix[latex]; - else if (isl_space_is_set(dim) || type == isl_dim_in) + else if (isl_space_is_set(space) || type == isl_dim_in) prefix = s_input_prefix[latex]; else prefix = s_output_prefix[latex]; snprintf(buffer, sizeof(buffer), "%s%d", prefix, pos); name = buffer; } - primes = count_same_name(dim, name == buffer ? isl_dim_div : type, + primes = count_same_name(space, name == buffer ? isl_dim_div : type, pos, name); p = isl_printer_print_str(p, name); while (primes-- > 0) @@ -229,10 +234,27 @@ static enum isl_dim_type pos2type(__isl_keep isl_space *dim, unsigned *pos) return type; } +/* Can the div expression of the integer division at position "row" of "div" + * be printed? + * In particular, are the div expressions available and does the selected + * variable have a known explicit representation? + * Furthermore, the Omega format does not allow and div expressions + * to be printed. + */ +static isl_bool can_print_div_expr(__isl_keep isl_printer *p, + __isl_keep isl_mat *div, int pos) +{ + if (p->output_format == ISL_FORMAT_OMEGA) + return isl_bool_false; + if (!div) + return isl_bool_false; + return !isl_int_is_zero(div->row[pos][0]); +} + static __isl_give isl_printer *print_div(__isl_keep isl_space *dim, __isl_keep isl_mat *div, int pos, __isl_take isl_printer *p); -static __isl_give isl_printer *print_term(__isl_keep isl_space *dim, +static __isl_give isl_printer *print_term(__isl_keep isl_space *space, __isl_keep isl_mat *div, isl_int c, unsigned pos, __isl_take isl_printer *p, int latex) { @@ -242,9 +264,8 @@ static __isl_give isl_printer *print_term(__isl_keep isl_space *dim, if (pos == 0) return isl_printer_print_isl_int(p, c); - type = pos2type(dim, &pos); - print_div_def = type == isl_dim_div && div && - !isl_int_is_zero(div->row[pos][0]); + type = pos2type(space, &pos); + print_div_def = type == isl_dim_div && can_print_div_expr(p, div, pos); if (isl_int_is_one(c)) ; @@ -256,9 +277,9 @@ static __isl_give isl_printer *print_term(__isl_keep isl_space *dim, p = isl_printer_print_str(p, "*"); } if (print_div_def) - p = print_div(dim, div, pos, p); + p = print_div(space, div, pos, p); else - p = print_name(dim, p, type, pos, latex); + p = print_name(space, p, type, pos, latex); return p; } @@ -291,34 +312,18 @@ static __isl_give isl_printer *print_affine_of_len(__isl_keep isl_space *dim, return p; } +/* Print an affine expression "c" corresponding to a constraint in "bmap" + * to "p", with the variable names taken from "space" and + * the integer division definitions taken from "div". + */ static __isl_give isl_printer *print_affine(__isl_keep isl_basic_map *bmap, - __isl_keep isl_space *dim, __isl_take isl_printer *p, isl_int *c) + __isl_keep isl_space *space, __isl_keep isl_mat *div, + __isl_take isl_printer *p, isl_int *c) { unsigned len = 1 + isl_basic_map_total_dim(bmap); - return print_affine_of_len(dim, NULL, p, c, len); + return print_affine_of_len(space, div, p, c, len); } -/* Internal data structure for print_space. - * - * latex is set if that is the output format. - * print_dim (if not NULL) is called on each dimension. - * user is set by the caller of print_space and may be used inside print_dim. - * - * space is the global space that is being printed. This field is set by - * print_space. - * type is the tuple of the global space that is currently being printed. - * This field is set by print_space. - */ -struct isl_print_space_data { - int latex; - __isl_give isl_printer *(*print_dim)(__isl_take isl_printer *p, - struct isl_print_space_data *data, unsigned pos); - void *user; - - isl_space *space; - enum isl_dim_type type; -}; - /* offset is the offset of local_dim inside data->type of data->space. */ static __isl_give isl_printer *print_nested_var_list(__isl_take isl_printer *p, @@ -407,20 +412,20 @@ static __isl_give isl_printer *print_nested_map_dim(__isl_take isl_printer *p, return p; } -static __isl_give isl_printer *print_space(__isl_keep isl_space *dim, +__isl_give isl_printer *isl_print_space(__isl_keep isl_space *space, __isl_take isl_printer *p, int rational, struct isl_print_space_data *data) { if (rational && !data->latex) p = isl_printer_print_str(p, "rat: "); - if (isl_space_is_params(dim)) + if (isl_space_is_params(space)) ; - else if (isl_space_is_set(dim)) - p = print_tuple(dim, p, isl_dim_set, data); + else if (isl_space_is_set(space)) + p = print_tuple(space, p, isl_dim_set, data); else { - p = print_tuple(dim, p, isl_dim_in, data); + p = print_tuple(space, p, isl_dim_in, data); p = isl_printer_print_str(p, s_to[data->latex]); - p = print_tuple(dim, p, isl_dim_out, data); + p = print_tuple(space, p, isl_dim_out, data); } return p; @@ -440,8 +445,91 @@ static __isl_give isl_printer *print_omega_parameters(__isl_keep isl_space *dim, return p; } +/* Does the inequality constraint following "i" in "bmap" + * have an opposite value for the same last coefficient? + * "last" is the position of the last coefficient of inequality "i". + * If the next constraint is a div constraint, then it is ignored + * since div constraints are not printed. + */ +static int next_is_opposite(__isl_keep isl_basic_map *bmap, int i, int last) +{ + unsigned total = isl_basic_map_total_dim(bmap); + unsigned o_div = isl_basic_map_offset(bmap, isl_dim_div); + + if (i + 1 >= bmap->n_ineq) + return 0; + if (isl_seq_last_non_zero(bmap->ineq[i + 1], 1 + total) != last) + return 0; + if (last >= o_div && + isl_basic_map_is_div_constraint(bmap, bmap->ineq[i + 1], + last - o_div)) + return 0; + return isl_int_abs_eq(bmap->ineq[i][last], bmap->ineq[i + 1][last]) && + !isl_int_eq(bmap->ineq[i][last], bmap->ineq[i + 1][last]); +} + +/* Return a string representation of the operator used when + * printing a constraint where the LHS is greater than or equal to the LHS + * (sign > 0) or smaller than or equal to the LHS (sign < 0). + * If "strict" is set, then return the strict version of the comparison + * operator. + */ +static const char *constraint_op(int sign, int strict, int latex) +{ + if (strict) + return sign < 0 ? "<" : ">"; + if (sign < 0) + return s_le[latex]; + else + return s_ge[latex]; +} + +/* Print one side of a constraint "c" from "bmap" to "p", with + * the variable names taken from "space" and the integer division definitions + * taken from "div". + * "last" is the position of the last non-zero coefficient. + * Let c' be the result of zeroing out this coefficient, then + * the partial constraint + * + * c' op + * + * is printed. + * "first_constraint" is set if this is the first constraint + * in the conjunction. + */ +static __isl_give isl_printer *print_half_constraint(struct isl_basic_map *bmap, + __isl_keep isl_space *space, __isl_keep isl_mat *div, + __isl_take isl_printer *p, isl_int *c, int last, const char *op, + int first_constraint, int latex) +{ + if (!first_constraint) + p = isl_printer_print_str(p, s_and[latex]); + + isl_int_set_si(c[last], 0); + p = print_affine(bmap, space, div, p, c); + + p = isl_printer_print_str(p, " "); + p = isl_printer_print_str(p, op); + p = isl_printer_print_str(p, " "); + + return p; +} + +/* Print a constraint "c" from "bmap" to "p", with the variable names + * taken from "space" and the integer division definitions taken from "div". + * "last" is the position of the last non-zero coefficient, which is + * moreover assumed to be negative. + * Let c' be the result of zeroing out this coefficient, then + * the constraint is printed in the form + * + * -c[last] op c' + * + * "first_constraint" is set if this is the first constraint + * in the conjunction. + */ static __isl_give isl_printer *print_constraint(struct isl_basic_map *bmap, - __isl_keep isl_space *dim, __isl_take isl_printer *p, + __isl_keep isl_space *space, __isl_keep isl_mat *div, + __isl_take isl_printer *p, isl_int *c, int last, const char *op, int first_constraint, int latex) { if (!first_constraint) @@ -449,24 +537,74 @@ static __isl_give isl_printer *print_constraint(struct isl_basic_map *bmap, isl_int_abs(c[last], c[last]); - p = print_term(dim, NULL, c[last], last, p, latex); + p = print_term(space, div, c[last], last, p, latex); p = isl_printer_print_str(p, " "); p = isl_printer_print_str(p, op); p = isl_printer_print_str(p, " "); isl_int_set_si(c[last], 0); - p = print_affine(bmap, dim, p, c); + p = print_affine(bmap, space, div, p, c); return p; } +/* Print the constraints of "bmap" to "p". + * The names of the variables are taken from "space" and + * the integer division definitions are taken from "div". + * Div constraints are only printed in "dump" mode. + * The constraints are sorted prior to printing (except in "dump" mode). + * + * If x is the last variable with a non-zero coefficient, + * then a lower bound + * + * f - a x >= 0 + * + * is printed as + * + * a x <= f + * + * while an upper bound + * + * f + a x >= 0 + * + * is printed as + * + * a x >= -f + * + * If the next constraint has an opposite sign for the same last coefficient, + * then it is printed as + * + * f >= a x + * + * or + * + * -f <= a x + * + * instead. In fact, the "a x" part is not printed explicitly, but + * reused from the next constraint, which is therefore treated as + * a first constraint in the conjunction. + * + * If the constant term of "f" is -1, then "f" is replaced by "f + 1" and + * the comparison operator is replaced by the strict variant. + * Essentially, ">= 1" is replaced by "> 0". + */ static __isl_give isl_printer *print_constraints(__isl_keep isl_basic_map *bmap, - __isl_keep isl_space *dim, __isl_take isl_printer *p, int latex) + __isl_keep isl_space *space, __isl_keep isl_mat *div, + __isl_take isl_printer *p, int latex) { int i; - struct isl_vec *c; + isl_vec *c = NULL; + int rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL); unsigned total = isl_basic_map_total_dim(bmap); + unsigned o_div = isl_basic_map_offset(bmap, isl_dim_div); + int first = 1; + + bmap = isl_basic_map_copy(bmap); + if (!p->dump) + bmap = isl_basic_map_sort_constraints(bmap); + if (!bmap) + goto error; c = isl_vec_alloc(bmap->ctx, 1 + total); if (!c) @@ -484,29 +622,48 @@ static __isl_give isl_printer *print_constraints(__isl_keep isl_basic_map *bmap, isl_seq_cpy(c->el, bmap->eq[i], 1 + total); else isl_seq_neg(c->el, bmap->eq[i], 1 + total); - p = print_constraint(bmap, dim, p, c->el, l, - "=", i == bmap->n_eq - 1, latex); + p = print_constraint(bmap, space, div, p, c->el, l, + "=", first, latex); + first = 0; } for (i = 0; i < bmap->n_ineq; ++i) { int l = isl_seq_last_non_zero(bmap->ineq[i], 1 + total); + int strict; int s; const char *op; if (l < 0) continue; + if (!p->dump && l >= o_div && + isl_basic_map_is_div_constraint(bmap, bmap->ineq[i], + l - o_div)) + continue; s = isl_int_sgn(bmap->ineq[i][l]); + strict = !rational && isl_int_is_negone(bmap->ineq[i][0]); if (s < 0) isl_seq_cpy(c->el, bmap->ineq[i], 1 + total); else isl_seq_neg(c->el, bmap->ineq[i], 1 + total); - op = s < 0 ? s_le[latex] : s_ge[latex]; - p = print_constraint(bmap, dim, p, c->el, l, - op, !bmap->n_eq && !i, latex); + if (strict) + isl_int_set_si(c->el[0], 0); + if (!p->dump && next_is_opposite(bmap, i, l)) { + op = constraint_op(-s, strict, latex); + p = print_half_constraint(bmap, space, div, p, c->el, l, + op, first, latex); + first = 1; + } else { + op = constraint_op(s, strict, latex); + p = print_constraint(bmap, space, div, p, c->el, l, + op, first, latex); + first = 0; + } } + isl_basic_map_free(bmap); isl_vec_free(c); return p; error: + isl_basic_map_free(bmap); isl_vec_free(c); isl_printer_free(p); return NULL; @@ -515,7 +672,12 @@ error: static __isl_give isl_printer *print_div(__isl_keep isl_space *dim, __isl_keep isl_mat *div, int pos, __isl_take isl_printer *p) { - int c = p->output_format == ISL_FORMAT_C; + int c; + + if (!p || !div) + return isl_printer_free(p); + + c = p->output_format == ISL_FORMAT_C; p = isl_printer_print_str(p, c ? "floord(" : "floor(("); p = print_affine_of_len(dim, div, p, div->row[pos] + 1, div->n_col - 1); @@ -525,13 +687,17 @@ static __isl_give isl_printer *print_div(__isl_keep isl_space *dim, return p; } -/* Print a comma separated list of div names, with their definitions - * (provided that they have a definition and we are printing in isl format). +/* Print a comma separated list of div names, except those that have + * a definition that can be printed. + * If "print_defined_divs" is set, then those div names are printed + * as well, along with their definitions. */ static __isl_give isl_printer *print_div_list(__isl_take isl_printer *p, - __isl_keep isl_space *space, __isl_keep isl_mat *div, int latex) + __isl_keep isl_space *space, __isl_keep isl_mat *div, int latex, + int print_defined_divs) { int i; + int first = 1; unsigned n_div; if (!p || !space || !div) @@ -540,11 +706,13 @@ static __isl_give isl_printer *print_div_list(__isl_take isl_printer *p, n_div = isl_mat_rows(div); for (i = 0; i < n_div; ++i) { - if (i) + if (!print_defined_divs && can_print_div_expr(p, div, i)) + continue; + if (!first) p = isl_printer_print_str(p, ", "); p = print_name(space, p, isl_dim_div, i, latex); - if (p->output_format != ISL_FORMAT_ISL || - isl_int_is_zero(div->row[i][0])) + first = 0; + if (!can_print_div_expr(p, div, i)) continue; p = isl_printer_print_str(p, " = "); p = print_div(space, div, i, p); @@ -553,25 +721,52 @@ static __isl_give isl_printer *print_div_list(__isl_take isl_printer *p, return p; } +/* Does printing "bmap" require an "exists" clause? + * That is, are there any local variables without an explicit representation? + */ +static isl_bool need_exists(__isl_keep isl_printer *p, + __isl_keep isl_basic_map *bmap, __isl_keep isl_mat *div) +{ + int i; + + if (!p || !bmap) + return isl_bool_error; + if (bmap->n_div == 0) + return isl_bool_false; + for (i = 0; i < bmap->n_div; ++i) + if (!can_print_div_expr(p, div, i)) + return isl_bool_true; + return isl_bool_false; +} + +/* Print the constraints of "bmap" to "p". + * The names of the variables are taken from "space". + * "latex" is set if the constraints should be printed in LaTeX format. + * Do not print inline explicit div representations in "dump" mode. + */ static __isl_give isl_printer *print_disjunct(__isl_keep isl_basic_map *bmap, - __isl_keep isl_space *dim, __isl_take isl_printer *p, int latex) + __isl_keep isl_space *space, __isl_take isl_printer *p, int latex) { - if (bmap->n_div > 0) { - isl_space *space; - isl_mat *div; + isl_mat *div; + isl_bool exists; - space = isl_basic_map_get_space(bmap); - div = isl_basic_map_get_divs(bmap); + div = isl_basic_map_get_divs(bmap); + if (p->dump) + exists = bmap->n_div > 0; + else + exists = need_exists(p, bmap, div); + if (exists >= 0 && exists) { p = isl_printer_print_str(p, s_open_exists[latex]); - p = print_div_list(p, space, div, latex); - isl_space_free(space); - isl_mat_free(div); + p = print_div_list(p, space, div, latex, p->dump); p = isl_printer_print_str(p, ": "); } - p = print_constraints(bmap, dim, p, latex); + if (p->dump) + div = isl_mat_free(div); + p = print_constraints(bmap, space, div, p, latex); + isl_mat_free(div); - if (bmap->n_div > 0) + if (exists >= 0 && exists) p = isl_printer_print_str(p, s_close_exists[latex]); return p; } @@ -656,22 +851,22 @@ static __isl_give isl_printer *isl_basic_map_print_isl( p = isl_printer_print_str(p, " -> "); } p = isl_printer_print_str(p, "{ "); - p = print_space(bmap->dim, p, rational, &data); + p = isl_print_space(bmap->dim, p, rational, &data); p = isl_printer_print_str(p, " : "); p = print_disjunct(bmap, bmap->dim, p, latex); p = isl_printer_print_str(p, " }"); return p; } -static __isl_give isl_printer *print_disjuncts(__isl_keep isl_map *map, - __isl_take isl_printer *p, int latex) +/* Print the disjuncts of a map (or set) "map" to "p". + * The names of the variables are taken from "space". + * "latex" is set if the constraints should be printed in LaTeX format. + */ +static __isl_give isl_printer *print_disjuncts_core(__isl_keep isl_map *map, + __isl_keep isl_space *space, __isl_take isl_printer *p, int latex) { int i; - if (isl_map_plain_is_universe(map)) - return p; - - p = isl_printer_print_str(p, s_such_that[latex]); if (map->n == 0) p = isl_printer_print_str(p, "1 = 0"); for (i = 0; i < map->n; ++i) { @@ -679,25 +874,96 @@ static __isl_give isl_printer *print_disjuncts(__isl_keep isl_map *map, p = isl_printer_print_str(p, s_or[latex]); if (map->n > 1 && map->p[i]->n_eq + map->p[i]->n_ineq > 1) p = isl_printer_print_str(p, "("); - p = print_disjunct(map->p[i], map->dim, p, latex); + p = print_disjunct(map->p[i], space, p, latex); if (map->n > 1 && map->p[i]->n_eq + map->p[i]->n_ineq > 1) p = isl_printer_print_str(p, ")"); } return p; } +/* Print the disjuncts of a map (or set) "map" to "p". + * The names of the variables are taken from "space". + * "hull" describes constraints shared by all disjuncts of "map". + * "latex" is set if the constraints should be printed in LaTeX format. + * + * Print the disjuncts as a conjunction of "hull" and + * the result of removing the constraints of "hull" from "map". + * If this result turns out to be the universe, then simply print "hull". + */ +static __isl_give isl_printer *print_disjuncts_in_hull(__isl_keep isl_map *map, + __isl_keep isl_space *space, __isl_take isl_basic_map *hull, + __isl_take isl_printer *p, int latex) +{ + isl_bool is_universe; + + p = print_disjunct(hull, space, p, latex); + map = isl_map_plain_gist_basic_map(isl_map_copy(map), hull); + is_universe = isl_map_plain_is_universe(map); + if (is_universe < 0) + goto error; + if (!is_universe) { + p = isl_printer_print_str(p, s_and[latex]); + p = isl_printer_print_str(p, "("); + p = print_disjuncts_core(map, space, p, latex); + p = isl_printer_print_str(p, ")"); + } + isl_map_free(map); + + return p; +error: + isl_map_free(map); + isl_printer_free(p); + return NULL; +} + +/* Print the disjuncts of a map (or set) "map" to "p". + * The names of the variables are taken from "space". + * "latex" is set if the constraints should be printed in LaTeX format. + * + * If there are at least two disjuncts and "dump" mode is not turned out, + * check for any shared constraints among all disjuncts. + * If there are any, then print them separately in print_disjuncts_in_hull. + */ +static __isl_give isl_printer *print_disjuncts(__isl_keep isl_map *map, + __isl_keep isl_space *space, __isl_take isl_printer *p, int latex) +{ + if (isl_map_plain_is_universe(map)) + return p; + + p = isl_printer_print_str(p, s_such_that[latex]); + + if (!p->dump && map->n >= 2) { + isl_basic_map *hull; + isl_bool is_universe; + + hull = isl_map_plain_unshifted_simple_hull(isl_map_copy(map)); + is_universe = isl_basic_map_is_universe(hull); + if (is_universe < 0) + p = isl_printer_free(p); + else if (!is_universe) + return print_disjuncts_in_hull(map, space, hull, + p, latex); + isl_basic_map_free(hull); + } + + return print_disjuncts_core(map, space, p, latex); +} + /* Print the disjuncts of a map (or set). + * The names of the variables are taken from "space". + * "latex" is set if the constraints should be printed in LaTeX format. + * * If the map turns out to be a universal parameter domain, then * we need to print the colon. Otherwise, the output looks identical * to the empty set. */ static __isl_give isl_printer *print_disjuncts_map(__isl_keep isl_map *map, - __isl_take isl_printer *p, int latex) + __isl_keep isl_space *space, __isl_take isl_printer *p, int latex) { if (isl_map_plain_is_universe(map) && isl_space_is_params(map->dim)) return isl_printer_print_str(p, s_such_that[latex]); else - return print_disjuncts(map, p, latex); + return print_disjuncts(map, space, p, latex); } struct isl_aff_split { @@ -888,7 +1154,7 @@ static __isl_give isl_printer *print_dim_eq(__isl_take isl_printer *p, } static __isl_give isl_printer *print_split_map(__isl_take isl_printer *p, - struct isl_aff_split *split, int n) + struct isl_aff_split *split, int n, __isl_keep isl_space *space) { struct isl_print_space_data data = { 0 }; int i; @@ -896,18 +1162,15 @@ static __isl_give isl_printer *print_split_map(__isl_take isl_printer *p, data.print_dim = &print_dim_eq; for (i = 0; i < n; ++i) { - isl_space *dim; - if (!split[i].map) break; - dim = split[i].map->dim; rational = split[i].map->n > 0 && ISL_F_ISSET(split[i].map->p[0], ISL_BASIC_MAP_RATIONAL); if (i) p = isl_printer_print_str(p, "; "); data.user = split[i].aff; - p = print_space(dim, p, rational, &data); - p = print_disjuncts_map(split[i].map, p, 0); + p = isl_print_space(space, p, rational, &data); + p = print_disjuncts_map(split[i].map, space, p, 0); } return p; @@ -920,15 +1183,15 @@ static __isl_give isl_printer *isl_map_print_isl_body(__isl_keep isl_map *map, struct isl_aff_split *split = NULL; int rational; - if (map->n > 0) + if (!p->dump && map->n > 0) split = split_aff(map); if (split) { - p = print_split_map(p, split, map->n); + p = print_split_map(p, split, map->n, map->dim); } else { rational = map->n > 0 && ISL_F_ISSET(map->p[0], ISL_BASIC_MAP_RATIONAL); - p = print_space(map->dim, p, rational, &data); - p = print_disjuncts_map(map, p, 0); + p = isl_print_space(map->dim, p, rational, &data); + p = print_disjuncts_map(map, map->dim, p, 0); } free_split(split, map->n); return p; @@ -962,8 +1225,8 @@ static __isl_give isl_printer *print_latex_map(__isl_keep isl_map *map, p = isl_printer_print_str(p, s_open_set[1]); data.print_dim = &print_dim_eq; data.user = aff; - p = print_space(map->dim, p, 0, &data); - p = print_disjuncts_map(map, p, 1); + p = isl_print_space(map->dim, p, 0, &data); + p = print_disjuncts_map(map, map->dim, p, 1); p = isl_printer_print_str(p, s_close_set[1]); return p; @@ -1333,7 +1596,7 @@ static __isl_give isl_printer *print_qpolynomial_isl(__isl_take isl_printer *p, } p = isl_printer_print_str(p, "{ "); if (!isl_space_is_params(qp->dim)) { - p = print_space(qp->dim, p, 0, &data); + p = isl_print_space(qp->dim, p, 0, &data); p = isl_printer_print_str(p, " -> "); } p = print_qpolynomial(p, qp); @@ -1447,14 +1710,18 @@ static __isl_give isl_printer *isl_pwqp_print_isl_body( int i = 0; for (i = 0; i < pwqp->n; ++i) { + isl_space *space; + if (i) p = isl_printer_print_str(p, "; "); - if (!isl_space_is_params(pwqp->p[i].set->dim)) { - p = print_space(pwqp->p[i].set->dim, p, 0, &data); + space = isl_qpolynomial_get_domain_space(pwqp->p[i].qp); + if (!isl_space_is_params(space)) { + p = isl_print_space(space, p, 0, &data); p = isl_printer_print_str(p, " -> "); } p = print_qpolynomial(p, pwqp->p[i].qp); - p = print_disjuncts((isl_map *)pwqp->p[i].set, p, 0); + p = print_disjuncts((isl_map *)pwqp->p[i].set, space, p, 0); + isl_space_free(space); } return p; @@ -1510,14 +1777,18 @@ static __isl_give isl_printer *isl_pwf_print_isl_body( int i = 0; for (i = 0; i < pwf->n; ++i) { + isl_space *space; + if (i) p = isl_printer_print_str(p, "; "); - if (!isl_space_is_params(pwf->p[i].set->dim)) { - p = print_space(pwf->p[i].set->dim, p, 0, &data); + space = isl_qpolynomial_fold_get_domain_space(pwf->p[i].fold); + if (!isl_space_is_params(space)) { + p = isl_print_space(space, p, 0, &data); p = isl_printer_print_str(p, " -> "); } p = qpolynomial_fold_print(pwf->p[i].fold, p); - p = print_disjuncts((isl_map *)pwf->p[i].set, p, 0); + p = print_disjuncts((isl_map *)pwf->p[i].set, space, p, 0); + isl_space_free(space); } return p; @@ -1968,23 +2239,23 @@ error: } static __isl_give isl_printer *isl_printer_print_space_isl( - __isl_take isl_printer *p, __isl_keep isl_space *dim) + __isl_take isl_printer *p, __isl_keep isl_space *space) { struct isl_print_space_data data = { 0 }; - if (!dim) + if (!space) goto error; - if (isl_space_dim(dim, isl_dim_param) > 0) { - p = print_tuple(dim, p, isl_dim_param, &data); + if (isl_space_dim(space, isl_dim_param) > 0) { + p = print_tuple(space, p, isl_dim_param, &data); p = isl_printer_print_str(p, " -> "); } p = isl_printer_print_str(p, "{ "); - if (isl_space_is_params(dim)) + if (isl_space_is_params(space)) p = isl_printer_print_str(p, s_such_that[0]); else - p = print_space(dim, p, 0, &data); + p = isl_print_space(space, p, 0, &data); p = isl_printer_print_str(p, " }"); return p; @@ -2022,12 +2293,13 @@ __isl_give isl_printer *isl_printer_print_local_space(__isl_take isl_printer *p, p = isl_printer_print_str(p, " -> "); } p = isl_printer_print_str(p, "{ "); - p = print_space(ls->dim, p, 0, &data); + p = isl_print_space(ls->dim, p, 0, &data); n_div = isl_local_space_dim(ls, isl_dim_div); if (n_div > 0) { p = isl_printer_print_str(p, " : "); p = isl_printer_print_str(p, s_open_exists[0]); - p = print_div_list(p, ls->dim, ls->div, 0); + p = print_div_list(p, ls->dim, ls->div, 0, 1); + p = isl_printer_print_str(p, s_close_exists[0]); } else if (isl_space_is_params(ls->dim)) p = isl_printer_print_str(p, s_such_that[0]); p = isl_printer_print_str(p, " }"); @@ -2110,10 +2382,14 @@ static __isl_give isl_printer *print_pw_aff_body( return isl_printer_free(p); for (i = 0; i < pa->n; ++i) { + isl_space *space; + if (i) p = isl_printer_print_str(p, "; "); p = print_aff(p, pa->p[i].aff); - p = print_disjuncts((isl_map *)pa->p[i].set, p, 0); + space = isl_aff_get_domain_space(pa->p[i].aff); + p = print_disjuncts((isl_map *)pa->p[i].set, space, p, 0); + isl_space_free(space); } return p; @@ -2402,7 +2678,7 @@ static __isl_give isl_printer *print_multi_aff(__isl_take isl_printer *p, data.print_dim = &print_dim_ma; data.user = maff; - return print_space(maff->space, p, 0, &data); + return isl_print_space(maff->space, p, 0, &data); } static __isl_give isl_printer *print_multi_aff_isl(__isl_take isl_printer *p, @@ -2450,10 +2726,14 @@ static __isl_give isl_printer *print_pw_multi_aff_body( goto error; for (i = 0; i < pma->n; ++i) { + isl_space *space; + if (i) p = isl_printer_print_str(p, "; "); p = print_multi_aff(p, pma->p[i].maff); - p = print_disjuncts((isl_map *)pma->p[i].set, p, 0); + space = isl_multi_aff_get_domain_space(pma->p[i].maff); + p = print_disjuncts((isl_map *)pma->p[i].set, space, p, 0); + isl_space_free(space); } return p; error: @@ -2628,10 +2908,14 @@ static __isl_give isl_printer *print_dim_mpa(__isl_take isl_printer *p, if (need_parens) p = isl_printer_print_str(p, "("); for (i = 0; i < pa->n; ++i) { + isl_space *space; + if (i) p = isl_printer_print_str(p, "; "); p = print_aff_body(p, pa->p[i].aff); - p = print_disjuncts(pa->p[i].set, p, 0); + space = isl_aff_get_domain_space(pa->p[i].aff); + p = print_disjuncts(pa->p[i].set, space, p, 0); + isl_space_free(space); } if (need_parens) p = isl_printer_print_str(p, ")"); @@ -2656,7 +2940,7 @@ static __isl_give isl_printer *print_multi_pw_aff_isl(__isl_take isl_printer *p, p = isl_printer_print_str(p, "{ "); data.print_dim = &print_dim_mpa; data.user = mpa; - p = print_space(mpa->space, p, 0, &data); + p = isl_print_space(mpa->space, p, 0, &data); p = isl_printer_print_str(p, " }"); return p; } @@ -2708,7 +2992,7 @@ static __isl_give isl_printer *print_multi_val_isl(__isl_take isl_printer *p, p = isl_printer_print_str(p, "{ "); data.print_dim = &print_dim_mv; data.user = mv; - p = print_space(mv->space, p, 0, &data); + p = isl_print_space(mv->space, p, 0, &data); p = isl_printer_print_str(p, " }"); return p; } @@ -2768,7 +3052,7 @@ static __isl_give isl_printer *print_multi_union_pw_aff_isl( data.print_dim = &print_union_pw_aff_dim; data.user = mupa; - p = print_space(space, p, 0, &data); + p = isl_print_space(space, p, 0, &data); isl_space_free(space); return p; |