Skip to content

Commit 4b1a23e

Browse files
Merge pull request #448 from rust-lang/sync-upstream
Sync upstream
2 parents 49176ae + 638667a commit 4b1a23e

15 files changed

+46
-49
lines changed

crates/core_simd/examples/dot_product.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Code taken from the `packed_simd` crate
2-
// Run this code with `cargo test --example dot_product`
3-
//use std::iter::zip;
1+
//! Code taken from the `packed_simd` crate.
2+
//! Run this code with `cargo test --example dot_product`.
43
54
#![feature(array_chunks)]
65
#![feature(slice_as_chunks)]

crates/core_simd/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
#![no_std]
22
#![feature(
33
const_eval_select,
4-
const_intrinsic_copy,
5-
const_refs_to_cell,
6-
const_maybe_uninit_as_mut_ptr,
7-
const_mut_refs,
84
convert_float_to_int,
95
core_intrinsics,
106
decl_macro,
117
intra_doc_pointers,
128
repr_simd,
139
simd_ffi,
1410
staged_api,
15-
strict_provenance,
1611
prelude_import,
1712
ptr_metadata
1813
)]

crates/core_simd/src/masks.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ where
137137
T: MaskElement,
138138
LaneCount<N>: SupportedLaneCount,
139139
{
140-
/// Construct a mask by setting all elements to the given value.
140+
/// Constructs a mask by setting all elements to the given value.
141141
#[inline]
142142
pub fn splat(value: bool) -> Self {
143143
Self(mask_impl::Mask::splat(value))
@@ -288,7 +288,7 @@ where
288288
self.0.all()
289289
}
290290

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

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

311-
/// Find the index of the first set element.
311+
/// Finds the index of the first set element.
312312
///
313313
/// ```
314314
/// # #![feature(portable_simd)]

crates/core_simd/src/ops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ macro_rules! for_base_types {
137137
#[inline]
138138
#[must_use = "operator returns a new vector without mutating the inputs"]
139139
// TODO: only useful for int Div::div, but we hope that this
140-
// will essentially always always get inlined anyway.
140+
// will essentially always get inlined anyway.
141141
#[track_caller]
142142
fn $call(self, rhs: Self) -> Self::Output {
143143
$macro_impl!(self, rhs, $inner, $scalar)

crates/core_simd/src/ops/assign.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Assignment operators
2+
23
use super::*;
34
use core::ops::{AddAssign, MulAssign}; // commutative binary op-assignment
45
use core::ops::{BitAndAssign, BitOrAssign, BitXorAssign}; // commutative bit binary op-assignment

crates/core_simd/src/ops/deref.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! Ideally, Rust would take care of this itself,
33
//! and method calls usually handle the LHS implicitly.
44
//! But this is not the case with arithmetic ops.
5+
56
use super::*;
67

78
macro_rules! deref_lhs {

crates/core_simd/src/simd/ptr/const_ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub trait SimdConstPtr: Copy + Sealed {
4242
/// Equivalent to calling [`pointer::addr`] on each element.
4343
fn addr(self) -> Self::Usize;
4444

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

70-
/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
70+
/// Converts an address back to a pointer, picking up a previously "exposed" provenance.
7171
///
7272
/// Equivalent to calling [`core::ptr::with_exposed_provenance`] on each element.
7373
fn with_exposed_provenance(addr: Self::Usize) -> Self;

crates/core_simd/src/simd/ptr/mut_ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub trait SimdMutPtr: Copy + Sealed {
3939
/// Equivalent to calling [`pointer::addr`] on each element.
4040
fn addr(self) -> Self::Usize;
4141

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

67-
/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
67+
/// Converts an address back to a pointer, picking up a previously "exposed" provenance.
6868
///
6969
/// Equivalent to calling [`core::ptr::with_exposed_provenance_mut`] on each element.
7070
fn with_exposed_provenance(addr: Self::Usize) -> Self;

crates/core_simd/src/swizzle.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ pub macro simd_swizzle {
6969
}
7070
}
7171

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

77-
/// Create a new vector from the elements of `vector`.
77+
/// Creates a new vector from the elements of `vector`.
7878
///
7979
/// Lane `i` of the output is `vector[Self::INDEX[i]]`.
8080
#[inline]
@@ -85,7 +85,7 @@ pub trait Swizzle<const N: usize> {
8585
LaneCount<N>: SupportedLaneCount,
8686
LaneCount<M>: SupportedLaneCount,
8787
{
88-
// Safety: `vector` is a vector, and the index is a const array of u32.
88+
// Safety: `vector` is a vector, and the index is a const vector of u32.
8989
unsafe {
9090
core::intrinsics::simd::simd_shuffle(
9191
vector,
@@ -103,13 +103,17 @@ pub trait Swizzle<const N: usize> {
103103
output[i] = index as u32;
104104
i += 1;
105105
}
106-
output
106+
107+
// The index list needs to be returned as a vector.
108+
#[repr(simd)]
109+
struct SimdShuffleIdx<const LEN: usize>([u32; LEN]);
110+
SimdShuffleIdx(output)
107111
},
108112
)
109113
}
110114
}
111115

112-
/// Create a new vector from the elements of `first` and `second`.
116+
/// Creates a new vector from the elements of `first` and `second`.
113117
///
114118
/// Lane `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
115119
/// `first` and `second`.
@@ -121,7 +125,7 @@ pub trait Swizzle<const N: usize> {
121125
LaneCount<N>: SupportedLaneCount,
122126
LaneCount<M>: SupportedLaneCount,
123127
{
124-
// Safety: `first` and `second` are vectors, and the index is a const array of u32.
128+
// Safety: `first` and `second` are vectors, and the index is a const vector of u32.
125129
unsafe {
126130
core::intrinsics::simd::simd_shuffle(
127131
first,
@@ -139,13 +143,17 @@ pub trait Swizzle<const N: usize> {
139143
output[i] = index as u32;
140144
i += 1;
141145
}
142-
output
146+
147+
// The index list needs to be returned as a vector.
148+
#[repr(simd)]
149+
struct SimdShuffleIdx<const LEN: usize>([u32; LEN]);
150+
SimdShuffleIdx(output)
143151
},
144152
)
145153
}
146154
}
147155

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

163-
/// Create a new mask from the elements of `first` and `second`.
171+
/// Creates a new mask from the elements of `first` and `second`.
164172
///
165173
/// Element `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of
166174
/// `first` and `second`.

crates/core_simd/src/swizzle_dyn.rs

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ where
3030
use core::arch::arm::{uint8x8_t, vtbl1_u8};
3131
#[cfg(target_arch = "wasm32")]
3232
use core::arch::wasm32 as wasm;
33+
#[cfg(target_arch = "wasm64")]
34+
use core::arch::wasm64 as wasm;
3335
#[cfg(target_arch = "x86")]
3436
use core::arch::x86;
3537
#[cfg(target_arch = "x86_64")]

crates/core_simd/src/to_bytes.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod sealed {
1010
}
1111
use sealed::Sealed;
1212

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

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

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

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

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

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

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

crates/core_simd/src/vector.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ where
205205
unsafe { &mut *(self as *mut Self as *mut [T; N]) }
206206
}
207207

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

594-
/// Read elementwise from pointers into a SIMD vector.
594+
/// Reads elementwise from pointers into a SIMD vector.
595595
///
596596
/// # Safety
597597
///
@@ -832,7 +832,7 @@ where
832832
}
833833
}
834834

835-
/// Write pointers elementwise into a SIMD vector.
835+
/// Writes pointers elementwise into a SIMD vector.
836836
///
837837
/// # Safety
838838
///

crates/core_simd/src/vendor/arm.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ mod neon {
4848
from_transmute! { unsafe u64x2 => poly64x2_t }
4949
}
5050

51-
#[cfg(any(
52-
all(target_feature = "v5te", not(target_feature = "mclass")),
53-
all(target_feature = "mclass", target_feature = "dsp"),
54-
))]
55-
mod dsp {
56-
use super::*;
57-
58-
from_transmute! { unsafe Simd<u16, 2> => uint16x2_t }
59-
from_transmute! { unsafe Simd<i16, 2> => int16x2_t }
60-
}
61-
6251
#[cfg(any(
6352
all(target_feature = "v6", not(target_feature = "mclass")),
6453
all(target_feature = "mclass", target_feature = "dsp"),
@@ -68,6 +57,8 @@ mod simd32 {
6857

6958
from_transmute! { unsafe Simd<u8, 4> => uint8x4_t }
7059
from_transmute! { unsafe Simd<i8, 4> => int8x4_t }
60+
from_transmute! { unsafe Simd<u16, 2> => uint16x2_t }
61+
from_transmute! { unsafe Simd<i16, 2> => int16x2_t }
7162
}
7263

7364
#[cfg(all(

crates/core_simd/tests/pointers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(portable_simd, strict_provenance, exposed_provenance)]
1+
#![feature(portable_simd)]
22

33
use core_simd::simd::{
44
ptr::{SimdConstPtr, SimdMutPtr},

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2024-09-11"
2+
channel = "nightly-2025-01-16"
33
components = ["rustfmt", "clippy", "miri", "rust-src"]

0 commit comments

Comments
 (0)