After adding sprintf, snprintf is simple. The functions are very
similar. The tests only cover the behavior of the max length since the
sprintf tests should cover the other behavior.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D125826
This adds the sprintf entrypoint, as well as unit tests. Currently
sprintf only supports %%, %s, and %c, but the other conversions are on
the way.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D125573
This adds the main pieces of the last piece of printf, the converter.
This takes the completed format section from the parser and then
converts it to a string for the writer, which is why it was the last
piece to be written. So far it supports chars and strings, but more
pieces are coming. Additionally, it supports replacing all of the
conversion functions with user supplied versions at compile time to
allow for additional functionality.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D125327
This patch adds a document describing the status of the string functions
in LLVM-libc.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D123823
This patch fixes the includes for the new UInt class so that the api
test now passes, additionally it fixes the bazel files to account for
the new dependencies.
Differential Revision: https://reviews.llvm.org/D125490
Some platforms don't support proper 128 bit integers, but some
algorithms use them, such as any that use long doubles. This patch
modifies the existing UInt class to support the necessary operators.
This does not put this new class into use, that will be in followup
patches.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D124959
This patch is a followup to the previous patch which implemented the
main printf parsing logic as well as sequential mode. This patch adds
index mode.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D123424
The entrypoint list for windows hasn't been updated in a while, this
adds all of the entrypoints that are working for windows now.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D125058
The printf implmentation is made up of three main pieces, the parser,
the converter, and the writer. This patch adds the implementation for
the writer, as well as the function for writing to a string, along with
tests.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D124421
This patch fixes the string to long double tests for systems that use
long double is double, and don't support uint128.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D124803
The PrintfMatcher depends on printf which is in stdio. Stdio is
currently fullbuild only, but the matcher wasn't, causing failing builds
when fullbuild was off. This patch adds the fullbuild condition to the
PrintfMatcher cmake.
Differential Revision: https://reviews.llvm.org/D124304
This patch changes the printf parser tests to use a more robust matcher.
This allows for better debugging of parsing issues. This does not affect
the actual printf code at all, only the tests.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D124130
Note that the underlying flush implementation does not yet fully implement
the POSIX standard. It is complete with respect to the C standard
however. A future change will add the POSIX behavior. It should not affect
the implementation of the fflush function however as the POSIX behavior
will be added in a lower layer.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D124073
POSIX locking and unlocking functions flockfile and funlockfile have
also been added. The locking is not recursive yet. A future patch will
make the underlying lock a recursive lock.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D123986
A section briefly mentioning the planned future enhancements has also
been included.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D123761
This patch adds a document describing the status of the string functions
in LLVM-libc.
Reviewed By: sivachandra, jeffbailey
Differential Revision: https://reviews.llvm.org/D123645
Not all attributes have been added to phtread_attr_t in this patch. They
will be added gradually in future patches.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D123423
This patch adds the sequential mode implementation of the printf parser,
as well as unit tests for it. In addition it adjusts the surrounding
files to accomodate changes in the design found in the implementation
process.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D123339
Make FMA flag checks more accurate for x86-64 targets, and refactor
polyeval to use multiply and add instead when FMA instructions are not
available.
Reviewed By: michaelrj, sivachandra
Differential Revision: https://reviews.llvm.org/D123335
This change is essentially a mechanical change which moves the thread
creation and join implementations from src/threads/linux to
src/__support/threads/linux/thread.h. The idea being that, in future, a
pthread implementation can reuse the common thread implementations in
src/__support/threads.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D123287
This class is intended to be used in cases where a class is being used
on a va_list. It provides destruction and copy semantics with small
overhead. This is intended to be used in printf.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D123061
A simple implementation of the getters and setters has been added. More
logic can be added to them in future as required.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D122969
Instead, memory is allocated and deallocated using mmap and munmap
syscalls directly.
Reviewed By: lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D122876
This patch adds the headers for printf. It contains minimal actual code,
and is more intended to be used for design review. The code is not built
yet, and may have minor errors.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D122773
In the previous patch adding -mfma to functions that need it for windows
builds I missed log2f.
Differential Revision: https://reviews.llvm.org/D122693
On Windows the functions that use fma don't properly include the fma
intrinsics unless -mfma is added to the compile options. This patch adds
the compile option to all of the functions that need it.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D122689
Previously, the "fsqrt" instruction was used on all x86_64 platforms
for finding the square root of long doubles. On long double is double
platforms (e.g. windows) this created errors. This patch changes square
root function for long doubles to be the same as the one for doubles if
long doubles are doubles.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D122688
The clang driver to picks up compiler runtime files using full paths.
Without this, at least for aarch64, the driver tries to pick up the
compiler runtime files from the working directory.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D122617
Reduce the polynomial's degree from 7 down to 4.
Currently we use a degree-7 minimax polynomial on an interval of length 2^-7
around 0 to compute `expf`. Based on the suggestion of @santoshn and the RLIBM
project (https://github.com/rutgers-apl/rlibm-all/blob/main/source/float/exp.c)
and the improvement we made with `exp2f` in https://reviews.llvm.org/D122346,
it is possible to have a good polynomial of degree-4 on a subinterval of length
2^(-7) to approximate e^x.
We did try to either reduce the degree of the polynomial down to 3 or increase
the interval size to 2^(-6), but in both cases the number of exceptional values
exploded. So we settle with using a degree-4 polynomial of the interval of
size 2^(-7) around 0.
Reviewed By: sivachandra, zimmermann6, santoshn
Differential Revision: https://reviews.llvm.org/D122418
Reduce the range-reduction table size from 128 entries down to 64 entries, and
reduce the polynomial's degree from 6 down to 4.
Currently we use a degree-6 minimax polynomial on an interval of length 2^-7
around 0 to compute exp2f. Based on the suggestion of @santoshn and the RLIBM
project (https://github.com/rutgers-apl/rlibm-prog/blob/main/libm/float/exp2.c)
it is possible to have a good polynomial of degree-4 on a subinterval of length
2^(-6) to approximate 2^x.
We did try to either reduce the degree of the polynomial down to 3 or increase
the interval size to 2^(-5), but in both cases the number of exceptional values
exploded. So we settle with using a degree-4 polynomial of the interval of
size 2^(-6) around 0.
Reviewed By: michaelrj, sivachandra, zimmermann6, santoshn
Differential Revision: https://reviews.llvm.org/D122346
The main code for the FILE struct is only enabled on platforms that it
works on, but before this patch the tests were included unconditionally.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D122363
Previously, we used empty, non-ELF crti.o, crtn.o, libm.a and libc++.a
files. Instead, we now still use dummies but they are real ELF object
files and archives.
This patch adds aligned_alloc as an entrypoint. Previously it was being
included implicitly.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D122362
We were previously linking to libllvmlibc.a. But, with libllvmlibc.a now
including functions which depend on the loader, we will have to use the
LLVM libc loader as well. To avoid this, we will link to a special
library which is just a collection of SCUDO allocator entrypoints.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D122360
This patch primarily fixes the fenv implementation on Windows, since
Windows uses the MXCSR in place of the x87 status registers for storing
information about the floating point environment. This allows FEnv to
work correctly on Windows, and successfully build.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D121839
All existing loader tests are switched to an integration test added with
the new rule. Also, the getenv test is now enabled as an integration test.
All loader tests have been moved to test/integration. Also, the simple
checker library for the previous loader tests has been moved to a
separate directory of its own.
A follow up change will perform more cleanup of the loader CMake rules
to eliminate now redundent options.
Reviewed By: lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D122266
An unnecessary dep of the getenv function is removed. From the x86_64
loader, a call to __llvm_libc::memcpy is replaced with call to
__llvm_libc::inline_memcpy.
The platform independent file implementation is not an entrypoint so it
cannot be excluded via the entrypoints.txt file. Hence, we need a
special treatment to exclude it from the build.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D121947
Having a separate flag helps in setting up proper flags when
implementing, say the Linux specialization of File.
Along the way, a signature for a function which is to be used to open
files has been added. The implementation of the function is to be
included in platform specializations.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D121889
This is now possible because we have a platform independent abstraction
for mutexes.
Reviewed By: lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D121773
Implement expm1f function that is correctly rounded for all rounding modes. This is based on expf implementation.
From exhaustive testings, using expf implementation, and subtract 1.0 before rounding the final result to single precision
gives correctly rounded results for all |x| > 2^-4 with 1 exception. When |x| < 2^-25, we use x + x^2 (implemented with a
single fma). And for 2^-25 <= |x| <= 2^-4, we use a single degree-8 minimax polynomial generated by Sollya.
Reviewed By: sivachandra, zimmermann6
Differential Revision: https://reviews.llvm.org/D121574
Implement exp2f function that is correctly rounded for all rounding modes.
Reviewed By: sivachandra, zimmermann6
Differential Revision: https://reviews.llvm.org/D121463
Implement expf function that is correctly rounded for all rounding modes.
Reviewed By: sivachandra, zimmermann6
Differential Revision: https://reviews.llvm.org/D121440
The new container is used to store atexit callbacks. This way, we avoid
the possibility of the destructor of the container itself getting added
as an at exit callback.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D121350
Add initial support for darwin-aarch64 (macOS M1).
Some differences compared to linux-aarch64:
- `math.h` defined `math_errhandling` by the compiler builtin `__math_errhandling()` but Apple Clang 13.0.0 on M1 does not support `__math_errhandling()` builtin as a macro function or a constexpr function.
- `math.h` defines `UNDERFLOW` and `OVERFLOW` macros.
- Besides 5 usual floating point exceptions: `FE_INEXACT`, `FE_UNDERFLOW`, `FE_OVERFLOW`, `FE_DIVBYZERO`, and `FE_INVALID`, `fenv.h` also has another floating point exception: `FE_FLUSHTOZERO`. The corresponding trap for `FE_FLUSHTOZERO` in the control register is at the different location compared to the status register.
- `FE_FLUSHTOZERO` exception flag cannot be raised with the default CPU floating point operation mode.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D120914
There were some "TODO" messages that were for things that I have already
completed. This patch removes those.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D121232
Previously, the entire support/CPP folder was in one header library,
which meant that a lot of headers were included where they shouldn't be.
This patch splits each header into its own target, as well as adjusting
each place they were included to only include what is used.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D121237
The loader TLS test for x86_64, which now passes, has been enabled.
A future change should enable the test for aarch64 as well.
Reviewed By: jeffbailey
Differential Revision: https://reviews.llvm.org/D121091
The idea is that, other parts of the libc which require thread/lock
support will be able to use this platform independent setup.
With this change, only the linux implementation of a mutex type has been
moved to the new library. Because of this, there is some duplication
between the new library and src/threads/linux. A follow up change will
move all of src/threads/linux to the new library. The duplication should
be eliminated with that move.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D120795
With modern architectures having a thread pointer and language supporting
thread locals, there is no reason to use a function intermediary to access
the thread local errno value.
The entrypoint corresponding to errno has been replaced with an object
library as there is no formal entrypoint for errno anymore.
Reviewed By: jeffbailey, michaelrj
Differential Revision: https://reviews.llvm.org/D120920
The upstream project ships CMake rules for building vanilla gtest/gmock which conflict with the names chosen by LLVM. Since LLVM's build rules here are quite specific to LLVM, prefixing them to avoid collision is the right thing (i.e. there does not appear to be a path to letting someone *replace* LLVM's googletest with one they bring, so co-existence should be the goal).
This allows LLVM to be included with testing enabled within projects that themselves have a dependency on an official gtest release.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D120789
New methods to the Atomic class have been added as required. Futex
related types have been consolidated at a common place.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D120705
Add LLVM_LIBC_CLANG_TIDY option and allow LLVM_LIBC_ENABLE_LINTING without full build.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D119180
Only the methods currently required by the libc have been added.
Most of the existing uses of atomic operations have been switched over
to this new class. A future change will clean up the rest of uses.
This change now allows building mutex and condition variable code with a
C++ compiler which does not have stdatomic.h, for example g++.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D120642
__builtin_clz requires just a single instruction on x86 and arm, so this is a performance improvement.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D120579
The benchmark framework synthesizes fake "aggregate" Samples representing mean, median and cv.
We're only interested in "iteration" samples.
Differential Revision: https://reviews.llvm.org/D120062
Often atexit is implemented using __cxa_atexit. I have not implemented __cxa_atexit here because it potentially requires more discussion. It is unique for llvm-libc (I think) that it is an exported symbol that wouldn’t be defined in any spec file because it doesn’t have a header. Implementing it will be trivial given what is here already, but I figured it would be more contentious so it can be implemented later.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D119512
Algorithm for hypotf: compute (a*a + b*b) in double precision, then use Dekker's algorithm to find the rounding error, and then correcting it after taking its square-root.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D118157
The prior page was the proposal doc, this one is now
more about what the project intends to do, written in the
present tense.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D119379
This implements a basic arm64 loader for Linux, and all the currently
enabled linker tests pass. TLS is not implemented, and functions
using it will have undefined behaviour. Notably, the TLS test is
currently disabled on x86_64.
Much of the structure is copied from x86_64 to allow for a refactoring
of the start code between architectures.
Tested:
ninja libc_loader_tests on aarch64-linux.
Co-authored-by: Raman Tenneti <rtenneti@google.com>
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D119641
Previously, building LLVM-libc with GWP ASAN was conditioned on the flag
COMPILER_RT_BUILD_GWP_ASAN, which caused issues do to the default value
of the flag being set in the compiler-rt cmake, which is seperate. Now
GWP ASAN is included based on if it exists as a target, which is more
consistent.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D119789
Simplify the logic when the exponent difference is at least MantissaLength + 2, while still maintaining correct rounding for all rounding modes.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D119843
Add support for getenv as defined by the Open Group's "System Interface &
Header" in https://pubs.opengroup.org/onlinepubs/7908799/xsh/getenv.html
getenv requires a standard way of accessing the environment,
so a pointer to the environment is added to the startup in crt1.
Consquently, this function is not usable on top of other libcs.
Added starts_with method to StringView. getenv function uses it.
Co-authored-by: Jeff Bailey <jeffbailey@google.com>
Reviewed By: sivachandra, rtenneti
Differential Revision: https://reviews.llvm.org/D119403
Previously, allocator functions were only available if they were included
from scudo or by using the system libc headers (i.e. by turning off the
full build). This patch changes the logic to include the prototypes for
the allocator functitons in all cases, which allows the linker to link
in the system's allocator.
Reviewed By: sivachandra, abrachet
Differential Revision: https://reviews.llvm.org/D119587
the vector class, due to being dynamically resized, needs malloc. This
fixes the build so that it only includes it when malloc should be
available.
Differential Revision: https://reviews.llvm.org/D119464
Add a basic implementation of the vector class for use internally to
LLVM-libc.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D118954
GCC complains about undefined reference in LibcTest.cpp and indeed the wrong version of the template has been explicitly instanciated.
This is necessary to get llvm-libc compile with GCC.
Mentionning D119002 here for navigability.
Differential Revision: https://reviews.llvm.org/D119242
Although type punning is defined for union in C, it is UB in C++.
This patch introduces a bit_cast function to convert between types in a safe way.
This is necessary to get llvm-libc compile with GCC.
This patch is extracted from D119002.
Differential Revision: https://reviews.llvm.org/D119145
These were all the non OS agnostic implementations I could find in general directories.
Currently none of these functions are actually enabled, but for when they do it makes sense that they be in linux/ specific directories.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D119164
This implementation relies on storing data in registers for sizes up to 128B.
Then depending on whether `dst` is less (resp. greater) than `src` we move data forward (resp. backward) by chunks of 32B.
We first make sure one of the pointers is aligned to increase performance on large move sizes.
Differential Revision: https://reviews.llvm.org/D114637
llvm-libc exhibits a C interface but its source is C++.
This patch explicitly disables the use of exceptions and RTTI when compiling the entrypoints.
Differential Revision: https://reviews.llvm.org/D118889
CMAKE_CXX_STANDARD 14 is set in the llvm-project/llvm folder overriding all COMPILE_OPTIONS -std=c++17. We need to override the CXX_STANDARD property of the target in order to set the correct C++ standard flags.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D118871
The LLVM Libc project is no longer just a proposal and should have
a webpage tracking the status of the project. This changes
puts the pieces into the right place so that the webpage can be
created.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D117436
They are implemented as simple syscall wrappers. The file creation
macros have been put in a header file as a temporary solution until we
have a cleaner approach to listing platform relevant macros.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D118396
Guard sqrt_80_bit_long_double.h header to not be included with aarch64.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D118389
The type names in the spec are just sugar used by the header generator to
generate the function prototype. Giving the VarArgType a name of "..."
allows the header generator to treat and generate the "type name" for var
arg parameters similar to how it does for any other type.
Refactor sqrt implementations:
- Move architecture specific instructions from `src/math/<arch>` to `src/__support/FPUtil/<arch>` folder.
- Move generic implementation of `sqrt` to `src/__support/FPUtil/generic` folder and add it as a header library.
- Use `src/__support/FPUtil/sqrt.h` for architecture/generic selections.
- Add unit tests for generic implementation of `sqrt`.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D118173
Make logf function correctly rounded for all rounding modes.
Reviewed By: sivachandra, zimmermann6, santoshn, jpl169
Differential Revision: https://reviews.llvm.org/D118149
Based on RLIBM implementation similar to logf and log2f. Most of the exceptional inputs are the exact powers of 10.
Reviewed By: sivachandra, zimmermann6, santoshn, jpl169
Differential Revision: https://reviews.llvm.org/D118093
in all the other `add_tablegen` calls, the project name is so transformed so it
can be a prefix of a CMake variable. I think it is better to do do that here
too for consistency.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D117979
This is an optimization that using a single CPU instruction on supported
architectures (amd64 and aarch64, but possibly others) to replace what was
previously an iterative look-up-table algorithm.
Originally I suggested using inline assembly for this in
https://reviews.llvm.org/D117584.
Reviewed By: lntue, sivachandra
Differential Revision: https://reviews.llvm.org/D117684
Add to log2f 2 more exceptional cases got when not using fma for polyeval.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D117812
The floating point tricks used to get rounding mode require -frounding-math flag, which behaves differently on aarch64. Reverting back to use get_round instead.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D117824
Update the rounding logic for generic hypot function so that it will round correctly with all rounding modes.
Reviewed By: sivachandra, zimmermann6
Differential Revision: https://reviews.llvm.org/D117590
Use hexadecimal floats with C++17 instead of as_double as floating point constant initializations.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D117628
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!
It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up
- Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.
- Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.
I figured it was time to make a new revision.
I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.
---
As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.
These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.
Reviewed By: #libunwind, #libc, #libc_abi, compnerd
Differential Revision: https://reviews.llvm.org/D99484
This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!
It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up
- Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.
- Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.
I figured it was time to make a new revision.
I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.
---
As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.
These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.
Reviewed By: #libunwind, #libc, #libc_abi, compnerd
Differential Revision: https://reviews.llvm.org/D99484
strdup needs either scudo enabled or fullbuild disabled, this properly
adds the second condition
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D117138
Add an extra argument for rounding mode to EXPECT_MPFR_MATCH and ASSERT_MPFR_MATCH macros.
Reviewed By: sivachandra, michaelrj
Differential Revision: https://reviews.llvm.org/D116777
Some functions were added to x86_64 that were untested on Aarch64. Now
that I've had an opportunity to test them, they all work on Aarch64 with
the minor formatting change included.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D117146
Specifically, mmap and munmap have been moved to the default build list
of entrypoints. To support this, certain deps and includes have been
adjusted. The use of errno in some cases has been updated.
Add mmap and munmap to the linux aarch64 entrypoint list as the first
user of these syscalls.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D116949
Other threads related tests have been using the API that is tested here
without any problems. The main reason for disabling the test has also been
fixed many months ago.
A variable was named in a way that doesn't match the format. This patch
renames it to match the format.
Differential Revision: https://reviews.llvm.org/D116228
The Eisel-Lemire algorithm is an effecient way to handle converting to
floating point numbers from strings, but in its base form it only
supports up to 64 bit floating point numbers. This adds an
implementation to handle long doubles.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D115280
I missed two instances of "SetUp" being replaced by "set_up" and
"TearDown" being replaced by "tear_down" when finalizing the formatting
change. This fixes that.
Differential Revision: https://reviews.llvm.org/D116178
Apply the formatting rules that were applied to the libc/src directory
to the libc/test directory, as well as the files in libc/utils that are
included by the tests. This does not include automated enforcement.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D116127
Run performance tests in denormal and normal ranges separately and show more detailed results.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D116112
previously, memcpy could get stuck in a loop, calling __builtin_memcpy
which would redirect to itself. This patch removes that path.
Reviewed By: gchatelet, sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D115542
The default isnan returns an int, and hence failing the EXPECT_TRUE tests.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D115892
A small collection of utils called osutils has been added. These utils
are now used in loader tests instead of the equivalent entrypoints.
The loader can now be built and tested without depending on any entrypoint.
In a follow up change, the relevent entrypoints will be updated to use the
newly added osutils.
Reviewed By: lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D115655
Due to the differences between the types of long double, this function
is effectively three functions in one. This patch adds basic support for
the types of long double, although it's just using the fast path and the
fallback for the moment. I still need to implement a version of
Eisel-Lemire for performance, but the existing algorithms should be
correct.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D113710
Add ADD_FMA_FLAG macro to add -mfma flag to functions that requires it.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D115572
- Use intrinsics for x86-64 fma
- Optimize PolyEval for x86-64 with degree 3 & 5 polynomials.
- There might be a slight loss of accuracy compared to Horner's scheme due to usages of higher powers x^2 and x^3 in the computations.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D115347
Generation of the .yaml has been removed to prevent lint from
running with every ninja invocation. The new .clang-tidy file is copied
to the libc build directory so that generated files also get checked.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D115405
adds the .yaml files clang-tidy generates as byproducts, which means
that they will be updated properly and cleaned by `ninja -t clean`
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D115290
This patch applies the lint rules described in the previous patch. There
was also a significant amount of effort put into manually fixing things,
since all of the templated functions, or structs defined in /spec, were
not updated and had to be handled manually.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D114302
This commit changes the clang-tidy rules for LLVM-libc to follow the new
format. The next commit applies these rules to the codebase.
The rules are as follows:
CamelCase for classes
lower_case for variables
lower_case for functions
UPPER_CASE for constexpr variables
There are also some exceptions, but the most important one is that any
function or variable that starts with an underscore is exempt from the
formatting.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D114301
We want to simplify the build system and rely on code to do the implementation selection.
This is in preparation of adding a Bazel configuration (D114712).
Differential Revision: https://reviews.llvm.org/D115034
Fix a bug in MPFRUtils making ULP values off by 2^(-mantissaWidth) and incorrect eps for denormal numbers.
Differential Revision: https://reviews.llvm.org/D114878
Up until now, all references to `errno` were marked with `NOLINT`, since
it was technically calling an external function. This fixes the lint
rules so that `errno`, as well as `malloc`, `calloc`, `realloc`, and
`free` are all allowed to be called as external functions. All of the
relevant `NOLINT` comments have been removed, and the documentation has
been updated.
Reviewed By: sivachandra, lntue, aaron.ballman
Differential Revision: https://reviews.llvm.org/D113946
This patch enables the benchmarking of `memmove`.
Ideally, this should be submitted before D114637.
Differential Revision: https://reviews.llvm.org/D114694
Fix the fact that previously strtof/d/ld would only accept a NaN as
having parentheses if the thing in the parentheses was a valid number,
now it will accept any combination of letters and numbers, but will only
put valid numbers in the mantissa.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D113790
This reverts commit 39e9f5d368.
Reverting, as we needed to re-revert the benchmarks move because it was
causing a build failure in the Fuchsia bots due to the way they consume
libcxx's CMakeLists. I want to make sure I understand where the fix
should be for that. After that, I'll incorporate the change here in the
re-reland.
Update binaryExpTofloat so that it will round correctly for long inputs when converting hexadecimal strings to floating points.
Differential Revision: https://reviews.llvm.org/D113815
This reverts commit e7568b68da and relands
c6f7b720ec.
The culprit was: missed that libc also had a dependency on one of the
copies of `google-benchmark`
Also opportunistically fixed indentation from prev. change.
Differential Revision: https://reviews.llvm.org/D112012
Combine two loops in decimalStringToFloat and hexadecimalStringToFloat that extract the digits and re-arrange them a little bit. This slightly improves the performance of strtof and strtod:
Running libc_str_to_float_comparison_test parse-number-fxx-test_data/data/* on my machine (Ryzen 1700)
- with glibc: ~1.92 seconds
- with current implementation: ~1.78 seconds
- with this change: ~1.67 seconds
Differential Revision: https://reviews.llvm.org/D113681
When strtof/d/ld return a subnormal number they may set errno to
ERANGE. This change makes this behavior more consistent by making any
decimal number converting to a subnormal set errno to ERANGE. This
brings it in line with hexadecimals, which currently only set errno to
ERANGE if the number is truncated when converting to a subnormal.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D113626
Add quietNaNMask consts to FloatProperties and make LongDoubleBitsX86
clear the extra bits that aren't set when initializing with an 80 bit
long double.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D113625
Split the code for parsing hexadecimal floating point numbers from the
code for parsing the decimal floating point numbers so that the parsing
can be faster for both of them.
This decreases the time for the benchmark in release mode by about 15%,
which noticeably beats GLibc.
Old version: 2.299s
New version: 1.893s
GLibc: 2.133s
Tests run by running the following command 10 times for each version:
time ~/llvm-project/build/bin/libc_str_to_float_comparison_test ~/parse-number-fxx-test-data/data/*
the parse-number-fxx-test-data-repository is here:
fe94de252c
It's important to build llvm-libc in Release mode for accurate
performance comparisons against glibc (set -DCMAKE_BUILD_TYPE=Release in
your cmake).
You also have to build the libc_str_to_float_comparison_test target.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D113036
Adds an implementation for stpcpy and stpncpy, which are posix extension
functions.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D111913
This allows shipping individual functions without also having to provide
memset or bzero at the expense of bigger functions.
Similar to D113097.
Differential Revision: https://reviews.llvm.org/D113108
Similar to D113097 although not strictly necessary for now. It helps
keeping the same structure for all memory functions.
Differential Revision: https://reviews.llvm.org/D113103