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/AST/DeclPrinter.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/AST/DeclPrinter.cpp')
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index a3e8475a1e7..46069898cc0 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -101,6 +101,7 @@ namespace { void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D); void VisitOMPRequiresDecl(OMPRequiresDecl *D); void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D); + void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D); void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D); void printTemplateParameters(const TemplateParameterList *Params); @@ -423,7 +424,7 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) { // FIXME: Need to be able to tell the DeclPrinter when const char *Terminator = nullptr; if (isa<OMPThreadPrivateDecl>(*D) || isa<OMPDeclareReductionDecl>(*D) || - isa<OMPRequiresDecl>(*D)) + isa<OMPDeclareMapperDecl>(*D) || isa<OMPRequiresDecl>(*D)) Terminator = nullptr; else if (isa<ObjCMethodDecl>(*D) && cast<ObjCMethodDecl>(*D)->hasBody()) Terminator = nullptr; @@ -1597,6 +1598,25 @@ void DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { } } +void DeclPrinter::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) { + if (!D->isInvalidDecl()) { + Out << "#pragma omp declare mapper ("; + D->printName(Out); + Out << " : "; + D->getType().print(Out, Policy); + Out << " "; + Out << D->getVarName(); + Out << ")"; + if (!D->clauselist_empty()) { + OMPClausePrinter Printer(Out, Policy); + for (auto *C : D->clauselists()) { + Out << " "; + Printer.Visit(C); + } + } + } +} + void DeclPrinter::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) { D->getInit()->printPretty(Out, nullptr, Policy, Indentation); } |