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.
|
||||
OS << " match(";
|
||||
int Used[OMP_CTX_SET_unknown] = {0};
|
||||
for (unsigned I = 0, E = ctxSelectorSets_size(); I < E; ++I) {
|
||||
auto CtxSet = static_cast<OpenMPContextSelectorSetKind>(
|
||||
*std::next(ctxSelectorSets_begin(), I));
|
||||
auto Ctx = static_cast<OpenMPContextSelectorKind>(
|
||||
*std::next(ctxSelectors_begin(), I));
|
||||
assert(CtxSet != OMP_CTX_SET_unknown && Ctx != OMP_CTX_unknown &&
|
||||
"Unknown context selector.");
|
||||
if (Used[CtxSet])
|
||||
continue;
|
||||
if (I > 0)
|
||||
OS << ",";
|
||||
switch (CtxSet) {
|
||||
case OMP_CTX_SET_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) {
|
||||
case OMP_CTX_vendor:
|
||||
assert(CtxSet == OMP_CTX_SET_implementation &&
|
||||
"Expected implementation context selector set.");
|
||||
OS << "vendor(";
|
||||
printScore(OS, Policy, I);
|
||||
printScore(OS, Policy, K);
|
||||
if (implVendors_size() > 0) {
|
||||
OS << *implVendors(). begin();
|
||||
for (StringRef VendorName : llvm::drop_begin(implVendors(), 1))
|
||||
|
@ -3357,16 +3377,8 @@ def OMPDeclareVariant : InheritableAttr {
|
|||
OS << ")";
|
||||
break;
|
||||
case OMP_CTX_kind:
|
||||
llvm_unreachable("Unexpected context selector in implementation set.");
|
||||
case OMP_CTX_unknown:
|
||||
llvm_unreachable("Unknown context selector.");
|
||||
}
|
||||
OS << "}";
|
||||
break;
|
||||
case OMP_CTX_SET_device:
|
||||
OS << "device={";
|
||||
switch (Ctx) {
|
||||
case OMP_CTX_kind:
|
||||
assert(CtxSet == OMP_CTX_SET_device &&
|
||||
"Expected device context selector set.");
|
||||
OS << "kind(";
|
||||
if (deviceKinds_size() > 0) {
|
||||
OS << *deviceKinds().begin();
|
||||
|
@ -3375,18 +3387,11 @@ def OMPDeclareVariant : InheritableAttr {
|
|||
}
|
||||
OS << ")";
|
||||
break;
|
||||
case OMP_CTX_vendor:
|
||||
llvm_unreachable("Unexpected context selector in device set.");
|
||||
case OMP_CTX_unknown:
|
||||
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 << ")";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue