Skip to content

Commit c2095c4

Browse files
committed
Rustup to rustc 1.35.0-nightly (87a4363 2019-03-03)
1 parent 2ce5387 commit c2095c4

File tree

3 files changed

+33
-167
lines changed

3 files changed

+33
-167
lines changed

patches/0009-Workaround-missing-saturating_-add-sub-intrinsic-imp.patch

Lines changed: 0 additions & 166 deletions
This file was deleted.

src/base.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ fn trans_stmt<'a, 'tcx: 'a>(
515515
_ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", ty),
516516
}
517517
}
518-
Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => {
518+
Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty)
519+
| Rvalue::Cast(CastKind::MutToConstPointer, operand, ty) => {
519520
let operand = trans_operand(fx, operand);
520521
let layout = fx.layout_of(ty);
521522
lval.write_cvalue(fx, operand.unchecked_cast_to(layout));

src/intrinsics.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
192192
ret.write_cvalue(fx, type_id);
193193
};
194194
_ if intrinsic.starts_with("unchecked_") || intrinsic == "exact_div", (c x, c y) {
195+
// FIXME trap on overflow
195196
let bin_op = match intrinsic {
196197
"unchecked_div" | "exact_div" => BinOp::Div,
197198
"unchecked_rem" => BinOp::Rem,
@@ -278,6 +279,36 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
278279
};
279280
ret.write_cvalue(fx, res);
280281
};
282+
_ if intrinsic.starts_with("saturating_"), <T> (c x, c y) {
283+
// FIXME implement saturating behavior
284+
assert_eq!(x.layout().ty, y.layout().ty);
285+
let bin_op = match intrinsic {
286+
"saturating_add" => BinOp::Add,
287+
"saturating_sub" => BinOp::Sub,
288+
"saturating_mul" => BinOp::Mul,
289+
_ => unimplemented!("intrinsic {}", intrinsic),
290+
};
291+
let res = match T.sty {
292+
ty::Uint(_) => crate::base::trans_int_binop(
293+
fx,
294+
bin_op,
295+
x,
296+
y,
297+
ret.layout().ty,
298+
false,
299+
),
300+
ty::Int(_) => crate::base::trans_int_binop(
301+
fx,
302+
bin_op,
303+
x,
304+
y,
305+
ret.layout().ty,
306+
true,
307+
),
308+
_ => panic!(),
309+
};
310+
ret.write_cvalue(fx, res);
311+
};
281312
rotate_left, <T>(v x, v y) {
282313
let layout = fx.layout_of(T);
283314
let res = fx.bcx.ins().rotl(x, y);

0 commit comments

Comments
 (0)