From b3f57e98af9bd2210a4ba672354382d38a2bb542 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Sun, 29 Oct 2023 12:53:36 -0700 Subject: [PATCH] [simd] Add support for new x86[_64] types (#571) Release 0.7.20. --- Cargo.toml | 8 ++++---- src/lib.rs | 26 +++++++++++++++++++------- zerocopy-derive/Cargo.toml | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 51eca9b38a..96a060aad4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ [package] edition = "2018" name = "zerocopy" -version = "0.7.19" +version = "0.7.20" authors = ["Joshua Liebow-Feeser "] description = "Utilities for zero-copy parsing and serialization" license = "BSD-2-Clause OR Apache-2.0 OR MIT" @@ -45,7 +45,7 @@ simd-nightly = ["simd"] __internal_use_only_features_that_work_on_stable = ["alloc", "derive", "simd"] [dependencies] -zerocopy-derive = { version = "=0.7.19", path = "zerocopy-derive", optional = true } +zerocopy-derive = { version = "=0.7.20", path = "zerocopy-derive", optional = true } [dependencies.byteorder] version = "1.3" @@ -56,7 +56,7 @@ optional = true # zerocopy-derive remain equal, even if the 'derive' feature isn't used. # See: https://github.com/matklad/macro-dep-test [target.'cfg(any())'.dependencies] -zerocopy-derive = { version = "=0.7.19", path = "zerocopy-derive" } +zerocopy-derive = { version = "=0.7.20", path = "zerocopy-derive" } [dev-dependencies] assert_matches = "1.5" @@ -71,4 +71,4 @@ testutil = { path = "testutil" } # CI test failures. trybuild = { version = "=1.0.85", features = ["diff"] } # In tests, unlike in production, zerocopy-derive is not optional -zerocopy-derive = { version = "=0.7.19", path = "zerocopy-derive" } +zerocopy-derive = { version = "=0.7.20", path = "zerocopy-derive" } diff --git a/src/lib.rs b/src/lib.rs index 72fb52055b..56b4cf46be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1930,8 +1930,8 @@ mod simd { // target/feature combinations don't emit any impls // and thus don't use this macro. macro_rules! simd_arch_mod { - ($arch:ident, $($typ:ident),*) => { - mod $arch { + ($arch:ident, $mod:ident, $($typ:ident),*) => { + mod $mod { use core::arch::$arch::{$($typ),*}; use crate::*; @@ -1946,13 +1946,18 @@ mod simd { } #[cfg(target_arch = "x86")] - simd_arch_mod!(x86, __m128, __m128d, __m128i, __m256, __m256d, __m256i); + simd_arch_mod!(x86, x86, __m128, __m128d, __m128i, __m256, __m256d, __m256i); + #[cfg(all(feature = "simd-nightly", target_arch = "x86"))] + simd_arch_mod!(x86, x86_nightly, __m512bh, __m512, __m512d, __m512i); #[cfg(target_arch = "x86_64")] - simd_arch_mod!(x86_64, __m128, __m128d, __m128i, __m256, __m256d, __m256i); + simd_arch_mod!(x86_64, x86_64, __m128, __m128d, __m128i, __m256, __m256d, __m256i); + #[cfg(all(feature = "simd-nightly", target_arch = "x86_64"))] + simd_arch_mod!(x86_64, x86_64_nightly, __m512bh, __m512, __m512d, __m512i); #[cfg(target_arch = "wasm32")] - simd_arch_mod!(wasm32, v128); + simd_arch_mod!(wasm32, wasm32, v128); #[cfg(all(feature = "simd-nightly", target_arch = "powerpc"))] simd_arch_mod!( + powerpc, powerpc, vector_bool_long, vector_double, @@ -1961,6 +1966,7 @@ mod simd { ); #[cfg(all(feature = "simd-nightly", target_arch = "powerpc64"))] simd_arch_mod!( + powerpc64, powerpc64, vector_bool_long, vector_double, @@ -1970,7 +1976,7 @@ mod simd { #[cfg(target_arch = "aarch64")] #[rustfmt::skip] simd_arch_mod!( - aarch64, float32x2_t, float32x4_t, float64x1_t, float64x2_t, int8x8_t, int8x8x2_t, + aarch64, aarch64, float32x2_t, float32x4_t, float64x1_t, float64x2_t, int8x8_t, int8x8x2_t, int8x8x3_t, int8x8x4_t, int8x16_t, int8x16x2_t, int8x16x3_t, int8x16x4_t, int16x4_t, int16x8_t, int32x2_t, int32x4_t, int64x1_t, int64x2_t, poly8x8_t, poly8x8x2_t, poly8x8x3_t, poly8x8x4_t, poly8x16_t, poly8x16x2_t, poly8x16x3_t, poly8x16x4_t, poly16x4_t, poly16x8_t, @@ -1980,7 +1986,7 @@ mod simd { ); #[cfg(all(feature = "simd-nightly", target_arch = "arm"))] #[rustfmt::skip] - simd_arch_mod!(arm, int8x4_t, uint8x4_t); + simd_arch_mod!(arm, arm, int8x4_t, uint8x4_t); } /// Safely transmutes a value of one type to a value of another type of the same @@ -5380,9 +5386,15 @@ mod tests { #[cfg(target_arch = "x86")] test_simd_arch_mod!(x86, __m128, __m128d, __m128i, __m256, __m256d, __m256i); + #[cfg(all(feature = "simd-nightly", target_arch = "x86"))] + test_simd_arch_mod!(x86, __m512bh, __m512, __m512d, __m512i); + #[cfg(target_arch = "x86_64")] test_simd_arch_mod!(x86_64, __m128, __m128d, __m128i, __m256, __m256d, __m256i); + #[cfg(all(feature = "simd-nightly", target_arch = "x86_64"))] + test_simd_arch_mod!(x86_64, __m512bh, __m512, __m512d, __m512i); + #[cfg(target_arch = "wasm32")] test_simd_arch_mod!(wasm32, v128); diff --git a/zerocopy-derive/Cargo.toml b/zerocopy-derive/Cargo.toml index 2f9d951379..fb23585ba2 100644 --- a/zerocopy-derive/Cargo.toml +++ b/zerocopy-derive/Cargo.toml @@ -9,7 +9,7 @@ [package] edition = "2018" name = "zerocopy-derive" -version = "0.7.19" +version = "0.7.20" authors = ["Joshua Liebow-Feeser "] description = "Custom derive for traits from the zerocopy crate" license = "BSD-2-Clause OR Apache-2.0 OR MIT"