Commit Graph

329 Commits

Author SHA1 Message Date
Michael Jones
d4eea5cf0f [libc][NFC] Add a few casts to suppress loss of precision warnings
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D95646
2021-01-29 01:16:03 +00:00
Petr Hosek
1daaa6432e [CMake][libc] Support cross-compiling libc-hdrgen
This is useful when cross-compiling libc to another target in which
case we first need to compile libc-hdrgen for host. We rely on the
existing LLVM CMake infrastructure for that.

Differential Revision: https://reviews.llvm.org/D95205
2021-01-28 13:13:06 -08:00
Petr Hosek
c4819eec1a [CMake][libc] Don't do CPU feature detection when cross-compiling
We won't be able to run the compiled program since it will be compiled
for different system. We instead allow passing the CPU features via
CMake option in that case.

Differential Revision: https://reviews.llvm.org/D95203
2021-01-28 12:54:37 -08:00
Siva Chandra
ec5a782c10 [libc] Fix list of public headers usable on aarch64. 2021-01-27 12:43:18 -08:00
Siva Chandra
e958d49157 [libc] Fix the CMake var name of the list of public headers. 2021-01-27 12:13:35 -08:00
Siva Chandra
d90bb66dd9 [libc] Include only the relevant header files in the integration test. 2021-01-27 11:15:12 -08:00
Siva Chandra
74c87a363f [libc] Disable sqrtl_test on non-x86 platforms.
The added comment explains why it has been disabled for now. We will
enable back when we fix the problem.
2021-01-27 10:30:54 -08:00
Siva Chandra Reddy
7cd420649f [libc][NFC] Use a end of list marker for cpu feature detection.
Without this, the array can end up being an empty array leading to
compiler failures.
2021-01-27 01:24:15 -08:00
Petr Hosek
b014335263 [libc] Distinguish compiler and run failures
This is useful for debugging issues, for example when cross-compiling.

Differential Revision: https://reviews.llvm.org/D95118
2021-01-21 15:27:34 -08:00
Michael Jones
689de5841c [libc][NFC][obvious] fix the names of MPFR tests
I missed the MPFR tests in my previous commit. They have now been fixed
to not fail the prefix check in the test macro.
2021-01-20 23:42:01 +00:00
Michael Jones
1df0dbfcb5 [libc][NFC] add "LlvmLibc" as a prefix to all test names
Summary:
Having a consistent prefix makes selecting all of the llvm libc tests
easier on any platform that is also using the gtest framework.
This also modifies the TEST and TEST_F macros to enforce this change
moving forward.

Reviewers: sivachandra

Subscribers:
2021-01-20 23:15:36 +00:00
Siva Chandra
7bd3702b64 [libc] Extend the current fenv functions to aarch64.
This change does not try to move the common parts of x86 and aarch64 and
build few abstractions over them. While this is possible, x86 story
needs a bit of cleanup, especially around manipulation of the mxcsr
register. Moreover, on x86 one can raise exceptions without performing
exception raising operations. So, all of this can be done in follow up
patches.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D94947
2021-01-19 12:47:54 -08:00
Guillaume Chatelet
e517dff50a [libc][NFC] remove dependency on non standard ssize_t
`ssize_t` is from POSIX and is not standard unfortunately.
Rewritting the code so it doesn't depend on it.

Differential Revision: https://reviews.llvm.org/D94760
2021-01-19 08:12:38 +00:00
Guillaume Chatelet
d4bb3ef532 [libc][NFC] Remove dead code 2021-01-19 08:11:45 +00:00
Siva Chandra
ffb254978c [libc][NFC][Obvious] Add a missing dep. 2021-01-18 22:04:20 -08:00
Siva Chandra Reddy
bfbbb62b22 [libc][NFC] Use ASSERT_EQ instead of EXPECT_EQ in fenv/exception_status_test 2021-01-18 21:38:11 -08:00
Guillaume Chatelet
5bf47e142b [libc] CopyAlignedBlocks can now specify alignment on top of block size
This has been requested in D92236

Differential Revision: https://reviews.llvm.org/D94770
2021-01-15 15:32:02 +00:00
Guillaume Chatelet
a10300a2b2 [libc] Allow customization of memcpy via flags.
- Adds LLVM_LIBC_IS_DEFINED macro to libc/src/__support/common.h
 - Adds a few knobs to memcpy to help with experimentations:
   - LLVM_LIBC_MEMCPY_X86_USE_ONLY_REPMOVSB replaces the implementation with a single call to rep;movsb
   - LLVM_LIBC_MEMCPY_X86_USE_REPMOVSB_FROM_SIZE customizes where the usage of rep;movsb

Differential Revision: https://reviews.llvm.org/D94692
2021-01-15 09:26:45 +00:00
Cheng Wang
2423ec5837 [libc] Add memmove implementation.
Use `memcpy` rather than copying bytes one by one, for there might be large
size structs to move.

Reviewed By: gchatelet, sivachandra

Differential Revision: https://reviews.llvm.org/D93195
2021-01-15 12:08:25 +08:00
Roland McGrath
e7228062b2 [libc] Use #undef isascii in specific header
Standard C allows all standard headers to declare macros for all
their functions.  So after possibly including any standard header
like <ctype.h>, it's perfectly normal for any and all of the
functions it declares to be defined as macros.  Standard C requires
explicit `#undef` before using that identifier in a way that is not
compatible with function-like macro definitions.

The C standard's rules for this are extended to POSIX as well for
the interfaces it defines, and it's the expected norm for
nonstandard extensions declared by standard C library headers too.

So far the only place this has come up for llvm-libc's code is with
the isascii function in Fuchsia's libc.  But other cases can arise
for any standard (or common extension) function names that source
code in llvm-libc is using in nonstandard ways, i.e. as C++
identifiers.

The only correct and robust way to handle the possible inclusion of
standard C library headers when building llvm-libc source code is to
use `#undef` explicitly for each identifier before using it.  The
easy and obvious place to do that is in the per-function header.
This requires that all code, such as test code, that might include
any standard C library headers, e.g. via utils/UnitTest/Test.h, make
sure to include those *first* before the per-function header.

This change does that for isascii and its test.  But it should be
done uniformly for all the code and documented as a consistent
convention so new implementation files are sure to get this right.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D94642
2021-01-14 13:25:05 -08:00
Michael Jones
ea8034ec35 [libc][NFC] change isblank and iscntrl from implicit casting
isblank and iscntrl were casting an int to a char implicitly and this
was throwing errors under Fuchsia. I've added a static cast to resolve
this issue.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D94634
2021-01-13 22:06:56 +00:00
Michael Jones
4cfccd5133 [libc][NFC] add macro for fuchsia to switch test backend to zxtest
This moves utils/UnitTest/Test.[h/cpp] to LibcTest.[h/cpp] and adds a
new Test.h that acts as a switcher so that Fuchsia can use the zxtest
backend for running our tests as part of their build.

FuchsiaTest.h is for including fuchsia's zxtest library and anything
else needed to make the tests work under fuchsia (currently just
undefining the isascii macro for the test).

Downstream users, please fix your build instead of reverting.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D94625
2021-01-13 21:28:02 +00:00
Guillaume Chatelet
ab57780716 [libc] Refresh benchmark progress bar when needed. 2021-01-13 14:06:51 +00:00
Siva Chandra Reddy
0c8466c001 [libc][NFC] Use more specific comparison macros in LdExpTest.h. 2021-01-12 16:13:10 -08:00
Michael Jones
04edcc0263 [libc] add isascii and toascii implementations
adding both at once since these are trivial functions.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D94558
2021-01-12 23:41:20 +00:00
Siva Chandra Reddy
aefeb5f136 [libc][NFC] Make __support/common.h an in tree header.
It was previously a generated header. It can easily converted to a
generated header if required in future.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D94445
2021-01-11 13:10:56 -08:00
Michael Jones
b02ca0969e [libc][NFC] add includes for internal headers to all libc functions
this will make sure that all of the functions are using the correct
prototypes. Explained much better in the comments of this diff:
https://reviews.llvm.org/D94195
2021-01-09 00:39:18 +00:00
Michael Jones
a0b65a7bcd [libc] Switch to use a macro which does not insert a section for every libc function.
Summary:
The new macro also inserts the C alias for the C++ implementations
without needing an objcopy based post processing step. The CMake
rules have been updated to reflect this. More CMake cleanup can be
taken up in future rounds and appropriate TODOs have been added for them.

Reviewers: mcgrathr, sivachandra

Subscribers:
2021-01-08 23:52:35 +00:00
Siva Chandra Reddy
f9e858f5fd [libc] Use a wrapper for rand instead of calling std::rand in fma tests.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D94198
2021-01-06 15:07:44 -08:00
Tue Ly
4726bec8f2 [libc] Add implementation of fmaf.
Differential Revision: https://reviews.llvm.org/D94018
2021-01-06 17:14:20 -05:00
Guillaume Chatelet
aa9db51ef6 [libc] Align src buffer instead of dst buffer
We used to align destination buffer instead of source buffer for the loop of block copy.
This is a mistake.

Differential Revision: https://reviews.llvm.org/D93457
2021-01-06 12:04:53 +00:00
Guillaume Chatelet
223a6f94c5 [libc] remove modulo from CircularArrayRef iterator 2021-01-06 12:03:52 +00:00
Siva Chandra Reddy
7f7b0dc4e1 [libc] Add implementations of nextafter[f|l] functions.
A differential fuzzer for these functions has also been added.
Along the way, a small correction has been done to the normal/subnormal
limits of x86 long double values.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D94109
2021-01-05 22:32:39 -08:00
Siva Chandra Reddy
993d8ac5cb [libc] Add implementations of nearbyint[f|l].
The implementation is exactly the same as rint* as even rint does not
raise any floating point exceptions currently. [Note that the standards
do not specify that floating point exceptions must be raised - they
leave it up to the implementation to choose to raise FE_INEXACT when
rounding non-integral values.]

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D94112
2021-01-05 21:51:10 -08:00
Siva Chandra Reddy
cc07d52511 [libc][NFC] Use ASSERT_FP_EQ to compare nan values in tests.
This change "fixes" one of the uses that was missed in
0524da67b4.
2020-12-30 13:06:40 -08:00
Siva Chandra Reddy
ff6fd38552 [libc] Add implementations of rounding functions which depend rounding mode.
Namely, implementations for rint, rintf, rintl, lrint, lrintf, lrintl,
llrint, llrintf and llrintl have been added.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D93889
2020-12-29 22:22:02 -08:00
Siva Chandra Reddy
2d9ae1d217 [libc][NFC] Use #include <math.h> in utils/FPUtil/ManipulationFunctions.h.
This reverts commit 352cba2441.
"add back math.h #include utils/FPUtil/ManipulationFunctions.h".

Using `<math.h>` correct so downstream setup should be fixed.
2020-12-18 00:05:02 -08:00
Siva Chandra Reddy
d599ed49b3 [libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests.
This is a continuation of the previous CL which did a similar change in
other tests. To elaborate a little about why we need this - under C++
compilation with headers not from LLVM libc, libraries like libc++ and
libstdc++ provide their own math.h which undefine macros like `isnan`
and provide the overloaded C++ isnan functions which return a boolean
value instead of an integer value returned by the isnan macro.
2020-12-17 23:16:26 -08:00
Siva Chandra Reddy
e1a5b234ef [libc][Obvious] Fix typo is wrappergen unittest. 2020-12-17 09:13:23 -08:00
Paula Toth
17b3ff511c [libc] Add python3 to libc buildbot depedencies.
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D93463
2020-12-17 08:59:13 -08:00
Siva Chandra Reddy
bf03eba1f9 [libc] Refactor WrapperGen to make the flow cleaner.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D93417
2020-12-17 08:56:45 -08:00
Guillaume Chatelet
cfe096d1f6
Fix dead link 2020-12-17 15:49:28 +01:00
Guillaume Chatelet
deae7e982a [libc] revamp memory function benchmark
The benchmarking infrastructure can now run in two modes:
 - Sweep Mode: which generates a ramp of size values (same as before),
 - Distribution Mode: allows the user to select a distribution for the size paramater that is representative from production.

The analysis tool has also been updated to handle both modes.

Differential Revision: https://reviews.llvm.org/D93210
2020-12-17 13:23:33 +00:00
Krasimir Georgiev
352cba2441 [libc] add back math.h #include utils/FPUtil/ManipulationFunctions.h
This partially reverts cee1e7d14f:
  [libc][NFC][Obvious] Remove few unnecessary #include directives in tests.

That commit causes a test failure in our configuration:
[ RUN      ] ILogbTest.SpecialNumbers_ilogb
third_party/llvm/llvm-project/libc/test/src/math/ILogbTest.h:28: FAILURE
      Expected: FP_ILOGBNAN
      Which is: 2147483647
To be equal to: func(__llvm_libc::fputil::FPBits<T>::buildNaN(1))
      Which is: -2147483648
2020-12-17 11:16:08 +01:00
Siva Chandra Reddy
0524da67b4 [libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests. 2020-12-15 23:48:54 -08:00
Siva Chandra Reddy
f66cf13d5d [libc][NFC] Rename global nan in tests to aNaN.
The name `nan` conflicts with the function `nan` defined declared in
math.h.
2020-12-15 22:37:02 -08:00
Siva Chandra Reddy
cee1e7d14f [libc][NFC][Obvious] Remove few unnecessary #include directives in tests. 2020-12-15 21:41:44 -08:00
Siva Chandra
f0cd6aa614 [libc] Add remainder[f|l] and remquo[f|l] to the list of aarch64 entrypoints. 2020-12-14 18:06:05 -08:00
Siva Chandra
b1067a9b3c [libc][NFC] Skip adding dummy targets for skipped unit tests. 2020-12-14 17:52:47 -08:00
Cheng Wang
af68c3b892 [libc] Add memcmp implementation.
Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D93009
2020-12-15 09:47:29 +08:00