diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 13a4445aca76b2..33ecff813a1fbd 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -506,7 +506,15 @@ if(LIBC_TYPES_HAS_FLOAT16) libc.src.math.fdimf16 libc.src.math.floorf16 libc.src.math.fmaxf16 + libc.src.math.fmaximumf16 + libc.src.math.fmaximum_magf16 + libc.src.math.fmaximum_mag_numf16 + libc.src.math.fmaximum_numf16 libc.src.math.fminf16 + libc.src.math.fminimumf16 + libc.src.math.fminimum_magf16 + libc.src.math.fminimum_mag_numf16 + libc.src.math.fminimum_numf16 libc.src.math.fromfpf16 libc.src.math.fromfpxf16 libc.src.math.llrintf16 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 9db044e953f31b..ebacb1c59ceec2 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -539,7 +539,15 @@ if(LIBC_TYPES_HAS_FLOAT16) libc.src.math.fdimf16 libc.src.math.floorf16 libc.src.math.fmaxf16 + libc.src.math.fmaximumf16 + libc.src.math.fmaximum_magf16 + libc.src.math.fmaximum_mag_numf16 + libc.src.math.fmaximum_numf16 libc.src.math.fminf16 + libc.src.math.fminimumf16 + libc.src.math.fminimum_magf16 + libc.src.math.fminimum_mag_numf16 + libc.src.math.fminimum_numf16 libc.src.math.fromfpf16 libc.src.math.fromfpxf16 libc.src.math.llrintf16 diff --git a/libc/docs/c23.rst b/libc/docs/c23.rst index fa7a59893f89c6..71232cc004c709 100644 --- a/libc/docs/c23.rst +++ b/libc/docs/c23.rst @@ -62,12 +62,14 @@ Additions: * nextup* |check| * nextdown* |check| * canonicalize* |check| - * fmaximum* - * fminimum* - * fmaximum_mag* - * fminimum_mag* - * fmaximum_mag_num* - * fminimum_mag_num* + * fmaximum* |check| + * fminimum* |check| + * fmaximum_mag* |check| + * fminimum_mag* |check| + * fmaximum_num* |check| + * fminimum_num* |check| + * fmaximum_mag_num* |check| + * fminimum_mag_num* |check| * fadd* * fsub* * fmul* diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst index 8c3c07a35b9355..b9507f0887cd78 100644 --- a/libc/docs/math/index.rst +++ b/libc/docs/math/index.rst @@ -138,23 +138,23 @@ Basic Operations +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | fmax | |check| | |check| | |check| | |check| | |check| | 7.12.12.2 | F.10.9.2 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| fmaximum | |check| | |check| | |check| | | |check| | 7.12.12.4 | F.10.9.4 | +| fmaximum | |check| | |check| | |check| | |check| | |check| | 7.12.12.4 | F.10.9.4 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| fmaximum_mag | |check| | |check| | |check| | | |check| | 7.12.12.6 | F.10.9.4 | +| fmaximum_mag | |check| | |check| | |check| | |check| | |check| | 7.12.12.6 | F.10.9.4 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| fmaximum_mag_num | |check| | |check| | |check| | | |check| | 7.12.12.10 | F.10.9.5 | +| fmaximum_mag_num | |check| | |check| | |check| | |check| | |check| | 7.12.12.10 | F.10.9.5 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| fmaximum_num | |check| | |check| | |check| | | |check| | 7.12.12.8 | F.10.9.5 | +| fmaximum_num | |check| | |check| | |check| | |check| | |check| | 7.12.12.8 | F.10.9.5 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | fmin | |check| | |check| | |check| | |check| | |check| | 7.12.12.3 | F.10.9.3 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| fminimum | |check| | |check| | |check| | | |check| | 7.12.12.5 | F.10.9.4 | +| fminimum | |check| | |check| | |check| | |check| | |check| | 7.12.12.5 | F.10.9.4 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| fminimum_mag | |check| | |check| | |check| | | |check| | 7.12.12.7 | F.10.9.4 | +| fminimum_mag | |check| | |check| | |check| | |check| | |check| | 7.12.12.7 | F.10.9.4 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| fminimum_mag_num | |check| | |check| | |check| | | |check| | 7.12.12.11 | F.10.9.5 | +| fminimum_mag_num | |check| | |check| | |check| | |check| | |check| | 7.12.12.11 | F.10.9.5 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| fminimum_num | |check| | |check| | |check| | | |check| | 7.12.12.9 | F.10.9.5 | +| fminimum_num | |check| | |check| | |check| | |check| | |check| | 7.12.12.9 | F.10.9.5 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | fmod | |check| | |check| | |check| | | |check| | 7.12.10.1 | F.10.7.1 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index f867a3d27403a0..210f2a13251697 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -427,41 +427,49 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"fmaximum", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaximumf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaximuml", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"fmaximumf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fmaximumf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fmaximum_num", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaximum_numf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaximum_numl", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"fmaximum_numf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fmaximum_numf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fmaximum_mag", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaximum_magf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaximum_magl", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"fmaximum_magf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fmaximum_magf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fmaximum_mag_num", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaximum_mag_numf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaximum_mag_numl", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"fmaximum_mag_numf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fmaximum_mag_numf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fminimum", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fminimumf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fminimuml", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"fminimumf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fminimumf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fminimum_num", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fminimum_numf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fmaximum_numl", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"fminimum_numf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fminimum_numf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fminimum_mag", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fminimum_magf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fminimum_magl", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"fminimum_magf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fminimum_magf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fminimum_mag_num", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fminimum_mag_numf", RetValSpec, [ArgSpec, ArgSpec]>, FunctionSpec<"fminimum_mag_numl", RetValSpec, [ArgSpec, ArgSpec]>, + GuardedFunctionSpec<"fminimum_mag_numf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fminimum_mag_numf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"fma", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index 498466692fccad..7a349ddc537249 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -135,41 +135,49 @@ add_math_entrypoint_object(fminf16) add_math_entrypoint_object(fmaximum) add_math_entrypoint_object(fmaximumf) add_math_entrypoint_object(fmaximuml) +add_math_entrypoint_object(fmaximumf16) add_math_entrypoint_object(fmaximumf128) add_math_entrypoint_object(fmaximum_num) add_math_entrypoint_object(fmaximum_numf) add_math_entrypoint_object(fmaximum_numl) +add_math_entrypoint_object(fmaximum_numf16) add_math_entrypoint_object(fmaximum_numf128) add_math_entrypoint_object(fmaximum_mag) add_math_entrypoint_object(fmaximum_magf) add_math_entrypoint_object(fmaximum_magl) +add_math_entrypoint_object(fmaximum_magf16) add_math_entrypoint_object(fmaximum_magf128) add_math_entrypoint_object(fmaximum_mag_num) add_math_entrypoint_object(fmaximum_mag_numf) add_math_entrypoint_object(fmaximum_mag_numl) +add_math_entrypoint_object(fmaximum_mag_numf16) add_math_entrypoint_object(fmaximum_mag_numf128) add_math_entrypoint_object(fminimum) add_math_entrypoint_object(fminimumf) add_math_entrypoint_object(fminimuml) +add_math_entrypoint_object(fminimumf16) add_math_entrypoint_object(fminimumf128) add_math_entrypoint_object(fminimum_num) add_math_entrypoint_object(fminimum_numf) add_math_entrypoint_object(fminimum_numl) +add_math_entrypoint_object(fminimum_numf16) add_math_entrypoint_object(fminimum_numf128) add_math_entrypoint_object(fminimum_mag) add_math_entrypoint_object(fminimum_magf) add_math_entrypoint_object(fminimum_magl) +add_math_entrypoint_object(fminimum_magf16) add_math_entrypoint_object(fminimum_magf128) add_math_entrypoint_object(fminimum_mag_num) add_math_entrypoint_object(fminimum_mag_numf) add_math_entrypoint_object(fminimum_mag_numl) +add_math_entrypoint_object(fminimum_mag_numf16) add_math_entrypoint_object(fminimum_mag_numf128) add_math_entrypoint_object(fmod) diff --git a/libc/src/math/fmaximum_mag_numf16.h b/libc/src/math/fmaximum_mag_numf16.h new file mode 100644 index 00000000000000..4c963d4dccc738 --- /dev/null +++ b/libc/src/math/fmaximum_mag_numf16.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fmaximum_mag_numf16 -----------*- 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_FMAXIMUM_MAG_NUMF16_H +#define LLVM_LIBC_SRC_MATH_FMAXIMUM_MAG_NUMF16_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 fmaximum_mag_numf16(float16 x, float16 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_FMAXIMUM_MAG_NUMF16_H diff --git a/libc/src/math/fmaximum_magf16.h b/libc/src/math/fmaximum_magf16.h new file mode 100644 index 00000000000000..e5f57d3b7f1df4 --- /dev/null +++ b/libc/src/math/fmaximum_magf16.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fmaximum_magf16 ---------------*- 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_FMAXIMUM_MAGF16_H +#define LLVM_LIBC_SRC_MATH_FMAXIMUM_MAGF16_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 fmaximum_magf16(float16 x, float16 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_FMAXIMUM_MAGF16_H diff --git a/libc/src/math/fmaximum_numf16.h b/libc/src/math/fmaximum_numf16.h new file mode 100644 index 00000000000000..b450a459564831 --- /dev/null +++ b/libc/src/math/fmaximum_numf16.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fmaximum_numf16 ---------------*- 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_FMAXIMUM_NUMF16_H +#define LLVM_LIBC_SRC_MATH_FMAXIMUM_NUMF16_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 fmaximum_numf16(float16 x, float16 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_FMAXIMUM_NUMF16_H diff --git a/libc/src/math/fmaximumf16.h b/libc/src/math/fmaximumf16.h new file mode 100644 index 00000000000000..806339fde68309 --- /dev/null +++ b/libc/src/math/fmaximumf16.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fmaximumf16 -------------------*- 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_FMAXIMUMF16_H +#define LLVM_LIBC_SRC_MATH_FMAXIMUMF16_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 fmaximumf16(float16 x, float16 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_FMAXIMUMF16_H diff --git a/libc/src/math/fminimum_mag_numf16.h b/libc/src/math/fminimum_mag_numf16.h new file mode 100644 index 00000000000000..0fd314b2f5a222 --- /dev/null +++ b/libc/src/math/fminimum_mag_numf16.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fminimum_mag_numf16 -----------*- 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_FMINIMUM_MAG_NUMF16_H +#define LLVM_LIBC_SRC_MATH_FMINIMUM_MAG_NUMF16_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 fminimum_mag_numf16(float16 x, float16 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_FMINIMUM_MAG_NUMF16_H diff --git a/libc/src/math/fminimum_magf16.h b/libc/src/math/fminimum_magf16.h new file mode 100644 index 00000000000000..27673555403c93 --- /dev/null +++ b/libc/src/math/fminimum_magf16.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fminimum_magf16 ---------------*- 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_FMINIMUM_MAGF16_H +#define LLVM_LIBC_SRC_MATH_FMINIMUM_MAGF16_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 fminimum_magf16(float16 x, float16 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_FMINIMUM_MAGF16_H diff --git a/libc/src/math/fminimum_numf16.h b/libc/src/math/fminimum_numf16.h new file mode 100644 index 00000000000000..598ff9d3c32d23 --- /dev/null +++ b/libc/src/math/fminimum_numf16.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fminimum_numf16 ---------------*- 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_FMINIMUM_NUMF16_H +#define LLVM_LIBC_SRC_MATH_FMINIMUM_NUMF16_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 fminimum_numf16(float16 x, float16 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_FMINIMUM_NUMF16_H diff --git a/libc/src/math/fminimumf16.h b/libc/src/math/fminimumf16.h new file mode 100644 index 00000000000000..86dd240ae406d2 --- /dev/null +++ b/libc/src/math/fminimumf16.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fminimumf16 -------------------*- 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_FMINIMUMF16_H +#define LLVM_LIBC_SRC_MATH_FMINIMUMF16_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 fminimumf16(float16 x, float16 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_FMINIMUMF16_H diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index c183f09fa5e3db..b1d786fc6b29f1 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -1894,6 +1894,19 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + fmaximumf16 + SRCS + fmaximumf16.cpp + HDRS + ../fmaximumf16.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( fmaximumf128 SRCS @@ -1943,6 +1956,19 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + fmaximum_numf16 + SRCS + fmaximum_numf16.cpp + HDRS + ../fmaximum_numf16.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( fmaximum_numf128 SRCS @@ -1992,6 +2018,19 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + fmaximum_magf16 + SRCS + fmaximum_magf16.cpp + HDRS + ../fmaximum_magf16.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( fmaximum_magf128 SRCS @@ -2005,7 +2044,6 @@ add_entrypoint_object( -O3 ) - add_entrypoint_object( fmaximum_mag_num SRCS @@ -2042,6 +2080,19 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + fmaximum_mag_numf16 + SRCS + fmaximum_mag_numf16.cpp + HDRS + ../fmaximum_mag_numf16.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( fmaximum_mag_numf128 SRCS @@ -2091,6 +2142,19 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + fminimumf16 + SRCS + fminimumf16.cpp + HDRS + ../fminimumf16.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( fminimumf128 SRCS @@ -2140,6 +2204,19 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + fminimum_numf16 + SRCS + fminimum_numf16.cpp + HDRS + ../fminimum_numf16.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( fminimum_numf128 SRCS @@ -2189,6 +2266,19 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + fminimum_magf16 + SRCS + fminimum_magf16.cpp + HDRS + ../fminimum_magf16.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( fminimum_magf128 SRCS @@ -2202,7 +2292,6 @@ add_entrypoint_object( -O3 ) - add_entrypoint_object( fminimum_mag_num SRCS @@ -2239,6 +2328,19 @@ add_entrypoint_object( -O2 ) +add_entrypoint_object( + fminimum_mag_numf16 + SRCS + fminimum_mag_numf16.cpp + HDRS + ../fminimum_mag_numf16.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.basic_operations + COMPILE_OPTIONS + -O3 +) + add_entrypoint_object( fminimum_mag_numf128 SRCS diff --git a/libc/src/math/generic/fmaximum_mag_numf16.cpp b/libc/src/math/generic/fmaximum_mag_numf16.cpp new file mode 100644 index 00000000000000..5055802c4cf85b --- /dev/null +++ b/libc/src/math/generic/fmaximum_mag_numf16.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of fmaximum_mag_numf16 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/fmaximum_mag_numf16.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, fmaximum_mag_numf16, (float16 x, float16 y)) { + return fputil::fmaximum_mag_num(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/fmaximum_magf16.cpp b/libc/src/math/generic/fmaximum_magf16.cpp new file mode 100644 index 00000000000000..fbd5eaccf30931 --- /dev/null +++ b/libc/src/math/generic/fmaximum_magf16.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of fmaximum_magf16 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/fmaximum_magf16.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, fmaximum_magf16, (float16 x, float16 y)) { + return fputil::fmaximum_mag(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/fmaximum_numf16.cpp b/libc/src/math/generic/fmaximum_numf16.cpp new file mode 100644 index 00000000000000..187cfbeee6e2d8 --- /dev/null +++ b/libc/src/math/generic/fmaximum_numf16.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of fmaximum_numf16 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/fmaximum_numf16.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, fmaximum_numf16, (float16 x, float16 y)) { + return fputil::fmaximum_num(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/fmaximumf16.cpp b/libc/src/math/generic/fmaximumf16.cpp new file mode 100644 index 00000000000000..9e194d2ecef693 --- /dev/null +++ b/libc/src/math/generic/fmaximumf16.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of fmaximumf16 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/fmaximumf16.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, fmaximumf16, (float16 x, float16 y)) { + return fputil::fmaximum(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/fminimum_mag_numf16.cpp b/libc/src/math/generic/fminimum_mag_numf16.cpp new file mode 100644 index 00000000000000..1a893c6c4bbc18 --- /dev/null +++ b/libc/src/math/generic/fminimum_mag_numf16.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of fminimum_mag_numf16 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/fminimum_mag_numf16.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, fminimum_mag_numf16, (float16 x, float16 y)) { + return fputil::fminimum_mag_num(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/fminimum_magf16.cpp b/libc/src/math/generic/fminimum_magf16.cpp new file mode 100644 index 00000000000000..45183a963e2d88 --- /dev/null +++ b/libc/src/math/generic/fminimum_magf16.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of fminimum_magf16 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/fminimum_magf16.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, fminimum_magf16, (float16 x, float16 y)) { + return fputil::fminimum_mag(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/fminimum_numf16.cpp b/libc/src/math/generic/fminimum_numf16.cpp new file mode 100644 index 00000000000000..825ad3e7b63af0 --- /dev/null +++ b/libc/src/math/generic/fminimum_numf16.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of fminimum_numf16 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/fminimum_numf16.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, fminimum_numf16, (float16 x, float16 y)) { + return fputil::fminimum_num(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/fminimumf16.cpp b/libc/src/math/generic/fminimumf16.cpp new file mode 100644 index 00000000000000..16f738be7e58c5 --- /dev/null +++ b/libc/src/math/generic/fminimumf16.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of fminimumf16 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/fminimumf16.h" +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, fminimumf16, (float16 x, float16 y)) { + return fputil::fminimum(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index 16c6537df2ab8e..110fa1de97d6da 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -1845,6 +1845,21 @@ add_fp_unittest( FMaximumTest.h DEPENDS libc.src.math.fmaximuml + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.fp_bits +) + +add_fp_unittest( + fmaximumf16_test + SUITE + libc-math-smoke-tests + SRCS + fmaximumf16_test.cpp + HDRS + FMaximumTest.h + DEPENDS + libc.src.math.fmaximumf16 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -1858,6 +1873,7 @@ add_fp_unittest( FMaximumTest.h DEPENDS libc.src.math.fmaximumf128 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -1871,6 +1887,7 @@ add_fp_unittest( FMaximumTest.h DEPENDS libc.src.math.fmaximum + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -1884,6 +1901,7 @@ add_fp_unittest( FMaximumTest.h DEPENDS libc.src.math.fmaximumf + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -1897,6 +1915,7 @@ add_fp_unittest( FMaximumNumTest.h DEPENDS libc.src.math.fmaximum_numf + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -1910,6 +1929,7 @@ add_fp_unittest( FMaximumNumTest.h DEPENDS libc.src.math.fmaximum_num + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -1923,6 +1943,21 @@ add_fp_unittest( FMaximumNumTest.h DEPENDS libc.src.math.fmaximum_numl + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.fp_bits +) + +add_fp_unittest( + fmaximum_numf16_test + SUITE + libc-math-smoke-tests + SRCS + fmaximum_numf16_test.cpp + HDRS + FMaximumNumTest.h + DEPENDS + libc.src.math.fmaximum_numf16 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -1936,6 +1971,7 @@ add_fp_unittest( FMaximumNumTest.h DEPENDS libc.src.math.fmaximum_numf128 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -1949,6 +1985,8 @@ add_fp_unittest( FMaximumMagTest.h DEPENDS libc.src.math.fmaximum_magf + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.fp_bits ) @@ -1962,6 +2000,8 @@ add_fp_unittest( FMaximumMagTest.h DEPENDS libc.src.math.fmaximum_mag + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.fp_bits ) @@ -1975,6 +2015,23 @@ add_fp_unittest( FMaximumMagTest.h DEPENDS libc.src.math.fmaximum_magl + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.basic_operations + libc.src.__support.FPUtil.fp_bits +) + +add_fp_unittest( + fmaximum_magf16_test + SUITE + libc-math-smoke-tests + SRCS + fmaximum_magf16_test.cpp + HDRS + FMaximumMagTest.h + DEPENDS + libc.src.math.fmaximum_magf16 + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.fp_bits ) @@ -1988,10 +2045,11 @@ add_fp_unittest( FMaximumMagTest.h DEPENDS libc.src.math.fmaximum_magf128 + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.fp_bits ) - add_fp_unittest( fmaximum_mag_numf_test SUITE @@ -2002,6 +2060,7 @@ add_fp_unittest( FMaximumMagNumTest.h DEPENDS libc.src.math.fmaximum_mag_numf + libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.fp_bits ) @@ -2015,6 +2074,7 @@ add_fp_unittest( FMaximumMagNumTest.h DEPENDS libc.src.math.fmaximum_mag_num + libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.fp_bits ) @@ -2028,6 +2088,21 @@ add_fp_unittest( FMaximumMagNumTest.h DEPENDS libc.src.math.fmaximum_mag_numl + libc.src.__support.FPUtil.basic_operations + libc.src.__support.FPUtil.fp_bits +) + +add_fp_unittest( + fmaximum_mag_numf16_test + SUITE + libc-math-smoke-tests + SRCS + fmaximum_mag_numf16_test.cpp + HDRS + FMaximumMagNumTest.h + DEPENDS + libc.src.math.fmaximum_mag_numf16 + libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.fp_bits ) @@ -2041,6 +2116,7 @@ add_fp_unittest( FMaximumMagNumTest.h DEPENDS libc.src.math.fmaximum_mag_numf128 + libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.fp_bits ) @@ -2054,6 +2130,21 @@ add_fp_unittest( FMinimumTest.h DEPENDS libc.src.math.fminimuml + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.fp_bits +) + +add_fp_unittest( + fminimumf16_test + SUITE + libc-math-smoke-tests + SRCS + fminimumf16_test.cpp + HDRS + FMinimumTest.h + DEPENDS + libc.src.math.fminimumf16 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2067,6 +2158,7 @@ add_fp_unittest( FMinimumTest.h DEPENDS libc.src.math.fminimumf128 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2080,6 +2172,7 @@ add_fp_unittest( FMinimumTest.h DEPENDS libc.src.math.fminimum + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2093,6 +2186,7 @@ add_fp_unittest( FMinimumTest.h DEPENDS libc.src.math.fminimumf + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2106,6 +2200,7 @@ add_fp_unittest( FMinimumNumTest.h DEPENDS libc.src.math.fminimum_numf + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2119,6 +2214,7 @@ add_fp_unittest( FMinimumNumTest.h DEPENDS libc.src.math.fminimum_num + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2132,6 +2228,21 @@ add_fp_unittest( FMinimumNumTest.h DEPENDS libc.src.math.fminimum_numl + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.fp_bits +) + +add_fp_unittest( + fminimum_numf16_test + SUITE + libc-math-smoke-tests + SRCS + fminimum_numf16_test.cpp + HDRS + FMinimumNumTest.h + DEPENDS + libc.src.math.fminimum_numf16 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2145,6 +2256,7 @@ add_fp_unittest( FMinimumNumTest.h DEPENDS libc.src.math.fminimum_numf128 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2158,6 +2270,7 @@ add_fp_unittest( FMinimumMagTest.h DEPENDS libc.src.math.fminimum_magf + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2171,6 +2284,7 @@ add_fp_unittest( FMinimumMagTest.h DEPENDS libc.src.math.fminimum_mag + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2184,6 +2298,21 @@ add_fp_unittest( FMinimumMagTest.h DEPENDS libc.src.math.fminimum_magl + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.fp_bits +) + +add_fp_unittest( + fminimum_magf16_test + SUITE + libc-math-smoke-tests + SRCS + fminimum_magf16_test.cpp + HDRS + FMinimumMagTest.h + DEPENDS + libc.src.math.fminimum_magf16 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2197,10 +2326,10 @@ add_fp_unittest( FMinimumMagTest.h DEPENDS libc.src.math.fminimum_magf128 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) - add_fp_unittest( fminimum_mag_numf_test SUITE @@ -2211,6 +2340,7 @@ add_fp_unittest( FMinimumMagNumTest.h DEPENDS libc.src.math.fminimum_mag_numf + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2224,6 +2354,7 @@ add_fp_unittest( FMinimumMagNumTest.h DEPENDS libc.src.math.fminimum_mag_num + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2237,6 +2368,21 @@ add_fp_unittest( FMinimumMagNumTest.h DEPENDS libc.src.math.fminimum_mag_numl + libc.src.__support.CPP.algorithm + libc.src.__support.FPUtil.fp_bits +) + +add_fp_unittest( + fminimum_mag_numf16_test + SUITE + libc-math-smoke-tests + SRCS + fminimum_mag_numf16_test.cpp + HDRS + FMinimumMagNumTest.h + DEPENDS + libc.src.math.fminimum_mag_numf16 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) @@ -2250,6 +2396,7 @@ add_fp_unittest( FMinimumMagNumTest.h DEPENDS libc.src.math.fminimum_mag_numf128 + libc.src.__support.CPP.algorithm libc.src.__support.FPUtil.fp_bits ) diff --git a/libc/test/src/math/smoke/FMaximumMagNumTest.h b/libc/test/src/math/smoke/FMaximumMagNumTest.h index aafb6d2b0d5eac..726f87059fc64b 100644 --- a/libc/test/src/math/smoke/FMaximumMagNumTest.h +++ b/libc/test/src/math/smoke/FMaximumMagNumTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMMAG_NUMTEST_H #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMMAG_NUMTEST_H +#include "src/__support/CPP/algorithm.h" #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" @@ -68,10 +69,11 @@ class FMaximumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { } void testRange(FMaximumMagNumFunc func) { - constexpr StorageType COUNT = 100'001; - constexpr StorageType STEP = STORAGE_MAX / COUNT; - for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; - ++i, v += STEP, w -= STEP) { + constexpr int COUNT = 100'001; + constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max( + static_cast(STORAGE_MAX / COUNT), StorageType(1)); + StorageType v = 0, w = STORAGE_MAX; + for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) { FPBits xbits(v), ybits(w); if (xbits.is_inf_or_nan()) continue; @@ -82,11 +84,10 @@ class FMaximumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { if ((x == 0) && (y == 0)) continue; - if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y)) { + if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y)) EXPECT_FP_EQ(x, func(x, y)); - } else { + else EXPECT_FP_EQ(y, func(x, y)); - } } } }; diff --git a/libc/test/src/math/smoke/FMaximumMagTest.h b/libc/test/src/math/smoke/FMaximumMagTest.h index 7bb79a69be580f..b5b2c1ca79abc4 100644 --- a/libc/test/src/math/smoke/FMaximumMagTest.h +++ b/libc/test/src/math/smoke/FMaximumMagTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUM_MAGTEST_H #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUM_MAGTEST_H +#include "src/__support/CPP/algorithm.h" #include "src/__support/FPUtil/BasicOperations.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" @@ -56,10 +57,11 @@ class FMaximumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { } void testRange(FMaximumMagFunc func) { - constexpr StorageType COUNT = 100'001; - constexpr StorageType STEP = STORAGE_MAX / COUNT; - for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; - ++i, v += STEP, w -= STEP) { + constexpr int COUNT = 100'001; + constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max( + static_cast(STORAGE_MAX / COUNT), StorageType(1)); + StorageType v = 0, w = STORAGE_MAX; + for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) { FPBits xbits(v), ybits(w); if (xbits.is_inf_or_nan()) continue; @@ -70,11 +72,10 @@ class FMaximumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { if ((x == 0) && (y == 0)) continue; - if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y)) { + if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y)) EXPECT_FP_EQ(x, func(x, y)); - } else { + else EXPECT_FP_EQ(y, func(x, y)); - } } } }; diff --git a/libc/test/src/math/smoke/FMaximumNumTest.h b/libc/test/src/math/smoke/FMaximumNumTest.h index da0ea2c247a9ee..ec7913509d3942 100644 --- a/libc/test/src/math/smoke/FMaximumNumTest.h +++ b/libc/test/src/math/smoke/FMaximumNumTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMNUMTEST_H #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMNUMTEST_H +#include "src/__support/CPP/algorithm.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" @@ -67,10 +68,11 @@ class FMaximumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { } void testRange(FMaximumNumFunc func) { - constexpr StorageType COUNT = 100'001; - constexpr StorageType STEP = STORAGE_MAX / COUNT; - for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; - ++i, v += STEP, w -= STEP) { + constexpr int COUNT = 100'001; + constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max( + static_cast(STORAGE_MAX / COUNT), StorageType(1)); + StorageType v = 0, w = STORAGE_MAX; + for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) { FPBits xbits(v), ybits(w); if (xbits.is_inf_or_nan()) continue; @@ -81,11 +83,10 @@ class FMaximumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { if ((x == 0) && (y == 0)) continue; - if (x > y) { + if (x > y) EXPECT_FP_EQ(x, func(x, y)); - } else { + else EXPECT_FP_EQ(y, func(x, y)); - } } } }; diff --git a/libc/test/src/math/smoke/FMaximumTest.h b/libc/test/src/math/smoke/FMaximumTest.h index 1bd15163ed7529..94e4a343190a5b 100644 --- a/libc/test/src/math/smoke/FMaximumTest.h +++ b/libc/test/src/math/smoke/FMaximumTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMTEST_H #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMTEST_H +#include "src/__support/CPP/algorithm.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -55,10 +56,11 @@ class FMaximumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { } void testRange(FMaximumFunc func) { - constexpr StorageType COUNT = 100'001; - constexpr StorageType STEP = STORAGE_MAX / COUNT; - for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; - ++i, v += STEP, w -= STEP) { + constexpr int COUNT = 100'001; + constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max( + static_cast(STORAGE_MAX / COUNT), StorageType(1)); + StorageType v = 0, w = STORAGE_MAX; + for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) { FPBits xbits(v), ybits(w); if (xbits.is_inf_or_nan()) continue; @@ -69,11 +71,10 @@ class FMaximumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { if ((x == 0) && (y == 0)) continue; - if (x > y) { + if (x > y) EXPECT_FP_EQ(x, func(x, y)); - } else { + else EXPECT_FP_EQ(y, func(x, y)); - } } } }; diff --git a/libc/test/src/math/smoke/FMinimumMagNumTest.h b/libc/test/src/math/smoke/FMinimumMagNumTest.h index e4b8fd9e335311..2ceca6ff95bac2 100644 --- a/libc/test/src/math/smoke/FMinimumMagNumTest.h +++ b/libc/test/src/math/smoke/FMinimumMagNumTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMMAG_NUMTEST_H #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMMAG_NUMTEST_H +#include "src/__support/CPP/algorithm.h" #include "src/__support/FPUtil/BasicOperations.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" @@ -68,10 +69,11 @@ class FMinimumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { } void testRange(FMinimumMagNumFunc func) { - constexpr StorageType COUNT = 100'001; - constexpr StorageType STEP = STORAGE_MAX / COUNT; - for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; - ++i, v += STEP, w -= STEP) { + constexpr int COUNT = 100'001; + constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max( + static_cast(STORAGE_MAX / COUNT), StorageType(1)); + StorageType v = 0, w = STORAGE_MAX; + for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) { FPBits xbits(v), ybits(w); if (xbits.is_inf_or_nan()) continue; @@ -82,11 +84,10 @@ class FMinimumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { if ((x == 0) && (y == 0)) continue; - if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y)) { + if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y)) EXPECT_FP_EQ(y, func(x, y)); - } else { + else EXPECT_FP_EQ(x, func(x, y)); - } } } }; diff --git a/libc/test/src/math/smoke/FMinimumMagTest.h b/libc/test/src/math/smoke/FMinimumMagTest.h index 3e16622fe3fa41..9c49446795ceef 100644 --- a/libc/test/src/math/smoke/FMinimumMagTest.h +++ b/libc/test/src/math/smoke/FMinimumMagTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUM_MAGTEST_H #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUM_MAGTEST_H +#include "src/__support/CPP/algorithm.h" #include "src/__support/FPUtil/BasicOperations.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" @@ -56,10 +57,11 @@ class FMinimumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { } void testRange(FMinimumMagFunc func) { - constexpr StorageType COUNT = 100'001; - constexpr StorageType STEP = STORAGE_MAX / COUNT; - for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; - ++i, v += STEP, w -= STEP) { + constexpr int COUNT = 100'001; + constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max( + static_cast(STORAGE_MAX / COUNT), StorageType(1)); + StorageType v = 0, w = STORAGE_MAX; + for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) { FPBits xbits(v), ybits(w); if (xbits.is_inf_or_nan()) continue; @@ -70,11 +72,10 @@ class FMinimumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { if ((x == 0) && (y == 0)) continue; - if (LIBC_NAMESPACE::fputil::abs(x) < LIBC_NAMESPACE::fputil::abs(y)) { + if (LIBC_NAMESPACE::fputil::abs(x) < LIBC_NAMESPACE::fputil::abs(y)) EXPECT_FP_EQ(x, func(x, y)); - } else { + else EXPECT_FP_EQ(y, func(x, y)); - } } } }; diff --git a/libc/test/src/math/smoke/FMinimumNumTest.h b/libc/test/src/math/smoke/FMinimumNumTest.h index 6186ea0df17cce..8004ee98745432 100644 --- a/libc/test/src/math/smoke/FMinimumNumTest.h +++ b/libc/test/src/math/smoke/FMinimumNumTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMNUMTEST_H #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMNUMTEST_H +#include "src/__support/CPP/algorithm.h" #include "src/__support/FPUtil/FPBits.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" @@ -67,10 +68,11 @@ class FMinimumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { } void testRange(FMinimumNumFunc func) { - constexpr StorageType COUNT = 100'001; - constexpr StorageType STEP = STORAGE_MAX / COUNT; - for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; - ++i, v += STEP, w -= STEP) { + constexpr int COUNT = 100'001; + constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max( + static_cast(STORAGE_MAX / COUNT), StorageType(1)); + StorageType v = 0, w = STORAGE_MAX; + for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) { FPBits xbits(v), ybits(w); if (xbits.is_inf_or_nan()) continue; @@ -81,11 +83,10 @@ class FMinimumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { if ((x == 0) && (y == 0)) continue; - if (x > y) { + if (x > y) EXPECT_FP_EQ(y, func(x, y)); - } else { + else EXPECT_FP_EQ(x, func(x, y)); - } } } }; diff --git a/libc/test/src/math/smoke/FMinimumTest.h b/libc/test/src/math/smoke/FMinimumTest.h index a267f6c7832145..242c857fbb99bc 100644 --- a/libc/test/src/math/smoke/FMinimumTest.h +++ b/libc/test/src/math/smoke/FMinimumTest.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMTEST_H #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMTEST_H +#include "src/__support/CPP/algorithm.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/Test.h" @@ -55,10 +56,11 @@ class FMinimumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { } void testRange(FMinimumFunc func) { - constexpr StorageType COUNT = 100'001; - constexpr StorageType STEP = STORAGE_MAX / COUNT; - for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT; - ++i, v += STEP, w -= STEP) { + constexpr int COUNT = 100'001; + constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max( + static_cast(STORAGE_MAX / COUNT), StorageType(1)); + StorageType v = 0, w = STORAGE_MAX; + for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) { FPBits xbits(v), ybits(w); if (xbits.is_inf_or_nan()) continue; @@ -69,11 +71,10 @@ class FMinimumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest { if ((x == 0) && (y == 0)) continue; - if (x > y) { + if (x > y) EXPECT_FP_EQ(y, func(x, y)); - } else { + else EXPECT_FP_EQ(x, func(x, y)); - } } } }; diff --git a/libc/test/src/math/smoke/fmaximum_mag_numf16_test.cpp b/libc/test/src/math/smoke/fmaximum_mag_numf16_test.cpp new file mode 100644 index 00000000000000..b11653eb395e2e --- /dev/null +++ b/libc/test/src/math/smoke/fmaximum_mag_numf16_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fmaximum_mag_numf16 ---------------------------------===// +// +// 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 "FMaximumMagNumTest.h" + +#include "src/math/fmaximum_mag_numf16.h" + +LIST_FMAXIMUM_MAG_NUM_TESTS(float16, LIBC_NAMESPACE::fmaximum_mag_numf16) diff --git a/libc/test/src/math/smoke/fmaximum_magf16_test.cpp b/libc/test/src/math/smoke/fmaximum_magf16_test.cpp new file mode 100644 index 00000000000000..6df1e4aaf6a967 --- /dev/null +++ b/libc/test/src/math/smoke/fmaximum_magf16_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fmaximum_magf16 -------------------------------------===// +// +// 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 "FMaximumMagTest.h" + +#include "src/math/fmaximum_magf16.h" + +LIST_FMAXIMUM_MAG_TESTS(float16, LIBC_NAMESPACE::fmaximum_magf16) diff --git a/libc/test/src/math/smoke/fmaximum_numf16_test.cpp b/libc/test/src/math/smoke/fmaximum_numf16_test.cpp new file mode 100644 index 00000000000000..7cb9cb068cf7f1 --- /dev/null +++ b/libc/test/src/math/smoke/fmaximum_numf16_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fmaximum_numf16 -------------------------------------===// +// +// 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 "FMaximumNumTest.h" + +#include "src/math/fmaximum_numf16.h" + +LIST_FMAXIMUM_NUM_TESTS(float16, LIBC_NAMESPACE::fmaximum_numf16) diff --git a/libc/test/src/math/smoke/fmaximumf16_test.cpp b/libc/test/src/math/smoke/fmaximumf16_test.cpp new file mode 100644 index 00000000000000..4cbf846a1610f6 --- /dev/null +++ b/libc/test/src/math/smoke/fmaximumf16_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fmaximumf16 -----------------------------------------===// +// +// 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 "FMaximumTest.h" + +#include "src/math/fmaximumf16.h" + +LIST_FMAXIMUM_TESTS(float16, LIBC_NAMESPACE::fmaximumf16) diff --git a/libc/test/src/math/smoke/fminimum_mag_numf16_test.cpp b/libc/test/src/math/smoke/fminimum_mag_numf16_test.cpp new file mode 100644 index 00000000000000..2c6aede529cd46 --- /dev/null +++ b/libc/test/src/math/smoke/fminimum_mag_numf16_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fminimum_mag_numf16 ---------------------------------===// +// +// 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 "FMinimumMagNumTest.h" + +#include "src/math/fminimum_mag_numf16.h" + +LIST_FMINIMUM_MAG_NUM_TESTS(float16, LIBC_NAMESPACE::fminimum_mag_numf16) diff --git a/libc/test/src/math/smoke/fminimum_magf16_test.cpp b/libc/test/src/math/smoke/fminimum_magf16_test.cpp new file mode 100644 index 00000000000000..3687aecedfd9f2 --- /dev/null +++ b/libc/test/src/math/smoke/fminimum_magf16_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fminimum_magf16 -------------------------------------===// +// +// 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 "FMinimumMagTest.h" + +#include "src/math/fminimum_magf16.h" + +LIST_FMINIMUM_MAG_TESTS(float16, LIBC_NAMESPACE::fminimum_magf16) diff --git a/libc/test/src/math/smoke/fminimum_numf16_test.cpp b/libc/test/src/math/smoke/fminimum_numf16_test.cpp new file mode 100644 index 00000000000000..67750816d229c3 --- /dev/null +++ b/libc/test/src/math/smoke/fminimum_numf16_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fminimum_numf16 -------------------------------------===// +// +// 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 "FMinimumNumTest.h" + +#include "src/math/fminimum_numf16.h" + +LIST_FMINIMUM_NUM_TESTS(float16, LIBC_NAMESPACE::fminimum_numf16) diff --git a/libc/test/src/math/smoke/fminimumf16_test.cpp b/libc/test/src/math/smoke/fminimumf16_test.cpp new file mode 100644 index 00000000000000..f8b0577490b9fe --- /dev/null +++ b/libc/test/src/math/smoke/fminimumf16_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fminimumf16 -----------------------------------------===// +// +// 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 "FMinimumTest.h" + +#include "src/math/fminimumf16.h" + +LIST_FMINIMUM_TESTS(float16, LIBC_NAMESPACE::fminimumf16)