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

Commit 29ad465

Browse files
committed
Fix float to int compiler builtin call abi
1 parent c6a0d37 commit 29ad465

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/cast.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,29 @@ pub(crate) fn clif_int_or_float_cast(
9696
},
9797
);
9898

99-
fx.lib_call(
100-
&name,
101-
vec![AbiParam::new(from_ty)],
102-
vec![AbiParam::new(types::I128)],
103-
&[from],
104-
)[0]
99+
if fx.tcx.sess.target.is_like_windows {
100+
let ret = fx.lib_call(
101+
&name,
102+
vec![AbiParam::new(from_ty)],
103+
vec![AbiParam::new(types::I64X2)],
104+
&[from],
105+
)[0];
106+
// FIXME use bitcast instead of store to get from i64x2 to i128
107+
let stack_slot = fx.bcx.create_sized_stack_slot(StackSlotData {
108+
kind: StackSlotKind::ExplicitSlot,
109+
size: 16,
110+
});
111+
let ret_ptr = Pointer::stack_slot(stack_slot);
112+
ret_ptr.store(fx, ret, MemFlags::trusted());
113+
ret_ptr.load(fx, types::I128, MemFlags::trusted())
114+
} else {
115+
fx.lib_call(
116+
&name,
117+
vec![AbiParam::new(from_ty)],
118+
vec![AbiParam::new(types::I128)],
119+
&[from],
120+
)[0]
121+
}
105122
} else if to_ty == types::I8 || to_ty == types::I16 {
106123
// FIXME implement fcvt_to_*int_sat.i8/i16
107124
let val = if to_signed {

0 commit comments

Comments
 (0)