]> granicus.if.org Git - clang/commitdiff
Add support for 'dynamic_allocators' clause on 'requires' directive. Differential...
authorPatrick Lyster <Patrick.lyster@ibm.com>
Thu, 11 Oct 2018 14:41:10 +0000 (14:41 +0000)
committerPatrick Lyster <Patrick.lyster@ibm.com>
Thu, 11 Oct 2018 14:41:10 +0000 (14:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344249 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
include/clang/AST/OpenMPClause.h
include/clang/AST/RecursiveASTVisitor.h
include/clang/Basic/OpenMPKinds.def
include/clang/Sema/Sema.h
lib/AST/OpenMPClause.cpp
lib/AST/StmtPrinter.cpp
lib/AST/StmtProfile.cpp
lib/Basic/OpenMPKinds.cpp
lib/CodeGen/CGStmtOpenMP.cpp
lib/Parse/ParseOpenMP.cpp
lib/Sema/SemaOpenMP.cpp
lib/Sema/TreeTransform.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
test/OpenMP/requires_unified_address_ast_print.cpp
test/OpenMP/requires_unified_address_messages.cpp
tools/libclang/CIndex.cpp

index 98b19862e5777d609668d3b6b5796a8891e02bef..6a85cfbd0eaf543d99205940704065fa952a5ee1 100644 (file)
@@ -827,6 +827,38 @@ public:
   }
 };
 
+/// This represents 'dynamic_allocators' clause in the '#pragma omp requires'
+/// directive.
+///
+/// \code
+/// #pragma omp requires dynamic_allocators
+/// \endcode
+/// In this example directive '#pragma omp requires' has 'dynamic_allocators'
+/// clause.
+class OMPDynamicAllocatorsClause final : public OMPClause {
+public:
+  friend class OMPClauseReader;
+  /// Build 'dynamic_allocators' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPDynamicAllocatorsClause(SourceLocation StartLoc, SourceLocation EndLoc)
+      : OMPClause(OMPC_dynamic_allocators, StartLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPDynamicAllocatorsClause()
+      : OMPClause(OMPC_dynamic_allocators, SourceLocation(), SourceLocation()) {
+  }
+
+  child_range children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+    return T->getClauseKind() == OMPC_dynamic_allocators;
+  }
+};
+
 /// This represents 'schedule' clause in the '#pragma omp ...' directive.
 ///
 /// \code
index 5933c88a48a9df9912698fe1ed4aab0d7b94fe41..87f324e42d4728ec873e90edeaab3beb4d607aa4 100644 (file)
@@ -2879,6 +2879,12 @@ bool RecursiveASTVisitor<Derived>::VisitOMPReverseOffloadClause(
   return true;
 }
 
+template <typename Derived>
+bool RecursiveASTVisitor<Derived>::VisitOMPDynamicAllocatorsClause(
+    OMPDynamicAllocatorsClause *) {
+  return true;
+}
+
 template <typename Derived>
 bool
 RecursiveASTVisitor<Derived>::VisitOMPScheduleClause(OMPScheduleClause *C) {
index 375eddf8c99c75044243f23889370b394fb39188..ad40d3f819f9480faa511f61f631ee15846d8774 100644 (file)
@@ -282,6 +282,7 @@ OPENMP_CLAUSE(in_reduction,  OMPInReductionClause)
 OPENMP_CLAUSE(unified_address, OMPUnifiedAddressClause)
 OPENMP_CLAUSE(unified_shared_memory, OMPUnifiedSharedMemoryClause)
 OPENMP_CLAUSE(reverse_offload, OMPReverseOffloadClause)
+OPENMP_CLAUSE(dynamic_allocators, OMPDynamicAllocatorsClause)
 
 // Clauses allowed for OpenMP directive 'parallel'.
 OPENMP_PARALLEL_CLAUSE(if)
@@ -467,6 +468,7 @@ OPENMP_TARGET_CLAUSE(reduction)
 OPENMP_REQUIRES_CLAUSE(unified_address)
 OPENMP_REQUIRES_CLAUSE(unified_shared_memory)
 OPENMP_REQUIRES_CLAUSE(reverse_offload)
+OPENMP_REQUIRES_CLAUSE(dynamic_allocators)
 
 // Clauses allowed for OpenMP directive 'target data'.
 OPENMP_TARGET_DATA_CLAUSE(if)
index 703c64624e5220ed7c3c0799c4c70f83746bebc2..e1718e0b304121e4a962275770cd14efdb4b4383 100644 (file)
@@ -9191,6 +9191,10 @@ public:
   OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc,
                                              SourceLocation EndLoc);
 
+  /// Called on well-formed 'dynamic_allocators' clause.
+  OMPClause *ActOnOpenMPDynamicAllocatorsClause(SourceLocation StartLoc,
+                                                SourceLocation EndLoc);
+
   OMPClause *ActOnOpenMPVarListClause(
       OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, Expr *TailExpr,
       SourceLocation StartLoc, SourceLocation LParenLoc,
index 5642294f09decb8f07ac4ddba5c9133d5fc054f3..a39f8b06c51aecbd73b4115bc110948617c38b59 100644 (file)
@@ -109,6 +109,7 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     break;
   }
 
@@ -181,6 +182,7 @@ const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C)
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     break;
   }
 
index fc12ce9a5fc1e92fbe83da3de3ccec721f0268f4..e9d351e8682fc6349d9490d9ec9057053717878e 100644 (file)
@@ -709,6 +709,11 @@ void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
   OS << "reverse_offload";
 }
 
+void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
+    OMPDynamicAllocatorsClause *) {
+  OS << "dynamic_allocators";
+}
+
 void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
   OS << "schedule(";
   if (Node->getFirstScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) {
index 10b10254ddf4742e4f0c76b575f9fd227b54f963..2ad973436cf6d594053a65eb65e061f411abec09 100644 (file)
@@ -476,6 +476,9 @@ void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause(
 void OMPClauseProfiler::VisitOMPReverseOffloadClause(
     const OMPReverseOffloadClause *C) {}
 
+void OMPClauseProfiler::VisitOMPDynamicAllocatorsClause(
+    const OMPDynamicAllocatorsClause *C) {}
+
 void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
   VistOMPClauseWithPreInit(C);
   if (auto *S = C->getChunkSize())
index fa3c3dfd510b86bf28ce85e69a3b70d43541bf47..7693c4288b2797f2575c369a341e8315ff2f6d4d 100644 (file)
@@ -171,6 +171,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     break;
   }
   llvm_unreachable("Invalid OpenMP simple clause kind");
@@ -315,6 +316,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     break;
   }
   llvm_unreachable("Invalid OpenMP simple clause kind");
index 7872a805cc3560a8fe0d8834bae3f5566a2a1033..f410c59829d868b3581ee8afe89c62f316130649 100644 (file)
@@ -3901,6 +3901,7 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind,
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
 }
index 94eabf4797de2ed4e5aa8885ba1e590a2a6af69d..353bb800607fdbe56e4da7e5b96cc8339f5ea1d7 100644 (file)
@@ -1381,6 +1381,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     // 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]
index de78a1a5203746792e87ac06e4471a4c4d7ff8ca..d9f29735522f4975c8425d3b3a2d83934601c520 100644 (file)
@@ -8013,6 +8013,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     llvm_unreachable("Clause is not allowed.");
   }
   return Res;
@@ -8537,6 +8538,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     llvm_unreachable("Unexpected OpenMP clause.");
   }
   return CaptureRegion;
@@ -8857,6 +8859,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     llvm_unreachable("Clause is not allowed.");
   }
   return Res;
@@ -9016,6 +9019,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     llvm_unreachable("Clause is not allowed.");
   }
   return Res;
@@ -9180,6 +9184,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
   case OMPC_reverse_offload:
     Res = ActOnOpenMPReverseOffloadClause(StartLoc, EndLoc);
     break;
+  case OMPC_dynamic_allocators:
+    Res = ActOnOpenMPDynamicAllocatorsClause(StartLoc, EndLoc);
+    break;
   case OMPC_if:
   case OMPC_final:
   case OMPC_num_threads:
@@ -9295,6 +9302,11 @@ OMPClause *Sema::ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc,
   return new (Context) OMPReverseOffloadClause(StartLoc, EndLoc);
 }
 
+OMPClause *Sema::ActOnOpenMPDynamicAllocatorsClause(SourceLocation StartLoc,
+                                                    SourceLocation EndLoc) {
+  return new (Context) OMPDynamicAllocatorsClause(StartLoc, EndLoc);
+}
+
 OMPClause *Sema::ActOnOpenMPVarListClause(
     OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,
     SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
@@ -9405,6 +9417,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
   case OMPC_unified_address:
   case OMPC_unified_shared_memory:
   case OMPC_reverse_offload:
+  case OMPC_dynamic_allocators:
     llvm_unreachable("Clause is not allowed.");
   }
   return Res;
index 5d600b735a663ef1e8263ab5cd9ad04a8cfb211e..73a522b2ea4fa823d8d6e762e00a402e286c79c3 100644 (file)
@@ -8449,6 +8449,13 @@ OMPClause *TreeTransform<Derived>::TransformOMPReverseOffloadClause(
   llvm_unreachable("reverse_offload clause cannot appear in dependent context");
 }
 
+template <typename Derived>
+OMPClause *TreeTransform<Derived>::TransformOMPDynamicAllocatorsClause(
+    OMPDynamicAllocatorsClause *C) {
+  llvm_unreachable(
+      "dynamic_allocators clause cannot appear in dependent context");
+}
+
 template <typename Derived>
 OMPClause *
 TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
index 7cf78175fb032fcf4dd24bbfd6f57eb0fb5c3b04..5a29b2e33b1982fb06a2bf5e6f952d9618c57a16 100644 (file)
@@ -11729,6 +11729,9 @@ OMPClause *OMPClauseReader::readClause() {
   case OMPC_reverse_offload:
     C = new (Context) OMPReverseOffloadClause();
     break;
+  case OMPC_dynamic_allocators:
+    C = new (Context) OMPDynamicAllocatorsClause();
+    break;
   case OMPC_private:
     C = OMPPrivateClause::CreateEmpty(Context, Record.readInt());
     break;
@@ -11964,6 +11967,10 @@ void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause(
 
 void OMPClauseReader::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
 
+void
+OMPClauseReader::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
+}
+
 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
   C->setLParenLoc(Record.readSourceLocation());
   unsigned NumVars = C->varlist_size();
index 81ef885779ca7ceefc85565e5d58ac658e22e98c..06df715699bdd26b08490ac06b6c969c8796944f 100644 (file)
@@ -6937,3 +6937,7 @@ void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
     OMPUnifiedSharedMemoryClause *) {}
 
 void OMPClauseWriter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
+
+void
+OMPClauseWriter::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
+}
index 7a8a97050f858d76c993d4b95d81675801239d78..8c51ee05cad9b30b642f4ec0d53095500eb3fa87 100644 (file)
@@ -19,4 +19,7 @@
 #pragma omp requires reverse_offload
 // CHECK:#pragma omp requires reverse_offload
 
+#pragma omp requires dynamic_allocators
+// CHECK:#pragma omp requires dynamic_allocators
+
 #endif
index 916140f24eec6714147cac021d46ff9006bbc715..8809ec415b70f0c13f29084e8a076c16f6bfc3d9 100644 (file)
 
 #pragma omp requires reverse_offload, reverse_offload // expected-error {{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'reverse_offload' clause}}
 
+#pragma omp requires dynamic_allocators // expected-note {{dynamic_allocators clause previously used here}} expected-note {{dynamic_allocators clause previously used here}}
+
+#pragma omp requires dynamic_allocators, dynamic_allocators // expected-error {{Only one dynamic_allocators clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'dynamic_allocators' clause}}
+
+
 #pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}}
 
 #pragma omp requires invalid_clause // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}}
@@ -24,7 +29,7 @@
 
 #pragma omp requires invalid_clause unified_address // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}}
 
-#pragma omp requires unified_shared_memory, unified_address, reverse_offload // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error{{Only one reverse_offload clause can appear on a requires directive in a single translation unit}}
+#pragma omp requires unified_shared_memory, unified_address, reverse_offload, dynamic_allocators // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error{{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} expected-error{{Only one dynamic_allocators clause can appear on a requires directive in a single translation unit}}
 
 namespace A {
   #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}}
index ce653db8c9924424ed7351e9628cd67f7d21f0e2..d104edd82d46e9f5d9869ff94410d41f56f33894 100644 (file)
@@ -2216,6 +2216,9 @@ void OMPClauseEnqueue::VisitOMPUnifiedSharedMemoryClause(
 void OMPClauseEnqueue::VisitOMPReverseOffloadClause(
     const OMPReverseOffloadClause *) {}
 
+void OMPClauseEnqueue::VisitOMPDynamicAllocatorsClause(
+    const OMPDynamicAllocatorsClause *) {}
+
 void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) {
   Visitor->AddStmt(C->getDevice());
 }