In the printf_core CMake, the file pieces are defined as object
libraries that depend on the File data structure. If these are added
unconditionally they'll try to evaluate that dependancy even when there
is no File available. This patch adds a guard to prevent that error.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D131921
To use the FILE data structure, LLVM-libc must be in fullbuild mode
since it expects its own implementation. This means that (f)printf can't
be used without fullbuild, but s(n)printf only uses strings. This patch
adjusts the CMake to allow for this.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D131913
To accurately measure the size of sprintf in a finished binary, the
easiest method is to simply build a binary with and without sprintf.
This patch adds an integration test that can be built with and without
sprintf, as well as targets to build it.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D131735
Implement tanf function correctly rounded for all rounding modes.
We use the range reduction that is shared with `sinf`, `cosf`, and `sincosf`:
```
k = round(x * 32/pi) and y = x * (32/pi) - k.
```
Then we use the tangent of sum formula:
```
tan(x) = tan((k + y)* pi/32) = tan((k mod 32) * pi / 32 + y * pi/32)
= (tan((k mod 32) * pi/32) + tan(y * pi/32)) / (1 - tan((k mod 32) * pi/32) * tan(y * pi/32))
```
We need to make a further reduction when `k mod 32 >= 16` due to the pole at `pi/2` of `tan(x)` function:
```
if (k mod 32 >= 16): k = k - 31, y = y - 1.0
```
And to compute the final result, we store `tan(k * pi/32)` for `k = -15..15` in a table of 32 double values,
and evaluate `tan(y * pi/32)` with a degree-11 minimax odd polynomial generated by Sollya with:
```
> P = fpminimax(tan(y * pi/32)/y, [|0, 2, 4, 6, 8, 10|], [|D...|], [0, 1.5]);
```
Performance benchmark using `perf` tool from the CORE-MATH project on Ryzen 1700:
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanf
CORE-MATH reciprocal throughput : 18.586
System LIBC reciprocal throughput : 50.068
LIBC reciprocal throughput : 33.823
LIBC reciprocal throughput : 25.161 (with `-msse4.2` flag)
LIBC reciprocal throughput : 19.157 (with `-mfma` flag)
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanf --latency
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH latency : 55.630
System LIBC latency : 106.264
LIBC latency : 96.060
LIBC latency : 90.727 (with `-msse4.2` flag)
LIBC latency : 82.361 (with `-mfma` flag)
```
Reviewed By: orex
Differential Revision: https://reviews.llvm.org/D131715
Specifically, POSIX functions pthread_key_create, pthread_key_delete,
pthread_setspecific and pthread_getspecific have been added. The C
standard equivalents tss_create, tss_delete, tss_set and tss_get have
also been added.
Reviewed By: lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D131647
The default IntegerToString class only supports base 10, this patch adds
a version which supports any base between 2 and 36 inclusive. This will
be used in an upcoming patch.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D131301
Previously, the integer_to_string tests used EXPECT_TRUE(.equals)
which doesn't have useful error messages. Now they properly check
equality with the EXPECT_EQ macro, which allows for comparing the
strings more naturally.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D131300
This data structure uses a backing cpp::array object and supports a
vector like push_back API. In comparison with a traditional vector
data structure, it is of a fixed capacity and cannot be resized.
Differential Revision: https://reviews.llvm.org/D131377
This class has only the minimum functionality in it to provide what the
TZ variable parsing needs. In particular, the standard makes guarantees
about how trivial the destructors are, throws an expception if it's used
incorrectly, etc. There are also missing features.
Tested:
Trivial testsuite added, and use in development.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D129920
Since this now allows, the init/fini array iteration has been added in
a similar fashion to x86_64 and the corresponding test enabled.
Reviewed By: jeffbailey
Differential Revision: https://reviews.llvm.org/D131133
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion.
Differential Revision: https://reviews.llvm.org/D130771
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion.
Differential Revision: https://reviews.llvm.org/D130762
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion.
Differential Revision: https://reviews.llvm.org/D130760
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion.
Differential Revision: https://reviews.llvm.org/D130773
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion. Starting with the type_traits header.
Differential Revision: https://reviews.llvm.org/D130727
Printf's integer converter has been modified to use the new converter. In
future, it will be used to implement other parts of the libc.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D130227
Currently, there are two string parsers that can be used in a call to
strtofloatingpoint. There is the main parser used by Clinger's fast path
and Eisel-Lemire, and the backup parser used by Simple Decimal
Conversion. There was a bug in the backup parser where if the number had
more than 800 digits (the size of the SDC buffer) before the decimal
point, it would just ignore the digits after the 800th and not count
them into the exponent. This patch fixes that issue and adds regression
tests.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D130032
The API in StringView.h for remove_prefix was incorrect and was returning a
new StringView rather than just altering the view.
As part of this, also removed some of the safety features. The comment
correctly noted that the behaviour is undefined in some cases,
but the code and test cases checked for that.
One caller was relying on the old behaviour, so fixed it and added some
comments.
Tested:
check-libc
llvmlibc
libc-loader-tests
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D129950
This adds functionality for rounding towards negative inf, positive inf,
and zero to the float hex conversion (%a).
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D129702
Add support for three more string_view functions
1) starts_with(char)
2) ends_with(char)
3) find_first_of(char, size_t)
Reimplemented trim in terms of the new starts_with and ends_with.
Tested:
New unit tests.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D129618
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