171088Sjasone//===- OMPConstants.h - OpenMP related constants and helpers ------ C++ -*-===// 271088Sjasone// 371088Sjasone// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 471088Sjasone// See https://llvm.org/LICENSE.txt for license information. 571088Sjasone// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 671088Sjasone// 771088Sjasone//===----------------------------------------------------------------------===// 871088Sjasone/// \file 971088Sjasone/// 1071088Sjasone/// This file defines constans and helpers used when dealing with OpenMP. 1171088Sjasone/// 1271088Sjasone//===----------------------------------------------------------------------===// 1371088Sjasone 1471088Sjasone#ifndef LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H 1571088Sjasone#define LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H 1671088Sjasone 1771088Sjasone#include "llvm/ADT/BitmaskEnum.h" 1871088Sjasone 1971088Sjasone#include "llvm/ADT/StringRef.h" 2071088Sjasone#include "llvm/Frontend/OpenMP/OMP.h.inc" 2171088Sjasone 2271088Sjasonenamespace llvm { 2371088Sjasoneclass Type; 2471088Sjasoneclass Module; 2571088Sjasoneclass ArrayType; 2671088Sjasoneclass StructType; 2771088Sjasoneclass PointerType; 2871088Sjasoneclass StringRef; 2971088Sjasoneclass FunctionType; 3071088Sjasone 3171088Sjasonenamespace omp { 3271088SjasoneLLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); 3376166Smarkm 3476166Smarkm/// IDs for all Internal Control Variables (ICVs). 3571088Sjasoneenum class InternalControlVar { 3671088Sjasone#define ICV_DATA_ENV(Enum, ...) Enum, 3771088Sjasone#include "llvm/Frontend/OpenMP/OMPKinds.def" 3871088Sjasone}; 39109862Sjeff 4071088Sjasone#define ICV_DATA_ENV(Enum, ...) \ 4171088Sjasone constexpr auto Enum = omp::InternalControlVar::Enum; 4271088Sjasone#include "llvm/Frontend/OpenMP/OMPKinds.def" 4371088Sjasone 4471088Sjasoneenum class ICVInitValue { 4571088Sjasone#define ICV_INIT_VALUE(Enum, Name) Enum, 4671088Sjasone#include "llvm/Frontend/OpenMP/OMPKinds.def" 4771088Sjasone}; 4871088Sjasone 4971088Sjasone#define ICV_INIT_VALUE(Enum, Name) \ 5083366Sjulian constexpr auto Enum = omp::ICVInitValue::Enum; 5187594Sobrien#include "llvm/Frontend/OpenMP/OMPKinds.def" 52103216Sjulian 5387594Sobrien/// IDs for all omp runtime library (RTL) functions. 5487594Sobrienenum class RuntimeFunction { 5571088Sjasone#define OMP_RTL(Enum, ...) Enum, 5671088Sjasone#include "llvm/Frontend/OpenMP/OMPKinds.def" 5771088Sjasone}; 5893408Sdan 5971088Sjasone#define OMP_RTL(Enum, ...) constexpr auto Enum = omp::RuntimeFunction::Enum; 6071088Sjasone#include "llvm/Frontend/OpenMP/OMPKinds.def" 6171088Sjasone 6271088Sjasone/// IDs for the different default kinds. 6371088Sjasoneenum class DefaultKind { 6471088Sjasone#define OMP_DEFAULT_KIND(Enum, Str) Enum, 6571088Sjasone#include "llvm/Frontend/OpenMP/OMPKinds.def" 6671088Sjasone}; 6771088Sjasone 6871088Sjasone#define OMP_DEFAULT_KIND(Enum, ...) \ 6987594Sobrien constexpr auto Enum = omp::DefaultKind::Enum; 7071088Sjasone#include "llvm/Frontend/OpenMP/OMPKinds.def" 7171088Sjasone 72103216Sjulian/// IDs for all omp runtime library ident_t flag encodings (see 7371088Sjasone/// their defintion in openmp/runtime/src/kmp.h). 7471088Sjasoneenum class IdentFlag { 7571088Sjasone#define OMP_IDENT_FLAG(Enum, Str, Value) Enum = Value, 76103216Sjulian#include "llvm/Frontend/OpenMP/OMPKinds.def" 7771088Sjasone LLVM_MARK_AS_BITMASK_ENUM(0x7FFFFFFF) 7871088Sjasone}; 79103216Sjulian 8071088Sjasone#define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum; 8171088Sjasone#include "llvm/Frontend/OpenMP/OMPKinds.def" 8271088Sjasone 8371088Sjasone/// Helper to describe assume clauses. 8471088Sjasonestruct AssumptionClauseMappingInfo { 8571088Sjasone /// The identifier describing the (beginning of the) clause. 8671088Sjasone llvm::StringLiteral Identifier; 8771088Sjasone /// Flag to determine if the identifier is a full name or the start of a name. 8871088Sjasone bool StartsWith; 8971088Sjasone /// Flag to determine if a directive lists follows. 9071088Sjasone bool HasDirectiveList; 9171088Sjasone /// Flag to determine if an expression follows. 9271088Sjasone bool HasExpression; 9371088Sjasone}; 9471088Sjasone 9571088Sjasone/// All known assume clauses. 9671088Sjasonestatic constexpr AssumptionClauseMappingInfo AssumptionClauseMappings[] = { 9771088Sjasone#define OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, \ 9871088Sjasone HasExpression) \ 9971088Sjasone {Identifier, StartsWith, HasDirectiveList, HasExpression}, 10071088Sjasone#include "llvm/Frontend/OpenMP/OMPKinds.def" 10171088Sjasone}; 10271088Sjasone 10371088Sjasoneinline std::string getAllAssumeClauseOptions() { 10471088Sjasone std::string S; 10571088Sjasone for (const AssumptionClauseMappingInfo &ACMI : AssumptionClauseMappings) 10671088Sjasone S += (S.empty() ? "'" : "', '") + ACMI.Identifier.str(); 10787594Sobrien return S + "'"; 10871088Sjasone} 10971088Sjasone 11071088Sjasone/// \note This needs to be kept in sync with kmp.h enum sched_type. 11171088Sjasone/// Todo: Update kmp.h to include this file, and remove the enums in kmp.h 11271088Sjasone/// To complete this, more enum values will need to be moved here. 11371088Sjasoneenum class OMPScheduleType { 11471088Sjasone Static = 34, // static unspecialized 115105911Sjulian DynamicChunked = 35, 11699072Sjulian GuidedChunked = 36, // guided unspecialized 117105911Sjulian Runtime = 37, 118105911Sjulian Auto = 38, // auto 11999072Sjulian 120103216Sjulian ModifierNonmonotonic = 12183366Sjulian (1 << 30), /**< Set if the nonmonotonic schedule modifier was present */ 12271088Sjasone 12383650Sjhb LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue */ ModifierNonmonotonic) 12483650Sjhb}; 12571088Sjasone 12671088Sjasone} // end namespace omp 12771088Sjasone 12871088Sjasone} // end namespace llvm 12971088Sjasone 13071088Sjasone#endif // LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H 13183366Sjulian