================ @@ -1363,19 +1363,28 @@ static llvm::X86::ProcessorFeatures getFeature(StringRef Name) { // correct, so it asserts if the value is out of range. } -unsigned X86TargetInfo::multiVersionSortPriority(StringRef Name) const { - // Valid CPUs have a 'key feature' that compares just better than its key - // feature. - using namespace llvm::X86; - CPUKind Kind = parseArchX86(Name); - if (Kind != CK_None) { - ProcessorFeatures KeyFeature = getKeyFeature(Kind); - return (getFeaturePriority(KeyFeature) << 1) + 1; - } - - // Now we know we have a feature, so get its priority and shift it a few so - // that we have sufficient room for the CPUs (above). - return getFeaturePriority(getFeature(Name)) << 1; +unsigned X86TargetInfo::getFMVPriority(ArrayRef<StringRef> Features) const { + auto getPriority = [this](StringRef Feature) -> unsigned { + if (Feature.empty()) + return 0; + + // Valid CPUs have a 'key feature' that compares just better than its key + // feature. + using namespace llvm::X86; + CPUKind Kind = parseArchX86(Feature); + if (Kind != CK_None) { + ProcessorFeatures KeyFeature = getKeyFeature(Kind); + return (getFeaturePriority(KeyFeature) << 1) + 1; + } + // Now we know we have a feature, so get its priority and shift it a few so + // that we have sufficient room for the CPUs (above). + return getFeaturePriority(getFeature(Feature)) << 1; + }; + + unsigned Priority = 0; + for (StringRef Feature : Features) + Priority = std::max(Priority, getPriority(Feature)); ---------------- erichkeane wrote:
I don't think 'max' does the right thing here, does it? The whole point was to put together a mask representation that matches the `cpuid` call (Best we could!) that is the collection of all the features. That way you could have a list of features and have them be differentiated (that is, some of the FMV supports just a list of features, and we want to be able to differentiate between `high-feature, low-feature` and `high-feature, lower-feature`. https://github.com/llvm/llvm-project/pull/116257 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits