isl_stream_read_map: accept arbitrary affine expressions in tuples
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 25 Jul 2011 09:48:49 +0000 (11:48 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 28 Jul 2011 14:47:53 +0000 (16:47 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_input.c
isl_test.c

index f9bbdff..175c2ec 100644 (file)
@@ -566,6 +566,9 @@ static __isl_give isl_map *read_var_list(struct isl_stream *s,
        int i = 0;
        struct isl_token *tok;
 
+       if (isl_stream_next_token_is(s, ']'))
+               return map;
+
        while ((tok = next_token(s)) != NULL) {
                int new_name = 0;
 
@@ -581,10 +584,7 @@ static __isl_give isl_map *read_var_list(struct isl_stream *s,
                        map = isl_map_add_dims(map, type, 1);
                        map = set_name(map, 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 == '(') {
+               } else {
                        if (type == isl_dim_param) {
                                isl_stream_error(s, tok,
                                                "expecting unique identifier");
@@ -596,8 +596,7 @@ static __isl_give isl_map *read_var_list(struct isl_stream *s,
                                goto error;
                        map = isl_map_add_dims(map, type, 1);
                        map = read_var_def(s, map, type, v);
-               } else
-                       break;
+               }
 
                tok = isl_stream_next_token(s);
                if (tok && tok->type == ']' &&
index d8248a3..94f415c 100644 (file)
@@ -120,6 +120,10 @@ void test_parse(struct isl_ctx *ctx)
        str2 = "[n] -> { [c1] : c1 >= 0 and 3c1 <= -4 + n }";
        test_parse_map_equal(ctx, str, str2);
 
+       str = "{ [i,j] -> [i] : i < j; [i,j] -> [j] : j <= i }";
+       str2 = "{ [i,j] -> [min(i,j)] }";
+       test_parse_map_equal(ctx, str, str2);
+
        test_parse_pwqp(ctx, "{ [i] -> i + [ (i + [i/3])/2 ] }");
        test_parse_map(ctx, "{ S1[i] -> [([i/10]),i%10] : 0 <= i <= 45 }");
 }