Commit Graph

965 Commits

Author SHA1 Message Date
Alex Brachet 04c681d195 [libc] Specify rounding mode for strto[f|d] tests
The specified rounding mode will be used and restored
to what it was before the test ran.

Additionally, it moves ForceRoundingMode and RoundingMode
out of MPFRUtils to be used in more places.

Differential Revision: https://reviews.llvm.org/D129685
2022-07-13 20:20:30 +00:00
Alex Brachet 31cccebb5c [libc][NFC] Make explicit casts for gcc 2022-07-13 16:53:39 +00:00
Alex Brachet 2e8fa86e09 [libc] Add explicit casts for gcc 2022-07-13 16:52:13 +00:00
Alex Brachet 4f281fa2a8 [libc] Reset rounding mode after fsetround tests
Differential Revision: https://reviews.llvm.org/D129619
2022-07-13 15:42:47 +00:00
Siva Chandra Reddy 3c5d6312c4 [libc][NFC] Move thread platform data pointer to thread attributes.
Along the way, added constexpr constructors to the Thread data
structures.
2022-07-13 07:09:40 +00:00
Guillaume Chatelet e0aece276f [libc][utils] Add more methods to StringView
Differential Revision: https://reviews.llvm.org/D128908
2022-07-12 07:42:29 +00:00
Michael Jones 9e421a1633 [libc] clean up printf error codes
Move the constants for printf's return values into core_structs, and
update the converters to match.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D128767
2022-07-11 16:49:47 -07:00
Alex Brachet c179bcc151 [libc] Add imaxabs
Differential Revision: https://reviews.llvm.org/D129517
2022-07-11 21:28:21 +00:00
Siva Chandra Reddy 9b9ff63b03 [libc][NFC] Make thread_detach_test an integration test.
This is simple switch from a unittest to an integration test. It is
being done as a preparatory step to adding TLS support to thread
creation. TLS setup and initialization is tightly coupled with the
loader and hence all thread related tests should be integration tests.
2022-07-11 06:48:54 +00:00
Siva Chandra Reddy badda4ac3c [libc] Linux threads - Set CLEAR_TID addr to 0 when exiting a detached thread.
A detached thread cleans itself up at completion. So, the CLEAR_TID memory is
also gone by the time the kernel tries to signal potential waiters. By nulling
the CLEAR_TID address, we prevent the kernel from signalling at a non-existent
futex location.
2022-07-11 04:42:59 +00:00
Siva Chandra Reddy 379428c2ac [libc] Linux threads - store a ptr to the thread attribs in the start args.
Previosly, a pointer to the thread data structure was stored in the
start args. However, the thread data structure need not have the
lifetime of the thread. On the the other hand, thread attributes are
stored on the thread stack so they live as long as the thread lives.
2022-07-10 05:02:45 +00:00
Siva Chandra Reddy 9c78d92557 [libc][NFC] Remove the now used thread_attrib target. 2022-07-09 18:28:28 +00:00
Michael Jones f9f8693be3 [libc] add printf hexadecimal float conversion
This patch adds the %a/A conversions to printf, as well as the compiler
flag to disable floating point handling entirely. This will allow our
printf implementation to display every type of argument allowed by
printf, although some formats are still incomplete.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D129240
2022-07-08 15:58:20 -07:00
Michael Jones 8bf8385ef0 [libc] add dependencies to generic sqrt tests
This adds dependencies on the corresponding sqrt function to each
generic sqrt test. This is so that on platforms that don't support the
math functions, the tests are not run.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D129388
2022-07-08 15:41:11 -07:00
Michael Jones 6656029a49 [libc][nfc] update get_explicit_mantissa
The get_explicit_mantissa function returns the mantissa of an FPBits
floating point value with the implicit leading 1, if appropriate. This
function existed previously, but did not handle non-normal numbers
properly.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D129241
2022-07-07 10:13:24 -07:00
Alex Brachet a442c62888 [libc] Make div test names unique
In Fuchsia, all tests in a directory, ie stdlib, are linked
into one executable, this causes problems for multiple
definitions of the vtables of the div tests because their
class has the same name. This patch just trivially changes
their name to be unique between all div tests.

Differential revision: https://reviews.llvm.org/D129248
2022-07-07 15:06:52 +00:00
Alex Brachet 7c23138f1b [libc][NFC] Make explicit casts 2022-07-07 02:10:05 +00:00
Jeff Bailey bc70ba814d Use add_llvm_install_targets for install-llvmlibc
Using the LLVM rules for install ensures that DESTDIR and other expected
variables for an LLVM install work correctly.

Tested:
Manually with DESTDIR=/tmp/testinstall/ ninja install-llvmlibc

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D129041
2022-07-04 17:18:36 +00:00
Tue Ly 4e6c30c835 [libc] Add a separate algorithm_test.
Differential Revision: https://reviews.llvm.org/D128994
2022-07-04 13:56:35 +00:00
Kirill Okhotnikov fdf1fda5a8 [libc][math] Improved ExhaustiveTest performance.
Previous implementation splits value ranges around threads. Because of
very different performance of testing functions over different ranges,
CPU utilization were poor. Current implementation split test range
over small pieces and threads take the pieces when they finish with
previous. Therefore the CPU load is constant during testing.

Differential Revision: https://reviews.llvm.org/D128995
2022-07-01 18:32:54 +02:00
Guillaume Chatelet b66d02eaa0 Revert "[reland] algorithm_test.cpp"
This reverts commit 1514acb20f.
2022-07-01 10:48:57 +00:00
Guillaume Chatelet 1514acb20f [reland] algorithm_test.cpp
Removing `-ffreestanding` for the tests should allow us to use `<iostream>`

Differential Revision: https://reviews.llvm.org/D128916
2022-07-01 10:45:29 +00:00
Tue Ly ae5c82502e [libc][Obvious] Do not add __NO_ to targets with FLAG__NO suffix. 2022-06-30 10:45:59 -04:00
Guillaume Chatelet 98007e9753 Revert "[libc][test] Remove dependency on sstream in algorithm_test.cpp"
This reverts commit 292b281caf.
2022-06-29 15:12:24 +00:00
Guillaume Chatelet 292b281caf [libc][test] Remove dependency on sstream in algorithm_test.cpp
Bots have been failing in full build mode because ´#include <sstream>´ would pull pthread which is not possible when code is compiled with ´-freestanding´.

Differential Revision: https://reviews.llvm.org/D128809
2022-06-29 14:53:53 +00:00
Michael Jones 88b801392c [libc] add integer writing to printf
This patch adds %n to printf, as well as a compiler flag to disable it.
This is due to it having serious security issues when misused.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D127517
2022-06-28 14:00:46 -07:00
Michael Jones 1088d4ad74 [libc] disable algorithm_test.cpp temporarily
The unit tests introduced in patch D128335 are causing build failures,
and the fix is non-trivial. This patch disables these tests temporarily
until a proper fix can be implemented.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D128746
2022-06-28 11:22:45 -07:00
Michael Jones 03a26c34a7 [libc] Fix compile options for algorithm test
This patch fixes the problem the bots were having with the algorithm
test not including pthreads correctly. They will likely need a manual
forced clean build for this to take effect.

Differential Revision: https://reviews.llvm.org/D128742
2022-06-28 10:22:15 -07:00
Guillaume Chatelet f6f53e990d [libc] Disable use of inlined builtins for tests 2022-06-28 10:17:46 +00:00
Guillaume Chatelet 81863dd303 [libc] Fix missing static_cast 2022-06-28 09:50:54 +00:00
Guillaume Chatelet 5ae9b42efb [libc] Use ASSERT_ instead of EXPECT_ in memcmp tests 2022-06-28 09:36:04 +00:00
Guillaume Chatelet 7f5d7bc827 [libc][mem*] Introduce Algorithms for new mem framework
This patch is a subpart of D125768 intented to make the review easier.

This patch introduces the same algorithms as in `libc/src/string/memory_utils/elements.h` but using the new API.

Differential Revision: https://reviews.llvm.org/D128335
2022-06-28 09:23:49 +00:00
Michael Jones 6ec465ab8f [libc] add printf oct conversion
The oct converter handles the %o conversion.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D127985
2022-06-27 15:36:50 -07:00
Kirill Okhotnikov 5358457089 [libc][docs] Added fmod performance results. 2022-06-27 19:31:54 +02:00
Siva Chandra Reddy 8bb1dd7d34 [libc] Add a simple arm32 config.
This will be expanded in future as more functions are brought up on arm32.
2022-06-27 09:03:22 +00:00
Siva Chandra Reddy fe8017476c [libc][NFC] Make the support thread library an object library.
It was previously a header library. Making it an object library will
allow us to declare thread local variables which can used to setup a
thread's self object.
2022-06-27 08:47:05 +00:00
Siva Chandra Reddy 4965cea2f3 [libc] Add compound assignment and pre-increment operators to UInt. 2022-06-25 06:38:24 +00:00
Siva Chandra Reddy a83034ef2b [libc][Obvious] Compare values of the same type in memory_utils/backend_test. 2022-06-25 04:50:04 +00:00
Siva Chandra Reddy bcdd9fbf08 [libc][Obvious] Fix incorrect nested namespace name. 2022-06-25 04:47:21 +00:00
Siva Chandra Reddy 66a6c1073a [libc] Add a cacheline size of arm target.
It is set arbitrarily at 32 now. It can be adjusted as required in
future.
2022-06-25 04:42:40 +00:00
Kirill Okhotnikov 27aca975b6 [libc][math] Fix broken compilation due to __builtin_inf/nan functions. 2022-06-25 01:39:32 +02:00
Kirill Okhotnikov 349fee08d5 [libc][math] Fix broken aarch64 due to clz refactoring. 2022-06-24 23:59:26 +02:00
Kirill Okhotnikov b8e8012aa2 [libc][math] fmod/fmodf implementation.
This is a implementation of find remainder fmod function from standard libm.
The underline algorithm is developed by myself, but probably it was first
invented before.
Some features of the implementation:
1. The code is written on more-or-less modern C++.
2. One general implementation for both float and double precision numbers.
3. Spitted platform/architecture dependent and independent code and tests.
4. Tests covers 100% of the code for both float and double numbers. Tests cases with NaN/Inf etc is copied from glibc.
5. The new implementation in general 2-4 times faster for “regular” x,y values. It can be 20 times faster for x/y huge value, but can also be 2 times slower for double denormalized range (according to perf tests provided).
6. Two different implementation of division loop are provided. In some platforms division can be very time consuming operation. Depend on platform it can be 3-10 times slower than multiplication.

Performance tests:

The test is based on core-math project (https://gitlab.inria.fr/core-math/core-math). By Tue Ly suggestion I took hypot function and use it as template for fmod. Preserving all test cases.

`./check.sh <--special|--worst> fmodf` passed.
`CORE_MATH_PERF_MODE=rdtsc ./perf.sh fmodf` results are

```
GNU libc version: 2.35
GNU libc release: stable
21.166 <-- FPU
51.031 <-- current glibc
37.659 <-- this fmod version.
```
2022-06-24 23:09:14 +02:00
Siva Chandra Reddy 300f8da8e8 [libc] Add Uint128 type as a fallback when __uint128_t is not available.
Also, the unused specializations of __int128_t have been removed.

Differential Revision: https://reviews.llvm.org/D128304
2022-06-24 16:03:35 +00:00
Siva Chandra Reddy f4580c6d5a [libc][NFC] Remove the templatization from the linux implementation of thread.
This enables setting up a single "self" thread object to be returned by
API like thrd_self and pthread_self.
2022-06-24 08:22:53 +00:00
Siva Chandra Reddy ba93b23eb3 [libc] Revert "Eliminate the internal header library target."
This reverts commit 306f2731f4. The CMake
version used by the bots does like it.
2022-06-23 20:53:09 +00:00
Siva Chandra Reddy 306f2731f4 [libc][NFC] Eliminate the internal header library target.
The internal header library target with name suffix .__header_library
has been removed as it serves no purpose now.
2022-06-23 20:45:25 +00:00
Siva Chandra Reddy 0a537a1299 [libc][NFC] Convert pthread tests which create threads to integration tests. 2022-06-23 20:36:20 +00:00
Siva Chandra Reddy d5475af2f7 [libc][NFC] Convert threads unittests in to integration tests.
This is mostly a mechanical change. In a future pass, all tests from
pthread which create threads will also be converted to integration tests.

Some of thread related features are tightly coupled with the loader. So,
they can only be tested with the in-house loader. Hence, going forward, all
tests which create threads will have to be integration tests.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D128381
2022-06-23 20:32:33 +00:00
Guillaume Chatelet aeccc16497 Re-land [libc] Apply no-builtin everywhere, remove unnecessary flags
This is a reland of D126773 / b2a9ea4420.

The removal of `-mllvm -combiner-global-alias-analysis` has landed separately
in D128051 / 7b73f53790.

And the removal of `-mllvm --tail-merge-threshold=0` is scheduled for
removal in a subsequent patch.
2022-06-22 12:30:20 +00:00
Guillaume Chatelet 67fe3bd33c [libc][mem*] Introduce Sized/Backends for new mem framework
This patch is a subpart of D125768 intented to make the review easier.

The `SizedOp` struct represents operations to be performed on a certain number of bytes.
It is responsible for breaking them down into platform types and forwarded to the `Backend`.

The `Backend` struct represents a lower level abstraction that works only on types (`uint8_t`, `__m128i`, ...).
It is similar to instruction selection.

Differential Revision: https://reviews.llvm.org/D126768
2022-06-22 11:21:06 +00:00
Siva Chandra Reddy 5aa9efbab5 [libc] Fix bug in UInt comparison operators.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D128303
2022-06-22 05:41:07 +00:00
Siva Chandra Reddy a5cb6edb47 [libc] Revert: Temporary disable environment tests for PATH variable.
This reverts commit 2846c2bb4f. The reason
for the disable is not relevant anymore.
2022-06-19 21:39:10 +00:00
Tue Ly 2846c2bb4f [libc] Temporary disable environment tests for PATH variable.
This is blocking fullbuild bot.
2022-06-18 23:04:33 -04:00
Tue Ly c5ca7649e3 [libc][Obvious] Fix c++20-designator warnings for tests that use TmHelper.h. 2022-06-18 22:55:57 -04:00
Siva Chandra be6af89f85 [libc] Add TLS image initialization to aarch64 startup code.
The TLS loader test has been enabled for aarch64.
Handling of PT_TLS' filesz and memsz for x86_64 has also been fixed.

Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D128032
2022-06-17 22:50:14 -07:00
Michael Jones 121c645414 [libc] add printf pointer conv
The pointer converter handles the %p conversion. It uses the hex
converter for most of the conversion.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D127995
2022-06-17 17:18:13 -07:00
Michael Jones ad709a752d [libc][obvious] fix sign warning in file_writer
In the sign writer, a size_t was being compared to an int. This patch
casts the size_t to an int so that the comparison doesn't cause a sign
comparison warning.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D127984
2022-06-17 09:48:04 -07:00
Guillaume Chatelet 7b73f53790 [libc] Rely on __builtin_memcpy_inline for memcpy implementation
This patch removes usage of `-mllvm -combiner-global-alias-analysis`
and relies on compiler builtin to implement `memcpy`.

Note that `-mllvm -combiner-global-alias-analysis` is actually only useful for
functions where buffers can alias (namely `memcpy` and `memmove`). The other
memory functions where not benefiting from the flag anyways.

The upside is that the memory functions can now be compiled from source with
thinlto (thinlto would not be able to carry on the flag when doing inlining).

The downside is that for compilers other than clang (i.e. not providing
`__builtin_memcpy_inline`) the codegen may be worse.

Differential Revision: https://reviews.llvm.org/D128051
2022-06-17 14:22:26 +00:00
Tue Ly 6441bfb886 [libc][Obvious] Fix hyperlink and typo in math status page. 2022-06-17 09:35:51 -04:00
Tue Ly 72c1effb34 [libc] Add a status page for math functions.
Add a status page for math functions.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D127920
2022-06-16 17:41:46 -04:00
Michael Jones 1e6c819d6d [libc][obvious] fix address test on windows
On windows size_t != unsigned long.

Differential Revision: https://reviews.llvm.org/D127989
2022-06-16 10:53:54 -07:00
Michael Jones 5bcda1d3a9 [libc] fix line buffered empty file writes
Previously, any line buffered write of size 0 would cause an error.
The variable used to track the index of the last newline started at
the size of the write - 1, which underflowed. Now it's handled properly,
and a test has been added to prevent regressions.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D127914
2022-06-16 09:54:57 -07:00
Michael Jones 652ecb251e [libc] add printf hex conversion
The hex converter handles the %x and %X conversions.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D126082
2022-06-16 09:51:09 -07:00
Alex Brachet 40a55fff05 [libc][NFC] Make explicit uint16_t casts in fenv 2022-06-16 16:18:44 +00:00
Guillaume Chatelet 4a6929f811 Revert "[libc] Apply no-builtin everywhere, remove unnecessary flags"
This reverts commit b2a9ea4420.
2022-06-16 09:28:17 +00:00
Siva Chandra f8fae5b660 [libc][Obvious] Include arm_acle.h only for aarch64 builds. 2022-06-15 23:06:34 -07:00
Siva Chandra 33d14e3cd3 [libc][aarch64] Set frame pointer of the new thread to the stack pointer.
This allows sniffing thread start args in a robust fashion.
2022-06-15 22:58:49 -07:00
Michael Jones ad233c6047 [libc] add printf
This patch adds the entrypoint for printf. With this, building a
"hello world" program with just LLVM-libc is possible.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D126831
2022-06-15 11:45:38 -07:00
Michael Jones 2e6eccfe34 [libc] refactor printf file writing
Add return values to converter functions to allow for better error
handling when writing files. Also move the file writing code around to
be easier to read.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D127773
2022-06-15 11:45:36 -07:00
Siva Chandra Reddy 0f72a0d2ae [libc][Obvious] Removed few unused vars. 2022-06-15 08:13:38 +00:00
Siva Chandra Reddy f0e608de27 [libc] Add linux threads targets only if __support/OSUtil targets are available. 2022-06-15 07:18:57 +00:00
Siva Chandra Reddy a099139fa9 [libc][NFC] Add src.__support.OSUtil targets conditionally.
Before this change, they were unconditionally added, irrespective of the
availability of the architecture specific pieces.
2022-06-15 06:33:31 +00:00
Siva Chandra Reddy 2eafb96289 [libc][NFC] Use uint32_t to represent futex words.
Futexes are 32 bits in size on all platforms, including 64-bit systems.
2022-06-15 05:44:00 +00:00
Alex Brachet 60d4a10710 [libc] Guard common macro names
Differential revision: https://reviews.llvm.org/D127692
2022-06-14 15:05:16 +00:00
Alex Brachet 6d1543a167 [libc] Add explicit casts for string functions
This fixes warnings from `-Wimplicit-int-conversion`

Differential revision: https://reviews.llvm.org/D127694
2022-06-13 21:07:45 +00:00
Alex Brachet 15db8c306d [libc] Add Fuchsia implementation of ::testing::Test 2022-06-13 21:03:51 +00:00
Siva Chandra Reddy 5db4177817 [libc] Add pthread_detach and thrd_detach.
Tests for pthread_detach and thrd_detach have not been added. Instead, a
test for the underlying implementation has been added as it makes use of
an internal wait method to synchronize with detached threads.

Reviewed By: lntue, michaelrj

Differential Revision: https://reviews.llvm.org/D127479
2022-06-11 05:29:40 +00:00
Tue Ly ee89927707 [libc] Implement double precision FMA for targets without FMA instructions.
Implement double precision FMA (Fused Multiply-Add) for targets without
FMA instructions using __uint128_t to store the intermediate results.

Reviewed By: michaelrj, sivachandra

Differential Revision: https://reviews.llvm.org/D124495
2022-06-10 20:57:27 -04:00
Michael Jones 02f4affe2d [libc] add EXP_MAT_MASK to x87 long double
A previous patch added the constant EXP_MANT_MASK to the FloatProperties
for other types of long double. This patch adds it to the special 80-bit
x87 long double.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D127550
2022-06-10 16:26:29 -07:00
Tue Ly 2a746ebf1a [libc][Obvious] Change all __builtin_clz* calls to clz in builtin_wrappers.h. 2022-06-10 16:03:10 -04:00
Michael Jones 6ce490e5a6 [libc] add buffering to FILE writes
Previously all FILE objects were fully buffered, this patch adds line
buffering and unbuffered output, as well as applying them to stdout and
stderr.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D126829
2022-06-10 09:58:46 -07:00
Benjamin Kramer 6ee5baeb97 [libc][math] Add EXP_MANT_MASK when long double is double or quad 2022-06-10 18:48:31 +02:00
Kirill Okhotnikov b03567fe2b [libc][math] Improved FBits performance and readablity.
Some function added in preparation to fmod commit.

Differential Revision: https://reviews.llvm.org/D127097
2022-06-10 10:21:44 +02:00
Kirill Okhotnikov 76b57ef88c [libc][math] Differential "diff" test for hypot/hypotf functions.
Added test handler in preparation to fmod/fmodf commit.

Differential Revision: https://reviews.llvm.org/D127091
2022-06-10 10:08:47 +02:00
Kirill Okhotnikov 081aba27b1 [libc][math] Separated builtin function in special FPUtils header.
A small refactoring of builtin functions in preparation to adding fmod/fmodf function.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D127088
2022-06-10 03:18:35 +02:00
Michael Jones e1c54d4ddc [libc] move printf_main in to object library
Previously printf_main was a header library, but header library
dependencies don't work properly so it's been moved to an object
library. Additionally, the writers have been marked inline.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D126830
2022-06-09 14:35:18 -07:00
Michael Jones 1be3669dda [libc] add printf base 10 integer conversion
This patch adds support for d, i, and u conversions in printf, as well
as comprehensive unit tests.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D125929
2022-06-09 10:27:11 -07:00
Siva Chandra Reddy 214be9d1cd [libc] Add compile options to pthread_create target.
The compile options now match that of thrd_create. Two compile options
are of importance:
1. -O3 - This is required so that stack is not used between the clone
   syscall and the start function in the child thread.
2. -fno-omit-frame-pointer - This is required so that we can sniff out
   the thread start args from the child thread's stack memory.

Without these two options, pthread_create will exhibit flaky behavior.

Reviewed By: lntue, michaelrj

Differential Revision: https://reviews.llvm.org/D127381
2022-06-09 17:26:19 +00:00
Michael Jones 0bff6a3e39 [libc] simplify printf converter tests
previously the printf converter tests reused the same string_writer,
which meant that each test depended on the tests before it to succeed.
This makes a new string_writer for each test to simplify and clarify the
tests.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D127341
2022-06-09 10:05:22 -07:00
Alex Brachet 6504b15992 [libc][NFC] Mark some methods constexpr
gcc is complaining that these methods are being called
from a function that is marked constexpr but these
aren't.
2022-06-08 22:41:09 +00:00
Alex Brachet 122da690b3 [libc] Fix build when __FE_DENORM is defined
Differential revision: https://reviews.llvm.org/D127222
2022-06-08 16:21:53 +00:00
Jeff Bailey ef3db4fcab Replace Goals and Why section with Introduction
Rewrite the introduction of the page to state clearly the goals of
LLVM's libc project.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D127174
2022-06-07 06:53:54 +00:00
Siva Chandra 0539a6b420 [libc] Align the new thread stack as required by the target ABI. 2022-06-06 14:45:43 -07:00
Tue Ly 667863d8a8 [libc] Fix cmake compatibility issue with list(POP_FRONT).
list(POP_FRONT) is only added to cmake in 3.15, while our base line
version is 3.13

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D127129
2022-06-06 13:36:03 -04:00
Fangrui Song d86a206f06 Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options 2022-06-05 00:31:44 -07:00
Tue Ly 484319f497 [libc] Make expm1f correctly rounded when the targets have no FMA instructions.
Add another exceptional value and fix the case when |x| is small.

Performance tests with CORE-MATH project scripts:
With FMA instructions on Ryzen 1700:
```
$ ./perf.sh expm1f
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
CORE-MATH reciprocal throughput   : 15.362
System LIBC reciprocal throughput : 53.194
LIBC reciprocal throughput        : 14.595
$ ./perf.sh expm1f --latency
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
CORE-MATH latency   : 57.755
System LIBC latency : 147.020
LIBC latency        : 60.269
```
Without FMA instructions:
```
$ ./perf.sh expm1f
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
CORE-MATH reciprocal throughput   : 15.362
System LIBC reciprocal throughput : 53.300
LIBC reciprocal throughput        : 18.020
$ ./perf.sh expm1f --latency
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
CORE-MATH latency   : 57.758
System LIBC latency : 147.025
LIBC latency        : 70.304
```

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D123440
2022-06-03 15:57:48 -04:00
Tue Ly 614567a7bf [libc] Automatically add -mfma flag for architectures supporting FMA.
Detect if the architecture supports FMA instructions and if
the targets depend on fma.

Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D123615
2022-06-03 01:21:20 -04:00
Siva Chandra Reddy 70c8d12b79 [libc] Add pthread_create and pthread_join functions.
They do not yet support all the feature/attributes in pthread_attr_t.
Future changes will add such support.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D126718
2022-06-02 01:47:24 +00:00
Siva Chandra Reddy ad89cf4e2d [libc] Keep all thread state information separate from the thread structure.
The state is now stored on the thread's stack memory. This enables
implementing pthread API like pthread_detach which takes the pthread_t
structure argument by value.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D126716
2022-06-01 17:36:58 +00:00