From dddfcb758911e7983dec17880d073489131f4bf7 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 9 Jul 2011 12:03:55 +0200 Subject: [PATCH] add isl_pw_aff_cond Signed-off-by: Sven Verdoolaege --- doc/user.pod | 11 +++++++++++ include/isl/aff.h | 3 +++ isl_aff.c | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 76d82e53..9c6d2e68 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2412,6 +2412,17 @@ containing those elements in the domain of C where C is non-negative. #include + __isl_give isl_pw_aff *isl_pw_aff_cond( + __isl_take isl_set *cond, + __isl_take isl_pw_aff *pwaff_true, + __isl_take isl_pw_aff *pwaff_false); + +The function C performs a conditional operator +and returns an expression that is equal to C +for elements in C and equal to C for elements +not in C. + + #include __isl_give isl_pw_aff *isl_pw_aff_max( __isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2); diff --git a/include/isl/aff.h b/include/isl/aff.h index 1b61942e..4eec72ec 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -113,6 +113,9 @@ __isl_give isl_pw_aff *isl_pw_aff_neg(__isl_take isl_pw_aff *pwaff); __isl_give isl_pw_aff *isl_pw_aff_ceil(__isl_take isl_pw_aff *pwaff); __isl_give isl_pw_aff *isl_pw_aff_floor(__isl_take isl_pw_aff *pwaff); +__isl_give isl_pw_aff *isl_pw_aff_cond(__isl_take isl_set *cond, + __isl_take isl_pw_aff *pwaff_true, __isl_take isl_pw_aff *pwaff_false); + __isl_give isl_pw_aff *isl_pw_aff_scale_down(__isl_take isl_pw_aff *pwaff, isl_int f); diff --git a/isl_aff.c b/isl_aff.c index 6e01226b..82d9a556 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -1270,3 +1270,19 @@ __isl_give isl_pw_aff *isl_pw_aff_ceil(__isl_take isl_pw_aff *pwaff) return pwaff; } + +/* Return an affine expression that is equal to pwaff_true for elements + * in "cond" and to pwaff_false for elements not in "cond". + * That is, return cond ? pwaff_true : pwaff_false; + */ +__isl_give isl_pw_aff *isl_pw_aff_cond(__isl_take isl_set *cond, + __isl_take isl_pw_aff *pwaff_true, __isl_take isl_pw_aff *pwaff_false) +{ + isl_set *comp; + + comp = isl_set_complement(isl_set_copy(cond)); + pwaff_true = isl_pw_aff_intersect_domain(pwaff_true, cond); + pwaff_false = isl_pw_aff_intersect_domain(pwaff_false, comp); + + return isl_pw_aff_add_disjoint(pwaff_true, pwaff_false); +} -- 2.11.4.GIT