From 88d60cfe146531ab81feeb09ba81d45d7370e385 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 7 Oct 2013 14:54:55 +0200 Subject: [PATCH] add isl_ast_expr_call Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/ast.h | 2 ++ isl_ast.c | 59 ++++++++++++++++++++++++++++++++++++------------------- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/doc/user.pod b/doc/user.pod index 568cd1d3..28cd255e 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -8661,6 +8661,9 @@ the context of an C. __isl_give isl_ast_expr *isl_ast_expr_access( __isl_take isl_ast_expr *array, __isl_take isl_ast_expr_list *indices); + __isl_give isl_ast_expr *isl_ast_expr_call( + __isl_take isl_ast_expr *function, + __isl_take isl_ast_expr_list *arguments); The function C can be applied to an C of type C only. It is meant diff --git a/include/isl/ast.h b/include/isl/ast.h index 735739c5..24210d7b 100644 --- a/include/isl/ast.h +++ b/include/isl/ast.h @@ -54,6 +54,8 @@ __isl_give isl_ast_expr *isl_ast_expr_eq(__isl_take isl_ast_expr *expr1, __isl_take isl_ast_expr *expr2); __isl_give isl_ast_expr *isl_ast_expr_access(__isl_take isl_ast_expr *array, __isl_take isl_ast_expr_list *indices); +__isl_give isl_ast_expr *isl_ast_expr_call(__isl_take isl_ast_expr *function, + __isl_take isl_ast_expr_list *arguments); __isl_give isl_ast_expr *isl_ast_expr_address_of(__isl_take isl_ast_expr *expr); __isl_give isl_ast_expr *isl_ast_expr_copy(__isl_keep isl_ast_expr *expr); diff --git a/isl_ast.c b/isl_ast.c index b9a7cea4..56ed3400 100644 --- a/isl_ast.c +++ b/isl_ast.c @@ -665,42 +665,61 @@ __isl_give isl_ast_expr *isl_ast_expr_eq(__isl_take isl_ast_expr *expr1, return isl_ast_expr_alloc_binary(isl_ast_op_eq, expr1, expr2); } -/* Create an expression representing an access to "array" with index - * expressions "indices". +/* Create an expression of type "type" with as arguments "arg0" followed + * by "arguments". */ -__isl_give isl_ast_expr *isl_ast_expr_access(__isl_take isl_ast_expr *array, - __isl_take isl_ast_expr_list *indices) +static __isl_give isl_ast_expr *ast_expr_with_arguments( + enum isl_ast_op_type type, __isl_take isl_ast_expr *arg0, + __isl_take isl_ast_expr_list *arguments) { int i, n; isl_ctx *ctx; - isl_ast_expr *access = NULL; + isl_ast_expr *res = NULL; - if (!array || !indices) + if (!arg0 || !arguments) goto error; - ctx = isl_ast_expr_get_ctx(array); - n = isl_ast_expr_list_n_ast_expr(indices); - access = isl_ast_expr_alloc_op(ctx, isl_ast_op_access, 1 + n); - if (!access) + ctx = isl_ast_expr_get_ctx(arg0); + n = isl_ast_expr_list_n_ast_expr(arguments); + res = isl_ast_expr_alloc_op(ctx, type, 1 + n); + if (!res) goto error; for (i = 0; i < n; ++i) { - isl_ast_expr *index; - index = isl_ast_expr_list_get_ast_expr(indices, i); - access->u.op.args[1 + i] = index; - if (!index) + isl_ast_expr *arg; + arg = isl_ast_expr_list_get_ast_expr(arguments, i); + res->u.op.args[1 + i] = arg; + if (!arg) goto error; } - access->u.op.args[0] = array; + res->u.op.args[0] = arg0; - isl_ast_expr_list_free(indices); - return access; + isl_ast_expr_list_free(arguments); + return res; error: - isl_ast_expr_free(array); - isl_ast_expr_list_free(indices); - isl_ast_expr_free(access); + isl_ast_expr_free(arg0); + isl_ast_expr_list_free(arguments); + isl_ast_expr_free(res); return NULL; } +/* Create an expression representing an access to "array" with index + * expressions "indices". + */ +__isl_give isl_ast_expr *isl_ast_expr_access(__isl_take isl_ast_expr *array, + __isl_take isl_ast_expr_list *indices) +{ + return ast_expr_with_arguments(isl_ast_op_access, array, indices); +} + +/* Create an expression representing a call to "function" with argument + * expressions "arguments". + */ +__isl_give isl_ast_expr *isl_ast_expr_call(__isl_take isl_ast_expr *function, + __isl_take isl_ast_expr_list *arguments) +{ + return ast_expr_with_arguments(isl_ast_op_call, function, arguments); +} + /* For each subexpression of "expr" of type isl_ast_expr_id, * if it appears in "id2expr", then replace it by the corresponding * expression. -- 2.11.4.GIT