diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2015-02-05 05:57:51 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-02-05 05:57:51 +0000 |
commit | 9f797f32e28e3c1f5524c42ff4ee6ff500a4c595 (patch) | |
tree | 73c395dc90862a63d668cf8014dc840c7804ca00 /clang/lib/CodeGen | |
parent | bc9f12e7bcb75fb6e7a2c46ffefa3fc810d7a0b2 (diff) | |
download | bcm5719-llvm-9f797f32e28e3c1f5524c42ff4ee6ff500a4c595.tar.gz bcm5719-llvm-9f797f32e28e3c1f5524c42ff4ee6ff500a4c595.zip |
[OPENMP] Codegen for 'taskyield' directive
For 'taskyield' directive emit call to kmp_int32 __kmpc_omp_taskyield(ident_t *,
kmp_int32 global_tid, int end_part); runtime function call with end_part arg set
to 0 (it is ignored).
Differential Revision: http://reviews.llvm.org/D7047
llvm-svn: 228272
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 19 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.h | 6 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 5 |
3 files changed, 28 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 90bc5dbdb6d..abc609aebb2 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -475,6 +475,15 @@ CGOpenMPRuntime::CreateRuntimeFunction(OpenMPRTLFunction Function) { RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_end_master"); break; } + case OMPRTL__kmpc_omp_taskyield: { + // Build kmp_int32 __kmpc_omp_taskyield(ident_t *, kmp_int32 global_tid, + // int end_part); + llvm::Type *TypeParams[] = {getIdentTyPointerTy(), CGM.Int32Ty, CGM.IntTy}; + llvm::FunctionType *FnTy = + llvm::FunctionType::get(CGM.Int32Ty, TypeParams, /*isVarArg=*/false); + RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_omp_taskyield"); + break; + } } return RTLFn; } @@ -786,6 +795,16 @@ void CGOpenMPRuntime::EmitOMPMasterRegion( }); } +void CGOpenMPRuntime::EmitOMPTaskyieldCall(CodeGenFunction &CGF, + SourceLocation Loc) { + // Build call __kmpc_omp_taskyield(loc, thread_id, 0); + llvm::Value *Args[] = { + EmitOpenMPUpdateLocation(CGF, Loc), GetOpenMPThreadID(CGF, Loc), + llvm::ConstantInt::get(CGM.IntTy, /*V=*/0, /*isSigned=*/true)}; + auto RTLFn = CreateRuntimeFunction(OMPRTL__kmpc_omp_taskyield); + CGF.EmitRuntimeCall(RTLFn, Args); +} + void CGOpenMPRuntime::EmitOMPBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, bool IsExplicit) { // Build call __kmpc_cancel_barrier(loc, thread_id); diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h index 5c40d530a10..5ff8dd654ef 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.h +++ b/clang/lib/CodeGen/CGOpenMPRuntime.h @@ -88,6 +88,9 @@ private: OMPRTL__kmpc_master, // Call to void __kmpc_end_master(ident_t *, kmp_int32 global_tid); OMPRTL__kmpc_end_master, + // Call to kmp_int32 __kmpc_omp_taskyield(ident_t *, kmp_int32 global_tid, + // int end_part); + OMPRTL__kmpc_omp_taskyield, }; /// \brief Values for bit flags used in the ident_t to describe the fields. @@ -306,6 +309,9 @@ public: const std::function<void()> &MasterOpGen, SourceLocation Loc); + /// \brief Emits code for a taskyield directive. + virtual void EmitOMPTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc); + /// \brief Emits explicit barrier for OpenMP threads. /// \param IsExplicit true, if it is explicitly specified barrier. /// diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 29743282d36..2518e55d4b3 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -750,8 +750,9 @@ void CodeGenFunction::EmitOMPTaskDirective(const OMPTaskDirective &) { llvm_unreachable("CodeGen for 'omp task' is not supported yet."); } -void CodeGenFunction::EmitOMPTaskyieldDirective(const OMPTaskyieldDirective &) { - llvm_unreachable("CodeGen for 'omp taskyield' is not supported yet."); +void CodeGenFunction::EmitOMPTaskyieldDirective( + const OMPTaskyieldDirective &S) { + CGM.getOpenMPRuntime().EmitOMPTaskyieldCall(*this, S.getLocStart()); } void CodeGenFunction::EmitOMPBarrierDirective(const OMPBarrierDirective &S) { |