From 434a5f8ee9341eec9d88fa9032e7fe7753494c93 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 26 Aug 2012 15:53:42 +0200 Subject: [PATCH] add isl_set_dim_has_{lower,upper}_bound Signed-off-by: Sven Verdoolaege --- doc/user.pod | 12 ++++++++++++ include/isl/set.h | 4 ++++ isl_map.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index e13d4893..9192efa1 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -176,6 +176,8 @@ A call C can be replaced by C have been renamed to C and C. +The new C and +C have slightly different meanings. =back @@ -1675,6 +1677,16 @@ a given dimension is involved in any lower or upper bound. int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set, enum isl_dim_type type, unsigned pos); +Note that these functions return true even if there is a bound on +the dimension on only some of the basic sets of C. +To check if they have a bound for all of the basic sets in C, +use the following functions instead. + + int isl_set_dim_has_lower_bound(__isl_keep isl_set *set, + enum isl_dim_type type, unsigned pos); + int isl_set_dim_has_upper_bound(__isl_keep isl_set *set, + enum isl_dim_type type, unsigned pos); + The identifiers or names of the domain and range spaces of a set or relation can be read off or set using the following functions. diff --git a/include/isl/set.h b/include/isl/set.h index 9dc59e8e..6552a8d9 100644 --- a/include/isl/set.h +++ b/include/isl/set.h @@ -419,6 +419,10 @@ int isl_set_plain_dim_has_fixed_lower_bound(__isl_keep isl_set *set, unsigned dim, isl_int *val); int isl_set_dim_is_bounded(__isl_keep isl_set *set, enum isl_dim_type type, unsigned pos); +int isl_set_dim_has_lower_bound(__isl_keep isl_set *set, + enum isl_dim_type type, unsigned pos); +int isl_set_dim_has_upper_bound(__isl_keep isl_set *set, + enum isl_dim_type type, unsigned pos); int isl_set_dim_has_any_lower_bound(__isl_keep isl_set *set, enum isl_dim_type type, unsigned pos); int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set, diff --git a/isl_map.c b/isl_map.c index 81543718..894f2bd4 100644 --- a/isl_map.c +++ b/isl_map.c @@ -9187,6 +9187,8 @@ int isl_set_dim_is_bounded(__isl_keep isl_set *set, return isl_map_dim_is_bounded((isl_map *)set, type, pos); } +/* Does "map" have a bound (according to "fn") for any of its basic maps? + */ static int has_any_bound(__isl_keep isl_map *map, enum isl_dim_type type, unsigned pos, int (*fn)(__isl_keep isl_basic_map *bmap, @@ -9225,6 +9227,44 @@ int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set, &isl_basic_map_dim_has_upper_bound); } +/* Does "map" have a bound (according to "fn") for all of its basic maps? + */ +static int has_bound(__isl_keep isl_map *map, + enum isl_dim_type type, unsigned pos, + int (*fn)(__isl_keep isl_basic_map *bmap, + enum isl_dim_type type, unsigned pos)) +{ + int i; + + if (!map) + return -1; + + for (i = 0; i < map->n; ++i) { + int bounded; + bounded = fn(map->p[i], type, pos); + if (bounded < 0 || !bounded) + return bounded; + } + + return 1; +} + +/* Return 1 if the specified dim has a lower bound (in each of its basic sets). + */ +int isl_set_dim_has_lower_bound(__isl_keep isl_set *set, + enum isl_dim_type type, unsigned pos) +{ + return has_bound(set, type, pos, &isl_basic_map_dim_has_lower_bound); +} + +/* Return 1 if the specified dim has an upper bound (in each of its basic sets). + */ +int isl_set_dim_has_upper_bound(__isl_keep isl_set *set, + enum isl_dim_type type, unsigned pos) +{ + return has_bound(set, type, pos, &isl_basic_map_dim_has_upper_bound); +} + /* For each of the "n" variables starting at "first", determine * the sign of the variable and put the results in the first "n" * elements of the array "signs". -- 2.11.4.GIT