Skip to content

Commit 361fd7e

Browse files
committed
intrinsics::simd: add missing functions
1 parent 4316d0c commit 361fd7e

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.
@@ -315,6 +333,18 @@ extern "platform-intrinsic" {
315333
/// Starting with the value `y`, add the elements of `x` and accumulate.
316334
pub fn simd_reduce_add_ordered<T, U>(x: T, y: U) -> U;
317335

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

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

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

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

0 commit comments

Comments
 (0)