aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@redhat.com>2006-01-19 16:55:52 +0000
committerDiego Novillo <dnovillo@gcc.gnu.org>2006-01-19 11:55:52 -0500
commit50674e968a56527fa78d2fa78651276e696b64fd (patch)
tree40a0696b5a88f85ca1ddd8a91201d544d829b1f2 /gcc/gimplify.c
parent307d19feb13bd6ba0886ef8bda1f17bf5ab5362c (diff)
downloadgcc-50674e968a56527fa78d2fa78651276e696b64fd.zip
gcc-50674e968a56527fa78d2fa78651276e696b64fd.tar.gz
gcc-50674e968a56527fa78d2fa78651276e696b64fd.tar.bz2
tree-pretty-print.c (dump_generic_node): Handle OMP_PARALLEL_FN, OMP_PARALLEL_DATA_ARG and OMP_RETURN_EXPR.
* tree-pretty-print.c (dump_generic_node): Handle OMP_PARALLEL_FN, OMP_PARALLEL_DATA_ARG and OMP_RETURN_EXPR. * cgraph.c (cgraph_expand_queue): Rename from cgraph_analyze_queue. Update all users. * cgraphunit.c (cgraph_assemble_pending_functions): Process cgraph_expand_queue. (cgraph_expand_all_functions): Likewise. (cgraph_finalize_pending_functions): Remove. Update callers. * tree.h (OMP_DIRECTIVE_P): Define. (OMP_PARALLEL_FN): Define. (OMP_PARALLEL_DATA_ARG): Define. (OMP_SECTIONS_SECTIONS): Define. * tree-pass.h (pass_expand_omp): Declare. * omp-low.c (struct omp_region): Declare. (struct omp_context): Remove fields 'parallel_type', 'parallel_start_ix' and 'parallel_start_additional_args'. Update all users. (struct omp_for_data): Rename from struct expand_omp_for_data. (omp_regions): New static variable. (root_omp_region): New static variable. (find_omp_clause): Make static. (is_in_combined_parallel_ctx): Remove. (is_combined_parallel): New. (extract_omp_for_data): Move earlier in the file. (workshare_safe_to_combine_p): New. (get_ws_args_for): New. (determine_parallel_type): Move earlier in the file. (omp_copy_decl_2): Do not set DECL_CONTEXT of new local to the child function. (omp_copy_decl): Likewise. (create_omp_child_function): Likewise. (lookup_omp_region): New. (dump_omp_region): New. (debug_omp_region): New. (debug_all_omp_regions): New. (new_omp_region): New. (scan_omp_parallel): If parallel_nesting_level > 1, the directive is nested within another parallel directive. Set OMP_PARALLEL_FN. (scan_omp_for): Do not try to handle combined parallel+for cases. Remove FIXME comment. (scan_omp_nested): Remove. (scan_omp_1): Do not call scan_omp_nested when parallel_nesting_level is > 1. Do not change the DECL_CONTEXT of local variables found. (lookup_decl_in_outer_ctx): New. (lower_rec_input_clauses): Rename from expand_rec_input_clauses. (lower_lastprivate_clauses): Rename from expand_lastprivate_clauses. (lower_reduction_clauses): Rename from expand_reduction_clauses. (lower_copyprivate_clauses): Rename from expand_copyprivate_clauses. If CTX is nested, lookup VAR in the outer context when building copy assignment. (lower_send_clauses): Rename from expand_send_clauses. If CTX is nested, lookup VAR in the outer context when building copy assignments. (lower_send_shared_vars): Rename from expand_send_shared_vars. If CTX is nested, lookup VAR in the outer context when building copy assignments. (expand_parallel_call): Rename from build_parallel_call. Handle combined parallel+workshare cases. Re-implement to emit code into the CFG. (list2chain): New. (expand_omp_parallel): Re-implement to emit code into the CFG. Call move_sese_region_to_fn to outline the sub-graph containing the parallel region. (expand_omp_for_1): Remove. (expand_omp_for_generic): Re-implement to emit code into the CFG. (expand_omp_for_static_nochunk): Likewise. (expand_omp_for_static_chunk): Likewise. (expand_omp_for): Likewise. (expand_omp_sections): Likewise. (remove_exit_barriers): New. (expand_omp_synch): New. (expand_omp): New. (build_omp_regions_1): New. (build_omp_regions): New. (execute_expand_omp): New. (gate_expand_omp): New. (pass_expand_omp): Define. (lower_omp_sections): Rename from expand_omp_sections. Set OMP_SECTIONS_SECTIONS. (lower_omp_single_simple): Rename from expand_omp_single_simple. (lower_omp_single_copy): Rename from expand_omp_single_copy. (lower_omp_single): Rename from expand_omp_simple. (lower_omp_master): Rename from expand_omp_master. (lower_omp_ordered): Rename from expand_omp_ordered. (lower_omp_critical): Rename from expand_omp_critical. (lower_omp_for_lastprivate): Rename from expand_omp_for_lastprivate. (lower_omp_for): Re-implement. (lower_omp_parallel): Re-implement. (lower_regimplify): Rename from expand_regimplify. (lower_omp_1): Rename from expand_omp_1. If there are syntax errors in the program, replace every OpenMP directive with NOP. Call lower_omp_* instead of expand_omp_*. (lower_omp): Rename from expand_omp. * tree-gimple.c (is_gimple_stmt): Handle OMP_RETURN_EXPR. * tree-gimple.h (enum omp_parallel_type): Remove. (gimple_boolify): Declare extern. (find_omp_clause, determine_parallel_type): Remove. * gimple-low.c (lower_omp_directive): New. (lower_stmt): Call it. (record_vars_into): Move from ... (record_vars): ... here. Call record_vars_into with current_function_decl. * gimplify.c (struct gimplify_ctx): Remove fields combined_pre_p and combined_ctxp. Update users. (get_formal_tmp_var): Add documentation. (gimple_boolify): Make extern. (gimplify_expr_in_ctx): Remove. Update callers. (gimplify_omp_parallel): Do not assume that OMP_PARALLEL_BODY will always be a BIND_EXPR. (gimplify_expr): Handle OMP_RETURN_EXPR. * tree.def (BLOCK): Remove documentation about BLOCK_TYPE_TAGS. (OMP_PARALLEL): Add 3 operands. (OMP_SECTIONS): Add 1 operand. (OMP_RETURN_EXPR): Define. * tree-inline.c (estimate_num_insns_1): Handle OpenMP directives. (copy_tree_r): Restore TREE_CHAIN in OMP_CLAUSE_*. * tree-iterator.c (alloc_stmt_list): Assert that we are not creating a circular free list. (free_stmt_list): Assert that we are not freeing stmt_list_cache. * tree-flow.h (move_sese_region_to_fn): Declare. (record_vars_into): Declare. * tree-cfg.c (make_omp_sections_edges): New. (make_exit_edges): Handle OMP_PARALLEL, OMP_FOR, OMP_SINGLE, OMP_MASTER, OMP_ORDERED, OMP_CRITICAL, OMP_RETURN_EXPR, OMP_SECTIONS and OMP_SECTION. (is_ctrl_altering_stmt): Return true for OMP_DIRECTIVE_P. (set_bb_for_stmt): Undo change to check currently_expanding_to_rtl. (verify_stmt): Do not handle OMP_DIRECTIVE_P. (gather_blocks_in_sese_region): New. (struct move_stmt_d): Declare. (move_stmt_r): New. (move_block_to_fn): New. (move_sese_region_to_fn): New. * passes.c (init_optimization_passes): Schedule pass_expand_omp after pass_init_datastructures. * tree-ssa-operands.c (get_expr_operands): Handle OMP_PARALLEL, OMP_SECTIONS, OMP_FOR, OMP_RETURN_EXPR, OMP_SINGLE, OMP_MASTER, OMP_ORDERED, OMP_CRITICAL. testsuite/ * testsuite/gcc.dg/gomp/for-13.c: Use -fdump-tree-ompexp. * testsuite/gcc.dg/gomp/critical-1.c: Likewise. * testsuite/gcc.dg/gomp/critical-3.c: Likewise. * testsuite/gcc.dg/gomp/empty.c: Likewise. * testsuite/gcc.dg/gomp/ordered-1.c: Likewise. * testsuite/gcc.dg/gomp/for-4.c: Likewise. * testsuite/gcc.dg/gomp/for-6.c: Likewise. * testsuite/gcc.dg/gomp/master-3.c: Likewise. * testsuite/gcc.dg/gomp/for-8.c: Likewise. * testsuite/gcc.dg/gomp/for-10.c: Likewise. * testsuite/gcc.dg/gomp/for-18.c: Likewise. * testsuite/gcc.dg/gomp/for-5.c: Likewise. * testsuite/gcc.dg/gomp/for-7.c: Likewise. * testsuite/gcc.dg/gomp/for-9.c: Likewise. From-SVN: r109969
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c113
1 files changed, 19 insertions, 94 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index acd0468..7d7b80f 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -92,16 +92,6 @@ struct gimplify_ctx
int conditions;
bool save_stack;
bool into_ssa;
-
- /* When gimplifying combined omp parallel directives (omp parallel
- loop and omp parallel sections), any prefix code needed to setup
- the associated worksharing construct needs to be emitted in the
- pre-queue of its parent parallel, otherwise the lowering process
- will move that code to the child function. Similarly, we need to
- move up to the gimplification context of the parent parallel
- directive so temporaries are declared in the right context. */
- tree *combined_pre_p;
- struct gimplify_ctx *combined_ctxp;
};
static struct gimplify_ctx *gimplify_ctxp;
@@ -634,6 +624,10 @@ internal_get_tmp_var (tree val, tree *pre_p, tree *post_p, bool is_formal)
return t;
}
+/* Returns a formal temporary variable initialized with VAL. PRE_P
+ points to a statement list where side-effects needed to compute VAL
+ should be stored. */
+
tree
get_formal_tmp_var (tree val, tree *pre_p)
{
@@ -2297,7 +2291,7 @@ shortcut_cond_expr (tree expr)
/* EXPR is used in a boolean context; make sure it has BOOLEAN_TYPE. */
-static tree
+tree
gimple_boolify (tree expr)
{
tree type = TREE_TYPE (expr);
@@ -4131,29 +4125,6 @@ gimplify_to_stmt_list (tree *stmt_p)
}
}
-/* Gimplify *EXPR_P as if it had been used inside the gimplification
- context CTX_P. The other arguments are as in gimplify_expr. */
-
-static enum gimplify_status
-gimplify_expr_in_ctx (tree *expr_p, tree *pre_p, tree *post_p,
- bool (* gimple_test_f) (tree), fallback_t fallback,
- struct gimplify_ctx *ctx_p,
- struct gimplify_omp_ctx *omp_ctx_p)
-{
- enum gimplify_status ret;
- struct gimplify_ctx *prev_ctxp;
- struct gimplify_omp_ctx *prev_omp_ctxp;
-
- prev_ctxp = gimplify_ctxp;
- gimplify_ctxp = ctx_p;
- prev_omp_ctxp = gimplify_omp_ctxp;
- gimplify_omp_ctxp = omp_ctx_p;
- ret = gimplify_expr (expr_p, pre_p, post_p, gimple_test_f, fallback);
- gimplify_ctxp = prev_ctxp;
- gimplify_omp_ctxp = prev_omp_ctxp;
-
- return ret;
-}
/* Add FIRSTPRIVATE entries for DECL in the OpenMP the surrounding parallels
to CTX. If entries already exist, force them to be some flavor of private.
@@ -4531,19 +4502,6 @@ gimplify_scan_omp_clauses (tree *list_p, tree *pre_p, bool in_parallel)
break;
case OMP_CLAUSE_SCHEDULE:
- if (gimplify_ctxp->combined_pre_p)
- {
- gcc_assert (gimplify_omp_ctxp == outer_ctx);
- gs = gimplify_expr_in_ctx (&OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c),
- gimplify_ctxp->combined_pre_p, NULL,
- is_gimple_val, fb_rvalue,
- gimplify_ctxp->combined_ctxp,
- outer_ctx->outer_context);
- if (gs == GS_ERROR)
- remove = true;
- break;
- }
- /* FALLTHRU */
case OMP_CLAUSE_IF:
case OMP_CLAUSE_NUM_THREADS:
gs = gimplify_expr (&TREE_OPERAND (c, 0), pre_p, NULL,
@@ -4708,17 +4666,12 @@ gimplify_omp_parallel (tree *expr_p, tree *pre_p)
push_gimplify_context ();
- if (determine_parallel_type (expr) == IS_COMBINED_PARALLEL)
- {
- gimplify_ctxp->combined_pre_p = pre_p;
- gimplify_ctxp->combined_ctxp = gimplify_ctxp->prev_context;
- }
-
gimplify_stmt (&OMP_PARALLEL_BODY (expr));
- pop_gimplify_context (OMP_PARALLEL_BODY (expr));
- gimplify_ctxp->combined_pre_p = NULL;
- gimplify_ctxp->combined_ctxp = NULL;
+ if (TREE_CODE (OMP_PARALLEL_BODY (expr)) == BIND_EXPR)
+ pop_gimplify_context (OMP_PARALLEL_BODY (expr));
+ else
+ pop_gimplify_context (NULL_TREE);
gimplify_adjust_omp_clauses (&OMP_PARALLEL_CLAUSES (expr));
@@ -4732,13 +4685,9 @@ gimplify_omp_for (tree *expr_p, tree *pre_p)
{
tree for_stmt, decl, t;
enum gimplify_status ret = 0;
- struct gimplify_omp_ctx *outer_combined_omp_ctxp = NULL;
for_stmt = *expr_p;
- if (gimplify_ctxp->combined_pre_p)
- outer_combined_omp_ctxp = gimplify_omp_ctxp->outer_context;
-
gimplify_scan_omp_clauses (&OMP_FOR_CLAUSES (for_stmt), pre_p, false);
t = OMP_FOR_INIT (for_stmt);
@@ -4754,33 +4703,15 @@ gimplify_omp_for (tree *expr_p, tree *pre_p)
else
omp_add_variable (gimplify_omp_ctxp, decl, GOVD_PRIVATE | GOVD_SEEN);
- /* Gimplify inside our parent's context if this is part of a combined
- parallel+workshare directive. */
- if (gimplify_ctxp->combined_pre_p)
- ret |= gimplify_expr_in_ctx (&TREE_OPERAND (t, 1),
- gimplify_ctxp->combined_pre_p, NULL,
- is_gimple_val, fb_rvalue,
- gimplify_ctxp->combined_ctxp,
- outer_combined_omp_ctxp);
- else
- ret |= gimplify_expr (&TREE_OPERAND (t, 1), &OMP_FOR_PRE_BODY (for_stmt),
- NULL, is_gimple_val, fb_rvalue);
+ ret |= gimplify_expr (&TREE_OPERAND (t, 1), &OMP_FOR_PRE_BODY (for_stmt),
+ NULL, is_gimple_val, fb_rvalue);
t = OMP_FOR_COND (for_stmt);
gcc_assert (COMPARISON_CLASS_P (t));
gcc_assert (TREE_OPERAND (t, 0) == decl);
- /* Gimplify inside our parent's context if this is part of a combined
- parallel+workshare directive. */
- if (gimplify_ctxp->combined_pre_p)
- ret |= gimplify_expr_in_ctx (&TREE_OPERAND (t, 1),
- gimplify_ctxp->combined_pre_p, NULL,
- is_gimple_val, fb_rvalue,
- gimplify_ctxp->combined_ctxp,
- outer_combined_omp_ctxp);
- else
- ret |= gimplify_expr (&TREE_OPERAND (t, 1), &OMP_FOR_PRE_BODY (for_stmt),
- NULL, is_gimple_val, fb_rvalue);
+ ret |= gimplify_expr (&TREE_OPERAND (t, 1), &OMP_FOR_PRE_BODY (for_stmt),
+ NULL, is_gimple_val, fb_rvalue);
t = OMP_FOR_INCR (for_stmt);
switch (TREE_CODE (t))
@@ -4818,18 +4749,8 @@ gimplify_omp_for (tree *expr_p, tree *pre_p)
gcc_unreachable ();
}
- /* Gimplify inside our parent's context if this is part of a
- combined parallel+workshare directive. */
- if (gimplify_ctxp->combined_pre_p)
- ret |= gimplify_expr_in_ctx (&TREE_OPERAND (t, 1),
- gimplify_ctxp->combined_pre_p, NULL,
- is_gimple_val, fb_rvalue,
- gimplify_ctxp->combined_ctxp,
- outer_combined_omp_ctxp);
- else
- ret |= gimplify_expr (&TREE_OPERAND (t, 1),
- &OMP_FOR_PRE_BODY (for_stmt), NULL,
- is_gimple_val, fb_rvalue);
+ ret |= gimplify_expr (&TREE_OPERAND (t, 1), &OMP_FOR_PRE_BODY (for_stmt),
+ NULL, is_gimple_val, fb_rvalue);
break;
default:
@@ -5622,6 +5543,10 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
ret = gimplify_omp_atomic (expr_p, pre_p);
break;
+ case OMP_RETURN_EXPR:
+ ret = GS_ALL_DONE;
+ break;
+
default:
switch (TREE_CODE_CLASS (TREE_CODE (*expr_p)))
{