Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync upstream #448

Merged
merged 29 commits into from
Jan 18, 2025
Merged
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bd7c794
Sync portable-simd to 2023 July 07
workingjubilee Jul 7, 2023
78c05f9
remove repetitive words
cuishuang Jul 15, 2023
5895729
use visibility to check unused imports and delete some stmts
bvanjoi Oct 15, 2023
62030c7
Merge commit 'e0e9a4517f9fc021283514da387e70a56061bd3e' into sync-por…
calebzulawski Nov 26, 2023
c6b3b35
Remove link to core::arch::x86_64
calebzulawski Dec 2, 2023
08069a5
portable-simd: add missing feature gate
RalfJung Dec 4, 2023
98fc771
Fix target_feature config in portable-simd
Urgau Dec 12, 2023
7e65a05
Disable conversions between portable_simd and stdarch on big-endian ARM
Amanieu Jan 30, 2024
f699661
Merge commit '649110751ef4f27440d7cc711b3e07d11bf02d4a' into sync-por…
calebzulawski Feb 18, 2024
8d2208e
Merge commit 'cff979eec1ac0473fc4960ee6cde462c6aeda824' into sync-por…
dpaoliello Mar 22, 2024
def711f
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance
RalfJung Mar 23, 2024
c7a9561
also rename the SIMD intrinsic
RalfJung Mar 23, 2024
61daba9
Import the 2021 prelude in the core crate
dpaoliello Mar 25, 2024
93d3300
Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu
jhpratt Apr 3, 2024
b039861
rename `expose_addr` to `expose_provenance`
joboet Apr 3, 2024
4fa3e88
Stabilise `inline_const`
nbdd0121 Apr 19, 2024
3927f4a
Add `size_of`, `size_of_val`, `align_of`, and `align_of_val` to the p…
joshtriplett Mar 28, 2024
435f706
Fix typos (taking into account review comments)
blyxyas May 18, 2024
4da8687
Rollup merge of #123168 - joshtriplett:size-of-prelude, r=Amanieu
workingjubilee Jun 5, 2024
30a6317
Convert some module-level `//` and `///` comments to `//!`.
nnethercote Jun 19, 2024
2937f6f
Add blank lines after module-level `//!` comments.
nnethercote Jun 19, 2024
b173176
wasm64 build with target-feature=+simd128,+atomics
wooden-worm Jun 24, 2024
048ba3e
Fix doc nits
bitfield Jul 15, 2024
4111fb2
simd_shuffle: require index argument to be a vector
RalfJung Sep 12, 2024
2458792
stabilize const_intrinsic_copy
RalfJung Sep 23, 2024
6c1656d
move strict provenance lints to new feature gate, remove old feature …
RalfJung Sep 14, 2024
8423171
Bump `stdarch`
daxpedda Dec 15, 2024
a2c745e
Merge branch 'sync-upstream-2025-01-16' into test
calebzulawski Jan 16, 2025
638667a
Remove stable features
calebzulawski Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions crates/core_simd/examples/dot_product.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Code taken from the `packed_simd` crate
// Run this code with `cargo test --example dot_product`
//use std::iter::zip;
//! Code taken from the `packed_simd` crate.
//! Run this code with `cargo test --example dot_product`.

#![feature(array_chunks)]
#![feature(slice_as_chunks)]
2 changes: 0 additions & 2 deletions crates/core_simd/src/lib.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
const_eval_select,
const_intrinsic_copy,
const_refs_to_cell,
const_maybe_uninit_as_mut_ptr,
const_mut_refs,
convert_float_to_int,
core_intrinsics,
@@ -12,7 +11,6 @@
repr_simd,
simd_ffi,
staged_api,
strict_provenance,
prelude_import,
ptr_metadata
)]
8 changes: 4 additions & 4 deletions crates/core_simd/src/masks.rs
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ where
T: MaskElement,
LaneCount<N>: SupportedLaneCount,
{
/// Construct a mask by setting all elements to the given value.
/// Constructs a mask by setting all elements to the given value.
#[inline]
pub fn splat(value: bool) -> Self {
Self(mask_impl::Mask::splat(value))
@@ -288,7 +288,7 @@ where
self.0.all()
}

/// Create a bitmask from a mask.
/// Creates a bitmask from a mask.
///
/// Each bit is set if the corresponding element in the mask is `true`.
/// If the mask contains more than 64 elements, the bitmask is truncated to the first 64.
@@ -298,7 +298,7 @@ where
self.0.to_bitmask_integer()
}

/// Create a mask from a bitmask.
/// Creates a mask from a bitmask.
///
/// For each bit, if it is set, the corresponding element in the mask is set to `true`.
/// If the mask contains more than 64 elements, the remainder are set to `false`.
@@ -308,7 +308,7 @@ where
Self(mask_impl::Mask::from_bitmask_integer(bitmask))
}

/// Find the index of the first set element.
/// Finds the index of the first set element.
///
/// ```
/// # #![feature(portable_simd)]
2 changes: 1 addition & 1 deletion crates/core_simd/src/ops.rs
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ macro_rules! for_base_types {
#[inline]
#[must_use = "operator returns a new vector without mutating the inputs"]
// TODO: only useful for int Div::div, but we hope that this
// will essentially always always get inlined anyway.
// will essentially always get inlined anyway.
#[track_caller]
fn $call(self, rhs: Self) -> Self::Output {
$macro_impl!(self, rhs, $inner, $scalar)
1 change: 1 addition & 0 deletions crates/core_simd/src/ops/assign.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Assignment operators

use super::*;
use core::ops::{AddAssign, MulAssign}; // commutative binary op-assignment
use core::ops::{BitAndAssign, BitOrAssign, BitXorAssign}; // commutative bit binary op-assignment
1 change: 1 addition & 0 deletions crates/core_simd/src/ops/deref.rs
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
//! Ideally, Rust would take care of this itself,
//! and method calls usually handle the LHS implicitly.
//! But this is not the case with arithmetic ops.

use super::*;

macro_rules! deref_lhs {
4 changes: 2 additions & 2 deletions crates/core_simd/src/simd/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ pub trait SimdConstPtr: Copy + Sealed {
/// Equivalent to calling [`pointer::addr`] on each element.
fn addr(self) -> Self::Usize;

/// Convert an address to a pointer without giving it any provenance.
/// Converts an address to a pointer without giving it any provenance.
///
/// Without provenance, this pointer is not associated with any actual allocation. Such a
/// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but
@@ -67,7 +67,7 @@ pub trait SimdConstPtr: Copy + Sealed {
/// [`Self::with_exposed_provenance`] and returns the "address" portion.
fn expose_provenance(self) -> Self::Usize;

/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
/// Converts an address back to a pointer, picking up a previously "exposed" provenance.
///
/// Equivalent to calling [`core::ptr::with_exposed_provenance`] on each element.
fn with_exposed_provenance(addr: Self::Usize) -> Self;
4 changes: 2 additions & 2 deletions crates/core_simd/src/simd/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ pub trait SimdMutPtr: Copy + Sealed {
/// Equivalent to calling [`pointer::addr`] on each element.
fn addr(self) -> Self::Usize;

/// Convert an address to a pointer without giving it any provenance.
/// Converts an address to a pointer without giving it any provenance.
///
/// Without provenance, this pointer is not associated with any actual allocation. Such a
/// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but
@@ -64,7 +64,7 @@ pub trait SimdMutPtr: Copy + Sealed {
/// [`Self::with_exposed_provenance`] and returns the "address" portion.
fn expose_provenance(self) -> Self::Usize;

/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
/// Converts an address back to a pointer, picking up a previously "exposed" provenance.
///
/// Equivalent to calling [`core::ptr::with_exposed_provenance_mut`] on each element.
fn with_exposed_provenance(addr: Self::Usize) -> Self;
26 changes: 17 additions & 9 deletions crates/core_simd/src/swizzle.rs
Original file line number Diff line number Diff line change
@@ -69,12 +69,12 @@ pub macro simd_swizzle {
}
}

/// Create a vector from the elements of another vector.
/// Creates a vector from the elements of another vector.
pub trait Swizzle<const N: usize> {
/// Map from the elements of the input vector to the output vector.
const INDEX: [usize; N];

/// Create a new vector from the elements of `vector`.
/// Creates a new vector from the elements of `vector`.
///
/// Lane `i` of the output is `vector[Self::INDEX[i]]`.
#[inline]
@@ -85,7 +85,7 @@ pub trait Swizzle<const N: usize> {
LaneCount<N>: SupportedLaneCount,
LaneCount<M>: SupportedLaneCount,
{
// Safety: `vector` is a vector, and the index is a const array of u32.
// Safety: `vector` is a vector, and the index is a const vector of u32.
unsafe {
core::intrinsics::simd::simd_shuffle(
vector,
@@ -103,13 +103,17 @@ pub trait Swizzle<const N: usize> {
output[i] = index as u32;
i += 1;
}
output

// The index list needs to be returned as a vector.
#[repr(simd)]
struct SimdShuffleIdx<const LEN: usize>([u32; LEN]);
SimdShuffleIdx(output)
},
)
}
}

/// Create a new vector from the elements of `first` and `second`.
/// Creates a new vector from the elements of `first` and `second`.
///
/// Lane `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
/// `first` and `second`.
@@ -121,7 +125,7 @@ pub trait Swizzle<const N: usize> {
LaneCount<N>: SupportedLaneCount,
LaneCount<M>: SupportedLaneCount,
{
// Safety: `first` and `second` are vectors, and the index is a const array of u32.
// Safety: `first` and `second` are vectors, and the index is a const vector of u32.
unsafe {
core::intrinsics::simd::simd_shuffle(
first,
@@ -139,13 +143,17 @@ pub trait Swizzle<const N: usize> {
output[i] = index as u32;
i += 1;
}
output

// The index list needs to be returned as a vector.
#[repr(simd)]
struct SimdShuffleIdx<const LEN: usize>([u32; LEN]);
SimdShuffleIdx(output)
},
)
}
}

/// Create a new mask from the elements of `mask`.
/// Creates a new mask from the elements of `mask`.
///
/// Element `i` of the output is `mask[Self::INDEX[i]]`.
#[inline]
@@ -160,7 +168,7 @@ pub trait Swizzle<const N: usize> {
unsafe { Mask::from_int_unchecked(Self::swizzle(mask.to_int())) }
}

/// Create a new mask from the elements of `first` and `second`.
/// Creates a new mask from the elements of `first` and `second`.
///
/// Element `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
/// `first` and `second`.
2 changes: 2 additions & 0 deletions crates/core_simd/src/swizzle_dyn.rs
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ where
use core::arch::arm::{uint8x8_t, vtbl1_u8};
#[cfg(target_arch = "wasm32")]
use core::arch::wasm32 as wasm;
#[cfg(target_arch = "wasm64")]
use core::arch::wasm64 as wasm;
#[cfg(target_arch = "x86")]
use core::arch::x86;
#[cfg(target_arch = "x86_64")]
14 changes: 7 additions & 7 deletions crates/core_simd/src/to_bytes.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ mod sealed {
}
use sealed::Sealed;

/// Convert SIMD vectors to vectors of bytes
/// Converts SIMD vectors to vectors of bytes
pub trait ToBytes: Sealed {
/// This type, reinterpreted as bytes.
type Bytes: Copy
@@ -22,26 +22,26 @@ pub trait ToBytes: Sealed {
+ SimdUint<Scalar = u8>
+ 'static;

/// Return the memory representation of this integer as a byte array in native byte
/// Returns the memory representation of this integer as a byte array in native byte
/// order.
fn to_ne_bytes(self) -> Self::Bytes;

/// Return the memory representation of this integer as a byte array in big-endian
/// Returns the memory representation of this integer as a byte array in big-endian
/// (network) byte order.
fn to_be_bytes(self) -> Self::Bytes;

/// Return the memory representation of this integer as a byte array in little-endian
/// Returns the memory representation of this integer as a byte array in little-endian
/// byte order.
fn to_le_bytes(self) -> Self::Bytes;

/// Create a native endian integer value from its memory representation as a byte array
/// Creates a native endian integer value from its memory representation as a byte array
/// in native endianness.
fn from_ne_bytes(bytes: Self::Bytes) -> Self;

/// Create an integer value from its representation as a byte array in big endian.
/// Creates an integer value from its representation as a byte array in big endian.
fn from_be_bytes(bytes: Self::Bytes) -> Self;

/// Create an integer value from its representation as a byte array in little endian.
/// Creates an integer value from its representation as a byte array in little endian.
fn from_le_bytes(bytes: Self::Bytes) -> Self;
}

6 changes: 3 additions & 3 deletions crates/core_simd/src/vector.rs
Original file line number Diff line number Diff line change
@@ -205,7 +205,7 @@ where
unsafe { &mut *(self as *mut Self as *mut [T; N]) }
}

/// Load a vector from an array of `T`.
/// Loads a vector from an array of `T`.
///
/// This function is necessary since `repr(simd)` has padding for non-power-of-2 vectors (at the time of writing).
/// With padding, `read_unaligned` will read past the end of an array of N elements.
@@ -591,7 +591,7 @@ where
unsafe { Self::gather_select_ptr(ptrs, enable, or) }
}

/// Read elementwise from pointers into a SIMD vector.
/// Reads elementwise from pointers into a SIMD vector.
///
/// # Safety
///
@@ -832,7 +832,7 @@ where
}
}

/// Write pointers elementwise into a SIMD vector.
/// Writes pointers elementwise into a SIMD vector.
///
/// # Safety
///
13 changes: 2 additions & 11 deletions crates/core_simd/src/vendor/arm.rs
Original file line number Diff line number Diff line change
@@ -48,17 +48,6 @@ mod neon {
from_transmute! { unsafe u64x2 => poly64x2_t }
}

#[cfg(any(
all(target_feature = "v5te", not(target_feature = "mclass")),
all(target_feature = "mclass", target_feature = "dsp"),
))]
mod dsp {
use super::*;

from_transmute! { unsafe Simd<u16, 2> => uint16x2_t }
from_transmute! { unsafe Simd<i16, 2> => int16x2_t }
}

#[cfg(any(
all(target_feature = "v6", not(target_feature = "mclass")),
all(target_feature = "mclass", target_feature = "dsp"),
@@ -68,6 +57,8 @@ mod simd32 {

from_transmute! { unsafe Simd<u8, 4> => uint8x4_t }
from_transmute! { unsafe Simd<i8, 4> => int8x4_t }
from_transmute! { unsafe Simd<u16, 2> => uint16x2_t }
from_transmute! { unsafe Simd<i16, 2> => int16x2_t }
}

#[cfg(all(
2 changes: 1 addition & 1 deletion crates/core_simd/tests/pointers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(portable_simd, strict_provenance, exposed_provenance)]
#![feature(portable_simd)]

use core_simd::simd::{
ptr::{SimdConstPtr, SimdMutPtr},
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-09-11"
channel = "nightly-2025-01-16"
components = ["rustfmt", "clippy", "miri", "rust-src"]
Loading