@@ -43,7 +43,10 @@ namespace CodeGen {
43
43
class CodeGenFunction ;
44
44
class CodeGenModule ;
45
45
46
+ typedef llvm::function_ref<void (CodeGenFunction &)> RegionCodeGenTy;
47
+
46
48
class CGOpenMPRuntime {
49
+ private:
47
50
enum OpenMPRTLFunction {
48
51
// / \brief Call to void __kmpc_fork_call(ident_t *loc, kmp_int32 argc,
49
52
// / kmpc_micro microtask, ...);
@@ -284,25 +287,27 @@ class CGOpenMPRuntime {
284
287
virtual ~CGOpenMPRuntime () {}
285
288
virtual void clear ();
286
289
287
- // / \brief Emits outlined function for the specified OpenMP directive \a D.
288
- // / This outlined function has type void(*)(kmp_int32 *ThreadID, kmp_int32
289
- // / BoundID, struct context_vars*).
290
+ // / \brief Emits outlined function for the specified OpenMP parallel directive
291
+ // / \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
292
+ // / kmp_int32 BoundID, struct context_vars*).
290
293
// / \param D OpenMP directive.
291
294
// / \param ThreadIDVar Variable for thread id in the current OpenMP region.
292
- // /
293
- virtual llvm::Value *emitOutlinedFunction (const OMPExecutableDirective &D,
294
- const VarDecl *ThreadIDVar);
295
+ // / \param CodeGen Code generation sequence for the \a D directive.
296
+ virtual llvm::Value *
297
+ emitParallelOutlinedFunction (const OMPExecutableDirective &D,
298
+ const VarDecl *ThreadIDVar,
299
+ const RegionCodeGenTy &CodeGen);
295
300
296
301
// / \brief Emits outlined function for the OpenMP task directive \a D. This
297
302
// / outlined function has type void(*)(kmp_int32 ThreadID, kmp_int32
298
303
// / PartID, struct context_vars*).
299
304
// / \param D OpenMP directive.
300
305
// / \param ThreadIDVar Variable for thread id in the current OpenMP region.
301
- // / \param PartIDVar If not nullptr - variable used for part id in tasks .
306
+ // / \param CodeGen Code generation sequence for the \a D directive .
302
307
// /
303
308
virtual llvm::Value *emitTaskOutlinedFunction (const OMPExecutableDirective &D,
304
309
const VarDecl *ThreadIDVar,
305
- const VarDecl *PartIDVar );
310
+ const RegionCodeGenTy &CodeGen );
306
311
307
312
// / \brief Cleans up references to the objects in finished function.
308
313
// /
@@ -334,14 +339,14 @@ class CGOpenMPRuntime {
334
339
// / \param CriticalOpGen Generator for the statement associated with the given
335
340
// / critical region.
336
341
virtual void emitCriticalRegion (CodeGenFunction &CGF, StringRef CriticalName,
337
- const std::function< void ()> &CriticalOpGen,
342
+ const RegionCodeGenTy &CriticalOpGen,
338
343
SourceLocation Loc);
339
344
340
345
// / \brief Emits a master region.
341
346
// / \param MasterOpGen Generator for the statement associated with the given
342
347
// / master region.
343
348
virtual void emitMasterRegion (CodeGenFunction &CGF,
344
- const std::function< void ()> &MasterOpGen,
349
+ const RegionCodeGenTy &MasterOpGen,
345
350
SourceLocation Loc);
346
351
347
352
// / \brief Emits code for a taskyield directive.
@@ -351,7 +356,7 @@ class CGOpenMPRuntime {
351
356
// / \param SingleOpGen Generator for the statement associated with the given
352
357
// / single region.
353
358
virtual void emitSingleRegion (CodeGenFunction &CGF,
354
- const std::function< void ()> &SingleOpGen,
359
+ const RegionCodeGenTy &SingleOpGen,
355
360
SourceLocation Loc,
356
361
ArrayRef<const Expr *> CopyprivateVars,
357
362
ArrayRef<const Expr *> SrcExprs,
@@ -506,17 +511,13 @@ class CGOpenMPRuntime {
506
511
llvm::PointerIntPair<llvm::Value *, 1 , bool > Final,
507
512
llvm::Value *TaskFunction, QualType SharedsTy,
508
513
llvm::Value *Shareds);
514
+ // / \brief Emit code for the directive that does not require outlining.
515
+ // /
516
+ // / \param CodeGen Code generation sequence for the \a D directive.
517
+ virtual void emitInlinedDirective (CodeGenFunction &CGF,
518
+ const RegionCodeGenTy &CodeGen);
509
519
};
510
520
511
- // / \brief RAII for emitting code of CapturedStmt without function outlining.
512
- class InlinedOpenMPRegionRAII {
513
- CodeGenFunction &CGF;
514
-
515
- public:
516
- InlinedOpenMPRegionRAII (CodeGenFunction &CGF,
517
- const OMPExecutableDirective &D);
518
- ~InlinedOpenMPRegionRAII ();
519
- };
520
521
} // namespace CodeGen
521
522
} // namespace clang
522
523
0 commit comments