Browse Source

Remove truncdfsf2.c from sources in build.rs and add test for __truncdfsf2vfp

Also fixed the calling convention for truncdfsf2 on ARM
Ayrton 3 years ago
parent
commit
f654edbaee
5 changed files with 12 additions and 11 deletions
  1. 1 1
      README.md
  2. 0 1
      build.rs
  3. 2 9
      examples/intrinsics.rs
  4. 1 0
      src/float/trunc.rs
  5. 8 0
      testcrate/tests/misc.rs

+ 1 - 1
README.md

@@ -126,7 +126,7 @@ features = ["c"]
 - [x] arm/softfloat-alias.list
 - [x] arm/subdf3vfp.S
 - [x] arm/subsf3vfp.S
-- [ ] arm/truncdfsf2vfp.S
+- [x] arm/truncdfsf2vfp.S
 - [ ] arm/udivmodsi4.S (generic version is done)
 - [ ] arm/udivsi3.S (generic version is done)
 - [ ] arm/umodsi3.S (generic version is done)

+ 0 - 1
build.rs

@@ -227,7 +227,6 @@ mod c {
                 ("__negsf2", "negsf2.c"),
                 ("__powixf2", "powixf2.c"),
                 ("__truncdfhf2", "truncdfhf2.c"),
-                ("__truncdfsf2", "truncdfsf2.c"),
                 ("__truncsfhf2", "truncsfhf2.c"),
             ]);
         }

+ 2 - 9
examples/intrinsics.rs

@@ -24,16 +24,9 @@ extern "C" {}
 // have an additional comment: the function name is the ARM name for the intrinsic and the comment
 // in the non-ARM name for the intrinsic.
 mod intrinsics {
-    // trunccdfsf2
+    // truncdfsf2
     pub fn aeabi_d2f(x: f64) -> f32 {
-        // This is only implemented in C currently, so only test it there.
-        #[cfg(feature = "c")]
-        return x as f32;
-        #[cfg(not(feature = "c"))]
-        {
-            drop(x);
-            0.0
-        }
+        x as f32
     }
 
     // fixdfsi

+ 1 - 0
src/float/trunc.rs

@@ -112,6 +112,7 @@ where
 }
 
 intrinsics! {
+    #[aapcs_on_arm]
     #[arm_aeabi_alias = __aeabi_d2f]
     pub extern "C" fn __truncdfsf2(a: f64) -> f32 {
         trunc(a)

+ 8 - 0
testcrate/tests/misc.rs

@@ -204,3 +204,11 @@ fn float_trunc() {
 
     trunc!(f64, f32, __truncdfsf2);
 }
+
+#[cfg(target_arch = "arm")]
+#[test]
+fn float_trunc_arm() {
+    use compiler_builtins::float::trunc::__truncdfsf2vfp;
+
+    trunc!(f64, f32, __truncdfsf2vfp);
+}