* Copyright 2008-2009 Katholieke Universiteit Leuven
* Copyright 2010 INRIA Saclay
*
- * Use of this software is governed by the GNU LGPLv2.1 license
+ * Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege, K.U.Leuven, Departement
* Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
#include <isl/seq.h>
#include <isl_polynomial_private.h>
#include <isl_printer_private.h>
-#include <isl_dim_private.h>
+#include <isl_space_private.h>
#include <isl_mat_private.h>
#include <isl/union_map.h>
+#include <isl/constraint.h>
+#include <isl_local_space_private.h>
+#include <isl_aff_private.h>
+#include <isl_ast_build_expr.h>
static const char *s_to[2] = { " -> ", " \\to " };
static const char *s_and[2] = { " and ", " \\wedge " };
return isl_map_print_polylib((struct isl_map *)set, p, ext);
}
-static int count_same_name(__isl_keep isl_dim *dim,
+static int count_same_name(__isl_keep isl_space *dim,
enum isl_dim_type type, unsigned pos, const char *name)
{
enum isl_dim_type t;
int count = 0;
for (t = isl_dim_param; t <= type && t <= isl_dim_out; ++t) {
- s = t == type ? pos : isl_dim_size(dim, t);
+ s = t == type ? pos : isl_space_dim(dim, t);
for (p = 0; p < s; ++p) {
- const char *n = isl_dim_get_name(dim, t, p);
+ const char *n = isl_space_get_dim_name(dim, t, p);
if (n && !strcmp(n, name))
count++;
}
return count;
}
-static __isl_give isl_printer *print_name(__isl_keep isl_dim *dim,
+static __isl_give isl_printer *print_name(__isl_keep isl_space *dim,
__isl_take isl_printer *p, enum isl_dim_type type, unsigned pos,
- int set, int latex)
+ int latex)
{
const char *name;
char buffer[20];
int primes;
- name = type == isl_dim_div ? NULL : isl_dim_get_name(dim, type, pos);
+ name = type == isl_dim_div ? NULL : isl_space_get_dim_name(dim, type, pos);
if (!name) {
const char *prefix;
prefix = s_param_prefix[latex];
else if (type == isl_dim_div)
prefix = s_div_prefix[latex];
- else if (set || type == isl_dim_in)
+ else if (isl_space_is_set(dim) || type == isl_dim_in)
prefix = s_input_prefix[latex];
else
prefix = s_output_prefix[latex];
return p;
}
-static enum isl_dim_type pos2type(__isl_keep isl_dim *dim, unsigned *pos)
+static enum isl_dim_type pos2type(__isl_keep isl_space *dim, unsigned *pos)
{
enum isl_dim_type type;
- unsigned n_in = isl_dim_size(dim, isl_dim_in);
- unsigned n_out = isl_dim_size(dim, isl_dim_out);
- unsigned nparam = isl_dim_size(dim, isl_dim_param);
+ unsigned n_in = isl_space_dim(dim, isl_dim_in);
+ unsigned n_out = isl_space_dim(dim, isl_dim_out);
+ unsigned nparam = isl_space_dim(dim, isl_dim_param);
if (*pos < 1 + nparam) {
type = isl_dim_param;
return type;
}
-static __isl_give isl_printer *print_div(__isl_keep isl_dim *dim,
+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_dim *dim,
+static __isl_give isl_printer *print_term(__isl_keep isl_space *dim,
__isl_keep isl_mat *div,
- isl_int c, unsigned pos, __isl_take isl_printer *p, int set, int latex)
+ isl_int c, unsigned pos, __isl_take isl_printer *p, int latex)
{
enum isl_dim_type type;
int print_div_def;
if (print_div_def)
p = print_div(dim, div, pos, p);
else
- p = print_name(dim, p, type, pos, set, latex);
+ p = print_name(dim, p, type, pos, latex);
return p;
}
-static __isl_give isl_printer *print_affine_of_len(__isl_keep isl_dim *dim,
+static __isl_give isl_printer *print_affine_of_len(__isl_keep isl_space *dim,
__isl_keep isl_mat *div,
- __isl_take isl_printer *p, isl_int *c, int len, int set)
+ __isl_take isl_printer *p, isl_int *c, int len)
{
int i;
int first;
p = isl_printer_print_str(p, " + ");
}
first = 0;
- p = print_term(dim, div, c[i], i, p, set, 0);
+ p = print_term(dim, div, c[i], i, p, 0);
if (flip)
isl_int_neg(c[i], c[i]);
}
}
static __isl_give isl_printer *print_affine(__isl_keep isl_basic_map *bmap,
- __isl_keep isl_dim *dim, __isl_take isl_printer *p, isl_int *c, int set)
+ __isl_keep isl_space *dim, __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, set);
+ return print_affine_of_len(dim, NULL, p, c, len);
}
static int defining_equality(__isl_keep isl_basic_map *eq,
- __isl_keep isl_dim *dim, enum isl_dim_type type, int pos)
+ __isl_keep isl_space *dim, enum isl_dim_type type, int pos)
{
int i;
unsigned total;
if (!eq)
return -1;
- pos += isl_dim_offset(dim, type);
+ pos += isl_space_offset(dim, type);
total = isl_basic_map_total_dim(eq);
for (i = 0; i < eq->n_eq; ++i) {
return -1;
}
+static __isl_give isl_printer *print_aff_body(__isl_take isl_printer *p,
+ __isl_keep isl_aff *aff);
+
/* offset is the offset of local_dim inside global_type of global_dim.
*/
static __isl_give isl_printer *print_nested_var_list(__isl_take isl_printer *p,
- __isl_keep isl_dim *global_dim, enum isl_dim_type global_type,
- __isl_keep isl_dim *local_dim, enum isl_dim_type local_type,
- int set, int latex, __isl_keep isl_basic_map *eq, int offset)
+ __isl_keep isl_space *global_dim, enum isl_dim_type global_type,
+ __isl_keep isl_space *local_dim, enum isl_dim_type local_type,
+ int latex, __isl_keep isl_basic_map *eq,
+ __isl_keep isl_multi_aff *maff, int offset)
{
int i, j;
if (global_dim != local_dim && local_type == isl_dim_out)
offset += local_dim->n_in;
- for (i = 0; i < isl_dim_size(local_dim, local_type); ++i) {
+ for (i = 0; i < isl_space_dim(local_dim, local_type); ++i) {
if (i)
p = isl_printer_print_str(p, ", ");
+ if (maff && global_type == isl_dim_out) {
+ p = print_aff_body(p, maff->p[offset + i]);
+ continue;
+ }
j = defining_equality(eq, global_dim, global_type, offset + i);
if (j >= 0) {
- int pos = 1 + isl_dim_offset(global_dim, global_type)
+ int pos = 1 + isl_space_offset(global_dim, global_type)
+ offset + i;
p = print_affine_of_len(eq->dim, NULL,
- p, eq->eq[j], pos, set);
+ p, eq->eq[j], pos);
} else {
p = print_name(global_dim, p, global_type, offset + i,
- set, latex);
+ latex);
}
}
return p;
}
-static __isl_give isl_printer *print_var_list(__isl_keep isl_dim *dim,
+static __isl_give isl_printer *print_var_list(__isl_keep isl_space *dim,
__isl_take isl_printer *p, enum isl_dim_type type,
- int set, int latex, __isl_keep isl_basic_map *eq)
+ int latex, __isl_keep isl_basic_map *eq, __isl_keep isl_multi_aff *maff)
{
- return print_nested_var_list(p, dim, type, dim, type, set, latex, eq, 0);
+ return print_nested_var_list(p, dim, type, dim, type, latex,
+ eq, maff, 0);
}
static __isl_give isl_printer *print_nested_map_dim(__isl_take isl_printer *p,
- __isl_keep isl_dim *global_dim, enum isl_dim_type global_type,
- __isl_keep isl_dim *local_dim,
- int set, int latex, __isl_keep isl_basic_map *eq, int offset);
+ __isl_keep isl_space *global_dim, enum isl_dim_type global_type,
+ __isl_keep isl_space *local_dim,
+ int latex, __isl_keep isl_basic_map *eq,
+ __isl_keep isl_multi_aff *maff, int offset);
static __isl_give isl_printer *print_nested_tuple(__isl_take isl_printer *p,
- __isl_keep isl_dim *global_dim, enum isl_dim_type global_type,
- __isl_keep isl_dim *local_dim, enum isl_dim_type local_type,
- int set, int latex, __isl_keep isl_basic_map *eq, int offset)
+ __isl_keep isl_space *global_dim, enum isl_dim_type global_type,
+ __isl_keep isl_space *local_dim, enum isl_dim_type local_type,
+ int latex, __isl_keep isl_basic_map *eq,
+ __isl_keep isl_multi_aff *maff, int offset)
{
const char *name = NULL;
- unsigned n = isl_dim_size(local_dim, local_type);
+ unsigned n = isl_space_dim(local_dim, local_type);
if ((local_type == isl_dim_in || local_type == isl_dim_out)) {
- name = isl_dim_get_tuple_name(local_dim, local_type);
+ name = isl_space_get_tuple_name(local_dim, local_type);
if (name) {
if (latex)
p = isl_printer_print_str(p, "\\mathrm{");
offset += local_dim->n_in;
p = print_nested_map_dim(p, global_dim, global_type,
local_dim->nested[local_type - isl_dim_in],
- set, latex, eq, offset);
+ latex, eq, maff, offset);
} else
p = print_nested_var_list(p, global_dim, global_type,
- local_dim, local_type, set, latex, eq, offset);
+ local_dim, local_type, latex,
+ eq, maff, offset);
if (!latex || n != 1 || name)
p = isl_printer_print_str(p, s_close_list[latex]);
return p;
}
-static __isl_give isl_printer *print_tuple(__isl_keep isl_dim *dim,
+static __isl_give isl_printer *print_tuple(__isl_keep isl_space *dim,
__isl_take isl_printer *p, enum isl_dim_type type,
- int set, int latex, __isl_keep isl_basic_map *eq)
+ int latex, __isl_keep isl_basic_map *eq, __isl_keep isl_multi_aff *maff)
{
- return print_nested_tuple(p, dim, type, dim, type, set, latex, eq, 0);
+ return print_nested_tuple(p, dim, type, dim, type, latex, eq, maff, 0);
}
static __isl_give isl_printer *print_nested_map_dim(__isl_take isl_printer *p,
- __isl_keep isl_dim *global_dim, enum isl_dim_type global_type,
- __isl_keep isl_dim *local_dim,
- int set, int latex, __isl_keep isl_basic_map *eq, int offset)
+ __isl_keep isl_space *global_dim, enum isl_dim_type global_type,
+ __isl_keep isl_space *local_dim,
+ int latex, __isl_keep isl_basic_map *eq,
+ __isl_keep isl_multi_aff *maff, int offset)
{
p = print_nested_tuple(p, global_dim, global_type,
- local_dim, isl_dim_in, set, latex, eq, offset);
+ local_dim, isl_dim_in, latex, eq, maff, offset);
p = isl_printer_print_str(p, s_to[latex]);
p = print_nested_tuple(p, global_dim, global_type,
- local_dim, isl_dim_out, set, latex, eq, offset);
+ local_dim, isl_dim_out, latex, eq, maff, offset);
return p;
}
-static __isl_give isl_printer *print_dim(__isl_keep isl_dim *dim,
- __isl_take isl_printer *p, int set, int latex, int rational,
- __isl_keep isl_basic_map *eq)
+static __isl_give isl_printer *print_space(__isl_keep isl_space *dim,
+ __isl_take isl_printer *p, int latex, int rational,
+ __isl_keep isl_basic_map *eq, __isl_keep isl_multi_aff *maff)
{
if (rational && !latex)
p = isl_printer_print_str(p, "rat: ");
- if (set)
- p = print_tuple(dim, p, isl_dim_set, 1, latex, eq);
+ if (isl_space_is_params(dim))
+ ;
+ else if (isl_space_is_set(dim))
+ p = print_tuple(dim, p, isl_dim_set, latex, eq, maff);
else {
- p = print_tuple(dim, p, isl_dim_in, 0, latex, eq);
+ p = print_tuple(dim, p, isl_dim_in, latex, eq, maff);
p = isl_printer_print_str(p, s_to[latex]);
- p = print_tuple(dim, p, isl_dim_out, 0, latex, eq);
+ p = print_tuple(dim, p, isl_dim_out, latex, eq, maff);
}
return p;
}
-static __isl_give isl_printer *print_omega_parameters(__isl_keep isl_dim *dim,
+static __isl_give isl_printer *print_omega_parameters(__isl_keep isl_space *dim,
__isl_take isl_printer *p)
{
- if (isl_dim_size(dim, isl_dim_param) == 0)
+ if (isl_space_dim(dim, isl_dim_param) == 0)
return p;
p = isl_printer_start_line(p);
p = isl_printer_print_str(p, "symbolic ");
- p = print_var_list(dim, p, isl_dim_param, 0, 0, NULL);
+ p = print_var_list(dim, p, isl_dim_param, 0, NULL, NULL);
p = isl_printer_print_str(p, ";");
p = isl_printer_end_line(p);
return p;
}
static __isl_give isl_printer *print_constraint(struct isl_basic_map *bmap,
- __isl_keep isl_dim *dim, __isl_take isl_printer *p,
- isl_int *c, int last, const char *op, int first_constraint, int set,
- int latex)
+ __isl_keep isl_space *dim, __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_abs(c[last], c[last]);
- p = print_term(dim, NULL, c[last], last, p, set, latex);
+ p = print_term(dim, NULL, 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, set);
+ p = print_affine(bmap, dim, p, c);
return p;
}
static __isl_give isl_printer *print_constraints(__isl_keep isl_basic_map *bmap,
- __isl_keep isl_dim *dim, __isl_take isl_printer *p, int set, int latex)
+ __isl_keep isl_space *dim, __isl_take isl_printer *p, int latex)
{
int i;
struct isl_vec *c;
for (i = bmap->n_eq - 1; i >= 0; --i) {
int l = isl_seq_last_non_zero(bmap->eq[i], 1 + total);
- isl_assert(bmap->ctx, l >= 0, goto error);
+ if (l < 0) {
+ if (i != bmap->n_eq - 1)
+ p = isl_printer_print_str(p, s_and[latex]);
+ p = isl_printer_print_str(p, "0 = 0");
+ continue;
+ }
if (isl_int_is_neg(bmap->eq[i][l]))
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, set, latex);
+ "=", i == bmap->n_eq - 1, latex);
}
for (i = 0; i < bmap->n_ineq; ++i) {
int l = isl_seq_last_non_zero(bmap->ineq[i], 1 + total);
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, set, latex);
+ op, !bmap->n_eq && !i, latex);
}
isl_vec_free(c);
}
static __isl_give isl_printer *print_omega_constraints(
- __isl_keep isl_basic_map *bmap, __isl_take isl_printer *p, int set)
+ __isl_keep isl_basic_map *bmap, __isl_take isl_printer *p)
{
if (bmap->n_eq + bmap->n_ineq == 0)
return p;
for (i = 0; i < bmap->n_div; ++i) {
if (i)
p = isl_printer_print_str(p, ", ");
- p = print_name(bmap->dim, p, isl_dim_div, i, 0, 0);
+ p = print_name(bmap->dim, p, isl_dim_div, i, 0);
}
p = isl_printer_print_str(p, ": ");
}
- p = print_constraints(bmap, bmap->dim, p, set, 0);
+ p = print_constraints(bmap, bmap->dim, p, 0);
if (bmap->n_div > 0)
p = isl_printer_print_str(p, ")");
return p;
__isl_keep isl_basic_map *bmap, __isl_take isl_printer *p)
{
p = isl_printer_print_str(p, "{ [");
- p = print_var_list(bmap->dim, p, isl_dim_in, 0, 0, NULL);
+ p = print_var_list(bmap->dim, p, isl_dim_in, 0, NULL, NULL);
p = isl_printer_print_str(p, "] -> [");
- p = print_var_list(bmap->dim, p, isl_dim_out, 0, 0, NULL);
+ p = print_var_list(bmap->dim, p, isl_dim_out, 0, NULL, NULL);
p = isl_printer_print_str(p, "] ");
- p = print_omega_constraints(bmap, p, 0);
+ p = print_omega_constraints(bmap, p);
p = isl_printer_print_str(p, " }");
return p;
}
-static __isl_give isl_printer *isl_basic_map_print_omega(
- __isl_keep isl_basic_map *bmap, __isl_take isl_printer *p)
-{
- p = print_omega_parameters(bmap->dim, p);
-
- p = isl_printer_start_line(p);
- p = basic_map_print_omega(bmap, p);
- p = isl_printer_end_line(p);
- return p;
-}
-
static __isl_give isl_printer *basic_set_print_omega(
__isl_keep isl_basic_set *bset, __isl_take isl_printer *p)
{
p = isl_printer_print_str(p, "{ [");
- p = print_var_list(bset->dim, p, isl_dim_set, 1, 0, NULL);
+ p = print_var_list(bset->dim, p, isl_dim_set, 0, NULL, NULL);
p = isl_printer_print_str(p, "] ");
- p = print_omega_constraints((isl_basic_map *)bset, p, 1);
+ p = print_omega_constraints((isl_basic_map *)bset, p);
p = isl_printer_print_str(p, " }");
return p;
}
-static __isl_give isl_printer *isl_basic_set_print_omega(
- __isl_keep isl_basic_set *bset, __isl_take isl_printer *p)
-{
- p = print_omega_parameters(bset->dim, p);
-
- p = isl_printer_start_line(p);
- p = basic_set_print_omega(bset, p);
- p = isl_printer_end_line(p);
- return p;
-}
-
static __isl_give isl_printer *isl_map_print_omega(__isl_keep isl_map *map,
__isl_take isl_printer *p)
{
int i;
- p = print_omega_parameters(map->dim, p);
-
- p = isl_printer_start_line(p);
for (i = 0; i < map->n; ++i) {
if (i)
p = isl_printer_print_str(p, " union ");
p = basic_map_print_omega(map->p[i], p);
}
- p = isl_printer_end_line(p);
return p;
}
{
int i;
- p = print_omega_parameters(set->dim, p);
-
- p = isl_printer_start_line(p);
for (i = 0; i < set->n; ++i) {
if (i)
p = isl_printer_print_str(p, " union ");
p = basic_set_print_omega(set->p[i], p);
}
- p = isl_printer_end_line(p);
return p;
}
static __isl_give isl_printer *print_disjunct(__isl_keep isl_basic_map *bmap,
- __isl_keep isl_dim *dim, __isl_take isl_printer *p, int set, int latex)
+ __isl_keep isl_space *dim, __isl_take isl_printer *p, int latex)
{
if (bmap->n_div > 0) {
int i;
for (i = 0; i < bmap->n_div; ++i) {
if (i)
p = isl_printer_print_str(p, ", ");
- p = print_name(dim, p, isl_dim_div, i, 0, latex);
+ p = print_name(dim, p, isl_dim_div, i, latex);
if (latex || isl_int_is_zero(bmap->div[i][0]))
continue;
p = isl_printer_print_str(p, " = [(");
- p = print_affine(bmap, dim, p, bmap->div[i] + 1, set);
+ p = print_affine(bmap, dim, p, bmap->div[i] + 1);
p = isl_printer_print_str(p, ")/");
p = isl_printer_print_isl_int(p, bmap->div[i][0]);
p = isl_printer_print_str(p, "]");
p = isl_printer_print_str(p, ": ");
}
- p = print_constraints(bmap, dim, p, set, latex);
+ p = print_constraints(bmap, dim, p, latex);
if (bmap->n_div > 0)
p = isl_printer_print_str(p, s_close_exists[latex]);
static __isl_give isl_printer *isl_basic_map_print_isl(
__isl_keep isl_basic_map *bmap, __isl_take isl_printer *p,
- int set, int latex)
+ int latex)
{
int rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
if (isl_basic_map_dim(bmap, isl_dim_param) > 0) {
- p = print_tuple(bmap->dim, p, isl_dim_param, 0, latex, NULL);
+ p = print_tuple(bmap->dim, p, isl_dim_param, latex, NULL, NULL);
p = isl_printer_print_str(p, " -> ");
}
p = isl_printer_print_str(p, "{ ");
- p = print_dim(bmap->dim, p, set, latex, rational, NULL);
+ p = print_space(bmap->dim, p, latex, rational, NULL, NULL);
p = isl_printer_print_str(p, " : ");
- p = print_disjunct(bmap, bmap->dim, p, set, latex);
+ 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 set, int latex)
+ __isl_take isl_printer *p, int latex)
{
int i;
- if (isl_map_fast_is_universe(map))
+ if (isl_map_plain_is_universe(map))
return p;
p = isl_printer_print_str(p, s_such_that[latex]);
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, set, latex);
+ p = print_disjunct(map->p[i], map->dim, 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).
+ * 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)
+{
+ 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);
+}
+
struct isl_aff_split {
isl_basic_map *aff;
isl_map *map;
s1 = (const struct isl_aff_split *) p1;
s2 = (const struct isl_aff_split *) p2;
- return isl_basic_map_fast_cmp(s1->aff, s2->aff);
+ return isl_basic_map_plain_cmp(s1->aff, s2->aff);
}
static __isl_give isl_basic_map *drop_aff(__isl_take isl_basic_map *bmap,
if (!bmap || !aff)
goto error;
- total = isl_dim_total(bmap->dim);
+ total = isl_space_dim(bmap->dim, isl_dim_all);
for (i = bmap->n_eq - 1; i >= 0; --i) {
if (isl_seq_first_non_zero(bmap->eq[i] + 1 + total,
{
int i, n;
struct isl_aff_split *split;
+ isl_ctx *ctx;
- split = isl_calloc_array(map->isl, struct isl_aff_split, map->n);
+ ctx = isl_map_get_ctx(map);
+ split = isl_calloc_array(ctx, struct isl_aff_split, map->n);
if (!split)
return NULL;
-
+
for (i = 0; i < map->n; ++i) {
isl_basic_map *bmap;
split[i].aff = get_aff(isl_basic_map_copy(map->p[i]));
n = map->n;
for (i = n - 1; i >= 1; --i) {
- if (!isl_basic_map_fast_is_equal(split[i - 1].aff,
+ if (!isl_basic_map_plain_is_equal(split[i - 1].aff,
split[i].aff))
continue;
isl_basic_map_free(split[i].aff);
}
static __isl_give isl_printer *print_split_map(__isl_take isl_printer *p,
- struct isl_aff_split *split, int n, int set)
+ struct isl_aff_split *split, int n)
{
int i;
int rational;
for (i = 0; i < n; ++i) {
- isl_dim *dim;
+ isl_space *dim;
if (!split[i].map)
break;
ISL_F_ISSET(split[i].map->p[0], ISL_BASIC_MAP_RATIONAL);
if (i)
p = isl_printer_print_str(p, "; ");
- p = print_dim(dim, p, set, 0, rational, split[i].aff);
- p = print_disjuncts(split[i].map, p, set, 0);
+ p = print_space(dim, p, 0, rational, split[i].aff, NULL);
+ p = print_disjuncts_map(split[i].map, p, 0);
}
return p;
}
static __isl_give isl_printer *isl_map_print_isl_body(__isl_keep isl_map *map,
- __isl_take isl_printer *p, int set)
+ __isl_take isl_printer *p)
{
struct isl_aff_split *split = NULL;
int rational;
if (map->n > 0)
split = split_aff(map);
if (split) {
- p = print_split_map(p, split, map->n, set);
+ p = print_split_map(p, split, map->n);
} else {
rational = map->n > 0 &&
ISL_F_ISSET(map->p[0], ISL_BASIC_MAP_RATIONAL);
- p = print_dim(map->dim, p, set, 0, rational, NULL);
- p = print_disjuncts(map, p, set, 0);
+ p = print_space(map->dim, p, 0, rational, NULL, NULL);
+ p = print_disjuncts_map(map, p, 0);
}
free_split(split, map->n);
return p;
}
static __isl_give isl_printer *isl_map_print_isl(__isl_keep isl_map *map,
- __isl_take isl_printer *p, int set)
+ __isl_take isl_printer *p)
{
if (isl_map_dim(map, isl_dim_param) > 0) {
- p = print_tuple(map->dim, p, isl_dim_param, set, 0, NULL);
+ p = print_tuple(map->dim, p, isl_dim_param, 0, NULL, NULL);
p = isl_printer_print_str(p, s_to[0]);
}
p = isl_printer_print_str(p, s_open_set[0]);
- p = isl_map_print_isl_body(map, p, set);
+ p = isl_map_print_isl_body(map, p);
p = isl_printer_print_str(p, s_close_set[0]);
return p;
}
static __isl_give isl_printer *print_latex_map(__isl_keep isl_map *map,
- __isl_take isl_printer *p, __isl_keep isl_basic_map *aff, int set)
+ __isl_take isl_printer *p, __isl_keep isl_basic_map *aff)
{
if (isl_map_dim(map, isl_dim_param) > 0) {
- p = print_tuple(map->dim, p, isl_dim_param, set, 1, NULL);
+ p = print_tuple(map->dim, p, isl_dim_param, 1, NULL, NULL);
p = isl_printer_print_str(p, s_to[1]);
}
p = isl_printer_print_str(p, s_open_set[1]);
- p = print_dim(map->dim, p, set, 1, 0, aff);
- p = print_disjuncts(map, p, set, 1);
+ p = print_space(map->dim, p, 1, 0, aff, NULL);
+ p = print_disjuncts_map(map, p, 1);
p = isl_printer_print_str(p, s_close_set[1]);
return p;
}
static __isl_give isl_printer *isl_map_print_latex(__isl_keep isl_map *map,
- __isl_take isl_printer *p, int set)
+ __isl_take isl_printer *p)
{
int i;
struct isl_aff_split *split = NULL;
split = split_aff(map);
if (!split)
- return print_latex_map(map, p, NULL, set);
+ return print_latex_map(map, p, NULL);
for (i = 0; i < map->n; ++i) {
if (!split[i].map)
break;
if (i)
p = isl_printer_print_str(p, " \\cup ");
- p = print_latex_map(split[i].map, p, split[i].aff, set);
+ p = print_latex_map(split[i].map, p, split[i].aff);
}
free_split(split, map->n);
if (!p || !bmap)
goto error;
if (p->output_format == ISL_FORMAT_ISL)
- return isl_basic_map_print_isl(bmap, p, 0, 0);
+ return isl_basic_map_print_isl(bmap, p, 0);
else if (p->output_format == ISL_FORMAT_OMEGA)
- return isl_basic_map_print_omega(bmap, p);
+ return basic_map_print_omega(bmap, p);
isl_assert(bmap->ctx, 0, goto error);
error:
isl_printer_free(p);
goto error;
if (p->output_format == ISL_FORMAT_ISL)
- return isl_basic_map_print_isl(bset, p, 1, 0);
+ return isl_basic_map_print_isl(bset, p, 0);
else if (p->output_format == ISL_FORMAT_POLYLIB)
return isl_basic_set_print_polylib(bset, p, 0);
else if (p->output_format == ISL_FORMAT_EXT_POLYLIB)
else if (p->output_format == ISL_FORMAT_POLYLIB_CONSTRAINTS)
return bset_print_constraints_polylib(bset, p);
else if (p->output_format == ISL_FORMAT_OMEGA)
- return isl_basic_set_print_omega(bset, p);
+ return basic_set_print_omega(bset, p);
isl_assert(p->ctx, 0, goto error);
error:
isl_printer_free(p);
if (!p || !set)
goto error;
if (p->output_format == ISL_FORMAT_ISL)
- return isl_map_print_isl((isl_map *)set, p, 1);
+ return isl_map_print_isl((isl_map *)set, p);
else if (p->output_format == ISL_FORMAT_POLYLIB)
return isl_set_print_polylib(set, p, 0);
else if (p->output_format == ISL_FORMAT_EXT_POLYLIB)
else if (p->output_format == ISL_FORMAT_OMEGA)
return isl_set_print_omega(set, p);
else if (p->output_format == ISL_FORMAT_LATEX)
- return isl_map_print_latex((isl_map *)set, p, 1);
+ return isl_map_print_latex((isl_map *)set, p);
isl_assert(set->ctx, 0, goto error);
error:
isl_printer_free(p);
goto error;
if (p->output_format == ISL_FORMAT_ISL)
- return isl_map_print_isl(map, p, 0);
+ return isl_map_print_isl(map, p);
else if (p->output_format == ISL_FORMAT_POLYLIB)
return isl_map_print_polylib(map, p, 0);
else if (p->output_format == ISL_FORMAT_EXT_POLYLIB)
else if (p->output_format == ISL_FORMAT_OMEGA)
return isl_map_print_omega(map, p);
else if (p->output_format == ISL_FORMAT_LATEX)
- return isl_map_print_latex(map, p, 0);
+ return isl_map_print_latex(map, p);
isl_assert(map->ctx, 0, goto error);
error:
isl_printer_free(p);
struct isl_union_print_data {
isl_printer *p;
- int set;
int first;
};
data->p = isl_printer_print_str(data->p, "; ");
data->first = 0;
- data->p = isl_map_print_isl_body(map, data->p, data->set);
+ data->p = isl_map_print_isl_body(map, data->p);
isl_map_free(map);
return 0;
}
static __isl_give isl_printer *isl_union_map_print_isl(
- __isl_keep isl_union_map *umap, __isl_take isl_printer *p, int set)
+ __isl_keep isl_union_map *umap, __isl_take isl_printer *p)
{
- struct isl_union_print_data data = { p, set, 1 };
- isl_dim *dim;
- dim = isl_union_map_get_dim(umap);
- if (isl_dim_size(dim, isl_dim_param) > 0) {
- p = print_tuple(dim, p, isl_dim_param, set, 0, NULL);
+ struct isl_union_print_data data = { p, 1 };
+ isl_space *dim;
+ dim = isl_union_map_get_space(umap);
+ if (isl_space_dim(dim, isl_dim_param) > 0) {
+ p = print_tuple(dim, p, isl_dim_param, 0, NULL, NULL);
p = isl_printer_print_str(p, s_to[0]);
}
- isl_dim_free(dim);
+ isl_space_free(dim);
p = isl_printer_print_str(p, s_open_set[0]);
isl_union_map_foreach_map(umap, &print_map_body, &data);
p = data.p;
data->p = isl_printer_print_str(data->p, " \\cup ");
data->first = 0;
- data->p = isl_map_print_latex(map, data->p, data->set);
+ data->p = isl_map_print_latex(map, data->p);
isl_map_free(map);
return 0;
}
static __isl_give isl_printer *isl_union_map_print_latex(
- __isl_keep isl_union_map *umap, __isl_take isl_printer *p, int set)
+ __isl_keep isl_union_map *umap, __isl_take isl_printer *p)
{
- struct isl_union_print_data data = { p, set, 1 };
+ struct isl_union_print_data data = { p, 1 };
isl_union_map_foreach_map(umap, &print_latex_map_body, &data);
p = data.p;
return p;
goto error;
if (p->output_format == ISL_FORMAT_ISL)
- return isl_union_map_print_isl(umap, p, 0);
+ return isl_union_map_print_isl(umap, p);
if (p->output_format == ISL_FORMAT_LATEX)
- return isl_union_map_print_latex(umap, p, 0);
+ return isl_union_map_print_latex(umap, p);
isl_die(p->ctx, isl_error_invalid,
"invalid output format for isl_union_map", goto error);
goto error;
if (p->output_format == ISL_FORMAT_ISL)
- return isl_union_map_print_isl((isl_union_map *)uset, p, 1);
+ return isl_union_map_print_isl((isl_union_map *)uset, p);
if (p->output_format == ISL_FORMAT_LATEX)
- return isl_union_map_print_latex((isl_union_map *)uset, p, 1);
+ return isl_union_map_print_latex((isl_union_map *)uset, p);
isl_die(p->ctx, isl_error_invalid,
"invalid output format for isl_union_set", goto error);
isl_printer_free(printer);
}
-void isl_basic_map_dump(__isl_keep isl_basic_map *bmap)
-{
- isl_printer *printer;
-
- if (!bmap)
- return;
-
- printer = isl_printer_to_file(isl_basic_map_get_ctx(bmap), stderr);
- printer = isl_printer_print_basic_map(printer, bmap);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_basic_set_dump(__isl_keep isl_basic_set *bset)
-{
- isl_printer *printer;
-
- if (!bset)
- return;
-
- printer = isl_printer_to_file(isl_basic_set_get_ctx(bset), stderr);
- printer = isl_printer_print_basic_set(printer, bset);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_map_dump(__isl_keep isl_map *map)
-{
- isl_printer *printer;
-
- if (!map)
- return;
-
- printer = isl_printer_to_file(isl_map_get_ctx(map), stderr);
- printer = isl_printer_print_map(printer, map);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_set_dump(__isl_keep isl_set *set)
-{
- isl_printer *printer;
-
- if (!set)
- return;
-
- printer = isl_printer_to_file(isl_set_get_ctx(set), stderr);
- printer = isl_printer_print_set(printer, set);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_union_map_dump(__isl_keep isl_union_map *umap)
-{
- isl_printer *printer;
-
- if (!umap)
- return;
-
- printer = isl_printer_to_file(isl_union_map_get_ctx(umap), stderr);
- printer = isl_printer_print_union_map(printer, umap);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_union_set_dump(__isl_keep isl_union_set *uset)
-{
- isl_printer *printer;
-
- if (!uset)
- return;
-
- printer = isl_printer_to_file(isl_union_set_get_ctx(uset), stderr);
- printer = isl_printer_print_union_set(printer, uset);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_union_pw_qpolynomial_dump(__isl_keep isl_union_pw_qpolynomial *upwqp)
-{
- isl_printer *printer;
-
- if (!upwqp)
- return;
-
- printer = isl_printer_to_file(isl_union_pw_qpolynomial_get_ctx(upwqp),
- stderr);
- printer = isl_printer_print_union_pw_qpolynomial(printer, upwqp);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_qpolynomial_dump(__isl_keep isl_qpolynomial *qp)
-{
- isl_printer *printer;
-
- if (!qp)
- return;
-
- printer = isl_printer_to_file(isl_qpolynomial_get_ctx(qp), stderr);
- printer = isl_printer_print_qpolynomial(printer, qp);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_qpolynomial_fold_dump(__isl_keep isl_qpolynomial_fold *fold)
-{
- isl_printer *printer;
-
- if (!fold)
- return;
-
- printer = isl_printer_to_file(isl_qpolynomial_fold_get_ctx(fold),
- stderr);
- printer = isl_printer_print_qpolynomial_fold(printer, fold);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_pw_qpolynomial_dump(__isl_keep isl_pw_qpolynomial *pwqp)
-{
- isl_printer *printer;
-
- if (!pwqp)
- return;
-
- printer = isl_printer_to_file(isl_pw_qpolynomial_get_ctx(pwqp), stderr);
- printer = isl_printer_print_pw_qpolynomial(printer, pwqp);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_pw_qpolynomial_fold_dump(__isl_keep isl_pw_qpolynomial_fold *pwf)
-{
- isl_printer *printer;
-
- if (!pwf)
- return;
-
- printer = isl_printer_to_file(
- isl_pw_qpolynomial_fold_get_ctx(pwf), stderr);
- printer = isl_printer_print_pw_qpolynomial_fold(printer, pwf);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
-void isl_union_pw_qpolynomial_fold_dump(
- __isl_keep isl_union_pw_qpolynomial_fold *upwf)
-{
- isl_printer *printer;
-
- if (!upwf)
- return;
-
- printer = isl_printer_to_file(
- isl_union_pw_qpolynomial_fold_get_ctx(upwf), stderr);
- printer = isl_printer_print_union_pw_qpolynomial_fold(printer, upwf);
- printer = isl_printer_end_line(printer);
-
- isl_printer_free(printer);
-}
-
static int upoly_rec_n_non_zero(__isl_keep struct isl_upoly_rec *rec)
{
int i;
return n;
}
-static __isl_give isl_printer *print_div(__isl_keep isl_dim *dim,
+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;
p = isl_printer_print_str(p, c ? "floord(" : "[(");
p = print_affine_of_len(dim, div, p,
- div->row[pos] + 1, div->n_col - 1, 1);
+ div->row[pos] + 1, div->n_col - 1);
p = isl_printer_print_str(p, c ? ", " : ")/");
p = isl_printer_print_isl_int(p, div->row[pos][0]);
p = isl_printer_print_str(p, c ? ")" : "]");
}
static __isl_give isl_printer *print_base(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim, __isl_keep isl_mat *div, int var)
+ __isl_keep isl_space *dim, __isl_keep isl_mat *div, int var)
{
unsigned total;
- total = isl_dim_total(dim);
+ total = isl_space_dim(dim, isl_dim_all);
if (var < total)
- p = print_term(dim, NULL, dim->ctx->one, 1 + var, p, 1, 0);
+ p = print_term(dim, NULL, dim->ctx->one, 1 + var, p, 0);
else
p = print_div(dim, div, var - total, p);
return p;
}
static __isl_give isl_printer *print_pow(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim, __isl_keep isl_mat *div, int var, int exp)
+ __isl_keep isl_space *dim, __isl_keep isl_mat *div, int var, int exp)
{
p = print_base(p, dim, div, var);
if (exp == 1)
}
static __isl_give isl_printer *upoly_print(__isl_keep struct isl_upoly *up,
- __isl_keep isl_dim *dim, __isl_keep isl_mat *div,
+ __isl_keep isl_space *dim, __isl_keep isl_mat *div,
__isl_take isl_printer *p, int outer)
{
int i, n, first, print_parens;
if (!rec)
goto error;
n = upoly_rec_n_non_zero(rec);
- print_parens = n > 1 || (outer && rec->up.var >= isl_dim_total(dim));
+ print_parens = n > 1 ||
+ (outer && rec->up.var >= isl_space_dim(dim, isl_dim_all));
if (print_parens)
p = isl_printer_print_str(p, "(");
for (i = 0, first = 1; i < rec->n; ++i) {
return NULL;
}
-__isl_give isl_printer *isl_printer_print_qpolynomial(__isl_take isl_printer *p,
+static __isl_give isl_printer *print_qpolynomial(__isl_take isl_printer *p,
__isl_keep isl_qpolynomial *qp)
{
if (!p || !qp)
return NULL;
}
+static __isl_give isl_printer *print_qpolynomial_isl(__isl_take isl_printer *p,
+ __isl_keep isl_qpolynomial *qp)
+{
+ if (!p || !qp)
+ goto error;
+
+ if (isl_space_dim(qp->dim, isl_dim_param) > 0) {
+ p = print_tuple(qp->dim, p, isl_dim_param, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " -> ");
+ }
+ p = isl_printer_print_str(p, "{ ");
+ if (!isl_space_is_params(qp->dim)) {
+ p = print_space(qp->dim, p, 0, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " -> ");
+ }
+ p = print_qpolynomial(p, qp);
+ p = isl_printer_print_str(p, " }");
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *print_qpolynomial_c(__isl_take isl_printer *p,
+ __isl_keep isl_space *dim, __isl_keep isl_qpolynomial *qp)
+{
+ isl_int den;
+
+ isl_int_init(den);
+ isl_qpolynomial_get_den(qp, &den);
+ if (!isl_int_is_one(den)) {
+ isl_qpolynomial *f;
+ p = isl_printer_print_str(p, "(");
+ qp = isl_qpolynomial_copy(qp);
+ f = isl_qpolynomial_rat_cst_on_domain(isl_space_copy(qp->dim),
+ den, qp->dim->ctx->one);
+ qp = isl_qpolynomial_mul(qp, f);
+ }
+ if (qp)
+ p = upoly_print(qp->upoly, dim, qp->div, p, 0);
+ if (!isl_int_is_one(den)) {
+ p = isl_printer_print_str(p, ")/");
+ p = isl_printer_print_isl_int(p, den);
+ isl_qpolynomial_free(qp);
+ }
+ isl_int_clear(den);
+ return p;
+}
+
+__isl_give isl_printer *isl_printer_print_qpolynomial(
+ __isl_take isl_printer *p, __isl_keep isl_qpolynomial *qp)
+{
+ if (!p || !qp)
+ goto error;
+
+ if (p->output_format == ISL_FORMAT_ISL)
+ return print_qpolynomial_isl(p, qp);
+ else if (p->output_format == ISL_FORMAT_C)
+ return print_qpolynomial_c(p, qp->dim, qp);
+ else
+ isl_die(qp->dim->ctx, isl_error_unsupported,
+ "output format not supported for isl_qpolynomials",
+ goto error);
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
void isl_qpolynomial_print(__isl_keep isl_qpolynomial *qp, FILE *out,
unsigned output_format)
{
for (i = 0; i < fold->n; ++i) {
if (i)
p = isl_printer_print_str(p, ", ");
- p = isl_printer_print_qpolynomial(p, fold->qp[i]);
+ p = print_qpolynomial(p, fold->qp[i]);
}
p = isl_printer_print_str(p, ")");
return p;
for (i = 0; i < pwqp->n; ++i) {
if (i)
p = isl_printer_print_str(p, "; ");
- if (isl_dim_size(pwqp->dim, isl_dim_set) > 0 ||
- isl_dim_is_named_or_nested(pwqp->dim, isl_dim_set)) {
- p = print_dim(pwqp->p[i].set->dim, p, 1, 0, 0, NULL);
+ if (!isl_space_is_params(pwqp->p[i].set->dim)) {
+ p = print_space(pwqp->p[i].set->dim, p, 0, 0, NULL, NULL);
p = isl_printer_print_str(p, " -> ");
}
- p = isl_printer_print_qpolynomial(p, pwqp->p[i].qp);
- p = print_disjuncts((isl_map *)pwqp->p[i].set, p, 1, 0);
+ p = print_qpolynomial(p, pwqp->p[i].qp);
+ p = print_disjuncts((isl_map *)pwqp->p[i].set, p, 0);
}
return p;
if (!p || !pwqp)
goto error;
- if (isl_dim_size(pwqp->dim, isl_dim_param) > 0) {
- p = print_tuple(pwqp->dim, p, isl_dim_param, 0, 0, NULL);
+ if (isl_space_dim(pwqp->dim, isl_dim_param) > 0) {
+ p = print_tuple(pwqp->dim, p, isl_dim_param, 0, NULL, NULL);
p = isl_printer_print_str(p, " -> ");
}
p = isl_printer_print_str(p, "{ ");
if (pwqp->n == 0) {
- if (isl_dim_size(pwqp->dim, isl_dim_set) > 0 ||
- isl_dim_is_named_or_nested(pwqp->dim, isl_dim_set)) {
- p = print_dim(pwqp->dim, p, 1, 0, 0, NULL);
+ if (!isl_space_is_set(pwqp->dim)) {
+ p = print_tuple(pwqp->dim, p, isl_dim_in, 0, NULL, NULL);
p = isl_printer_print_str(p, " -> ");
}
p = isl_printer_print_str(p, "0");
for (i = 0; i < pwf->n; ++i) {
if (i)
p = isl_printer_print_str(p, "; ");
- if (isl_dim_size(pwf->dim, isl_dim_set) > 0 ||
- isl_dim_is_named_or_nested(pwf->dim, isl_dim_set)) {
- p = print_dim(pwf->p[i].set->dim, p, 1, 0, 0, NULL);
+ if (!isl_space_is_params(pwf->p[i].set->dim)) {
+ p = print_space(pwf->p[i].set->dim, p, 0, 0, NULL, NULL);
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, 1, 0);
+ p = print_disjuncts((isl_map *)pwf->p[i].set, p, 0);
}
return p;
static __isl_give isl_printer *print_pw_qpolynomial_fold_isl(
__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf)
{
- if (isl_dim_size(pwf->dim, isl_dim_param) > 0) {
- p = print_tuple(pwf->dim, p, isl_dim_param, 0, 0, NULL);
+ if (isl_space_dim(pwf->dim, isl_dim_param) > 0) {
+ p = print_tuple(pwf->dim, p, isl_dim_param, 0, NULL, NULL);
p = isl_printer_print_str(p, " -> ");
}
p = isl_printer_print_str(p, "{ ");
if (pwf->n == 0) {
- if (isl_dim_size(pwf->dim, isl_dim_set) > 0 ||
- isl_dim_is_named_or_nested(pwf->dim, isl_dim_set)) {
- p = print_dim(pwf->dim, p, 1, 0, 0, NULL);
+ if (!isl_space_is_set(pwf->dim)) {
+ p = print_tuple(pwf->dim, p, isl_dim_in, 0, NULL, NULL);
p = isl_printer_print_str(p, " -> ");
}
p = isl_printer_print_str(p, "0");
}
static __isl_give isl_printer *print_affine_c(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim, __isl_keep isl_basic_set *bset, isl_int *c);
+ __isl_keep isl_space *dim, __isl_keep isl_basic_set *bset, isl_int *c);
static __isl_give isl_printer *print_name_c(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim,
+ __isl_keep isl_space *dim,
__isl_keep isl_basic_set *bset, enum isl_dim_type type, unsigned pos)
{
if (type == isl_dim_div) {
} else {
const char *name;
- name = isl_dim_get_name(dim, type, pos);
+ name = isl_space_get_dim_name(dim, type, pos);
if (!name)
name = "UNNAMED";
p = isl_printer_print_str(p, name);
}
static __isl_give isl_printer *print_term_c(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim,
+ __isl_keep isl_space *dim,
__isl_keep isl_basic_set *bset, isl_int c, unsigned pos)
{
enum isl_dim_type type;
- unsigned nparam = isl_basic_set_dim(bset, isl_dim_param);
if (pos == 0)
return isl_printer_print_isl_int(p, c);
}
static __isl_give isl_printer *print_partial_affine_c(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim,
+ __isl_keep isl_space *dim,
__isl_keep isl_basic_set *bset, isl_int *c, unsigned len)
{
int i;
}
static __isl_give isl_printer *print_affine_c(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim, __isl_keep isl_basic_set *bset, isl_int *c)
+ __isl_keep isl_space *dim, __isl_keep isl_basic_set *bset, isl_int *c)
{
unsigned len = 1 + isl_basic_set_total_dim(bset);
return print_partial_affine_c(p, dim, bset, c, len);
}
+/* We skip the constraint if it is implied by the div expression.
+ */
static __isl_give isl_printer *print_constraint_c(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim,
+ __isl_keep isl_space *dim,
__isl_keep isl_basic_set *bset, isl_int *c, const char *op, int first)
{
+ unsigned o_div;
+ unsigned n_div;
+ int div;
+
+ o_div = isl_basic_set_offset(bset, isl_dim_div);
+ n_div = isl_basic_set_dim(bset, isl_dim_div);
+ div = isl_seq_last_non_zero(c + o_div, n_div);
+ if (div >= 0 && isl_basic_set_is_div_constraint(bset, c, div))
+ return p;
+
if (!first)
p = isl_printer_print_str(p, " && ");
}
static __isl_give isl_printer *print_basic_set_c(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim, __isl_keep isl_basic_set *bset)
+ __isl_keep isl_space *dim, __isl_keep isl_basic_set *bset)
{
int i, j;
unsigned n_div = isl_basic_set_dim(bset, isl_dim_div);
}
static __isl_give isl_printer *print_set_c(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim, __isl_keep isl_set *set)
+ __isl_keep isl_space *dim, __isl_keep isl_set *set)
{
int i;
return p;
}
-static __isl_give isl_printer *print_qpolynomial_c(__isl_take isl_printer *p,
- __isl_keep isl_dim *dim, __isl_keep isl_qpolynomial *qp)
-{
- isl_int den;
-
- isl_int_init(den);
- isl_qpolynomial_get_den(qp, &den);
- if (!isl_int_is_one(den)) {
- isl_qpolynomial *f;
- p = isl_printer_print_str(p, "(");
- qp = isl_qpolynomial_copy(qp);
- f = isl_qpolynomial_rat_cst(isl_dim_copy(qp->dim),
- den, qp->dim->ctx->one);
- qp = isl_qpolynomial_mul(qp, f);
- }
- if (qp)
- p = upoly_print(qp->upoly, dim, qp->div, p, 0);
- if (!isl_int_is_one(den)) {
- p = isl_printer_print_str(p, ")/");
- p = isl_printer_print_isl_int(p, den);
- isl_qpolynomial_free(qp);
- }
- isl_int_clear(den);
- return p;
-}
-
static __isl_give isl_printer *print_pw_qpolynomial_c(
__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp)
{
int i;
- if (pwqp->n == 1 && isl_set_fast_is_universe(pwqp->p[0].set))
+ if (pwqp->n == 1 && isl_set_plain_is_universe(pwqp->p[0].set))
return print_qpolynomial_c(p, pwqp->dim, pwqp->p[0].qp);
for (i = 0; i < pwqp->n; ++i) {
static __isl_give isl_printer *print_union_pw_qpolynomial_isl(
__isl_take isl_printer *p, __isl_keep isl_union_pw_qpolynomial *upwqp)
{
- struct isl_union_print_data data = { p, 1, 1 };
- isl_dim *dim;
- dim = isl_union_pw_qpolynomial_get_dim(upwqp);
- if (isl_dim_size(dim, isl_dim_param) > 0) {
- p = print_tuple(dim, p, isl_dim_param, 1, 0, NULL);
+ struct isl_union_print_data data = { p, 1 };
+ isl_space *dim;
+ dim = isl_union_pw_qpolynomial_get_space(upwqp);
+ if (isl_space_dim(dim, isl_dim_param) > 0) {
+ p = print_tuple(dim, p, isl_dim_param, 0, NULL, NULL);
p = isl_printer_print_str(p, " -> ");
}
- isl_dim_free(dim);
+ isl_space_free(dim);
p = isl_printer_print_str(p, "{ ");
isl_union_pw_qpolynomial_foreach_pw_qpolynomial(upwqp, &print_pwqp_body,
&data);
}
static __isl_give isl_printer *print_qpolynomial_fold_c(
- __isl_take isl_printer *p, __isl_keep isl_dim *dim,
+ __isl_take isl_printer *p, __isl_keep isl_space *dim,
__isl_keep isl_qpolynomial_fold *fold)
{
int i;
{
int i;
- if (pwf->n == 1 && isl_set_fast_is_universe(pwf->p[0].set))
+ if (pwf->n == 1 && isl_set_plain_is_universe(pwf->p[0].set))
return print_qpolynomial_fold_c(p, pwf->dim, pwf->p[0].fold);
for (i = 0; i < pwf->n; ++i) {
__isl_take isl_printer *p,
__isl_keep isl_union_pw_qpolynomial_fold *upwf)
{
- struct isl_union_print_data data = { p, 1, 1 };
- isl_dim *dim;
- dim = isl_union_pw_qpolynomial_fold_get_dim(upwf);
- if (isl_dim_size(dim, isl_dim_param) > 0) {
- p = print_tuple(dim, p, isl_dim_param, 1, 0, NULL);
+ struct isl_union_print_data data = { p, 1 };
+ isl_space *dim;
+ dim = isl_union_pw_qpolynomial_fold_get_space(upwf);
+ if (isl_space_dim(dim, isl_dim_param) > 0) {
+ p = print_tuple(dim, p, isl_dim_param, 0, NULL, NULL);
p = isl_printer_print_str(p, " -> ");
}
- isl_dim_free(dim);
+ isl_space_free(dim);
p = isl_printer_print_str(p, "{ ");
isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(upwf,
&print_pwf_body, &data);
isl_printer_free(p);
return NULL;
}
+
+__isl_give isl_printer *isl_printer_print_constraint(__isl_take isl_printer *p,
+ __isl_keep isl_constraint *c)
+{
+ isl_basic_map *bmap;
+
+ if (!p || !c)
+ goto error;
+
+ bmap = isl_basic_map_from_constraint(isl_constraint_copy(c));
+ p = isl_printer_print_basic_map(p, bmap);
+ isl_basic_map_free(bmap);
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *isl_printer_print_space_isl(
+ __isl_take isl_printer *p, __isl_keep isl_space *dim)
+{
+ if (!dim)
+ goto error;
+
+ if (isl_space_dim(dim, isl_dim_param) > 0) {
+ p = print_tuple(dim, p, isl_dim_param, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " -> ");
+ }
+
+ p = isl_printer_print_str(p, "{ ");
+ if (isl_space_is_params(dim))
+ p = isl_printer_print_str(p, s_such_that[0]);
+ else
+ p = print_space(dim, p, 0, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " }");
+
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+__isl_give isl_printer *isl_printer_print_space(__isl_take isl_printer *p,
+ __isl_keep isl_space *space)
+{
+ if (!p || !space)
+ return isl_printer_free(p);
+ if (p->output_format == ISL_FORMAT_ISL)
+ return isl_printer_print_space_isl(p, space);
+ else if (p->output_format == ISL_FORMAT_OMEGA)
+ return print_omega_parameters(space, p);
+
+ isl_die(isl_space_get_ctx(space), isl_error_unsupported,
+ "output format not supported for space",
+ return isl_printer_free(p));
+}
+
+__isl_give isl_printer *isl_printer_print_local_space(__isl_take isl_printer *p,
+ __isl_keep isl_local_space *ls)
+{
+ unsigned total;
+ unsigned n_div;
+
+ if (!ls)
+ goto error;
+
+ total = isl_local_space_dim(ls, isl_dim_all);
+ if (isl_local_space_dim(ls, isl_dim_param) > 0) {
+ p = print_tuple(ls->dim, p, isl_dim_param, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " -> ");
+ }
+ p = isl_printer_print_str(p, "{ ");
+ p = print_space(ls->dim, p, 0, 0, NULL, NULL);
+ n_div = isl_local_space_dim(ls, isl_dim_div);
+ if (n_div > 0) {
+ int i;
+ p = isl_printer_print_str(p, " : ");
+ p = isl_printer_print_str(p, s_open_exists[0]);
+ for (i = 0; i < n_div; ++i) {
+ if (i)
+ p = isl_printer_print_str(p, ", ");
+ p = print_name(ls->dim, p, isl_dim_div, i, 0);
+ if (isl_int_is_zero(ls->div->row[i][0]))
+ continue;
+ p = isl_printer_print_str(p, " = [(");
+ p = print_affine_of_len(ls->dim, ls->div, p,
+ ls->div->row[i] + 1, 1 + total);
+ p = isl_printer_print_str(p, ")/");
+ p = isl_printer_print_isl_int(p, ls->div->row[i][0]);
+ p = isl_printer_print_str(p, "]");
+ }
+ } else if (isl_space_is_params(ls->dim))
+ p = isl_printer_print_str(p, s_such_that[0]);
+ p = isl_printer_print_str(p, " }");
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *print_aff_body(__isl_take isl_printer *p,
+ __isl_keep isl_aff *aff)
+{
+ unsigned total;
+
+ total = isl_local_space_dim(aff->ls, isl_dim_all);
+ p = isl_printer_print_str(p, "(");
+ p = print_affine_of_len(aff->ls->dim, aff->ls->div, p,
+ aff->v->el + 1, 1 + total);
+ if (isl_int_is_one(aff->v->el[0]))
+ p = isl_printer_print_str(p, ")");
+ else {
+ p = isl_printer_print_str(p, ")/");
+ p = isl_printer_print_isl_int(p, aff->v->el[0]);
+ }
+
+ return p;
+}
+
+static __isl_give isl_printer *print_aff(__isl_take isl_printer *p,
+ __isl_keep isl_aff *aff)
+{
+ if (isl_space_is_params(aff->ls->dim))
+ ;
+ else {
+ p = print_tuple(aff->ls->dim, p, isl_dim_set, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " -> ");
+ }
+ p = isl_printer_print_str(p, "[");
+ p = print_aff_body(p, aff);
+ p = isl_printer_print_str(p, "]");
+
+ return p;
+}
+
+static __isl_give isl_printer *print_aff_isl(__isl_take isl_printer *p,
+ __isl_keep isl_aff *aff)
+{
+ if (!aff)
+ goto error;
+
+ if (isl_local_space_dim(aff->ls, isl_dim_param) > 0) {
+ p = print_tuple(aff->ls->dim, p, isl_dim_param, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " -> ");
+ }
+ p = isl_printer_print_str(p, "{ ");
+ p = print_aff(p, aff);
+ p = isl_printer_print_str(p, " }");
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *print_pw_aff_isl(__isl_take isl_printer *p,
+ __isl_keep isl_pw_aff *pwaff)
+{
+ int i;
+
+ if (!pwaff)
+ goto error;
+
+ if (isl_space_dim(pwaff->dim, isl_dim_param) > 0) {
+ p = print_tuple(pwaff->dim, p, isl_dim_param, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " -> ");
+ }
+ p = isl_printer_print_str(p, "{ ");
+ for (i = 0; i < pwaff->n; ++i) {
+ if (i)
+ p = isl_printer_print_str(p, "; ");
+ p = print_aff(p, pwaff->p[i].aff);
+ p = print_disjuncts((isl_map *)pwaff->p[i].set, p, 0);
+ }
+ p = isl_printer_print_str(p, " }");
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *print_ls_affine_c(__isl_take isl_printer *p,
+ __isl_keep isl_local_space *ls, isl_int *c);
+
+static __isl_give isl_printer *print_ls_name_c(__isl_take isl_printer *p,
+ __isl_keep isl_local_space *ls, enum isl_dim_type type, unsigned pos)
+{
+ if (type == isl_dim_div) {
+ p = isl_printer_print_str(p, "floord(");
+ p = print_ls_affine_c(p, ls, ls->div->row[pos] + 1);
+ p = isl_printer_print_str(p, ", ");
+ p = isl_printer_print_isl_int(p, ls->div->row[pos][0]);
+ p = isl_printer_print_str(p, ")");
+ } else {
+ const char *name;
+
+ name = isl_space_get_dim_name(ls->dim, type, pos);
+ if (!name)
+ name = "UNNAMED";
+ p = isl_printer_print_str(p, name);
+ }
+ return p;
+}
+
+static __isl_give isl_printer *print_ls_term_c(__isl_take isl_printer *p,
+ __isl_keep isl_local_space *ls, isl_int c, unsigned pos)
+{
+ enum isl_dim_type type;
+
+ if (pos == 0)
+ return isl_printer_print_isl_int(p, c);
+
+ if (isl_int_is_one(c))
+ ;
+ else if (isl_int_is_negone(c))
+ p = isl_printer_print_str(p, "-");
+ else {
+ p = isl_printer_print_isl_int(p, c);
+ p = isl_printer_print_str(p, "*");
+ }
+ type = pos2type(ls->dim, &pos);
+ p = print_ls_name_c(p, ls, type, pos);
+ return p;
+}
+
+static __isl_give isl_printer *print_ls_partial_affine_c(
+ __isl_take isl_printer *p, __isl_keep isl_local_space *ls,
+ isl_int *c, unsigned len)
+{
+ int i;
+ int first;
+
+ for (i = 0, first = 1; i < len; ++i) {
+ int flip = 0;
+ if (isl_int_is_zero(c[i]))
+ continue;
+ if (!first) {
+ if (isl_int_is_neg(c[i])) {
+ flip = 1;
+ isl_int_neg(c[i], c[i]);
+ p = isl_printer_print_str(p, " - ");
+ } else
+ p = isl_printer_print_str(p, " + ");
+ }
+ first = 0;
+ p = print_ls_term_c(p, ls, c[i], i);
+ if (flip)
+ isl_int_neg(c[i], c[i]);
+ }
+ if (first)
+ p = isl_printer_print_str(p, "0");
+ return p;
+}
+
+static __isl_give isl_printer *print_ls_affine_c(__isl_take isl_printer *p,
+ __isl_keep isl_local_space *ls, isl_int *c)
+{
+ unsigned len = 1 + isl_local_space_dim(ls, isl_dim_all);
+ return print_ls_partial_affine_c(p, ls, c, len);
+}
+
+static __isl_give isl_printer *print_aff_c(__isl_take isl_printer *p,
+ __isl_keep isl_aff *aff)
+{
+ unsigned total;
+
+ total = isl_local_space_dim(aff->ls, isl_dim_all);
+ if (!isl_int_is_one(aff->v->el[0]))
+ p = isl_printer_print_str(p, "(");
+ p = print_ls_partial_affine_c(p, aff->ls, aff->v->el + 1, 1 + total);
+ if (!isl_int_is_one(aff->v->el[0])) {
+ p = isl_printer_print_str(p, ")/");
+ p = isl_printer_print_isl_int(p, aff->v->el[0]);
+ }
+ return p;
+}
+
+/* Print the affine expression "aff" in C format to "p".
+ * The dimension names are taken from "space"
+ * "set" represents the domain of the affine expression.
+ */
+static __isl_give isl_printer *print_aff_on_domain_c(__isl_take isl_printer *p,
+ __isl_keep isl_space *space, __isl_keep isl_aff *aff,
+ __isl_keep isl_set *set)
+{
+ isl_set *u;
+ isl_ast_build *build;
+ isl_ast_expr *expr;
+
+ u = isl_set_universe(isl_space_copy(space));
+ build = isl_ast_build_from_context(u);
+ build = isl_ast_build_restrict(build, isl_set_copy(set));
+ expr = isl_ast_expr_from_aff(isl_aff_copy(aff), build);
+ p = isl_printer_print_ast_expr(p, expr);
+ isl_ast_expr_free(expr);
+ isl_ast_build_free(build);
+
+ return p;
+}
+
+/* In the C format, we cannot express that "pwaff" may be undefined
+ * on parts of the domain space. We therefore assume that the expression
+ * will only be evaluated on its definition domain and compute the gist
+ * of each cell with respect to this domain.
+ */
+static __isl_give isl_printer *print_pw_aff_c(__isl_take isl_printer *p,
+ __isl_keep isl_pw_aff *pwaff)
+{
+ int i;
+ isl_set *domain;
+ isl_space *space;
+
+ if (pwaff->n < 1)
+ isl_die(p->ctx, isl_error_unsupported,
+ "cannot print empty isl_pw_aff in C format", goto error);
+ space = isl_pw_aff_get_domain_space(pwaff);
+ if (!space)
+ goto error;
+
+ domain = isl_pw_aff_domain(isl_pw_aff_copy(pwaff));
+
+ for (i = 0; i < pwaff->n - 1; ++i) {
+ isl_set *set_i;
+
+ p = isl_printer_print_str(p, "(");
+
+ set_i = isl_set_copy(pwaff->p[i].set);
+ set_i = isl_set_gist(set_i, isl_set_copy(domain));
+ p = print_set_c(p, space, set_i);
+ isl_set_free(set_i);
+
+ p = isl_printer_print_str(p, ") ? (");
+ p = print_aff_on_domain_c(p, space,
+ pwaff->p[i].aff, pwaff->p[i].set);
+ p = isl_printer_print_str(p, ") : ");
+ }
+
+ isl_set_free(domain);
+
+ p = print_aff_on_domain_c(p, space, pwaff->p[pwaff->n - 1].aff,
+ pwaff->p[pwaff->n - 1].set);
+ isl_space_free(space);
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+__isl_give isl_printer *isl_printer_print_aff(__isl_take isl_printer *p,
+ __isl_keep isl_aff *aff)
+{
+ if (!p || !aff)
+ goto error;
+
+ if (p->output_format == ISL_FORMAT_ISL)
+ return print_aff_isl(p, aff);
+ else if (p->output_format == ISL_FORMAT_C)
+ return print_aff_c(p, aff);
+ isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
+ goto error);
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+__isl_give isl_printer *isl_printer_print_pw_aff(__isl_take isl_printer *p,
+ __isl_keep isl_pw_aff *pwaff)
+{
+ if (!p || !pwaff)
+ goto error;
+
+ if (p->output_format == ISL_FORMAT_ISL)
+ return print_pw_aff_isl(p, pwaff);
+ else if (p->output_format == ISL_FORMAT_C)
+ return print_pw_aff_c(p, pwaff);
+ isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
+ goto error);
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *print_multi_aff(__isl_take isl_printer *p,
+ __isl_keep isl_multi_aff *maff)
+{
+ return print_space(maff->space, p, 0, 0, NULL, maff);
+}
+
+static __isl_give isl_printer *print_multi_aff_isl(__isl_take isl_printer *p,
+ __isl_keep isl_multi_aff *maff)
+{
+ if (!maff)
+ goto error;
+
+ if (isl_space_dim(maff->space, isl_dim_param) > 0) {
+ p = print_tuple(maff->space, p, isl_dim_param, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " -> ");
+ }
+ p = isl_printer_print_str(p, "{ ");
+ p = print_multi_aff(p, maff);
+ p = isl_printer_print_str(p, " }");
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+__isl_give isl_printer *isl_printer_print_multi_aff(__isl_take isl_printer *p,
+ __isl_keep isl_multi_aff *maff)
+{
+ if (!p || !maff)
+ goto error;
+
+ if (p->output_format == ISL_FORMAT_ISL)
+ return print_multi_aff_isl(p, maff);
+ isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
+ goto error);
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *print_pw_multi_aff_body(
+ __isl_take isl_printer *p, __isl_keep isl_pw_multi_aff *pma)
+{
+ int i;
+
+ if (!pma)
+ goto error;
+
+ for (i = 0; i < pma->n; ++i) {
+ 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);
+ }
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *print_pw_multi_aff_isl(__isl_take isl_printer *p,
+ __isl_keep isl_pw_multi_aff *pma)
+{
+ if (!pma)
+ goto error;
+
+ if (isl_space_dim(pma->dim, isl_dim_param) > 0) {
+ p = print_tuple(pma->dim, p, isl_dim_param, 0, NULL, NULL);
+ p = isl_printer_print_str(p, " -> ");
+ }
+ p = isl_printer_print_str(p, "{ ");
+ p = print_pw_multi_aff_body(p, pma);
+ p = isl_printer_print_str(p, " }");
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *print_unnamed_pw_multi_aff_c(
+ __isl_take isl_printer *p, __isl_keep isl_pw_multi_aff *pma)
+{
+ int i;
+
+ for (i = 0; i < pma->n - 1; ++i) {
+ p = isl_printer_print_str(p, "(");
+ p = print_set_c(p, pma->dim, pma->p[i].set);
+ p = isl_printer_print_str(p, ") ? (");
+ p = print_aff_c(p, pma->p[i].maff->p[0]);
+ p = isl_printer_print_str(p, ") : ");
+ }
+
+ return print_aff_c(p, pma->p[pma->n - 1].maff->p[0]);
+}
+
+static __isl_give isl_printer *print_pw_multi_aff_c(__isl_take isl_printer *p,
+ __isl_keep isl_pw_multi_aff *pma)
+{
+ int n;
+ const char *name;
+
+ if (!pma)
+ goto error;
+ if (pma->n < 1)
+ isl_die(p->ctx, isl_error_unsupported,
+ "cannot print empty isl_pw_multi_aff in C format",
+ goto error);
+ name = isl_pw_multi_aff_get_tuple_name(pma, isl_dim_out);
+ if (!name && isl_pw_multi_aff_dim(pma, isl_dim_out) == 1)
+ return print_unnamed_pw_multi_aff_c(p, pma);
+ if (!name)
+ isl_die(p->ctx, isl_error_unsupported,
+ "cannot print unnamed isl_pw_multi_aff in C format",
+ goto error);
+
+ p = isl_printer_print_str(p, name);
+ n = isl_pw_multi_aff_dim(pma, isl_dim_out);
+ if (n != 0)
+ isl_die(p->ctx, isl_error_unsupported,
+ "not supported yet", goto error);
+
+ return p;
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+__isl_give isl_printer *isl_printer_print_pw_multi_aff(
+ __isl_take isl_printer *p, __isl_keep isl_pw_multi_aff *pma)
+{
+ if (!p || !pma)
+ goto error;
+
+ if (p->output_format == ISL_FORMAT_ISL)
+ return print_pw_multi_aff_isl(p, pma);
+ if (p->output_format == ISL_FORMAT_C)
+ return print_pw_multi_aff_c(p, pma);
+ isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
+ goto error);
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static int print_pw_multi_aff_body_wrap(__isl_take isl_pw_multi_aff *pma,
+ void *user)
+{
+ struct isl_union_print_data *data;
+ data = (struct isl_union_print_data *) user;
+
+ if (!data->first)
+ data->p = isl_printer_print_str(data->p, "; ");
+ data->first = 0;
+
+ data->p = print_pw_multi_aff_body(data->p, pma);
+ isl_pw_multi_aff_free(pma);
+
+ return 0;
+}
+
+static __isl_give isl_printer *print_union_pw_multi_aff_isl(
+ __isl_take isl_printer *p, __isl_keep isl_union_pw_multi_aff *upma)
+{
+ struct isl_union_print_data data = { p, 1 };
+ isl_space *space;
+
+ space = isl_union_pw_multi_aff_get_space(upma);
+ if (isl_space_dim(space, isl_dim_param) > 0) {
+ p = print_tuple(space, p, isl_dim_param, 0, NULL, NULL);
+ p = isl_printer_print_str(p, s_to[0]);
+ }
+ isl_space_free(space);
+ p = isl_printer_print_str(p, s_open_set[0]);
+ isl_union_pw_multi_aff_foreach_pw_multi_aff(upma,
+ &print_pw_multi_aff_body_wrap, &data);
+ p = data.p;
+ p = isl_printer_print_str(p, s_close_set[0]);
+ return p;
+}
+
+__isl_give isl_printer *isl_printer_print_union_pw_multi_aff(
+ __isl_take isl_printer *p, __isl_keep isl_union_pw_multi_aff *upma)
+{
+ if (!p || !upma)
+ goto error;
+
+ if (p->output_format == ISL_FORMAT_ISL)
+ return print_union_pw_multi_aff_isl(p, upma);
+ isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
+ goto error);
+error:
+ isl_printer_free(p);
+ return NULL;
+}
+
+static __isl_give isl_printer *print_multi_pw_aff_isl(__isl_take isl_printer *p,
+ __isl_keep isl_multi_pw_aff *mpa)
+{
+ int i;
+
+ if (!mpa)
+ return isl_printer_free(p);
+
+ p = isl_printer_print_str(p, "(");
+ for (i = 0; i < mpa->n; ++i) {
+ if (i)
+ p = isl_printer_print_str(p, ",");
+ p = isl_printer_print_pw_aff(p, mpa->p[i]);
+ }
+ p = isl_printer_print_str(p, ")");
+ return p;
+}
+
+__isl_give isl_printer *isl_printer_print_multi_pw_aff(
+ __isl_take isl_printer *p, __isl_keep isl_multi_pw_aff *mpa)
+{
+ if (!p || !mpa)
+ return isl_printer_free(p);
+
+ if (p->output_format == ISL_FORMAT_ISL)
+ return print_multi_pw_aff_isl(p, mpa);
+ isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
+ return isl_printer_free(p));
+}