add isl_set_dim_has_{lower,upper}_bound
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 26 Aug 2012 13:53:42 +0000 (15:53 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Sep 2012 13:08:21 +0000 (15:08 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/set.h
isl_map.c

index e13d489..9192efa 100644 (file)
@@ -176,6 +176,8 @@ A call C<isl_pw_aff_cond(a, b, c)> can be replaced by
 C<isl_set_dim_has_upper_bound> have been renamed to
 C<isl_set_dim_has_any_lower_bound> and
 C<isl_set_dim_has_any_upper_bound>.
+The new C<isl_set_dim_has_lower_bound> and
+C<isl_set_dim_has_upper_bound> 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<set>.
+To check if they have a bound for all of the basic sets in C<set>,
+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.
 
index 9dc59e8..6552a8d 100644 (file)
@@ -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,
index 8154371..894f2bd 100644 (file)
--- 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".