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

Combine the source files for more generic implementations #537

Merged
merged 3 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/libm-test/src/f8_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl Float for f8 {
const INFINITY: Self = Self(0b0_1111_000);
const NEG_INFINITY: Self = Self(0b1_1111_000);
const NAN: Self = Self(0b0_1111_100);
const NEG_NAN: Self = Self(0b1_1111_100);
const MIN_POSITIVE_NORMAL: Self = Self(1 << Self::SIG_BITS);
// FIXME: incorrect values
const EPSILON: Self = Self::ZERO;
Expand Down
60 changes: 30 additions & 30 deletions etc/function-definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,21 @@
"ceilf": {
"sources": [
"src/math/arch/wasm32.rs",
"src/math/ceilf.rs",
"src/math/ceil.rs",
"src/math/generic/ceil.rs"
],
"type": "f32"
},
"ceilf128": {
"sources": [
"src/math/ceilf128.rs",
"src/math/ceil.rs",
"src/math/generic/ceil.rs"
],
"type": "f128"
},
"ceilf16": {
"sources": [
"src/math/ceilf16.rs",
"src/math/ceil.rs",
"src/math/generic/ceil.rs"
],
"type": "f16"
Expand All @@ -136,21 +136,21 @@
},
"copysignf": {
"sources": [
"src/math/copysignf.rs",
"src/math/copysign.rs",
"src/math/generic/copysign.rs"
],
"type": "f32"
},
"copysignf128": {
"sources": [
"src/math/copysignf128.rs",
"src/math/copysign.rs",
"src/math/generic/copysign.rs"
],
"type": "f128"
},
"copysignf16": {
"sources": [
"src/math/copysignf16.rs",
"src/math/copysign.rs",
"src/math/generic/copysign.rs"
],
"type": "f16"
Expand Down Expand Up @@ -262,21 +262,21 @@
"fabsf": {
"sources": [
"src/math/arch/wasm32.rs",
"src/math/fabsf.rs",
"src/math/fabs.rs",
"src/math/generic/fabs.rs"
],
"type": "f32"
},
"fabsf128": {
"sources": [
"src/math/fabsf128.rs",
"src/math/fabs.rs",
"src/math/generic/fabs.rs"
],
"type": "f128"
},
"fabsf16": {
"sources": [
"src/math/fabsf16.rs",
"src/math/fabs.rs",
"src/math/generic/fabs.rs"
],
"type": "f16"
Expand All @@ -290,21 +290,21 @@
},
"fdimf": {
"sources": [
"src/math/fdimf.rs",
"src/math/fdim.rs",
"src/math/generic/fdim.rs"
],
"type": "f32"
},
"fdimf128": {
"sources": [
"src/math/fdimf128.rs",
"src/math/fdim.rs",
"src/math/generic/fdim.rs"
],
"type": "f128"
},
"fdimf16": {
"sources": [
"src/math/fdimf16.rs",
"src/math/fdim.rs",
"src/math/generic/fdim.rs"
],
"type": "f16"
Expand All @@ -321,21 +321,21 @@
"floorf": {
"sources": [
"src/math/arch/wasm32.rs",
"src/math/floorf.rs",
"src/math/floor.rs",
"src/math/generic/floor.rs"
],
"type": "f32"
},
"floorf128": {
"sources": [
"src/math/floorf128.rs",
"src/math/floor.rs",
"src/math/generic/floor.rs"
],
"type": "f128"
},
"floorf16": {
"sources": [
"src/math/floorf16.rs",
"src/math/floor.rs",
"src/math/generic/floor.rs"
],
"type": "f16"
Expand Down Expand Up @@ -636,19 +636,19 @@
},
"ldexpf": {
"sources": [
"src/math/ldexpf.rs"
"src/math/ldexp.rs"
],
"type": "f32"
},
"ldexpf128": {
"sources": [
"src/math/ldexpf128.rs"
"src/math/ldexp.rs"
],
"type": "f128"
},
"ldexpf16": {
"sources": [
"src/math/ldexpf16.rs"
"src/math/ldexp.rs"
],
"type": "f16"
},
Expand Down Expand Up @@ -847,21 +847,21 @@
"roundf": {
"sources": [
"src/math/generic/round.rs",
"src/math/roundf.rs"
"src/math/round.rs"
],
"type": "f32"
},
"roundf128": {
"sources": [
"src/math/generic/round.rs",
"src/math/roundf128.rs"
"src/math/round.rs"
],
"type": "f128"
},
"roundf16": {
"sources": [
"src/math/generic/round.rs",
"src/math/roundf16.rs"
"src/math/round.rs"
],
"type": "f16"
},
Expand All @@ -875,21 +875,21 @@
"scalbnf": {
"sources": [
"src/math/generic/scalbn.rs",
"src/math/scalbnf.rs"
"src/math/scalbn.rs"
],
"type": "f32"
},
"scalbnf128": {
"sources": [
"src/math/generic/scalbn.rs",
"src/math/scalbnf128.rs"
"src/math/scalbn.rs"
],
"type": "f128"
},
"scalbnf16": {
"sources": [
"src/math/generic/scalbn.rs",
"src/math/scalbnf16.rs"
"src/math/scalbn.rs"
],
"type": "f16"
},
Expand Down Expand Up @@ -945,22 +945,22 @@
"src/math/arch/i686.rs",
"src/math/arch/wasm32.rs",
"src/math/generic/sqrt.rs",
"src/math/sqrtf.rs"
"src/math/sqrt.rs"
],
"type": "f32"
},
"sqrtf128": {
"sources": [
"src/math/generic/sqrt.rs",
"src/math/sqrtf128.rs"
"src/math/sqrt.rs"
],
"type": "f128"
},
"sqrtf16": {
"sources": [
"src/math/arch/aarch64.rs",
"src/math/generic/sqrt.rs",
"src/math/sqrtf16.rs"
"src/math/sqrt.rs"
],
"type": "f16"
},
Expand Down Expand Up @@ -1012,21 +1012,21 @@
"sources": [
"src/math/arch/wasm32.rs",
"src/math/generic/trunc.rs",
"src/math/truncf.rs"
"src/math/trunc.rs"
],
"type": "f32"
},
"truncf128": {
"sources": [
"src/math/generic/trunc.rs",
"src/math/truncf128.rs"
"src/math/trunc.rs"
],
"type": "f128"
},
"truncf16": {
"sources": [
"src/math/generic/trunc.rs",
"src/math/truncf16.rs"
"src/math/trunc.rs"
],
"type": "f16"
},
Expand Down
2 changes: 1 addition & 1 deletion src/math/acosf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* ====================================================
*/

use super::sqrtf::sqrtf;
use super::sqrt::sqrtf;

const PIO2_HI: f32 = 1.5707962513e+00; /* 0x3fc90fda */
const PIO2_LO: f32 = 7.5497894159e-08; /* 0x33a22168 */
Expand Down
4 changes: 2 additions & 2 deletions src/math/asinf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* ====================================================
*/

use super::fabsf::fabsf;
use super::sqrt::sqrt;
use super::support::Float;

const PIO2: f64 = 1.570796326794896558e+00;

Expand Down Expand Up @@ -61,7 +61,7 @@ pub fn asinf(mut x: f32) -> f32 {
}

/* 1 > |x| >= 0.5 */
let z = (1. - fabsf(x)) * 0.5;
let z = (1. - Float::abs(x)) * 0.5;
let s = sqrt(z as f64);
x = (PIO2 - 2. * (s + s * (r(z) as f64))) as f32;
if (hx >> 31) != 0 { -x } else { x }
Expand Down
32 changes: 32 additions & 0 deletions src/math/ceil.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/// Ceil (f16)
///
/// Finds the nearest integer greater than or equal to `x`.
#[cfg(f16_enabled)]
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn ceilf16(x: f16) -> f16 {
super::generic::ceil(x)
}

/// Ceil (f32)
///
/// Finds the nearest integer greater than or equal to `x`.
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn ceilf(x: f32) -> f32 {
select_implementation! {
name: ceilf,
use_arch: all(target_arch = "wasm32", intrinsics_enabled),
args: x,
}

super::generic::ceil(x)
}

/// Ceil (f64)
///
/// Finds the nearest integer greater than or equal to `x`.
Expand All @@ -12,3 +35,12 @@ pub fn ceil(x: f64) -> f64 {

super::generic::ceil(x)
}

/// Ceil (f128)
///
/// Finds the nearest integer greater than or equal to `x`.
#[cfg(f128_enabled)]
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn ceilf128(x: f128) -> f128 {
super::generic::ceil(x)
}
13 changes: 0 additions & 13 deletions src/math/ceilf.rs

This file was deleted.

7 changes: 0 additions & 7 deletions src/math/ceilf128.rs

This file was deleted.

7 changes: 0 additions & 7 deletions src/math/ceilf16.rs

This file was deleted.

Loading
Loading