2 * Copyright 2008-2009 Katholieke Universiteit Leuven
3 * Copyright 2010 INRIA Saclay
5 * Use of this software is governed by the GNU LGPLv2.1 license
7 * Written by Sven Verdoolaege, K.U.Leuven, Departement
8 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
9 * and INRIA Saclay - Ile-de-France, Parc Club Orsay Universite,
10 * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France
20 #include "isl_stream.h"
21 #include "isl_map_private.h"
23 #include "isl_polynomial_private.h"
24 #include <isl_union_map.h>
25 #include <isl_mat_private.h>
31 struct variable *next;
40 static struct vars *vars_new(struct isl_ctx *ctx)
43 v = isl_alloc_type(ctx, struct vars);
52 static void variable_free(struct variable *var)
55 struct variable *next = var->next;
56 isl_vec_free(var->def);
63 static void vars_free(struct vars *v)
71 static void vars_drop(struct vars *v, int n)
82 struct variable *next = var->next;
83 isl_vec_free(var->def);
91 static struct variable *variable_new(struct vars *v, const char *name, int len,
95 var = isl_alloc_type(v->ctx, struct variable);
98 var->name = strdup(name);
99 var->name[len] = '\0';
109 static int vars_pos(struct vars *v, const char *s, int len)
116 for (q = v->v; q; q = q->next) {
117 if (strncmp(q->name, s, len) == 0 && q->name[len] == '\0')
124 v->v = variable_new(v, s, len, v->n);
132 static int vars_add_anon(struct vars *v)
134 v->v = variable_new(v, "", 0, v->n);
143 static __isl_give isl_basic_map *set_name(__isl_take isl_basic_map *bmap,
144 enum isl_dim_type type, unsigned pos, char *name)
153 prime = strchr(name, '\'');
156 bmap = isl_basic_map_set_dim_name(bmap, type, pos, name);
163 static int accept_cst_factor(struct isl_stream *s, isl_int *f)
165 struct isl_token *tok;
167 tok = isl_stream_next_token(s);
168 if (!tok || tok->type != ISL_TOKEN_VALUE) {
169 isl_stream_error(s, tok, "expecting constant value");
173 isl_int_mul(*f, *f, tok->u.v);
177 if (isl_stream_eat_if_available(s, '*'))
178 return accept_cst_factor(s, f);
186 static struct isl_vec *accept_affine(struct isl_stream *s, struct vars *v);
187 static int read_div_definition(struct isl_stream *s, struct vars *v);
189 static __isl_give isl_vec *accept_affine_factor(struct isl_stream *s,
192 struct isl_token *tok = NULL;
195 tok = isl_stream_next_token(s);
197 isl_stream_error(s, NULL, "unexpected EOF");
200 if (tok->type == ISL_TOKEN_IDENT) {
202 int pos = vars_pos(v, tok->u.s, -1);
206 isl_stream_error(s, tok, "unknown identifier");
210 aff = isl_vec_alloc(v->ctx, 1 + v->n);
213 isl_seq_clr(aff->el, aff->size);
214 isl_int_set_si(aff->el[1 + pos], 1);
216 } else if (tok->type == ISL_TOKEN_VALUE) {
217 if (isl_stream_eat_if_available(s, '*')) {
218 aff = accept_affine_factor(s, v);
219 aff = isl_vec_scale(aff, tok->u.v);
221 aff = isl_vec_alloc(v->ctx, 1 + v->n);
224 isl_seq_clr(aff->el, aff->size);
225 isl_int_set(aff->el[0], tok->u.v);
228 } else if (tok->type == '(') {
231 aff = accept_affine(s, v);
234 if (isl_stream_eat(s, ')'))
236 } else if (tok->type == '[') {
237 if (vars_add_anon(v) < 0)
239 aff = isl_vec_alloc(v->ctx, 1 + v->n);
242 isl_seq_clr(aff->el, aff->size);
243 isl_int_set_si(aff->el[1 + v->n - 1], 1);
244 isl_stream_push_token(s, tok);
246 if (read_div_definition(s, v) < 0)
249 isl_stream_error(s, tok, "expecting factor");
252 if (isl_stream_eat_if_available(s, '*')) {
255 isl_int_set_si(f, 1);
256 if (accept_cst_factor(s, &f) < 0) {
260 aff = isl_vec_scale(aff, f);
271 static struct isl_vec *accept_affine(struct isl_stream *s, struct vars *v)
273 struct isl_token *tok = NULL;
277 aff = isl_vec_alloc(v->ctx, 1 + v->n);
280 isl_seq_clr(aff->el, aff->size);
283 tok = isl_stream_next_token(s);
285 isl_stream_error(s, NULL, "unexpected EOF");
288 if (tok->type == '-') {
293 if (tok->type == '(' || tok->type == '[' ||
294 tok->type == ISL_TOKEN_IDENT) {
296 isl_stream_push_token(s, tok);
298 aff2 = accept_affine_factor(s, v);
300 aff2 = isl_vec_scale(aff2, s->ctx->negone);
301 aff = isl_vec_zero_extend(aff, 1 + v->n);
302 aff = isl_vec_add(aff, aff2);
306 } else if (tok->type == ISL_TOKEN_VALUE) {
308 isl_int_neg(tok->u.v, tok->u.v);
309 if (isl_stream_eat_if_available(s, '*') ||
310 isl_stream_next_token_is(s, ISL_TOKEN_IDENT)) {
312 aff2 = accept_affine_factor(s, v);
313 aff2 = isl_vec_scale(aff2, tok->u.v);
314 aff = isl_vec_zero_extend(aff, 1 + v->n);
315 aff = isl_vec_add(aff, aff2);
319 isl_int_add(aff->el[0], aff->el[0], tok->u.v);
323 isl_stream_error(s, tok, "unexpected isl_token");
324 isl_stream_push_token(s, tok);
330 tok = isl_stream_next_token(s);
331 if (tok && tok->type == '-') {
334 } else if (tok && tok->type == '+') {
337 } else if (tok && tok->type == ISL_TOKEN_VALUE &&
338 isl_int_is_neg(tok->u.v)) {
339 isl_stream_push_token(s, tok);
342 isl_stream_push_token(s, tok);
354 /* Add any variables in the variable list "v" that are not already in "bmap"
355 * as existentially quantified variables in "bmap".
357 static __isl_give isl_basic_map *add_divs(__isl_take isl_basic_map *bmap,
362 struct variable *var;
364 extra = v->n - isl_basic_map_total_dim(bmap);
369 bmap = isl_basic_map_extend_dim(bmap, isl_basic_map_get_dim(bmap),
370 extra, 0, 2 * extra);
372 for (i = 0; i < extra; ++i)
373 if (isl_basic_map_alloc_div(bmap) < 0)
376 for (i = 0, var = v->v; i < extra; ++i, var = var->next) {
377 int k = bmap->n_div - 1 - i;
379 isl_seq_cpy(bmap->div[k], var->def->el, 2 + var->pos);
380 isl_seq_clr(bmap->div[k] + 2 + var->pos, v->n - var->pos);
382 if (isl_basic_map_add_div_constraints(bmap, k) < 0)
388 isl_basic_map_free(bmap);
392 static __isl_give isl_basic_map *read_var_def(struct isl_stream *s,
393 __isl_take isl_basic_map *bmap, enum isl_dim_type type, struct vars *v)
399 if (vars_add_anon(v) < 0)
403 vec = accept_affine(s, v);
407 bmap = add_divs(bmap, v);
408 bmap = isl_basic_map_extend_constraints(bmap, 1, 0);
409 k = isl_basic_map_alloc_equality(bmap);
411 isl_seq_cpy(bmap->eq[k], vec->el, vec->size);
412 isl_int_set_si(bmap->eq[k][1 + n - 1], -1);
418 vars_drop(v, v->n - n);
422 isl_basic_map_free(bmap);
426 static __isl_give isl_basic_map *read_var_list(struct isl_stream *s,
427 __isl_take isl_basic_map *bmap, enum isl_dim_type type, struct vars *v)
430 struct isl_token *tok;
432 while ((tok = isl_stream_next_token(s)) != NULL) {
435 if (tok->type == ISL_TOKEN_IDENT) {
437 int p = vars_pos(v, tok->u.s, -1);
444 bmap = isl_basic_map_add(bmap, type, 1);
445 bmap = set_name(bmap, type, i, v->v->name);
447 } else if (tok->type == ISL_TOKEN_IDENT ||
448 tok->type == ISL_TOKEN_VALUE ||
451 if (type == isl_dim_param) {
452 isl_stream_error(s, tok,
453 "expecting unique identifier");
456 isl_stream_push_token(s, tok);
458 bmap = isl_basic_map_add(bmap, type, 1);
459 bmap = read_var_def(s, bmap, type, v);
463 tok = isl_stream_next_token(s);
464 if (!tok || tok->type != ',')
471 isl_stream_push_token(s, tok);
476 isl_basic_map_free(bmap);
480 static __isl_give isl_mat *accept_affine_list(struct isl_stream *s,
485 struct isl_token *tok = NULL;
487 vec = accept_affine(s, v);
488 mat = isl_mat_from_row_vec(vec);
493 tok = isl_stream_next_token(s);
495 isl_stream_error(s, NULL, "unexpected EOF");
498 if (tok->type != ',') {
499 isl_stream_push_token(s, tok);
504 vec = accept_affine(s, v);
505 mat = isl_mat_add_zero_cols(mat, 1 + v->n - isl_mat_cols(mat));
506 mat = isl_mat_vec_concat(mat, vec);
517 static int read_div_definition(struct isl_stream *s, struct vars *v)
519 struct isl_token *tok;
522 struct variable *var;
524 if (isl_stream_eat(s, '['))
527 tok = isl_stream_next_token(s);
530 if (tok->type == '(') {
534 isl_stream_push_token(s, tok);
538 aff = accept_affine(s, v);
542 var->def = isl_vec_alloc(s->ctx, 2 + v->n);
548 isl_seq_cpy(var->def->el + 1, aff->el, aff->size);
552 if (seen_paren && isl_stream_eat(s, ')'))
554 if (isl_stream_eat(s, '/'))
557 tok = isl_stream_next_token(s);
560 if (tok->type != ISL_TOKEN_VALUE) {
561 isl_stream_error(s, tok, "expected denominator");
562 isl_stream_push_token(s, tok);
565 isl_int_set(var->def->el[0], tok->u.v);
568 if (isl_stream_eat(s, ']'))
574 static struct isl_basic_map *add_div_definition(struct isl_stream *s,
575 struct vars *v, struct isl_basic_map *bmap, int k)
577 struct variable *var = v->v;
579 if (read_div_definition(s, v) < 0)
582 isl_seq_cpy(bmap->div[k], var->def->el, 2 + v->n);
584 if (isl_basic_map_add_div_constraints(bmap, k) < 0)
589 isl_basic_map_free(bmap);
593 static struct isl_basic_map *read_defined_var_list(struct isl_stream *s,
594 struct vars *v, struct isl_basic_map *bmap)
596 struct isl_token *tok;
598 while ((tok = isl_stream_next_token(s)) != NULL) {
602 unsigned total = isl_basic_map_total_dim(bmap);
604 if (tok->type != ISL_TOKEN_IDENT)
607 p = vars_pos(v, tok->u.s, -1);
611 isl_stream_error(s, tok, "expecting unique identifier");
615 bmap = isl_basic_map_cow(bmap);
616 bmap = isl_basic_map_extend_dim(bmap, isl_dim_copy(bmap->dim),
619 if ((k = isl_basic_map_alloc_div(bmap)) < 0)
621 isl_seq_clr(bmap->div[k], 1 + 1 + total);
624 tok = isl_stream_next_token(s);
625 if (tok && tok->type == '=') {
627 bmap = add_div_definition(s, v, bmap, k);
628 tok = isl_stream_next_token(s);
631 if (!tok || tok->type != ',')
637 isl_stream_push_token(s, tok);
642 isl_basic_map_free(bmap);
646 static int next_is_tuple(struct isl_stream *s)
648 struct isl_token *tok;
651 tok = isl_stream_next_token(s);
654 if (tok->type == '[') {
655 isl_stream_push_token(s, tok);
658 if (tok->type != ISL_TOKEN_IDENT) {
659 isl_stream_push_token(s, tok);
663 is_tuple = isl_stream_next_token_is(s, '[');
665 isl_stream_push_token(s, tok);
670 static __isl_give isl_basic_map *read_tuple(struct isl_stream *s,
671 __isl_take isl_basic_map *bmap, enum isl_dim_type type, struct vars *v);
673 static __isl_give isl_basic_map *read_nested_tuple(struct isl_stream *s,
674 __isl_take isl_basic_map *bmap, struct vars *v)
676 bmap = read_tuple(s, bmap, isl_dim_in, v);
677 if (isl_stream_eat(s, ISL_TOKEN_TO))
679 bmap = read_tuple(s, bmap, isl_dim_out, v);
680 bmap = isl_basic_map_from_range(isl_basic_map_wrap(bmap));
683 isl_basic_map_free(bmap);
687 static __isl_give isl_basic_map *read_tuple(struct isl_stream *s,
688 __isl_take isl_basic_map *bmap, enum isl_dim_type type, struct vars *v)
690 struct isl_token *tok;
693 tok = isl_stream_next_token(s);
694 if (tok && tok->type == ISL_TOKEN_IDENT) {
695 name = strdup(tok->u.s);
699 tok = isl_stream_next_token(s);
701 if (!tok || tok->type != '[') {
702 isl_stream_error(s, tok, "expecting '['");
706 if (type != isl_dim_param && next_is_tuple(s)) {
707 isl_dim *dim = isl_basic_map_get_dim(bmap);
708 int nparam = isl_dim_size(dim, isl_dim_param);
709 int n_in = isl_dim_size(dim, isl_dim_in);
710 isl_basic_map *nested;
711 if (type == isl_dim_out)
712 dim = isl_dim_move(dim, isl_dim_param, nparam,
713 isl_dim_in, 0, n_in);
714 nested = isl_basic_map_alloc_dim(dim, 0, 0, 0);
715 nested = read_nested_tuple(s, nested, v);
716 if (type == isl_dim_in) {
717 nested = isl_basic_map_reverse(nested);
718 bmap = isl_basic_map_intersect(nested, bmap);
721 dim = isl_dim_range(isl_basic_map_get_dim(nested));
722 dim = isl_dim_drop(dim, isl_dim_param, nparam, n_in);
723 dim = isl_dim_join(isl_basic_map_get_dim(bmap), dim);
724 bset = isl_basic_map_domain(bmap);
725 nested = isl_basic_map_reset_dim(nested, dim);
726 bmap = isl_basic_map_intersect_domain(nested, bset);
729 bmap = read_var_list(s, bmap, type, v);
730 tok = isl_stream_next_token(s);
731 if (!tok || tok->type != ']') {
732 isl_stream_error(s, tok, "expecting ']'");
738 bmap = isl_basic_map_set_tuple_name(bmap, type, name);
746 isl_basic_map_free(bmap);
750 static struct isl_basic_map *add_constraints(struct isl_stream *s,
751 struct vars *v, struct isl_basic_map *bmap);
753 static struct isl_basic_map *add_exists(struct isl_stream *s,
754 struct vars *v, struct isl_basic_map *bmap)
756 struct isl_token *tok;
763 tok = isl_stream_next_token(s);
766 if (tok->type == '(') {
770 isl_stream_push_token(s, tok);
772 bmap = read_defined_var_list(s, v, bmap);
776 if (isl_stream_eat(s, ':'))
778 bmap = add_constraints(s, v, bmap);
779 if (seen_paren && isl_stream_eat(s, ')'))
783 isl_basic_map_free(bmap);
787 static __isl_give isl_basic_map *construct_constraint(
788 __isl_take isl_basic_map *bmap, enum isl_token_type type,
789 isl_int *left, isl_int *right)
797 len = 1 + isl_basic_map_total_dim(bmap);
800 k = isl_basic_map_alloc_inequality(bmap);
803 if (type == ISL_TOKEN_LE)
804 isl_seq_combine(bmap->ineq[k], ctx->negone, left,
807 else if (type == ISL_TOKEN_GE)
808 isl_seq_combine(bmap->ineq[k], ctx->one, left,
811 else if (type == ISL_TOKEN_LT) {
812 isl_seq_combine(bmap->ineq[k], ctx->negone, left,
815 isl_int_sub_ui(bmap->ineq[k][0], bmap->ineq[k][0], 1);
816 } else if (type == ISL_TOKEN_GT) {
817 isl_seq_combine(bmap->ineq[k], ctx->one, left,
820 isl_int_sub_ui(bmap->ineq[k][0], bmap->ineq[k][0], 1);
822 isl_seq_combine(bmap->ineq[k], ctx->one, left,
825 isl_basic_map_inequality_to_equality(bmap, k);
830 isl_basic_map_free(bmap);
834 static int is_comparator(struct isl_token *tok)
851 static struct isl_basic_map *add_constraint(struct isl_stream *s,
852 struct vars *v, struct isl_basic_map *bmap)
855 struct isl_token *tok = NULL;
856 struct isl_mat *aff1 = NULL, *aff2 = NULL;
858 tok = isl_stream_next_token(s);
861 if (tok->type == ISL_TOKEN_EXISTS) {
863 return add_exists(s, v, bmap);
865 isl_stream_push_token(s, tok);
868 bmap = isl_basic_map_cow(bmap);
870 aff1 = accept_affine_list(s, v);
873 tok = isl_stream_next_token(s);
874 if (!is_comparator(tok)) {
875 isl_stream_error(s, tok, "missing operator");
877 isl_stream_push_token(s, tok);
882 aff2 = accept_affine_list(s, v);
886 aff1 = isl_mat_add_zero_cols(aff1, aff2->n_col - aff1->n_col);
889 bmap = add_divs(bmap, v);
890 bmap = isl_basic_map_extend_constraints(bmap, 0,
891 aff1->n_row * aff2->n_row);
892 for (i = 0; i < aff1->n_row; ++i)
893 for (j = 0; j < aff2->n_row; ++j)
894 bmap = construct_constraint(bmap, tok->type,
895 aff1->row[i], aff2->row[j]);
900 tok = isl_stream_next_token(s);
901 if (!is_comparator(tok)) {
903 isl_stream_push_token(s, tok);
915 isl_basic_map_free(bmap);
919 static struct isl_basic_map *add_constraints(struct isl_stream *s,
920 struct vars *v, struct isl_basic_map *bmap)
922 struct isl_token *tok;
925 bmap = add_constraint(s, v, bmap);
928 tok = isl_stream_next_token(s);
930 isl_stream_error(s, NULL, "unexpected EOF");
933 if (tok->type != ISL_TOKEN_AND)
937 isl_stream_push_token(s, tok);
943 isl_basic_map_free(bmap);
947 static struct isl_basic_map *read_disjunct(struct isl_stream *s,
948 struct vars *v, __isl_take isl_dim *dim)
951 struct isl_token *tok;
952 struct isl_basic_map *bmap;
954 bmap = isl_basic_map_alloc_dim(dim, 0, 0, 0);
958 tok = isl_stream_next_token(s);
961 if (tok->type == '(') {
965 isl_stream_push_token(s, tok);
967 bmap = add_constraints(s, v, bmap);
968 bmap = isl_basic_map_simplify(bmap);
969 bmap = isl_basic_map_finalize(bmap);
971 if (seen_paren && isl_stream_eat(s, ')'))
976 isl_basic_map_free(bmap);
980 static struct isl_map *read_disjuncts(struct isl_stream *s,
981 struct vars *v, __isl_take isl_dim *dim)
983 struct isl_token *tok;
986 tok = isl_stream_next_token(s);
988 isl_stream_error(s, NULL, "unexpected EOF");
991 if (tok->type == '}') {
992 isl_stream_push_token(s, tok);
993 return isl_map_universe(dim);
995 isl_stream_push_token(s, tok);
997 map = isl_map_empty(isl_dim_copy(dim));
999 struct isl_basic_map *bmap;
1002 bmap = read_disjunct(s, v, isl_dim_copy(dim));
1003 map = isl_map_union(map, isl_map_from_basic_map(bmap));
1005 vars_drop(v, v->n - n);
1007 tok = isl_stream_next_token(s);
1008 if (!tok || tok->type != ISL_TOKEN_OR)
1010 isl_token_free(tok);
1013 isl_stream_push_token(s, tok);
1022 static int polylib_pos_to_isl_pos(__isl_keep isl_basic_map *bmap, int pos)
1024 if (pos < isl_basic_map_dim(bmap, isl_dim_out))
1025 return 1 + isl_basic_map_dim(bmap, isl_dim_param) +
1026 isl_basic_map_dim(bmap, isl_dim_in) + pos;
1027 pos -= isl_basic_map_dim(bmap, isl_dim_out);
1029 if (pos < isl_basic_map_dim(bmap, isl_dim_in))
1030 return 1 + isl_basic_map_dim(bmap, isl_dim_param) + pos;
1031 pos -= isl_basic_map_dim(bmap, isl_dim_in);
1033 if (pos < isl_basic_map_dim(bmap, isl_dim_div))
1034 return 1 + isl_basic_map_dim(bmap, isl_dim_param) +
1035 isl_basic_map_dim(bmap, isl_dim_in) +
1036 isl_basic_map_dim(bmap, isl_dim_out) + pos;
1037 pos -= isl_basic_map_dim(bmap, isl_dim_div);
1039 if (pos < isl_basic_map_dim(bmap, isl_dim_param))
1045 static __isl_give isl_basic_map *basic_map_read_polylib_constraint(
1046 struct isl_stream *s, __isl_take isl_basic_map *bmap)
1049 struct isl_token *tok;
1059 nparam = isl_basic_map_dim(bmap, isl_dim_param);
1060 dim = isl_basic_map_dim(bmap, isl_dim_out);
1062 tok = isl_stream_next_token(s);
1063 if (!tok || tok->type != ISL_TOKEN_VALUE) {
1064 isl_stream_error(s, tok, "expecting coefficient");
1066 isl_stream_push_token(s, tok);
1069 if (!tok->on_new_line) {
1070 isl_stream_error(s, tok, "coefficient should appear on new line");
1071 isl_stream_push_token(s, tok);
1075 type = isl_int_get_si(tok->u.v);
1076 isl_token_free(tok);
1078 isl_assert(s->ctx, type == 0 || type == 1, goto error);
1080 k = isl_basic_map_alloc_equality(bmap);
1083 k = isl_basic_map_alloc_inequality(bmap);
1089 for (j = 0; j < 1 + isl_basic_map_total_dim(bmap); ++j) {
1091 tok = isl_stream_next_token(s);
1092 if (!tok || tok->type != ISL_TOKEN_VALUE) {
1093 isl_stream_error(s, tok, "expecting coefficient");
1095 isl_stream_push_token(s, tok);
1098 if (tok->on_new_line) {
1099 isl_stream_error(s, tok,
1100 "coefficient should not appear on new line");
1101 isl_stream_push_token(s, tok);
1104 pos = polylib_pos_to_isl_pos(bmap, j);
1105 isl_int_set(c[pos], tok->u.v);
1106 isl_token_free(tok);
1111 isl_basic_map_free(bmap);
1115 static __isl_give isl_basic_map *basic_map_read_polylib(struct isl_stream *s,
1119 struct isl_token *tok;
1120 struct isl_token *tok2;
1123 unsigned in = 0, out, local = 0;
1124 struct isl_basic_map *bmap = NULL;
1129 tok = isl_stream_next_token(s);
1131 isl_stream_error(s, NULL, "unexpected EOF");
1134 tok2 = isl_stream_next_token(s);
1136 isl_token_free(tok);
1137 isl_stream_error(s, NULL, "unexpected EOF");
1140 n_row = isl_int_get_si(tok->u.v);
1141 n_col = isl_int_get_si(tok2->u.v);
1142 on_new_line = tok2->on_new_line;
1143 isl_token_free(tok2);
1144 isl_token_free(tok);
1145 isl_assert(s->ctx, !on_new_line, return NULL);
1146 isl_assert(s->ctx, n_row >= 0, return NULL);
1147 isl_assert(s->ctx, n_col >= 2 + nparam, return NULL);
1148 tok = isl_stream_next_token_on_same_line(s);
1150 if (tok->type != ISL_TOKEN_VALUE) {
1151 isl_stream_error(s, tok,
1152 "expecting number of output dimensions");
1153 isl_stream_push_token(s, tok);
1156 out = isl_int_get_si(tok->u.v);
1157 isl_token_free(tok);
1159 tok = isl_stream_next_token_on_same_line(s);
1160 if (!tok || tok->type != ISL_TOKEN_VALUE) {
1161 isl_stream_error(s, tok,
1162 "expecting number of input dimensions");
1164 isl_stream_push_token(s, tok);
1167 in = isl_int_get_si(tok->u.v);
1168 isl_token_free(tok);
1170 tok = isl_stream_next_token_on_same_line(s);
1171 if (!tok || tok->type != ISL_TOKEN_VALUE) {
1172 isl_stream_error(s, tok,
1173 "expecting number of existentials");
1175 isl_stream_push_token(s, tok);
1178 local = isl_int_get_si(tok->u.v);
1179 isl_token_free(tok);
1181 tok = isl_stream_next_token_on_same_line(s);
1182 if (!tok || tok->type != ISL_TOKEN_VALUE) {
1183 isl_stream_error(s, tok,
1184 "expecting number of parameters");
1186 isl_stream_push_token(s, tok);
1189 nparam = isl_int_get_si(tok->u.v);
1190 isl_token_free(tok);
1191 if (n_col != 1 + out + in + local + nparam + 1) {
1192 isl_stream_error(s, NULL,
1193 "dimensions don't match");
1197 out = n_col - 2 - nparam;
1198 bmap = isl_basic_map_alloc(s->ctx, nparam, in, out, local, n_row, n_row);
1202 for (i = 0; i < local; ++i) {
1203 int k = isl_basic_map_alloc_div(bmap);
1206 isl_seq_clr(bmap->div[k], 1 + 1 + nparam + in + out + local);
1209 for (i = 0; i < n_row; ++i)
1210 bmap = basic_map_read_polylib_constraint(s, bmap);
1212 tok = isl_stream_next_token_on_same_line(s);
1214 isl_stream_error(s, tok, "unexpected extra token on line");
1215 isl_stream_push_token(s, tok);
1219 bmap = isl_basic_map_simplify(bmap);
1220 bmap = isl_basic_map_finalize(bmap);
1223 isl_basic_map_free(bmap);
1227 static struct isl_map *map_read_polylib(struct isl_stream *s, int nparam)
1229 struct isl_token *tok;
1230 struct isl_token *tok2;
1232 struct isl_map *map;
1234 tok = isl_stream_next_token(s);
1236 isl_stream_error(s, NULL, "unexpected EOF");
1239 tok2 = isl_stream_next_token_on_same_line(s);
1241 isl_stream_push_token(s, tok2);
1242 isl_stream_push_token(s, tok);
1243 return isl_map_from_basic_map(basic_map_read_polylib(s, nparam));
1245 n = isl_int_get_si(tok->u.v);
1246 isl_token_free(tok);
1248 isl_assert(s->ctx, n >= 1, return NULL);
1250 map = isl_map_from_basic_map(basic_map_read_polylib(s, nparam));
1252 for (i = 1; i < n; ++i)
1253 map = isl_map_union(map,
1254 isl_map_from_basic_map(basic_map_read_polylib(s, nparam)));
1259 static int optional_power(struct isl_stream *s)
1262 struct isl_token *tok;
1264 tok = isl_stream_next_token(s);
1267 if (tok->type != '^') {
1268 isl_stream_push_token(s, tok);
1271 isl_token_free(tok);
1272 tok = isl_stream_next_token(s);
1273 if (!tok || tok->type != ISL_TOKEN_VALUE) {
1274 isl_stream_error(s, tok, "expecting exponent");
1276 isl_stream_push_token(s, tok);
1279 pow = isl_int_get_si(tok->u.v);
1280 isl_token_free(tok);
1284 static __isl_give isl_div *read_div(struct isl_stream *s,
1285 __isl_keep isl_basic_map *bmap, struct vars *v)
1287 unsigned total = isl_basic_map_total_dim(bmap);
1290 bmap = isl_basic_map_copy(bmap);
1291 bmap = isl_basic_map_cow(bmap);
1292 bmap = isl_basic_map_extend_dim(bmap, isl_dim_copy(bmap->dim),
1295 if ((k = isl_basic_map_alloc_div(bmap)) < 0)
1297 isl_seq_clr(bmap->div[k], 1 + 1 + total);
1299 if (vars_add_anon(v) < 0)
1301 bmap = add_div_definition(s, v, bmap, k);
1304 return isl_basic_map_div(bmap, k);
1306 isl_basic_map_free(bmap);
1310 static __isl_give isl_qpolynomial *read_term(struct isl_stream *s,
1311 __isl_keep isl_basic_map *bmap, struct vars *v);
1313 static __isl_give isl_qpolynomial *read_factor(struct isl_stream *s,
1314 __isl_keep isl_basic_map *bmap, struct vars *v)
1316 struct isl_qpolynomial *qp;
1317 struct isl_token *tok;
1319 tok = isl_stream_next_token(s);
1321 isl_stream_error(s, NULL, "unexpected EOF");
1324 if (tok->type == '(') {
1325 isl_token_free(tok);
1326 qp = read_term(s, bmap, v);
1329 if (isl_stream_eat(s, ')'))
1331 } else if (tok->type == ISL_TOKEN_VALUE) {
1332 struct isl_token *tok2;
1333 tok2 = isl_stream_next_token(s);
1334 if (tok2 && tok2->type == '/') {
1335 isl_token_free(tok2);
1336 tok2 = isl_stream_next_token(s);
1337 if (!tok2 || tok2->type != ISL_TOKEN_VALUE) {
1338 isl_stream_error(s, tok2, "expected denominator");
1339 isl_token_free(tok);
1340 isl_token_free(tok2);
1343 qp = isl_qpolynomial_rat_cst(isl_basic_map_get_dim(bmap),
1344 tok->u.v, tok2->u.v);
1345 isl_token_free(tok2);
1347 isl_stream_push_token(s, tok2);
1348 qp = isl_qpolynomial_cst(isl_basic_map_get_dim(bmap),
1351 isl_token_free(tok);
1352 } else if (tok->type == ISL_TOKEN_INFTY) {
1353 isl_token_free(tok);
1354 qp = isl_qpolynomial_infty(isl_basic_map_get_dim(bmap));
1355 } else if (tok->type == ISL_TOKEN_NAN) {
1356 isl_token_free(tok);
1357 qp = isl_qpolynomial_nan(isl_basic_map_get_dim(bmap));
1358 } else if (tok->type == ISL_TOKEN_IDENT) {
1360 int pos = vars_pos(v, tok->u.s, -1);
1363 isl_token_free(tok);
1367 isl_stream_error(s, tok, "unknown identifier");
1368 isl_token_free(tok);
1371 isl_token_free(tok);
1372 pow = optional_power(s);
1373 qp = isl_qpolynomial_pow(isl_basic_map_get_dim(bmap), pos, pow);
1374 } else if (tok->type == '[') {
1378 isl_stream_push_token(s, tok);
1379 div = read_div(s, bmap, v);
1380 pow = optional_power(s);
1381 qp = isl_qpolynomial_div_pow(div, pow);
1382 } else if (tok->type == '-') {
1383 struct isl_qpolynomial *qp2;
1385 isl_token_free(tok);
1386 qp = isl_qpolynomial_cst(isl_basic_map_get_dim(bmap),
1388 qp2 = read_factor(s, bmap, v);
1389 qp = isl_qpolynomial_mul(qp, qp2);
1391 isl_stream_error(s, tok, "unexpected isl_token");
1392 isl_stream_push_token(s, tok);
1396 if (isl_stream_eat_if_available(s, '*') ||
1397 isl_stream_next_token_is(s, ISL_TOKEN_IDENT)) {
1398 struct isl_qpolynomial *qp2;
1400 qp2 = read_factor(s, bmap, v);
1401 qp = isl_qpolynomial_mul(qp, qp2);
1406 isl_qpolynomial_free(qp);
1410 static __isl_give isl_qpolynomial *read_term(struct isl_stream *s,
1411 __isl_keep isl_basic_map *bmap, struct vars *v)
1413 struct isl_token *tok;
1414 struct isl_qpolynomial *qp;
1416 qp = read_factor(s, bmap, v);
1419 tok = isl_stream_next_token(s);
1423 if (tok->type == '+') {
1424 struct isl_qpolynomial *qp2;
1426 isl_token_free(tok);
1427 qp2 = read_factor(s, bmap, v);
1428 qp = isl_qpolynomial_add(qp, qp2);
1429 } else if (tok->type == '-') {
1430 struct isl_qpolynomial *qp2;
1432 isl_token_free(tok);
1433 qp2 = read_factor(s, bmap, v);
1434 qp = isl_qpolynomial_sub(qp, qp2);
1435 } else if (tok->type == ISL_TOKEN_VALUE &&
1436 isl_int_is_neg(tok->u.v)) {
1437 struct isl_qpolynomial *qp2;
1439 isl_stream_push_token(s, tok);
1440 qp2 = read_factor(s, bmap, v);
1441 qp = isl_qpolynomial_add(qp, qp2);
1443 isl_stream_push_token(s, tok);
1451 static __isl_give isl_map *read_optional_disjuncts(struct isl_stream *s,
1452 __isl_take isl_basic_map *bmap, struct vars *v)
1454 struct isl_token *tok;
1455 struct isl_map *map;
1457 tok = isl_stream_next_token(s);
1459 isl_stream_error(s, NULL, "unexpected EOF");
1462 map = isl_map_from_basic_map(isl_basic_map_copy(bmap));
1463 if (tok->type == ':') {
1464 isl_token_free(tok);
1465 map = isl_map_intersect(map,
1466 read_disjuncts(s, v, isl_basic_map_get_dim(bmap)));
1468 isl_stream_push_token(s, tok);
1470 isl_basic_map_free(bmap);
1474 isl_basic_map_free(bmap);
1478 static struct isl_obj obj_read_poly(struct isl_stream *s,
1479 __isl_take isl_basic_map *bmap, struct vars *v, int n)
1481 struct isl_obj obj = { isl_obj_pw_qpolynomial, NULL };
1482 struct isl_pw_qpolynomial *pwqp;
1483 struct isl_qpolynomial *qp;
1484 struct isl_map *map;
1485 struct isl_set *set;
1487 qp = read_term(s, bmap, v);
1488 map = read_optional_disjuncts(s, bmap, v);
1489 set = isl_map_range(map);
1491 pwqp = isl_pw_qpolynomial_alloc(set, qp);
1493 vars_drop(v, v->n - n);
1499 static struct isl_obj obj_read_poly_or_fold(struct isl_stream *s,
1500 __isl_take isl_basic_map *bmap, struct vars *v, int n)
1502 struct isl_obj obj = { isl_obj_pw_qpolynomial_fold, NULL };
1503 struct isl_obj obj_p;
1504 isl_qpolynomial *qp;
1505 isl_qpolynomial_fold *fold = NULL;
1506 isl_pw_qpolynomial_fold *pwf;
1510 if (!isl_stream_eat_if_available(s, ISL_TOKEN_MAX))
1511 return obj_read_poly(s, bmap, v, n);
1513 if (isl_stream_eat(s, '('))
1516 qp = read_term(s, bmap, v);
1517 fold = isl_qpolynomial_fold_alloc(isl_fold_max, qp);
1519 while (isl_stream_eat_if_available(s, ',')) {
1520 isl_qpolynomial_fold *fold_i;
1521 qp = read_term(s, bmap, v);
1522 fold_i = isl_qpolynomial_fold_alloc(isl_fold_max, qp);
1523 fold = isl_qpolynomial_fold_fold(fold, fold_i);
1526 if (isl_stream_eat(s, ')'))
1529 map = read_optional_disjuncts(s, bmap, v);
1530 set = isl_map_range(map);
1531 pwf = isl_pw_qpolynomial_fold_alloc(isl_fold_max, set, fold);
1533 vars_drop(v, v->n - n);
1538 isl_basic_map_free(bmap);
1539 isl_qpolynomial_fold_free(fold);
1540 obj.type = isl_obj_none;
1544 static struct isl_obj obj_read_body(struct isl_stream *s,
1545 __isl_take isl_basic_map *bmap, struct vars *v)
1547 struct isl_map *map = NULL;
1548 struct isl_token *tok;
1549 struct isl_obj obj = { isl_obj_set, NULL };
1552 if (!next_is_tuple(s))
1553 return obj_read_poly_or_fold(s, bmap, v, n);
1555 bmap = read_tuple(s, bmap, isl_dim_in, v);
1558 tok = isl_stream_next_token(s);
1559 if (tok && tok->type == ISL_TOKEN_TO) {
1560 obj.type = isl_obj_map;
1561 isl_token_free(tok);
1562 if (!next_is_tuple(s)) {
1563 bmap = isl_basic_map_reverse(bmap);
1564 return obj_read_poly_or_fold(s, bmap, v, n);
1566 bmap = read_tuple(s, bmap, isl_dim_out, v);
1570 bmap = isl_basic_map_reverse(bmap);
1572 isl_stream_push_token(s, tok);
1575 map = read_optional_disjuncts(s, bmap, v);
1577 vars_drop(v, v->n - n);
1582 isl_basic_map_free(bmap);
1583 obj.type = isl_obj_none;
1587 static struct isl_obj to_union(isl_ctx *ctx, struct isl_obj obj)
1589 if (obj.type == isl_obj_map) {
1590 obj.v = isl_union_map_from_map(obj.v);
1591 obj.type = isl_obj_union_map;
1592 } else if (obj.type == isl_obj_set) {
1593 obj.v = isl_union_set_from_set(obj.v);
1594 obj.type = isl_obj_union_set;
1595 } else if (obj.type == isl_obj_pw_qpolynomial) {
1596 obj.v = isl_union_pw_qpolynomial_from_pw_qpolynomial(obj.v);
1597 obj.type = isl_obj_union_pw_qpolynomial;
1598 } else if (obj.type == isl_obj_pw_qpolynomial_fold) {
1599 obj.v = isl_union_pw_qpolynomial_fold_from_pw_qpolynomial_fold(obj.v);
1600 obj.type = isl_obj_union_pw_qpolynomial_fold;
1602 isl_assert(ctx, 0, goto error);
1605 obj.type->free(obj.v);
1606 obj.type = isl_obj_none;
1610 static struct isl_obj obj_add(struct isl_ctx *ctx,
1611 struct isl_obj obj1, struct isl_obj obj2)
1613 if (obj1.type == isl_obj_set && obj2.type == isl_obj_union_set)
1614 obj1 = to_union(ctx, obj1);
1615 if (obj1.type == isl_obj_union_set && obj2.type == isl_obj_set)
1616 obj2 = to_union(ctx, obj2);
1617 if (obj1.type == isl_obj_map && obj2.type == isl_obj_union_map)
1618 obj1 = to_union(ctx, obj1);
1619 if (obj1.type == isl_obj_union_map && obj2.type == isl_obj_map)
1620 obj2 = to_union(ctx, obj2);
1621 if (obj1.type == isl_obj_pw_qpolynomial &&
1622 obj2.type == isl_obj_union_pw_qpolynomial)
1623 obj1 = to_union(ctx, obj1);
1624 if (obj1.type == isl_obj_union_pw_qpolynomial &&
1625 obj2.type == isl_obj_pw_qpolynomial)
1626 obj2 = to_union(ctx, obj2);
1627 if (obj1.type == isl_obj_pw_qpolynomial_fold &&
1628 obj2.type == isl_obj_union_pw_qpolynomial_fold)
1629 obj1 = to_union(ctx, obj1);
1630 if (obj1.type == isl_obj_union_pw_qpolynomial_fold &&
1631 obj2.type == isl_obj_pw_qpolynomial_fold)
1632 obj2 = to_union(ctx, obj2);
1633 isl_assert(ctx, obj1.type == obj2.type, goto error);
1634 if (obj1.type == isl_obj_map && !isl_map_has_equal_dim(obj1.v, obj2.v)) {
1635 obj1 = to_union(ctx, obj1);
1636 obj2 = to_union(ctx, obj2);
1638 if (obj1.type == isl_obj_set && !isl_set_has_equal_dim(obj1.v, obj2.v)) {
1639 obj1 = to_union(ctx, obj1);
1640 obj2 = to_union(ctx, obj2);
1642 if (obj1.type == isl_obj_pw_qpolynomial &&
1643 !isl_pw_qpolynomial_has_equal_dim(obj1.v, obj2.v)) {
1644 obj1 = to_union(ctx, obj1);
1645 obj2 = to_union(ctx, obj2);
1647 if (obj1.type == isl_obj_pw_qpolynomial_fold &&
1648 !isl_pw_qpolynomial_fold_has_equal_dim(obj1.v, obj2.v)) {
1649 obj1 = to_union(ctx, obj1);
1650 obj2 = to_union(ctx, obj2);
1652 obj1.v = obj1.type->add(obj1.v, obj2.v);
1655 obj1.type->free(obj1.v);
1656 obj2.type->free(obj2.v);
1657 obj1.type = isl_obj_none;
1662 static struct isl_obj obj_read(struct isl_stream *s, int nparam)
1664 isl_basic_map *bmap = NULL;
1665 struct isl_token *tok;
1666 struct vars *v = NULL;
1667 struct isl_obj obj = { isl_obj_set, NULL };
1669 tok = isl_stream_next_token(s);
1671 isl_stream_error(s, NULL, "unexpected EOF");
1674 if (tok->type == ISL_TOKEN_VALUE) {
1675 struct isl_map *map;
1676 isl_stream_push_token(s, tok);
1677 map = map_read_polylib(s, nparam);
1680 if (isl_map_dim(map, isl_dim_in) > 0)
1681 obj.type = isl_obj_map;
1685 v = vars_new(s->ctx);
1687 isl_stream_push_token(s, tok);
1690 bmap = isl_basic_map_alloc(s->ctx, 0, 0, 0, 0, 0, 0);
1691 if (tok->type == '[') {
1692 isl_stream_push_token(s, tok);
1693 bmap = read_tuple(s, bmap, isl_dim_param, v);
1697 isl_assert(s->ctx, nparam == v->n, goto error);
1698 tok = isl_stream_next_token(s);
1699 if (!tok || tok->type != ISL_TOKEN_TO) {
1700 isl_stream_error(s, tok, "expecting '->'");
1702 isl_stream_push_token(s, tok);
1705 isl_token_free(tok);
1706 tok = isl_stream_next_token(s);
1707 } else if (nparam > 0)
1708 bmap = isl_basic_map_add(bmap, isl_dim_param, nparam);
1709 if (!tok || tok->type != '{') {
1710 isl_stream_error(s, tok, "expecting '{'");
1712 isl_stream_push_token(s, tok);
1715 isl_token_free(tok);
1717 tok = isl_stream_next_token(s);
1720 else if (tok->type == ISL_TOKEN_IDENT && !strcmp(tok->u.s, "Sym")) {
1721 isl_token_free(tok);
1722 if (isl_stream_eat(s, '='))
1724 bmap = read_tuple(s, bmap, isl_dim_param, v);
1728 isl_assert(s->ctx, nparam == v->n, goto error);
1729 } else if (tok->type == '}') {
1730 obj.type = isl_obj_union_set;
1731 obj.v = isl_union_set_empty(isl_basic_map_get_dim(bmap));
1732 isl_token_free(tok);
1735 isl_stream_push_token(s, tok);
1740 o = obj_read_body(s, isl_basic_map_copy(bmap), v);
1741 if (o.type == isl_obj_none || !o.v)
1746 obj = obj_add(s->ctx, obj, o);
1747 if (obj.type == isl_obj_none || !obj.v)
1750 tok = isl_stream_next_token(s);
1751 if (!tok || tok->type != ';')
1753 isl_token_free(tok);
1756 if (tok && tok->type == '}') {
1757 isl_token_free(tok);
1759 isl_stream_error(s, tok, "unexpected isl_token");
1761 isl_token_free(tok);
1766 isl_basic_map_free(bmap);
1770 isl_basic_map_free(bmap);
1771 obj.type->free(obj.v);
1778 struct isl_obj isl_stream_read_obj(struct isl_stream *s)
1780 return obj_read(s, -1);
1783 __isl_give isl_map *isl_stream_read_map(struct isl_stream *s, int nparam)
1786 struct isl_map *map;
1788 obj = obj_read(s, nparam);
1790 isl_assert(s->ctx, obj.type == isl_obj_map ||
1791 obj.type == isl_obj_set, goto error);
1795 obj.type->free(obj.v);
1799 __isl_give isl_set *isl_stream_read_set(struct isl_stream *s, int nparam)
1802 struct isl_set *set;
1804 obj = obj_read(s, nparam);
1806 isl_assert(s->ctx, obj.type == isl_obj_set, goto error);
1810 obj.type->free(obj.v);
1814 static struct isl_basic_map *basic_map_read(struct isl_stream *s, int nparam)
1817 struct isl_map *map;
1818 struct isl_basic_map *bmap;
1820 obj = obj_read(s, nparam);
1825 isl_assert(map->ctx, map->n <= 1, goto error);
1828 bmap = isl_basic_map_empty_like_map(map);
1830 bmap = isl_basic_map_copy(map->p[0]);
1840 __isl_give isl_basic_map *isl_basic_map_read_from_file(isl_ctx *ctx,
1841 FILE *input, int nparam)
1843 struct isl_basic_map *bmap;
1844 struct isl_stream *s = isl_stream_new_file(ctx, input);
1847 bmap = basic_map_read(s, nparam);
1852 __isl_give isl_basic_set *isl_basic_set_read_from_file(isl_ctx *ctx,
1853 FILE *input, int nparam)
1855 struct isl_basic_map *bmap;
1856 bmap = isl_basic_map_read_from_file(ctx, input, nparam);
1859 isl_assert(ctx, isl_basic_map_n_in(bmap) == 0, goto error);
1860 return (struct isl_basic_set *)bmap;
1862 isl_basic_map_free(bmap);
1866 struct isl_basic_map *isl_basic_map_read_from_str(struct isl_ctx *ctx,
1867 const char *str, int nparam)
1869 struct isl_basic_map *bmap;
1870 struct isl_stream *s = isl_stream_new_str(ctx, str);
1873 bmap = basic_map_read(s, nparam);
1878 struct isl_basic_set *isl_basic_set_read_from_str(struct isl_ctx *ctx,
1879 const char *str, int nparam)
1881 struct isl_basic_map *bmap;
1882 bmap = isl_basic_map_read_from_str(ctx, str, nparam);
1885 isl_assert(ctx, isl_basic_map_n_in(bmap) == 0, goto error);
1886 return (struct isl_basic_set *)bmap;
1888 isl_basic_map_free(bmap);
1892 __isl_give isl_map *isl_map_read_from_file(struct isl_ctx *ctx,
1893 FILE *input, int nparam)
1895 struct isl_map *map;
1896 struct isl_stream *s = isl_stream_new_file(ctx, input);
1899 map = isl_stream_read_map(s, nparam);
1904 __isl_give isl_map *isl_map_read_from_str(struct isl_ctx *ctx,
1905 const char *str, int nparam)
1907 struct isl_map *map;
1908 struct isl_stream *s = isl_stream_new_str(ctx, str);
1911 map = isl_stream_read_map(s, nparam);
1916 __isl_give isl_set *isl_set_read_from_file(struct isl_ctx *ctx,
1917 FILE *input, int nparam)
1919 struct isl_map *map;
1920 map = isl_map_read_from_file(ctx, input, nparam);
1923 isl_assert(ctx, isl_map_n_in(map) == 0, goto error);
1924 return (struct isl_set *)map;
1930 struct isl_set *isl_set_read_from_str(struct isl_ctx *ctx,
1931 const char *str, int nparam)
1933 struct isl_map *map;
1934 map = isl_map_read_from_str(ctx, str, nparam);
1937 isl_assert(ctx, isl_map_n_in(map) == 0, goto error);
1938 return (struct isl_set *)map;
1944 static char *next_line(FILE *input, char *line, unsigned len)
1949 if (!(p = fgets(line, len, input)))
1951 while (isspace(*p) && *p != '\n')
1953 } while (*p == '#' || *p == '\n');
1958 static struct isl_vec *isl_vec_read_from_file_polylib(struct isl_ctx *ctx,
1961 struct isl_vec *vec = NULL;
1970 isl_assert(ctx, next_line(input, line, sizeof(line)), return NULL);
1971 isl_assert(ctx, sscanf(line, "%u", &size) == 1, return NULL);
1973 vec = isl_vec_alloc(ctx, size);
1975 p = next_line(input, line, sizeof(line));
1976 isl_assert(ctx, p, goto error);
1978 for (j = 0; j < size; ++j) {
1979 n = sscanf(p, "%s%n", val, &offset);
1980 isl_assert(ctx, n != 0, goto error);
1981 isl_int_read(vec->el[j], val);
1991 struct isl_vec *isl_vec_read_from_file(struct isl_ctx *ctx,
1992 FILE *input, unsigned input_format)
1994 if (input_format == ISL_FORMAT_POLYLIB)
1995 return isl_vec_read_from_file_polylib(ctx, input);
1997 isl_assert(ctx, 0, return NULL);
2000 __isl_give isl_pw_qpolynomial *isl_stream_read_pw_qpolynomial(
2001 struct isl_stream *s)
2004 struct isl_pw_qpolynomial *pwqp;
2006 obj = obj_read(s, -1);
2008 isl_assert(s->ctx, obj.type == isl_obj_pw_qpolynomial,
2013 obj.type->free(obj.v);
2017 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_read_from_str(isl_ctx *ctx,
2020 isl_pw_qpolynomial *pwqp;
2021 struct isl_stream *s = isl_stream_new_str(ctx, str);
2024 pwqp = isl_stream_read_pw_qpolynomial(s);