isl_map.c: div_involves_vars: use isl_basic_map_var_offset
[isl.git] / isl_pw_un_op_templ.c
blob5b9a0550a67fc11762e2a8eeca174bb888717991
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 /* Data structure that specifies how isl_pw_*_un_op should
14 * modify its input.
16 * If "fn_space" is set, then it is applied to the space.
18 * If "fn_domain" is set, then it is applied to the cells.
20 * "fn_base" is applied to each base expression.
21 * This function is assumed to have no effect on the default value
22 * (i.e., zero for those objects with a default value).
24 S(PW,un_op_control) {
25 __isl_give isl_space *(*fn_space)(__isl_take isl_space *space);
26 __isl_give isl_set *(*fn_domain)(__isl_take isl_set *domain);
27 __isl_give EL *(*fn_base)(__isl_take EL *el);
30 /* Modify "pw" based on "control".
32 * If the cells are modified, then the corresponding base expressions
33 * may need to be adjusted to the possibly modified equality constraints.
35 static __isl_give PW *FN(PW,un_op)(__isl_take PW *pw,
36 S(PW,un_op_control) *control)
38 isl_space *space;
39 isl_size n;
40 int i;
42 n = FN(PW,n_piece)(pw);
43 if (n < 0)
44 return FN(PW,free)(pw);
46 for (i = n - 1; i >= 0; --i) {
47 EL *el;
48 isl_set *domain;
50 el = FN(PW,take_base_at)(pw, i);
51 el = control->fn_base(el);
52 pw = FN(PW,restore_base_at)(pw, i, el);
54 if (!control->fn_domain)
55 continue;
57 domain = FN(PW,take_domain_at)(pw, i);
58 domain = control->fn_domain(domain);
59 pw = FN(PW,restore_domain_at)(pw, i, domain);
61 pw = FN(PW,exploit_equalities_and_remove_if_empty)(pw, i);
64 if (!control->fn_space)
65 return pw;
67 space = FN(PW,take_space)(pw);
68 space = control->fn_space(space);
69 pw = FN(PW,restore_space)(pw, space);
71 return pw;