isl_stream_read_map: allow negations
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 13 Feb 2011 14:11:41 +0000 (15:11 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 17 Feb 2011 18:50:22 +0000 (19:50 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
include/isl/stream.h
isl_input.c
isl_stream.c

index a7becf6..1fad576 100644 (file)
@@ -25,7 +25,7 @@ enum isl_token_type { ISL_TOKEN_ERROR = -1,
                        ISL_TOKEN_LEX_GE, ISL_TOKEN_LEX_LE,
                        ISL_TOKEN_LEX_GT, ISL_TOKEN_LEX_LT,
                        ISL_TOKEN_TO, ISL_TOKEN_AND,
-                       ISL_TOKEN_OR, ISL_TOKEN_EXISTS,
+                       ISL_TOKEN_OR, ISL_TOKEN_EXISTS, ISL_TOKEN_NOT,
                        ISL_TOKEN_DEF, ISL_TOKEN_INFTY, ISL_TOKEN_NAN,
                        ISL_TOKEN_MAX, ISL_TOKEN_RAT,
                        ISL_TOKEN_STRING,
index 46e3dbb..9dca423 100644 (file)
@@ -1001,13 +1001,25 @@ static __isl_give isl_map *read_conjuncts(struct isl_stream *s,
        struct vars *v, __isl_take isl_basic_map *bmap)
 {
        isl_map *map;
+       int negate;
 
+       negate = isl_stream_eat_if_available(s, ISL_TOKEN_NOT);
        map = read_conjunct(s, v, isl_basic_map_copy(bmap));
+       if (negate) {
+               isl_map *t;
+               t = isl_map_from_basic_map(isl_basic_map_copy(bmap));
+               map = isl_map_subtract(t, map);
+       }
+
        while (isl_stream_eat_if_available(s, ISL_TOKEN_AND)) {
                isl_map *map_i;
 
+               negate = isl_stream_eat_if_available(s, ISL_TOKEN_NOT);
                map_i = read_conjunct(s, v, isl_basic_map_copy(bmap));
-               map = isl_map_intersect(map, map_i);
+               if (negate)
+                       map = isl_map_subtract(map, map_i);
+               else
+                       map = isl_map_intersect(map, map_i);
        }
 
        isl_basic_map_free(bmap);
index 3d37343..ce50657 100644 (file)
@@ -223,6 +223,8 @@ static enum isl_token_type check_keywords(struct isl_stream *s)
                return ISL_TOKEN_AND;
        if (!strcasecmp(s->buffer, "or"))
                return ISL_TOKEN_OR;
+       if (!strcasecmp(s->buffer, "not"))
+               return ISL_TOKEN_NOT;
        if (!strcasecmp(s->buffer, "infty"))
                return ISL_TOKEN_INFTY;
        if (!strcasecmp(s->buffer, "infinity"))
@@ -481,6 +483,14 @@ static struct isl_token *next_token(struct isl_stream *s, int same_line)
                        tok->u.s = strdup("||");
                return tok;
        }
+       if (c == '!') {
+               tok = isl_token_new(s->ctx, line, col, old_line != line);
+               if (!tok)
+                       return NULL;
+               tok->type = ISL_TOKEN_NOT;
+               tok->u.s = strdup("!");
+               return tok;
+       }
 
        tok = isl_token_new(s->ctx, line, col, old_line != line);
        if (!tok)