From 48bbd53d1964d8eefdcf1310d830aa64d299b1d5 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sat, 18 Jan 2025 13:44:24 +0100 Subject: [PATCH] basic infra for s390x vector intrinsics --- library/stdarch/ci/run.sh | 4 ++++ library/stdarch/crates/core_arch/src/lib.rs | 2 ++ library/stdarch/crates/core_arch/src/mod.rs | 14 +++++++++++++ .../stdarch/crates/core_arch/src/s390x/mod.rs | 5 +++++ .../crates/core_arch/src/s390x/vector.rs | 20 +++++++++++++++++++ .../stdarch/crates/simd-test-macro/src/lib.rs | 1 + 6 files changed, 46 insertions(+) create mode 100644 library/stdarch/crates/core_arch/src/s390x/mod.rs create mode 100644 library/stdarch/crates/core_arch/src/s390x/vector.rs diff --git a/library/stdarch/ci/run.sh b/library/stdarch/ci/run.sh index 28d53c537587..2ea550449233 100755 --- a/library/stdarch/ci/run.sh +++ b/library/stdarch/ci/run.sh @@ -124,6 +124,10 @@ case ${TARGET} in export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa" cargo_test "${PROFILE}" ;; + s390x*) + export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+vector" + cargo_test "${PROFILE}" + ;; powerpc64*) # We don't build the ppc 32-bit targets with these - these targets # are mostly unsupported for now. diff --git a/library/stdarch/crates/core_arch/src/lib.rs b/library/stdarch/crates/core_arch/src/lib.rs index 068bce1b75f7..acec8d3f7679 100644 --- a/library/stdarch/crates/core_arch/src/lib.rs +++ b/library/stdarch/crates/core_arch/src/lib.rs @@ -25,6 +25,7 @@ avx512_target_feature, mips_target_feature, powerpc_target_feature, + s390x_target_feature, loongarch_target_feature, wasm_target_feature, abi_unadjusted, @@ -69,6 +70,7 @@ feature( stdarch_arm_feature_detection, stdarch_powerpc_feature_detection, + stdarch_s390x_feature_detection, stdarch_loongarch_feature_detection ) )] diff --git a/library/stdarch/crates/core_arch/src/mod.rs b/library/stdarch/crates/core_arch/src/mod.rs index 7f5f81e378af..8f1da6ffe792 100644 --- a/library/stdarch/crates/core_arch/src/mod.rs +++ b/library/stdarch/crates/core_arch/src/mod.rs @@ -278,6 +278,16 @@ pub mod arch { pub mod loongarch64 { pub use crate::core_arch::loongarch64::*; } + + /// Platform-specific intrinsics for the `s390x` platform. + /// + /// See the [module documentation](../index.html) for more details. + #[cfg(any(target_arch = "s390x", doc))] + #[doc(cfg(target_arch = "s390x"))] + #[unstable(feature = "stdarch_s390x", issue = "1")] + pub mod s390x { + pub use crate::core_arch::s390x::*; + } } #[cfg(any(target_arch = "x86", target_arch = "x86_64", doc))] @@ -325,3 +335,7 @@ mod nvptx; #[cfg(any(target_arch = "loongarch64", doc))] #[doc(cfg(target_arch = "loongarch64"))] mod loongarch64; + +#[cfg(any(target_arch = "s390x", doc))] +#[doc(cfg(target_arch = "s390x"))] +mod s390x; diff --git a/library/stdarch/crates/core_arch/src/s390x/mod.rs b/library/stdarch/crates/core_arch/src/s390x/mod.rs new file mode 100644 index 000000000000..60996d6accf6 --- /dev/null +++ b/library/stdarch/crates/core_arch/src/s390x/mod.rs @@ -0,0 +1,5 @@ +//! `SystemZ` intrinsics + +mod vector; +#[unstable(feature = "stdarch_s390x", issue = "130869")] +pub use self::vector::*; diff --git a/library/stdarch/crates/core_arch/src/s390x/vector.rs b/library/stdarch/crates/core_arch/src/s390x/vector.rs new file mode 100644 index 000000000000..e7f5c55ce7c3 --- /dev/null +++ b/library/stdarch/crates/core_arch/src/s390x/vector.rs @@ -0,0 +1,20 @@ +#![allow(non_camel_case_types)] +#![allow(unused_imports)] + +use crate::{intrinsics::simd::*, mem::transmute}; + +#[cfg(test)] +use stdarch_test::assert_instr; + +#[cfg(test)] +mod tests { + use super::*; + + use std::mem::transmute; + + use crate::core_arch::simd::*; + use stdarch_test::simd_test; + + #[simd_test(enable = "vector")] + unsafe fn dummy() {} +} diff --git a/library/stdarch/crates/simd-test-macro/src/lib.rs b/library/stdarch/crates/simd-test-macro/src/lib.rs index e7291dd111cb..2855888cebdc 100644 --- a/library/stdarch/crates/simd-test-macro/src/lib.rs +++ b/library/stdarch/crates/simd-test-macro/src/lib.rs @@ -79,6 +79,7 @@ pub fn simd_test( "is_mips64_feature_detected" } "loongarch64" => "is_loongarch_feature_detected", + "s390x" => "is_s390x_feature_detected", t => panic!("unknown target: {t}"), }; let macro_test = Ident::new(macro_test, Span::call_site());