From: Sven Verdoolaege Date: Fri, 5 Oct 2012 12:15:20 +0000 (+0200) Subject: isl_ast_build_ast_from_schedule: make construction of else branches optional X-Git-Tag: isl-0.11~89 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b0241c844a0607b498556564d084d90ed0f4058;p=platform%2Fupstream%2Fisl.git isl_ast_build_ast_from_schedule: make construction of else branches optional Signed-off-by: Sven Verdoolaege --- diff --git a/doc/user.pod b/doc/user.pod index a58c94d..aff35a3 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -5629,6 +5629,9 @@ while printing the AST. isl_ctx *ctx, int val); int isl_options_get_ast_build_scale_strides( isl_ctx *ctx); + int isl_options_set_ast_build_allow_else(isl_ctx *ctx, + int val); + int isl_options_get_ast_build_allow_else(isl_ctx *ctx); =over @@ -5722,6 +5725,11 @@ be used during separation. This option specifies whether the AST generator is allowed to scale down iterators of strided loops. +=item * ast_build_allow_else + +This option specifies whether the AST generator is allowed +to construct if statements with else branches. + =back =head3 Fine-grained Control over AST Generation diff --git a/include/isl/ast_build.h b/include/isl/ast_build.h index 4bae4d1..daf78dc 100644 --- a/include/isl/ast_build.h +++ b/include/isl/ast_build.h @@ -33,6 +33,8 @@ int isl_options_get_ast_build_separation_bounds(isl_ctx *ctx); int isl_options_set_ast_build_scale_strides(isl_ctx *ctx, int val); int isl_options_get_ast_build_scale_strides(isl_ctx *ctx); +int isl_options_set_ast_build_allow_else(isl_ctx *ctx, int val); +int isl_options_get_ast_build_allow_else(isl_ctx *ctx); isl_ctx *isl_ast_build_get_ctx(__isl_keep isl_ast_build *build); diff --git a/isl_ast_graft.c b/isl_ast_graft.c index 11355bd..627393b 100644 --- a/isl_ast_graft.c +++ b/isl_ast_graft.c @@ -430,12 +430,15 @@ static int clear_if_nodes(struct isl_if_node *if_node, int first, int n) * The guard of the node is then simplified based on the conditions * enforced at that then or else branch. * Otherwise, the current graft is appended to the list. + * + * We only construct else branches if allowed by the user. */ static __isl_give isl_ast_graft_list *insert_pending_guard_nodes( __isl_take isl_ast_graft_list *list, __isl_keep isl_ast_build *build) { int i, j, n, n_if; + int allow_else; isl_ctx *ctx; isl_ast_graft_list *res; struct isl_if_node *if_node = NULL; @@ -446,6 +449,8 @@ static __isl_give isl_ast_graft_list *insert_pending_guard_nodes( ctx = isl_ast_build_get_ctx(build); n = isl_ast_graft_list_n_ast_graft(list); + allow_else = isl_options_get_ast_build_allow_else(ctx); + n_if = 0; if (n > 0) { if_node = isl_alloc_array(ctx, struct isl_if_node, n - 1); @@ -478,6 +483,8 @@ static __isl_give isl_ast_graft_list *insert_pending_guard_nodes( found_then = j; break; } + if (!allow_else) + continue; subset = isl_set_is_subset(test, if_node[j].complement); if (subset < 0 || subset) { diff --git a/isl_options.c b/isl_options.c index 159a782..a5c6f66 100644 --- a/isl_options.c +++ b/isl_options.c @@ -196,6 +196,8 @@ ISL_ARG_CHOICE(struct isl_options, ast_build_separation_bounds, 0, ISL_ARG_BOOL(struct isl_options, ast_build_scale_strides, 0, "ast-build-scale-strides", 1, "allow iterators of strided loops to be scaled down") +ISL_ARG_BOOL(struct isl_options, ast_build_allow_else, 0, + "ast-build-allow-else", 1, "generate if statements with else branches") ISL_ARG_VERSION(print_version) ISL_ARGS_END @@ -300,3 +302,8 @@ ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args, ast_build_scale_strides) ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args, ast_build_scale_strides) + +ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args, + ast_build_allow_else) +ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args, + ast_build_allow_else) diff --git a/isl_options_private.h b/isl_options_private.h index 0b1139a..b7cacb1 100644 --- a/isl_options_private.h +++ b/isl_options_private.h @@ -67,6 +67,7 @@ struct isl_options { int ast_build_group_coscheduled; int ast_build_separation_bounds; int ast_build_scale_strides; + int ast_build_allow_else; }; #endif