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

ARM Thumb targets need fmax*/fmin* intrinsics #354

Closed
saleemrashid opened this issue May 11, 2020 · 1 comment · Fixed by #389
Closed

ARM Thumb targets need fmax*/fmin* intrinsics #354

saleemrashid opened this issue May 11, 2020 · 1 comment · Fixed by #389

Comments

@saleemrashid
Copy link

saleemrashid commented May 11, 2020

core::f32 and core::f64 expose max and min, but these use the fmax*/fmin* intrinsics, which aren't exposed for the Thumb targets

// only for the thumb*-none-eabi* targets
#[cfg(all(target_arch = "arm", target_os = "none"))]
no_mangle! {
// `f64 % f64`
fn fmod(x: f64, y: f64) -> f64;
// `f32 % f32`
fn fmodf(x: f32, y: f32) -> f32;
}

https://rust.godbolt.org/z/B4tB6w

#![no_std]

pub fn maxf(a: f32, b: f32) -> f32 {
    a.max(b)
}

pub fn minf(a: f32, b: f32) -> f32 {
    a.min(b)
}

pub fn max(a: f64, b: f64) -> f64 {
    a.max(b)
}

pub fn min(a: f64, b: f64) -> f64 {
    a.min(b)
}
example::maxf:
        b       fmaxf

example::minf:
        b       fminf

example::max:
        b       fmax

example::min:
        b       fmin
@jordens
Copy link
Contributor

jordens commented Oct 24, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants