[clang] [llvm] [NFC][clang][FMV][TargetInfo] Refactor API for FMV feature priority. (PR #116257)
Alexandros Lamprineas via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 15 09:49:42 PST 2024
================
@@ -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));
----------------
labrinea wrote:
My aim was for this to be NFC. Does it look different from what TargetMVPriority did in the old code? The old multiVersionSortPriority is now the above lambda.
https://github.com/llvm/llvm-project/pull/116257
More information about the cfe-commits
mailing list