add isl_union_{set,map}_plain_unshifted_simple_hull
[isl.git] / isl_pw_print_templ.c
blob423267f4c07842a39d97f1d099116bfd59bdea56
1 /*
2 * Copyright 2011 Sven Verdoolaege
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege.
7 */
9 #undef EL
10 #define EL CAT(isl_,BASE)
11 #undef PW
12 #define PW CAT(isl_pw_,BASE)
14 /* Print the empty body of a piecewise expression.
16 * In particular, print the space with some arbitrary value (zero)
17 * for all dimensions, followed by unsatisfiable constraints (false).
19 static __isl_give isl_printer *FN(print_empty_body_pw,BASE)(
20 __isl_take isl_printer *p, __isl_keep PW *pw)
22 struct isl_print_space_data data = { 0 };
23 isl_space *space;
25 space = FN(PW,get_space)(pw);
26 data.print_dim = &print_dim_zero;
27 p = isl_print_space(space, p, 0, &data);
28 isl_space_free(space);
29 p = isl_printer_print_str(p, " : false");
30 return p;
33 /* Print the body of a piecewise expression, i.e., a semicolon delimited
34 * sequence of expressions, each followed by constraints.
36 static __isl_give isl_printer *FN(print_body_pw,BASE)(
37 __isl_take isl_printer *p, __isl_keep PW *pw)
39 int i;
40 isl_size n;
42 n = FN(PW,n_piece)(pw);
43 if (n < 0)
44 return isl_printer_free(p);
46 if (n == 0)
47 FN(print_empty_body_pw,BASE)(p, pw);
49 for (i = 0; i < n; ++i) {
50 EL *el;
51 isl_space *space;
53 if (i)
54 p = isl_printer_print_str(p, "; ");
55 el = FN(PW,peek_base_at)(pw, i);
56 p = FN(print_body,BASE)(p, el);
57 space = FN(EL,get_domain_space)(el);
58 p = print_disjuncts(set_to_map(pw->p[i].set), space, p, 0);
59 isl_space_free(space);
61 return p;
64 /* Print a piecewise expression in isl format.
66 static __isl_give isl_printer *FN(FN(print_pw,BASE),isl)(
67 __isl_take isl_printer *p, __isl_keep PW *pw)
69 struct isl_print_space_data data = { 0 };
71 if (!pw)
72 return isl_printer_free(p);
74 p = print_param_tuple(p, pw->dim, &data);
75 p = isl_printer_print_str(p, "{ ");
76 p = FN(print_body_pw,BASE)(p, pw);
77 p = isl_printer_print_str(p, " }");
78 return p;