isl_map_coalesce: avoid ignoring constraints redundant wrt implicit equalities
[isl.git] / isl_multi_read_no_explicit_domain_templ.c
blobb6ec27f688c8fd2ab33bb004e1d1337278d715d0
1 /*
2 * Copyright 2013 Ecole Normale Superieure
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8 */
10 #include <isl/space.h>
11 #include <isl/set.h>
13 #include <isl_multi_macro.h>
15 /* This function is called for each element in a tuple inside
16 * isl_stream_read_multi_*.
17 * Read an EL from "s" and add it to *list.
19 static __isl_give isl_space *FN(read_el,BASE)(__isl_keep isl_stream *s,
20 struct vars *v, __isl_take isl_space *space, int rational, void *user)
22 LIST(EL) **list = (LIST(EL) **) user;
23 EL *el;
25 el = FN(isl_stream_read,BASE)(s);
26 *list = FN(LIST(EL),add)(*list, el);
27 if (!*list)
28 return isl_space_free(space);
30 return space;
33 /* Read a multi expression from "s".
35 * We first read a tuple space, collecting the element values in a list.
36 * Then we create an isl_multi_* from the space and the isl_*_list.
38 __isl_give MULTI(BASE) *FN(isl_stream_read_multi,BASE)(
39 __isl_keep isl_stream *s)
41 struct vars *v;
42 isl_set *dom = NULL;
43 isl_space *space;
44 MULTI(BASE) *multi = NULL;
45 LIST(EL) *list;
47 v = vars_new(s->ctx);
48 if (!v)
49 return NULL;
51 dom = isl_set_universe(isl_space_params_alloc(s->ctx, 0));
52 if (next_is_tuple(s)) {
53 dom = read_map_tuple(s, dom, isl_dim_param, v, 0);
54 if (isl_stream_eat(s, ISL_TOKEN_TO))
55 goto error;
57 if (!isl_set_plain_is_universe(dom))
58 isl_die(s->ctx, isl_error_invalid,
59 "expecting universe parameter domain", goto error);
60 if (isl_stream_eat(s, '{'))
61 goto error;
63 space = isl_set_get_space(dom);
65 list = FN(LIST(EL),alloc)(s->ctx, 0);
66 space = read_tuple_space(s, v, space, 1, 0, &FN(read_el,BASE), &list);
67 multi = FN(FN(MULTI(BASE),from),LIST(BASE))(space, list);
69 if (isl_stream_eat(s, '}'))
70 goto error;
72 vars_free(v);
73 isl_set_free(dom);
74 return multi;
75 error:
76 vars_free(v);
77 isl_set_free(dom);
78 FN(MULTI(BASE),free)(multi);
79 return NULL;
82 #undef TYPE_BASE
83 #define TYPE_BASE CAT(multi_,BASE)
84 #include "isl_read_from_str_templ.c"