summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp187
1 files changed, 186 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 5cbcea4cce3..25096e615fe 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1693,7 +1693,8 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) {
case OMPD_distribute_parallel_for_simd:
case OMPD_distribute_simd:
case OMPD_distribute_parallel_for:
- case OMPD_teams_distribute: {
+ case OMPD_teams_distribute:
+ case OMPD_teams_distribute_simd: {
QualType KmpInt32Ty = Context.getIntTypeForBitwidth(32, 1);
QualType KmpInt32PtrTy =
Context.getPointerType(KmpInt32Ty).withConst().withRestrict();
@@ -1922,6 +1923,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | parallel | distribute simd | + |
// | parallel | target simd | * |
// | parallel | teams distribute| + |
+ // | parallel | teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | for | parallel | * |
// | for | for | + |
@@ -1967,6 +1970,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | for | target simd | * |
// | for | teams distribute| + |
+ // | for | teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | master | parallel | * |
// | master | for | + |
@@ -2012,6 +2017,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | master | target simd | * |
// | master | teams distribute| + |
+ // | master | teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | critical | parallel | * |
// | critical | for | + |
@@ -2056,6 +2063,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | critical | target simd | * |
// | critical | teams distribute| + |
+ // | critical | teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | simd | parallel | |
// | simd | for | |
@@ -2101,6 +2110,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | simd | target simd | |
// | simd | teams distribute| |
+ // | simd | teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | for simd | parallel | |
// | for simd | for | |
@@ -2146,6 +2157,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | for simd | target simd | |
// | for simd | teams distribute| |
+ // | for simd | teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | parallel for simd| parallel | |
// | parallel for simd| for | |
@@ -2190,6 +2203,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | parallel for simd| target simd | |
// | parallel for simd| teams distribute| |
+ // | parallel for simd| teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | sections | parallel | * |
// | sections | for | + |
@@ -2234,6 +2249,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | sections | target parallel | + |
// | | for simd | |
// | sections | target simd | * |
+ // | sections | teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | section | parallel | * |
// | section | for | + |
@@ -2279,6 +2296,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | section | target simd | * |
// | section | teams distrubte | + |
+ // | section | teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | single | parallel | * |
// | single | for | + |
@@ -2324,6 +2343,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | single | target simd | * |
// | single | teams distrubte | + |
+ // | single | teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | parallel for | parallel | * |
// | parallel for | for | + |
@@ -2369,6 +2390,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | parallel for | target simd | * |
// | parallel for | teams distribute| + |
+ // | parallel for | teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | parallel sections| parallel | * |
// | parallel sections| for | + |
@@ -2414,6 +2437,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | parallel sections| target simd | * |
// | parallel sections| teams distribute| + |
+ // | parallel sections| teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | task | parallel | * |
// | task | for | + |
@@ -2459,6 +2484,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | task | target simd | * |
// | task | teams distribute| + |
+ // | task | teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | ordered | parallel | * |
// | ordered | for | + |
@@ -2504,6 +2531,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | ordered | target simd | * |
// | ordered | teams distribute| + |
+ // | ordered | teams distribute| |
+ // | | simd | + |
// +------------------+-----------------+------------------------------------+
// | atomic | parallel | |
// | atomic | for | |
@@ -2549,6 +2578,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | atomic | target simd | |
// | atomic | teams distribute| |
+ // | atomic | teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | target | parallel | * |
// | target | for | * |
@@ -2594,6 +2625,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | target | target simd | |
// | target | teams distribute| |
+ // | target | teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | target parallel | parallel | * |
// | target parallel | for | * |
@@ -2639,6 +2672,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | target parallel | target simd | |
// | target parallel | teams distribute| + |
+ // | target parallel | teams distribute| + |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | target parallel | parallel | * |
// | for | | |
@@ -2714,6 +2749,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | for | | |
// | target parallel | teams distribute| |
// | for | | |
+ // | target parallel | teams distribute| |
+ // | for | simd | |
// +------------------+-----------------+------------------------------------+
// | teams | parallel | * |
// | teams | for | + |
@@ -2759,6 +2796,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | teams | target simd | + |
// | teams | teams distribute| + |
+ // | teams | teams distribute| + |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | taskloop | parallel | * |
// | taskloop | for | + |
@@ -2803,6 +2842,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | taskloop | target simd | * |
// | taskloop | teams distribute| + |
+ // | taskloop | teams distribute| + |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | taskloop simd | parallel | |
// | taskloop simd | for | |
@@ -2848,6 +2889,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | taskloop simd | target simd | |
// | taskloop simd | teams distribute| |
+ // | taskloop simd | teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | distribute | parallel | * |
// | distribute | for | * |
@@ -2893,6 +2936,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | distribute | target simd | |
// | distribute | teams distribute| |
+ // | distribute | teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | distribute | parallel | * |
// | parallel for | | |
@@ -2969,6 +3014,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | parallel for | | |
// | distribute | teams distribute| |
// | parallel for | | |
+ // | distribute | teams distribute| |
+ // | parallel for | simd | |
// +------------------+-----------------+------------------------------------+
// | distribute | parallel | * |
// | parallel for simd| | |
@@ -3044,6 +3091,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | parallel for simd| | |
// | distribute | teams distribute| |
// | parallel for simd| | |
+ // | distribute | teams distribute| |
+ // | parallel for simd| simd | |
// +------------------+-----------------+------------------------------------+
// | distribute simd | parallel | * |
// | distribute simd | for | * |
@@ -3089,6 +3138,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | distribute simd | target simd | * |
// | distribute simd | teams distribute| * |
+ // | distribute simd | teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | target parallel | parallel | * |
// | for simd | | |
@@ -3164,6 +3215,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | for simd | | |
// | target parallel | teams distribute| * |
// | for simd | | |
+ // | target parallel | teams distribute| |
+ // | for simd | simd | |
// +------------------+-----------------+------------------------------------+
// | target simd | parallel | |
// | target simd | for | |
@@ -3209,6 +3262,8 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | | for simd | |
// | target simd | target simd | |
// | target simd | teams distribute| |
+ // | target simd | teams distribute| |
+ // | | simd | |
// +------------------+-----------------+------------------------------------+
// | teams distribute | parallel | |
// | teams distribute | for | |
@@ -3253,6 +3308,83 @@ static bool CheckNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
// | teams distribute | target parallel | |
// | | for simd | |
// | teams distribute | teams distribute| |
+ // | teams distribute | teams distribute| |
+ // | | simd | |
+ // +------------------+-----------------+------------------------------------+
+ // | teams distribute | parallel | |
+ // | simd | | |
+ // | teams distribute | for | |
+ // | simd | | |
+ // | teams distribute | for simd | |
+ // | simd | | |
+ // | teams distribute | master | |
+ // | simd | | |
+ // | teams distribute | critical | |
+ // | simd | | |
+ // | teams distribute | simd | |
+ // | simd | | |
+ // | teams distribute | sections | |
+ // | simd | | |
+ // | teams distribute | section | |
+ // | simd | | |
+ // | teams distribute | single | |
+ // | simd | | |
+ // | teams distribute | parallel for | |
+ // | simd | | |
+ // | teams distribute |parallel for simd| |
+ // | simd | | |
+ // | teams distribute |parallel sections| |
+ // | simd | | |
+ // | teams distribute | task | |
+ // | simd | | |
+ // | teams distribute | taskyield | |
+ // | simd | | |
+ // | teams distribute | barrier | |
+ // | simd | | |
+ // | teams distribute | taskwait | |
+ // | simd | | |
+ // | teams distribute | taskgroup | |
+ // | simd | | |
+ // | teams distribute | flush | |
+ // | simd | | |
+ // | teams distribute | ordered | + (with simd clause) |
+ // | simd | | |
+ // | teams distribute | atomic | |
+ // | simd | | |
+ // | teams distribute | target | |
+ // | simd | | |
+ // | teams distribute | target parallel | |
+ // | simd | | |
+ // | teams distribute | target parallel | |
+ // | simd | for | |
+ // | teams distribute | target enter | |
+ // | simd | data | |
+ // | teams distribute | target exit | |
+ // | simd | data | |
+ // | teams distribute | teams | |
+ // | simd | | |
+ // | teams distribute | cancellation | |
+ // | simd | point | |
+ // | teams distribute | cancel | |
+ // | simd | | |
+ // | teams distribute | taskloop | |
+ // | simd | | |
+ // | teams distribute | taskloop simd | |
+ // | simd | | |
+ // | teams distribute | distribute | |
+ // | simd | | |
+ // | teams distribute | distribute | |
+ // | simd | parallel for | |
+ // | teams distribute | distribute | |
+ // | simd |parallel for simd| |
+ // | teams distribute | distribute simd | |
+ // | simd | | |
+ // | teams distribute | target parallel | |
+ // | simd | for simd | |
+ // | teams distribute | teams distribute| |
+ // | simd | | |
+ // | teams distribute | teams distribute| |
+ // | simd | simd | |
// +------------------+-----------------+------------------------------------+
if (Stack->getCurScope()) {
auto ParentRegion = Stack->getParentDirective();
@@ -3773,6 +3905,10 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
Res = ActOnOpenMPTeamsDistributeDirective(
ClausesWithImplicit, AStmt, StartLoc, EndLoc, VarsWithInheritedDSA);
break;
+ case OMPD_teams_distribute_simd:
+ Res = ActOnOpenMPTeamsDistributeSimdDirective(
+ ClausesWithImplicit, AStmt, StartLoc, EndLoc, VarsWithInheritedDSA);
+ break;
case OMPD_declare_target:
case OMPD_end_declare_target:
case OMPD_threadprivate:
@@ -7465,6 +7601,55 @@ StmtResult Sema::ActOnOpenMPTeamsDistributeDirective(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
+StmtResult Sema::ActOnOpenMPTeamsDistributeSimdDirective(
+ ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
+ SourceLocation EndLoc,
+ llvm::DenseMap<ValueDecl *, Expr *> &VarsWithImplicitDSA) {
+ 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();
+
+ OMPLoopDirective::HelperExprs B;
+ // In presence of clause 'collapse' with number of loops, it will
+ // define the nested loops number.
+ unsigned NestedLoopCount =
+ CheckOpenMPLoop(OMPD_teams_distribute_simd,
+ getCollapseNumberExpr(Clauses),
+ nullptr /*ordered not a clause on distribute*/, AStmt,
+ *this, *DSAStack, VarsWithImplicitDSA, B);
+
+ if (NestedLoopCount == 0)
+ return StmtError();
+
+ assert((CurContext->isDependentContext() || B.builtAll()) &&
+ "omp teams distribute simd loop exprs were not built");
+
+ if (!CurContext->isDependentContext()) {
+ // Finalize the clauses that need pre-built expressions for CodeGen.
+ for (auto C : Clauses) {
+ if (auto *LC = dyn_cast<OMPLinearClause>(C))
+ if (FinishOpenMPLinearClause(*LC, cast<DeclRefExpr>(B.IterationVarRef),
+ B.NumIterations, *this, CurScope,
+ DSAStack))
+ return StmtError();
+ }
+ }
+
+ if (checkSimdlenSafelenSpecified(*this, Clauses))
+ return StmtError();
+
+ getCurFunction()->setHasBranchProtectedScope();
+ return OMPTeamsDistributeSimdDirective::Create(
+ Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
+}
+
OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
SourceLocation StartLoc,
SourceLocation LParenLoc,
OpenPOWER on IntegriCloud