Skip to content

Commit 78eead6

Browse files
committed
Implement the simd_insert/simd_extract intrinsics.
1 parent 9af385b commit 78eead6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/librustc_trans/trans/intrinsic.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,5 +1426,24 @@ fn generic_simd_intrinsic<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
14261426

14271427
return ShuffleVector(bcx, llargs[0], llargs[1], C_vector(&indices))
14281428
}
1429-
C_null(llret_ty)
1429+
1430+
if name == "simd_insert" {
1431+
require!(arg_tys[0].is_simd(tcx),
1432+
"SIMD insert intrinsic monomorphised for non-SIMD input type");
1433+
1434+
let elem_ty = arg_tys[0].simd_type(tcx);
1435+
require!(arg_tys[2] == elem_ty,
1436+
"SIMD insert intrinsic monomorphised with inserted type not SIMD element type");
1437+
return InsertElement(bcx, llargs[0], llargs[2], llargs[1])
1438+
}
1439+
if name == "simd_extract" {
1440+
require!(arg_tys[0].is_simd(tcx),
1441+
"SIMD insert intrinsic monomorphised for non-SIMD input type");
1442+
1443+
let elem_ty = arg_tys[0].simd_type(tcx);
1444+
require!(ret_ty == elem_ty,
1445+
"SIMD insert intrinsic monomorphised with returned type not SIMD element type");
1446+
return ExtractElement(bcx, llargs[0], llargs[1])
1447+
}
1448+
bcx.sess().span_bug(call_info.span, "unknown SIMD intrinsic");
14301449
}

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5344,6 +5344,8 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
53445344
"simd_eq" | "simd_ne" | "simd_lt" | "simd_le" | "simd_gt" | "simd_ge" => {
53455345
(2, vec![param(ccx, 0), param(ccx, 0)], param(ccx, 1))
53465346
}
5347+
"simd_insert" => (2, vec![param(ccx, 0), tcx.types.u32, param(ccx, 1)], param(ccx, 0)),
5348+
"simd_extract" => (2, vec![param(ccx, 0), tcx.types.u32], param(ccx, 1)),
53475349
name if name.starts_with("simd_shuffle") => {
53485350
match name["simd_shuffle".len()..].parse() {
53495351
Ok(n) => {

0 commit comments

Comments
 (0)