Skip to content

Commit e73e5e9

Browse files
authored
Unrolled build for rust-lang#119213
Rollup merge of rust-lang#119213 - RalfJung:simd_shuffle, r=workingjubilee simd intrinsics: add simd_shuffle_generic and other missing intrinsics Also tweak the simd_shuffle docs a bit. r? `@calebzulawski`
2 parents 980cf08 + 3bc490d commit e73e5e9

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

Diff for: library/core/src/intrinsics/simd.rs

+51-3
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,27 @@ extern "platform-intrinsic" {
190190
///
191191
/// `T` must be a vector.
192192
///
193-
/// `U` must be a const array of `i32`s.
193+
/// `U` must be a **const** array of `i32`s. This means it must either refer to a named
194+
/// const or be given as an inline const expression (`const { ... }`).
194195
///
195196
/// `V` must be a vector with the same element type as `T` and the same length as `U`.
196197
///
197-
/// Concatenates `x` and `y`, then returns a new vector such that each element is selected from
198-
/// the concatenation by the matching index in `idx`.
198+
/// Returns a new vector such that element `i` is selected from `xy[idx[i]]`, where `xy`
199+
/// is the concatenation of `x` and `y`. It is a compile-time error if `idx[i]` is out-of-bounds
200+
/// of `xy`.
199201
pub fn simd_shuffle<T, U, V>(x: T, y: T, idx: U) -> V;
200202

203+
/// Shuffle two vectors by const indices.
204+
///
205+
/// `T` must be a vector.
206+
///
207+
/// `U` must be a vector with the same element type as `T` and the same length as `IDX`.
208+
///
209+
/// Returns a new vector such that element `i` is selected from `xy[IDX[i]]`, where `xy`
210+
/// is the concatenation of `x` and `y`. It is a compile-time error if `IDX[i]` is out-of-bounds
211+
/// of `xy`.
212+
pub fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U;
213+
201214
/// Read a vector of pointers.
202215
///
203216
/// `T` must be a vector.
@@ -232,6 +245,9 @@ extern "platform-intrinsic" {
232245
/// corresponding value in `val` to the pointer.
233246
/// Otherwise if the corresponding value in `mask` is `0`, do nothing.
234247
///
248+
/// The stores happen in left-to-right order.
249+
/// (This is relevant in case two of the stores overlap.)
250+
///
235251
/// # Safety
236252
/// Unmasked values in `T` must be writeable as if by `<ptr>::write` (e.g. aligned to the element
237253
/// type).
@@ -468,4 +484,36 @@ extern "platform-intrinsic" {
468484
///
469485
/// `T` must be a vector of integers.
470486
pub fn simd_cttz<T>(x: T) -> T;
487+
488+
/// Round up each element to the next highest integer-valued float.
489+
///
490+
/// `T` must be a vector of floats.
491+
pub fn simd_ceil<T>(x: T) -> T;
492+
493+
/// Round down each element to the next lowest integer-valued float.
494+
///
495+
/// `T` must be a vector of floats.
496+
pub fn simd_floor<T>(x: T) -> T;
497+
498+
/// Round each element to the closest integer-valued float.
499+
/// Ties are resolved by rounding away from 0.
500+
///
501+
/// `T` must be a vector of floats.
502+
pub fn simd_round<T>(x: T) -> T;
503+
504+
/// Return the integer part of each element as an integer-valued float.
505+
/// In other words, non-integer values are truncated towards zero.
506+
///
507+
/// `T` must be a vector of floats.
508+
pub fn simd_trunc<T>(x: T) -> T;
509+
510+
/// Takes the square root of each element.
511+
///
512+
/// `T` must be a vector of floats.
513+
pub fn simd_fsqrt<T>(x: T) -> T;
514+
515+
/// Computes `(x*y) + z` for each element, but without any intermediate rounding.
516+
///
517+
/// `T` must be a vector of floats.
518+
pub fn simd_fma<T>(x: T, y: T, z: T) -> T;
471519
}

0 commit comments

Comments
 (0)