diff options
author | Johannes Doerfert <johannes@jdoerfert.de> | 2020-03-30 00:57:28 -0500 |
---|---|---|
committer | Johannes Doerfert <johannes@jdoerfert.de> | 2020-04-06 00:04:08 -0500 |
commit | 931c0cd713ee9b082389727bed1b518c6a44344f (patch) | |
tree | f7fb84eb6a362a550fe0f92b43480c1dfe3f1be6 /clang/lib/Basic/OpenMPKinds.cpp | |
parent | 8ea07f62a6f06bdb7da981425227995423867a4d (diff) | |
download | llvm-931c0cd713ee9b082389727bed1b518c6a44344f.zip llvm-931c0cd713ee9b082389727bed1b518c6a44344f.tar.gz llvm-931c0cd713ee9b082389727bed1b518c6a44344f.tar.bz2 |
[OpenMP][NFC] Move and simplify directive -> allowed clause mapping
Move the listing of allowed clauses per OpenMP directive to the new
macro file in `llvm/Frontend/OpenMP`. Also, use a single generic macro
that specifies the directive and one allowed clause explicitly instead
of a dedicated macro per directive.
We save 800 loc and boilerplate for all new directives/clauses with no
functional change. We also need to include the macro file only once and
not once per directive.
Depends on D77112.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D77113
Diffstat (limited to 'clang/lib/Basic/OpenMPKinds.cpp')
-rw-r--r-- | clang/lib/Basic/OpenMPKinds.cpp | 575 |
1 files changed, 0 insertions, 575 deletions
diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp index 981bd7a..888666b 100644 --- a/clang/lib/Basic/OpenMPKinds.cpp +++ b/clang/lib/Basic/OpenMPKinds.cpp @@ -425,581 +425,6 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, llvm_unreachable("Invalid OpenMP simple clause kind"); } -bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind, - OpenMPClauseKind CKind, - unsigned OpenMPVersion) { - assert(unsigned(DKind) <= unsigned(OMPD_unknown)); - assert(CKind <= OMPC_unknown); - // Nontemporal clause is not supported in OpenMP < 5.0. - if (OpenMPVersion < 50 && CKind == OMPC_nontemporal) - return false; - // Order clause is not supported in OpenMP < 5.0. - if (OpenMPVersion < 50 && CKind == OMPC_order) - return false; - switch (DKind) { - case OMPD_parallel: - switch (CKind) { -#define OPENMP_PARALLEL_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_simd: - if (OpenMPVersion < 50 && CKind == OMPC_if) - return false; - switch (CKind) { -#define OPENMP_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_for: - switch (CKind) { -#define OPENMP_FOR_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_for_simd: - if (OpenMPVersion < 50 && CKind == OMPC_if) - return false; - switch (CKind) { -#define OPENMP_FOR_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_sections: - switch (CKind) { -#define OPENMP_SECTIONS_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_single: - switch (CKind) { -#define OPENMP_SINGLE_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_parallel_for: - switch (CKind) { -#define OPENMP_PARALLEL_FOR_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_parallel_for_simd: - switch (CKind) { -#define OPENMP_PARALLEL_FOR_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_parallel_master: - switch (CKind) { -#define OPENMP_PARALLEL_MASTER_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_parallel_sections: - switch (CKind) { -#define OPENMP_PARALLEL_SECTIONS_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_task: - if (OpenMPVersion < 50 && CKind == OMPC_detach) - return false; - switch (CKind) { -#define OPENMP_TASK_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_flush: - if (CKind == OMPC_flush) - return true; - if (OpenMPVersion < 50) - return false; - switch (CKind) { -#define OPENMP_FLUSH_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_depobj: - if (OpenMPVersion < 50) - return false; - switch (CKind) { -#define OPENMP_DEPOBJ_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - case OMPC_depobj: - return true; - default: - break; - } - break; - case OMPD_scan: - if (OpenMPVersion < 50) - return false; - switch (CKind) { -#define OPENMP_SCAN_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_atomic: - if (OpenMPVersion < 50 && - (CKind == OMPC_acq_rel || CKind == OMPC_acquire || - CKind == OMPC_release || CKind == OMPC_relaxed || CKind == OMPC_hint)) - return false; - switch (CKind) { -#define OPENMP_ATOMIC_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target: - switch (CKind) { -#define OPENMP_TARGET_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_requires: - switch (CKind) { -#define OPENMP_REQUIRES_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_data: - switch (CKind) { -#define OPENMP_TARGET_DATA_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_enter_data: - switch (CKind) { -#define OPENMP_TARGET_ENTER_DATA_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_exit_data: - switch (CKind) { -#define OPENMP_TARGET_EXIT_DATA_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_parallel: - switch (CKind) { -#define OPENMP_TARGET_PARALLEL_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_parallel_for: - switch (CKind) { -#define OPENMP_TARGET_PARALLEL_FOR_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_update: - switch (CKind) { -#define OPENMP_TARGET_UPDATE_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_teams: - switch (CKind) { -#define OPENMP_TEAMS_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_cancel: - switch (CKind) { -#define OPENMP_CANCEL_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_ordered: - switch (CKind) { -#define OPENMP_ORDERED_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_taskloop: - switch (CKind) { -#define OPENMP_TASKLOOP_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_taskloop_simd: - switch (CKind) { -#define OPENMP_TASKLOOP_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_master_taskloop: - switch (CKind) { -#define OPENMP_MASTER_TASKLOOP_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_master_taskloop_simd: - switch (CKind) { -#define OPENMP_MASTER_TASKLOOP_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_parallel_master_taskloop: - switch (CKind) { -#define OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_parallel_master_taskloop_simd: - switch (CKind) { -#define OPENMP_PARALLEL_MASTER_TASKLOOP_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_critical: - switch (CKind) { -#define OPENMP_CRITICAL_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_distribute: - switch (CKind) { -#define OPENMP_DISTRIBUTE_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_distribute_parallel_for: - switch (CKind) { -#define OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_distribute_parallel_for_simd: - switch (CKind) { -#define OPENMP_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_distribute_simd: - if (OpenMPVersion < 50 && CKind == OMPC_if) - return false; - switch (CKind) { -#define OPENMP_DISTRIBUTE_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_parallel_for_simd: - switch (CKind) { -#define OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_simd: - switch (CKind) { -#define OPENMP_TARGET_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_teams_distribute: - switch (CKind) { -#define OPENMP_TEAMS_DISTRIBUTE_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_teams_distribute_simd: - if (OpenMPVersion < 50 && CKind == OMPC_if) - return false; - switch (CKind) { -#define OPENMP_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_teams_distribute_parallel_for_simd: - switch (CKind) { -#define OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_teams_distribute_parallel_for: - switch (CKind) { -#define OPENMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_teams: - switch (CKind) { -#define OPENMP_TARGET_TEAMS_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_teams_distribute: - switch (CKind) { -#define OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_teams_distribute_parallel_for: - switch (CKind) { -#define OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_teams_distribute_parallel_for_simd: - switch (CKind) { -#define OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_target_teams_distribute_simd: - switch (CKind) { -#define OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_taskgroup: - switch (CKind) { -#define OPENMP_TASKGROUP_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_declare_mapper: - switch (CKind) { -#define OPENMP_DECLARE_MAPPER_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_allocate: - switch (CKind) { -#define OPENMP_ALLOCATE_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_declare_variant: - switch (CKind) { -#define OPENMP_DECLARE_VARIANT_CLAUSE(Name) \ - case OMPC_##Name: \ - return true; -#include "clang/Basic/OpenMPKinds.def" - default: - break; - } - break; - case OMPD_begin_declare_variant: - case OMPD_end_declare_variant: - case OMPD_declare_target: - case OMPD_end_declare_target: - case OMPD_unknown: - case OMPD_threadprivate: - case OMPD_section: - case OMPD_master: - case OMPD_taskyield: - case OMPD_barrier: - case OMPD_taskwait: - case OMPD_cancellation_point: - case OMPD_declare_reduction: - case OMPD_declare_simd: - break; - } - return false; -} - bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) { return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd || DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd || |