This is a revised version of the patch set I last posted in late May: https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653066.html
Aside from rebasing the patch set so it applies cleanly to mainline head again, I incorporated a few small code cleanups and testsuite fixes I'd collected, plus a few more substantive improvements: - I changed the metadirective pretty-printers to use "otherwise" instead of the now-deprecated "default" clause, as Tobias suggested in his review of the previous version of part 1, and made corresponding tweaks to the test cases that were examining the dump output. - I also re-did the device_num support for the target_device selector along the lines suggested by Tobias (simplifying the libgomp support and adding a conditional to the generated code), and added a new testcase for that. - When I was working on something else I observed that the C front end now has support for attribute-syntax directives; when I originally implemented that for metadirectives on the OG13 branch about a year ago, only C++ had general support for attribute syntax. My C++ testcases failed to "just work" in C because the lookahead save/restore mechanism for attribute directives collided with the token caching used by metadirective for parsing the body. So I fixed that, now the testcases work in both languages. Also note the lists of improvements and bug fixes for previous versions of the patch set, which I won't duplicate here. I realize this is a large and complicated patch set with many dependencies between the pieces (and I have another layer on top of this in the works to support "begin declare variant"). If the maintainers would find it easier to review if I refactored the pieces in some other way, please let me know what would help to expedite the process. I'd really like to get these patches in somehow or another, so I don't have to continue to spend so much time maintaining them out of tree. :-S -Sandra Sandra Loosemore (12): OpenMP: metadirective tree data structures and front-end interfaces OpenMP: middle-end support for metadirectives libgomp: runtime support for target_device selector OpenMP: C front end support for metadirectives OpenMP: C++ front-end support for metadirectives OpenMP: common c/c++ testcases for metadirectives OpenMP: Fortran front-end support for metadirectives. OpenMP: Reject other properties with kind(any) OpenMP: Extend dynamic selector support to declare variant OpenMP: Remove dead code from declare variant reimplementation OpenMP: Update "declare target"/OpenMP context interaction OpenMP: Update documentation of metadirective implementation status. gcc/Makefile.in | 2 +- gcc/builtin-types.def | 2 + gcc/c-family/c-attribs.cc | 2 - gcc/c-family/c-common.h | 4 +- gcc/c-family/c-gimplify.cc | 27 + gcc/c-family/c-omp.cc | 60 +- gcc/c-family/c-pragma.cc | 1 + gcc/c-family/c-pragma.h | 1 + gcc/c/c-decl.cc | 8 +- gcc/c/c-parser.cc | 508 +++- gcc/cgraph.cc | 2 - gcc/cgraph.h | 12 +- gcc/cgraphclones.cc | 2 +- gcc/cp/cp-tree.h | 2 + gcc/cp/decl.cc | 2 +- gcc/cp/decl2.cc | 9 +- gcc/cp/parser.cc | 526 ++++- gcc/cp/parser.h | 7 + gcc/cp/pt.cc | 120 + gcc/cp/semantics.cc | 3 +- gcc/doc/generic.texi | 32 + gcc/doc/gimple.texi | 6 + gcc/fortran/decl.cc | 29 + gcc/fortran/dump-parse-tree.cc | 21 + gcc/fortran/gfortran.h | 21 +- gcc/fortran/io.cc | 2 +- gcc/fortran/match.h | 2 + gcc/fortran/openmp.cc | 294 ++- gcc/fortran/parse.cc | 578 +++-- gcc/fortran/parse.h | 8 +- gcc/fortran/resolve.cc | 6 + gcc/fortran/st.cc | 4 + gcc/fortran/symbol.cc | 25 +- gcc/fortran/trans-decl.cc | 5 +- gcc/fortran/trans-openmp.cc | 238 +- gcc/fortran/trans-stmt.h | 1 + gcc/fortran/trans.cc | 1 + gcc/fortran/types.def | 2 + gcc/gimple-low.cc | 36 + gcc/gimple-pretty-print.cc | 78 + gcc/gimple-streamer-in.cc | 13 + gcc/gimple-streamer-out.cc | 10 + gcc/gimple-walk.cc | 28 + gcc/gimple.cc | 36 + gcc/gimple.def | 8 + gcc/gimple.h | 122 +- gcc/gimplify.cc | 574 +++-- gcc/gimplify.h | 2 +- gcc/gsstruct.def | 2 + gcc/ipa-free-lang-data.cc | 2 +- gcc/ipa.cc | 3 - gcc/lto-cgraph.cc | 12 +- gcc/lto-streamer-out.cc | 3 +- gcc/lto-streamer.h | 6 - gcc/lto/lto-partition.cc | 5 +- gcc/omp-builtins.def | 3 + gcc/omp-expand.cc | 32 +- gcc/omp-general.cc | 2043 +++++++++-------- gcc/omp-general.h | 50 +- gcc/omp-low.cc | 83 + gcc/omp-offload.cc | 117 +- gcc/omp-simd-clone.cc | 3 +- gcc/passes.cc | 3 +- gcc/symtab.cc | 2 +- .../c-c++-common/gomp/attrs-metadirective-1.c | 41 + .../c-c++-common/gomp/attrs-metadirective-2.c | 75 + .../c-c++-common/gomp/attrs-metadirective-3.c | 23 + .../c-c++-common/gomp/attrs-metadirective-4.c | 41 + .../c-c++-common/gomp/attrs-metadirective-5.c | 25 + .../c-c++-common/gomp/attrs-metadirective-6.c | 32 + .../c-c++-common/gomp/attrs-metadirective-7.c | 32 + .../c-c++-common/gomp/attrs-metadirective-8.c | 17 + .../gomp/declare-target-indirect-2.c | 10 +- .../c-c++-common/gomp/declare-variant-10.c | 4 +- .../c-c++-common/gomp/declare-variant-12.c | 14 +- .../c-c++-common/gomp/declare-variant-13.c | 6 +- .../c-c++-common/gomp/declare-variant-2.c | 4 +- .../c-c++-common/gomp/declare-variant-3.c | 10 +- .../c-c++-common/gomp/declare-variant-8.c | 4 +- .../c-c++-common/gomp/declare-variant-9.c | 4 +- .../c-c++-common/gomp/declare-variant-any.c | 10 + .../gomp/declare-variant-arg-exprs.c | 29 + .../gomp/declare-variant-dynamic-1.c | 26 + .../gomp/declare-variant-dynamic-2.c | 30 + .../c-c++-common/gomp/metadirective-1.c | 52 + .../c-c++-common/gomp/metadirective-2.c | 74 + .../c-c++-common/gomp/metadirective-3.c | 22 + .../c-c++-common/gomp/metadirective-4.c | 40 + .../c-c++-common/gomp/metadirective-5.c | 24 + .../c-c++-common/gomp/metadirective-6.c | 31 + .../c-c++-common/gomp/metadirective-7.c | 31 + .../c-c++-common/gomp/metadirective-8.c | 16 + .../gomp/metadirective-construct.c | 177 ++ .../c-c++-common/gomp/metadirective-device.c | 147 ++ .../gomp/metadirective-no-score.c | 95 + .../gomp/metadirective-target-device.c | 147 ++ .../c-c++-common/gomp/reverse-offload-1.c | 2 +- .../g++.dg/gomp/declare-variant-class-1.C | 32 + .../g++.dg/gomp/declare-variant-class-2.C | 37 + gcc/testsuite/gcc.dg/gomp/metadirective-1.c | 15 + .../gfortran.dg/gomp/declare-variant-10.f90 | 4 +- .../gfortran.dg/gomp/declare-variant-12.f90 | 14 +- .../gfortran.dg/gomp/declare-variant-13.f90 | 28 +- .../gfortran.dg/gomp/declare-variant-3.f90 | 12 +- .../gfortran.dg/gomp/declare-variant-8.f90 | 12 +- .../gfortran.dg/gomp/declare-variant-9.f90 | 2 +- .../gfortran.dg/gomp/declare-variant-any.f90 | 28 + .../gfortran.dg/gomp/metadirective-1.f90 | 73 + .../gfortran.dg/gomp/metadirective-10.f90 | 40 + .../gfortran.dg/gomp/metadirective-11.f90 | 33 + .../gfortran.dg/gomp/metadirective-2.f90 | 62 + .../gfortran.dg/gomp/metadirective-3.f90 | 25 + .../gfortran.dg/gomp/metadirective-4.f90 | 39 + .../gfortran.dg/gomp/metadirective-5.f90 | 30 + .../gfortran.dg/gomp/metadirective-6.f90 | 31 + .../gfortran.dg/gomp/metadirective-7.f90 | 36 + .../gfortran.dg/gomp/metadirective-8.f90 | 22 + .../gfortran.dg/gomp/metadirective-9.f90 | 30 + .../gomp/metadirective-construct.f90 | 260 +++ .../gomp/metadirective-no-score.f90 | 122 + gcc/testsuite/gfortran.dg/gomp/pure-1.f90 | 7 + gcc/testsuite/gfortran.dg/gomp/pure-2.f90 | 8 - gcc/tree-cfg.cc | 24 + gcc/tree-inline.cc | 45 +- gcc/tree-nested.cc | 43 + gcc/tree-pretty-print.cc | 36 +- gcc/tree-pretty-print.h | 2 + gcc/tree-ssa-operands.cc | 17 + gcc/tree.def | 6 + gcc/tree.h | 3 + include/cuda/cuda.h | 2 + libgomp/Makefile.am | 2 +- libgomp/Makefile.in | 5 +- libgomp/config/gcn/selector.c | 102 + libgomp/config/linux/selector.c | 65 + libgomp/config/linux/x86/selector.c | 406 ++++ libgomp/config/nvptx/selector.c | 77 + libgomp/libgomp-plugin.h | 2 + libgomp/libgomp.h | 1 + libgomp/libgomp.map | 5 + libgomp/libgomp.texi | 39 +- libgomp/libgomp_g.h | 8 + libgomp/oacc-host.c | 11 + libgomp/plugin/plugin-gcn.c | 52 + libgomp/plugin/plugin-nvptx.c | 82 + libgomp/selector.c | 64 + libgomp/target.c | 22 + .../libgomp.c++/metadirective-template-1.C | 37 + .../libgomp.c++/metadirective-template-2.C | 41 + .../libgomp.c++/metadirective-template-3.C | 41 + .../libgomp.c-c++-common/metadirective-1.c | 35 + .../libgomp.c-c++-common/metadirective-2.c | 41 + .../libgomp.c-c++-common/metadirective-3.c | 34 + .../libgomp.c-c++-common/metadirective-4.c | 52 + .../libgomp.c-c++-common/metadirective-5.c | 46 + .../metadirective-target-device.c | 63 + .../libgomp.fortran/metadirective-1.f90 | 61 + .../libgomp.fortran/metadirective-2.f90 | 40 + .../libgomp.fortran/metadirective-3.f90 | 29 + .../libgomp.fortran/metadirective-4.f90 | 46 + .../libgomp.fortran/metadirective-5.f90 | 44 + .../libgomp.fortran/metadirective-6.f90 | 58 + 162 files changed, 8273 insertions(+), 1664 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-1.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-2.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-4.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-5.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-6.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-7.c create mode 100644 gcc/testsuite/c-c++-common/gomp/attrs-metadirective-8.c create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-any.c create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-arg-exprs.c create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-dynamic-1.c create mode 100644 gcc/testsuite/c-c++-common/gomp/declare-variant-dynamic-2.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-1.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-2.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-3.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-4.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-5.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-6.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-7.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-8.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-construct.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-device.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-no-score.c create mode 100644 gcc/testsuite/c-c++-common/gomp/metadirective-target-device.c create mode 100644 gcc/testsuite/g++.dg/gomp/declare-variant-class-1.C create mode 100644 gcc/testsuite/g++.dg/gomp/declare-variant-class-2.C create mode 100644 gcc/testsuite/gcc.dg/gomp/metadirective-1.c create mode 100644 gcc/testsuite/gfortran.dg/gomp/declare-variant-any.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-1.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-10.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-11.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-2.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-3.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-4.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-5.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-6.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-7.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-8.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-construct.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/metadirective-no-score.f90 create mode 100644 libgomp/config/gcn/selector.c create mode 100644 libgomp/config/linux/selector.c create mode 100644 libgomp/config/linux/x86/selector.c create mode 100644 libgomp/config/nvptx/selector.c create mode 100644 libgomp/selector.c create mode 100644 libgomp/testsuite/libgomp.c++/metadirective-template-1.C create mode 100644 libgomp/testsuite/libgomp.c++/metadirective-template-2.C create mode 100644 libgomp/testsuite/libgomp.c++/metadirective-template-3.C create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-1.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-2.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-3.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-4.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-5.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/metadirective-target-device.c create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-1.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-2.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-3.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-4.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-5.f90 create mode 100644 libgomp/testsuite/libgomp.fortran/metadirective-6.f90 -- 2.25.1