From dd1cd02a438dc372e1f8457096d01fabb93c9ced Mon Sep 17 00:00:00 2001 From: OverMighty Date: Thu, 6 Jun 2024 17:20:29 +0200 Subject: [libc][math][c23] Add {fmaximum,fminimum}{,_mag,_mag_num,_num} C23 math functions (#94510) #93566 --- libc/config/linux/aarch64/entrypoints.txt | 8 ++ libc/config/linux/x86_64/entrypoints.txt | 8 ++ libc/docs/c23.rst | 14 +- libc/docs/math/index.rst | 16 +-- libc/spec/stdc.td | 8 ++ libc/src/math/CMakeLists.txt | 8 ++ libc/src/math/fmaximum_mag_numf16.h | 20 +++ libc/src/math/fmaximum_magf16.h | 20 +++ libc/src/math/fmaximum_numf16.h | 20 +++ libc/src/math/fmaximumf16.h | 20 +++ libc/src/math/fminimum_mag_numf16.h | 20 +++ libc/src/math/fminimum_magf16.h | 20 +++ libc/src/math/fminimum_numf16.h | 20 +++ libc/src/math/fminimumf16.h | 20 +++ libc/src/math/generic/CMakeLists.txt | 106 ++++++++++++++- libc/src/math/generic/fmaximum_mag_numf16.cpp | 19 +++ libc/src/math/generic/fmaximum_magf16.cpp | 19 +++ libc/src/math/generic/fmaximum_numf16.cpp | 19 +++ libc/src/math/generic/fmaximumf16.cpp | 19 +++ libc/src/math/generic/fminimum_mag_numf16.cpp | 19 +++ libc/src/math/generic/fminimum_magf16.cpp | 19 +++ libc/src/math/generic/fminimum_numf16.cpp | 19 +++ libc/src/math/generic/fminimumf16.cpp | 19 +++ libc/test/src/math/smoke/CMakeLists.txt | 151 ++++++++++++++++++++- libc/test/src/math/smoke/FMaximumMagNumTest.h | 15 +- libc/test/src/math/smoke/FMaximumMagTest.h | 15 +- libc/test/src/math/smoke/FMaximumNumTest.h | 15 +- libc/test/src/math/smoke/FMaximumTest.h | 15 +- libc/test/src/math/smoke/FMinimumMagNumTest.h | 15 +- libc/test/src/math/smoke/FMinimumMagTest.h | 15 +- libc/test/src/math/smoke/FMinimumNumTest.h | 15 +- libc/test/src/math/smoke/FMinimumTest.h | 15 +- .../src/math/smoke/fmaximum_mag_numf16_test.cpp | 13 ++ libc/test/src/math/smoke/fmaximum_magf16_test.cpp | 13 ++ libc/test/src/math/smoke/fmaximum_numf16_test.cpp | 13 ++ libc/test/src/math/smoke/fmaximumf16_test.cpp | 13 ++ .../src/math/smoke/fminimum_mag_numf16_test.cpp | 13 ++ libc/test/src/math/smoke/fminimum_magf16_test.cpp | 13 ++ libc/test/src/math/smoke/fminimum_numf16_test.cpp | 13 ++ libc/test/src/math/smoke/fminimumf16_test.cpp | 13 ++ 40 files changed, 781 insertions(+), 74 deletions(-) create mode 100644 libc/src/math/fmaximum_mag_numf16.h create mode 100644 libc/src/math/fmaximum_magf16.h create mode 100644 libc/src/math/fmaximum_numf16.h create mode 100644 libc/src/math/fmaximumf16.h create mode 100644 libc/src/math/fminimum_mag_numf16.h create mode 100644 libc/src/math/fminimum_magf16.h create mode 100644 libc/src/math/fminimum_numf16.h create mode 100644 libc/src/math/fminimumf16.h create mode 100644 libc/src/math/generic/fmaximum_mag_numf16.cpp create mode 100644 libc/src/math/generic/fmaximum_magf16.cpp create mode 100644 libc/src/math/generic/fmaximum_numf16.cpp create mode 100644 libc/src/math/generic/fmaximumf16.cpp create mode 100644 libc/src/math/generic/fminimum_mag_numf16.cpp create mode 100644 libc/src/math/generic/fminimum_magf16.cpp create mode 100644 libc/src/math/generic/fminimum_numf16.cpp create mode 100644 libc/src/math/generic/fminimumf16.cpp create mode 100644 libc/test/src/math/smoke/fmaximum_mag_numf16_test.cpp create mode 100644 libc/test/src/math/smoke/fmaximum_magf16_test.cpp create mode 100644 libc/test/src/math/smoke/fmaximum_numf16_test.cpp create mode 100644 libc/test/src/math/smoke/fmaximumf16_test.cpp create mode 100644 libc/test/src/math/smoke/fminimum_mag_numf16_test.cpp create mode 100644 libc/test/src/math/smoke/fminimum_magf16_test.cpp create mode 100644 libc/test/src/math/smoke/fminimum_numf16_test.cpp create mode 100644 libc/test/src/math/smoke/fminimumf16_test.cpp diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 13a4445..33ecff8 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 9db044e..ebacb1c 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 fa7a598..71232cc 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 8c3c07a..b9507f0 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 f867a3d..210f2a13 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 4984666..7a349dd 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 0000000..4c963d4 --- /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 0000000..e5f57d3 --- /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 0000000..b450a45 --- /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 0000000..806339f --- /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 0000000..0fd314b --- /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 0000000..27673555 --- /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 0000000..598ff9d --- /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 0000000..86dd240 --- /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 c183f09..b1d786f 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -1895,6 +1895,19 @@ add_entrypoint_object( ) 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 fmaximumf128.cpp @@ -1944,6 +1957,19 @@ add_entrypoint_object( ) 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 fmaximum_numf128.cpp @@ -1993,6 +2019,19 @@ add_entrypoint_object( ) 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 fmaximum_magf128.cpp @@ -2005,7 +2044,6 @@ add_entrypoint_object( -O3 ) - add_entrypoint_object( fmaximum_mag_num SRCS @@ -2043,6 +2081,19 @@ add_entrypoint_object( ) 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 fmaximum_mag_numf128.cpp @@ -2092,6 +2143,19 @@ add_entrypoint_object( ) 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 fminimumf128.cpp @@ -2141,6 +2205,19 @@ add_entrypoint_object( ) 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 fminimum_numf128.cpp @@ -2190,6 +2267,19 @@ add_entrypoint_object( ) 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 fminimum_magf128.cpp @@ -2202,7 +2292,6 @@ add_entrypoint_object( -O3 ) - add_entrypoint_object( fminimum_mag_num SRCS @@ -2240,6 +2329,19 @@ add_entrypoint_object( ) 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 fminimum_mag_numf128.cpp 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 0000000..5055802 --- /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 0000000..fbd5eac --- /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 0000000..187cfbe --- /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 0000000..9e194d2ece --- /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 0000000..1a893c6 --- /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 0000000..45183a9 --- /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 0000000..825ad3e --- /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 0000000..16f738b --- /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 16c6537..110fa1d 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 aafb6d2..726f870 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 @@ public: } 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 @@ public: 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 7bb79a6..b5b2c1c 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 @@ public: } 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 @@ public: 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 da0ea2c..ec79135 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 @@ public: } 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 @@ public: 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 1bd1516..94e4a34 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 @@ public: } 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 @@ public: 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 e4b8fd9..2ceca6f 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 @@ public: } 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 @@ public: 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 3e16622..9c49446 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 @@ public: } 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 @@ public: 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 6186ea0..8004ee9 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 @@ public: } 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 @@ public: 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 a267f6c..242c857 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 @@ public: } 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 @@ public: 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 0000000..b11653e --- /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 0000000..6df1e4a --- /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 0000000..7cb9cb0 --- /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 0000000..4cbf846 --- /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 0000000..2c6aede --- /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 0000000..3687aec --- /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 0000000..6775081 --- /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 0000000..f8b0577 --- /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) -- cgit v1.1