summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Lyster <Patrick.lyster@ibm.com>2018-10-11 14:41:10 +0000
committerPatrick Lyster <Patrick.lyster@ibm.com>2018-10-11 14:41:10 +0000
commit851f70b951e5e068b0afa6f69ec58e0e80b0a1a4 (patch)
treec84f9b2e4f0280db12231998549f63b635884345
parentbb45239209491f6df1cf5bac7896673d5864640a (diff)
Add support for 'dynamic_allocators' clause on 'requires' directive. Differential Revision: https://reviews.llvm.org/D53079
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344249 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/OpenMPClause.h32
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h6
-rw-r--r--include/clang/Basic/OpenMPKinds.def2
-rw-r--r--include/clang/Sema/Sema.h4
-rw-r--r--lib/AST/OpenMPClause.cpp2
-rw-r--r--lib/AST/StmtPrinter.cpp5
-rw-r--r--lib/AST/StmtProfile.cpp3
-rw-r--r--lib/Basic/OpenMPKinds.cpp2
-rw-r--r--lib/CodeGen/CGStmtOpenMP.cpp1
-rw-r--r--lib/Parse/ParseOpenMP.cpp1
-rw-r--r--lib/Sema/SemaOpenMP.cpp13
-rw-r--r--lib/Sema/TreeTransform.h7
-rw-r--r--lib/Serialization/ASTReader.cpp7
-rw-r--r--lib/Serialization/ASTWriter.cpp4
-rw-r--r--test/OpenMP/requires_unified_address_ast_print.cpp3
-rw-r--r--test/OpenMP/requires_unified_address_messages.cpp7
-rw-r--r--tools/libclang/CIndex.cpp3
17 files changed, 101 insertions, 1 deletions
diff --git a/include/clang/AST/OpenMPClause.h b/include/clang/AST/OpenMPClause.h
index 98b19862e5..6a85cfbd0e 100644
--- a/include/clang/AST/OpenMPClause.h
+++ b/include/clang/AST/OpenMPClause.h
@@ -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
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index 5933c88a48..87f324e42d 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -2880,6 +2880,12 @@ bool RecursiveASTVisitor<Derived>::VisitOMPReverseOffloadClause(
}
template <typename Derived>
+bool RecursiveASTVisitor<Derived>::VisitOMPDynamicAllocatorsClause(
+ OMPDynamicAllocatorsClause *) {
+ return true;
+}
+
+template <typename Derived>
bool
RecursiveASTVisitor<Derived>::VisitOMPScheduleClause(OMPScheduleClause *C) {
TRY_TO(VisitOMPClauseWithPreInit(C));
diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def
index 375eddf8c9..ad40d3f819 100644
--- a/include/clang/Basic/OpenMPKinds.def
+++ b/include/clang/Basic/OpenMPKinds.def
@@ -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)
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 703c64624e..e1718e0b30 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -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,
diff --git a/lib/AST/OpenMPClause.cpp b/lib/AST/OpenMPClause.cpp
index 5642294f09..a39f8b06c5 100644
--- a/lib/AST/OpenMPClause.cpp
+++ b/lib/AST/OpenMPClause.cpp
@@ -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;
}
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index fc12ce9a5f..e9d351e868 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -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) {
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index 10b10254dd..2ad973436c 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -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())
diff --git a/lib/Basic/OpenMPKinds.cpp b/lib/Basic/OpenMPKinds.cpp
index fa3c3dfd51..7693c4288b 100644
--- a/lib/Basic/OpenMPKinds.cpp
+++ b/lib/Basic/OpenMPKinds.cpp
@@ -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");
diff --git a/lib/CodeGen/CGStmtOpenMP.cpp b/lib/CodeGen/CGStmtOpenMP.cpp
index 7872a805cc..f410c59829 100644
--- a/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/lib/CodeGen/CGStmtOpenMP.cpp
@@ -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'.");
}
}
diff --git a/lib/Parse/ParseOpenMP.cpp b/lib/Parse/ParseOpenMP.cpp
index 94eabf4797..353bb80060 100644
--- a/lib/Parse/ParseOpenMP.cpp
+++ b/lib/Parse/ParseOpenMP.cpp
@@ -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]
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp
index de78a1a520..d9f2973552 100644
--- a/lib/Sema/SemaOpenMP.cpp
+++ b/lib/Sema/SemaOpenMP.cpp
@@ -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;
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 5d600b735a..73a522b2ea 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -8450,6 +8450,13 @@ OMPClause *TreeTransform<Derived>::TransformOMPReverseOffloadClause(
}
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) {
llvm::SmallVector<Expr *, 16> Vars;
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 7cf78175fb..5a29b2e33b 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -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();
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 81ef885779..06df715699 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -6937,3 +6937,7 @@ void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
OMPUnifiedSharedMemoryClause *) {}
void OMPClauseWriter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
+
+void
+OMPClauseWriter::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
+}
diff --git a/test/OpenMP/requires_unified_address_ast_print.cpp b/test/OpenMP/requires_unified_address_ast_print.cpp
index 7a8a97050f..8c51ee05ca 100644
--- a/test/OpenMP/requires_unified_address_ast_print.cpp
+++ b/test/OpenMP/requires_unified_address_ast_print.cpp
@@ -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
diff --git a/test/OpenMP/requires_unified_address_messages.cpp b/test/OpenMP/requires_unified_address_messages.cpp
index 916140f24e..8809ec415b 100644
--- a/test/OpenMP/requires_unified_address_messages.cpp
+++ b/test/OpenMP/requires_unified_address_messages.cpp
@@ -14,6 +14,11 @@
#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}}
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index ce653db8c9..d104edd82d 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -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());
}