17 Commits

Author SHA1 Message Date
Joseph Huber
6cd37eb5de
[libc] Fix INFINITY being defined as a double (#103445)
Summary:
If the implementation supports floating-point infinities, the macro
INFINITY expands to constant expression of type float which evaluates to
positive or unsigned infinity.

Currently this is a double, this makes it a float.
2024-08-13 16:02:18 -05:00
Petr Hosek
6cbea4880e
[libc] Define HUGE_VALF in math.h (#98522)
This is analogous to `HUGE_VAL`.
2024-07-11 14:18:38 -07:00
Petr Hosek
b6e41c159b
[libc] Provide isnan, isnanf and isnanl functions (#96008)
While C99 defines type generic isnan macro, BSD provided isnan, isnanf
and isnanl in prior C standards and existing code still relies on these.
2024-07-09 21:28:51 -07:00
Joseph Huber
d358151a4f Reapply "[libc] Make GPU libm use generic implementations" (#98061)
This reverts commit ea3fd020f4879d5b4261eabd9a56c24f30bc47f9.
2024-07-08 15:02:05 -05:00
Mehdi Amini
ea3fd020f4
Revert "[libc] Make GPU libm use generic implementations" (#98061)
Reverts llvm/llvm-project#98014

buildbot is broken.
2024-07-08 20:17:35 +02:00
Joseph Huber
5c40e561bb
[libc] Make GPU libm use generic implementations (#98014)
Summary:
This patch moves a lot of the old vendor implementations to the new
generic math functions. Previously a lot of these were done through the
vendor functions, but the long term goal is to completely phase these
out. In order to make the tests pass I had to disable exceptions so they
only perform functional tests.
2024-07-08 08:48:53 -05:00
lntue
22b1f1bc69
[libc] Remove #ifdef __cplusplus part from include/llvm-libc-macros/math-macros.h. (#87864)
Now with the proxy header `hdr/math_macros.h`, the header
`include/llvm-libc-macros/math-macros.h` will not be included in overlay
mode, and the extra definitions for `__cplusplus` mode is not needed any
more.
2024-04-08 19:26:12 -04:00
lntue
5748ad84e5
[libc] Add proxy header math_macros.h. (#87598)
Context: https://github.com/llvm/llvm-project/pull/87017

- Add proxy header `libc/hdr/math_macros.h` that will:
  - include `<math.h>` in overlay mode,
- include `"include/llvm-libc-macros/math-macros.h"` in full build mode.
- Its corresponding CMake target `libc.hdr.math_macros` will only depend
on `libc.include.math` and `libc.include.llvm-libc-macros.math_macros`
in full build mode.
- Replace all `#include "include/llvm-libc-macros/math-macros.h"` with
`#include "hdr/math_macros.h"`.
- Add dependency to `libc.hdr.math_macros` CMake target when using
`add_fp_unittest`.
- Update the remaining dependency.
- Update bazel overlay: add `libc:hdr_math_macros` target, and replacing
all dependency on `libc:llvm_libc_macros_math_macros` with
`libc:hdr_math_macros`.
2024-04-05 18:21:16 -04:00
Michael Jones
5264c22ef1
[libc] Temporary math macros fix (#87681)
Downstream's having some issues due to math-macros.h issues. These will
be fixed properly soon.

See https://github.com/llvm/llvm-project/issues/87683 for tracking this
tech debt.
2024-04-04 14:28:56 -07:00
Michael Jones
d5f06342a3
[libc] add flag for FP_*LOGB0/NAN values (#86723)
These values vary by system, this flag allows you to toggle their value.
2024-03-27 15:09:57 -07:00
OverMighty
b282259711
[libc][math][c23] Add {,u}fromfp{,x}{,f,l,f128} functions (#86003)
Fixes #85279.

cc @lntue
2024-03-25 10:26:22 -04:00
Roland McGrath
c56211b243
[libc] Make math-macros.h C++-friendly (#86206)
The isfinite, isnan, and isinf "functions" are specified by C99..C23 to
be macros that act as type-generic functions. Defining them as their
__builtin_* counterparts works fine for this. However, in C++ the
identifiers need to be usable in different contexts, such as being
declared inside a C++ namespace. So define inline constexpr template
functions for them under `#ifdef __cplusplus`.
2024-03-21 18:11:31 -04:00
Petr Hosek
bb5921e2a2
[libc] Include FP_* macros in math.h (#84996)
These are used unconditionally by libc++ math.h.

This is related to issue #84879.
2024-03-12 17:01:29 -07:00
Nick Desaulniers
330793c91d
[libc] fix clang-tidy llvm-header-guard warnings (#82679)
Towards the goal of getting `ninja libc-lint` back to green, fix the numerous
instances of:

    warning: header guard does not follow preferred style [llvm-header-guard]

This is because many of our header guards start with `__LLVM` rather than
`LLVM`.

To filter just these warnings:

    $ ninja -k2000 libc-lint 2>&1 | grep llvm-header-guard

To automatically apply fixits:

    $ find libc/src libc/include libc/test -name \*.h | \
        xargs -n1 -I {} clang-tidy {} -p build/compile_commands.json \
        -checks='-*,llvm-header-guard' --fix --quiet

Some manual cleanup is still necessary as headers that were missing header
guards outright will have them inserted before the license block (we prefer
them after).
2024-02-28 12:53:56 -08:00
Joseph Huber
fd42044649
[libc] Re-Enable GPU tests and fix math exception handling (#83172)
Summary:
A lot of these tests failed previously and were disabled. However we
have fixed some things since then and many of these seem to pass.
Additionally, the last remaining math tests that failed seemed to be due
to the exception handling. For now we just set it to be 'errno'.

These pass locally when tested on a gfx1030, gfx90a, and sm_89
architecture. Hopefully these pass correctly on the sm_60 bot as I've
had things fail on that one only before.
2024-02-27 13:51:01 -06:00
lntue
aa95aa69b9
[libc][math][c23] Add C23 math functions ilogbf128, logbf128, and llogb(f|l|f128). (#82144) 2024-02-27 12:23:19 -05:00
Siva Chandra Reddy
9edef3e93d [libc] Move math.h and fenv.h macro definitions to llvm-libc-macros.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145475
2023-03-07 18:08:52 +00:00