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