add isl_map_plain_get_val_if_fixed
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 14 Apr 2013 15:53:52 +0000 (17:53 +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 ab1081e..6739879 100644 (file)
@@ -2060,6 +2060,14 @@ 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_map_plain_get_val_if_fixed(
+               __isl_keep isl_map *map,
+               enum isl_dim_type type, unsigned pos);
+
+If the relation obviously lies on a hyperplane where the given dimension
+has a fixed value, then return that value.
+Otherwise return NaN.
+
 =item * Space
 
 To check whether a set is a parameter domain, use this function:
index f807fe6..b94d08e 100644 (file)
@@ -580,6 +580,8 @@ int isl_map_plain_is_fixed(__isl_keep isl_map *map,
        enum isl_dim_type type, unsigned pos, isl_int *val);
 int isl_map_fast_is_fixed(__isl_keep isl_map *map,
        enum isl_dim_type type, unsigned pos, isl_int *val);
+__isl_give isl_val *isl_map_plain_get_val_if_fixed(__isl_keep isl_map *map,
+       enum isl_dim_type type, unsigned pos);
 
 __isl_export
 __isl_give isl_basic_map *isl_basic_map_gist(__isl_take isl_basic_map *bmap,
index f5e95d1..5f55931 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -8452,6 +8452,34 @@ int isl_map_plain_is_fixed(__isl_keep isl_map *map,
                map_offset(map, type) - 1 + pos, val);
 }
 
+/* If "map" 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_map_plain_get_val_if_fixed(__isl_keep isl_map *map,
+       enum isl_dim_type type, unsigned pos)
+{
+       isl_ctx *ctx;
+       isl_val *v;
+       int fixed;
+
+       if (!map)
+               return NULL;
+       ctx = isl_map_get_ctx(map);
+       v = isl_val_alloc(ctx);
+       if (!v)
+               return NULL;
+       fixed = isl_map_plain_is_fixed(map, 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_set_plain_is_fixed(__isl_keep isl_set *set,
        enum isl_dim_type type, unsigned pos, isl_int *val)
 {