From: Sven Verdoolaege Date: Thu, 18 Feb 2010 20:37:04 +0000 (+0100) Subject: isl_map_read: accept affine combinations of earlier variables in variable tuples X-Git-Tag: isl-0.02~63 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d267cfa3e1761fafb462d52aa40e106a2bac7fc6;p=platform%2Fupstream%2Fisl.git isl_map_read: accept affine combinations of earlier variables in variable tuples --- diff --git a/isl_input.c b/isl_input.c index 542b3c6..daeac8b 100644 --- a/isl_input.c +++ b/isl_input.c @@ -146,47 +146,6 @@ error: return NULL; } -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) { - int p; - int n = v->n; - - if (tok->type != ISL_TOKEN_IDENT) - break; - - p = vars_pos(v, tok->u.s, -1); - if (p < 0) - goto error; - if (p < n) { - isl_stream_error(s, tok, "expecting unique identifier"); - goto error; - } - isl_token_free(tok); - - bmap = isl_basic_map_add(bmap, type, 1); - bmap = set_name(bmap, type, i++, v->v->name); - - tok = isl_stream_next_token(s); - if (!tok || tok->type != ',') - break; - - isl_token_free(tok); - } - if (tok) - isl_stream_push_token(s, tok); - - return bmap; -error: - isl_token_free(tok); - isl_basic_map_free(bmap); - return NULL; -} - static struct isl_vec *accept_affine(struct isl_stream *s, struct vars *v) { struct isl_token *tok = NULL; @@ -260,6 +219,72 @@ error: return NULL; } +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) { + int new_name = 0; + + if (tok->type == ISL_TOKEN_IDENT) { + int n = v->n; + int p = vars_pos(v, tok->u.s, -1); + if (p < 0) + goto error; + new_name = p >= n; + } + + if (new_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) { + struct isl_vec *vec; + int k; + if (type == isl_dim_param) { + isl_stream_error(s, tok, + "expecting unique identifier"); + goto error; + } + isl_stream_push_token(s, tok); + tok = NULL; + vec = accept_affine(s, v); + if (!vec) + goto error; + v->n++; + bmap = isl_basic_map_add(bmap, type, 1); + bmap = isl_basic_map_extend_constraints(bmap, 1, 0); + k = isl_basic_map_alloc_equality(bmap); + if (k >= 0) { + isl_seq_cpy(bmap->eq[k], vec->el, vec->size); + isl_int_set_si(bmap->eq[k][vec->size], -1); + } + isl_vec_free(vec); + if (k < 0) + goto error; + } else + break; + + tok = isl_stream_next_token(s); + if (!tok || tok->type != ',') + break; + + isl_token_free(tok); + i++; + } + if (tok) + isl_stream_push_token(s, tok); + + return bmap; +error: + isl_token_free(tok); + isl_basic_map_free(bmap); + return NULL; +} + static __isl_give isl_mat *accept_affine_list(struct isl_stream *s, struct vars *v) {