Skip to content

Commit b70ad2d

Browse files
committed
Remove unneeded libcalls from codegen_i128.rs
1 parent b929b68 commit b70ad2d

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

src/codegen_i128.rs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,7 @@ pub(crate) fn maybe_codegen<'tcx>(
2323
match bin_op {
2424
BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => None,
2525
BinOp::Add | BinOp::AddUnchecked | BinOp::Sub | BinOp::SubUnchecked => None,
26-
BinOp::Mul | BinOp::MulUnchecked => {
27-
let args = [lhs.load_scalar(fx), rhs.load_scalar(fx)];
28-
let ret_val = fx.lib_call(
29-
"__multi3",
30-
vec![AbiParam::new(types::I128), AbiParam::new(types::I128)],
31-
vec![AbiParam::new(types::I128)],
32-
&args,
33-
)[0];
34-
Some(CValue::by_val(
35-
ret_val,
36-
fx.layout_of(if is_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }),
37-
))
38-
}
26+
BinOp::Mul | BinOp::MulUnchecked => None,
3927
BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"),
4028
BinOp::Div | BinOp::Rem => {
4129
let name = match (bin_op, is_signed) {
@@ -92,6 +80,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
9280

9381
match bin_op {
9482
BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => unreachable!(),
83+
BinOp::Add | BinOp::Sub => None,
9584
BinOp::Mul if is_signed => {
9685
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
9786
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
@@ -112,7 +101,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
112101
let oflow = fx.bcx.ins().ireduce(types::I8, oflow);
113102
Some(CValue::by_val_pair(res, oflow, fx.layout_of(out_ty)))
114103
}
115-
BinOp::Add | BinOp::Sub | BinOp::Mul => {
104+
BinOp::Mul => {
116105
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
117106
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
118107
let param_types = vec![
@@ -121,15 +110,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
121110
AbiParam::new(types::I128),
122111
];
123112
let args = [out_place.to_ptr().get_addr(fx), lhs.load_scalar(fx), rhs.load_scalar(fx)];
124-
let name = match (bin_op, is_signed) {
125-
(BinOp::Add, false) => "__rust_u128_addo",
126-
(BinOp::Add, true) => "__rust_i128_addo",
127-
(BinOp::Sub, false) => "__rust_u128_subo",
128-
(BinOp::Sub, true) => "__rust_i128_subo",
129-
(BinOp::Mul, false) => "__rust_u128_mulo",
130-
_ => unreachable!(),
131-
};
132-
fx.lib_call(name, param_types, vec![], &args);
113+
fx.lib_call("__rust_u128_mulo", param_types, vec![], &args);
133114
Some(out_place.to_cvalue(fx))
134115
}
135116
BinOp::AddUnchecked | BinOp::SubUnchecked | BinOp::MulUnchecked => unreachable!(),

src/compiler_builtins.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,12 @@ builtin_functions! {
3838
register_functions_for_jit;
3939

4040
// integers
41-
fn __multi3(a: i128, b: i128) -> i128;
4241
fn __muloti4(n: i128, d: i128, oflow: &mut i32) -> i128;
4342
fn __udivti3(n: u128, d: u128) -> u128;
4443
fn __divti3(n: i128, d: i128) -> i128;
4544
fn __umodti3(n: u128, d: u128) -> u128;
4645
fn __modti3(n: i128, d: i128) -> i128;
47-
fn __rust_u128_addo(a: u128, b: u128) -> (u128, bool);
48-
fn __rust_i128_addo(a: i128, b: i128) -> (i128, bool);
49-
fn __rust_u128_subo(a: u128, b: u128) -> (u128, bool);
50-
fn __rust_i128_subo(a: i128, b: i128) -> (i128, bool);
5146
fn __rust_u128_mulo(a: u128, b: u128) -> (u128, bool);
52-
fn __rust_i128_mulo(a: i128, b: i128) -> (i128, bool);
5347

5448
// floats
5549
fn __floattisf(i: i128) -> f32;

0 commit comments

Comments
 (0)