From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10457 invoked by alias); 27 Oct 2014 20:52:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 10385 invoked by uid 89); 27 Oct 2014 20:52:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 27 Oct 2014 20:52:15 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xir1X-000803-8R for gcc-patches@gcc.gnu.org; Mon, 27 Oct 2014 16:36:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xir1W-0007zx-Vn for gcc-patches@gcc.gnu.org; Mon, 27 Oct 2014 16:36:19 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9RKZIhS015915 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Oct 2014 16:35:18 -0400 Received: from c64.redhat.com (vpn-236-51.phx2.redhat.com [10.3.236.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9RKYt5L021050; Mon, 27 Oct 2014 16:35:17 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 37/92] Introduce gimple_omp_parallel Date: Mon, 27 Oct 2014 20:52:00 -0000 Message-Id: <1414442490-14841-38-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1414442490-14841-1-git-send-email-dmalcolm@redhat.com> References: <1414442490-14841-1-git-send-email-dmalcolm@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg02842.txt.bz2 This corresponds to: [PATCH 39/89] Introduce gimple_omp_parallel https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01159.html from the original 89-patch kit That earlier patch was approved by Jeff: > OK with expected changes due to renaming/updates to const handling. > Please repost the final patch for archival purposes. in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00827.html gcc/ * coretypes.h (gimple_omp_parallel): New typedef. (const_gimple_omp_parallel): New typedef. * cgraphbuild.c (build_cgraph_edges): Convert check of code against GIMPLE_OMP_PARALLEL to a dyn_cast and new local. * gimple-pretty-print.c (dump_gimple_omp_parallel): Require a gimple_omp_parallel rather than a plain gimple. (pp_gimple_stmt_1): Add a checked cast to gimple_omp_parallel within GIMPLE_OMP_PARALLEL case of switch statement. * gimple-walk.c (walk_gimple_op): Likewise, introducing a local. * gimple.c (gimple_build_omp_parallel): Return a gimple_omp_parallel rather than a plain gimple. (gimple_copy): Add checked casts to gimple_omp_parallel within GIMPLE_OMP_PARALLEL case of switch statement, introducing locals. * gimple.h (gimple_build_omp_parallel): Return a gimple_omp_parallel rather than a plain gimple. (gimple_omp_parallel_clauses_ptr): Require a gimple_omp_parallel rather than a plain gimple. (gimple_omp_parallel_set_clauses): Likewise. (gimple_omp_parallel_data_arg_ptr): Likewise. (gimple_omp_parallel_set_data_arg): Likewise. (gimple_omp_parallel_child_fn_ptr): Likewise. (gimple_omp_parallel_set_child_fn): Likewise. (gimple_omp_parallel_child_fn): Require a const_gimple_omp_parallel rather than a plain const_gimple. (gimple_omp_parallel_data_arg): Likewise. * omp-low.c (scan_omp_parallel): Strengthen local "stmt" from gimple to gimple_omp_parallel. (expand_parallel_call): Require a gimple_omp_parallel for "entry_stmt" rather than a plain gimple. (remove_exit_barrier): Strengthen local "parallel_stmt" from gimple to gimple_omp_parallel. (expand_omp_taskreg): Add checked casts to gimple_omp_parallel. * tree-inline.c (remap_gimple_stmt): Add a checked cast to gimple_omp_parallel within GIMPLE_OMP_PARALLEL case of switch statement, introducing local. --- gcc/ChangeLog.gimple-classes | 48 +++++++++++++++++++++++++++++++++++++++ gcc/cgraphbuild.c | 6 ++--- gcc/coretypes.h | 4 ++++ gcc/gimple-pretty-print.c | 7 +++--- gcc/gimple-walk.c | 27 ++++++++++++---------- gcc/gimple.c | 23 ++++++++++++------- gcc/gimple.h | 54 ++++++++++++++++---------------------------- gcc/omp-low.c | 19 ++++++++++------ gcc/tree-inline.c | 16 ++++++++----- 9 files changed, 131 insertions(+), 73 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 7ad116a..b0ddcd3 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,53 @@ 2014-10-24 David Malcolm + Introduce gimple_omp_parallel + + * coretypes.h (gimple_omp_parallel): New typedef. + (const_gimple_omp_parallel): New typedef. + + * cgraphbuild.c (build_cgraph_edges): Convert check of code + against GIMPLE_OMP_PARALLEL to a dyn_cast + and new local. + + * gimple-pretty-print.c (dump_gimple_omp_parallel): Require a + gimple_omp_parallel rather than a plain gimple. + (pp_gimple_stmt_1): Add a checked cast to gimple_omp_parallel + within GIMPLE_OMP_PARALLEL case of switch statement. + + * gimple-walk.c (walk_gimple_op): Likewise, introducing a local. + + * gimple.c (gimple_build_omp_parallel): Return a + gimple_omp_parallel rather than a plain gimple. + (gimple_copy): Add checked casts to gimple_omp_parallel within + GIMPLE_OMP_PARALLEL case of switch statement, introducing locals. + + * gimple.h (gimple_build_omp_parallel): Return a + gimple_omp_parallel rather than a plain gimple. + (gimple_omp_parallel_clauses_ptr): Require a gimple_omp_parallel + rather than a plain gimple. + (gimple_omp_parallel_set_clauses): Likewise. + (gimple_omp_parallel_data_arg_ptr): Likewise. + (gimple_omp_parallel_set_data_arg): Likewise. + (gimple_omp_parallel_child_fn_ptr): Likewise. + (gimple_omp_parallel_set_child_fn): Likewise. + (gimple_omp_parallel_child_fn): Require a + const_gimple_omp_parallel rather than a plain const_gimple. + (gimple_omp_parallel_data_arg): Likewise. + + * omp-low.c (scan_omp_parallel): Strengthen local "stmt" from + gimple to gimple_omp_parallel. + (expand_parallel_call): Require a gimple_omp_parallel for + "entry_stmt" rather than a plain gimple. + (remove_exit_barrier): Strengthen local "parallel_stmt" from + gimple to gimple_omp_parallel. + (expand_omp_taskreg): Add checked casts to gimple_omp_parallel. + + * tree-inline.c (remap_gimple_stmt): Add a checked cast to + gimple_omp_parallel within GIMPLE_OMP_PARALLEL case of switch + statement, introducing local. + +2014-10-24 David Malcolm + Introduce gimple_omp_for * coretypes.h (gimple_omp_for): New. diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c index 96d7015..be3e866 100644 --- a/gcc/cgraphbuild.c +++ b/gcc/cgraphbuild.c @@ -352,10 +352,10 @@ pass_build_cgraph_edges::execute (function *fun) bb->count, freq); } node->record_stmt_references (stmt); - if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL - && gimple_omp_parallel_child_fn (stmt)) + if (gimple_omp_parallel omp_par_stmt = + dyn_cast (stmt)) { - tree fn = gimple_omp_parallel_child_fn (stmt); + tree fn = gimple_omp_parallel_child_fn (omp_par_stmt); node->create_reference (cgraph_node::get_create (fn), IPA_REF_ADDR, stmt); } diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 273ba7e..641658f 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -188,6 +188,10 @@ struct gimple_statement_omp_for; typedef struct gimple_statement_omp_for *gimple_omp_for; typedef const struct gimple_statement_omp_for *const_gimple_omp_for; +struct gimple_statement_omp_parallel; +typedef struct gimple_statement_omp_parallel *gimple_omp_parallel; +typedef const struct gimple_statement_omp_parallel *const_gimple_omp_parallel; + union section; typedef union section section; struct gcc_options; diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 69a4b4c..ea788c2 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -1857,8 +1857,8 @@ dump_gimple_phi (pretty_printer *buffer, gimple_phi phi, int spc, bool comment, dumpfile.h). */ static void -dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc, - int flags) +dump_gimple_omp_parallel (pretty_printer *buffer, gimple_omp_parallel gs, + int spc, int flags) { if (flags & TDF_RAW) { @@ -2137,7 +2137,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags) break; case GIMPLE_OMP_PARALLEL: - dump_gimple_omp_parallel (buffer, gs, spc, flags); + dump_gimple_omp_parallel (buffer, as_a (gs), spc, + flags); break; case GIMPLE_OMP_TASK: diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c index 8293e0d..2b823ac 100644 --- a/gcc/gimple-walk.c +++ b/gcc/gimple-walk.c @@ -347,18 +347,21 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op, break; case GIMPLE_OMP_PARALLEL: - ret = walk_tree (gimple_omp_parallel_clauses_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; - ret = walk_tree (gimple_omp_parallel_child_fn_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; - ret = walk_tree (gimple_omp_parallel_data_arg_ptr (stmt), callback_op, - wi, pset); - if (ret) - return ret; + { + gimple_omp_parallel omp_par_stmt = as_a (stmt); + ret = walk_tree (gimple_omp_parallel_clauses_ptr (omp_par_stmt), + callback_op, wi, pset); + if (ret) + return ret; + ret = walk_tree (gimple_omp_parallel_child_fn_ptr (omp_par_stmt), + callback_op, wi, pset); + if (ret) + return ret; + ret = walk_tree (gimple_omp_parallel_data_arg_ptr (omp_par_stmt), + callback_op, wi, pset); + if (ret) + return ret; + } break; case GIMPLE_OMP_TASK: diff --git a/gcc/gimple.c b/gcc/gimple.c index 3d8fd44..26bd509 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -865,11 +865,12 @@ gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse, CHILD_FN is the function created for the parallel threads to execute. DATA_ARG are the shared data argument(s). */ -gimple +gimple_omp_parallel gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn, tree data_arg) { - gimple p = gimple_alloc (GIMPLE_OMP_PARALLEL, 0); + gimple_omp_parallel p = + as_a (gimple_alloc (GIMPLE_OMP_PARALLEL, 0)); if (body) gimple_omp_set_body (p, body); gimple_omp_parallel_set_clauses (p, clauses); @@ -1730,12 +1731,18 @@ gimple_copy (gimple stmt) goto copy_omp_body; case GIMPLE_OMP_PARALLEL: - t = unshare_expr (gimple_omp_parallel_clauses (stmt)); - gimple_omp_parallel_set_clauses (copy, t); - t = unshare_expr (gimple_omp_parallel_child_fn (stmt)); - gimple_omp_parallel_set_child_fn (copy, t); - t = unshare_expr (gimple_omp_parallel_data_arg (stmt)); - gimple_omp_parallel_set_data_arg (copy, t); + { + gimple_omp_parallel omp_par_stmt = + as_a (stmt); + gimple_omp_parallel omp_par_copy = + as_a (copy); + t = unshare_expr (gimple_omp_parallel_clauses (omp_par_stmt)); + gimple_omp_parallel_set_clauses (omp_par_copy, t); + t = unshare_expr (gimple_omp_parallel_child_fn (omp_par_stmt)); + gimple_omp_parallel_set_child_fn (omp_par_copy, t); + t = unshare_expr (gimple_omp_parallel_data_arg (omp_par_stmt)); + gimple_omp_parallel_set_data_arg (omp_par_copy, t); + } goto copy_omp_body; case GIMPLE_OMP_TASK: diff --git a/gcc/gimple.h b/gcc/gimple.h index 3ed5fc9..cc460499 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1344,7 +1344,7 @@ gimple_debug gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DE gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO) gimple_omp_critical gimple_build_omp_critical (gimple_seq, tree); gimple_omp_for gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq); -gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree); +gimple_omp_parallel gimple_build_omp_parallel (gimple_seq, tree, tree, tree); gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree); gimple gimple_build_omp_section (gimple_seq); gimple gimple_build_omp_master (gimple_seq); @@ -4682,92 +4682,78 @@ gimple_omp_parallel_clauses (const_gimple gs) } -/* Return a pointer to the clauses associated with OMP_PARALLEL GS. */ +/* Return a pointer to the clauses associated with OMP_PARALLEL_STMT. */ static inline tree * -gimple_omp_parallel_clauses_ptr (gimple gs) +gimple_omp_parallel_clauses_ptr (gimple_omp_parallel omp_parallel_stmt) { - gimple_statement_omp_parallel *omp_parallel_stmt = - as_a (gs); return &omp_parallel_stmt->clauses; } -/* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL - GS. */ +/* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL_STMT. */ static inline void -gimple_omp_parallel_set_clauses (gimple gs, tree clauses) +gimple_omp_parallel_set_clauses (gimple_omp_parallel omp_parallel_stmt, + tree clauses) { - gimple_statement_omp_parallel *omp_parallel_stmt = - as_a (gs); omp_parallel_stmt->clauses = clauses; } -/* Return the child function used to hold the body of OMP_PARALLEL GS. */ +/* Return the child function used to hold the body of OMP_PARALLEL_STMT. */ static inline tree -gimple_omp_parallel_child_fn (const_gimple gs) +gimple_omp_parallel_child_fn (const_gimple_omp_parallel omp_parallel_stmt) { - const gimple_statement_omp_parallel *omp_parallel_stmt = - as_a (gs); return omp_parallel_stmt->child_fn; } /* Return a pointer to the child function used to hold the body of - OMP_PARALLEL GS. */ + OMP_PARALLEL_STMT. */ static inline tree * -gimple_omp_parallel_child_fn_ptr (gimple gs) +gimple_omp_parallel_child_fn_ptr (gimple_omp_parallel omp_parallel_stmt) { - gimple_statement_omp_parallel *omp_parallel_stmt = - as_a (gs); return &omp_parallel_stmt->child_fn; } -/* Set CHILD_FN to be the child function for OMP_PARALLEL GS. */ +/* Set CHILD_FN to be the child function for OMP_PARALLEL_STMT. */ static inline void -gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn) +gimple_omp_parallel_set_child_fn (gimple_omp_parallel omp_parallel_stmt, + tree child_fn) { - gimple_statement_omp_parallel *omp_parallel_stmt = - as_a (gs); omp_parallel_stmt->child_fn = child_fn; } /* Return the artificial argument used to send variables and values - from the parent to the children threads in OMP_PARALLEL GS. */ + from the parent to the children threads in OMP_PARALLEL_STMT. */ static inline tree -gimple_omp_parallel_data_arg (const_gimple gs) +gimple_omp_parallel_data_arg (const_gimple_omp_parallel omp_parallel_stmt) { - const gimple_statement_omp_parallel *omp_parallel_stmt = - as_a (gs); return omp_parallel_stmt->data_arg; } -/* Return a pointer to the data argument for OMP_PARALLEL GS. */ +/* Return a pointer to the data argument for OMP_PARALLEL_STMT. */ static inline tree * -gimple_omp_parallel_data_arg_ptr (gimple gs) +gimple_omp_parallel_data_arg_ptr (gimple_omp_parallel omp_parallel_stmt) { - gimple_statement_omp_parallel *omp_parallel_stmt = - as_a (gs); return &omp_parallel_stmt->data_arg; } -/* Set DATA_ARG to be the data argument for OMP_PARALLEL GS. */ +/* Set DATA_ARG to be the data argument for OMP_PARALLEL_STMT. */ static inline void -gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg) +gimple_omp_parallel_set_data_arg (gimple_omp_parallel omp_parallel_stmt, + tree data_arg) { - gimple_statement_omp_parallel *omp_parallel_stmt = - as_a (gs); omp_parallel_stmt->data_arg = data_arg; } diff --git a/gcc/omp-low.c b/gcc/omp-low.c index a40a405..46155d6 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2049,7 +2049,7 @@ scan_omp_parallel (gimple_stmt_iterator *gsi, omp_context *outer_ctx) { omp_context *ctx; tree name; - gimple stmt = gsi_stmt (*gsi); + gimple_omp_parallel stmt = as_a (gsi_stmt (*gsi)); /* Ignore parallel directives with empty bodies, unless there are copyin clauses. */ @@ -4363,7 +4363,8 @@ gimple_build_cond_empty (tree cond) static void expand_parallel_call (struct omp_region *region, basic_block bb, - gimple entry_stmt, vec *ws_args) + gimple_omp_parallel entry_stmt, + vec *ws_args) { tree t, t1, t2, val, cond, c, clauses, flags; gimple_stmt_iterator gsi; @@ -4526,7 +4527,7 @@ expand_parallel_call (struct omp_region *region, basic_block bb, ENTRY_STMT into the basic_block BB. */ static void -expand_cilk_for_call (basic_block bb, gimple entry_stmt, +expand_cilk_for_call (basic_block bb, gimple_omp_parallel entry_stmt, vec *ws_args) { tree t, t1, t2; @@ -4719,7 +4720,8 @@ remove_exit_barrier (struct omp_region *region) of such a variable. */ if (any_addressable_vars < 0) { - gimple parallel_stmt = last_stmt (region->entry); + gimple_omp_parallel parallel_stmt = + as_a (last_stmt (region->entry)); tree child_fun = gimple_omp_parallel_child_fn (parallel_stmt); tree local_decls, block, decl; unsigned ix; @@ -5119,9 +5121,11 @@ expand_omp_taskreg (struct omp_region *region) /* Emit a library call to launch the children threads. */ if (is_cilk_for) - expand_cilk_for_call (new_bb, entry_stmt, ws_args); + expand_cilk_for_call (new_bb, + as_a (entry_stmt), ws_args); else if (gimple_code (entry_stmt) == GIMPLE_OMP_PARALLEL) - expand_parallel_call (region, new_bb, entry_stmt, ws_args); + expand_parallel_call (region, new_bb, + as_a (entry_stmt), ws_args); else expand_task_call (new_bb, entry_stmt); if (gimple_in_ssa_p (cfun)) @@ -6877,7 +6881,8 @@ expand_cilk_for (struct omp_region *region, struct omp_for_data *fd) comment). */ tree child_fndecl - = gimple_omp_parallel_child_fn (last_stmt (region->outer->entry)); + = gimple_omp_parallel_child_fn ( + as_a (last_stmt (region->outer->entry))); tree t, low_val = NULL_TREE, high_val = NULL_TREE; for (t = DECL_ARGUMENTS (child_fndecl); t; t = TREE_CHAIN (t)) { diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index b3254e5..a4d5809 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1362,12 +1362,16 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) break; case GIMPLE_OMP_PARALLEL: - s1 = remap_gimple_seq (gimple_omp_body (stmt), id); - copy = gimple_build_omp_parallel - (s1, - gimple_omp_parallel_clauses (stmt), - gimple_omp_parallel_child_fn (stmt), - gimple_omp_parallel_data_arg (stmt)); + { + gimple_omp_parallel omp_par_stmt = + as_a (stmt); + s1 = remap_gimple_seq (gimple_omp_body (omp_par_stmt), id); + copy = gimple_build_omp_parallel + (s1, + gimple_omp_parallel_clauses (omp_par_stmt), + gimple_omp_parallel_child_fn (omp_par_stmt), + gimple_omp_parallel_data_arg (omp_par_stmt)); + } break; case GIMPLE_OMP_TASK: -- 1.8.5.3