Skip to content

Commit aebad29

Browse files
committed
Sync from rust 419b3e2
2 parents 6ef4582 + b52c07f commit aebad29

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ index 7165c3e48af..968552ad435 100644
1616

1717
[dependencies]
1818
core = { path = "../core" }
19-
-compiler_builtins = { version = "=0.1.140", features = ['rustc-dep-of-std'] }
20-
+compiler_builtins = { version = "=0.1.140", features = ['rustc-dep-of-std', 'no-f16-f128'] }
19+
-compiler_builtins = { version = "=0.1.143", features = ['rustc-dep-of-std'] }
20+
+compiler_builtins = { version = "=0.1.143", features = ['rustc-dep-of-std', 'no-f16-f128'] }
2121

2222
[dev-dependencies]
2323
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

src/codegen_i128.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,22 @@ pub(crate) fn maybe_codegen_mul_checked<'tcx>(
7676
}
7777

7878
let is_signed = type_sign(lhs.layout().ty);
79-
80-
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
81-
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
79+
let oflow_out_place = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
8280
let param_types = vec![
83-
AbiParam::special(fx.pointer_type, ArgumentPurpose::StructReturn),
8481
AbiParam::new(types::I128),
8582
AbiParam::new(types::I128),
83+
AbiParam::special(fx.pointer_type, ArgumentPurpose::Normal),
8684
];
87-
let args = [out_place.to_ptr().get_addr(fx), lhs.load_scalar(fx), rhs.load_scalar(fx)];
88-
fx.lib_call(
85+
let args = [lhs.load_scalar(fx), rhs.load_scalar(fx), oflow_out_place.to_ptr().get_addr(fx)];
86+
let ret = fx.lib_call(
8987
if is_signed { "__rust_i128_mulo" } else { "__rust_u128_mulo" },
9088
param_types,
91-
vec![],
89+
vec![AbiParam::new(types::I128)],
9290
&args,
9391
);
94-
Some(out_place.to_cvalue(fx))
92+
let mul = ret[0];
93+
let oflow = oflow_out_place.to_cvalue(fx).load_scalar(fx);
94+
let oflow = clif_intcast(fx, oflow, types::I8, false);
95+
let layout = fx.layout_of(Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]));
96+
Some(CValue::by_val_pair(mul, oflow, layout))
9597
}

src/compiler_builtins.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ builtin_functions! {
4343
fn __divti3(n: i128, d: i128) -> i128;
4444
fn __umodti3(n: u128, d: u128) -> u128;
4545
fn __modti3(n: i128, d: i128) -> i128;
46-
fn __rust_u128_mulo(a: u128, b: u128) -> (u128, bool);
46+
fn __rust_u128_mulo(a: u128, b: u128, oflow: &mut i32) -> u128;
4747

4848
// floats
4949
fn __floattisf(i: i128) -> f32;

0 commit comments

Comments
 (0)