1 //===- OMPConstants.h - OpenMP related constants and helpers ------ C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 /// This file defines constans and helpers used when dealing with OpenMP.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_OPENMP_CONSTANTS_H
15 #define LLVM_OPENMP_CONSTANTS_H
17 #include "llvm/ADT/BitmaskEnum.h"
18 #include "llvm/ADT/StringRef.h"
28 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
30 /// IDs for all OpenMP directives.
31 enum class Directive {
32 #define OMP_DIRECTIVE(Enum, ...) Enum,
33 #include "llvm/Frontend/OpenMP/OMPKinds.def"
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"
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"
49 #define OMP_RTL(Enum, ...) constexpr auto Enum = omp::RuntimeFunction::Enum;
50 #include "llvm/Frontend/OpenMP/OMPKinds.def"
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"
58 #define OMP_PROC_BIND_KIND(Enum, ...) \
59 constexpr auto Enum = omp::ProcBindKind::Enum;
60 #include "llvm/Frontend/OpenMP/OMPKinds.def"
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)
70 #define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum;
71 #include "llvm/Frontend/OpenMP/OMPKinds.def"
73 /// Parse \p Str and return the directive it matches or OMPD_unknown if none.
74 Directive getOpenMPDirectiveKind(StringRef Str);
76 /// Return a textual representation of the directive \p D.
77 StringRef getOpenMPDirectiveName(Directive D);
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.
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"
96 /// Helper to initialize all types defined in OpenMP/OMPKinds.def.
97 void initializeTypes(Module &M);
99 /// Helper to uninitialize all types defined in OpenMP/OMPKinds.def.
100 void uninitializeTypes();
105 } // end namespace omp
107 } // end namespace llvm
109 #endif // LLVM_OPENMP_CONSTANTS_H