This is yet another revised version of the patch set for metadirective
and dynamic selector support, along with "declare variant"
fixes/improvements, incorporating comments received on the last
posted version in July:

https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657841.html

The current version includes two big functional changes compared to
the July patch set.

(1) Comments on the previous version indicated that resolution of the
target_device selector ought to use target properties present at
compile-time rather than relying on functions in libgomp that reflect
how the library was configured.  So the whole set of changes to
libgomp from the previous version of the patch completely gone, and
there's now some machinery to expand these selectors into a new magic
cookie that is resolved to a constant in the ompdevlow pass.

(2) In his comments on the last version, Jakub suggested that
GIMPLE_SWITCH would be a better representation of variant directives
requiring late resolution (in ompdevlow) than another new gimple thing
that branches to a bunch of labels.  I also realized that the way the
last version waited until ompdevlow to insert the predicates for
dynamic selector tests was broken for any user conditions that
introduced additional control flow (eg, ?:, &&, || expressions), and
also that doing surgery on the control-flow graph edges, as the
previous version did, was too fragile when compiling with -O.  So now
the gimplifier produces GIMPLE_SWITCH, setting the switch variable to
a magic cookie that is similarly replaced with a constant after late
variant resolution in ompdevlow.  In the case of dynamic selectors,
the GIMPLE_SWITCH is in a loop with the dynamic selector conditionals
already inserted into their respective cases, with the same magic
cookie being used to set the switch variable for the "else" case to
try the next time through the loop.  See the comments in part 2 of the
patch series for more details on this.  The overall idea here is to
let the optimizers rearrange the code and discard dead alternatives
after the magic cookies are replaced with constants in ompdevlow
resolution, instead of trying to fight optimizations happening before
that point.

I've also re-worked the organization of the patch series somewhat.  In
the last version, I had the complete support for metadirectives with
dynamic selectors ordered before additional changes to make declare
variant use the same resolution mechanism, leading to me needing to
include some backward-compatibility interfaces that went away in
subsequent patch pieces, and getting code review comments like "why is
this only for metadirective and not declare variant".  In this
version, I've re-ordered things to get all the middle-end interface
changes in first and switch "declare variant" to use them, before
adding any of the new front-end support for metadirectives.  I hope
this will make it easier to review.

Finally, I'm aware there are multiple bugs still open in bugzilla for
metadirective parse errors that were reported against much earlier
versions of this patch set (e.g., OG12 branch), missing support for
some context selectors added in newer versions of the standard, and
some other corner cases.  Tobias and I discussed this offline and we
both think it's more important to get the basic functionality in GCC
15, and that doing so will make it easier to track and address these
other issues as follow-up patches.  I also have a (now somewhat
bit-rotten) patch series for "begin declare variant" that I have not
yet submitted because I've been blocked on getting these
infrastructure changes in first.

-Sandra

Sandra Loosemore (10):
  OpenMP: New tree nodes for metadirective and dynamic selector support.
  OpenMP: Re-work and extend context selector resolution
  OpenMP: Remove dead code from declare variant reimplementation
  OpenMP: Robustify C front end handling of attribute-syntax pragmas
  OpenMP: Add C support for metadirectives and dynamic selectors.
  OpenMP: C++ support for metadirectives and dynamic selectors.
  OpenMP: Shared metadirective/dynamic selector tests for C and C++
  OpenMP: Fortran support for metadirectives and dynamic selectors
  OpenMP: Update "declare target"/OpenMP context interaction
  OpenMP: Update documentation of metadirective implementation status.

 gcc/Makefile.in                               |    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                             |  537 +++-
 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                              |  542 +++-
 gcc/cp/parser.h                               |    6 +
 gcc/cp/pt.cc                                  |  126 +
 gcc/cp/semantics.cc                           |    3 +-
 gcc/doc/generic.texi                          |   63 +
 gcc/fold-const.cc                             |    2 +
 gcc/fortran/decl.cc                           |   29 +
 gcc/fortran/dump-parse-tree.cc                |   20 +
 gcc/fortran/gfortran.h                        |   21 +-
 gcc/fortran/io.cc                             |    2 +-
 gcc/fortran/match.h                           |    2 +
 gcc/fortran/openmp.cc                         |  302 ++-
 gcc/fortran/parse.cc                          |  582 +++--
 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/gimple-expr.cc                            |    5 +
 gcc/gimple.cc                                 |    4 +-
 gcc/gimplify.cc                               |  646 ++++-
 gcc/gimplify.h                                |    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-expand.cc                             |    6 +-
 gcc/omp-general.cc                            | 2198 +++++++++--------
 gcc/omp-general.h                             |   44 +-
 gcc/omp-low.cc                                |   18 +
 gcc/omp-offload.cc                            |   97 +-
 gcc/omp-simd-clone.cc                         |    4 +-
 gcc/passes.cc                                 |    3 +-
 gcc/symtab.cc                                 |    2 +-
 .../c-c++-common/gomp/attrs-metadirective-1.c |   47 +
 .../c-c++-common/gomp/attrs-metadirective-2.c |   76 +
 .../c-c++-common/gomp/attrs-metadirective-3.c |   24 +
 .../c-c++-common/gomp/attrs-metadirective-4.c |   43 +
 .../c-c++-common/gomp/attrs-metadirective-5.c |   26 +
 .../c-c++-common/gomp/attrs-metadirective-6.c |   33 +
 .../c-c++-common/gomp/attrs-metadirective-7.c |   37 +
 .../c-c++-common/gomp/attrs-metadirective-8.c |   18 +
 .../gomp/declare-target-indirect-2.c          |   10 +-
 .../c-c++-common/gomp/declare-variant-12.c    |   14 +-
 .../c-c++-common/gomp/declare-variant-13.c    |    6 +-
 .../c-c++-common/gomp/declare-variant-14.c    |    2 +-
 .../c-c++-common/gomp/declare-variant-2.c     |    4 +-
 .../c-c++-common/gomp/declare-variant-8.c     |    4 +-
 .../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       |   58 +
 .../c-c++-common/gomp/metadirective-2.c       |   75 +
 .../c-c++-common/gomp/metadirective-3.c       |   23 +
 .../c-c++-common/gomp/metadirective-4.c       |   42 +
 .../c-c++-common/gomp/metadirective-5.c       |   25 +
 .../c-c++-common/gomp/metadirective-6.c       |   32 +
 .../c-c++-common/gomp/metadirective-7.c       |   36 +
 .../c-c++-common/gomp/metadirective-8.c       |   17 +
 .../gomp/metadirective-construct.c            |  178 ++
 .../c-c++-common/gomp/metadirective-device.c  |  149 ++
 .../gomp/metadirective-no-score.c             |   95 +
 .../gomp/metadirective-target-device.c        |  149 ++
 .../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 +
 .../g++.dg/gomp/metadirective-template-1.C    |   74 +
 gcc/testsuite/gcc.dg/gomp/metadirective-1.c   |   15 +
 .../gfortran.dg/gomp/declare-variant-12.f90   |   14 +-
 .../gfortran.dg/gomp/declare-variant-13.f90   |   25 +-
 .../gfortran.dg/gomp/declare-variant-14.f90   |   28 +-
 .../gfortran.dg/gomp/declare-variant-8.f90    |   12 +-
 .../gfortran.dg/gomp/metadirective-1.f90      |   80 +
 .../gfortran.dg/gomp/metadirective-10.f90     |   40 +
 .../gfortran.dg/gomp/metadirective-11.f90     |   33 +
 .../gfortran.dg/gomp/metadirective-12.f90     |   18 +
 .../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      |   37 +
 .../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                               |    1 +
 gcc/tree-inline.cc                            |   15 +-
 gcc/tree-pretty-print.cc                      |   81 +
 gcc/tree-ssa-operands.cc                      |    4 +
 gcc/tree.def                                  |   34 +
 gcc/tree.h                                    |   22 +
 libgomp/libgomp.texi                          |   21 +-
 .../libgomp.c++/metadirective-template-1.C    |   39 +
 .../libgomp.c++/metadirective-template-2.C    |   43 +
 .../libgomp.c++/metadirective-template-3.C    |   43 +
 .../libgomp.c-c++-common/metadirective-1.c    |   37 +
 .../libgomp.c-c++-common/metadirective-2.c    |   43 +
 .../libgomp.c-c++-common/metadirective-3.c    |   36 +
 .../libgomp.c-c++-common/metadirective-4.c    |   54 +
 .../libgomp.c-c++-common/metadirective-5.c    |   48 +
 .../metadirective-late-1.c                    |   66 +
 .../metadirective-late-2.c                    |   66 +
 .../metadirective-target-device.c             |   76 +
 .../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 +
 132 files changed, 7450 insertions(+), 1667 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-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/g++.dg/gomp/metadirective-template-1.C
 create mode 100644 gcc/testsuite/gcc.dg/gomp/metadirective-1.c
 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-12.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/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-late-1.c
 create mode 100644 
libgomp/testsuite/libgomp.c-c++-common/metadirective-late-2.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

Reply via email to