From 3793ff1d7f2e1724999fe68f09e29caa67db623a Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 28 Apr 2013 15:33:28 +0200 Subject: [PATCH] add isl_basic_map_order_gt Signed-off-by: Sven Verdoolaege --- doc/user.pod | 4 ++++ include/isl/map.h | 2 ++ isl_map.c | 59 +++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/doc/user.pod b/doc/user.pod index 49d12f4f..2278000d 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2165,6 +2165,10 @@ dimensions have opposite values. __isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2); + __isl_give isl_basic_map *isl_basic_map_order_gt( + __isl_take isl_basic_map *bmap, + enum isl_dim_type type1, int pos1, + enum isl_dim_type type2, int pos2); __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2); diff --git a/include/isl/map.h b/include/isl/map.h index 0c55af70..1667a343 100644 --- a/include/isl/map.h +++ b/include/isl/map.h @@ -452,6 +452,8 @@ __isl_give isl_map *isl_map_oppose(__isl_take isl_map *map, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2); __isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2); +__isl_give isl_basic_map *isl_basic_map_order_gt(__isl_take isl_basic_map *bmap, + enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2); __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2); diff --git a/isl_map.c b/isl_map.c index 9052c19d..0478d727 100644 --- a/isl_map.c +++ b/isl_map.c @@ -11056,32 +11056,29 @@ __isl_give isl_basic_map *isl_basic_map_order_ge(__isl_take isl_basic_map *bmap, return bmap; } -/* Add a constraint imposing that the value of the first dimension is +/* Construct a basic map where the value of the first dimension is * greater than that of the second. */ -__isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map, +static __isl_give isl_basic_map *greator(__isl_take isl_space *space, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2) { isl_basic_map *bmap = NULL; int i; - if (!map) + if (!space) return NULL; - if (pos1 >= isl_map_dim(map, type1)) - isl_die(map->ctx, isl_error_invalid, + if (pos1 >= isl_space_dim(space, type1)) + isl_die(isl_space_get_ctx(space), isl_error_invalid, "index out of bounds", goto error); - if (pos2 >= isl_map_dim(map, type2)) - isl_die(map->ctx, isl_error_invalid, + if (pos2 >= isl_space_dim(space, type2)) + isl_die(isl_space_get_ctx(space), isl_error_invalid, "index out of bounds", goto error); - if (type1 == type2 && pos1 == pos2) { - isl_space *space = isl_map_get_space(map); - isl_map_free(map); - return isl_map_empty(space); - } + if (type1 == type2 && pos1 == pos2) + return isl_basic_map_empty(space); - bmap = isl_basic_map_alloc_space(isl_map_get_space(map), 0, 0, 1); + bmap = isl_basic_map_alloc_space(space, 0, 0, 1); i = isl_basic_map_alloc_inequality(bmap); if (i < 0) goto error; @@ -11093,16 +11090,44 @@ __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map, isl_int_set_si(bmap->ineq[i][0], -1); bmap = isl_basic_map_finalize(bmap); - map = isl_map_intersect(map, isl_map_from_basic_map(bmap)); - - return map; + return bmap; error: + isl_space_free(space); isl_basic_map_free(bmap); - isl_map_free(map); return NULL; } /* Add a constraint imposing that the value of the first dimension is + * greater than that of the second. + */ +__isl_give isl_basic_map *isl_basic_map_order_gt(__isl_take isl_basic_map *bmap, + enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2) +{ + isl_basic_map *gt; + + gt = greator(isl_basic_map_get_space(bmap), type1, pos1, type2, pos2); + + bmap = isl_basic_map_intersect(bmap, gt); + + return bmap; +} + +/* Add a constraint imposing that the value of the first dimension is + * greater than that of the second. + */ +__isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map, + enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2) +{ + isl_basic_map *bmap; + + bmap = greator(isl_map_get_space(map), type1, pos1, type2, pos2); + + map = isl_map_intersect(map, isl_map_from_basic_map(bmap)); + + return map; +} + +/* Add a constraint imposing that the value of the first dimension is * smaller than that of the second. */ __isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map, -- 2.11.4.GIT