1 /*
2 * Copyright 2023 Sven Verdoolaege
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege
7 */
8
9 /* Is "part" defined over a domain wrapping a binary relation?
10 */
FN(UNION,select_domain_is_wrapping_entry)11 static isl_bool FN(UNION,select_domain_is_wrapping_entry)(__isl_keep PART *part,
12 void *user)
13 {
14 return isl_space_domain_is_wrapping(FN(PART,peek_space)(part));
15 }
16
17 /* Wrapper around PART_domain_reverse for use
18 * as an isl_union_*_transform callback.
19 */
FN(UNION,domain_reverse_entry)20 static __isl_give PART *FN(UNION,domain_reverse_entry)(__isl_take PART *part,
21 void *user)
22 {
23 return FN(PART,domain_reverse)(part);
24 }
25
26 /* For each base expression defined on a domain (A -> B),
27 * interchange A and B in the wrapped domain
28 * to obtain an expression on the domain (B -> A) and
29 * collect the results.
30 */
FN(UNION,domain_reverse)31 __isl_give UNION *FN(UNION,domain_reverse)(__isl_keep UNION *u)
32 {
33 S(UNION,transform_control) control = {
34 .filter = &FN(UNION,select_domain_is_wrapping_entry),
35 .fn = &FN(UNION,domain_reverse_entry),
36 };
37
38 return FN(UNION,transform)(u, &control);
39 }
40