Skip to content

Commit

Permalink
Avoid depending on unadjusted abi
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Dec 5, 2024
1 parent 16181b5 commit ff37ef2
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/codegen_i128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,15 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
BinOp::Add | BinOp::Sub => None,
BinOp::Mul if is_signed => {
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
let lhs = lhs.load_scalar(fx);
let rhs = rhs.load_scalar(fx);
let oflow_ptr = oflow.to_ptr().get_addr(fx);
let res = fx.lib_call_unadjusted(
"__muloti4",
vec![
AbiParam::new(types::I128),
AbiParam::new(types::I128),
AbiParam::new(fx.pointer_type),
],
vec![AbiParam::new(types::I128)],
&[lhs, rhs, oflow_ptr],
)[0];
let oflow = oflow.to_cvalue(fx).load_scalar(fx);
let oflow = fx.bcx.ins().ireduce(types::I8, oflow);
Some(CValue::by_val_pair(res, oflow, fx.layout_of(out_ty)))
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
let param_types = vec![
AbiParam::special(fx.pointer_type, ArgumentPurpose::StructReturn),
AbiParam::new(types::I128),
AbiParam::new(types::I128),
];
let args = [out_place.to_ptr().get_addr(fx), lhs.load_scalar(fx), rhs.load_scalar(fx)];
fx.lib_call("__rust_i128_mulo", param_types, vec![], &args);
Some(out_place.to_cvalue(fx))
}
BinOp::Mul => {
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
Expand Down

0 comments on commit ff37ef2

Please sign in to comment.