Polly 20.0.0git
isl_multi_read_no_explicit_domain_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2013 Ecole Normale Superieure
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8 */
9
10#include <isl/space.h>
11#include <isl/set.h>
12
13#include <isl_multi_macro.h>
14
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.
18 */
20 struct vars *v, __isl_take isl_space *space, int rational, void *user)
21{
22 LIST(EL) **list = (LIST(EL) **) user;
23 EL *el;
24
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);
29
30 return space;
31}
32
33/* Read a multi expression from "s".
34 *
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.
37 */
38__isl_give MULTI(BASE) *FN(isl_stream_read_multi,BASE)(
40{
41 struct vars *v;
42 isl_set *dom = NULL;
43 isl_space *space;
44 MULTI(BASE) *multi = NULL;
45 LIST(EL) *list;
46
47 v = vars_new(s->ctx);
48 if (!v)
49 return NULL;
50
52 if (next_is_tuple(s)) {
53 dom = read_map_tuple(s, dom, isl_dim_param, v, 1, 0);
55 goto error;
56 }
59 "expecting universe parameter domain", goto error);
60 if (isl_stream_eat(s, '{'))
61 goto error;
62
63 space = isl_set_get_space(dom);
64
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);
68
69 if (isl_stream_eat(s, '}'))
70 goto error;
71
72 vars_free(v);
73 isl_set_free(dom);
74 return multi;
75error:
76 vars_free(v);
77 isl_set_free(dom);
78 FN(MULTI(BASE),free)(multi);
79 return NULL;
80}
81
82#undef TYPE_BASE
83#define TYPE_BASE CAT(multi_,BASE)
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
#define isl_die(ctx, errno, msg, code)
Definition: ctx.h:137
@ isl_error_invalid
Definition: ctx.h:80
#define __isl_keep
Definition: ctx.h:25
#define BASE
Definition: flow_cmp.c:49
isl_stat isl_stat(*) void user)
Definition: hmap.h:39
void GMPZAPI() add(mp_int rop, mp_int op1, mp_int op2)
#define EL
static int next_is_tuple(__isl_keep isl_stream *s)
Definition: isl_input.c:969
static void vars_free(struct vars *v)
Definition: isl_input.c:70
static __isl_give isl_map * read_map_tuple(__isl_keep isl_stream *s, __isl_take isl_map *map, enum isl_dim_type type, struct vars *v, int rational, int comma)
Definition: isl_input.c:1705
static struct vars * vars_new(struct isl_ctx *ctx)
Definition: isl_input.c:48
static __isl_give isl_space * read_tuple_space(__isl_keep isl_stream *s, struct vars *v, __isl_take isl_space *space, int rational, int comma, __isl_give isl_space *(*read_el)(__isl_keep isl_stream *s, struct vars *v, __isl_take isl_space *space, int rational, void *user), void *user)
Definition: isl_input.c:1445
#define LIST(EL)
Definition: isl_list_macro.h:8
#define MULTI(BASE)
struct isl_set isl_set
Definition: map_type.h:26
__isl_export __isl_give isl_set * isl_set_universe(__isl_take isl_space *space)
Definition: isl_map.c:6366
__isl_export __isl_give isl_space * isl_set_get_space(__isl_keep isl_set *set)
Definition: isl_map.c:603
__isl_null isl_set * isl_set_free(__isl_take isl_set *set)
Definition: isl_map.c:3513
isl_bool isl_set_plain_is_universe(__isl_keep isl_set *set)
Definition: isl_map.c:9374
__isl_null isl_space * isl_space_free(__isl_take isl_space *space)
Definition: isl_space.c:445
__isl_give isl_space * isl_space_params_alloc(isl_ctx *ctx, unsigned nparam)
Definition: isl_space.c:195
@ isl_dim_param
Definition: space_type.h:15
@ ISL_TOKEN_TO
Definition: stream.h:31
int isl_stream_eat(__isl_keep isl_stream *s, int type)
Definition: isl_stream.c:747
Definition: isl_input.c:42
struct variable * v
Definition: isl_input.c:45