From: Tobias Burnus <tobias@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.com>,
gcc-patches <gcc-patches@gcc.gnu.org>,
fortran <fortran@gcc.gnu.org>
Subject: [Patch] Fortran: Cleanup OpenMP match{o,s,do,ds} macros
Date: Thu, 30 Jun 2022 14:30:24 +0200 [thread overview]
Message-ID: <783d48b1-3939-19c6-78ce-dc0e0cc59231@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 558 bytes --]
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
[-- Attachment #2: omp-match-macro.diff --]
[-- Type: text/x-patch, Size: 4790 bytes --]
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)
next reply other threads:[~2022-06-30 12:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 12:30 Tobias Burnus [this message]
2022-06-30 12:51 ` Jakub Jelinek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=783d48b1-3939-19c6-78ce-dc0e0cc59231@codesourcery.com \
--to=tobias@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).