Skip to content

Commit ff37ef2

Browse files
committed
Avoid depending on unadjusted abi
1 parent 16181b5 commit ff37ef2

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/codegen_i128.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,15 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
8383
BinOp::Add | BinOp::Sub => None,
8484
BinOp::Mul if is_signed => {
8585
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
86-
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
87-
let lhs = lhs.load_scalar(fx);
88-
let rhs = rhs.load_scalar(fx);
89-
let oflow_ptr = oflow.to_ptr().get_addr(fx);
90-
let res = fx.lib_call_unadjusted(
91-
"__muloti4",
92-
vec![
93-
AbiParam::new(types::I128),
94-
AbiParam::new(types::I128),
95-
AbiParam::new(fx.pointer_type),
96-
],
97-
vec![AbiParam::new(types::I128)],
98-
&[lhs, rhs, oflow_ptr],
99-
)[0];
100-
let oflow = oflow.to_cvalue(fx).load_scalar(fx);
101-
let oflow = fx.bcx.ins().ireduce(types::I8, oflow);
102-
Some(CValue::by_val_pair(res, oflow, fx.layout_of(out_ty)))
86+
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
87+
let param_types = vec![
88+
AbiParam::special(fx.pointer_type, ArgumentPurpose::StructReturn),
89+
AbiParam::new(types::I128),
90+
AbiParam::new(types::I128),
91+
];
92+
let args = [out_place.to_ptr().get_addr(fx), lhs.load_scalar(fx), rhs.load_scalar(fx)];
93+
fx.lib_call("__rust_i128_mulo", param_types, vec![], &args);
94+
Some(out_place.to_cvalue(fx))
10395
}
10496
BinOp::Mul => {
10597
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);

0 commit comments

Comments
 (0)