add remaining floating point tests
This commit is contained in:
parent
ec4fc5dab5
commit
96a6110d69
5 changed files with 160 additions and 15 deletions
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(unused_macros)]
|
||||
|
||||
use testcrate::*;
|
||||
|
||||
macro_rules! sum {
|
||||
|
|
@ -107,3 +109,18 @@ fn float_addsub() {
|
|||
f64, __adddf3, __subdf3;
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
#[test]
|
||||
fn float_addsub_arm() {
|
||||
use compiler_builtins::float::{
|
||||
add::{__adddf3vfp, __addsf3vfp},
|
||||
sub::{__subdf3vfp, __subsf3vfp},
|
||||
Float,
|
||||
};
|
||||
|
||||
float_sum!(
|
||||
f32, __addsf3vfp, __subsf3vfp;
|
||||
f64, __adddf3vfp, __subdf3vfp;
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(unused_macros)]
|
||||
|
||||
use testcrate::*;
|
||||
|
||||
macro_rules! cmp {
|
||||
|
|
@ -50,3 +52,61 @@ fn float_comparisons() {
|
|||
);
|
||||
});
|
||||
}
|
||||
|
||||
macro_rules! cmp2 {
|
||||
($x:ident, $y:ident, $($unordered_val:expr, $fn_std:expr, $fn_builtins:ident);*;) => {
|
||||
$(
|
||||
let cmp0: i32 = if $x.is_nan() || $y.is_nan() {
|
||||
$unordered_val
|
||||
} else {
|
||||
$fn_std as i32
|
||||
};
|
||||
let cmp1: i32 = $fn_builtins($x, $y);
|
||||
if cmp0 != cmp1 {
|
||||
panic!("{}({}, {}): std: {}, builtins: {}", stringify!($fn_builtins), $x, $y, cmp0, cmp1);
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
#[test]
|
||||
fn float_comparisons_arm() {
|
||||
use compiler_builtins::float::cmp::{
|
||||
__aeabi_dcmpeq, __aeabi_dcmpge, __aeabi_dcmpgt, __aeabi_dcmple, __aeabi_dcmplt,
|
||||
__aeabi_fcmpeq, __aeabi_fcmpge, __aeabi_fcmpgt, __aeabi_fcmple, __aeabi_fcmplt, __eqdf2vfp,
|
||||
__eqsf2vfp, __gedf2vfp, __gesf2vfp, __gtdf2vfp, __gtsf2vfp, __ledf2vfp, __lesf2vfp,
|
||||
__ltdf2vfp, __ltsf2vfp, __nedf2vfp, __nesf2vfp,
|
||||
};
|
||||
|
||||
fuzz_float_2(N, |x: f32, y: f32| {
|
||||
cmp2!(x, y,
|
||||
0, x < y, __aeabi_fcmplt;
|
||||
0, x <= y, __aeabi_fcmple;
|
||||
0, x == y, __aeabi_fcmpeq;
|
||||
0, x >= y, __aeabi_fcmpge;
|
||||
0, x > y, __aeabi_fcmpgt;
|
||||
0, x < y, __ltsf2vfp;
|
||||
0, x <= y, __lesf2vfp;
|
||||
0, x == y, __eqsf2vfp;
|
||||
0, x >= y, __gesf2vfp;
|
||||
0, x > y, __gtsf2vfp;
|
||||
1, x != y, __nesf2vfp;
|
||||
);
|
||||
});
|
||||
fuzz_float_2(N, |x: f64, y: f64| {
|
||||
cmp2!(x, y,
|
||||
0, x < y, __aeabi_dcmplt;
|
||||
0, x <= y, __aeabi_dcmple;
|
||||
0, x == y, __aeabi_dcmpeq;
|
||||
0, x >= y, __aeabi_dcmpge;
|
||||
0, x > y, __aeabi_dcmpgt;
|
||||
0, x < y, __ltdf2vfp;
|
||||
0, x <= y, __ledf2vfp;
|
||||
0, x == y, __eqdf2vfp;
|
||||
0, x >= y, __gedf2vfp;
|
||||
0, x > y, __gtdf2vfp;
|
||||
1, x != y, __nedf2vfp;
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(unused_macros)]
|
||||
|
||||
use compiler_builtins::int::sdiv::{__divmoddi4, __divmodsi4, __divmodti4};
|
||||
use compiler_builtins::int::udiv::{__udivmoddi4, __udivmodsi4, __udivmodti4, u128_divide_sparc};
|
||||
use testcrate::*;
|
||||
|
|
@ -134,3 +136,17 @@ fn float_div() {
|
|||
f64, __divdf3;
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
#[test]
|
||||
fn float_div_arm() {
|
||||
use compiler_builtins::float::{
|
||||
div::{__divdf3vfp, __divsf3vfp},
|
||||
Float,
|
||||
};
|
||||
|
||||
float!(
|
||||
f32, __divsf3vfp;
|
||||
f64, __divdf3vfp;
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// makes configuration easier
|
||||
#![allow(unused_macros)]
|
||||
|
||||
use compiler_builtins::float::Float;
|
||||
use testcrate::*;
|
||||
|
||||
/// Make sure that the the edge case tester and randomized tester don't break, and list examples of
|
||||
|
|
@ -89,15 +93,37 @@ fn leading_zeros() {
|
|||
})
|
||||
}
|
||||
|
||||
macro_rules! extend {
|
||||
($fX:ident, $fD:ident, $fn:ident) => {
|
||||
fuzz_float(N, |x: $fX| {
|
||||
let tmp0 = x as $fD;
|
||||
let tmp1: $fD = $fn(x);
|
||||
if !Float::eq_repr(tmp0, tmp1) {
|
||||
panic!(
|
||||
"{}({}): std: {}, builtins: {}",
|
||||
stringify!($fn),
|
||||
x,
|
||||
tmp0,
|
||||
tmp1
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn float_extend() {
|
||||
fuzz_float(N, |x: f32| {
|
||||
let tmp0 = x as f64;
|
||||
let tmp1: f64 = compiler_builtins::float::extend::__extendsfdf2(x);
|
||||
if !compiler_builtins::float::Float::eq_repr(tmp0, tmp1) {
|
||||
panic!("__extendsfdf2({}): std: {}, builtins: {}", x, tmp0, tmp1);
|
||||
}
|
||||
});
|
||||
use compiler_builtins::float::extend::__extendsfdf2;
|
||||
|
||||
extend!(f32, f64, __extendsfdf2);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
#[test]
|
||||
fn float_extend_arm() {
|
||||
use compiler_builtins::float::extend::__extendsfdf2vfp;
|
||||
|
||||
extend!(f32, f64, __extendsfdf2vfp);
|
||||
}
|
||||
|
||||
// This doesn't quite work because of issues related to
|
||||
|
|
@ -108,14 +134,16 @@ macro_rules! pow {
|
|||
($($f:ty, $fn:ident);*;) => {
|
||||
$(
|
||||
fuzz_float_2(N, |x: $f, y: $f| {
|
||||
let n = y as i32;
|
||||
let tmp0: $f = x.powi(n);
|
||||
let tmp1: $f = $fn(x, n);
|
||||
if tmp0 != tmp1 {
|
||||
panic!(
|
||||
"{}({}, {}): std: {}, builtins: {}",
|
||||
stringify!($fn), x, y, tmp0, tmp1
|
||||
);
|
||||
if !(Float::is_subnormal(x) || Float::is_subnormal(y) || x < 0. || y < 0.) {
|
||||
let n = y as i32;
|
||||
let tmp0: $f = x.powi(n);
|
||||
let tmp1: $f = $fn(x, n);
|
||||
if tmp0 != tmp1 {
|
||||
panic!(
|
||||
"{}({}, {}): std: {}, builtins: {}",
|
||||
stringify!($fn), x, y, tmp0, tmp1
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
)*
|
||||
|
|
@ -132,3 +160,11 @@ fn float_pow() {
|
|||
);
|
||||
}
|
||||
*/
|
||||
|
||||
// placeholder test to make sure basic functionality works
|
||||
#[test]
|
||||
fn float_pow() {
|
||||
use compiler_builtins::float::pow::{__powidf2, __powisf2};
|
||||
assert_eq!(__powisf2(-3.0, 3), -27.0);
|
||||
assert_eq!(__powidf2(-3.0, 3), -27.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(unused_macros)]
|
||||
|
||||
use testcrate::*;
|
||||
|
||||
macro_rules! mul {
|
||||
|
|
@ -112,3 +114,17 @@ fn float_mul() {
|
|||
f64, __muldf3;
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
#[test]
|
||||
fn float_mul_arm() {
|
||||
use compiler_builtins::float::{
|
||||
mul::{__muldf3vfp, __mulsf3vfp},
|
||||
Float,
|
||||
};
|
||||
|
||||
float_mul!(
|
||||
f32, __mulsf3vfp;
|
||||
f64, __muldf3vfp;
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue