Commit Graph

282 Commits

Author SHA1 Message Date
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
Michael Jones a200d6cdf0 [libc] make part of libc's unit test framework independent of llvm
This is mostly changing stringref to std::string, outs() to cout,
and small supporting changes. This will make running unit tests possible
on systems that are only grabbing the libc part of llvm.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D91568
2020-11-17 18:43:15 +00:00
Tue Ly d41280467d [libc] Add implementations of fdim[f|l].
Implementing fdim, fdimf, and fdiml for llvm-libc.

Differential Revision: https://reviews.llvm.org/D90906
2020-11-10 18:48:11 -05:00
Siva Chandra Reddy d50149b42e [libc] Extend WrapperGen to emit aliases.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D90985
2020-11-06 16:12:10 -08:00
Siva Chandra Reddy 573ade4bef [libc][WrapperGen] Replace the C _Noreturn annotation with C++ [[noreturn]].
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D90900
2020-11-06 11:37:48 -08:00
Siva Chandra Reddy 930cf1cb9f [libc] Add implementations of ilogb[f|l].
Depends on D90805.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D90806
2020-11-05 16:27:44 -08:00
Siva Chandra Reddy 0e3532da98 [libc][NFC] Make test macros callable from helper methods of test classes.
This is acheived by making the RunContext a state variable of the test
classes.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D90805
2020-11-05 16:14:24 -08:00
Michael Jones 5c801de13c [libc] Fix WrapperGen seeing no arguments as a void argument.
This corrects WrapperGen generating incorrect wrappers for functions
that take no arguments. Previously it would generate a wrapper with a
single argument of type `void`.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D90800
2020-11-05 19:13:37 +00:00
Siva Chandra Reddy 50c2f2b6f0 [libc][NFC][Obvious] Use the new macro to declare special constants in tests. 2020-11-03 15:44:06 -08:00
Michael Jones 5080840d28 [LIBC][NFC] Rename errno and assert files to match other files with functions
Rename the files containing the `__errno_location` function
to `__errno_location.h/cpp` to match the other files and move
the `llvmlibc_errno` macro to its own file.

Split assert.h into `__assert_fail.h` (contains the function prototype)
and assert.h (contains the assert macro).

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D90653
2020-11-03 21:29:32 +00:00
Siva Chandra Reddy e4be4bcf83 [libc][NFC] Use a convenience macro to declare special floating point constants.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D90262
2020-10-27 16:55:16 -07:00
Michael Jones ba24ba7e9c [libc] Add LLVM libc specific functions to llvm_libc_ext.td.
Also moved most of the common type definitions from libc/spec/stdc.td
to libc/spec/spec.td so that they can be used to list functions in llvm_libc_ext.td.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D89436
2020-10-19 18:21:25 +00:00
Michael Jones f6bf2823c4 [libc] Use entrypoints.txt as the single source of list of functions for a platform.
The function listings in api.td are removed. The same lists are now deduced using the information
in entrypoints.txt.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D89267
2020-10-15 20:46:13 +00:00
Guillaume Chatelet c400e01c62 [libc][NFC] Add probability distributions for memory function sizes
This patch adds memory function size distributions sampled from different applications running in production.
This will be used to benchmark and compare memory functions implementations.

Differential Revision: https://reviews.llvm.org/D89401
2020-10-15 08:15:58 +00:00
Guillaume Chatelet cba533febc Fix conjuntion of -Werror,-Wsuggest-override with google/benchmark 2020-10-14 15:26:55 +00:00
Paula Toth f60686f35c [libc] Update buildbot worker version to 2.8.4.
Tested locally by connecting to LLVM master. (:
http://lab.llvm.org:8011/#/builders/78/builds/1

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D89069
2020-10-08 13:43:53 -07:00
Anthony Steinhauser ef36e8380a [libc] Using llvm_libc memcpy in mem* benchmarks.
Currently the mem* benchmarks use memcpy from Glibc and memset from LLVM libc.
That's misleading and produces inconsistent results and behaviors.

This change makes Memcpy.cpp consistent with Memset.cpp:
https://github.com/llvm/llvm-project/blob/master/libc/benchmarks/Memset.cpp#L49

Reviewers: sivachandra

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D88271
2020-09-24 22:03:52 -07:00
Tue Ly f55963d501 [libc] Add implementation for hypotf
Truncating the sum of squares, and then use shift-and-add algorithm to compute its square root.
Required MPFR testing infra is updated in https://reviews.llvm.org/D87514

Differential Revision: https://reviews.llvm.org/D87516
2020-09-17 23:28:36 -04:00
Guillaume Chatelet c3fd2a50ba [libc] Remove special case for 8 and 16 bytes
They don't seem to gain much in real apps and its better to favor less branches and smaller code.
2020-09-15 20:48:27 +00:00
Guillaume Chatelet c19fda9aa0 [libc] use stddef instead of string header 2020-09-15 20:12:55 +00:00
Guillaume Chatelet 00ba1a3de7 [libc] remove useless headers 2020-09-15 20:04:12 +00:00
Guillaume Chatelet e328456a9e [libc] Add missing TableGen dependency
Differential Revision: https://reviews.llvm.org/D87689
2020-09-15 14:26:04 +00:00
Guillaume Chatelet 00d6e7116c [libc] Add missing LibcFPTestHelpers library
Differential Revision: https://reviews.llvm.org/D87690
2020-09-15 14:25:34 +00:00