summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorArpith Chacko Jacob <acjacob@us.ibm.com>2016-01-26 18:48:41 +0000
committerArpith Chacko Jacob <acjacob@us.ibm.com>2016-01-26 18:48:41 +0000
commite955b3d3fe12a05e7639aa336d6945fa9427c0dc (patch)
tree3423de8c95bccda8edcb7065c05cd525a8acc621 /clang/lib/Sema
parent6ac3f739ca4cd90b41388cc50070a6bca85b6842 (diff)
downloadbcm5719-llvm-e955b3d3fe12a05e7639aa336d6945fa9427c0dc.tar.gz
bcm5719-llvm-e955b3d3fe12a05e7639aa336d6945fa9427c0dc.zip
[OpenMP] Parsing + sema for target parallel directive.
Summary: This patch adds parsing + sema for the target parallel directive and its clauses along with testcases. Reviewers: ABataev Differential Revision: http://reviews.llvm.org/D16553 Rebased to current trunk and updated test cases. llvm-svn: 258832
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp88
-rw-r--r--clang/lib/Sema/TreeTransform.h11
2 files changed, 97 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 6a5c1d9e126..577772301f0 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1628,7 +1628,8 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) {
break;
}
case OMPD_target_data:
- case OMPD_target: {
+ case OMPD_target:
+ case OMPD_target_parallel: {
Sema::CapturedParamNameType Params[] = {
std::make_pair(StringRef(), QualType()) // __context with shared vars
};
@@ -1804,6 +1805,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | parallel | ordered | + |
// | parallel | atomic | * |
// | parallel | target | * |
+ // | parallel | target parallel | * |
// | parallel | target enter | * |
// | | data | |
// | parallel | target exit | * |
@@ -1837,6 +1839,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | for | ordered | * (if construct is ordered) |
// | for | atomic | * |
// | for | target | * |
+ // | for | target parallel | * |
// | for | target enter | * |
// | | data | |
// | for | target exit | * |
@@ -1870,6 +1873,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | master | ordered | + |
// | master | atomic | * |
// | master | target | * |
+ // | master | target parallel | * |
// | master | target enter | * |
// | | data | |
// | master | target exit | * |
@@ -1902,6 +1906,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | critical | ordered | + |
// | critical | atomic | * |
// | critical | target | * |
+ // | critical | target parallel | * |
// | critical | target enter | * |
// | | data | |
// | critical | target exit | * |
@@ -1935,6 +1940,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | simd | ordered | + (with simd clause) |
// | simd | atomic | |
// | simd | target | |
+ // | simd | target parallel | |
// | simd | target enter | |
// | | data | |
// | simd | target exit | |
@@ -1968,6 +1974,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | for simd | ordered | + (with simd clause) |
// | for simd | atomic | |
// | for simd | target | |
+ // | for simd | target parallel | |
// | for simd | target enter | |
// | | data | |
// | for simd | target exit | |
@@ -2001,6 +2008,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | parallel for simd| ordered | + (with simd clause) |
// | parallel for simd| atomic | |
// | parallel for simd| target | |
+ // | parallel for simd| target parallel | |
// | parallel for simd| target enter | |
// | | data | |
// | parallel for simd| target exit | |
@@ -2034,6 +2042,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | sections | ordered | + |
// | sections | atomic | * |
// | sections | target | * |
+ // | sections | target parallel | * |
// | sections | target enter | * |
// | | data | |
// | sections | target exit | * |
@@ -2067,6 +2076,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | section | ordered | + |
// | section | atomic | * |
// | section | target | * |
+ // | section | target parallel | * |
// | section | target enter | * |
// | | data | |
// | section | target exit | * |
@@ -2100,6 +2110,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | single | ordered | + |
// | single | atomic | * |
// | single | target | * |
+ // | single | target parallel | * |
// | single | target enter | * |
// | | data | |
// | single | target exit | * |
@@ -2133,6 +2144,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | parallel for | ordered | * (if construct is ordered) |
// | parallel for | atomic | * |
// | parallel for | target | * |
+ // | parallel for | target parallel | * |
// | parallel for | target enter | * |
// | | data | |
// | parallel for | target exit | * |
@@ -2166,6 +2178,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | parallel sections| ordered | + |
// | parallel sections| atomic | * |
// | parallel sections| target | * |
+ // | parallel sections| target parallel | * |
// | parallel sections| target enter | * |
// | | data | |
// | parallel sections| target exit | * |
@@ -2199,6 +2212,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | task | ordered | + |
// | task | atomic | * |
// | task | target | * |
+ // | task | target parallel | * |
// | task | target enter | * |
// | | data | |
// | task | target exit | * |
@@ -2232,6 +2246,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | ordered | ordered | + |
// | ordered | atomic | * |
// | ordered | target | * |
+ // | ordered | target parallel | * |
// | ordered | target enter | * |
// | | data | |
// | ordered | target exit | * |
@@ -2265,6 +2280,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | atomic | ordered | |
// | atomic | atomic | |
// | atomic | target | |
+ // | atomic | target parallel | |
// | atomic | target enter | |
// | | data | |
// | atomic | target exit | |
@@ -2298,6 +2314,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | target | ordered | * |
// | target | atomic | * |
// | target | target | * |
+ // | target | target parallel | * |
// | target | target enter | * |
// | | data | |
// | target | target exit | * |
@@ -2310,6 +2327,40 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | target | taskloop simd | * |
// | target | distribute | |
// +------------------+-----------------+------------------------------------+
+ // | target parallel | parallel | * |
+ // | target parallel | for | * |
+ // | target parallel | for simd | * |
+ // | target parallel | master | * |
+ // | target parallel | critical | * |
+ // | target parallel | simd | * |
+ // | target parallel | sections | * |
+ // | target parallel | section | * |
+ // | target parallel | single | * |
+ // | target parallel | parallel for | * |
+ // | target parallel |parallel for simd| * |
+ // | target parallel |parallel sections| * |
+ // | target parallel | task | * |
+ // | target parallel | taskyield | * |
+ // | target parallel | barrier | * |
+ // | target parallel | taskwait | * |
+ // | target parallel | taskgroup | * |
+ // | target parallel | flush | * |
+ // | target parallel | ordered | * |
+ // | target parallel | atomic | * |
+ // | target parallel | target | * |
+ // | target parallel | target parallel | * |
+ // | target parallel | target enter | * |
+ // | | data | |
+ // | target parallel | target exit | * |
+ // | | data | |
+ // | target parallel | teams | |
+ // | target parallel | cancellation | |
+ // | | point | ! |
+ // | target parallel | cancel | ! |
+ // | target parallel | taskloop | * |
+ // | target parallel | taskloop simd | * |
+ // | target parallel | distribute | |
+ // +------------------+-----------------+------------------------------------+
// | teams | parallel | * |
// | teams | for | + |
// | teams | for simd | + |
@@ -2331,6 +2382,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | teams | ordered | + |
// | teams | atomic | + |
// | teams | target | + |
+ // | teams | target parallel | + |
// | teams | target enter | + |
// | | data | |
// | teams | target exit | + |
@@ -2364,6 +2416,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | taskloop | ordered | + |
// | taskloop | atomic | * |
// | taskloop | target | * |
+ // | taskloop | target parallel | * |
// | taskloop | target enter | * |
// | | data | |
// | taskloop | target exit | * |
@@ -2396,6 +2449,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | taskloop simd | ordered | + (with simd clause) |
// | taskloop simd | atomic | |
// | taskloop simd | target | |
+ // | taskloop simd | target parallel | |
// | taskloop simd | target enter | |
// | | data | |
// | taskloop simd | target exit | |
@@ -2429,6 +2483,7 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | distribute | ordered | + |
// | distribute | atomic | * |
// | distribute | target | |
+ // | distribute | target parallel | |
// | distribute | target enter | |
// | | data | |
// | distribute | target exit | |
@@ -2499,7 +2554,9 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// OpenMP construct that matches the type specified in
// construct-type-clause.
NestingProhibited =
- !((CancelRegion == OMPD_parallel && ParentRegion == OMPD_parallel) ||
+ !((CancelRegion == OMPD_parallel &&
+ (ParentRegion == OMPD_parallel ||
+ ParentRegion == OMPD_target_parallel)) ||
(CancelRegion == OMPD_for &&
(ParentRegion == OMPD_for || ParentRegion == OMPD_parallel_for)) ||
(CancelRegion == OMPD_taskgroup && ParentRegion == OMPD_task) ||
@@ -2838,6 +2895,12 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
EndLoc);
AllowedNameModifiers.push_back(OMPD_target);
break;
+ case OMPD_target_parallel:
+ Res = ActOnOpenMPTargetParallelDirective(ClausesWithImplicit, AStmt,
+ StartLoc, EndLoc);
+ AllowedNameModifiers.push_back(OMPD_target);
+ AllowedNameModifiers.push_back(OMPD_parallel);
+ break;
case OMPD_cancellation_point:
assert(ClausesWithImplicit.empty() &&
"No clauses are allowed for 'omp cancellation point' directive");
@@ -5603,6 +5666,27 @@ StmtResult Sema::ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses,
return OMPTargetDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
}
+StmtResult
+Sema::ActOnOpenMPTargetParallelDirective(ArrayRef<OMPClause *> Clauses,
+ Stmt *AStmt, SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ if (!AStmt)
+ return StmtError();
+
+ CapturedStmt *CS = cast<CapturedStmt>(AStmt);
+ // 1.2.2 OpenMP Language Terminology
+ // Structured block - An executable statement with a single entry at the
+ // top and a single exit at the bottom.
+ // The point of exit cannot be a branch out of the structured block.
+ // longjmp() and throw() must not violate the entry/exit criteria.
+ CS->getCapturedDecl()->setNothrow();
+
+ getCurFunction()->setHasBranchProtectedScope();
+
+ return OMPTargetParallelDirective::Create(Context, StartLoc, EndLoc, Clauses,
+ AStmt);
+}
+
/// \brief Check for existence of a map clause in the list of clauses.
static bool HasMapClause(ArrayRef<OMPClause *> Clauses) {
for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 648a6c17425..e3272eec42c 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -7414,6 +7414,17 @@ StmtResult TreeTransform<Derived>::TransformOMPTargetExitDataDirective(
}
template <typename Derived>
+StmtResult TreeTransform<Derived>::TransformOMPTargetParallelDirective(
+ OMPTargetParallelDirective *D) {
+ DeclarationNameInfo DirName;
+ getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel, 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;
OpenPOWER on IntegriCloud