summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2013-06-02 17:56:04 +0200
committerSven Verdoolaege <skimo@kotnet.org>2013-06-02 17:56:04 +0200
commitf754c9901913c3cabe7a8ace6ea0c8880418781a (patch)
treee0b4233748da339ede61abb3c7defd03d1b5827e
parent7a361e6e472e452b3fb6794c96f6ab983fc716cc (diff)
downloadisl-f754c9901913c3cabe7a8ace6ea0c8880418781a.tar.gz
isl-f754c9901913c3cabe7a8ace6ea0c8880418781a.tar.bz2
isl-f754c9901913c3cabe7a8ace6ea0c8880418781a.zip
isl_input.c: extract out common is_start_of_div
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
-rw-r--r--isl_input.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/isl_input.c b/isl_input.c
index 164a269f..ba10ce89 100644
--- a/isl_input.c
+++ b/isl_input.c
@@ -342,6 +342,21 @@ error:
return NULL;
}
+/* Is "tok" the start of an integer division?
+ */
+static int is_start_of_div(struct isl_token *tok)
+{
+ if (!tok)
+ return 0;
+ if (tok->type == '[')
+ return 1;
+ if (tok->type == ISL_TOKEN_FLOORD)
+ return 1;
+ if (tok->type == ISL_TOKEN_CEILD)
+ return 1;
+ return 0;
+}
+
static __isl_give isl_pw_aff *accept_div(struct isl_stream *s,
__isl_take isl_space *dim, struct vars *v)
{
@@ -456,9 +471,7 @@ static __isl_give isl_pw_aff *accept_affine_factor(struct isl_stream *s,
goto error;
if (isl_stream_eat(s, ')'))
goto error;
- } else if (tok->type == '[' ||
- tok->type == ISL_TOKEN_FLOORD ||
- tok->type == ISL_TOKEN_CEILD) {
+ } else if (is_start_of_div(tok)) {
isl_stream_push_token(s, tok);
tok = NULL;
res = accept_div(s, isl_space_copy(dim), v);
@@ -544,10 +557,8 @@ static __isl_give isl_pw_aff *accept_affine(struct isl_stream *s,
isl_token_free(tok);
continue;
}
- if (tok->type == '(' || tok->type == '[' ||
+ if (tok->type == '(' || is_start_of_div(tok) ||
tok->type == ISL_TOKEN_MIN || tok->type == ISL_TOKEN_MAX ||
- tok->type == ISL_TOKEN_FLOORD ||
- tok->type == ISL_TOKEN_CEILD ||
tok->type == ISL_TOKEN_IDENT ||
tok->type == ISL_TOKEN_AFF) {
isl_pw_aff *term;
@@ -1822,7 +1833,7 @@ static __isl_give isl_pw_qpolynomial *read_factor(struct isl_stream *s,
pow = optional_power(s);
qp = isl_qpolynomial_var_pow_on_domain(isl_map_get_space(map), pos, pow);
pwqp = isl_pw_qpolynomial_from_qpolynomial(qp);
- } else if (tok->type == '[') {
+ } else if (is_start_of_div(tok)) {
isl_pw_aff *pwaff;
int pow;