diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-05-27 12:48:48 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-05-27 12:48:48 +0200 |
commit | 0ccba4ed8571c18c7015413441e971d4863c3644 (patch) | |
tree | 843f46ea0c2b3fb1552486dc157b140ce137525c /gcc/cp/parser.cc | |
parent | e7c482b08076bb299742883c4ffd65b31e33200c (diff) | |
download | gcc-0ccba4ed8571c18c7015413441e971d4863c3644.zip gcc-0ccba4ed8571c18c7015413441e971d4863c3644.tar.gz gcc-0ccba4ed8571c18c7015413441e971d4863c3644.tar.bz2 |
openmp: Add support for enter clause on declare target
OpenMP 5.1 and earlier had 2 different uses of to clause, one for target
update construct with one semantics, and one for declare target directive
with a different semantics.
Under the hood we were using OMP_CLAUSE_TO_DECLARE to represent the latter.
OpenMP 5.2 renamed the declare target clause to to enter, the old one is
kept as a deprecated alias.
As we are far from having full OpenMP 5.2 support, this patch adds support
for the enter clause (and renames OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER
with a flag to tell the spelling of the clause for better diagnostics),
but doesn't deprecate the to clause on declare target just yet (that
should be done as one of the last steps in 5.2 support).
2022-05-27 Jakub Jelinek <jakub@redhat.com>
gcc/
* tree-core.h (enum omp_clause_code): Rename OMP_CLAUSE_TO_DECLARE
to OMP_CLAUSE_ENTER.
* tree.h (OMP_CLAUSE_ENTER_TO): Define.
* tree.cc (omp_clause_num_ops, omp_clause_code_name): Rename
OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER.
* tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_ENTER
instead of OMP_CLAUSE_TO_DECLARE, if OMP_CLAUSE_ENTER_TO, print
"to" instead of "enter".
* tree-nested.cc (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Handle OMP_CLAUSE_ENTER instead of
OMP_CLAUSE_TO_DECLARE.
gcc/c-family/
* c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_ENTER.
gcc/c/
* c-parser.cc (c_parser_omp_clause_name): Parse enter clause.
(c_parser_omp_all_clauses): For to clause on declare target, use
OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of
OMP_CLAUSE_TO_DECLARE clause. Handle PRAGMA_OMP_CLAUSE_ENTER.
(OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause.
(c_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of
OMP_CLAUSE_TO_DECLARE.
* c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead
of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause
name in diagnostics instead of
omp_clause_code_name[OMP_CLAUSE_CODE (c)].
gcc/cp/
* parser.cc (cp_parser_omp_clause_name): Parse enter clause.
(cp_parser_omp_all_clauses): For to clause on declare target, use
OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of
OMP_CLAUSE_TO_DECLARE clause. Handle PRAGMA_OMP_CLAUSE_ENTER.
(OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause.
(cp_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of
OMP_CLAUSE_TO_DECLARE.
* semantics.cc (finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead
of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause
name in diagnostics instead of
omp_clause_code_name[OMP_CLAUSE_CODE (c)].
gcc/testsuite/
* c-c++-common/gomp/clauses-3.c: Add tests with enter clause instead
of to or modify some existing to clauses to enter.
* c-c++-common/gomp/declare-target-1.c: Likewise.
* c-c++-common/gomp/declare-target-2.c: Likewise.
* c-c++-common/gomp/declare-target-3.c: Likewise.
* g++.dg/gomp/attrs-9.C: Likewise.
* g++.dg/gomp/declare-target-1.C: Likewise.
libgomp/
* testsuite/libgomp.c-c++-common/target-40.c: Modify some existing to
clauses to enter.
* testsuite/libgomp.c/target-41.c: Likewise.
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r-- | gcc/cp/parser.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index a6af993..4b98595 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -36498,6 +36498,10 @@ cp_parser_omp_clause_name (cp_parser *parser) else if (!strcmp ("dist_schedule", p)) result = PRAGMA_OMP_CLAUSE_DIST_SCHEDULE; break; + case 'e': + if (!strcmp ("enter", p)) + result = PRAGMA_OMP_CLAUSE_ENTER; + break; case 'f': if (!strcmp ("filter", p)) result = PRAGMA_OMP_CLAUSE_FILTER; @@ -40418,8 +40422,13 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, break; case PRAGMA_OMP_CLAUSE_TO: if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINK)) != 0) - clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_TO_DECLARE, - clauses); + { + tree nl = cp_parser_omp_var_list (parser, OMP_CLAUSE_ENTER, + clauses); + for (tree c = nl; c != clauses; c = OMP_CLAUSE_CHAIN (c)) + OMP_CLAUSE_ENTER_TO (c) = 1; + clauses = nl; + } else clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_TO, clauses, true); @@ -40526,6 +40535,11 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, clauses, token->location); c_name = "simd"; break; + case PRAGMA_OMP_CLAUSE_ENTER: + clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_ENTER, + clauses); + c_name = "enter"; + break; default: cp_parser_error (parser, "expected %<#pragma omp%> clause"); goto saw_error; @@ -46037,6 +46051,7 @@ handle_omp_declare_target_clause (tree c, tree t, int device_type) #define OMP_DECLARE_TARGET_CLAUSE_MASK \ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TO) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ENTER) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINK) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE_TYPE)) @@ -46056,7 +46071,7 @@ cp_parser_omp_declare_target (cp_parser *parser, cp_token *pragma_tok) "#pragma omp declare target", pragma_tok); else if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) { - clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_TO_DECLARE, + clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_ENTER, clauses); clauses = finish_omp_clauses (clauses, C_ORT_OMP); cp_parser_require_pragma_eol (parser, pragma_tok); |