about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-02-06 16:58:05 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-02-17 18:20:34 +0000
commite58bb2acbd3a2c61d4c492c322e9c53ed3068489 (patch)
tree9eaf4c7414a0b7da8065a9f3641abcaebd1d62e1
parentcdf4f4287a7727b72a2f7f47a88ca1d450fdafd0 (diff)
downloadrust-e58bb2acbd3a2c61d4c492c322e9c53ed3068489.tar.gz
rust-e58bb2acbd3a2c61d4c492c322e9c53ed3068489.zip
Use new abi for 128bit int to float cast intrinsics on Windows
-rw-r--r--src/cast.rs28
-rw-r--r--src/lib.rs2
2 files changed, 23 insertions, 7 deletions
diff --git a/src/cast.rs b/src/cast.rs
index 8c23152cda7..0ab29f335a0 100644
--- a/src/cast.rs
+++ b/src/cast.rs
@@ -64,12 +64,28 @@ pub(crate) fn clif_int_or_float_cast(
                 },
             );
 
-            return fx.lib_call(
-                &name,
-                vec![AbiParam::new(types::I128)],
-                vec![AbiParam::new(to_ty)],
-                &[from],
-            )[0];
+            if fx.tcx.sess.target.is_like_windows {
+                let arg_place = CPlace::new_stack_slot(
+                    fx,
+                    fx.layout_of(if from_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }),
+                );
+                let arg_ptr = arg_place.to_ptr();
+                arg_ptr.store(fx, from, MemFlags::trusted());
+                let args = [arg_ptr.get_addr(fx)];
+                return fx.lib_call(
+                    &name,
+                    vec![AbiParam::new(fx.pointer_type)],
+                    vec![AbiParam::new(to_ty)],
+                    &args,
+                )[0];
+            } else {
+                return fx.lib_call(
+                    &name,
+                    vec![AbiParam::new(types::I128)],
+                    vec![AbiParam::new(to_ty)],
+                    &[from],
+                )[0];
+            }
         }
 
         // int-like -> float
diff --git a/src/lib.rs b/src/lib.rs
index c7fe382bac4..5b69bc7cc9b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -188,7 +188,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
     }
 
     fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> {
-        vec![]
+        vec![Symbol::intern("llvm14-builtins-abi")]
     }
 
     fn print_version(&self) {