Commit Graph

104 Commits

Author SHA1 Message Date
Joseph Huber
f7d5e9bc4c [libc] Support the abs functions in the GPU libc.
This patch simply enables building the integer `abs` functions for the
GPU.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D149317
2023-04-27 20:31:59 -05:00
Joseph Huber
72bfe2c05a [libc] Support the string conversion methods on the GPU
This patch enables us to use the existing `libc` support for string
conversion functions on the GPU. This required setting the `fenv_t` and
long double configuration. As far as I am aware, long doubles are
converted to doubles on the GPU and the floating point environment is
just an `uint32_t`.

This code is still untested as we are still working out how to run the
unit tests on the GPU.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D149306
2023-04-27 20:31:58 -05:00
Joseph Huber
807f058487 [libc][Docs] Begin improving documentation for the GPU libc
This patch updates some of the documentation for the GPU libc project.
There is a lot of work still to be done, but this sets the general
outline.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D149194
2023-04-26 10:30:54 -05:00
Kazu Hirata
e042efdab6 [libc] Fix typos in documentation 2023-04-24 23:31:48 -07:00
Siva Chandra Reddy
733ac920be [libc] Add two more recipes to do a cross build.
Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D147350
2023-04-18 12:40:14 -07:00
Tue Ly
f63025f52f [libc][Obvious] Fix the performance table in math function documentation. 2023-04-18 14:10:26 -04:00
Michael Jones
1c261e360f [libc] Add implementation of getchar
added getchar and getchar_unlocked which are just wrappers getc and getc_unlocked respectively.

Reviewed By: sivachandra, lntue, michaelrj

Differential Revision: https://reviews.llvm.org/D147919
2023-04-14 15:40:05 -07:00
Tue Ly
9af8dca70f [libc][math] Update range reduction step for log10f and reduce its latency.
Simplify the range reduction steps by choosing the reduction constants
carefully so that the reduced arguments v = r*m_x - 1 and v^2 are exact in double
precision, even without FMA instructions, and -2^-8 <= v < 2^-7.  This allows the
polynomial evaluations to be parallelized more efficiently.

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D147676
2023-04-07 10:31:46 -04:00
Siva Chandra Reddy
08b9835072 [libc][docs] Add a section about allocations and deallocations to the style doc.
Fixes #59277 - The main part of that bug has already been addressed. This commit
just adds documentation.

Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D146115
2023-03-15 20:41:51 -07:00
Siva Chandra Reddy
be721a38c6 [libc][docs] Move the link to "Compiler Support" under "Status".
Also, fixed a minor typo in compiler_support.rst.

Reviewed By: jeffbailey, gchatelet

Differential Revision: https://reviews.llvm.org/D146112
2023-03-15 20:41:10 -07:00
Jeff Bailey
1b89aeb517 [libc] Add instructions for linux headers
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D146049
2023-03-15 03:02:16 +00:00
Jeff Bailey
ea471e2aa8 [libc] Update cross-compilation instructions
* Add various options so that it uses the build lld and compiler-rt
 * Add instructions on how to use the newly built libc
 * Remove trailing comments in code-block for cut and pastability

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145878
2023-03-14 05:31:20 +00:00
Michael Jones
08df6c78b5 [libc][docs] update list of completed stdio funcs
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145633
2023-03-09 10:44:50 -08:00
Michael Jones
60178f04fc [libc][docs] add link to join the discord
Previously we only linked to the channel within the discord.

Differential Revision: https://reviews.llvm.org/D145283
2023-03-07 16:33:27 -08:00
Siva Chandra Reddy
4155503b71 [libc] Add a note about using assertions in the libc runtime code.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145466
2023-03-07 10:16:50 -08:00
Siva Chandra Reddy
4052bc8674 [libc] Make errno an entrypoint.
The entrypoint has been added to the various entrypoint lists. The libc
code style doc has been updated with information on how errno should be
set from the libc runtime code.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145179
2023-03-03 06:59:19 +00:00
Siva Chandra Reddy
54faf22f7b [libc][NFC] Move all developer docs into a sub-directory docs/dev. 2023-03-02 10:59:49 -08:00
Tue Ly
6c7894a8e6 [libc][doc] Move docs/math.rst to docs/math/index.rst
Move docs/math.rst to docs/math/index.rst

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D144028
2023-02-14 13:41:44 -05:00
Renyi Chen
6cb14adbfa [libc][math] Implement scalbn, scalbnf, scalbnl.
Implement scalbn via `fptuil::ldexp` for `FLT_RADIX==2` case.
"unimplemented" otherwise.

Reviewed By: lntue, sivachandra

Differential Revision: https://reviews.llvm.org/D143116
2023-02-09 05:55:34 +00:00
Guillaume Chatelet
a2569a76e0 [libc][NFC] Rename macros 2023-02-07 20:43:33 +00:00
Guillaume Chatelet
83e98c8556 [libc][doc] Update compiler
Differential Revision: https://reviews.llvm.org/D143389
2023-02-07 09:32:34 +00:00
Guillaume Chatelet
c1832e903e [libc][doc] Add macros guidelines
This is a first follow up on the libc tuning RFC
https://discourse.llvm.org/t/rfc-llvm-libc-tuning/67980

Once we agree on the format. I'll land a couple of patches to match the guidelines.

Differential Revision: https://reviews.llvm.org/D143413
2023-02-07 09:29:36 +00:00
Tue Ly
a48c4a45e0 [libc][Obvious] Change ninja llvmlibc to ninja libc in the documentations. 2023-02-03 15:16:01 -05:00
Tue Ly
1ad8d9d66d [libc][bazel] Add bazel targets and unit tests for math functions.
Add bazel targets and unit tests for single precision exponential,
logarithm, trigonometric, inverse trig, hyperbolic, and inverse hyperbolic
functions.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D143275
2023-02-03 15:11:20 -05:00
David Spickett
008acfb519 [libc] Fix quotation marks in overlay mode instructions
These were using ” ("right double quotation mark") instead of
the usual ". This means CMake took the value literally and you
got:
```
CMake Error at CMakeLists.txt:139 (MESSAGE):
  ”libc” isn't a known project:
  bolt;clang;clang-tools-extra;compiler-rt;cross-project-tests;libc;libclc;lld;lldb;mlir;openmp;polly;pstl;flang.
  Did you mean to enable it as a runtime in LLVM_ENABLE_RUNTIMES?
```
`="libc"` works fine.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D143254
2023-02-03 14:44:40 +00:00
Tue Ly
9b30f6b6d7 [libc][math] Implement acoshf function correctly rounded to all rounding modes.
Implement acoshf function correctly rounded to all rounding modes.

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D142781
2023-02-01 11:35:15 -05:00
Tue Ly
46b15fd19e [libc][math] Implement asinhf function correctly rounded for all rounding modes.
Implement asinhf function correctly rounded for all rounding modes.

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D142681
2023-01-27 11:12:27 -05:00
Siva Chandra Reddy
05d9cc4799 [libc][NFC] Replace "inline" keyword with "LIBC_INLINE".
This is the first of patches doing similar cleanup. A section in the
code style doc has been added explaining where and how LIBC_INLINE is to
be used.

Reviewed By: jeffbailey, lntue

Differential Revision: https://reviews.llvm.org/D142434
2023-01-24 19:35:34 +00:00
Tue Ly
5814b7b279 [libc][math] Implement log10 function correctly rounded for all rounding modes
Implement double precision log10 function correctly rounded for all
rounding modes.  This implementation currently needs FMA instructions for
correctness.

Use 2 passes:
Fast pass:
- 1 step range reduction with a lookup table of `2^7 = 128` elements to reduce the ranges to `[-2^-7, 2^-7]`.
- Use a degree-7 minimax polynomial generated by Sollya, evaluated using a mixed of double-double and double precisions.
- Apply Ziv's test for accuracy.
Accurate pass:
- Apply 5 more range reduction steps to reduce the ranges further to [-2^-27, 2^-27].
- Use a degree-4 minimax polynomial generated by Sollya, evaluated using 192-bit precisions.
- By the result of Lefevre (add quote), this is more than enough for correct rounding to all rounding modes.

In progress: Adding detail documentations about the algorithm.

Depend on: https://reviews.llvm.org/D136799

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D139846
2023-01-08 17:41:54 -05:00
Guillaume Chatelet
062a7ea591 [libc] Add a section about supported compilers in the documentation
Context https://github.com/llvm/llvm-project/issues/59368

Differential Revision: https://reviews.llvm.org/D141045
2023-01-06 09:30:50 +00:00
Siva Chandra Reddy
fbe0b51767 [libc] Make the sidebar colors have a higher constract in the white background.
Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D141039
2023-01-05 09:43:59 -08:00
Siva Chandra Reddy
36de85f93f [libc] Add document for a recipe to do a full standalone cross-build.
Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D141037
2023-01-05 09:37:21 -08:00
Jeff Bailey
6e5c35819e [libc] Add documentation on hacking with vscode
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D140826
2023-01-05 17:27:32 +00:00
Jeff Bailey
bc09f1e5c3 [libc] [nfc] Fix heading underline.
Differential Revision: https://reviews.llvm.org/D140825
2023-01-01 20:53:10 +00:00
Siva Chandra Reddy
4f9c10eb48 [libc] Add support for standalone cross compilation of libc.
One should be able to do a cross build of the libc now. For example, using
clang on a x86_64 linux host, one can build for an aarch64 linux target by
specifying -DLIBC_TARGET_TRIPLE=aarch64-linux-gnu.

Follow up changes will add a baremetal config and also appropriate
documentation about cross compiling the libc for CPU targets.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D140351
2022-12-20 00:33:35 +00:00
Siva Chandra Reddy
9a07780687 [libc][NFC] Rename "loader" to "startup".
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D140049
2022-12-15 19:54:21 +00:00
Guillaume Chatelet
436c8f4420 [reland][libc] Add bcopy
Differential Revision: https://reviews.llvm.org/D138994
2022-12-01 10:07:04 +00:00
Guillaume Chatelet
c5fe7eb216 Revert D138994 "[libc] Add bcopy"
Broke build bot

This reverts commit 186a15f7a9.
2022-12-01 09:55:36 +00:00
Guillaume Chatelet
186a15f7a9 [libc] Add bcopy
Differential Revision: https://reviews.llvm.org/D138994
2022-12-01 09:52:10 +00:00
Joseph Huber
db923a610b [libc][docs] Fix code block not being emitted 2022-11-30 09:33:40 -06:00
Joseph Huber
194788b2fd [libc][docs] Add documentation for the new GPU mode
This patch introduces documentation for the new GPU mode added in
D138608. The documentation includes instructions for building and using
the library, along with a description of the supported functions and
headers.

Reviewed By: sivachandra, lntue, michaelrj

Differential Revision: https://reviews.llvm.org/D138856
2022-11-29 14:51:55 -06:00
Raman Tenneti
78f172e45a [libc] Implement gettimeofday
Implement gettimeofday per
.../onlinepubs/9699919799/functions/gettimeofday.html.
This call clock_gettime to implement gettimeofday function.

Tested:
Limited unit test: This makes a call and checks that no error was
returned. Used nanosleep for 100 microseconds and verfified it
returns a value that elapses more than 100 microseconds and less
than 300 microseconds.

Co-authored-by: Jeff Bailey <jeffbailey@google.com>

Differential Revision: https://reviews.llvm.org/D137881
2022-11-11 18:02:33 -08:00
Siva Chandra Reddy
b12c677033 [libc][docs] Add a build and test document. 2022-11-05 01:06:01 -07:00
Siva Chandra Reddy
64821f178e [libc][docs] Fix typos. 2022-11-05 00:21:09 -07:00
Siva Chandra Reddy
1bb6f1bb8f [libc][docs] Move links to internal developer guides out of the main side bar.
The links are all now from a "Developer Guides" page which is linked from the
main side bar.
2022-11-05 00:04:50 -07:00
Siva Chandra Reddy
136b927c9e [libc] Add a doc about the libc fullbuild mode.
Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D137061
2022-11-02 08:18:48 -07:00
Siva Chandra Reddy
f7fd4f319a [libc] Add links to libc Discourse and to the libc Discord channel.
Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D137229
2022-11-02 08:03:53 -07:00
Siva Chandra Reddy
a2a87ee7e9 [libc] Add a contributing guide to the docs.
Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D136961
2022-11-02 08:02:11 -07:00
Siva Chandra Reddy
9dd7388668 [libc] Add a porting guide to the docs.
Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D136960
2022-11-02 07:59:07 -07:00
Siva Chandra
227eb3d72d [libc] Cleanup stale documentation. 2022-10-26 22:53:15 -07:00