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 19 #include "llvm/ADT/StringRef.h" 20 #include "llvm/Frontend/OpenMP/OMP.h.inc" 21 22 namespace llvm { 23 class Type; 24 class Module; 25 class ArrayType; 26 class StructType; 27 class PointerType; 28 class StringRef; 29 class FunctionType; 30 31 namespace omp { 32 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); 33 34 /// IDs for all Internal Control Variables (ICVs). 35 enum class InternalControlVar { 36 #define ICV_DATA_ENV(Enum, ...) Enum, 37 #include "llvm/Frontend/OpenMP/OMPKinds.def" 38 }; 39 40 #define ICV_DATA_ENV(Enum, ...) \ 41 constexpr auto Enum = omp::InternalControlVar::Enum; 42 #include "llvm/Frontend/OpenMP/OMPKinds.def" 43 44 enum class ICVInitValue { 45 #define ICV_INIT_VALUE(Enum, Name) Enum, 46 #include "llvm/Frontend/OpenMP/OMPKinds.def" 47 }; 48 49 #define ICV_INIT_VALUE(Enum, Name) \ 50 constexpr auto Enum = omp::ICVInitValue::Enum; 51 #include "llvm/Frontend/OpenMP/OMPKinds.def" 52 53 /// IDs for all omp runtime library (RTL) functions. 54 enum class RuntimeFunction { 55 #define OMP_RTL(Enum, ...) Enum, 56 #include "llvm/Frontend/OpenMP/OMPKinds.def" 57 }; 58 59 #define OMP_RTL(Enum, ...) constexpr auto Enum = omp::RuntimeFunction::Enum; 60 #include "llvm/Frontend/OpenMP/OMPKinds.def" 61 62 /// IDs for the different default kinds. 63 enum class DefaultKind { 64 #define OMP_DEFAULT_KIND(Enum, Str) Enum, 65 #include "llvm/Frontend/OpenMP/OMPKinds.def" 66 }; 67 68 #define OMP_DEFAULT_KIND(Enum, ...) \ 69 constexpr auto Enum = omp::DefaultKind::Enum; 70 #include "llvm/Frontend/OpenMP/OMPKinds.def" 71 72 /// IDs for all omp runtime library ident_t flag encodings (see 73 /// their defintion in openmp/runtime/src/kmp.h). 74 enum class IdentFlag { 75 #define OMP_IDENT_FLAG(Enum, Str, Value) Enum = Value, 76 #include "llvm/Frontend/OpenMP/OMPKinds.def" 77 LLVM_MARK_AS_BITMASK_ENUM(0x7FFFFFFF) 78 }; 79 80 #define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum; 81 #include "llvm/Frontend/OpenMP/OMPKinds.def" 82 83 /// Helper to describe assume clauses. 84 struct AssumptionClauseMappingInfo { 85 /// The identifier describing the (beginning of the) clause. 86 llvm::StringLiteral Identifier; 87 /// Flag to determine if the identifier is a full name or the start of a name. 88 bool StartsWith; 89 /// Flag to determine if a directive lists follows. 90 bool HasDirectiveList; 91 /// Flag to determine if an expression follows. 92 bool HasExpression; 93 }; 94 95 /// All known assume clauses. 96 static constexpr AssumptionClauseMappingInfo AssumptionClauseMappings[] = { 97 #define OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, \ 98 HasExpression) \ 99 {Identifier, StartsWith, HasDirectiveList, HasExpression}, 100 #include "llvm/Frontend/OpenMP/OMPKinds.def" 101 }; 102 103 inline std::string getAllAssumeClauseOptions() { 104 std::string S; 105 for (const AssumptionClauseMappingInfo &ACMI : AssumptionClauseMappings) 106 S += (S.empty() ? "'" : "', '") + ACMI.Identifier.str(); 107 return S + "'"; 108 } 109 110 } // end namespace omp 111 112 } // end namespace llvm 113 114 #endif // LLVM_OPENMP_CONSTANTS_H 115