File tree Expand file tree Collapse file tree 8 files changed +117
-0
lines changed Expand file tree Collapse file tree 8 files changed +117
-0
lines changed Original file line number Diff line number Diff line change @@ -373,6 +373,7 @@ set(TARGET_LIBM_ENTRYPOINTS
373373 libc.src.complex.cproj
374374 libc.src.complex.cprojf
375375 libc.src.complex.cprojl
376+ libc.src.complex.cargf
376377
377378 # fenv.h entrypoints
378379 libc.src.fenv.feclearexcept
Original file line number Diff line number Diff line change @@ -36,3 +36,5 @@ add_complex_entrypoint_object(cprojf)
3636add_complex_entrypoint_object(cprojl)
3737add_complex_entrypoint_object(cprojf16)
3838add_complex_entrypoint_object(cprojf128)
39+
40+ add_complex_entrypoint_object(cargf)
Original file line number Diff line number Diff line change 1+ // ===-- Implementation header for cargf -------------------------*- C++ -*-===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ // ===----------------------------------------------------------------------===//
8+
9+ #ifndef LLVM_LIBC_SRC_COMPLEX_CARGF_H
10+ #define LLVM_LIBC_SRC_COMPLEX_CARGF_H
11+
12+ #include " src/__support/macros/config.h"
13+
14+ namespace LIBC_NAMESPACE_DECL {
15+
16+ float cargf (_Complex float x);
17+
18+ } // namespace LIBC_NAMESPACE_DECL
19+
20+ #endif // LLVM_LIBC_SRC_COMPLEX_CARGF_H
Original file line number Diff line number Diff line change 1+ add_entrypoint_object(
2+ cargf
3+ SRCS
4+ cargf.cpp
5+ HDRS
6+ ../cargf.h
7+ COMPILE_OPTIONS
8+ ${libc_opt_high_flag}
9+ DEPENDS
10+ libc.src.__support.complex_type
11+ libc.src.math.atan2f
12+ )
13+
114add_entrypoint_object(
215 cproj
316 SRCS
Original file line number Diff line number Diff line change 1+ // ===-- Implementation of cargf function ----------------------------------===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ // ===----------------------------------------------------------------------===//
8+
9+ #include " src/complex/cargf.h"
10+ #include " src/__support/common.h"
11+ #include " src/__support/complex_type.h"
12+ #include " src/math/atan2f.h"
13+
14+ namespace LIBC_NAMESPACE_DECL {
15+
16+ LLVM_LIBC_FUNCTION (float , cargf, (_Complex float x)) {
17+ Complex<float > x_c = cpp::bit_cast<Complex<float >>(x);
18+ return atan2f (x_c.imag , x_c.real );
19+ }
20+
21+ } // namespace LIBC_NAMESPACE_DECL
Original file line number Diff line number Diff line change 11add_custom_target (libc-complex-unittests)
22
3+ add_libc_test(
4+ cargf_test
5+ SUITE
6+ libc-complex-unittests
7+ SRCS
8+ cargf_test.cpp
9+ DEPENDS
10+ libc.src.complex.cargf
11+ LINK_LIBRARIES
12+ LibcFPTestHelpers
13+ )
14+
315add_libc_test(
416 conj_test
517 SUITE
Original file line number Diff line number Diff line change 1+ // ===-- Utility class to test different flavors of carg ---------*- C++ -*-===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ // ===----------------------------------------------------------------------===//
8+
9+ #ifndef LLVM_LIBC_TEST_SRC_COMPLEX_CARGTEST_H
10+ #define LLVM_LIBC_TEST_SRC_COMPLEX_CARGTEST_H
11+
12+ #include " test/UnitTest/FEnvSafeTest.h"
13+ #include " test/UnitTest/FPMatcher.h"
14+ #include " test/UnitTest/Test.h"
15+
16+ #include " hdr/math_macros.h"
17+
18+ template <typename CFPT, typename FPT>
19+ class CargTest : public LIBC_NAMESPACE ::testing::FEnvSafeTest {
20+
21+ DECLARE_SPECIAL_CONSTANTS (FPT)
22+
23+ public:
24+ typedef FPT (*CargFunc)(CFPT);
25+
26+ void testRoundedNumbers (CargFunc func) {
27+ EXPECT_FP_EQ ((FPT)(1.10714871762320399284 ), func ((CFPT)(1.0 + 2 .0i)));
28+ }
29+ };
30+
31+ #define LIST_CARG_TESTS (U, T, func ) \
32+ using LlvmLibcCargTest = CargTest<U, T>; \
33+ TEST_F (LlvmLibcCargTest, RoundedNumbers) { testRoundedNumbers (&func); }
34+
35+ #endif // LLVM_LIBC_TEST_SRC_COMPLEX_CARGTEST_H
Original file line number Diff line number Diff line change 1+ // ===-- Unittests for cargf -----------------------------------------------===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ // ===----------------------------------------------------------------------===//
8+
9+ #include " CargTest.h"
10+
11+ #include " src/complex/cargf.h"
12+
13+ LIST_CARG_TESTS (_Complex float , float , LIBC_NAMESPACE::cargf)
You can’t perform that action at this time.
0 commit comments