Add fminf16, fmaxf16, fminf128, and fmaxf128

This commit is contained in:
Trevor Gross 2025-01-24 02:57:35 +00:00
parent f94df5d524
commit 6d5105c006
12 changed files with 76 additions and 4 deletions

View file

@ -47,7 +47,7 @@ const ALL_OPERATIONS_NESTED: &[(FloatTy, Signature, Option<Signature>, &[&str])]
FloatTy::F16,
Signature { args: &[Ty::F16, Ty::F16], returns: &[Ty::F16] },
None,
&["copysignf16", "fdimf16"],
&["copysignf16", "fdimf16", "fmaxf16", "fminf16"],
),
(
// `(f32, f32) -> f32`
@ -90,7 +90,7 @@ const ALL_OPERATIONS_NESTED: &[(FloatTy, Signature, Option<Signature>, &[&str])]
FloatTy::F128,
Signature { args: &[Ty::F128, Ty::F128], returns: &[Ty::F128] },
None,
&["copysignf128", "fdimf128"],
&["copysignf128", "fdimf128", "fmaxf128", "fminf128"],
),
(
// `(f32, f32, f32) -> f32`

View file

@ -127,6 +127,10 @@ libm_macros::for_each_function! {
| fdimf16
| floorf128
| floorf16
| fmaxf128
| fmaxf16
| fminf128
| fminf16
| rintf128
| rintf16
| roundf128

View file

@ -192,8 +192,8 @@ libm_macros::for_each_function! {
fabs | fabsf => abs,
fdim | fdimf | fdimf16 | fdimf128 => positive_diff,
fma | fmaf => mul_add,
fmax | fmaxf => max,
fmin | fminf => min,
fmax | fmaxf | fmaxf16 | fmaxf128 => max,
fmin | fminf | fminf16 | fminf128 => min,
lgamma | lgammaf => ln_gamma,
log | logf => ln,
log1p | log1pf => ln_1p,

View file

@ -89,6 +89,10 @@ libm_macros::for_each_function! {
fdimf16,
floorf128,
floorf16,
fmaxf128,
fmaxf16,
fminf128,
fminf16,
rintf128,
rintf16,
roundf128,

View file

@ -96,6 +96,10 @@ fn do_eval(basis: &str, op: &str, inputs: &[&str]) {
| fdimf16
| floorf128
| floorf16
| fmaxf128
| fmaxf16
| fminf128
| fminf16
| rintf128
| rintf16
| roundf128

View file

@ -391,6 +391,20 @@
],
"type": "f32"
},
"fmaxf128": {
"sources": [
"src/math/fmaxf128.rs",
"src/math/generic/fmax.rs"
],
"type": "f128"
},
"fmaxf16": {
"sources": [
"src/math/fmaxf16.rs",
"src/math/generic/fmax.rs"
],
"type": "f16"
},
"fmin": {
"sources": [
"src/libm_helper.rs",
@ -406,6 +420,20 @@
],
"type": "f32"
},
"fminf128": {
"sources": [
"src/math/fminf128.rs",
"src/math/generic/fmin.rs"
],
"type": "f128"
},
"fminf16": {
"sources": [
"src/math/fminf16.rs",
"src/math/generic/fmin.rs"
],
"type": "f16"
},
"fmod": {
"sources": [
"src/libm_helper.rs",

View file

@ -55,8 +55,12 @@ fma
fmaf
fmax
fmaxf
fmaxf128
fmaxf16
fmin
fminf
fminf128
fminf16
fmod
fmodf
frexp

View file

@ -0,0 +1,5 @@
/// Return the greater of two arguments or, if either argument is NaN, the other argument.
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn fmaxf128(x: f128, y: f128) -> f128 {
super::generic::fmax(x, y)
}

View file

@ -0,0 +1,5 @@
/// Return the greater of two arguments or, if either argument is NaN, the other argument.
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn fmaxf16(x: f16, y: f16) -> f16 {
super::generic::fmax(x, y)
}

View file

@ -0,0 +1,5 @@
/// Return the lesser of two arguments or, if either argument is NaN, the other argument.
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn fminf128(x: f128, y: f128) -> f128 {
super::generic::fmin(x, y)
}

View file

@ -0,0 +1,5 @@
/// Return the lesser of two arguments or, if either argument is NaN, the other argument.
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn fminf16(x: f16, y: f16) -> f16 {
super::generic::fmin(x, y)
}

View file

@ -346,6 +346,8 @@ cfg_if! {
mod fabsf16;
mod fdimf16;
mod floorf16;
mod fmaxf16;
mod fminf16;
mod rintf16;
mod roundf16;
mod sqrtf16;
@ -356,6 +358,8 @@ cfg_if! {
pub use self::fabsf16::fabsf16;
pub use self::fdimf16::fdimf16;
pub use self::floorf16::floorf16;
pub use self::fmaxf16::fmaxf16;
pub use self::fminf16::fminf16;
pub use self::rintf16::rintf16;
pub use self::roundf16::roundf16;
pub use self::sqrtf16::sqrtf16;
@ -370,6 +374,8 @@ cfg_if! {
mod fabsf128;
mod fdimf128;
mod floorf128;
mod fmaxf128;
mod fminf128;
mod rintf128;
mod roundf128;
mod sqrtf128;
@ -380,6 +386,8 @@ cfg_if! {
pub use self::fabsf128::fabsf128;
pub use self::fdimf128::fdimf128;
pub use self::floorf128::floorf128;
pub use self::fmaxf128::fmaxf128;
pub use self::fminf128::fminf128;
pub use self::rintf128::rintf128;
pub use self::roundf128::roundf128;
pub use self::sqrtf128::sqrtf128;