summaryrefslogtreecommitdiff
path: root/polly/lib/External/isl/isl_pw_print_templ.c
blob: 77f62c61f9d3826ed582c982d433a86cfe339340 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright 2011      Sven Verdoolaege
 *
 * Use of this software is governed by the MIT license
 *
 * Written by Sven Verdoolaege.
 */

#undef EL
#define EL CAT(isl_,BASE)
#undef PW
#define PW CAT(isl_pw_,BASE)

/* Print the body of a piecewise expression, i.e., a semicolon delimited
 * sequence of expressions, each followed by constraints.
 */
static __isl_give isl_printer *FN(print_body_pw,BASE)(
	__isl_take isl_printer *p, __isl_keep PW *pw)
{
	int i;

	if (!pw)
		return isl_printer_free(p);

	for (i = 0; i < pw->n; ++i) {
		EL *el;
		isl_space *space;

		if (i)
			p = isl_printer_print_str(p, "; ");
		el = FN(PW,peek_base_at)(pw, i);
		p = FN(print_body,BASE)(p, el);
		space = FN(EL,get_domain_space)(el);
		p = print_disjuncts(set_to_map(pw->p[i].set), space, p, 0);
		isl_space_free(space);
	}
	return p;
}

/* Print a piecewise expression in isl format.
 */
static __isl_give isl_printer *FN(FN(print_pw,BASE),isl)(
	__isl_take isl_printer *p, __isl_keep PW *pw)
{
	struct isl_print_space_data data = { 0 };

	if (!pw)
		return isl_printer_free(p);

	p = print_param_tuple(p, pw->dim, &data);
	p = isl_printer_print_str(p, "{ ");
	p = FN(print_body_pw,BASE)(p, pw);
	p = isl_printer_print_str(p, " }");
	return p;
}