diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2014-05-06 10:08:46 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2014-05-06 10:08:46 +0000 |
commit | bfa38388de6a8e39aa29284442650f49e3d2d713 (patch) | |
tree | 7ad40dee502d383e5eaaf975e88cbf58bf43ac58 /lib/Sema/SemaOpenMP.cpp | |
parent | 600a7d72132a5248669b39fd55367a3715169ad3 (diff) | |
download | clang-bfa38388de6a8e39aa29284442650f49e3d2d713.tar.gz clang-bfa38388de6a8e39aa29284442650f49e3d2d713.tar.bz2 clang-bfa38388de6a8e39aa29284442650f49e3d2d713.tar.xz |
[OPENMP] Initial codegen for '#pragma omp parallel'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOpenMP.cpp')
-rw-r--r-- | lib/Sema/SemaOpenMP.cpp | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 441fc56a7f..219ad074ce 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -1,4 +1,4 @@ -//===--- SemaOpenMP.cpp - Semantic Analysis for OpenMP constructs ----------===// +//===--- SemaOpenMP.cpp - Semantic Analysis for OpenMP constructs ---------===// // // The LLVM Compiler Infrastructure // @@ -12,13 +12,15 @@ /// //===----------------------------------------------------------------------===// -#include "clang/Basic/OpenMPKinds.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclOpenMP.h" #include "clang/AST/StmtCXX.h" #include "clang/AST/StmtOpenMP.h" #include "clang/AST/StmtVisitor.h" +#include "clang/Basic/OpenMPKinds.h" +#include "clang/Lex/Preprocessor.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Scope.h" @@ -669,6 +671,36 @@ public: }; } +void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, SourceLocation Loc, + Scope *CurScope) { + switch (DKind) { + case OMPD_parallel: { + QualType KmpInt32Ty = Context.getIntTypeForBitwidth(32, 1); + QualType KmpInt32PtrTy = Context.getPointerType(KmpInt32Ty); + Sema::CapturedParamNameType Params[3] = { + std::make_pair(".global_tid.", KmpInt32PtrTy), + std::make_pair(".bound_tid.", KmpInt32PtrTy), + std::make_pair(StringRef(), QualType()) // __context with shared vars + }; + ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP, Params); + break; + } + case OMPD_simd: { + Sema::CapturedParamNameType Params[1] = { + std::make_pair(StringRef(), QualType()) // __context with shared vars + }; + ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP, Params); + break; + } + case OMPD_threadprivate: + case OMPD_task: + llvm_unreachable("OpenMP Directive is not allowed"); + case OMPD_unknown: + case NUM_OPENMP_DIRECTIVES: + llvm_unreachable("Unknown OpenMP directive"); + } +} + StmtResult Sema::ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, ArrayRef<OMPClause *> Clauses, Stmt *AStmt, @@ -725,6 +757,15 @@ StmtResult Sema::ActOnOpenMPParallelDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc) { + assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement expected"); + CapturedStmt *CS = cast<CapturedStmt>(AStmt); + // 1.2.2 OpenMP Language Terminology + // Structured block - An executable statement with a single entry at the + // top and a single exit at the bottom. + // The point of exit cannot be a branch out of the structured block. + // longjmp() and throw() must not violate the entry/exit criteria. + CS->getCapturedDecl()->setNothrow(); + getCurFunction()->setHasBranchProtectedScope(); return Owned(OMPParallelDirective::Create(Context, StartLoc, EndLoc, |