summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2019-11-05 15:13:30 -0500
committerAlexey Bataev <a.bataev@hotmail.com>2019-11-21 13:28:11 -0500
commit4e8231b5cf0f5f62c7a51a857e29f5be5cb55734 (patch)
treebb8bf731c65aa91653f764e4797715edb0468780 /clang/lib/Sema/SemaOpenMP.cpp
parent70d173fb1f7b920c0a56fb5b0b6776985728716e (diff)
downloadbcm5719-llvm-4e8231b5cf0f5f62c7a51a857e29f5be5cb55734.tar.gz
bcm5719-llvm-4e8231b5cf0f5f62c7a51a857e29f5be5cb55734.zip
[OPENMP50]Add device/kind context selector support.
Summary: Added basic parsing/sema support for device/kind context selector. Reviewers: jdoerfert Subscribers: rampitec, aheejin, fedor.sergeev, simoncook, guansong, s.egerton, hfinkel, kkwli0, caomhin, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70245
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index d603d2139a0..45cac595004 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5364,7 +5364,7 @@ void Sema::ActOnOpenMPDeclareVariantDirective(
SmallVector<Expr *, 4> CtxScores;
SmallVector<unsigned, 4> CtxSets;
SmallVector<unsigned, 4> Ctxs;
- SmallVector<StringRef, 4> ImplVendors;
+ SmallVector<StringRef, 4> ImplVendors, DeviceKinds;
bool IsError = false;
for (const OMPCtxSelectorData &D : Data) {
OpenMPContextSelectorSetKind CtxSet = D.CtxSet;
@@ -5384,7 +5384,19 @@ void Sema::ActOnOpenMPDeclareVariantDirective(
Score = VerifyIntegerConstantExpression(Score).get();
}
} else {
- Score = ActOnIntegerConstant(SourceLocation(), 0).get();
+ // OpenMP 5.0, 2.3.3 Matching and Scoring Context Selectors.
+ // The kind, arch, and isa selectors are given the values 2^l, 2^(l+1) and
+ // 2^(l+2), respectively, where l is the number of traits in the construct
+ // set.
+ // TODO: implement correct logic for isa and arch traits.
+ // TODO: take the construct context set into account when it is
+ // implemented.
+ int L = 0; // Currently set the number of traits in construct set to 0,
+ // since the construct trait set in not supported yet.
+ if (CtxSet == OMP_CTX_SET_device && Ctx == OMP_CTX_kind)
+ Score = ActOnIntegerConstant(SourceLocation(), std::pow(2, L)).get();
+ else
+ Score = ActOnIntegerConstant(SourceLocation(), 0).get();
}
switch (CtxSet) {
case OMP_CTX_SET_implementation:
@@ -5392,6 +5404,17 @@ void Sema::ActOnOpenMPDeclareVariantDirective(
case OMP_CTX_vendor:
ImplVendors.append(D.Names.begin(), D.Names.end());
break;
+ case OMP_CTX_kind:
+ case OMP_CTX_unknown:
+ llvm_unreachable("Unexpected context selector kind.");
+ }
+ break;
+ case OMP_CTX_SET_device:
+ switch (Ctx) {
+ case OMP_CTX_kind:
+ DeviceKinds.append(D.Names.begin(), D.Names.end());
+ break;
+ case OMP_CTX_vendor:
case OMP_CTX_unknown:
llvm_unreachable("Unexpected context selector kind.");
}
@@ -5408,7 +5431,8 @@ void Sema::ActOnOpenMPDeclareVariantDirective(
auto *NewAttr = OMPDeclareVariantAttr::CreateImplicit(
Context, VariantRef, CtxScores.begin(), CtxScores.size(),
CtxSets.begin(), CtxSets.size(), Ctxs.begin(), Ctxs.size(),
- ImplVendors.begin(), ImplVendors.size(), SR);
+ ImplVendors.begin(), ImplVendors.size(), DeviceKinds.begin(),
+ DeviceKinds.size(), SR);
FD->addAttr(NewAttr);
}
}
OpenPOWER on IntegriCloud