[clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (#98138)
[llvm-project.git] / polly / lib / External / isl / isl_pw_fix_templ.c
blob36a50bc12a2b1731cf1e2e7c44902a8f6e73c02a
1 #include <isl_pw_macro.h>
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)
9 int i;
10 isl_size n;
12 n = FN(PW,n_piece)(pw);
13 if (n < 0)
14 return FN(PW,free)(pw);
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));
20 if (type == isl_dim_in)
21 type = isl_dim_set;
23 for (i = n - 1; i >= 0; --i) {
24 isl_set *domain;
26 domain = FN(PW,take_domain_at)(pw, i);
27 domain = isl_set_fix_si(domain, type, pos, value);
28 pw = FN(PW,restore_domain_at)(pw, i, domain);
29 pw = FN(PW,exploit_equalities_and_remove_if_empty)(pw, i);
32 return pw;
35 /* Fix the value of the variable at position "pos" of type "type" of "pw"
36 * to be equal to "v".
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)
41 int i;
42 isl_size n;
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);
50 n = FN(PW,n_piece)(pw);
51 if (n < 0)
52 goto error;
54 if (type == isl_dim_in)
55 type = isl_dim_set;
57 for (i = 0; i < n; ++i) {
58 isl_set *domain;
60 domain = FN(PW,take_domain_at)(pw, i);
61 domain = isl_set_fix(domain, type, pos, v->n);
62 pw = FN(PW,restore_domain_at)(pw, i, domain);
63 pw = FN(PW,exploit_equalities_and_remove_if_empty)(pw, i);
66 isl_val_free(v);
67 return pw;
68 error:
69 isl_val_free(v);
70 return FN(PW,free)(pw);