Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 1 | //===----- CGOpenMPRuntime.h - Interface to OpenMP Runtimes -----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This provides a class for OpenMP runtime code generation. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | 2f5db8b | 2014-08-13 16:25:19 +0000 | [diff] [blame] | 14 | #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H |
| 15 | #define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 16 | |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 17 | #include "clang/Basic/SourceLocation.h" |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/DenseMap.h" |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/DenseSet.h" |
Alexey Bataev | 3a3bf0b | 2014-09-22 10:01:53 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/StringMap.h" |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 21 | #include "llvm/IR/ValueHandle.h" |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 22 | |
| 23 | namespace llvm { |
| 24 | class ArrayType; |
| 25 | class Constant; |
| 26 | class Function; |
| 27 | class FunctionType; |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 28 | class GlobalVariable; |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 29 | class StructType; |
| 30 | class Type; |
| 31 | class Value; |
| 32 | } // namespace llvm |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 33 | |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 34 | namespace clang { |
Alexey Bataev | cc37cc1 | 2014-11-20 04:34:54 +0000 | [diff] [blame] | 35 | class Expr; |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 36 | class OMPExecutableDirective; |
| 37 | class VarDecl; |
| 38 | |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 39 | namespace CodeGen { |
| 40 | |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 41 | class CodeGenFunction; |
| 42 | class CodeGenModule; |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 43 | |
| 44 | class CGOpenMPRuntime { |
| 45 | public: |
| 46 | /// \brief Values for bit flags used in the ident_t to describe the fields. |
| 47 | /// All enumeric elements are named and described in accordance with the code |
| 48 | /// from http://llvm.org/svn/llvm-project/openmp/trunk/runtime/src/kmp.h |
| 49 | enum OpenMPLocationFlags { |
| 50 | /// \brief Use trampoline for internal microtask. |
| 51 | OMP_IDENT_IMD = 0x01, |
| 52 | /// \brief Use c-style ident structure. |
| 53 | OMP_IDENT_KMPC = 0x02, |
| 54 | /// \brief Atomic reduction option for kmpc_reduce. |
| 55 | OMP_ATOMIC_REDUCE = 0x10, |
| 56 | /// \brief Explicit 'barrier' directive. |
| 57 | OMP_IDENT_BARRIER_EXPL = 0x20, |
| 58 | /// \brief Implicit barrier in code. |
| 59 | OMP_IDENT_BARRIER_IMPL = 0x40, |
| 60 | /// \brief Implicit barrier in 'for' directive. |
| 61 | OMP_IDENT_BARRIER_IMPL_FOR = 0x40, |
| 62 | /// \brief Implicit barrier in 'sections' directive. |
| 63 | OMP_IDENT_BARRIER_IMPL_SECTIONS = 0xC0, |
| 64 | /// \brief Implicit barrier in 'single' directive. |
| 65 | OMP_IDENT_BARRIER_IMPL_SINGLE = 0x140 |
| 66 | }; |
Alexey Bataev | 1e4b713 | 2014-12-03 12:11:24 +0000 | [diff] [blame] | 67 | |
| 68 | private: |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 69 | enum OpenMPRTLFunction { |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 70 | /// \brief Call to void __kmpc_fork_call(ident_t *loc, kmp_int32 argc, |
| 71 | /// kmpc_micro microtask, ...); |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 72 | OMPRTL__kmpc_fork_call, |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 73 | /// \brief Call to void *__kmpc_threadprivate_cached(ident_t *loc, |
| 74 | /// kmp_int32 global_tid, void *data, size_t size, void ***cache); |
| 75 | OMPRTL__kmpc_threadprivate_cached, |
| 76 | /// \brief Call to void __kmpc_threadprivate_register( ident_t *, |
| 77 | /// void *data, kmpc_ctor ctor, kmpc_cctor cctor, kmpc_dtor dtor); |
| 78 | OMPRTL__kmpc_threadprivate_register, |
Alexey Bataev | 3a3bf0b | 2014-09-22 10:01:53 +0000 | [diff] [blame] | 79 | // Call to __kmpc_int32 kmpc_global_thread_num(ident_t *loc); |
| 80 | OMPRTL__kmpc_global_thread_num, |
Alexey Bataev | f947218 | 2014-09-22 12:32:31 +0000 | [diff] [blame] | 81 | // Call to void __kmpc_critical(ident_t *loc, kmp_int32 global_tid, |
| 82 | // kmp_critical_name *crit); |
Alexey Bataev | 3a3bf0b | 2014-09-22 10:01:53 +0000 | [diff] [blame] | 83 | OMPRTL__kmpc_critical, |
Alexey Bataev | f947218 | 2014-09-22 12:32:31 +0000 | [diff] [blame] | 84 | // Call to void __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid, |
| 85 | // kmp_critical_name *crit); |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 86 | OMPRTL__kmpc_end_critical, |
| 87 | // Call to void __kmpc_barrier(ident_t *loc, kmp_int32 global_tid); |
Alexey Bataev | d74d060 | 2014-10-13 06:02:40 +0000 | [diff] [blame] | 88 | OMPRTL__kmpc_barrier, |
| 89 | // Call to void __kmpc_serialized_parallel(ident_t *loc, kmp_int32 |
| 90 | // global_tid); |
| 91 | OMPRTL__kmpc_serialized_parallel, |
| 92 | // Call to void __kmpc_end_serialized_parallel(ident_t *loc, kmp_int32 |
| 93 | // global_tid); |
Alexey Bataev | b205978 | 2014-10-13 08:23:51 +0000 | [diff] [blame] | 94 | OMPRTL__kmpc_end_serialized_parallel, |
| 95 | // Call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 global_tid, |
| 96 | // kmp_int32 num_threads); |
Alexey Bataev | cc37cc1 | 2014-11-20 04:34:54 +0000 | [diff] [blame] | 97 | OMPRTL__kmpc_push_num_threads, |
| 98 | // Call to void __kmpc_flush(ident_t *loc, ...); |
Alexey Bataev | 8d69065 | 2014-12-04 07:23:53 +0000 | [diff] [blame] | 99 | OMPRTL__kmpc_flush, |
| 100 | // Call to kmp_int32 __kmpc_master(ident_t *, kmp_int32 global_tid); |
| 101 | OMPRTL__kmpc_master, |
| 102 | // Call to void __kmpc_end_master(ident_t *, kmp_int32 global_tid); |
| 103 | OMPRTL__kmpc_end_master, |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 104 | }; |
| 105 | |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 106 | CodeGenModule &CGM; |
| 107 | /// \brief Default const ident_t object used for initialization of all other |
| 108 | /// ident_t objects. |
| 109 | llvm::Constant *DefaultOpenMPPSource; |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 110 | /// \brief Map of flags and corresponding default locations. |
Alexey Bataev | 15007ba | 2014-05-07 06:18:01 +0000 | [diff] [blame] | 111 | typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDefaultLocMapTy; |
| 112 | OpenMPDefaultLocMapTy OpenMPDefaultLocMap; |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 113 | llvm::Value *GetOrCreateDefaultOpenMPLocation(OpenMPLocationFlags Flags); |
| 114 | /// \brief Describes ident structure that describes a source location. |
| 115 | /// All descriptions are taken from |
| 116 | /// http://llvm.org/svn/llvm-project/openmp/trunk/runtime/src/kmp.h |
| 117 | /// Original structure: |
| 118 | /// typedef struct ident { |
| 119 | /// kmp_int32 reserved_1; /**< might be used in Fortran; |
| 120 | /// see above */ |
| 121 | /// kmp_int32 flags; /**< also f.flags; KMP_IDENT_xxx flags; |
| 122 | /// KMP_IDENT_KMPC identifies this union |
| 123 | /// member */ |
| 124 | /// kmp_int32 reserved_2; /**< not really used in Fortran any more; |
| 125 | /// see above */ |
| 126 | ///#if USE_ITT_BUILD |
| 127 | /// /* but currently used for storing |
| 128 | /// region-specific ITT */ |
| 129 | /// /* contextual information. */ |
| 130 | ///#endif /* USE_ITT_BUILD */ |
| 131 | /// kmp_int32 reserved_3; /**< source[4] in Fortran, do not use for |
| 132 | /// C++ */ |
| 133 | /// char const *psource; /**< String describing the source location. |
| 134 | /// The string is composed of semi-colon separated |
| 135 | // fields which describe the source file, |
| 136 | /// the function and a pair of line numbers that |
| 137 | /// delimit the construct. |
| 138 | /// */ |
| 139 | /// } ident_t; |
| 140 | enum IdentFieldIndex { |
| 141 | /// \brief might be used in Fortran |
| 142 | IdentField_Reserved_1, |
| 143 | /// \brief OMP_IDENT_xxx flags; OMP_IDENT_KMPC identifies this union member. |
| 144 | IdentField_Flags, |
| 145 | /// \brief Not really used in Fortran any more |
| 146 | IdentField_Reserved_2, |
| 147 | /// \brief Source[4] in Fortran, do not use for C++ |
| 148 | IdentField_Reserved_3, |
| 149 | /// \brief String describing the source location. The string is composed of |
| 150 | /// semi-colon separated fields which describe the source file, the function |
| 151 | /// and a pair of line numbers that delimit the construct. |
| 152 | IdentField_PSource |
| 153 | }; |
| 154 | llvm::StructType *IdentTy; |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 155 | /// \brief Map for SourceLocation and OpenMP runtime library debug locations. |
Alexey Bataev | f002aca | 2014-05-30 05:48:40 +0000 | [diff] [blame] | 156 | typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDebugLocMapTy; |
| 157 | OpenMPDebugLocMapTy OpenMPDebugLocMap; |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 158 | /// \brief The type for a microtask which gets passed to __kmpc_fork_call(). |
| 159 | /// Original representation is: |
| 160 | /// typedef void (kmpc_micro)(kmp_int32 global_tid, kmp_int32 bound_tid,...); |
| 161 | llvm::FunctionType *Kmpc_MicroTy; |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 162 | /// \brief Stores debug location and ThreadID for the function. |
| 163 | struct DebugLocThreadIdTy { |
| 164 | llvm::Value *DebugLoc; |
| 165 | llvm::Value *ThreadID; |
| 166 | }; |
| 167 | /// \brief Map of local debug location, ThreadId and functions. |
| 168 | typedef llvm::DenseMap<llvm::Function *, DebugLocThreadIdTy> |
| 169 | OpenMPLocThreadIDMapTy; |
| 170 | OpenMPLocThreadIDMapTy OpenMPLocThreadIDMap; |
Alexey Bataev | 3a3bf0b | 2014-09-22 10:01:53 +0000 | [diff] [blame] | 171 | /// \brief Type kmp_critical_name, originally defined as typedef kmp_int32 |
| 172 | /// kmp_critical_name[8]; |
| 173 | llvm::ArrayType *KmpCriticalNameTy; |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 174 | /// \brief An ordered map of auto-generated variables to their unique names. |
| 175 | /// It stores variables with the following names: 1) ".gomp_critical_user_" + |
| 176 | /// <critical_section_name> + ".var" for "omp critical" directives; 2) |
| 177 | /// <mangled_name_for_global_var> + ".cache." for cache for threadprivate |
| 178 | /// variables. |
| 179 | llvm::StringMap<llvm::AssertingVH<llvm::Constant>, llvm::BumpPtrAllocator> |
| 180 | InternalVars; |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 181 | |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 182 | /// \brief Emits object of ident_t type with info for source location. |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 183 | /// \param Flags Flags for OpenMP location. |
| 184 | /// |
| 185 | llvm::Value * |
| 186 | EmitOpenMPUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc, |
| 187 | OpenMPLocationFlags Flags = OMP_IDENT_KMPC); |
| 188 | |
Alexey Bataev | d74d060 | 2014-10-13 06:02:40 +0000 | [diff] [blame] | 189 | /// \brief Returns pointer to ident_t type. |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 190 | llvm::Type *getIdentTyPointerTy(); |
| 191 | |
Alexey Bataev | d74d060 | 2014-10-13 06:02:40 +0000 | [diff] [blame] | 192 | /// \brief Returns pointer to kmpc_micro type. |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 193 | llvm::Type *getKmpc_MicroPointerTy(); |
| 194 | |
| 195 | /// \brief Returns specified OpenMP runtime function. |
| 196 | /// \param Function OpenMP runtime function. |
| 197 | /// \return Specified function. |
| 198 | llvm::Constant *CreateRuntimeFunction(OpenMPRTLFunction Function); |
Alexey Bataev | 3a3bf0b | 2014-09-22 10:01:53 +0000 | [diff] [blame] | 199 | |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 200 | /// \brief If the specified mangled name is not in the module, create and |
| 201 | /// return threadprivate cache object. This object is a pointer's worth of |
| 202 | /// storage that's reserved for use by the OpenMP runtime. |
NAKAMURA Takumi | cdcbfba | 2014-11-11 07:58:06 +0000 | [diff] [blame] | 203 | /// \param VD Threadprivate variable. |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 204 | /// \return Cache variable for the specified threadprivate. |
| 205 | llvm::Constant *getOrCreateThreadPrivateCache(const VarDecl *VD); |
| 206 | |
Alexey Bataev | d74d060 | 2014-10-13 06:02:40 +0000 | [diff] [blame] | 207 | /// \brief Emits address of the word in a memory where current thread id is |
| 208 | /// stored. |
| 209 | virtual llvm::Value *EmitThreadIDAddress(CodeGenFunction &CGF, |
| 210 | SourceLocation Loc); |
| 211 | |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 212 | /// \brief Gets thread id value for the current thread. |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 213 | /// |
| 214 | llvm::Value *GetOpenMPThreadID(CodeGenFunction &CGF, SourceLocation Loc); |
| 215 | |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 216 | /// \brief Gets (if variable with the given name already exist) or creates |
| 217 | /// internal global variable with the specified Name. The created variable has |
| 218 | /// linkage CommonLinkage by default and is initialized by null value. |
| 219 | /// \param Ty Type of the global variable. If it is exist already the type |
| 220 | /// must be the same. |
| 221 | /// \param Name Name of the variable. |
| 222 | llvm::Constant *GetOrCreateInternalVariable(llvm::Type *Ty, |
| 223 | const llvm::Twine &Name); |
| 224 | |
| 225 | /// \brief Set of threadprivate variables with the generated initializer. |
| 226 | llvm::DenseSet<const VarDecl *> ThreadPrivateWithDefinition; |
| 227 | |
| 228 | /// \brief Emits initialization code for the threadprivate variables. |
| 229 | /// \param VDAddr Address of the global variable \a VD. |
| 230 | /// \param Ctor Pointer to a global init function for \a VD. |
| 231 | /// \param CopyCtor Pointer to a global copy function for \a VD. |
| 232 | /// \param Dtor Pointer to a global destructor function for \a VD. |
| 233 | /// \param Loc Location of threadprivate declaration. |
| 234 | void EmitOMPThreadPrivateVarInit(CodeGenFunction &CGF, llvm::Value *VDAddr, |
| 235 | llvm::Value *Ctor, llvm::Value *CopyCtor, |
| 236 | llvm::Value *Dtor, SourceLocation Loc); |
| 237 | |
Alexey Bataev | 75ddfab | 2014-12-01 11:32:38 +0000 | [diff] [blame] | 238 | /// \brief Returns corresponding lock object for the specified critical region |
| 239 | /// name. If the lock object does not exist it is created, otherwise the |
| 240 | /// reference to the existing copy is returned. |
| 241 | /// \param CriticalName Name of the critical region. |
| 242 | /// |
| 243 | llvm::Value *GetCriticalRegionLock(StringRef CriticalName); |
| 244 | |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 245 | public: |
| 246 | explicit CGOpenMPRuntime(CodeGenModule &CGM); |
| 247 | virtual ~CGOpenMPRuntime() {} |
| 248 | |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 249 | /// \brief Emits outlined function for the specified OpenMP directive \a D |
| 250 | /// (required for parallel and task directives). This outlined function has |
| 251 | /// type void(*)(kmp_int32 /*ThreadID*/, kmp_int32 /*BoundID*/, struct |
| 252 | /// context_vars*). |
| 253 | /// \param D OpenMP directive. |
| 254 | /// \param ThreadIDVar Variable for thread id in the current OpenMP region. |
| 255 | /// |
| 256 | virtual llvm::Value * |
| 257 | EmitOpenMPOutlinedFunction(const OMPExecutableDirective &D, |
| 258 | const VarDecl *ThreadIDVar); |
| 259 | |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 260 | /// \brief Cleans up references to the objects in finished function. |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 261 | /// |
| 262 | void FunctionFinished(CodeGenFunction &CGF); |
| 263 | |
| 264 | /// \brief Emits code for parallel call of the \a OutlinedFn with variables |
| 265 | /// captured in a record which address is stored in \a CapturedStruct. |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 266 | /// \param OutlinedFn Outlined function to be run in parallel threads. Type of |
| 267 | /// this function is void(*)(kmp_int32, kmp_int32, struct context_vars*). |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 268 | /// \param CapturedStruct A pointer to the record with the references to |
| 269 | /// variables used in \a OutlinedFn function. |
| 270 | /// |
| 271 | virtual void EmitOMPParallelCall(CodeGenFunction &CGF, SourceLocation Loc, |
| 272 | llvm::Value *OutlinedFn, |
| 273 | llvm::Value *CapturedStruct); |
| 274 | |
Alexey Bataev | d74d060 | 2014-10-13 06:02:40 +0000 | [diff] [blame] | 275 | /// \brief Emits code for serial call of the \a OutlinedFn with variables |
| 276 | /// captured in a record which address is stored in \a CapturedStruct. |
| 277 | /// \param OutlinedFn Outlined function to be run in serial mode. |
| 278 | /// \param CapturedStruct A pointer to the record with the references to |
| 279 | /// variables used in \a OutlinedFn function. |
| 280 | /// |
| 281 | virtual void EmitOMPSerialCall(CodeGenFunction &CGF, SourceLocation Loc, |
| 282 | llvm::Value *OutlinedFn, |
| 283 | llvm::Value *CapturedStruct); |
| 284 | |
Alexey Bataev | 75ddfab | 2014-12-01 11:32:38 +0000 | [diff] [blame] | 285 | /// \brief Emits a critical region. |
Alexey Bataev | 1809571 | 2014-10-10 12:19:54 +0000 | [diff] [blame] | 286 | /// \param CriticalName Name of the critical region. |
Alexey Bataev | 75ddfab | 2014-12-01 11:32:38 +0000 | [diff] [blame] | 287 | /// \param CriticalOpGen Generator for the statement associated with the given |
| 288 | /// critical region. |
| 289 | virtual void EmitOMPCriticalRegion(CodeGenFunction &CGF, |
| 290 | StringRef CriticalName, |
| 291 | const std::function<void()> &CriticalOpGen, |
| 292 | SourceLocation Loc); |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 293 | |
Alexey Bataev | 8d69065 | 2014-12-04 07:23:53 +0000 | [diff] [blame] | 294 | /// \brief Emits a master region. |
| 295 | /// \param MasterOpGen Generator for the statement associated with the given |
| 296 | /// master region. |
| 297 | virtual void EmitOMPMasterRegion(CodeGenFunction &CGF, |
| 298 | const std::function<void()> &MasterOpGen, |
| 299 | SourceLocation Loc); |
| 300 | |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 301 | /// \brief Emits a barrier for OpenMP threads. |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 302 | /// \param Flags Flags for the barrier. |
| 303 | /// |
| 304 | virtual void EmitOMPBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, |
| 305 | OpenMPLocationFlags Flags); |
Alexey Bataev | b205978 | 2014-10-13 08:23:51 +0000 | [diff] [blame] | 306 | |
| 307 | /// \brief Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 |
| 308 | /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads' |
| 309 | /// clause. |
| 310 | /// \param NumThreads An integer value of threads. |
| 311 | virtual void EmitOMPNumThreadsClause(CodeGenFunction &CGF, |
| 312 | llvm::Value *NumThreads, |
| 313 | SourceLocation Loc); |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 314 | |
| 315 | /// \brief Returns address of the threadprivate variable for the current |
| 316 | /// thread. |
NAKAMURA Takumi | cdcbfba | 2014-11-11 07:58:06 +0000 | [diff] [blame] | 317 | /// \param VD Threadprivate variable. |
Alexey Bataev | 9772000 | 2014-11-11 04:05:39 +0000 | [diff] [blame] | 318 | /// \param VDAddr Address of the global variable \a VD. |
| 319 | /// \param Loc Location of the reference to threadprivate var. |
| 320 | /// \return Address of the threadprivate variable for the current thread. |
| 321 | virtual llvm::Value *getOMPAddrOfThreadPrivate(CodeGenFunction &CGF, |
| 322 | const VarDecl *VD, |
| 323 | llvm::Value *VDAddr, |
| 324 | SourceLocation Loc); |
| 325 | |
| 326 | /// \brief Emit a code for initialization of threadprivate variable. It emits |
| 327 | /// a call to runtime library which adds initial value to the newly created |
| 328 | /// threadprivate variable (if it is not constant) and registers destructor |
| 329 | /// for the variable (if any). |
| 330 | /// \param VD Threadprivate variable. |
| 331 | /// \param VDAddr Address of the global variable \a VD. |
| 332 | /// \param Loc Location of threadprivate declaration. |
| 333 | /// \param PerformInit true if initialization expression is not constant. |
| 334 | virtual llvm::Function * |
| 335 | EmitOMPThreadPrivateVarDefinition(const VarDecl *VD, llvm::Value *VDAddr, |
| 336 | SourceLocation Loc, bool PerformInit, |
| 337 | CodeGenFunction *CGF = nullptr); |
Alexey Bataev | cc37cc1 | 2014-11-20 04:34:54 +0000 | [diff] [blame] | 338 | |
| 339 | /// \brief Emit flush of the variables specified in 'omp flush' directive. |
| 340 | /// \param Vars List of variables to flush. |
| 341 | virtual void EmitOMPFlush(CodeGenFunction &CGF, ArrayRef<const Expr *> Vars, |
| 342 | SourceLocation Loc); |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 343 | }; |
Alexey Bataev | 23b6942 | 2014-06-18 07:08:49 +0000 | [diff] [blame] | 344 | } // namespace CodeGen |
| 345 | } // namespace clang |
Alexey Bataev | 9959db5 | 2014-05-06 10:08:46 +0000 | [diff] [blame] | 346 | |
| 347 | #endif |