summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorAlexander Musman <alexander.musman@gmail.com>2014-05-27 15:12:19 +0000
committerAlexander Musman <alexander.musman@gmail.com>2014-05-27 15:12:19 +0000
commit8bd31e69a441bb7178134de57bc60c22be8e0f3c (patch)
tree03c7c30a004a5d9aa29ba6ec4ad5ba26d832ef2a /clang/lib/Sema
parentb355e8f604d3b26f15990b478a126b254a0fd9b8 (diff)
downloadbcm5719-llvm-8bd31e69a441bb7178134de57bc60c22be8e0f3c.tar.gz
bcm5719-llvm-8bd31e69a441bb7178134de57bc60c22be8e0f3c.zip
Parsing/Sema for OMPCollapseClause.
Actual usage in Sema for collapsing loops will in some future patch. llvm-svn: 209660
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp19
-rw-r--r--clang/lib/Sema/TreeTransform.h21
2 files changed, 40 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 18cfd43c804..39ec6327357 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -809,6 +809,9 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
case OMPC_safelen:
Res = ActOnOpenMPSafelenClause(Expr, StartLoc, LParenLoc, EndLoc);
break;
+ case OMPC_collapse:
+ Res = ActOnOpenMPCollapseClause(Expr, StartLoc, LParenLoc, EndLoc);
+ break;
case OMPC_default:
case OMPC_proc_bind:
case OMPC_private:
@@ -950,6 +953,20 @@ OMPClause *Sema::ActOnOpenMPSafelenClause(Expr *Len, SourceLocation StartLoc,
OMPSafelenClause(Safelen.take(), StartLoc, LParenLoc, EndLoc);
}
+OMPClause *Sema::ActOnOpenMPCollapseClause(Expr *Num, SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc) {
+ // OpenMP [2.8.1, simd construct, Description]
+ // The parameter of the collapse clause must be a constant
+ // positive integer expression.
+ ExprResult NumForLoops =
+ VerifyPositiveIntegerConstantInClause(Num, OMPC_collapse);
+ if (NumForLoops.isInvalid())
+ return nullptr;
+ return new (Context)
+ OMPCollapseClause(NumForLoops.take(), StartLoc, LParenLoc, EndLoc);
+}
+
OMPClause *Sema::ActOnOpenMPSimpleClause(OpenMPClauseKind Kind,
unsigned Argument,
SourceLocation ArgumentLoc,
@@ -971,6 +988,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(OpenMPClauseKind Kind,
case OMPC_if:
case OMPC_num_threads:
case OMPC_safelen:
+ case OMPC_collapse:
case OMPC_private:
case OMPC_firstprivate:
case OMPC_shared:
@@ -1086,6 +1104,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(OpenMPClauseKind Kind,
case OMPC_if:
case OMPC_num_threads:
case OMPC_safelen:
+ case OMPC_collapse:
case OMPC_default:
case OMPC_proc_bind:
case OMPC_threadprivate:
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index ef82b821469..3386b5bceeb 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -1333,6 +1333,17 @@ public:
return getSema().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc, EndLoc);
}
+ /// \brief Build a new OpenMP 'collapse' clause.
+ ///
+ /// By default, performs semantic analysis to build the new statement.
+ /// Subclasses may override this routine to provide different behavior.
+ OMPClause *RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc) {
+ return getSema().ActOnOpenMPCollapseClause(Num, StartLoc, LParenLoc,
+ EndLoc);
+ }
+
/// \brief Build a new OpenMP 'default' clause.
///
/// By default, performs semantic analysis to build the new statement.
@@ -6399,6 +6410,16 @@ TreeTransform<Derived>::TransformOMPSafelenClause(OMPSafelenClause *C) {
E.take(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
}
+template <typename Derived>
+OMPClause *
+TreeTransform<Derived>::TransformOMPCollapseClause(OMPCollapseClause *C) {
+ ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
+ if (E.isInvalid())
+ return 0;
+ return getDerived().RebuildOMPCollapseClause(
+ E.take(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
+}
+
template<typename Derived>
OMPClause *
TreeTransform<Derived>::TransformOMPDefaultClause(OMPDefaultClause *C) {
OpenPOWER on IntegriCloud