[clang] [llvm] [FMV][AIX] Implement target_clones part 2 (target-features) (PR #206786)
Wael Yehia via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 14 18:55:15 PDT 2026
================
@@ -719,17 +719,37 @@ llvm::APInt PPCTargetInfo::getFMVPriority(ArrayRef<StringRef> Features) const {
return llvm::APInt(32, 0);
assert(Features.size() == 1 && "one feature/cpu per clone on PowerPC");
ParsedTargetAttr ParsedAttr = parseTargetAttr(Features[0]);
+
+ // Priority scheme: Features requiring POWERXX are higher than cpu=pwrXX
+ // but lower than cpu=pwr(XX+1). This ensures proper version selection.
+ // Example: mma (POWER10 feature) > cpu=pwr10 > power9-vector (POWER9 feature)
+
if (!ParsedAttr.CPU.empty()) {
int Priority = llvm::StringSwitch<int>(ParsedAttr.CPU)
- .Case("pwr7", 1)
- .Case("pwr8", 2)
- .Case("pwr9", 3)
- .Case("pwr10", 4)
- .Case("pwr11", 5)
+ .Case("pwr7", 100)
+ .Case("pwr8", 200)
+ .Case("pwr9", 300)
+ .Case("pwr10", 400)
+ .Case("pwr11", 500)
+ .Default(0);
+ return llvm::APInt(32, Priority);
+ }
+
+ // Feature strings: priority between cpu=pwrN and cpu=pwr(N+1)
+ if (!ParsedAttr.Features.empty()) {
+ StringRef Feature = ParsedAttr.Features[0];
+ // Remove leading '+' or '-'
+ if (Feature.starts_with("+") || Feature.starts_with("-"))
+ Feature = Feature.drop_front(1);
+
+ int Priority = llvm::StringSwitch<int>(Feature)
+#define PPC_AIX_CLONES_FEATURE(FEATURE_NAME, _, PRIORITY) \
+ .Case(FEATURE_NAME, PRIORITY)
+#include "llvm/TargetParser/PPCTargetParser.def"
.Default(0);
return llvm::APInt(32, Priority);
}
- assert(false && "unimplemented");
+
----------------
w2yehia wrote:
you're right, this should be unreachable too.
https://github.com/llvm/llvm-project/pull/206786
More information about the cfe-commits
mailing list