Skip to content

Commit 3ae72e3

Browse files
committed
ABI checks: add support for tier2 arches
See #131800 for the data collection behind this change.
1 parent 6689597 commit 3ae72e3

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

compiler/rustc_target/src/target_features.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,14 @@ pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
582582
const X86_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] =
583583
&[(128, "sse"), (256, "avx"), (512, "avx512f")];
584584
const AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "neon")];
585+
const ARM_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "neon")];
586+
const POWERPC_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "altivec")];
587+
const WASM_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "simd128")];
588+
const S390X_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "vector")];
589+
// Always warn on RISCV and SPARC, as the necessary target features cannot be enabled in Rust at
590+
// the moment.
591+
const RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[];
592+
const SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[];
585593

586594
impl super::spec::Target {
587595
pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, ImpliedFeatures)] {
@@ -606,9 +614,19 @@ impl super::spec::Target {
606614
// Returns None if we do not support ABI checks on the given target yet.
607615
pub fn features_for_correct_vector_abi(&self) -> Option<&'static [(u64, &'static str)]> {
608616
match &*self.arch {
617+
// Tier 1
609618
"x86" | "x86_64" => Some(X86_FEATURES_FOR_CORRECT_VECTOR_ABI),
610619
"aarch64" => Some(AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI),
611-
// FIXME: add support for non-tier1 architectures
620+
// Tier 2
621+
"arm64ec" => Some(AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI),
622+
"arm" => Some(ARM_FEATURES_FOR_CORRECT_VECTOR_ABI),
623+
"powerpc" | "powerpc64" => Some(POWERPC_FEATURES_FOR_CORRECT_VECTOR_ABI),
624+
"loongarch64" => Some(&[]), // on-stack ABI, so we complain about all by-val vectors
625+
"riscv32" | "riscv64" => Some(RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI),
626+
"wasm32" | "wasm64" => Some(WASM_FEATURES_FOR_CORRECT_VECTOR_ABI),
627+
"s390x" => Some(S390X_FEATURES_FOR_CORRECT_VECTOR_ABI),
628+
"sparc" | "sparc64" => Some(SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI),
629+
// FIXME: add support for non-tier2 architectures
612630
_ => None,
613631
}
614632
}

0 commit comments

Comments
 (0)