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
111namespace detail {
112// Type trait to determine whether T is a specialization of std::variant.
113template <typename T> struct is_variant {
114 static constexpr bool value = false;
115};
116
117template <typename... Ts> struct is_variant<std::variant<Ts...>> {
118 static constexpr bool value = true;
119};
120
121template <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.
124template <typename...> struct UnionOfTwo;
125
126template <typename... Types1, typename... Types2>
127struct UnionOfTwo<std::variant<Types1...>, std::variant<Types2...>> {
128 using type = std::variant<Types1..., Types2...>;
129};
130} // namespace detail
131
132namespace tomp {
133namespace type {
134
135// Helper utility to create a type which is a union of an arbitrary number
136// of variants.
137template <typename...> struct Union;
138
139template <> struct Union<> {
140 // Legal to define, illegal to instantiate.
141 using type = std::variant<>;
142};
143
144template <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
150template <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.
180template <typename IdType, typename ExprType> struct ObjectT;
181
182// By default, object equality is only determined by its identity.
183template <typename I, typename E>
184bool operator==(const ObjectT<I, E> &o1, const ObjectT<I, E> &o2) {
185 return o1.id() == o2.id();
186}
187
188template <typename I, typename E> using ObjectListT = ListT<ObjectT<I, E>>;
189
190using DirectiveName = llvm::omp::Directive;
191
192template <typename I, typename E> //
193struct 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
200template <typename I, typename E> //
201struct 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
208template <typename I, typename E> //
209struct 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
219template <typename E> //
220struct 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
227template <typename TypeType, typename IdType, typename ExprType> //
228struct 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
243template <typename I, typename E> //
244struct 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`.
252ENUM(MemoryOrder, AcqRel, Acquire, Relaxed, Release, SeqCst);
253ENUM(MotionExpectation, Present);
254// Union of `dependence-type` and `task-depenence-type`.
255// V5.2: [15.9.1] `task-dependence-type` modifier
256ENUM(DependenceType, Depobj, In, Inout, Inoutset, Mutexinoutset, Out, Sink,
257 Source);
258ENUM(Prescriptiveness, Strict);
259
260template <typename I, typename E> //
261struct 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
270template <typename I, typename E> //
271struct 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.
283template <typename I, typename E> //
284struct ReductionIdentifierT {
285 using UnionTrait = std::true_type;
286 std::variant<DefinedOperatorT<I, E>, ProcedureDesignatorT<I, E>> u;
287};
288
289template <typename T, typename I, typename E> //
290using IteratorT = ListT<IteratorSpecifierT<T, I, E>>;
291
292template <typename T>
293std::enable_if_t<T::EmptyTrait::value, bool> operator==(const T &a,
294 const T &b) {
295 return true;
296}
297template <typename T>
298std::enable_if_t<T::IncompleteTrait::value, bool> operator==(const T &a,
299 const T &b) {
300 return true;
301}
302template <typename T>
303std::enable_if_t<T::WrapperTrait::value, bool> operator==(const T &a,
304 const T &b) {
305 return a.v == b.v;
306}
307template <typename T>
308std::enable_if_t<T::TupleTrait::value, bool> operator==(const T &a,
309 const T &b) {
310 return a.t == b.t;
311}
312template <typename T>
313std::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
319template <typename T> using ListT = type::ListT<T>;
320
321template <typename I, typename E> using ObjectT = type::ObjectT<I, E>;
322template <typename I, typename E> using ObjectListT = type::ObjectListT<I, E>;
323
324template <typename T, typename I, typename E>
325using IteratorT = type::IteratorT<T, I, E>;
326
327template <
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>>
331ListT<ResultTy> makeList(ContainerTy &&container, FunctionTy &&func) {
332 ListT<ResultTy> v;
333 llvm::transform(container, std::back_inserter(v), func);
334 return v;
335}
336
337namespace clause {
338using type::operator==;
339
340// V5.2: [8.3.1] `assumption` clauses
341template <typename T, typename I, typename E> //
342struct 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
349template <typename T, typename I, typename E> //
350struct AcqRelT {
351 using EmptyTrait = std::true_type;
352};
353
354// V5.2: [15.8.1] `memory-order` clauses
355template <typename T, typename I, typename E> //
356struct AcquireT {
357 using EmptyTrait = std::true_type;
358};
359
360// V5.2: [7.5.2] `adjust_args` clause
361template <typename T, typename I, typename E> //
362struct AdjustArgsT {
363 using IncompleteTrait = std::true_type;
364};
365
366// V5.2: [12.5.1] `affinity` clause
367template <typename T, typename I, typename E> //
368struct 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
377template <typename T, typename I, typename E> //
378struct AlignT {
379 using Alignment = E;
380
381 using WrapperTrait = std::true_type;
382 Alignment v;
383};
384
385// V5.2: [5.11] `aligned` clause
386template <typename T, typename I, typename E> //
387struct 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
395template <typename T, typename I, typename E> //
396struct AllocatorT;
397
398// V5.2: [6.6] `allocate` clause
399template <typename T, typename I, typename E> //
400struct 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
411template <typename T, typename I, typename E> //
412struct 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
419template <typename T, typename I, typename E> //
420struct AppendArgsT {
421 using IncompleteTrait = std::true_type;
422};
423
424// [6.0:372-373]
425template <typename T, typename I, typename E> //
426struct ApplyT {
427 using IncompleteTrait = std::true_type;
428};
429
430// V5.2: [8.1] `at` clause
431template <typename T, typename I, typename E> //
432struct 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
439template <typename T, typename I, typename E> //
440struct 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
447template <typename T, typename I, typename E> //
448struct 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
455template <typename T, typename I, typename E> //
456struct CaptureT {
457 using EmptyTrait = std::true_type;
458};
459
460// V5.2: [4.4.3] `collapse` clause
461template <typename T, typename I, typename E> //
462struct CollapseT {
463 using N = E;
464 using WrapperTrait = std::true_type;
465 N v;
466};
467
468// [6.0:266]
469template <typename T, typename I, typename E> //
470struct CollectorT {
471 using IncompleteTrait = std::true_type;
472};
473
474// [6.0:262]
475template <typename T, typename I, typename E> //
476struct 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
483template <typename T, typename I, typename E> //
484struct CompareT {
485 using EmptyTrait = std::true_type;
486};
487
488// V5.2: [8.3.1] `assumption` clauses
489template <typename T, typename I, typename E> //
490struct 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
497template <typename T, typename I, typename E> //
498struct 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
505template <typename T, typename I, typename E> //
506struct CopyprivateT {
507 using List = ObjectListT<I, E>;
508 using WrapperTrait = std::true_type;
509 List v;
510};
511
512// [6.0:378-379]
513template <typename T, typename I, typename E> //
514struct CountsT {
515 using IncompleteTrait = std::true_type;
516};
517
518// V5.2: [5.4.1] `default` clause
519template <typename T, typename I, typename E> //
520struct 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
527template <typename T, typename I, typename E> //
528struct 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
537template <typename T, typename I, typename E> //
538struct 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]
555template <typename T, typename I, typename E> //
556struct DepthT {
557 using DepthExpr = E;
558 using WrapperTrait = std::true_type;
559 DepthExpr v;
560};
561
562// V5.2: [3.5] `destroy` clause
563template <typename T, typename I, typename E> //
564struct 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
572template <typename T, typename I, typename E> //
573struct 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
580template <typename T, typename I, typename E> //
581struct 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]
589template <typename T, typename I, typename E> //
590struct 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
597template <typename T, typename I, typename E> //
598struct 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
605template <typename T, typename I, typename E> //
606struct 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
614template <typename T, typename I, typename E> //
615struct 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
624template <typename T, typename I, typename E> //
625struct DynamicAllocatorsT {
626 using Requires = E;
627 using WrapperTrait = std::true_type;
628 OPT(Requires) v;
629};
630
631template <typename T, typename I, typename E> //
632struct 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
641template <typename T, typename I, typename E> //
642struct 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
650template <typename T, typename I, typename E> //
651struct 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
658template <typename T, typename I, typename E> //
659struct 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
666template <typename T, typename I, typename E> //
667struct FilterT {
668 using ThreadNum = E;
669 using WrapperTrait = std::true_type;
670 ThreadNum v;
671};
672
673// V5.2: [12.3] `final` clause
674template <typename T, typename I, typename E> //
675struct FinalT {
676 using Finalize = E;
677 using WrapperTrait = std::true_type;
678 Finalize v;
679};
680
681// V5.2: [5.4.4] `firstprivate` clause
682template <typename T, typename I, typename E> //
683struct 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
690template <typename T, typename I, typename E> //
691struct 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
703template <typename T, typename I, typename E> //
704struct FullT {
705 using EmptyTrait = std::true_type;
706};
707
708// V5.2: [12.6.1] `grainsize` clause
709template <typename T, typename I, typename E> //
710struct 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
718template <typename T, typename I, typename E> //
719struct GraphIdT {
720 using IncompleteTrait = std::true_type;
721};
722
723// [6.0:438] `graph_reset` clause
724template <typename T, typename I, typename E> //
725struct GraphResetT {
726 using IncompleteTrait = std::true_type;
727};
728
729// V5.2: [5.4.9] `has_device_addr` clause
730template <typename T, typename I, typename E> //
731struct 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
738template <typename T, typename I, typename E> //
739struct HintT {
740 using HintExpr = E;
741 using WrapperTrait = std::true_type;
742 HintExpr v;
743};
744
745// V5.2: [8.3.1] Assumption clauses
746template <typename T, typename I, typename E> //
747struct 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
753template <typename T, typename I, typename E> //
754struct 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
762template <typename T, typename I, typename E> //
763struct InbranchT {
764 using EmptyTrait = std::true_type;
765};
766
767// V5.2: [5.6.1] `exclusive` clause
768template <typename T, typename I, typename E> //
769struct 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
776template <typename T, typename I, typename E> //
777struct IndirectT {
778 using InvokedByFptr = E;
779 using WrapperTrait = std::true_type;
780 OPT(InvokedByFptr) v;
781};
782
783// [6.0:257-261]
784template <typename T, typename I, typename E> //
785struct InductionT {
786 using IncompleteTrait = std::true_type;
787};
788
789// [6.0:265-266]
790template <typename T, typename I, typename E> //
791struct InductorT {
792 using IncompleteTrait = std::true_type;
793};
794
795// V5.2: [14.1.2] `init` clause
796template <typename T, typename I, typename E> //
797struct 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]
809template <typename T, typename I, typename E> //
810struct InitCompleteT {
811 using IncompleteTrait = std::true_type;
812};
813
814// V5.2: [5.5.4] `initializer` clause
815template <typename T, typename I, typename E> //
816struct 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
823template <typename T, typename I, typename E> //
824struct 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]
834template <typename T, typename I, typename E> //
835struct InteropT {
836 using IncompleteTrait = std::true_type;
837};
838
839// V5.2: [5.4.7] `is_device_ptr` clause
840template <typename T, typename I, typename E> //
841struct 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
848template <typename T, typename I, typename E> //
849struct 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
857template <typename T, typename I, typename E> //
858struct 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
871template <typename T, typename I, typename E> //
872struct LinkT {
873 using List = ObjectListT<I, E>;
874 using WrapperTrait = std::true_type;
875 List v;
876};
877
878// [6.0:303]
879template <typename T, typename I, typename E> //
880struct LocalT {
881 using IncompleteTrait = std::true_type;
882};
883
884// V6: [6.4.7] Looprange clause
885template <typename T, typename I, typename E> //
886struct 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
895template <typename T, typename I, typename E> //
896struct 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
914template <typename T, typename I, typename E> //
915struct MatchT {
916 using IncompleteTrait = std::true_type;
917};
918
919// [6.0:493-494]
920template <typename T, typename I, typename E> //
921struct MemscopeT {
922 using IncompleteTrait = std::true_type;
923};
924
925// V5.2: [12.2] `mergeable` clause
926template <typename T, typename I, typename E> //
927struct MergeableT {
928 using EmptyTrait = std::true_type;
929};
930
931// V5.2: [8.5.2] `message` clause
932template <typename T, typename I, typename E> //
933struct MessageT {
934 using MsgString = E;
935 using WrapperTrait = std::true_type;
936 MsgString v;
937};
938
939// V5.2: [7.6.2] `nocontext` clause
940template <typename T, typename I, typename E> //
941struct NocontextT {
942 using DoNotUpdateContext = E;
943 using WrapperTrait = std::true_type;
944 DoNotUpdateContext v;
945};
946
947// V5.2: [15.7] `nowait` clause
948template <typename T, typename I, typename E> //
949struct NogroupT {
950 using EmptyTrait = std::true_type;
951};
952
953// V5.2: [10.4.1] `nontemporal` clause
954template <typename T, typename I, typename E> //
955struct 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
962template <typename T, typename I, typename E> //
963struct NoOpenmpT {
964 using EmptyTrait = std::true_type;
965};
966
967// V6.0: [10.6.1] `assumption` clauses
968template <typename T, typename I, typename E> //
969struct NoOpenmpConstructsT {
970 using EmptyTrait = std::true_type;
971};
972
973// V5.2: [8.3.1] `assumption` clauses
974template <typename T, typename I, typename E> //
975struct NoOpenmpRoutinesT {
976 using EmptyTrait = std::true_type;
977};
978
979// V5.2: [8.3.1] `assumption` clauses
980template <typename T, typename I, typename E> //
981struct NoParallelismT {
982 using EmptyTrait = std::true_type;
983};
984
985// V5.2: [7.7.1] `branch` clauses
986template <typename T, typename I, typename E> //
987struct NotinbranchT {
988 using EmptyTrait = std::true_type;
989};
990
991// V5.2: [7.6.1] `novariants` clause
992template <typename T, typename I, typename E> //
993struct NovariantsT {
994 using DoNotUseVariant = E;
995 using WrapperTrait = std::true_type;
996 DoNotUseVariant v;
997};
998
999// V5.2: [15.6] `nowait` clause
1000template <typename T, typename I, typename E> //
1001struct NowaitT {
1002 using EmptyTrait = std::true_type;
1003};
1004
1005// V5.2: [12.6.2] `num_tasks` clause
1006template <typename T, typename I, typename E> //
1007struct 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
1016template <typename T, typename I, typename E> //
1017struct 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
1029template <typename T, typename I, typename E> //
1030struct NumThreadsT {
1031 using Nthreads = E;
1032 using List = ListT<Nthreads>;
1033 using WrapperTrait = std::true_type;
1034 List v;
1035};
1036
1037template <typename T, typename I, typename E> //
1038struct OmpxAttributeT {
1039 using EmptyTrait = std::true_type;
1040};
1041
1042template <typename T, typename I, typename E> //
1043struct OmpxBareT {
1044 using EmptyTrait = std::true_type;
1045};
1046
1047template <typename T, typename I, typename E> //
1048struct OmpxDynCgroupMemT {
1049 using WrapperTrait = std::true_type;
1050 E v;
1051};
1052
1053// V5.2: [10.3] `order` clause
1054template <typename T, typename I, typename E> //
1055struct 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
1063template <typename T, typename I, typename E> //
1064struct 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
1071template <typename T, typename I, typename E> //
1072struct OtherwiseT {
1073 using IncompleteTrait = std::true_type;
1074};
1075
1076// V5.2: [9.2.2] `partial` clause
1077template <typename T, typename I, typename E> //
1078struct PartialT {
1079 using UnrollFactor = E;
1080 using WrapperTrait = std::true_type;
1081 OPT(UnrollFactor) v;
1082};
1083
1084// V6.0: `permutation` clause
1085template <typename T, typename I, typename E> //
1086struct PermutationT {
1087 using ArgList = ListT<E>;
1088 using WrapperTrait = std::true_type;
1089 ArgList v;
1090};
1091
1092// V5.2: [12.4] `priority` clause
1093template <typename T, typename I, typename E> //
1094struct PriorityT {
1095 using PriorityValue = E;
1096 using WrapperTrait = std::true_type;
1097 PriorityValue v;
1098};
1099
1100// V5.2: [5.4.3] `private` clause
1101template <typename T, typename I, typename E> //
1102struct 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
1109template <typename T, typename I, typename E> //
1110struct 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
1117template <typename T, typename I, typename E> //
1118struct ReadT {
1119 using EmptyTrait = std::true_type;
1120};
1121
1122// V5.2: [5.5.8] `reduction` clause
1123template <typename T, typename I, typename E> //
1124struct 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
1135template <typename T, typename I, typename E> //
1136struct ReductionKindT {
1137 using IncompleteTrait = std::true_type;
1138};
1139
1140// V5.2: [15.8.1] `memory-order` clauses
1141template <typename T, typename I, typename E> //
1142struct RelaxedT {
1143 using EmptyTrait = std::true_type;
1144};
1145
1146// V5.2: [15.8.1] `memory-order` clauses
1147template <typename T, typename I, typename E> //
1148struct ReleaseT {
1149 using EmptyTrait = std::true_type;
1150};
1151
1152// [6.0:440-441] `replayable` clause
1153template <typename T, typename I, typename E> //
1154struct ReplayableT {
1155 using IncompleteTrait = std::true_type;
1156};
1157
1158// V5.2: [8.2.1] `requirement` clauses
1159template <typename T, typename I, typename E> //
1160struct 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
1167template <typename T, typename I, typename E> //
1168struct SafelenT {
1169 using Length = E;
1170 using WrapperTrait = std::true_type;
1171 Length v;
1172};
1173
1174// [6.0:393]
1175template <typename T, typename I, typename E> //
1176struct SafesyncT {
1177 using IncompleteTrait = std::true_type;
1178};
1179
1180// V5.2: [11.5.3] `schedule` clause
1181template <typename T, typename I, typename E> //
1182struct 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]
1192template <typename T, typename I, typename E> //
1193struct 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
1200template <typename T, typename I, typename E> //
1201struct SeqCstT {
1202 using EmptyTrait = std::true_type;
1203};
1204
1205// V5.2: [8.5.1] `severity` clause
1206template <typename T, typename I, typename E> //
1207struct 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
1214template <typename T, typename I, typename E> //
1215struct SharedT {
1216 using List = ObjectListT<I, E>;
1217 using WrapperTrait = std::true_type;
1218 List v;
1219};
1220
1221// TR15:408-409
1222template <typename T, typename I, typename E> //
1223struct ShiftT {
1224 using IncompleteTrait = std::true_type;
1225};
1226
1227// V5.2: [15.10.3] `parallelization-level` clauses
1228template <typename T, typename I, typename E> //
1229struct SimdT {
1230 using EmptyTrait = std::true_type;
1231};
1232
1233// V5.2: [10.4.3] `simdlen` clause
1234template <typename T, typename I, typename E> //
1235struct SimdlenT {
1236 using Length = E;
1237 using WrapperTrait = std::true_type;
1238 Length v;
1239};
1240
1241// V5.2: [9.1.1] `sizes` clause
1242template <typename T, typename I, typename E> //
1243struct 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
1250template <typename T, typename I, typename E> //
1251struct 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
1262template <typename T, typename I, typename E> //
1263struct 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
1271template <typename T, typename I, typename E> //
1272struct ThreadsT {
1273 using EmptyTrait = std::true_type;
1274};
1275
1276// V6.0: [14.8] `threadset` clause
1277template <typename T, typename I, typename E> //
1278struct 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
1285template <typename T, typename I, typename E> //
1286struct 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
1298template <typename T, typename I, typename E> //
1299struct TransparentT {
1300 using IncompleteTrait = std::true_type;
1301};
1302
1303// V5.2: [8.2.1] `requirement` clauses
1304template <typename T, typename I, typename E> //
1305struct 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
1312template <typename T, typename I, typename E> //
1313struct UnifiedSharedMemoryT {
1314 using Requires = E;
1315 using WrapperTrait = std::true_type;
1316 OPT(Requires) v;
1317};
1318
1319// V5.2: [5.10] `uniform` clause
1320template <typename T, typename I, typename E> //
1321struct UniformT {
1322 using ParameterList = ObjectListT<I, E>;
1323 using WrapperTrait = std::true_type;
1324 ParameterList v;
1325};
1326
1327template <typename T, typename I, typename E> //
1328struct UnknownT {
1329 using EmptyTrait = std::true_type;
1330};
1331
1332// V5.2: [12.1] `untied` clause
1333template <typename T, typename I, typename E> //
1334struct 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
1341template <typename T, typename I, typename E> //
1342struct UpdateT {
1343 using EmptyTrait = std::true_type;
1344};
1345
1346template <typename T, typename I, typename E> //
1347struct 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
1354template <typename T, typename I, typename E> //
1355struct 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
1362template <typename T, typename I, typename E> //
1363struct 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
1370template <typename T, typename I, typename E> //
1371struct 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
1378template <typename T, typename I, typename E> //
1379struct 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
1393template <typename T, typename I, typename E> //
1394struct WeakT {
1395 using EmptyTrait = std::true_type;
1396};
1397
1398// V5.2: [7.4.1] `when` clause
1399template <typename T, typename I, typename E> //
1400struct WhenT {
1401 using IncompleteTrait = std::true_type;
1402};
1403
1404// V5.2: [15.8.2] Atomic clauses
1405template <typename T, typename I, typename E> //
1406struct WriteT {
1407 using EmptyTrait = std::true_type;
1408};
1409
1410// ---
1411
1412template <typename T, typename I, typename E>
1413using ExtensionClausesT =
1414 std::variant<OmpxAttributeT<T, I, E>, OmpxBareT<T, I, E>,
1415 OmpxDynCgroupMemT<T, I, E>>;
1416
1417template <typename T, typename I, typename E>
1418using 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
1428template <typename T, typename I, typename E>
1429using 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
1439template <typename T, typename I, typename E>
1440using 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
1450template <typename T, typename I, typename E>
1451using UnionClausesT = std::variant<DependT<T, I, E>>;
1452
1453template <typename T, typename I, typename E>
1454using 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
1476template <typename T, typename I, typename E>
1477using 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
1487using 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<...>.
1501template <typename TypeType, typename IdType, typename ExprType,
1502 typename... Extras>
1503struct 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
1520template <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