LLVM 24.0.0git
OMPDescriptors.cpp
Go to the documentation of this file.
1//===-- OMPDescriptors.cpp - OpenMP descriptors ------------------- 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 descriptors of OpenMP elements.
10//
11//===----------------------------------------------------------------------===//
12
14
15#include <map>
16
17// For unassociated directives the .inc file uses an "Unassociated" enum
18// (since it's the name used in the OpenMP spec), while the existing enum
19// (in OMP.h.inc) uses "None". Redefine the token "Unassociated" to "None"
20// in this file to allow the reuse of the pre-existing enum.
21#define Unassociated None
22
23namespace llvm::omp {
26#define GEN_OMP_CLAUSE_DESCRIPTORS
27#include "OMPDescriptors.inc"
28#undef GEN_OMP_CLAUSE_DESCRIPTORS
29 };
30 return Map;
31}
32
35#define GEN_OMP_CLAUSE_GROUP_DESCRIPTORS
36#include "OMPDescriptors.inc"
37#undef GEN_OMP_CLAUSE_GROUP_DESCRIPTORS
38
39#define GEN_OMP_CLAUSE_SET_DESCRIPTORS
40#include "OMPDescriptors.inc"
41#undef GEN_OMP_CLAUSE_SET_DESCRIPTORS
42 };
43 return Map;
44}
45
48#define GEN_OMP_DIRECTIVE_DESCRIPTORS
49#include "OMPDescriptors.inc"
50#undef GEN_OMP_DIRECTIVE_DESCRIPTORS
51 };
52 return Map;
53}
54
57#define GEN_OMP_MODIFIER_DESCRIPTORS
58#include "OMPDescriptors.inc"
59#undef GEN_OMP_MODIFIER_DESCRIPTORS
60 };
61 return Map;
62}
63
66#define GEN_OMP_MODIFIER_GROUP_DESCRIPTORS
67#include "OMPDescriptors.inc"
68#undef GEN_OMP_MODIFIER_GROUP_DESCRIPTORS
69
70#define GEN_OMP_MODIFIER_SET_DESCRIPTORS
71#include "OMPDescriptors.inc"
72#undef GEN_OMP_MODIFIER_SET_DESCRIPTORS
73 };
74 return Map;
75}
76
77#define GET_THING_OR_EMPTY(Thing, Member) \
78 template <typename DetailsTy> \
79 static Thing get##Thing##OrEmpty(const DetailsTy &D, Version V) { \
80 V = std::max(V, Version(45)); \
81 if (auto Found = D.find(V); Found != D.end()) \
82 return Found->second.Member; \
83 return Thing{}; \
84 }
85
92
93#undef GET_THING_OR_EMPTY
94
95// Clause
97 return getPropertiesOrEmpty(Details, V);
98}
100 return getDirectivesOrEmpty(Details, V);
101}
103 return getModifiersOrEmpty(Details, V);
104}
106 return getModifierSetsOrEmpty(Details, V);
107}
108// ClauseSet
110 return getPropertiesOrEmpty(Details, V);
111}
113 return getClausesOrEmpty(Details, V);
114}
116 return getDirectivesOrEmpty(Details, V);
117}
118// Directive
120 return getPropertiesOrEmpty(Details, V);
121}
123 return Details.at(std::max(V, Version(45))).Assoc;
124}
126 return Details.at(std::max(V, Version(45))).Cat;
127}
129 return getClausesOrEmpty(Details, V);
130}
132 return getClauseSetsOrEmpty(Details, V);
133}
134
135// Modifier
137 return getPropertiesOrEmpty(Details, V);
138}
140 return getClausesOrEmpty(Details, V);
141}
142// ModifierSet
144 return getPropertiesOrEmpty(Details, V);
145}
147 return getModifiersOrEmpty(Details, V);
148}
150 return getClausesOrEmpty(Details, V);
151}
152
154 return getClauseMap().at(C);
155}
156
160
163 if (Leafs.size() == 1)
164 return getDirectiveMap().at(Leafs[0]);
165
166 static std::map<Directive, descriptor::Directive> Compound;
167 if (auto F = Compound.find(D); F != Compound.end())
168 return F->second;
169
170 // Combine details from all leafs into a single map and create a descriptor
171 // from it.
172 using Details = descriptor::details::Directive;
174 DetailsMap Det;
175 // The name of the descriptor will be the spelling from the latest supported
176 // version.
177 llvm::omp::Version MaxV(0);
178
179 for (llvm::omp::Directive L : Leafs) {
180 const auto &Desc{getDescriptor(L)};
181 for (auto &[V, T] : Desc.getDetails()) {
182 MaxV = std::max(MaxV, V); // Used for descriptor's name.
183 auto F = Det.insert({V, Details{}}).first;
184 // Compound directives do not have properties. Their semantics or
185 // restrictions need to be inferred from the properties of their
186 // constituents.
187 F->second.Spelling = getOpenMPDirectiveName(D, V);
188 // The category should be the same for all of them (i.e. executable),
189 // the association of the last one is the association of the whole
190 // directive. Since the leafs are ordered from the outermost to the
191 // innermost it is safe to simply overwrite the non-set members each
192 // time.
193 F->second.Assoc = T.Assoc;
194 F->second.Cat = T.Cat;
195 F->second.Cls |= T.Cls;
196 F->second.ClsSets |= T.ClsSets;
197 }
198 }
199
200 auto At =
201 Compound.try_emplace(D, getOpenMPDirectiveName(D, MaxV), std::move(Det));
202 return At.first->second;
203}
204
206 return getModifierMap().at(M);
207}
208
212
214 return getDescriptor(C).getProperties(std::max(V, Version(45)));
215}
216} // namespace llvm::omp
217
218#undef Unassociated
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define F(x, y, z)
Definition MD5.cpp:54
#define T
#define GET_THING_OR_EMPTY(Thing, Member)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
DenseMap< Version, DetailsTy > DetailsMap
EnumSet< Modifier > Modifiers
LLVM_ABI const descriptor::Clause & getDescriptor(Clause C)
EnumSet< Directive > Directives
Definition OMP.h:159
EnumSet< ClauseSet > ClauseSets
const DescriptorMap< Clause, descriptor::Clause > & getClauseMap()
EnumSet< Clause > Clauses
Definition OMP.h:158
EnumSet< ModifierSet > ModifierSets
LLVM_ABI ArrayRef< Directive > getLeafConstructsOrSelf(Directive D)
Definition OMP.cpp:106
const DescriptorMap< ClauseSet, descriptor::ClauseSet > & getClauseSetMap()
DenseMap< Enum, DescriptorTy > DescriptorMap
LLVM_ABI Properties getProperties(Clause C, Version V)
const DescriptorMap< ModifierSet, descriptor::ModifierSet > & getModifierSetMap()
const DescriptorMap< Modifier, descriptor::Modifier > & getModifierMap()
EnumSet< Property > Properties
const DescriptorMap< Directive, descriptor::Directive > & getDirectiveMap()
Op::Description Desc
LLVM_ABI Clauses getClauses(Version V) const
LLVM_ABI Directives getDirectives(Version V) const
LLVM_ABI Properties getProperties(Version V) const
LLVM_ABI Modifiers getModifiers(Version V) const
LLVM_ABI ModifierSets getModifierSets(Version V) const
LLVM_ABI Directives getDirectives(Version V) const
LLVM_ABI Properties getProperties(Version V) const
LLVM_ABI Association getAssociation(Version V) const
LLVM_ABI Clauses getClauses(Version V) const
LLVM_ABI ClauseSets getClauseSets(Version V) const
LLVM_ABI Properties getProperties(Version V) const
LLVM_ABI Category getCategory(Version V) const
LLVM_ABI Clauses getClauses(Version V) const
LLVM_ABI Modifiers getModifiers(Version V) const
LLVM_ABI Properties getProperties(Version V) const
LLVM_ABI Clauses getClauses(Version V) const
LLVM_ABI Properties getProperties(Version V) const