This corresponds to: [PATCH 43/89] Introduce gimple_omp_target https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01201.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/msg00823.html gcc/ * coretypes.h (gimple_omp_target): New typedef. (const_gimple_omp_target): New typedef. * gimple.h (gimple_build_omp_target): Return a gimple_omp_target rather than a plain gimple. (gimple_omp_target_set_clauses): Require a gimple_omp_target rather than a plain gimple. (gimple_omp_target_set_kind): Likewise. (gimple_omp_target_child_fn_ptr): Likewise. (gimple_omp_target_set_child_fn): Likewise. (gimple_omp_target_data_arg_ptr): Likewise. (gimple_omp_target_set_data_arg): Likewise. (gimple_omp_target_child_fn): Require a const_gimple_omp_target rather than a plain const_gimple. (gimple_omp_target_data_arg): Likewise. * gimple-pretty-print.c (dump_gimple_omp_target): Require a gimple_omp_target rather than a plain gimple. (pp_gimple_stmt_1): Add checked cast to gimple_omp_target within GIMPLE_OMP_TARGET case of switch statement. * gimple.c (gimple_build_omp_target): Return a gimple_omp_target rather than a plain gimple. * gimplify.c (gimplify_omp_target_update): Strengthen local "stmt" from gimple to gimple_omp_target. * omp-low.c (scan_omp_target): Require a gimple_omp_target rather than a plain gimple. (scan_omp_1_stmt): Add checked cast to gimple_omp_target within GIMPLE_OMP_TARGET case of switch statement. (expand_omp_target): Strengthen local "entry_stmt" from gimple to gimple_omp_target. (lower_omp_target): Likewise for "stmt". * tree-nested.c (convert_nonlocal_reference_stmt): Add checked cast to gimple_omp_target. (convert_local_reference_stmt): Likewise. (convert_gimple_call): Likewise. --- gcc/ChangeLog.gimple-classes | 44 ++++++++++++++++++++++++++++++++++++++++ gcc/coretypes.h | 4 ++++ gcc/gimple-pretty-print.c | 6 ++++-- gcc/gimple.c | 5 +++-- gcc/gimple.h | 48 +++++++++++++++++--------------------------- gcc/gimplify.c | 2 +- gcc/omp-low.c | 11 +++++----- gcc/tree-nested.c | 7 ++++--- 8 files changed, 84 insertions(+), 43 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 88ebaa9..e576b5e 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,49 @@ 2014-10-24 David Malcolm <dmalc...@redhat.com> + Introduce gimple_omp_target + + * coretypes.h (gimple_omp_target): New typedef. + (const_gimple_omp_target): New typedef. + + * gimple.h (gimple_build_omp_target): Return a gimple_omp_target + rather than a plain gimple. + (gimple_omp_target_set_clauses): Require a gimple_omp_target + rather than a plain gimple. + (gimple_omp_target_set_kind): Likewise. + (gimple_omp_target_child_fn_ptr): Likewise. + (gimple_omp_target_set_child_fn): Likewise. + (gimple_omp_target_data_arg_ptr): Likewise. + (gimple_omp_target_set_data_arg): Likewise. + (gimple_omp_target_child_fn): Require a const_gimple_omp_target + rather than a plain const_gimple. + (gimple_omp_target_data_arg): Likewise. + + * gimple-pretty-print.c (dump_gimple_omp_target): Require a + gimple_omp_target rather than a plain gimple. + (pp_gimple_stmt_1): Add checked cast to gimple_omp_target within + GIMPLE_OMP_TARGET case of switch statement. + + * gimple.c (gimple_build_omp_target): Return a gimple_omp_target + rather than a plain gimple. + + * gimplify.c (gimplify_omp_target_update): Strengthen local "stmt" + from gimple to gimple_omp_target. + + * omp-low.c (scan_omp_target): Require a gimple_omp_target rather + than a plain gimple. + (scan_omp_1_stmt): Add checked cast to gimple_omp_target within + GIMPLE_OMP_TARGET case of switch statement. + (expand_omp_target): Strengthen local "entry_stmt" from gimple to + gimple_omp_target. + (lower_omp_target): Likewise for "stmt". + + * tree-nested.c (convert_nonlocal_reference_stmt): Add checked + cast to gimple_omp_target. + (convert_local_reference_stmt): Likewise. + (convert_gimple_call): Likewise. + +2014-10-24 David Malcolm <dmalc...@redhat.com> + Introduce gimple_omp_single * coretypes.h (gimple_omp_single): New typedef. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index ea8f8f4..6996373 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -200,6 +200,10 @@ struct gimple_statement_omp_single; typedef struct gimple_statement_omp_single *gimple_omp_single; typedef const struct gimple_statement_omp_single *const_gimple_omp_single; +struct gimple_statement_omp_target; +typedef struct gimple_statement_omp_target *gimple_omp_target; +typedef const struct gimple_statement_omp_target *const_gimple_omp_target; + union section; typedef union section section; struct gcc_options; diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 61eacd2..6491c55 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -1307,7 +1307,8 @@ dump_gimple_omp_single (pretty_printer *buffer, gimple_omp_single gs, /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */ static void -dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags) +dump_gimple_omp_target (pretty_printer *buffer, gimple_omp_target gs, + int spc, int flags) { const char *kind; switch (gimple_omp_target_kind (gs)) @@ -2172,7 +2173,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags) break; case GIMPLE_OMP_TARGET: - dump_gimple_omp_target (buffer, gs, spc, flags); + dump_gimple_omp_target (buffer, as_a <gimple_omp_target> (gs), spc, + flags); break; case GIMPLE_OMP_TEAMS: diff --git a/gcc/gimple.c b/gcc/gimple.c index bf5f315..afeaa5b 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1052,10 +1052,11 @@ gimple_build_omp_single (gimple_seq body, tree clauses) BODY is the sequence of statements that will be executed. CLAUSES are any of the OMP target construct's clauses. */ -gimple +gimple_omp_target gimple_build_omp_target (gimple_seq body, int kind, tree clauses) { - gimple p = gimple_alloc (GIMPLE_OMP_TARGET, 0); + gimple_omp_target p = + as_a <gimple_omp_target> (gimple_alloc (GIMPLE_OMP_TARGET, 0)); if (body) gimple_omp_set_body (p, body); gimple_omp_target_set_clauses (p, clauses); diff --git a/gcc/gimple.h b/gcc/gimple.h index 1caf745..6bad165 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1356,7 +1356,7 @@ gimple gimple_build_omp_return (bool); gimple gimple_build_omp_sections (gimple_seq, tree); gimple gimple_build_omp_sections_switch (void); gimple_omp_single gimple_build_omp_single (gimple_seq, tree); -gimple gimple_build_omp_target (gimple_seq, int, tree); +gimple_omp_target gimple_build_omp_target (gimple_seq, int, tree); gimple gimple_build_omp_teams (gimple_seq, tree); gimple_omp_atomic_load gimple_build_omp_atomic_load (tree, tree); gimple_omp_atomic_store gimple_build_omp_atomic_store (tree); @@ -5113,13 +5113,12 @@ gimple_omp_target_clauses_ptr (gimple gs) } -/* Set CLAUSES to be the clauses associated with OMP_TARGET GS. */ +/* Set CLAUSES to be the clauses associated with OMP_TARGET_STMT. */ static inline void -gimple_omp_target_set_clauses (gimple gs, tree clauses) +gimple_omp_target_set_clauses (gimple_omp_target omp_target_stmt, + tree clauses) { - gimple_statement_omp_target *omp_target_stmt = - as_a <gimple_statement_omp_target *> (gs); omp_target_stmt->clauses = clauses; } @@ -5137,55 +5136,47 @@ gimple_omp_target_kind (const_gimple g) /* Set the OMP target kind. */ static inline void -gimple_omp_target_set_kind (gimple g, int kind) +gimple_omp_target_set_kind (gimple_omp_target g, int kind) { - GIMPLE_CHECK (g, GIMPLE_OMP_TARGET); g->subcode = (g->subcode & ~GF_OMP_TARGET_KIND_MASK) | (kind & GF_OMP_TARGET_KIND_MASK); } -/* Return the child function used to hold the body of OMP_TARGET GS. */ +/* Return the child function used to hold the body of OMP_TARGET_STMT. */ static inline tree -gimple_omp_target_child_fn (const_gimple gs) +gimple_omp_target_child_fn (const_gimple_omp_target omp_target_stmt) { - const gimple_statement_omp_target *omp_target_stmt = - as_a <const gimple_statement_omp_target *> (gs); return omp_target_stmt->child_fn; } /* Return a pointer to the child function used to hold the body of - OMP_TARGET GS. */ + OMP_TARGET_STMT. */ static inline tree * -gimple_omp_target_child_fn_ptr (gimple gs) +gimple_omp_target_child_fn_ptr (gimple_omp_target omp_target_stmt) { - gimple_statement_omp_target *omp_target_stmt = - as_a <gimple_statement_omp_target *> (gs); return &omp_target_stmt->child_fn; } -/* Set CHILD_FN to be the child function for OMP_TARGET GS. */ +/* Set CHILD_FN to be the child function for OMP_TARGET_STMT. */ static inline void -gimple_omp_target_set_child_fn (gimple gs, tree child_fn) +gimple_omp_target_set_child_fn (gimple_omp_target omp_target_stmt, + tree child_fn) { - gimple_statement_omp_target *omp_target_stmt = - as_a <gimple_statement_omp_target *> (gs); omp_target_stmt->child_fn = child_fn; } /* Return the artificial argument used to send variables and values - from the parent to the children threads in OMP_TARGET GS. */ + from the parent to the children threads in OMP_TARGET_STMT. */ static inline tree -gimple_omp_target_data_arg (const_gimple gs) +gimple_omp_target_data_arg (const_gimple_omp_target omp_target_stmt) { - const gimple_statement_omp_target *omp_target_stmt = - as_a <const gimple_statement_omp_target *> (gs); return omp_target_stmt->data_arg; } @@ -5193,21 +5184,18 @@ gimple_omp_target_data_arg (const_gimple gs) /* Return a pointer to the data argument for OMP_TARGET GS. */ static inline tree * -gimple_omp_target_data_arg_ptr (gimple gs) +gimple_omp_target_data_arg_ptr (gimple_omp_target omp_target_stmt) { - gimple_statement_omp_target *omp_target_stmt = - as_a <gimple_statement_omp_target *> (gs); return &omp_target_stmt->data_arg; } -/* Set DATA_ARG to be the data argument for OMP_TARGET GS. */ +/* Set DATA_ARG to be the data argument for OMP_TARGET_STMT. */ static inline void -gimple_omp_target_set_data_arg (gimple gs, tree data_arg) +gimple_omp_target_set_data_arg (gimple_omp_target omp_target_stmt, + tree data_arg) { - gimple_statement_omp_target *omp_target_stmt = - as_a <gimple_statement_omp_target *> (gs); omp_target_stmt->data_arg = data_arg; } diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 8883523..e3da6ae 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -7180,7 +7180,7 @@ static void gimplify_omp_target_update (tree *expr_p, gimple_seq *pre_p) { tree expr = *expr_p; - gimple stmt; + gimple_omp_target stmt; gimplify_scan_omp_clauses (&OMP_TARGET_UPDATE_CLAUSES (expr), pre_p, ORT_WORKSHARE); diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 3f68ab2..4b4ae4b 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2332,7 +2332,7 @@ scan_omp_single (gimple_omp_single stmt, omp_context *outer_ctx) /* Scan an OpenMP target{, data, update} directive. */ static void -scan_omp_target (gimple stmt, omp_context *outer_ctx) +scan_omp_target (gimple_omp_target stmt, omp_context *outer_ctx) { omp_context *ctx; tree name; @@ -2831,7 +2831,7 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, break; case GIMPLE_OMP_TARGET: - scan_omp_target (stmt, ctx); + scan_omp_target (as_a <gimple_omp_target> (stmt), ctx); break; case GIMPLE_OMP_TEAMS: @@ -8265,10 +8265,11 @@ expand_omp_target (struct omp_region *region) struct function *child_cfun = NULL; tree child_fn = NULL_TREE, block, t; gimple_stmt_iterator gsi; - gimple entry_stmt, stmt; + gimple_omp_target entry_stmt; + gimple stmt; edge e; - entry_stmt = last_stmt (region->entry); + entry_stmt = as_a <gimple_omp_target> (last_stmt (region->entry)); new_bb = region->entry; int kind = gimple_omp_target_kind (entry_stmt); if (kind == GF_OMP_TARGET_KIND_REGION) @@ -10045,7 +10046,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) { tree clauses; tree child_fn, t, c; - gimple stmt = gsi_stmt (*gsi_p); + gimple_omp_target stmt = as_a <gimple_omp_target> (gsi_stmt (*gsi_p)); gimple_bind tgt_bind = NULL, bind; gimple_seq tgt_body = NULL, olist, ilist, new_body; location_t loc = gimple_location (stmt); diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 84401df..e6f5c1a 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -1392,7 +1392,7 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, OMP_CLAUSE_MAP_KIND (c) = OMP_CLAUSE_MAP_TO; OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (decl); OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (stmt); - gimple_omp_target_set_clauses (stmt, c); + gimple_omp_target_set_clauses (as_a <gimple_omp_target> (stmt), c); } save_local_var_chain = info->new_local_var_chain; @@ -1958,7 +1958,7 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, OMP_CLAUSE_MAP_KIND (c) = OMP_CLAUSE_MAP_TOFROM; OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (info->frame_decl); OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (stmt); - gimple_omp_target_set_clauses (stmt, c); + gimple_omp_target_set_clauses (as_a <gimple_omp_target> (stmt), c); } save_local_var_chain = info->new_local_var_chain; @@ -2400,7 +2400,8 @@ convert_gimple_call (gimple_stmt_iterator *gsi, bool *handled_ops_p, = i ? OMP_CLAUSE_MAP_TO : OMP_CLAUSE_MAP_TOFROM; OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (decl); OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (stmt); - gimple_omp_target_set_clauses (stmt, c); + gimple_omp_target_set_clauses (as_a <gimple_omp_target> (stmt), + c); } } info->static_chain_added |= save_static_chain_added; -- 1.8.5.3