From 439e8b6ff4c90e52c43600bbd5010cfc8693b0cb Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 25 Jul 2011 12:03:05 +0200 Subject: [PATCH] isl_stream_read_map: accept "!=" in expressions Signed-off-by: Sven Verdoolaege --- include/isl/stream.h | 1 + isl_input.c | 4 ++++ isl_stream.c | 12 ++++++++++-- isl_test.c | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/isl/stream.h b/include/isl/stream.h index 0abc1fc..7aded32 100644 --- a/include/isl/stream.h +++ b/include/isl/stream.h @@ -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, diff --git a/isl_input.c b/isl_input.c index ce9b04b..6fc61a4 100644 --- a/isl_input.c +++ b/isl_input.c @@ -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: diff --git a/isl_stream.c b/isl_stream.c index b2406c0..d82436a 100644 --- a/isl_stream.c +++ b/isl_stream.c @@ -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; } diff --git a/isl_test.c b/isl_test.c index 94f415c..c5e3e83 100644 --- a/isl_test.c +++ b/isl_test.c @@ -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 }"); } -- 2.7.4