Fix __aeabi_fcmple and add test cases

`le` in __aeabi_fcmple means `less or equal`
This commit is contained in:
Paolo Teti 2018-02-04 09:48:06 +01:00
parent 1129b62ca2
commit 73884ae671
2 changed files with 93 additions and 1 deletions

View File

@ -174,7 +174,7 @@ intrinsics! {
#[cfg(target_arch = "arm")] #[cfg(target_arch = "arm")]
intrinsics! { intrinsics! {
pub extern "aapcs" fn __aeabi_fcmple(a: f32, b: f32) -> i32 { pub extern "aapcs" fn __aeabi_fcmple(a: f32, b: f32) -> i32 {
(__lesf2(a, b) < 0) as i32 (__lesf2(a, b) <= 0) as i32
} }
pub extern "aapcs" fn __aeabi_fcmpge(a: f32, b: f32) -> i32 { pub extern "aapcs" fn __aeabi_fcmpge(a: f32, b: f32) -> i32 {

View File

@ -121,6 +121,98 @@ fn main() {
}, },
"compiler_builtins::float::cmp::__lesf2(a, b)"); "compiler_builtins::float::cmp::__lesf2(a, b)");
if target_arch_arm {
gen(|(a, b): (MyF32, MyF32)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 <= b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_fcmple(a, b)");
gen(|(a, b): (MyF32, MyF32)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 >= b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_fcmpge(a, b)");
gen(|(a, b): (MyF32, MyF32)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 == b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_fcmpeq(a, b)");
gen(|(a, b): (MyF32, MyF32)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 < b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_fcmplt(a, b)");
gen(|(a, b): (MyF32, MyF32)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 > b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_fcmpgt(a, b)");
gen(|(a, b): (MyF64, MyF64)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 <= b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_dcmple(a, b)");
gen(|(a, b): (MyF64, MyF64)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 >= b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_dcmpge(a, b)");
gen(|(a, b): (MyF64, MyF64)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 == b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_dcmpeq(a, b)");
gen(|(a, b): (MyF64, MyF64)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 < b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_dcmplt(a, b)");
gen(|(a, b): (MyF64, MyF64)| {
if a.0.is_nan() || b.0.is_nan() {
return None;
}
let c = (a.0 > b.0) as i32;
Some(c)
},
"compiler_builtins::float::cmp::__aeabi_dcmpgt(a, b)");
}
// float/conv.rs // float/conv.rs
gen(|a: MyF64| i64(a.0).ok(), gen(|a: MyF64| i64(a.0).ok(),
"compiler_builtins::float::conv::__fixdfdi(a)"); "compiler_builtins::float::conv::__fixdfdi(a)");