-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc][complex] Set up headers and add documentation for complex.h. #111659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d9c3226
init
Sh0g0-1758 135b2eb
Libc: Complex init
Sh0g0-1758 4fc0e05
add _Imaginary type
Sh0g0-1758 e4e2bb4
fix doc
Sh0g0-1758 9021b17
Add F16 and F128
Sh0g0-1758 3bac6b3
Update complex-macros.h
Sh0g0-1758 33c4e02
Update _Imaginary.h
Sh0g0-1758 1ceaffb
remove _Imaginary
Sh0g0-1758 f5027c2
Add tests
Sh0g0-1758 7967075
Add FpBits
Sh0g0-1758 9c61d3a
fmt
Sh0g0-1758 bce4a29
Merge branch 'main' into complex
Sh0g0-1758 f19dcbc
Added iscomplex type
Sh0g0-1758 4433861
Added CFPMatcher
Sh0g0-1758 af6ce5e
fmt
Sh0g0-1758 94f8130
nit
Sh0g0-1758 4f8fe9a
nit
Sh0g0-1758 720f95e
nit
Sh0g0-1758 e946993
Cmake nit
Sh0g0-1758 6af7faf
Add FP16 and FP128
Sh0g0-1758 729aea1
nit
Sh0g0-1758 0c7457c
Fixed bug for long double and FP128
Sh0g0-1758 4078236
fmt
Sh0g0-1758 e769743
remove F16 and F128
Sh0g0-1758 1b94e49
Update is_complex.h
Sh0g0-1758 05c18fb
removed unnecessary imports
Sh0g0-1758 764f7cd
nit
Sh0g0-1758 db9737b
nit
Sh0g0-1758 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
.. include:: check.rst | ||
|
||
========= | ||
complex.h | ||
========= | ||
|
||
Macros | ||
====== | ||
|
||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| <Func> | <Func_f> (float) | <Func> (double) | <Func_l> (long double) | <Func_f16> (float16) | <Func_f128> (float128) | C23 Definition Section | C23 Error Handling Section | | ||
+===========+==================+=================+========================+======================+========================+========================+============================+ | ||
| CMPLX | | | | | | 7.3.9.3 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
|
||
Functions | ||
Sh0g0-1758 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
========= | ||
|
||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| <Func> | <Func_f> (float) | <Func> (double) | <Func_l> (long double) | <Func_f16> (float16) | <Func_f128> (float128) | C23 Definition Section | C23 Error Handling Section | | ||
+===========+==================+=================+========================+======================+========================+========================+============================+ | ||
| cacos | | | | | | 7.3.5.1 | G.6.2.1 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| casin | | | | | | 7.3.5.2 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| catan | | | | | | 7.3.5.3 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| ccos | | | | | | 7.3.5.4 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| csin | | | | | | 7.3.5.5 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| ctan | | | | | | 7.3.5.6 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| cacosh | | | | | | 7.3.6.1 | G.6.3.1 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| casinh | | | | | | 7.3.6.2 | G.6.3.2 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| catanh | | | | | | 7.3.6.3 | G.6.3.3 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| ccosh | | | | | | 7.3.6.4 | G.6.3.4 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| csinh | | | | | | 7.3.6.5 | G.6.3.5 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| ctanh | | | | | | 7.3.6.6 | G.6.3.6 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| cexp | | | | | | 7.3.7.1 | G.6.4.1 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| clog | | | | | | 7.3.7.2 | G.6.4.2 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| cabs | | | | | | 7.3.8.1 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| cpow | | | | | | 7.3.8.2 | G.6.5.1 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| csqrt | | | | | | 7.3.8.3 | G.6.5.2 | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| carg | | | | | | 7.3.9.1 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| cimag | | | | | | 7.3.9.2 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| conj | | | | | | 7.3.9.4 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| cproj | | | | | | 7.3.9.5 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | ||
| creal | | | | | | 7.3.9.6 | N/A | | ||
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ stages there is no ABI stability in any form. | |
libc_search | ||
c23 | ||
ctype | ||
complex | ||
signal | ||
threads | ||
setjmp | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//===-- C standard library header complex.h -------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_COMPLEX_H | ||
#define LLVM_LIBC_COMPLEX_H | ||
|
||
#include "__llvm-libc-common.h" | ||
#include "llvm-libc-macros/complex-macros.h" | ||
|
||
%%public_api() | ||
|
||
#endif // LLVM_LIBC_COMPLEX_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//===-- Definition of macros to be used with complex functions ------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef __LLVM_LIBC_MACROS_COMPLEX_MACROS_H | ||
#define __LLVM_LIBC_MACROS_COMPLEX_MACROS_H | ||
|
||
#ifndef __STDC_NO_COMPLEX__ | ||
|
||
#define __STDC_VERSION_COMPLEX_H__ 202311L | ||
|
||
#define complex _Complex | ||
#define _Complex_I ((_Complex float)1.0fi) | ||
#define I _Complex_I | ||
|
||
// TODO: Add imaginary macros once GCC or Clang support _Imaginary builtin-type. | ||
|
||
#endif | ||
|
||
#endif // __LLVM_LIBC_MACROS_COMPLEX_MACROS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//===-- is_complex type_traits ----------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H | ||
#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H | ||
|
||
#include "src/__support/CPP/type_traits/is_same.h" | ||
#include "src/__support/CPP/type_traits/remove_cv.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
namespace cpp { | ||
|
||
// is_complex | ||
template <typename T> struct is_complex { | ||
private: | ||
template <typename Head, typename... Args> | ||
LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { | ||
return (... || is_same_v<remove_cv_t<Head>, Args>); | ||
} | ||
|
||
public: | ||
LIBC_INLINE_VAR static constexpr bool value = | ||
__is_unqualified_any_of<T, _Complex float, _Complex double, | ||
_Complex long double>(); | ||
}; | ||
template <typename T> | ||
LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex<T>::value; | ||
template <typename T1, typename T2> | ||
LIBC_INLINE_VAR constexpr bool is_complex_type_same() { | ||
return is_same_v<remove_cv_t<T1>, T2>; | ||
} | ||
|
||
} // namespace cpp | ||
} // namespace LIBC_NAMESPACE_DECL | ||
|
||
#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//===-- Unittests for complex ---------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDSList-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "include/llvm-libc-macros/complex-macros.h" | ||
#include "test/UnitTest/FPMatcher.h" | ||
#include "test/UnitTest/Test.h" | ||
|
||
TEST(LlvmLibcComplexTest, VersionMacro) { | ||
EXPECT_EQ(__STDC_VERSION_COMPLEX_H__, 202311L); | ||
} | ||
|
||
TEST(LlvmLibcComplexTest, IMacro) { EXPECT_CFP_EQ(1.0fi, I); } | ||
|
||
TEST(LlvmLibcComplexTest, _Complex_IMacro) { EXPECT_CFP_EQ(1.0fi, _Complex_I); } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.