| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lasx | ||
| // RUN: not %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lasx -flax-vector-conversions=none | ||
| // RUN: not %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lasx -flax-vector-conversions=none -fno-signed-char | ||
| // FIXME: "not" should be removed once we fix GH#110834. | ||
|
|
||
| #include <lasxintrin.h> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lsx | ||
| // RUN: not %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lsx -flax-vector-conversions=none | ||
| // RUN: not %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lsx -flax-vector-conversions=none -fno-signed-char | ||
| // FIXME: "not" should be removed once we fix GH#110834. | ||
|
|
||
| #include <lsxintrin.h> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| add_proxy_header_library( | ||
| aligned_alloc | ||
| HDRS | ||
| aligned_alloc.h | ||
| DEPENDS | ||
| libc.hdr.stdlib_overlay | ||
| FULL_BUILD_DEPENDS | ||
| libc.include.stdlib | ||
| libc.hdr.types.size_t | ||
| ) | ||
|
|
||
| add_proxy_header_library( | ||
| malloc | ||
| HDRS | ||
| malloc.h | ||
| DEPENDS | ||
| libc.hdr.stdlib_overlay | ||
| FULL_BUILD_DEPENDS | ||
| libc.include.stdlib | ||
| libc.hdr.types.size_t | ||
| ) | ||
|
|
||
| add_proxy_header_library( | ||
| realloc | ||
| HDRS | ||
| realloc.h | ||
| DEPENDS | ||
| libc.hdr.stdlib_overlay | ||
| FULL_BUILD_DEPENDS | ||
| libc.include.stdlib | ||
| libc.hdr.types.size_t | ||
| ) | ||
|
|
||
| add_proxy_header_library( | ||
| free | ||
| HDRS | ||
| free.h | ||
| DEPENDS | ||
| libc.hdr.stdlib_overlay | ||
| FULL_BUILD_DEPENDS | ||
| libc.include.stdlib | ||
| ) | ||
|
|
||
| add_proxy_header_library( | ||
| _Exit | ||
| HDRS | ||
| _Exit.h | ||
| DEPENDS | ||
| libc.hdr.stdlib_overlay | ||
| FULL_BUILD_DEPENDS | ||
| libc.include.stdlib | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Definition of the _Exit proxy -------------------------------------===// | ||
| // | ||
| // 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_HDR_FUNC_EXIT_H | ||
| #define LLVM_LIBC_HDR_FUNC_EXIT_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
| // We will use the `_Exit` declaration from our generated stdlib.h | ||
| #include <stdlib.h> | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include "hdr/stdlib_overlay.h" | ||
|
|
||
| #endif | ||
|
|
||
| #endif // LLVM_LIBC_HDR_EXIT_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Definition of the aligned_alloc.h proxy ---------------------------===// | ||
| // | ||
| // 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_HDR_FUNC_ALIGNED_ALLOC_H | ||
| #define LLVM_LIBC_HDR_FUNC_ALIGNED_ALLOC_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
| #include "hdr/types/size_t.h" | ||
| extern "C" void *aligned_alloc(size_t, size_t); | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include "hdr/stdlib_overlay.h" | ||
|
|
||
| #endif | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Definition of the free.h proxy ------------------------------------===// | ||
| // | ||
| // 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_HDR_FUNC_FREE_H | ||
| #define LLVM_LIBC_HDR_FUNC_FREE_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
| extern "C" void free(void *); | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include "hdr/stdlib_overlay.h" | ||
|
|
||
| #endif | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Definition of the malloc.h proxy ----------------------------------===// | ||
| // | ||
| // 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_HDR_FUNC_MALLOC_H | ||
| #define LLVM_LIBC_HDR_FUNC_MALLOC_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
| #include "hdr/types/size_t.h" | ||
| extern "C" void *malloc(size_t); | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include "hdr/stdlib_overlay.h" | ||
|
|
||
| #endif | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Definition of the realloc.h proxy ---------------------------------===// | ||
| // | ||
| // 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_HDR_FUNC_REALLOC_H | ||
| #define LLVM_LIBC_HDR_FUNC_REALLOC_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
| #include "hdr/types/size_t.h" | ||
| extern "C" void *realloc(void *ptr, size_t new_size); | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include "hdr/stdlib_overlay.h" | ||
|
|
||
| #endif | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Definition of macros from stdlib.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_HDR_STDLIB_MACROS_H | ||
| #define LLVM_LIBC_HDR_STDLIB_MACROS_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-macros/stdlib-macros.h" | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include "stdlib_overlay.h" | ||
|
|
||
| #endif // LLVM_LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_STDLIB_MACROS_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| //===-- Including stdlib.h in overlay mode --------------------------------===// | ||
| // | ||
| // 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_HDR_STDLIB_OVERLAY_H | ||
| #define LLVM_LIBC_HDR_STDLIB_OVERLAY_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
| #error "This header should only be included in overlay mode" | ||
| #endif | ||
|
|
||
| // Overlay mode | ||
|
|
||
| // glibc <stdlib.h> header might provide extern inline definitions for few | ||
| // functions, causing external alias errors. They are guarded by | ||
| // `__USE_FORTIFY_LEVEL`, which will be temporarily disabled. | ||
|
|
||
| #ifdef __USE_FORTIFY_LEVEL | ||
| #define LIBC_OLD_USE_FORTIFY_LEVEL __USE_FORTIFY_LEVEL | ||
| #undef __USE_FORTIFY_LEVEL | ||
| #define __USE_FORTIFY_LEVEL 0 | ||
| #endif | ||
|
|
||
| #include <stdlib.h> | ||
|
|
||
| #ifdef LIBC_OLD_USE_FORTIFY_LEVEL | ||
| #undef __USE_FORTIFY_LEVEL | ||
| #define __USE_FORTIFY_LEVEL LIBC_OLD_USE_FORTIFY_LEVEL | ||
| #undef LIBC_OLD_USE_FORTIFY_LEVEL | ||
| #endif | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Definition of macros from div_t.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_HDR_TYPES_DIV_T_H | ||
| #define LLVM_LIBC_HDR_TYPES_DIV_T_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-types/div_t.h" | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include "hdr/stdlib_overlay.h" | ||
|
|
||
| #endif // LLVM_LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_TYPES_DIV_T_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Definition of macros from ldiv_t.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_HDR_TYPES_LDIV_T_H | ||
| #define LLVM_LIBC_HDR_TYPES_LDIV_T_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-types/ldiv_t.h" | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include "hdr/stdlib_overlay.h" | ||
|
|
||
| #endif // LLVM_LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_TYPES_LDIV_T_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Definition of macros from lldiv_t.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_HDR_TYPES_LLDIV_T_H | ||
| #define LLVM_LIBC_HDR_TYPES_LLDIV_T_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-types/lldiv_t.h" | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include "hdr/stdlib_overlay.h" | ||
|
|
||
| #endif // LLVM_LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_TYPES_LLDIV_T_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| //===-- Proxy for size_t --------------------------------------------------===// | ||
| // | ||
| // 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_HDR_TYPES_SIZE_T_H | ||
| #define LLVM_LIBC_HDR_TYPES_SIZE_T_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-types/size_t.h" | ||
|
|
||
| #else | ||
|
|
||
| #define __need_size_t | ||
| #include <stddef.h> | ||
| #undef __need_size_t | ||
|
|
||
| #endif // LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_TYPES_SIZE_T_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,6 @@ | |
| #include "src/__support/threads/mutex.h" | ||
|
|
||
| #include <dirent.h> | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- complex type --------------------------------------------*- 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_COMPLEX_TYPE_H | ||
| #define LLVM_LIBC_SRC___SUPPORT_COMPLEX_TYPE_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
| template <typename T> struct Complex { | ||
| T real; | ||
| T imag; | ||
| }; | ||
| } // namespace LIBC_NAMESPACE_DECL | ||
| #endif // LLVM_LIBC_SRC___SUPPORT_COMPLEX_TYPE_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| add_subdirectory(generic) | ||
|
|
||
| function(add_complex_entrypoint_object name) | ||
| get_fq_target_name("generic.${name}" fq_generic_target_name) | ||
| if(TARGET ${fq_generic_target_name}) | ||
| add_entrypoint_object( | ||
| ${name} | ||
| ALIAS | ||
| DEPENDS | ||
| .generic.${name} | ||
| ) | ||
| return() | ||
| endif() | ||
| endfunction() | ||
|
|
||
| add_complex_entrypoint_object(creal) | ||
| add_complex_entrypoint_object(crealf) | ||
| add_complex_entrypoint_object(creall) | ||
| add_complex_entrypoint_object(crealf16) | ||
| add_complex_entrypoint_object(crealf128) | ||
|
|
||
| add_complex_entrypoint_object(cimag) | ||
| add_complex_entrypoint_object(cimagf) | ||
| add_complex_entrypoint_object(cimagl) | ||
| add_complex_entrypoint_object(cimagf16) | ||
| add_complex_entrypoint_object(cimagf128) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation header for cimag -------------------------*- 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_COMPLEX_CIMAG_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CIMAG_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| double cimag(_Complex double x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CIMAG_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation header for cimagf ------------------------*- 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_COMPLEX_CIMAGF_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CIMAGF_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| float cimagf(_Complex float x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CIMAGF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //===-- Implementation header for cimagf128 ---------------------*- 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/macros/properties/complex_types.h" | ||
| #include "src/__support/macros/properties/types.h" | ||
|
|
||
| #if defined(LIBC_TYPES_HAS_CFLOAT128) | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_COMPLEX_CIMAGF128_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CIMAGF128_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| float128 cimagf128(cfloat128 x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CIMAGF128_H | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT128 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //===-- Implementation header for cimagf16 ----------------------*- 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/macros/properties/complex_types.h" | ||
| #include "src/__support/macros/properties/types.h" | ||
|
|
||
| #if defined(LIBC_TYPES_HAS_CFLOAT16) | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_COMPLEX_CIMAGF16_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CIMAGF16_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| float16 cimagf16(cfloat16 x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CIMAGF16_H | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT16 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation header for cimagl ------------------------*- 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_COMPLEX_CIMAGL_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CIMAGL_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| long double cimagl(_Complex long double x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CIMAGL_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation header for creal -------------------------*- 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_COMPLEX_CREAL_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CREAL_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| double creal(_Complex double x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CREAL_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation header for crealf ------------------------*- 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_COMPLEX_CREALF_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CREALF_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| float crealf(_Complex float x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CREALF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //===-- Implementation header for crealf128 ---------------------*- 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/macros/properties/complex_types.h" | ||
| #include "src/__support/macros/properties/types.h" | ||
|
|
||
| #if defined(LIBC_TYPES_HAS_CFLOAT128) | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_COMPLEX_CREALF128_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CREALF128_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| float128 crealf128(cfloat128 x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CREALF128_H | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT128 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //===-- Implementation header for crealf16 ----------------------*- 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/macros/properties/complex_types.h" | ||
| #include "src/__support/macros/properties/types.h" | ||
|
|
||
| #if defined(LIBC_TYPES_HAS_CFLOAT16) | ||
|
|
||
| #ifndef LLVM_LIBC_SRC_COMPLEX_CREALF16_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CREALF16_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| float16 crealf16(cfloat16 x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CREALF16_H | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT16 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- Implementation header for creall ------------------------*- 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_COMPLEX_CREALL_H | ||
| #define LLVM_LIBC_SRC_COMPLEX_CREALL_H | ||
|
|
||
| #include "src/__support/macros/config.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| long double creall(_Complex long double x); | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LLVM_LIBC_SRC_COMPLEX_CREALL_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| add_entrypoint_object( | ||
| creal | ||
| SRCS | ||
| creal.cpp | ||
| HDRS | ||
| ../creal.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| ) | ||
|
|
||
| add_entrypoint_object( | ||
| crealf | ||
| SRCS | ||
| crealf.cpp | ||
| HDRS | ||
| ../crealf.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| ) | ||
|
|
||
| add_entrypoint_object( | ||
| creall | ||
| SRCS | ||
| creall.cpp | ||
| HDRS | ||
| ../creall.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| ) | ||
|
|
||
| add_entrypoint_object( | ||
| crealf16 | ||
| SRCS | ||
| crealf16.cpp | ||
| HDRS | ||
| ../crealf16.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| libc.src.__support.macros.properties.types | ||
| libc.src.__support.macros.properties.complex_types | ||
| ) | ||
|
|
||
| add_entrypoint_object( | ||
| crealf128 | ||
| SRCS | ||
| crealf128.cpp | ||
| HDRS | ||
| ../crealf128.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| libc.src.__support.macros.properties.types | ||
| libc.src.__support.macros.properties.complex_types | ||
| ) | ||
|
|
||
| add_entrypoint_object( | ||
| cimag | ||
| SRCS | ||
| cimag.cpp | ||
| HDRS | ||
| ../cimag.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| ) | ||
|
|
||
| add_entrypoint_object( | ||
| cimagf | ||
| SRCS | ||
| cimagf.cpp | ||
| HDRS | ||
| ../cimagf.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| ) | ||
|
|
||
| add_entrypoint_object( | ||
| cimagl | ||
| SRCS | ||
| cimagl.cpp | ||
| HDRS | ||
| ../cimagl.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| ) | ||
|
|
||
| add_entrypoint_object( | ||
| cimagf16 | ||
| SRCS | ||
| cimagf16.cpp | ||
| HDRS | ||
| ../cimagf16.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| libc.src.__support.macros.properties.types | ||
| libc.src.__support.macros.properties.complex_types | ||
| ) | ||
|
|
||
| add_entrypoint_object( | ||
| cimagf128 | ||
| SRCS | ||
| cimagf128.cpp | ||
| HDRS | ||
| ../cimagf128.h | ||
| COMPILE_OPTIONS | ||
| -O3 | ||
| DEPENDS | ||
| libc.src.__support.CPP.bit | ||
| libc.src.__support.complex_type | ||
| libc.src.__support.macros.properties.types | ||
| libc.src.__support.macros.properties.complex_types | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Implementation of cimag function ----------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/cimag.h" | ||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, cimag, (_Complex double x)) { | ||
| Complex<double> x_c = cpp::bit_cast<Complex<double>>(x); | ||
| return x_c.imag; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Implementation of cimagf function ---------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/cimagf.h" | ||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, cimagf, (_Complex float x)) { | ||
| Complex<float> x_c = cpp::bit_cast<Complex<float>>(x); | ||
| return x_c.imag; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===-- Implementation of cimagf128 function ------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/cimagf128.h" | ||
| #if defined(LIBC_TYPES_HAS_CFLOAT128) | ||
|
|
||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float128, cimagf128, (cfloat128 x)) { | ||
| Complex<float128> x_c = cpp::bit_cast<Complex<float128>>(x); | ||
| return x_c.imag; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT128 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===-- Implementation of cimagf16 function -------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/cimagf16.h" | ||
| #if defined(LIBC_TYPES_HAS_CFLOAT16) | ||
|
|
||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float16, cimagf16, (cfloat16 x)) { | ||
| Complex<float16> x_c = cpp::bit_cast<Complex<float16>>(x); | ||
| return x_c.imag; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT16 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Implementation of cimagl function ---------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/cimagl.h" | ||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(long double, cimagl, (_Complex long double x)) { | ||
| Complex<long double> x_c = cpp::bit_cast<Complex<long double>>(x); | ||
| return x_c.imag; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Implementation of creal function ----------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/creal.h" | ||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(double, creal, (_Complex double x)) { | ||
| Complex<double> x_c = cpp::bit_cast<Complex<double>>(x); | ||
| return x_c.real; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Implementation of crealf function ---------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/crealf.h" | ||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float, crealf, (_Complex float x)) { | ||
| Complex<float> x_c = cpp::bit_cast<Complex<float>>(x); | ||
| return x_c.real; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===-- Implementation of crealf128 function ------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/crealf128.h" | ||
| #if defined(LIBC_TYPES_HAS_CFLOAT128) | ||
|
|
||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float128, crealf128, (cfloat128 x)) { | ||
| Complex<float128> x_c = cpp::bit_cast<Complex<float128>>(x); | ||
| return x_c.real; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT128 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //===-- Implementation of crealf16 function -------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/crealf16.h" | ||
| #if defined(LIBC_TYPES_HAS_CFLOAT16) | ||
|
|
||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(float16, crealf16, (cfloat16 x)) { | ||
| Complex<float16> x_c = cpp::bit_cast<Complex<float16>>(x); | ||
| return x_c.real; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT16 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Implementation of creall function ---------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/complex/creall.h" | ||
| #include "src/__support/CPP/bit.h" | ||
| #include "src/__support/common.h" | ||
| #include "src/__support/complex_type.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(long double, creall, (_Complex long double x)) { | ||
| Complex<long double> x_c = cpp::bit_cast<Complex<long double>>(x); | ||
| return x_c.real; | ||
| } | ||
|
|
||
| } // namespace LIBC_NAMESPACE_DECL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| //===-- Utility class to test different flavors of cimag --------*- 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_TEST_SRC_COMPLEX_CIMAGTEST_H | ||
| #define LLVM_LIBC_TEST_SRC_COMPLEX_CIMAGTEST_H | ||
|
|
||
| #include "test/UnitTest/FEnvSafeTest.h" | ||
| #include "test/UnitTest/FPMatcher.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| #include "hdr/math_macros.h" | ||
|
|
||
| template <typename CFPT, typename FPT> | ||
| class CImagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { | ||
|
|
||
| DECLARE_SPECIAL_CONSTANTS(FPT) | ||
|
|
||
| public: | ||
| typedef FPT (*CImagFunc)(CFPT); | ||
|
|
||
| void testSpecialNumbers(CImagFunc func) { | ||
| EXPECT_FP_EQ(func(CFPT(67.123 + aNaN * 1.0i)), aNaN); | ||
| EXPECT_FP_EQ(func(CFPT(78.319 + neg_aNaN * 1.0i)), neg_aNaN); | ||
| EXPECT_FP_EQ(func(CFPT(7813.131 + sNaN * 1.0i)), sNaN); | ||
| EXPECT_FP_EQ(func(CFPT(7824.152 + neg_sNaN * 1.0i)), neg_sNaN); | ||
| EXPECT_FP_EQ(func(CFPT(9024.2442 + inf * 1.0i)), inf); | ||
| EXPECT_FP_EQ(func(CFPT(8923.124 + neg_inf * 1.0i)), neg_inf); | ||
| EXPECT_FP_EQ(func(CFPT(782.124 + min_normal * 1.0i)), min_normal); | ||
| EXPECT_FP_EQ(func(CFPT(2141.2352 + max_normal * 1.0i)), max_normal); | ||
| EXPECT_FP_EQ(func(CFPT(341.134 + neg_max_normal * 1.0i)), neg_max_normal); | ||
| EXPECT_FP_EQ(func(CFPT(781.142 + min_denormal * 1.0i)), min_denormal); | ||
| EXPECT_FP_EQ(func(CFPT(781.134 + neg_min_denormal * 1.0i)), | ||
| neg_min_denormal); | ||
| EXPECT_FP_EQ(func(CFPT(1241.112 + max_denormal * 1.0i)), max_denormal); | ||
| EXPECT_FP_EQ(func(CFPT(121.121 + zero * 1.0i)), zero); | ||
| EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero); | ||
| EXPECT_FP_EQ(func(CFPT(neg_zero + neg_zero * 1.0i)), neg_zero); | ||
| EXPECT_FP_EQ(func(CFPT(zero + neg_zero * 1.0i)), neg_zero); | ||
| } | ||
|
|
||
| void testRoundedNumbers(CImagFunc func) { | ||
| EXPECT_FP_EQ(func((CFPT)(4523.1413 + 12413.1414i)), (FPT)(12413.1414)); | ||
| EXPECT_FP_EQ(func((CFPT)(-4523.1413 + 12413.1414i)), (FPT)(12413.1414)); | ||
| EXPECT_FP_EQ(func((CFPT)(4523.1413 - 12413.1414i)), (FPT)(-12413.1414)); | ||
| EXPECT_FP_EQ(func((CFPT)(-4523.1413 - 12413.1414i)), (FPT)(-12413.1414)); | ||
|
|
||
| EXPECT_FP_EQ(func((CFPT)(3210.5678 + 9876.5432i)), (FPT)(9876.5432)); | ||
| EXPECT_FP_EQ(func((CFPT)(-3210.5678 + 9876.5432i)), (FPT)(9876.5432)); | ||
| EXPECT_FP_EQ(func((CFPT)(3210.5678 - 9876.5432i)), (FPT)(-9876.5432)); | ||
| EXPECT_FP_EQ(func((CFPT)(-3210.5678 - 9876.5432i)), (FPT)(-9876.5432)); | ||
|
|
||
| EXPECT_FP_EQ(func((CFPT)(1234.4321 + 4321.1234i)), (FPT)(4321.1234)); | ||
| EXPECT_FP_EQ(func((CFPT)(-1234.4321 + 4321.1234i)), (FPT)(4321.1234)); | ||
| EXPECT_FP_EQ(func((CFPT)(1234.4321 - 4321.1234i)), (FPT)(-4321.1234)); | ||
| EXPECT_FP_EQ(func((CFPT)(-1234.4321 - 4321.1234i)), (FPT)(-4321.1234)); | ||
|
|
||
| EXPECT_FP_EQ(func((CFPT)(6789.1234 + 8765.6789i)), (FPT)(8765.6789)); | ||
| EXPECT_FP_EQ(func((CFPT)(-6789.1234 + 8765.6789i)), (FPT)(8765.6789)); | ||
| EXPECT_FP_EQ(func((CFPT)(6789.1234 - 8765.6789i)), (FPT)(-8765.6789)); | ||
| EXPECT_FP_EQ(func((CFPT)(-6789.1234 - 8765.6789i)), (FPT)(-8765.6789)); | ||
| } | ||
| }; | ||
|
|
||
| #define LIST_CIMAG_TESTS(U, T, func) \ | ||
| using LlvmLibcCImagTest = CImagTest<U, T>; \ | ||
| TEST_F(LlvmLibcCImagTest, SpecialNumbers) { testSpecialNumbers(&func); } \ | ||
| TEST_F(LlvmLibcCImagTest, RoundedNumbers) { testRoundedNumbers(&func); } | ||
|
|
||
| #endif // LLVM_LIBC_TEST_SRC_COMPLEX_CIMAGTEST_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| add_custom_target(libc-complex-unittests) | ||
|
|
||
| add_libc_test( | ||
| creal_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| creal_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.creal | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) | ||
|
|
||
| add_libc_test( | ||
| crealf_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| crealf_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.crealf | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) | ||
|
|
||
| add_libc_test( | ||
| creall_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| creall_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.creall | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) | ||
|
|
||
| add_libc_test( | ||
| crealf16_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| crealf16_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.crealf16 | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) | ||
|
|
||
| add_libc_test( | ||
| crealf128_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| crealf128_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.crealf128 | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) | ||
|
|
||
| add_libc_test( | ||
| cimag_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| cimag_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.cimag | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) | ||
|
|
||
| add_libc_test( | ||
| cimagf_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| cimagf_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.cimagf | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) | ||
|
|
||
| add_libc_test( | ||
| cimagl_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| cimagl_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.cimagl | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) | ||
|
|
||
| add_libc_test( | ||
| cimagf16_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| cimagf16_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.cimagf16 | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) | ||
|
|
||
| add_libc_test( | ||
| cimagf128_test | ||
| SUITE | ||
| libc-complex-unittests | ||
| SRCS | ||
| cimagf128_test.cpp | ||
| DEPENDS | ||
| libc.src.complex.cimagf128 | ||
| LINK_LIBRARIES | ||
| LibcFPTestHelpers | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| //===-- Utility class to test different flavors of creal --------*- 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_TEST_SRC_COMPLEX_CREALTEST_H | ||
| #define LLVM_LIBC_TEST_SRC_COMPLEX_CREALTEST_H | ||
|
|
||
| #include "test/UnitTest/FEnvSafeTest.h" | ||
| #include "test/UnitTest/FPMatcher.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| #include "hdr/math_macros.h" | ||
|
|
||
| template <typename CFPT, typename FPT> | ||
| class CRealTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { | ||
|
|
||
| DECLARE_SPECIAL_CONSTANTS(FPT) | ||
|
|
||
| public: | ||
| typedef FPT (*CRealFunc)(CFPT); | ||
|
|
||
| void testSpecialNumbers(CRealFunc func) { | ||
| EXPECT_FP_EQ(func(CFPT(aNaN + 67.123i)), aNaN); | ||
| EXPECT_FP_EQ(func(CFPT(neg_aNaN + 78.319i)), neg_aNaN); | ||
| EXPECT_FP_EQ(func(CFPT(sNaN + 7813.131i)), sNaN); | ||
| EXPECT_FP_EQ(func(CFPT(neg_sNaN + 7824.152i)), neg_sNaN); | ||
| EXPECT_FP_EQ(func(CFPT(inf + 9024.2442i)), inf); | ||
| EXPECT_FP_EQ(func(CFPT(neg_inf + 8923.124i)), neg_inf); | ||
| EXPECT_FP_EQ(func(CFPT(min_normal + 782.124i)), min_normal); | ||
| EXPECT_FP_EQ(func(CFPT(max_normal + 2141.2352i)), max_normal); | ||
| EXPECT_FP_EQ(func(CFPT(neg_max_normal + 341.134i)), neg_max_normal); | ||
| EXPECT_FP_EQ(func(CFPT(min_denormal + 781.142i)), min_denormal); | ||
| EXPECT_FP_EQ(func(CFPT(neg_min_denormal + 781.134i)), neg_min_denormal); | ||
| EXPECT_FP_EQ(func(CFPT(max_denormal + 1241.112i)), max_denormal); | ||
| EXPECT_FP_EQ(func(CFPT(zero + 121.121i)), zero); | ||
| EXPECT_FP_EQ(func(CFPT(neg_zero + neg_zero * 1.0i)), neg_zero); | ||
| EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero); | ||
| } | ||
|
|
||
| void testRoundedNumbers(CRealFunc func) { | ||
| EXPECT_FP_EQ(func((CFPT)(4523.1413 + 12413.1414i)), (FPT)(4523.1413)); | ||
| EXPECT_FP_EQ(func((CFPT)(-4523.1413 + 12413.1414i)), (FPT)(-4523.1413)); | ||
| EXPECT_FP_EQ(func((CFPT)(4523.1413 - 12413.1414i)), (FPT)(4523.1413)); | ||
| EXPECT_FP_EQ(func((CFPT)(-4523.1413 - 12413.1414i)), (FPT)(-4523.1413)); | ||
|
|
||
| EXPECT_FP_EQ(func((CFPT)(3210.5678 + 9876.5432i)), (FPT)(3210.5678)); | ||
| EXPECT_FP_EQ(func((CFPT)(-3210.5678 + 9876.5432i)), (FPT)(-3210.5678)); | ||
| EXPECT_FP_EQ(func((CFPT)(3210.5678 - 9876.5432i)), (FPT)(3210.5678)); | ||
| EXPECT_FP_EQ(func((CFPT)(-3210.5678 - 9876.5432i)), (FPT)(-3210.5678)); | ||
|
|
||
| EXPECT_FP_EQ(func((CFPT)(1234.4321 + 4321.1234i)), (FPT)(1234.4321)); | ||
| EXPECT_FP_EQ(func((CFPT)(-1234.4321 + 4321.1234i)), (FPT)(-1234.4321)); | ||
| EXPECT_FP_EQ(func((CFPT)(1234.4321 - 4321.1234i)), (FPT)(1234.4321)); | ||
| EXPECT_FP_EQ(func((CFPT)(-1234.4321 - 4321.1234i)), (FPT)(-1234.4321)); | ||
|
|
||
| EXPECT_FP_EQ(func((CFPT)(6789.1234 + 8765.6789i)), (FPT)(6789.1234)); | ||
| EXPECT_FP_EQ(func((CFPT)(-6789.1234 + 8765.6789i)), (FPT)(-6789.1234)); | ||
| EXPECT_FP_EQ(func((CFPT)(6789.1234 - 8765.6789i)), (FPT)(6789.1234)); | ||
| EXPECT_FP_EQ(func((CFPT)(-6789.1234 - 8765.6789i)), (FPT)(-6789.1234)); | ||
| } | ||
| }; | ||
|
|
||
| #define LIST_CREAL_TESTS(U, T, func) \ | ||
| using LlvmLibcCRealTest = CRealTest<U, T>; \ | ||
| TEST_F(LlvmLibcCRealTest, SpecialNumbers) { testSpecialNumbers(&func); } \ | ||
| TEST_F(LlvmLibcCRealTest, RoundedNumbers) { testRoundedNumbers(&func); } | ||
|
|
||
| #endif // LLVM_LIBC_TEST_SRC_COMPLEX_CREALTEST_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for cimag -----------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CImagTest.h" | ||
|
|
||
| #include "src/complex/cimag.h" | ||
|
|
||
| LIST_CIMAG_TESTS(_Complex double, double, LIBC_NAMESPACE::cimag) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //===-- Unittests for cimagf128 -------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CImagTest.h" | ||
|
|
||
| #include "src/complex/cimagf128.h" | ||
|
|
||
| #if defined(LIBC_TYPES_HAS_CFLOAT128) | ||
|
|
||
| LIST_CIMAG_TESTS(cfloat128, float128, LIBC_NAMESPACE::cimagf128) | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT128 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //===-- Unittests for cimagf16 --------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CImagTest.h" | ||
|
|
||
| #include "src/complex/cimagf16.h" | ||
|
|
||
| #if defined(LIBC_TYPES_HAS_CFLOAT16) | ||
|
|
||
| LIST_CIMAG_TESTS(cfloat16, float16, LIBC_NAMESPACE::cimagf16) | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT16 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for cimagf ----------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CImagTest.h" | ||
|
|
||
| #include "src/complex/cimagf.h" | ||
|
|
||
| LIST_CIMAG_TESTS(_Complex float, float, LIBC_NAMESPACE::cimagf) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for cimagl ----------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CImagTest.h" | ||
|
|
||
| #include "src/complex/cimagl.h" | ||
|
|
||
| LIST_CIMAG_TESTS(_Complex long double, long double, LIBC_NAMESPACE::cimagl) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for creal -----------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CRealTest.h" | ||
|
|
||
| #include "src/complex/creal.h" | ||
|
|
||
| LIST_CREAL_TESTS(_Complex double, double, LIBC_NAMESPACE::creal) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //===-- Unittests for crealf128 -------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CRealTest.h" | ||
|
|
||
| #include "src/complex/crealf128.h" | ||
|
|
||
| #if defined(LIBC_TYPES_HAS_CFLOAT128) | ||
|
|
||
| LIST_CREAL_TESTS(cfloat128, float128, LIBC_NAMESPACE::crealf128) | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT128 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //===-- Unittests for crealf16 --------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CRealTest.h" | ||
|
|
||
| #include "src/complex/crealf16.h" | ||
|
|
||
| #if defined(LIBC_TYPES_HAS_CFLOAT16) | ||
|
|
||
| LIST_CREAL_TESTS(cfloat16, float16, LIBC_NAMESPACE::crealf16) | ||
|
|
||
| #endif // LIBC_TYPES_HAS_CFLOAT16 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for crealf ----------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CRealTest.h" | ||
|
|
||
| #include "src/complex/crealf.h" | ||
|
|
||
| LIST_CREAL_TESTS(_Complex float, float, LIBC_NAMESPACE::crealf) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for creall ----------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "CRealTest.h" | ||
|
|
||
| #include "src/complex/creall.h" | ||
|
|
||
| LIST_CREAL_TESTS(_Complex long double, long double, LIBC_NAMESPACE::creall) |