@@ -49,10 +49,10 @@ extern "platform-intrinsic" {
49
49
50
50
/// Elementwise vector right shift, with UB on overflow.
51
51
///
52
- /// Shift `lhs` right by `rhs`, shifting in sign bits for signed types.
53
- ///
54
52
/// `T` must be a vector of integer primitive types.
55
53
///
54
+ /// Shift `lhs` right by `rhs`, shifting in sign bits for signed types.
55
+ ///
56
56
/// # Safety
57
57
///
58
58
/// Each element of `rhs` must be less than `<int>::BITS`.
@@ -75,35 +75,35 @@ extern "platform-intrinsic" {
75
75
76
76
/// Numerically cast a vector, elementwise.
77
77
///
78
+ /// `T` and `U` must be vectors of integer or floating point primitive types, and must have the
79
+ /// same length.
80
+ ///
78
81
/// When casting floats to integers, the result is truncated. Out-of-bounds result lead to UB.
79
82
/// When casting integers to floats, the result is rounded.
80
83
/// Otherwise, truncates or extends the value, maintaining the sign for signed integers.
81
84
///
82
- /// `T` and `U` must be vectors of integer or floating point primitive types, and must have the
83
- /// same length.
84
- ///
85
85
/// # Safety
86
86
/// Casting floats to integers truncates, but the truncated value must fit in the target type.
87
87
pub fn simd_cast < T , U > ( x : T ) -> U ;
88
88
89
89
/// Numerically cast a vector, elementwise.
90
90
///
91
+ /// `T` and `U` be a vectors of integer or floating point primitive types, and must have the
92
+ /// same length.
93
+ ///
91
94
/// Like `simd_cast`, but saturates float-to-integer conversions.
92
95
/// This matches regular `as` and is always safe.
93
96
///
94
97
/// When casting floats to integers, the result is truncated.
95
98
/// When casting integers to floats, the result is rounded.
96
99
/// Otherwise, truncates or extends the value, maintaining the sign for signed integers.
97
- ///
98
- /// `T` and `U` be a vectors of integer or floating point primitive types, and must have the
99
- /// same length.
100
100
pub fn simd_as < T , U > ( x : T ) -> U ;
101
101
102
102
/// Elementwise negation of a vector.
103
103
///
104
- /// Rust panics for `-<int>::Min` due to overflow, but it is not UB with this intrinsic.
105
- ///
106
104
/// `T` must be a vector of integer or floating-point primitive types.
105
+ ///
106
+ /// Rust panics for `-<int>::Min` due to overflow, but it is not UB with this intrinsic.
107
107
pub fn simd_neg < T > ( x : T ) -> T ;
108
108
109
109
/// Elementwise absolute value of a vector.
@@ -113,95 +113,96 @@ extern "platform-intrinsic" {
113
113
114
114
/// Elementwise minimum of a vector.
115
115
///
116
- /// Follows IEEE-754 `minNum` semantics.
117
- ///
118
116
/// `T` must be a vector of floating-point primitive types.
117
+ ///
118
+ /// Follows IEEE-754 `minNum` semantics.
119
119
pub fn simd_fmin < T > ( x : T , y : T ) -> T ;
120
120
121
121
/// Elementwise maximum of a vector.
122
122
///
123
- /// Follows IEEE-754 `maxNum` semantics.
124
- ///
125
123
/// `T` must be a vector of floating-point primitive types.
124
+ ///
125
+ /// Follows IEEE-754 `maxNum` semantics.
126
126
pub fn simd_fmax < T > ( x : T , y : T ) -> T ;
127
127
128
128
/// Tests elementwise equality of two vectors.
129
129
///
130
- /// Returns `0` for false and `!0` for true.
131
- ///
132
130
/// `T` must be a vector of floating-point primitive types.
131
+ ///
133
132
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
133
+ ///
134
+ /// Returns `0` for false and `!0` for true.
134
135
pub fn simd_eq < T , U > ( x : T , y : T ) -> U ;
135
136
136
137
/// Tests elementwise inequality equality of two vectors.
137
138
///
138
- /// Returns `0` for false and `!0` for true.
139
- ///
140
139
/// `T` must be a vector of floating-point primitive types.
141
140
///
142
141
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
142
+ ///
143
+ /// Returns `0` for false and `!0` for true.
143
144
pub fn simd_ne < T , U > ( x : T , y : T ) -> U ;
144
145
145
146
/// Tests if `x` is less than `y`, elementwise.
146
147
///
147
- /// Returns `0` for false and `!0` for true.
148
- ///
149
148
/// `T` must be a vector of floating-point primitive types.
150
149
///
151
150
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
151
+ ///
152
+ /// Returns `0` for false and `!0` for true.
152
153
pub fn simd_lt < T , U > ( x : T , y : T ) -> U ;
153
154
154
155
/// Tests if `x` is less than or equal to `y`, elementwise.
155
156
///
156
- /// Returns `0` for false and `!0` for true.
157
- ///
158
157
/// `T` must be a vector of floating-point primitive types.
159
158
///
160
159
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
160
+ ///
161
+ /// Returns `0` for false and `!0` for true.
161
162
pub fn simd_le < T , U > ( x : T , y : T ) -> U ;
162
163
163
164
/// Tests if `x` is greater than `y`, elementwise.
164
165
///
165
- /// Returns `0` for false and `!0` for true.
166
- ///
167
166
/// `T` must be a vector of floating-point primitive types.
168
167
///
169
168
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
169
+ ///
170
+ /// Returns `0` for false and `!0` for true.
170
171
pub fn simd_gt < T , U > ( x : T , y : T ) -> U ;
171
172
172
173
/// Tests if `x` is greater than or equal to `y`, elementwise.
173
174
///
174
- /// Returns `0` for false and `!0` for true.
175
- ///
176
175
/// `T` must be a vector of floating-point primitive types.
177
176
///
178
177
/// `U` must be a vector of integers with the same number of elements and element size as `T`.
178
+ ///
179
+ /// Returns `0` for false and `!0` for true.
179
180
pub fn simd_ge < T , U > ( x : T , y : T ) -> U ;
180
181
181
182
/// Shuffle two vectors by const indices.
182
183
///
183
- /// Concatenates `x` and `y`, then returns a new vector such that each element is selected from
184
- /// the concatenation by the matching index in `idx`.
185
- ///
186
184
/// `T` must be a vector.
187
185
///
188
186
/// `U` must be a const array of `i32`s.
189
187
///
190
188
/// `V` must be a vector with the same element type as `T` and the same length as `U`.
189
+ ///
190
+ /// Concatenates `x` and `y`, then returns a new vector such that each element is selected from
191
+ /// the concatenation by the matching index in `idx`.
191
192
pub fn simd_shuffle < T , U , V > ( x : T , y : T , idx : U ) -> V ;
192
193
193
194
/// Read a vector of pointers.
194
195
///
195
- /// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, read the pointer.
196
- /// Otherwise if the corresponding value in `mask` is `0`, return the corresponding value from
197
- /// `val`.
198
- ///
199
196
/// `T` must be a vector.
200
197
///
201
198
/// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`.
202
199
///
203
200
/// `V` must be a vector of integers with the same length as `T` (but any element size).
204
201
///
202
+ /// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, read the pointer.
203
+ /// Otherwise if the corresponding value in `mask` is `0`, return the corresponding value from
204
+ /// `val`.
205
+ ///
205
206
/// # Safety
206
207
/// Unmasked values in `T` must be readable as if by `<ptr>::read` (e.g. aligned to the element
207
208
/// type).
@@ -211,16 +212,16 @@ extern "platform-intrinsic" {
211
212
212
213
/// Write to a vector of pointers.
213
214
///
214
- /// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, write the
215
- /// corresponding value in `val` to the pointer.
216
- /// Otherwise if the corresponding value in `mask` is `0`, do nothing.
217
- ///
218
215
/// `T` must be a vector.
219
216
///
220
217
/// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`.
221
218
///
222
219
/// `V` must be a vector of integers with the same length as `T` (but any element size).
223
220
///
221
+ /// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, write the
222
+ /// corresponding value in `val` to the pointer.
223
+ /// Otherwise if the corresponding value in `mask` is `0`, do nothing.
224
+ ///
224
225
/// # Safety
225
226
/// Unmasked values in `T` must be writeable as if by `<ptr>::write` (e.g. aligned to the element
226
227
/// type).
@@ -235,27 +236,27 @@ extern "platform-intrinsic" {
235
236
236
237
/// Subtract two simd vectors elementwise, with saturation.
237
238
///
238
- /// Subtract `rhs` from `lhs`.
239
- ///
240
239
/// `T` must be a vector of integer primitive types.
240
+ ///
241
+ /// Subtract `rhs` from `lhs`.
241
242
pub fn simd_saturating_sub < T > ( lhs : T , rhs : T ) -> T ;
242
243
243
244
/// Add elements within a vector from left to right.
244
245
///
245
- /// Starting with the value `y`, add the elements of `x` and accumulate.
246
- ///
247
246
/// `T` must be a vector of integer or floating-point primitive types.
248
247
///
249
248
/// `U` must be the element type of `T`.
249
+ ///
250
+ /// Starting with the value `y`, add the elements of `x` and accumulate.
250
251
pub fn simd_reduce_add_ordered < T , U > ( x : T , y : U ) -> U ;
251
252
252
253
/// Multiply elements within a vector from left to right.
253
254
///
254
- /// Starting with the value `y`, multiply the elements of `x` and accumulate.
255
- ///
256
255
/// `T` must be a vector of integer or floating-point primitive types.
257
256
///
258
257
/// `U` must be the element type of `T`.
258
+ ///
259
+ /// Starting with the value `y`, multiply the elements of `x` and accumulate.
259
260
pub fn simd_reduce_mul_ordered < T , U > ( x : T , y : U ) -> U ;
260
261
261
262
/// Check if all mask values are true.
@@ -276,20 +277,20 @@ extern "platform-intrinsic" {
276
277
277
278
/// Return the maximum element of a vector.
278
279
///
279
- /// For floating-point values, uses IEEE-754 `maxNum`.
280
- ///
281
280
/// `T` must be a vector of integer or floating-point primitive types.
282
281
///
283
282
/// `U` must be the element type of `T`.
283
+ ///
284
+ /// For floating-point values, uses IEEE-754 `maxNum`.
284
285
pub fn simd_reduce_max < T , U > ( x : T ) -> U ;
285
286
286
287
/// Return the minimum element of a vector.
287
288
///
288
- /// For floating-point values, uses IEEE-754 `minNum`.
289
- ///
290
289
/// `T` must be a vector of integer or floating-point primitive types.
291
290
///
292
291
/// `U` must be the element type of `T`.
292
+ ///
293
+ /// For floating-point values, uses IEEE-754 `minNum`.
293
294
pub fn simd_reduce_min < T , U > ( x : T ) -> U ;
294
295
295
296
/// Logical "and" all elements together.
@@ -315,17 +316,17 @@ extern "platform-intrinsic" {
315
316
316
317
/// Truncate an integer vector to a bitmask.
317
318
///
319
+ /// `T` must be an integer vector.
320
+ ///
321
+ /// `U` must be either the smallest unsigned integer with at least as many bits as the length
322
+ ///
318
323
/// Each element is truncated to a single bit and packed into the result.
319
324
///
320
325
/// The bit order depends on the byte endianness.
321
326
/// The bitmask is always packed into the smallest/first bits, but the order is LSB-first for
322
327
/// little endian and MSB-first for big endian.
323
328
/// In other words, the LSB corresponds to the first vector element for little endian,
324
329
/// and the last vector element for big endian.
325
- ///
326
- /// `T` must be an integer vector.
327
- ///
328
- /// `U` must be either the smallest unsigned integer with at least as many bits as the length
329
330
/// of `T`, or the smallest array of `u8` with as many bits as the length of `T`.
330
331
///
331
332
/// # Safety
@@ -334,41 +335,41 @@ extern "platform-intrinsic" {
334
335
335
336
/// Select elements from a mask.
336
337
///
337
- /// For each element, if the corresponding value in `mask` is `!0`, select the element from
338
- /// `if_true`. If the corresponding value in `mask` is `0`, select the element from
339
- /// `if_false`.
340
- ///
341
338
/// `M` must be an integer vector.
342
339
///
343
340
/// `T` must be a vector with the same number of elements as `M`.
344
341
///
342
+ /// For each element, if the corresponding value in `mask` is `!0`, select the element from
343
+ /// `if_true`. If the corresponding value in `mask` is `0`, select the element from
344
+ /// `if_false`.
345
+ ///
345
346
/// # Safety
346
347
/// `mask` must only contain `0` and `!0`.
347
348
pub fn simd_select < M , T > ( mask : M , if_true : T , if_false : T ) -> T ;
348
349
349
350
/// Select elements from a bitmask.
350
351
///
352
+ /// `M` must be an unsigned integer of type matching `simd_bitmask`.
353
+ ///
354
+ /// `T` must be a vector.
355
+ ///
351
356
/// For each element, if the bit in `mask` is `1`, select the element from
352
357
/// `if_true`. If the corresponding bit in `mask` is `0`, select the element from
353
358
/// `if_false`.
354
359
///
355
360
/// The bitmask bit order matches `simd_bitmask`.
356
361
///
357
- /// `M` must be an unsigned integer of type matching `simd_bitmask`.
358
- ///
359
- /// `T` must be a vector.
360
- ///
361
362
/// # Safety
362
363
/// `mask` must only contain `0` and `!0`.
363
364
pub fn simd_select_bitmask < M , T > ( m : M , yes : T , no : T ) -> T ;
364
365
365
366
/// Elementwise calculates the offset from a pointer vector, potentially wrapping.
366
367
///
367
- /// Operates as if by `<ptr>::wrapping_offset`.
368
- ///
369
368
/// `T` must be a vector of pointers.
370
369
///
371
370
/// `U` must be a vector of `isize` or `usize` with the same number of elements as `T`.
371
+ ///
372
+ /// Operates as if by `<ptr>::wrapping_offset`.
372
373
pub fn simd_arith_offset < T , U > ( ptr : T , offset : U ) -> T ;
373
374
374
375
/// Cast a vector of pointers.
0 commit comments