From c803e4470da3afa29b82fec9300c5b724722e4d6 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 18 Jul 2011 16:28:53 +0200 Subject: [PATCH] add isl_map_equate Signed-off-by: Sven Verdoolaege --- doc/user.pod | 10 ++++++++++ include/isl/map.h | 3 +++ include/isl/set.h | 3 +++ isl_map.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 413a470..9fca1d0 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -1520,6 +1520,16 @@ without removing the dimensions. Intersect the set or relation with the hyperplane where the given dimension has the fixed given value. + __isl_give isl_set *isl_set_equate(__isl_take isl_set *set, + enum isl_dim_type type1, int pos1, + enum isl_dim_type type2, int pos2); + __isl_give isl_map *isl_map_equate(__isl_take isl_map *map, + enum isl_dim_type type1, int pos1, + enum isl_dim_type type2, int pos2); + +Intersect the set or relation with the hyperplane where the given +dimensions are equal to each other. + =item * Identity __isl_give isl_map *isl_set_identity( diff --git a/include/isl/map.h b/include/isl/map.h index 8e53ba5..d27172e 100644 --- a/include/isl/map.h +++ b/include/isl/map.h @@ -342,6 +342,9 @@ __isl_give isl_map *isl_map_remove_dims(__isl_take isl_map *map, struct isl_map *isl_map_remove_inputs(struct isl_map *map, unsigned first, unsigned n); +__isl_give isl_map *isl_map_equate(__isl_take isl_map *map, + enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2); + __isl_give isl_map *isl_set_identity(__isl_take isl_set *set); int isl_basic_set_is_wrapping(__isl_keep isl_basic_set *bset); diff --git a/include/isl/set.h b/include/isl/set.h index 026adc3..511ddf0 100644 --- a/include/isl/set.h +++ b/include/isl/set.h @@ -132,6 +132,9 @@ __isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set, __isl_give isl_set *isl_set_lower_bound_si(__isl_take isl_set *set, enum isl_dim_type type, unsigned pos, int value); +__isl_give isl_set *isl_set_equate(__isl_take isl_set *set, + enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2); + struct isl_basic_set *isl_basic_set_from_underlying_set( struct isl_basic_set *bset, struct isl_basic_set *like); struct isl_set *isl_set_from_underlying_set( diff --git a/isl_map.c b/isl_map.c index 919c308..6f0362d 100644 --- a/isl_map.c +++ b/isl_map.c @@ -8961,3 +8961,47 @@ __isl_give isl_basic_map *isl_basic_map_from_aff_list( isl_aff_list_free(list); return bmap; } + +__isl_give isl_set *isl_set_equate(__isl_take isl_set *set, + enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2) +{ + return isl_map_equate(set, type1, pos1, type2, pos2); +} + +/* Add a constraint imposing that the given two dimensions are equal. + */ +__isl_give isl_map *isl_map_equate(__isl_take isl_map *map, + enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2) +{ + isl_basic_map *bmap = NULL; + int i; + + if (!map) + return NULL; + + if (pos1 >= isl_map_dim(map, type1)) + isl_die(map->ctx, isl_error_invalid, + "index out of bounds", goto error); + if (pos2 >= isl_map_dim(map, type2)) + isl_die(map->ctx, isl_error_invalid, + "index out of bounds", goto error); + + bmap = isl_basic_map_alloc_dim(isl_map_get_dim(map), 0, 1, 0); + i = isl_basic_map_alloc_equality(bmap); + if (i < 0) + goto error; + isl_seq_clr(bmap->eq[i], 1 + isl_basic_map_total_dim(bmap)); + pos1 += isl_basic_map_offset(bmap, type1); + pos2 += isl_basic_map_offset(bmap, type2); + isl_int_set_si(bmap->eq[i][pos1], -1); + isl_int_set_si(bmap->eq[i][pos2], 1); + bmap = isl_basic_map_finalize(bmap); + + map = isl_map_intersect(map, isl_map_from_basic_map(bmap)); + + return map; +error: + isl_basic_map_free(bmap); + isl_map_free(map); + return NULL; +} -- 2.7.4