77 lines · c
1/*2 * Copyright 2010 INRIA Saclay3 *4 * Use of this software is governed by the MIT license5 *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, France9 */10 11#include <isl_pw_macro.h>12 13static isl_stat foreach_lifted_subset(__isl_take isl_set *set,14 __isl_take EL *el,15 isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,16 void *user), void *user)17{18 int i;19 20 if (!set || !el)21 goto error;22 23 for (i = 0; i < set->n; ++i) {24 isl_set *lift;25 EL *copy;26 27 lift = isl_set_from_basic_set(isl_basic_set_copy(set->p[i]));28 lift = isl_set_lift(lift);29 30 copy = FN(EL,copy)(el);31 copy = FN(EL,lift)(copy, isl_set_get_space(lift));32 33 if (fn(lift, copy, user) < 0)34 goto error;35 }36 37 isl_set_free(set);38 FN(EL,free)(el);39 40 return isl_stat_ok;41error:42 isl_set_free(set);43 FN(EL,free)(el);44 return isl_stat_error;45}46 47isl_stat FN(PW,foreach_lifted_piece)(__isl_keep PW *pw,48 isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,49 void *user), void *user)50{51 int i;52 53 if (!pw)54 return isl_stat_error;55 56 for (i = 0; i < pw->n; ++i) {57 isl_bool any;58 isl_set *set;59 EL *el;60 61 any = isl_set_involves_locals(pw->p[i].set);62 if (any < 0)63 return isl_stat_error;64 set = isl_set_copy(pw->p[i].set);65 el = FN(EL,copy)(pw->p[i].FIELD);66 if (!any) {67 if (fn(set, el, user) < 0)68 return isl_stat_error;69 continue;70 }71 if (foreach_lifted_subset(set, el, fn, user) < 0)72 return isl_stat_error;73 }74 75 return isl_stat_ok;76}77