/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/polly/lib/External/isl/isl_union_single.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2010 INRIA Saclay |
3 | | * Copyright 2013 Ecole Normale Superieure |
4 | | * |
5 | | * Use of this software is governed by the MIT license |
6 | | * |
7 | | * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, |
8 | | * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, |
9 | | * 91893 Orsay, France |
10 | | * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France |
11 | | */ |
12 | | |
13 | | #include <isl_hash_private.h> |
14 | | #include <isl_union_macro.h> |
15 | | |
16 | | /* A union of expressions defined over different domain spaces. |
17 | | * "space" describes the parameters. |
18 | | * The entries of "table" are keyed on the domain space of the entry. |
19 | | */ |
20 | | struct UNION { |
21 | | int ref; |
22 | | #ifdef HAS_TYPE |
23 | | enum isl_fold type; |
24 | | #endif |
25 | | isl_space *space; |
26 | | |
27 | | struct isl_hash_table table; |
28 | | }; |
29 | | |
30 | | /* Return the number of base expressions in "u". |
31 | | */ |
32 | | int FN(FN(UNION,n),BASE)(__isl_keep UNION *u) |
33 | 160 | { |
34 | 160 | return u ? u->table.n : 00 ; |
35 | 160 | } isl_union_pw_aff_n_pw_aff Line | Count | Source | 33 | 158 | { | 34 | 158 | return u ? u->table.n : 00 ; | 35 | 158 | } |
Unexecuted instantiation: isl_union_pw_qpolynomial_fold_n_pw_qpolynomial_fold isl_union_pw_qpolynomial_n_pw_qpolynomial Line | Count | Source | 33 | 2 | { | 34 | 2 | return u ? u->table.n : 00 ; | 35 | 2 | } |
|
36 | | |
37 | | S(UNION,foreach_data) |
38 | | { |
39 | | isl_stat (*fn)(__isl_take PART *part, void *user); |
40 | | void *user; |
41 | | }; |
42 | | |
43 | | static isl_stat FN(UNION,call_on_copy)(void **entry, void *user) |
44 | 42.2k | { |
45 | 42.2k | PART *part = *entry; |
46 | 42.2k | S(UNION,foreach_data) *data = (S(UNION,foreach_data) *)user; |
47 | 42.2k | |
48 | 42.2k | part = FN(PART,copy)(part); |
49 | 42.2k | if (!part) |
50 | 0 | return isl_stat_error; |
51 | 42.2k | return data->fn(part, data->user); |
52 | 42.2k | } isl_aff.c:isl_union_pw_aff_call_on_copy Line | Count | Source | 44 | 42.2k | { | 45 | 42.2k | PART *part = *entry; | 46 | 42.2k | S(UNION,foreach_data) *data = (S(UNION,foreach_data) *)user; | 47 | 42.2k | | 48 | 42.2k | part = FN(PART,copy)(part); | 49 | 42.2k | if (!part) | 50 | 0 | return isl_stat_error; | 51 | 42.2k | return data->fn(part, data->user); | 52 | 42.2k | } |
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_call_on_copy isl_polynomial.c:isl_union_pw_qpolynomial_call_on_copy Line | Count | Source | 44 | 3 | { | 45 | 3 | PART *part = *entry; | 46 | 3 | S(UNION,foreach_data) *data = (S(UNION,foreach_data) *)user; | 47 | 3 | | 48 | 3 | part = FN(PART,copy)(part); | 49 | 3 | if (!part) | 50 | 0 | return isl_stat_error; | 51 | 3 | return data->fn(part, data->user); | 52 | 3 | } |
|
53 | | |
54 | | isl_stat FN(FN(UNION,foreach),BASE)(__isl_keep UNION *u, |
55 | | isl_stat (*fn)(__isl_take PART *part, void *user), void *user) |
56 | 21.6k | { |
57 | 21.6k | S(UNION,foreach_data) data = { fn, user }; |
58 | 21.6k | |
59 | 21.6k | if (!u) |
60 | 0 | return isl_stat_error; |
61 | 21.6k | |
62 | 21.6k | return isl_hash_table_foreach(u->space->ctx, &u->table, |
63 | 21.6k | &FN(UNION,call_on_copy), &data); |
64 | 21.6k | } isl_union_pw_aff_foreach_pw_aff Line | Count | Source | 56 | 21.6k | { | 57 | 21.6k | S(UNION,foreach_data) data = { fn, user }; | 58 | 21.6k | | 59 | 21.6k | if (!u) | 60 | 0 | return isl_stat_error; | 61 | 21.6k | | 62 | 21.6k | return isl_hash_table_foreach(u->space->ctx, &u->table, | 63 | 21.6k | &FN(UNION,call_on_copy), &data); | 64 | 21.6k | } |
Unexecuted instantiation: isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold isl_union_pw_qpolynomial_foreach_pw_qpolynomial Line | Count | Source | 56 | 3 | { | 57 | 3 | S(UNION,foreach_data) data = { fn, user }; | 58 | 3 | | 59 | 3 | if (!u) | 60 | 0 | return isl_stat_error; | 61 | 3 | | 62 | 3 | return isl_hash_table_foreach(u->space->ctx, &u->table, | 63 | 3 | &FN(UNION,call_on_copy), &data); | 64 | 3 | } |
|
65 | | |
66 | | /* Is the domain space of "entry" equal to the domain of "space"? |
67 | | */ |
68 | | static int FN(UNION,has_same_domain_space)(const void *entry, const void *val) |
69 | 794 | { |
70 | 794 | PART *part = (PART *)entry; |
71 | 794 | isl_space *space = (isl_space *) val; |
72 | 794 | |
73 | 794 | if (isl_space_is_set(space)) |
74 | 13 | return isl_space_is_set(part->dim); |
75 | 781 | |
76 | 781 | return isl_space_tuple_is_equal(part->dim, isl_dim_in, |
77 | 781 | space, isl_dim_in); |
78 | 781 | } isl_aff.c:isl_union_pw_aff_has_same_domain_space Line | Count | Source | 69 | 793 | { | 70 | 793 | PART *part = (PART *)entry; | 71 | 793 | isl_space *space = (isl_space *) val; | 72 | 793 | | 73 | 793 | if (isl_space_is_set(space)) | 74 | 13 | return isl_space_is_set(part->dim); | 75 | 780 | | 76 | 780 | return isl_space_tuple_is_equal(part->dim, isl_dim_in, | 77 | 780 | space, isl_dim_in); | 78 | 780 | } |
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_has_same_domain_space isl_polynomial.c:isl_union_pw_qpolynomial_has_same_domain_space Line | Count | Source | 69 | 1 | { | 70 | 1 | PART *part = (PART *)entry; | 71 | 1 | isl_space *space = (isl_space *) val; | 72 | 1 | | 73 | 1 | if (isl_space_is_set(space)) | 74 | 0 | return isl_space_is_set(part->dim); | 75 | 1 | | 76 | 1 | return isl_space_tuple_is_equal(part->dim, isl_dim_in, | 77 | 1 | space, isl_dim_in); | 78 | 1 | } |
|
79 | | |
80 | | /* Return the entry, if any, in "u" that lives in "space". |
81 | | * If "reserve" is set, then an entry is created if it does not exist yet. |
82 | | * Return NULL on error and isl_hash_table_entry_none if no entry was found. |
83 | | * Note that when "reserve" is set, the function will never return |
84 | | * isl_hash_table_entry_none. |
85 | | * |
86 | | * First look for the entry (if any) with the same domain space. |
87 | | * If it exists, then check if the range space also matches. |
88 | | */ |
89 | | static struct isl_hash_table_entry *FN(UNION,find_part_entry)( |
90 | | __isl_keep UNION *u, __isl_keep isl_space *space, int reserve) |
91 | 18.1k | { |
92 | 18.1k | isl_ctx *ctx; |
93 | 18.1k | uint32_t hash; |
94 | 18.1k | struct isl_hash_table_entry *entry; |
95 | 18.1k | isl_bool equal; |
96 | 18.1k | PART *part; |
97 | 18.1k | |
98 | 18.1k | if (!u || !space) |
99 | 0 | return NULL; |
100 | 18.1k | |
101 | 18.1k | ctx = FN(UNION,get_ctx)(u); |
102 | 18.1k | hash = isl_space_get_domain_hash(space); |
103 | 18.1k | entry = isl_hash_table_find(ctx, &u->table, hash, |
104 | 18.1k | &FN(UNION,has_same_domain_space), space, reserve); |
105 | 18.1k | if (!entry) |
106 | 2 | return reserve ? NULL : isl_hash_table_entry_none; |
107 | 18.1k | if (reserve && !entry->data17.3k ) |
108 | 17.3k | return entry; |
109 | 794 | part = entry->data; |
110 | 794 | equal = isl_space_tuple_is_equal(part->dim, isl_dim_out, |
111 | 794 | space, isl_dim_out); |
112 | 794 | if (equal < 0) |
113 | 0 | return NULL; |
114 | 794 | if (equal) |
115 | 794 | return entry; |
116 | 0 | if (!reserve) |
117 | 0 | return isl_hash_table_entry_none; |
118 | 0 | isl_die(FN(UNION,get_ctx)(u), isl_error_invalid, |
119 | 0 | "union expression can only contain a single " |
120 | 0 | "expression over a given domain", return NULL); |
121 | 0 | } isl_aff.c:isl_union_pw_aff_find_part_entry Line | Count | Source | 91 | 18.0k | { | 92 | 18.0k | isl_ctx *ctx; | 93 | 18.0k | uint32_t hash; | 94 | 18.0k | struct isl_hash_table_entry *entry; | 95 | 18.0k | isl_bool equal; | 96 | 18.0k | PART *part; | 97 | 18.0k | | 98 | 18.0k | if (!u || !space) | 99 | 0 | return NULL; | 100 | 18.0k | | 101 | 18.0k | ctx = FN(UNION,get_ctx)(u); | 102 | 18.0k | hash = isl_space_get_domain_hash(space); | 103 | 18.0k | entry = isl_hash_table_find(ctx, &u->table, hash, | 104 | 18.0k | &FN(UNION,has_same_domain_space), space, reserve); | 105 | 18.0k | if (!entry) | 106 | 2 | return reserve ? NULL : isl_hash_table_entry_none; | 107 | 18.0k | if (reserve && !entry->data17.3k ) | 108 | 17.3k | return entry; | 109 | 793 | part = entry->data; | 110 | 793 | equal = isl_space_tuple_is_equal(part->dim, isl_dim_out, | 111 | 793 | space, isl_dim_out); | 112 | 793 | if (equal < 0) | 113 | 0 | return NULL; | 114 | 793 | if (equal) | 115 | 793 | return entry; | 116 | 0 | if (!reserve) | 117 | 0 | return isl_hash_table_entry_none; | 118 | 0 | isl_die(FN(UNION,get_ctx)(u), isl_error_invalid, | 119 | 0 | "union expression can only contain a single " | 120 | 0 | "expression over a given domain", return NULL); | 121 | 0 | } |
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_find_part_entry isl_polynomial.c:isl_union_pw_qpolynomial_find_part_entry Line | Count | Source | 91 | 6 | { | 92 | 6 | isl_ctx *ctx; | 93 | 6 | uint32_t hash; | 94 | 6 | struct isl_hash_table_entry *entry; | 95 | 6 | isl_bool equal; | 96 | 6 | PART *part; | 97 | 6 | | 98 | 6 | if (!u || !space) | 99 | 0 | return NULL; | 100 | 6 | | 101 | 6 | ctx = FN(UNION,get_ctx)(u); | 102 | 6 | hash = isl_space_get_domain_hash(space); | 103 | 6 | entry = isl_hash_table_find(ctx, &u->table, hash, | 104 | 6 | &FN(UNION,has_same_domain_space), space, reserve); | 105 | 6 | if (!entry) | 106 | 0 | return reserve ? NULL : isl_hash_table_entry_none; | 107 | 6 | if (reserve && !entry->data5 ) | 108 | 5 | return entry; | 109 | 1 | part = entry->data; | 110 | 1 | equal = isl_space_tuple_is_equal(part->dim, isl_dim_out, | 111 | 1 | space, isl_dim_out); | 112 | 1 | if (equal < 0) | 113 | 0 | return NULL; | 114 | 1 | if (equal) | 115 | 1 | return entry; | 116 | 0 | if (!reserve) | 117 | 0 | return isl_hash_table_entry_none; | 118 | 0 | isl_die(FN(UNION,get_ctx)(u), isl_error_invalid, | 119 | 0 | "union expression can only contain a single " | 120 | 0 | "expression over a given domain", return NULL); | 121 | 0 | } |
|
122 | | |
123 | | /* Remove "part_entry" from the hash table of "u". |
124 | | */ |
125 | | static __isl_give UNION *FN(UNION,remove_part_entry)(__isl_take UNION *u, |
126 | | struct isl_hash_table_entry *part_entry) |
127 | 0 | { |
128 | 0 | isl_ctx *ctx; |
129 | 0 |
|
130 | 0 | if (!u || !part_entry) |
131 | 0 | return FN(UNION,free)(u); |
132 | 0 |
|
133 | 0 | ctx = FN(UNION,get_ctx)(u); |
134 | 0 | isl_hash_table_remove(ctx, &u->table, part_entry); |
135 | 0 | FN(PART,free)(part_entry->data); |
136 | 0 |
|
137 | 0 | return u; |
138 | 0 | } Unexecuted instantiation: isl_aff.c:isl_union_pw_aff_remove_part_entry Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_remove_part_entry Unexecuted instantiation: isl_polynomial.c:isl_union_pw_qpolynomial_remove_part_entry |
139 | | |
140 | | /* Check that the domain of "part" is disjoint from the domain of the entries |
141 | | * in "u" that are defined on the same domain space, but have a different |
142 | | * target space. |
143 | | * Since a UNION with a single entry per domain space is not allowed |
144 | | * to contain two entries with the same domain space, there cannot be |
145 | | * any such other entry. |
146 | | */ |
147 | | static isl_stat FN(UNION,check_disjoint_domain_other)(__isl_keep UNION *u, |
148 | | __isl_keep PART *part) |
149 | 17.3k | { |
150 | 17.3k | return isl_stat_ok; |
151 | 17.3k | } isl_aff.c:isl_union_pw_aff_check_disjoint_domain_other Line | Count | Source | 149 | 17.3k | { | 150 | 17.3k | return isl_stat_ok; | 151 | 17.3k | } |
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_check_disjoint_domain_other isl_polynomial.c:isl_union_pw_qpolynomial_check_disjoint_domain_other Line | Count | Source | 149 | 5 | { | 150 | 5 | return isl_stat_ok; | 151 | 5 | } |
|
152 | | |
153 | | /* Check that the domain of "part1" is disjoint from the domain of "part2". |
154 | | * This check is performed before "part2" is added to a UNION to ensure |
155 | | * that the UNION expression remains a function. |
156 | | * Since a UNION with a single entry per domain space is not allowed |
157 | | * to contain two entries with the same domain space, fail unconditionally. |
158 | | */ |
159 | | static isl_stat FN(UNION,check_disjoint_domain)(__isl_keep PART *part1, |
160 | | __isl_keep PART *part2) |
161 | 0 | { |
162 | 0 | isl_die(FN(PART,get_ctx)(part1), isl_error_invalid, |
163 | 0 | "additional part should live on separate space", |
164 | 0 | return isl_stat_error); |
165 | 0 | } Unexecuted instantiation: isl_aff.c:isl_union_pw_aff_check_disjoint_domain Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_check_disjoint_domain Unexecuted instantiation: isl_polynomial.c:isl_union_pw_qpolynomial_check_disjoint_domain |
166 | | |
167 | | /* Call "fn" on each part entry of "u". |
168 | | */ |
169 | | static isl_stat FN(UNION,foreach_inplace)(__isl_keep UNION *u, |
170 | | isl_stat (*fn)(void **part, void *user), void *user) |
171 | 770 | { |
172 | 770 | isl_ctx *ctx; |
173 | 770 | |
174 | 770 | if (!u) |
175 | 0 | return isl_stat_error; |
176 | 770 | ctx = FN(UNION,get_ctx)(u); |
177 | 770 | return isl_hash_table_foreach(ctx, &u->table, fn, user); |
178 | 770 | } isl_aff.c:isl_union_pw_aff_foreach_inplace Line | Count | Source | 171 | 769 | { | 172 | 769 | isl_ctx *ctx; | 173 | 769 | | 174 | 769 | if (!u) | 175 | 0 | return isl_stat_error; | 176 | 769 | ctx = FN(UNION,get_ctx)(u); | 177 | 769 | return isl_hash_table_foreach(ctx, &u->table, fn, user); | 178 | 769 | } |
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_foreach_inplace isl_polynomial.c:isl_union_pw_qpolynomial_foreach_inplace Line | Count | Source | 171 | 1 | { | 172 | 1 | isl_ctx *ctx; | 173 | 1 | | 174 | 1 | if (!u) | 175 | 0 | return isl_stat_error; | 176 | 1 | ctx = FN(UNION,get_ctx)(u); | 177 | 1 | return isl_hash_table_foreach(ctx, &u->table, fn, user); | 178 | 1 | } |
|
179 | | |
180 | | /* Does "u" have a single reference? |
181 | | * That is, can we change "u" inplace? |
182 | | */ |
183 | | static isl_bool FN(UNION,has_single_reference)(__isl_keep UNION *u) |
184 | 3.05k | { |
185 | 3.05k | if (!u) |
186 | 0 | return isl_bool_error; |
187 | 3.05k | return u->ref == 1; |
188 | 3.05k | } isl_aff.c:isl_union_pw_aff_has_single_reference Line | Count | Source | 184 | 3.05k | { | 185 | 3.05k | if (!u) | 186 | 0 | return isl_bool_error; | 187 | 3.05k | return u->ref == 1; | 188 | 3.05k | } |
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_has_single_reference Unexecuted instantiation: isl_polynomial.c:isl_union_pw_qpolynomial_has_single_reference |
189 | | |
190 | | static isl_stat FN(UNION,free_u_entry)(void **entry, void *user) |
191 | 17.2k | { |
192 | 17.2k | PART *part = *entry; |
193 | 17.2k | FN(PART,free)(part); |
194 | 17.2k | return isl_stat_ok; |
195 | 17.2k | } isl_aff.c:isl_union_pw_aff_free_u_entry Line | Count | Source | 191 | 17.2k | { | 192 | 17.2k | PART *part = *entry; | 193 | 17.2k | FN(PART,free)(part); | 194 | 17.2k | return isl_stat_ok; | 195 | 17.2k | } |
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_free_u_entry isl_polynomial.c:isl_union_pw_qpolynomial_free_u_entry Line | Count | Source | 191 | 5 | { | 192 | 5 | PART *part = *entry; | 193 | 5 | FN(PART,free)(part); | 194 | 5 | return isl_stat_ok; | 195 | 5 | } |
|
196 | | |
197 | | #include <isl_union_templ.c> |