rustc_target: Add various aarch64 features

Add various aarch64 features already supported by LLVM and Linux.

The features are marked as unstable using a newly added symbol, i.e.
aarch64_unstable_target_feature.

Additionally include some comment fixes to ensure consistency of
feature names with the Arm ARM and support for architecture version
target features up to v9.5a.

This commit adds compiler support for the following features:

- FEAT_CSSC
- FEAT_ECV
- FEAT_FAMINMAX
- FEAT_FLAGM2
- FEAT_FP8
- FEAT_FP8DOT2
- FEAT_FP8DOT4
- FEAT_FP8FMA
- FEAT_FPMR
- FEAT_HBC
- FEAT_LSE128
- FEAT_LSE2
- FEAT_LUT
- FEAT_MOPS
- FEAT_LRCPC3
- FEAT_SVE_B16B16
- FEAT_SVE2p1
- FEAT_WFxT
This commit is contained in:
Kajetan Puchalski 2024-06-14 18:05:09 +01:00
parent ae9f5019f9
commit 4f847bd326
6 changed files with 75 additions and 5 deletions

View File

@ -234,6 +234,8 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a
("aarch64", "pmuv3") => LLVMFeature::new("perfmon"), ("aarch64", "pmuv3") => LLVMFeature::new("perfmon"),
("aarch64", "paca") => LLVMFeature::new("pauth"), ("aarch64", "paca") => LLVMFeature::new("pauth"),
("aarch64", "pacg") => LLVMFeature::new("pauth"), ("aarch64", "pacg") => LLVMFeature::new("pauth"),
("aarch64", "sve-b16b16") => LLVMFeature::new("b16b16"),
("aarch64", "flagm2") => LLVMFeature::new("altnzcv"),
// Rust ties fp and neon together. // Rust ties fp and neon together.
("aarch64", "neon") => { ("aarch64", "neon") => {
LLVMFeature::with_dependency("neon", TargetFeatureFoldStrength::Both("fp-armv8")) LLVMFeature::with_dependency("neon", TargetFeatureFoldStrength::Both("fp-armv8"))

View File

@ -302,6 +302,7 @@ pub fn internal(&self, feature: Symbol) -> bool {
// FIXME: Document these and merge with the list below. // FIXME: Document these and merge with the list below.
// Unstable `#[target_feature]` directives. // Unstable `#[target_feature]` directives.
(unstable, aarch64_unstable_target_feature, "CURRENT_RUSTC_VERSION", Some(44839)),
(unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)), (unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)),
(unstable, arm_target_feature, "1.27.0", Some(44839)), (unstable, arm_target_feature, "1.27.0", Some(44839)),
(unstable, avx512_target_feature, "1.27.0", Some(44839)), (unstable, avx512_target_feature, "1.27.0", Some(44839)),

View File

@ -356,6 +356,7 @@
_task_context, _task_context,
a32, a32,
aarch64_target_feature, aarch64_target_feature,
aarch64_unstable_target_feature,
aarch64_ver_target_feature, aarch64_ver_target_feature,
abi, abi,
abi_amdgpu_kernel, abi_amdgpu_kernel,

View File

@ -99,6 +99,8 @@ pub fn is_stable(self) -> bool {
("bti", Stable, &[]), ("bti", Stable, &[]),
// FEAT_CRC // FEAT_CRC
("crc", Stable, &[]), ("crc", Stable, &[]),
// FEAT_CSSC
("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_DIT // FEAT_DIT
("dit", Stable, &[]), ("dit", Stable, &[]),
// FEAT_DotProd // FEAT_DotProd
@ -107,21 +109,39 @@ pub fn is_stable(self) -> bool {
("dpb", Stable, &[]), ("dpb", Stable, &[]),
// FEAT_DPB2 // FEAT_DPB2
("dpb2", Stable, &["dpb"]), ("dpb2", Stable, &["dpb"]),
// FEAT_ECV
("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_F32MM // FEAT_F32MM
("f32mm", Stable, &["sve"]), ("f32mm", Stable, &["sve"]),
// FEAT_F64MM // FEAT_F64MM
("f64mm", Stable, &["sve"]), ("f64mm", Stable, &["sve"]),
// FEAT_FAMINMAX
("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_FCMA // FEAT_FCMA
("fcma", Stable, &["neon"]), ("fcma", Stable, &["neon"]),
// FEAT_FHM // FEAT_FHM
("fhm", Stable, &["fp16"]), ("fhm", Stable, &["fp16"]),
// FEAT_FLAGM // FEAT_FLAGM
("flagm", Stable, &[]), ("flagm", Stable, &[]),
// FEAT_FLAGM2
("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_FP16 // FEAT_FP16
// Rust ties FP and Neon: https://github.com/rust-lang/rust/pull/91608 // Rust ties FP and Neon: https://github.com/rust-lang/rust/pull/91608
("fp16", Stable, &["neon"]), ("fp16", Stable, &["neon"]),
// FEAT_FP8
("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
// FEAT_FP8DOT2
("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
// FEAT_FP8DOT4
("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
// FEAT_FP8FMA
("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
// FEAT_FPMR
("fpmr", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_FRINTTS // FEAT_FRINTTS
("frintts", Stable, &[]), ("frintts", Stable, &[]),
// FEAT_HBC
("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_I8MM // FEAT_I8MM
("i8mm", Stable, &[]), ("i8mm", Stable, &[]),
// FEAT_JSCVT // FEAT_JSCVT
@ -131,6 +151,14 @@ pub fn is_stable(self) -> bool {
("lor", Stable, &[]), ("lor", Stable, &[]),
// FEAT_LSE // FEAT_LSE
("lse", Stable, &[]), ("lse", Stable, &[]),
// FEAT_LSE128
("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
// FEAT_LSE2
("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_LUT
("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_MOPS
("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_MTE & FEAT_MTE2 // FEAT_MTE & FEAT_MTE2
("mte", Stable, &[]), ("mte", Stable, &[]),
// FEAT_AdvSimd & FEAT_FP // FEAT_AdvSimd & FEAT_FP
@ -143,14 +171,16 @@ pub fn is_stable(self) -> bool {
("pan", Stable, &[]), ("pan", Stable, &[]),
// FEAT_PMUv3 // FEAT_PMUv3
("pmuv3", Stable, &[]), ("pmuv3", Stable, &[]),
// FEAT_RAND // FEAT_RNG
("rand", Stable, &[]), ("rand", Stable, &[]),
// FEAT_RAS & FEAT_RASv1p1 // FEAT_RAS & FEAT_RASv1p1
("ras", Stable, &[]), ("ras", Stable, &[]),
// FEAT_RCPC // FEAT_LRCPC
("rcpc", Stable, &[]), ("rcpc", Stable, &[]),
// FEAT_RCPC2 // FEAT_LRCPC2
("rcpc2", Stable, &["rcpc"]), ("rcpc2", Stable, &["rcpc"]),
// FEAT_LRCPC3
("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
// FEAT_RDM // FEAT_RDM
("rdm", Stable, &["neon"]), ("rdm", Stable, &["neon"]),
// FEAT_SB // FEAT_SB
@ -173,9 +203,11 @@ pub fn is_stable(self) -> bool {
// //
// "For backwards compatibility, Neon and VFP are required in the latest architectures." // "For backwards compatibility, Neon and VFP are required in the latest architectures."
("sve", Stable, &["neon"]), ("sve", Stable, &["neon"]),
// FEAT_SVE_B16B16 (SVE or SME Instructions)
("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
// FEAT_SVE2 // FEAT_SVE2
("sve2", Stable, &["sve"]), ("sve2", Stable, &["sve"]),
// FEAT_SVE2_AES // FEAT_SVE_AES & FEAT_SVE_PMULL128
("sve2-aes", Stable, &["sve2", "aes"]), ("sve2-aes", Stable, &["sve2", "aes"]),
// FEAT_SVE2_BitPerm // FEAT_SVE2_BitPerm
("sve2-bitperm", Stable, &["sve2"]), ("sve2-bitperm", Stable, &["sve2"]),
@ -183,6 +215,8 @@ pub fn is_stable(self) -> bool {
("sve2-sha3", Stable, &["sve2", "sha3"]), ("sve2-sha3", Stable, &["sve2", "sha3"]),
// FEAT_SVE2_SM4 // FEAT_SVE2_SM4
("sve2-sm4", Stable, &["sve2", "sm4"]), ("sve2-sm4", Stable, &["sve2", "sm4"]),
// FEAT_SVE2p1
("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
// FEAT_TME // FEAT_TME
("tme", Stable, &[]), ("tme", Stable, &[]),
( (
@ -199,9 +233,19 @@ pub fn is_stable(self) -> bool {
("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]), ("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]), ("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]), ("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
("v8.7a", Unstable(sym::aarch64_ver_target_feature), &[]), ("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "sve2"]),
// FEAT_VHE // FEAT_VHE
("vh", Stable, &[]), ("vh", Stable, &[]),
// FEAT_WFxT
("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];

View File

@ -4,6 +4,10 @@
all(target_arch = "arm", any(target_os = "linux", target_os = "android")), all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
feature(stdarch_arm_feature_detection) feature(stdarch_arm_feature_detection)
)] )]
#![cfg_attr(
all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")),
feature(stdarch_aarch64_feature_detection)
)]
#![cfg_attr( #![cfg_attr(
all(target_arch = "powerpc", target_os = "linux"), all(target_arch = "powerpc", target_os = "linux"),
feature(stdarch_powerpc_feature_detection) feature(stdarch_powerpc_feature_detection)
@ -36,21 +40,34 @@ fn aarch64_linux() {
println!("bf16: {}", is_aarch64_feature_detected!("bf16")); println!("bf16: {}", is_aarch64_feature_detected!("bf16"));
println!("bti: {}", is_aarch64_feature_detected!("bti")); println!("bti: {}", is_aarch64_feature_detected!("bti"));
println!("crc: {}", is_aarch64_feature_detected!("crc")); println!("crc: {}", is_aarch64_feature_detected!("crc"));
println!("cssc: {}", is_aarch64_feature_detected!("cssc"));
println!("dit: {}", is_aarch64_feature_detected!("dit")); println!("dit: {}", is_aarch64_feature_detected!("dit"));
println!("dotprod: {}", is_aarch64_feature_detected!("dotprod")); println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
println!("dpb2: {}", is_aarch64_feature_detected!("dpb2")); println!("dpb2: {}", is_aarch64_feature_detected!("dpb2"));
println!("dpb: {}", is_aarch64_feature_detected!("dpb")); println!("dpb: {}", is_aarch64_feature_detected!("dpb"));
println!("ecv: {}", is_aarch64_feature_detected!("ecv"));
println!("f32mm: {}", is_aarch64_feature_detected!("f32mm")); println!("f32mm: {}", is_aarch64_feature_detected!("f32mm"));
println!("f64mm: {}", is_aarch64_feature_detected!("f64mm")); println!("f64mm: {}", is_aarch64_feature_detected!("f64mm"));
println!("faminmax: {}", is_aarch64_feature_detected!("faminmax"));
println!("fcma: {}", is_aarch64_feature_detected!("fcma")); println!("fcma: {}", is_aarch64_feature_detected!("fcma"));
println!("fhm: {}", is_aarch64_feature_detected!("fhm")); println!("fhm: {}", is_aarch64_feature_detected!("fhm"));
println!("flagm2: {}", is_aarch64_feature_detected!("flagm2"));
println!("flagm: {}", is_aarch64_feature_detected!("flagm")); println!("flagm: {}", is_aarch64_feature_detected!("flagm"));
println!("fp16: {}", is_aarch64_feature_detected!("fp16")); println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
println!("fp8: {}", is_aarch64_feature_detected!("fp8"));
println!("fp8dot2: {}", is_aarch64_feature_detected!("fp8dot2"));
println!("fp8dot4: {}", is_aarch64_feature_detected!("fp8dot4"));
println!("fp8fma: {}", is_aarch64_feature_detected!("fp8fma"));
println!("fpmr: {}", is_aarch64_feature_detected!("fpmr"));
println!("frintts: {}", is_aarch64_feature_detected!("frintts")); println!("frintts: {}", is_aarch64_feature_detected!("frintts"));
println!("hbc: {}", is_aarch64_feature_detected!("hbc"));
println!("i8mm: {}", is_aarch64_feature_detected!("i8mm")); println!("i8mm: {}", is_aarch64_feature_detected!("i8mm"));
println!("jsconv: {}", is_aarch64_feature_detected!("jsconv")); println!("jsconv: {}", is_aarch64_feature_detected!("jsconv"));
println!("lse128: {}", is_aarch64_feature_detected!("lse128"));
println!("lse2: {}", is_aarch64_feature_detected!("lse2")); println!("lse2: {}", is_aarch64_feature_detected!("lse2"));
println!("lse: {}", is_aarch64_feature_detected!("lse")); println!("lse: {}", is_aarch64_feature_detected!("lse"));
println!("lut: {}", is_aarch64_feature_detected!("lut"));
println!("mops: {}", is_aarch64_feature_detected!("mops"));
println!("mte: {}", is_aarch64_feature_detected!("mte")); println!("mte: {}", is_aarch64_feature_detected!("mte"));
println!("neon: {}", is_aarch64_feature_detected!("neon")); println!("neon: {}", is_aarch64_feature_detected!("neon"));
println!("paca: {}", is_aarch64_feature_detected!("paca")); println!("paca: {}", is_aarch64_feature_detected!("paca"));
@ -58,6 +75,7 @@ fn aarch64_linux() {
println!("pmull: {}", is_aarch64_feature_detected!("pmull")); println!("pmull: {}", is_aarch64_feature_detected!("pmull"));
println!("rand: {}", is_aarch64_feature_detected!("rand")); println!("rand: {}", is_aarch64_feature_detected!("rand"));
println!("rcpc2: {}", is_aarch64_feature_detected!("rcpc2")); println!("rcpc2: {}", is_aarch64_feature_detected!("rcpc2"));
println!("rcpc3: {}", is_aarch64_feature_detected!("rcpc3"));
println!("rcpc: {}", is_aarch64_feature_detected!("rcpc")); println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
println!("rdm: {}", is_aarch64_feature_detected!("rdm")); println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
println!("sb: {}", is_aarch64_feature_detected!("sb")); println!("sb: {}", is_aarch64_feature_detected!("sb"));
@ -65,13 +83,16 @@ fn aarch64_linux() {
println!("sha3: {}", is_aarch64_feature_detected!("sha3")); println!("sha3: {}", is_aarch64_feature_detected!("sha3"));
println!("sm4: {}", is_aarch64_feature_detected!("sm4")); println!("sm4: {}", is_aarch64_feature_detected!("sm4"));
println!("ssbs: {}", is_aarch64_feature_detected!("ssbs")); println!("ssbs: {}", is_aarch64_feature_detected!("ssbs"));
println!("sve-b16b16: {}", is_aarch64_feature_detected!("sve-b16b16"));
println!("sve2-aes: {}", is_aarch64_feature_detected!("sve2-aes")); println!("sve2-aes: {}", is_aarch64_feature_detected!("sve2-aes"));
println!("sve2-bitperm: {}", is_aarch64_feature_detected!("sve2-bitperm")); println!("sve2-bitperm: {}", is_aarch64_feature_detected!("sve2-bitperm"));
println!("sve2-sha3: {}", is_aarch64_feature_detected!("sve2-sha3")); println!("sve2-sha3: {}", is_aarch64_feature_detected!("sve2-sha3"));
println!("sve2-sm4: {}", is_aarch64_feature_detected!("sve2-sm4")); println!("sve2-sm4: {}", is_aarch64_feature_detected!("sve2-sm4"));
println!("sve2: {}", is_aarch64_feature_detected!("sve2")); println!("sve2: {}", is_aarch64_feature_detected!("sve2"));
println!("sve2p1: {}", is_aarch64_feature_detected!("sve2p1"));
println!("sve: {}", is_aarch64_feature_detected!("sve")); println!("sve: {}", is_aarch64_feature_detected!("sve"));
println!("tme: {}", is_aarch64_feature_detected!("tme")); println!("tme: {}", is_aarch64_feature_detected!("tme"));
println!("wfxt: {}", is_aarch64_feature_detected!("wfxt"));
// tidy-alphabetical-end // tidy-alphabetical-end
} }

View File

@ -17,6 +17,7 @@
// gate-test-ermsb_target_feature // gate-test-ermsb_target_feature
// gate-test-bpf_target_feature // gate-test-bpf_target_feature
// gate-test-aarch64_ver_target_feature // gate-test-aarch64_ver_target_feature
// gate-test-aarch64_unstable_target_feature
// gate-test-csky_target_feature // gate-test-csky_target_feature
// gate-test-loongarch_target_feature // gate-test-loongarch_target_feature
// gate-test-lahfsahf_target_feature // gate-test-lahfsahf_target_feature