return true;
}
+template <typename Derived>
+bool
+RecursiveASTVisitor<Derived>::VisitOMPOrderedClause(OMPOrderedClause *) {
+ return true;
+}
+
template <typename Derived>
template <typename T>
void RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
StmtRange children() { return StmtRange(&ChunkSize, &ChunkSize + 1); }
};
+/// \brief This represents 'ordered' clause in the '#pragma omp ...' directive.
+///
+/// \code
+/// #pragma omp for ordered
+/// \endcode
+/// In this example directive '#pragma omp for' has 'ordered' clause.
+///
+class OMPOrderedClause : public OMPClause {
+public:
+ /// \brief Build 'ordered' clause.
+ ///
+ /// \param StartLoc Starting location of the clause.
+ /// \param EndLoc Ending location of the clause.
+ ///
+ OMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc)
+ : OMPClause(OMPC_ordered, StartLoc, EndLoc) {}
+
+ /// \brief Build an empty clause.
+ ///
+ OMPOrderedClause()
+ : OMPClause(OMPC_ordered, SourceLocation(), SourceLocation()) {}
+
+ static bool classof(const OMPClause *T) {
+ return T->getClauseKind() == OMPC_ordered;
+ }
+
+ StmtRange children() { return StmtRange(); }
+};
+
/// \brief This represents clause 'private' in the '#pragma omp ...' directives.
///
/// \code
return true;
}
+template <typename Derived>
+bool
+RecursiveASTVisitor<Derived>::VisitOMPOrderedClause(OMPOrderedClause *) {
+ return true;
+}
+
template <typename Derived>
template <typename T>
void RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
OPENMP_CLAUSE(copyin, OMPCopyinClause)
OPENMP_CLAUSE(proc_bind, OMPProcBindClause)
OPENMP_CLAUSE(schedule, OMPScheduleClause)
+OPENMP_CLAUSE(ordered, OMPOrderedClause)
// Clauses allowed for OpenMP directive 'parallel'.
OPENMP_PARALLEL_CLAUSE(if)
OPENMP_FOR_CLAUSE(reduction)
OPENMP_FOR_CLAUSE(collapse)
OPENMP_FOR_CLAUSE(schedule)
+OPENMP_FOR_CLAUSE(ordered)
// Static attributes for 'default' clause.
OPENMP_DEFAULT_KIND(none)
/// \param Kind Kind of current clause.
///
OMPClause *ParseOpenMPSingleExprWithArgClause(OpenMPClauseKind Kind);
+ /// \brief Parses clause without any additional arguments.
+ ///
+ /// \param Kind Kind of current clause.
+ ///
+ OMPClause *ParseOpenMPClause(OpenMPClauseKind Kind);
/// \brief Parses clause with the list of variables of a kind \a Kind.
///
/// \param Kind Kind of current clause.
SourceLocation CommaLoc,
SourceLocation EndLoc);
+ OMPClause *ActOnOpenMPClause(OpenMPClauseKind Kind, SourceLocation StartLoc,
+ SourceLocation EndLoc);
+ /// \brief Called on well-formed 'ordered' clause.
+ OMPClause *ActOnOpenMPOrderedClause(SourceLocation StartLoc,
+ SourceLocation EndLoc);
+
OMPClause *
ActOnOpenMPVarListClause(OpenMPClauseKind Kind, ArrayRef<Expr *> Vars,
Expr *TailExpr, SourceLocation StartLoc,
OS << ")";
}
+void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *) {
+ OS << "ordered";
+}
+
template<typename T>
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
for (typename T::varlist_iterator I = Node->varlist_begin(),
Profiler->VisitStmt(C->getChunkSize());
}
+void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *) {}
+
template<typename T>
void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
for (auto *I : Node->varlists())
case OMPC_linear:
case OMPC_aligned:
case OMPC_copyin:
+ case OMPC_ordered:
break;
}
llvm_unreachable("Invalid OpenMP simple clause kind");
case OMPC_linear:
case OMPC_aligned:
case OMPC_copyin:
+ case OMPC_ordered:
break;
}
llvm_unreachable("Invalid OpenMP simple clause kind");
Clause = ParseOpenMPSingleExprWithArgClause(CKind);
break;
+ case OMPC_ordered:
+ // OpenMP [2.7.1, Restrictions, p. 9]
+ // Only one ordered clause can appear on a loop directive.
+ if (!FirstClause) {
+ Diag(Tok, diag::err_omp_more_one_clause) << getOpenMPDirectiveName(DKind)
+ << getOpenMPClauseName(CKind);
+ }
+
+ Clause = ParseOpenMPClause(CKind);
+ break;
case OMPC_private:
case OMPC_firstprivate:
case OMPC_lastprivate:
Tok.getLocation());
}
+/// \brief Parsing of OpenMP clauses like 'ordered'.
+///
+/// ordered-clause:
+/// 'ordered'
+///
+OMPClause *Parser::ParseOpenMPClause(OpenMPClauseKind Kind) {
+ SourceLocation Loc = Tok.getLocation();
+ ConsumeAnyToken();
+
+ return Actions.ActOnOpenMPClause(Kind, Loc, Tok.getLocation());
+}
+
+
/// \brief Parsing of OpenMP clauses with single expressions and some additional
/// argument like 'schedule' or 'dist_schedule'.
///
case OMPC_linear:
case OMPC_aligned:
case OMPC_copyin:
+ case OMPC_ordered:
case OMPC_threadprivate:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
case OMPC_linear:
case OMPC_aligned:
case OMPC_copyin:
+ case OMPC_ordered:
case OMPC_threadprivate:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
case OMPC_linear:
case OMPC_aligned:
case OMPC_copyin:
+ case OMPC_ordered:
case OMPC_threadprivate:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
EndLoc, Kind, ValExpr);
}
+OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
+ SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ OMPClause *Res = nullptr;
+ switch (Kind) {
+ case OMPC_ordered:
+ Res = ActOnOpenMPOrderedClause(StartLoc, EndLoc);
+ break;
+ case OMPC_if:
+ case OMPC_num_threads:
+ case OMPC_safelen:
+ case OMPC_collapse:
+ case OMPC_schedule:
+ case OMPC_private:
+ case OMPC_firstprivate:
+ case OMPC_lastprivate:
+ case OMPC_shared:
+ case OMPC_reduction:
+ case OMPC_linear:
+ case OMPC_aligned:
+ case OMPC_copyin:
+ case OMPC_default:
+ case OMPC_proc_bind:
+ case OMPC_threadprivate:
+ case OMPC_unknown:
+ llvm_unreachable("Clause is not allowed.");
+ }
+ return Res;
+}
+
+OMPClause *Sema::ActOnOpenMPOrderedClause(SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ return new (Context) OMPOrderedClause(StartLoc, EndLoc);
+}
+
OMPClause *Sema::ActOnOpenMPVarListClause(
OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
case OMPC_default:
case OMPC_proc_bind:
case OMPC_schedule:
+ case OMPC_ordered:
case OMPC_threadprivate:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
C->getScheduleKindLoc(), C->getCommaLoc(), C->getLocEnd());
}
+template <typename Derived>
+OMPClause *
+TreeTransform<Derived>::TransformOMPOrderedClause(OMPOrderedClause *C) {
+ // No need to rebuild this clause, no template-dependent parameters.
+ return C;
+}
+
template <typename Derived>
OMPClause *
TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
case OMPC_schedule:
C = new (Context) OMPScheduleClause();
break;
+ case OMPC_ordered:
+ C = new (Context) OMPOrderedClause();
+ break;
case OMPC_private:
C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
break;
C->setCommaLoc(Reader->ReadSourceLocation(Record, Idx));
}
+void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *) {}
+
void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
unsigned NumVars = C->varlist_size();
Writer->Writer.AddSourceLocation(C->getCommaLoc(), Record);
}
+void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *) {}
+
void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
Record.push_back(C->varlist_size());
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
// CHECK-NEXT: a = 2;
#pragma omp parallel
-#pragma omp for private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N)
+#pragma omp for private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered
for (int i = 0; i < 10; ++i)
for (int j = 0; j < 10; ++j)
foo();
// CHECK-NEXT: #pragma omp parallel
- // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N)
+ // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered
// CHECK-NEXT: for (int i = 0; i < 10; ++i)
// CHECK-NEXT: for (int j = 0; j < 10; ++j)
// CHECK-NEXT: foo();
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
// CHECK-NEXT: a = 2;
#pragma omp parallel
-#pragma omp for private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) schedule(auto)
+#pragma omp for private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) schedule(auto) ordered
for (int i = 0; i < 10; ++i)
for (int j = 0; j < 10; ++j)
foo();
// CHECK-NEXT: #pragma omp parallel
- // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) schedule(auto)
+ // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) schedule(auto) ordered
// CHECK-NEXT: for (int i = 0; i < 10; ++i)
// CHECK-NEXT: for (int j = 0; j < 10; ++j)
// CHECK-NEXT: foo();
Visitor->AddStmt(C->getChunkSize());
}
+void OMPClauseEnqueue::VisitOMPOrderedClause(const OMPOrderedClause *) {}
+
template<typename T>
void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
for (const auto *I : Node->varlists())