isl_codegen: skip explicit printing of outermost block by default
[isl.git] / isl_pw_lift_templ.c
blobad5b9e0d98e91b637ee1fa01bd99adb6ba4465be
1 /*
2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
11 #include <isl_pw_macro.h>
13 static isl_bool any_divs(__isl_keep isl_set *set)
15 int i;
17 if (!set)
18 return isl_bool_error;
20 for (i = 0; i < set->n; ++i)
21 if (set->p[i]->n_div > 0)
22 return isl_bool_true;
24 return isl_bool_false;
27 static isl_stat foreach_lifted_subset(__isl_take isl_set *set,
28 __isl_take EL *el,
29 isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,
30 void *user), void *user)
32 int i;
34 if (!set || !el)
35 goto error;
37 for (i = 0; i < set->n; ++i) {
38 isl_set *lift;
39 EL *copy;
41 lift = isl_set_from_basic_set(isl_basic_set_copy(set->p[i]));
42 lift = isl_set_lift(lift);
44 copy = FN(EL,copy)(el);
45 copy = FN(EL,lift)(copy, isl_set_get_space(lift));
47 if (fn(lift, copy, user) < 0)
48 goto error;
51 isl_set_free(set);
52 FN(EL,free)(el);
54 return isl_stat_ok;
55 error:
56 isl_set_free(set);
57 FN(EL,free)(el);
58 return isl_stat_error;
61 isl_stat FN(PW,foreach_lifted_piece)(__isl_keep PW *pw,
62 isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,
63 void *user), void *user)
65 int i;
67 if (!pw)
68 return isl_stat_error;
70 for (i = 0; i < pw->n; ++i) {
71 isl_bool any;
72 isl_set *set;
73 EL *el;
75 any = any_divs(pw->p[i].set);
76 if (any < 0)
77 return isl_stat_error;
78 set = isl_set_copy(pw->p[i].set);
79 el = FN(EL,copy)(pw->p[i].FIELD);
80 if (!any) {
81 if (fn(set, el, user) < 0)
82 return isl_stat_error;
83 continue;
85 if (foreach_lifted_subset(set, el, fn, user) < 0)
86 return isl_stat_error;
89 return isl_stat_ok;