From: Sven Verdoolaege Date: Fri, 28 Jun 2013 10:24:49 +0000 (+0200) Subject: add isl_ast_build_{access,call}_from_multi_pw_aff X-Git-Tag: isl-0.13~148 X-Git-Url: https://repo.or.cz/w/isl.git/commitdiff_plain/23736388eabae4931e74a0d668f42f09854258aa add isl_ast_build_{access,call}_from_multi_pw_aff Signed-off-by: Sven Verdoolaege --- diff --git a/doc/user.pod b/doc/user.pod index 390bc47b..2d65a173 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -6119,13 +6119,21 @@ the context of an C. __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma); __isl_give isl_ast_expr * + isl_ast_build_access_from_multi_pw_aff( + __isl_keep isl_ast_build *build, + __isl_take isl_multi_pw_aff *mpa); + __isl_give isl_ast_expr * isl_ast_build_call_from_pw_multi_aff( __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma); + __isl_give isl_ast_expr * + isl_ast_build_call_from_multi_pw_aff( + __isl_keep isl_ast_build *build, + __isl_take isl_multi_pw_aff *mpa); -The domains of C and C should correspond +The domains of C, C and C should correspond to the schedule space of C. -The tuple id of C is used as the array being accessed or +The tuple id of C or C is used as the array being accessed or the function being called. User specified data can be attached to an C and obtained diff --git a/include/isl/ast_build.h b/include/isl/ast_build.h index aa000dc6..3dd8e294 100644 --- a/include/isl/ast_build.h +++ b/include/isl/ast_build.h @@ -82,8 +82,12 @@ __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff( __isl_keep isl_ast_build *build, __isl_take isl_pw_aff *pa); __isl_give isl_ast_expr *isl_ast_build_access_from_pw_multi_aff( __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma); +__isl_give isl_ast_expr *isl_ast_build_access_from_multi_pw_aff( + __isl_keep isl_ast_build *build, __isl_take isl_multi_pw_aff *mpa); __isl_give isl_ast_expr *isl_ast_build_call_from_pw_multi_aff( __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma); +__isl_give isl_ast_expr *isl_ast_build_call_from_multi_pw_aff( + __isl_keep isl_ast_build *build, __isl_take isl_multi_pw_aff *mpa); __isl_give isl_ast_node *isl_ast_build_ast_from_schedule( __isl_keep isl_ast_build *build, __isl_take isl_union_map *schedule); diff --git a/isl_ast_build_expr.c b/isl_ast_build_expr.c index f89a67dd..851e8850 100644 --- a/isl_ast_build_expr.c +++ b/isl_ast_build_expr.c @@ -962,53 +962,53 @@ __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff( return expr; } -/* Set the ids of the input dimensions of "pma" to the iterator ids +/* Set the ids of the input dimensions of "mpa" to the iterator ids * of "build". * - * The domain of "pma" is assumed to live in the internal schedule domain. + * The domain of "mpa" is assumed to live in the internal schedule domain. */ -static __isl_give isl_pw_multi_aff *set_iterator_names( - __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma) +static __isl_give isl_multi_pw_aff *set_iterator_names( + __isl_keep isl_ast_build *build, __isl_take isl_multi_pw_aff *mpa) { int i, n; - n = isl_pw_multi_aff_dim(pma, isl_dim_in); + n = isl_multi_pw_aff_dim(mpa, isl_dim_in); for (i = 0; i < n; ++i) { isl_id *id; id = isl_ast_build_get_iterator_id(build, i); - pma = isl_pw_multi_aff_set_dim_id(pma, isl_dim_in, i, id); + mpa = isl_multi_pw_aff_set_dim_id(mpa, isl_dim_in, i, id); } - return pma; + return mpa; } /* Construct an isl_ast_expr of type "type" that calls or accesses - * the element specified by "pma". + * the element specified by "mpa". * The first argument is obtained from the output tuple name. * The remaining arguments are given by the piecewise affine expressions. * - * The domain of "pma" is assumed to live in the internal schedule domain. + * The domain of "mpa" is assumed to live in the internal schedule domain. */ -static __isl_give isl_ast_expr *isl_ast_build_from_pw_multi_aff_internal( +static __isl_give isl_ast_expr *isl_ast_build_from_multi_pw_aff_internal( __isl_keep isl_ast_build *build, enum isl_ast_op_type type, - __isl_take isl_pw_multi_aff *pma) + __isl_take isl_multi_pw_aff *mpa) { int i, n; isl_ctx *ctx; isl_id *id; isl_ast_expr *expr; - pma = set_iterator_names(build, pma); - if (!build || !pma) - return isl_pw_multi_aff_free(pma); + mpa = set_iterator_names(build, mpa); + if (!build || !mpa) + return isl_multi_pw_aff_free(mpa); ctx = isl_ast_build_get_ctx(build); - n = isl_pw_multi_aff_dim(pma, isl_dim_out); + n = isl_multi_pw_aff_dim(mpa, isl_dim_out); expr = isl_ast_expr_alloc_op(ctx, type, 1 + n); - if (isl_pw_multi_aff_has_tuple_id(pma, isl_dim_out)) - id = isl_pw_multi_aff_get_tuple_id(pma, isl_dim_out); + if (isl_multi_pw_aff_has_tuple_id(mpa, isl_dim_out)) + id = isl_multi_pw_aff_get_tuple_id(mpa, isl_dim_out); else id = isl_id_alloc(ctx, "", NULL); @@ -1017,12 +1017,12 @@ static __isl_give isl_ast_expr *isl_ast_build_from_pw_multi_aff_internal( isl_pw_aff *pa; isl_ast_expr *arg; - pa = isl_pw_multi_aff_get_pw_aff(pma, i); + pa = isl_multi_pw_aff_get_pw_aff(mpa, i); arg = isl_ast_build_expr_from_pw_aff_internal(build, pa); expr = isl_ast_expr_set_op_arg(expr, 1 + i, arg); } - isl_pw_multi_aff_free(pma); + isl_multi_pw_aff_free(mpa); return expr; } @@ -1031,39 +1031,97 @@ static __isl_give isl_ast_expr *isl_ast_build_from_pw_multi_aff_internal( * The first argument is obtained from the output tuple name. * The remaining arguments are given by the piecewise affine expressions. * - * The domain of "pma" is assumed to live in the external schedule domain. + * The domain of "pma" is assumed to live in the internal schedule domain. */ -static __isl_give isl_ast_expr *isl_ast_build_from_pw_multi_aff( +static __isl_give isl_ast_expr *isl_ast_build_from_pw_multi_aff_internal( __isl_keep isl_ast_build *build, enum isl_ast_op_type type, __isl_take isl_pw_multi_aff *pma) { + isl_multi_pw_aff *mpa; + + mpa = isl_multi_pw_aff_from_pw_multi_aff(pma); + return isl_ast_build_from_multi_pw_aff_internal(build, type, mpa); +} + +/* Construct an isl_ast_expr of type "type" that calls or accesses + * the element specified by "mpa". + * The first argument is obtained from the output tuple name. + * The remaining arguments are given by the piecewise affine expressions. + * + * The domain of "mpa" is assumed to live in the external schedule domain. + */ +static __isl_give isl_ast_expr *isl_ast_build_from_multi_pw_aff( + __isl_keep isl_ast_build *build, enum isl_ast_op_type type, + __isl_take isl_multi_pw_aff *mpa) +{ int is_domain; isl_ast_expr *expr; - isl_space *space_build, *space_pma; + isl_space *space_build, *space_mpa; space_build = isl_ast_build_get_space(build, 0); - space_pma = isl_pw_multi_aff_get_space(pma); + space_mpa = isl_multi_pw_aff_get_space(mpa); is_domain = isl_space_tuple_match(space_build, isl_dim_set, - space_pma, isl_dim_in); + space_mpa, isl_dim_in); isl_space_free(space_build); - isl_space_free(space_pma); + isl_space_free(space_mpa); if (is_domain < 0) - return isl_pw_multi_aff_free(pma); + return isl_multi_pw_aff_free(mpa); if (!is_domain) isl_die(isl_ast_build_get_ctx(build), isl_error_invalid, "spaces don't match", - return isl_pw_multi_aff_free(pma)); + return isl_multi_pw_aff_free(mpa)); if (isl_ast_build_need_schedule_map(build)) { isl_multi_aff *ma; ma = isl_ast_build_get_schedule_map_multi_aff(build); - pma = isl_pw_multi_aff_pullback_multi_aff(pma, ma); + mpa = isl_multi_pw_aff_pullback_multi_aff(mpa, ma); } - expr = isl_ast_build_from_pw_multi_aff_internal(build, type, pma); + expr = isl_ast_build_from_multi_pw_aff_internal(build, type, mpa); return expr; } +/* Construct an isl_ast_expr that calls the domain element specified by "mpa". + * The name of the function is obtained from the output tuple name. + * The arguments are given by the piecewise affine expressions. + * + * The domain of "mpa" is assumed to live in the external schedule domain. + */ +__isl_give isl_ast_expr *isl_ast_build_call_from_multi_pw_aff( + __isl_keep isl_ast_build *build, __isl_take isl_multi_pw_aff *mpa) +{ + return isl_ast_build_from_multi_pw_aff(build, isl_ast_op_call, mpa); +} + +/* Construct an isl_ast_expr that accesses the array element specified by "mpa". + * The name of the array is obtained from the output tuple name. + * The index expressions are given by the piecewise affine expressions. + * + * The domain of "mpa" is assumed to live in the external schedule domain. + */ +__isl_give isl_ast_expr *isl_ast_build_access_from_multi_pw_aff( + __isl_keep isl_ast_build *build, __isl_take isl_multi_pw_aff *mpa) +{ + return isl_ast_build_from_multi_pw_aff(build, isl_ast_op_access, mpa); +} + +/* Construct an isl_ast_expr of type "type" that calls or accesses + * the element specified by "pma". + * The first argument is obtained from the output tuple name. + * The remaining arguments are given by the piecewise affine expressions. + * + * The domain of "pma" is assumed to live in the external schedule domain. + */ +static __isl_give isl_ast_expr *isl_ast_build_from_pw_multi_aff( + __isl_keep isl_ast_build *build, enum isl_ast_op_type type, + __isl_take isl_pw_multi_aff *pma) +{ + isl_multi_pw_aff *mpa; + + mpa = isl_multi_pw_aff_from_pw_multi_aff(pma); + return isl_ast_build_from_multi_pw_aff(build, type, mpa); +} + /* Construct an isl_ast_expr that calls the domain element specified by "pma". * The name of the function is obtained from the output tuple name. * The arguments are given by the piecewise affine expressions.