Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e58bb2a

Browse files
committed
Use new abi for 128bit int to float cast intrinsics on Windows
1 parent cdf4f42 commit e58bb2a

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/cast.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,28 @@ pub(crate) fn clif_int_or_float_cast(
6464
},
6565
);
6666

67-
return fx.lib_call(
68-
&name,
69-
vec![AbiParam::new(types::I128)],
70-
vec![AbiParam::new(to_ty)],
71-
&[from],
72-
)[0];
67+
if fx.tcx.sess.target.is_like_windows {
68+
let arg_place = CPlace::new_stack_slot(
69+
fx,
70+
fx.layout_of(if from_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }),
71+
);
72+
let arg_ptr = arg_place.to_ptr();
73+
arg_ptr.store(fx, from, MemFlags::trusted());
74+
let args = [arg_ptr.get_addr(fx)];
75+
return fx.lib_call(
76+
&name,
77+
vec![AbiParam::new(fx.pointer_type)],
78+
vec![AbiParam::new(to_ty)],
79+
&args,
80+
)[0];
81+
} else {
82+
return fx.lib_call(
83+
&name,
84+
vec![AbiParam::new(types::I128)],
85+
vec![AbiParam::new(to_ty)],
86+
&[from],
87+
)[0];
88+
}
7389
}
7490

7591
// int-like -> float

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
188188
}
189189

190190
fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> {
191-
vec![]
191+
vec![Symbol::intern("llvm14-builtins-abi")]
192192
}
193193

194194
fn print_version(&self) {

0 commit comments

Comments
 (0)