Commit Graph

633 Commits

Author SHA1 Message Date
Yannic Bonenberger a01523ea99 [libc] improve error message for unsupported target platforms
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D116888
2022-01-19 10:39:34 -08:00
Siva Chandra Reddy d7c8d51f94 [libc][Obvious] Add -Wno-c++17-extensions to sinf, cosf and sincosf targets. 2022-01-19 06:22:17 +00:00
Tue Ly b0cd3abf03 [libc] Remove as_double usage as constant initializations in sincosf implementation.
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
2022-01-18 23:48:48 -05:00
John Ericson da77db58d7 Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."
https://lab.llvm.org/buildbot/#/builders/46/builds/21146 Still have
this odd error, not sure how to reproduce, so I will just try breaking
up my patch.

This reverts commit 4a678f8072.
2022-01-16 05:48:30 +00:00
John Ericson 4a678f8072 [cmake] Use `GNUInstallDirs` to support custom installation dirs.
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
2022-01-16 05:33:07 +00:00
John Ericson 6e52bfe09d Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."
Sorry for the disruption, I will try again later.

This reverts commit efeb501970.
2022-01-15 07:35:02 +00:00
John Ericson efeb501970 [cmake] Use `GNUInstallDirs` to support custom installation dirs.
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
2022-01-15 01:08:35 +00:00
Michael Jones 0b442db9f6 [libc] move strdup out of requiring SCUDO
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
2022-01-14 13:32:42 -08:00
Tue Ly 63d2df003e [libc] Implement correctly rounded log2f based on RLIBM library.
Implement log2f based on RLIBM library correctly rounded for all rounding modes.

Reviewed By: sivachandra, michaelrj, santoshn, jpl169, zimmermann6

Differential Revision: https://reviews.llvm.org/D115828
2022-01-14 12:40:49 -05:00
Tue Ly e11e973e68 [libc] Update exhaustive testing documentations. 2022-01-14 11:10:05 -05:00
Tue Ly c386d6eb2d [libc] Fix precision constants for long double in MPFRUtils.cpp. 2022-01-13 21:33:05 -05:00
Tue Ly 355e56f5b2 [libc][trivial] Make LlvmLibcExhaustiveTest::check method purely virtual. 2022-01-13 14:35:11 -05:00
Tue Ly 8cd81274ff [libc] Add multithreading support for exhaustive testing and MPFRUtils.
Add threading support for exhaustive testing and MPFRUtils.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D117028
2022-01-13 13:46:14 -05:00
Tue Ly cce6507767 [libc] Add rounding mode support for MPFR testing macros.
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
2022-01-13 13:28:50 -05:00
Michael Jones 04e8c8f997 [libc] fix strtold_test formatting on ARM
I missed a variable when reformatting the tests. This fixes that.

Differential Revision: https://reviews.llvm.org/D117161
2022-01-12 14:34:57 -08:00
Michael Jones ba6a3972d7 [libc] add working ARM entrypoints
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
2022-01-12 14:24:18 -08:00
Siva Chandra Reddy 134e9d1914 [libc][NFC] Move sys/mman entrypoints to the default build configs.
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.
2022-01-11 16:51:10 +00:00
Siva Chandra 371779fac1 [libc] Add linux aarch64 syscall implementation.
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
2022-01-10 15:53:17 -08:00
Siva Chandra Reddy cd4deef28e [libc] Re-enable thrd_test.
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.
2022-01-10 06:18:51 +00:00
Siva Chandra Reddy 60509623c4 [libc][obvious] Fix style of MPFRWrapper. 2021-12-23 23:19:42 +00:00
Michael Jones 3e52096809 [libc][NFC] fix variable name
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
2021-12-23 10:42:30 -08:00
Tue Ly 12779edd71 [libc] Add performance tests for hypotf and hypot.
Add performance tests for hypotf and hypot.

Reviewed By: sivachandra, michaelrj

Differential Revision: https://reviews.llvm.org/D116122
2021-12-23 00:44:43 -05:00
Michael Jones 9b39737129 [libc] add modified Eisel-Lemire for long doubles
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
2021-12-22 16:45:22 -08:00
Siva Chandra Reddy e8a0af8013 [libc][Obvious] Add target OSUtil tests only if the target OS/arch match. 2021-12-22 22:38:03 +00:00
Siva Chandra Reddy 3cc2161c89 [libc] Move the x86_64 syscall functions to OSUtil.
Reviewed By: michaelrj, lntue

Differential Revision: https://reviews.llvm.org/D116177
2021-12-22 21:48:57 +00:00
Michael Jones 79abf89303 [libc][obvious] fix formatting mistake
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
2021-12-22 11:40:08 -08:00
Michael Jones 25226f3e4a [libc] apply formatting to tests
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
2021-12-22 10:53:25 -08:00
Tue Ly db8716a2ec [libc] Show average runtime for math single-input-single-output performance tests.
Run performance tests in denormal and normal ranges separately and show more detailed results.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D116112
2021-12-21 14:22:20 -05:00
Tue Ly 9369aa1444 [libc][Obvious] Change func_ to <func>_ in add_math_function.md. 2021-12-17 13:32:51 -05:00
Michael Jones 467b5017e2 [libc] fix memcpy builtin looping
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
2021-12-16 13:54:35 -08:00
Tue Ly 4036b12d96 [libc] Fix problem with using isnan in test/src/math/logf_test.cpp.
The default isnan returns an int, and hence failing the EXPECT_TRUE tests.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D115892
2021-12-16 14:51:10 -05:00
Tue Ly d08a801b5f [libc] Implement correctly rounded logf based on RLIBM library.
Implement correctly rounded logf based on RLIBM library: https://people.cs.rutgers.edu/~sn349/rlibm/.

Reviewed By: sivachandra, santoshn, jpl169, zimmermann6

Differential Revision: https://reviews.llvm.org/D115408
2021-12-16 13:43:15 -05:00
Tue Ly a2b3e6bed8 [libc] Add documentation about how to add a math function to LLVM-libc.
Add documentation about how to add a math function to LLVM-libc.

Differential Revision: https://reviews.llvm.org/D115608
2021-12-16 12:12:21 -05:00
Siva Chandra Reddy 2cf203d9f6 [libc] Disable signal.h API and its users.
The signal.h header file from LLVM libc is incorrect. The signal API and
its users will be enabled once signal.h is fixed.
2021-12-16 05:52:28 +00:00
Siva Chandra Reddy 261c17c1d3 [libc][NFC] Remove dependecies on entrypoints from loader tests.
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
2021-12-13 19:29:29 +00:00
Michael Jones aa1902f917 [libc] add basic strtold implementation
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
2021-12-13 10:40:44 -08:00
Siva Chandra Reddy d37d0aadbf [libc][NFC] Add back NOLINT anntotations to PolyEval.
They were accidentally removed in a previous change.
2021-12-13 07:08:08 +00:00
Tue Ly 08aa40b9e6 [libc] Add ADD_FMA_FLAG macro to add -mfma flag to functions that requires it.
Add ADD_FMA_FLAG macro to add -mfma flag to functions that requires it.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D115572
2021-12-11 16:21:33 -05:00
Siva Chandra Reddy e5d104b280 [libc][NFC] Add NOLINT annotations at call sites to immintrin functions.
These annotations are intended to be temporary while we understand why
clang-tidy is not able to treat them as builtin exceptions.
2021-12-10 06:38:45 +00:00
Tue Ly cdf6a581b9 [libc] Use intrinsics for x86-64 fma and optimize PolyEval for x86-64 with degree 3 & 5 polynomials.
- 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
2021-12-09 18:34:18 -05:00
Siva Chandra Reddy a5a79f69d6 [libc] Add a .clang-tidy file for the toplevel libc directory.
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
2021-12-09 00:19:25 +00:00
Siva Chandra Reddy 45927444e7 [libc][Obvious] Fix variable naming in the generic sqrt implementations. 2021-12-08 19:57:46 +00:00
Haojian Wu 5bb0a9075c [libc] Fix two missing cases in 1c92911e9e
Fix the broken build.
2021-12-08 15:14:21 +01:00
Mircea Trofin 5dda2efde5 Re-Reland "[benchmarks] Move libcxx's fork of google/benchmark and llvm/utils'"
This reverts commit b2fbd45d23. D114922
fixed the reason of the 2nd revert.

This patch also re-applies 39e9f5d368.

Differential Revision: https://reviews.llvm.org/D112012
2021-12-07 17:10:41 -08:00
Michael Jones 5b3a51fda1 [libc][obvious] fix missed rename
In https://reviews.llvm.org/D114302 I renamed ForLoopCopy to
for_loop_copy, but these got missed.

Differential Revision: https://reviews.llvm.org/D115303
2021-12-07 16:09:37 -08:00
Michael Jones 2b197888e0 [libc] fix the .yaml files not being tracked
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
2021-12-07 16:04:46 -08:00
Michael Jones 1c92911e9e [libc] apply new lint rules
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
2021-12-07 10:49:47 -08:00
Michael Jones 43e2f7cd24 [libc] update tidy rules to fix variable formatting
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
2021-12-07 10:49:45 -08:00
Guillaume Chatelet b902b314ff [libc] Fix invalid include for SqrtLongDouble.h 2021-12-03 16:13:59 +00:00
Guillaume Chatelet 71405d90f0 [libc] Select FPUtils implementations via code instead of build
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
2021-12-03 15:48:41 +00:00