diff options
| author | Alexey Bataev <a.bataev@hotmail.com> | 2014-07-18 10:17:07 +0000 |
|---|---|---|
| committer | Alexey Bataev <a.bataev@hotmail.com> | 2014-07-18 10:17:07 +0000 |
| commit | 2df347ad96350cc4f0761db412608193703a46c7 (patch) | |
| tree | d45673a081abd8f272ddaa0d4622bb6f49c8ec1f /clang/lib | |
| parent | 7a86a548b94d7316345481498a46335e1a220406 (diff) | |
| download | bcm5719-llvm-2df347ad96350cc4f0761db412608193703a46c7.tar.gz bcm5719-llvm-2df347ad96350cc4f0761db412608193703a46c7.zip | |
[OPENMP] Initial parsing and sema analysis for 'taskwait' directive.
llvm-svn: 213363
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Stmt.cpp | 14 | ||||
| -rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/AST/StmtProfile.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Basic/OpenMPKinds.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGStmt.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 1 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 30 | ||||
| -rw-r--r-- | clang/lib/Sema/TreeTransform.h | 11 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTReaderStmt.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTWriterStmt.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 1 |
14 files changed, 93 insertions, 7 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 2328d27b9c0..e46edd23ec0 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -1603,3 +1603,17 @@ OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C, return new (Mem) OMPBarrierDirective(); } +OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation EndLoc) { + void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); + OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc); + return Dir; +} + +OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C, + EmptyShell) { + void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective)); + return new (Mem) OMPTaskwaitDirective(); +} + diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 02f09c4a5ae..0267bcca2ab 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -860,6 +860,11 @@ void StmtPrinter::VisitOMPBarrierDirective(OMPBarrierDirective *Node) { PrintOMPExecutableDirective(Node); } +void StmtPrinter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *Node) { + Indent() << "#pragma omp taskwait"; + PrintOMPExecutableDirective(Node); +} + //===----------------------------------------------------------------------===// // Expr printing methods. //===----------------------------------------------------------------------===// diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index ae3be8dc1a0..0cd0f62dc5f 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -415,6 +415,10 @@ void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) { VisitOMPExecutableDirective(S); } +void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) { + VisitOMPExecutableDirective(S); +} + void StmtProfiler::VisitExpr(const Expr *S) { VisitStmt(S); } diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp index ec2e6b4e0e7..f304513fccf 100644 --- a/clang/lib/Basic/OpenMPKinds.cpp +++ b/clang/lib/Basic/OpenMPKinds.cpp @@ -259,6 +259,7 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind, case OMPD_master: case OMPD_taskyield: case OMPD_barrier: + case OMPD_taskwait: break; } return false; diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 5da12222fc8..cd970c747c0 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -212,6 +212,9 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { case Stmt::OMPBarrierDirectiveClass: EmitOMPBarrierDirective(cast<OMPBarrierDirective>(*S)); break; + case Stmt::OMPTaskwaitDirectiveClass: + EmitOMPTaskwaitDirective(cast<OMPTaskwaitDirective>(*S)); + break; } } diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index db9daefbac2..7731c76f512 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -116,3 +116,7 @@ void CodeGenFunction::EmitOMPBarrierDirective(const OMPBarrierDirective &) { llvm_unreachable("CodeGen for 'omp barrier' is not supported yet."); } +void CodeGenFunction::EmitOMPTaskwaitDirective(const OMPTaskwaitDirective &) { + llvm_unreachable("CodeGen for 'omp taskwait' is not supported yet."); +} + diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index f0541f5bf1b..3692b0203f4 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -1933,6 +1933,7 @@ public: void EmitOMPTaskDirective(const OMPTaskDirective &S); void EmitOMPTaskyieldDirective(const OMPTaskyieldDirective &S); void EmitOMPBarrierDirective(const OMPBarrierDirective &S); + void EmitOMPTaskwaitDirective(const OMPTaskwaitDirective &S); //===--------------------------------------------------------------------===// // LValue Expression Emission diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index b3f13b8bff3..cf991784306 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -85,6 +85,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() { case OMPD_task: case OMPD_taskyield: case OMPD_barrier: + case OMPD_taskwait: case OMPD_for: case OMPD_sections: case OMPD_section: @@ -109,8 +110,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() { /// executable-directive: /// annot_pragma_openmp 'parallel' | 'simd' | 'for' | 'sections' | /// 'section' | 'single' | 'master' | 'parallel for' | -/// 'parallel sections' | 'task' | 'taskyield' | 'barrier' {clause} -/// annot_pragma_openmp_end +/// 'parallel sections' | 'task' | 'taskyield' | 'barrier' | 'taskwait' +/// {clause} annot_pragma_openmp_end /// StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(bool StandAloneAllowed) { @@ -148,6 +149,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(bool StandAloneAllowed) { break; case OMPD_taskyield: case OMPD_barrier: + case OMPD_taskwait: if (!StandAloneAllowed) { Diag(Tok, diag::err_omp_immediate_directive) << getOpenMPDirectiveName(DKind); diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 01abf5f63cc..6f6c495dde3 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -804,7 +804,6 @@ StmtResult Parser::ParseCompoundStatement(bool isStmtExpr) { /// declaration /// [GNU] '__extension__' declaration /// statement -/// [OMP] openmp-directive [TODO] /// /// [GNU] label-declarations: /// [GNU] label-declaration @@ -813,10 +812,6 @@ StmtResult Parser::ParseCompoundStatement(bool isStmtExpr) { /// [GNU] label-declaration: /// [GNU] '__label__' identifier-list ';' /// -/// [OMP] openmp-directive: [TODO] -/// [OMP] barrier-directive -/// [OMP] flush-directive -/// StmtResult Parser::ParseCompoundStatement(bool isStmtExpr, unsigned ScopeFlags) { assert(Tok.is(tok::l_brace) && "Not a compount stmt!"); diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index eeb4fbd7527..f2421da5822 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1052,6 +1052,14 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) { Params); break; } + case OMPD_taskwait: { + 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: @@ -1078,6 +1086,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | parallel | task | * | // | parallel | taskyield | * | // | parallel | barrier | * | + // | parallel | taskwait | * | // +------------------+-----------------+------------------------------------+ // | for | parallel | * | // | for | for | + | @@ -1091,6 +1100,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | for | task | * | // | for | taskyield | * | // | for | barrier | + | + // | for | taskwait | * | // +------------------+-----------------+------------------------------------+ // | master | parallel | * | // | master | for | + | @@ -1104,6 +1114,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | master | task | * | // | master | taskyield | * | // | master | barrier | + | + // | master | taskwait | * | // +------------------+-----------------+------------------------------------+ // | simd | parallel | | // | simd | for | | @@ -1117,6 +1128,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | simd | task | | // | simd | taskyield | | // | simd | barrier | | + // | simd | taskwait | | // +------------------+-----------------+------------------------------------+ // | sections | parallel | * | // | sections | for | + | @@ -1130,6 +1142,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | sections | task | * | // | sections | taskyield | * | // | sections | barrier | + | + // | sections | taskwait | * | // +------------------+-----------------+------------------------------------+ // | section | parallel | * | // | section | for | + | @@ -1143,6 +1156,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | section | task | * | // | section | taskyield | * | // | section | barrier | + | + // | section | taskwait | * | // +------------------+-----------------+------------------------------------+ // | single | parallel | * | // | single | for | + | @@ -1156,6 +1170,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | single | task | * | // | single | taskyield | * | // | single | barrier | + | + // | single | taskwait | * | // +------------------+-----------------+------------------------------------+ // | parallel for | parallel | * | // | parallel for | for | + | @@ -1169,6 +1184,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | parallel for | task | * | // | parallel for | taskyield | * | // | parallel for | barrier | + | + // | parallel for | taskwait | * | // +------------------+-----------------+------------------------------------+ // | parallel sections| parallel | * | // | parallel sections| for | + | @@ -1182,6 +1198,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | parallel sections| task | * | // | parallel sections| taskyield | * | // | parallel sections| barrier | + | + // | parallel sections| taskwait | * | // +------------------+-----------------+------------------------------------+ // | task | parallel | * | // | task | for | + | @@ -1195,6 +1212,7 @@ bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack, // | task | task | * | // | task | taskyield | * | // | task | barrier | + | + // | task | taskwait | * | // +------------------+-----------------+------------------------------------+ if (Stack->getCurScope()) { auto ParentRegion = Stack->getParentDirective(); @@ -1351,6 +1369,13 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, "No associated statement allowed for 'omp barrier' directive"); Res = ActOnOpenMPBarrierDirective(StartLoc, EndLoc); break; + case OMPD_taskwait: + assert(ClausesWithImplicit.empty() && + "No clauses are allowed for 'omp taskwait' directive"); + assert(AStmt == nullptr && + "No associated statement allowed for 'omp taskwait' directive"); + Res = ActOnOpenMPTaskwaitDirective(StartLoc, EndLoc); + break; case OMPD_threadprivate: llvm_unreachable("OpenMP Directive is not allowed"); case OMPD_unknown: @@ -2104,6 +2129,11 @@ StmtResult Sema::ActOnOpenMPBarrierDirective(SourceLocation StartLoc, return OMPBarrierDirective::Create(Context, StartLoc, EndLoc); } +StmtResult Sema::ActOnOpenMPTaskwaitDirective(SourceLocation StartLoc, + SourceLocation EndLoc) { + return OMPTaskwaitDirective::Create(Context, StartLoc, EndLoc); +} + OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, SourceLocation StartLoc, SourceLocation LParenLoc, diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index a562bfd6167..04a3909da35 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -6579,6 +6579,17 @@ TreeTransform<Derived>::TransformOMPBarrierDirective(OMPBarrierDirective *D) { return Res; } +template <typename Derived> +StmtResult +TreeTransform<Derived>::TransformOMPTaskwaitDirective(OMPTaskwaitDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_taskwait, DirName, nullptr, + D->getLocStart()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + //===----------------------------------------------------------------------===// // OpenMP clause transformation //===----------------------------------------------------------------------===// diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index 9c6707a750c..99c9827ae24 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -2000,6 +2000,11 @@ void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) { VisitOMPExecutableDirective(D); } +void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) { + VisitStmt(D); + VisitOMPExecutableDirective(D); +} + //===----------------------------------------------------------------------===// // ASTReader Implementation //===----------------------------------------------------------------------===// @@ -2542,6 +2547,10 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { S = OMPBarrierDirective::CreateEmpty(Context, Empty); break; + case STMT_OMP_TASKWAIT_DIRECTIVE: + S = OMPTaskwaitDirective::CreateEmpty(Context, Empty); + break; + case EXPR_CXX_OPERATOR_CALL: S = new (Context) CXXOperatorCallExpr(Context, Empty); break; diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index 204c18a4e75..db6adbcbaa7 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -1903,6 +1903,12 @@ void ASTStmtWriter::VisitOMPBarrierDirective(OMPBarrierDirective *D) { Code = serialization::STMT_OMP_BARRIER_DIRECTIVE; } +void ASTStmtWriter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) { + VisitStmt(D); + VisitOMPExecutableDirective(D); + Code = serialization::STMT_OMP_TASKWAIT_DIRECTIVE; +} + //===----------------------------------------------------------------------===// // ASTWriter Implementation //===----------------------------------------------------------------------===// diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 5b26f4eef8d..8da1d8e9422 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -743,6 +743,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred, case Stmt::OMPTaskDirectiveClass: case Stmt::OMPTaskyieldDirectiveClass: case Stmt::OMPBarrierDirectiveClass: + case Stmt::OMPTaskwaitDirectiveClass: llvm_unreachable("Stmt should not be in analyzer evaluation loop"); case Stmt::ObjCSubscriptRefExprClass: |

