From ec29e23033d5225359010ddb6863724909a5b4da Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 28 May 2013 10:48:24 +0200 Subject: [PATCH] add isl_basic_map_plain_get_val_if_fixed Signed-off-by: Sven Verdoolaege --- doc/user.pod | 4 ++++ include/isl/map.h | 3 +++ isl_map.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 6739879..d5814fd 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -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); diff --git a/include/isl/map.h b/include/isl/map.h index b94d08e..0edc520 100644 --- a/include/isl/map.h +++ b/include/isl/map.h @@ -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); diff --git a/isl_map.c b/isl_map.c index 5f55931..3505edf 100644 --- 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) { -- 2.7.4