Commit Graph

833 Commits

Author SHA1 Message Date
wldfngrs
ecf4f95c4f [libc][math][c23] Add tanf16 function (#121018)
- Implementation of tan for 16-bit floating point inputs.
- Exhaustive tests across the 16-bit input range
2025-01-12 23:46:53 -05:00
Schrodinger ZHU Yifan
73dd730fb9 [libc] implement sys/uio/writev (#122233)
implement sys/uio/writev according to POSIX standard. This vectorized IO
API is needed by many logging libraries to achieve atomic logging
multiple strings.
2025-01-10 12:49:00 +08:00
Prabhuk
3b19e787fc [libc] Keep framepointers for baremetal (#121836)
Keep framepointers enabled by default for the default baremetal libc
builds.

Frame pointers help unwind the stack and unwinding without frame pointer
is complex and increaseis the code size. This code size increase is
potentially larger than the savings achieved by disabling frame
pointers. Retaining the original behavior of retaining frame pointers as
the default behavior.
2025-01-07 13:22:14 -08:00
Joseph Huber
f4bab06c97 [libc] Split AMDGPU and NVPTX configs into separate folders (#120153)
Summary:
This is a holdover from when these targets were merged. They're
basically the same but there's no reason they should be treated as
identical. I think we will live with a little duplication.
2025-01-06 13:49:19 -06:00
Prabhuk
7deaed975e [libc] Reduce binary size for baremetal targets (#121164)
For `math` functions we must choose size optimized implementations.
Removing framepointers will also help with binary size savings.
2024-12-26 15:55:39 -08:00
Shourya Goel
9f75b6664f [libc][complex] fix buildbot errors (#121141)
Fix buildbot errors due to #121140
2024-12-26 12:57:48 +05:30
Shourya Goel
abd9102344 [libc][complex] add cfloat16 and cfloat128 compiler flags (#121140)
Proper fix for the temporary fix in #114696
2024-12-26 12:50:07 +05:30
Shourya Goel
ff97daadcd Revert "[libc][complex] enable CFP128 entrypoints on X86_64 (#121111)" (#121113)
This reverts commit dd9c5c1182.
2024-12-25 20:56:13 +05:30
Shourya Goel
dd9c5c1182 [libc][complex] enable CFP128 entrypoints on X86_64 (#121111) 2024-12-25 20:45:32 +05:30
Joseph Huber
3bbd53ce97 [libc] Remove old RPC host call extension for GPU (#120800)
Summary:
This was originally a hacked together function that served to just
implement some features for OpenMP. That has been moved into OpenMP
itself now that we have exported RPC properly. This can now be deleted.
2024-12-20 19:34:05 -06:00
Joseph Huber
958de20b30 [libc] Enable 'timespec_get' for the GPU build (#120304)
Summary:
Currently fails to build libc++ because this is missing.
2024-12-17 15:31:07 -06:00
Shourya Goel
c98e79d856 [libc][complex] Implement different flavors of the cproj function (#119722)
Refer section 7.3.9.5 of ISO/IEC 9899:2023
2024-12-18 02:04:50 +05:30
Petr Hosek
7bf3137c39 [libc] Breakup freelist_malloc into separate files (#119806)
This better matches the structure we use for the rest of libc.
2024-12-16 10:30:27 -08:00
wldfngrs
6a865b6d3d [libc][math][c23] Add cosf16 function (#118785) 2024-12-15 18:58:54 +01:00
Petr Hosek
379cc44f56 Revert "[libc] Breakup freelist_malloc into separate files" (#119749)
Reverts llvm/llvm-project#98784 which broke libc builders.
2024-12-12 13:28:30 -08:00
Petr Hosek
4e2a9e50f6 [libc] Breakup freelist_malloc into separate files (#98784)
This better matches the structure we use for the rest of libc.
2024-12-12 11:24:36 -08:00
Shourya Goel
d5b7b97034 [libc][complex] Add complex.yaml in hdrgen. (#119609) 2024-12-12 03:12:09 +05:30
Nick Desaulniers
d1d5fc381f [libc] fix up strings.h entrypoints (#119417)
I typo'd riscv, and the newly added baremetal aarch64 entrypoints had a mid air
collision.

Link: #118691
Link: #118899
2024-12-10 10:14:01 -08:00
Nick Desaulniers
1d7d0051f9 [libc] move src/network to src/arpa/inet (#119273)
So that docgen can find our implementations.

Fixes: #119272
2024-12-10 08:59:39 -08:00
Nick Desaulniers
431ea2d076 [libc] move bcmp, bzero, bcopy, index, rindex, strcasecmp, strncasecmp to strings.h (#118899)
docgen relies on the convention that we have a file foo.cpp in
libc/src/\<header\>/. Because the above functions weren't in libc/src/strings/
but rather libc/src/string/, docgen could not find that we had implemented
these.

Rather than add special carve outs to docgen, let's fix up our sources for
these 7 functions to stick with the existing conventions the rest of the
codebase follows.

Link: #118860
Fixes: #118875
2024-12-10 08:58:45 -08:00
Shourya Goel
78c2b6d483 [libc][complex] Implement different flavors of the conj function (#118671)
Refer section 7.3.9.4 of ISO/IEC 9899:2023
2024-12-10 10:05:11 +05:30
Schrodinger ZHU Yifan
9a06fb7e5c [libc][time][windows] implement clock_getres (#118931) 2024-12-09 22:00:01 -05:00
Petr Hosek
2e8ce30423 [libc] Support baremetal libc on aarch64 (#118691)
We have users that target baremetal aarch64.
2024-12-09 15:34:51 -08:00
Schrodinger ZHU Yifan
e6cf5d2863 Reapply "[libc][windows] start time API implementation (#117775)" (#118886) 2024-12-05 18:21:03 -05:00
Joseph Huber
9fd052a122 Revert "[libc][windows] start time API implementation (#117775)"
This reverts commit 0adff0af20.

Breaks the GPU build
2024-12-05 14:43:06 -06:00
Schrodinger ZHU Yifan
0adff0af20 [libc][windows] start time API implementation (#117775)
Add a `clock_gettime` emulation layer and use it to implement the `time`
entrypoint.

For windows, the monotonic clock is emulated using `QPC`.
The realtime clock is emulated using `GetSystemTimePreciseAsFileTime`.
2024-12-05 14:08:27 -05:00
Schrodinger ZHU Yifan
245f26a3d3 [libc] revert all process_mrelease changes (#118650)
Revert as its test is unstable.
https://github.com/llvm/llvm-project/issues/118057
2024-12-05 11:58:37 -05:00
Nick Desaulniers
5e769fb234 [libc] add headers.txt for windows (#118675)
Link:
https://github.com/llvm/llvm-project/pull/117220#issuecomment-2518126598

---------

Co-authored-by: Michael Jones <michaelrj@google.com>
2024-12-04 12:38:21 -08:00
Nick Desaulniers
e0ae7793fc [libc] delete hdrgen (#117220)
Thanks to the effort of @RoseZhang03 and @aaryanshukla under the
guidance of
@michaelrj-google and @amykhuang, we now have newhdrgen and no longer
have a
dependency on TableGen and thus LLVM in order to start bootstrapping a
full
build.

This PR removes:
- LIBC_HDRGEN_EXE; the in tree newhdrgen is the only hdrgen that can be
used.
- LIBC_USE_NEW_HEADER_GEN; newhdrgen is the default and only option.
- LIBC_HDRGEN_ONLY; there is no need to have a distinct build step for
old
  hdrgen.
- libc-api-test and libc-api-test-tidy build targets.
- Deletes all .td files.

It does not rename newhdrgen to just hdrgen. Will follow up with a
distinct PR
for that.

Link: #117209
Link: #117254
Fixes: #117208
2024-12-03 12:34:26 -08:00
wldfngrs
cd04653c4e [libc][math][c23] Add sinf16 C23 math function (#116674)
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-12-03 21:08:46 +01:00
Petr Hosek
b8daa45a56 [libc] Implement timespec_get (#116102)
`timespec_get` is C standard counterpart to POSIX `clock_gettime`. On
Linux we simply use `clock_gettime`. On baremetal we introduce a new
external API `__llvm_libc_timespec_get_utc` that should be implemented
by the vendor.
2024-12-02 14:29:49 -08:00
Schrodinger ZHU Yifan
700d9ac9ef [libc] disable process_mrelease for riscv (#117956)
`process_mrelease` upsets the RV32 build bot. Disable it for now.
2024-11-27 21:17:38 -05:00
Omar Hossam
d2b482b0ef [libc] (reland #117503) Implement process_mrelease (#117851)
This PR implements process_mrelease.
A previous PR was merged #117503, but failed on merge due to an issue in
the tests. Namely the failing tests were comparing against return type
as opposed to errno. This is fixed in this PR.
2024-11-27 20:15:17 -05:00
lntue
3372303188 Revert "[libc] Implement process_mrelease." (#117807)
Reverts llvm/llvm-project#117503
2024-11-26 18:07:30 -05:00
Omar Hossam
36a46d85e7 [libc] Implement process_mrelease. (#117503)
This PR addresses #110124.
2024-11-26 17:40:06 -05:00
Petr Hosek
a4f3a10c0e [libc] Include features.h in baremetal targets (#109444)
This is used by other libraries like libc++.
2024-11-12 23:46:20 -08:00
William Tran-Viet
13ced90b00 [libc] {u}lkbits broken on riscv32 (#115799)
- Re-enabled ulkbits and lkbits for Risc-V
- Bumped `int_lk_t` to a `signed long long` and a `uint_ulk_t` to an
`unsigned long long` to guarantee they both fit in 8 bytes, which `long
_Accum` and `unsigned long _Accum` are defaulted to on 32bit
architectures.

This is probably inconvenient on systems that have a word size larger
than 64 bits?

#115778
2024-11-12 10:38:08 -08:00
Nick Desaulniers
28cdebf7ba [libc][stdfix] disable ulkbits on riscv (#115781) (#115792)
I should have disabled this in #115781. Mea culpa.

Link: #114912
Link: #115778
Link: #115781
2024-11-11 16:18:55 -08:00
Nick Desaulniers
448d7da562 [libc][stdfix] disable lkbits on riscv (#115781)
Link: #114912
Link: #115778
2024-11-11 14:45:22 -08:00
Michael Jones
1ae0dae368 [libc] Clean up skipped and failing cmake (#115400)
I normally run my cmake with LIBC_CMAKE_VERBOSE_LOGGING set to ON so I
can debug build issues more easily. One of the effects of this is I see
which tests/entrypoints are skipped on my machine. This patch fixes up
the tests and entrypoints that were skipped, but easily fixed. These
were:

libc.src.pthread.pthread_spin_destroy
libc.src.pthread.pthread_spin_init
libc.src.pthread.pthread_spin_lock
libc.src.pthread.pthread_spin_trylock
libc.src.pthread.pthread_spin_unlock
(entrypoints were just missing)

libc.src.wchar.btowc
(I forgot to finish it)

libc.test.src.sys.statvfs.linux.statvfs_test
libc.test.src.sys.statvfs.linux.fstatvfs_test
(Incorrect includes for rmdir, needed some cleanup)

libc.test.integration.src.unistd.execve_test
(wrong dep for errno)

libc.test.src.math.smoke.fmaf_test
(add_fp_unittest doesn't support flags)

libc.test.src.stdio.scanf_core.converter_test
(needed to be moved away from string_reader, further cleanup needed)
2024-11-11 14:28:36 -08:00
Nick Desaulniers
f1800df5d5 [libc] fix lfind entrypoints (#115771)
- move arm entrypoint to fullbuild only
- remove baremetal entrypoints; we avoid POSIX on baremetal
- remove darwin/arm and windows entrypoints since these are untested

Fixes: #114692
2024-11-11 13:37:59 -08:00
Nick Desaulniers
582a4799e1 [libc] fix lfind old hdrgen (#115760)
Fixes: #114692
2024-11-11 11:51:24 -08:00
William Tran-Viet
c11b6e80b6 [libc][stdfix] Implement fixed point fxbits functions in llvm-libc (#114912) 2024-11-11 12:54:16 -05:00
Duncan
396ed9c2a1 [libc][search] implement posix lfind function (#114692)
# Changes
- Implement the POSIX
[`lfind`](https://man7.org/linux/man-pages/man3/lsearch.3.html)
function.

- Put a checkmark in the [posix support table
docs](https://libc.llvm.org/libc_search.html) next to `lfind`.
2024-11-11 09:53:20 -08:00
wldfngrs
f7bb12901e [libc][math][c23] Add tanpif16 function (#115183)
- Implementation of `tan` for 16-bit floating point inputs scaled by pi.
i.e,. `tanpif16()`
- Implementation of Tanpi in MPFRWrapper for MPFR versions < 4.2
- Exhaustive tests for `tanpif16()`
2024-11-08 09:56:31 -05:00
OverMighty
faefedf7f8 [libc][math][c23] Add exp10m1f C23 math function (#87992)
Fixes #86503.
2024-11-07 23:56:00 +01:00
Jingyu Qiu
5a6cc50921 [libc] add mremap (#112804) 2024-11-06 10:25:50 -08:00
Duncan
6219c80839 [libc] [unistd] implement pipe2 syscall wrapper (#114474)
Closes #85289

Co-authored-by: Michael Jones <michaelrj@google.com>
2024-11-06 08:35:03 -08:00
Shourya Goel
790a7859a8 Comment out CF16 entrypoints for aarch64 and CF128 entrypoints for X84-64 (#114696)
Temporarily Fixes buildbot errors due to #113300
2024-11-03 11:14:11 +05:30
Shourya Goel
ffe04e0351 [libc][complex] implement different flavors of creal and cimag functions (#113300)
I have commented out the test for `neg_zero`(creal) because : 

1. real(neg_zero + 0.0i) equals zero. 
2. real(neg_zero - 0.0i) equals neg_zero.

I am not sure if this is the intended behaviour. 

[EDIT]
I have updated tests for `neg_zero` (creal) to be : 

```
    EXPECT_FP_EQ(func(CFPT(neg_zero - zero * 1.0i)), neg_zero);
    EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);
```

because all three [gcc, clang and GNU MPC] also give the same result. 
https://godbolt.org/z/hxhcn6aof
and it seems that it is indeed the correct behaviour since Imaginary
types are not supported yet, refer #113671
2024-11-03 09:38:09 +05:30