From patchwork Tue Sep 5 19:28:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1830100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RgFwb3Lpqz1ygx for ; Wed, 6 Sep 2023 05:30:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9BB193885C34 for ; Tue, 5 Sep 2023 19:30:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 923C0388215F; Tue, 5 Sep 2023 19:30:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 923C0388215F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.02,229,1688457600"; d="scan'208";a="18105086" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 05 Sep 2023 11:30:12 -0800 IronPort-SDR: gGOamSm+jIshwXY3olWiu2UTg1qQb1Wo9MNTd41UeKrI9EfY9FQ2WotnPe6/ZHxGQW+iDHnwDP REPPqbZQmmaCIFaa/0Hvvg07AI+zp0pxPtTsA15v1Ulcv2izrgDFnr44D9ivUgK1YDcNIPR24C Rhl69uJHF5axvIyt3L8hLuciPRukElzq8gSTAreIr3z1IpDMzo5ZosGqdGFGF6pT+qmV64IT+7 yHM3nrcsJJcLMgB4ceg2OUN1nxx8V/5ZkRPbtjgGEDojwUIsONWWEl1n6GIpRIeF+Lm1eYs4ko uQg= From: Julian Brown To: CC: , , Subject: [PATCH 5/8] OpenMP, Fortran: Pass list number to gfc_free_omp_namelist Date: Tue, 5 Sep 2023 12:28:25 -0700 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-14.mgc.mentorg.com (139.181.222.14) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This is a cleanup to avoid passing an ever-longer list of boolean arguments to gfc_free_omp_namelist, in support of the Fortran "declare mapper" implementation further along this patch series. This patch isn't intended to cause any behavioural changes. 2023-09-05 Julian Brown gcc/fortran/ * gfortran.h (gfc_free_omp_namelist): Update prototype. * match.cc (gfc_free_omp_namelist): Remove FREE_NS, FREE_ALIGN_ALLOCATOR, FREE_MEM_TRAITS_SPACE parameters and replace with LIST. * openmp.cc (gfc_free_omp_clauses, gfc_match_omp_clause_reduction, gfc_match_omp_clause_uses_allocators, gfc_match_omp_clauses, gfc_match_omp_allocate, gfc_match_omp_flush, resolve_omp_clauses): Update calls to gfc_free_omp_namelist. * st.cc (gfc_free_statement): Update call to gfc_free_omp_namelist. --- gcc/fortran/gfortran.h | 2 +- gcc/fortran/match.cc | 7 ++++--- gcc/fortran/openmp.cc | 31 ++++++++++++++----------------- gcc/fortran/st.cc | 2 +- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 3c8270a0f83a..34ee800668ca 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -3605,7 +3605,7 @@ void gfc_free_iterator (gfc_iterator *, int); void gfc_free_forall_iterator (gfc_forall_iterator *); void gfc_free_alloc_list (gfc_alloc *); void gfc_free_namelist (gfc_namelist *); -void gfc_free_omp_namelist (gfc_omp_namelist *, bool, bool, bool); +void gfc_free_omp_namelist (gfc_omp_namelist *, int = OMP_LIST_NUM); void gfc_free_equiv (gfc_equiv *); void gfc_free_equiv_until (gfc_equiv *, gfc_equiv *); void gfc_free_data (gfc_data *); diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index ba23bcd96923..dd72a03027a1 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -5536,10 +5536,11 @@ gfc_free_namelist (gfc_namelist *name) /* Free an OpenMP namelist structure. */ void -gfc_free_omp_namelist (gfc_omp_namelist *name, bool free_ns, - bool free_align_allocator, - bool free_mem_traits_space) +gfc_free_omp_namelist (gfc_omp_namelist *name, int list) { + bool free_ns = (list == OMP_LIST_AFFINITY || list == OMP_LIST_DEPEND); + bool free_align_allocator = (list == OMP_LIST_ALLOCATE); + bool free_mem_traits_space = (list == OMP_LIST_USES_ALLOCATORS); gfc_omp_namelist *n; for (; name; name = n) diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 234d896b2ce2..576b6784b441 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -186,10 +186,7 @@ gfc_free_omp_clauses (gfc_omp_clauses *c) gfc_free_expr (c->num_workers_expr); gfc_free_expr (c->vector_length_expr); for (i = 0; i < OMP_LIST_NUM; i++) - gfc_free_omp_namelist (c->lists[i], - i == OMP_LIST_AFFINITY || i == OMP_LIST_DEPEND, - i == OMP_LIST_ALLOCATE, - i == OMP_LIST_USES_ALLOCATORS); + gfc_free_omp_namelist (c->lists[i], i); gfc_free_expr_list (c->wait_list); gfc_free_expr_list (c->tile_list); free (CONST_CAST (char *, c->critical_name)); @@ -554,7 +551,7 @@ syntax: gfc_error ("Syntax error in OpenMP variable list at %C"); cleanup: - gfc_free_omp_namelist (head, false, false, false); + gfc_free_omp_namelist (head); gfc_current_locus = old_loc; return MATCH_ERROR; } @@ -644,7 +641,7 @@ syntax: gfc_error ("Syntax error in OpenMP variable list at %C"); cleanup: - gfc_free_omp_namelist (head, false, false, false); + gfc_free_omp_namelist (head); gfc_current_locus = old_loc; return MATCH_ERROR; } @@ -753,7 +750,7 @@ syntax: gfc_error ("Syntax error in OpenMP SINK dependence-type list at %C"); cleanup: - gfc_free_omp_namelist (head, false, false, false); + gfc_free_omp_namelist (head); gfc_current_locus = old_loc; return MATCH_ERROR; } @@ -1504,7 +1501,7 @@ gfc_match_omp_clause_reduction (char pc, gfc_omp_clauses *c, bool openacc, *head = NULL; gfc_error_now ("!$OMP DECLARE REDUCTION %s not found at %L", buffer, &old_loc); - gfc_free_omp_namelist (n, false, false, false); + gfc_free_omp_namelist (n, list_idx); } else for (n = *head; n; n = n->next) @@ -1795,7 +1792,7 @@ gfc_match_omp_clause_uses_allocators (gfc_omp_clauses *c) return MATCH_YES; error: - gfc_free_omp_namelist (head, false, false, true); + gfc_free_omp_namelist (head, OMP_LIST_USES_ALLOCATORS); return MATCH_ERROR; } @@ -1922,7 +1919,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, if (end_colon && gfc_match (" %e )", &alignment) != MATCH_YES) { - gfc_free_omp_namelist (*head, false, false, false); + gfc_free_omp_namelist (*head); gfc_current_locus = old_loc; *head = NULL; break; @@ -2865,7 +2862,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, end_colon = true; else if (gfc_match (" )") != MATCH_YES) { - gfc_free_omp_namelist (*head, false, false, false); + gfc_free_omp_namelist (*head); gfc_current_locus = old_loc; *head = NULL; break; @@ -2876,7 +2873,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, { if (gfc_match (" %e )", &step) != MATCH_YES) { - gfc_free_omp_namelist (*head, false, false, false); + gfc_free_omp_namelist (*head); gfc_current_locus = old_loc; *head = NULL; goto error; @@ -2973,7 +2970,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, } if (has_error) { - gfc_free_omp_namelist (*head, false, false, false); + gfc_free_omp_namelist (*head); *head = NULL; goto error; } @@ -4519,7 +4516,7 @@ gfc_match_omp_allocate (void) gfc_error ("Unexpected expression as list item at %L in ALLOCATE " "directive", &n->expr->where); - gfc_free_omp_namelist (vars, false, true, false); + gfc_free_omp_namelist (vars, OMP_LIST_ALLOCATE); goto error; } @@ -4923,14 +4920,14 @@ gfc_match_omp_flush (void) { gfc_error ("List specified together with memory order clause in FLUSH " "directive at %C"); - gfc_free_omp_namelist (list, false, false, false); + gfc_free_omp_namelist (list); gfc_free_omp_clauses (c); return MATCH_ERROR; } if (gfc_match_omp_eos () != MATCH_YES) { gfc_error ("Unexpected junk after $OMP FLUSH statement at %C"); - gfc_free_omp_namelist (list, false, false, false); + gfc_free_omp_namelist (list); gfc_free_omp_clauses (c); return MATCH_ERROR; } @@ -7831,7 +7828,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, { prev->next = n->next; n->next = NULL; - gfc_free_omp_namelist (n, false, true, false); + gfc_free_omp_namelist (n, OMP_LIST_ALLOCATE); n = prev->next; } continue; diff --git a/gcc/fortran/st.cc b/gcc/fortran/st.cc index b6d87c402074..257e08bc074c 100644 --- a/gcc/fortran/st.cc +++ b/gcc/fortran/st.cc @@ -288,7 +288,7 @@ gfc_free_statement (gfc_code *p) break; case EXEC_OMP_FLUSH: - gfc_free_omp_namelist (p->ext.omp_namelist, false, false, false); + gfc_free_omp_namelist (p->ext.omp_namelist); break; case EXEC_OMP_BARRIER: