From patchwork Thu Jun 30 12:30:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 55597 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C6FB3842AF8 for ; Thu, 30 Jun 2022 12:30:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 465A63842ACD; Thu, 30 Jun 2022 12:30:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 465A63842ACD 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="5.92,234,1650960000"; d="diff'?scan'208";a="80770696" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 30 Jun 2022 04:30:29 -0800 IronPort-SDR: k4OPKYH5VG7S5qGEdbN3ctVP0KJZ0m6PlwfUflD2llb0Pny7RyNgGbOnZb2SXIKGXXviSYdIDh 4f6i70QAgXBBJGuLd7c3u4URTb381+r7U4AjvmxoXgFPwSz1FDZyR4wlEje+8e3xTu3SBiPquW diT2vvlDMTKInNQ9yR8fyNxKOvxZhVv8Ffxaf4iO6Dck7BonWXXg71DpfNVRCkBSw4/aQ1CFmz zl3ru3JM5HissGXRJvnCJIFS3pLdz7WvMX6cV26T+zK4+oE9jFQE0sSyVS9ELQSUpqwGEXa8cY 2VQ= Message-ID: <783d48b1-3939-19c6-78ce-dc0e0cc59231@codesourcery.com> Date: Thu, 30 Jun 2022 14:30:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: Jakub Jelinek , gcc-patches , fortran From: Tobias Burnus Subject: [Patch] Fortran: Cleanup OpenMP match{o,s,do,ds} macros X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" I initially thought that I need another set of macros - and started with this cleanup. I then realized that I don't. However, I still wonder whether this cleanup makes sense even if only 4 macros are affected. OK for mainline - or should I put that patch into the bin? Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 Fortran: Cleanup OpenMP match{o,s,do,ds} macros Create match_internal as universal macro and use it to define match{o,s,do,ds} gcc/fortran/ChangeLog: * parse.cc (match_internal): New macro. (matcho, matchs, matchds, matchdo): Use it. diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index 7356d1b5a3a..ebe27a7569f 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -745,81 +745,58 @@ decode_oacc_directive (void) return ST_GET_FCN_CHARACTERISTICS; } -/* Like match, but set a flag simd_matched if keyword matched - and if spec_only, goto do_spec_only without actually matching. */ -#define matchs(keyword, subr, st) \ - do { \ - match m2; \ - if (spec_only && gfc_match (keyword) == MATCH_YES) \ - goto do_spec_only; \ - if ((m2 = match_word_omp_simd (keyword, subr, &old_locus, \ - &simd_matched)) == MATCH_YES) \ - { \ - ret = st; \ - goto finish; \ - } \ - else if (m2 == MATCH_ERROR) \ - goto error_handling; \ - else \ - undo_new_statement (); \ +/* Like match, but with some special handling: + - dosimd - if false, don't do anything if not -fopenmp, + otherwise do match_word_omp_simd matching + - if dospec_only: if spec_only, goto do_spec_only after matching. + + If the directive matched but the clauses failed, do not start + matching the next directive in the same switch statement. */ + +#define match_internal(match_simd, match_spec_only, keyword, subr, st) \ + do { \ + match m2; \ + if (!match_simd && !flag_openmp) \ + ; \ + else if (match_spec_only \ + && spec_only \ + && gfc_match (keyword) == MATCH_YES) \ + goto do_spec_only; \ + else if (!match_simd \ + && ((m2 = match_word (keyword, subr, &old_locus)) \ + == MATCH_YES)) \ + { \ + ret = st; \ + goto finish; \ + } \ + else if (match_simd \ + && (m2 = match_word_omp_simd (keyword, subr, &old_locus, \ + &simd_matched)) == MATCH_YES) \ + { \ + ret = st; \ + goto finish; \ + } \ + else if (m2 == MATCH_ERROR) \ + goto error_handling; \ + else \ + undo_new_statement (); \ } while (0) -/* Like match, but don't match anything if not -fopenmp - and if spec_only, goto do_spec_only without actually matching. */ -/* If the directive matched but the clauses failed, do not start - matching the next directive in the same switch statement. */ -#define matcho(keyword, subr, st) \ - do { \ - match m2; \ - if (!flag_openmp) \ - ; \ - else if (spec_only && gfc_match (keyword) == MATCH_YES) \ - goto do_spec_only; \ - else if ((m2 = match_word (keyword, subr, &old_locus)) \ - == MATCH_YES) \ - { \ - ret = st; \ - goto finish; \ - } \ - else if (m2 == MATCH_ERROR) \ - goto error_handling; \ - else \ - undo_new_statement (); \ - } while (0) +/* Like match. Does simd matching; sets flag simd_matched if keyword matched. */ +#define matchds(keyword, subr, st) \ + match_internal(true, false, keyword, subr, st) -/* Like match, but set a flag simd_matched if keyword matched. */ -#define matchds(keyword, subr, st) \ - do { \ - match m2; \ - if ((m2 = match_word_omp_simd (keyword, subr, &old_locus, \ - &simd_matched)) == MATCH_YES) \ - { \ - ret = st; \ - goto finish; \ - } \ - else if (m2 == MATCH_ERROR) \ - goto error_handling; \ - else \ - undo_new_statement (); \ - } while (0) +/* Like matchds, but also honors spec_only. */ +#define matchs(keyword, subr, st) \ + match_internal(true, true, keyword, subr, st) /* Like match, but don't match anything if not -fopenmp. */ -#define matchdo(keyword, subr, st) \ - do { \ - match m2; \ - if (!flag_openmp) \ - ; \ - else if ((m2 = match_word (keyword, subr, &old_locus)) \ - == MATCH_YES) \ - { \ - ret = st; \ - goto finish; \ - } \ - else if (m2 == MATCH_ERROR) \ - goto error_handling; \ - else \ - undo_new_statement (); \ - } while (0) +#define matchdo(keyword, subr, st) \ + match_internal(false, false, keyword, subr, st) + +/* Like matchdo, but also honors spec_only. */ +#define matcho(keyword, subr, st) \ + match_internal(false, true, keyword, subr, st) static gfc_statement decode_omp_directive (void)