summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorMichael Wong <fraggamuffin@gmail.com>2015-08-07 16:16:36 +0000
committerMichael Wong <fraggamuffin@gmail.com>2015-08-07 16:16:36 +0000
commite710d5459ee7fc4ffac35e89651611b1498bb1d3 (patch)
treef588d60e0fc73c26fa8b9b65e74042d976236b45 /clang/lib/Sema/SemaOpenMP.cpp
parent827a40b94420680063477bef5dadf9e69c2140b2 (diff)
downloadbcm5719-llvm-e710d5459ee7fc4ffac35e89651611b1498bb1d3.tar.gz
bcm5719-llvm-e710d5459ee7fc4ffac35e89651611b1498bb1d3.zip
This patch commits OpenMP 4 target device clauses
This is committed on behalf of Kelvin Li http://reviews.llvm.org/D11469?id=31227 llvm-svn: 244325
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 57ebb38a70c..03e7d237188 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4511,6 +4511,9 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
case OMPC_ordered:
Res = ActOnOpenMPOrderedClause(StartLoc, EndLoc, LParenLoc, Expr);
break;
+ case OMPC_device:
+ Res = ActOnOpenMPDeviceClause(Expr, StartLoc, LParenLoc, EndLoc);
+ break;
case OMPC_default:
case OMPC_proc_bind:
case OMPC_schedule:
@@ -4774,6 +4777,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
case OMPC_capture:
case OMPC_seq_cst:
case OMPC_depend:
+ case OMPC_device:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -4895,6 +4899,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
case OMPC_capture:
case OMPC_seq_cst:
case OMPC_depend:
+ case OMPC_device:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -5018,6 +5023,7 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
case OMPC_threadprivate:
case OMPC_flush:
case OMPC_depend:
+ case OMPC_device:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -5128,6 +5134,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
case OMPC_update:
case OMPC_capture:
case OMPC_seq_cst:
+ case OMPC_device:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -6722,3 +6729,28 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind,
return OMPDependClause::Create(Context, StartLoc, LParenLoc, EndLoc, DepKind,
DepLoc, ColonLoc, Vars);
}
+
+OMPClause *Sema::ActOnOpenMPDeviceClause(Expr *Device, SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc) {
+ Expr *ValExpr = Device;
+ if (!ValExpr->isTypeDependent() && !ValExpr->isValueDependent() &&
+ !ValExpr->isInstantiationDependent()) {
+ SourceLocation Loc = ValExpr->getExprLoc();
+ ExprResult Value = PerformOpenMPImplicitIntegerConversion(Loc, ValExpr);
+ if (Value.isInvalid())
+ return nullptr;
+
+ // OpenMP [2.9.1, Restrictions]
+ // The device expression must evaluate to a non-negative integer value.
+ llvm::APSInt Result;
+ if (Value.get()->isIntegerConstantExpr(Result, Context) &&
+ Result.isSigned() && !Result.isStrictlyPositive()) {
+ Diag(Loc, diag::err_omp_negative_expression_in_clause)
+ << "device" << ValExpr->getSourceRange();
+ return nullptr;
+ }
+ }
+
+ return new (Context) OMPDeviceClause(ValExpr, StartLoc, LParenLoc, EndLoc);
+}
OpenPOWER on IntegriCloud