From a04aa8da531e03d2d36abb272967bf5883573d33 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 14 Jun 2013 08:26:50 +0200 Subject: [PATCH] add isl_multi_pw_aff_intersect_domain Signed-off-by: Sven Verdoolaege --- doc/user.pod | 4 ++++ include/isl/aff.h | 2 ++ isl_aff.c | 3 +++ isl_multi_templ.c | 43 ++++++++++++++++++++++++++++++++++++++++++- isl_val.c | 1 + 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/doc/user.pod b/doc/user.pod index ab19ffa7..659f8e18 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -4322,6 +4322,10 @@ by the corresponding elements of C. __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_domain( __isl_take isl_pw_multi_aff *pma, __isl_take isl_set *set); + __isl_give isl_multi_pw_aff * + isl_multi_pw_aff_intersect_domain( + __isl_take isl_multi_pw_aff *mpa, + __isl_take isl_set *domain); __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_intersect_domain( __isl_take isl_union_pw_multi_aff *upma, diff --git a/include/isl/aff.h b/include/isl/aff.h index a4400959..2407ba74 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -526,6 +526,8 @@ __isl_give isl_multi_pw_aff *isl_multi_pw_aff_identity( __isl_take isl_space *space); __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_aff( __isl_take isl_pw_aff *pa); +__isl_give isl_multi_pw_aff *isl_multi_pw_aff_intersect_domain( + __isl_take isl_multi_pw_aff *mpa, __isl_take isl_set *domain); __isl_give isl_multi_pw_aff *isl_multi_pw_aff_coalesce( __isl_take isl_multi_pw_aff *mpa); diff --git a/isl_aff.c b/isl_aff.c index c14b104f..481cc433 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -3242,9 +3242,12 @@ error: #undef BASE #define BASE aff +#define NO_INTERSECT_DOMAIN #include +#undef NO_INTERSECT_DOMAIN + /* Given a map space, return an isl_multi_aff that maps a wrapped copy * of the space to its domain. */ diff --git a/isl_multi_templ.c b/isl_multi_templ.c index 1e9d2b87..1184f917 100644 --- a/isl_multi_templ.c +++ b/isl_multi_templ.c @@ -487,7 +487,7 @@ error: return NULL; } -#ifndef NO_GIST +#if !defined(NO_GIST) || !defined(NO_INTERSECT_DOMAIN) static __isl_give MULTI(BASE) *FN(MULTI(BASE),align_params_multi_set_and)( __isl_take MULTI(BASE) *multi, __isl_take isl_set *set, __isl_give MULTI(BASE) *(*fn)(__isl_take MULTI(BASE) *multi, @@ -513,7 +513,9 @@ error: isl_set_free(set); return NULL; } +#endif +#ifndef NO_GIST __isl_give MULTI(BASE) *FN(MULTI(BASE),gist_aligned)( __isl_take MULTI(BASE) *multi, __isl_take isl_set *context) { @@ -554,6 +556,45 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),gist_params)( } #endif +#ifndef NO_INTERSECT_DOMAIN +/* Intersect the domain of "multi" with "domain". + * + * The parameters of "multi" and "domain" are assumed to have been aligned. + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_domain_aligned)( + __isl_take MULTI(BASE) *multi, __isl_take isl_set *domain) +{ + int i; + + multi = FN(MULTI(BASE),cow)(multi); + if (!multi || !domain) + goto error; + + for (i = 0; i < multi->n; ++i) { + multi->p[i] = FN(EL,intersect_domain)(multi->p[i], + isl_set_copy(domain)); + if (!multi->p[i]) + goto error; + } + + isl_set_free(domain); + return multi; +error: + isl_set_free(domain); + FN(MULTI(BASE),free)(multi); + return NULL; +} + +/* Intersect the domain of "multi" with "domain". + */ +__isl_give MULTI(BASE) *FN(MULTI(BASE),intersect_domain)( + __isl_take MULTI(BASE) *multi, __isl_take isl_set *domain) +{ + return FN(MULTI(BASE),align_params_multi_set_and)(multi, domain, + &FN(MULTI(BASE),intersect_domain_aligned)); +} +#endif + __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),from),LIST(BASE))( __isl_take isl_space *space, __isl_take LIST(EL) *list) { diff --git a/isl_val.c b/isl_val.c index f16a97d6..7b0aebde 100644 --- a/isl_val.c +++ b/isl_val.c @@ -1460,6 +1460,7 @@ int isl_val_check_match_domain_space(__isl_keep isl_val *v, #undef BASE #define BASE val +#define NO_INTERSECT_DOMAIN #define NO_GIST #define NO_IDENTITY #define NO_FROM_BASE -- 2.11.4.GIT