forked from OSchip/llvm-project
[OPENMP]Simplify printing of declare variant attribute, NFC.
This commit is contained in:
parent
4965779f17
commit
87c3f4a5e0
|
@ -3335,20 +3335,40 @@ def OMPDeclareVariant : InheritableAttr {
|
||||||
}
|
}
|
||||||
// TODO: add printing of real context selectors.
|
// TODO: add printing of real context selectors.
|
||||||
OS << " match(";
|
OS << " match(";
|
||||||
|
int Used[OMP_CTX_SET_unknown] = {0};
|
||||||
for (unsigned I = 0, E = ctxSelectorSets_size(); I < E; ++I) {
|
for (unsigned I = 0, E = ctxSelectorSets_size(); I < E; ++I) {
|
||||||
auto CtxSet = static_cast<OpenMPContextSelectorSetKind>(
|
auto CtxSet = static_cast<OpenMPContextSelectorSetKind>(
|
||||||
*std::next(ctxSelectorSets_begin(), I));
|
*std::next(ctxSelectorSets_begin(), I));
|
||||||
auto Ctx = static_cast<OpenMPContextSelectorKind>(
|
if (Used[CtxSet])
|
||||||
*std::next(ctxSelectors_begin(), I));
|
continue;
|
||||||
assert(CtxSet != OMP_CTX_SET_unknown && Ctx != OMP_CTX_unknown &&
|
if (I > 0)
|
||||||
"Unknown context selector.");
|
OS << ",";
|
||||||
switch (CtxSet) {
|
switch (CtxSet) {
|
||||||
case OMP_CTX_SET_implementation:
|
case OMP_CTX_SET_implementation:
|
||||||
OS << "implementation={";
|
OS << "implementation={";
|
||||||
|
break;
|
||||||
|
case OMP_CTX_SET_device:
|
||||||
|
OS << "device={";
|
||||||
|
break;
|
||||||
|
case OMP_CTX_SET_unknown:
|
||||||
|
llvm_unreachable("Unknown context selector set.");
|
||||||
|
}
|
||||||
|
Used[CtxSet] = 1;
|
||||||
|
for (unsigned K = I, EK = ctxSelectors_size(); K < EK; ++K) {
|
||||||
|
auto CtxSetK = static_cast<OpenMPContextSelectorSetKind>(
|
||||||
|
*std::next(ctxSelectorSets_begin(), K));
|
||||||
|
if (CtxSet != CtxSetK)
|
||||||
|
continue;
|
||||||
|
if (K != I)
|
||||||
|
OS << ",";
|
||||||
|
auto Ctx = static_cast<OpenMPContextSelectorKind>(
|
||||||
|
*std::next(ctxSelectors_begin(), K));
|
||||||
switch (Ctx) {
|
switch (Ctx) {
|
||||||
case OMP_CTX_vendor:
|
case OMP_CTX_vendor:
|
||||||
|
assert(CtxSet == OMP_CTX_SET_implementation &&
|
||||||
|
"Expected implementation context selector set.");
|
||||||
OS << "vendor(";
|
OS << "vendor(";
|
||||||
printScore(OS, Policy, I);
|
printScore(OS, Policy, K);
|
||||||
if (implVendors_size() > 0) {
|
if (implVendors_size() > 0) {
|
||||||
OS << *implVendors(). begin();
|
OS << *implVendors(). begin();
|
||||||
for (StringRef VendorName : llvm::drop_begin(implVendors(), 1))
|
for (StringRef VendorName : llvm::drop_begin(implVendors(), 1))
|
||||||
|
@ -3357,16 +3377,8 @@ def OMPDeclareVariant : InheritableAttr {
|
||||||
OS << ")";
|
OS << ")";
|
||||||
break;
|
break;
|
||||||
case OMP_CTX_kind:
|
case OMP_CTX_kind:
|
||||||
llvm_unreachable("Unexpected context selector in implementation set.");
|
assert(CtxSet == OMP_CTX_SET_device &&
|
||||||
case OMP_CTX_unknown:
|
"Expected device context selector set.");
|
||||||
llvm_unreachable("Unknown context selector.");
|
|
||||||
}
|
|
||||||
OS << "}";
|
|
||||||
break;
|
|
||||||
case OMP_CTX_SET_device:
|
|
||||||
OS << "device={";
|
|
||||||
switch (Ctx) {
|
|
||||||
case OMP_CTX_kind:
|
|
||||||
OS << "kind(";
|
OS << "kind(";
|
||||||
if (deviceKinds_size() > 0) {
|
if (deviceKinds_size() > 0) {
|
||||||
OS << *deviceKinds().begin();
|
OS << *deviceKinds().begin();
|
||||||
|
@ -3375,18 +3387,11 @@ def OMPDeclareVariant : InheritableAttr {
|
||||||
}
|
}
|
||||||
OS << ")";
|
OS << ")";
|
||||||
break;
|
break;
|
||||||
case OMP_CTX_vendor:
|
|
||||||
llvm_unreachable("Unexpected context selector in device set.");
|
|
||||||
case OMP_CTX_unknown:
|
case OMP_CTX_unknown:
|
||||||
llvm_unreachable("Unknown context selector.");
|
llvm_unreachable("Unknown context selector.");
|
||||||
}
|
}
|
||||||
OS << "}";
|
|
||||||
break;
|
|
||||||
case OMP_CTX_SET_unknown:
|
|
||||||
llvm_unreachable("Unknown context selector set.");
|
|
||||||
}
|
}
|
||||||
if (I != E - 1)
|
OS << "}";
|
||||||
OS << ",";
|
|
||||||
}
|
}
|
||||||
OS << ")";
|
OS << ")";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue