diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2014-07-18 09:11:51 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2014-07-18 09:11:51 +0000 |
commit | 4d1dfeabc969093847dce13a2c959c30544c79d2 (patch) | |
tree | cab67a86614d7f7f653ffc21f48b302de747771c /clang/lib/Sema/SemaOpenMP.cpp | |
parent | e022851f3b253f421eced5fb0f8f5654771a35a1 (diff) | |
download | bcm5719-llvm-4d1dfeabc969093847dce13a2c959c30544c79d2.tar.gz bcm5719-llvm-4d1dfeabc969093847dce13a2c959c30544c79d2.zip |
[OPENMP] Initial parsing and sema analysis for 'barrier' directive.
llvm-svn: 213360
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 67f9eb9fd93..eeb4fbd7527 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1044,6 +1044,14 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) { Params); break; } + case OMPD_barrier: { + Sema::CapturedParamNameType Params[] = { + std::make_pair(StringRef(), QualType()) // __context with shared vars + }; + ActOnCapturedRegionStart(DSAStack->getConstructLoc(), CurScope, CR_OpenMP, + Params); + break; + } case OMPD_threadprivate: llvm_unreachable("OpenMP Directive is not allowed"); case OMPD_unknown: @@ -1069,6 +1077,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | parallel |parallel sections| * | // | parallel | task | * | // | parallel | taskyield | * | + // | parallel | barrier | * | // +------------------+-----------------+------------------------------------+ // | for | parallel | * | // | for | for | + | @@ -1081,6 +1090,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | for |parallel sections| * | // | for | task | * | // | for | taskyield | * | + // | for | barrier | + | // +------------------+-----------------+------------------------------------+ // | master | parallel | * | // | master | for | + | @@ -1093,6 +1103,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | master |parallel sections| * | // | master | task | * | // | master | taskyield | * | + // | master | barrier | + | // +------------------+-----------------+------------------------------------+ // | simd | parallel | | // | simd | for | | @@ -1105,6 +1116,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | simd |parallel sections| | // | simd | task | | // | simd | taskyield | | + // | simd | barrier | | // +------------------+-----------------+------------------------------------+ // | sections | parallel | * | // | sections | for | + | @@ -1117,6 +1129,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | sections |parallel sections| * | // | sections | task | * | // | sections | taskyield | * | + // | sections | barrier | + | // +------------------+-----------------+------------------------------------+ // | section | parallel | * | // | section | for | + | @@ -1129,6 +1142,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | section |parallel sections| * | // | section | task | * | // | section | taskyield | * | + // | section | barrier | + | // +------------------+-----------------+------------------------------------+ // | single | parallel | * | // | single | for | + | @@ -1141,6 +1155,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | single |parallel sections| * | // | single | task | * | // | single | taskyield | * | + // | single | barrier | + | // +------------------+-----------------+------------------------------------+ // | parallel for | parallel | * | // | parallel for | for | + | @@ -1153,6 +1168,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | parallel for |parallel sections| * | // | parallel for | task | * | // | parallel for | taskyield | * | + // | parallel for | barrier | + | // +------------------+-----------------+------------------------------------+ // | parallel sections| parallel | * | // | parallel sections| for | + | @@ -1165,6 +1181,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | parallel sections|parallel sections| * | // | parallel sections| task | * | // | parallel sections| taskyield | * | + // | parallel sections| barrier | + | // +------------------+-----------------+------------------------------------+ // | task | parallel | * | // | task | for | + | @@ -1177,6 +1194,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | task |parallel sections| * | // | task | task | * | // | task | taskyield | * | + // | task | barrier | + | // +------------------+-----------------+------------------------------------+ if (Stack->getCurScope()) { auto ParentRegion = Stack->getParentDirective(); @@ -1209,6 +1227,14 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // atomic (TODO), or explicit task region. NestingProhibited = isOpenMPWorksharingDirective(ParentRegion) || ParentRegion == OMPD_task; + } else if (CurrentRegion == OMPD_barrier) { + // OpenMP [2.16, Nesting of Regions] + // A barrier region may not be closely nested inside a worksharing, + // explicit task, critical(TODO), ordered(TODO), atomic(TODO), or master + // region. + NestingProhibited = isOpenMPWorksharingDirective(ParentRegion) || + ParentRegion == OMPD_task || + ParentRegion == OMPD_master; } else if (isOpenMPWorksharingDirective(CurrentRegion) && !isOpenMPParallelDirective(CurrentRegion) && !isOpenMPSimdDirective(CurrentRegion)) { @@ -1318,6 +1344,13 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, "No associated statement allowed for 'omp taskyield' directive"); Res = ActOnOpenMPTaskyieldDirective(StartLoc, EndLoc); break; + case OMPD_barrier: + assert(ClausesWithImplicit.empty() && + "No clauses are allowed for 'omp barrier' directive"); + assert(AStmt == nullptr && + "No associated statement allowed for 'omp barrier' directive"); + Res = ActOnOpenMPBarrierDirective(StartLoc, EndLoc); + break; case OMPD_threadprivate: llvm_unreachable("OpenMP Directive is not allowed"); case OMPD_unknown: @@ -2066,6 +2099,11 @@ StmtResult Sema::ActOnOpenMPTaskyieldDirective(SourceLocation StartLoc, return OMPTaskyieldDirective::Create(Context, StartLoc, EndLoc); } +StmtResult Sema::ActOnOpenMPBarrierDirective(SourceLocation StartLoc, + SourceLocation EndLoc) { + return OMPBarrierDirective::Create(Context, StartLoc, EndLoc); +} + OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, SourceLocation StartLoc, SourceLocation LParenLoc, |