Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit d2da7f7

Browse files
committed
Add rintf16 and rintf128
Use the generic algorithms to provide implementations for these routines.
1 parent a9cfff9 commit d2da7f7

File tree

14 files changed

+52
-6
lines changed

14 files changed

+52
-6
lines changed

crates/compiler-builtins-smoke-test/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ no_mangle! {
145145
remquof(x: f32, y: f32 | q: &mut c_int) -> f32;
146146
rint(x: f64) -> f64;
147147
rintf(x: f32) -> f32;
148+
rintf128(x: f128) -> f128;
149+
rintf16(x: f16) -> f16;
148150
round(x: f64) -> f64;
149151
roundf(x: f32) -> f32;
150152
scalbn(x: f64, y: c_int) -> f64;

crates/libm-macros/src/shared.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ALL_OPERATIONS_NESTED: &[(FloatTy, Signature, Option<Signature>, &[&str])]
99
FloatTy::F16,
1010
Signature { args: &[Ty::F16], returns: &[Ty::F16] },
1111
None,
12-
&["ceilf16", "fabsf16", "floorf16", "sqrtf16", "truncf16"],
12+
&["ceilf16", "fabsf16", "floorf16", "rintf16", "sqrtf16", "truncf16"],
1313
),
1414
(
1515
// `fn(f32) -> f32`
@@ -40,7 +40,7 @@ const ALL_OPERATIONS_NESTED: &[(FloatTy, Signature, Option<Signature>, &[&str])]
4040
FloatTy::F128,
4141
Signature { args: &[Ty::F128], returns: &[Ty::F128] },
4242
None,
43-
&["ceilf128", "fabsf128", "floorf128", "sqrtf128", "truncf128"],
43+
&["ceilf128", "fabsf128", "floorf128", "rintf128", "sqrtf128", "truncf128"],
4444
),
4545
(
4646
// `(f16, f16) -> f16`

crates/libm-test/benches/icount.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ main!(
149149
icount_bench_remquo_group,
150150
icount_bench_remquof_group,
151151
icount_bench_rint_group,
152+
icount_bench_rintf128_group,
153+
icount_bench_rintf16_group,
152154
icount_bench_rintf_group,
153155
icount_bench_round_group,
154156
icount_bench_roundf_group,

crates/libm-test/benches/random.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ libm_macros::for_each_function! {
127127
| fdimf16
128128
| floorf128
129129
| floorf16
130+
| rintf128
131+
| rintf16
130132
| sqrtf128
131133
| sqrtf16
132134
| truncf128

crates/libm-test/src/mpfloat.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ libm_macros::for_each_function! {
170170
remquof,
171171
rint,
172172
rintf,
173+
rintf128,
174+
rintf16,
173175
round,
174176
roundf,
175177
scalbn,
@@ -240,17 +242,19 @@ impl_no_round! {
240242

241243
#[cfg(f16_enabled)]
242244
impl_no_round! {
243-
fabsf16 => abs_mut;
244245
ceilf16 => ceil_mut;
246+
fabsf16 => abs_mut;
245247
floorf16 => floor_mut;
248+
rintf16 => round_even_mut; // FIXME: respect rounding mode
246249
truncf16 => trunc_mut;
247250
}
248251

249252
#[cfg(f128_enabled)]
250253
impl_no_round! {
251-
fabsf128 => abs_mut;
252254
ceilf128 => ceil_mut;
255+
fabsf128 => abs_mut;
253256
floorf128 => floor_mut;
257+
rintf128 => round_even_mut; // FIXME: respect rounding mode
254258
truncf128 => trunc_mut;
255259
}
256260

crates/libm-test/tests/compare_built_musl.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ libm_macros::for_each_function! {
8989
fdimf16,
9090
floorf128,
9191
floorf16,
92+
rintf128,
93+
rintf16,
94+
sqrtf128,
95+
sqrtf16,
9296
truncf128,
9397
truncf16,
94-
sqrtf16,
95-
sqrtf128,
9698
],
9799
}

crates/util/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ fn do_eval(basis: &str, op: &str, inputs: &[&str]) {
9494
| fdimf16
9595
| floorf128
9696
| floorf16
97+
| rintf128
98+
| rintf16
9799
| sqrtf128
98100
| sqrtf16
99101
| truncf128

etc/function-definitions.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,20 @@
668668
],
669669
"type": "f32"
670670
},
671+
"rintf128": {
672+
"sources": [
673+
"src/math/generic/rint.rs",
674+
"src/math/rintf128.rs"
675+
],
676+
"type": "f128"
677+
},
678+
"rintf16": {
679+
"sources": [
680+
"src/math/generic/rint.rs",
681+
"src/math/rintf16.rs"
682+
],
683+
"type": "f16"
684+
},
671685
"round": {
672686
"sources": [
673687
"src/libm_helper.rs",

etc/function-list.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ remquo
9797
remquof
9898
rint
9999
rintf
100+
rintf128
101+
rintf16
100102
round
101103
roundf
102104
scalbn

src/math/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ cfg_if! {
346346
mod fabsf16;
347347
mod fdimf16;
348348
mod floorf16;
349+
mod rintf16;
349350
mod sqrtf16;
350351
mod truncf16;
351352

@@ -354,6 +355,7 @@ cfg_if! {
354355
pub use self::fabsf16::fabsf16;
355356
pub use self::fdimf16::fdimf16;
356357
pub use self::floorf16::floorf16;
358+
pub use self::rintf16::rintf16;
357359
pub use self::sqrtf16::sqrtf16;
358360
pub use self::truncf16::truncf16;
359361
}
@@ -366,6 +368,7 @@ cfg_if! {
366368
mod fabsf128;
367369
mod fdimf128;
368370
mod floorf128;
371+
mod rintf128;
369372
mod sqrtf128;
370373
mod truncf128;
371374

@@ -374,6 +377,7 @@ cfg_if! {
374377
pub use self::fabsf128::fabsf128;
375378
pub use self::fdimf128::fdimf128;
376379
pub use self::floorf128::floorf128;
380+
pub use self::rintf128::rintf128;
377381
pub use self::sqrtf128::sqrtf128;
378382
pub use self::truncf128::truncf128;
379383
}

0 commit comments

Comments
 (0)