Skip to content

Commit 0a2dc5d

Browse files
committed
Combine the source files for more generic implementations
Splitting into different source files by float size doesn't have any benefit when the only content is a small function that forwards to the generic implementation. Combine the source files for all width versions of: * ceil * copysign * fabs * fdim * floor * fmaximum * fmaximum_num * fminimum * fminimum_num * ldexp * scalbn * sqrt * truc fmod is excluded to avoid conflicts with an open PR. As part of this change move unit tests out of the generic module, instead testing the type-specific functions (e.g. `ceilf16` rather than `ceil::<f16>()`). This ensures that unit tests are validating whatever we expose, such as arch-specific implementations via `select_implementation!`, which would otherwise be skipped. (They are still covered by integration tests).
1 parent 221a0a0 commit 0a2dc5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+819
-804
lines changed

libm/etc/function-definitions.json

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,21 @@
108108
"ceilf": {
109109
"sources": [
110110
"src/math/arch/wasm32.rs",
111-
"src/math/ceilf.rs",
111+
"src/math/ceil.rs",
112112
"src/math/generic/ceil.rs"
113113
],
114114
"type": "f32"
115115
},
116116
"ceilf128": {
117117
"sources": [
118-
"src/math/ceilf128.rs",
118+
"src/math/ceil.rs",
119119
"src/math/generic/ceil.rs"
120120
],
121121
"type": "f128"
122122
},
123123
"ceilf16": {
124124
"sources": [
125-
"src/math/ceilf16.rs",
125+
"src/math/ceil.rs",
126126
"src/math/generic/ceil.rs"
127127
],
128128
"type": "f16"
@@ -136,21 +136,21 @@
136136
},
137137
"copysignf": {
138138
"sources": [
139-
"src/math/copysignf.rs",
139+
"src/math/copysign.rs",
140140
"src/math/generic/copysign.rs"
141141
],
142142
"type": "f32"
143143
},
144144
"copysignf128": {
145145
"sources": [
146-
"src/math/copysignf128.rs",
146+
"src/math/copysign.rs",
147147
"src/math/generic/copysign.rs"
148148
],
149149
"type": "f128"
150150
},
151151
"copysignf16": {
152152
"sources": [
153-
"src/math/copysignf16.rs",
153+
"src/math/copysign.rs",
154154
"src/math/generic/copysign.rs"
155155
],
156156
"type": "f16"
@@ -262,21 +262,21 @@
262262
"fabsf": {
263263
"sources": [
264264
"src/math/arch/wasm32.rs",
265-
"src/math/fabsf.rs",
265+
"src/math/fabs.rs",
266266
"src/math/generic/fabs.rs"
267267
],
268268
"type": "f32"
269269
},
270270
"fabsf128": {
271271
"sources": [
272-
"src/math/fabsf128.rs",
272+
"src/math/fabs.rs",
273273
"src/math/generic/fabs.rs"
274274
],
275275
"type": "f128"
276276
},
277277
"fabsf16": {
278278
"sources": [
279-
"src/math/fabsf16.rs",
279+
"src/math/fabs.rs",
280280
"src/math/generic/fabs.rs"
281281
],
282282
"type": "f16"
@@ -290,21 +290,21 @@
290290
},
291291
"fdimf": {
292292
"sources": [
293-
"src/math/fdimf.rs",
293+
"src/math/fdim.rs",
294294
"src/math/generic/fdim.rs"
295295
],
296296
"type": "f32"
297297
},
298298
"fdimf128": {
299299
"sources": [
300-
"src/math/fdimf128.rs",
300+
"src/math/fdim.rs",
301301
"src/math/generic/fdim.rs"
302302
],
303303
"type": "f128"
304304
},
305305
"fdimf16": {
306306
"sources": [
307-
"src/math/fdimf16.rs",
307+
"src/math/fdim.rs",
308308
"src/math/generic/fdim.rs"
309309
],
310310
"type": "f16"
@@ -321,21 +321,21 @@
321321
"floorf": {
322322
"sources": [
323323
"src/math/arch/wasm32.rs",
324-
"src/math/floorf.rs",
324+
"src/math/floor.rs",
325325
"src/math/generic/floor.rs"
326326
],
327327
"type": "f32"
328328
},
329329
"floorf128": {
330330
"sources": [
331-
"src/math/floorf128.rs",
331+
"src/math/floor.rs",
332332
"src/math/generic/floor.rs"
333333
],
334334
"type": "f128"
335335
},
336336
"floorf16": {
337337
"sources": [
338-
"src/math/floorf16.rs",
338+
"src/math/floor.rs",
339339
"src/math/generic/floor.rs"
340340
],
341341
"type": "f16"
@@ -636,19 +636,19 @@
636636
},
637637
"ldexpf": {
638638
"sources": [
639-
"src/math/ldexpf.rs"
639+
"src/math/ldexp.rs"
640640
],
641641
"type": "f32"
642642
},
643643
"ldexpf128": {
644644
"sources": [
645-
"src/math/ldexpf128.rs"
645+
"src/math/ldexp.rs"
646646
],
647647
"type": "f128"
648648
},
649649
"ldexpf16": {
650650
"sources": [
651-
"src/math/ldexpf16.rs"
651+
"src/math/ldexp.rs"
652652
],
653653
"type": "f16"
654654
},
@@ -847,21 +847,21 @@
847847
"roundf": {
848848
"sources": [
849849
"src/math/generic/round.rs",
850-
"src/math/roundf.rs"
850+
"src/math/round.rs"
851851
],
852852
"type": "f32"
853853
},
854854
"roundf128": {
855855
"sources": [
856856
"src/math/generic/round.rs",
857-
"src/math/roundf128.rs"
857+
"src/math/round.rs"
858858
],
859859
"type": "f128"
860860
},
861861
"roundf16": {
862862
"sources": [
863863
"src/math/generic/round.rs",
864-
"src/math/roundf16.rs"
864+
"src/math/round.rs"
865865
],
866866
"type": "f16"
867867
},
@@ -875,21 +875,21 @@
875875
"scalbnf": {
876876
"sources": [
877877
"src/math/generic/scalbn.rs",
878-
"src/math/scalbnf.rs"
878+
"src/math/scalbn.rs"
879879
],
880880
"type": "f32"
881881
},
882882
"scalbnf128": {
883883
"sources": [
884884
"src/math/generic/scalbn.rs",
885-
"src/math/scalbnf128.rs"
885+
"src/math/scalbn.rs"
886886
],
887887
"type": "f128"
888888
},
889889
"scalbnf16": {
890890
"sources": [
891891
"src/math/generic/scalbn.rs",
892-
"src/math/scalbnf16.rs"
892+
"src/math/scalbn.rs"
893893
],
894894
"type": "f16"
895895
},
@@ -945,22 +945,22 @@
945945
"src/math/arch/i686.rs",
946946
"src/math/arch/wasm32.rs",
947947
"src/math/generic/sqrt.rs",
948-
"src/math/sqrtf.rs"
948+
"src/math/sqrt.rs"
949949
],
950950
"type": "f32"
951951
},
952952
"sqrtf128": {
953953
"sources": [
954954
"src/math/generic/sqrt.rs",
955-
"src/math/sqrtf128.rs"
955+
"src/math/sqrt.rs"
956956
],
957957
"type": "f128"
958958
},
959959
"sqrtf16": {
960960
"sources": [
961961
"src/math/arch/aarch64.rs",
962962
"src/math/generic/sqrt.rs",
963-
"src/math/sqrtf16.rs"
963+
"src/math/sqrt.rs"
964964
],
965965
"type": "f16"
966966
},
@@ -1012,21 +1012,21 @@
10121012
"sources": [
10131013
"src/math/arch/wasm32.rs",
10141014
"src/math/generic/trunc.rs",
1015-
"src/math/truncf.rs"
1015+
"src/math/trunc.rs"
10161016
],
10171017
"type": "f32"
10181018
},
10191019
"truncf128": {
10201020
"sources": [
10211021
"src/math/generic/trunc.rs",
1022-
"src/math/truncf128.rs"
1022+
"src/math/trunc.rs"
10231023
],
10241024
"type": "f128"
10251025
},
10261026
"truncf16": {
10271027
"sources": [
10281028
"src/math/generic/trunc.rs",
1029-
"src/math/truncf16.rs"
1029+
"src/math/trunc.rs"
10301030
],
10311031
"type": "f16"
10321032
},

libm/src/math/acosf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* ====================================================
1414
*/
1515

16-
use super::sqrtf::sqrtf;
16+
use super::sqrt::sqrtf;
1717

1818
const PIO2_HI: f32 = 1.5707962513e+00; /* 0x3fc90fda */
1919
const PIO2_LO: f32 = 7.5497894159e-08; /* 0x33a22168 */

libm/src/math/asinf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* ====================================================
1414
*/
1515

16-
use super::fabsf::fabsf;
1716
use super::sqrt::sqrt;
17+
use super::support::Float;
1818

1919
const PIO2: f64 = 1.570796326794896558e+00;
2020

@@ -61,7 +61,7 @@ pub fn asinf(mut x: f32) -> f32 {
6161
}
6262

6363
/* 1 > |x| >= 0.5 */
64-
let z = (1. - fabsf(x)) * 0.5;
64+
let z = (1. - Float::abs(x)) * 0.5;
6565
let s = sqrt(z as f64);
6666
x = (PIO2 - 2. * (s + s * (r(z) as f64))) as f32;
6767
if (hx >> 31) != 0 { -x } else { x }

libm/src/math/ceil.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
/// Ceil (f16)
2+
///
3+
/// Finds the nearest integer greater than or equal to `x`.
4+
#[cfg(f16_enabled)]
5+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
6+
pub fn ceilf16(x: f16) -> f16 {
7+
super::generic::ceil(x)
8+
}
9+
10+
/// Ceil (f32)
11+
///
12+
/// Finds the nearest integer greater than or equal to `x`.
13+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
14+
pub fn ceilf(x: f32) -> f32 {
15+
select_implementation! {
16+
name: ceilf,
17+
use_arch: all(target_arch = "wasm32", intrinsics_enabled),
18+
args: x,
19+
}
20+
21+
super::generic::ceil(x)
22+
}
23+
124
/// Ceil (f64)
225
///
326
/// Finds the nearest integer greater than or equal to `x`.
@@ -12,3 +35,12 @@ pub fn ceil(x: f64) -> f64 {
1235

1336
super::generic::ceil(x)
1437
}
38+
39+
/// Ceil (f128)
40+
///
41+
/// Finds the nearest integer greater than or equal to `x`.
42+
#[cfg(f128_enabled)]
43+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
44+
pub fn ceilf128(x: f128) -> f128 {
45+
super::generic::ceil(x)
46+
}

libm/src/math/ceilf.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

libm/src/math/ceilf128.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

libm/src/math/ceilf16.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)