diff options
author | Alexander Musman <alexander.musman@gmail.com> | 2014-07-17 08:54:58 +0000 |
---|---|---|
committer | Alexander Musman <alexander.musman@gmail.com> | 2014-07-17 08:54:58 +0000 |
commit | 80c2289a03f8a993b2377993a873242a62116c58 (patch) | |
tree | 884ff25047b61490212bc094c568afb654d56757 /clang/lib/Sema | |
parent | c790515c8b2f395cc259030532992a4497b5daa8 (diff) | |
download | bcm5719-llvm-80c2289a03f8a993b2377993a873242a62116c58.tar.gz bcm5719-llvm-80c2289a03f8a993b2377993a873242a62116c58.zip |
[OPENMP] Parsing/Sema analysis of directive 'master'
llvm-svn: 213237
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 64 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 11 |
2 files changed, 68 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 58f9bbed6f9..ef36e7e901e 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1000,6 +1000,14 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) { Params); break; } + case OMPD_master: { + Sema::CapturedParamNameType Params[] = { + std::make_pair(StringRef(), QualType()) // __context with shared vars + }; + ActOnCapturedRegionStart(DSAStack->getConstructLoc(), CurScope, CR_OpenMP, + Params); + break; + } case OMPD_parallel_for: { QualType KmpInt32Ty = Context.getIntTypeForBitwidth(32, 1); QualType KmpInt32PtrTy = Context.getPointerType(KmpInt32Ty); @@ -1044,9 +1052,10 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // +------------------+-----------------+------------------------------------+ // | parallel | parallel | * | // | parallel | for | * | + // | parallel | master | * | // | parallel | simd | * | // | parallel | sections | * | - // | parallel | section | + | + // | parallel | section | + | // | parallel | single | * | // | parallel | parallel for | * | // | parallel |parallel sections| * | @@ -1054,6 +1063,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // +------------------+-----------------+------------------------------------+ // | for | parallel | * | // | for | for | + | + // | for | master | + | // | for | simd | * | // | for | sections | + | // | for | section | + | @@ -1062,8 +1072,20 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | for |parallel sections| * | // | for | task | * | // +------------------+-----------------+------------------------------------+ + // | master | parallel | * | + // | master | for | + | + // | master | master | * | + // | master | simd | * | + // | master | sections | + | + // | master | section | + | + // | master | single | + | + // | master | parallel for | * | + // | master |parallel sections| * | + // | master | task | * | + // +------------------+-----------------+------------------------------------+ // | simd | parallel | | // | simd | for | | + // | simd | master | | // | simd | simd | | // | simd | sections | | // | simd | section | | @@ -1074,6 +1096,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // +------------------+-----------------+------------------------------------+ // | sections | parallel | * | // | sections | for | + | + // | sections | master | + | // | sections | simd | * | // | sections | sections | + | // | sections | section | * | @@ -1084,6 +1107,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // +------------------+-----------------+------------------------------------+ // | section | parallel | * | // | section | for | + | + // | section | master | + | // | section | simd | * | // | section | sections | + | // | section | section | + | @@ -1094,6 +1118,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // +------------------+-----------------+------------------------------------+ // | single | parallel | * | // | single | for | + | + // | single | master | + | // | single | simd | * | // | single | sections | + | // | single | section | + | @@ -1104,6 +1129,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // +------------------+-----------------+------------------------------------+ // | parallel for | parallel | * | // | parallel for | for | + | + // | parallel for | master | + | // | parallel for | simd | * | // | parallel for | sections | + | // | parallel for | section | + | @@ -1114,6 +1140,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // +------------------+-----------------+------------------------------------+ // | parallel sections| parallel | * | // | parallel sections| for | + | + // | parallel sections| master | + | // | parallel sections| simd | * | // | parallel sections| sections | + | // | parallel sections| section | * | @@ -1124,9 +1151,10 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // +------------------+-----------------+------------------------------------+ // | task | parallel | * | // | task | for | + | + // | task | master | + | // | task | simd | * | // | task | sections | + | - // | task | section | + | + // | task | section | + | // | task | single | + | // | task | parallel for | * | // | task |parallel sections| * | @@ -1157,16 +1185,23 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, } return false; } - if (isOpenMPWorksharingDirective(CurrentRegion) && - !isOpenMPParallelDirective(CurrentRegion) && - !isOpenMPSimdDirective(CurrentRegion)) { + if (CurrentRegion == OMPD_master) { + // OpenMP [2.16, Nesting of Regions] + // A master region may not be closely nested inside a worksharing, + // atomic (TODO), or explicit task region. + NestingProhibited = isOpenMPWorksharingDirective(ParentRegion) || + ParentRegion == OMPD_task; + } else if (isOpenMPWorksharingDirective(CurrentRegion) && + !isOpenMPParallelDirective(CurrentRegion) && + !isOpenMPSimdDirective(CurrentRegion)) { // OpenMP [2.16, Nesting of Regions] // A worksharing region may not be closely nested inside a worksharing, // explicit task, critical, ordered, atomic, or master region. // TODO NestingProhibited = (isOpenMPWorksharingDirective(ParentRegion) && !isOpenMPSimdDirective(ParentRegion)) || - ParentRegion == OMPD_task; + ParentRegion == OMPD_task || + ParentRegion == OMPD_master; ShouldBeInParallelRegion = true; } if (NestingProhibited) { @@ -1231,13 +1266,18 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, break; case OMPD_section: assert(ClausesWithImplicit.empty() && - "No clauses is allowed for 'omp section' directive"); + "No clauses are allowed for 'omp section' directive"); Res = ActOnOpenMPSectionDirective(AStmt, StartLoc, EndLoc); break; case OMPD_single: Res = ActOnOpenMPSingleDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc); break; + case OMPD_master: + assert(ClausesWithImplicit.empty() && + "No clauses are allowed for 'omp master' directive"); + Res = ActOnOpenMPMasterDirective(AStmt, StartLoc, EndLoc); + break; case OMPD_parallel_for: Res = ActOnOpenMPParallelForDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc, VarsWithInheritedDSA); @@ -1906,6 +1946,16 @@ StmtResult Sema::ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses, return OMPSingleDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt); } +StmtResult Sema::ActOnOpenMPMasterDirective(Stmt *AStmt, + SourceLocation StartLoc, + SourceLocation EndLoc) { + assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement expected"); + + getCurFunction()->setHasBranchProtectedScope(); + + return OMPMasterDirective::Create(Context, StartLoc, EndLoc, AStmt); +} + StmtResult Sema::ActOnOpenMPParallelForDirective( ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index f9775c1ad10..6eb18e8ac79 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -6509,6 +6509,17 @@ TreeTransform<Derived>::TransformOMPSingleDirective(OMPSingleDirective *D) { } template <typename Derived> +StmtResult +TreeTransform<Derived>::TransformOMPMasterDirective(OMPMasterDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_master, DirName, nullptr, + D->getLocStart()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + +template <typename Derived> StmtResult TreeTransform<Derived>::TransformOMPParallelForDirective( OMPParallelForDirective *D) { DeclarationNameInfo DirName; |