From 4e567242133678c88a6cb5aeb979c6148f6a7035 Mon Sep 17 00:00:00 2001 From: OverMighty Date: Wed, 3 Jul 2024 01:27:09 +0200 Subject: [libc][math][c23] Add f16{add,sub}{,l,f128} C23 math functions (#97072) Part of #93566. --- libc/config/linux/aarch64/entrypoints.txt | 2 + libc/config/linux/x86_64/entrypoints.txt | 6 ++ libc/docs/math/index.rst | 4 +- libc/spec/llvm_libc_ext.td | 4 ++ libc/spec/stdc.td | 4 ++ libc/src/math/CMakeLists.txt | 6 ++ libc/src/math/f16add.h | 20 +++++++ libc/src/math/f16addf128.h | 20 +++++++ libc/src/math/f16addl.h | 20 +++++++ libc/src/math/f16sub.h | 20 +++++++ libc/src/math/f16subf128.h | 20 +++++++ libc/src/math/f16subl.h | 20 +++++++ libc/src/math/generic/CMakeLists.txt | 78 +++++++++++++++++++++++++ libc/src/math/generic/f16add.cpp | 19 ++++++ libc/src/math/generic/f16addf128.cpp | 19 ++++++ libc/src/math/generic/f16addl.cpp | 19 ++++++ libc/src/math/generic/f16sub.cpp | 19 ++++++ libc/src/math/generic/f16subf128.cpp | 19 ++++++ libc/src/math/generic/f16subl.cpp | 19 ++++++ libc/test/src/math/CMakeLists.txt | 52 +++++++++++++++++ libc/test/src/math/f16add_test.cpp | 13 +++++ libc/test/src/math/f16addl_test.cpp | 13 +++++ libc/test/src/math/f16sub_test.cpp | 13 +++++ libc/test/src/math/f16subl_test.cpp | 13 +++++ libc/test/src/math/smoke/CMakeLists.txt | 87 ++++++++++++++++++++++++++++ libc/test/src/math/smoke/f16add_test.cpp | 13 +++++ libc/test/src/math/smoke/f16addf128_test.cpp | 13 +++++ libc/test/src/math/smoke/f16addl_test.cpp | 13 +++++ libc/test/src/math/smoke/f16sub_test.cpp | 13 +++++ libc/test/src/math/smoke/f16subf128_test.cpp | 13 +++++ libc/test/src/math/smoke/f16subl_test.cpp | 13 +++++ 31 files changed, 605 insertions(+), 2 deletions(-) create mode 100644 libc/src/math/f16add.h create mode 100644 libc/src/math/f16addf128.h create mode 100644 libc/src/math/f16addl.h create mode 100644 libc/src/math/f16sub.h create mode 100644 libc/src/math/f16subf128.h create mode 100644 libc/src/math/f16subl.h create mode 100644 libc/src/math/generic/f16add.cpp create mode 100644 libc/src/math/generic/f16addf128.cpp create mode 100644 libc/src/math/generic/f16addl.cpp create mode 100644 libc/src/math/generic/f16sub.cpp create mode 100644 libc/src/math/generic/f16subf128.cpp create mode 100644 libc/src/math/generic/f16subl.cpp create mode 100644 libc/test/src/math/f16add_test.cpp create mode 100644 libc/test/src/math/f16addl_test.cpp create mode 100644 libc/test/src/math/f16sub_test.cpp create mode 100644 libc/test/src/math/f16subl_test.cpp create mode 100644 libc/test/src/math/smoke/f16add_test.cpp create mode 100644 libc/test/src/math/smoke/f16addf128_test.cpp create mode 100644 libc/test/src/math/smoke/f16addl_test.cpp create mode 100644 libc/test/src/math/smoke/f16sub_test.cpp create mode 100644 libc/test/src/math/smoke/f16subf128_test.cpp create mode 100644 libc/test/src/math/smoke/f16subl_test.cpp (limited to 'libc') diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index ff35e8f..940df63 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -508,12 +508,14 @@ if(LIBC_TYPES_HAS_FLOAT16) libc.src.math.canonicalizef16 libc.src.math.ceilf16 libc.src.math.copysignf16 + libc.src.math.f16add libc.src.math.f16addf libc.src.math.f16div libc.src.math.f16divf libc.src.math.f16fmaf libc.src.math.f16sqrt libc.src.math.f16sqrtf + libc.src.math.f16sub libc.src.math.f16subf libc.src.math.fabsf16 libc.src.math.fdimf16 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 3eefa12..09f04fb 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -538,7 +538,9 @@ if(LIBC_TYPES_HAS_FLOAT16) libc.src.math.canonicalizef16 libc.src.math.ceilf16 libc.src.math.copysignf16 + libc.src.math.f16add libc.src.math.f16addf + libc.src.math.f16addl libc.src.math.f16div libc.src.math.f16divf libc.src.math.f16divl @@ -548,7 +550,9 @@ if(LIBC_TYPES_HAS_FLOAT16) libc.src.math.f16sqrt libc.src.math.f16sqrtf libc.src.math.f16sqrtl + libc.src.math.f16sub libc.src.math.f16subf + libc.src.math.f16subl libc.src.math.fabsf16 libc.src.math.fdimf16 libc.src.math.floorf16 @@ -601,9 +605,11 @@ if(LIBC_TYPES_HAS_FLOAT16) if(LIBC_TYPES_HAS_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 mixed _Float16 and _Float128 entrypoints + libc.src.math.f16addf128 libc.src.math.f16divf128 libc.src.math.f16fmaf128 libc.src.math.f16sqrtf128 + libc.src.math.f16subf128 ) endif() endif() diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst index e4da3d4..04f63d0 100644 --- a/libc/docs/math/index.rst +++ b/libc/docs/math/index.rst @@ -124,13 +124,13 @@ Basic Operations +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | dsub | N/A | N/A | | N/A | | 7.12.14.2 | F.10.11 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| f16add | |check|\* | | | N/A | | 7.12.14.1 | F.10.11 | +| f16add | |check|\* | |check|\* | |check|\* | N/A | |check| | 7.12.14.1 | F.10.11 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | f16div | |check|\* | |check|\* | |check|\* | N/A | |check| | 7.12.14.4 | F.10.11 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | f16fma | |check| | |check| | |check| | N/A | |check| | 7.12.14.5 | F.10.11 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| f16sub | |check|\* | | | N/A | | 7.12.14.2 | F.10.11 | +| f16sub | |check|\* | |check|\* | |check|\* | N/A | |check| | 7.12.14.2 | F.10.11 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | fabs | |check| | |check| | |check| | |check| | |check| | 7.12.7.3 | F.10.4.3 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ diff --git a/libc/spec/llvm_libc_ext.td b/libc/spec/llvm_libc_ext.td index ff7831f..b994e7c 100644 --- a/libc/spec/llvm_libc_ext.td +++ b/libc/spec/llvm_libc_ext.td @@ -57,9 +57,13 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> { [], // Types [], // Enumerations [ + GuardedFunctionSpec<"f16add", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"f16addf", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, + GuardedFunctionSpec<"f16addl", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, + GuardedFunctionSpec<"f16sub", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"f16subf", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, + GuardedFunctionSpec<"f16subl", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"f16div", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"f16divf", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index 6e59062..9ff40bf 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -729,6 +729,10 @@ def StdC : StandardSpec<"stdc"> { GuardedFunctionSpec<"setpayloadsigf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, + GuardedFunctionSpec<"f16addf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, + + GuardedFunctionSpec<"f16subf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, + GuardedFunctionSpec<"f16divf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, GuardedFunctionSpec<"f16sqrtf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index 5b20913..0983d26 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -99,7 +99,10 @@ add_math_entrypoint_object(exp10f) add_math_entrypoint_object(expm1) add_math_entrypoint_object(expm1f) +add_math_entrypoint_object(f16add) add_math_entrypoint_object(f16addf) +add_math_entrypoint_object(f16addl) +add_math_entrypoint_object(f16addf128) add_math_entrypoint_object(f16div) add_math_entrypoint_object(f16divf) @@ -116,7 +119,10 @@ add_math_entrypoint_object(f16sqrtf) add_math_entrypoint_object(f16sqrtl) add_math_entrypoint_object(f16sqrtf128) +add_math_entrypoint_object(f16sub) add_math_entrypoint_object(f16subf) +add_math_entrypoint_object(f16subl) +add_math_entrypoint_object(f16subf128) add_math_entrypoint_object(fabs) add_math_entrypoint_object(fabsf) diff --git a/libc/src/math/f16add.h b/libc/src/math/f16add.h new file mode 100644 index 0000000..763a078 --- /dev/null +++ b/libc/src/math/f16add.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16add ------------------------*- 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_MATH_F16ADD_H +#define LLVM_LIBC_SRC_MATH_F16ADD_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16add(double x, double y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16ADD_H diff --git a/libc/src/math/f16addf128.h b/libc/src/math/f16addf128.h new file mode 100644 index 0000000..284ce1d --- /dev/null +++ b/libc/src/math/f16addf128.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16addf128 --------------------*- 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_MATH_F16ADDF128_H +#define LLVM_LIBC_SRC_MATH_F16ADDF128_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16addf128(float128 x, float128 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16ADDF128_H diff --git a/libc/src/math/f16addl.h b/libc/src/math/f16addl.h new file mode 100644 index 0000000..6a7267a --- /dev/null +++ b/libc/src/math/f16addl.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16addl -----------------------*- 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_MATH_F16ADDL_H +#define LLVM_LIBC_SRC_MATH_F16ADDL_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16addl(long double x, long double y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16ADDL_H diff --git a/libc/src/math/f16sub.h b/libc/src/math/f16sub.h new file mode 100644 index 0000000..66f82da --- /dev/null +++ b/libc/src/math/f16sub.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16sub ------------------------*- 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_MATH_F16SUB_H +#define LLVM_LIBC_SRC_MATH_F16SUB_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16sub(double x, double y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16SUB_H diff --git a/libc/src/math/f16subf128.h b/libc/src/math/f16subf128.h new file mode 100644 index 0000000..eb67429 --- /dev/null +++ b/libc/src/math/f16subf128.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16subf128 --------------------*- 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_MATH_F16SUBF128_H +#define LLVM_LIBC_SRC_MATH_F16SUBF128_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16subf128(float128 x, float128 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16SUBF128_H diff --git a/libc/src/math/f16subl.h b/libc/src/math/f16subl.h new file mode 100644 index 0000000..43b44a5 --- /dev/null +++ b/libc/src/math/f16subl.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16subl -----------------------*- 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_MATH_F16SUBL_H +#define LLVM_LIBC_SRC_MATH_F16SUBL_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16subl(long double x, long double y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16SUBL_H diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index d6ea8c5..2e4ed8f 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -3796,6 +3796,19 @@ add_entrypoint_object( ) add_entrypoint_object( + f16add + SRCS + f16add.cpp + HDRS + ../f16add.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( f16addf SRCS f16addf.cpp @@ -3809,6 +3822,45 @@ add_entrypoint_object( ) add_entrypoint_object( + f16addl + SRCS + f16addl.cpp + HDRS + ../f16addl.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( + f16addf128 + SRCS + f16addf128.cpp + HDRS + ../f16addf128.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( + f16sub + SRCS + f16sub.cpp + HDRS + ../f16sub.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( f16subf SRCS f16subf.cpp @@ -3822,6 +3874,32 @@ add_entrypoint_object( ) add_entrypoint_object( + f16subl + SRCS + f16subl.cpp + HDRS + ../f16subl.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( + f16subf128 + SRCS + f16subf128.cpp + HDRS + ../f16subf128.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( f16div SRCS f16div.cpp diff --git a/libc/src/math/generic/f16add.cpp b/libc/src/math/generic/f16add.cpp new file mode 100644 index 0000000..ef9b43e --- /dev/null +++ b/libc/src/math/generic/f16add.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16add 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/math/f16add.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16add, (double x, double y)) { + return fputil::generic::add(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16addf128.cpp b/libc/src/math/generic/f16addf128.cpp new file mode 100644 index 0000000..61c458f --- /dev/null +++ b/libc/src/math/generic/f16addf128.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16addf128 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/math/f16addf128.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16addf128, (float128 x, float128 y)) { + return fputil::generic::add(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16addl.cpp b/libc/src/math/generic/f16addl.cpp new file mode 100644 index 0000000..d32d09d --- /dev/null +++ b/libc/src/math/generic/f16addl.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16addl 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/math/f16addl.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16addl, (long double x, long double y)) { + return fputil::generic::add(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16sub.cpp b/libc/src/math/generic/f16sub.cpp new file mode 100644 index 0000000..114c8ad --- /dev/null +++ b/libc/src/math/generic/f16sub.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16sub 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/math/f16sub.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16sub, (double x, double y)) { + return fputil::generic::sub(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16subf128.cpp b/libc/src/math/generic/f16subf128.cpp new file mode 100644 index 0000000..1f9ff28 --- /dev/null +++ b/libc/src/math/generic/f16subf128.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16subf128 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/math/f16subf128.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16subf128, (float128 x, float128 y)) { + return fputil::generic::sub(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16subl.cpp b/libc/src/math/generic/f16subl.cpp new file mode 100644 index 0000000..31970af --- /dev/null +++ b/libc/src/math/generic/f16subl.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16subl 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/math/f16subl.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16subl, (long double x, long double y)) { + return fputil::generic::sub(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt index 637e672..f919634 100644 --- a/libc/test/src/math/CMakeLists.txt +++ b/libc/test/src/math/CMakeLists.txt @@ -1997,6 +1997,19 @@ add_fp_unittest( ) add_fp_unittest( + f16add_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + f16add_test.cpp + HDRS + AddTest.h + DEPENDS + libc.src.math.f16add +) + +add_fp_unittest( f16addf_test NEED_MPFR SUITE @@ -2010,6 +2023,32 @@ add_fp_unittest( ) add_fp_unittest( + f16addl_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + f16addl_test.cpp + HDRS + AddTest.h + DEPENDS + libc.src.math.f16addl +) + +add_fp_unittest( + f16sub_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + f16sub_test.cpp + HDRS + SubTest.h + DEPENDS + libc.src.math.f16sub +) + +add_fp_unittest( f16subf_test NEED_MPFR SUITE @@ -2023,6 +2062,19 @@ add_fp_unittest( ) add_fp_unittest( + f16subl_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + f16subl_test.cpp + HDRS + SubTest.h + DEPENDS + libc.src.math.f16subl +) + +add_fp_unittest( f16div_test NEED_MPFR SUITE diff --git a/libc/test/src/math/f16add_test.cpp b/libc/test/src/math/f16add_test.cpp new file mode 100644 index 0000000..c47ece2 --- /dev/null +++ b/libc/test/src/math/f16add_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16add ----------------------------------------------===// +// +// 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 "AddTest.h" + +#include "src/math/f16add.h" + +LIST_ADD_TESTS(float16, double, LIBC_NAMESPACE::f16add) diff --git a/libc/test/src/math/f16addl_test.cpp b/libc/test/src/math/f16addl_test.cpp new file mode 100644 index 0000000..f8e0d9b --- /dev/null +++ b/libc/test/src/math/f16addl_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16addl ---------------------------------------------===// +// +// 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 "AddTest.h" + +#include "src/math/f16addl.h" + +LIST_ADD_TESTS(float16, long double, LIBC_NAMESPACE::f16addl) diff --git a/libc/test/src/math/f16sub_test.cpp b/libc/test/src/math/f16sub_test.cpp new file mode 100644 index 0000000..37b9709 --- /dev/null +++ b/libc/test/src/math/f16sub_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16sub ----------------------------------------------===/ +// +// 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 "SubTest.h" + +#include "src/math/f16sub.h" + +LIST_SUB_TESTS(float16, double, LIBC_NAMESPACE::f16sub) diff --git a/libc/test/src/math/f16subl_test.cpp b/libc/test/src/math/f16subl_test.cpp new file mode 100644 index 0000000..c41e6e9 --- /dev/null +++ b/libc/test/src/math/f16subl_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16subl ---------------------------------------------===// +// +// 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 "SubTest.h" + +#include "src/math/f16subl.h" + +LIST_SUB_TESTS(float16, long double, LIBC_NAMESPACE::f16subl) diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index 1b269ed..f244e7a 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -3644,6 +3644,21 @@ add_fp_unittest( ) add_fp_unittest( + f16add_test + SUITE + libc-math-smoke-tests + SRCS + f16add_test.cpp + HDRS + AddTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.__support.FPUtil.basic_operations + libc.src.math.f16add +) + +add_fp_unittest( f16addf_test SUITE libc-math-smoke-tests @@ -3659,6 +3674,50 @@ add_fp_unittest( ) add_fp_unittest( + f16addl_test + SUITE + libc-math-smoke-tests + SRCS + f16addl_test.cpp + HDRS + AddTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.__support.FPUtil.basic_operations + libc.src.math.f16addl +) + +add_fp_unittest( + f16addf128_test + SUITE + libc-math-smoke-tests + SRCS + f16addf128_test.cpp + HDRS + AddTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.__support.FPUtil.basic_operations + libc.src.math.f16addf128 +) + +add_fp_unittest( + f16sub_test + SUITE + libc-math-smoke-tests + SRCS + f16sub_test.cpp + HDRS + SubTest.h + DEPENDS + libc.hdr.fenv_macros + libc.src.__support.FPUtil.basic_operations + libc.src.math.f16sub +) + +add_fp_unittest( f16subf_test SUITE libc-math-smoke-tests @@ -3673,6 +3732,34 @@ add_fp_unittest( ) add_fp_unittest( + f16subl_test + SUITE + libc-math-smoke-tests + SRCS + f16subl_test.cpp + HDRS + SubTest.h + DEPENDS + libc.hdr.fenv_macros + libc.src.__support.FPUtil.basic_operations + libc.src.math.f16subl +) + +add_fp_unittest( + f16subf128_test + SUITE + libc-math-smoke-tests + SRCS + f16subf128_test.cpp + HDRS + SubTest.h + DEPENDS + libc.hdr.fenv_macros + libc.src.__support.FPUtil.basic_operations + libc.src.math.f16subf128 +) + +add_fp_unittest( f16div_test SUITE libc-math-smoke-tests diff --git a/libc/test/src/math/smoke/f16add_test.cpp b/libc/test/src/math/smoke/f16add_test.cpp new file mode 100644 index 0000000..c47ece2 --- /dev/null +++ b/libc/test/src/math/smoke/f16add_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16add ----------------------------------------------===// +// +// 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 "AddTest.h" + +#include "src/math/f16add.h" + +LIST_ADD_TESTS(float16, double, LIBC_NAMESPACE::f16add) diff --git a/libc/test/src/math/smoke/f16addf128_test.cpp b/libc/test/src/math/smoke/f16addf128_test.cpp new file mode 100644 index 0000000..8ed123b --- /dev/null +++ b/libc/test/src/math/smoke/f16addf128_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16addf128 ------------------------------------------===// +// +// 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 "AddTest.h" + +#include "src/math/f16addf128.h" + +LIST_ADD_TESTS(float16, float128, LIBC_NAMESPACE::f16addf128) diff --git a/libc/test/src/math/smoke/f16addl_test.cpp b/libc/test/src/math/smoke/f16addl_test.cpp new file mode 100644 index 0000000..f8e0d9b --- /dev/null +++ b/libc/test/src/math/smoke/f16addl_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16addl ---------------------------------------------===// +// +// 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 "AddTest.h" + +#include "src/math/f16addl.h" + +LIST_ADD_TESTS(float16, long double, LIBC_NAMESPACE::f16addl) diff --git a/libc/test/src/math/smoke/f16sub_test.cpp b/libc/test/src/math/smoke/f16sub_test.cpp new file mode 100644 index 0000000..4ab347b --- /dev/null +++ b/libc/test/src/math/smoke/f16sub_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16sub ----------------------------------------------===// +// +// 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 "SubTest.h" + +#include "src/math/f16sub.h" + +LIST_SUB_TESTS(float16, double, LIBC_NAMESPACE::f16sub) diff --git a/libc/test/src/math/smoke/f16subf128_test.cpp b/libc/test/src/math/smoke/f16subf128_test.cpp new file mode 100644 index 0000000..4936d89 --- /dev/null +++ b/libc/test/src/math/smoke/f16subf128_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16subf128 ------------------------------------------===// +// +// 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 "SubTest.h" + +#include "src/math/f16subf128.h" + +LIST_SUB_TESTS(float16, float128, LIBC_NAMESPACE::f16subf128) diff --git a/libc/test/src/math/smoke/f16subl_test.cpp b/libc/test/src/math/smoke/f16subl_test.cpp new file mode 100644 index 0000000..c41e6e9 --- /dev/null +++ b/libc/test/src/math/smoke/f16subl_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for f16subl ---------------------------------------------===// +// +// 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 "SubTest.h" + +#include "src/math/f16subl.h" + +LIST_SUB_TESTS(float16, long double, LIBC_NAMESPACE::f16subl) -- cgit v1.1