summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/StmtOpenMP.cpp53
-rw-r--r--clang/lib/AST/StmtPrinter.cpp6
-rw-r--r--clang/lib/AST/StmtProfile.cpp5
-rw-r--r--clang/lib/Basic/OpenMPKinds.cpp23
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp4
-rw-r--r--clang/lib/CodeGen/CGStmtOpenMP.cpp13
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h2
-rw-r--r--clang/lib/Parse/ParseOpenMP.cpp9
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp187
-rw-r--r--clang/lib/Sema/TreeTransform.h11
-rw-r--r--clang/lib/Serialization/ASTReaderStmt.cpp13
-rw-r--r--clang/lib/Serialization/ASTWriterStmt.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Core/ExprEngine.cpp1
13 files changed, 324 insertions, 9 deletions
diff --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index 946f1d182f9..8eee7e41a5f 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -1350,3 +1350,56 @@ OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
return new (Mem) OMPTeamsDistributeDirective(CollapsedNum, NumClauses);
}
+
+OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
+ const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
+ unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
+ const HelperExprs &Exprs) {
+ unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
+ alignof(OMPClause *));
+ void *Mem =
+ C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
+ sizeof(Stmt *) *
+ numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
+ OMPTeamsDistributeSimdDirective *Dir =
+ new (Mem) OMPTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
+ Clauses.size());
+ Dir->setClauses(Clauses);
+ Dir->setAssociatedStmt(AssociatedStmt);
+ Dir->setIterationVariable(Exprs.IterationVarRef);
+ Dir->setLastIteration(Exprs.LastIteration);
+ Dir->setCalcLastIteration(Exprs.CalcLastIteration);
+ Dir->setPreCond(Exprs.PreCond);
+ Dir->setCond(Exprs.Cond);
+ Dir->setInit(Exprs.Init);
+ Dir->setInc(Exprs.Inc);
+ Dir->setIsLastIterVariable(Exprs.IL);
+ Dir->setLowerBoundVariable(Exprs.LB);
+ Dir->setUpperBoundVariable(Exprs.UB);
+ Dir->setStrideVariable(Exprs.ST);
+ Dir->setEnsureUpperBound(Exprs.EUB);
+ Dir->setNextLowerBound(Exprs.NLB);
+ Dir->setNextUpperBound(Exprs.NUB);
+ Dir->setNumIterations(Exprs.NumIterations);
+ Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
+ Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
+ Dir->setCounters(Exprs.Counters);
+ Dir->setPrivateCounters(Exprs.PrivateCounters);
+ Dir->setInits(Exprs.Inits);
+ Dir->setUpdates(Exprs.Updates);
+ Dir->setFinals(Exprs.Finals);
+ Dir->setPreInits(Exprs.PreInits);
+ return Dir;
+}
+
+OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
+ const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
+ EmptyShell) {
+ unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
+ alignof(OMPClause *));
+ void *Mem =
+ C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
+ sizeof(Stmt *) *
+ numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
+ return new (Mem) OMPTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
+}
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 0b103f96a5c..e80598469da 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1209,6 +1209,12 @@ void StmtPrinter::VisitOMPTeamsDistributeDirective(
PrintOMPExecutableDirective(Node);
}
+void StmtPrinter::VisitOMPTeamsDistributeSimdDirective(
+ OMPTeamsDistributeSimdDirective *Node) {
+ Indent() << "#pragma omp teams distribute simd ";
+ PrintOMPExecutableDirective(Node);
+}
+
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index cf965aa0284..5a27934276a 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -733,6 +733,11 @@ void StmtProfiler::VisitOMPTeamsDistributeDirective(
VisitOMPLoopDirective(S);
}
+void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
+ const OMPTeamsDistributeSimdDirective *S) {
+ VisitOMPLoopDirective(S);
+}
+
void StmtProfiler::VisitExpr(const Expr *S) {
VisitStmt(S);
}
diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 4b41ab186d4..fa4b75cce47 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -630,6 +630,16 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
break;
}
break;
+ case OMPD_teams_distribute_simd:
+ switch (CKind) {
+#define OPENMP_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \
+ case OMPC_##Name: \
+ return true;
+#include "clang/Basic/OpenMPKinds.def"
+ default:
+ break;
+ }
+ break;
case OMPD_declare_target:
case OMPD_end_declare_target:
case OMPD_unknown:
@@ -656,7 +666,7 @@ bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
DKind == OMPD_distribute_parallel_for_simd ||
DKind == OMPD_distribute_simd ||
DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute;
+ DKind == OMPD_teams_distribute || DKind == OMPD_teams_distribute_simd;
// TODO add next directives.
}
@@ -699,7 +709,8 @@ bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
}
bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
- return DKind == OMPD_teams || DKind == OMPD_teams_distribute;
+ return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
+ DKind == OMPD_teams_distribute_simd;
// TODO add next directives.
}
@@ -707,7 +718,8 @@ bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
return DKind == OMPD_simd || DKind == OMPD_for_simd ||
DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd || DKind == OMPD_target_simd;
+ DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
+ DKind == OMPD_teams_distribute_simd;
// TODO add next directives.
}
@@ -720,7 +732,7 @@ bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind) {
bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) {
return isOpenMPNestingDistributeDirective(Kind) ||
- Kind == OMPD_teams_distribute;
+ Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd;
// TODO add next directives.
}
@@ -741,5 +753,6 @@ bool clang::isOpenMPTaskingDirective(OpenMPDirectiveKind Kind) {
bool clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind) {
return Kind == OMPD_distribute_parallel_for ||
Kind == OMPD_distribute_parallel_for_simd ||
- Kind == OMPD_distribute_simd || Kind == OMPD_teams_distribute;
+ Kind == OMPD_distribute_simd || Kind == OMPD_teams_distribute ||
+ Kind == OMPD_teams_distribute_simd;
}
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 9447ae56c7a..b4f309353fb 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -301,6 +301,10 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
case Stmt::OMPTeamsDistributeDirectiveClass:
EmitOMPTeamsDistributeDirective(cast<OMPTeamsDistributeDirective>(*S));
break;
+ case Stmt::OMPTeamsDistributeSimdDirectiveClass:
+ EmitOMPTeamsDistributeSimdDirective(
+ cast<OMPTeamsDistributeSimdDirective>(*S));
+ break;
}
}
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 7c2cfd5909c..b09d8c8807d 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1959,6 +1959,19 @@ void CodeGenFunction::EmitOMPTeamsDistributeDirective(
});
}
+void CodeGenFunction::EmitOMPTeamsDistributeSimdDirective(
+ const OMPTeamsDistributeSimdDirective &S) {
+ OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
+ CGM.getOpenMPRuntime().emitInlinedDirective(
+ *this, OMPD_teams_distribute_simd,
+ [&S](CodeGenFunction &CGF, PrePostActionTy &) {
+ OMPLoopScope PreInitScope(CGF, S);
+ CGF.EmitStmt(
+ cast<CapturedStmt>(S.getAssociatedStmt())->getCapturedStmt());
+ });
+}
+
+
/// \brief Emit a helper variable and return corresponding lvalue.
static LValue EmitOMPHelperVar(CodeGenFunction &CGF,
const DeclRefExpr *Helper) {
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index a63cce65f58..2782f4b1670 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -2526,6 +2526,8 @@ public:
const OMPTargetParallelForSimdDirective &S);
void EmitOMPTargetSimdDirective(const OMPTargetSimdDirective &S);
void EmitOMPTeamsDistributeDirective(const OMPTeamsDistributeDirective &S);
+ void
+ EmitOMPTeamsDistributeSimdDirective(const OMPTeamsDistributeSimdDirective &S);
/// Emit outlined function for the target directive.
static std::pair<llvm::Function * /*OutlinedFn*/,
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 4edac71549e..4f418e3946d 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -109,7 +109,8 @@ static OpenMPDirectiveKind ParseOpenMPDirectiveKind(Parser &P) {
{ OMPD_target, OMPD_simd, OMPD_target_simd },
{ OMPD_target_parallel, OMPD_for, OMPD_target_parallel_for },
{ OMPD_target_parallel_for, OMPD_simd, OMPD_target_parallel_for_simd },
- { OMPD_teams, OMPD_distribute, OMPD_teams_distribute }
+ { OMPD_teams, OMPD_distribute, OMPD_teams_distribute },
+ { OMPD_teams_distribute, OMPD_simd, OMPD_teams_distribute_simd }
};
enum { CancellationPoint = 0, DeclareReduction = 1, TargetData = 2 };
auto Tok = P.getCurToken();
@@ -742,6 +743,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
case OMPD_target_parallel_for_simd:
case OMPD_target_simd:
case OMPD_teams_distribute:
+ case OMPD_teams_distribute_simd:
Diag(Tok, diag::err_omp_unexpected_directive)
<< getOpenMPDirectiveName(DKind);
break;
@@ -776,7 +778,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
/// 'target update' | 'distribute parallel for' |
/// 'distribute paralle for simd' | 'distribute simd' |
/// 'target parallel for simd' | 'target simd' |
-/// 'teams distribute' {clause}
+/// 'teams distribute' | 'teams distribute simd' {clause}
/// annot_pragma_openmp_end
///
StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
@@ -886,7 +888,8 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
case OMPD_distribute_simd:
case OMPD_target_parallel_for_simd:
case OMPD_target_simd:
- case OMPD_teams_distribute: {
+ case OMPD_teams_distribute:
+ case OMPD_teams_distribute_simd: {
ConsumeToken();
// Parse directive name of the 'critical' directive if any.
if (DKind == OMPD_critical) {
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 237331da4a3..f4abf4ffcfd 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,
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index c54e194e838..a17bcd3b9d9 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -7683,6 +7683,17 @@ StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeDirective(
return Res;
}
+template <typename Derived>
+StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeSimdDirective(
+ OMPTeamsDistributeSimdDirective *D) {
+ DeclarationNameInfo DirName;
+ getDerived().getSema().StartOpenMPDSABlock(
+ OMPD_teams_distribute_simd, DirName, nullptr, D->getLocStart());
+ StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
+ getDerived().getSema().EndOpenMPDSABlock(Res.get());
+ return Res;
+}
+
//===----------------------------------------------------------------------===//
// OpenMP clause transformation
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index a87a054f116..0930ff8a944 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2871,6 +2871,11 @@ void ASTStmtReader::VisitOMPTeamsDistributeDirective(
VisitOMPLoopDirective(D);
}
+void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
+ OMPTeamsDistributeSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
//===----------------------------------------------------------------------===//
// ASTReader Implementation
//===----------------------------------------------------------------------===//
@@ -3598,6 +3603,14 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
break;
}
+ case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
+ unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
+ unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
+ CollapsedNum, Empty);
+ break;
+ }
+
case EXPR_CXX_OPERATOR_CALL:
S = new (Context) CXXOperatorCallExpr(Context, Empty);
break;
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index ddb69d966a7..8dc4a7ec32f 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2520,6 +2520,12 @@ void ASTStmtWriter::VisitOMPTeamsDistributeDirective(
Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE;
}
+void ASTStmtWriter::VisitOMPTeamsDistributeSimdDirective(
+ OMPTeamsDistributeSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE;
+}
+
//===----------------------------------------------------------------------===//
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index f24e0714afe..6a3cdb2f76f 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -848,6 +848,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::OMPTargetParallelForSimdDirectiveClass:
case Stmt::OMPTargetSimdDirectiveClass:
case Stmt::OMPTeamsDistributeDirectiveClass:
+ case Stmt::OMPTeamsDistributeSimdDirectiveClass:
llvm_unreachable("Stmt should not be in analyzer evaluation loop");
case Stmt::ObjCSubscriptRefExprClass:
OpenPOWER on IntegriCloud