From: Sven Verdoolaege Date: Tue, 28 May 2013 08:48:24 +0000 (+0200) Subject: add isl_basic_map_plain_get_val_if_fixed X-Git-Tag: isl-0.12~59 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec29e23033d5225359010ddb6863724909a5b4da;p=platform%2Fupstream%2Fisl.git add isl_basic_map_plain_get_val_if_fixed Signed-off-by: Sven Verdoolaege --- 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) {