Commit Graph

304 Commits

Author SHA1 Message Date
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
Siva Chandra Reddy
b266c818e7 [libc][Obvious] Mark functions in DummyFEnv.h as static inline. 2020-12-14 17:12:54 -08:00
Siva Chandra Reddy
9ad2091e78 [libc][Obvious] Include <fenv.h> from DummyFenv.h. 2020-12-14 08:51:54 -08:00
Siva Chandra Reddy
9ab6c1a99f [libc] Let wrappergen pick LLVM libc mangled name from aliasee file.
Along the way, made a change to run tool unittests when the target
"check-libc" is run by introducing a libc testsuite for tool unittests.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D93142
2020-12-11 14:33:03 -08:00
Siva Chandra Reddy
7aeb3804c4 [libc] Add implementations of lround[f|l] and llround[f|l].
A new function to MPFRWrapper has been added, which is used to set up
the unit tests.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D93007
2020-12-11 11:12:40 -08:00
Cheng Wang
1fd32dcb29 [libc] Add [l|ll]abs implementation.
Implement abs, labs and llabs with template.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D92626
2020-12-11 09:25:20 +08:00
Siva Chandra Reddy
ab3cbe4bc0 [libc] Raise x87 exceptions by synchronizing with "fwait".
Couple of helper functions enableExcept and disableExcept have been
added. In a later round, they will be used to implemented the GNU
extension functions feenableexcept and fedisableexcept.

Differential Revision: https://reviews.llvm.org/D92821
2020-12-08 13:16:19 -08:00
Michael Jones
e60f2cbd0c [libc] add tests to WrapperGen
This adds an initial test that can serve as a basis for other tests on
wrappergen.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D92137
2020-12-04 18:14:17 +00:00
Siva Chandra Reddy
3a375125b0 [libc][NFC] Remove dependence on xmmintrin.h to read/write MXCSR.
The version of clang on the bots is unhappy with using xmmintrin.h.
So, this change removes dependence on xmmintrin by using inline
assembly.
2020-12-03 13:49:17 -08:00
Siva Chandra Reddy
4fff2a7e89 [libc] Add simple x86_64 floating point exception and rounding mode support.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D92546
2020-12-03 12:55:12 -08:00
Tue Ly
3b487d51e2 [libc] Add implementation of hypot.
Refactor src/math/hypotf.cpp and test/src/math/hypotf_test.cpp and reuse them for hypot and hypot_test

Differential Revision: https://reviews.llvm.org/D91831
2020-12-03 11:08:20 -05:00
Siva Chandra Reddy
19c3894f94 [libc] Fix couple of corner cases in remquo.
These two cases are fixed:
1. If numerator is not zero and denominator is infinity, then the
numerator is returned as the remainder.
2. If numerator and denominator are equal in magnitude, then quotient
with the right sign is returned.

The differet tests of remquo, remquof and remquol have been unified
into a single file to avoid duplication.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D92353
2020-12-02 11:48:49 -08:00
Cheng Wang
60cef89362 [libc] Add strncpy implementation.
Add libc strncpy implementation.

Reviewed By: sivachandra, gchatelet

Differential Revision: https://reviews.llvm.org/D91399
2020-12-02 20:45:51 +08:00
Raman Tenneti
6f0f844e9a Initial commit of mktime.
This introduces mktime to LLVM libc, based on C99/C2X/Single Unix Spec.

Co-authored-by: Jeff Bailey <jeffbailey@google.com>

This change doesn't handle TIMEZONE,  tm_isdst and leap seconds.  It returns -1 for invalid dates. I have verified the return results for all the possible dates with glibc's mktime.

TODO:
+ Handle leap seconds.
+ Handle out of range time and date values that don't overflow or underflow.
+ Implement the following suggestion Siva - As we start accumulating the seconds, we should be able to check if the next amount of seconds to be added can lead to an overflow. If it does, return the overflow value.  If not keep accumulating. The benefit is that, we don't have to validate every input, and also do not need the special cases for sizeof(time_t) == 4.
+ Handle timezone and update of tm_isdst

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D91551
2020-11-30 21:07:16 -08:00
Guillaume Chatelet
699d17d4d6 [libc] Improve memcpy copy loop
Rewriting loop so the terminating condition does not depend on the loop body

Differential Revision: https://reviews.llvm.org/D91976
2020-11-30 08:24:10 +00:00
Cheng Wang
a8beb4ada4 [libc] Fix typo in buildbot README.txt.
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D90381
2020-11-27 19:01:21 +08:00
Cheng Wang
a513be4900 [libc][Obvious] Fix typo in strnlen_test.cpp. 2020-11-27 15:56:19 +08:00
Guillaume Chatelet
d899f9970e Fix case mismatch between definition and declaration 2020-11-25 14:23:31 +00:00
Michael Jones
8a4ee3550b [libc] Make more of the libc unit testing llvm independent
(WIP, hopefully I'll add more to this patch before submitting)

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D91665
2020-11-21 00:27:08 +00:00
Michael Jones
3e18fb3390 [libc] Switch functions to using global headers
This switches all of the files in src/string, src/math, and
test/src/math from using relative paths (e.g. `#include “include/string.h”`)
to global paths (e.g. `#include <string.h>`) to make bringing up those
functions on other platforms, such as fuchsia, easier.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D91394
2020-11-21 00:07:17 +00:00
Siva Chandra Reddy
4766a86cf2 [libc] Combine all math differential fuzzers into one target.
Also added diffing of a few more math functions. Combining the diff check
for all of these functions helps us meet the OSS fuzz bar of a minimum of
100 program edges.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D91817
2020-11-20 07:46:15 -08:00
Siva Chandra Reddy
892ed1f150 [libc] Add differential fuzzers for ldexp and remquo.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D91763
2020-11-19 08:32:05 -08:00
Siva Chandra Reddy
4d8dede5e5 [libc] Fix the overflow check condition of ldexp.
Targeted tests have been added.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D91752
2020-11-18 21:35:48 -08:00
Siva Chandra Reddy
d1b921e3bf [libc][NFC][Obvious] Remove few unnecessary pieces from ilogb tests. 2020-11-18 11:26:05 -08:00
Siva Chandra Reddy
ad0e764ead [libc][obvious] Fix fdim[f|l] signatures in stdc spec. 2020-11-18 07:39:11 -08:00
Siva Chandra Reddy
bb8f2585c6 [libc] Add implementations of ldexp[f|l].
The rounding behavior of NormalFloat to float format has been changed
to round to nearest. Also, a bug in NormalFloat to subnormal number
conversion has been fixed.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D91591
2020-11-17 15:05:42 -08:00