LLVM 24.0.0git
OMP.h
Go to the documentation of this file.
1//===-- OMP.h - Core OpenMP definitions and declarations ---------- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the core set of OpenMP definitions and declarations.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_FRONTEND_OPENMP_OMP_H
14#define LLVM_FRONTEND_OPENMP_OMP_H
15
16#include "llvm/Frontend/OpenMP/OMP.h.inc"
18
19#include "llvm/ADT/ArrayRef.h"
20#include "llvm/ADT/Sequence.h"
22#include "llvm/ADT/StringRef.h"
23
24namespace llvm::omp {
27
29getLeafOrCompositeConstructs(Directive D, SmallVectorImpl<Directive> &Output);
30
32
33LLVM_ABI bool isLeafConstruct(Directive D);
34LLVM_ABI bool isCompositeConstruct(Directive D);
35LLVM_ABI bool isCombinedConstruct(Directive D);
36
37static constexpr inline auto clauses() {
38 return llvm::enum_seq_inclusive(Clause::First_, Clause::Last_);
39}
40
41static constexpr inline auto directives() {
42 return llvm::enum_seq_inclusive(Directive::First_, Directive::Last_);
43}
44
45/// Can clause C have an iterator-modifier.
46static constexpr inline bool canHaveIterator(Clause C) {
47 // [5.2:67:5]
48 switch (C) {
49 case OMPC_affinity:
50 case OMPC_depend:
51 case OMPC_from:
52 case OMPC_map:
53 case OMPC_to:
54 return true;
55 default:
56 return false;
57 }
58}
59
60// Can clause C create a private copy of a variable.
61static constexpr inline bool isPrivatizingClause(Clause C, unsigned Version) {
62 switch (C) {
63 case OMPC_firstprivate:
64 case OMPC_in_reduction:
65 case OMPC_lastprivate:
66 case OMPC_linear:
67 case OMPC_private:
68 case OMPC_reduction:
69 case OMPC_task_reduction:
70 return true;
71 case OMPC_detach:
72 case OMPC_induction:
73 case OMPC_is_device_ptr:
74 case OMPC_use_device_ptr:
75 return Version >= 60;
76 default:
77 return false;
78 }
79}
80
81static constexpr inline bool isDataSharingAttributeClause(Clause C,
82 unsigned Version) {
83 // The "Version" parameter is in case the result is version-depenent
84 // in the future.
85 (void)Version;
86 switch (C) {
87 case OMPC_detach:
88 case OMPC_firstprivate:
89 case OMPC_has_device_addr:
90 case OMPC_induction:
91 case OMPC_in_reduction:
92 case OMPC_is_device_ptr:
93 case OMPC_lastprivate:
94 case OMPC_linear:
95 case OMPC_private:
96 case OMPC_reduction:
97 case OMPC_shared:
98 case OMPC_task_reduction:
99 case OMPC_use_device_addr:
100 case OMPC_use_device_ptr:
101 case OMPC_uses_allocators:
102 return true;
103 default:
104 return false;
105 }
106}
107
108static constexpr inline bool isEndClause(Clause C) {
109 switch (C) {
110 case OMPC_copyprivate:
111 case OMPC_nowait:
112 return true;
113 default:
114 return false;
115 }
116}
117
118static constexpr unsigned FallbackVersion = 52;
120
121/// Can directive D, under some circumstances, create a private copy
122/// of a variable in given OpenMP version?
124
126
127/// Create a nicer version of a function name for humans to look at.
128LLVM_ABI std::string prettifyFunctionName(StringRef FunctionName);
129
130/// Deconstruct an OpenMP kernel name into the parent function name and the line
131/// number.
132LLVM_ABI std::string deconstructOpenMPKernelName(StringRef KernelName,
133 unsigned &LineNo);
134
135} // namespace llvm::omp
136
137#endif // LLVM_FRONTEND_OPENMP_OMP_H
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_ABI
Definition Compiler.h:215
Provides some synthesis utilities to produce sequences of values.
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
static constexpr auto clauses()
Definition OMP.h:37
LLVM_ABI ArrayRef< unsigned > getOpenMPVersions()
Definition OMP.cpp:212
static constexpr bool isDataSharingAttributeClause(Clause C, unsigned Version)
Definition OMP.h:81
LLVM_ABI bool isCombinedConstruct(Directive D)
Definition OMP.cpp:206
LLVM_ABI std::string deconstructOpenMPKernelName(StringRef KernelName, unsigned &LineNo)
Deconstruct an OpenMP kernel name into the parent function name and the line number.
Definition OMP.cpp:249
static constexpr bool isEndClause(Clause C)
Definition OMP.h:108
LLVM_ABI ArrayRef< Directive > getLeafOrCompositeConstructs(Directive D, SmallVectorImpl< Directive > &Output)
Definition OMP.cpp:118
LLVM_ABI bool isPrivatizingConstruct(Directive D, unsigned Version)
Can directive D, under some circumstances, create a private copy of a variable in given OpenMP versio...
Definition OMP.cpp:217
static constexpr bool canHaveIterator(Clause C)
Can clause C have an iterator-modifier.
Definition OMP.h:46
LLVM_ABI bool isCompositeConstruct(Directive D)
Definition OMP.cpp:198
LLVM_ABI Directive getCompoundConstruct(ArrayRef< Directive > Parts)
Definition OMP.cpp:145
static constexpr unsigned FallbackVersion
Definition OMP.h:118
LLVM_ABI ArrayRef< StringRef > getReservedLocatorNames()
Definition OMP.cpp:229
LLVM_ABI bool isLeafConstruct(Directive D)
Definition OMP.cpp:196
LLVM_ABI ArrayRef< Directive > getLeafConstructsOrSelf(Directive D)
Definition OMP.cpp:107
LLVM_ABI std::string prettifyFunctionName(StringRef FunctionName)
Create a nicer version of a function name for humans to look at.
Definition OMP.cpp:235
static constexpr auto directives()
Definition OMP.h:41
LLVM_ABI ArrayRef< Directive > getLeafConstructs(Directive D)
Definition OMP.cpp:99
static constexpr bool isPrivatizingClause(Clause C, unsigned Version)
Definition OMP.h:61
constexpr auto enum_seq_inclusive(EnumT Begin, EnumT End)
Iterate over an enum type from Begin to End inclusive.
Definition Sequence.h:401
ArrayRef(const T &OneElt) -> ArrayRef< T >