1361 Commits

Author SHA1 Message Date
Siva Chandra Reddy
05d9cc4799 [libc][NFC] Replace "inline" keyword with "LIBC_INLINE".
This is the first of patches doing similar cleanup. A section in the
code style doc has been added explaining where and how LIBC_INLINE is to
be used.

Reviewed By: jeffbailey, lntue

Differential Revision: https://reviews.llvm.org/D142434
2023-01-24 19:35:34 +00:00
Guillaume Chatelet
76f9a6a4e7 Revert D142108 "[reland][libc][NFC] Detect host CPU features using try_compile instead of try_run."
The build bots are failing.
This reverts commit c84d74f5bfe810744de1268eb0516a6622e4aa73.
2023-01-24 16:23:32 +00:00
Guillaume Chatelet
c84d74f5bf [reland][libc][NFC] Detect host CPU features using try_compile instead of try_run.
This implements the same behavior as D141997 but makes sure that the same detection mechanism is used between CMake and source code.

Differential Revision: https://reviews.llvm.org/D142108
2023-01-24 16:04:10 +00:00
Siva Chandra Reddy
6363320ba6 [libc][NFC] Another round of replacement of static inline with LIBC_INLINE.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D142398
2023-01-24 00:37:09 +00:00
Guillaume Chatelet
fcef706363 [libc][NFC] Reduce CMake configuration time
This patch reduces CMake configuration time drastically by removing a non-linear behavior.
Time to execute CMake configure step goes from 45s to 15s.

Differential Revision: https://reviews.llvm.org/D142374
2023-01-23 17:02:27 +00:00
Guillaume Chatelet
9c4c32a3d0 Revert D142108 "[libc][NFC] Detect host CPU features using try_compile instead of try_run."
Build bots are failing.
https://lab.llvm.org/buildbot/#/builders/90/builds/44634

This reverts commit 9acc2f37bdfce08ca0c2faec03392db10d1bb7a9.
2023-01-23 10:43:34 +00:00
Guillaume Chatelet
9acc2f37bd [libc][NFC] Detect host CPU features using try_compile instead of try_run.
This implements the same behavior as D141997 but makes sure that the same detection mechanism is used between CMake and source code.

Differential Revision: https://reviews.llvm.org/D142108
2023-01-23 09:05:53 +00:00
Siva Chandra
0e3ff29b95 [libc][Obvious] Restore static keyword of a few static methods.
The static keyword of the concerned methods was accidentally lost in a
previous commit.
2023-01-20 16:57:12 -08:00
Siva Chandra Reddy
59c809cd9b [libc][NFC] Replace static inline and inline annotations with LIBC_INLINE.
This is first of a few patches which will do similar mechanical changes.

LIBC_INLINE is a simple macro which is default defined as just `inline`.
The idea is that, different downstream contexts can define the macro as
suitable to their use case and context. For example, one can choose to
define LIBC_INLINE as `[[clang::internal_linkage]] inline`.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D142154
2023-01-20 22:27:17 +00:00
Michael Jones
9a32e53941 [libc] add scanf float converter
This patch adds the %f/F/e/E/g/G/a/A conversions for scanf, as well as
accompanying tests. This implementation matches the definition set forth
in the standard, which may conflict with some other implementations.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D141091
2023-01-19 09:26:25 -08:00
Michael Jones
176c853d1d [libc] add internal string class
The scanf implementation needs a dynamically resizing string class. This
patch adds a minimal version of that class along with tests to check the
current functionality.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D141162
2023-01-19 09:26:22 -08:00
Guillaume Chatelet
2156d33b49 [libc] Fix memcpy inefficiency 2023-01-17 11:06:21 +00:00
Kazu Hirata
660c33e51d [libc] Use std::optional instead of llvm::Optional (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14 21:10:14 -08:00
Kazu Hirata
b5516be056 [libc] Use std::optional instead of llvm::Optional (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14 20:52:00 -08:00
Kazu Hirata
e1cdda57fa [libc] Use std::optional instead of llvm::Optional (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14 20:22:48 -08:00
Siva Chandra Reddy
c68b9cc0aa [libc][NFC] Use C headers in host CPU sniffing code. 2023-01-13 07:43:32 +00:00
Siva Chandra Reddy
3054bc5fa0 [libc][obvious] Add a missing dep. 2023-01-12 22:33:38 +00:00
Siva Chandra Reddy
41c6c75333 [libc] Use the boostrap build's target triple if available.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D141428
2023-01-11 06:37:05 +00:00
Alex Brachet
e9d571d3b6 [libc] Implement str{,n}casecmp
Differential Revision: https://reviews.llvm.org/D141236
2023-01-11 05:38:33 +00:00
Siva Chandra Reddy
1f0c237a24 [libc][NFC] Remove the now unused WrapperGen tool and tests. 2023-01-10 22:20:06 +00:00
Alex Brachet
b1372fe7b0 [libc] Fix -Wimplicit-int-conversion warnings
Differential Revision: https://reviews.llvm.org/D140492
2023-01-10 16:41:28 +00:00
Alex Brachet
f296dce763 Reland: "[libc] Templatize str{,n}cmp"
This will be used to implement the case insensitive str{,n}casecmp

This was initially reverted because it broke tests on arm platforms.
Unfortunately, it didn't break on my arm machine, but I suspect the
problem was the old comparator returned char and not int.

Differential Revision: https://reviews.llvm.org/D141235
2023-01-10 15:39:54 +00:00
serge-sans-paille
984b800a03
Move from llvm::makeArrayRef to ArrayRef deduction guides - last part
This is a follow-up to https://reviews.llvm.org/D140896, split into
several parts as it touches a lot of files.

Differential Revision: https://reviews.llvm.org/D141298
2023-01-10 11:47:43 +01:00
Tue Ly
72a794c220 [libc][Obvious] Re-enable log10 tests. 2023-01-09 15:55:32 -05:00
Siva Chandra Reddy
a439c4afdc [libc][Obvious] Address few GCC warnings. 2023-01-09 20:54:13 +00:00
Tue Ly
05727d94de [libc][Obvious] Fix typos in LLVMLibCArchitectures.cmake defining target architectures.
Fix typos in LLVMLibCArchitectures.cmake defining target architectures.

Differential Revision: https://reviews.llvm.org/D141314
2023-01-09 15:53:22 -05:00
Alex Brachet
3af4e4031d Revert "[libc] Templatize str{,n}cmp"
This reverts commit c6dcbed2e5327f0c11962bdbbcd02f1b5c570fea.

Broke tests on arm and aarch64
2023-01-09 20:24:16 +00:00
Alex Brachet
dc1b614bb8 [libc] Move b* string functions to strings.h
Traditionally these functions are exposed in string*s*.h not string.h

Differential Revision: https://reviews.llvm.org/D141237
2023-01-09 20:16:20 +00:00
Alex Brachet
c6dcbed2e5 [libc] Templatize str{,n}cmp
This will be used to implement the case insensitive str{,n}casecmp

Differential Revision: https://reviews.llvm.org/D141235
2023-01-09 20:13:02 +00:00
Tue Ly
9e5fde59a4 [libc][Obvious] Temporarily disable log10_test for further investigation. 2023-01-08 18:21:30 -05:00
Tue Ly
1b9c21fda9 [libc][Obvious] Remove constexpr fomr exact_mult in double_double.h 2023-01-08 17:52:46 -05:00
Tue Ly
5814b7b279 [libc][math] Implement log10 function correctly rounded for all rounding modes
Implement double precision log10 function correctly rounded for all
rounding modes.  This implementation currently needs FMA instructions for
correctness.

Use 2 passes:
Fast pass:
- 1 step range reduction with a lookup table of `2^7 = 128` elements to reduce the ranges to `[-2^-7, 2^-7]`.
- Use a degree-7 minimax polynomial generated by Sollya, evaluated using a mixed of double-double and double precisions.
- Apply Ziv's test for accuracy.
Accurate pass:
- Apply 5 more range reduction steps to reduce the ranges further to [-2^-27, 2^-27].
- Use a degree-4 minimax polynomial generated by Sollya, evaluated using 192-bit precisions.
- By the result of Lefevre (add quote), this is more than enough for correct rounding to all rounding modes.

In progress: Adding detail documentations about the algorithm.

Depend on: https://reviews.llvm.org/D136799

Reviewed By: zimmermann6

Differential Revision: https://reviews.llvm.org/D139846
2023-01-08 17:41:54 -05:00
Siva Chandra Reddy
8304f6de94 [libc] Add a separate install target for the libc static archives.
Also, skip installing startup objects for baremetal targets for now.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D141112
2023-01-06 23:32:07 +00:00
Michael Jones
9b8a64b88d [libc] add noexcept to external function headers
To improve code generation for C++ code that directly includes our
headers, the external function definitions will now be marked noexcept.
This may not be necessary for the internal definitions since we build
with the -fno-exceptions flag.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D141095
2023-01-06 11:43:43 -08:00
Guillaume Chatelet
062a7ea591 [libc] Add a section about supported compilers in the documentation
Context https://github.com/llvm/llvm-project/issues/59368

Differential Revision: https://reviews.llvm.org/D141045
2023-01-06 09:30:50 +00:00
Siva Chandra Reddy
fbe0b51767 [libc] Make the sidebar colors have a higher constract in the white background.
Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D141039
2023-01-05 09:43:59 -08:00
Siva Chandra Reddy
36de85f93f [libc] Add document for a recipe to do a full standalone cross-build.
Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D141037
2023-01-05 09:37:21 -08:00
Jeff Bailey
6e5c35819e [libc] Add documentation on hacking with vscode
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D140826
2023-01-05 17:27:32 +00:00
Guillaume Chatelet
abcdc26a81 [libc] get_table_negative cannot be constexpr
GCC complains about if conditions not being constant expressions.
As-is get_table_negative cannot be marked constexpr.

Differential Revision: https://reviews.llvm.org/D140967
2023-01-05 14:28:50 +00:00
Guillaume Chatelet
79c730218e [libc] Fix invalid constructor declaration 2023-01-05 14:01:37 +00:00
Guillaume Chatelet
c25af9bb1e [libc][NFC] Use a function instead of templated static member functions for TYPE_DESC
I'm surprised that clang accepts the current code.
It seems odd to me to specialize templated static member variables.

GCC rejects them: https://godbolt.org/z/3ecE9Ps7T

This patch is in the context of https://github.com/llvm/llvm-project/issues/59368

Differential Revision: https://reviews.llvm.org/D140981
2023-01-05 10:02:57 +00:00
Guillaume Chatelet
feb0778862 [libc][NFC] Remove unused variable 2023-01-04 15:27:04 +00:00
Siva Chandra Reddy
fa715e2dad [libc][NFC] Remove a constexpr marking to fix GCC build. 2023-01-03 18:00:57 +00:00
Jeff Bailey
bc09f1e5c3 [libc] [nfc] Fix heading underline.
Differential Revision: https://reviews.llvm.org/D140825
2023-01-01 20:53:10 +00:00
Guillaume Chatelet
4e9ac30816 [reland][libc][NFC] Add -fno-lax-vector-conversions compilation flag
Now that a3d2c344773cc4fc95136fd67245880b34d8e335 has been submitted.
2022-12-27 10:32:41 +00:00
Guillaume Chatelet
56ab6f783b [libc][NFC] Fix lax vector conversion for aarch64 2022-12-27 10:16:37 +00:00
Guillaume Chatelet
d065472c9e Revert "[libc][NFC] Add -fno-lax-vector-conversions compilation flag"
This breaks aarch64 build.

This reverts commit 32f4c3f1033e32b7d2b7ba310c46c8c0d4013eb0.
2022-12-27 08:30:19 +00:00
Guillaume Chatelet
32f4c3f103 [libc][NFC] Add -fno-lax-vector-conversions compilation flag 2022-12-27 08:25:32 +00:00
Siva Chandra Reddy
c89db6ad39 [libc][obvious] Remove a spurious statement leftover from a previous change. 2022-12-23 06:50:28 +00:00
Siva Chandra Reddy
f112960190 [libc][NFC] Use operator new and operator delete in POSIX file actions API.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D140597
2022-12-23 05:58:25 +00:00