Commit Graph

353 Commits

Author SHA1 Message Date
Siva Chandra Reddy 3f3f88fb95 [libc][Obvious] Add a file which was missed in 001a12ed59. 2021-03-08 15:39:29 -08:00
Siva Chandra Reddy 001a12ed59 [libc][NFC] Make x86_64 fenv functions msan safe.
These functions used inline asm to read FPU state. This change adds
explicit unpoisoning in these functions as the sanitizers don't see the
read operations.
2021-03-08 15:20:08 -08:00
Siva Chandra Reddy 9550f8ba9a [libc][NFC] Make few fenv functions work with fexcept_t from other libcs. 2021-03-04 11:25:28 -08:00
Siva Chandra Reddy 35e2e448ce [libc] Remove redundant header files included from internal paths. 2021-03-03 21:29:46 -08:00
Siva Chandra Reddy 6628387c9a [libc][NFC] Exclude few targets from the `all` target. 2021-02-24 08:59:55 -08:00
Siva Chandra Reddy 5f0800cc18 [libc][NFC] Remove headergen for the cacheline size macro.
We want to be able to build and test the string functions in contexts
like that of Fuchsia where LLVM pieces like tablegen are not available.
Since header generation uses tablegen, we are removing the dependency on
headergen here.

Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D97363
2021-02-24 07:29:09 -08:00
Siva Chandra Reddy 8d4ac5337f [libc][NFC] Merge llvmlibc and llvmlibm targets in to a single target.
The single target is called llvmlibc. We can add back smaller libm and
other targets in future if required.
2021-02-23 21:29:06 -08:00
Siva Chandra Reddy dbb131d53a [libc] Add a standalone flavor of an equivalent of std::string_view.
This class is to serve as a replacement for llvm::StringRef as part of
the plans to limit dependency on other parts of LLVM. One use of
llvm::StringRef in MPFRWrapper has been replaced with the new class.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D97330
2021-02-23 15:40:26 -08:00
Tue Ly b79507a4ac [libc] Add exhaustive test for sqrtf.
Differential Revision: https://reviews.llvm.org/D96985
2021-02-23 18:39:33 -05:00
Siva Chandra Reddy 881402ce62 [libc][NFC] Eliminate couple of dependencies on llvm/ADT/StringExtras.h. 2021-02-22 21:41:24 -08:00
Raman Tenneti 80bea4a0d5 [libc] [Obvious] Fix. 2021-02-22 19:15:35 -08:00
Raman Tenneti 034f562925 Changes to mktime to handle invalid dates, overflow and underflow andcalculating the correct date and thenumber of seconds even if invalid datesare passed as arguments.
Added tests for invalid dates like the following
  Date 1970-01-01 00:00:-1 is treated as 1969-12-31 23:59:59 and seconds
  are returned for the modified date.

Tested the code by doing ninja check-libc (and cmake).

Reviewed By: sivachandra, rtenneti

Differential Revision: https://reviews.llvm.org/D96684
2021-02-22 18:37:40 -08:00
Siva Chandra Reddy b7e05c874b [libc] Add implementations of the remaining fenv functions.
Namely, implementations of fegetexceptfflag, fesetexceptflag,
fegetenv, fesetenv, feholdexcept and feupdateenv have been added.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D96935
2021-02-18 13:29:40 -08:00
Siva Chandra Reddy dba14814a6 [libc][NFC] Make few maths functions buildable outside of LLVM libc build.
Few math functions manipulate errno. They assumed that LLVM libc's errno
is available. However, that might not be the case when these functions
are used in a libc which does not use LLVM libc's errno. This change
switches such uses of LLVM libc's errno to the normal public errno macro.
This does not affect LLVM libc's build because the include order ensures
we get LLVM libc's errno. Also, the header check rule ensures we are only
including LLVM libc's errno.h.
2021-02-16 09:14:29 -08:00
Guillaume Chatelet 74916008a8 Fix errors in distributions 2021-02-11 21:53:50 +00:00
Siva Chandra 53fcf6bb62 [libc][aarch64] Enable a bunch of math functions.
Namely, these are the functions enabled: rint*, lrint*, llrint*, lround*,
llround*, nearbyint*. They were previously not enabled because they
required rounding mode and FP exception support. Now that rounding mode
and FP exception support is available for Aarch64, they can be enabled.
2021-02-05 15:11:17 -08:00
Siva Chandra c90c8d38d3 [libc] Add aarch64 flavors of floor, round, sqrt and trunc.
Only single and double precision flavors have been added.

Reviewed By: lntue, sdesmalen

Differential Revision: https://reviews.llvm.org/D95999
2021-02-05 10:41:32 -08:00
Siva Chandra bbb7555403 [libc][NFC] Move generic math implementations to the generic directory.
This expands the pattern suggest in https://reviews.llvm.org/D95850 to all
math functions.
2021-02-03 10:46:00 -08:00
Andre Vieira 369f7de313 [LIBC] Add optimized memcpy routine for AArch64
This patch adds an optimized memcpy routine for AArch64 tuned and benchmarked
on Neoverse-N1.

Differential Revision: https://reviews.llvm.org/D92235
2021-02-03 09:30:55 +00:00
Siva Chandra 2668714747 [libc] Add hardware implementations of ceil and ceilf for aarch64.
This change also introduces a new source layout for adding machine
specific and generic implementations. To keep the scope of this change
small, this new pattern is only applied for ceil, ceilf and ceill.
Follow up changes will switch all math functions in to the new pattern.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D95850
2021-02-02 15:36:19 -08:00
Michael Jones c73c23f2a9 [libc][NFC] Add a death test API adaptation macro
Fuchsia's zxtest has a slightly different death test definition, and
this macro makes our death test API work on Fuchsia.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D95648
2021-02-01 19:19:04 +00:00
Michael Jones cb2e2d5068 [libc] Small adjustments to fenv tests
Some libcs define non-standard FE_* macros and include them in
FE_ALL_EXCEPT. This change adjusts the fenv tests so that the
non-standard FE_* macros do not interfere when compiled with
fenv.h from another libc.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D95650
2021-02-01 18:40:32 +00:00
Cheng Wang 1c762a81d2 [libc][Obvious] Fix typo 2021-01-29 17:43:41 +08:00
Cheng Wang 83bd242202 [libc][Obvious] Remove DEPS for unistd.h in CMake file of memmove. 2021-01-29 17:05:24 +08:00
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