diff options
| author | Samuel Antao <sfantao@us.ibm.com> | 2016-05-26 17:30:50 +0000 |
|---|---|---|
| committer | Samuel Antao <sfantao@us.ibm.com> | 2016-05-26 17:30:50 +0000 |
| commit | 686c70c3dc951d6f4b9c09197171f10ac25189f6 (patch) | |
| tree | 5ee915c9d908d3f860823b8190b39ff63f6e6b43 /clang/lib/Sema | |
| parent | 11f69ba0cfeb73381f47c7c8288684e686921221 (diff) | |
| download | bcm5719-llvm-686c70c3dc951d6f4b9c09197171f10ac25189f6.tar.gz bcm5719-llvm-686c70c3dc951d6f4b9c09197171f10ac25189f6.zip | |
[OpenMP] Parsing and sema support for target update directive
Summary:
This patch is to add parsing and sema support for `target update` directive. Support for the `to` and `from` clauses will be added by a different patch. This patch also adds support for other clauses that are already implemented upstream and apply to `target update`, e.g. `device` and `if`.
This patch is based on the original post by Kelvin Li.
Reviewers: hfinkel, carlo.bertolli, kkwli0, arpith-jacob, ABataev
Subscribers: caomhin, cfe-commits
Differential Revision: http://reviews.llvm.org/D15944
llvm-svn: 270878
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 23 | ||||
| -rw-r--r-- | clang/lib/Sema/TreeTransform.h | 11 |
2 files changed, 33 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 57759bcb63b..14830f21557 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1825,6 +1825,7 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) { case OMPD_declare_simd: case OMPD_declare_target: case OMPD_end_declare_target: + case OMPD_target_update: llvm_unreachable("OpenMP Directive is not allowed"); case OMPD_unknown: llvm_unreachable("Unknown OpenMP directive"); @@ -3274,6 +3275,12 @@ StmtResult Sema::ActOnOpenMPExecutableDirective( Res = ActOnOpenMPDistributeDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc, VarsWithInheritedDSA); break; + case OMPD_target_update: + assert(!AStmt && "Statement is not allowed for target update"); + Res = + ActOnOpenMPTargetUpdateDirective(ClausesWithImplicit, StartLoc, EndLoc); + AllowedNameModifiers.push_back(OMPD_target_update); + break; case OMPD_declare_target: case OMPD_end_declare_target: case OMPD_threadprivate: @@ -6511,6 +6518,20 @@ Sema::ActOnOpenMPTargetExitDataDirective(ArrayRef<OMPClause *> Clauses, return OMPTargetExitDataDirective::Create(Context, StartLoc, EndLoc, Clauses); } +StmtResult Sema::ActOnOpenMPTargetUpdateDirective(ArrayRef<OMPClause *> Clauses, + SourceLocation StartLoc, + SourceLocation EndLoc) { + // TODO: Set this flag accordingly when we add support for the 'to' and 'from' + // clauses. + bool seenMotionClause = false; + + if (!seenMotionClause) { + Diag(StartLoc, diag::err_omp_at_least_one_motion_clause_required); + return StmtError(); + } + return OMPTargetUpdateDirective::Create(Context, StartLoc, EndLoc, Clauses); +} + StmtResult Sema::ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc) { @@ -10407,7 +10428,7 @@ Sema::ActOnOpenMPMapClause(OpenMPMapClauseKind MapTypeModifier, // Save the components and declaration to create the clause. For purposes of // the clause creation, any component list that has has base 'this' uses - // null has + // null as base declaration. ClauseComponents.resize(ClauseComponents.size() + 1); ClauseComponents.back().append(CurComponents.begin(), CurComponents.end()); ClauseBaseDeclarations.push_back(isa<MemberExpr>(BE) ? nullptr diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index a2ad14fde01..9aeefd3d4b5 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -7477,6 +7477,17 @@ StmtResult TreeTransform<Derived>::TransformOMPTargetParallelForDirective( } template <typename Derived> +StmtResult TreeTransform<Derived>::TransformOMPTargetUpdateDirective( + OMPTargetUpdateDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_target_update, DirName, + nullptr, D->getLocStart()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + +template <typename Derived> StmtResult TreeTransform<Derived>::TransformOMPTeamsDirective(OMPTeamsDirective *D) { DeclarationNameInfo DirName; |

