From patchwork Thu Apr 28 02:37:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cesar Philippidis X-Patchwork-Id: 615977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qwLbP6Vmxz9t6v for ; Thu, 28 Apr 2016 12:37:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=LmDj4Hd4; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=udGyDG/2z1q+EPIf/mPaMjNADj73Jm+TjJRPSw0XKt15FShkDneeT J6vTvNARKfu/LLaqca/TA5CwLi7ULJzvkrbOJYjITgn0wkIDhmGsO8Qp0Kuy94nx yB4nfTS4dQbchkl6iqSYh3Gc5EajVTeQniuA28QvSEVj5/XT6N76Qc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=wq5JGfr0hjw3MMPirL6o/nvWJjw=; b=LmDj4Hd40fw+twv3xZZh lGGGxFlYLBncZd9kfqkN6RrgJjsLjyBPTkvPrP/qFJaKA/I8xVm7jTm5dnxoU2h9 2921PW4lyorbiSG5KS9azW7BtDv/c6hBLMMQsJg1DmF5IXumo6a/Meow7TTslozo hqoMfo4YRW33fRymw9tVZvs= Received: (qmail 104387 invoked by alias); 28 Apr 2016 02:37:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 104375 invoked by uid 89); 28 Apr 2016 02:37:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=nreverse, decl_arguments, DECL_ARGUMENTS, sk:pragma_ X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 28 Apr 2016 02:37:22 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1avbpO-0004FA-Jn from Cesar_Philippidis@mentor.com ; Wed, 27 Apr 2016 19:37:18 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.3.224.2; Wed, 27 Apr 2016 19:37:18 -0700 From: Cesar Philippidis Subject: [patch] cleanup *finish_omp_clauses To: "gcc-patches@gcc.gnu.org" , Jakub Jelinek Message-ID: <5721775D.5060004@codesourcery.com> Date: Wed, 27 Apr 2016 19:37:17 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 This patch replaces all of the bool argument to c_finish_omp_clauses and finish_omp_clauses in the c and c++ front ends, respectively. Right now there are three bool arguments, one for is_omp/allow_fields, declare_simd and is_cilk, the latter two have default values set. OpenACC will require some special handling in *finish_omp_clauses in the near future, too, so rather than add an is_oacc argument, I introduced an enum c_omp_region_type, similar to the one in gimplify.c. Is this patch ok for trunk? I'll make use of C_ORT_ACC shortly in a follow up patch. Cesar 2016-04-27 Cesar Philippidis gcc/c-family/ * c-common.h (enum c_omp_region_type): Define. ****************************************************************************** gcc/c/ * c-parser.c (c_parser_oacc_all_clauses): Update call to c_finish_omp_clauses. (c_parser_omp_all_clauses): Likewise. (c_parser_oacc_cache): Likewise. (c_parser_oacc_loop): Likewise. (omp_split_clauses): Likewise. (c_parser_omp_declare_target): Likewise. (c_parser_cilk_all_clauses): Likewise. (c_parser_cilk_for): Likewise. * c-typeck.c (c_finish_omp_clauses): Replace bool arguments is_omp, declare_simd, and is_cilk with enum c_omp_region_type. gcc/cp/ * cp-tree.h (finish_omp_clauses): Update prototype. * parser.c (cp_parser_oacc_all_clauses): Update call to finish_omp_clauses. (cp_parser_omp_all_clauses): Likewise. (cp_parser_omp_for_loop): Likewise. (cp_omp_split_clauses): Likewise. (cp_parser_oacc_cache): Likewise. (cp_parser_oacc_loop): Likewise. (cp_parser_omp_declare_target): (cp_parser_cilk_simd_all_clauses): Likewise. (cp_parser_cilk_for): Likewise. * pt.c (tsubst_attribute): Likewise. (tsubst_omp_clauses): Likewise. (tsubst_omp_for_iterator): Likewise. * semantics.c (finish_omp_clauses): Replace bool arguments allow_fields, declare_simd, and is_cilk with enum c_omp_region_type. (finish_omp_for): Update call to finish_omp_clauses. diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index b631e7d..303269f 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1261,6 +1261,17 @@ enum c_omp_clause_split C_OMP_CLAUSE_SPLIT_TASKLOOP = C_OMP_CLAUSE_SPLIT_FOR }; +enum c_omp_region_type +{ + C_ORT_NONE = 0, + C_ORT_OMP = 1 << 0, + C_ORT_SIMD = 1 << 1, + C_ORT_CILK = 1 << 2, + C_ORT_ACC = 1 << 3, + C_ORT_OMP_SIMD = C_ORT_OMP | C_ORT_SIMD, + C_ORT_OMP_CILK = C_ORT_OMP | C_ORT_CILK +}; + extern tree c_finish_omp_master (location_t, tree); extern tree c_finish_omp_taskgroup (location_t, tree); extern tree c_finish_omp_critical (location_t, tree, tree, tree); diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 36c44ab..aa8ef3e 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -13183,7 +13183,7 @@ c_parser_oacc_all_clauses (c_parser *parser, omp_clause_mask mask, c_parser_skip_to_pragma_eol (parser); if (finish_p) - return c_finish_omp_clauses (clauses, false); + return c_finish_omp_clauses (clauses, C_ORT_ACC); return clauses; } @@ -13468,8 +13468,8 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, if (finish_p) { if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)) != 0) - return c_finish_omp_clauses (clauses, true, true); - return c_finish_omp_clauses (clauses, true); + return c_finish_omp_clauses (clauses, C_ORT_OMP_SIMD); + return c_finish_omp_clauses (clauses, C_ORT_OMP); } return clauses; @@ -13503,7 +13503,7 @@ c_parser_oacc_cache (location_t loc, c_parser *parser) tree stmt, clauses; clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE__CACHE_, NULL); - clauses = c_finish_omp_clauses (clauses, false); + clauses = c_finish_omp_clauses (clauses, C_ORT_ACC); c_parser_skip_to_pragma_eol (parser); @@ -13837,9 +13837,9 @@ c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name, { clauses = c_oacc_split_loop_clauses (clauses, cclauses); if (*cclauses) - *cclauses = c_finish_omp_clauses (*cclauses, false); + *cclauses = c_finish_omp_clauses (*cclauses, C_ORT_ACC); if (clauses) - clauses = c_finish_omp_clauses (clauses, false); + clauses = c_finish_omp_clauses (clauses, C_ORT_ACC); } tree block = c_begin_compound_stmt (true); @@ -15015,7 +15015,7 @@ omp_split_clauses (location_t loc, enum tree_code code, c_omp_split_clauses (loc, code, mask, clauses, cclauses); for (i = 0; i < C_OMP_CLAUSE_SPLIT_COUNT; i++) if (cclauses[i]) - cclauses[i] = c_finish_omp_clauses (cclauses[i], true); + cclauses[i] = c_finish_omp_clauses (cclauses[i], C_ORT_OMP); } /* OpenMP 4.0: @@ -16546,7 +16546,7 @@ c_parser_omp_declare_target (c_parser *parser) { clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_TO_DECLARE, clauses); - clauses = c_finish_omp_clauses (clauses, true); + clauses = c_finish_omp_clauses (clauses, C_ORT_OMP); c_parser_skip_to_pragma_eol (parser); } else @@ -17515,7 +17515,7 @@ c_parser_cilk_all_clauses (c_parser *parser) saw_error: c_parser_skip_to_pragma_eol (parser); - return c_finish_omp_clauses (clauses, false, false, true); + return c_finish_omp_clauses (clauses, C_ORT_CILK); } /* This function helps parse the grainsize pragma for a _Cilk_for statement. @@ -17597,7 +17597,7 @@ c_parser_cilk_for (c_parser *parser, tree grain, bool *if_p) tree clauses = build_omp_clause (EXPR_LOCATION (grain), OMP_CLAUSE_SCHEDULE); OMP_CLAUSE_SCHEDULE_KIND (clauses) = OMP_CLAUSE_SCHEDULE_CILKFOR; OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clauses) = grain; - clauses = c_finish_omp_clauses (clauses, false); + clauses = c_finish_omp_clauses (clauses, C_ORT_NONE); tree block = c_begin_compound_stmt (true); tree sb = push_stmt_list (); @@ -17663,7 +17663,7 @@ c_parser_cilk_for (c_parser *parser, tree grain, bool *if_p) OMP_CLAUSE_OPERAND (c, 0) = cilk_for_number_of_iterations (omp_for); OMP_CLAUSE_CHAIN (c) = clauses; - OMP_PARALLEL_CLAUSES (omp_par) = c_finish_omp_clauses (c, true); + OMP_PARALLEL_CLAUSES (omp_par) = c_finish_omp_clauses (c, C_ORT_OMP); add_stmt (omp_par); } diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 4633182..07d0f65 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -661,7 +661,7 @@ extern tree c_begin_omp_task (void); extern tree c_finish_omp_task (location_t, tree, tree); extern void c_finish_omp_cancel (location_t, tree); extern void c_finish_omp_cancellation_point (location_t, tree); -extern tree c_finish_omp_clauses (tree, bool, bool = false, bool = false); +extern tree c_finish_omp_clauses (tree, enum c_omp_region_type); extern tree c_build_va_arg (location_t, tree, location_t, tree); extern tree c_finish_transaction (location_t, tree, int); extern bool c_tree_equal (tree, tree); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 58c2139..3876e2d 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -12496,8 +12496,7 @@ c_find_omp_placeholder_r (tree *tp, int *, void *data) Remove any elements from the list that are invalid. */ tree -c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, - bool is_cilk) +c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) { bitmap_head generic_head, firstprivate_head, lastprivate_head; bitmap_head aligned_head, map_head, map_field_head; @@ -12509,6 +12508,9 @@ c_finish_omp_clauses (tree clauses, bool is_omp, bool declare_simd, tree *nowait_clause = NULL; bool ordered_seen = false; tree schedule_clause = NULL_TREE; + bool is_omp = ort & C_ORT_OMP; + bool declare_simd = ort == C_ORT_OMP_SIMD; + bool is_cilk = ort & C_ORT_CILK; bitmap_obstack_initialize (NULL); bitmap_initialize (&generic_head, &bitmap_default_obstack); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 0e46ae1..ed3ac64 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6396,8 +6396,7 @@ extern tree omp_reduction_id (enum tree_code, tree, tree); extern tree cp_remove_omp_priv_cleanup_stmt (tree *, int *, void *); extern void cp_check_omp_declare_reduction (tree); extern void finish_omp_declare_simd_methods (tree); -extern tree finish_omp_clauses (tree, bool, bool = false, - bool = false); +extern tree finish_omp_clauses (tree, enum c_omp_region_type); extern tree push_omp_privatization_clauses (bool); extern void pop_omp_privatization_clauses (tree); extern void save_omp_privatization_clauses (vec &); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 98a0cd4..bef3470 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -32260,7 +32260,7 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask, cp_parser_skip_to_pragma_eol (parser, pragma_tok); if (finish_p) - return finish_omp_clauses (clauses, false); + return finish_omp_clauses (clauses, C_ORT_ACC); return clauses; } @@ -32579,9 +32579,9 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, if (finish_p) { if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)) != 0) - return finish_omp_clauses (clauses, false, true); + return finish_omp_clauses (clauses, C_ORT_SIMD); else - return finish_omp_clauses (clauses, true); + return finish_omp_clauses (clauses, C_ORT_OMP); } return clauses; } @@ -33656,7 +33656,7 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses, else c = build_omp_clause (loc, OMP_CLAUSE_LASTPRIVATE); OMP_CLAUSE_DECL (c) = add_private_clause; - c = finish_omp_clauses (c, true); + c = finish_omp_clauses (c, C_ORT_OMP); if (c) { OMP_CLAUSE_CHAIN (c) = clauses; @@ -33808,7 +33808,7 @@ cp_omp_split_clauses (location_t loc, enum tree_code code, c_omp_split_clauses (loc, code, mask, clauses, cclauses); for (i = 0; i < C_OMP_CLAUSE_SPLIT_COUNT; i++) if (cclauses[i]) - cclauses[i] = finish_omp_clauses (cclauses[i], true); + cclauses[i] = finish_omp_clauses (cclauses[i], C_ORT_OMP); } /* OpenMP 4.0: @@ -35091,7 +35091,7 @@ cp_parser_oacc_cache (cp_parser *parser, cp_token *pragma_tok) tree stmt, clauses; clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE__CACHE_, NULL_TREE); - clauses = finish_omp_clauses (clauses, false); + clauses = finish_omp_clauses (clauses, C_ORT_ACC); cp_parser_require_pragma_eol (parser, cp_lexer_peek_token (parser->lexer)); @@ -35416,9 +35416,9 @@ cp_parser_oacc_loop (cp_parser *parser, cp_token *pragma_tok, char *p_name, { clauses = c_oacc_split_loop_clauses (clauses, cclauses); if (*cclauses) - *cclauses = finish_omp_clauses (*cclauses, false); + *cclauses = finish_omp_clauses (*cclauses, C_ORT_ACC); if (clauses) - clauses = finish_omp_clauses (clauses, false); + clauses = finish_omp_clauses (clauses, C_ORT_ACC); } tree block = begin_omp_structured_block (); @@ -35785,7 +35785,7 @@ cp_parser_omp_declare_target (cp_parser *parser, cp_token *pragma_tok) { clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_TO_DECLARE, clauses); - clauses = finish_omp_clauses (clauses, true); + clauses = finish_omp_clauses (clauses, C_ORT_OMP); cp_parser_require_pragma_eol (parser, pragma_tok); } else @@ -37725,7 +37725,7 @@ cp_parser_cilk_simd_all_clauses (cp_parser *parser, cp_token *pragma_token) if (clauses == error_mark_node) return error_mark_node; else - return finish_omp_clauses (clauses, false, false, true); + return finish_omp_clauses (clauses, C_ORT_CILK); } /* Main entry-point for parsing Cilk Plus <#pragma simd> for loops. */ @@ -37770,7 +37770,7 @@ cp_parser_cilk_for (cp_parser *parser, tree grain, bool *if_p) tree clauses = build_omp_clause (EXPR_LOCATION (grain), OMP_CLAUSE_SCHEDULE); OMP_CLAUSE_SCHEDULE_KIND (clauses) = OMP_CLAUSE_SCHEDULE_CILKFOR; OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clauses) = grain; - clauses = finish_omp_clauses (clauses, false); + clauses = finish_omp_clauses (clauses, C_ORT_NONE); tree ret = cp_parser_omp_for_loop (parser, CILK_FOR, clauses, NULL, if_p); if (ret) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2d033e3..b17b092 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9585,7 +9585,7 @@ tsubst_attribute (tree t, tree *decl_p, tree args, clauses = tsubst_omp_clauses (clauses, true, false, args, complain, in_decl); c_omp_declare_simd_clauses_to_decls (*decl_p, clauses); - clauses = finish_omp_clauses (clauses, false, true); + clauses = finish_omp_clauses (clauses, C_ORT_SIMD); tree parms = DECL_ARGUMENTS (*decl_p); clauses = c_omp_declare_simd_clauses_to_numbers (parms, clauses); @@ -14749,7 +14749,8 @@ tsubst_omp_clauses (tree clauses, bool declare_simd, bool allow_fields, new_clauses = nreverse (new_clauses); if (!declare_simd) { - new_clauses = finish_omp_clauses (new_clauses, allow_fields); + enum c_omp_region_type ort = allow_fields ? C_ORT_OMP : C_ORT_NONE; + new_clauses = finish_omp_clauses (new_clauses, ort); if (linear_no_step) for (nc = new_clauses; nc; nc = OMP_CLAUSE_CHAIN (nc)) if (nc == linear_no_step) @@ -14970,7 +14971,7 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree orig_declv, { tree c = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE); OMP_CLAUSE_DECL (c) = decl; - c = finish_omp_clauses (c, true); + c = finish_omp_clauses (c, C_ORT_OMP); if (c) { OMP_CLAUSE_CHAIN (c) = *clauses; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2365a73..5525dc0 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5793,8 +5793,7 @@ cp_finish_omp_clause_depend_sink (tree sink_clause) Remove any elements from the list that are invalid. */ tree -finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, - bool is_cilk) +finish_omp_clauses (tree clauses, enum c_omp_region_type ort) { bitmap_head generic_head, firstprivate_head, lastprivate_head; bitmap_head aligned_head, map_head, map_field_head; @@ -5803,6 +5802,9 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd, bool branch_seen = false; bool copyprivate_seen = false; bool ordered_seen = false; + bool allow_fields = ort & C_ORT_OMP; + bool declare_simd = ort == C_ORT_SIMD; + bool is_cilk = ort == C_ORT_CILK; bitmap_obstack_initialize (NULL); bitmap_initialize (&generic_head, &bitmap_default_obstack); @@ -8342,7 +8344,7 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv, OMP_CLAUSE_OPERAND (c, 0) = cilk_for_number_of_iterations (omp_for); OMP_CLAUSE_CHAIN (c) = clauses; - OMP_PARALLEL_CLAUSES (omp_par) = finish_omp_clauses (c, false); + OMP_PARALLEL_CLAUSES (omp_par) = finish_omp_clauses (c, C_ORT_NONE); add_stmt (omp_par); return omp_par; }