From 230c927e6e9c6af47b3aa6e2af96941cca9f7a5c Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 15 Mar 2010 14:22:22 +0100 Subject: [PATCH] iscc: add inverse operation --- doc/isl.tex | 2 ++ iscc.c | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/doc/isl.tex b/doc/isl.tex index 1b38e6a..ca117ef 100644 --- a/doc/isl.tex +++ b/doc/isl.tex @@ -171,6 +171,8 @@ of the set $s$ and return a piecewise quasipolynomial mapping each of the individual elements to the resulting constant \\ +$m_2$ := $m_1$\ai[\tt]{\^{}-1} & inverse of $m_1$ +\\ $l$ := $m$\ai[\tt]{\^{}+} & compute an overapproximation of the transitive closure of $m$ and return a list containing the overapproximation diff --git a/iscc.c b/iscc.c index eb0cad8..61a3f56 100644 --- a/iscc.c +++ b/iscc.c @@ -501,6 +501,35 @@ error: return obj; } +static struct isl_obj power(struct isl_stream *s, struct isl_obj obj) +{ + struct isl_token *tok; + + if (isl_stream_eat_if_available(s, '+')) + return transitive_closure(s->ctx, obj); + + tok = isl_stream_next_token(s); + if (!tok || tok->type != ISL_TOKEN_VALUE || isl_int_cmp_si(tok->u.v, -1)) { + isl_stream_error(s, tok, "expecting -1"); + if (tok) + isl_stream_push_token(s, tok); + goto error; + } + isl_token_free(tok); + isl_assert(s->ctx, obj.type == isl_obj_map, goto error); + + obj.v = isl_map_reverse(obj.v); + if (!obj.v) + goto error; + + return obj; +error: + free_obj(obj); + obj.type = isl_obj_none; + obj.v = NULL; + return obj; +} + static struct isl_obj read_obj(struct isl_stream *s, struct isl_hash_table *table) { @@ -526,11 +555,9 @@ static struct isl_obj read_obj(struct isl_stream *s, } } - if (isl_stream_eat_if_available(s, '^')) { - if (isl_stream_eat(s, '+')) - goto error; - obj = transitive_closure(s->ctx, obj); - } else if (obj.type == isl_obj_list && isl_stream_eat_if_available(s, '[')) + if (isl_stream_eat_if_available(s, '^')) + obj = power(s, obj); + else if (obj.type == isl_obj_list && isl_stream_eat_if_available(s, '[')) obj = obj_at_index(s, obj); return obj; -- 2.11.4.GIT