Skip to content

Commit 7bbaa88

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 780b41c commit 7bbaa88

File tree

6 files changed

+77
-4
lines changed

6 files changed

+77
-4
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 5 additions & 0 deletions
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"))
@@ -261,6 +263,9 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
261263
("aarch64", "sve2") => {
262264
LLVMFeature::with_dependency("sve2", TargetFeatureFoldStrength::EnableOnly("neon"))
263265
}
266+
("aarch64", "sve2p1") => {
267+
LLVMFeature::with_dependency("sve2p1", TargetFeatureFoldStrength::EnableOnly("neon"))
268+
}
264269
("aarch64", "sve2-aes") => {
265270
LLVMFeature::with_dependency("sve2-aes", TargetFeatureFoldStrength::EnableOnly("neon"))
266271
}

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ declare_features! (
298298
// FIXME: Document these and merge with the list below.
299299

300300
// Unstable `#[target_feature]` directives.
301+
(unstable, aarch64_unstable_target_feature, "CURRENT_RUSTC_VERSION", Some(44839)),
301302
(unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)),
302303
(unstable, arm_target_feature, "1.27.0", Some(44839)),
303304
(unstable, avx512_target_feature, "1.27.0", Some(44839)),

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
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

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
9797
("bti", Stable),
9898
// FEAT_CRC
9999
("crc", Stable),
100+
// FEAT_CSSC
101+
("cssc", Unstable(sym::aarch64_unstable_target_feature)),
100102
// FEAT_DIT
101103
("dit", Stable),
102104
// FEAT_DotProd
@@ -105,20 +107,38 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
105107
("dpb", Stable),
106108
// FEAT_DPB2
107109
("dpb2", Stable),
110+
// FEAT_ECV
111+
("ecv", Unstable(sym::aarch64_unstable_target_feature)),
108112
// FEAT_F32MM
109113
("f32mm", Stable),
110114
// FEAT_F64MM
111115
("f64mm", Stable),
116+
// FEAT_FAMINMAX
117+
("faminmax", Unstable(sym::aarch64_unstable_target_feature)),
112118
// FEAT_FCMA
113119
("fcma", Stable),
114120
// FEAT_FHM
115121
("fhm", Stable),
116122
// FEAT_FLAGM
117123
("flagm", Stable),
124+
// FEAT_FLAGM2
125+
("flagm2", Unstable(sym::aarch64_unstable_target_feature)),
118126
// FEAT_FP16
119127
("fp16", Stable),
128+
// FEAT_FP8
129+
("fp8", Unstable(sym::aarch64_unstable_target_feature)),
130+
// FEAT_FP8DOT2
131+
("fp8dot2", Unstable(sym::aarch64_unstable_target_feature)),
132+
// FEAT_FP8DOT4
133+
("fp8dot4", Unstable(sym::aarch64_unstable_target_feature)),
134+
// FEAT_FP8FMA
135+
("fp8fma", Unstable(sym::aarch64_unstable_target_feature)),
136+
// FEAT_FPMR
137+
("fpmr", Unstable(sym::aarch64_unstable_target_feature)),
120138
// FEAT_FRINTTS
121139
("frintts", Stable),
140+
// FEAT_HBC
141+
("hbc", Unstable(sym::aarch64_unstable_target_feature)),
122142
// FEAT_I8MM
123143
("i8mm", Stable),
124144
// FEAT_JSCVT
@@ -127,6 +147,14 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
127147
("lor", Stable),
128148
// FEAT_LSE
129149
("lse", Stable),
150+
// FEAT_LSE128
151+
("lse128", Unstable(sym::aarch64_unstable_target_feature)),
152+
// FEAT_LSE2
153+
("lse2", Unstable(sym::aarch64_unstable_target_feature)),
154+
// FEAT_LUT
155+
("lut", Unstable(sym::aarch64_unstable_target_feature)),
156+
// FEAT_MOPS
157+
("mops", Unstable(sym::aarch64_unstable_target_feature)),
130158
// FEAT_MTE & FEAT_MTE2
131159
("mte", Stable),
132160
// FEAT_AdvSimd & FEAT_FP
@@ -139,14 +167,16 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
139167
("pan", Stable),
140168
// FEAT_PMUv3
141169
("pmuv3", Stable),
142-
// FEAT_RAND
170+
// FEAT_RNG
143171
("rand", Stable),
144172
// FEAT_RAS & FEAT_RASv1p1
145173
("ras", Stable),
146-
// FEAT_RCPC
174+
// FEAT_LRCPC
147175
("rcpc", Stable),
148-
// FEAT_RCPC2
176+
// FEAT_LRCPC2
149177
("rcpc2", Stable),
178+
// FEAT_LRCPC3
179+
("rcpc3", Unstable(sym::aarch64_unstable_target_feature)),
150180
// FEAT_RDM
151181
("rdm", Stable),
152182
// FEAT_SB
@@ -163,16 +193,20 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
163193
("ssbs", Stable),
164194
// FEAT_SVE
165195
("sve", Stable),
196+
// FEAT_SVE_B16B16 (SVE or SME Instructions)
197+
("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature)),
166198
// FEAT_SVE2
167199
("sve2", Stable),
168-
// FEAT_SVE2_AES
200+
// FEAT_SVE_AES & FEAT_SVE_PMULL128
169201
("sve2-aes", Stable),
170202
// FEAT_SVE2_BitPerm
171203
("sve2-bitperm", Stable),
172204
// FEAT_SVE2_SHA3
173205
("sve2-sha3", Stable),
174206
// FEAT_SVE2_SM4
175207
("sve2-sm4", Stable),
208+
// FEAT_SVE2p1
209+
("sve2p1", Unstable(sym::aarch64_unstable_target_feature)),
176210
// FEAT_TME
177211
("tme", Stable),
178212
("v8.1a", Unstable(sym::aarch64_ver_target_feature)),
@@ -182,8 +216,18 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability)] = &[
182216
("v8.5a", Unstable(sym::aarch64_ver_target_feature)),
183217
("v8.6a", Unstable(sym::aarch64_ver_target_feature)),
184218
("v8.7a", Unstable(sym::aarch64_ver_target_feature)),
219+
("v8.8a", Unstable(sym::aarch64_ver_target_feature)),
220+
("v8.9a", Unstable(sym::aarch64_ver_target_feature)),
221+
("v9.1a", Unstable(sym::aarch64_ver_target_feature)),
222+
("v9.2a", Unstable(sym::aarch64_ver_target_feature)),
223+
("v9.3a", Unstable(sym::aarch64_ver_target_feature)),
224+
("v9.4a", Unstable(sym::aarch64_ver_target_feature)),
225+
("v9.5a", Unstable(sym::aarch64_ver_target_feature)),
226+
("v9a", Unstable(sym::aarch64_ver_target_feature)),
185227
// FEAT_VHE
186228
("vh", Stable),
229+
// FEAT_WFxT
230+
("wfxt", Unstable(sym::aarch64_unstable_target_feature)),
187231
// tidy-alphabetical-end
188232
];
189233

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

Lines changed: 21 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)