about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-02-11 01:37:54 +0100
committerGitHub <noreply@github.com>2024-02-11 01:37:54 +0100
commit5f9457c85147c04dccb78e57dde63dba8362161f (patch)
treee789bf0deeb672aa789204c4cfddbc6b1291e498
parent42752cbe095b9ad9941f20f22f80788d95f4ab06 (diff)
parent3bc490d814b126087d2a5f564688fb6991025b86 (diff)
downloadrust-5f9457c85147c04dccb78e57dde63dba8362161f.tar.gz
rust-5f9457c85147c04dccb78e57dde63dba8362161f.zip
Rollup merge of #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`
-rw-r--r--library/core/src/intrinsics/simd.rs54
1 files changed, 51 insertions, 3 deletions
diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs
index 0fd27974dce..ef4c65639eb 100644
--- a/library/core/src/intrinsics/simd.rs
+++ b/library/core/src/intrinsics/simd.rs
@@ -190,14 +190,27 @@ extern "platform-intrinsic" {
     ///
     /// `T` must be a vector.
     ///
-    /// `U` must be a const array of `i32`s.
+    /// `U` must be a **const** array of `i32`s. This means it must either refer to a named
+    /// const or be given as an inline const expression (`const { ... }`).
     ///
     /// `V` must be a vector with the same element type as `T` and the same length as `U`.
     ///
-    /// Concatenates `x` and `y`, then returns a new vector such that each element is selected from
-    /// the concatenation by the matching index in `idx`.
+    /// Returns a new vector such that element `i` is selected from `xy[idx[i]]`, where `xy`
+    /// is the concatenation of `x` and `y`. It is a compile-time error if `idx[i]` is out-of-bounds
+    /// of `xy`.
     pub fn simd_shuffle<T, U, V>(x: T, y: T, idx: U) -> V;
 
+    /// Shuffle two vectors by const indices.
+    ///
+    /// `T` must be a vector.
+    ///
+    /// `U` must be a vector with the same element type as `T` and the same length as `IDX`.
+    ///
+    /// Returns a new vector such that element `i` is selected from `xy[IDX[i]]`, where `xy`
+    /// is the concatenation of `x` and `y`. It is a compile-time error if `IDX[i]` is out-of-bounds
+    /// of `xy`.
+    pub fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U;
+
     /// Read a vector of pointers.
     ///
     /// `T` must be a vector.
@@ -232,6 +245,9 @@ extern "platform-intrinsic" {
     /// corresponding value in `val` to the pointer.
     /// Otherwise if the corresponding value in `mask` is `0`, do nothing.
     ///
+    /// The stores happen in left-to-right order.
+    /// (This is relevant in case two of the stores overlap.)
+    ///
     /// # Safety
     /// Unmasked values in `T` must be writeable as if by `<ptr>::write` (e.g. aligned to the element
     /// type).
@@ -468,4 +484,36 @@ extern "platform-intrinsic" {
     ///
     /// `T` must be a vector of integers.
     pub fn simd_cttz<T>(x: T) -> T;
+
+    /// Round up each element to the next highest integer-valued float.
+    ///
+    /// `T` must be a vector of floats.
+    pub fn simd_ceil<T>(x: T) -> T;
+
+    /// Round down each element to the next lowest integer-valued float.
+    ///
+    /// `T` must be a vector of floats.
+    pub fn simd_floor<T>(x: T) -> T;
+
+    /// Round each element to the closest integer-valued float.
+    /// Ties are resolved by rounding away from 0.
+    ///
+    /// `T` must be a vector of floats.
+    pub fn simd_round<T>(x: T) -> T;
+
+    /// Return the integer part of each element as an integer-valued float.
+    /// In other words, non-integer values are truncated towards zero.
+    ///
+    /// `T` must be a vector of floats.
+    pub fn simd_trunc<T>(x: T) -> T;
+
+    /// Takes the square root of each element.
+    ///
+    /// `T` must be a vector of floats.
+    pub fn simd_fsqrt<T>(x: T) -> T;
+
+    /// Computes `(x*y) + z` for each element, but without any intermediate rounding.
+    ///
+    /// `T` must be a vector of floats.
+    pub fn simd_fma<T>(x: T, y: T, z: T) -> T;
 }