30 Commits

Author SHA1 Message Date
Trevor Gross
725759602a Upgrade all dependencies to the latest
This is mostly done to get the latest version of `rand`, which includes
some breaking changes.
2025-03-18 19:46:34 -05:00
Trevor Gross
53a055049c Add roundeven{,f,f16,f128}
C23 specifies a new set of `roundeven` functions that round to the
nearest integral, with ties to even. It does not raise any floating
point exceptions.

This behavior is similar to two other functions:

1. `rint`, which rounds to the nearest integer respecting rounding mode
   and possibly raising exceptions.
2. `nearbyint`, which is identical to `rint` except it may not raise
   exceptions.

Technically `rint`, `nearbyint`, and `roundeven` all behave the same in
Rust because we assume default floating point environment. The backends
are allowed to lower to `roundeven`, however, so we should provide it in
case the fallback is needed.

Add the `roundeven` family here and convert `rint` to a function that
takes a rounding mode. This currently has no effect.
2025-02-11 00:55:22 -06:00
Trevor Gross
669731335e Add fminimum, fmaximum, fminimum_num, and fmaximum_num
These functions represent new operations from IEEE 754-2019. Introduce
them for all float sizes.
2025-02-10 16:17:33 -06:00
Trevor Gross
3e2de21344 Remove or reduce the scope of allow(unused) where possible
Now that we have more in this crate making use of traits, try to be more
specific about what is actually unused.
2025-02-06 21:57:17 -06:00
Trevor Gross
9223d60dfa Add fmaf128
Resolve all remaining `f64`-specific items in the generic version of
`fma`, then expose `fmaf128`.
2025-02-06 18:41:45 -06:00
Trevor Gross
cc1a55a77e Add a check in the shared.rs that the function list is sorted 2025-02-05 15:13:53 +00:00
Trevor Gross
cc2874c9a9 Add scalbnf16, scalbnf128, ldexpf16, and ldexpf128
Use the generic `scalbn` to provide `f16` and `f128` versions, which
also work for `ldexp`.

This involves a new algorithm for `f16` because the default does not
converge fast enough with a limited number of rounds.
2025-02-05 13:37:54 +00:00
Trevor Gross
7c6c0c1b79 Upgrade all dependencies to the latest version
In particular, this includes updates to Rug that we can make use of [1],
[2], [3], [4].

[1]: https://gitlab.com/tspiteri/rug/-/issues/78
[2]: https://gitlab.com/tspiteri/rug/-/issues/80
[3]: https://gitlab.com/tspiteri/rug/-/issues/76
[4]: https://gitlab.com/tspiteri/rug/-/issues/73
2025-01-25 00:50:02 +00:00
Trevor Gross
71200bc3ce Add fmodf128
This function is significantly slower than all others so includes an
override in `EXTREMELY_SLOW_TESTS`. Without it, PR CI takes ~1hour and
the extensive tests in CI take ~1day.
2025-01-24 08:23:15 +00:00
Trevor Gross
67218cbaa5 Add fmodf16 using the generic implementation 2025-01-24 06:03:59 +00:00
Trevor Gross
6d5105c006 Add fminf16, fmaxf16, fminf128, and fmaxf128 2025-01-24 03:01:36 +00:00
Trevor Gross
d20a5e82a5 Add roundf16 and roundf128 2025-01-24 01:59:10 +00:00
Trevor Gross
b22398d658 Add rintf16 and rintf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-22 11:04:39 +00:00
Trevor Gross
6a8bb0fa80 Add floorf16 and floorf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-22 08:50:06 +00:00
Trevor Gross
9064c42abe Add ceilf16 and ceilf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-22 07:22:32 +00:00
Trevor Gross
186eac9227 Add sqrtf16 and sqrtf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-22 05:31:13 +00:00
Trevor Gross
13b5bf3959 Add fdimf16 and fdimf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-13 14:04:54 +00:00
Trevor Gross
b558b365d3 Add truncf16 and truncf128
Use the generic algorithms to provide implementations for these
routines.
2025-01-13 10:12:09 +00:00
Trevor Gross
6b5e8b20f0 Add test infrastructure for f16 and f128
Update test traits to support `f16` and `f128`, as applicable. Add the
new routines (`fabs` and `copysign` for `f16` and `f128`) to the list of
all operations.
2025-01-06 04:10:51 -05:00
Trevor Gross
3fb16fbdbe macros: Always emit f16_enabled and f128_enabled attributes
Once we start addinf `f16` and `f128` routines, we will need to have
this cfg for almost all uses of `for_each_function`. Rather than needing
to specify this each time, always emit `#[cfg(f16_enabled)]` or
`#[cfg(f128_enabled)]` for each function that uses `f16` or `f128`,
respectively.
2025-01-02 17:38:09 -05:00
Trevor Gross
e754ecb6d9 Add missing functions to the macro list
Now that we are using rustdoc output to locate public functions, the
test is indicating a few that were missed since they don't have their
own function. Update everything to now include the following routines:

* `erfc`
* `erfcf`
* `y0`
* `y0f`
* `y1`
* `y1f`
* `yn`
* `ynf`
2025-01-01 11:15:48 +00:00
Trevor Gross
6e97fef9c9 Add ALL, from_str and math_op to Identifier
Introduce new API to iterate the function list and associate items with
their `MathOp`.
2024-12-29 08:07:40 +00:00
Trevor Gross
1069346b6d Move the macro's input function list to a new module shared
This will enable us to `include!` the file to access these types in
`libm-test`, rather than somehow reproducing the types as part of the
macro. Ideally `libm-test` would just `use` the types from `libm-macros`
but proc macro crates cannot currently export anything else.

This also adjusts naming to closer match the scheme described in
`libm_test::op`.
2024-12-29 08:03:19 +00:00
Trevor Gross
f2e16b6ac1 Add f16 and f128 configuration from compiler-builtins
In preparation of adding routines from these two types, duplicate the
`compiler-builtins` configuration here.
2024-12-29 02:33:41 -05:00
Trevor Gross
2fab4f4580 Change the CheckCtx constructor to take a Name enum
This prepares to eliminate some reliance on string matching but does not
yet make those changes.
2024-11-02 22:35:30 -05:00
Trevor Gross
6aef9e17c8 Correct the proc macro to emit pub functions 2024-11-02 17:01:39 -05:00
Trevor Gross
5b0a775c12 Adjust how the proc macro emits types and add an enum
Currently the macro always provides `CFn`, `RustFn`, `RustArgs`, etc.
Change this so that:

1. This information must be explicily requested in the invocation.
2. There is a new `FTy` field available that emits a single float type,
   rather than a tuple or signature.

Additionally, add two new macros that create enums representing function
names.
2024-11-02 10:54:00 -05:00
Trevor Gross
2411357947 Fix clippy lints in crates/ and enable this on CI 2024-11-02 10:33:23 -05:00
Trevor Gross
bf757e3a7b Mark libm-macros and musl-math-sys as publish=false 2024-10-28 13:36:00 -05:00
Trevor Gross
56deb13bd4 Add a procedural macro for expanding all function signatures
Introduce `libm_test::for_each_function`. which macro takes a callback
macro and invokes it once per function signature. This provides an
easier way of registering various tests and benchmarks without
duplicating the function names and signatures each time.
2024-10-28 12:59:38 -05:00