Skip to content

Commit 25fe3cc

Browse files
committed
intrinsics::simd: add missing functions
1 parent 1d447a9 commit 25fe3cc

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

library/core/src/intrinsics/simd.rs

+103
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
//! In this module, a "vector" is any `repr(simd)` type.
44
55
extern "platform-intrinsic" {
6+
/// Insert an element into a vector, returning the updated vector.
7+
///
8+
/// `T` must be a vector with element type `U`.
9+
///
10+
/// # Safety
11+
///
12+
/// `idx` must be in-bounds of the vector.
13+
pub fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
14+
15+
/// Extract an element from a vector.
16+
///
17+
/// `T` must be a vector with element type `U`.
18+
///
19+
/// # Safety
20+
///
21+
/// `idx` must be in-bounds of the vector.
22+
pub fn simd_extract<T, U>(x: T, idx: u32) -> U;
23+
624
/// Add two simd vectors elementwise.
725
///
826
/// `T` must be a vector of integer or floating point primitive types.
@@ -317,6 +335,18 @@ extern "platform-intrinsic" {
317335
/// Starting with the value `y`, add the elements of `x` and accumulate.
318336
pub fn simd_reduce_add_ordered<T, U>(x: T, y: U) -> U;
319337

338+
/// Add elements within a vector in arbitrary order, and without regard
339+
/// for signed zeros.
340+
///
341+
/// `T` must be a vector of integer or floating-point primitive types.
342+
///
343+
/// `U` must be the element type of `T`.
344+
///
345+
/// # Safety
346+
///
347+
/// All input elements must be finite (i.e., not NAN and not +/- INF).
348+
pub fn simd_reduce_add_unordered<T, U>(x: T) -> U;
349+
320350
/// Multiply elements within a vector from left to right.
321351
///
322352
/// `T` must be a vector of integer or floating-point primitive types.
@@ -326,6 +356,18 @@ extern "platform-intrinsic" {
326356
/// Starting with the value `y`, multiply the elements of `x` and accumulate.
327357
pub fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U;
328358

359+
/// Multiply elements within a vector in arbitrary order, and without regard
360+
/// for signed zeros.
361+
///
362+
/// `T` must be a vector of integer or floating-point primitive types.
363+
///
364+
/// `U` must be the element type of `T`.
365+
///
366+
/// # Safety
367+
///
368+
/// All input elements must be finite (i.e., not NAN and not +/- INF).
369+
pub fn simd_reduce_mul_unordered<T, U>(x: T) -> U;
370+
329371
/// Check if all mask values are true.
330372
///
331373
/// `T` must be a vector of integer primitive types.
@@ -351,6 +393,19 @@ extern "platform-intrinsic" {
351393
/// For floating-point values, uses IEEE-754 `maxNum`.
352394
pub fn simd_reduce_max<T, U>(x: T) -> U;
353395

396+
/// Return the maximum element of a vector.
397+
///
398+
/// `T` must be a vector of integer or floating-point primitive types.
399+
///
400+
/// `U` must be the element type of `T`.
401+
///
402+
/// For floating-point values, uses IEEE-754 `maxNum`.
403+
///
404+
/// # Safety
405+
///
406+
/// All input elements must be finite (i.e., not NAN and not +/- INF).
407+
pub fn simd_reduce_max_nanless<T, U>(x: T) -> U;
408+
354409
/// Return the minimum element of a vector.
355410
///
356411
/// `T` must be a vector of integer or floating-point primitive types.
@@ -360,6 +415,19 @@ extern "platform-intrinsic" {
360415
/// For floating-point values, uses IEEE-754 `minNum`.
361416
pub fn simd_reduce_min<T, U>(x: T) -> U;
362417

418+
/// Return the minimum element of a vector.
419+
///
420+
/// `T` must be a vector of integer or floating-point primitive types.
421+
///
422+
/// `U` must be the element type of `T`.
423+
///
424+
/// For floating-point values, uses IEEE-754 `minNum`.
425+
///
426+
/// # Safety
427+
///
428+
/// All input elements must be finite (i.e., not NAN and not +/- INF).
429+
pub fn simd_reduce_min_nanless<T, U>(x: T) -> U;
430+
363431
/// Logical "and" all elements together.
364432
///
365433
/// `T` must be a vector of integer or floating-point primitive types.
@@ -518,4 +586,39 @@ extern "platform-intrinsic" {
518586
///
519587
/// `T` must be a vector of floats.
520588
pub fn simd_fma<T>(x: T, y: T, z: T) -> T;
589+
590+
// Computes the sine of each element.
591+
///
592+
/// `T` must be a vector of floats.
593+
pub fn simd_fsin<T>(a: T) -> T;
594+
595+
// Computes the cosine of each element.
596+
///
597+
/// `T` must be a vector of floats.
598+
pub fn simd_fcos<T>(a: T) -> T;
599+
600+
// Computes the exponential function of each element.
601+
///
602+
/// `T` must be a vector of floats.
603+
pub fn simd_fexp<T>(a: T) -> T;
604+
605+
// Computes 2 raised to the power of each element.
606+
///
607+
/// `T` must be a vector of floats.
608+
pub fn simd_fexp2<T>(a: T) -> T;
609+
610+
// Computes the base 10 logarithm of each element.
611+
///
612+
/// `T` must be a vector of floats.
613+
pub fn simd_flog10<T>(a: T) -> T;
614+
615+
// Computes the base 2 logarithm of each element.
616+
///
617+
/// `T` must be a vector of floats.
618+
pub fn simd_flog2<T>(a: T) -> T;
619+
620+
// Computes the natural logarithm of each element.
621+
///
622+
/// `T` must be a vector of floats.
623+
pub fn simd_flog<T>(a: T) -> T;
521624
}

0 commit comments

Comments
 (0)