add isl_union_map_read_from_str
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 17 Nov 2010 15:24:05 +0000 (16:24 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 17 Nov 2010 16:08:32 +0000 (17:08 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl_stream.h
include/isl_union_map.h
include/isl_union_set.h
isl_input.c
isl_test.c

index 75cb914..59f4c5e 100644 (file)
@@ -585,6 +585,14 @@ dimensions is zero.
        __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx,
                const char *str, int nparam);
 
+       #include <isl_union_set.h>
+       __isl_give isl_union_set *isl_union_set_read_from_str(
+               struct isl_ctx *ctx, const char *str);
+
+       #include <isl_union_map.h>
+       __isl_give isl_union_map *isl_union_map_read_from_str(
+               struct isl_ctx *ctx, const char *str);
+
 The input format is autodetected and may be either the C<PolyLib> format
 or the C<isl> format.
 C<nparam> specifies how many of the final columns in
index 75a1456..20f7a2f 100644 (file)
@@ -91,6 +91,7 @@ __isl_give isl_map *isl_stream_read_map(struct isl_stream *s, int nparam);
 __isl_give isl_set *isl_stream_read_set(struct isl_stream *s, int nparam);
 __isl_give isl_pw_qpolynomial *isl_stream_read_pw_qpolynomial(
        struct isl_stream *s);
+__isl_give isl_union_map *isl_stream_read_union_map(struct isl_stream *s);
 
 #if defined(__cplusplus)
 }
index 306ac2f..97d7004 100644 (file)
@@ -100,6 +100,8 @@ __isl_give isl_union_map *isl_union_map_lex_gt_union_map(
 __isl_give isl_union_map *isl_union_map_lex_ge_union_map(
        __isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
 
+__isl_give isl_union_map *isl_union_map_read_from_str(struct isl_ctx *ctx,
+       const char *str);
 __isl_give isl_printer *isl_printer_print_union_map(__isl_take isl_printer *p,
        __isl_keep isl_union_map *umap);
 
index 010a4a9..a7b7918 100644 (file)
@@ -64,6 +64,8 @@ __isl_give isl_union_map *isl_union_set_lex_gt_union_set(
 __isl_give isl_union_map *isl_union_set_lex_ge_union_set(
        __isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2);
 
+__isl_give isl_union_set *isl_union_set_read_from_str(struct isl_ctx *ctx,
+       const char *str);
 __isl_give isl_printer *isl_printer_print_union_set(__isl_take isl_printer *p,
        __isl_keep isl_union_set *uset);
 
index 84cde79..9c9c298 100644 (file)
@@ -1819,6 +1819,49 @@ error:
        return NULL;
 }
 
+__isl_give isl_union_map *isl_stream_read_union_map(struct isl_stream *s)
+{
+       struct isl_obj obj;
+       isl_union_map *umap;
+
+       obj = obj_read(s, -1);
+       if (obj.type == isl_obj_map) {
+               obj.type = isl_obj_union_map;
+               obj.v = isl_union_map_from_map(obj.v);
+       }
+       if (obj.type == isl_obj_set) {
+               obj.type = isl_obj_union_set;
+               obj.v = isl_union_set_from_set(obj.v);
+       }
+       if (obj.v)
+               isl_assert(s->ctx, obj.type == isl_obj_union_map ||
+                                  obj.type == isl_obj_union_set, goto error);
+
+       return obj.v;
+error:
+       obj.type->free(obj.v);
+       return NULL;
+}
+
+__isl_give isl_union_set *isl_stream_read_union_set(struct isl_stream *s)
+{
+       struct isl_obj obj;
+       isl_union_set *uset;
+
+       obj = obj_read(s, -1);
+       if (obj.type == isl_obj_set) {
+               obj.type = isl_obj_union_set;
+               obj.v = isl_union_set_from_set(obj.v);
+       }
+       if (obj.v)
+               isl_assert(s->ctx, obj.type == isl_obj_union_set, goto error);
+
+       return obj.v;
+error:
+       obj.type->free(obj.v);
+       return NULL;
+}
+
 static struct isl_basic_map *basic_map_read(struct isl_stream *s, int nparam)
 {
        struct isl_obj obj;
@@ -1949,6 +1992,30 @@ error:
        return NULL;
 }
 
+__isl_give isl_union_map *isl_union_map_read_from_str(struct isl_ctx *ctx,
+               const char *str)
+{
+       isl_union_map *umap;
+       struct isl_stream *s = isl_stream_new_str(ctx, str);
+       if (!s)
+               return NULL;
+       umap = isl_stream_read_union_map(s);
+       isl_stream_free(s);
+       return umap;
+}
+
+__isl_give isl_union_set *isl_union_set_read_from_str(struct isl_ctx *ctx,
+               const char *str)
+{
+       isl_union_set *uset;
+       struct isl_stream *s = isl_stream_new_str(ctx, str);
+       if (!s)
+               return NULL;
+       uset = isl_stream_read_union_set(s);
+       isl_stream_free(s);
+       return uset;
+}
+
 static char *next_line(FILE *input, char *line, unsigned len)
 {
        char *p;
index 1765919..793248b 100644 (file)
@@ -1504,9 +1504,9 @@ void test_union(isl_ctx *ctx)
        isl_union_map *umap1, *umap2;
 
        str = "{ [i] : 0 <= i <= 1 }";
-       uset = isl_union_set_from_set(isl_set_read_from_str(ctx, str, -1));
+       uset = isl_union_set_read_from_str(ctx, str);
        str = "{ [1] -> [0] }";
-       umap1 = isl_union_map_from_map(isl_map_read_from_str(ctx, str, -1));
+       umap1 = isl_union_map_read_from_str(ctx, str);
 
        umap2 = isl_union_set_lex_gt_union_set(isl_union_set_copy(uset), uset);
        assert(isl_union_map_is_equal(umap1, umap2));