[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)

Jon Roelofs via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 11:24:53 PDT 2024


================
@@ -19,3 +19,19 @@
 // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s
 // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s
 // ARM64-GENERICV81A: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic"{{.*}} "-target-feature" "+v8.1a"{{.*}} "-target-feature" "+neon"
+
+// ===== Architecture extensions =====
+
+// RUN: %clang -target aarch64 -march=armv8.1-a --print-enabled-extensions 2>&1 | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s
+// ARCH-EXTENSION: FEAT_ETE
+// ARCH-EXTENSION: FEAT_LOR
+// ARCH-EXTENSION: FEAT_TRBE
+// ARCH-EXTENSION: FEAT_VHE
+// ARCH-EXTENSION: FEAT_PAN
+// ARCH-EXTENSION: FEAT_CRC32
+// FIXME: FEAT_FP is optional from v8.0a
+// ARCH-EXTENSION: FEAT_FP
+// ARCH-EXTENSION: FEAT_LSE
+// ARCH-EXTENSION: FEAT_RDM
+// FIXME: FEAT_AdvSIMD is optional from v8.0a
----------------
jroelofs wrote:

> The same idea has been applied to SVE2 in Armv9 (although that one has become more debatable).

Yep, this is a problem for `apple-m4`, which does not have support for SVE/SVE2, but because of that choice on LLVM's part, we have to consider it v8.7 instead. This has a compounding problem when users want to write preprocessor version checks for newer features: they often can't use feature test macros because they don't exist yet, and the version numbered ones don't help them either, since we have to report the mcpu as being that older version.

To fix this without disrupting existing software in the wild, I think we need to make the `HasVX_Ya` feature groups _not_ apply their `DefaultExts` to processors that they're included on, and instead only transitively include the `implied_features` sets. That, or add support for "negative" features, which I think comes with its own can of worms.

https://github.com/llvm/llvm-project/pull/95805


More information about the llvm-commits mailing list