浏览代码

Merge pull request #234 from ketsuban/master

Add __floatdisf and __floatundisf intrinsics
Alex Crichton 7 年之前
父节点
当前提交
cb04a0718b
共有 3 个文件被更改,包括 22 次插入4 次删除
  1. 2 2
      README.md
  2. 0 2
      build.rs
  3. 20 0
      src/float/conv.rs

+ 2 - 2
README.md

@@ -156,11 +156,11 @@ features = ["c"]
 - [x] fixunssfdi.c
 - [x] fixunssfdi.c
 - [x] fixunssfsi.c
 - [x] fixunssfsi.c
 - [x] floatdidf.c
 - [x] floatdidf.c
-- [ ] floatdisf.c
+- [x] floatdisf.c
 - [x] floatsidf.c
 - [x] floatsidf.c
 - [x] floatsisf.c
 - [x] floatsisf.c
 - [x] floatundidf.c
 - [x] floatundidf.c
-- [ ] floatundisf.c
+- [x] floatundisf.c
 - [x] floatunsidf.c
 - [x] floatunsidf.c
 - [x] floatunsisf.c
 - [x] floatunsisf.c
 - [ ] i386/ashldi3.S
 - [ ] i386/ashldi3.S

+ 0 - 2
build.rs

@@ -174,8 +174,6 @@ mod c {
                 "divsc3.c",
                 "divsc3.c",
                 "divxc3.c",
                 "divxc3.c",
                 "extendhfsf2.c",
                 "extendhfsf2.c",
-                "floatdisf.c",
-                "floatundisf.c",
                 "int_util.c",
                 "int_util.c",
                 "muldc3.c",
                 "muldc3.c",
                 "mulsc3.c",
                 "mulsc3.c",

+ 20 - 0
src/float/conv.rs

@@ -80,6 +80,18 @@ intrinsics! {
         int_to_float!(i, i32, f64)
         int_to_float!(i, i32, f64)
     }
     }
 
 
+    #[use_c_shim_if(all(target_arch = "x86", not(target_env = "msvc")))]
+    #[arm_aeabi_alias = __aeabi_l2f]
+    pub extern "C" fn __floatdisf(i: i64) -> f32 {
+        // On x86_64 LLVM will use native instructions for this conversion, we
+        // can just do it directly
+        if cfg!(target_arch = "x86_64") {
+            i as f32
+        } else {
+            int_to_float!(i, i64, f32)
+        }
+    }
+
     #[use_c_shim_if(all(target_arch = "x86", not(target_env = "msvc")))]
     #[use_c_shim_if(all(target_arch = "x86", not(target_env = "msvc")))]
     #[arm_aeabi_alias = __aeabi_l2d]
     #[arm_aeabi_alias = __aeabi_l2d]
     pub extern "C" fn __floatdidf(i: i64) -> f64 {
     pub extern "C" fn __floatdidf(i: i64) -> f64 {
@@ -112,6 +124,14 @@ intrinsics! {
         int_to_float!(i, u32, f64)
         int_to_float!(i, u32, f64)
     }
     }
 
 
+    #[use_c_shim_if(all(not(target_env = "msvc"),
+                        any(target_arch = "x86",
+                            all(not(windows), target_arch = "x86_64"))))]
+    #[arm_aeabi_alias = __aeabi_ul2f]
+    pub extern "C" fn __floatundisf(i: u64) -> f32 {
+        int_to_float!(i, u64, f32)
+    }
+
     #[use_c_shim_if(all(not(target_env = "msvc"),
     #[use_c_shim_if(all(not(target_env = "msvc"),
                         any(target_arch = "x86",
                         any(target_arch = "x86",
                             all(not(windows), target_arch = "x86_64"))))]
                             all(not(windows), target_arch = "x86_64"))))]