Skip to content

Commit 8f8f41c

Browse files
committed
---
yaml --- r: 233460 b: refs/heads/beta c: ecb3df5 h: refs/heads/master v: v3
1 parent cc1ad3e commit 8f8f41c

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: f1d3b0271ef62e52e65962744701861c32534114
26+
refs/heads/beta: ecb3df5a91b71e31e242737d9203b2798bd489de
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_trans/trans/intrinsic.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,5 +1445,56 @@ fn generic_simd_intrinsic<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
14451445
"SIMD insert intrinsic monomorphised with returned type not SIMD element type");
14461446
return ExtractElement(bcx, llargs[0], llargs[1])
14471447
}
1448+
1449+
if name == "simd_cast" {
1450+
require!(arg_tys[0].simd_size(tcx) == ret_ty.simd_size(tcx),
1451+
"SIMD cast intrinsic monomorphised with input and \
1452+
return types of different lengths");
1453+
// casting cares about nominal type, not just structural type
1454+
let in_ = arg_tys[0].simd_type(tcx);
1455+
let out = ret_ty.simd_type(tcx);
1456+
1457+
if in_ == out { return llargs[0]; }
1458+
1459+
match (&in_.sty, &out.sty) {
1460+
(&ty::TyInt(lhs), &ty::TyUint(rhs)) => {
1461+
match (lhs, rhs) {
1462+
(ast::TyI8, ast::TyU8) |
1463+
(ast::TyI16, ast::TyU16) |
1464+
(ast::TyI32, ast::TyU32) |
1465+
(ast::TyI64, ast::TyU64) => return llargs[0],
1466+
_ => {},
1467+
}
1468+
}
1469+
(&ty::TyUint(lhs), &ty::TyInt(rhs)) => {
1470+
match (lhs, rhs) {
1471+
(ast::TyU8, ast::TyI8) |
1472+
(ast::TyU16, ast::TyI16) |
1473+
(ast::TyU32, ast::TyI32) |
1474+
(ast::TyU64, ast::TyI64) => return llargs[0],
1475+
_ => {},
1476+
}
1477+
}
1478+
(&ty::TyInt(ast::TyI32), &ty::TyFloat(ast::TyF32)) |
1479+
(&ty::TyInt(ast::TyI64), &ty::TyFloat(ast::TyF64)) => {
1480+
return SIToFP(bcx, llargs[0], llret_ty)
1481+
}
1482+
(&ty::TyUint(ast::TyU32), &ty::TyFloat(ast::TyF32)) |
1483+
(&ty::TyUint(ast::TyU64), &ty::TyFloat(ast::TyF64)) => {
1484+
return UIToFP(bcx, llargs[0], llret_ty)
1485+
}
1486+
1487+
(&ty::TyFloat(ast::TyF32), &ty::TyInt(ast::TyI32)) |
1488+
(&ty::TyFloat(ast::TyF64), &ty::TyInt(ast::TyI64)) => {
1489+
return FPToSI(bcx, llargs[0], llret_ty)
1490+
}
1491+
(&ty::TyFloat(ast::TyF32), &ty::TyUint(ast::TyU32)) |
1492+
(&ty::TyFloat(ast::TyF64), &ty::TyUint(ast::TyU64)) => {
1493+
return FPToUI(bcx, llargs[0], llret_ty)
1494+
}
1495+
_ => {}
1496+
}
1497+
require!(false, "SIMD cast intrinsic monomorphised with incompatible cast");
1498+
}
14481499
bcx.sess().span_bug(call_info.span, "unknown SIMD intrinsic");
14491500
}

branches/beta/src/librustc_trans/trans/type_of.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
182182
None => ()
183183
}
184184

185+
debug!("sizing_type_of {:?}", t);
185186
let llsizingty = match t.sty {
186187
_ if !type_is_sized(cx.tcx(), t) => {
187188
Type::struct_(cx, &[Type::i8p(cx), Type::i8p(cx)], false)
@@ -240,6 +241,10 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
240241
ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => unreachable!()
241242
};
242243

244+
debug!("--> mapped t={:?} to llsizingty={}",
245+
t,
246+
cx.tn().type_to_string(llsizingty));
247+
243248
cx.llsizingtypes().borrow_mut().insert(t, llsizingty);
244249
llsizingty
245250
}
@@ -426,8 +431,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
426431
ty::TyError(..) => cx.sess().bug("type_of with TyError"),
427432
};
428433

429-
debug!("--> mapped t={:?} {:?} to llty={}",
430-
t,
434+
debug!("--> mapped t={:?} to llty={}",
431435
t,
432436
cx.tn().type_to_string(llty));
433437

branches/beta/src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5346,6 +5346,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
53465346
}
53475347
"simd_insert" => (2, vec![param(ccx, 0), tcx.types.u32, param(ccx, 1)], param(ccx, 0)),
53485348
"simd_extract" => (2, vec![param(ccx, 0), tcx.types.u32], param(ccx, 1)),
5349+
"simd_cast" => (2, vec![param(ccx, 0)], param(ccx, 1)),
53495350
name if name.starts_with("simd_shuffle") => {
53505351
match name["simd_shuffle".len()..].parse() {
53515352
Ok(n) => {

0 commit comments

Comments
 (0)