@@ -239,7 +239,52 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
239
239
"transmute" => {
240
240
self . copy_op_transmute ( args[ 0 ] , dest) ?;
241
241
}
242
+ "simd_insert" => {
243
+ let index = self . read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ? as u64 ;
244
+ let scalar = args[ 2 ] ;
245
+ let input = args[ 0 ] ;
246
+ let ( len, e_ty) = self . read_vector_ty ( input) ;
247
+ assert ! (
248
+ index < len,
249
+ "Index `{}` must be in bounds of vector type `{}`: `[0, {})`" ,
250
+ index, e_ty, len
251
+ ) ;
252
+ assert_eq ! (
253
+ input. layout, dest. layout,
254
+ "Return type `{}` must match vector type `{}`" ,
255
+ dest. layout. ty, input. layout. ty
256
+ ) ;
257
+ assert_eq ! (
258
+ scalar. layout. ty, e_ty,
259
+ "Scalar type `{}` must match vector element type `{}`" ,
260
+ scalar. layout. ty, e_ty
261
+ ) ;
242
262
263
+ for i in 0 ..len {
264
+ let place = self . place_field ( dest, i) ?;
265
+ let value = if i == index {
266
+ scalar
267
+ } else {
268
+ self . operand_field ( input, i) ?
269
+ } ;
270
+ self . copy_op ( value, place) ?;
271
+ }
272
+ }
273
+ "simd_extract" => {
274
+ let index = self . read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ? as _ ;
275
+ let ( len, e_ty) = self . read_vector_ty ( args[ 0 ] ) ;
276
+ assert ! (
277
+ index < len,
278
+ "index `{}` is out-of-bounds of vector type `{}` with length `{}`" ,
279
+ index, e_ty, len
280
+ ) ;
281
+ assert_eq ! (
282
+ e_ty, dest. layout. ty,
283
+ "Return type `{}` must match vector element type `{}`" ,
284
+ dest. layout. ty, e_ty
285
+ ) ;
286
+ self . copy_op ( self . operand_field ( args[ 0 ] , index) ?, dest) ?;
287
+ }
243
288
_ => return Ok ( false ) ,
244
289
}
245
290
0 commit comments