Add rintf16 and rintf128
Use the generic algorithms to provide implementations for these routines.
This commit is contained in:
parent
bf2d171b1a
commit
b22398d658
14 changed files with 52 additions and 6 deletions
|
|
@ -145,6 +145,8 @@ no_mangle! {
|
|||
remquof(x: f32, y: f32 | q: &mut c_int) -> f32;
|
||||
rint(x: f64) -> f64;
|
||||
rintf(x: f32) -> f32;
|
||||
rintf128(x: f128) -> f128;
|
||||
rintf16(x: f16) -> f16;
|
||||
round(x: f64) -> f64;
|
||||
roundf(x: f32) -> f32;
|
||||
scalbn(x: f64, y: c_int) -> f64;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const ALL_OPERATIONS_NESTED: &[(FloatTy, Signature, Option<Signature>, &[&str])]
|
|||
FloatTy::F16,
|
||||
Signature { args: &[Ty::F16], returns: &[Ty::F16] },
|
||||
None,
|
||||
&["ceilf16", "fabsf16", "floorf16", "sqrtf16", "truncf16"],
|
||||
&["ceilf16", "fabsf16", "floorf16", "rintf16", "sqrtf16", "truncf16"],
|
||||
),
|
||||
(
|
||||
// `fn(f32) -> f32`
|
||||
|
|
@ -40,7 +40,7 @@ const ALL_OPERATIONS_NESTED: &[(FloatTy, Signature, Option<Signature>, &[&str])]
|
|||
FloatTy::F128,
|
||||
Signature { args: &[Ty::F128], returns: &[Ty::F128] },
|
||||
None,
|
||||
&["ceilf128", "fabsf128", "floorf128", "sqrtf128", "truncf128"],
|
||||
&["ceilf128", "fabsf128", "floorf128", "rintf128", "sqrtf128", "truncf128"],
|
||||
),
|
||||
(
|
||||
// `(f16, f16) -> f16`
|
||||
|
|
|
|||
|
|
@ -149,6 +149,8 @@ main!(
|
|||
icount_bench_remquo_group,
|
||||
icount_bench_remquof_group,
|
||||
icount_bench_rint_group,
|
||||
icount_bench_rintf128_group,
|
||||
icount_bench_rintf16_group,
|
||||
icount_bench_rintf_group,
|
||||
icount_bench_round_group,
|
||||
icount_bench_roundf_group,
|
||||
|
|
|
|||
|
|
@ -127,6 +127,8 @@ libm_macros::for_each_function! {
|
|||
| fdimf16
|
||||
| floorf128
|
||||
| floorf16
|
||||
| rintf128
|
||||
| rintf16
|
||||
| sqrtf128
|
||||
| sqrtf16
|
||||
| truncf128
|
||||
|
|
|
|||
|
|
@ -170,6 +170,8 @@ libm_macros::for_each_function! {
|
|||
remquof,
|
||||
rint,
|
||||
rintf,
|
||||
rintf128,
|
||||
rintf16,
|
||||
round,
|
||||
roundf,
|
||||
scalbn,
|
||||
|
|
@ -240,17 +242,19 @@ impl_no_round! {
|
|||
|
||||
#[cfg(f16_enabled)]
|
||||
impl_no_round! {
|
||||
fabsf16 => abs_mut;
|
||||
ceilf16 => ceil_mut;
|
||||
fabsf16 => abs_mut;
|
||||
floorf16 => floor_mut;
|
||||
rintf16 => round_even_mut; // FIXME: respect rounding mode
|
||||
truncf16 => trunc_mut;
|
||||
}
|
||||
|
||||
#[cfg(f128_enabled)]
|
||||
impl_no_round! {
|
||||
fabsf128 => abs_mut;
|
||||
ceilf128 => ceil_mut;
|
||||
fabsf128 => abs_mut;
|
||||
floorf128 => floor_mut;
|
||||
rintf128 => round_even_mut; // FIXME: respect rounding mode
|
||||
truncf128 => trunc_mut;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,9 +89,11 @@ libm_macros::for_each_function! {
|
|||
fdimf16,
|
||||
floorf128,
|
||||
floorf16,
|
||||
rintf128,
|
||||
rintf16,
|
||||
sqrtf128,
|
||||
sqrtf16,
|
||||
truncf128,
|
||||
truncf16,
|
||||
sqrtf16,
|
||||
sqrtf128,
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@ fn do_eval(basis: &str, op: &str, inputs: &[&str]) {
|
|||
| fdimf16
|
||||
| floorf128
|
||||
| floorf16
|
||||
| rintf128
|
||||
| rintf16
|
||||
| sqrtf128
|
||||
| sqrtf16
|
||||
| truncf128
|
||||
|
|
|
|||
|
|
@ -668,6 +668,20 @@
|
|||
],
|
||||
"type": "f32"
|
||||
},
|
||||
"rintf128": {
|
||||
"sources": [
|
||||
"src/math/generic/rint.rs",
|
||||
"src/math/rintf128.rs"
|
||||
],
|
||||
"type": "f128"
|
||||
},
|
||||
"rintf16": {
|
||||
"sources": [
|
||||
"src/math/generic/rint.rs",
|
||||
"src/math/rintf16.rs"
|
||||
],
|
||||
"type": "f16"
|
||||
},
|
||||
"round": {
|
||||
"sources": [
|
||||
"src/libm_helper.rs",
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ remquo
|
|||
remquof
|
||||
rint
|
||||
rintf
|
||||
rintf128
|
||||
rintf16
|
||||
round
|
||||
roundf
|
||||
scalbn
|
||||
|
|
|
|||
|
|
@ -346,6 +346,7 @@ cfg_if! {
|
|||
mod fabsf16;
|
||||
mod fdimf16;
|
||||
mod floorf16;
|
||||
mod rintf16;
|
||||
mod sqrtf16;
|
||||
mod truncf16;
|
||||
|
||||
|
|
@ -354,6 +355,7 @@ cfg_if! {
|
|||
pub use self::fabsf16::fabsf16;
|
||||
pub use self::fdimf16::fdimf16;
|
||||
pub use self::floorf16::floorf16;
|
||||
pub use self::rintf16::rintf16;
|
||||
pub use self::sqrtf16::sqrtf16;
|
||||
pub use self::truncf16::truncf16;
|
||||
}
|
||||
|
|
@ -366,6 +368,7 @@ cfg_if! {
|
|||
mod fabsf128;
|
||||
mod fdimf128;
|
||||
mod floorf128;
|
||||
mod rintf128;
|
||||
mod sqrtf128;
|
||||
mod truncf128;
|
||||
|
||||
|
|
@ -374,6 +377,7 @@ cfg_if! {
|
|||
pub use self::fabsf128::fabsf128;
|
||||
pub use self::fdimf128::fdimf128;
|
||||
pub use self::floorf128::floorf128;
|
||||
pub use self::rintf128::rintf128;
|
||||
pub use self::sqrtf128::sqrtf128;
|
||||
pub use self::truncf128::truncf128;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/// Round `x` to the nearest integer, breaking ties toward even.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn rint(x: f64) -> f64 {
|
||||
select_implementation! {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/// Round `x` to the nearest integer, breaking ties toward even.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn rintf(x: f32) -> f32 {
|
||||
select_implementation! {
|
||||
|
|
|
|||
5
library/compiler-builtins/libm/src/math/rintf128.rs
Normal file
5
library/compiler-builtins/libm/src/math/rintf128.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/// Round `x` to the nearest integer, breaking ties toward even.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn rintf128(x: f128) -> f128 {
|
||||
super::generic::rint(x)
|
||||
}
|
||||
5
library/compiler-builtins/libm/src/math/rintf16.rs
Normal file
5
library/compiler-builtins/libm/src/math/rintf16.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/// Round `x` to the nearest integer, breaking ties toward even.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn rintf16(x: f16) -> f16 {
|
||||
super::generic::rint(x)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue