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