diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 6 | ||||
-rw-r--r-- | clang/lib/AST/StmtProfile.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Basic/OpenMPKinds.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 23 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 21 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReaderStmt.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriterStmt.cpp | 5 |
9 files changed, 78 insertions, 2 deletions
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index d8802eb1a75..f680b784165 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -731,6 +731,12 @@ void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) { OS << ")"; } +void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) { + OS << "grainsize("; + Node->getGrainsize()->printPretty(OS, nullptr, Policy, 0); + OS << ")"; +} + template<typename T> void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { for (typename T::varlist_iterator I = Node->varlist_begin(), diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index a4255aa621d..b779b4f0b52 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -465,6 +465,9 @@ void OMPClauseProfiler::VisitOMPThreadLimitClause( void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) { Profiler->VisitStmt(C->getPriority()); } +void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) { + Profiler->VisitStmt(C->getGrainsize()); +} } void diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp index 4a9e7fdcfa8..4c4d151640f 100644 --- a/clang/lib/Basic/OpenMPKinds.cpp +++ b/clang/lib/Basic/OpenMPKinds.cpp @@ -138,6 +138,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, case OMPC_num_teams: case OMPC_thread_limit: case OMPC_priority: + case OMPC_grainsize: case OMPC_nogroup: break; } @@ -240,6 +241,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, case OMPC_num_teams: case OMPC_thread_limit: case OMPC_priority: + case OMPC_grainsize: case OMPC_nogroup: break; } diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index c80e60278b4..9c6dc62010a 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -2481,6 +2481,7 @@ static void EmitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind, case OMPC_num_teams: case OMPC_thread_limit: case OMPC_priority: + case OMPC_grainsize: case OMPC_nogroup: llvm_unreachable("Clause is not allowed in 'omp atomic'."); } diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 78d40ef4f6c..8f24f5d0f30 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -400,7 +400,8 @@ bool Parser::ParseOpenMPSimpleVarList(OpenMPDirectiveKind Kind, /// mergeable-clause | flush-clause | read-clause | write-clause | /// update-clause | capture-clause | seq_cst-clause | device-clause | /// simdlen-clause | threads-clause | simd-clause | num_teams-clause | -/// thread_limit-clause | priority-clause | nogroup-clause +/// thread_limit-clause | priority-clause | grainsize-clause | +/// nogroup-clause /// OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, OpenMPClauseKind CKind, bool FirstClause) { @@ -424,6 +425,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, case OMPC_num_teams: case OMPC_thread_limit: case OMPC_priority: + case OMPC_grainsize: // OpenMP [2.5, Restrictions] // At most one num_threads clause can appear on the directive. // OpenMP [2.8.1, simd construct, Restrictions] @@ -440,6 +442,8 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, // At most one thread_limit clause can appear on the directive. // OpenMP [2.9.1, task Construct, Restrictions] // At most one priority clause can appear on the directive. + // OpenMP [2.9.2, taskloop Construct, Restrictions] + // At most one grainsize clause can appear on the directive. if (!FirstClause) { Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind) << 0; @@ -531,7 +535,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, /// \brief Parsing of OpenMP clauses with single expressions like 'final', /// 'collapse', 'safelen', 'num_threads', 'simdlen', 'num_teams', -/// 'thread_limit', 'simdlen' or 'priority'. +/// 'thread_limit', 'simdlen', 'priority' or 'grainsize'. /// /// final-clause: /// 'final' '(' expression ')' @@ -551,6 +555,9 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, /// priority-clause: /// 'priority' '(' expression ')' /// +/// grainsize-clause: +/// 'grainsize' '(' expression ')' +/// OMPClause *Parser::ParseOpenMPSingleExprClause(OpenMPClauseKind Kind) { SourceLocation Loc = ConsumeToken(); diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 125113a37b6..f9efe8e997c 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -5381,6 +5381,9 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, case OMPC_priority: Res = ActOnOpenMPPriorityClause(Expr, StartLoc, LParenLoc, EndLoc); break; + case OMPC_grainsize: + Res = ActOnOpenMPGrainsizeClause(Expr, StartLoc, LParenLoc, EndLoc); + break; case OMPC_if: case OMPC_default: case OMPC_proc_bind: @@ -5685,6 +5688,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause( case OMPC_num_teams: case OMPC_thread_limit: case OMPC_priority: + case OMPC_grainsize: case OMPC_nogroup: case OMPC_unknown: llvm_unreachable("Clause is not allowed."); @@ -5819,6 +5823,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause( case OMPC_num_teams: case OMPC_thread_limit: case OMPC_priority: + case OMPC_grainsize: case OMPC_nogroup: case OMPC_unknown: llvm_unreachable("Clause is not allowed."); @@ -5958,6 +5963,7 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind, case OMPC_num_teams: case OMPC_thread_limit: case OMPC_priority: + case OMPC_grainsize: case OMPC_unknown: llvm_unreachable("Clause is not allowed."); } @@ -6095,6 +6101,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause( case OMPC_num_teams: case OMPC_thread_limit: case OMPC_priority: + case OMPC_grainsize: case OMPC_nogroup: case OMPC_unknown: llvm_unreachable("Clause is not allowed."); @@ -8006,3 +8013,19 @@ OMPClause *Sema::ActOnOpenMPPriorityClause(Expr *Priority, return new (Context) OMPPriorityClause(ValExpr, StartLoc, LParenLoc, EndLoc); } + +OMPClause *Sema::ActOnOpenMPGrainsizeClause(Expr *Grainsize, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + Expr *ValExpr = Grainsize; + + // OpenMP [2.9.2, taskloop Constrcut] + // The parameter of the grainsize clause must be a positive integer + // expression. + if (!IsNonNegativeIntegerValue(ValExpr, *this, OMPC_grainsize, + /*StrictlyPositive=*/true)) + return nullptr; + + return new (Context) OMPGrainsizeClause(ValExpr, StartLoc, LParenLoc, EndLoc); +} diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 6d80d038a43..677b2198b1e 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1700,6 +1700,17 @@ public: EndLoc); } + /// \brief Build a new OpenMP 'grainsize' clause. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPGrainsizeClause(Expr *Grainsize, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPGrainsizeClause(Grainsize, StartLoc, LParenLoc, + EndLoc); + } + /// \brief Rebuild the operand to an Objective-C \@synchronized statement. /// /// By default, performs semantic analysis to build the new statement. @@ -7790,6 +7801,16 @@ TreeTransform<Derived>::TransformOMPPriorityClause(OMPPriorityClause *C) { E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); } +template <typename Derived> +OMPClause * +TreeTransform<Derived>::TransformOMPGrainsizeClause(OMPGrainsizeClause *C) { + ExprResult E = getDerived().TransformExpr(C->getGrainsize()); + if (E.isInvalid()) + return nullptr; + return getDerived().RebuildOMPGrainsizeClause( + E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); +} + //===----------------------------------------------------------------------===// // Expression transformation //===----------------------------------------------------------------------===// diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index fc1b6b45ebe..95bfa236543 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -1862,6 +1862,9 @@ OMPClause *OMPClauseReader::readClause() { case OMPC_priority: C = new (Context) OMPPriorityClause(); break; + case OMPC_grainsize: + C = new (Context) OMPGrainsizeClause(); + break; } Visit(C); C->setLocStart(Reader->ReadSourceLocation(Record, Idx)); @@ -2203,6 +2206,11 @@ void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) { C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); } +void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) { + C->setGrainsize(Reader->Reader.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); +} + //===----------------------------------------------------------------------===// // OpenMP Directives. //===----------------------------------------------------------------------===// diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index d9585e684d1..21ba24357e3 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -2018,6 +2018,11 @@ void OMPClauseWriter::VisitOMPPriorityClause(OMPPriorityClause *C) { Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record); } +void OMPClauseWriter::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) { + Writer->Writer.AddStmt(C->getGrainsize()); + Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record); +} + //===----------------------------------------------------------------------===// // OpenMP Directives. //===----------------------------------------------------------------------===// |