Home | History | Annotate | Download | only in dist

Lines Matching refs:PW

20 static __isl_give isl_set *FN(PW,better)(__isl_keep EL *el1, __isl_keep EL *el2,
26 /* Return a list containing the domains of the pieces of "pw".
28 static __isl_give isl_set_list *FN(PW,extract_domains)(__isl_keep PW *pw)
34 if (!pw)
36 ctx = FN(PW,get_ctx)(pw);
37 list = isl_set_list_alloc(ctx, pw->n);
38 for (i = 0; i < pw->n; ++i)
39 list = isl_set_list_add(list, isl_set_copy(pw->p[i].set));
48 static __isl_give isl_set *FN(PW,better_or_out)(__isl_take isl_set *set,
63 static __isl_give isl_set *FN(PW,worse_or_out)(__isl_take isl_set *set,
76 * "pw" holds the original piecewise expression.
79 S(PW,union_opt_cmp_data) {
80 PW *pw;
86 static void FN(PW,union_opt_cmp_data_clear)(S(PW,union_opt_cmp_data) *data)
89 FN(PW,free)(data->pw);
92 /* Given (potentially) updated cells "i" of data_i->pw and "j" of data_j->pw and
93 * a set "better" where the piece from data_j->pw is better
94 * than the piece from data_i->pw,
121 static isl_stat FN(PW,union_opt_cmp_split)(S(PW,union_opt_cmp_data) *data_i,
122 int i, S(PW,union_opt_cmp_data) *data_j, int j,
128 set_j = FN(PW,get_domain_at)(data_j->pw, j);
129 set_i = FN(PW,worse_or_out)(set_i, isl_set_copy(better), set_j);
131 set_i = FN(PW,get_domain_at)(data_i->pw, i);
133 set_j = FN(PW,better_or_out)(set_j, better, set_i);
139 /* Given (potentially) updated cells "i" of data_i->pw and "j" of data_j->pw and
145 static isl_stat FN(PW,union_opt_cmp_pair)(S(PW,union_opt_cmp_data) *data_i,
146 int i, S(PW,union_opt_cmp_data) *data_j, int j,
152 el_i = FN(PW,peek_base_at)(data_i->pw, i);
153 el_j = FN(PW,peek_base_at)(data_j->pw, j);
154 better = FN(PW,better)(el_j, el_i, cmp);
155 return FN(PW,union_opt_cmp_split)(data_i, i, data_j, j, better);
158 /* Given (potentially) updated cells "i" of data_i->pw and "j" of data_j->pw and
166 * where the piece from data_j->pw is better than the piece from data_i->pw.
173 * data_i->pw is always better than data_j->pw on the intersection.
175 * is equal to the cell "j" and data_i->pw is better on its entire cell.
177 * Similarly, if data_i->pw is never better than data_j->pw,
179 * where data_j->pw is better than data_i->pw.
181 static isl_stat FN(PW,union_opt_cmp_two)(S(PW,union_opt_cmp_data) *data_i,
182 int i, S(PW,union_opt_cmp_data) *data_j, int j,
189 set_i = FN(PW,peek_domain_at)(data_i->pw, i);
190 set_j = FN(PW,peek_domain_at)(data_j->pw, j);
195 return FN(PW,union_opt_cmp_pair)(data_i, i, data_j, j, cmp);
197 el_i = FN(PW,peek_base_at)(data_i->pw, i);
198 el_j = FN(PW,peek_base_at)(data_j->pw, j);
199 better = FN(PW,better)(el_i, el_j, cmp);
202 return FN(PW,union_opt_cmp_split)(data_j, j, data_i, i, better);
205 return FN(PW,union_opt_cmp_split)(data_j, j, data_i, i, better);
210 return FN(PW,union_opt_cmp_pair)(data_i, i, data_j, j, cmp);
213 /* Given two piecewise expressions data1->pw and data2->pw, replace
217 * The pieces of data1->pw and data2->pw are assumed to have been sorted
221 * Run through the pieces of data1->pw and data2->pw in order until they
222 * have both been exhausted, picking the piece from data1->pw or data2->pw
225 * in both data1->pw and data2->pw have the same function value expression,
229 static __isl_give PW *FN(PW,merge)(S(PW,union_opt_cmp_data) *data1,
230 S(PW,union_opt_cmp_data) *data2)
233 PW *res;
234 PW *pw1 = data1->pw;
235 PW *pw2 = data2->pw;
242 res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->n + pw2->n);
271 res = FN(PW,add_piece)(res, set, el);
295 static __isl_give PW *FN(PW,union_opt_cmp)(
296 __isl_take PW *pw1, __isl_take PW *pw2,
299 S(PW,union_opt_cmp_data) data[2] = { { pw1, NULL }, { pw2, NULL } };
302 PW *res = NULL;
313 if (FN(PW,is_empty)(pw1)) {
314 FN(PW,free)(pw1);
318 if (FN(PW,is_empty)(pw2)) {
319 FN(PW,free)(pw2);
324 data[i].pw = FN(PW,sort_unique)(data[i].pw);
325 data[i].cell = FN(PW,extract_domains)(data[i].pw);
328 n1 = FN(PW,n_piece)(data[0].pw);
329 n2 = FN(PW,n_piece)(data[1].pw);
337 set_i = FN(PW,peek_domain_at)(data[0].pw, i);
338 set_j = FN(PW,peek_domain_at)(data[1].pw, j);
344 if (FN(PW,union_opt_cmp_two)(&data[0], i,
350 res = FN(PW,merge)(&data[0], &data[1]);
352 FN(PW,union_opt_cmp_data_clear)(&data[i]);
357 FN(PW,union_opt_cmp_data_clear)(&data[i]);
358 return FN(PW,free)(res);