about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-02-17 18:31:41 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-02-17 18:40:22 +0000
commit29ad465127eb9f048e02a0b320e59cb0c7717134 (patch)
tree87c285b75d3803cfab11a02eec1b6298c33d0ea3
parentc6a0d3716b3ffa5be96c161bb4d82ea007463021 (diff)
downloadrust-29ad465127eb9f048e02a0b320e59cb0c7717134.tar.gz
rust-29ad465127eb9f048e02a0b320e59cb0c7717134.zip
Fix float to int compiler builtin call abi
-rw-r--r--src/cast.rs29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/cast.rs b/src/cast.rs
index 8c23152cda7..032d1151041 100644
--- a/src/cast.rs
+++ b/src/cast.rs
@@ -96,12 +96,29 @@ pub(crate) fn clif_int_or_float_cast(
                 },
             );
 
-            fx.lib_call(
-                &name,
-                vec![AbiParam::new(from_ty)],
-                vec![AbiParam::new(types::I128)],
-                &[from],
-            )[0]
+            if fx.tcx.sess.target.is_like_windows {
+                let ret = fx.lib_call(
+                    &name,
+                    vec![AbiParam::new(from_ty)],
+                    vec![AbiParam::new(types::I64X2)],
+                    &[from],
+                )[0];
+                // FIXME use bitcast instead of store to get from i64x2 to i128
+                let stack_slot = fx.bcx.create_sized_stack_slot(StackSlotData {
+                    kind: StackSlotKind::ExplicitSlot,
+                    size: 16,
+                });
+                let ret_ptr = Pointer::stack_slot(stack_slot);
+                ret_ptr.store(fx, ret, MemFlags::trusted());
+                ret_ptr.load(fx, types::I128, MemFlags::trusted())
+            } else {
+                fx.lib_call(
+                    &name,
+                    vec![AbiParam::new(from_ty)],
+                    vec![AbiParam::new(types::I128)],
+                    &[from],
+                )[0]
+            }
         } else if to_ty == types::I8 || to_ty == types::I16 {
             // FIXME implement fcvt_to_*int_sat.i8/i16
             let val = if to_signed {