]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / include / llvm / Frontend / OpenMP / OMPConstants.h
1 //===- OMPConstants.h - OpenMP related constants and helpers ------ 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 /// \file
9 ///
10 /// This file defines constans and helpers used when dealing with OpenMP.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_OPENMP_CONSTANTS_H
15 #define LLVM_OPENMP_CONSTANTS_H
16
17 #include "llvm/ADT/BitmaskEnum.h"
18 #include "llvm/ADT/StringRef.h"
19
20 namespace llvm {
21 class Type;
22 class Module;
23 class StructType;
24 class PointerType;
25 class FunctionType;
26
27 namespace omp {
28 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
29
30 /// IDs for all OpenMP directives.
31 enum class Directive {
32 #define OMP_DIRECTIVE(Enum, ...) Enum,
33 #include "llvm/Frontend/OpenMP/OMPKinds.def"
34 };
35
36 /// Make the enum values available in the llvm::omp namespace. This allows us to
37 /// write something like OMPD_parallel if we have a `using namespace omp`. At
38 /// the same time we do not loose the strong type guarantees of the enum class,
39 /// that is we cannot pass an unsigned as Directive without an explicit cast.
40 #define OMP_DIRECTIVE(Enum, ...) constexpr auto Enum = omp::Directive::Enum;
41 #include "llvm/Frontend/OpenMP/OMPKinds.def"
42
43 /// IDs for all omp runtime library (RTL) functions.
44 enum class RuntimeFunction {
45 #define OMP_RTL(Enum, ...) Enum,
46 #include "llvm/Frontend/OpenMP/OMPKinds.def"
47 };
48
49 #define OMP_RTL(Enum, ...) constexpr auto Enum = omp::RuntimeFunction::Enum;
50 #include "llvm/Frontend/OpenMP/OMPKinds.def"
51
52 /// IDs for the different proc bind kinds.
53 enum class ProcBindKind {
54 #define OMP_PROC_BIND_KIND(Enum, Str, Value) Enum = Value,
55 #include "llvm/Frontend/OpenMP/OMPKinds.def"
56 };
57
58 #define OMP_PROC_BIND_KIND(Enum, ...)                                          \
59   constexpr auto Enum = omp::ProcBindKind::Enum;
60 #include "llvm/Frontend/OpenMP/OMPKinds.def"
61
62 /// IDs for all omp runtime library ident_t flag encodings (see
63 /// their defintion in openmp/runtime/src/kmp.h).
64 enum class IdentFlag {
65 #define OMP_IDENT_FLAG(Enum, Str, Value) Enum = Value,
66 #include "llvm/Frontend/OpenMP/OMPKinds.def"
67   LLVM_MARK_AS_BITMASK_ENUM(0x7FFFFFFF)
68 };
69
70 #define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum;
71 #include "llvm/Frontend/OpenMP/OMPKinds.def"
72
73 /// Parse \p Str and return the directive it matches or OMPD_unknown if none.
74 Directive getOpenMPDirectiveKind(StringRef Str);
75
76 /// Return a textual representation of the directive \p D.
77 StringRef getOpenMPDirectiveName(Directive D);
78
79 /// Forward declarations for LLVM-IR types (simple, function and structure) are
80 /// generated below. Their names are defined and used in OpenMP/OMPKinds.def.
81 /// Here we provide the forward declarations, the initializeTypes function will
82 /// provide the values.
83 ///
84 ///{
85 namespace types {
86
87 #define OMP_TYPE(VarName, InitValue) extern Type *VarName;
88 #define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...)                  \
89   extern FunctionType *VarName;                                                \
90   extern PointerType *VarName##Ptr;
91 #define OMP_STRUCT_TYPE(VarName, StrName, ...)                                 \
92   extern StructType *VarName;                                                  \
93   extern PointerType *VarName##Ptr;
94 #include "llvm/Frontend/OpenMP/OMPKinds.def"
95
96 /// Helper to initialize all types defined in OpenMP/OMPKinds.def.
97 void initializeTypes(Module &M);
98
99 /// Helper to uninitialize all types defined in OpenMP/OMPKinds.def.
100 void uninitializeTypes();
101
102 } // namespace types
103 ///}
104
105 } // end namespace omp
106
107 } // end namespace llvm
108
109 #endif // LLVM_OPENMP_CONSTANTS_H