blob: 76d4f2a62390bac23655130cf75ae18d0382034f [file] [log] [blame]
Alexey Bataev9959db52014-05-06 10:08:46 +00001//===----- 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 Kramer2f5db8b2014-08-13 16:25:19 +000014#ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H
15#define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H
Alexey Bataev9959db52014-05-06 10:08:46 +000016
Alexander Musmanc6388682014-12-15 07:07:06 +000017#include "clang/Basic/OpenMPKinds.h"
Chandler Carruth0d9593d2015-01-14 11:29:14 +000018#include "clang/Basic/SourceLocation.h"
Alexey Bataev9959db52014-05-06 10:08:46 +000019#include "llvm/ADT/DenseMap.h"
Alexey Bataev97720002014-11-11 04:05:39 +000020#include "llvm/ADT/DenseSet.h"
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +000021#include "llvm/ADT/StringMap.h"
Alexey Bataev97720002014-11-11 04:05:39 +000022#include "llvm/IR/ValueHandle.h"
Alexey Bataev18095712014-10-10 12:19:54 +000023
24namespace llvm {
25class ArrayType;
26class Constant;
27class Function;
28class FunctionType;
Alexey Bataev97720002014-11-11 04:05:39 +000029class GlobalVariable;
Alexey Bataev18095712014-10-10 12:19:54 +000030class StructType;
31class Type;
32class Value;
33} // namespace llvm
Alexey Bataev9959db52014-05-06 10:08:46 +000034
Alexey Bataev9959db52014-05-06 10:08:46 +000035namespace clang {
Alexey Bataevcc37cc12014-11-20 04:34:54 +000036class Expr;
Alexey Bataev18095712014-10-10 12:19:54 +000037class OMPExecutableDirective;
38class VarDecl;
39
Alexey Bataev9959db52014-05-06 10:08:46 +000040namespace CodeGen {
41
Alexey Bataev18095712014-10-10 12:19:54 +000042class CodeGenFunction;
43class CodeGenModule;
Alexey Bataev9959db52014-05-06 10:08:46 +000044
45class CGOpenMPRuntime {
46public:
Alexey Bataev8f7c1b02014-12-05 04:09:23 +000047
48private:
49 enum OpenMPRTLFunction {
50 /// \brief Call to void __kmpc_fork_call(ident_t *loc, kmp_int32 argc,
51 /// kmpc_micro microtask, ...);
52 OMPRTL__kmpc_fork_call,
53 /// \brief Call to void *__kmpc_threadprivate_cached(ident_t *loc,
54 /// kmp_int32 global_tid, void *data, size_t size, void ***cache);
55 OMPRTL__kmpc_threadprivate_cached,
56 /// \brief Call to void __kmpc_threadprivate_register( ident_t *,
57 /// void *data, kmpc_ctor ctor, kmpc_cctor cctor, kmpc_dtor dtor);
58 OMPRTL__kmpc_threadprivate_register,
59 // Call to __kmpc_int32 kmpc_global_thread_num(ident_t *loc);
60 OMPRTL__kmpc_global_thread_num,
61 // Call to void __kmpc_critical(ident_t *loc, kmp_int32 global_tid,
62 // kmp_critical_name *crit);
63 OMPRTL__kmpc_critical,
64 // Call to void __kmpc_end_critical(ident_t *loc, kmp_int32 global_tid,
65 // kmp_critical_name *crit);
66 OMPRTL__kmpc_end_critical,
67 // Call to kmp_int32 __kmpc_cancel_barrier(ident_t *loc, kmp_int32
68 // global_tid);
69 OMPRTL__kmpc_cancel_barrier,
Alexander Musmanc6388682014-12-15 07:07:06 +000070 // Calls for static scheduling 'omp for' loops.
71 OMPRTL__kmpc_for_static_init_4,
72 OMPRTL__kmpc_for_static_init_4u,
73 OMPRTL__kmpc_for_static_init_8,
74 OMPRTL__kmpc_for_static_init_8u,
75 OMPRTL__kmpc_for_static_fini,
Alexey Bataev8f7c1b02014-12-05 04:09:23 +000076 // Call to void __kmpc_serialized_parallel(ident_t *loc, kmp_int32
77 // global_tid);
78 OMPRTL__kmpc_serialized_parallel,
79 // Call to void __kmpc_end_serialized_parallel(ident_t *loc, kmp_int32
80 // global_tid);
81 OMPRTL__kmpc_end_serialized_parallel,
82 // Call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 global_tid,
83 // kmp_int32 num_threads);
84 OMPRTL__kmpc_push_num_threads,
85 // Call to void __kmpc_flush(ident_t *loc, ...);
86 OMPRTL__kmpc_flush,
87 // Call to kmp_int32 __kmpc_master(ident_t *, kmp_int32 global_tid);
88 OMPRTL__kmpc_master,
89 // Call to void __kmpc_end_master(ident_t *, kmp_int32 global_tid);
90 OMPRTL__kmpc_end_master,
Alexey Bataev9f797f32015-02-05 05:57:51 +000091 // Call to kmp_int32 __kmpc_omp_taskyield(ident_t *, kmp_int32 global_tid,
92 // int end_part);
93 OMPRTL__kmpc_omp_taskyield,
Alexey Bataev6956e2e2015-02-05 06:35:41 +000094 // Call to kmp_int32 __kmpc_single(ident_t *, kmp_int32 global_tid);
95 OMPRTL__kmpc_single,
96 // Call to void __kmpc_end_single(ident_t *, kmp_int32 global_tid);
97 OMPRTL__kmpc_end_single,
Alexey Bataev8f7c1b02014-12-05 04:09:23 +000098 };
99
Alexey Bataev9959db52014-05-06 10:08:46 +0000100 /// \brief Values for bit flags used in the ident_t to describe the fields.
101 /// All enumeric elements are named and described in accordance with the code
102 /// from http://llvm.org/svn/llvm-project/openmp/trunk/runtime/src/kmp.h
103 enum OpenMPLocationFlags {
104 /// \brief Use trampoline for internal microtask.
105 OMP_IDENT_IMD = 0x01,
106 /// \brief Use c-style ident structure.
107 OMP_IDENT_KMPC = 0x02,
108 /// \brief Atomic reduction option for kmpc_reduce.
109 OMP_ATOMIC_REDUCE = 0x10,
110 /// \brief Explicit 'barrier' directive.
111 OMP_IDENT_BARRIER_EXPL = 0x20,
112 /// \brief Implicit barrier in code.
113 OMP_IDENT_BARRIER_IMPL = 0x40,
114 /// \brief Implicit barrier in 'for' directive.
115 OMP_IDENT_BARRIER_IMPL_FOR = 0x40,
116 /// \brief Implicit barrier in 'sections' directive.
117 OMP_IDENT_BARRIER_IMPL_SECTIONS = 0xC0,
118 /// \brief Implicit barrier in 'single' directive.
119 OMP_IDENT_BARRIER_IMPL_SINGLE = 0x140
120 };
Alexey Bataev9959db52014-05-06 10:08:46 +0000121 CodeGenModule &CGM;
122 /// \brief Default const ident_t object used for initialization of all other
123 /// ident_t objects.
124 llvm::Constant *DefaultOpenMPPSource;
Alexey Bataev18095712014-10-10 12:19:54 +0000125 /// \brief Map of flags and corresponding default locations.
Alexey Bataev15007ba2014-05-07 06:18:01 +0000126 typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDefaultLocMapTy;
127 OpenMPDefaultLocMapTy OpenMPDefaultLocMap;
Alexey Bataev9959db52014-05-06 10:08:46 +0000128 llvm::Value *GetOrCreateDefaultOpenMPLocation(OpenMPLocationFlags Flags);
129 /// \brief Describes ident structure that describes a source location.
130 /// All descriptions are taken from
131 /// http://llvm.org/svn/llvm-project/openmp/trunk/runtime/src/kmp.h
132 /// Original structure:
133 /// typedef struct ident {
134 /// kmp_int32 reserved_1; /**< might be used in Fortran;
135 /// see above */
136 /// kmp_int32 flags; /**< also f.flags; KMP_IDENT_xxx flags;
137 /// KMP_IDENT_KMPC identifies this union
138 /// member */
139 /// kmp_int32 reserved_2; /**< not really used in Fortran any more;
140 /// see above */
141 ///#if USE_ITT_BUILD
142 /// /* but currently used for storing
143 /// region-specific ITT */
144 /// /* contextual information. */
145 ///#endif /* USE_ITT_BUILD */
146 /// kmp_int32 reserved_3; /**< source[4] in Fortran, do not use for
147 /// C++ */
148 /// char const *psource; /**< String describing the source location.
149 /// The string is composed of semi-colon separated
150 // fields which describe the source file,
151 /// the function and a pair of line numbers that
152 /// delimit the construct.
153 /// */
154 /// } ident_t;
155 enum IdentFieldIndex {
156 /// \brief might be used in Fortran
157 IdentField_Reserved_1,
158 /// \brief OMP_IDENT_xxx flags; OMP_IDENT_KMPC identifies this union member.
159 IdentField_Flags,
160 /// \brief Not really used in Fortran any more
161 IdentField_Reserved_2,
162 /// \brief Source[4] in Fortran, do not use for C++
163 IdentField_Reserved_3,
164 /// \brief String describing the source location. The string is composed of
165 /// semi-colon separated fields which describe the source file, the function
166 /// and a pair of line numbers that delimit the construct.
167 IdentField_PSource
168 };
169 llvm::StructType *IdentTy;
Alexey Bataev18095712014-10-10 12:19:54 +0000170 /// \brief Map for SourceLocation and OpenMP runtime library debug locations.
Alexey Bataevf002aca2014-05-30 05:48:40 +0000171 typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDebugLocMapTy;
172 OpenMPDebugLocMapTy OpenMPDebugLocMap;
Alexey Bataev9959db52014-05-06 10:08:46 +0000173 /// \brief The type for a microtask which gets passed to __kmpc_fork_call().
174 /// Original representation is:
175 /// typedef void (kmpc_micro)(kmp_int32 global_tid, kmp_int32 bound_tid,...);
176 llvm::FunctionType *Kmpc_MicroTy;
Alexey Bataev18095712014-10-10 12:19:54 +0000177 /// \brief Stores debug location and ThreadID for the function.
178 struct DebugLocThreadIdTy {
179 llvm::Value *DebugLoc;
180 llvm::Value *ThreadID;
181 };
182 /// \brief Map of local debug location, ThreadId and functions.
183 typedef llvm::DenseMap<llvm::Function *, DebugLocThreadIdTy>
184 OpenMPLocThreadIDMapTy;
185 OpenMPLocThreadIDMapTy OpenMPLocThreadIDMap;
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000186 /// \brief Type kmp_critical_name, originally defined as typedef kmp_int32
187 /// kmp_critical_name[8];
188 llvm::ArrayType *KmpCriticalNameTy;
Alexey Bataev97720002014-11-11 04:05:39 +0000189 /// \brief An ordered map of auto-generated variables to their unique names.
190 /// It stores variables with the following names: 1) ".gomp_critical_user_" +
191 /// <critical_section_name> + ".var" for "omp critical" directives; 2)
192 /// <mangled_name_for_global_var> + ".cache." for cache for threadprivate
193 /// variables.
194 llvm::StringMap<llvm::AssertingVH<llvm::Constant>, llvm::BumpPtrAllocator>
195 InternalVars;
Alexey Bataev9959db52014-05-06 10:08:46 +0000196
Alexey Bataev9959db52014-05-06 10:08:46 +0000197 /// \brief Emits object of ident_t type with info for source location.
Alexey Bataev9959db52014-05-06 10:08:46 +0000198 /// \param Flags Flags for OpenMP location.
199 ///
200 llvm::Value *
201 EmitOpenMPUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc,
202 OpenMPLocationFlags Flags = OMP_IDENT_KMPC);
203
Alexey Bataevd74d0602014-10-13 06:02:40 +0000204 /// \brief Returns pointer to ident_t type.
Alexey Bataev9959db52014-05-06 10:08:46 +0000205 llvm::Type *getIdentTyPointerTy();
206
Alexey Bataevd74d0602014-10-13 06:02:40 +0000207 /// \brief Returns pointer to kmpc_micro type.
Alexey Bataev9959db52014-05-06 10:08:46 +0000208 llvm::Type *getKmpc_MicroPointerTy();
209
210 /// \brief Returns specified OpenMP runtime function.
211 /// \param Function OpenMP runtime function.
212 /// \return Specified function.
213 llvm::Constant *CreateRuntimeFunction(OpenMPRTLFunction Function);
Alexey Bataev3a3bf0b2014-09-22 10:01:53 +0000214
Alexey Bataev97720002014-11-11 04:05:39 +0000215 /// \brief If the specified mangled name is not in the module, create and
216 /// return threadprivate cache object. This object is a pointer's worth of
217 /// storage that's reserved for use by the OpenMP runtime.
NAKAMURA Takumicdcbfba2014-11-11 07:58:06 +0000218 /// \param VD Threadprivate variable.
Alexey Bataev97720002014-11-11 04:05:39 +0000219 /// \return Cache variable for the specified threadprivate.
220 llvm::Constant *getOrCreateThreadPrivateCache(const VarDecl *VD);
221
Alexey Bataevd74d0602014-10-13 06:02:40 +0000222 /// \brief Emits address of the word in a memory where current thread id is
223 /// stored.
224 virtual llvm::Value *EmitThreadIDAddress(CodeGenFunction &CGF,
225 SourceLocation Loc);
226
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000227 /// \brief Gets thread id value for the current thread.
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000228 ///
229 llvm::Value *GetOpenMPThreadID(CodeGenFunction &CGF, SourceLocation Loc);
230
Alexey Bataev97720002014-11-11 04:05:39 +0000231 /// \brief Gets (if variable with the given name already exist) or creates
232 /// internal global variable with the specified Name. The created variable has
233 /// linkage CommonLinkage by default and is initialized by null value.
234 /// \param Ty Type of the global variable. If it is exist already the type
235 /// must be the same.
236 /// \param Name Name of the variable.
237 llvm::Constant *GetOrCreateInternalVariable(llvm::Type *Ty,
238 const llvm::Twine &Name);
239
240 /// \brief Set of threadprivate variables with the generated initializer.
241 llvm::DenseSet<const VarDecl *> ThreadPrivateWithDefinition;
242
243 /// \brief Emits initialization code for the threadprivate variables.
244 /// \param VDAddr Address of the global variable \a VD.
245 /// \param Ctor Pointer to a global init function for \a VD.
246 /// \param CopyCtor Pointer to a global copy function for \a VD.
247 /// \param Dtor Pointer to a global destructor function for \a VD.
248 /// \param Loc Location of threadprivate declaration.
249 void EmitOMPThreadPrivateVarInit(CodeGenFunction &CGF, llvm::Value *VDAddr,
250 llvm::Value *Ctor, llvm::Value *CopyCtor,
251 llvm::Value *Dtor, SourceLocation Loc);
252
Alexey Bataev75ddfab2014-12-01 11:32:38 +0000253 /// \brief Returns corresponding lock object for the specified critical region
254 /// name. If the lock object does not exist it is created, otherwise the
255 /// reference to the existing copy is returned.
256 /// \param CriticalName Name of the critical region.
257 ///
258 llvm::Value *GetCriticalRegionLock(StringRef CriticalName);
259
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000260public:
261 explicit CGOpenMPRuntime(CodeGenModule &CGM);
262 virtual ~CGOpenMPRuntime() {}
263
Alexey Bataev18095712014-10-10 12:19:54 +0000264 /// \brief Emits outlined function for the specified OpenMP directive \a D
265 /// (required for parallel and task directives). This outlined function has
266 /// type void(*)(kmp_int32 /*ThreadID*/, kmp_int32 /*BoundID*/, struct
267 /// context_vars*).
268 /// \param D OpenMP directive.
269 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
270 ///
271 virtual llvm::Value *
272 EmitOpenMPOutlinedFunction(const OMPExecutableDirective &D,
273 const VarDecl *ThreadIDVar);
274
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000275 /// \brief Cleans up references to the objects in finished function.
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000276 ///
277 void FunctionFinished(CodeGenFunction &CGF);
278
279 /// \brief Emits code for parallel call of the \a OutlinedFn with variables
280 /// captured in a record which address is stored in \a CapturedStruct.
Alexey Bataev18095712014-10-10 12:19:54 +0000281 /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
282 /// this function is void(*)(kmp_int32, kmp_int32, struct context_vars*).
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000283 /// \param CapturedStruct A pointer to the record with the references to
284 /// variables used in \a OutlinedFn function.
285 ///
286 virtual void EmitOMPParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
287 llvm::Value *OutlinedFn,
288 llvm::Value *CapturedStruct);
289
Alexey Bataevd74d0602014-10-13 06:02:40 +0000290 /// \brief Emits code for serial call of the \a OutlinedFn with variables
291 /// captured in a record which address is stored in \a CapturedStruct.
292 /// \param OutlinedFn Outlined function to be run in serial mode.
293 /// \param CapturedStruct A pointer to the record with the references to
294 /// variables used in \a OutlinedFn function.
295 ///
296 virtual void EmitOMPSerialCall(CodeGenFunction &CGF, SourceLocation Loc,
297 llvm::Value *OutlinedFn,
298 llvm::Value *CapturedStruct);
299
Alexey Bataev75ddfab2014-12-01 11:32:38 +0000300 /// \brief Emits a critical region.
Alexey Bataev18095712014-10-10 12:19:54 +0000301 /// \param CriticalName Name of the critical region.
Alexey Bataev75ddfab2014-12-01 11:32:38 +0000302 /// \param CriticalOpGen Generator for the statement associated with the given
303 /// critical region.
304 virtual void EmitOMPCriticalRegion(CodeGenFunction &CGF,
305 StringRef CriticalName,
306 const std::function<void()> &CriticalOpGen,
307 SourceLocation Loc);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000308
Alexey Bataev8d690652014-12-04 07:23:53 +0000309 /// \brief Emits a master region.
310 /// \param MasterOpGen Generator for the statement associated with the given
311 /// master region.
312 virtual void EmitOMPMasterRegion(CodeGenFunction &CGF,
313 const std::function<void()> &MasterOpGen,
314 SourceLocation Loc);
315
Alexey Bataev9f797f32015-02-05 05:57:51 +0000316 /// \brief Emits code for a taskyield directive.
317 virtual void EmitOMPTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc);
318
Alexey Bataev6956e2e2015-02-05 06:35:41 +0000319 /// \brief Emits a single region.
320 /// \param SingleOpGen Generator for the statement associated with the given
321 /// single region.
322 virtual void EmitOMPSingleRegion(CodeGenFunction &CGF,
323 const std::function<void()> &SingleOpGen,
324 SourceLocation Loc);
325
Alexey Bataev8f7c1b02014-12-05 04:09:23 +0000326 /// \brief Emits explicit barrier for OpenMP threads.
327 /// \param IsExplicit true, if it is explicitly specified barrier.
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000328 ///
329 virtual void EmitOMPBarrierCall(CodeGenFunction &CGF, SourceLocation Loc,
Alexey Bataev8f7c1b02014-12-05 04:09:23 +0000330 bool IsExplicit = true);
Alexey Bataevb2059782014-10-13 08:23:51 +0000331
Alexander Musmanc6388682014-12-15 07:07:06 +0000332 /// \brief Check if the specified \a ScheduleKind is static non-chunked.
333 /// This kind of worksharing directive is emitted without outer loop.
334 /// \param ScheduleKind Schedule kind specified in the 'schedule' clause.
335 /// \param Chunked True if chunk is specified in the clause.
336 ///
337 virtual bool isStaticNonchunked(OpenMPScheduleClauseKind ScheduleKind,
338 bool Chunked) const;
339
Alexander Musmandf7a8e22015-01-22 08:49:35 +0000340 /// \brief Check if the specified \a ScheduleKind is dynamic.
341 /// This kind of worksharing directive is emitted without outer loop.
342 /// \param ScheduleKind Schedule Kind specified in the 'schedule' clause.
343 ///
344 virtual bool isDynamic(OpenMPScheduleClauseKind ScheduleKind) const;
345
Alexander Musmanc6388682014-12-15 07:07:06 +0000346 /// \brief Call the appropriate runtime routine to initialize it before start
347 /// of loop.
348 ///
349 /// Depending on the loop schedule, it is nesessary to call some runtime
350 /// routine before start of the OpenMP loop to get the loop upper / lower
351 /// bounds \a LB and \a UB and stride \a ST.
352 ///
353 /// \param CGF Reference to current CodeGenFunction.
354 /// \param Loc Clang source location.
NAKAMURA Takumieca08382014-12-17 14:47:06 +0000355 /// \param SchedKind Schedule kind, specified by the 'schedule' clause.
Alexander Musmanc6388682014-12-15 07:07:06 +0000356 /// \param IVSize Size of the iteration variable in bits.
357 /// \param IVSigned Sign of the interation variable.
358 /// \param IL Address of the output variable in which the flag of the
359 /// last iteration is returned.
360 /// \param LB Address of the output variable in which the lower iteration
361 /// number is returned.
362 /// \param UB Address of the output variable in which the upper iteration
363 /// number is returned.
364 /// \param ST Address of the output variable in which the stride value is
365 /// returned nesessary to generated the static_chunked scheduled loop.
366 /// \param Chunk Value of the chunk for the static_chunked scheduled loop.
367 /// For the default (nullptr) value, the chunk 1 will be used.
368 ///
369 virtual void EmitOMPForInit(CodeGenFunction &CGF, SourceLocation Loc,
370 OpenMPScheduleClauseKind SchedKind,
371 unsigned IVSize, bool IVSigned, llvm::Value *IL,
372 llvm::Value *LB, llvm::Value *UB, llvm::Value *ST,
373 llvm::Value *Chunk = nullptr);
374
375 /// \brief Call the appropriate runtime routine to notify that we finished
376 /// all the work with current loop.
377 ///
378 /// \param CGF Reference to current CodeGenFunction.
379 /// \param Loc Clang source location.
380 /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
381 ///
382 virtual void EmitOMPForFinish(CodeGenFunction &CGF, SourceLocation Loc,
383 OpenMPScheduleClauseKind ScheduleKind);
384
Alexey Bataevb2059782014-10-13 08:23:51 +0000385 /// \brief Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32
386 /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads'
387 /// clause.
388 /// \param NumThreads An integer value of threads.
389 virtual void EmitOMPNumThreadsClause(CodeGenFunction &CGF,
390 llvm::Value *NumThreads,
391 SourceLocation Loc);
Alexey Bataev97720002014-11-11 04:05:39 +0000392
393 /// \brief Returns address of the threadprivate variable for the current
394 /// thread.
NAKAMURA Takumicdcbfba2014-11-11 07:58:06 +0000395 /// \param VD Threadprivate variable.
Alexey Bataev97720002014-11-11 04:05:39 +0000396 /// \param VDAddr Address of the global variable \a VD.
397 /// \param Loc Location of the reference to threadprivate var.
398 /// \return Address of the threadprivate variable for the current thread.
399 virtual llvm::Value *getOMPAddrOfThreadPrivate(CodeGenFunction &CGF,
400 const VarDecl *VD,
401 llvm::Value *VDAddr,
402 SourceLocation Loc);
403
404 /// \brief Emit a code for initialization of threadprivate variable. It emits
405 /// a call to runtime library which adds initial value to the newly created
406 /// threadprivate variable (if it is not constant) and registers destructor
407 /// for the variable (if any).
408 /// \param VD Threadprivate variable.
409 /// \param VDAddr Address of the global variable \a VD.
410 /// \param Loc Location of threadprivate declaration.
411 /// \param PerformInit true if initialization expression is not constant.
412 virtual llvm::Function *
413 EmitOMPThreadPrivateVarDefinition(const VarDecl *VD, llvm::Value *VDAddr,
414 SourceLocation Loc, bool PerformInit,
415 CodeGenFunction *CGF = nullptr);
Alexey Bataevcc37cc12014-11-20 04:34:54 +0000416
417 /// \brief Emit flush of the variables specified in 'omp flush' directive.
418 /// \param Vars List of variables to flush.
419 virtual void EmitOMPFlush(CodeGenFunction &CGF, ArrayRef<const Expr *> Vars,
420 SourceLocation Loc);
Alexey Bataev9959db52014-05-06 10:08:46 +0000421};
Alexey Bataev23b69422014-06-18 07:08:49 +0000422} // namespace CodeGen
423} // namespace clang
Alexey Bataev9959db52014-05-06 10:08:46 +0000424
425#endif