summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorCarlo Bertolli <cbertol@us.ibm.com>2016-07-13 15:37:16 +0000
committerCarlo Bertolli <cbertol@us.ibm.com>2016-07-13 15:37:16 +0000
commit2404b1719241456b7c4a3f8c5f9ece18eebcfa48 (patch)
treec0ab2da3adf82d8b9c5ff603fb8bdba0443bf95b /clang/lib/Sema/SemaOpenMP.cpp
parent48d83407602b15f80310bba0bdf5731ed194e092 (diff)
downloadbcm5719-llvm-2404b1719241456b7c4a3f8c5f9ece18eebcfa48.tar.gz
bcm5719-llvm-2404b1719241456b7c4a3f8c5f9ece18eebcfa48.zip
[OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'
http://reviews.llvm.org/D21904 This patch is similar to the implementation of 'private' clause: it adds a list of private pointers to be used within the target data region to store the device pointers returned by the runtime. Please refer to the following document for a full description of what the runtime witll return in this case (page 10 and 11): https://github.com/clang-omp/OffloadingDesign I am happy to answer any question related to the runtime interface to help reviewing this patch. llvm-svn: 275271
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 59c2f8bfc00..979c5215f11 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -7269,6 +7269,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
case OMPC_uniform:
case OMPC_to:
case OMPC_from:
+ case OMPC_use_device_ptr:
llvm_unreachable("Clause is not allowed.");
}
return Res;
@@ -7555,6 +7556,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
case OMPC_uniform:
case OMPC_to:
case OMPC_from:
+ case OMPC_use_device_ptr:
llvm_unreachable("Clause is not allowed.");
}
return Res;
@@ -7708,6 +7710,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
case OMPC_uniform:
case OMPC_to:
case OMPC_from:
+ case OMPC_use_device_ptr:
llvm_unreachable("Clause is not allowed.");
}
return Res;
@@ -7895,6 +7898,7 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
case OMPC_uniform:
case OMPC_to:
case OMPC_from:
+ case OMPC_use_device_ptr:
llvm_unreachable("Clause is not allowed.");
}
return Res;
@@ -8014,6 +8018,9 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
case OMPC_from:
Res = ActOnOpenMPFromClause(VarList, StartLoc, LParenLoc, EndLoc);
break;
+ case OMPC_use_device_ptr:
+ Res = ActOnOpenMPUseDevicePtrClause(VarList, StartLoc, LParenLoc, EndLoc);
+ break;
case OMPC_if:
case OMPC_final:
case OMPC_num_threads:
@@ -11616,3 +11623,39 @@ OMPClause *Sema::ActOnOpenMPFromClause(ArrayRef<Expr *> VarList,
MVLI.ProcessedVarList, MVLI.VarBaseDeclarations,
MVLI.VarComponents);
}
+
+OMPClause *Sema::ActOnOpenMPUseDevicePtrClause(ArrayRef<Expr *> VarList,
+ SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc) {
+ SmallVector<Expr *, 8> Vars;
+ for (auto &RefExpr : VarList) {
+ assert(RefExpr && "NULL expr in OpenMP use_device_ptr clause.");
+ SourceLocation ELoc;
+ SourceRange ERange;
+ Expr *SimpleRefExpr = RefExpr;
+ auto Res = getPrivateItem(*this, SimpleRefExpr, ELoc, ERange);
+ if (Res.second) {
+ // It will be analyzed later.
+ Vars.push_back(RefExpr);
+ }
+ ValueDecl *D = Res.first;
+ if (!D)
+ continue;
+
+ QualType Type = D->getType();
+ // item should be a pointer or reference to pointer
+ if (!Type.getNonReferenceType()->isPointerType()) {
+ Diag(ELoc, diag::err_omp_usedeviceptr_not_a_pointer)
+ << 0 << RefExpr->getSourceRange();
+ continue;
+ }
+ Vars.push_back(RefExpr->IgnoreParens());
+ }
+
+ if (Vars.empty())
+ return nullptr;
+
+ return OMPUseDevicePtrClause::Create(Context, StartLoc, LParenLoc, EndLoc,
+ Vars);
+}
OpenPOWER on IntegriCloud