isl_stream: support compound tokens
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 26 Jul 2011 10:32:14 +0000 (12:32 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 28 Jul 2011 14:50:25 +0000 (16:50 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
include/isl/stream.h
isl_stream.c

index 7aded32..80199f2 100644 (file)
@@ -32,6 +32,7 @@ enum isl_token_type { ISL_TOKEN_ERROR = -1,
                        ISL_TOKEN_TRUE, ISL_TOKEN_FALSE,
                        ISL_TOKEN_CEILD, ISL_TOKEN_FLOORD, ISL_TOKEN_MOD,
                        ISL_TOKEN_STRING,
+                       ISL_TOKEN_MAP, ISL_TOKEN_AFF,
                        ISL_TOKEN_LAST };
 
 struct isl_token {
@@ -45,6 +46,8 @@ struct isl_token {
        union {
                isl_int v;
                char    *s;
+               isl_map *map;
+               isl_pw_aff *pwaff;
        } u;
 };
 
index 86cb41e..3b79067 100644 (file)
@@ -12,6 +12,8 @@
 #include <strings.h>
 #include <isl/ctx.h>
 #include <isl_stream_private.h>
+#include <isl/map.h>
+#include <isl/aff.h>
 
 struct isl_keyword {
        char                    *name;
@@ -84,6 +86,10 @@ void isl_token_free(struct isl_token *tok)
                return;
        if (tok->type == ISL_TOKEN_VALUE)
                isl_int_clear(tok->u.v);
+       else if (tok->type == ISL_TOKEN_MAP)
+               isl_map_free(tok->u.map);
+       else if (tok->type == ISL_TOKEN_AFF)
+               isl_pw_aff_free(tok->u.pwaff);
        else
                free(tok->u.s);
        free(tok);
@@ -105,6 +111,20 @@ void isl_stream_error(struct isl_stream *s, struct isl_token *tok, char *msg)
                        fprintf(stderr, "got value '");
                        isl_int_print(stderr, tok->u.v, 0);
                        fprintf(stderr, "'\n");
+               } else if (tok->type == ISL_TOKEN_MAP) {
+                       isl_printer *p;
+                       fprintf(stderr, "got map '");
+                       p = isl_printer_to_file(s->ctx, stderr);
+                       p = isl_printer_print_map(p, tok->u.map);
+                       isl_printer_free(p);
+                       fprintf(stderr, "'\n");
+               } else if (tok->type == ISL_TOKEN_AFF) {
+                       isl_printer *p;
+                       fprintf(stderr, "got affine expression '");
+                       p = isl_printer_to_file(s->ctx, stderr);
+                       p = isl_printer_print_pw_aff(p, tok->u.pwaff);
+                       isl_printer_free(p);
+                       fprintf(stderr, "'\n");
                } else if (tok->u.s)
                        fprintf(stderr, "got token '%s'\n", tok->u.s);
                else