From 8dfc07ce8182c725ff3b386ede4bd96951e7c371 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 8 Jul 2013 14:35:48 +0200 Subject: [PATCH] add isl_pw_aff_from_range Signed-off-by: Sven Verdoolaege --- doc/user.pod | 2 ++ include/isl/aff.h | 1 + isl_pw_templ.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index d3d07e53..a3c16bac 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -3755,6 +3755,8 @@ Operations include __isl_give isl_aff *isl_aff_project_domain_on_params( __isl_take isl_aff *aff); + __isl_give isl_pw_aff *isl_pw_aff_from_range( + __isl_take isl_pw_aff *pwa); __isl_give isl_aff *isl_aff_gist_params( __isl_take isl_aff *aff, diff --git a/include/isl/aff.h b/include/isl/aff.h index 01478d4b..3f437903 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -179,6 +179,7 @@ __isl_give isl_pw_aff *isl_pw_aff_set_tuple_id(__isl_take isl_pw_aff *pwaff, enum isl_dim_type type, __isl_take isl_id *id); __isl_give isl_set *isl_pw_aff_domain(__isl_take isl_pw_aff *pwaff); +__isl_give isl_pw_aff *isl_pw_aff_from_range(__isl_take isl_pw_aff *pwa); __isl_give isl_pw_aff *isl_pw_aff_min(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2); diff --git a/isl_pw_templ.c b/isl_pw_templ.c index c8c78946..72c0c701 100644 --- a/isl_pw_templ.c +++ b/isl_pw_templ.c @@ -1,3 +1,16 @@ +/* + * Copyright 2010-2011 INRIA Saclay + * Copyright 2011 Sven Verdoolaege + * Copyright 2012-2013 Ecole Normale Superieure + * + * Use of this software is governed by the MIT license + * + * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, + * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, + * 91893 Orsay, France + * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France + */ + #include #include @@ -726,6 +739,26 @@ static int FN(PW,exploit_equalities_and_remove_if_empty)(__isl_keep PW *pw, return 0; } +/* Convert a piecewise expression defined over a parameter domain + * into one that is defined over a zero-dimensional set. + */ +__isl_give PW *FN(PW,from_range)(__isl_take PW *pw) +{ + isl_space *space; + + if (!pw) + return NULL; + if (!isl_space_is_set(pw->dim)) + isl_die(FN(PW,get_ctx)(pw), isl_error_invalid, + "not living in a set space", return FN(PW,free)(pw)); + + space = FN(PW,get_space)(pw); + space = isl_space_from_range(space); + pw = FN(PW,reset_space)(pw, space); + + return pw; +} + /* Restrict the domain of "pw" by combining each cell * with "set" through a call to "fn", where "fn" may be * isl_set_intersect or isl_set_intersect_params. -- 2.11.4.GIT