isl_stream_read_map: accept "!=" in expressions
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 25 Jul 2011 10:03:05 +0000 (12:03 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 28 Jul 2011 14:49:24 +0000 (16:49 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
include/isl/stream.h
isl_input.c
isl_stream.c
isl_test.c

index 0abc1fc..7aded32 100644 (file)
@@ -22,6 +22,7 @@ enum isl_token_type { ISL_TOKEN_ERROR = -1,
                        ISL_TOKEN_UNKNOWN = 256, ISL_TOKEN_VALUE,
                        ISL_TOKEN_IDENT, ISL_TOKEN_GE,
                        ISL_TOKEN_LE, ISL_TOKEN_GT, ISL_TOKEN_LT,
+                       ISL_TOKEN_NE,
                        ISL_TOKEN_LEX_GE, ISL_TOKEN_LEX_LE,
                        ISL_TOKEN_LEX_GT, ISL_TOKEN_LEX_LT,
                        ISL_TOKEN_TO, ISL_TOKEN_AND,
index ce9b04b..6fc61a4 100644 (file)
@@ -826,6 +826,9 @@ static __isl_give isl_set *construct_constraints(
        else if (type == ISL_TOKEN_GT)
                cond = isl_pw_aff_list_gt_set(isl_pw_aff_list_copy(left),
                                              isl_pw_aff_list_copy(right));
+       else if (type == ISL_TOKEN_NE)
+               cond = isl_pw_aff_list_ne_set(isl_pw_aff_list_copy(left),
+                                             isl_pw_aff_list_copy(right));
        else
                cond = isl_pw_aff_list_eq_set(isl_pw_aff_list_copy(left),
                                              isl_pw_aff_list_copy(right));
@@ -843,6 +846,7 @@ static int is_comparator(struct isl_token *tok)
        case ISL_TOKEN_GT:
        case ISL_TOKEN_LE:
        case ISL_TOKEN_GE:
+       case ISL_TOKEN_NE:
        case '=':
                return 1;
        default:
index b2406c0..d82436a 100644 (file)
@@ -544,8 +544,16 @@ static struct isl_token *next_token(struct isl_stream *s, int same_line)
                tok = isl_token_new(s->ctx, line, col, old_line != line);
                if (!tok)
                        return NULL;
-               tok->type = ISL_TOKEN_NOT;
-               tok->u.s = strdup("!");
+               if ((c = isl_stream_getc(s)) == '=') {
+                       tok->u.s = strdup("!=");
+                       tok->type = ISL_TOKEN_NE;
+                       return tok;
+               } else {
+                       tok->type = ISL_TOKEN_NOT;
+                       tok->u.s = strdup("!");
+               }
+               if (c != -1)
+                       isl_stream_ungetc(s, c);
                return tok;
        }
 
index 94f415c..c5e3e83 100644 (file)
@@ -124,6 +124,10 @@ void test_parse(struct isl_ctx *ctx)
        str2 = "{ [i,j] -> [min(i,j)] }";
        test_parse_map_equal(ctx, str, str2);
 
+       str = "{ [i,j] : i != j }";
+       str2 = "{ [i,j] : i < j or 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 }");
 }