Skip to content

Commit 703007f

Browse files
committed
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
1 parent 9337f7a commit 703007f

File tree

6 files changed

+75
-5
lines changed

6 files changed

+75
-5
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+2
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
234234
("aarch64", "pmuv3") => LLVMFeature::new("perfmon"),
235235
("aarch64", "paca") => LLVMFeature::new("pauth"),
236236
("aarch64", "pacg") => LLVMFeature::new("pauth"),
237+
("aarch64", "sve-b16b16") => LLVMFeature::new("b16b16"),
238+
("aarch64", "flagm2") => LLVMFeature::new("altnzcv"),
237239
// Rust ties fp and neon together.
238240
("aarch64", "neon") => {
239241
LLVMFeature::with_dependency("neon", TargetFeatureFoldStrength::Both("fp-armv8"))

compiler/rustc_feature/src/unstable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ declare_features! (
300300
// FIXME: Document these and merge with the list below.
301301

302302
// Unstable `#[target_feature]` directives.
303+
(unstable, aarch64_unstable_target_feature, "CURRENT_RUSTC_VERSION", Some(44839)),
303304
(unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)),
304305
(unstable, arm_target_feature, "1.27.0", Some(44839)),
305306
(unstable, avx512_target_feature, "1.27.0", Some(44839)),

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ symbols! {
356356
_task_context,
357357
a32,
358358
aarch64_target_feature,
359+
aarch64_unstable_target_feature,
359360
aarch64_ver_target_feature,
360361
abi,
361362
abi_amdgpu_kernel,

compiler/rustc_target/src/target_features.rs

+49-5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
9999
("bti", Stable, &[]),
100100
// FEAT_CRC
101101
("crc", Stable, &[]),
102+
// FEAT_CSSC
103+
("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
102104
// FEAT_DIT
103105
("dit", Stable, &[]),
104106
// FEAT_DotProd
@@ -107,21 +109,39 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
107109
("dpb", Stable, &[]),
108110
// FEAT_DPB2
109111
("dpb2", Stable, &["dpb"]),
112+
// FEAT_ECV
113+
("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
110114
// FEAT_F32MM
111115
("f32mm", Stable, &["sve"]),
112116
// FEAT_F64MM
113117
("f64mm", Stable, &["sve"]),
118+
// FEAT_FAMINMAX
119+
("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
114120
// FEAT_FCMA
115121
("fcma", Stable, &["neon"]),
116122
// FEAT_FHM
117123
("fhm", Stable, &["fp16"]),
118124
// FEAT_FLAGM
119125
("flagm", Stable, &[]),
126+
// FEAT_FLAGM2
127+
("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
120128
// FEAT_FP16
121129
// Rust ties FP and Neon: https://github.com/rust-lang/rust/pull/91608
122130
("fp16", Stable, &["neon"]),
131+
// FEAT_FP8
132+
("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
133+
// FEAT_FP8DOT2
134+
("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
135+
// FEAT_FP8DOT4
136+
("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
137+
// FEAT_FP8FMA
138+
("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
139+
// FEAT_FPMR
140+
("fpmr", Unstable(sym::aarch64_unstable_target_feature), &[]),
123141
// FEAT_FRINTTS
124142
("frintts", Stable, &[]),
143+
// FEAT_HBC
144+
("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
125145
// FEAT_I8MM
126146
("i8mm", Stable, &[]),
127147
// FEAT_JSCVT
@@ -131,6 +151,14 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
131151
("lor", Stable, &[]),
132152
// FEAT_LSE
133153
("lse", Stable, &[]),
154+
// FEAT_LSE128
155+
("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
156+
// FEAT_LSE2
157+
("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
158+
// FEAT_LUT
159+
("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
160+
// FEAT_MOPS
161+
("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
134162
// FEAT_MTE & FEAT_MTE2
135163
("mte", Stable, &[]),
136164
// FEAT_AdvSimd & FEAT_FP
@@ -143,14 +171,16 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
143171
("pan", Stable, &[]),
144172
// FEAT_PMUv3
145173
("pmuv3", Stable, &[]),
146-
// FEAT_RAND
174+
// FEAT_RNG
147175
("rand", Stable, &[]),
148176
// FEAT_RAS & FEAT_RASv1p1
149177
("ras", Stable, &[]),
150-
// FEAT_RCPC
178+
// FEAT_LRCPC
151179
("rcpc", Stable, &[]),
152-
// FEAT_RCPC2
180+
// FEAT_LRCPC2
153181
("rcpc2", Stable, &["rcpc"]),
182+
// FEAT_LRCPC3
183+
("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
154184
// FEAT_RDM
155185
("rdm", Stable, &["neon"]),
156186
// FEAT_SB
@@ -173,16 +203,20 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
173203
//
174204
// "For backwards compatibility, Neon and VFP are required in the latest architectures."
175205
("sve", Stable, &["neon"]),
206+
// FEAT_SVE_B16B16 (SVE or SME Instructions)
207+
("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
176208
// FEAT_SVE2
177209
("sve2", Stable, &["sve"]),
178-
// FEAT_SVE2_AES
210+
// FEAT_SVE_AES & FEAT_SVE_PMULL128
179211
("sve2-aes", Stable, &["sve2", "aes"]),
180212
// FEAT_SVE2_BitPerm
181213
("sve2-bitperm", Stable, &["sve2"]),
182214
// FEAT_SVE2_SHA3
183215
("sve2-sha3", Stable, &["sve2", "sha3"]),
184216
// FEAT_SVE2_SM4
185217
("sve2-sm4", Stable, &["sve2", "sm4"]),
218+
// FEAT_SVE2p1
219+
("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
186220
// FEAT_TME
187221
("tme", Stable, &[]),
188222
(
@@ -199,9 +233,19 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
199233
("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
200234
("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
201235
("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
202-
("v8.7a", Unstable(sym::aarch64_ver_target_feature), &[]),
236+
("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
237+
("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
238+
("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
239+
("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
240+
("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
241+
("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
242+
("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
243+
("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
244+
("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "sve2"]),
203245
// FEAT_VHE
204246
("vh", Stable, &[]),
247+
// FEAT_WFxT
248+
("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
205249
// tidy-alphabetical-end
206250
];
207251

library/std/tests/run-time-detect.rs

+21
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
55
feature(stdarch_arm_feature_detection)
66
)]
7+
#![cfg_attr(
8+
all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")),
9+
feature(stdarch_aarch64_feature_detection)
10+
)]
711
#![cfg_attr(
812
all(target_arch = "powerpc", target_os = "linux"),
913
feature(stdarch_powerpc_feature_detection)
@@ -36,42 +40,59 @@ fn aarch64_linux() {
3640
println!("bf16: {}", is_aarch64_feature_detected!("bf16"));
3741
println!("bti: {}", is_aarch64_feature_detected!("bti"));
3842
println!("crc: {}", is_aarch64_feature_detected!("crc"));
43+
println!("cssc: {}", is_aarch64_feature_detected!("cssc"));
3944
println!("dit: {}", is_aarch64_feature_detected!("dit"));
4045
println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
4146
println!("dpb2: {}", is_aarch64_feature_detected!("dpb2"));
4247
println!("dpb: {}", is_aarch64_feature_detected!("dpb"));
48+
println!("ecv: {}", is_aarch64_feature_detected!("ecv"));
4349
println!("f32mm: {}", is_aarch64_feature_detected!("f32mm"));
4450
println!("f64mm: {}", is_aarch64_feature_detected!("f64mm"));
51+
println!("faminmax: {}", is_aarch64_feature_detected!("faminmax"));
4552
println!("fcma: {}", is_aarch64_feature_detected!("fcma"));
4653
println!("fhm: {}", is_aarch64_feature_detected!("fhm"));
54+
println!("flagm2: {}", is_aarch64_feature_detected!("flagm2"));
4755
println!("flagm: {}", is_aarch64_feature_detected!("flagm"));
4856
println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
57+
println!("fp8: {}", is_aarch64_feature_detected!("fp8"));
58+
println!("fp8dot2: {}", is_aarch64_feature_detected!("fp8dot2"));
59+
println!("fp8dot4: {}", is_aarch64_feature_detected!("fp8dot4"));
60+
println!("fp8fma: {}", is_aarch64_feature_detected!("fp8fma"));
61+
println!("fpmr: {}", is_aarch64_feature_detected!("fpmr"));
4962
println!("frintts: {}", is_aarch64_feature_detected!("frintts"));
63+
println!("hbc: {}", is_aarch64_feature_detected!("hbc"));
5064
println!("i8mm: {}", is_aarch64_feature_detected!("i8mm"));
5165
println!("jsconv: {}", is_aarch64_feature_detected!("jsconv"));
66+
println!("lse128: {}", is_aarch64_feature_detected!("lse128"));
5267
println!("lse2: {}", is_aarch64_feature_detected!("lse2"));
5368
println!("lse: {}", is_aarch64_feature_detected!("lse"));
69+
println!("lut: {}", is_aarch64_feature_detected!("lut"));
70+
println!("mops: {}", is_aarch64_feature_detected!("mops"));
5471
println!("mte: {}", is_aarch64_feature_detected!("mte"));
5572
println!("neon: {}", is_aarch64_feature_detected!("neon"));
5673
println!("paca: {}", is_aarch64_feature_detected!("paca"));
5774
println!("pacg: {}", is_aarch64_feature_detected!("pacg"));
5875
println!("pmull: {}", is_aarch64_feature_detected!("pmull"));
5976
println!("rand: {}", is_aarch64_feature_detected!("rand"));
6077
println!("rcpc2: {}", is_aarch64_feature_detected!("rcpc2"));
78+
println!("rcpc3: {}", is_aarch64_feature_detected!("rcpc3"));
6179
println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
6280
println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
6381
println!("sb: {}", is_aarch64_feature_detected!("sb"));
6482
println!("sha2: {}", is_aarch64_feature_detected!("sha2"));
6583
println!("sha3: {}", is_aarch64_feature_detected!("sha3"));
6684
println!("sm4: {}", is_aarch64_feature_detected!("sm4"));
6785
println!("ssbs: {}", is_aarch64_feature_detected!("ssbs"));
86+
println!("sve-b16b16: {}", is_aarch64_feature_detected!("sve-b16b16"));
6887
println!("sve2-aes: {}", is_aarch64_feature_detected!("sve2-aes"));
6988
println!("sve2-bitperm: {}", is_aarch64_feature_detected!("sve2-bitperm"));
7089
println!("sve2-sha3: {}", is_aarch64_feature_detected!("sve2-sha3"));
7190
println!("sve2-sm4: {}", is_aarch64_feature_detected!("sve2-sm4"));
7291
println!("sve2: {}", is_aarch64_feature_detected!("sve2"));
92+
println!("sve2p1: {}", is_aarch64_feature_detected!("sve2p1"));
7393
println!("sve: {}", is_aarch64_feature_detected!("sve"));
7494
println!("tme: {}", is_aarch64_feature_detected!("tme"));
95+
println!("wfxt: {}", is_aarch64_feature_detected!("wfxt"));
7596
// tidy-alphabetical-end
7697
}
7798

tests/ui/target-feature/gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// gate-test-ermsb_target_feature
1818
// gate-test-bpf_target_feature
1919
// gate-test-aarch64_ver_target_feature
20+
// gate-test-aarch64_unstable_target_feature
2021
// gate-test-csky_target_feature
2122
// gate-test-loongarch_target_feature
2223
// gate-test-lahfsahf_target_feature

0 commit comments

Comments
 (0)