From 3905442bd3b9233f2b07996c1701ddb734049abe Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 25 Jul 2011 09:04:12 +0200 Subject: [PATCH] add isl_pw_aff_list_*_set Signed-off-by: Sven Verdoolaege --- doc/user.pod | 21 ++++++++++++++ include/isl/aff.h | 14 +++++++++ isl_aff.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 0ef1e1e1..1df5af92 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2578,12 +2578,33 @@ to be a constant. __isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2); + __isl_give isl_set *isl_pw_aff_list_eq_set( + __isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); + __isl_give isl_set *isl_pw_aff_list_ne_set( + __isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); + __isl_give isl_set *isl_pw_aff_list_le_set( + __isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); + __isl_give isl_set *isl_pw_aff_list_lt_set( + __isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); + __isl_give isl_set *isl_pw_aff_list_ge_set( + __isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); + __isl_give isl_set *isl_pw_aff_list_gt_set( + __isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); + The function C returns a basic set containing those elements in the shared space of C and C where C is greater than or equal to C. The function C returns a set containing those elements in the shared domain of C and C where C is greater than or equal to C. +The functions operating on C apply the corresponding +C function to each pair of elements in the two lists. #include __isl_give isl_set *isl_pw_aff_nonneg_set( diff --git a/include/isl/aff.h b/include/isl/aff.h index 2fd1c0be..d9813419 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -6,6 +6,7 @@ #include #include #include +#include #if defined(__cplusplus) extern "C" { @@ -173,6 +174,19 @@ __isl_give isl_printer *isl_printer_print_pw_aff(__isl_take isl_printer *p, __isl_keep isl_pw_aff *pwaff); void isl_pw_aff_dump(__isl_keep isl_pw_aff *pwaff); +__isl_give isl_set *isl_pw_aff_list_eq_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); +__isl_give isl_set *isl_pw_aff_list_ne_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); +__isl_give isl_set *isl_pw_aff_list_le_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); +__isl_give isl_set *isl_pw_aff_list_lt_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); +__isl_give isl_set *isl_pw_aff_list_ge_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); +__isl_give isl_set *isl_pw_aff_list_gt_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2); + #if defined(__cplusplus) } #endif diff --git a/isl_aff.c b/isl_aff.c index 99ea33ef..dc87ad9b 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1359,6 +1360,91 @@ __isl_give isl_set *isl_pw_aff_lt_set(__isl_take isl_pw_aff *pwaff1, } /* Return a set containing those elements in the shared domain + * of the elements of list1 and list2 where each element in list1 + * has the relation specified by "fn" with each element in list2. + */ +static __isl_give isl_set *pw_aff_list_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2, + __isl_give isl_set *(*fn)(__isl_take isl_pw_aff *pwaff1, + __isl_take isl_pw_aff *pwaff2)) +{ + int i, j; + isl_ctx *ctx; + isl_set *set; + + if (!list1 || !list2) + goto error; + + ctx = isl_pw_aff_list_get_ctx(list1); + if (list1->n < 1 || list2->n < 1) + isl_die(ctx, isl_error_invalid, + "list should contain at least one element", goto error); + + set = isl_set_universe(isl_pw_aff_get_dim(list1->p[0])); + for (i = 0; i < list1->n; ++i) + for (j = 0; j < list2->n; ++j) { + isl_set *set_ij; + + set_ij = fn(isl_pw_aff_copy(list1->p[i]), + isl_pw_aff_copy(list2->p[j])); + set = isl_set_intersect(set, set_ij); + } + + isl_pw_aff_list_free(list1); + isl_pw_aff_list_free(list2); + return set; +error: + isl_pw_aff_list_free(list1); + isl_pw_aff_list_free(list2); + return NULL; +} + +/* Return a set containing those elements in the shared domain + * of the elements of list1 and list2 where each element in list1 + * is equal to each element in list2. + */ +__isl_give isl_set *isl_pw_aff_list_eq_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2) +{ + return pw_aff_list_set(list1, list2, &isl_pw_aff_eq_set); +} + +__isl_give isl_set *isl_pw_aff_list_ne_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2) +{ + return pw_aff_list_set(list1, list2, &isl_pw_aff_ne_set); +} + +/* Return a set containing those elements in the shared domain + * of the elements of list1 and list2 where each element in list1 + * is less than or equal to each element in list2. + */ +__isl_give isl_set *isl_pw_aff_list_le_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2) +{ + return pw_aff_list_set(list1, list2, &isl_pw_aff_le_set); +} + +__isl_give isl_set *isl_pw_aff_list_lt_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2) +{ + return pw_aff_list_set(list1, list2, &isl_pw_aff_lt_set); +} + +__isl_give isl_set *isl_pw_aff_list_ge_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2) +{ + return pw_aff_list_set(list1, list2, &isl_pw_aff_ge_set); +} + +__isl_give isl_set *isl_pw_aff_list_gt_set(__isl_take isl_pw_aff_list *list1, + __isl_take isl_pw_aff_list *list2) +{ + return pw_aff_list_set(list1, list2, &isl_pw_aff_gt_set); +} + + +/* Return a set containing those elements in the shared domain * of pwaff1 and pwaff2 where pwaff1 is not equal to pwaff2. */ static __isl_give isl_set *pw_aff_ne_set(__isl_take isl_pw_aff *pwaff1, -- 2.11.4.GIT