[clang] [llvm] [FMV][AIX] Implement target_clones part 2 (target-features) (PR #206786)
Wael Yehia via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 09:49:07 PDT 2026
================
@@ -727,18 +727,55 @@ 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:
+ // CPU specifications: 100-500 (pwr7=100, pwr8=200, ..., pwr11=500)
+ // For target-features, they can be divided into 3 categories:
+ // 1) non-CPU properties (e.g. invariant-function-descriptors); those cannot
+ // be tested at runtime, and are currently excluded from target_clones.
+ // 2) CPU properties that cannot be disabled (e.g. mma); these features map to
+ // CPUs directly:
+ // +feature => __builtin_cpu_supports("<minimum-cpu>")
+ // => true for CPU <minimum-cpu> and above.
+ // -feature => !__builtin_cpu_supports("<minimum-cpu>")
+ // => true for CPU <minimum-cpu-minus-one> and below.
+ // 3) CPU properties that can be disabled (e.g. vsx); those can map to CPUs
+ // directly for the positive requirement (same as (2));
+ // for the negative requirement checking the CPU is incorrect:
+ // target_clones(no-vsx, cpu=pwr8)
+ // should pick no-vsx when vsx is disabled at runtime, so we need to test
+ // negative form of category 3 first, and will only allow one negative form
+ // from this category on a target_clones.
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)
+#define PPC_AIX_CLONES_CPU(CPU_NAME, _, PRIORITY) .Case(CPU_NAME, PRIORITY)
+#include "llvm/TargetParser/PPCTargetParser.def"
+ .Default(0);
+ return llvm::APInt(32, Priority);
+ }
+
+ // Feature strings
+ if (!ParsedAttr.Features.empty()) {
+ StringRef Feature = ParsedAttr.Features[0];
----------------
w2yehia wrote:
how about
```
- if (!ParsedAttr.Features.empty()) {
+ if (ParsedAttr.Features.size() == 1) {
```
https://github.com/llvm/llvm-project/pull/206786
More information about the llvm-commits
mailing list