add isl_basic_map_plain_get_val_if_fixed
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 28 May 2013 08:48:24 +0000 (10:48 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 28 May 2013 18:42:47 +0000 (20:42 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/map.h
isl_map.c

index 6739879..d5814fd 100644 (file)
@@ -2060,6 +2060,10 @@ is already known to be empty.
 Check if the relation obviously lies on a hyperplane where the given dimension
 has a fixed value and if so, return that value in C<*val>.
 
+       __isl_give isl_val *
+       isl_basic_map_plain_get_val_if_fixed(
+               __isl_keep isl_basic_map *bmap,
+               enum isl_dim_type type, unsigned pos);
        __isl_give isl_val *isl_map_plain_get_val_if_fixed(
                __isl_keep isl_map *map,
                enum isl_dim_type type, unsigned pos);
index b94d08e..0edc520 100644 (file)
@@ -280,6 +280,9 @@ __isl_give isl_map *isl_map_drop_basic_map(__isl_take isl_map *map,
 
 int isl_basic_map_plain_is_fixed(__isl_keep isl_basic_map *bmap,
        enum isl_dim_type type, unsigned pos, isl_int *val);
+__isl_give isl_val *isl_basic_map_plain_get_val_if_fixed(
+       __isl_keep isl_basic_map *bmap,
+       enum isl_dim_type type, unsigned pos);
 
 int isl_basic_map_image_is_bounded(__isl_keep isl_basic_map *bmap);
 int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
index 5f55931..3505edf 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -8443,6 +8443,35 @@ int isl_basic_map_plain_is_fixed(__isl_keep isl_basic_map *bmap,
                isl_basic_map_offset(bmap, type) - 1 + pos, val);
 }
 
+/* If "bmap" obviously lies on a hyperplane where the given dimension
+ * has a fixed value, then return that value.
+ * Otherwise return NaN.
+ */
+__isl_give isl_val *isl_basic_map_plain_get_val_if_fixed(
+       __isl_keep isl_basic_map *bmap,
+       enum isl_dim_type type, unsigned pos)
+{
+       isl_ctx *ctx;
+       isl_val *v;
+       int fixed;
+
+       if (!bmap)
+               return NULL;
+       ctx = isl_basic_map_get_ctx(bmap);
+       v = isl_val_alloc(ctx);
+       if (!v)
+               return NULL;
+       fixed = isl_basic_map_plain_is_fixed(bmap, type, pos, &v->n);
+       if (fixed < 0)
+               return isl_val_free(v);
+       if (fixed) {
+               isl_int_set_si(v->d, 1);
+               return v;
+       }
+       isl_val_free(v);
+       return isl_val_nan(ctx);
+}
+
 int isl_map_plain_is_fixed(__isl_keep isl_map *map,
        enum isl_dim_type type, unsigned pos, isl_int *val)
 {