isl_basic_map_gist: allow existentially quantified variables
[isl.git] / isl_multi_un_op_templ.c
blobcdee6182496e84a6a980d44c32e60f3a275fed1e
1 /*
2 * Copyright 2014 Ecole Normale Superieure
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8 */
10 #include <isl_multi_macro.h>
12 /* Data structure that specifies how isl_multi_*_un_op should
13 * modify its input.
15 * If "fn_space" is set, then it is applied to the space.
17 * "fn_el" is applied to each base expression.
19 S(MULTI(BASE),un_op_control) {
20 __isl_give isl_space *(*fn_space)(__isl_take isl_space *space);
21 __isl_give EL *(*fn_el)(__isl_take EL *el);
24 /* Modify "multi" based on "control".
26 static __isl_give MULTI(BASE) *FN(MULTI(BASE),un_op)(
27 __isl_take MULTI(BASE) *multi, S(MULTI(BASE),un_op_control) *control)
29 int i;
30 isl_size n;
31 isl_space *space;
33 n = FN(MULTI(BASE),size)(multi);
34 if (n < 0)
35 return FN(MULTI(BASE),free)(multi);
37 for (i = 0; i < n; ++i) {
38 EL *el;
40 el = FN(MULTI(BASE),take_at)(multi, i);
41 el = control->fn_el(el);
42 multi = FN(MULTI(BASE),restore_at)(multi, i, el);
45 if (!control->fn_space)
46 return multi;
48 space = FN(MULTI(BASE),take_space)(multi);
49 space = control->fn_space(space);
50 multi = FN(MULTI(BASE),restore_space)(multi, space);
52 return multi;