Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add #[avr_skip] for floats #527

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/float/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,60 +99,74 @@ fn unord<F: Float>(a: F, b: F) -> bool {
}

intrinsics! {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n.b. we could just do #[cfg(not(target_arch = "avr"))], but I think using an explicit #[avr_skip] is better because one can then easily find the related For some intrinsics, AVR uses a custom [...] comment without having to copy-paste it here

#[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()
}
Expand Down
11 changes: 5 additions & 6 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down