isl_ast_codegen.c: create_node_scaled: hoist inclusion of stride guard
[isl.git] / isl_multi_templ.c
blobc02918622ef280cca3ecdef1bc2f7b7ee11b0636
1 /*
2 * Copyright 2011 Sven Verdoolaege
3 * Copyright 2012-2013 Ecole Normale Superieure
5 * Use of this software is governed by the MIT license
7 * Written by Sven Verdoolaege,
8 * Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
9 */
11 #include <isl_space_private.h>
12 #include <isl/set.h>
13 #include <isl_reordering.h>
15 #define xCAT(A,B) A ## B
16 #define CAT(A,B) xCAT(A,B)
17 #undef EL
18 #define EL CAT(isl_,BASE)
19 #define xFN(TYPE,NAME) TYPE ## _ ## NAME
20 #define FN(TYPE,NAME) xFN(TYPE,NAME)
21 #define xMULTI(BASE) isl_multi_ ## BASE
22 #define MULTI(BASE) xMULTI(BASE)
23 #define MULTI_NAME(BASE) "isl_multi_" #BASE
24 #define xLIST(EL) EL ## _list
25 #define LIST(EL) xLIST(EL)
27 isl_ctx *FN(MULTI(BASE),get_ctx)(__isl_keep MULTI(BASE) *multi)
29 return multi ? isl_space_get_ctx(multi->space) : NULL;
32 __isl_give isl_space *FN(MULTI(BASE),get_space)(__isl_keep MULTI(BASE) *multi)
34 return multi ? isl_space_copy(multi->space) : NULL;
37 __isl_give isl_space *FN(MULTI(BASE),get_domain_space)(
38 __isl_keep MULTI(BASE) *multi)
40 return multi ? isl_space_domain(isl_space_copy(multi->space)) : NULL;
43 __isl_give MULTI(BASE) *FN(MULTI(BASE),alloc)(__isl_take isl_space *space)
45 isl_ctx *ctx;
46 int n;
47 MULTI(BASE) *multi;
49 if (!space)
50 return NULL;
52 ctx = isl_space_get_ctx(space);
53 n = isl_space_dim(space, isl_dim_out);
54 multi = isl_calloc(ctx, MULTI(BASE),
55 sizeof(MULTI(BASE)) + (n - 1) * sizeof(struct EL *));
56 if (!multi)
57 goto error;
59 multi->space = space;
60 multi->n = n;
61 multi->ref = 1;
62 return multi;
63 error:
64 isl_space_free(space);
65 return NULL;
68 __isl_give MULTI(BASE) *FN(MULTI(BASE),dup)(__isl_keep MULTI(BASE) *multi)
70 int i;
71 MULTI(BASE) *dup;
73 if (!multi)
74 return NULL;
76 dup = FN(MULTI(BASE),alloc)(isl_space_copy(multi->space));
77 if (!dup)
78 return NULL;
80 for (i = 0; i < multi->n; ++i)
81 dup = FN(FN(MULTI(BASE),set),BASE)(dup, i,
82 FN(EL,copy)(multi->p[i]));
84 return dup;
87 __isl_give MULTI(BASE) *FN(MULTI(BASE),cow)(__isl_take MULTI(BASE) *multi)
89 if (!multi)
90 return NULL;
92 if (multi->ref == 1)
93 return multi;
95 multi->ref--;
96 return FN(MULTI(BASE),dup)(multi);
99 __isl_give MULTI(BASE) *FN(MULTI(BASE),copy)(__isl_keep MULTI(BASE) *multi)
101 if (!multi)
102 return NULL;
104 multi->ref++;
105 return multi;
108 __isl_null MULTI(BASE) *FN(MULTI(BASE),free)(__isl_take MULTI(BASE) *multi)
110 int i;
112 if (!multi)
113 return NULL;
115 if (--multi->ref > 0)
116 return NULL;
118 isl_space_free(multi->space);
119 for (i = 0; i < multi->n; ++i)
120 FN(EL,free)(multi->p[i]);
121 free(multi);
123 return NULL;
126 /* Check whether "multi" has non-zero coefficients for any dimension
127 * in the given range or if any of these dimensions appear
128 * with non-zero coefficients in any of the integer divisions involved.
130 int FN(MULTI(BASE),involves_dims)(__isl_keep MULTI(BASE) *multi,
131 enum isl_dim_type type, unsigned first, unsigned n)
133 int i;
135 if (!multi)
136 return -1;
137 if (multi->n == 0 || n == 0)
138 return 0;
140 for (i = 0; i < multi->n; ++i) {
141 int involves;
143 involves = FN(EL,involves_dims)(multi->p[i], type, first, n);
144 if (involves < 0 || involves)
145 return involves;
148 return 0;
151 __isl_give MULTI(BASE) *FN(MULTI(BASE),insert_dims)(
152 __isl_take MULTI(BASE) *multi,
153 enum isl_dim_type type, unsigned first, unsigned n)
155 int i;
157 if (!multi)
158 return NULL;
159 if (type == isl_dim_out)
160 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
161 "cannot insert output/set dimensions",
162 return FN(MULTI(BASE),free)(multi));
163 if (n == 0 && !isl_space_is_named_or_nested(multi->space, type))
164 return multi;
166 multi = FN(MULTI(BASE),cow)(multi);
167 if (!multi)
168 return NULL;
170 multi->space = isl_space_insert_dims(multi->space, type, first, n);
171 if (!multi->space)
172 return FN(MULTI(BASE),free)(multi);
174 for (i = 0; i < multi->n; ++i) {
175 multi->p[i] = FN(EL,insert_dims)(multi->p[i], type, first, n);
176 if (!multi->p[i])
177 return FN(MULTI(BASE),free)(multi);
180 return multi;
183 __isl_give MULTI(BASE) *FN(MULTI(BASE),add_dims)(__isl_take MULTI(BASE) *multi,
184 enum isl_dim_type type, unsigned n)
186 unsigned pos;
188 pos = FN(MULTI(BASE),dim)(multi, type);
190 return FN(MULTI(BASE),insert_dims)(multi, type, pos, n);
193 unsigned FN(MULTI(BASE),dim)(__isl_keep MULTI(BASE) *multi,
194 enum isl_dim_type type)
196 return multi ? isl_space_dim(multi->space, type) : 0;
199 /* Return the position of the first dimension of "type" with id "id".
200 * Return -1 if there is no such dimension.
202 int FN(MULTI(BASE),find_dim_by_id)(__isl_keep MULTI(BASE) *multi,
203 enum isl_dim_type type, __isl_keep isl_id *id)
205 if (!multi)
206 return -1;
207 return isl_space_find_dim_by_id(multi->space, type, id);
210 /* Return the id of the given dimension.
212 __isl_give isl_id *FN(MULTI(BASE),get_dim_id)(__isl_keep MULTI(BASE) *multi,
213 enum isl_dim_type type, unsigned pos)
215 return multi ? isl_space_get_dim_id(multi->space, type, pos) : NULL;
218 __isl_give MULTI(BASE) *FN(MULTI(BASE),set_dim_name)(
219 __isl_take MULTI(BASE) *multi,
220 enum isl_dim_type type, unsigned pos, const char *s)
222 int i;
224 multi = FN(MULTI(BASE),cow)(multi);
225 if (!multi)
226 return NULL;
228 multi->space = isl_space_set_dim_name(multi->space, type, pos, s);
229 if (!multi->space)
230 return FN(MULTI(BASE),free)(multi);
232 if (type == isl_dim_out)
233 return multi;
234 for (i = 0; i < multi->n; ++i) {
235 multi->p[i] = FN(EL,set_dim_name)(multi->p[i], type, pos, s);
236 if (!multi->p[i])
237 return FN(MULTI(BASE),free)(multi);
240 return multi;
243 const char *FN(MULTI(BASE),get_tuple_name)(__isl_keep MULTI(BASE) *multi,
244 enum isl_dim_type type)
246 return multi ? isl_space_get_tuple_name(multi->space, type) : NULL;
249 /* Does the specified tuple have an id?
251 int FN(MULTI(BASE),has_tuple_id)(__isl_keep MULTI(BASE) *multi,
252 enum isl_dim_type type)
254 return multi ? isl_space_has_tuple_id(multi->space, type) : -1;
257 /* Return the id of the specified tuple.
259 __isl_give isl_id *FN(MULTI(BASE),get_tuple_id)(__isl_keep MULTI(BASE) *multi,
260 enum isl_dim_type type)
262 return multi ? isl_space_get_tuple_id(multi->space, type) : NULL;
265 __isl_give EL *FN(FN(MULTI(BASE),get),BASE)(__isl_keep MULTI(BASE) *multi,
266 int pos)
268 isl_ctx *ctx;
270 if (!multi)
271 return NULL;
272 ctx = FN(MULTI(BASE),get_ctx)(multi);
273 if (pos < 0 || pos >= multi->n)
274 isl_die(ctx, isl_error_invalid,
275 "index out of bounds", return NULL);
276 return FN(EL,copy)(multi->p[pos]);
279 __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),set),BASE)(
280 __isl_take MULTI(BASE) *multi, int pos, __isl_take EL *el)
282 isl_space *multi_space = NULL;
283 isl_space *el_space = NULL;
284 int match;
286 multi = FN(MULTI(BASE),cow)(multi);
287 if (!multi || !el)
288 goto error;
290 multi_space = FN(MULTI(BASE),get_space)(multi);
291 match = FN(EL,matching_params)(el, multi_space);
292 if (match < 0)
293 goto error;
294 if (!match) {
295 multi = FN(MULTI(BASE),align_params)(multi,
296 FN(EL,get_space)(el));
297 isl_space_free(multi_space);
298 multi_space = FN(MULTI(BASE),get_space)(multi);
299 el = FN(EL,align_params)(el, isl_space_copy(multi_space));
301 if (FN(EL,check_match_domain_space)(el, multi_space) < 0)
302 goto error;
304 if (pos < 0 || pos >= multi->n)
305 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
306 "index out of bounds", goto error);
308 FN(EL,free)(multi->p[pos]);
309 multi->p[pos] = el;
311 isl_space_free(multi_space);
312 isl_space_free(el_space);
314 return multi;
315 error:
316 FN(MULTI(BASE),free)(multi);
317 FN(EL,free)(el);
318 isl_space_free(multi_space);
319 isl_space_free(el_space);
320 return NULL;
323 /* Reset the space of "multi". This function is called from isl_pw_templ.c
324 * and doesn't know if the space of an element object is represented
325 * directly or through its domain. It therefore passes along both,
326 * which we pass along to the element function since we don't how
327 * that is represented either.
329 __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_space_and_domain)(
330 __isl_take MULTI(BASE) *multi, __isl_take isl_space *space,
331 __isl_take isl_space *domain)
333 int i;
335 multi = FN(MULTI(BASE),cow)(multi);
336 if (!multi || !space || !domain)
337 goto error;
339 for (i = 0; i < multi->n; ++i) {
340 multi->p[i] = FN(EL,reset_domain_space)(multi->p[i],
341 isl_space_copy(domain));
342 if (!multi->p[i])
343 goto error;
345 isl_space_free(domain);
346 isl_space_free(multi->space);
347 multi->space = space;
349 return multi;
350 error:
351 isl_space_free(domain);
352 isl_space_free(space);
353 FN(MULTI(BASE),free)(multi);
354 return NULL;
357 __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_domain_space)(
358 __isl_take MULTI(BASE) *multi, __isl_take isl_space *domain)
360 isl_space *space;
362 space = isl_space_extend_domain_with_range(isl_space_copy(domain),
363 isl_space_copy(multi->space));
364 return FN(MULTI(BASE),reset_space_and_domain)(multi, space, domain);
367 __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_space)(
368 __isl_take MULTI(BASE) *multi, __isl_take isl_space *space)
370 isl_space *domain;
372 domain = isl_space_domain(isl_space_copy(space));
373 return FN(MULTI(BASE),reset_space_and_domain)(multi, space, domain);
376 /* Set the id of the given dimension of "multi" to "id".
378 __isl_give MULTI(BASE) *FN(MULTI(BASE),set_dim_id)(
379 __isl_take MULTI(BASE) *multi,
380 enum isl_dim_type type, unsigned pos, __isl_take isl_id *id)
382 isl_space *space;
384 multi = FN(MULTI(BASE),cow)(multi);
385 if (!multi || !id)
386 goto error;
388 space = FN(MULTI(BASE),get_space)(multi);
389 space = isl_space_set_dim_id(space, type, pos, id);
391 return FN(MULTI(BASE),reset_space)(multi, space);
392 error:
393 isl_id_free(id);
394 FN(MULTI(BASE),free)(multi);
395 return NULL;
398 __isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_name)(
399 __isl_keep MULTI(BASE) *multi, enum isl_dim_type type,
400 const char *s)
402 isl_space *space;
404 multi = FN(MULTI(BASE),cow)(multi);
405 if (!multi)
406 return NULL;
408 space = FN(MULTI(BASE),get_space)(multi);
409 space = isl_space_set_tuple_name(space, type, s);
411 return FN(MULTI(BASE),reset_space)(multi, space);
414 __isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_id)(
415 __isl_take MULTI(BASE) *multi, enum isl_dim_type type,
416 __isl_take isl_id *id)
418 isl_space *space;
420 multi = FN(MULTI(BASE),cow)(multi);
421 if (!multi)
422 goto error;
424 space = FN(MULTI(BASE),get_space)(multi);
425 space = isl_space_set_tuple_id(space, type, id);
427 return FN(MULTI(BASE),reset_space)(multi, space);
428 error:
429 isl_id_free(id);
430 return NULL;
433 /* Drop the id on the specified tuple.
435 __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_tuple_id)(
436 __isl_take MULTI(BASE) *multi, enum isl_dim_type type)
438 isl_space *space;
440 if (!multi)
441 return NULL;
442 if (!FN(MULTI(BASE),has_tuple_id)(multi, type))
443 return multi;
445 multi = FN(MULTI(BASE),cow)(multi);
446 if (!multi)
447 return NULL;
449 space = FN(MULTI(BASE),get_space)(multi);
450 space = isl_space_reset_tuple_id(space, type);
452 return FN(MULTI(BASE),reset_space)(multi, space);
455 /* Reset the user pointer on all identifiers of parameters and tuples
456 * of the space of "multi".
458 __isl_give MULTI(BASE) *FN(MULTI(BASE),reset_user)(
459 __isl_take MULTI(BASE) *multi)
461 isl_space *space;
463 space = FN(MULTI(BASE),get_space)(multi);
464 space = isl_space_reset_user(space);
466 return FN(MULTI(BASE),reset_space)(multi, space);
469 __isl_give MULTI(BASE) *FN(MULTI(BASE),realign_domain)(
470 __isl_take MULTI(BASE) *multi, __isl_take isl_reordering *exp)
472 int i;
474 multi = FN(MULTI(BASE),cow)(multi);
475 if (!multi || !exp)
476 goto error;
478 for (i = 0; i < multi->n; ++i) {
479 multi->p[i] = FN(EL,realign_domain)(multi->p[i],
480 isl_reordering_copy(exp));
481 if (!multi->p[i])
482 goto error;
485 multi = FN(MULTI(BASE),reset_domain_space)(multi,
486 isl_space_copy(exp->dim));
488 isl_reordering_free(exp);
489 return multi;
490 error:
491 isl_reordering_free(exp);
492 FN(MULTI(BASE),free)(multi);
493 return NULL;
496 /* Align the parameters of "multi" to those of "model".
498 __isl_give MULTI(BASE) *FN(MULTI(BASE),align_params)(
499 __isl_take MULTI(BASE) *multi, __isl_take isl_space *model)
501 isl_ctx *ctx;
502 isl_reordering *exp;
504 if (!multi || !model)
505 goto error;
507 if (isl_space_match(multi->space, isl_dim_param,
508 model, isl_dim_param)) {
509 isl_space_free(model);
510 return multi;
513 ctx = isl_space_get_ctx(model);
514 if (!isl_space_has_named_params(model))
515 isl_die(ctx, isl_error_invalid,
516 "model has unnamed parameters", goto error);
517 if (!isl_space_has_named_params(multi->space))
518 isl_die(ctx, isl_error_invalid,
519 "input has unnamed parameters", goto error);
521 model = isl_space_params(model);
522 exp = isl_parameter_alignment_reordering(multi->space, model);
523 exp = isl_reordering_extend_space(exp,
524 FN(MULTI(BASE),get_domain_space)(multi));
525 multi = FN(MULTI(BASE),realign_domain)(multi, exp);
527 isl_space_free(model);
528 return multi;
529 error:
530 isl_space_free(model);
531 FN(MULTI(BASE),free)(multi);
532 return NULL;
535 #if !defined(NO_GIST) || !defined(NO_INTERSECT_DOMAIN)
536 static __isl_give MULTI(BASE) *FN(MULTI(BASE),align_params_multi_set_and)(
537 __isl_take MULTI(BASE) *multi, __isl_take isl_set *set,
538 __isl_give MULTI(BASE) *(*fn)(__isl_take MULTI(BASE) *multi,
539 __isl_take isl_set *set))
541 isl_ctx *ctx;
543 if (!multi || !set)
544 goto error;
545 if (isl_space_match(multi->space, isl_dim_param,
546 set->dim, isl_dim_param))
547 return fn(multi, set);
548 ctx = FN(MULTI(BASE),get_ctx)(multi);
549 if (!isl_space_has_named_params(multi->space) ||
550 !isl_space_has_named_params(set->dim))
551 isl_die(ctx, isl_error_invalid,
552 "unaligned unnamed parameters", goto error);
553 multi = FN(MULTI(BASE),align_params)(multi, isl_set_get_space(set));
554 set = isl_set_align_params(set, FN(MULTI(BASE),get_space)(multi));
555 return fn(multi, set);
556 error:
557 FN(MULTI(BASE),free)(multi);
558 isl_set_free(set);
559 return NULL;
561 #endif
563 #ifndef NO_GIST
564 __isl_give MULTI(BASE) *FN(MULTI(BASE),gist_aligned)(
565 __isl_take MULTI(BASE) *multi, __isl_take isl_set *context)
567 int i;
569 multi = FN(MULTI(BASE),cow)(multi);
570 if (!multi || !context)
571 goto error;
573 for (i = 0; i < multi->n; ++i) {
574 multi->p[i] = FN(EL,gist)(multi->p[i], isl_set_copy(context));
575 if (!multi->p[i])
576 goto error;
579 isl_set_free(context);
580 return multi;
581 error:
582 isl_set_free(context);
583 FN(MULTI(BASE),free)(multi);
584 return NULL;
587 __isl_give MULTI(BASE) *FN(MULTI(BASE),gist)(__isl_take MULTI(BASE) *multi,
588 __isl_take isl_set *context)
590 return FN(MULTI(BASE),align_params_multi_set_and)(multi, context,
591 &FN(MULTI(BASE),gist_aligned));
594 __isl_give MULTI(BASE) *FN(MULTI(BASE),gist_params)(
595 __isl_take MULTI(BASE) *multi, __isl_take isl_set *context)
597 isl_space *space = FN(MULTI(BASE),get_domain_space)(multi);
598 isl_set *dom_context = isl_set_universe(space);
599 dom_context = isl_set_intersect_params(dom_context, context);
600 return FN(MULTI(BASE),gist)(multi, dom_context);
602 #endif
604 #ifndef NO_INTERSECT_DOMAIN
605 /* Transform the domain of "multi" by combining it with "domain"
606 * using "fn".
608 * The parameters of "multi" and "domain" are assumed to have been aligned.
610 __isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_aligned)(
611 __isl_take MULTI(BASE) *multi, __isl_take isl_set *domain,
612 __isl_give EL *(*fn)(EL *el, __isl_take isl_set *set2))
614 int i;
616 if (!multi || !domain)
617 goto error;
619 if (multi->n == 0) {
620 isl_set_free(domain);
621 return multi;
624 multi = FN(MULTI(BASE),cow)(multi);
625 if (!multi)
626 goto error;
628 for (i = 0; i < multi->n; ++i) {
629 multi->p[i] = fn(multi->p[i], isl_set_copy(domain));
630 if (!multi->p[i])
631 goto error;
634 isl_set_free(domain);
635 return multi;
636 error:
637 isl_set_free(domain);
638 FN(MULTI(BASE),free)(multi);
639 return NULL;
642 /* Intersect the domain of "multi" with "domain".
644 * The parameters of "multi" and "domain" are assumed to have been aligned.
646 __isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_domain_aligned)(
647 __isl_take MULTI(BASE) *multi, __isl_take isl_set *domain)
649 return FN(MULTI(BASE),intersect_aligned)(multi, domain,
650 &FN(EL,intersect_domain));
653 /* Intersect the domain of "multi" with "domain".
655 __isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_domain)(
656 __isl_take MULTI(BASE) *multi, __isl_take isl_set *domain)
658 return FN(MULTI(BASE),align_params_multi_set_and)(multi, domain,
659 &FN(MULTI(BASE),intersect_domain_aligned));
662 /* Intersect the parameter domain of "multi" with "domain".
664 * The parameters of "multi" and "domain" are assumed to have been aligned.
666 __isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_params_aligned)(
667 __isl_take MULTI(BASE) *multi, __isl_take isl_set *domain)
669 return FN(MULTI(BASE),intersect_aligned)(multi, domain,
670 &FN(EL,intersect_params));
673 /* Intersect the parameter domain of "multi" with "domain".
675 __isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_params)(
676 __isl_take MULTI(BASE) *multi, __isl_take isl_set *domain)
678 return FN(MULTI(BASE),align_params_multi_set_and)(multi, domain,
679 &FN(MULTI(BASE),intersect_params_aligned));
681 #endif
683 __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),from),LIST(BASE))(
684 __isl_take isl_space *space, __isl_take LIST(EL) *list)
686 int i;
687 int n;
688 isl_ctx *ctx;
689 MULTI(BASE) *multi;
691 if (!space || !list)
692 goto error;
694 ctx = isl_space_get_ctx(space);
695 n = FN(FN(LIST(EL),n),BASE)(list);
696 if (n != isl_space_dim(space, isl_dim_out))
697 isl_die(ctx, isl_error_invalid,
698 "invalid number of elements in list", goto error);
700 multi = FN(MULTI(BASE),alloc)(isl_space_copy(space));
701 for (i = 0; i < n; ++i) {
702 multi = FN(FN(MULTI(BASE),set),BASE)(multi, i,
703 FN(FN(LIST(EL),get),BASE)(list, i));
706 isl_space_free(space);
707 FN(LIST(EL),free)(list);
708 return multi;
709 error:
710 isl_space_free(space);
711 FN(LIST(EL),free)(list);
712 return NULL;
715 #ifndef NO_IDENTITY
716 /* Create a multi expression in the given space that maps each
717 * input dimension to the corresponding output dimension.
719 __isl_give MULTI(BASE) *FN(MULTI(BASE),identity)(__isl_take isl_space *space)
721 int i, n;
722 isl_local_space *ls;
723 MULTI(BASE) *multi;
725 if (!space)
726 return NULL;
728 if (isl_space_is_set(space))
729 isl_die(isl_space_get_ctx(space), isl_error_invalid,
730 "expecting map space", goto error);
732 n = isl_space_dim(space, isl_dim_out);
733 if (n != isl_space_dim(space, isl_dim_in))
734 isl_die(isl_space_get_ctx(space), isl_error_invalid,
735 "number of input and output dimensions needs to be "
736 "the same", goto error);
738 multi = FN(MULTI(BASE),alloc)(isl_space_copy(space));
740 if (!n) {
741 isl_space_free(space);
742 return multi;
745 space = isl_space_domain(space);
746 ls = isl_local_space_from_space(space);
748 for (i = 0; i < n; ++i) {
749 EL *el;
750 el = FN(EL,var_on_domain)(isl_local_space_copy(ls),
751 isl_dim_set, i);
752 multi = FN(FN(MULTI(BASE),set),BASE)(multi, i, el);
755 isl_local_space_free(ls);
757 return multi;
758 error:
759 isl_space_free(space);
760 return NULL;
762 #endif
764 /* Construct a multi expression in the given space with value zero in
765 * each of the output dimensions.
767 __isl_give MULTI(BASE) *FN(MULTI(BASE),zero)(__isl_take isl_space *space)
769 int n;
770 MULTI(BASE) *multi;
772 if (!space)
773 return NULL;
775 n = isl_space_dim(space , isl_dim_out);
776 multi = FN(MULTI(BASE),alloc)(isl_space_copy(space));
778 if (!n)
779 isl_space_free(space);
780 else {
781 int i;
782 isl_local_space *ls;
783 EL *el;
785 space = isl_space_domain(space);
786 ls = isl_local_space_from_space(space);
787 el = FN(EL,zero_on_domain)(ls);
789 for (i = 0; i < n; ++i)
790 multi = FN(FN(MULTI(BASE),set),BASE)(multi, i,
791 FN(EL,copy)(el));
793 FN(EL,free)(el);
796 return multi;
799 #ifndef NO_FROM_BASE
800 __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),from),BASE)(__isl_take EL *el)
802 MULTI(BASE) *multi;
804 multi = FN(MULTI(BASE),alloc)(FN(EL,get_space)(el));
805 multi = FN(FN(MULTI(BASE),set),BASE)(multi, 0, el);
807 return multi;
809 #endif
811 __isl_give MULTI(BASE) *FN(MULTI(BASE),drop_dims)(
812 __isl_take MULTI(BASE) *multi,
813 enum isl_dim_type type, unsigned first, unsigned n)
815 int i;
816 unsigned dim;
818 multi = FN(MULTI(BASE),cow)(multi);
819 if (!multi)
820 return NULL;
822 dim = FN(MULTI(BASE),dim)(multi, type);
823 if (first + n > dim || first + n < first)
824 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
825 "index out of bounds",
826 return FN(MULTI(BASE),cow)(multi));
828 multi->space = isl_space_drop_dims(multi->space, type, first, n);
829 if (!multi->space)
830 return FN(MULTI(BASE),cow)(multi);
832 if (type == isl_dim_out) {
833 for (i = 0; i < n; ++i)
834 FN(EL,free)(multi->p[first + i]);
835 for (i = first; i + n < multi->n; ++i)
836 multi->p[i] = multi->p[i + n];
837 multi->n -= n;
839 return multi;
842 for (i = 0; i < multi->n; ++i) {
843 multi->p[i] = FN(EL,drop_dims)(multi->p[i], type, first, n);
844 if (!multi->p[i])
845 return FN(MULTI(BASE),cow)(multi);
848 return multi;
851 /* Align the parameters of "multi1" and "multi2" (if needed) and call "fn".
853 static __isl_give MULTI(BASE) *FN(MULTI(BASE),align_params_multi_multi_and)(
854 __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2,
855 __isl_give MULTI(BASE) *(*fn)(__isl_take MULTI(BASE) *multi1,
856 __isl_take MULTI(BASE) *multi2))
858 isl_ctx *ctx;
860 if (!multi1 || !multi2)
861 goto error;
862 if (isl_space_match(multi1->space, isl_dim_param,
863 multi2->space, isl_dim_param))
864 return fn(multi1, multi2);
865 ctx = FN(MULTI(BASE),get_ctx)(multi1);
866 if (!isl_space_has_named_params(multi1->space) ||
867 !isl_space_has_named_params(multi2->space))
868 isl_die(ctx, isl_error_invalid,
869 "unaligned unnamed parameters", goto error);
870 multi1 = FN(MULTI(BASE),align_params)(multi1,
871 FN(MULTI(BASE),get_space)(multi2));
872 multi2 = FN(MULTI(BASE),align_params)(multi2,
873 FN(MULTI(BASE),get_space)(multi1));
874 return fn(multi1, multi2);
875 error:
876 FN(MULTI(BASE),free)(multi1);
877 FN(MULTI(BASE),free)(multi2);
878 return NULL;
881 /* Given two MULTI(BASE)s A -> B and C -> D,
882 * construct a MULTI(BASE) (A * C) -> [B -> D].
884 * The parameters are assumed to have been aligned.
886 static __isl_give MULTI(BASE) *FN(MULTI(BASE),range_product_aligned)(
887 __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
889 int i, n1, n2;
890 EL *el;
891 isl_space *space;
892 MULTI(BASE) *res;
894 if (!multi1 || !multi2)
895 goto error;
897 space = isl_space_range_product(FN(MULTI(BASE),get_space)(multi1),
898 FN(MULTI(BASE),get_space)(multi2));
899 res = FN(MULTI(BASE),alloc)(space);
901 n1 = FN(MULTI(BASE),dim)(multi1, isl_dim_out);
902 n2 = FN(MULTI(BASE),dim)(multi2, isl_dim_out);
904 for (i = 0; i < n1; ++i) {
905 el = FN(FN(MULTI(BASE),get),BASE)(multi1, i);
906 res = FN(FN(MULTI(BASE),set),BASE)(res, i, el);
909 for (i = 0; i < n2; ++i) {
910 el = FN(FN(MULTI(BASE),get),BASE)(multi2, i);
911 res = FN(FN(MULTI(BASE),set),BASE)(res, n1 + i, el);
914 FN(MULTI(BASE),free)(multi1);
915 FN(MULTI(BASE),free)(multi2);
916 return res;
917 error:
918 FN(MULTI(BASE),free)(multi1);
919 FN(MULTI(BASE),free)(multi2);
920 return NULL;
923 /* Given two MULTI(BASE)s A -> B and C -> D,
924 * construct a MULTI(BASE) (A * C) -> [B -> D].
926 __isl_give MULTI(BASE) *FN(MULTI(BASE),range_product)(
927 __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
929 return FN(MULTI(BASE),align_params_multi_multi_and)(multi1, multi2,
930 &FN(MULTI(BASE),range_product_aligned));
933 /* Is the range of "multi" a wrapped relation?
935 int FN(MULTI(BASE),range_is_wrapping)(__isl_keep MULTI(BASE) *multi)
937 if (!multi)
938 return -1;
939 return isl_space_range_is_wrapping(multi->space);
942 /* Given a function A -> [B -> C], extract the function A -> B.
944 __isl_give MULTI(BASE) *FN(MULTI(BASE),range_factor_domain)(
945 __isl_take MULTI(BASE) *multi)
947 isl_space *space;
948 int total, keep;
950 if (!multi)
951 return NULL;
952 if (!isl_space_range_is_wrapping(multi->space))
953 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
954 "range is not a product",
955 return FN(MULTI(BASE),free)(multi));
957 space = FN(MULTI(BASE),get_space)(multi);
958 total = isl_space_dim(space, isl_dim_out);
959 space = isl_space_range_factor_domain(space);
960 keep = isl_space_dim(space, isl_dim_out);
961 multi = FN(MULTI(BASE),drop_dims)(multi,
962 isl_dim_out, keep, total - keep);
963 multi = FN(MULTI(BASE),reset_space)(multi, space);
965 return multi;
968 /* Given a function A -> [B -> C], extract the function A -> C.
970 __isl_give MULTI(BASE) *FN(MULTI(BASE),range_factor_range)(
971 __isl_take MULTI(BASE) *multi)
973 isl_space *space;
974 int total, keep;
976 if (!multi)
977 return NULL;
978 if (!isl_space_range_is_wrapping(multi->space))
979 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
980 "range is not a product",
981 return FN(MULTI(BASE),free)(multi));
983 space = FN(MULTI(BASE),get_space)(multi);
984 total = isl_space_dim(space, isl_dim_out);
985 space = isl_space_range_factor_range(space);
986 keep = isl_space_dim(space, isl_dim_out);
987 multi = FN(MULTI(BASE),drop_dims)(multi, isl_dim_out, 0, total - keep);
988 multi = FN(MULTI(BASE),reset_space)(multi, space);
990 return multi;
993 /* Given two MULTI(BASE)s A -> B and C -> D,
994 * construct a MULTI(BASE) [A -> C] -> [B -> D].
996 * The parameters are assumed to have been aligned.
998 __isl_give MULTI(BASE) *FN(MULTI(BASE),product_aligned)(
999 __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
1001 int i;
1002 EL *el;
1003 isl_space *space;
1004 MULTI(BASE) *res;
1005 int in1, in2, out1, out2;
1007 in1 = FN(MULTI(BASE),dim)(multi1, isl_dim_in);
1008 in2 = FN(MULTI(BASE),dim)(multi2, isl_dim_in);
1009 out1 = FN(MULTI(BASE),dim)(multi1, isl_dim_out);
1010 out2 = FN(MULTI(BASE),dim)(multi2, isl_dim_out);
1011 space = isl_space_product(FN(MULTI(BASE),get_space)(multi1),
1012 FN(MULTI(BASE),get_space)(multi2));
1013 res = FN(MULTI(BASE),alloc)(isl_space_copy(space));
1014 space = isl_space_domain(space);
1016 for (i = 0; i < out1; ++i) {
1017 el = FN(FN(MULTI(BASE),get),BASE)(multi1, i);
1018 el = FN(EL,insert_dims)(el, isl_dim_in, in1, in2);
1019 el = FN(EL,reset_domain_space)(el, isl_space_copy(space));
1020 res = FN(FN(MULTI(BASE),set),BASE)(res, i, el);
1023 for (i = 0; i < out2; ++i) {
1024 el = FN(FN(MULTI(BASE),get),BASE)(multi2, i);
1025 el = FN(EL,insert_dims)(el, isl_dim_in, 0, in1);
1026 el = FN(EL,reset_domain_space)(el, isl_space_copy(space));
1027 res = FN(FN(MULTI(BASE),set),BASE)(res, out1 + i, el);
1030 isl_space_free(space);
1031 FN(MULTI(BASE),free)(multi1);
1032 FN(MULTI(BASE),free)(multi2);
1033 return res;
1036 /* Given two MULTI(BASE)s A -> B and C -> D,
1037 * construct a MULTI(BASE) [A -> C] -> [B -> D].
1039 __isl_give MULTI(BASE) *FN(MULTI(BASE),product)(
1040 __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
1042 return FN(MULTI(BASE),align_params_multi_multi_and)(multi1, multi2,
1043 &FN(MULTI(BASE),product_aligned));
1046 __isl_give MULTI(BASE) *FN(MULTI(BASE),flatten_range)(
1047 __isl_take MULTI(BASE) *multi)
1049 if (!multi)
1050 return NULL;
1052 if (!multi->space->nested[1])
1053 return multi;
1055 multi = FN(MULTI(BASE),cow)(multi);
1056 if (!multi)
1057 return NULL;
1059 multi->space = isl_space_flatten_range(multi->space);
1060 if (!multi->space)
1061 return FN(MULTI(BASE),free)(multi);
1063 return multi;
1066 /* Given two MULTI(BASE)s A -> B and C -> D,
1067 * construct a MULTI(BASE) (A * C) -> (B, D).
1069 __isl_give MULTI(BASE) *FN(MULTI(BASE),flat_range_product)(
1070 __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2)
1072 MULTI(BASE) *multi;
1074 multi = FN(MULTI(BASE),range_product)(multi1, multi2);
1075 multi = FN(MULTI(BASE),flatten_range)(multi);
1076 return multi;
1079 /* Given two multi expressions, "multi1"
1081 * [A] -> [B1 B2]
1083 * where B2 starts at position "pos", and "multi2"
1085 * [A] -> [D]
1087 * return the multi expression
1089 * [A] -> [B1 D B2]
1091 __isl_give MULTI(BASE) *FN(MULTI(BASE),range_splice)(
1092 __isl_take MULTI(BASE) *multi1, unsigned pos,
1093 __isl_take MULTI(BASE) *multi2)
1095 MULTI(BASE) *res;
1096 unsigned dim;
1098 if (!multi1 || !multi2)
1099 goto error;
1101 dim = FN(MULTI(BASE),dim)(multi1, isl_dim_out);
1102 if (pos > dim)
1103 isl_die(FN(MULTI(BASE),get_ctx)(multi1), isl_error_invalid,
1104 "index out of bounds", goto error);
1106 res = FN(MULTI(BASE),copy)(multi1);
1107 res = FN(MULTI(BASE),drop_dims)(res, isl_dim_out, pos, dim - pos);
1108 multi1 = FN(MULTI(BASE),drop_dims)(multi1, isl_dim_out, 0, pos);
1110 res = FN(MULTI(BASE),flat_range_product)(res, multi2);
1111 res = FN(MULTI(BASE),flat_range_product)(res, multi1);
1113 return res;
1114 error:
1115 FN(MULTI(BASE),free)(multi1);
1116 FN(MULTI(BASE),free)(multi2);
1117 return NULL;
1120 /* Given two multi expressions, "multi1"
1122 * [A1 A2] -> [B1 B2]
1124 * where A2 starts at position "in_pos" and B2 starts at position "out_pos",
1125 * and "multi2"
1127 * [C] -> [D]
1129 * return the multi expression
1131 * [A1 C A2] -> [B1 D B2]
1133 * We first insert input dimensions to obtain
1135 * [A1 C A2] -> [B1 B2]
1137 * and
1139 * [A1 C A2] -> [D]
1141 * and then apply range_splice.
1143 __isl_give MULTI(BASE) *FN(MULTI(BASE),splice)(
1144 __isl_take MULTI(BASE) *multi1, unsigned in_pos, unsigned out_pos,
1145 __isl_take MULTI(BASE) *multi2)
1147 unsigned n_in1;
1148 unsigned n_in2;
1150 if (!multi1 || !multi2)
1151 goto error;
1153 n_in1 = FN(MULTI(BASE),dim)(multi1, isl_dim_in);
1154 if (in_pos > n_in1)
1155 isl_die(FN(MULTI(BASE),get_ctx)(multi1), isl_error_invalid,
1156 "index out of bounds", goto error);
1158 n_in2 = FN(MULTI(BASE),dim)(multi2, isl_dim_in);
1160 multi1 = FN(MULTI(BASE),insert_dims)(multi1, isl_dim_in, in_pos, n_in2);
1161 multi2 = FN(MULTI(BASE),insert_dims)(multi2, isl_dim_in, n_in2,
1162 n_in1 - in_pos);
1163 multi2 = FN(MULTI(BASE),insert_dims)(multi2, isl_dim_in, 0, in_pos);
1165 return FN(MULTI(BASE),range_splice)(multi1, out_pos, multi2);
1166 error:
1167 FN(MULTI(BASE),free)(multi1);
1168 FN(MULTI(BASE),free)(multi2);
1169 return NULL;
1172 /* This function is currently only used from isl_aff.c
1174 static __isl_give MULTI(BASE) *FN(MULTI(BASE),bin_op)(
1175 __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2,
1176 __isl_give EL *(*fn)(__isl_take EL *, __isl_take EL *))
1177 __attribute__ ((unused));
1179 /* Pairwise perform "fn" to the elements of "multi1" and "multi2" and
1180 * return the result.
1182 static __isl_give MULTI(BASE) *FN(MULTI(BASE),bin_op)(
1183 __isl_take MULTI(BASE) *multi1, __isl_take MULTI(BASE) *multi2,
1184 __isl_give EL *(*fn)(__isl_take EL *, __isl_take EL *))
1186 int i;
1187 isl_ctx *ctx;
1189 multi1 = FN(MULTI(BASE),cow)(multi1);
1190 if (!multi1 || !multi2)
1191 goto error;
1193 ctx = FN(MULTI(BASE),get_ctx)(multi1);
1194 if (!isl_space_is_equal(multi1->space, multi2->space))
1195 isl_die(ctx, isl_error_invalid,
1196 "spaces don't match", goto error);
1198 for (i = 0; i < multi1->n; ++i) {
1199 multi1->p[i] = fn(multi1->p[i], FN(EL,copy)(multi2->p[i]));
1200 if (!multi1->p[i])
1201 goto error;
1204 FN(MULTI(BASE),free)(multi2);
1205 return multi1;
1206 error:
1207 FN(MULTI(BASE),free)(multi1);
1208 FN(MULTI(BASE),free)(multi2);
1209 return NULL;
1212 /* Multiply the elements of "multi" by "v" and return the result.
1214 __isl_give MULTI(BASE) *FN(MULTI(BASE),scale_val)(__isl_take MULTI(BASE) *multi,
1215 __isl_take isl_val *v)
1217 int i;
1219 if (!multi || !v)
1220 goto error;
1222 if (isl_val_is_one(v)) {
1223 isl_val_free(v);
1224 return multi;
1227 if (!isl_val_is_rat(v))
1228 isl_die(isl_val_get_ctx(v), isl_error_invalid,
1229 "expecting rational factor", goto error);
1231 multi = FN(MULTI(BASE),cow)(multi);
1232 if (!multi)
1233 return NULL;
1235 for (i = 0; i < multi->n; ++i) {
1236 multi->p[i] = FN(EL,scale_val)(multi->p[i], isl_val_copy(v));
1237 if (!multi->p[i])
1238 goto error;
1241 isl_val_free(v);
1242 return multi;
1243 error:
1244 isl_val_free(v);
1245 return FN(MULTI(BASE),free)(multi);
1248 /* Multiply the elements of "multi" by the corresponding element of "mv"
1249 * and return the result.
1251 __isl_give MULTI(BASE) *FN(MULTI(BASE),scale_multi_val)(
1252 __isl_take MULTI(BASE) *multi, __isl_take isl_multi_val *mv)
1254 int i;
1256 if (!multi || !mv)
1257 goto error;
1259 if (!isl_space_tuple_match(multi->space, isl_dim_out,
1260 mv->space, isl_dim_set))
1261 isl_die(isl_multi_val_get_ctx(mv), isl_error_invalid,
1262 "spaces don't match", goto error);
1264 multi = FN(MULTI(BASE),cow)(multi);
1265 if (!multi)
1266 return NULL;
1268 for (i = 0; i < multi->n; ++i) {
1269 isl_val *v;
1271 v = isl_multi_val_get_val(mv, i);
1272 multi->p[i] = FN(EL,scale_val)(multi->p[i], v);
1273 if (!multi->p[i])
1274 goto error;
1277 isl_multi_val_free(mv);
1278 return multi;
1279 error:
1280 isl_multi_val_free(mv);
1281 return FN(MULTI(BASE),free)(multi);
1284 /* Divide the elements of "multi" by the corresponding element of "mv"
1285 * and return the result.
1287 __isl_give MULTI(BASE) *FN(MULTI(BASE),scale_down_multi_val)(
1288 __isl_take MULTI(BASE) *multi, __isl_take isl_multi_val *mv)
1290 int i;
1292 if (!multi || !mv)
1293 goto error;
1295 if (!isl_space_tuple_match(multi->space, isl_dim_out,
1296 mv->space, isl_dim_set))
1297 isl_die(isl_multi_val_get_ctx(mv), isl_error_invalid,
1298 "spaces don't match", goto error);
1300 multi = FN(MULTI(BASE),cow)(multi);
1301 if (!multi)
1302 return NULL;
1304 for (i = 0; i < multi->n; ++i) {
1305 isl_val *v;
1307 v = isl_multi_val_get_val(mv, i);
1308 multi->p[i] = FN(EL,scale_down_val)(multi->p[i], v);
1309 if (!multi->p[i])
1310 goto error;
1313 isl_multi_val_free(mv);
1314 return multi;
1315 error:
1316 isl_multi_val_free(mv);
1317 return FN(MULTI(BASE),free)(multi);
1320 #ifndef NO_MOVE_DIMS
1321 /* Move the "n" dimensions of "src_type" starting at "src_pos" of "multi"
1322 * to dimensions of "dst_type" at "dst_pos".
1324 * We only support moving input dimensions to parameters and vice versa.
1326 __isl_give MULTI(BASE) *FN(MULTI(BASE),move_dims)(__isl_take MULTI(BASE) *multi,
1327 enum isl_dim_type dst_type, unsigned dst_pos,
1328 enum isl_dim_type src_type, unsigned src_pos, unsigned n)
1330 int i;
1332 if (!multi)
1333 return NULL;
1335 if (n == 0 &&
1336 !isl_space_is_named_or_nested(multi->space, src_type) &&
1337 !isl_space_is_named_or_nested(multi->space, dst_type))
1338 return multi;
1340 if (dst_type == isl_dim_out || src_type == isl_dim_out)
1341 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
1342 "cannot move output/set dimension",
1343 return FN(MULTI(BASE),free)(multi));
1344 if (dst_type == isl_dim_div || src_type == isl_dim_div)
1345 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
1346 "cannot move divs",
1347 return FN(MULTI(BASE),free)(multi));
1348 if (src_pos + n > isl_space_dim(multi->space, src_type))
1349 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
1350 "range out of bounds",
1351 return FN(MULTI(BASE),free)(multi));
1352 if (dst_type == src_type)
1353 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_unsupported,
1354 "moving dims within the same type not supported",
1355 return FN(MULTI(BASE),free)(multi));
1357 multi = FN(MULTI(BASE),cow)(multi);
1358 if (!multi)
1359 return NULL;
1361 multi->space = isl_space_move_dims(multi->space, dst_type, dst_pos,
1362 src_type, src_pos, n);
1363 if (!multi->space)
1364 return FN(MULTI(BASE),free)(multi);
1366 for (i = 0; i < multi->n; ++i) {
1367 multi->p[i] = FN(EL,move_dims)(multi->p[i], dst_type, dst_pos,
1368 src_type, src_pos, n);
1369 if (!multi->p[i])
1370 return FN(MULTI(BASE),free)(multi);
1373 return multi;
1375 #endif
1377 /* Convert a multiple expression defined over a parameter domain
1378 * into one that is defined over a zero-dimensional set.
1380 __isl_give MULTI(BASE) *FN(MULTI(BASE),from_range)(
1381 __isl_take MULTI(BASE) *multi)
1383 isl_space *space;
1385 if (!multi)
1386 return NULL;
1387 if (!isl_space_is_set(multi->space))
1388 isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
1389 "not living in a set space",
1390 return FN(MULTI(BASE),free)(multi));
1392 space = FN(MULTI(BASE),get_space)(multi);
1393 space = isl_space_from_range(space);
1394 multi = FN(MULTI(BASE),reset_space)(multi, space);
1396 return multi;
1399 /* Are "multi1" and "multi2" obviously equal?
1401 int FN(MULTI(BASE),plain_is_equal)(__isl_keep MULTI(BASE) *multi1,
1402 __isl_keep MULTI(BASE) *multi2)
1404 int i;
1405 int equal;
1407 if (!multi1 || !multi2)
1408 return -1;
1409 if (multi1->n != multi2->n)
1410 return 0;
1411 equal = isl_space_is_equal(multi1->space, multi2->space);
1412 if (equal < 0 || !equal)
1413 return equal;
1415 for (i = 0; i < multi1->n; ++i) {
1416 equal = FN(EL,plain_is_equal)(multi1->p[i], multi2->p[i]);
1417 if (equal < 0 || !equal)
1418 return equal;
1421 return 1;
1424 #ifndef NO_DOMAIN
1425 /* Return the shared domain of the elements of "multi".
1427 __isl_give isl_set *FN(MULTI(BASE),domain)(__isl_take MULTI(BASE) *multi)
1429 int i;
1430 isl_set *dom;
1432 if (!multi)
1433 return NULL;
1435 dom = isl_set_universe(FN(MULTI(BASE),get_domain_space)(multi));
1436 for (i = 0; i < multi->n; ++i) {
1437 isl_set *dom_i;
1439 dom_i = FN(EL,domain)(FN(FN(MULTI(BASE),get),BASE)(multi, i));
1440 dom = isl_set_intersect(dom, dom_i);
1443 FN(MULTI(BASE),free)(multi);
1444 return dom;
1446 #endif