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
13#include "llvm/Frontend/OpenMP/OMPDescriptors.h"
14
15namespace llvm::omp {
16const DescriptorMap<Clause, descriptor::Clause> &getClauseMap() {
17 static const DescriptorMap<Clause, descriptor::Clause> Map{
18#define GEN_OMP_CLAUSE_DESCRIPTORS
19#include "OMPDescriptors.inc"
20#undef GEN_OMP_CLAUSE_DESCRIPTORS
21 };
22 return Map;
23}
24
25const DescriptorMap<Modifier, descriptor::Modifier> &getModifierMap() {
26 static const DescriptorMap<Modifier, descriptor::Modifier> Map{
27#define GEN_OMP_MODIFIER_DESCRIPTORS
28#include "OMPDescriptors.inc"
29#undef GEN_OMP_MODIFIER_DESCRIPTORS
30 };
31 return Map;
32}
33
34const DescriptorMap<ModifierSet, descriptor::ModifierSet> &getModifierSetMap() {
35 static const DescriptorMap<ModifierSet, descriptor::ModifierSet> Map{
36#define GEN_OMP_MODIFIER_GROUP_DESCRIPTORS
37#include "OMPDescriptors.inc"
38#undef GEN_OMP_MODIFIER_GROUP_DESCRIPTORS
39
40#define GEN_OMP_MODIFIER_SET_DESCRIPTORS
41#include "OMPDescriptors.inc"
42#undef GEN_OMP_MODIFIER_SET_DESCRIPTORS
43 };
44 return Map;
45}
46
47#define GET_THING_OR_EMPTY(Thing, Member) \
48 template <typename DetailsTy> \
49 static Thing get##Thing##OrEmpty(const DetailsTy &D, Version V) { \
50 V = std::max(V, Version(45)); \
51 if (auto Found = D.find(V); Found != D.end()) \
52 return Found->second.Member; \
53 return Thing{}; \
54 }
55
56GET_THING_OR_EMPTY(Clauses, Cls)
57GET_THING_OR_EMPTY(Directives, Dirs)
58GET_THING_OR_EMPTY(Modifiers, Mods)
59GET_THING_OR_EMPTY(ModifierSets, ModSets)
60GET_THING_OR_EMPTY(Properties, Props)
61
62#undef GET_THING_OR_EMPTY
63
64// Clause
65Properties descriptor::Clause::getProperties(Version V) const {
66 return getPropertiesOrEmpty(D: Details, V);
67}
68Directives descriptor::Clause::getDirectives(Version V) const {
69 return getDirectivesOrEmpty(D: Details, V);
70}
71Modifiers descriptor::Clause::getModifiers(Version V) const {
72 return getModifiersOrEmpty(D: Details, V);
73}
74ModifierSets descriptor::Clause::getModifierSets(Version V) const {
75 return getModifierSetsOrEmpty(D: Details, V);
76}
77// Modifier
78Properties descriptor::Modifier::getProperties(Version V) const {
79 return getPropertiesOrEmpty(D: Details, V);
80}
81Clauses descriptor::Modifier::getClauses(Version V) const {
82 return getClausesOrEmpty(D: Details, V);
83}
84// ModifierSet
85Properties descriptor::ModifierSet::getProperties(Version V) const {
86 return getPropertiesOrEmpty(D: Details, V);
87}
88Modifiers descriptor::ModifierSet::getModifiers(Version V) const {
89 return getModifiersOrEmpty(D: Details, V);
90}
91Clauses descriptor::ModifierSet::getClauses(Version V) const {
92 return getClausesOrEmpty(D: Details, V);
93}
94
95const descriptor::Clause &getDescriptor(llvm::omp::Clause C) {
96 return getClauseMap().at(Val: C);
97}
98const descriptor::Modifier &getDescriptor(llvm::omp::Modifier M) {
99 return getModifierMap().at(Val: M);
100}
101const descriptor::ModifierSet &getDescriptor(llvm::omp::ModifierSet S) {
102 return getModifierSetMap().at(Val: S);
103}
104
105Properties getProperties(Clause C, Version V) {
106 return getDescriptor(C).getProperties(V: std::max(a: V, b: Version(45)));
107}
108} // namespace llvm::omp
109