Skip to content

Commit 705169f

Browse files
committed
add the new intrinsics
1 parent f04bbc6 commit 705169f

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

compiler/rustc_span/src/symbol.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,7 @@ symbols! {
18741874
simd_eq,
18751875
simd_expose_provenance,
18761876
simd_extract,
1877+
simd_extract_dyn,
18771878
simd_fabs,
18781879
simd_fcos,
18791880
simd_fexp,
@@ -1894,6 +1895,7 @@ symbols! {
18941895
simd_ge,
18951896
simd_gt,
18961897
simd_insert,
1898+
simd_insert_dyn,
18971899
simd_le,
18981900
simd_lt,
18991901
simd_masked_load,
@@ -1924,6 +1926,7 @@ symbols! {
19241926
simd_shl,
19251927
simd_shr,
19261928
simd_shuffle,
1929+
simd_shuffle_dyn,
19271930
simd_shuffle_generic,
19281931
simd_sub,
19291932
simd_trunc,

library/core/src/intrinsics/simd.rs

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
/// Inserts an element into a vector, returning the updated vector.
66
///
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`.
88
///
99
/// # Safety
1010
///
@@ -16,20 +16,52 @@ pub unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T {
1616
unreachable!()
1717
}
1818

19-
/// Extracts an element from a vector.
19+
/// Inserts an element into a vector, returning the updated vector.
2020
///
2121
/// `T` must be a vector with element type `U`.
2222
///
23+
/// If the index is `const`, [`simd_insert`] may emit better assembly.
24+
///
2325
/// # Safety
2426
///
2527
/// `idx` must be in-bounds of the vector.
2628
#[rustc_intrinsic]
2729
#[rustc_intrinsic_must_be_overridden]
2830
#[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]
2945
pub unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U {
3046
unreachable!()
3147
}
3248

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+
3365
/// Adds two simd vectors elementwise.
3466
///
3567
/// `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 {
342374
unreachable!()
343375
}
344376

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+
345395
/// Reads a vector of pointers.
346396
///
347397
/// `T` must be a vector.

0 commit comments

Comments
 (0)