4
4
5
5
/// Inserts an element into a vector, returning the updated vector.
6
6
///
7
- /// `T` must be a vector with element type `U`.
7
+ /// `T` must be a vector with element type `U`, and `idx` must be `const` .
8
8
///
9
9
/// # Safety
10
10
///
@@ -16,20 +16,52 @@ pub unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T {
16
16
unreachable ! ( )
17
17
}
18
18
19
- /// Extracts an element from a vector.
19
+ /// Inserts an element into a vector, returning the updated vector.
20
20
///
21
21
/// `T` must be a vector with element type `U`.
22
22
///
23
+ /// If the index is `const`, [`simd_insert`] may emit better assembly.
24
+ ///
23
25
/// # Safety
24
26
///
25
27
/// `idx` must be in-bounds of the vector.
26
28
#[ rustc_intrinsic]
27
29
#[ rustc_intrinsic_must_be_overridden]
28
30
#[ rustc_nounwind]
31
+ pub unsafe fn simd_insert_dyn < T , U > ( _x : T , _idx : u32 , _val : U ) -> T {
32
+ unreachable ! ( )
33
+ }
34
+
35
+ /// Extracts an element from a vector.
36
+ ///
37
+ /// `T` must be a vector with element type `U`, and `idx` must be `const`.
38
+ ///
39
+ /// # Safety
40
+ ///
41
+ /// `idx` must be const and in-bounds of the vector.
42
+ #[ rustc_intrinsic]
43
+ #[ rustc_intrinsic_must_be_overridden]
44
+ #[ rustc_nounwind]
29
45
pub unsafe fn simd_extract < T , U > ( _x : T , _idx : u32 ) -> U {
30
46
unreachable ! ( )
31
47
}
32
48
49
+ /// Extracts an element from a vector.
50
+ ///
51
+ /// `T` must be a vector with element type `U`.
52
+ ///
53
+ /// If the index is `const`, [`simd_extract`] may emit better assembly.
54
+ ///
55
+ /// # Safety
56
+ ///
57
+ /// `idx` must be in-bounds of the vector.
58
+ #[ rustc_intrinsic]
59
+ #[ rustc_intrinsic_must_be_overridden]
60
+ #[ rustc_nounwind]
61
+ pub unsafe fn simd_extract_dyn < T , U > ( _x : T , _idx : u32 ) -> U {
62
+ unreachable ! ( )
63
+ }
64
+
33
65
/// Adds two simd vectors elementwise.
34
66
///
35
67
/// `T` must be a vector of integer or floating point primitive types.
@@ -342,6 +374,24 @@ pub unsafe fn simd_shuffle<T, U, V>(_x: T, _y: T, _idx: U) -> V {
342
374
unreachable ! ( )
343
375
}
344
376
377
+ /// Shuffles two vectors by const indices.
378
+ ///
379
+ /// `T` must be a vector.
380
+ ///
381
+ /// `U` must be a vector of `u32`s. Contrary to [`simd_shuffle`], this argument does not need to be
382
+ /// const, but [`simd_shuffle`] may emit better assembly for a const vector.
383
+ ///
384
+ /// `V` must be a vector with the same element type as `T` and the same length as `U`.
385
+ ///
386
+ /// Returns a new vector such that element `i` is selected from `xy[idx[i]]`, where `xy`
387
+ /// is the concatenation of `x` and `y`.
388
+ #[ rustc_intrinsic]
389
+ #[ rustc_intrinsic_must_be_overridden]
390
+ #[ rustc_nounwind]
391
+ pub unsafe fn simd_shuffle_dyn < T , U , V > ( _x : T , _y : T , _idx : U ) -> V {
392
+ unreachable ! ( )
393
+ }
394
+
345
395
/// Reads a vector of pointers.
346
396
///
347
397
/// `T` must be a vector.
0 commit comments