]> granicus.if.org Git - clang/commitdiff
[OPENMP] Initial support for parsing and sema analysis of 'untied' clause.
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 17 Jul 2014 12:19:31 +0000 (12:19 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 17 Jul 2014 12:19:31 +0000 (12:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213257 91177308-0d34-0410-b5e6-96231b3b80d8

16 files changed:
include/clang/AST/DataRecursiveASTVisitor.h
include/clang/AST/OpenMPClause.h
include/clang/AST/RecursiveASTVisitor.h
include/clang/Basic/OpenMPKinds.def
include/clang/Sema/Sema.h
lib/AST/StmtPrinter.cpp
lib/AST/StmtProfile.cpp
lib/Basic/OpenMPKinds.cpp
lib/Parse/ParseOpenMP.cpp
lib/Sema/SemaOpenMP.cpp
lib/Sema/TreeTransform.h
lib/Serialization/ASTReaderStmt.cpp
lib/Serialization/ASTWriterStmt.cpp
test/OpenMP/task_ast_print.cpp
test/OpenMP/task_messages.cpp
tools/libclang/CIndex.cpp

index e47e99b496d344448dc3fa0b8bcb6e99677ed5ee..541886c0c1820e129ff3819077b8afe84178c1e0 100644 (file)
@@ -2386,6 +2386,11 @@ bool RecursiveASTVisitor<Derived>::VisitOMPNowaitClause(OMPNowaitClause *) {
   return true;
 }
 
+template <typename Derived>
+bool RecursiveASTVisitor<Derived>::VisitOMPUntiedClause(OMPUntiedClause *) {
+  return true;
+}
+
 template <typename Derived>
 template <typename T>
 bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
index 35431753f489834fecd076fa45c32058f70c91cd..4173e91d78b127f0307ea3bad15dbba1799823ac 100644 (file)
@@ -711,6 +711,35 @@ public:
   StmtRange children() { return StmtRange(); }
 };
 
+/// \brief This represents 'untied' clause in the '#pragma omp ...' directive.
+///
+/// \code
+/// #pragma omp task untied
+/// \endcode
+/// In this example directive '#pragma omp task' has 'untied' clause.
+///
+class OMPUntiedClause : public OMPClause {
+public:
+  /// \brief Build 'untied' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  ///
+  OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc)
+      : OMPClause(OMPC_untied, StartLoc, EndLoc) {}
+
+  /// \brief Build an empty clause.
+  ///
+  OMPUntiedClause()
+      : OMPClause(OMPC_untied, SourceLocation(), SourceLocation()) {}
+
+  static bool classof(const OMPClause *T) {
+    return T->getClauseKind() == OMPC_untied;
+  }
+
+  StmtRange children() { return StmtRange(); }
+};
+
 /// \brief This represents clause 'private' in the '#pragma omp ...' directives.
 ///
 /// \code
index 208d0f509d89ec2022825854711c60dd291733e5..9178f67aa10415009b8a55145cffab583cb627a9 100644 (file)
@@ -2408,6 +2408,11 @@ bool RecursiveASTVisitor<Derived>::VisitOMPNowaitClause(OMPNowaitClause *) {
   return true;
 }
 
+template <typename Derived>
+bool RecursiveASTVisitor<Derived>::VisitOMPUntiedClause(OMPUntiedClause *) {
+  return true;
+}
+
 template <typename Derived>
 template <typename T>
 bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
index 61d23d4658617392fdcb205dd730df60d4abb72d..6da343e05f932e925eecc45f37e4509ae50b7797 100644 (file)
@@ -88,6 +88,7 @@ OPENMP_CLAUSE(proc_bind, OMPProcBindClause)
 OPENMP_CLAUSE(schedule, OMPScheduleClause)
 OPENMP_CLAUSE(ordered, OMPOrderedClause)
 OPENMP_CLAUSE(nowait, OMPNowaitClause)
+OPENMP_CLAUSE(untied, OMPUntiedClause)
 
 // Clauses allowed for OpenMP directive 'parallel'.
 OPENMP_PARALLEL_CLAUSE(if)
@@ -182,6 +183,7 @@ OPENMP_TASK_CLAUSE(default)
 OPENMP_TASK_CLAUSE(private)
 OPENMP_TASK_CLAUSE(firstprivate)
 OPENMP_TASK_CLAUSE(shared)
+OPENMP_TASK_CLAUSE(untied)
 
 #undef OPENMP_SCHEDULE_KIND
 #undef OPENMP_PROC_BIND_KIND
index f6479208887c2771ed2551a64da74af1399b986c..283dfb6acdb97dd3c62b8318da24eed1feed0683 100644 (file)
@@ -7440,6 +7440,9 @@ public:
   /// \brief Called on well-formed 'nowait' clause.
   OMPClause *ActOnOpenMPNowaitClause(SourceLocation StartLoc,
                                      SourceLocation EndLoc);
+  /// \brief Called on well-formed 'untied' clause.
+  OMPClause *ActOnOpenMPUntiedClause(SourceLocation StartLoc,
+                                     SourceLocation EndLoc);
 
   OMPClause *
   ActOnOpenMPVarListClause(OpenMPClauseKind Kind, ArrayRef<Expr *> Vars,
index fd511ef465def461139b4e2abc270aa8794639c6..29d958bacff5619d0cad2183ec60c28afae6d215 100644 (file)
@@ -657,6 +657,10 @@ void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) {
   OS << "nowait";
 }
 
+void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
+  OS << "untied";
+}
+
 template<typename T>
 void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
   for (typename T::varlist_iterator I = Node->varlist_begin(),
index c45281f13f4a91fd0635d0896c705ff600b0f53a..b17551cd40721947ecf96eeb0d401ab9cd642047 100644 (file)
@@ -306,6 +306,8 @@ void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *) {}
 
 void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
 
+void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
+
 template<typename T>
 void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
   for (auto *I : Node->varlists())
index 31b571cac8c34fe53ce2a1cb1910e37f09643155..d8af63f1d03214fdbb4d72fd9cb3c5ecf36feed6 100644 (file)
@@ -103,6 +103,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
   case OMPC_copyprivate:
   case OMPC_ordered:
   case OMPC_nowait:
+  case OMPC_untied:
     break;
   }
   llvm_unreachable("Invalid OpenMP simple clause kind");
@@ -159,6 +160,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
   case OMPC_copyprivate:
   case OMPC_ordered:
   case OMPC_nowait:
+  case OMPC_untied:
     break;
   }
   llvm_unreachable("Invalid OpenMP simple clause kind");
index 172aef8cf3e206e59ae0edf82167db90262e11d4..9f1fa0af154c647127e8345b18d72653c7df5683 100644 (file)
@@ -292,7 +292,7 @@ bool Parser::ParseOpenMPSimpleVarList(OpenMPDirectiveKind 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
+///       schedule-clause | copyin-clause | copyprivate-clause | untied-clause
 ///
 OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
                                      OpenMPClauseKind CKind, bool FirstClause) {
@@ -353,6 +353,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
     break;
   case OMPC_ordered:
   case OMPC_nowait:
+  case OMPC_untied:
     // 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]
@@ -468,6 +469,9 @@ OMPClause *Parser::ParseOpenMPSimpleClause(OpenMPClauseKind Kind) {
 ///    nowait-clause:
 ///         'nowait'
 ///
+///    untied-clause:
+///         'untied'
+///
 OMPClause *Parser::ParseOpenMPClause(OpenMPClauseKind Kind) {
   SourceLocation Loc = Tok.getLocation();
   ConsumeAnyToken();
index ef36e7e901e83cc14c3ee37073825f6bdd2fd9b2..85a9ccffd8c05570e700041c599c7bfe3ba72c53 100644 (file)
@@ -2068,6 +2068,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
   case OMPC_copyprivate:
   case OMPC_ordered:
   case OMPC_nowait:
+  case OMPC_untied:
   case OMPC_threadprivate:
   case OMPC_unknown:
     llvm_unreachable("Clause is not allowed.");
@@ -2268,6 +2269,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
   case OMPC_copyprivate:
   case OMPC_ordered:
   case OMPC_nowait:
+  case OMPC_untied:
   case OMPC_threadprivate:
   case OMPC_unknown:
     llvm_unreachable("Clause is not allowed.");
@@ -2380,6 +2382,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
   case OMPC_copyprivate:
   case OMPC_ordered:
   case OMPC_nowait:
+  case OMPC_untied:
   case OMPC_threadprivate:
   case OMPC_unknown:
     llvm_unreachable("Clause is not allowed.");
@@ -2454,6 +2457,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
   case OMPC_nowait:
     Res = ActOnOpenMPNowaitClause(StartLoc, EndLoc);
     break;
+  case OMPC_untied:
+    Res = ActOnOpenMPUntiedClause(StartLoc, EndLoc);
+    break;
   case OMPC_if:
   case OMPC_final:
   case OMPC_num_threads:
@@ -2488,6 +2494,11 @@ OMPClause *Sema::ActOnOpenMPNowaitClause(SourceLocation StartLoc,
   return new (Context) OMPNowaitClause(StartLoc, EndLoc);
 }
 
+OMPClause *Sema::ActOnOpenMPUntiedClause(SourceLocation StartLoc,
+                                         SourceLocation EndLoc) {
+  return new (Context) OMPUntiedClause(StartLoc, EndLoc);
+}
+
 OMPClause *Sema::ActOnOpenMPVarListClause(
     OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,
     SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
@@ -2535,6 +2546,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
   case OMPC_schedule:
   case OMPC_ordered:
   case OMPC_nowait:
+  case OMPC_untied:
   case OMPC_threadprivate:
   case OMPC_unknown:
     llvm_unreachable("Clause is not allowed.");
index 6eb18e8ac792d319959f16f17e2cdc7f3b5250e3..4a9cd78bb6efea95114aa5dfda1e1471eefa5707 100644 (file)
@@ -6644,6 +6644,13 @@ TreeTransform<Derived>::TransformOMPNowaitClause(OMPNowaitClause *C) {
   return C;
 }
 
+template <typename Derived>
+OMPClause *
+TreeTransform<Derived>::TransformOMPUntiedClause(OMPUntiedClause *C) {
+  // No need to rebuild this clause, no template-dependent parameters.
+  return C;
+}
+
 template <typename Derived>
 OMPClause *
 TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
index e6c71b45a1bef5d59d21b02d0dca4fae388f747a..4986e2e47e755be61c6116de054d69178baf7e8d 100644 (file)
@@ -1709,6 +1709,9 @@ OMPClause *OMPClauseReader::readClause() {
   case OMPC_nowait:
     C = new (Context) OMPNowaitClause();
     break;
+  case OMPC_untied:
+    C = new (Context) OMPUntiedClause();
+    break;
   case OMPC_private:
     C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
     break;
@@ -1796,6 +1799,8 @@ void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *) {}
 
 void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {}
 
+void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {}
+
 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
   unsigned NumVars = C->varlist_size();
index e8027e733c104f154dc785d67106feb78813263f..6edad3ddf5de89bf0d947b71dfd763a3ffb18f87 100644 (file)
@@ -1731,6 +1731,8 @@ void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *) {}
 
 void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *) {}
 
+void OMPClauseWriter::VisitOMPUntiedClause(OMPUntiedClause *) {}
+
 void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
   Record.push_back(C->varlist_size());
   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
index c868e74977c6e94631fc179483bbb195a227b28c..f29b5b3fe7196e6dca215c93e89ff5c4e0a8958d 100644 (file)
@@ -33,7 +33,7 @@ T tmain(T argc, T *argv) {
   T b = argc, c, d, e, f, g;
   static T a;
   S<T> s;
-#pragma omp task
+#pragma omp task untied
   a = 2;
 #pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0) final(S<T>::TS > 0)
   foo();
@@ -46,7 +46,7 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: int b = argc, c, d, e, f, g;
 // CHECK-NEXT: static int a;
 // CHECK-NEXT: S<int> s;
-// CHECK-NEXT: #pragma omp task
+// CHECK-NEXT: #pragma omp task untied
 // 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()
@@ -56,7 +56,7 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: long b = argc, c, d, e, f, g;
 // CHECK-NEXT: static long a;
 // CHECK-NEXT: S<long> s;
-// CHECK-NEXT: #pragma omp task
+// CHECK-NEXT: #pragma omp task untied
 // 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()
@@ -66,7 +66,7 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: T b = argc, c, d, e, f, g;
 // CHECK-NEXT: static T a;
 // CHECK-NEXT: S<T> s;
-// CHECK-NEXT: #pragma omp task
+// CHECK-NEXT: #pragma omp task untied
 // 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()
@@ -82,8 +82,8 @@ int main(int argc, char **argv) {
 #pragma omp threadprivate(a)
   Enum ee;
 // CHECK: Enum ee;
-#pragma omp task
-  // CHECK-NEXT: #pragma omp task
+#pragma omp task untied
+  // CHECK-NEXT: #pragma omp task untied
   a = 2;
 // CHECK-NEXT: a = 2;
 #pragma omp task default(none), private(argc, b) firstprivate(argv) if (argc > 0) final(a > 0)
index 3c8968299c4f42965328154f071c1bcb70e99e9c..7491c23b739d6c4aa297925d1c8abc42912bbbc0 100644 (file)
@@ -97,6 +97,9 @@ int foo() {
 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
 #pragma omp for reduction(+ : r)
   ++r;
+// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
+#pragma omp task untied untied
+  ++r;
   return a + b;
 }
 
@@ -256,6 +259,9 @@ L2:
 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
 #pragma omp for reduction(+ : r)
   ++r;
+// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
+#pragma omp task untied untied
+  ++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>();
index 75438e20ea65c4f9b4554c7c2b86b82e81375ccb..e83a659b1f2f129b8a5329a0e514fd8ae6ab8bda 100644 (file)
@@ -1968,6 +1968,8 @@ void OMPClauseEnqueue::VisitOMPOrderedClause(const OMPOrderedClause *) {}
 
 void OMPClauseEnqueue::VisitOMPNowaitClause(const OMPNowaitClause *) {}
 
+void OMPClauseEnqueue::VisitOMPUntiedClause(const OMPUntiedClause *) {}
+
 template<typename T>
 void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
   for (const auto *I : Node->varlists())