|
| 1 | +//===-- include/flang/Semantics/openmp-directive-sets.h ---------*- C++ -*-===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | + |
| 9 | +#ifndef FORTRAN_SEMANTICS_OPENMP_DIRECTIVE_SETS_H_ |
| 10 | +#define FORTRAN_SEMANTICS_OPENMP_DIRECTIVE_SETS_H_ |
| 11 | + |
| 12 | +#include "flang/Common/enum-set.h" |
| 13 | +#include "llvm/Frontend/OpenMP/OMPConstants.h" |
| 14 | + |
| 15 | +using OmpDirectiveSet = Fortran::common::EnumSet<llvm::omp::Directive, |
| 16 | + llvm::omp::Directive_enumSize>; |
| 17 | + |
| 18 | +namespace llvm::omp { |
| 19 | +//===----------------------------------------------------------------------===// |
| 20 | +// Directive sets for single directives |
| 21 | +//===----------------------------------------------------------------------===// |
| 22 | +// - top<Directive>Set: The directive appears alone or as the first in a |
| 23 | +// combined construct. |
| 24 | +// - all<Directive>Set: All standalone or combined uses of the directive. |
| 25 | + |
| 26 | +const inline OmpDirectiveSet topParallelSet{ |
| 27 | + Directive::OMPD_parallel, |
| 28 | + Directive::OMPD_parallel_do, |
| 29 | + Directive::OMPD_parallel_do_simd, |
| 30 | + Directive::OMPD_parallel_sections, |
| 31 | + Directive::OMPD_parallel_workshare, |
| 32 | +}; |
| 33 | + |
| 34 | +const inline OmpDirectiveSet allParallelSet{ |
| 35 | + Directive::OMPD_distribute_parallel_do, |
| 36 | + Directive::OMPD_distribute_parallel_do_simd, |
| 37 | + Directive::OMPD_parallel, |
| 38 | + Directive::OMPD_parallel_do, |
| 39 | + Directive::OMPD_parallel_do_simd, |
| 40 | + Directive::OMPD_parallel_sections, |
| 41 | + Directive::OMPD_parallel_workshare, |
| 42 | + Directive::OMPD_target_parallel, |
| 43 | + Directive::OMPD_target_parallel_do, |
| 44 | + Directive::OMPD_target_parallel_do_simd, |
| 45 | + Directive::OMPD_target_teams_distribute_parallel_do, |
| 46 | + Directive::OMPD_target_teams_distribute_parallel_do_simd, |
| 47 | + Directive::OMPD_teams_distribute_parallel_do, |
| 48 | + Directive::OMPD_teams_distribute_parallel_do_simd, |
| 49 | +}; |
| 50 | + |
| 51 | +const inline OmpDirectiveSet topDoSet{ |
| 52 | + Directive::OMPD_do, |
| 53 | + Directive::OMPD_do_simd, |
| 54 | +}; |
| 55 | + |
| 56 | +const inline OmpDirectiveSet allDoSet{ |
| 57 | + Directive::OMPD_distribute_parallel_do, |
| 58 | + Directive::OMPD_distribute_parallel_do_simd, |
| 59 | + Directive::OMPD_parallel_do, |
| 60 | + Directive::OMPD_parallel_do_simd, |
| 61 | + Directive::OMPD_do, |
| 62 | + Directive::OMPD_do_simd, |
| 63 | + Directive::OMPD_target_parallel_do, |
| 64 | + Directive::OMPD_target_parallel_do_simd, |
| 65 | + Directive::OMPD_target_teams_distribute_parallel_do, |
| 66 | + Directive::OMPD_target_teams_distribute_parallel_do_simd, |
| 67 | + Directive::OMPD_teams_distribute_parallel_do, |
| 68 | + Directive::OMPD_teams_distribute_parallel_do_simd, |
| 69 | +}; |
| 70 | + |
| 71 | +const inline OmpDirectiveSet topTaskloopSet{ |
| 72 | + Directive::OMPD_taskloop, |
| 73 | + Directive::OMPD_taskloop_simd, |
| 74 | +}; |
| 75 | + |
| 76 | +const inline OmpDirectiveSet allTaskloopSet = topTaskloopSet; |
| 77 | + |
| 78 | +const inline OmpDirectiveSet topTargetSet{ |
| 79 | + Directive::OMPD_target, |
| 80 | + Directive::OMPD_target_parallel, |
| 81 | + Directive::OMPD_target_parallel_do, |
| 82 | + Directive::OMPD_target_parallel_do_simd, |
| 83 | + Directive::OMPD_target_simd, |
| 84 | + Directive::OMPD_target_teams, |
| 85 | + Directive::OMPD_target_teams_distribute, |
| 86 | + Directive::OMPD_target_teams_distribute_parallel_do, |
| 87 | + Directive::OMPD_target_teams_distribute_parallel_do_simd, |
| 88 | + Directive::OMPD_target_teams_distribute_simd, |
| 89 | +}; |
| 90 | + |
| 91 | +const inline OmpDirectiveSet allTargetSet = topTargetSet; |
| 92 | + |
| 93 | +const inline OmpDirectiveSet topSimdSet{ |
| 94 | + Directive::OMPD_simd, |
| 95 | +}; |
| 96 | + |
| 97 | +const inline OmpDirectiveSet allSimdSet{ |
| 98 | + Directive::OMPD_distribute_parallel_do_simd, |
| 99 | + Directive::OMPD_distribute_simd, |
| 100 | + Directive::OMPD_do_simd, |
| 101 | + Directive::OMPD_parallel_do_simd, |
| 102 | + Directive::OMPD_simd, |
| 103 | + Directive::OMPD_target_parallel_do_simd, |
| 104 | + Directive::OMPD_target_simd, |
| 105 | + Directive::OMPD_target_teams_distribute_parallel_do_simd, |
| 106 | + Directive::OMPD_target_teams_distribute_simd, |
| 107 | + Directive::OMPD_taskloop_simd, |
| 108 | + Directive::OMPD_teams_distribute_parallel_do_simd, |
| 109 | + Directive::OMPD_teams_distribute_simd, |
| 110 | +}; |
| 111 | + |
| 112 | +const inline OmpDirectiveSet topTeamsSet{ |
| 113 | + Directive::OMPD_teams, |
| 114 | + Directive::OMPD_teams_distribute, |
| 115 | + Directive::OMPD_teams_distribute_parallel_do, |
| 116 | + Directive::OMPD_teams_distribute_parallel_do_simd, |
| 117 | + Directive::OMPD_teams_distribute_simd, |
| 118 | +}; |
| 119 | + |
| 120 | +const inline OmpDirectiveSet allTeamsSet{ |
| 121 | + llvm::omp::OMPD_target_teams, |
| 122 | + llvm::omp::OMPD_target_teams_distribute, |
| 123 | + llvm::omp::OMPD_target_teams_distribute_parallel_do, |
| 124 | + llvm::omp::OMPD_target_teams_distribute_parallel_do_simd, |
| 125 | + llvm::omp::OMPD_target_teams_distribute_simd, |
| 126 | + llvm::omp::OMPD_teams, |
| 127 | + llvm::omp::OMPD_teams_distribute, |
| 128 | + llvm::omp::OMPD_teams_distribute_parallel_do, |
| 129 | + llvm::omp::OMPD_teams_distribute_parallel_do_simd, |
| 130 | + llvm::omp::OMPD_teams_distribute_simd, |
| 131 | +}; |
| 132 | + |
| 133 | +const inline OmpDirectiveSet topDistributeSet{ |
| 134 | + Directive::OMPD_distribute, |
| 135 | + Directive::OMPD_distribute_parallel_do, |
| 136 | + Directive::OMPD_distribute_parallel_do_simd, |
| 137 | + Directive::OMPD_distribute_simd, |
| 138 | +}; |
| 139 | + |
| 140 | +const inline OmpDirectiveSet allDistributeSet{ |
| 141 | + llvm::omp::OMPD_distribute, |
| 142 | + llvm::omp::OMPD_distribute_parallel_do, |
| 143 | + llvm::omp::OMPD_distribute_parallel_do_simd, |
| 144 | + llvm::omp::OMPD_distribute_simd, |
| 145 | + llvm::omp::OMPD_target_teams_distribute, |
| 146 | + llvm::omp::OMPD_target_teams_distribute_parallel_do, |
| 147 | + llvm::omp::OMPD_target_teams_distribute_parallel_do_simd, |
| 148 | + llvm::omp::OMPD_target_teams_distribute_simd, |
| 149 | + llvm::omp::OMPD_teams_distribute, |
| 150 | + llvm::omp::OMPD_teams_distribute_parallel_do, |
| 151 | + llvm::omp::OMPD_teams_distribute_parallel_do_simd, |
| 152 | + llvm::omp::OMPD_teams_distribute_simd, |
| 153 | +}; |
| 154 | + |
| 155 | +//===----------------------------------------------------------------------===// |
| 156 | +// Directive sets for groups of multiple directives |
| 157 | +//===----------------------------------------------------------------------===// |
| 158 | + |
| 159 | +const inline OmpDirectiveSet allDoSimdSet = allDoSet & allSimdSet; |
| 160 | + |
| 161 | +const inline OmpDirectiveSet workShareSet{ |
| 162 | + OmpDirectiveSet{ |
| 163 | + Directive::OMPD_workshare, |
| 164 | + Directive::OMPD_parallel_workshare, |
| 165 | + Directive::OMPD_parallel_sections, |
| 166 | + Directive::OMPD_sections, |
| 167 | + Directive::OMPD_single, |
| 168 | + } | allDoSet, |
| 169 | +}; |
| 170 | + |
| 171 | +const inline OmpDirectiveSet taskGeneratingSet{ |
| 172 | + OmpDirectiveSet{ |
| 173 | + Directive::OMPD_task, |
| 174 | + } | allTaskloopSet, |
| 175 | +}; |
| 176 | + |
| 177 | +const inline OmpDirectiveSet nonPartialVarSet{ |
| 178 | + Directive::OMPD_allocate, |
| 179 | + Directive::OMPD_allocators, |
| 180 | + Directive::OMPD_threadprivate, |
| 181 | + Directive::OMPD_declare_target, |
| 182 | +}; |
| 183 | + |
| 184 | +//===----------------------------------------------------------------------===// |
| 185 | +// Directive sets for allowed/not allowed nested directives |
| 186 | +//===----------------------------------------------------------------------===// |
| 187 | + |
| 188 | +const inline OmpDirectiveSet nestedOrderedErrSet{ |
| 189 | + Directive::OMPD_critical, |
| 190 | + Directive::OMPD_ordered, |
| 191 | + Directive::OMPD_atomic, |
| 192 | + Directive::OMPD_task, |
| 193 | + Directive::OMPD_taskloop, |
| 194 | +}; |
| 195 | + |
| 196 | +const inline OmpDirectiveSet nestedWorkshareErrSet{ |
| 197 | + OmpDirectiveSet{ |
| 198 | + Directive::OMPD_task, |
| 199 | + Directive::OMPD_taskloop, |
| 200 | + Directive::OMPD_critical, |
| 201 | + Directive::OMPD_ordered, |
| 202 | + Directive::OMPD_atomic, |
| 203 | + Directive::OMPD_master, |
| 204 | + } | workShareSet, |
| 205 | +}; |
| 206 | + |
| 207 | +const inline OmpDirectiveSet nestedMasterErrSet{ |
| 208 | + OmpDirectiveSet{ |
| 209 | + Directive::OMPD_atomic, |
| 210 | + } | taskGeneratingSet | |
| 211 | + workShareSet, |
| 212 | +}; |
| 213 | + |
| 214 | +const inline OmpDirectiveSet nestedBarrierErrSet{ |
| 215 | + OmpDirectiveSet{ |
| 216 | + Directive::OMPD_critical, |
| 217 | + Directive::OMPD_ordered, |
| 218 | + Directive::OMPD_atomic, |
| 219 | + Directive::OMPD_master, |
| 220 | + } | taskGeneratingSet | |
| 221 | + workShareSet, |
| 222 | +}; |
| 223 | + |
| 224 | +const inline OmpDirectiveSet nestedTeamsAllowedSet{ |
| 225 | + Directive::OMPD_parallel, |
| 226 | + Directive::OMPD_parallel_do, |
| 227 | + Directive::OMPD_parallel_do_simd, |
| 228 | + Directive::OMPD_parallel_master, |
| 229 | + Directive::OMPD_parallel_master_taskloop, |
| 230 | + Directive::OMPD_parallel_master_taskloop_simd, |
| 231 | + Directive::OMPD_parallel_sections, |
| 232 | + Directive::OMPD_parallel_workshare, |
| 233 | + Directive::OMPD_distribute, |
| 234 | + Directive::OMPD_distribute_parallel_do, |
| 235 | + Directive::OMPD_distribute_parallel_do_simd, |
| 236 | + Directive::OMPD_distribute_simd, |
| 237 | +}; |
| 238 | + |
| 239 | +const inline OmpDirectiveSet nestedOrderedParallelErrSet{ |
| 240 | + Directive::OMPD_parallel, |
| 241 | + Directive::OMPD_target_parallel, |
| 242 | + Directive::OMPD_parallel_sections, |
| 243 | + Directive::OMPD_parallel_workshare, |
| 244 | +}; |
| 245 | + |
| 246 | +const inline OmpDirectiveSet nestedOrderedDoAllowedSet{ |
| 247 | + Directive::OMPD_do, |
| 248 | + Directive::OMPD_parallel_do, |
| 249 | + Directive::OMPD_target_parallel_do, |
| 250 | +}; |
| 251 | + |
| 252 | +const inline OmpDirectiveSet nestedCancelTaskgroupAllowedSet{ |
| 253 | + Directive::OMPD_task, |
| 254 | + Directive::OMPD_taskloop, |
| 255 | +}; |
| 256 | + |
| 257 | +const inline OmpDirectiveSet nestedCancelSectionsAllowedSet{ |
| 258 | + Directive::OMPD_sections, |
| 259 | + Directive::OMPD_parallel_sections, |
| 260 | +}; |
| 261 | + |
| 262 | +const inline OmpDirectiveSet nestedCancelDoAllowedSet{ |
| 263 | + Directive::OMPD_do, |
| 264 | + Directive::OMPD_distribute_parallel_do, |
| 265 | + Directive::OMPD_parallel_do, |
| 266 | + Directive::OMPD_target_parallel_do, |
| 267 | + Directive::OMPD_target_teams_distribute_parallel_do, |
| 268 | + Directive::OMPD_teams_distribute_parallel_do, |
| 269 | +}; |
| 270 | + |
| 271 | +const inline OmpDirectiveSet nestedCancelParallelAllowedSet{ |
| 272 | + Directive::OMPD_parallel, |
| 273 | + Directive::OMPD_target_parallel, |
| 274 | +}; |
| 275 | + |
| 276 | +const inline OmpDirectiveSet nestedReduceWorkshareAllowedSet{ |
| 277 | + Directive::OMPD_do, |
| 278 | + Directive::OMPD_sections, |
| 279 | + Directive::OMPD_do_simd, |
| 280 | +}; |
| 281 | +} // namespace llvm::omp |
| 282 | + |
| 283 | +#endif // FORTRAN_SEMANTICS_OPENMP_DIRECTIVE_SETS_H_ |
0 commit comments