1 //===-- OMP.h - Core OpenMP definitions and declarations ---------- 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 the core set of OpenMP definitions and declarations. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_FRONTEND_OPENMP_OMP_H 14 #define LLVM_FRONTEND_OPENMP_OMP_H 15 16 #include "llvm/Frontend/OpenMP/OMP.h.inc" 17 #include "llvm/Support/Compiler.h" 18 19 #include "llvm/ADT/ArrayRef.h" 20 #include "llvm/ADT/SmallVector.h" 21 #include "llvm/ADT/StringRef.h" 22 23 namespace llvm::omp { 24 LLVM_ABI ArrayRef<Directive> getLeafConstructs(Directive D); 25 LLVM_ABI ArrayRef<Directive> getLeafConstructsOrSelf(Directive D); 26 27 LLVM_ABI ArrayRef<Directive> 28 getLeafOrCompositeConstructs(Directive D, SmallVectorImpl<Directive> &Output); 29 30 LLVM_ABI Directive getCompoundConstruct(ArrayRef<Directive> Parts); 31 32 LLVM_ABI bool isLeafConstruct(Directive D); 33 LLVM_ABI bool isCompositeConstruct(Directive D); 34 LLVM_ABI bool isCombinedConstruct(Directive D); 35 36 /// Can clause C have an iterator-modifier. canHaveIterator(Clause C)37static constexpr inline bool canHaveIterator(Clause C) { 38 // [5.2:67:5] 39 switch (C) { 40 case OMPC_affinity: 41 case OMPC_depend: 42 case OMPC_from: 43 case OMPC_map: 44 case OMPC_to: 45 return true; 46 default: 47 return false; 48 } 49 } 50 51 // Can clause C create a private copy of a variable. isPrivatizingClause(Clause C)52static constexpr inline bool isPrivatizingClause(Clause C) { 53 switch (C) { 54 case OMPC_firstprivate: 55 case OMPC_in_reduction: 56 case OMPC_lastprivate: 57 case OMPC_linear: 58 case OMPC_private: 59 case OMPC_reduction: 60 case OMPC_task_reduction: 61 return true; 62 default: 63 return false; 64 } 65 } 66 67 static constexpr unsigned FallbackVersion = 52; 68 LLVM_ABI ArrayRef<unsigned> getOpenMPVersions(); 69 70 /// Create a nicer version of a function name for humans to look at. 71 LLVM_ABI std::string prettifyFunctionName(StringRef FunctionName); 72 73 /// Deconstruct an OpenMP kernel name into the parent function name and the line 74 /// number. 75 LLVM_ABI std::string deconstructOpenMPKernelName(StringRef KernelName, 76 unsigned &LineNo); 77 78 } // namespace llvm::omp 79 80 #endif // LLVM_FRONTEND_OPENMP_OMP_H 81