1
Fork 0

Implement 128bit checked add and sub

This commit is contained in:
bjorn3 2019-07-24 13:16:36 +02:00
parent 4d35be684d
commit 63b82238bb
3 changed files with 17 additions and 29 deletions

View file

@ -23,8 +23,20 @@ pub fn maybe_codegen<'a, 'tcx>(
assert!(!checked);
return None;
}
BinOp::Add | BinOp::Sub => {
return None; // FIXME implement checked versions
BinOp::Add | BinOp::Sub if !checked => return None,
BinOp::Add => {
return Some(if is_signed {
fx.easy_call("__rust_i128_addo", &[lhs, rhs], out_ty)
} else {
fx.easy_call("__rust_u128_addo", &[lhs, rhs], out_ty)
})
}
BinOp::Sub => {
return Some(if is_signed {
fx.easy_call("__rust_i128_subo", &[lhs, rhs], out_ty)
} else {
fx.easy_call("__rust_u128_subo", &[lhs, rhs], out_ty)
})
}
BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"),
BinOp::Mul => {