1#include <isl_pw_macro.h>
2
3/* Fix the value of the given parameter or domain dimension of "pw"
4 * to be equal to "value".
5 */
6__isl_give PW *FN(PW,fix_si)(__isl_take PW *pw, enum isl_dim_type type,
7 unsigned pos, int value)
8{
9 int i;
10 isl_size n;
11
12 n = FN(PW,n_piece)(pw);
13 if (n < 0)
14 return FN(PW,free)(pw);
15
16 if (type == isl_dim_out)
17 isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
18 "cannot fix output dimension", return FN(PW,free)(pw));
19
20 if (type == isl_dim_in)
21 type = isl_dim_set;
22
23 for (i = n - 1; i >= 0; --i) {
24 isl_set *domain;
25
26 domain = FN(PW,take_domain_at)(pw, pos: i);
27 domain = isl_set_fix_si(set: domain, type, pos, value);
28 pw = FN(PW,restore_domain_at)(pw, pos: i, domain);
29 pw = FN(PW,exploit_equalities_and_remove_if_empty)(pw, i);
30 }
31
32 return pw;
33}
34
35/* Fix the value of the variable at position "pos" of type "type" of "pw"
36 * to be equal to "v".
37 */
38__isl_give PW *FN(PW,fix_val)(__isl_take PW *pw,
39 enum isl_dim_type type, unsigned pos, __isl_take isl_val *v)
40{
41 int i;
42 isl_size n;
43
44 if (!v)
45 return FN(PW,free)(pw);
46 if (!isl_val_is_int(v))
47 isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
48 "expecting integer value", goto error);
49
50 n = FN(PW,n_piece)(pw);
51 if (n < 0)
52 goto error;
53
54 if (type == isl_dim_in)
55 type = isl_dim_set;
56
57 for (i = 0; i < n; ++i) {
58 isl_set *domain;
59
60 domain = FN(PW,take_domain_at)(pw, pos: i);
61 domain = isl_set_fix(set: domain, type, pos, value: v->n);
62 pw = FN(PW,restore_domain_at)(pw, pos: i, domain);
63 pw = FN(PW,exploit_equalities_and_remove_if_empty)(pw, i);
64 }
65
66 isl_val_free(v);
67 return pw;
68error:
69 isl_val_free(v);
70 return FN(PW,free)(pw);
71}
72

source code of polly/lib/External/isl/isl_pw_fix_templ.c