Skip to content

Commit 6f1ffc0

Browse files
committedApr 10, 2015
[OPENMP] Refactoring of codegen for OpenMP directives.
Refactored API of OpenMPRuntime for compatibility with combined directives. Differential Revision: http://reviews.llvm.org/D8859 llvm-svn: 234564
1 parent bd51a6a commit 6f1ffc0

9 files changed

+498
-372
lines changed
 

‎clang/lib/CodeGen/CGOpenMPRuntime.cpp

+163-83
Large diffs are not rendered by default.

‎clang/lib/CodeGen/CGOpenMPRuntime.h

+21-20
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ namespace CodeGen {
4343
class CodeGenFunction;
4444
class CodeGenModule;
4545

46+
typedef llvm::function_ref<void(CodeGenFunction &)> RegionCodeGenTy;
47+
4648
class CGOpenMPRuntime {
49+
private:
4750
enum OpenMPRTLFunction {
4851
/// \brief Call to void __kmpc_fork_call(ident_t *loc, kmp_int32 argc,
4952
/// kmpc_micro microtask, ...);
@@ -284,25 +287,27 @@ class CGOpenMPRuntime {
284287
virtual ~CGOpenMPRuntime() {}
285288
virtual void clear();
286289

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*).
290293
/// \param D OpenMP directive.
291294
/// \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);
295300

296301
/// \brief Emits outlined function for the OpenMP task directive \a D. This
297302
/// outlined function has type void(*)(kmp_int32 ThreadID, kmp_int32
298303
/// PartID, struct context_vars*).
299304
/// \param D OpenMP directive.
300305
/// \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.
302307
///
303308
virtual llvm::Value *emitTaskOutlinedFunction(const OMPExecutableDirective &D,
304309
const VarDecl *ThreadIDVar,
305-
const VarDecl *PartIDVar);
310+
const RegionCodeGenTy &CodeGen);
306311

307312
/// \brief Cleans up references to the objects in finished function.
308313
///
@@ -334,14 +339,14 @@ class CGOpenMPRuntime {
334339
/// \param CriticalOpGen Generator for the statement associated with the given
335340
/// critical region.
336341
virtual void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName,
337-
const std::function<void()> &CriticalOpGen,
342+
const RegionCodeGenTy &CriticalOpGen,
338343
SourceLocation Loc);
339344

340345
/// \brief Emits a master region.
341346
/// \param MasterOpGen Generator for the statement associated with the given
342347
/// master region.
343348
virtual void emitMasterRegion(CodeGenFunction &CGF,
344-
const std::function<void()> &MasterOpGen,
349+
const RegionCodeGenTy &MasterOpGen,
345350
SourceLocation Loc);
346351

347352
/// \brief Emits code for a taskyield directive.
@@ -351,7 +356,7 @@ class CGOpenMPRuntime {
351356
/// \param SingleOpGen Generator for the statement associated with the given
352357
/// single region.
353358
virtual void emitSingleRegion(CodeGenFunction &CGF,
354-
const std::function<void()> &SingleOpGen,
359+
const RegionCodeGenTy &SingleOpGen,
355360
SourceLocation Loc,
356361
ArrayRef<const Expr *> CopyprivateVars,
357362
ArrayRef<const Expr *> SrcExprs,
@@ -506,17 +511,13 @@ class CGOpenMPRuntime {
506511
llvm::PointerIntPair<llvm::Value *, 1, bool> Final,
507512
llvm::Value *TaskFunction, QualType SharedsTy,
508513
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);
509519
};
510520

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-
};
520521
} // namespace CodeGen
521522
} // namespace clang
522523

0 commit comments

Comments
 (0)
Please sign in to comment.