Merge branch 'sync-upstream-2025-01-16' into test
This commit is contained in:
commit
a2c745e75d
15 changed files with 46 additions and 46 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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,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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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`.
|
||||
|
|
|
|||
|
|
@ -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")]
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
crates/core_simd/src/vendor/arm.rs
vendored
13
crates/core_simd/src/vendor/arm.rs
vendored
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(portable_simd, strict_provenance, exposed_provenance)]
|
||||
#![feature(portable_simd)]
|
||||
|
||||
use core_simd::simd::{
|
||||
ptr::{SimdConstPtr, SimdMutPtr},
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
[toolchain]
|
||||
channel = "nightly-2024-09-11"
|
||||
channel = "nightly-2025-01-16"
|
||||
components = ["rustfmt", "clippy", "miri", "rust-src"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue