From: Sven Verdoolaege Date: Thu, 6 Jun 2013 10:04:16 +0000 (+0200) Subject: add isl_ast_build_access_from_pw_multi_aff X-Git-Tag: isl-0.13~149 X-Git-Url: https://repo.or.cz/w/isl.git/commitdiff_plain/f7b2d504141ea06422e26ea79b7514bf00e21bd1 add isl_ast_build_access_from_pw_multi_aff Signed-off-by: Sven Verdoolaege --- diff --git a/doc/user.pod b/doc/user.pod index 6b251510..390bc47b 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -6036,6 +6036,13 @@ The number of arguments of the C is one more than the number of arguments in the function call, the first argument representing the function being called. +=item C + +An array access. +The number of arguments of the C is one more than +the number of index expressions in the array access, the first argument +representing the array being accessed. + =back #include @@ -6108,13 +6115,18 @@ the context of an C. __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_call_from_pw_multi_aff( __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma); The domains of C and C should correspond to the schedule space of C. -The tuple id of C is used as the function being called. +The tuple id of C is used as the array being accessed or +the function being called. User specified data can be attached to an C and obtained from the same C using the following functions. diff --git a/include/isl/ast.h b/include/isl/ast.h index 76f1d38e..3eadef76 100644 --- a/include/isl/ast.h +++ b/include/isl/ast.h @@ -40,7 +40,8 @@ enum isl_ast_op_type { isl_ast_op_lt, isl_ast_op_ge, isl_ast_op_gt, - isl_ast_op_call + isl_ast_op_call, + isl_ast_op_access }; enum isl_ast_expr_type { diff --git a/include/isl/ast_build.h b/include/isl/ast_build.h index 79b4e241..aa000dc6 100644 --- a/include/isl/ast_build.h +++ b/include/isl/ast_build.h @@ -80,6 +80,8 @@ __isl_give isl_ast_build *isl_ast_build_set_create_leaf( __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_call_from_pw_multi_aff( __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma); diff --git a/isl_ast.c b/isl_ast.c index b52041f5..06565c31 100644 --- a/isl_ast.c +++ b/isl_ast.c @@ -1074,7 +1074,8 @@ static int op_prec[] = { [isl_ast_op_ge] = 8, [isl_ast_op_lt] = 8, [isl_ast_op_gt] = 8, - [isl_ast_op_call] = 2 + [isl_ast_op_call] = 2, + [isl_ast_op_access] = 2 }; /* Is the operator left-to-right associative? @@ -1101,7 +1102,8 @@ static int op_left[] = { [isl_ast_op_ge] = 1, [isl_ast_op_lt] = 1, [isl_ast_op_gt] = 1, - [isl_ast_op_call] = 1 + [isl_ast_op_call] = 1, + [isl_ast_op_access] = 1 }; static int is_and(enum isl_ast_op_type op) @@ -1224,6 +1226,25 @@ static __isl_give isl_printer *print_call(__isl_take isl_printer *p, return p; } +/* Print an array access "expr". + * + * The first argument represents the array being accessed. + */ +static __isl_give isl_printer *print_access(__isl_take isl_printer *p, + __isl_keep isl_ast_expr *expr) +{ + int i = 0; + + p = isl_printer_print_ast_expr(p, expr->u.op.args[0]); + for (i = 1; i < expr->u.op.n_arg; ++i) { + p = isl_printer_print_str(p, "["); + p = isl_printer_print_ast_expr(p, expr->u.op.args[i]); + p = isl_printer_print_str(p, "]"); + } + + return p; +} + /* Print "expr" to "p". * * If we are printing in isl format, then we also print an indication @@ -1243,6 +1264,10 @@ __isl_give isl_printer *isl_printer_print_ast_expr(__isl_take isl_printer *p, p = print_call(p, expr); break; } + if (expr->u.op.op == isl_ast_op_access) { + p = print_access(p, expr); + break; + } if (expr->u.op.n_arg == 1) { p = isl_printer_print_str(p, op_str[expr->u.op.op]); p = print_sub_expr(p, expr->u.op.op, diff --git a/isl_ast_build_expr.c b/isl_ast_build_expr.c index d794d52a..f89a67dd 100644 --- a/isl_ast_build_expr.c +++ b/isl_ast_build_expr.c @@ -983,14 +983,16 @@ static __isl_give isl_pw_multi_aff *set_iterator_names( return pma; } -/* 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. +/* 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 internal schedule domain. */ -static __isl_give isl_ast_expr *isl_ast_build_call_from_pw_multi_aff_internal( - __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma) +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) { int i, n; isl_ctx *ctx; @@ -1003,7 +1005,7 @@ static __isl_give isl_ast_expr *isl_ast_build_call_from_pw_multi_aff_internal( ctx = isl_ast_build_get_ctx(build); n = isl_pw_multi_aff_dim(pma, isl_dim_out); - expr = isl_ast_expr_alloc_op(ctx, isl_ast_op_call, 1 + n); + 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); @@ -1024,14 +1026,16 @@ static __isl_give isl_ast_expr *isl_ast_build_call_from_pw_multi_aff_internal( return expr; } -/* 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. +/* 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. */ -__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) +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) { int is_domain; isl_ast_expr *expr; @@ -1056,10 +1060,34 @@ __isl_give isl_ast_expr *isl_ast_build_call_from_pw_multi_aff( pma = isl_pw_multi_aff_pullback_multi_aff(pma, ma); } - expr = isl_ast_build_call_from_pw_multi_aff_internal(build, pma); + expr = isl_ast_build_from_pw_multi_aff_internal(build, type, pma); return expr; } +/* 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. + * + * The domain of "pma" is assumed to live in the external schedule domain. + */ +__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) +{ + return isl_ast_build_from_pw_multi_aff(build, isl_ast_op_call, pma); +} + +/* Construct an isl_ast_expr that accesses the array element specified by "pma". + * 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 "pma" is assumed to live in the external schedule domain. + */ +__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) +{ + return isl_ast_build_from_pw_multi_aff(build, isl_ast_op_access, pma); +} + /* Construct an isl_ast_expr that calls the domain element * specified by "executed". * @@ -1076,6 +1104,7 @@ __isl_give isl_ast_node *isl_ast_build_call_from_executed( iteration = isl_ast_build_compute_gist_pw_multi_aff(build, iteration); iteration = isl_pw_multi_aff_intersect_domain(iteration, isl_ast_build_get_domain(build)); - expr = isl_ast_build_call_from_pw_multi_aff_internal(build, iteration); + expr = isl_ast_build_from_pw_multi_aff_internal(build, isl_ast_op_call, + iteration); return isl_ast_node_alloc_user(expr); }