[clang] 5459a90 - [OPENMP]Simplify processing of context selectors, NFC.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 08:56:14 PST 2019
Author: Alexey Bataev
Date: 2019-11-22T11:53:06-05:00
New Revision: 5459a905c23c03fad68e80b2dff23ca1ca3b7c7c
URL: https://github.com/llvm/llvm-project/commit/5459a905c23c03fad68e80b2dff23ca1ca3b7c7c
DIFF: https://github.com/llvm/llvm-project/commit/5459a905c23c03fad68e80b2dff23ca1ca3b7c7c.diff
LOG: [OPENMP]Simplify processing of context selectors, NFC.
Added:
Modified:
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaOpenMP.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index c2d895b4ea4a..f80249483c7a 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -11138,33 +11138,22 @@ bool checkContext<OMP_CTX_SET_device, OMP_CTX_kind, CodeGenModule &>(
bool matchesContext(CodeGenModule &CGM,
const CompleteOMPContextSelectorData &ContextData) {
for (const OMPContextSelectorData &Data : ContextData) {
- switch (Data.CtxSet) {
- case OMP_CTX_SET_implementation:
- switch (Data.Ctx) {
- case OMP_CTX_vendor:
- if (!checkContext<OMP_CTX_SET_implementation, OMP_CTX_vendor>(Data))
- return false;
- break;
- case OMP_CTX_kind:
- case OMP_CTX_unknown:
- llvm_unreachable(
- "Unexpected context selector kind in implementation set.");
- }
+ switch (Data.Ctx) {
+ case OMP_CTX_vendor:
+ assert(Data.CtxSet == OMP_CTX_SET_implementation &&
+ "Expected implementation context selector set.");
+ if (!checkContext<OMP_CTX_SET_implementation, OMP_CTX_vendor>(Data))
+ return false;
break;
- case OMP_CTX_SET_device:
- switch (Data.Ctx) {
- case OMP_CTX_kind:
- if (!checkContext<OMP_CTX_SET_device, OMP_CTX_kind, CodeGenModule &>(
- Data, CGM))
- return false;
- break;
- case OMP_CTX_vendor:
- case OMP_CTX_unknown:
- llvm_unreachable("Unexpected context selector kind in device set.");
- }
+ case OMP_CTX_kind:
+ assert(Data.CtxSet == OMP_CTX_SET_device &&
+ "Expected device context selector set.");
+ if (!checkContext<OMP_CTX_SET_device, OMP_CTX_kind, CodeGenModule &>(Data,
+ CGM))
+ return false;
break;
- case OMP_CTX_SET_unknown:
- llvm_unreachable("Unexpected context selector set kind.");
+ case OMP_CTX_unknown:
+ llvm_unreachable("Unknown context selector kind.");
}
}
return true;
@@ -11184,32 +11173,21 @@ translateAttrToContextSelectorData(ASTContext &C,
Data.back().Ctx = Ctx;
const Expr *Score = *std::next(A->scores_begin(), I);
Data.back().Score = Score->EvaluateKnownConstInt(C);
- switch (CtxSet) {
- case OMP_CTX_SET_implementation:
- switch (Ctx) {
- case OMP_CTX_vendor:
- Data.back().Names =
- llvm::makeArrayRef(A->implVendors_begin(), A->implVendors_end());
- break;
- case OMP_CTX_kind:
- case OMP_CTX_unknown:
- llvm_unreachable(
- "Unexpected context selector kind in implementation set.");
- }
+ switch (Ctx) {
+ case OMP_CTX_vendor:
+ assert(CtxSet == OMP_CTX_SET_implementation &&
+ "Expected implementation context selector set.");
+ Data.back().Names =
+ llvm::makeArrayRef(A->implVendors_begin(), A->implVendors_end());
break;
- case OMP_CTX_SET_device:
- switch (Ctx) {
- case OMP_CTX_kind:
- Data.back().Names =
- llvm::makeArrayRef(A->deviceKinds_begin(), A->deviceKinds_end());
- break;
- case OMP_CTX_vendor:
- case OMP_CTX_unknown:
- llvm_unreachable("Unexpected context selector kind in device set.");
- }
+ case OMP_CTX_kind:
+ assert(CtxSet == OMP_CTX_SET_device &&
+ "Expected device context selector set.");
+ Data.back().Names =
+ llvm::makeArrayRef(A->deviceKinds_begin(), A->deviceKinds_end());
break;
- case OMP_CTX_SET_unknown:
- llvm_unreachable("Unexpected context selector set kind.");
+ case OMP_CTX_unknown:
+ llvm_unreachable("Unknown context selector kind.");
}
}
return Data;
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 53840d400164..59178fb671fb 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5404,29 +5404,19 @@ void Sema::ActOnOpenMPDeclareVariantDirective(
else
Score = ActOnIntegerConstant(SourceLocation(), 0).get();
}
- switch (CtxSet) {
- case OMP_CTX_SET_implementation:
- switch (Ctx) {
- 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.");
- }
+ switch (Ctx) {
+ case OMP_CTX_vendor:
+ assert(CtxSet == OMP_CTX_SET_implementation &&
+ "Expected implementation context selector set.");
+ ImplVendors.append(D.Names.begin(), D.Names.end());
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.");
- }
+ case OMP_CTX_kind:
+ assert(CtxSet == OMP_CTX_SET_device &&
+ "Expected device context selector set.");
+ DeviceKinds.append(D.Names.begin(), D.Names.end());
break;
- case OMP_CTX_SET_unknown:
- llvm_unreachable("Unexpected context selector set kind.");
+ case OMP_CTX_unknown:
+ llvm_unreachable("Unknown context selector kind.");
}
IsError = IsError || !Score;
CtxSets.push_back(CtxSet);
More information about the cfe-commits
mailing list