/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/polly/lib/External/isl/isl_multi_pw_aff_explicit_domain.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2017 Sven Verdoolaege |
3 | | * |
4 | | * Use of this software is governed by the MIT license |
5 | | * |
6 | | * Written by Sven Verdoolaege. |
7 | | */ |
8 | | |
9 | | /* Initialize the explicit domain of "mpa". |
10 | | * |
11 | | * The explicit domain is initialized to a universe set |
12 | | * in the domain space. |
13 | | */ |
14 | | static __isl_give isl_multi_pw_aff *isl_multi_pw_aff_init_explicit_domain( |
15 | | __isl_take isl_multi_pw_aff *mpa) |
16 | 1.14k | { |
17 | 1.14k | if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) |
18 | 0 | return isl_multi_pw_aff_free(mpa); |
19 | 1.14k | mpa->u.dom = isl_set_universe(isl_multi_pw_aff_get_domain_space(mpa)); |
20 | 1.14k | if (!mpa->u.dom) |
21 | 0 | return isl_multi_pw_aff_free(mpa); |
22 | 1.14k | return mpa; |
23 | 1.14k | } |
24 | | |
25 | | /* Intersect the domain of "dst" with the domain product |
26 | | * of the explicit domains of "src1" and "src2". |
27 | | * This function is only called if at least one of "src1" or "src2" |
28 | | * has an explicit domain. |
29 | | */ |
30 | | static __isl_give isl_multi_pw_aff * |
31 | | isl_multi_pw_aff_intersect_explicit_domain_product( |
32 | | __isl_take isl_multi_pw_aff *dst, __isl_keep isl_multi_pw_aff *src1, |
33 | | __isl_keep isl_multi_pw_aff *src2) |
34 | 6 | { |
35 | 6 | isl_space *space; |
36 | 6 | isl_set *dom; |
37 | 6 | isl_map *map; |
38 | 6 | |
39 | 6 | if (!src1 || !src2) |
40 | 0 | return FN(isl_multi_pw_aff,free)(dst); |
41 | 6 | space = isl_multi_pw_aff_get_domain_space(dst); |
42 | 6 | dom = isl_set_universe(space); |
43 | 6 | map = isl_set_unwrap(dom); |
44 | 6 | if (isl_multi_pw_aff_has_explicit_domain(src1)) { |
45 | 4 | dom = isl_set_copy(src1->u.dom); |
46 | 4 | map = isl_map_intersect_domain(map, dom); |
47 | 4 | } |
48 | 6 | if (isl_multi_pw_aff_has_explicit_domain(src2)) { |
49 | 4 | dom = isl_set_copy(src2->u.dom); |
50 | 4 | map = isl_map_intersect_range(map, dom); |
51 | 4 | } |
52 | 6 | dom = isl_map_wrap(map); |
53 | 6 | dst = isl_multi_pw_aff_intersect_domain(dst, dom); |
54 | 6 | return dst; |
55 | 6 | } |
56 | | |
57 | | /* Check whether the explicit domain of "mpa" has non-zero coefficients |
58 | | * for any dimension in the given range or if any of these dimensions appear |
59 | | * with non-zero coefficients in any of the integer divisions involved. |
60 | | */ |
61 | | isl_bool isl_multi_pw_aff_involves_explicit_domain_dims( |
62 | | __isl_keep isl_multi_pw_aff *mpa, |
63 | | enum isl_dim_type type, unsigned pos, unsigned n) |
64 | 3 | { |
65 | 3 | if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) |
66 | 0 | return isl_bool_error; |
67 | 3 | if (type == isl_dim_in) |
68 | 3 | type = isl_dim_set; |
69 | 3 | return isl_set_involves_dims(mpa->u.dom, type, pos, n); |
70 | 3 | } |
71 | | |
72 | | /* Insert "n" dimensions of type "type" at position "pos" |
73 | | * of the explicit domain of "mpa". |
74 | | */ |
75 | | static __isl_give isl_multi_pw_aff * |
76 | | isl_multi_pw_aff_insert_explicit_domain_dims(__isl_take isl_multi_pw_aff *mpa, |
77 | | enum isl_dim_type type, unsigned pos, unsigned n) |
78 | 1 | { |
79 | 1 | if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) |
80 | 0 | return isl_multi_pw_aff_free(mpa); |
81 | 1 | mpa = isl_multi_pw_aff_cow(mpa); |
82 | 1 | if (!mpa) |
83 | 0 | return NULL; |
84 | 1 | if (type == isl_dim_in) |
85 | 1 | type = isl_dim_set; |
86 | 1 | mpa->u.dom = isl_set_insert_dims(mpa->u.dom, type, pos, n); |
87 | 1 | if (!mpa->u.dom) |
88 | 0 | return isl_multi_pw_aff_free(mpa); |
89 | 1 | return mpa; |
90 | 1 | } |
91 | | |
92 | | /* Drop the "n" dimensions of type "type" starting at position "pos" |
93 | | * of the explicit domain of "mpa". |
94 | | */ |
95 | | static __isl_give isl_multi_pw_aff * |
96 | | isl_multi_pw_aff_drop_explicit_domain_dims(__isl_take isl_multi_pw_aff *mpa, |
97 | | enum isl_dim_type type, unsigned pos, unsigned n) |
98 | 1 | { |
99 | 1 | if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) |
100 | 0 | return isl_multi_pw_aff_free(mpa); |
101 | 1 | mpa = isl_multi_pw_aff_cow(mpa); |
102 | 1 | if (!mpa) |
103 | 0 | return NULL; |
104 | 1 | if (type == isl_dim_in) |
105 | 1 | type = isl_dim_set; |
106 | 1 | mpa->u.dom = isl_set_drop(mpa->u.dom, type, pos, n); |
107 | 1 | if (!mpa->u.dom) |
108 | 0 | return isl_multi_pw_aff_free(mpa); |
109 | 1 | return mpa; |
110 | 1 | } |
111 | | |
112 | | /* Move the "n" dimensions of "src_type" starting at "src_pos" of |
113 | | * of the explicit domain of "mpa" to dimensions of "dst_type" at "dst_pos". |
114 | | */ |
115 | | static __isl_give isl_multi_pw_aff *isl_multi_pw_aff_move_explicit_domain_dims( |
116 | | __isl_take isl_multi_pw_aff *mpa, |
117 | | enum isl_dim_type dst_type, unsigned dst_pos, |
118 | | enum isl_dim_type src_type, unsigned src_pos, unsigned n) |
119 | 0 | { |
120 | 0 | if (isl_multi_pw_aff_check_has_explicit_domain(mpa) < 0) |
121 | 0 | return isl_multi_pw_aff_free(mpa); |
122 | 0 | mpa = isl_multi_pw_aff_cow(mpa); |
123 | 0 | if (!mpa) |
124 | 0 | return NULL; |
125 | 0 | if (dst_type == isl_dim_in) |
126 | 0 | dst_type = isl_dim_set; |
127 | 0 | if (src_type == isl_dim_in) |
128 | 0 | src_type = isl_dim_set; |
129 | 0 | mpa->u.dom = isl_set_move_dims(mpa->u.dom, dst_type, dst_pos, |
130 | 0 | src_type, src_pos, n); |
131 | 0 | if (!mpa->u.dom) |
132 | 0 | return isl_multi_pw_aff_free(mpa); |
133 | 0 | return mpa; |
134 | 0 | } |