Commit Graph

277 Commits

Author SHA1 Message Date
OverMighty
7683a16dbf [libc][math][c23] Add {remainder,remquo}f16 C23 math functions (#94773)
Part of #93566.
2024-06-10 11:02:09 -04:00
OverMighty
10cd96dd33 [libc][math][c23] Add {frexp,ilogb,llogb,logb,modf}f16 C23 math functions (#94758)
Part of #93566.
2024-06-10 08:38:47 -04:00
OverMighty
cb1a727dea [libc][math][c23] Add nanf16 C23 math function (#94767)
Part of #93566.
2024-06-10 00:19:22 -04:00
Hendrik Hübner
44aecca020 [libc][math][C23] Implemented remquof128 function (#94809)
Added remquof128 function. Closes #94312
2024-06-08 15:08:45 -04:00
Job Henandez Lara
263be9fb00 [libc][math][c23] fmul correcly rounded to all rounding modes (#91537)
This is an implementation of floating point multiplication:

It will consist of 
   - `double x double -> float`
2024-06-08 15:07:27 -04:00
OverMighty
0cdb0b7473 [libc][math][c23] Add fmodf16 C23 math function (#94629)
Part of #93566.
2024-06-07 18:26:58 -04:00
OverMighty
dd1cd02a43 [libc][math][c23] Add {fmaximum,fminimum}{,_mag,_mag_num,_num} C23 math functions (#94510)
#93566
2024-06-06 11:20:29 -04:00
OverMighty
63cda2d19c [libc][math][c23] Add {nextafter,nexttoward,nextup,nextdown}f16 C23 math functions (#94535)
#93566
2024-06-05 23:06:48 -04:00
Hendrik Hübner
8e67495326 [libc][math][c23] Implement fmaxf16 and fminf16 function (#94131)
Implements fmaxf16 and fminf16, which are two missing functions listed
here: #93566
2024-06-05 22:44:44 -04:00
OverMighty
c537f35646 [libc][math][c23] Add fdimf16 C23 math function (#94354)
#93566
2024-06-05 10:37:55 -04:00
OverMighty
6c97303681 [libc][math][c23] Add copysignf16 C23 math function (#94351)
#93566
2024-06-05 09:46:36 -04:00
OverMighty
3614beede1 [libc][math][c23] Add canonicalizef16 C23 math function (#94341)
#93566
2024-06-05 08:24:23 -04:00
Joachim Meyer
8896f21ca9 [NFC] Fix typo in libc/docs/gpu/using.rst 2024-06-04 15:40:45 -07:00
OverMighty
6b5ae148e5 [libc][math][c23] Add {fromfp,fromfpx,ufromfp,ufromfpx}f16 C23 math functions (#94254)
https://github.com/llvm/llvm-project/issues/93566
2024-06-04 18:29:53 -04:00
OverMighty
2635d0419e [libc][math][c23] Add {nearbyint,rint,lrint,llrint,lround,llround}f16 C23 math functions (#94218)
https://github.com/llvm/llvm-project/issues/93566
2024-06-04 10:03:31 -04:00
OverMighty
25b037bdb5 [libc][math][c23] Add {ceil,floor,round,roundeven,trunc}f16 C23 math functions (#94001) 2024-06-03 14:28:51 -04:00
Schrodinger ZHU Yifan
142afde0eb [libc] rework mutex (#92168) 2024-05-31 18:57:18 -07:00
OverMighty
0eb9e021b1 [libc][math][c23] Add fabsf16 C23 math function (#93567)
cc @lntue
2024-05-30 15:37:15 -04:00
Michael Flanders
0f6c4d8b06 [libc][docs] adds macro handling, POSIX status, and validation to docgen (#89421)
docgen now lists macro implementation status in the generated rst files.

Adds POSIX definition link property to docgen json API (`posix-definition`) and
changes the `defined` property of docgen json API to `c-definition`. Now that
docgen's api is getting more specified, adds validation checks to docgen to
start codifying the docgen api spec.

To make sure this all looks good, I've added POSIX definition links to signal.h
as a tester.
2024-05-23 10:48:16 -07:00
Fabian Keßler
cd7a7a56fc Add basic char*_t support for libc (partial WG14 N2653) (#90360)
This PR implements a part of WG14 N2653:
 - Define C23 char8_t
 - Define C11 char16_t
 - Define C11 char32_t
 
 Missing goals are:
- The type of UTF-8 character literals is changed from unsigned char to
char8_t. (Since UTF-8 character literals already have type unsigned
char, this is not a semantic change).
- New mbrtoc8() and c8rtomb() functions declared in <uchar.h> enable
conversions between multibyte characters and UTF-8.
    - A new ATOMIC_CHAR8_T_LOCK_FREE macro.
    - A new atomic_char8_t typedef name.
2024-04-30 15:08:38 -07:00
Michael Flanders
5e9937d1b3 [libc][math] Adds entrypoint and tests for nearbyintf128,scalbnf128 (#88443)
Closes #84689.

Adding @lntue for review.

I was curious about the implementation of
`round_using_current_rounding_mode` used for the `nearbyint` functions.
It has one of the rounding modes as unreachable
([here](https://github.com/llvm/llvm-project/blob/main/libc/src/__support/FPUtil/NearestIntegerOperations.h#L243)),
and I was wondering if this was okay for the `nearbyint` functions.

---------

Co-authored-by: Michael Flanders <mkf727@cs.washington.edu>
2024-04-29 19:25:45 -04:00
Rajveer Singh Bharadwaj
3ae10fde39 [libc] Generate docs for setjmp.h (#89542)
Resolves #88065

Added macros and functions.
2024-04-23 11:28:09 -07:00
Nick Desaulniers
0336116ed4 [libc][docs] codify Policy on Assembler Sources (#88185)
It would be helpful in future code reviews to document a policy with
regards to
where and when Assembler sources are appropriate. That way when
reviewers point
out infractions, they can point to this written policy, which may help
contributors understand that it's not solely the personal preferences of
individual reviewers but instead rather a previously agreed upon rule by
maintainers.

Link: https://github.com/llvm/llvm-project/pull/87837
Link: https://github.com/llvm/llvm-project/pull/88157
Link:
https://discourse.llvm.org/t/hand-written-in-assembly-in-libc-setjmp-longjmp/73249/12
2024-04-22 11:57:28 -07:00
Nick Desaulniers
7aad1ee70f [libc][docs] link to good beginner bugs (#89297)
Tagging bugs as "good first issue" and taking the time to work with new
contributors pays dividends.
2024-04-18 13:38:00 -07:00
Michael Flanders
bd0f818d63 [libc][docs] adds threads.h impl status docs (#89275)
Closes #88067.

Adding @nickdesaulniers for review.
2024-04-18 12:26:41 -07:00
Michael Flanders
2a2e21cd2b [libc][docs] adds highlighting languages to docs/dev/config_options.rst (#89136)
Fixes #89135.
2024-04-18 12:26:14 -07:00
Robin Caloudis
b854a23233 [libc][c23][fenv] Implement fetestexceptflag (#87828)
Provide C23 `fetestexceptflag` function according to 7.6.4.6 in the
latest [revision of the C
standard](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf)
from 2023-04-02.

Closes https://github.com/llvm/llvm-project/issues/87565.
2024-04-17 08:38:47 -07:00
Michael Flanders
2996cb7970 [libc][docs] use docgen to generate stdbit rst docs (#88540)
Closes #88066.

Compared to before, the function names in the stdbit table are sorted by
function name, not order-of-appearance in the standard. Since macros
aren't printed by docgen.py and are still a TODO in the code, they are
also not printed in the new stdbit.h docs.

Adds some checks to docgen.py for conditions that tripped me up.

Add code to docgen.py to add the include of the `|check|` rewriter,
since all other generated files need it.
2024-04-12 14:35:10 -07:00
Nick Desaulniers
f626a35086 [libc] Codify header inclusion policy (#87017)
When supporting "overlay" vs "fullbuild" modes, "what ABI are you
using?" becomes a fundamental question to have concrete answers for.
Overlay mode MUST match the ABI of the system being overlayed onto;
fullbuild more flexible (the only system ABI relevant is the OS kernel).

When implementing llvm-libc we generally prefer the include-what-you use
style of avoiding transitive dependencies (since that makes refactoring
headers more painful, and slows down build times). So what header do you
include for any given type or function declaration? For any given
userspace program, the answer is straightforward. But for llvm-libc
which is trying to support multiple ABIs (at least one per
configuration), the answer is perhaps less clear.

This proposal seeks to add one layer of indirection relative to what's
being done today.

It then converts users of sigset_t and struct epoll_event and the epoll
implemenations over to this convention as an example.
2024-04-11 10:11:58 -07:00
Xu Zhang
7ab7e7a55f [libc][docs] Generate docs for signal.h & optimized is_implemented func (#88028)
Fixes #87835

This patch added the documentation for the POSIX functions according to
[n3096](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf)
Section 7.14, and gives the *docgen.py* script a more elegant *is_implemented*
function.
2024-04-11 08:49:59 -07:00
Joseph Huber
fad14707b7 [libc] Add note to use LIBC_GPU_BUILD=ON as another form
Summary:
This is a shorthand to enable GPU support so it should be listed in the
docs.
2024-04-10 14:07:57 -05:00
Nick Desaulniers
e127997155 [libc][docs] fix missing include
Fixes #87946
2024-04-08 15:58:36 -07:00
Zander Dumont-Strom
279c758b5d [libc][docs] generate docs for ctype.h (#87946)
Fixes #87833
2024-04-08 15:51:31 -07:00
Nick Desaulniers
af34a5d382 [libc][docs] Introduce docgen (#87682)
This script+config should help us generate more consistent documentation wrt.
what we currently support or not.

As an example usage:

    $ ./libc/utils/docgen/docgen.py fenv.h

Will spit out an RST formatted table that can be copy+pasted into our docs.

The config is not filled out entirely, but doing so and then updating our docs
would be great beginner bugs for new contributors.

Having python+json generate things like docs, or headers (as imagined in
https://github.com/nickdesaulniers/llvm-project/tree/hdr-gen2) is perhaps
easier to work with than tablegen, and doesn't introduce a dependency on a host
tool that needs to be compiled from llvm sources before building the rest of
the libc. This can probably be merged with whatever we end up doing to replace
libc-hdrgen.

Please use

https://llvm.org/docs/CodingStandards.html#python-version-and-source-code-formatting
for keeping this file formatted.
2024-04-05 14:50:45 -07:00
aniplcc
8ee6ab7f69 [libc][c23][fenv] implement fesetexcept (#87603)
Closes #87564
2024-04-05 13:52:57 -07:00
Vinayak Dev
3b961d113e [libc] Implement roundeven C23 math functions (#87678)
Implements the functions `roundeven()`, `roundevenf()`, `roundevenl()`
from the roundeven family of functions introduced in C23. Also
implements `roundevenf128()`.
2024-04-05 08:36:12 -04:00
OverMighty
a8c59750d9 [libc][math][c23] Add exp2m1f C23 math function (#86996)
Fixes #86502.

cc @lntue
2024-04-04 08:22:45 -04:00
Vinayak Dev
986435c765 [libc] Move {f,d}sqrt to higher functions in docs (#87445)
Moves the functions `fsqrt()` and `dsqrt()` from basic functions to
higher math functions in math docs
2024-04-02 22:39:48 -04:00
Vinayak Dev
2fb5440e76 [libc] Re-organize the math function tables in docs (#87412)
Re-organizes the tables that listed libc's support for math functions,
and adds two new columns to the tables indicating where the respective
function definitions and error handling methods are located in the C23
standard draft WG14-N3096.
2024-04-02 22:23:35 -04:00
lntue
2be722587f [libc][math] Implement atan2f correctly rounded to all rounding modes. (#86716)
We compute atan2f(y, x) in 2 stages:
- Fast step: perform computations in double precision , with relative
errors < 2^-50
- Accurate step: if the result from the Fast step fails Ziv's rounding
test, then we perform computations in double-double precision, with
relative errors < 2^-100.

On Ryzen 5900X, worst-case latency is ~ 200 clocks, compared to average
latency ~ 60 clocks, and average reciprocal throughput ~ 20 clocks.
2024-04-01 13:31:07 -04:00
Schrodinger ZHU Yifan
a8b0ecd260 [libc] enable stack protectors and frame pointers on default (#86288) 2024-03-29 20:17:11 -04:00
Joseph Huber
99379522d0 [libc][Docs] Update RPC server example using CUDA after changes
Summary:
This has changed, so update it to match the new interface.
2024-03-29 13:13:20 -05:00
Om Prakaash
fdef5c4f45 Add bit width length modifier to printf (#82461)
Resolves #81685. This adds support for wN and wfN length modifiers in
fprintf.
2024-03-29 10:15:22 -07:00
Nick Desaulniers
8a071678a9 Revert "[libc][math][c23] Add remaining linux/* entrypoints for {,u}fromfp{,x}* (#86692)"
This reverts commit cd17082b24 because the newly
added tests fail on 32b ARM.

Link: #86692
Link: https://lab.llvm.org/buildbot/#/builders/229/builds/24458
2024-03-27 13:28:26 -07:00
OverMighty
cd17082b24 [libc][math][c23] Add remaining linux/* entrypoints for {,u}fromfp{,x}* (#86692) 2024-03-27 12:28:27 -07:00
Marc Auberer
77118536b5 [libc] Remove obsolete LIBC_HAS_BUILTIN macro (#86554)
Fixes #86546 and removes the macro `LIBC_HAS_BUILTIN`. This was
necessary to support older compilers that did not support
`__has_builtin`. All of the compilers we support already have this
builtin.
See: https://libc.llvm.org/compiler_support.html
All uses now use `__has_builtin` directly

cc @nickdesaulniers
2024-03-27 17:22:41 +01:00
Shourya Goel
19ca79e867 [libc][math][c23] Implement canonicalize functions (#85940)
Fixes: #85286
2024-03-26 08:28:22 -04: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
aniplcc
c04807c84e [libc][c11] Add stdio.h's rename() function (#85068)
Adds stdio.h's rename() function as defined in n3096. Fixes  #84980.
2024-03-21 08:21:06 -07:00
OverMighty
85b6af198f [libc][math][c23] Add linux/* entrypoints for nextup* and nextdown* (#85803)
See
https://github.com/llvm/llvm-project/pull/85484#discussion_r1526971653.

There already were entrypoints for linux/x86_64. I haven't tested on the other
targets and will rely on the buildbots.
2024-03-19 12:47:01 -07:00