diff options
-rw-r--r-- | clang/include/clang/AST/OpenMPClause.h | 31 | ||||
-rw-r--r-- | clang/include/clang/AST/RecursiveASTVisitor.h | 6 | ||||
-rw-r--r-- | clang/include/clang/Basic/OpenMPKinds.def | 2 | ||||
-rw-r--r-- | clang/include/clang/Sema/Sema.h | 4 | ||||
-rw-r--r-- | clang/lib/AST/OpenMPClause.cpp | 2 | ||||
-rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 5 | ||||
-rw-r--r-- | clang/lib/AST/StmtProfile.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Basic/OpenMPKinds.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 7 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 3 | ||||
-rw-r--r-- | clang/test/OpenMP/requires_unified_address_ast_print.cpp | 3 | ||||
-rw-r--r-- | clang/test/OpenMP/requires_unified_address_messages.cpp | 8 | ||||
-rw-r--r-- | clang/tools/libclang/CIndex.cpp | 3 |
17 files changed, 99 insertions, 1 deletions
diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h index 6a2c806bb63..41846f088f5 100644 --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -765,6 +765,37 @@ public: } }; +/// This represents 'unified_shared_memory' clause in the '#pragma omp requires' +/// directive. +/// +/// \code +/// #pragma omp requires unified_shared_memory +/// \endcode +/// In this example directive '#pragma omp requires' has 'unified_shared_memory' +/// clause. +class OMPUnifiedSharedMemoryClause final : public OMPClause { +public: + friend class OMPClauseReader; + /// Build 'unified_shared_memory' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param EndLoc Ending location of the clause. + OMPUnifiedSharedMemoryClause(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPClause(OMPC_unified_shared_memory, StartLoc, EndLoc) {} + + /// Build an empty clause. + OMPUnifiedSharedMemoryClause() + : OMPClause(OMPC_unified_shared_memory, SourceLocation(), SourceLocation()) {} + + child_range children() { + return child_range(child_iterator(), child_iterator()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == OMPC_unified_shared_memory; + } +}; + /// This represents 'schedule' clause in the '#pragma omp ...' directive. /// /// \code diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 436425a9eeb..6e2b4f183f1 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -2868,6 +2868,12 @@ bool RecursiveASTVisitor<Derived>::VisitOMPUnifiedAddressClause( } template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPUnifiedSharedMemoryClause( + OMPUnifiedSharedMemoryClause *) { + return true; +} + +template <typename Derived> bool RecursiveASTVisitor<Derived>::VisitOMPScheduleClause(OMPScheduleClause *C) { TRY_TO(VisitOMPClauseWithPreInit(C)); diff --git a/clang/include/clang/Basic/OpenMPKinds.def b/clang/include/clang/Basic/OpenMPKinds.def index 8ad40d68a4a..5f7c6efc1bb 100644 --- a/clang/include/clang/Basic/OpenMPKinds.def +++ b/clang/include/clang/Basic/OpenMPKinds.def @@ -280,6 +280,7 @@ OPENMP_CLAUSE(is_device_ptr, OMPIsDevicePtrClause) OPENMP_CLAUSE(task_reduction, OMPTaskReductionClause) OPENMP_CLAUSE(in_reduction, OMPInReductionClause) OPENMP_CLAUSE(unified_address, OMPUnifiedAddressClause) +OPENMP_CLAUSE(unified_shared_memory, OMPUnifiedSharedMemoryClause) // Clauses allowed for OpenMP directive 'parallel'. OPENMP_PARALLEL_CLAUSE(if) @@ -463,6 +464,7 @@ OPENMP_TARGET_CLAUSE(reduction) // Clauses allowed for OpenMP directive 'requires'. OPENMP_REQUIRES_CLAUSE(unified_address) +OPENMP_REQUIRES_CLAUSE(unified_shared_memory) // Clauses allowed for OpenMP directive 'target data'. OPENMP_TARGET_DATA_CLAUSE(if) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 8b57ebb0060..1d39ddf3989 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -9168,6 +9168,10 @@ public: OMPClause *ActOnOpenMPUnifiedAddressClause(SourceLocation StartLoc, SourceLocation EndLoc); + /// Called on well-formed 'unified_address' clause. + OMPClause *ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc, + SourceLocation EndLoc); + OMPClause *ActOnOpenMPVarListClause( OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, Expr *TailExpr, SourceLocation StartLoc, SourceLocation LParenLoc, diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp index 1114ae3e92e..79c49f206dd 100644 --- a/clang/lib/AST/OpenMPClause.cpp +++ b/clang/lib/AST/OpenMPClause.cpp @@ -107,6 +107,7 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) { case OMPC_use_device_ptr: case OMPC_is_device_ptr: case OMPC_unified_address: + case OMPC_unified_shared_memory: break; } @@ -177,6 +178,7 @@ const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) case OMPC_use_device_ptr: case OMPC_is_device_ptr: case OMPC_unified_address: + case OMPC_unified_shared_memory: break; } diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 51591953e74..93981bdcde4 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -700,6 +700,11 @@ void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) { OS << "unified_address"; } +void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause( + OMPUnifiedSharedMemoryClause *) { + OS << "unified_shared_memory"; +} + void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) { OS << "schedule("; if (Node->getFirstScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) { diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index b97812345be..f3db8f7e040 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -470,6 +470,9 @@ void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { } void OMPClauseProfiler::VisitOMPUnifiedAddressClause( const OMPUnifiedAddressClause *C) {} +void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause( + const OMPUnifiedSharedMemoryClause *C) {} + void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) { VistOMPClauseWithPreInit(C); if (auto *S = C->getChunkSize()) diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp index 2251d897542..aaaf04f6aa8 100644 --- a/clang/lib/Basic/OpenMPKinds.cpp +++ b/clang/lib/Basic/OpenMPKinds.cpp @@ -169,6 +169,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, case OMPC_use_device_ptr: case OMPC_is_device_ptr: case OMPC_unified_address: + case OMPC_unified_shared_memory: break; } llvm_unreachable("Invalid OpenMP simple clause kind"); @@ -311,6 +312,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, case OMPC_use_device_ptr: case OMPC_is_device_ptr: case OMPC_unified_address: + case OMPC_unified_shared_memory: break; } llvm_unreachable("Invalid OpenMP simple clause kind"); diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 79ffa7c8e94..937b59f506a 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -3912,6 +3912,7 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind, case OMPC_use_device_ptr: case OMPC_is_device_ptr: case OMPC_unified_address: + case OMP_unified_shared_memory: llvm_unreachable("Clause is not allowed in 'omp atomic'."); } } diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index e8a17b5e12c..209b87e1b87 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -1379,6 +1379,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, case OMPC_simd: case OMPC_nogroup: case OMPC_unified_address: + case OMPC_unified_shared_memory: // 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/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 75351ebabde..fec8f8b10b0 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -8011,6 +8011,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, case OMPC_use_device_ptr: case OMPC_is_device_ptr: case OMPC_unified_address: + case OMPC_unified_shared_memory: llvm_unreachable("Clause is not allowed."); } return Res; @@ -8533,6 +8534,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPC_use_device_ptr: case OMPC_is_device_ptr: case OMPC_unified_address: + case OMPC_unified_shared_memory: llvm_unreachable("Unexpected OpenMP clause."); } return CaptureRegion; @@ -8851,6 +8853,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause( case OMPC_use_device_ptr: case OMPC_is_device_ptr: case OMPC_unified_address: + case OMPC_unified_shared_memory: llvm_unreachable("Clause is not allowed."); } return Res; @@ -9008,6 +9011,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause( case OMPC_use_device_ptr: case OMPC_is_device_ptr: case OMPC_unified_address: + case OMPC_unified_shared_memory: llvm_unreachable("Clause is not allowed."); } return Res; @@ -9166,6 +9170,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind, case OMPC_unified_address: Res = ActOnOpenMPUnifiedAddressClause(StartLoc, EndLoc); break; + case OMPC_unified_shared_memory: + Res = ActOnOpenMPUnifiedSharedMemoryClause(StartLoc, EndLoc); + break; case OMPC_if: case OMPC_final: case OMPC_num_threads: @@ -9271,6 +9278,11 @@ OMPClause *Sema::ActOnOpenMPUnifiedAddressClause(SourceLocation StartLoc, return new (Context) OMPUnifiedAddressClause(StartLoc, EndLoc); } +OMPClause *Sema::ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc, + SourceLocation EndLoc) { + return new (Context) OMPUnifiedSharedMemoryClause(StartLoc, EndLoc); +} + OMPClause *Sema::ActOnOpenMPVarListClause( OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, @@ -9379,6 +9391,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause( case OMPC_unknown: case OMPC_uniform: case OMPC_unified_address: + case OMPC_unified_shared_memory: llvm_unreachable("Clause is not allowed."); } return Res; diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index a75d3075638..b9a5494ecda 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -8437,6 +8437,13 @@ OMPClause *TreeTransform<Derived>::TransformOMPUnifiedAddressClause( } template <typename Derived> +OMPClause *TreeTransform<Derived>::TransformOMPUnifiedSharedMemoryClause( + OMPUnifiedSharedMemoryClause *C) { + llvm_unreachable( + "unified_shared_memory clause cannot appear in dependent context"); +} + +template <typename Derived> OMPClause * TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) { llvm::SmallVector<Expr *, 16> Vars; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index f8d98eeeb65..cb4f491e176 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -11723,6 +11723,9 @@ OMPClause *OMPClauseReader::readClause() { case OMPC_unified_address: C = new (Context) OMPUnifiedAddressClause(); break; + case OMPC_unified_shared_memory: + C = new (Context) OMPUnifiedSharedMemoryClause(); + break; case OMPC_private: C = OMPPrivateClause::CreateEmpty(Context, Record.readInt()); break; @@ -11953,6 +11956,9 @@ void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {} void OMPClauseReader::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {} +void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause( + OMPUnifiedSharedMemoryClause *) {} + void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) { C->setLParenLoc(Record.readSourceLocation()); unsigned NumVars = C->varlist_size(); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 570a1e1643e..08cfa6bce7f 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -6932,3 +6932,6 @@ void OMPClauseWriter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { } void OMPClauseWriter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {} + +void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause( + OMPUnifiedSharedMemoryClause *) {} diff --git a/clang/test/OpenMP/requires_unified_address_ast_print.cpp b/clang/test/OpenMP/requires_unified_address_ast_print.cpp index 641d6c4b90b..69b69054812 100644 --- a/clang/test/OpenMP/requires_unified_address_ast_print.cpp +++ b/clang/test/OpenMP/requires_unified_address_ast_print.cpp @@ -13,4 +13,7 @@ #pragma omp requires unified_address // CHECK:#pragma omp requires unified_address +#pragma omp requires unified_shared_memory +// CHECK:#pragma omp requires unified_shared_memory + #endif diff --git a/clang/test/OpenMP/requires_unified_address_messages.cpp b/clang/test/OpenMP/requires_unified_address_messages.cpp index ed5d27a5ec9..8f1904de315 100644 --- a/clang/test/OpenMP/requires_unified_address_messages.cpp +++ b/clang/test/OpenMP/requires_unified_address_messages.cpp @@ -1,6 +1,10 @@ // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} +#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note{{unified_address clause previously used here}} + +#pragma omp requires unified_shared_memory // expected-note {{unified_shared_memory clause previously used here}} expected-note{{unified_shared_memory clause previously used here}} + +#pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} @@ -16,6 +20,8 @@ #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 // 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}} + 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}} namespace B { diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 7e2380ea7b8..3826be5cf7a 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -2210,6 +2210,9 @@ void OMPClauseEnqueue::VisitOMPNogroupClause(const OMPNogroupClause *) {} void OMPClauseEnqueue::VisitOMPUnifiedAddressClause( const OMPUnifiedAddressClause *) {} +void OMPClauseEnqueue::VisitOMPUnifiedSharedMemoryClause( + const OMPUnifiedSharedMemoryClause *) {} + void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) { Visitor->AddStmt(C->getDevice()); } |