isl_ast_build_ast_from_schedule: make construction of else branches optional
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 5 Oct 2012 12:15:20 +0000 (14:15 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 5 Oct 2012 13:03:10 +0000 (15:03 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/ast_build.h
isl_ast_graft.c
isl_options.c
isl_options_private.h

index a58c94d..aff35a3 100644 (file)
@@ -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
index 4bae4d1..daf78dc 100644 (file)
@@ -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);
 
index 11355bd..627393b 100644 (file)
@@ -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) {
index 159a782..a5c6f66 100644 (file)
@@ -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)
index 0b1139a..b7cacb1 100644 (file)
@@ -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