| 1 | //===- ClauseT.h -- clause template definitions ---------------------------===// |
| 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 | // This file contains template classes that represent OpenMP clauses, as |
| 9 | // described in the OpenMP API specification. |
| 10 | // |
| 11 | // The general structure of any specific clause class is that it is either |
| 12 | // empty, or it consists of a single data member, which can take one of these |
| 13 | // three forms: |
| 14 | // - a value member, named `v`, or |
| 15 | // - a tuple of values, named `t`, or |
| 16 | // - a variant (i.e. union) of values, named `u`. |
| 17 | // To assist with generic visit algorithms, classes define one of the following |
| 18 | // traits: |
| 19 | // - EmptyTrait: the class has no data members. |
| 20 | // - WrapperTrait: the class has a single member `v` |
| 21 | // - TupleTrait: the class has a tuple member `t` |
| 22 | // - UnionTrait the class has a variant member `u` |
| 23 | // - IncompleteTrait: the class is a placeholder class that is currently empty, |
| 24 | // but will be completed at a later time. |
| 25 | // Note: This structure follows the one used in flang parser. |
| 26 | // |
| 27 | // The types used in the class definitions follow the names used in the spec |
| 28 | // (there are a few exceptions to this). For example, given |
| 29 | // Clause `foo` |
| 30 | // - foo-modifier : description... |
| 31 | // - list : list of variables |
| 32 | // the corresponding class would be |
| 33 | // template <...> |
| 34 | // struct FooT { |
| 35 | // using FooModifier = type that can represent the modifier |
| 36 | // using List = ListT<ObjectT<...>>; |
| 37 | // using TupleTrait = std::true_type; |
| 38 | // std::tuple<std::optional<FooModifier>, List> t; |
| 39 | // }; |
| 40 | //===----------------------------------------------------------------------===// |
| 41 | #ifndef LLVM_FRONTEND_OPENMP_CLAUSET_H |
| 42 | #define LLVM_FRONTEND_OPENMP_CLAUSET_H |
| 43 | |
| 44 | #include "llvm/ADT/ArrayRef.h" |
| 45 | #include "llvm/ADT/DenseMap.h" |
| 46 | #include "llvm/ADT/DenseSet.h" |
| 47 | #include "llvm/ADT/STLExtras.h" |
| 48 | #include "llvm/ADT/SmallVector.h" |
| 49 | #include "llvm/Frontend/OpenMP/OMP.h" |
| 50 | #include "llvm/Support/ErrorHandling.h" |
| 51 | #include "llvm/Support/raw_ostream.h" |
| 52 | |
| 53 | #include <iterator> |
| 54 | #include <optional> |
| 55 | #include <tuple> |
| 56 | #include <type_traits> |
| 57 | #include <utility> |
| 58 | #include <variant> |
| 59 | |
| 60 | #define ENUM(Name, ...) enum class Name { __VA_ARGS__ } |
| 61 | #define OPT(x) std::optional<x> |
| 62 | |
| 63 | // A number of OpenMP clauses contain values that come from a given set of |
| 64 | // possibilities. In the IR these are usually represented by enums. Both |
| 65 | // clang and flang use different types for the enums, and the enum elements |
| 66 | // representing the same thing may have different values between clang and |
| 67 | // flang. |
| 68 | // Since the representation below tries to adhere to the spec, and be source |
| 69 | // language agnostic, it defines its own enums, independent from any language |
| 70 | // frontend. As a consequence, when instantiating the templates below, |
| 71 | // frontend-specific enums need to be translated into the representation |
| 72 | // used here. The macros below are intended to assist with the conversion. |
| 73 | |
| 74 | // Helper macro for enum-class conversion. |
| 75 | #define CLAUSET_SCOPED_ENUM_MEMBER_CONVERT(Ov, Tv) \ |
| 76 | if (v == OtherEnum::Ov) { \ |
| 77 | return ThisEnum::Tv; \ |
| 78 | } |
| 79 | |
| 80 | // Helper macro for enum (non-class) conversion. |
| 81 | #define CLAUSET_UNSCOPED_ENUM_MEMBER_CONVERT(Ov, Tv) \ |
| 82 | if (v == Ov) { \ |
| 83 | return ThisEnum::Tv; \ |
| 84 | } |
| 85 | |
| 86 | #define CLAUSET_ENUM_CONVERT(func, OtherE, ThisE, Maps) \ |
| 87 | auto func = [](OtherE v) -> ThisE { \ |
| 88 | using ThisEnum = ThisE; \ |
| 89 | using OtherEnum = OtherE; \ |
| 90 | (void)sizeof(OtherEnum); /*Avoid "unused local typedef" warning*/ \ |
| 91 | Maps; \ |
| 92 | llvm_unreachable("Unexpected value in " #OtherE); \ |
| 93 | } |
| 94 | |
| 95 | // Usage: |
| 96 | // |
| 97 | // Given two enums, |
| 98 | // enum class Other { o1, o2 }; |
| 99 | // enum class This { t1, t2 }; |
| 100 | // generate conversion function "Func : Other -> This" with |
| 101 | // CLAUSET_ENUM_CONVERT( |
| 102 | // Func, Other, This, |
| 103 | // CLAUSET_ENUM_MEMBER_CONVERT(o1, t1) // <- No comma |
| 104 | // CLAUSET_ENUM_MEMBER_CONVERT(o2, t2) |
| 105 | // ... |
| 106 | // ) |
| 107 | // |
| 108 | // Note that the sequence of M(other-value, this-value) is separated |
| 109 | // with _spaces_, not commas. |
| 110 | |
| 111 | namespace detail { |
| 112 | // Type trait to determine whether T is a specialization of std::variant. |
| 113 | template <typename T> struct is_variant { |
| 114 | static constexpr bool value = false; |
| 115 | }; |
| 116 | |
| 117 | template <typename... Ts> struct is_variant<std::variant<Ts...>> { |
| 118 | static constexpr bool value = true; |
| 119 | }; |
| 120 | |
| 121 | template <typename T> constexpr bool is_variant_v = is_variant<T>::value; |
| 122 | |
| 123 | // Helper utility to create a type which is a union of two given variants. |
| 124 | template <typename...> struct UnionOfTwo; |
| 125 | |
| 126 | template <typename... Types1, typename... Types2> |
| 127 | struct UnionOfTwo<std::variant<Types1...>, std::variant<Types2...>> { |
| 128 | using type = std::variant<Types1..., Types2...>; |
| 129 | }; |
| 130 | } // namespace detail |
| 131 | |
| 132 | namespace tomp { |
| 133 | namespace type { |
| 134 | |
| 135 | // Helper utility to create a type which is a union of an arbitrary number |
| 136 | // of variants. |
| 137 | template <typename...> struct Union; |
| 138 | |
| 139 | template <> struct Union<> { |
| 140 | // Legal to define, illegal to instantiate. |
| 141 | using type = std::variant<>; |
| 142 | }; |
| 143 | |
| 144 | template <typename T, typename... Ts> struct Union<T, Ts...> { |
| 145 | static_assert(detail::is_variant_v<T>); |
| 146 | using type = |
| 147 | typename detail::UnionOfTwo<T, typename Union<Ts...>::type>::type; |
| 148 | }; |
| 149 | |
| 150 | template <typename T> using ListT = llvm::SmallVector<T, 0>; |
| 151 | |
| 152 | // The ObjectT class represents a variable or a locator (as defined in |
| 153 | // the OpenMP spec). |
| 154 | // Note: the ObjectT template is not defined. Any user of it is expected to |
| 155 | // provide their own specialization that conforms to the requirements listed |
| 156 | // below. |
| 157 | // |
| 158 | // Let ObjectS be any specialization of ObjectT: |
| 159 | // |
| 160 | // ObjectS must provide the following definitions: |
| 161 | // { |
| 162 | // using IdTy = Id; |
| 163 | // using ExprTy = Expr; |
| 164 | // |
| 165 | // auto id() const -> IdTy { |
| 166 | // // Return a value such that a.id() == b.id() if and only if: |
| 167 | // // (1) both `a` and `b` represent the same variable or location, or |
| 168 | // // (2) bool(a.id()) == false and bool(b.id()) == false |
| 169 | // } |
| 170 | // } |
| 171 | // |
| 172 | // The type IdTy should be hashable (usable as key in unordered containers). |
| 173 | // |
| 174 | // Values of type IdTy should be contextually convertible to `bool`. |
| 175 | // |
| 176 | // If S is an object of type ObjectS, then `bool(S.id())` is `false` if |
| 177 | // and only if S does not represent any variable or location. |
| 178 | // |
| 179 | // ObjectS should be copyable, movable, and default-constructible. |
| 180 | template <typename IdType, typename ExprType> struct ObjectT; |
| 181 | |
| 182 | // By default, object equality is only determined by its identity. |
| 183 | template <typename I, typename E> |
| 184 | bool operator==(const ObjectT<I, E> &o1, const ObjectT<I, E> &o2) { |
| 185 | return o1.id() == o2.id(); |
| 186 | } |
| 187 | |
| 188 | template <typename I, typename E> using ObjectListT = ListT<ObjectT<I, E>>; |
| 189 | |
| 190 | using DirectiveName = llvm::omp::Directive; |
| 191 | |
| 192 | template <typename I, typename E> // |
| 193 | struct StylizedInstanceT { |
| 194 | using Variables = ObjectListT<I, E>; |
| 195 | using Instance = E; |
| 196 | using TupleTrait = std::true_type; |
| 197 | std::tuple<Variables, Instance> t; |
| 198 | }; |
| 199 | |
| 200 | template <typename I, typename E> // |
| 201 | struct IntrinsicOperatorT { |
| 202 | ENUM(Operator, Power, Multiply, Divide, Add, Subtract, Concat, LT, LE, EQ, NE, |
| 203 | GE, GT, NOT, AND, OR, EQV, NEQV, Min, Max); |
| 204 | using WrapperTrait = std::true_type; |
| 205 | Operator v; |
| 206 | }; |
| 207 | |
| 208 | template <typename I, typename E> // |
| 209 | struct DefinedOperatorT { |
| 210 | struct DefinedOpName { |
| 211 | using WrapperTrait = std::true_type; |
| 212 | ObjectT<I, E> v; |
| 213 | }; |
| 214 | using UnionTrait = std::true_type; |
| 215 | std::variant<DefinedOpName, IntrinsicOperatorT<I, E>> u; |
| 216 | }; |
| 217 | |
| 218 | // V5.2: [3.2.6] `iterator` modifier |
| 219 | template <typename E> // |
| 220 | struct RangeT { |
| 221 | // range-specification: begin : end[: step] |
| 222 | using TupleTrait = std::true_type; |
| 223 | std::tuple<E, E, OPT(E)> t; |
| 224 | }; |
| 225 | |
| 226 | // V5.2: [3.2.6] `iterator` modifier |
| 227 | template <typename TypeType, typename IdType, typename ExprType> // |
| 228 | struct IteratorSpecifierT { |
| 229 | // iterators-specifier: [ iterator-type ] identifier = range-specification |
| 230 | using TupleTrait = std::true_type; |
| 231 | std::tuple<OPT(TypeType), ObjectT<IdType, ExprType>, RangeT<ExprType>> t; |
| 232 | }; |
| 233 | |
| 234 | // Note: |
| 235 | // For motion or map clauses the OpenMP spec allows a unique mapper modifier. |
| 236 | // In practice, since these clauses apply to multiple objects, there can be |
| 237 | // multiple effective mappers applicable to these objects (due to overloads, |
| 238 | // etc.). Because of that store a list of mappers every time a mapper modifier |
| 239 | // is allowed. If the mapper list contains a single element, it applies to |
| 240 | // all objects in the clause, otherwise there should be as many mappers as |
| 241 | // there are objects. |
| 242 | // V5.2: [5.8.2] Mapper identifiers and `mapper` modifiers |
| 243 | template <typename I, typename E> // |
| 244 | struct MapperT { |
| 245 | using MapperIdentifier = ObjectT<I, E>; |
| 246 | using WrapperTrait = std::true_type; |
| 247 | MapperIdentifier v; |
| 248 | }; |
| 249 | |
| 250 | // V5.2: [15.8.1] `memory-order` clauses |
| 251 | // When used as arguments for other clauses, e.g. `fail`. |
| 252 | ENUM(MemoryOrder, AcqRel, Acquire, Relaxed, Release, SeqCst); |
| 253 | ENUM(MotionExpectation, Present); |
| 254 | // Union of `dependence-type` and `task-depenence-type`. |
| 255 | // V5.2: [15.9.1] `task-dependence-type` modifier |
| 256 | ENUM(DependenceType, Depobj, In, Inout, Inoutset, Mutexinoutset, Out, Sink, |
| 257 | Source); |
| 258 | ENUM(Prescriptiveness, Strict); |
| 259 | |
| 260 | template <typename I, typename E> // |
| 261 | struct LoopIterationT { |
| 262 | struct Distance { |
| 263 | using TupleTrait = std::true_type; |
| 264 | std::tuple<IntrinsicOperatorT<I, E>, E> t; |
| 265 | }; |
| 266 | using TupleTrait = std::true_type; |
| 267 | std::tuple<ObjectT<I, E>, OPT(Distance)> t; |
| 268 | }; |
| 269 | |
| 270 | template <typename I, typename E> // |
| 271 | struct ProcedureDesignatorT { |
| 272 | using WrapperTrait = std::true_type; |
| 273 | ObjectT<I, E> v; |
| 274 | }; |
| 275 | |
| 276 | // Note: |
| 277 | // For reduction clauses the OpenMP spec allows a unique reduction identifier. |
| 278 | // For reasons analogous to those listed for the MapperT type, clauses that |
| 279 | // according to the spec contain a reduction identifier will contain a list of |
| 280 | // reduction identifiers. The same constraints apply: there is either a single |
| 281 | // identifier that applies to all objects, or there are as many identifiers |
| 282 | // as there are objects. |
| 283 | template <typename I, typename E> // |
| 284 | struct ReductionIdentifierT { |
| 285 | using UnionTrait = std::true_type; |
| 286 | std::variant<DefinedOperatorT<I, E>, ProcedureDesignatorT<I, E>> u; |
| 287 | }; |
| 288 | |
| 289 | template <typename T, typename I, typename E> // |
| 290 | using IteratorT = ListT<IteratorSpecifierT<T, I, E>>; |
| 291 | |
| 292 | template <typename T> |
| 293 | std::enable_if_t<T::EmptyTrait::value, bool> operator==(const T &a, |
| 294 | const T &b) { |
| 295 | return true; |
| 296 | } |
| 297 | template <typename T> |
| 298 | std::enable_if_t<T::IncompleteTrait::value, bool> operator==(const T &a, |
| 299 | const T &b) { |
| 300 | return true; |
| 301 | } |
| 302 | template <typename T> |
| 303 | std::enable_if_t<T::WrapperTrait::value, bool> operator==(const T &a, |
| 304 | const T &b) { |
| 305 | return a.v == b.v; |
| 306 | } |
| 307 | template <typename T> |
| 308 | std::enable_if_t<T::TupleTrait::value, bool> operator==(const T &a, |
| 309 | const T &b) { |
| 310 | return a.t == b.t; |
| 311 | } |
| 312 | template <typename T> |
| 313 | std::enable_if_t<T::UnionTrait::value, bool> operator==(const T &a, |
| 314 | const T &b) { |
| 315 | return a.u == b.u; |
| 316 | } |
| 317 | } // namespace type |
| 318 | |
| 319 | template <typename T> using ListT = type::ListT<T>; |
| 320 | |
| 321 | template <typename I, typename E> using ObjectT = type::ObjectT<I, E>; |
| 322 | template <typename I, typename E> using ObjectListT = type::ObjectListT<I, E>; |
| 323 | |
| 324 | template <typename T, typename I, typename E> |
| 325 | using IteratorT = type::IteratorT<T, I, E>; |
| 326 | |
| 327 | template < |
| 328 | typename ContainerTy, typename FunctionTy, |
| 329 | typename ElemTy = typename llvm::remove_cvref_t<ContainerTy>::value_type, |
| 330 | typename ResultTy = std::invoke_result_t<FunctionTy, ElemTy>> |
| 331 | ListT<ResultTy> makeList(ContainerTy &&container, FunctionTy &&func) { |
| 332 | ListT<ResultTy> v; |
| 333 | llvm::transform(container, std::back_inserter(v), func); |
| 334 | return v; |
| 335 | } |
| 336 | |
| 337 | namespace clause { |
| 338 | using type::operator==; |
| 339 | |
| 340 | // V5.2: [8.3.1] `assumption` clauses |
| 341 | template <typename T, typename I, typename E> // |
| 342 | struct AbsentT { |
| 343 | using List = ListT<type::DirectiveName>; |
| 344 | using WrapperTrait = std::true_type; |
| 345 | List v; |
| 346 | }; |
| 347 | |
| 348 | // V5.2: [15.8.1] `memory-order` clauses |
| 349 | template <typename T, typename I, typename E> // |
| 350 | struct AcqRelT { |
| 351 | using EmptyTrait = std::true_type; |
| 352 | }; |
| 353 | |
| 354 | // V5.2: [15.8.1] `memory-order` clauses |
| 355 | template <typename T, typename I, typename E> // |
| 356 | struct AcquireT { |
| 357 | using EmptyTrait = std::true_type; |
| 358 | }; |
| 359 | |
| 360 | // V5.2: [7.5.2] `adjust_args` clause |
| 361 | template <typename T, typename I, typename E> // |
| 362 | struct AdjustArgsT { |
| 363 | using IncompleteTrait = std::true_type; |
| 364 | }; |
| 365 | |
| 366 | // V5.2: [12.5.1] `affinity` clause |
| 367 | template <typename T, typename I, typename E> // |
| 368 | struct AffinityT { |
| 369 | using Iterator = type::IteratorT<T, I, E>; |
| 370 | using LocatorList = ObjectListT<I, E>; |
| 371 | |
| 372 | using TupleTrait = std::true_type; |
| 373 | std::tuple<OPT(Iterator), LocatorList> t; |
| 374 | }; |
| 375 | |
| 376 | // V5.2: [6.3] `align` clause |
| 377 | template <typename T, typename I, typename E> // |
| 378 | struct AlignT { |
| 379 | using Alignment = E; |
| 380 | |
| 381 | using WrapperTrait = std::true_type; |
| 382 | Alignment v; |
| 383 | }; |
| 384 | |
| 385 | // V5.2: [5.11] `aligned` clause |
| 386 | template <typename T, typename I, typename E> // |
| 387 | struct AlignedT { |
| 388 | using Alignment = E; |
| 389 | using List = ObjectListT<I, E>; |
| 390 | |
| 391 | using TupleTrait = std::true_type; |
| 392 | std::tuple<OPT(Alignment), List> t; |
| 393 | }; |
| 394 | |
| 395 | template <typename T, typename I, typename E> // |
| 396 | struct AllocatorT; |
| 397 | |
| 398 | // V5.2: [6.6] `allocate` clause |
| 399 | template <typename T, typename I, typename E> // |
| 400 | struct AllocateT { |
| 401 | // AllocatorSimpleModifier is same as AllocatorComplexModifier. |
| 402 | using AllocatorComplexModifier = AllocatorT<T, I, E>; |
| 403 | using AlignModifier = AlignT<T, I, E>; |
| 404 | using List = ObjectListT<I, E>; |
| 405 | |
| 406 | using TupleTrait = std::true_type; |
| 407 | std::tuple<OPT(AllocatorComplexModifier), OPT(AlignModifier), List> t; |
| 408 | }; |
| 409 | |
| 410 | // V5.2: [6.4] `allocator` clause |
| 411 | template <typename T, typename I, typename E> // |
| 412 | struct AllocatorT { |
| 413 | using Allocator = E; |
| 414 | using WrapperTrait = std::true_type; |
| 415 | Allocator v; |
| 416 | }; |
| 417 | |
| 418 | // V5.2: [7.5.3] `append_args` clause |
| 419 | template <typename T, typename I, typename E> // |
| 420 | struct AppendArgsT { |
| 421 | using IncompleteTrait = std::true_type; |
| 422 | }; |
| 423 | |
| 424 | // [6.0:372-373] |
| 425 | template <typename T, typename I, typename E> // |
| 426 | struct ApplyT { |
| 427 | using IncompleteTrait = std::true_type; |
| 428 | }; |
| 429 | |
| 430 | // V5.2: [8.1] `at` clause |
| 431 | template <typename T, typename I, typename E> // |
| 432 | struct AtT { |
| 433 | ENUM(ActionTime, Compilation, Execution); |
| 434 | using WrapperTrait = std::true_type; |
| 435 | ActionTime v; |
| 436 | }; |
| 437 | |
| 438 | // V5.2: [8.2.1] `requirement` clauses |
| 439 | template <typename T, typename I, typename E> // |
| 440 | struct AtomicDefaultMemOrderT { |
| 441 | using MemoryOrder = type::MemoryOrder; |
| 442 | using WrapperTrait = std::true_type; |
| 443 | MemoryOrder v; // Name not provided in spec |
| 444 | }; |
| 445 | |
| 446 | // V5.2: [11.7.1] `bind` clause |
| 447 | template <typename T, typename I, typename E> // |
| 448 | struct BindT { |
| 449 | ENUM(Binding, Teams, Parallel, Thread); |
| 450 | using WrapperTrait = std::true_type; |
| 451 | Binding v; |
| 452 | }; |
| 453 | |
| 454 | // V5.2: [15.8.3] `extended-atomic` clauses |
| 455 | template <typename T, typename I, typename E> // |
| 456 | struct CaptureT { |
| 457 | using EmptyTrait = std::true_type; |
| 458 | }; |
| 459 | |
| 460 | // V5.2: [4.4.3] `collapse` clause |
| 461 | template <typename T, typename I, typename E> // |
| 462 | struct CollapseT { |
| 463 | using N = E; |
| 464 | using WrapperTrait = std::true_type; |
| 465 | N v; |
| 466 | }; |
| 467 | |
| 468 | // [6.0:266] |
| 469 | template <typename T, typename I, typename E> // |
| 470 | struct CollectorT { |
| 471 | using IncompleteTrait = std::true_type; |
| 472 | }; |
| 473 | |
| 474 | // [6.0:262] |
| 475 | template <typename T, typename I, typename E> // |
| 476 | struct CombinerT { |
| 477 | using List = ListT<type::StylizedInstanceT<I, E>>; |
| 478 | using WrapperTrait = std::true_type; |
| 479 | List v; |
| 480 | }; |
| 481 | |
| 482 | // V5.2: [15.8.3] `extended-atomic` clauses |
| 483 | template <typename T, typename I, typename E> // |
| 484 | struct CompareT { |
| 485 | using EmptyTrait = std::true_type; |
| 486 | }; |
| 487 | |
| 488 | // V5.2: [8.3.1] `assumption` clauses |
| 489 | template <typename T, typename I, typename E> // |
| 490 | struct ContainsT { |
| 491 | using List = ListT<type::DirectiveName>; |
| 492 | using WrapperTrait = std::true_type; |
| 493 | List v; |
| 494 | }; |
| 495 | |
| 496 | // V5.2: [5.7.1] `copyin` clause |
| 497 | template <typename T, typename I, typename E> // |
| 498 | struct CopyinT { |
| 499 | using List = ObjectListT<I, E>; |
| 500 | using WrapperTrait = std::true_type; |
| 501 | List v; |
| 502 | }; |
| 503 | |
| 504 | // V5.2: [5.7.2] `copyprivate` clause |
| 505 | template <typename T, typename I, typename E> // |
| 506 | struct CopyprivateT { |
| 507 | using List = ObjectListT<I, E>; |
| 508 | using WrapperTrait = std::true_type; |
| 509 | List v; |
| 510 | }; |
| 511 | |
| 512 | // [6.0:378-379] |
| 513 | template <typename T, typename I, typename E> // |
| 514 | struct CountsT { |
| 515 | using IncompleteTrait = std::true_type; |
| 516 | }; |
| 517 | |
| 518 | // V5.2: [5.4.1] `default` clause |
| 519 | template <typename T, typename I, typename E> // |
| 520 | struct DefaultT { |
| 521 | ENUM(DataSharingAttribute, Firstprivate, None, Private, Shared); |
| 522 | using WrapperTrait = std::true_type; |
| 523 | DataSharingAttribute v; |
| 524 | }; |
| 525 | |
| 526 | // V5.2: [5.8.7] `defaultmap` clause |
| 527 | template <typename T, typename I, typename E> // |
| 528 | struct DefaultmapT { |
| 529 | ENUM(ImplicitBehavior, Alloc, To, From, Tofrom, Firstprivate, None, Default, |
| 530 | Present); |
| 531 | ENUM(VariableCategory, All, Scalar, Aggregate, Pointer, Allocatable); |
| 532 | using TupleTrait = std::true_type; |
| 533 | std::tuple<ImplicitBehavior, OPT(VariableCategory)> t; |
| 534 | }; |
| 535 | |
| 536 | // V5.2: [15.9.5] `depend` clause |
| 537 | template <typename T, typename I, typename E> // |
| 538 | struct DependT { |
| 539 | using Iterator = type::IteratorT<T, I, E>; |
| 540 | using LocatorList = ObjectListT<I, E>; |
| 541 | using DependenceType = tomp::type::DependenceType; |
| 542 | // For the (pre-5.2) doacross spelling of the depend clause on the |
| 543 | // ordered directive: depend(source) / depend(sink: vec). Empty Vector |
| 544 | // means omp_cur_iteration, matching DoacrossT::Vector. When Vector has a |
| 545 | // value, LocatorList must be empty and the dependence type must be Source or |
| 546 | // Sink. |
| 547 | using Vector = ListT<type::LoopIterationT<I, E>>; |
| 548 | |
| 549 | using TupleTrait = std::true_type; |
| 550 | // Empty LocatorList means "omp_all_memory". |
| 551 | std::tuple<DependenceType, OPT(Iterator), OPT(Vector), LocatorList> t; |
| 552 | }; |
| 553 | |
| 554 | // [tr14:212-213] |
| 555 | template <typename T, typename I, typename E> // |
| 556 | struct DepthT { |
| 557 | using DepthExpr = E; |
| 558 | using WrapperTrait = std::true_type; |
| 559 | DepthExpr v; |
| 560 | }; |
| 561 | |
| 562 | // V5.2: [3.5] `destroy` clause |
| 563 | template <typename T, typename I, typename E> // |
| 564 | struct DestroyT { |
| 565 | using DestroyVar = ObjectT<I, E>; |
| 566 | using WrapperTrait = std::true_type; |
| 567 | // DestroyVar can be ommitted in "depobj destroy". |
| 568 | OPT(DestroyVar) v; |
| 569 | }; |
| 570 | |
| 571 | // V5.2: [12.5.2] `detach` clause |
| 572 | template <typename T, typename I, typename E> // |
| 573 | struct DetachT { |
| 574 | using EventHandle = ObjectT<I, E>; |
| 575 | using WrapperTrait = std::true_type; |
| 576 | EventHandle v; |
| 577 | }; |
| 578 | |
| 579 | // V5.2: [13.2] `device` clause |
| 580 | template <typename T, typename I, typename E> // |
| 581 | struct DeviceT { |
| 582 | using DeviceDescription = E; |
| 583 | ENUM(DeviceModifier, Ancestor, DeviceNum); |
| 584 | using TupleTrait = std::true_type; |
| 585 | std::tuple<OPT(DeviceModifier), DeviceDescription> t; |
| 586 | }; |
| 587 | |
| 588 | // [6.0:362] |
| 589 | template <typename T, typename I, typename E> // |
| 590 | struct DeviceSafesyncT { |
| 591 | using Requires = E; |
| 592 | using WrapperTrait = std::true_type; |
| 593 | OPT(Requires) v; |
| 594 | }; |
| 595 | |
| 596 | // V5.2: [13.1] `device_type` clause |
| 597 | template <typename T, typename I, typename E> // |
| 598 | struct DeviceTypeT { |
| 599 | ENUM(DeviceTypeDescription, Any, Host, Nohost); |
| 600 | using WrapperTrait = std::true_type; |
| 601 | DeviceTypeDescription v; |
| 602 | }; |
| 603 | |
| 604 | // V5.2: [11.6.1] `dist_schedule` clause |
| 605 | template <typename T, typename I, typename E> // |
| 606 | struct DistScheduleT { |
| 607 | ENUM(Kind, Static); |
| 608 | using ChunkSize = E; |
| 609 | using TupleTrait = std::true_type; |
| 610 | std::tuple<Kind, OPT(ChunkSize)> t; |
| 611 | }; |
| 612 | |
| 613 | // V5.2: [15.9.6] `doacross` clause |
| 614 | template <typename T, typename I, typename E> // |
| 615 | struct DoacrossT { |
| 616 | using Vector = ListT<type::LoopIterationT<I, E>>; |
| 617 | using DependenceType = tomp::type::DependenceType; |
| 618 | using TupleTrait = std::true_type; |
| 619 | // Empty Vector means "omp_cur_iteration" |
| 620 | std::tuple<DependenceType, Vector> t; |
| 621 | }; |
| 622 | |
| 623 | // V5.2: [8.2.1] `requirement` clauses |
| 624 | template <typename T, typename I, typename E> // |
| 625 | struct DynamicAllocatorsT { |
| 626 | using Requires = E; |
| 627 | using WrapperTrait = std::true_type; |
| 628 | OPT(Requires) v; |
| 629 | }; |
| 630 | |
| 631 | template <typename T, typename I, typename E> // |
| 632 | struct DynGroupprivateT { |
| 633 | ENUM(AccessGroup, Cgroup); |
| 634 | ENUM(Fallback, Abort, Default_Mem, Null); |
| 635 | using Size = E; |
| 636 | using TupleTrait = std::true_type; |
| 637 | std::tuple<OPT(AccessGroup), OPT(Fallback), Size> t; |
| 638 | }; |
| 639 | |
| 640 | // V5.2: [5.8.4] `enter` clause |
| 641 | template <typename T, typename I, typename E> // |
| 642 | struct EnterT { |
| 643 | using List = ObjectListT<I, E>; |
| 644 | ENUM(Modifier, Automap); |
| 645 | using TupleTrait = std::true_type; |
| 646 | std::tuple<OPT(Modifier), List> t; |
| 647 | }; |
| 648 | |
| 649 | // V5.2: [5.6.2] `exclusive` clause |
| 650 | template <typename T, typename I, typename E> // |
| 651 | struct ExclusiveT { |
| 652 | using WrapperTrait = std::true_type; |
| 653 | using List = ObjectListT<I, E>; |
| 654 | List v; |
| 655 | }; |
| 656 | |
| 657 | // V5.2: [15.8.3] `extended-atomic` clauses |
| 658 | template <typename T, typename I, typename E> // |
| 659 | struct FailT { |
| 660 | using MemoryOrder = type::MemoryOrder; |
| 661 | using WrapperTrait = std::true_type; |
| 662 | MemoryOrder v; |
| 663 | }; |
| 664 | |
| 665 | // V5.2: [10.5.1] `filter` clause |
| 666 | template <typename T, typename I, typename E> // |
| 667 | struct FilterT { |
| 668 | using ThreadNum = E; |
| 669 | using WrapperTrait = std::true_type; |
| 670 | ThreadNum v; |
| 671 | }; |
| 672 | |
| 673 | // V5.2: [12.3] `final` clause |
| 674 | template <typename T, typename I, typename E> // |
| 675 | struct FinalT { |
| 676 | using Finalize = E; |
| 677 | using WrapperTrait = std::true_type; |
| 678 | Finalize v; |
| 679 | }; |
| 680 | |
| 681 | // V5.2: [5.4.4] `firstprivate` clause |
| 682 | template <typename T, typename I, typename E> // |
| 683 | struct FirstprivateT { |
| 684 | using List = ObjectListT<I, E>; |
| 685 | using WrapperTrait = std::true_type; |
| 686 | List v; |
| 687 | }; |
| 688 | |
| 689 | // V5.2: [5.9.2] `from` clause |
| 690 | template <typename T, typename I, typename E> // |
| 691 | struct FromT { |
| 692 | using LocatorList = ObjectListT<I, E>; |
| 693 | using Expectation = type::MotionExpectation; |
| 694 | using Iterator = type::IteratorT<T, I, E>; |
| 695 | // See note at the definition of the MapperT type. |
| 696 | using Mappers = ListT<type::MapperT<I, E>>; // Not a spec name |
| 697 | |
| 698 | using TupleTrait = std::true_type; |
| 699 | std::tuple<OPT(Expectation), OPT(Mappers), OPT(Iterator), LocatorList> t; |
| 700 | }; |
| 701 | |
| 702 | // V5.2: [9.2.1] `full` clause |
| 703 | template <typename T, typename I, typename E> // |
| 704 | struct FullT { |
| 705 | using EmptyTrait = std::true_type; |
| 706 | }; |
| 707 | |
| 708 | // V5.2: [12.6.1] `grainsize` clause |
| 709 | template <typename T, typename I, typename E> // |
| 710 | struct GrainsizeT { |
| 711 | using Prescriptiveness = type::Prescriptiveness; |
| 712 | using GrainSize = E; |
| 713 | using TupleTrait = std::true_type; |
| 714 | std::tuple<OPT(Prescriptiveness), GrainSize> t; |
| 715 | }; |
| 716 | |
| 717 | // [6.0:438] `graph_id` clause |
| 718 | template <typename T, typename I, typename E> // |
| 719 | struct GraphIdT { |
| 720 | using IncompleteTrait = std::true_type; |
| 721 | }; |
| 722 | |
| 723 | // [6.0:438] `graph_reset` clause |
| 724 | template <typename T, typename I, typename E> // |
| 725 | struct GraphResetT { |
| 726 | using IncompleteTrait = std::true_type; |
| 727 | }; |
| 728 | |
| 729 | // V5.2: [5.4.9] `has_device_addr` clause |
| 730 | template <typename T, typename I, typename E> // |
| 731 | struct HasDeviceAddrT { |
| 732 | using List = ObjectListT<I, E>; |
| 733 | using WrapperTrait = std::true_type; |
| 734 | List v; |
| 735 | }; |
| 736 | |
| 737 | // V5.2: [15.1.2] `hint` clause |
| 738 | template <typename T, typename I, typename E> // |
| 739 | struct HintT { |
| 740 | using HintExpr = E; |
| 741 | using WrapperTrait = std::true_type; |
| 742 | HintExpr v; |
| 743 | }; |
| 744 | |
| 745 | // V5.2: [8.3.1] Assumption clauses |
| 746 | template <typename T, typename I, typename E> // |
| 747 | struct HoldsT { |
| 748 | using WrapperTrait = std::true_type; |
| 749 | E v; // No argument name in spec 5.2 |
| 750 | }; |
| 751 | |
| 752 | // V5.2: [3.4] `if` clause |
| 753 | template <typename T, typename I, typename E> // |
| 754 | struct IfT { |
| 755 | using DirectiveNameModifier = type::DirectiveName; |
| 756 | using IfExpression = E; |
| 757 | using TupleTrait = std::true_type; |
| 758 | std::tuple<OPT(DirectiveNameModifier), IfExpression> t; |
| 759 | }; |
| 760 | |
| 761 | // V5.2: [7.7.1] `branch` clauses |
| 762 | template <typename T, typename I, typename E> // |
| 763 | struct InbranchT { |
| 764 | using EmptyTrait = std::true_type; |
| 765 | }; |
| 766 | |
| 767 | // V5.2: [5.6.1] `exclusive` clause |
| 768 | template <typename T, typename I, typename E> // |
| 769 | struct InclusiveT { |
| 770 | using List = ObjectListT<I, E>; |
| 771 | using WrapperTrait = std::true_type; |
| 772 | List v; |
| 773 | }; |
| 774 | |
| 775 | // V5.2: [7.8.3] `indirect` clause |
| 776 | template <typename T, typename I, typename E> // |
| 777 | struct IndirectT { |
| 778 | using InvokedByFptr = E; |
| 779 | using WrapperTrait = std::true_type; |
| 780 | OPT(InvokedByFptr) v; |
| 781 | }; |
| 782 | |
| 783 | // [6.0:257-261] |
| 784 | template <typename T, typename I, typename E> // |
| 785 | struct InductionT { |
| 786 | using IncompleteTrait = std::true_type; |
| 787 | }; |
| 788 | |
| 789 | // [6.0:265-266] |
| 790 | template <typename T, typename I, typename E> // |
| 791 | struct InductorT { |
| 792 | using IncompleteTrait = std::true_type; |
| 793 | }; |
| 794 | |
| 795 | // V5.2: [14.1.2] `init` clause |
| 796 | template <typename T, typename I, typename E> // |
| 797 | struct InitT { |
| 798 | using ForeignRuntimeId = E; |
| 799 | using InteropVar = ObjectT<I, E>; |
| 800 | using InteropPreference = ListT<ForeignRuntimeId>; |
| 801 | ENUM(InteropType, Target, Targetsync); // Repeatable |
| 802 | using InteropTypes = ListT<InteropType>; // Not a spec name |
| 803 | |
| 804 | using TupleTrait = std::true_type; |
| 805 | std::tuple<OPT(InteropPreference), InteropTypes, InteropVar> t; |
| 806 | }; |
| 807 | |
| 808 | // [6.0:270] |
| 809 | template <typename T, typename I, typename E> // |
| 810 | struct InitCompleteT { |
| 811 | using IncompleteTrait = std::true_type; |
| 812 | }; |
| 813 | |
| 814 | // V5.2: [5.5.4] `initializer` clause |
| 815 | template <typename T, typename I, typename E> // |
| 816 | struct InitializerT { |
| 817 | using List = ListT<type::StylizedInstanceT<I, E>>; |
| 818 | using WrapperTrait = std::true_type; |
| 819 | List v; |
| 820 | }; |
| 821 | |
| 822 | // V5.2: [5.5.10] `in_reduction` clause |
| 823 | template <typename T, typename I, typename E> // |
| 824 | struct InReductionT { |
| 825 | using List = ObjectListT<I, E>; |
| 826 | // See note at the definition of the ReductionIdentifierT type. |
| 827 | // The name ReductionIdentifiers is not a spec name. |
| 828 | using ReductionIdentifiers = ListT<type::ReductionIdentifierT<I, E>>; |
| 829 | using TupleTrait = std::true_type; |
| 830 | std::tuple<ReductionIdentifiers, List> t; |
| 831 | }; |
| 832 | |
| 833 | // [6.0:339-340] |
| 834 | template <typename T, typename I, typename E> // |
| 835 | struct InteropT { |
| 836 | using IncompleteTrait = std::true_type; |
| 837 | }; |
| 838 | |
| 839 | // V5.2: [5.4.7] `is_device_ptr` clause |
| 840 | template <typename T, typename I, typename E> // |
| 841 | struct IsDevicePtrT { |
| 842 | using List = ObjectListT<I, E>; |
| 843 | using WrapperTrait = std::true_type; |
| 844 | List v; |
| 845 | }; |
| 846 | |
| 847 | // V5.2: [5.4.5] `lastprivate` clause |
| 848 | template <typename T, typename I, typename E> // |
| 849 | struct LastprivateT { |
| 850 | using List = ObjectListT<I, E>; |
| 851 | ENUM(LastprivateModifier, Conditional); |
| 852 | using TupleTrait = std::true_type; |
| 853 | std::tuple<OPT(LastprivateModifier), List> t; |
| 854 | }; |
| 855 | |
| 856 | // V5.2: [5.4.6] `linear` clause |
| 857 | template <typename T, typename I, typename E> // |
| 858 | struct LinearT { |
| 859 | // std::get<type> won't work here due to duplicate types in the tuple. |
| 860 | using List = ObjectListT<I, E>; |
| 861 | // StepSimpleModifier is same as StepComplexModifier. |
| 862 | using StepComplexModifier = E; |
| 863 | ENUM(LinearModifier, Ref, Val, Uval); |
| 864 | |
| 865 | using TupleTrait = std::true_type; |
| 866 | // Step == nullopt means 1. |
| 867 | std::tuple<OPT(StepComplexModifier), OPT(LinearModifier), List> t; |
| 868 | }; |
| 869 | |
| 870 | // V5.2: [5.8.5] `link` clause |
| 871 | template <typename T, typename I, typename E> // |
| 872 | struct LinkT { |
| 873 | using List = ObjectListT<I, E>; |
| 874 | using WrapperTrait = std::true_type; |
| 875 | List v; |
| 876 | }; |
| 877 | |
| 878 | // [6.0:303] |
| 879 | template <typename T, typename I, typename E> // |
| 880 | struct LocalT { |
| 881 | using IncompleteTrait = std::true_type; |
| 882 | }; |
| 883 | |
| 884 | // V6: [6.4.7] Looprange clause |
| 885 | template <typename T, typename I, typename E> // |
| 886 | struct LooprangeT { |
| 887 | using Begin = E; |
| 888 | using Count = E; |
| 889 | |
| 890 | using TupleTrait = std::true_type; |
| 891 | std::tuple<Begin, Count> t; |
| 892 | }; |
| 893 | |
| 894 | // V5.2: [5.8.3] `map` clause |
| 895 | template <typename T, typename I, typename E> // |
| 896 | struct MapT { |
| 897 | using LocatorList = ObjectListT<I, E>; |
| 898 | ENUM(MapType, To, From, Tofrom, Storage); |
| 899 | ENUM(AttachModifier, Always, Auto, Never); |
| 900 | ENUM(MapTypeModifier, Always, Close, Delete, Present, Self, OmpxHold); |
| 901 | ENUM(RefModifier, RefPtee, RefPtr, RefPtrPtee); |
| 902 | // See note at the definition of the MapperT type. |
| 903 | using Mappers = ListT<type::MapperT<I, E>>; // Not a spec name |
| 904 | using Iterator = type::IteratorT<T, I, E>; |
| 905 | using MapTypeModifiers = ListT<MapTypeModifier>; // Not a spec name |
| 906 | |
| 907 | using TupleTrait = std::true_type; |
| 908 | std::tuple<OPT(MapType), OPT(MapTypeModifiers), OPT(AttachModifier), |
| 909 | OPT(RefModifier), OPT(Mappers), OPT(Iterator), LocatorList> |
| 910 | t; |
| 911 | }; |
| 912 | |
| 913 | // V5.2: [7.5.1] `match` clause |
| 914 | template <typename T, typename I, typename E> // |
| 915 | struct MatchT { |
| 916 | using IncompleteTrait = std::true_type; |
| 917 | }; |
| 918 | |
| 919 | // [6.0:493-494] |
| 920 | template <typename T, typename I, typename E> // |
| 921 | struct MemscopeT { |
| 922 | using IncompleteTrait = std::true_type; |
| 923 | }; |
| 924 | |
| 925 | // V5.2: [12.2] `mergeable` clause |
| 926 | template <typename T, typename I, typename E> // |
| 927 | struct MergeableT { |
| 928 | using EmptyTrait = std::true_type; |
| 929 | }; |
| 930 | |
| 931 | // V5.2: [8.5.2] `message` clause |
| 932 | template <typename T, typename I, typename E> // |
| 933 | struct MessageT { |
| 934 | using MsgString = E; |
| 935 | using WrapperTrait = std::true_type; |
| 936 | MsgString v; |
| 937 | }; |
| 938 | |
| 939 | // V5.2: [7.6.2] `nocontext` clause |
| 940 | template <typename T, typename I, typename E> // |
| 941 | struct NocontextT { |
| 942 | using DoNotUpdateContext = E; |
| 943 | using WrapperTrait = std::true_type; |
| 944 | DoNotUpdateContext v; |
| 945 | }; |
| 946 | |
| 947 | // V5.2: [15.7] `nowait` clause |
| 948 | template <typename T, typename I, typename E> // |
| 949 | struct NogroupT { |
| 950 | using EmptyTrait = std::true_type; |
| 951 | }; |
| 952 | |
| 953 | // V5.2: [10.4.1] `nontemporal` clause |
| 954 | template <typename T, typename I, typename E> // |
| 955 | struct NontemporalT { |
| 956 | using List = ObjectListT<I, E>; |
| 957 | using WrapperTrait = std::true_type; |
| 958 | List v; |
| 959 | }; |
| 960 | |
| 961 | // V5.2: [8.3.1] `assumption` clauses |
| 962 | template <typename T, typename I, typename E> // |
| 963 | struct NoOpenmpT { |
| 964 | using EmptyTrait = std::true_type; |
| 965 | }; |
| 966 | |
| 967 | // V6.0: [10.6.1] `assumption` clauses |
| 968 | template <typename T, typename I, typename E> // |
| 969 | struct NoOpenmpConstructsT { |
| 970 | using EmptyTrait = std::true_type; |
| 971 | }; |
| 972 | |
| 973 | // V5.2: [8.3.1] `assumption` clauses |
| 974 | template <typename T, typename I, typename E> // |
| 975 | struct NoOpenmpRoutinesT { |
| 976 | using EmptyTrait = std::true_type; |
| 977 | }; |
| 978 | |
| 979 | // V5.2: [8.3.1] `assumption` clauses |
| 980 | template <typename T, typename I, typename E> // |
| 981 | struct NoParallelismT { |
| 982 | using EmptyTrait = std::true_type; |
| 983 | }; |
| 984 | |
| 985 | // V5.2: [7.7.1] `branch` clauses |
| 986 | template <typename T, typename I, typename E> // |
| 987 | struct NotinbranchT { |
| 988 | using EmptyTrait = std::true_type; |
| 989 | }; |
| 990 | |
| 991 | // V5.2: [7.6.1] `novariants` clause |
| 992 | template <typename T, typename I, typename E> // |
| 993 | struct NovariantsT { |
| 994 | using DoNotUseVariant = E; |
| 995 | using WrapperTrait = std::true_type; |
| 996 | DoNotUseVariant v; |
| 997 | }; |
| 998 | |
| 999 | // V5.2: [15.6] `nowait` clause |
| 1000 | template <typename T, typename I, typename E> // |
| 1001 | struct NowaitT { |
| 1002 | using EmptyTrait = std::true_type; |
| 1003 | }; |
| 1004 | |
| 1005 | // V5.2: [12.6.2] `num_tasks` clause |
| 1006 | template <typename T, typename I, typename E> // |
| 1007 | struct NumTasksT { |
| 1008 | using Prescriptiveness = type::Prescriptiveness; |
| 1009 | using NumTasks = E; |
| 1010 | using TupleTrait = std::true_type; |
| 1011 | std::tuple<OPT(Prescriptiveness), NumTasks> t; |
| 1012 | }; |
| 1013 | |
| 1014 | // V5.2: [10.2.1] `num_teams` clause |
| 1015 | // V6.1: Extended with dims modifier support |
| 1016 | template <typename T, typename I, typename E> // |
| 1017 | struct NumTeamsT { |
| 1018 | using LowerBound = E; |
| 1019 | using UpperBound = E; |
| 1020 | using UpperBoundList = ListT<UpperBound>; |
| 1021 | |
| 1022 | using TupleTrait = std::true_type; |
| 1023 | // Representation: {LB?, [UB]} |
| 1024 | std::tuple<OPT(LowerBound), UpperBoundList> t; |
| 1025 | }; |
| 1026 | |
| 1027 | // V5.2: [10.1.2] `num_threads` clause |
| 1028 | // V6.1: Extended with dims modifier support |
| 1029 | template <typename T, typename I, typename E> // |
| 1030 | struct NumThreadsT { |
| 1031 | using Nthreads = E; |
| 1032 | using List = ListT<Nthreads>; |
| 1033 | using WrapperTrait = std::true_type; |
| 1034 | List v; |
| 1035 | }; |
| 1036 | |
| 1037 | template <typename T, typename I, typename E> // |
| 1038 | struct OmpxAttributeT { |
| 1039 | using EmptyTrait = std::true_type; |
| 1040 | }; |
| 1041 | |
| 1042 | template <typename T, typename I, typename E> // |
| 1043 | struct OmpxBareT { |
| 1044 | using EmptyTrait = std::true_type; |
| 1045 | }; |
| 1046 | |
| 1047 | template <typename T, typename I, typename E> // |
| 1048 | struct OmpxDynCgroupMemT { |
| 1049 | using WrapperTrait = std::true_type; |
| 1050 | E v; |
| 1051 | }; |
| 1052 | |
| 1053 | // V5.2: [10.3] `order` clause |
| 1054 | template <typename T, typename I, typename E> // |
| 1055 | struct OrderT { |
| 1056 | ENUM(OrderModifier, Reproducible, Unconstrained); |
| 1057 | ENUM(Ordering, Concurrent); |
| 1058 | using TupleTrait = std::true_type; |
| 1059 | std::tuple<OPT(OrderModifier), Ordering> t; |
| 1060 | }; |
| 1061 | |
| 1062 | // V5.2: [4.4.4] `ordered` clause |
| 1063 | template <typename T, typename I, typename E> // |
| 1064 | struct OrderedT { |
| 1065 | using N = E; |
| 1066 | using WrapperTrait = std::true_type; |
| 1067 | OPT(N) v; |
| 1068 | }; |
| 1069 | |
| 1070 | // V5.2: [7.4.2] `otherwise` clause |
| 1071 | template <typename T, typename I, typename E> // |
| 1072 | struct OtherwiseT { |
| 1073 | using IncompleteTrait = std::true_type; |
| 1074 | }; |
| 1075 | |
| 1076 | // V5.2: [9.2.2] `partial` clause |
| 1077 | template <typename T, typename I, typename E> // |
| 1078 | struct PartialT { |
| 1079 | using UnrollFactor = E; |
| 1080 | using WrapperTrait = std::true_type; |
| 1081 | OPT(UnrollFactor) v; |
| 1082 | }; |
| 1083 | |
| 1084 | // V6.0: `permutation` clause |
| 1085 | template <typename T, typename I, typename E> // |
| 1086 | struct PermutationT { |
| 1087 | using ArgList = ListT<E>; |
| 1088 | using WrapperTrait = std::true_type; |
| 1089 | ArgList v; |
| 1090 | }; |
| 1091 | |
| 1092 | // V5.2: [12.4] `priority` clause |
| 1093 | template <typename T, typename I, typename E> // |
| 1094 | struct PriorityT { |
| 1095 | using PriorityValue = E; |
| 1096 | using WrapperTrait = std::true_type; |
| 1097 | PriorityValue v; |
| 1098 | }; |
| 1099 | |
| 1100 | // V5.2: [5.4.3] `private` clause |
| 1101 | template <typename T, typename I, typename E> // |
| 1102 | struct PrivateT { |
| 1103 | using List = ObjectListT<I, E>; |
| 1104 | using WrapperTrait = std::true_type; |
| 1105 | List v; |
| 1106 | }; |
| 1107 | |
| 1108 | // V5.2: [10.1.4] `proc_bind` clause |
| 1109 | template <typename T, typename I, typename E> // |
| 1110 | struct ProcBindT { |
| 1111 | ENUM(AffinityPolicy, Close, Master, Spread, Primary); |
| 1112 | using WrapperTrait = std::true_type; |
| 1113 | AffinityPolicy v; |
| 1114 | }; |
| 1115 | |
| 1116 | // V5.2: [15.8.2] Atomic clauses |
| 1117 | template <typename T, typename I, typename E> // |
| 1118 | struct ReadT { |
| 1119 | using EmptyTrait = std::true_type; |
| 1120 | }; |
| 1121 | |
| 1122 | // V5.2: [5.5.8] `reduction` clause |
| 1123 | template <typename T, typename I, typename E> // |
| 1124 | struct ReductionT { |
| 1125 | using List = ObjectListT<I, E>; |
| 1126 | // See note at the definition of the ReductionIdentifierT type. |
| 1127 | // The name ReductionIdentifiers is not a spec name. |
| 1128 | using ReductionIdentifiers = ListT<type::ReductionIdentifierT<I, E>>; |
| 1129 | ENUM(ReductionModifier, Default, Inscan, Task); |
| 1130 | using TupleTrait = std::true_type; |
| 1131 | std::tuple<OPT(ReductionModifier), ReductionIdentifiers, List> t; |
| 1132 | }; |
| 1133 | |
| 1134 | // TR15:285 |
| 1135 | template <typename T, typename I, typename E> // |
| 1136 | struct ReductionKindT { |
| 1137 | using IncompleteTrait = std::true_type; |
| 1138 | }; |
| 1139 | |
| 1140 | // V5.2: [15.8.1] `memory-order` clauses |
| 1141 | template <typename T, typename I, typename E> // |
| 1142 | struct RelaxedT { |
| 1143 | using EmptyTrait = std::true_type; |
| 1144 | }; |
| 1145 | |
| 1146 | // V5.2: [15.8.1] `memory-order` clauses |
| 1147 | template <typename T, typename I, typename E> // |
| 1148 | struct ReleaseT { |
| 1149 | using EmptyTrait = std::true_type; |
| 1150 | }; |
| 1151 | |
| 1152 | // [6.0:440-441] `replayable` clause |
| 1153 | template <typename T, typename I, typename E> // |
| 1154 | struct ReplayableT { |
| 1155 | using IncompleteTrait = std::true_type; |
| 1156 | }; |
| 1157 | |
| 1158 | // V5.2: [8.2.1] `requirement` clauses |
| 1159 | template <typename T, typename I, typename E> // |
| 1160 | struct ReverseOffloadT { |
| 1161 | using Requires = E; |
| 1162 | using WrapperTrait = std::true_type; |
| 1163 | OPT(Requires) v; |
| 1164 | }; |
| 1165 | |
| 1166 | // V5.2: [10.4.2] `safelen` clause |
| 1167 | template <typename T, typename I, typename E> // |
| 1168 | struct SafelenT { |
| 1169 | using Length = E; |
| 1170 | using WrapperTrait = std::true_type; |
| 1171 | Length v; |
| 1172 | }; |
| 1173 | |
| 1174 | // [6.0:393] |
| 1175 | template <typename T, typename I, typename E> // |
| 1176 | struct SafesyncT { |
| 1177 | using IncompleteTrait = std::true_type; |
| 1178 | }; |
| 1179 | |
| 1180 | // V5.2: [11.5.3] `schedule` clause |
| 1181 | template <typename T, typename I, typename E> // |
| 1182 | struct ScheduleT { |
| 1183 | ENUM(Kind, Static, Dynamic, Guided, Auto, Runtime); |
| 1184 | using ChunkSize = E; |
| 1185 | ENUM(OrderingModifier, Monotonic, Nonmonotonic); |
| 1186 | ENUM(ChunkModifier, Simd); |
| 1187 | using TupleTrait = std::true_type; |
| 1188 | std::tuple<Kind, OPT(OrderingModifier), OPT(ChunkModifier), OPT(ChunkSize)> t; |
| 1189 | }; |
| 1190 | |
| 1191 | // [6.0:361] |
| 1192 | template <typename T, typename I, typename E> // |
| 1193 | struct SelfMapsT { |
| 1194 | using Requires = E; |
| 1195 | using WrapperTrait = std::true_type; |
| 1196 | OPT(Requires) v; |
| 1197 | }; |
| 1198 | |
| 1199 | // V5.2: [15.8.1] Memory-order clauses |
| 1200 | template <typename T, typename I, typename E> // |
| 1201 | struct SeqCstT { |
| 1202 | using EmptyTrait = std::true_type; |
| 1203 | }; |
| 1204 | |
| 1205 | // V5.2: [8.5.1] `severity` clause |
| 1206 | template <typename T, typename I, typename E> // |
| 1207 | struct SeverityT { |
| 1208 | ENUM(SevLevel, Fatal, Warning); |
| 1209 | using WrapperTrait = std::true_type; |
| 1210 | SevLevel v; |
| 1211 | }; |
| 1212 | |
| 1213 | // V5.2: [5.4.2] `shared` clause |
| 1214 | template <typename T, typename I, typename E> // |
| 1215 | struct SharedT { |
| 1216 | using List = ObjectListT<I, E>; |
| 1217 | using WrapperTrait = std::true_type; |
| 1218 | List v; |
| 1219 | }; |
| 1220 | |
| 1221 | // TR15:408-409 |
| 1222 | template <typename T, typename I, typename E> // |
| 1223 | struct ShiftT { |
| 1224 | using IncompleteTrait = std::true_type; |
| 1225 | }; |
| 1226 | |
| 1227 | // V5.2: [15.10.3] `parallelization-level` clauses |
| 1228 | template <typename T, typename I, typename E> // |
| 1229 | struct SimdT { |
| 1230 | using EmptyTrait = std::true_type; |
| 1231 | }; |
| 1232 | |
| 1233 | // V5.2: [10.4.3] `simdlen` clause |
| 1234 | template <typename T, typename I, typename E> // |
| 1235 | struct SimdlenT { |
| 1236 | using Length = E; |
| 1237 | using WrapperTrait = std::true_type; |
| 1238 | Length v; |
| 1239 | }; |
| 1240 | |
| 1241 | // V5.2: [9.1.1] `sizes` clause |
| 1242 | template <typename T, typename I, typename E> // |
| 1243 | struct SizesT { |
| 1244 | using SizeList = ListT<E>; |
| 1245 | using WrapperTrait = std::true_type; |
| 1246 | SizeList v; |
| 1247 | }; |
| 1248 | |
| 1249 | // V5.2: [5.5.9] `task_reduction` clause |
| 1250 | template <typename T, typename I, typename E> // |
| 1251 | struct TaskReductionT { |
| 1252 | using List = ObjectListT<I, E>; |
| 1253 | // See note at the definition of the ReductionIdentifierT type. |
| 1254 | // The name ReductionIdentifiers is not a spec name. |
| 1255 | using ReductionIdentifiers = ListT<type::ReductionIdentifierT<I, E>>; |
| 1256 | using TupleTrait = std::true_type; |
| 1257 | std::tuple<ReductionIdentifiers, List> t; |
| 1258 | }; |
| 1259 | |
| 1260 | // V5.2: [13.3] `thread_limit` clause |
| 1261 | // V6.1: Extended with dims modifier support |
| 1262 | template <typename T, typename I, typename E> // |
| 1263 | struct ThreadLimitT { |
| 1264 | using Threadlim = E; |
| 1265 | using List = ListT<Threadlim>; |
| 1266 | using WrapperTrait = std::true_type; |
| 1267 | List v; |
| 1268 | }; |
| 1269 | |
| 1270 | // V5.2: [15.10.3] `parallelization-level` clauses |
| 1271 | template <typename T, typename I, typename E> // |
| 1272 | struct ThreadsT { |
| 1273 | using EmptyTrait = std::true_type; |
| 1274 | }; |
| 1275 | |
| 1276 | // V6.0: [14.8] `threadset` clause |
| 1277 | template <typename T, typename I, typename E> // |
| 1278 | struct ThreadsetT { |
| 1279 | ENUM(ThreadsetPolicy, Omp_Pool, Omp_Team); |
| 1280 | using WrapperTrait = std::true_type; |
| 1281 | ThreadsetPolicy v; |
| 1282 | }; |
| 1283 | |
| 1284 | // V5.2: [5.9.1] `to` clause |
| 1285 | template <typename T, typename I, typename E> // |
| 1286 | struct ToT { |
| 1287 | using LocatorList = ObjectListT<I, E>; |
| 1288 | using Expectation = type::MotionExpectation; |
| 1289 | // See note at the definition of the MapperT type. |
| 1290 | using Mappers = ListT<type::MapperT<I, E>>; // Not a spec name |
| 1291 | using Iterator = type::IteratorT<T, I, E>; |
| 1292 | |
| 1293 | using TupleTrait = std::true_type; |
| 1294 | std::tuple<OPT(Expectation), OPT(Mappers), OPT(Iterator), LocatorList> t; |
| 1295 | }; |
| 1296 | |
| 1297 | // [6.0:510:25] `transparent` clause |
| 1298 | template <typename T, typename I, typename E> // |
| 1299 | struct TransparentT { |
| 1300 | using IncompleteTrait = std::true_type; |
| 1301 | }; |
| 1302 | |
| 1303 | // V5.2: [8.2.1] `requirement` clauses |
| 1304 | template <typename T, typename I, typename E> // |
| 1305 | struct UnifiedAddressT { |
| 1306 | using Requires = E; |
| 1307 | using WrapperTrait = std::true_type; |
| 1308 | OPT(Requires) v; |
| 1309 | }; |
| 1310 | |
| 1311 | // V5.2: [8.2.1] `requirement` clauses |
| 1312 | template <typename T, typename I, typename E> // |
| 1313 | struct UnifiedSharedMemoryT { |
| 1314 | using Requires = E; |
| 1315 | using WrapperTrait = std::true_type; |
| 1316 | OPT(Requires) v; |
| 1317 | }; |
| 1318 | |
| 1319 | // V5.2: [5.10] `uniform` clause |
| 1320 | template <typename T, typename I, typename E> // |
| 1321 | struct UniformT { |
| 1322 | using ParameterList = ObjectListT<I, E>; |
| 1323 | using WrapperTrait = std::true_type; |
| 1324 | ParameterList v; |
| 1325 | }; |
| 1326 | |
| 1327 | template <typename T, typename I, typename E> // |
| 1328 | struct UnknownT { |
| 1329 | using EmptyTrait = std::true_type; |
| 1330 | }; |
| 1331 | |
| 1332 | // V5.2: [12.1] `untied` clause |
| 1333 | template <typename T, typename I, typename E> // |
| 1334 | struct UntiedT { |
| 1335 | using EmptyTrait = std::true_type; |
| 1336 | }; |
| 1337 | |
| 1338 | // Both of the following |
| 1339 | // V5.2: [15.8.2] `atomic` clauses |
| 1340 | // V5.2: [15.9.3] `update` clause |
| 1341 | template <typename T, typename I, typename E> // |
| 1342 | struct UpdateT { |
| 1343 | using EmptyTrait = std::true_type; |
| 1344 | }; |
| 1345 | |
| 1346 | template <typename T, typename I, typename E> // |
| 1347 | struct UpdateDependObjectsT { |
| 1348 | using DependenceType = tomp::type::DependenceType; |
| 1349 | using WrapperTrait = std::true_type; |
| 1350 | DependenceType v; |
| 1351 | }; |
| 1352 | |
| 1353 | // V5.2: [14.1.3] `use` clause |
| 1354 | template <typename T, typename I, typename E> // |
| 1355 | struct UseT { |
| 1356 | using InteropVar = ObjectT<I, E>; |
| 1357 | using WrapperTrait = std::true_type; |
| 1358 | InteropVar v; |
| 1359 | }; |
| 1360 | |
| 1361 | // V5.2: [5.4.10] `use_device_addr` clause |
| 1362 | template <typename T, typename I, typename E> // |
| 1363 | struct UseDeviceAddrT { |
| 1364 | using List = ObjectListT<I, E>; |
| 1365 | using WrapperTrait = std::true_type; |
| 1366 | List v; |
| 1367 | }; |
| 1368 | |
| 1369 | // V5.2: [5.4.8] `use_device_ptr` clause |
| 1370 | template <typename T, typename I, typename E> // |
| 1371 | struct UseDevicePtrT { |
| 1372 | using List = ObjectListT<I, E>; |
| 1373 | using WrapperTrait = std::true_type; |
| 1374 | List v; |
| 1375 | }; |
| 1376 | |
| 1377 | // V5.2: [6.8] `uses_allocators` clause |
| 1378 | template <typename T, typename I, typename E> // |
| 1379 | struct UsesAllocatorsT { |
| 1380 | using MemSpace = E; |
| 1381 | using TraitsArray = ObjectT<I, E>; |
| 1382 | using Allocator = E; |
| 1383 | struct AllocatorSpec { // Not a spec name |
| 1384 | using TupleTrait = std::true_type; |
| 1385 | std::tuple<OPT(MemSpace), OPT(TraitsArray), Allocator> t; |
| 1386 | }; |
| 1387 | using Allocators = ListT<AllocatorSpec>; // Not a spec name |
| 1388 | using WrapperTrait = std::true_type; |
| 1389 | Allocators v; |
| 1390 | }; |
| 1391 | |
| 1392 | // V5.2: [15.8.3] `extended-atomic` clauses |
| 1393 | template <typename T, typename I, typename E> // |
| 1394 | struct WeakT { |
| 1395 | using EmptyTrait = std::true_type; |
| 1396 | }; |
| 1397 | |
| 1398 | // V5.2: [7.4.1] `when` clause |
| 1399 | template <typename T, typename I, typename E> // |
| 1400 | struct WhenT { |
| 1401 | using IncompleteTrait = std::true_type; |
| 1402 | }; |
| 1403 | |
| 1404 | // V5.2: [15.8.2] Atomic clauses |
| 1405 | template <typename T, typename I, typename E> // |
| 1406 | struct WriteT { |
| 1407 | using EmptyTrait = std::true_type; |
| 1408 | }; |
| 1409 | |
| 1410 | // --- |
| 1411 | |
| 1412 | template <typename T, typename I, typename E> |
| 1413 | using ExtensionClausesT = |
| 1414 | std::variant<OmpxAttributeT<T, I, E>, OmpxBareT<T, I, E>, |
| 1415 | OmpxDynCgroupMemT<T, I, E>>; |
| 1416 | |
| 1417 | template <typename T, typename I, typename E> |
| 1418 | using EmptyClausesT = std::variant< |
| 1419 | AcqRelT<T, I, E>, AcquireT<T, I, E>, CaptureT<T, I, E>, CompareT<T, I, E>, |
| 1420 | FullT<T, I, E>, InbranchT<T, I, E>, MergeableT<T, I, E>, NogroupT<T, I, E>, |
| 1421 | NoOpenmpConstructsT<T, I, E>, NoOpenmpRoutinesT<T, I, E>, |
| 1422 | NoOpenmpT<T, I, E>, NoParallelismT<T, I, E>, NotinbranchT<T, I, E>, |
| 1423 | NowaitT<T, I, E>, ReadT<T, I, E>, RelaxedT<T, I, E>, ReleaseT<T, I, E>, |
| 1424 | SeqCstT<T, I, E>, SimdT<T, I, E>, ThreadsT<T, I, E>, UnknownT<T, I, E>, |
| 1425 | UntiedT<T, I, E>, UpdateT<T, I, E>, UseT<T, I, E>, WeakT<T, I, E>, |
| 1426 | WriteT<T, I, E>>; |
| 1427 | |
| 1428 | template <typename T, typename I, typename E> |
| 1429 | using IncompleteClausesT = |
| 1430 | std::variant<AdjustArgsT<T, I, E>, AppendArgsT<T, I, E>, ApplyT<T, I, E>, |
| 1431 | CollectorT<T, I, E>, CountsT<T, I, E>, GraphIdT<T, I, E>, |
| 1432 | GraphResetT<T, I, E>, InductionT<T, I, E>, InductorT<T, I, E>, |
| 1433 | InitCompleteT<T, I, E>, InteropT<T, I, E>, LocalT<T, I, E>, |
| 1434 | MatchT<T, I, E>, MemscopeT<T, I, E>, OtherwiseT<T, I, E>, |
| 1435 | ReductionKindT<T, I, E>, ReplayableT<T, I, E>, |
| 1436 | SafesyncT<T, I, E>, ShiftT<T, I, E>, TransparentT<T, I, E>, |
| 1437 | WhenT<T, I, E>>; |
| 1438 | |
| 1439 | template <typename T, typename I, typename E> |
| 1440 | using TupleClausesT = |
| 1441 | std::variant<AffinityT<T, I, E>, AlignedT<T, I, E>, AllocateT<T, I, E>, |
| 1442 | DefaultmapT<T, I, E>, DeviceT<T, I, E>, DistScheduleT<T, I, E>, |
| 1443 | DoacrossT<T, I, E>, DynGroupprivateT<T, I, E>, FromT<T, I, E>, |
| 1444 | GrainsizeT<T, I, E>, IfT<T, I, E>, InitT<T, I, E>, |
| 1445 | InReductionT<T, I, E>, LastprivateT<T, I, E>, LinearT<T, I, E>, |
| 1446 | LooprangeT<T, I, E>, MapT<T, I, E>, NumTasksT<T, I, E>, |
| 1447 | OrderT<T, I, E>, ReductionT<T, I, E>, ScheduleT<T, I, E>, |
| 1448 | TaskReductionT<T, I, E>, ToT<T, I, E>>; |
| 1449 | |
| 1450 | template <typename T, typename I, typename E> |
| 1451 | using UnionClausesT = std::variant<DependT<T, I, E>>; |
| 1452 | |
| 1453 | template <typename T, typename I, typename E> |
| 1454 | using WrapperClausesT = std::variant< |
| 1455 | AbsentT<T, I, E>, AlignT<T, I, E>, AllocatorT<T, I, E>, |
| 1456 | AtomicDefaultMemOrderT<T, I, E>, AtT<T, I, E>, BindT<T, I, E>, |
| 1457 | CollapseT<T, I, E>, CombinerT<T, I, E>, ContainsT<T, I, E>, |
| 1458 | CopyinT<T, I, E>, CopyprivateT<T, I, E>, DefaultT<T, I, E>, DepthT<T, I, E>, |
| 1459 | DestroyT<T, I, E>, DetachT<T, I, E>, DeviceSafesyncT<T, I, E>, |
| 1460 | DeviceTypeT<T, I, E>, DynamicAllocatorsT<T, I, E>, EnterT<T, I, E>, |
| 1461 | ExclusiveT<T, I, E>, FailT<T, I, E>, FilterT<T, I, E>, FinalT<T, I, E>, |
| 1462 | FirstprivateT<T, I, E>, HasDeviceAddrT<T, I, E>, HintT<T, I, E>, |
| 1463 | HoldsT<T, I, E>, InclusiveT<T, I, E>, IndirectT<T, I, E>, |
| 1464 | InitializerT<T, I, E>, IsDevicePtrT<T, I, E>, LinkT<T, I, E>, |
| 1465 | MessageT<T, I, E>, NocontextT<T, I, E>, NontemporalT<T, I, E>, |
| 1466 | NovariantsT<T, I, E>, NumTeamsT<T, I, E>, NumThreadsT<T, I, E>, |
| 1467 | OrderedT<T, I, E>, PartialT<T, I, E>, PriorityT<T, I, E>, PrivateT<T, I, E>, |
| 1468 | ProcBindT<T, I, E>, ReverseOffloadT<T, I, E>, SafelenT<T, I, E>, |
| 1469 | SelfMapsT<T, I, E>, SeverityT<T, I, E>, SharedT<T, I, E>, SimdlenT<T, I, E>, |
| 1470 | SizesT<T, I, E>, PermutationT<T, I, E>, ThreadLimitT<T, I, E>, |
| 1471 | ThreadsetT<T, I, E>, UnifiedAddressT<T, I, E>, |
| 1472 | UnifiedSharedMemoryT<T, I, E>, UniformT<T, I, E>, |
| 1473 | UpdateDependObjectsT<T, I, E>, UseDeviceAddrT<T, I, E>, |
| 1474 | UseDevicePtrT<T, I, E>, UsesAllocatorsT<T, I, E>>; |
| 1475 | |
| 1476 | template <typename T, typename I, typename E> |
| 1477 | using UnionOfAllClausesT = typename type::Union< // |
| 1478 | EmptyClausesT<T, I, E>, // |
| 1479 | ExtensionClausesT<T, I, E>, // |
| 1480 | IncompleteClausesT<T, I, E>, // |
| 1481 | TupleClausesT<T, I, E>, // |
| 1482 | UnionClausesT<T, I, E>, // |
| 1483 | WrapperClausesT<T, I, E> // |
| 1484 | >::type; |
| 1485 | } // namespace clause |
| 1486 | |
| 1487 | using type::operator==; |
| 1488 | |
| 1489 | // The variant wrapper that encapsulates all possible specific clauses. |
| 1490 | // The `Extras` arguments are additional types representing local extensions |
| 1491 | // to the clause set, e.g. |
| 1492 | // |
| 1493 | // using Clause = ClauseT<Type, Id, Expr, |
| 1494 | // MyClause1, MyClause2>; |
| 1495 | // |
| 1496 | // The member Clause::u will be a variant containing all specific clauses |
| 1497 | // defined above, plus MyClause1 and MyClause2. |
| 1498 | // |
| 1499 | // Note: Any derived class must be constructible from the base class |
| 1500 | // ClauseT<...>. |
| 1501 | template <typename TypeType, typename IdType, typename ExprType, |
| 1502 | typename... Extras> |
| 1503 | struct ClauseT { |
| 1504 | using TypeTy = TypeType; |
| 1505 | using IdTy = IdType; |
| 1506 | using ExprTy = ExprType; |
| 1507 | |
| 1508 | // Type of "self" to specify this type given a derived class type. |
| 1509 | using BaseT = ClauseT<TypeType, IdType, ExprType, Extras...>; |
| 1510 | |
| 1511 | using VariantTy = typename type::Union< |
| 1512 | clause::UnionOfAllClausesT<TypeType, IdType, ExprType>, |
| 1513 | std::variant<Extras...>>::type; |
| 1514 | |
| 1515 | llvm::omp::Clause id; // The numeric id of the clause |
| 1516 | using UnionTrait = std::true_type; |
| 1517 | VariantTy u; |
| 1518 | }; |
| 1519 | |
| 1520 | template <typename ClauseType> struct DirectiveWithClauses { |
| 1521 | llvm::omp::Directive id = llvm::omp::Directive::OMPD_unknown; |
| 1522 | tomp::type::ListT<ClauseType> clauses; |
| 1523 | }; |
| 1524 | |
| 1525 | } // namespace tomp |
| 1526 | |
| 1527 | #undef OPT |
| 1528 | #undef ENUM |
| 1529 | |
| 1530 | #endif // LLVM_FRONTEND_OPENMP_CLAUSET_H |
| 1531 | |