[OpenMP] Add match_{all,any,none} declare variant selector extensions.
authorJohannes Doerfert <johannes@jdoerfert.de>
Fri, 3 Apr 2020 16:29:53 +0000 (11:29 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Wed, 8 Apr 2020 04:33:24 +0000 (23:33 -0500)
commita19eb1de726c1ccbf60dca6a1fbcd49b3157282f
tree5eec3afb54bbe4866934202d9101c6274feca286
parent8f0aa3f3a407994314371ee042854a8c79cea462
[OpenMP] Add match_{all,any,none} declare variant selector extensions.

By default, all traits in the OpenMP context selector have to match for
it to be acceptable. Though, we sometimes want a single property out of
multiple to match (=any) or no match at all (=none). We offer these
choices as extensions via
  `implementation={extension(match_{all,any,none})}`
to the user. The choice will affect the entire context selector not only
the traits following the match property.

The first user will be D75788. There we can replace
```
  #pragma omp begin declare variant match(device={arch(nvptx64)})
  #define __CUDA__

  #include <__clang_cuda_cmath.h>

  // TODO: Hack until we support an extension to the match clause that allows "or".
  #undef __CLANG_CUDA_CMATH_H__

  #undef __CUDA__
  #pragma omp end declare variant

  #pragma omp begin declare variant match(device={arch(nvptx)})
  #define __CUDA__

  #include <__clang_cuda_cmath.h>

  #undef __CUDA__
  #pragma omp end declare variant
```
with the much simpler
```
  #pragma omp begin declare variant match(device={arch(nvptx, nvptx64)}, implementation={extension(match_any)})
  #define __CUDA__

  #include <__clang_cuda_cmath.h>

  #undef __CUDA__
  #pragma omp end declare variant
```

Reviewed By: mikerice

Differential Revision: https://reviews.llvm.org/D77414
13 files changed:
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/AST/OpenMPClause.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/AST/ast-dump-openmp-declare-variant-extensions-messages.c [new file with mode: 0644]
clang/test/AST/ast-dump-openmp-declare-variant-extensions.c [new file with mode: 0644]
clang/test/OpenMP/declare_variant_ast_print.c
clang/test/OpenMP/declare_variant_messages.c
llvm/include/llvm/Frontend/OpenMP/OMPContext.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPContext.cpp