From cf2fbed26a8d3f772c01bf86a7e284155da4ed79 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 13 Feb 2014 17:00:07 +0100 Subject: [PATCH] extract out pet_expr_access_get_parameter_space Signed-off-by: Sven Verdoolaege --- expr.c | 17 +++++++++++++++++ expr.h | 2 ++ scan.cc | 17 ++++++++++------- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/expr.c b/expr.c index 2cac026..dabfc8f 100644 --- a/expr.c +++ b/expr.c @@ -589,6 +589,23 @@ __isl_give isl_id *pet_expr_access_get_id(struct pet_expr *expr) return isl_map_get_tuple_id(expr->acc.access, isl_dim_out); } +/* Return the parameter space of "expr". + */ +__isl_give isl_space *pet_expr_access_get_parameter_space(struct pet_expr *expr) +{ + isl_space *space; + + if (!expr) + return NULL; + if (expr->type != pet_expr_access) + return NULL; + + space = isl_multi_pw_aff_get_space(expr->acc.index); + space = isl_space_params(space); + + return space; +} + /* Return the space of the data accessed by "expr". */ __isl_give isl_space *pet_expr_access_get_data_space(struct pet_expr *expr) diff --git a/expr.h b/expr.h index 9b13e9e..6ff4d76 100644 --- a/expr.h +++ b/expr.h @@ -37,6 +37,8 @@ int pet_expr_is_scalar_access(struct pet_expr *expr); int pet_expr_is_equal(struct pet_expr *expr1, struct pet_expr *expr2); __isl_give isl_id *pet_expr_access_get_id(struct pet_expr *expr); +__isl_give isl_space *pet_expr_access_get_parameter_space( + struct pet_expr *expr); __isl_give isl_space *pet_expr_access_get_data_space(struct pet_expr *expr); int pet_expr_foreach_access_expr(struct pet_expr *expr, diff --git a/scan.cc b/scan.cc index 3af9fbc..12ba52e 100644 --- a/scan.cc +++ b/scan.cc @@ -3438,7 +3438,7 @@ struct pet_expr *PetScan::extract_nested(struct pet_expr *expr, int n, if (!expr->args) goto error; - space = isl_map_get_space(expr->acc.access); + space = pet_expr_access_get_parameter_space(expr); n = extract_nested(space, 0, expr->args, param2pos); isl_space_free(space); @@ -3497,7 +3497,9 @@ struct pet_expr *PetScan::resolve_nested(struct pet_expr *expr) if (expr->type != pet_expr_access) return expr; - n = n_nested_parameter(expr->acc.access); + space = pet_expr_access_get_parameter_space(expr); + n = n_nested_parameter(space); + isl_space_free(space); if (n == 0) return expr; @@ -3508,12 +3510,12 @@ struct pet_expr *PetScan::resolve_nested(struct pet_expr *expr) expr = pet_expr_access_align_params(expr); if (!expr) return NULL; - nparam = isl_map_dim(expr->acc.access, isl_dim_param); n = 0; + space = pet_expr_access_get_parameter_space(expr); + nparam = isl_space_dim(space, isl_dim_param); for (int i = nparam - 1; i >= 0; --i) { - isl_id *id = isl_map_get_dim_id(expr->acc.access, - isl_dim_param, i); + isl_id *id = isl_space_get_dim_id(space, isl_dim_param, i); if (!is_nested_parameter(id)) { isl_id_free(id); continue; @@ -3528,9 +3530,10 @@ struct pet_expr *PetScan::resolve_nested(struct pet_expr *expr) isl_id_free(id); } + isl_space_free(space); - space = isl_multi_pw_aff_get_space(expr->acc.index); - space = isl_space_set_from_params(isl_space_params(space)); + space = pet_expr_access_get_parameter_space(expr); + space = isl_space_set_from_params(space); space = isl_space_add_dims(space, isl_dim_set, expr->n_arg); space = isl_space_wrap(isl_space_from_range(space)); ls = isl_local_space_from_space(isl_space_copy(space)); -- 2.11.4.GIT