return true;
}
+template <typename Derived>
+bool
+RecursiveASTVisitor<Derived>::VisitOMPMergeableClause(OMPMergeableClause *) {
+ return true;
+}
+
template <typename Derived>
template <typename T>
bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
StmtRange children() { return StmtRange(); }
};
+/// \brief This represents 'mergeable' clause in the '#pragma omp ...'
+/// directive.
+///
+/// \code
+/// #pragma omp task mergeable
+/// \endcode
+/// In this example directive '#pragma omp task' has 'mergeable' clause.
+///
+class OMPMergeableClause : public OMPClause {
+public:
+ /// \brief Build 'mergeable' clause.
+ ///
+ /// \param StartLoc Starting location of the clause.
+ /// \param EndLoc Ending location of the clause.
+ ///
+ OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc)
+ : OMPClause(OMPC_mergeable, StartLoc, EndLoc) {}
+
+ /// \brief Build an empty clause.
+ ///
+ OMPMergeableClause()
+ : OMPClause(OMPC_mergeable, SourceLocation(), SourceLocation()) {}
+
+ static bool classof(const OMPClause *T) {
+ return T->getClauseKind() == OMPC_mergeable;
+ }
+
+ StmtRange children() { return StmtRange(); }
+};
+
/// \brief This represents clause 'private' in the '#pragma omp ...' directives.
///
/// \code
return true;
}
+template <typename Derived>
+bool
+RecursiveASTVisitor<Derived>::VisitOMPMergeableClause(OMPMergeableClause *) {
+ return true;
+}
+
template <typename Derived>
template <typename T>
bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
OPENMP_CLAUSE(ordered, OMPOrderedClause)
OPENMP_CLAUSE(nowait, OMPNowaitClause)
OPENMP_CLAUSE(untied, OMPUntiedClause)
+OPENMP_CLAUSE(mergeable, OMPMergeableClause)
// Clauses allowed for OpenMP directive 'parallel'.
OPENMP_PARALLEL_CLAUSE(if)
OPENMP_PARALLEL_SECTIONS_CLAUSE(copyin)
OPENMP_PARALLEL_SECTIONS_CLAUSE(lastprivate)
-// TODO more clauses allowed for OpenMP directive 'task'.
+// Clauses allowed for OpenMP directive 'task'.
OPENMP_TASK_CLAUSE(if)
OPENMP_TASK_CLAUSE(final)
OPENMP_TASK_CLAUSE(default)
OPENMP_TASK_CLAUSE(firstprivate)
OPENMP_TASK_CLAUSE(shared)
OPENMP_TASK_CLAUSE(untied)
+OPENMP_TASK_CLAUSE(mergeable)
#undef OPENMP_SCHEDULE_KIND
#undef OPENMP_PROC_BIND_KIND
/// \brief Called on well-formed 'untied' clause.
OMPClause *ActOnOpenMPUntiedClause(SourceLocation StartLoc,
SourceLocation EndLoc);
+ /// \brief Called on well-formed 'mergeable' clause.
+ OMPClause *ActOnOpenMPMergeableClause(SourceLocation StartLoc,
+ SourceLocation EndLoc);
OMPClause *
ActOnOpenMPVarListClause(OpenMPClauseKind Kind, ArrayRef<Expr *> Vars,
OS << "untied";
}
+void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
+ OS << "mergeable";
+}
+
template<typename T>
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
for (typename T::varlist_iterator I = Node->varlist_begin(),
void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
+void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
+
template<typename T>
void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
for (auto *I : Node->varlists())
case OMPC_ordered:
case OMPC_nowait:
case OMPC_untied:
+ case OMPC_mergeable:
break;
}
llvm_unreachable("Invalid OpenMP simple clause kind");
case OMPC_ordered:
case OMPC_nowait:
case OMPC_untied:
+ case OMPC_mergeable:
break;
}
llvm_unreachable("Invalid OpenMP simple clause kind");
/// default-clause | private-clause | firstprivate-clause | shared-clause
/// | linear-clause | aligned-clause | collapse-clause |
/// lastprivate-clause | reduction-clause | proc_bind-clause |
-/// schedule-clause | copyin-clause | copyprivate-clause | untied-clause
+/// schedule-clause | copyin-clause | copyprivate-clause | untied-clause |
+/// mergeable-clause
///
OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
OpenMPClauseKind CKind, bool FirstClause) {
case OMPC_ordered:
case OMPC_nowait:
case OMPC_untied:
+ case OMPC_mergeable:
// OpenMP [2.7.1, Restrictions, p. 9]
// Only one ordered clause can appear on a loop directive.
// OpenMP [2.7.1, Restrictions, C/C++, p. 4]
/// untied-clause:
/// 'untied'
///
+/// mergeable-clause:
+/// 'mergeable'
+///
OMPClause *Parser::ParseOpenMPClause(OpenMPClauseKind Kind) {
SourceLocation Loc = Tok.getLocation();
ConsumeAnyToken();
case OMPC_ordered:
case OMPC_nowait:
case OMPC_untied:
+ case OMPC_mergeable:
case OMPC_threadprivate:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
case OMPC_ordered:
case OMPC_nowait:
case OMPC_untied:
+ case OMPC_mergeable:
case OMPC_threadprivate:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
case OMPC_ordered:
case OMPC_nowait:
case OMPC_untied:
+ case OMPC_mergeable:
case OMPC_threadprivate:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
case OMPC_untied:
Res = ActOnOpenMPUntiedClause(StartLoc, EndLoc);
break;
+ case OMPC_mergeable:
+ Res = ActOnOpenMPMergeableClause(StartLoc, EndLoc);
+ break;
case OMPC_if:
case OMPC_final:
case OMPC_num_threads:
return new (Context) OMPUntiedClause(StartLoc, EndLoc);
}
+OMPClause *Sema::ActOnOpenMPMergeableClause(SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ return new (Context) OMPMergeableClause(StartLoc, EndLoc);
+}
+
OMPClause *Sema::ActOnOpenMPVarListClause(
OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
case OMPC_ordered:
case OMPC_nowait:
case OMPC_untied:
+ case OMPC_mergeable:
case OMPC_threadprivate:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
return C;
}
+template <typename Derived>
+OMPClause *
+TreeTransform<Derived>::TransformOMPMergeableClause(OMPMergeableClause *C) {
+ // No need to rebuild this clause, no template-dependent parameters.
+ return C;
+}
+
template <typename Derived>
OMPClause *
TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
case OMPC_untied:
C = new (Context) OMPUntiedClause();
break;
+ case OMPC_mergeable:
+ C = new (Context) OMPMergeableClause();
+ break;
case OMPC_private:
C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
break;
void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {}
+void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {}
+
void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
unsigned NumVars = C->varlist_size();
void OMPClauseWriter::VisitOMPUntiedClause(OMPUntiedClause *) {}
+void OMPClauseWriter::VisitOMPMergeableClause(OMPMergeableClause *) {}
+
void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
Record.push_back(C->varlist_size());
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
a = 2;
#pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0) final(S<T>::TS > 0)
foo();
-#pragma omp task if (C)
+#pragma omp task if (C) mergeable
foo();
return 0;
}
// CHECK-NEXT: a = 2;
// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<int>::TS > 0)
// CHECK-NEXT: foo()
-// CHECK-NEXT: #pragma omp task if(5)
+// CHECK-NEXT: #pragma omp task if(5) mergeable
// CHECK-NEXT: foo()
// CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) {
// CHECK-NEXT: long b = argc, c, d, e, f, g;
// CHECK-NEXT: a = 2;
// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<long>::TS > 0)
// CHECK-NEXT: foo()
-// CHECK-NEXT: #pragma omp task if(1)
+// CHECK-NEXT: #pragma omp task if(1) mergeable
// CHECK-NEXT: foo()
// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
// CHECK-NEXT: T b = argc, c, d, e, f, g;
// CHECK-NEXT: a = 2;
// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<T>::TS > 0)
// CHECK-NEXT: foo()
-// CHECK-NEXT: #pragma omp task if(C)
+// CHECK-NEXT: #pragma omp task if(C) mergeable
// CHECK-NEXT: foo()
enum Enum {};
#pragma omp threadprivate(a)
Enum ee;
// CHECK: Enum ee;
-#pragma omp task untied
- // CHECK-NEXT: #pragma omp task untied
+#pragma omp task untied mergeable
+ // CHECK-NEXT: #pragma omp task untied mergeable
a = 2;
// CHECK-NEXT: a = 2;
#pragma omp task default(none), private(argc, b) firstprivate(argv) if (argc > 0) final(a > 0)
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
#pragma omp task untied untied
++r;
+// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
+#pragma omp task mergeable mergeable
+ ++r;
return a + b;
}
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
#pragma omp task untied untied
++r;
+// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
+#pragma omp task mergeable mergeable
+ ++r;
// expected-note@+2 {{in instantiation of function template specialization 'foo<int>' requested here}}
// expected-note@+1 {{in instantiation of function template specialization 'foo<S>' requested here}}
return foo<int>() + foo<S>();
void OMPClauseEnqueue::VisitOMPUntiedClause(const OMPUntiedClause *) {}
+void OMPClauseEnqueue::VisitOMPMergeableClause(const OMPMergeableClause *) {}
+
template<typename T>
void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
for (const auto *I : Node->varlists())