diff options
author | Michael Kruse <llvm@meinersbur.de> | 2019-02-01 20:25:04 +0000 |
---|---|---|
committer | Michael Kruse <llvm@meinersbur.de> | 2019-02-01 20:25:04 +0000 |
commit | 251e1488e195a0ab618e503fe5b2bc8ff18d1724 (patch) | |
tree | fb857506e530be8dff680a7f283eaad431bdf545 /clang/lib/Serialization/ASTReaderDecl.cpp | |
parent | 6b653fc70ffdc3ec685a435b42c45611e21d407c (diff) | |
download | bcm5719-llvm-251e1488e195a0ab618e503fe5b2bc8ff18d1724.tar.gz bcm5719-llvm-251e1488e195a0ab618e503fe5b2bc8ff18d1724.zip |
[OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.
This patch implements parsing and sema for "omp declare mapper"
directive. User defined mapper, i.e., declare mapper directive, is a new
feature in OpenMP 5.0. It is introduced to extend existing map clauses
for the purpose of simplifying the copy of complex data structures
between host and device (i.e., deep copy). An example is shown below:
struct S { int len; int *d; };
#pragma omp declare mapper(struct S s) map(s, s.d[0:s.len]) // Memory region that d points to is also mapped using this mapper.
Contributed-by: Lingda Li <lildmh@gmail.com>
Differential Revision: https://reviews.llvm.org/D56326
llvm-svn: 352906
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 8b40dc853ba..1c56cdbf948 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -445,6 +445,7 @@ namespace clang { void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D); void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D); + void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D); void VisitOMPRequiresDecl(OMPRequiresDecl *D); void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D); }; @@ -2659,6 +2660,22 @@ void ASTDeclReader::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { D->PrevDeclInScope = ReadDeclID(); } +void ASTDeclReader::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) { + VisitValueDecl(D); + D->setLocation(ReadSourceLocation()); + Expr *MapperVarRefE = Record.readExpr(); + D->setMapperVarRef(MapperVarRefE); + D->VarName = Record.readDeclarationName(); + D->PrevDeclInScope = ReadDeclID(); + unsigned NumClauses = D->clauselist_size(); + SmallVector<OMPClause *, 8> Clauses; + Clauses.reserve(NumClauses); + OMPClauseReader ClauseReader(Record); + for (unsigned I = 0; I != NumClauses; ++I) + Clauses.push_back(ClauseReader.readClause()); + D->setClauses(Clauses); +} + void ASTDeclReader::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) { VisitVarDecl(D); } @@ -2776,7 +2793,8 @@ static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody) { isa<PragmaCommentDecl>(D) || isa<PragmaDetectMismatchDecl>(D)) return true; - if (isa<OMPThreadPrivateDecl>(D) || isa<OMPDeclareReductionDecl>(D)) + if (isa<OMPThreadPrivateDecl>(D) || isa<OMPDeclareReductionDecl>(D) || + isa<OMPDeclareMapperDecl>(D)) return !D->getDeclContext()->isFunctionOrMethod(); if (const auto *Var = dyn_cast<VarDecl>(D)) return Var->isFileVarDecl() && @@ -3853,6 +3871,9 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { case DECL_OMP_DECLARE_REDUCTION: D = OMPDeclareReductionDecl::CreateDeserialized(Context, ID); break; + case DECL_OMP_DECLARE_MAPPER: + D = OMPDeclareMapperDecl::CreateDeserialized(Context, ID, Record.readInt()); + break; case DECL_OMP_CAPTUREDEXPR: D = OMPCapturedExprDecl::CreateDeserialized(Context, ID); break; |