add isl_set_from_map
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 16 Sep 2008 19:16:32 +0000 (21:16 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 11 Oct 2008 21:39:20 +0000 (23:39 +0200)
include/isl_map.h
isl_map.c

index ad667a6..00fbeee 100644 (file)
@@ -199,6 +199,7 @@ struct isl_set *isl_map_domain(struct isl_map *bmap);
 struct isl_map *isl_map_from_basic_map(struct isl_basic_map *bmap);
 struct isl_map *isl_map_from_set(struct isl_set *set,
                unsigned n_in, unsigned n_out);
+struct isl_set *isl_set_from_map(struct isl_map *map);
 
 int isl_map_is_empty(struct isl_map *map);
 int isl_map_is_subset(struct isl_map *map1, struct isl_map *map2);
index 3b3e462..b1b280d 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -2174,6 +2174,30 @@ error:
        return NULL;
 }
 
+struct isl_set *isl_set_from_map(struct isl_map *map)
+{
+       int i;
+       struct isl_set *set = NULL;
+
+       if (!map)
+               return NULL;
+       map = isl_map_cow(map);
+       if (!map)
+               return NULL;
+       map->n_out += map->n_in;
+       map->n_in = 0;
+       set = (struct isl_set *)map;
+       for (i = 0; i < map->n; ++i) {
+               set->p[i] = isl_basic_set_from_basic_map(map->p[i]);
+               if (!set->p[i])
+                       goto error;
+       }
+       return set;
+error:
+       isl_map_free(map);
+       return NULL;
+}
+
 struct isl_map *isl_map_alloc(struct isl_ctx *ctx,
                unsigned nparam, unsigned in, unsigned out, int n,
                unsigned flags)