Skip to content

Commit 1492584

Browse files
committed
---
yaml --- r: 232461 b: refs/heads/try c: ecb3df5 h: refs/heads/master i: 232459: 38cc8d3 v: v3
1 parent dd70b81 commit 1492584

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: f1d3b0271ef62e52e65962744701861c32534114
4+
refs/heads/try: ecb3df5a91b71e31e242737d9203b2798bd489de
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/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/try/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/try/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)