Commit Graph

194 Commits

Author SHA1 Message Date
cgyurgyik 1b35c4fed2 [libc] [obvious] In strrchr, remove cast to unsigned char before
comparison.
2020-07-31 20:14:34 -04:00
cgyurgyik 5954755939 [libc] [obvious] Fix strchr and strrchr tests so that constness is
actually verified.
2020-07-31 20:00:59 -04:00
Chris Gyurgyik 7212ad067e
[libc] [obvious] Add rest of strrchr test. 2020-07-31 14:57:46 -04:00
cgyurgyik e8a2af28af [libc] Adds strrchr implementation.
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D84875
2020-07-31 14:38:34 -04:00
cgyurgyik e2d4bf6cec [libc] Add islower and isupper implementation.
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D84960
2020-07-31 14:05:27 -04:00
Siva Chandra Reddy a32af8252f [libc] Add a tool called WrapperGen.
This tool will be used to generate C wrappers for the C++ LLVM libc
implementations. This change does not hook this tool up to anything yet.
However, it can be useful for cases where one does not want to run the
objcopy step (to insert the C symbol in the object file) but can make use
of LTO to eliminate the cost of the additional wrapper call. This can be
relevant for certain downstream platforms. If this tool can benefit other
libc platforms in general, then it can be integrated into the build system
with options to use or not use the wrappers. An example of such a
platform is CUDA.

Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D84848
2020-07-30 16:07:26 -07:00
cgyurgyik e263dcc3ef [libc] Implements isdigit and isalnum. Adds a utility header to inline
functions to avoid overhead of function calls.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D84893
2020-07-30 12:37:30 -04:00
cgyurgyik e14a7ff762 [libc] Adds fuzz test for strstr and alphabetizes string fuzz CMakeList.
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D84611
2020-07-29 16:35:59 -04:00
Chris Gyurgyik 33abb7292e
[libc] [obvious] Fix typo in binary header. 2020-07-29 08:18:07 -04:00
Siva Chandra Reddy cd7a5c3cd9 [libc][obvious] Add license headers to APIIndexer.[cpp|h]. 2020-07-28 17:04:03 -07:00
Siva Chandra Reddy 462b3564f1 [libc][obvious] Add the new ctype.h target to the list of x86_64 headers.
This will fix the integration test which is failing currently.
2020-07-28 16:42:25 -07:00
Siva Chandra Reddy 59f17a7d4f [libc][NFC] Move tablegen indexer class into a util library of its own.
This class is currently used by two tools: HdrGen and PrototypeTestGen.
We will be adding more tools based on this class so it is convenient to
keep it in a util library of its own.
2020-07-28 16:35:19 -07:00
cgyurgyik 75f222b476 [libc] [Obvious] Delete ctype.h, since ctype.h.def is used. 2020-07-28 19:20:14 -04:00
cgyurgyik 686c82b974 [libc] Add scaffolding for ctype and implementation of isalpha
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D84575
2020-07-28 19:17:31 -04:00
Siva Chandra Reddy 9cc70e047c [libc][NFC] Zero out padding bits in the uint form of x86 FPBits<long double>. 2020-07-28 11:59:04 -07:00
Siva Chandra Reddy acca2980a3 [libc][obvious] Move ErrnoSetterMatcher to test/ErrnoSetterMetcher.h. 2020-07-28 11:05:52 -07:00
cgyurgyik 51eeeb477f [libc] [Obvious] Place entrypoints, specs alphabetically. 2020-07-24 15:52:35 -04:00
cgyurgyik 5a9630b777 [libc] Adds implementation for memrchr.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D84469
2020-07-24 14:40:12 -04:00
Tue Ly 1404d9d68a [libc] Remove unused #include <vector> in fmin_test, fminf_test, and fminl_test. 2020-07-23 15:26:05 -04:00
Tue Ly 4096088e19 [libc] Add implementations of fmax, fmaxf, and fmaxl.
Summary: Add implementations of fmax, fmaxf, and fmaxl.

Reviewers: sivachandra

Subscribers: mgorny, tschuett, libc-commits, ecnelises

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D84385
2020-07-23 15:23:08 -04:00
cgyurgyik f773d37ee1 [libc] Implements strnlen.
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D84247
2020-07-22 18:28:35 -04:00
Tue Ly 7ce32f87f9 Add implementations for fmin, fminf, and fminl. Testing infrastructure update is splitted to https://reviews.llvm.org/D83931. 2020-07-21 17:24:15 -04:00
Tue Ly e138ad41e0 Update Test (EXPECT_EQ and friends) to accept __uint128_t and floating point types (float, double, long double).
Summary: Update Test (EXPECT_EQ and friends) to accept __uint128_t and floating point types (float, double, long double).

Reviewers: sivachandra

Subscribers: mgorny, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D83931
2020-07-21 16:50:45 -04:00
Chris Gyurgyik a16129c138
[libc] [Obvious] Fix typo.
Fixes typo for strstr in entrypoints.
str -> src.
2020-07-21 11:52:12 -04:00
cgyurgyik d080635bfc [libc] Add strstr implementation.
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D83956
2020-07-21 11:39:23 -04:00
Siva Chandra Reddy 7738c03418 [libc][NFC] Use RemoveCVType to implement IsIntegral and IsPointerType.
Added IsSameV as a convenience variable and used it where convenient.

Reviewers: abrachet, lntue

Differential Revision: https://reviews.llvm.org/D83980
2020-07-17 11:32:50 -07:00
Siva Chandra Reddy f5db2411c2 [libc][Obvious] Cleanup of include lines and target listings in FPUtil. 2020-07-17 00:09:36 -07:00
serge-sans-paille 515bc8c155 Harmonize Python shebang
Differential Revision: https://reviews.llvm.org/D83857
2020-07-16 21:53:45 +02:00
Andre Vieira c051312eb2 [libc][benchmark] Add display option to render.py3
Differential Revision: https://reviews.llvm.org/D83380
2020-07-13 12:09:14 +01:00
cgyurgyik 7859242a37 [libc] [Obvious] Remove unneeded header in strchr.
Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D83589
2020-07-10 19:33:55 -04:00
cgyurgyik a4f0c58c6e [libc] Add strchr implementation. Fixes bug in memchr.
Summary: [libc] Adds strchr implementation with unit tests. Fixes signed character bug in memchr.

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D83353
2020-07-10 14:30:20 -04:00
Chris Gyurgyik 9d8b4defd3
[libc] Fix typographical error in math_utils.h. 2020-07-08 11:56:21 -04:00
cgyurgyik b6a20a4970 [libc] Add memchr implementation. 2020-07-07 17:08:50 -04:00
Paula Toth ab25ed26c6 [libc] Add documentation for clang-tidy checks.
Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D82846
2020-07-06 18:15:35 -07:00
Paula Toth aa6ef6fea0 [libc] Add documentation for integration tests.
Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: MaskRay, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D82907
2020-07-06 12:44:32 -07:00
cgyurgyik b07feef873 [libc] This commit fixes the strcmp fuzzing test. It uses a single input and
splits it into two by using the value of the first byte to determine the
length of the first string. Reviewed-by: PaulkaToast, Differential
Revision: https://reviews.llvm.org/D82427

Summary:
[libc] Since only one input is given, it is necessary to split the string into two containers so that they can be compared for the purposes of this fuzz test. This is done in the following manner:

1. Take the value of the first byte; this is size1. (Credits to @PaulkaToast for this idea).
2. size2 is the value of size - size1.
3. Copy the characters to new containers, data1 and data2 with corresponding sizes.
4. Add a null terminator to the first container, and verify the second container has a null terminator.
5. Verify output of strcmp.

A simpler alternative considered was simply splitting the input data into two, but this means the two strings are always within +- 1 character of each other. This above implementation avoids this.

ninja check-libc was run; no issues.

Reviewers: PaulkaToast, sivachandra

Reviewed By: PaulkaToast

Subscribers: mgorny, tschuett, ecnelises, libc-commits, PaulkaToast

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D82427
2020-06-28 12:50:04 -05:00
Siva Chandra Reddy d4adac4832 [libc] Add the remaining long double flavors of nearest integer functions.
Specifically: ceill, floorl and roundl have been added.

Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D82591
2020-06-25 22:45:05 -07:00
Siva Chandra 25ac19de4b [libc] Enable copysignl, frexpl, logbl and modfl on aarch64. 2020-06-24 00:16:23 -07:00
Siva Chandra Reddy 7abdb2b948 [libc][Obvious] Remove a debug #include of iostream. 2020-06-24 00:01:03 -07:00
Siva Chandra Reddy a00fb593b4 [libc] Add long double flavors of the floating point manipulation functions.
Specifically: copysignl, frexpl, logbl and modfl have been added.

Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D82357
2020-06-23 23:46:58 -07:00
Siva Chandra Reddy dc72be4e01 [libc][Obvious] Fix few typos in tests. 2020-06-23 13:11:41 -07:00
cgyurgyik 8bec88e638 Remove strcmp fuzz from CMakeList since it breaks build. 2020-06-23 12:52:36 -04:00
Simon Pilgrim f1c671925b Add stddef.h to fix missing size_t type build errors. 2020-06-23 13:12:18 +01:00
cgyurgyik 4ffe2b24f5 [libc] Add fuzz test for strcmp.
Summary:
Adds a fuzz test for string comparison.

This takes in two strings with associated lengths.
Verifies each string contains at least one character, and that the last character is the null terminator.
Then, finds the first instance where one of the following does not hold:
1. i < min(size1, size2)
2. s1[i] == s2[i]
3. s1[i] != '\0'

The result of strcmp is then compared to the value of the difference between s1[i] and s2[i]. For thoroughness, the operands are reversed and also checked.

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra, PaulkaToast

Subscribers: mgorny, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D82247
2020-06-23 07:24:03 -04:00
cgyurgyik 5540765be6 Add strcmp fuzz test.
Reviewed-by: todo
Differential Revision: https://reviews.llvm.org/D82247
2020-06-23 07:20:39 -04:00
Siva Chandra Reddy 987fac79c9 [libc] Match x86 long double NaN classification with that of the compiler.
Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D82330
2020-06-22 23:02:05 -07:00
cgyurgyik 05e1612c43 [libc] This adds the strcmp (string compare) implementation.
Reviewed-by: sivachandra
Differential Revision: https://reviews.llvm.org/D82134
2020-06-19 16:09:44 -04:00
Anthony Steinhauser 1a377055a7 [libc] Migrate the libc benchmark instruction to ninja.
Reviewers: sivachandra

    Reviewed By: sivachandra

    Differential Revision: https://reviews.llvm.org/D82143
2020-06-18 21:54:30 -07:00
Siva Chandra Reddy 139018265b [libc] Add implementations long double fabsl and truncl functions.
Current implementations of single precision and double precision
floating point operations operate on bits of the integer type of
same size. The code made use of magic masks which were listed as
literal integer values. This is not possible in the case of long
double type as the mantissa of quad-precision long double type used
on non-x86 architectures is wider that the widest integer type for
which we can list literal values. So, in this patch, to avoid
using magic masks specified with literal values, we use packed
bit-field struct types and let the compiler generate the masks.
This new scheme allows us to implement long double flavors of the
various floating point operations. To keep the size of the patch
small, only the implementations of fabs and trunc have been
switched to the new scheme. In following patches, all exisiting
implementations will be switched to the new scheme.

Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D82036
2020-06-18 11:08:26 -07:00
Siva Chandra Reddy 438f7fc068 [libc][benchmarks] Link the memory benchmark exes to functions from LLVM libc.
Summary:
To get the target order correct, the benchmarks directory has been moved
one level higher. Previously, it was living in the utils directory. The
utils directory is a collection of utils which are to be used by the
tests and implementations. However, benchmarks *use* the
implementations. So, moving it out of utils helps us setup proper
target level dependencies.

Reviewers: gchatelet

Differential Revision: https://reviews.llvm.org/D81910
2020-06-17 11:42:26 -07:00