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));
79S(
PW,union_opt_cmp_data) {
86static void FN(
PW,union_opt_cmp_data_clear)(
S(
PW,union_opt_cmp_data) *data)
88 isl_set_list_free(data->cell);
89 FN(
PW,free)(data->pw);
122 int i,
S(
PW,union_opt_cmp_data) *data_j,
int j,
127 set_i = isl_set_list_get_set(data_i->cell, i);
128 set_j =
FN(
PW,get_domain_at)(data_j->pw, j);
130 data_i->cell = isl_set_list_set_set(data_i->cell, i, set_i);
131 set_i =
FN(
PW,get_domain_at)(data_i->pw, i);
132 set_j = isl_set_list_get_set(data_j->cell, j);
133 set_j =
FN(
PW,better_or_out)(set_j, better, set_i);
134 data_j->cell = isl_set_list_set_set(data_j->cell, j, set_j);
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);
182 int i,
S(
PW,union_opt_cmp_data) *data_j,
int j,
186 isl_set *better, *set_i, *set_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);
201 if (is_empty >= 0 && is_empty)
202 return FN(
PW,union_opt_cmp_split)(data_j, j, data_i, i, better);
204 if (is_subset >= 0 && is_subset)
205 return FN(
PW,union_opt_cmp_split)(data_j, j, data_i, i, better);
207 if (is_empty < 0 || is_subset < 0)
210 return FN(
PW,union_opt_cmp_pair)(data_i, i, data_j, j,
cmp);
230 S(
PW,union_opt_cmp_data) *data2)
245 while (i < pw1->
n || j < pw2->
n) {
250 if (i < pw1->
n && j < pw2->
n)
251 cmp =
FN(
EL,plain_cmp)(pw1->p[i].FIELD,
254 cmp = i < pw1->n ? -1 : 1;
257 set = isl_set_list_get_set(list1, i);
258 el =
FN(
EL,copy)(pw1->p[i].FIELD);
260 }
else if (
cmp > 0) {
261 set = isl_set_list_get_set(list2, j);
262 el =
FN(
EL,copy)(pw2->p[j].FIELD);
266 isl_set_list_get_set(list2, j));
267 el =
FN(
EL,copy)(pw1->p[i].FIELD);
299 S(
PW,union_opt_cmp_data) data[2] = { { pw1, NULL }, { pw2, NULL } };
311 "arguments should live in the same space",
goto error);
313 if (
FN(
PW,is_empty)(pw1)) {
318 if (
FN(
PW,is_empty)(pw2)) {
323 for (i = 0; i < 2; ++i) {
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);
330 if (n1 < 0 || n2 < 0)
332 for (i = 0; i < n1; ++i) {
333 for (j = 0; j < n2; ++j) {
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,
345 &data[1], j,
cmp) < 0)
351 for (i = 0; i < 2; ++i)
352 FN(
PW,union_opt_cmp_data_clear)(&data[i]);
356 for (i = 0; i < 2; ++i)
357 FN(
PW,union_opt_cmp_data_clear)(&data[i]);
#define isl_die(ctx, errno, msg, code)
int GMPQAPI() cmp(mp_rat op1, mp_rat op2)
static isl_stat merge(isl_ctx *ctx, struct isl_clustering *c, struct isl_sched_graph *merge_graph)
__isl_export __isl_give isl_set * isl_set_subtract(__isl_take isl_set *set1, __isl_take isl_set *set2)
__isl_export __isl_give isl_set * isl_set_union(__isl_take isl_set *set1, __isl_take isl_set *set2)
__isl_export isl_bool isl_set_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
__isl_null isl_set * isl_set_free(__isl_take isl_set *set)
__isl_export isl_bool isl_set_is_subset(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
__isl_give isl_set * isl_set_copy(__isl_keep isl_set *set)
__isl_export __isl_give isl_set * isl_set_intersect(__isl_take isl_set *set1, __isl_take isl_set *set2)
__isl_export isl_bool isl_set_is_empty(__isl_keep isl_set *set)
isl_ctx * isl_space_get_ctx(__isl_keep isl_space *space)
__isl_give isl_space * isl_space_copy(__isl_keep isl_space *space)
__isl_export isl_bool isl_space_is_equal(__isl_keep isl_space *space1, __isl_keep isl_space *space2)