Merge pull request #527 from Patryk27/fix_avr_floats

This commit is contained in:
Amanieu d'Antras 2023-06-12 16:36:28 +02:00 committed by GitHub
commit e5dae376cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View file

@ -99,60 +99,74 @@ fn unord<F: Float>(a: F, b: F) -> bool {
}
intrinsics! {
#[avr_skip]
pub extern "C" fn __lesf2(a: f32, b: f32) -> i32 {
cmp(a, b).to_le_abi()
}
#[avr_skip]
pub extern "C" fn __gesf2(a: f32, b: f32) -> i32 {
cmp(a, b).to_ge_abi()
}
#[avr_skip]
#[arm_aeabi_alias = __aeabi_fcmpun]
pub extern "C" fn __unordsf2(a: f32, b: f32) -> i32 {
unord(a, b) as i32
}
#[avr_skip]
pub extern "C" fn __eqsf2(a: f32, b: f32) -> i32 {
cmp(a, b).to_le_abi()
}
#[avr_skip]
pub extern "C" fn __ltsf2(a: f32, b: f32) -> i32 {
cmp(a, b).to_le_abi()
}
#[avr_skip]
pub extern "C" fn __nesf2(a: f32, b: f32) -> i32 {
cmp(a, b).to_le_abi()
}
#[avr_skip]
pub extern "C" fn __gtsf2(a: f32, b: f32) -> i32 {
cmp(a, b).to_ge_abi()
}
#[avr_skip]
pub extern "C" fn __ledf2(a: f64, b: f64) -> i32 {
cmp(a, b).to_le_abi()
}
#[avr_skip]
pub extern "C" fn __gedf2(a: f64, b: f64) -> i32 {
cmp(a, b).to_ge_abi()
}
#[avr_skip]
#[arm_aeabi_alias = __aeabi_dcmpun]
pub extern "C" fn __unorddf2(a: f64, b: f64) -> i32 {
unord(a, b) as i32
}
#[avr_skip]
pub extern "C" fn __eqdf2(a: f64, b: f64) -> i32 {
cmp(a, b).to_le_abi()
}
#[avr_skip]
pub extern "C" fn __ltdf2(a: f64, b: f64) -> i32 {
cmp(a, b).to_le_abi()
}
#[avr_skip]
pub extern "C" fn __nedf2(a: f64, b: f64) -> i32 {
cmp(a, b).to_le_abi()
}
#[avr_skip]
pub extern "C" fn __gtdf2(a: f64, b: f64) -> i32 {
cmp(a, b).to_ge_abi()
}

View file

@ -437,12 +437,11 @@ macro_rules! intrinsics {
intrinsics!($($rest)*);
);
// For division and modulo, AVR uses a custom calling convention¹ that does
// not match our definitions here. Ideally we would just use hand-written
// naked functions, but that's quite a lot of code to port² - so for the
// time being we are just ignoring the problematic functions, letting
// avr-gcc (which is required to compile to AVR anyway) link them from
// libgcc.
// For some intrinsics, AVR uses a custom calling convention¹ that does not
// match our definitions here. Ideally we would just use hand-written naked
// functions, but that's quite a lot of code to port² - so for the time
// being we are just ignoring the problematic functions, letting avr-gcc
// (which is required to compile to AVR anyway) link them from libgcc.
//
// ¹ https://gcc.gnu.org/wiki/avr-gcc (see "Exceptions to the Calling
// Convention")