3
3
//! In this module, a "vector" is any `repr(simd)` type.
4
4
5
5
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
+
6
24
/// Add two simd vectors elementwise.
7
25
///
8
26
/// `T` must be a vector of integer or floating point primitive types.
@@ -315,6 +333,14 @@ extern "platform-intrinsic" {
315
333
/// Starting with the value `y`, add the elements of `x` and accumulate.
316
334
pub fn simd_reduce_add_ordered < T , U > ( x : T , y : U ) -> U ;
317
335
336
+ /// Add elements within a vector in arbitrary order. May also be re-associated with
337
+ /// unordered additions on the inputs/outputs.
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
+ pub fn simd_reduce_add_unordered < T , U > ( x : T ) -> U ;
343
+
318
344
/// Multiply elements within a vector from left to right.
319
345
///
320
346
/// `T` must be a vector of integer or floating-point primitive types.
@@ -324,6 +350,14 @@ extern "platform-intrinsic" {
324
350
/// Starting with the value `y`, multiply the elements of `x` and accumulate.
325
351
pub fn simd_reduce_mul_ordered < T , U > ( x : T , y : U ) -> U ;
326
352
353
+ /// Add elements within a vector in arbitrary order. May also be re-associated with
354
+ /// unordered additions on the inputs/outputs.
355
+ ///
356
+ /// `T` must be a vector of integer or floating-point primitive types.
357
+ ///
358
+ /// `U` must be the element type of `T`.
359
+ pub fn simd_reduce_mul_unordered < T , U > ( x : T ) -> U ;
360
+
327
361
/// Check if all mask values are true.
328
362
///
329
363
/// `T` must be a vector of integer primitive types.
@@ -349,6 +383,19 @@ extern "platform-intrinsic" {
349
383
/// For floating-point values, uses IEEE-754 `maxNum`.
350
384
pub fn simd_reduce_max < T , U > ( x : T ) -> U ;
351
385
386
+ /// Return the maximum element of a vector.
387
+ ///
388
+ /// `T` must be a vector of integer or floating-point primitive types.
389
+ ///
390
+ /// `U` must be the element type of `T`.
391
+ ///
392
+ /// For floating-point values, uses IEEE-754 `maxNum`.
393
+ ///
394
+ /// # Safety
395
+ ///
396
+ /// All input elements must be finite (i.e., not NAN and not +/- INF).
397
+ pub fn simd_reduce_max_nanless < T , U > ( x : T ) -> U ;
398
+
352
399
/// Return the minimum element of a vector.
353
400
///
354
401
/// `T` must be a vector of integer or floating-point primitive types.
@@ -358,6 +405,19 @@ extern "platform-intrinsic" {
358
405
/// For floating-point values, uses IEEE-754 `minNum`.
359
406
pub fn simd_reduce_min < T , U > ( x : T ) -> U ;
360
407
408
+ /// Return the minimum element of a vector.
409
+ ///
410
+ /// `T` must be a vector of integer or floating-point primitive types.
411
+ ///
412
+ /// `U` must be the element type of `T`.
413
+ ///
414
+ /// For floating-point values, uses IEEE-754 `minNum`.
415
+ ///
416
+ /// # Safety
417
+ ///
418
+ /// All input elements must be finite (i.e., not NAN and not +/- INF).
419
+ pub fn simd_reduce_min_nanless < T , U > ( x : T ) -> U ;
420
+
361
421
/// Logical "and" all elements together.
362
422
///
363
423
/// `T` must be a vector of integer or floating-point primitive types.
@@ -516,4 +576,39 @@ extern "platform-intrinsic" {
516
576
///
517
577
/// `T` must be a vector of floats.
518
578
pub fn simd_fma < T > ( x : T , y : T , z : T ) -> T ;
579
+
580
+ // Computes the sine of each element.
581
+ ///
582
+ /// `T` must be a vector of floats.
583
+ pub fn simd_fsin < T > ( a : T ) -> T ;
584
+
585
+ // Computes the cosine of each element.
586
+ ///
587
+ /// `T` must be a vector of floats.
588
+ pub fn simd_fcos < T > ( a : T ) -> T ;
589
+
590
+ // Computes the exponential function of each element.
591
+ ///
592
+ /// `T` must be a vector of floats.
593
+ pub fn simd_fexp < T > ( a : T ) -> T ;
594
+
595
+ // Computes 2 raised to the power of each element.
596
+ ///
597
+ /// `T` must be a vector of floats.
598
+ pub fn simd_fexp2 < T > ( a : T ) -> T ;
599
+
600
+ // Computes the base 10 logarithm of each element.
601
+ ///
602
+ /// `T` must be a vector of floats.
603
+ pub fn simd_flog10 < T > ( a : T ) -> T ;
604
+
605
+ // Computes the base 2 logarithm of each element.
606
+ ///
607
+ /// `T` must be a vector of floats.
608
+ pub fn simd_flog2 < T > ( a : T ) -> T ;
609
+
610
+ // Computes the natural logarithm of each element.
611
+ ///
612
+ /// `T` must be a vector of floats.
613
+ pub fn simd_flog < T > ( a : T ) -> T ;
519
614
}
0 commit comments