@@ -797,17 +797,22 @@ pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
797797// These arrays represent the least-constraining feature that is required for vector types up to a
798798// certain size to have their "proper" ABI on each architecture.
799799// Note that they must be kept sorted by vector size.
800- const X86_FEATURES_FOR_CORRECT_VECTOR_ABI : &'static [(u64, &'static str)] =
800+ const X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI : &'static [(u64, &'static str)] =
801801 &[(128, "sse"), (256, "avx"), (512, "avx512f")]; // FIXME: might need changes for AVX10.
802- const AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "neon")];
802+ const AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
803+ &[(128, "neon")];
803804
804805// We might want to add "helium" too.
805- const ARM_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "neon")];
806+ const ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
807+ &[(128, "neon")];
806808
807- const POWERPC_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "altivec")];
808- const WASM_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "simd128")];
809- const S390X_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "vector")];
810- const RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[
809+ const POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
810+ &[(128, "altivec")];
811+ const WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
812+ &[(128, "simd128")];
813+ const S390X_FEATURES_FOR_CORRECT_FIXED_LEGNTH_VECTOR_ABI: &'static [(u64, &'static str)] =
814+ &[(128, "vector")];
815+ const RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[
811816 (32, "zvl32b"),
812817 (64, "zvl64b"),
813818 (128, "zvl128b"),
@@ -822,13 +827,16 @@ const RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[
822827 (65536, "zvl65536b"),
823828];
824829// Always error on SPARC, as the necessary target features cannot be enabled in Rust at the moment.
825- const SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[/*(64, "vis")*/];
830+ const SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
831+ &[/*(64, "vis")*/];
826832
827- const HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI : &'static [(u64, &'static str)] =
833+ const HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI : &'static [(u64, &'static str)] =
828834 &[/*(512, "hvx-length64b"),*/ (1024, "hvx-length128b")];
829- const MIPS_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "msa")];
830- const CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "vdspv1")];
831- const LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI: &'static [(u64, &'static str)] =
835+ const MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
836+ &[(128, "msa")];
837+ const CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
838+ &[(128, "vdspv1")];
839+ const LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] =
832840 &[(128, "lsx"), (256, "lasx")];
833841
834842#[derive(Copy, Clone, Debug)]
@@ -860,27 +868,38 @@ impl Target {
860868 }
861869 }
862870
863- pub fn features_for_correct_vector_abi (&self) -> &'static [(u64, &'static str)] {
871+ pub fn features_for_correct_fixed_length_vector_abi (&self) -> &'static [(u64, &'static str)] {
864872 match &*self.arch {
865- "x86" | "x86_64" => X86_FEATURES_FOR_CORRECT_VECTOR_ABI,
866- "aarch64" | "arm64ec" => AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI,
867- "arm" => ARM_FEATURES_FOR_CORRECT_VECTOR_ABI,
868- "powerpc" | "powerpc64" => POWERPC_FEATURES_FOR_CORRECT_VECTOR_ABI,
869- "loongarch32" | "loongarch64" => LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI,
870- "riscv32" | "riscv64" => RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI,
871- "wasm32" | "wasm64" => WASM_FEATURES_FOR_CORRECT_VECTOR_ABI,
872- "s390x" => S390X_FEATURES_FOR_CORRECT_VECTOR_ABI,
873- "sparc" | "sparc64" => SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI,
874- "hexagon" => HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI,
875- "mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES_FOR_CORRECT_VECTOR_ABI,
873+ "x86" | "x86_64" => X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
874+ "aarch64" | "arm64ec" => AARCH64_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
875+ "arm" => ARM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
876+ "powerpc" | "powerpc64" => POWERPC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
877+ "loongarch32" | "loongarch64" => LOONGARCH_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
878+ "riscv32" | "riscv64" => RISCV_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
879+ "wasm32" | "wasm64" => WASM_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
880+ "s390x" => S390X_FEATURES_FOR_CORRECT_FIXED_LEGNTH_VECTOR_ABI,
881+ "sparc" | "sparc64" => SPARC_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
882+ "hexagon" => HEXAGON_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI,
883+ "mips" | "mips32r6" | "mips64" | "mips64r6" => {
884+ MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI
885+ }
876886 "bpf" | "m68k" => &[], // no vector ABI
877- "csky" => CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI ,
887+ "csky" => CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI ,
878888 // FIXME: for some tier3 targets, we are overly cautious and always give warnings
879889 // when passing args in vector registers.
880890 _ => &[],
881891 }
882892 }
883893
894+ pub fn features_for_correct_scalable_vector_abi(&self) -> Option<&'static str> {
895+ match &*self.arch {
896+ "aarch64" | "arm64ec" => Some("sve"),
897+ "riscv32" | "riscv64" => todo!(),
898+ // Other targets have no scalable vectors.
899+ _ => None,
900+ }
901+ }
902+
884903 pub fn tied_target_features(&self) -> &'static [&'static [&'static str]] {
885904 match &*self.arch {
886905 "aarch64" | "arm64ec" => AARCH64_TIED_FEATURES,
0 commit comments