Skip to content

Commit c8f3f91

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 7776c5d commit c8f3f91

File tree

6 files changed

+77
-4
lines changed

6 files changed

+77
-4
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+5
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
233233
("aarch64", "pmuv3") => LLVMFeature::new("perfmon"),
234234
("aarch64", "paca") => LLVMFeature::new("pauth"),
235235
("aarch64", "pacg") => LLVMFeature::new("pauth"),
236+
("aarch64", "sve-b16b16") => LLVMFeature::new("b16b16"),
237+
("aarch64", "flagm2") => LLVMFeature::new("altnzcv"),
236238
// Rust ties fp and neon together.
237239
("aarch64", "neon") => {
238240
LLVMFeature::with_dependency("neon", TargetFeatureFoldStrength::Both("fp-armv8"))
@@ -260,6 +262,9 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
260262
("aarch64", "sve2") => {
261263
LLVMFeature::with_dependency("sve2", TargetFeatureFoldStrength::EnableOnly("neon"))
262264
}
265+
("aarch64", "sve2p1") => {
266+
LLVMFeature::with_dependency("sve2p1", TargetFeatureFoldStrength::EnableOnly("neon"))
267+
}
263268
("aarch64", "sve2-aes") => {
264269
LLVMFeature::with_dependency("sve2-aes", TargetFeatureFoldStrength::EnableOnly("neon"))
265270
}

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
@@ -355,6 +355,7 @@ symbols! {
355355
_task_context,
356356
a32,
357357
aarch64_target_feature,
358+
aarch64_unstable_target_feature,
358359
aarch64_ver_target_feature,
359360
abi,
360361
abi_amdgpu_kernel,

compiler/rustc_target/src/target_features.rs

+48-4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
9696
("bti", Stable),
9797
// FEAT_CRC
9898
("crc", Stable),
99+
// FEAT_CSSC
100+
("cssc", Unstable(sym::aarch64_unstable_target_feature)),
99101
// FEAT_DIT
100102
("dit", Stable),
101103
// FEAT_DotProd
@@ -104,20 +106,38 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
104106
("dpb", Stable),
105107
// FEAT_DPB2
106108
("dpb2", Stable),
109+
// FEAT_ECV
110+
("ecv", Unstable(sym::aarch64_unstable_target_feature)),
107111
// FEAT_F32MM
108112
("f32mm", Stable),
109113
// FEAT_F64MM
110114
("f64mm", Stable),
115+
// FEAT_FAMINMAX
116+
("faminmax", Unstable(sym::aarch64_unstable_target_feature)),
111117
// FEAT_FCMA
112118
("fcma", Stable),
113119
// FEAT_FHM
114120
("fhm", Stable),
115121
// FEAT_FLAGM
116122
("flagm", Stable),
123+
// FEAT_FLAGM2
124+
("flagm2", Unstable(sym::aarch64_unstable_target_feature)),
117125
// FEAT_FP16
118126
("fp16", Stable),
127+
// FEAT_FP8
128+
("fp8", Unstable(sym::aarch64_unstable_target_feature)),
129+
// FEAT_FP8DOT2
130+
("fp8dot2", Unstable(sym::aarch64_unstable_target_feature)),
131+
// FEAT_FP8DOT4
132+
("fp8dot4", Unstable(sym::aarch64_unstable_target_feature)),
133+
// FEAT_FP8FMA
134+
("fp8fma", Unstable(sym::aarch64_unstable_target_feature)),
135+
// FEAT_FPMR
136+
("fpmr", Unstable(sym::aarch64_unstable_target_feature)),
119137
// FEAT_FRINTTS
120138
("frintts", Stable),
139+
// FEAT_HBC
140+
("hbc", Unstable(sym::aarch64_unstable_target_feature)),
121141
// FEAT_I8MM
122142
("i8mm", Stable),
123143
// FEAT_JSCVT
@@ -126,6 +146,14 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
126146
("lor", Stable),
127147
// FEAT_LSE
128148
("lse", Stable),
149+
// FEAT_LSE128
150+
("lse128", Unstable(sym::aarch64_unstable_target_feature)),
151+
// FEAT_LSE2
152+
("lse2", Unstable(sym::aarch64_unstable_target_feature)),
153+
// FEAT_LUT
154+
("lut", Unstable(sym::aarch64_unstable_target_feature)),
155+
// FEAT_MOPS
156+
("mops", Unstable(sym::aarch64_unstable_target_feature)),
129157
// FEAT_MTE & FEAT_MTE2
130158
("mte", Stable),
131159
// FEAT_AdvSimd & FEAT_FP
@@ -138,14 +166,16 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
138166
("pan", Stable),
139167
// FEAT_PMUv3
140168
("pmuv3", Stable),
141-
// FEAT_RAND
169+
// FEAT_RNG
142170
("rand", Stable),
143171
// FEAT_RAS & FEAT_RASv1p1
144172
("ras", Stable),
145-
// FEAT_RCPC
173+
// FEAT_LRCPC
146174
("rcpc", Stable),
147-
// FEAT_RCPC2
175+
// FEAT_LRCPC2
148176
("rcpc2", Stable),
177+
// FEAT_LRCPC3
178+
("rcpc3", Unstable(sym::aarch64_unstable_target_feature)),
149179
// FEAT_RDM
150180
("rdm", Stable),
151181
// FEAT_SB
@@ -162,16 +192,20 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
162192
("ssbs", Stable),
163193
// FEAT_SVE
164194
("sve", Stable),
195+
// FEAT_SVE_B16B16 (SVE or SME Instructions)
196+
("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature)),
165197
// FEAT_SVE2
166198
("sve2", Stable),
167-
// FEAT_SVE2_AES
199+
// FEAT_SVE_AES & FEAT_SVE_PMULL128
168200
("sve2-aes", Stable),
169201
// FEAT_SVE2_BitPerm
170202
("sve2-bitperm", Stable),
171203
// FEAT_SVE2_SHA3
172204
("sve2-sha3", Stable),
173205
// FEAT_SVE2_SM4
174206
("sve2-sm4", Stable),
207+
// FEAT_SVE2p1
208+
("sve2p1", Unstable(sym::aarch64_unstable_target_feature)),
175209
// FEAT_TME
176210
("tme", Stable),
177211
("v8.1a", Unstable(sym::aarch64_ver_target_feature)),
@@ -181,8 +215,18 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
181215
("v8.5a", Unstable(sym::aarch64_ver_target_feature)),
182216
("v8.6a", Unstable(sym::aarch64_ver_target_feature)),
183217
("v8.7a", Unstable(sym::aarch64_ver_target_feature)),
218+
("v8.8a", Unstable(sym::aarch64_ver_target_feature)),
219+
("v8.9a", Unstable(sym::aarch64_ver_target_feature)),
220+
("v9.1a", Unstable(sym::aarch64_ver_target_feature)),
221+
("v9.2a", Unstable(sym::aarch64_ver_target_feature)),
222+
("v9.3a", Unstable(sym::aarch64_ver_target_feature)),
223+
("v9.4a", Unstable(sym::aarch64_ver_target_feature)),
224+
("v9.5a", Unstable(sym::aarch64_ver_target_feature)),
225+
("v9a", Unstable(sym::aarch64_ver_target_feature)),
184226
// FEAT_VHE
185227
("vh", Stable),
228+
// FEAT_WFxT
229+
("wfxt", Unstable(sym::aarch64_unstable_target_feature)),
186230
// tidy-alphabetical-end
187231
];
188232

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)