#include <stdio.h>
#include <string.h>
#include <strings.h>
-#include <isl_set.h>
-#include <isl_seq.h>
-#include <isl_div.h>
-#include "isl_stream.h"
-#include "isl_map_private.h"
-#include "isl_obj.h"
+#include <isl_ctx_private.h>
+#include <isl_map_private.h>
+#include <isl/set.h>
+#include <isl/seq.h>
+#include <isl/div.h>
+#include <isl/stream.h>
+#include <isl/obj.h>
#include "isl_polynomial_private.h"
-#include <isl_union_map.h>
+#include <isl/union_map.h>
+#include <isl_mat_private.h>
struct variable {
char *name;
int pos;
+ isl_vec *def;
struct variable *next;
};
{
while (var) {
struct variable *next = var->next;
+ isl_vec_free(var->def);
free(var->name);
free(var);
var = next;
var = v->v;
while (--n >= 0) {
struct variable *next = var->next;
+ isl_vec_free(var->def);
free(var->name);
free(var);
var = next;
var->name = strdup(name);
var->name[len] = '\0';
var->pos = pos;
+ var->def = NULL;
var->next = v->v;
return var;
error:
return pos;
}
-static __isl_give isl_dim *set_name(__isl_take isl_dim *dim,
+static int vars_add_anon(struct vars *v)
+{
+ v->v = variable_new(v, "", 0, v->n);
+
+ if (!v->v)
+ return -1;
+ v->n++;
+
+ return 0;
+}
+
+static __isl_give isl_basic_map *set_name(__isl_take isl_basic_map *bmap,
enum isl_dim_type type, unsigned pos, char *name)
{
char *prime;
- if (!dim)
+ if (!bmap)
return NULL;
if (!name)
- return dim;
+ return bmap;
prime = strchr(name, '\'');
if (prime)
*prime = '\0';
- dim = isl_dim_set_name(dim, type, pos, name);
+ bmap = isl_basic_map_set_dim_name(bmap, type, pos, name);
if (prime)
*prime = '\'';
- return dim;
+ return bmap;
+}
+
+/* Obtain next token, with some preprocessing.
+ * In particular, evaluate expressions of the form x^y,
+ * with x and y values.
+ */
+static struct isl_token *next_token(struct isl_stream *s)
+{
+ struct isl_token *tok, *tok2;
+
+ tok = isl_stream_next_token(s);
+ if (!tok || tok->type != ISL_TOKEN_VALUE)
+ return tok;
+ if (!isl_stream_eat_if_available(s, '^'))
+ return tok;
+ tok2 = isl_stream_next_token(s);
+ if (!tok2 || tok2->type != ISL_TOKEN_VALUE) {
+ isl_stream_error(s, tok2, "expecting constant value");
+ goto error;
+ }
+
+ isl_int_pow_ui(tok->u.v, tok->u.v, isl_int_get_ui(tok2->u.v));
+
+ isl_token_free(tok2);
+ return tok;
+error:
+ isl_token_free(tok);
+ isl_token_free(tok2);
+ return NULL;
}
static int accept_cst_factor(struct isl_stream *s, isl_int *f)
{
struct isl_token *tok;
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok || tok->type != ISL_TOKEN_VALUE) {
isl_stream_error(s, tok, "expecting constant value");
goto error;
return -1;
}
+/* Given an affine expression aff, return an affine expression
+ * for aff % d, with d the next token on the stream, which is
+ * assumed to be a constant.
+ *
+ * We introduce an integer division q = [aff/d] and the result
+ * is set to aff - d q.
+ */
+static __isl_give isl_vec *affine_mod(struct isl_stream *s,
+ struct vars *v, __isl_take isl_vec *aff)
+{
+ struct isl_token *tok;
+ struct variable *var;
+ isl_vec *mod;
+
+ tok = next_token(s);
+ if (!tok || tok->type != ISL_TOKEN_VALUE) {
+ isl_stream_error(s, tok, "expecting constant value");
+ goto error;
+ }
+
+ if (vars_add_anon(v) < 0)
+ goto error;
+
+ var = v->v;
+
+ var->def = isl_vec_alloc(s->ctx, 2 + v->n);
+ if (!var->def)
+ goto error;
+ isl_seq_cpy(var->def->el + 1, aff->el, aff->size);
+ isl_int_set_si(var->def->el[1 + aff->size], 0);
+ isl_int_set(var->def->el[0], tok->u.v);
+
+ mod = isl_vec_alloc(v->ctx, 1 + v->n);
+ if (!mod)
+ goto error;
+
+ isl_seq_cpy(mod->el, aff->el, aff->size);
+ isl_int_neg(mod->el[aff->size], tok->u.v);
+
+ isl_vec_free(aff);
+ isl_token_free(tok);
+ return mod;
+error:
+ isl_vec_free(aff);
+ isl_token_free(tok);
+ return NULL;
+}
+
static struct isl_vec *accept_affine(struct isl_stream *s, struct vars *v);
+static int read_div_definition(struct isl_stream *s, struct vars *v);
static __isl_give isl_vec *accept_affine_factor(struct isl_stream *s,
struct vars *v)
struct isl_token *tok = NULL;
isl_vec *aff = NULL;
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok) {
isl_stream_error(s, NULL, "unexpected EOF");
goto error;
goto error;
if (isl_stream_eat(s, ')'))
goto error;
+ } else if (tok->type == '[') {
+ if (vars_add_anon(v) < 0)
+ goto error;
+ aff = isl_vec_alloc(v->ctx, 1 + v->n);
+ if (!aff)
+ goto error;
+ isl_seq_clr(aff->el, aff->size);
+ isl_int_set_si(aff->el[1 + v->n - 1], 1);
+ isl_stream_push_token(s, tok);
+ tok = NULL;
+ if (read_div_definition(s, v) < 0)
+ goto error;
+ aff = isl_vec_zero_extend(aff, 1 + v->n);
} else {
isl_stream_error(s, tok, "expecting factor");
goto error;
}
+ if (isl_stream_eat_if_available(s, '%'))
+ return affine_mod(s, v, aff);
if (isl_stream_eat_if_available(s, '*')) {
isl_int f;
isl_int_init(f);
isl_int_set_si(f, 1);
if (accept_cst_factor(s, &f) < 0) {
isl_int_clear(f);
- goto error;
+ goto error2;
}
aff = isl_vec_scale(aff, f);
isl_int_clear(f);
return aff;
error:
isl_token_free(tok);
+error2:
isl_vec_free(aff);
return NULL;
}
isl_seq_clr(aff->el, aff->size);
for (;;) {
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok) {
isl_stream_error(s, NULL, "unexpected EOF");
goto error;
isl_token_free(tok);
continue;
}
- if (tok->type == '(' || tok->type == ISL_TOKEN_IDENT) {
+ if (tok->type == '(' || tok->type == '[' ||
+ tok->type == ISL_TOKEN_IDENT) {
isl_vec *aff2;
isl_stream_push_token(s, tok);
tok = NULL;
aff2 = accept_affine_factor(s, v);
if (sign < 0)
aff2 = isl_vec_scale(aff2, s->ctx->negone);
+ aff = isl_vec_zero_extend(aff, 1 + v->n);
aff = isl_vec_add(aff, aff2);
if (!aff)
goto error;
isl_vec *aff2;
aff2 = accept_affine_factor(s, v);
aff2 = isl_vec_scale(aff2, tok->u.v);
+ aff = isl_vec_zero_extend(aff, 1 + v->n);
aff = isl_vec_add(aff, aff2);
if (!aff)
goto error;
isl_int_add(aff->el[0], aff->el[0], tok->u.v);
}
sign = 1;
+ } else {
+ isl_stream_error(s, tok, "unexpected isl_token");
+ isl_stream_push_token(s, tok);
+ isl_vec_free(aff);
+ return NULL;
}
isl_token_free(tok);
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (tok && tok->type == '-') {
sign = -sign;
isl_token_free(tok);
return NULL;
}
-static __isl_give isl_mat *read_var_def(struct isl_stream *s,
- __isl_take isl_mat *eq, enum isl_dim_type type, struct vars *v)
+/* Add any variables in the variable list "v" that are not already in "bmap"
+ * as existentially quantified variables in "bmap".
+ */
+static __isl_give isl_basic_map *add_divs(__isl_take isl_basic_map *bmap,
+ struct vars *v)
+{
+ int i;
+ int extra;
+ struct variable *var;
+
+ extra = v->n - isl_basic_map_total_dim(bmap);
+
+ if (extra == 0)
+ return bmap;
+
+ bmap = isl_basic_map_extend_dim(bmap, isl_basic_map_get_dim(bmap),
+ extra, 0, 2 * extra);
+
+ for (i = 0; i < extra; ++i)
+ if (isl_basic_map_alloc_div(bmap) < 0)
+ goto error;
+
+ for (i = 0, var = v->v; i < extra; ++i, var = var->next) {
+ int k = bmap->n_div - 1 - i;
+
+ isl_seq_cpy(bmap->div[k], var->def->el, var->def->size);
+ isl_seq_clr(bmap->div[k] + var->def->size,
+ 2 + v->n - var->def->size);
+
+ if (isl_basic_map_add_div_constraints(bmap, k) < 0)
+ goto error;
+ }
+
+ return bmap;
+error:
+ isl_basic_map_free(bmap);
+ return NULL;
+}
+
+static __isl_give isl_basic_map *read_var_def(struct isl_stream *s,
+ __isl_take isl_basic_map *bmap, enum isl_dim_type type, struct vars *v)
{
+ isl_dim *dim;
+ isl_basic_map *def = NULL;
struct isl_vec *vec;
+ int k;
+ int n;
+
+ if (vars_add_anon(v) < 0)
+ goto error;
+ n = v->n;
vec = accept_affine(s, v);
if (!vec)
goto error;
- v->v = variable_new(v, "", 0, v->n);
- if (!v->v)
- goto error;
- v->n++;
- eq = isl_mat_add_rows(eq, 1);
- if (eq) {
- isl_seq_cpy(eq->row[eq->n_row - 1], vec->el, vec->size);
- isl_int_set_si(eq->row[eq->n_row - 1][vec->size], -1);
+
+ dim = isl_basic_map_get_dim(bmap);
+ def = isl_basic_map_universe(dim);
+ def = add_divs(def, v);
+ def = isl_basic_map_extend_constraints(def, 1, 0);
+ k = isl_basic_map_alloc_equality(def);
+ if (k >= 0) {
+ isl_seq_cpy(def->eq[k], vec->el, vec->size);
+ isl_int_set_si(def->eq[k][1 + n - 1], -1);
}
isl_vec_free(vec);
+ if (k < 0)
+ goto error;
- return eq;
+ vars_drop(v, v->n - n);
+
+ def = isl_basic_map_simplify(def);
+ def = isl_basic_map_finalize(def);
+ bmap = isl_basic_map_intersect(bmap, def);
+ return bmap;
error:
- isl_mat_free(eq);
+ isl_basic_map_free(bmap);
+ isl_basic_map_free(def);
return NULL;
}
-static __isl_give isl_dim *read_var_list(struct isl_stream *s,
- __isl_take isl_dim *dim, enum isl_dim_type type, struct vars *v,
- __isl_keep isl_mat **eq)
+static __isl_give isl_basic_map *read_var_list(struct isl_stream *s,
+ __isl_take isl_basic_map *bmap, enum isl_dim_type type, struct vars *v)
{
int i = 0;
struct isl_token *tok;
- while ((tok = isl_stream_next_token(s)) != NULL) {
+ while ((tok = next_token(s)) != NULL) {
int new_name = 0;
if (tok->type == ISL_TOKEN_IDENT) {
}
if (new_name) {
- dim = isl_dim_add(dim, type, 1);
- if (eq)
- *eq = isl_mat_add_zero_cols(*eq, 1);
- dim = set_name(dim, type, i, v->v->name);
+ bmap = isl_basic_map_add(bmap, type, 1);
+ bmap = set_name(bmap, type, i, v->v->name);
isl_token_free(tok);
} else if (tok->type == ISL_TOKEN_IDENT ||
tok->type == ISL_TOKEN_VALUE ||
- tok->type == '-') {
+ tok->type == '-' ||
+ tok->type == '(') {
if (type == isl_dim_param) {
isl_stream_error(s, tok,
"expecting unique identifier");
}
isl_stream_push_token(s, tok);
tok = NULL;
- dim = isl_dim_add(dim, type, 1);
- *eq = isl_mat_add_zero_cols(*eq, 1);
- *eq = read_var_def(s, *eq, type, v);
+ bmap = isl_basic_map_add(bmap, type, 1);
+ bmap = read_var_def(s, bmap, type, v);
} else
break;
if (tok)
isl_stream_push_token(s, tok);
- return dim;
+ return bmap;
error:
isl_token_free(tok);
- isl_dim_free(dim);
+ isl_basic_map_free(bmap);
return NULL;
}
isl_token_free(tok);
vec = accept_affine(s, v);
+ mat = isl_mat_add_zero_cols(mat, 1 + v->n - isl_mat_cols(mat));
mat = isl_mat_vec_concat(mat, vec);
if (!mat)
return NULL;
return NULL;
}
-static struct isl_basic_map *add_div_definition(struct isl_stream *s,
- struct vars *v, struct isl_basic_map *bmap, int k)
+static int read_div_definition(struct isl_stream *s, struct vars *v)
{
struct isl_token *tok;
int seen_paren = 0;
struct isl_vec *aff;
+ struct variable *var;
if (isl_stream_eat(s, '['))
- goto error;
+ return -1;
tok = isl_stream_next_token(s);
if (!tok)
- goto error;
+ return -1;
if (tok->type == '(') {
seen_paren = 1;
isl_token_free(tok);
} else
isl_stream_push_token(s, tok);
+ var = v->v;
+
aff = accept_affine(s, v);
if (!aff)
- goto error;
+ return -1;
- isl_seq_cpy(bmap->div[k] + 1, aff->el, aff->size);
+ var->def = isl_vec_alloc(s->ctx, 2 + v->n);
+ if (!var->def) {
+ isl_vec_free(aff);
+ return -1;
+ }
+
+ isl_seq_cpy(var->def->el + 1, aff->el, aff->size);
isl_vec_free(aff);
if (seen_paren && isl_stream_eat(s, ')'))
- goto error;
+ return -1;
if (isl_stream_eat(s, '/'))
- goto error;
+ return -1;
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok)
- goto error;
+ return -1;
if (tok->type != ISL_TOKEN_VALUE) {
isl_stream_error(s, tok, "expected denominator");
isl_stream_push_token(s, tok);
- goto error;
+ return -1;
}
- isl_int_set(bmap->div[k][0], tok->u.v);
+ isl_int_set(var->def->el[0], tok->u.v);
isl_token_free(tok);
if (isl_stream_eat(s, ']'))
+ return -1;
+
+ return 0;
+}
+
+static struct isl_basic_map *add_div_definition(struct isl_stream *s,
+ struct vars *v, struct isl_basic_map *bmap, int pos)
+{
+ struct variable *var = v->v;
+ unsigned o_out = isl_basic_map_offset(bmap, isl_dim_out) - 1;
+
+ if (read_div_definition(s, v) < 0)
goto error;
- if (isl_basic_map_add_div_constraints(bmap, k) < 0)
+ if (isl_basic_map_add_div_constraints_var(bmap, o_out + pos,
+ var->def->el) < 0)
goto error;
return bmap;
struct isl_token *tok;
while ((tok = isl_stream_next_token(s)) != NULL) {
- int k;
int p;
int n = v->n;
- unsigned total = isl_basic_map_total_dim(bmap);
+ unsigned n_out = isl_basic_map_dim(bmap, isl_dim_out);
if (tok->type != ISL_TOKEN_IDENT)
break;
}
bmap = isl_basic_map_cow(bmap);
+ bmap = isl_basic_map_add(bmap, isl_dim_out, 1);
bmap = isl_basic_map_extend_dim(bmap, isl_dim_copy(bmap->dim),
- 1, 0, 2);
-
- if ((k = isl_basic_map_alloc_div(bmap)) < 0)
- goto error;
- isl_seq_clr(bmap->div[k], 1 + 1 + total);
+ 0, 0, 2);
isl_token_free(tok);
tok = isl_stream_next_token(s);
if (tok && tok->type == '=') {
isl_token_free(tok);
- bmap = add_div_definition(s, v, bmap, k);
+ bmap = add_div_definition(s, v, bmap, n_out);
tok = isl_stream_next_token(s);
}
isl_stream_push_token(s, tok);
return 1;
}
- if (tok->type != ISL_TOKEN_IDENT) {
+ if (tok->type != ISL_TOKEN_IDENT && !tok->is_keyword) {
isl_stream_push_token(s, tok);
return 0;
}
return is_tuple;
}
-static __isl_give isl_dim *read_tuple(struct isl_stream *s,
- __isl_take isl_dim *dim, enum isl_dim_type type, struct vars *v,
- __isl_keep isl_mat **eq);
+static __isl_give isl_basic_map *read_tuple(struct isl_stream *s,
+ __isl_take isl_basic_map *bmap, enum isl_dim_type type, struct vars *v);
-static __isl_give isl_dim *read_nested_tuple(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v, __isl_keep isl_mat **eq)
+static __isl_give isl_basic_map *read_nested_tuple(struct isl_stream *s,
+ __isl_take isl_basic_map *bmap, struct vars *v)
{
- dim = read_tuple(s, dim, isl_dim_in, v, eq);
+ bmap = read_tuple(s, bmap, isl_dim_in, v);
if (isl_stream_eat(s, ISL_TOKEN_TO))
goto error;
- dim = read_tuple(s, dim, isl_dim_out, v, eq);
- dim = isl_dim_wrap(dim);
- return dim;
+ bmap = read_tuple(s, bmap, isl_dim_out, v);
+ bmap = isl_basic_map_from_range(isl_basic_map_wrap(bmap));
+ return bmap;
error:
- isl_dim_free(dim);
+ isl_basic_map_free(bmap);
return NULL;
}
-static __isl_give isl_dim *read_tuple(struct isl_stream *s,
- __isl_take isl_dim *dim, enum isl_dim_type type, struct vars *v,
- __isl_keep isl_mat **eq)
+static __isl_give isl_basic_map *read_tuple(struct isl_stream *s,
+ __isl_take isl_basic_map *bmap, enum isl_dim_type type, struct vars *v)
{
struct isl_token *tok;
char *name = NULL;
tok = isl_stream_next_token(s);
- if (tok && tok->type == ISL_TOKEN_IDENT) {
+ if (tok && (tok->type == ISL_TOKEN_IDENT || tok->is_keyword)) {
name = strdup(tok->u.s);
if (!name)
goto error;
}
isl_token_free(tok);
if (type != isl_dim_param && next_is_tuple(s)) {
- isl_dim *nested = isl_dim_copy(dim);
- nested = isl_dim_drop(nested, isl_dim_in, 0,
- isl_dim_size(nested, isl_dim_in));
- nested = isl_dim_drop(nested, isl_dim_out, 0,
- isl_dim_size(nested, isl_dim_out));
- nested = read_nested_tuple(s, nested, v, eq);
+ isl_dim *dim = isl_basic_map_get_dim(bmap);
+ int nparam = isl_dim_size(dim, isl_dim_param);
+ int n_in = isl_dim_size(dim, isl_dim_in);
+ isl_basic_map *nested;
+ if (type == isl_dim_out)
+ dim = isl_dim_move(dim, isl_dim_param, nparam,
+ isl_dim_in, 0, n_in);
+ nested = isl_basic_map_alloc_dim(dim, 0, 0, 0);
+ nested = read_nested_tuple(s, nested, v);
if (type == isl_dim_in) {
- isl_dim_free(dim);
- dim = isl_dim_reverse(nested);
+ nested = isl_basic_map_reverse(nested);
+ bmap = isl_basic_map_intersect(nested, bmap);
} else {
- dim = isl_dim_join(dim, nested);
+ isl_basic_set *bset;
+ dim = isl_dim_range(isl_basic_map_get_dim(nested));
+ dim = isl_dim_drop(dim, isl_dim_param, nparam, n_in);
+ dim = isl_dim_join(isl_basic_map_get_dim(bmap), dim);
+ bset = isl_basic_map_domain(bmap);
+ nested = isl_basic_map_reset_dim(nested, dim);
+ bmap = isl_basic_map_intersect_domain(nested, bset);
}
} else
- dim = read_var_list(s, dim, type, v, eq);
+ bmap = read_var_list(s, bmap, type, v);
tok = isl_stream_next_token(s);
if (!tok || tok->type != ']') {
isl_stream_error(s, tok, "expecting ']'");
isl_token_free(tok);
if (name) {
- dim = isl_dim_set_tuple_name(dim, type, name);
+ bmap = isl_basic_map_set_tuple_name(bmap, type, name);
free(name);
}
- return dim;
+ return bmap;
error:
if (tok)
isl_token_free(tok);
- isl_dim_free(dim);
- return NULL;
-}
-
-static struct isl_basic_map *add_constraints(struct isl_stream *s,
- struct vars *v, struct isl_basic_map *bmap);
-
-static struct isl_basic_map *add_exists(struct isl_stream *s,
- struct vars *v, struct isl_basic_map *bmap)
-{
- struct isl_token *tok;
- int n = v->n;
- int extra;
- int seen_paren = 0;
- int i;
- unsigned total;
-
- tok = isl_stream_next_token(s);
- if (!tok)
- goto error;
- if (tok->type == '(') {
- seen_paren = 1;
- isl_token_free(tok);
- } else
- isl_stream_push_token(s, tok);
-
- bmap = read_defined_var_list(s, v, bmap);
- if (!bmap)
- goto error;
-
- if (isl_stream_eat(s, ':'))
- goto error;
- bmap = add_constraints(s, v, bmap);
- if (seen_paren && isl_stream_eat(s, ')'))
- goto error;
- return bmap;
-error:
isl_basic_map_free(bmap);
return NULL;
}
}
}
+/* Add any variables in the variable list "v" that are not already in "bmap"
+ * as output variables in "bmap".
+ */
+static __isl_give isl_basic_map *add_lifted_divs(__isl_take isl_basic_map *bmap,
+ struct vars *v)
+{
+ int i;
+ int extra;
+ struct variable *var;
+
+ extra = v->n - isl_basic_map_total_dim(bmap);
+
+ if (extra == 0)
+ return bmap;
+
+ bmap = isl_basic_map_add(bmap, isl_dim_out, extra);
+ bmap = isl_basic_map_extend_dim(bmap, isl_basic_map_get_dim(bmap),
+ 0, 0, 2 * extra);
+
+ for (i = 0, var = v->v; i < extra; ++i, var = var->next) {
+ var->def = isl_vec_zero_extend(var->def, 2 + v->n);
+ if (!var->def)
+ goto error;
+ if (isl_basic_map_add_div_constraints_var(bmap, var->pos,
+ var->def->el) < 0)
+ goto error;
+ }
+
+ return bmap;
+error:
+ isl_basic_map_free(bmap);
+ return NULL;
+}
+
static struct isl_basic_map *add_constraint(struct isl_stream *s,
struct vars *v, struct isl_basic_map *bmap)
{
int i, j;
- unsigned total = isl_basic_map_total_dim(bmap);
struct isl_token *tok = NULL;
struct isl_mat *aff1 = NULL, *aff2 = NULL;
- tok = isl_stream_next_token(s);
- if (!tok)
- goto error;
- if (tok->type == ISL_TOKEN_EXISTS) {
- isl_token_free(tok);
- return add_exists(s, v, bmap);
- }
- isl_stream_push_token(s, tok);
- tok = NULL;
-
bmap = isl_basic_map_cow(bmap);
aff1 = accept_affine_list(s, v);
tok = NULL;
goto error;
}
- isl_assert(aff1->ctx, aff1->n_col == 1 + total, goto error);
for (;;) {
aff2 = accept_affine_list(s, v);
if (!aff2)
goto error;
- isl_assert(aff2->ctx, aff2->n_col == 1 + total, goto error);
+ aff1 = isl_mat_add_zero_cols(aff1, aff2->n_col - aff1->n_col);
+ if (!aff1)
+ goto error;
+ bmap = add_lifted_divs(bmap, v);
bmap = isl_basic_map_extend_constraints(bmap, 0,
aff1->n_row * aff2->n_row);
for (i = 0; i < aff1->n_row; ++i)
return NULL;
}
-static struct isl_basic_map *add_constraints(struct isl_stream *s,
- struct vars *v, struct isl_basic_map *bmap)
+static isl_map *read_constraint(struct isl_stream *s,
+ struct vars *v, __isl_take isl_basic_map *bmap)
{
- struct isl_token *tok;
+ int n = v->n;
- for (;;) {
- bmap = add_constraint(s, v, bmap);
- if (!bmap)
- return NULL;
- tok = isl_stream_next_token(s);
- if (!tok) {
- isl_stream_error(s, NULL, "unexpected EOF");
- goto error;
- }
- if (tok->type != ISL_TOKEN_AND)
- break;
- isl_token_free(tok);
- }
- isl_stream_push_token(s, tok);
+ if (!bmap)
+ return NULL;
- return bmap;
-error:
- if (tok)
- isl_token_free(tok);
- isl_basic_map_free(bmap);
- return NULL;
+ bmap = isl_basic_set_unwrap(isl_basic_set_lift(isl_basic_map_wrap(bmap)));
+
+ bmap = add_constraint(s, v, bmap);
+ bmap = isl_basic_map_simplify(bmap);
+ bmap = isl_basic_map_finalize(bmap);
+
+ bmap = isl_basic_set_unwrap(isl_basic_map_domain(bmap));
+
+ vars_drop(v, v->n - n);
+
+ return isl_map_from_basic_map(bmap);
}
-static struct isl_basic_map *read_disjunct(struct isl_stream *s,
- struct vars *v, __isl_take isl_dim *dim)
+static struct isl_map *read_disjuncts(struct isl_stream *s,
+ struct vars *v, __isl_take isl_basic_map *bmap);
+
+static __isl_give isl_map *read_exists(struct isl_stream *s,
+ struct vars *v, __isl_take isl_basic_map *bmap)
{
- int seen_paren = 0;
- struct isl_token *tok;
- struct isl_basic_map *bmap;
+ int n = v->n;
+ int seen_paren = isl_stream_eat_if_available(s, '(');
+ isl_map *map = NULL;
- bmap = isl_basic_map_alloc_dim(dim, 0, 0, 0);
- if (!bmap)
- return NULL;
+ bmap = isl_basic_map_from_domain(isl_basic_map_wrap(bmap));
+ bmap = read_defined_var_list(s, v, bmap);
- tok = isl_stream_next_token(s);
- if (!tok)
+ if (isl_stream_eat(s, ':'))
goto error;
- if (tok->type == '(') {
- seen_paren = 1;
- isl_token_free(tok);
- } else
- isl_stream_push_token(s, tok);
- bmap = add_constraints(s, v, bmap);
- bmap = isl_basic_map_simplify(bmap);
- bmap = isl_basic_map_finalize(bmap);
+ map = read_disjuncts(s, v, bmap);
+ map = isl_set_unwrap(isl_map_domain(map));
+ bmap = NULL;
+ vars_drop(v, v->n - n);
if (seen_paren && isl_stream_eat(s, ')'))
goto error;
- return bmap;
+ return map;
error:
isl_basic_map_free(bmap);
+ isl_map_free(map);
return NULL;
}
-static struct isl_map *read_disjuncts(struct isl_stream *s,
- struct vars *v, __isl_take isl_dim *dim)
+static __isl_give isl_map *read_conjunct(struct isl_stream *s,
+ struct vars *v, __isl_take isl_basic_map *bmap)
{
- struct isl_token *tok;
- struct isl_map *map;
+ isl_map *map;
- tok = isl_stream_next_token(s);
- if (!tok) {
- isl_stream_error(s, NULL, "unexpected EOF");
- goto error;
+ if (isl_stream_eat_if_available(s, '(')) {
+ map = read_disjuncts(s, v, bmap);
+ if (isl_stream_eat(s, ')'))
+ goto error;
+ return map;
}
- if (tok->type == '}') {
- isl_stream_push_token(s, tok);
- return isl_map_universe(dim);
+
+ if (isl_stream_eat_if_available(s, ISL_TOKEN_EXISTS))
+ return read_exists(s, v, bmap);
+
+ if (isl_stream_eat_if_available(s, ISL_TOKEN_TRUE))
+ return isl_map_from_basic_map(bmap);
+
+ if (isl_stream_eat_if_available(s, ISL_TOKEN_FALSE)) {
+ isl_dim *dim = isl_basic_map_get_dim(bmap);
+ isl_basic_map_free(bmap);
+ return isl_map_empty(dim);
}
- isl_stream_push_token(s, tok);
+
+ return read_constraint(s, v, bmap);
+error:
+ isl_map_free(map);
+ return NULL;
+}
- map = isl_map_empty(isl_dim_copy(dim));
- for (;;) {
- struct isl_basic_map *bmap;
- int n = v->n;
+static __isl_give isl_map *read_conjuncts(struct isl_stream *s,
+ struct vars *v, __isl_take isl_basic_map *bmap)
+{
+ isl_map *map;
+ int negate;
+
+ negate = isl_stream_eat_if_available(s, ISL_TOKEN_NOT);
+ map = read_conjunct(s, v, isl_basic_map_copy(bmap));
+ if (negate) {
+ isl_map *t;
+ t = isl_map_from_basic_map(isl_basic_map_copy(bmap));
+ map = isl_map_subtract(t, map);
+ }
- bmap = read_disjunct(s, v, isl_dim_copy(dim));
- map = isl_map_union(map, isl_map_from_basic_map(bmap));
+ while (isl_stream_eat_if_available(s, ISL_TOKEN_AND)) {
+ isl_map *map_i;
- vars_drop(v, v->n - n);
+ negate = isl_stream_eat_if_available(s, ISL_TOKEN_NOT);
+ map_i = read_conjunct(s, v, isl_basic_map_copy(bmap));
+ if (negate)
+ map = isl_map_subtract(map, map_i);
+ else
+ map = isl_map_intersect(map, map_i);
+ }
- tok = isl_stream_next_token(s);
- if (!tok || tok->type != ISL_TOKEN_OR)
- break;
- isl_token_free(tok);
+ isl_basic_map_free(bmap);
+ return map;
+}
+
+static struct isl_map *read_disjuncts(struct isl_stream *s,
+ struct vars *v, __isl_take isl_basic_map *bmap)
+{
+ struct isl_map *map;
+
+ if (isl_stream_next_token_is(s, '}')) {
+ isl_dim *dim = isl_basic_map_get_dim(bmap);
+ isl_basic_map_free(bmap);
+ return isl_map_universe(dim);
}
- if (tok)
- isl_stream_push_token(s, tok);
- isl_dim_free(dim);
+ map = read_conjuncts(s, v, isl_basic_map_copy(bmap));
+ while (isl_stream_eat_if_available(s, ISL_TOKEN_OR)) {
+ isl_map *map_i;
+
+ map_i = read_conjuncts(s, v, isl_basic_map_copy(bmap));
+ map = isl_map_union(map, map_i);
+ }
+
+ isl_basic_map_free(bmap);
return map;
-error:
- isl_dim_free(dim);
- return NULL;
}
static int polylib_pos_to_isl_pos(__isl_keep isl_basic_map *bmap, int pos)
isl_stream_error(s, NULL, "unexpected EOF");
return NULL;
}
+ if (tok->type != ISL_TOKEN_VALUE || tok2->type != ISL_TOKEN_VALUE) {
+ isl_stream_push_token(s, tok2);
+ isl_stream_push_token(s, tok);
+ isl_stream_error(s, NULL,
+ "expecting constraint matrix dimensions");
+ return NULL;
+ }
n_row = isl_int_get_si(tok->u.v);
n_col = isl_int_get_si(tok2->u.v);
on_new_line = tok2->on_new_line;
int k = isl_basic_map_alloc_div(bmap);
if (k < 0)
goto error;
+ isl_seq_clr(bmap->div[k], 1 + 1 + nparam + in + out + local);
}
for (i = 0; i < n_row; ++i)
return NULL;
}
tok2 = isl_stream_next_token_on_same_line(s);
- if (tok2) {
+ if (tok2 && tok2->type == ISL_TOKEN_VALUE) {
isl_stream_push_token(s, tok2);
isl_stream_push_token(s, tok);
return isl_map_from_basic_map(basic_map_read_polylib(s, nparam));
}
+ if (tok2) {
+ isl_stream_error(s, tok2, "unexpected token");
+ isl_stream_push_token(s, tok2);
+ isl_stream_push_token(s, tok);
+ return NULL;
+ }
n = isl_int_get_si(tok->u.v);
isl_token_free(tok);
map = isl_map_from_basic_map(basic_map_read_polylib(s, nparam));
- for (i = 1; i < n; ++i)
+ for (i = 1; map && i < n; ++i)
map = isl_map_union(map,
isl_map_from_basic_map(basic_map_read_polylib(s, nparam)));
}
static __isl_give isl_div *read_div(struct isl_stream *s,
- __isl_keep isl_basic_map *bmap, struct vars *v)
+ __isl_take isl_dim *dim, struct vars *v)
{
- unsigned total = isl_basic_map_total_dim(bmap);
- int k;
+ int n;
+ isl_basic_map *bmap;
- bmap = isl_basic_map_copy(bmap);
- bmap = isl_basic_map_cow(bmap);
- bmap = isl_basic_map_extend_dim(bmap, isl_dim_copy(bmap->dim),
- 1, 0, 2);
+ n = v->n;
+ bmap = isl_basic_map_universe(dim);
- if ((k = isl_basic_map_alloc_div(bmap)) < 0)
+ if (vars_add_anon(v) < 0)
+ goto error;
+ if (read_div_definition(s, v) < 0)
goto error;
- isl_seq_clr(bmap->div[k], 1 + 1 + total);
- bmap = add_div_definition(s, v, bmap, k);
+ bmap = add_divs(bmap, v);
+ bmap = isl_basic_map_order_divs(bmap);
+ if (!bmap)
+ goto error;
+ vars_drop(v, v->n - n);
- return isl_basic_map_div(bmap, k);
+ return isl_basic_map_div(bmap, bmap->n_div - 1);
error:
isl_basic_map_free(bmap);
return NULL;
struct isl_qpolynomial *qp;
struct isl_token *tok;
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok) {
isl_stream_error(s, NULL, "unexpected EOF");
return NULL;
}
if (tok->type == '(') {
+ int pow;
+
isl_token_free(tok);
qp = read_term(s, bmap, v);
if (!qp)
return NULL;
if (isl_stream_eat(s, ')'))
goto error;
+ pow = optional_power(s);
+ qp = isl_qpolynomial_pow(qp, pow);
} else if (tok->type == ISL_TOKEN_VALUE) {
struct isl_token *tok2;
tok2 = isl_stream_next_token(s);
if (tok2 && tok2->type == '/') {
isl_token_free(tok2);
- tok2 = isl_stream_next_token(s);
+ tok2 = next_token(s);
if (!tok2 || tok2->type != ISL_TOKEN_VALUE) {
isl_stream_error(s, tok2, "expected denominator");
isl_token_free(tok);
return NULL;
}
if (pos >= n) {
+ vars_drop(v, v->n - n);
isl_stream_error(s, tok, "unknown identifier");
isl_token_free(tok);
return NULL;
}
isl_token_free(tok);
pow = optional_power(s);
- qp = isl_qpolynomial_pow(isl_basic_map_get_dim(bmap), pos, pow);
+ qp = isl_qpolynomial_var_pow(isl_basic_map_get_dim(bmap), pos, pow);
} else if (tok->type == '[') {
isl_div *div;
int pow;
isl_stream_push_token(s, tok);
- div = read_div(s, bmap, v);
+ div = read_div(s, isl_basic_map_get_dim(bmap), v);
pow = optional_power(s);
qp = isl_qpolynomial_div_pow(div, pow);
} else if (tok->type == '-') {
qp = read_factor(s, bmap, v);
for (;;) {
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok)
return qp;
goto error;
}
map = isl_map_from_basic_map(isl_basic_map_copy(bmap));
- if (tok->type == ':') {
+ if (tok->type == ':' ||
+ (tok->type == ISL_TOKEN_OR && !strcmp(tok->u.s, "|"))) {
isl_token_free(tok);
map = isl_map_intersect(map,
- read_disjuncts(s, v, isl_basic_map_get_dim(bmap)));
+ read_disjuncts(s, v, isl_basic_map_copy(bmap)));
} else
isl_stream_push_token(s, tok);
return obj;
}
-static __isl_give isl_basic_map *add_equalities(__isl_take isl_basic_map *bmap,
- isl_mat *eq)
+static int is_rational(struct isl_stream *s)
{
- int i, k;
- unsigned total = 1 + isl_basic_map_total_dim(bmap);
-
- if (!bmap || !eq)
- goto error;
-
- bmap = isl_basic_map_extend_constraints(bmap, eq->n_row, 0);
+ struct isl_token *tok;
- for (i = 0; i < eq->n_row; ++i) {
- k = isl_basic_map_alloc_equality(bmap);
- if (k < 0)
- goto error;
- isl_seq_cpy(bmap->eq[k], eq->row[i], eq->n_col);
- isl_seq_clr(bmap->eq[k] + eq->n_col, total - eq->n_col);
+ tok = isl_stream_next_token(s);
+ if (!tok)
+ return 0;
+ if (tok->type == ISL_TOKEN_RAT && isl_stream_next_token_is(s, ':')) {
+ isl_token_free(tok);
+ isl_stream_eat(s, ':');
+ return 1;
}
- isl_mat_free(eq);
- return bmap;
-error:
- isl_mat_free(eq);
- isl_basic_map_free(bmap);
- return NULL;
+ isl_stream_push_token(s, tok);
+
+ return 0;
}
static struct isl_obj obj_read_body(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v)
+ __isl_take isl_basic_map *bmap, struct vars *v)
{
struct isl_map *map = NULL;
struct isl_token *tok;
struct isl_obj obj = { isl_obj_set, NULL };
int n = v->n;
- isl_mat *eq = NULL;
- isl_basic_map *bmap;
- if (!next_is_tuple(s)) {
- bmap = isl_basic_map_alloc_dim(dim, 0, 0, 0);
- return obj_read_poly_or_fold(s, bmap, v, n);
- }
+ if (is_rational(s))
+ bmap = isl_basic_map_set_rational(bmap);
- eq = isl_mat_alloc(s->ctx, 0, 1 + n);
+ if (!next_is_tuple(s))
+ return obj_read_poly_or_fold(s, bmap, v, n);
- dim = read_tuple(s, dim, isl_dim_in, v, &eq);
- if (!dim)
+ bmap = read_tuple(s, bmap, isl_dim_in, v);
+ if (!bmap)
goto error;
tok = isl_stream_next_token(s);
if (tok && tok->type == ISL_TOKEN_TO) {
obj.type = isl_obj_map;
isl_token_free(tok);
if (!next_is_tuple(s)) {
- bmap = isl_basic_map_alloc_dim(dim, 0, 0, 0);
- bmap = add_equalities(bmap, eq);
bmap = isl_basic_map_reverse(bmap);
return obj_read_poly_or_fold(s, bmap, v, n);
}
- dim = read_tuple(s, dim, isl_dim_out, v, &eq);
- if (!dim)
+ bmap = read_tuple(s, bmap, isl_dim_out, v);
+ if (!bmap)
goto error;
} else {
- dim = isl_dim_reverse(dim);
+ bmap = isl_basic_map_reverse(bmap);
if (tok)
isl_stream_push_token(s, tok);
}
- bmap = isl_basic_map_alloc_dim(dim, 0, 0, 0);
- bmap = add_equalities(bmap, eq);
-
map = read_optional_disjuncts(s, bmap, v);
vars_drop(v, v->n - n);
obj.v = map;
return obj;
error:
- isl_mat_free(eq);
- isl_dim_free(dim);
+ isl_basic_map_free(bmap);
obj.type = isl_obj_none;
return obj;
}
static struct isl_obj obj_read(struct isl_stream *s, int nparam)
{
- isl_dim *dim = NULL;
+ isl_basic_map *bmap = NULL;
struct isl_token *tok;
struct vars *v = NULL;
struct isl_obj obj = { isl_obj_set, NULL };
- tok = isl_stream_next_token(s);
+ tok = next_token(s);
if (!tok) {
isl_stream_error(s, NULL, "unexpected EOF");
goto error;
}
if (tok->type == ISL_TOKEN_VALUE) {
+ struct isl_token *tok2;
struct isl_map *map;
+
+ tok2 = isl_stream_next_token(s);
+ if (!tok2 || tok2->type != ISL_TOKEN_VALUE ||
+ isl_int_is_neg(tok2->u.v)) {
+ if (tok2)
+ isl_stream_push_token(s, tok2);
+ obj.type = isl_obj_int;
+ obj.v = isl_int_obj_alloc(s->ctx, tok->u.v);
+ isl_token_free(tok);
+ return obj;
+ }
+ isl_stream_push_token(s, tok2);
isl_stream_push_token(s, tok);
map = map_read_polylib(s, nparam);
if (!map)
isl_stream_push_token(s, tok);
goto error;
}
- dim = isl_dim_alloc(s->ctx, 0, 0, 0);
+ bmap = isl_basic_map_alloc(s->ctx, 0, 0, 0, 0, 0, 0);
if (tok->type == '[') {
isl_stream_push_token(s, tok);
- dim = read_tuple(s, dim, isl_dim_param, v, NULL);
- if (!dim)
+ bmap = read_tuple(s, bmap, isl_dim_param, v);
+ if (!bmap)
goto error;
if (nparam >= 0)
isl_assert(s->ctx, nparam == v->n, goto error);
isl_token_free(tok);
tok = isl_stream_next_token(s);
} else if (nparam > 0)
- dim = isl_dim_add(dim, isl_dim_param, nparam);
+ bmap = isl_basic_map_add(bmap, isl_dim_param, nparam);
if (!tok || tok->type != '{') {
isl_stream_error(s, tok, "expecting '{'");
if (tok)
isl_token_free(tok);
if (isl_stream_eat(s, '='))
goto error;
- dim = read_tuple(s, dim, isl_dim_param, v, NULL);
- if (!dim)
+ bmap = read_tuple(s, bmap, isl_dim_param, v);
+ if (!bmap)
goto error;
if (nparam >= 0)
isl_assert(s->ctx, nparam == v->n, goto error);
} else if (tok->type == '}') {
obj.type = isl_obj_union_set;
- obj.v = isl_union_set_empty(isl_dim_copy(dim));
+ obj.v = isl_union_set_empty(isl_basic_map_get_dim(bmap));
isl_token_free(tok);
goto done;
} else
for (;;) {
struct isl_obj o;
tok = NULL;
- o = obj_read_body(s, isl_dim_copy(dim), v);
- if (o.type == isl_obj_none)
- break;
+ o = obj_read_body(s, isl_basic_map_copy(bmap), v);
+ if (o.type == isl_obj_none || !o.v)
+ goto error;
if (!obj.v)
obj = o;
else {
obj = obj_add(s->ctx, obj, o);
- if (obj.type == isl_obj_none)
- break;
+ if (obj.type == isl_obj_none || !obj.v)
+ goto error;
}
tok = isl_stream_next_token(s);
if (!tok || tok->type != ';')
break;
isl_token_free(tok);
+ if (isl_stream_next_token_is(s, '}')) {
+ tok = isl_stream_next_token(s);
+ break;
+ }
}
if (tok && tok->type == '}') {
}
done:
vars_free(v);
- isl_dim_free(dim);
+ isl_basic_map_free(bmap);
return obj;
error:
- isl_dim_free(dim);
+ isl_basic_map_free(bmap);
obj.type->free(obj.v);
if (v)
vars_free(v);
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;
return NULL;
}
-static char *next_line(FILE *input, char *line, unsigned len)
+__isl_give isl_union_map *isl_union_map_read_from_file(isl_ctx *ctx,
+ FILE *input)
{
- char *p;
+ isl_union_map *umap;
+ struct isl_stream *s = isl_stream_new_file(ctx, input);
+ if (!s)
+ return NULL;
+ umap = isl_stream_read_union_map(s);
+ isl_stream_free(s);
+ return umap;
+}
- do {
- if (!(p = fgets(line, len, input)))
- return NULL;
- while (isspace(*p) && *p != '\n')
- ++p;
- } while (*p == '#' || *p == '\n');
+__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_file(isl_ctx *ctx,
+ FILE *input)
+{
+ isl_union_set *uset;
+ struct isl_stream *s = isl_stream_new_file(ctx, input);
+ if (!s)
+ return NULL;
+ uset = isl_stream_read_union_set(s);
+ isl_stream_free(s);
+ return uset;
+}
- return p;
+__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 struct isl_vec *isl_vec_read_from_file_polylib(struct isl_ctx *ctx,
- FILE *input)
+static __isl_give isl_vec *isl_vec_read_polylib(struct isl_stream *s)
{
struct isl_vec *vec = NULL;
- char line[1024];
- char val[1024];
- char *p;
+ struct isl_token *tok;
unsigned size;
int j;
- int n;
- int offset;
- isl_assert(ctx, next_line(input, line, sizeof(line)), return NULL);
- isl_assert(ctx, sscanf(line, "%u", &size) == 1, return NULL);
+ tok = isl_stream_next_token(s);
+ if (!tok || tok->type != ISL_TOKEN_VALUE) {
+ isl_stream_error(s, tok, "expecting vector length");
+ goto error;
+ }
- vec = isl_vec_alloc(ctx, size);
+ size = isl_int_get_si(tok->u.v);
+ isl_token_free(tok);
- p = next_line(input, line, sizeof(line));
- isl_assert(ctx, p, goto error);
+ vec = isl_vec_alloc(s->ctx, size);
for (j = 0; j < size; ++j) {
- n = sscanf(p, "%s%n", val, &offset);
- isl_assert(ctx, n != 0, goto error);
- isl_int_read(vec->el[j], val);
- p += offset;
+ tok = isl_stream_next_token(s);
+ if (!tok || tok->type != ISL_TOKEN_VALUE) {
+ isl_stream_error(s, tok, "expecting constant value");
+ goto error;
+ }
+ isl_int_set(vec->el[j], tok->u.v);
+ isl_token_free(tok);
}
return vec;
error:
+ isl_token_free(tok);
isl_vec_free(vec);
return NULL;
}
-struct isl_vec *isl_vec_read_from_file(struct isl_ctx *ctx,
- FILE *input, unsigned input_format)
+static __isl_give isl_vec *vec_read(struct isl_stream *s)
{
- if (input_format == ISL_FORMAT_POLYLIB)
- return isl_vec_read_from_file_polylib(ctx, input);
- else
- isl_assert(ctx, 0, return NULL);
+ return isl_vec_read_polylib(s);
+}
+
+__isl_give isl_vec *isl_vec_read_from_file(isl_ctx *ctx, FILE *input)
+{
+ isl_vec *v;
+ struct isl_stream *s = isl_stream_new_file(ctx, input);
+ if (!s)
+ return NULL;
+ v = vec_read(s);
+ isl_stream_free(s);
+ return v;
}
__isl_give isl_pw_qpolynomial *isl_stream_read_pw_qpolynomial(