diff --git a/libc/config/darwin/arm/entrypoints.txt b/libc/config/darwin/arm/entrypoints.txt index 3e4cb3cebce9b..e9192ce4d9a62 100644 --- a/libc/config/darwin/arm/entrypoints.txt +++ b/libc/config/darwin/arm/entrypoints.txt @@ -165,6 +165,10 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.fdim libc.src.math.fdimf libc.src.math.fdiml + libc.src.math.fdiv + libc.src.math.fdivl + libc.src.math.ffma + libc.src.math.ffmal libc.src.math.floor libc.src.math.floorf libc.src.math.floorl diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt index 5aa8354a75279..dd1ee477f1ed3 100644 --- a/libc/config/darwin/x86_64/entrypoints.txt +++ b/libc/config/darwin/x86_64/entrypoints.txt @@ -132,6 +132,10 @@ set(TARGET_LIBM_ENTRYPOINTS #libc.src.math.fdim #libc.src.math.fdimf #libc.src.math.fdiml + #libc.src.math.fdiv + #libc.src.math.fdivl + #libc.src.math.ffma + #libc.src.math.ffmal #libc.src.math.floor #libc.src.math.floorf #libc.src.math.floorl diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 2c449c49d912a..c00a166826528 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -564,6 +564,10 @@ if(LIBC_TYPES_HAS_FLOAT16) libc.src.math.f16subf libc.src.math.fabsf16 libc.src.math.fdimf16 + libc.src.math.fdiv + libc.src.math.fdivl + libc.src.math.ffma + libc.src.math.ffmal libc.src.math.floorf16 libc.src.math.fmaxf16 libc.src.math.fmaximum_mag_numf16 @@ -626,6 +630,8 @@ if(LIBC_TYPES_HAS_FLOAT128) libc.src.math.dsubf128 libc.src.math.fabsf128 libc.src.math.fdimf128 + libc.src.math.fdivf128 + libc.src.math.ffmaf128 libc.src.math.floorf128 libc.src.math.fmaxf128 libc.src.math.fmaximum_mag_numf128 diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt index a9f4383542fe7..a2ebf1319ccb7 100644 --- a/libc/config/linux/arm/entrypoints.txt +++ b/libc/config/linux/arm/entrypoints.txt @@ -247,6 +247,10 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.fdim libc.src.math.fdimf libc.src.math.fdiml + libc.src.math.fdiv + libc.src.math.fdivl + libc.src.math.ffma + libc.src.math.ffmal libc.src.math.floor libc.src.math.floorf libc.src.math.floorl diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index 771f169332fcb..0ebd324c02e70 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -408,6 +408,10 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.fdim libc.src.math.fdimf libc.src.math.fdiml + libc.src.math.fdiv + libc.src.math.fdivl + libc.src.math.ffma + libc.src.math.ffmal libc.src.math.floor libc.src.math.floorf libc.src.math.floorl @@ -578,6 +582,8 @@ if(LIBC_TYPES_HAS_FLOAT128) libc.src.math.dsqrtf128 libc.src.math.fabsf128 libc.src.math.fdimf128 + libc.src.math.fdivf128 + libc.src.math.ffmaf128 libc.src.math.floorf128 libc.src.math.fmaxf128 libc.src.math.fmaximum_mag_numf128 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 044852b49c75f..5c937e9911e3f 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -408,6 +408,10 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.fdim libc.src.math.fdimf libc.src.math.fdiml + libc.src.math.fdiv + libc.src.math.fdivl + libc.src.math.ffma + libc.src.math.ffmal libc.src.math.floor libc.src.math.floorf libc.src.math.floorl @@ -669,6 +673,8 @@ if(LIBC_TYPES_HAS_FLOAT128) libc.src.math.dsubf128 libc.src.math.fabsf128 libc.src.math.fdimf128 + libc.src.math.fdivf128 + libc.src.math.ffmaf128 libc.src.math.floorf128 libc.src.math.fmaxf128 libc.src.math.fmaximum_mag_numf128 diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt index b7aac225ee055..223bbdd1a70c6 100644 --- a/libc/config/windows/entrypoints.txt +++ b/libc/config/windows/entrypoints.txt @@ -152,6 +152,10 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.fdim libc.src.math.fdimf libc.src.math.fdiml + libc.src.math.fdiv + libc.src.math.fdivl + libc.src.math.ffma + libc.src.math.ffmal libc.src.math.floor libc.src.math.floorf libc.src.math.floorl diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst index defd075d10997..bb8de2724b325 100644 --- a/libc/docs/math/index.rst +++ b/libc/docs/math/index.rst @@ -140,9 +140,9 @@ Basic Operations +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | fdim | |check| | |check| | |check| | |check| | |check| | 7.12.12.1 | F.10.9.1 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| fdiv | N/A | | | N/A | | 7.12.14.4 | F.10.11 | +| fdiv | N/A | |check| | |check| | N/A | |check|\* | 7.12.14.4 | F.10.11 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| ffma | N/A | | | N/A | | 7.12.14.5 | F.10.11 | +| ffma | N/A | |check| | |check| | N/A | |check|\* | 7.12.14.5 | F.10.11 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | floor | |check| | |check| | |check| | |check| | |check| | 7.12.9.2 | F.10.6.2 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ diff --git a/libc/newhdrgen/yaml/math.yaml b/libc/newhdrgen/yaml/math.yaml index ce562c653a6d2..057220e803e2f 100644 --- a/libc/newhdrgen/yaml/math.yaml +++ b/libc/newhdrgen/yaml/math.yaml @@ -1845,6 +1845,53 @@ functions: - type: float128 - type: float128 guard: LIBC_TYPES_HAS_FLOAT128 + - name: fdiv + standards: + - stdc + return_type: float + arguments: + - type: double + - type: double + - name: fdivl + standards: + - stdc + return_type: float + arguments: + - type: long double + - type: long double + - name: fdivf128 + standards: + - llvm_libc_ext + return_type: float + arguments: + - type: float128 + - type: float128 + guard: LIBC_TYPES_HAS_FLOAT128 + - name: ffma + standards: + - stdc + return_type: float + arguments: + - type: double + - type: double + - type: double + - name: ffmal + standards: + - stdc + return_type: float + arguments: + - type: long double + - type: long double + - type: long double + - name: ffmaf128 + standards: + - llvm_libc_ext + return_type: float + arguments: + - type: float128 + - type: float128 + - type: float128 + guards: LIBC_TYPES_HAS_FLOAT128 - name: floorf128 standards: - stdc diff --git a/libc/spec/llvm_libc_ext.td b/libc/spec/llvm_libc_ext.td index f86a8c1c6c106..5d1c906b931e0 100644 --- a/libc/spec/llvm_libc_ext.td +++ b/libc/spec/llvm_libc_ext.td @@ -71,6 +71,10 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> { GuardedFunctionSpec<"f16sub", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"f16subf", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"f16subl", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, + + GuardedFunctionSpec<"fdivf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, + + GuardedFunctionSpec<"ffmaf128", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, GuardedFunctionSpec<"fmulf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index 3f68eeb7853ad..f46f4bae18000 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -414,6 +414,12 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"fdiml", RetValSpec, [ArgSpec, ArgSpec]>, GuardedFunctionSpec<"fdimf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, GuardedFunctionSpec<"fdimf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, + + FunctionSpec<"fdiv", RetValSpec, [ArgSpec, ArgSpec]>, + FunctionSpec<"fdivl", RetValSpec, [ArgSpec, ArgSpec]>, + + FunctionSpec<"ffma", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, + FunctionSpec<"ffmal", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, FunctionSpec<"floor", RetValSpec, [ArgSpec]>, FunctionSpec<"floorf", RetValSpec, [ArgSpec]>, diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index e513d72260fb1..7cc97488c9e17 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -166,6 +166,14 @@ add_math_entrypoint_object(fdiml) add_math_entrypoint_object(fdimf16) add_math_entrypoint_object(fdimf128) +add_math_entrypoint_object(fdiv) +add_math_entrypoint_object(fdivl) +add_math_entrypoint_object(fdivf128) + +add_math_entrypoint_object(ffma) +add_math_entrypoint_object(ffmal) +add_math_entrypoint_object(ffmaf128) + add_math_entrypoint_object(floor) add_math_entrypoint_object(floorf) add_math_entrypoint_object(floorl) diff --git a/libc/src/math/fdiv.h b/libc/src/math/fdiv.h new file mode 100644 index 0000000000000..4d60afaf469f3 --- /dev/null +++ b/libc/src/math/fdiv.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fdiv --------------------------*- 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_FDIV_H +#define LLVM_LIBC_SRC_MATH_FDIV_H + +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +float fdiv(double x, double y); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_FDIV_H diff --git a/libc/src/math/fdivf128.h b/libc/src/math/fdivf128.h new file mode 100644 index 0000000000000..1a150389b6859 --- /dev/null +++ b/libc/src/math/fdivf128.h @@ -0,0 +1,21 @@ +//===-- Implementation header for fdivf128 ----------------------*- 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_FDIVF128_H +#define LLVM_LIBC_SRC_MATH_FDIVF128_H + +#include "src/__support/macros/config.h" +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE_DECL { + +float fdivf128(float128 x, float128 y); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_FDIVF128_H diff --git a/libc/src/math/fdivl.h b/libc/src/math/fdivl.h new file mode 100644 index 0000000000000..1943eaae7783c --- /dev/null +++ b/libc/src/math/fdivl.h @@ -0,0 +1,20 @@ +//===-- Implementation header for fdivl -------------------------*- 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_FDIVL_H +#define LLVM_LIBC_SRC_MATH_FDIVL_H + +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +float fdivl(long double x, long double y); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_FDIVL_H diff --git a/libc/src/math/ffma.h b/libc/src/math/ffma.h new file mode 100644 index 0000000000000..98d89f2eef983 --- /dev/null +++ b/libc/src/math/ffma.h @@ -0,0 +1,20 @@ +//===-- Implementation header for ffma --------------------------*- 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_FFMA_H +#define LLVM_LIBC_SRC_MATH_FFMA_H + +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +float ffma(double x, double y, double z); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_FFMA_H diff --git a/libc/src/math/ffmaf128.h b/libc/src/math/ffmaf128.h new file mode 100644 index 0000000000000..741099780b8d5 --- /dev/null +++ b/libc/src/math/ffmaf128.h @@ -0,0 +1,21 @@ +//===-- Implementation header for ffmaf128 ----------------------*- 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_FFMAF128_H +#define LLVM_LIBC_SRC_MATH_FFMAF128_H + +#include "src/__support/macros/config.h" +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE_DECL { + +float ffmaf128(float128 x, float128 y, float128 z); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_FFMAF128_H diff --git a/libc/src/math/ffmal.h b/libc/src/math/ffmal.h new file mode 100644 index 0000000000000..75fd40a0a92a2 --- /dev/null +++ b/libc/src/math/ffmal.h @@ -0,0 +1,20 @@ +//===-- Implementation header for ffmal -------------------------*- 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_FFMAL_H +#define LLVM_LIBC_SRC_MATH_FFMAL_H + +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +float ffmal(long double x, long double y, long double z); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_FFMAL_H diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 58daffaf4e932..4000bafc347ce 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -3100,6 +3100,80 @@ add_entrypoint_object( libc.src.__support.FPUtil.basic_operations ) +add_entrypoint_object( + fdiv + SRCS + fdiv.cpp + HDRS + ../fdiv.h + COMPILE_OPTIONS + -O3 + DEPENDS + libc.src.__support.FPUtil.generic.div +) + +add_entrypoint_object( + fdivl + SRCS + fdivl.cpp + HDRS + ../fdivl.h + COMPILE_OPTIONS + -O3 + DEPENDS + libc.src.__support.FPUtil.generic.div +) + +add_entrypoint_object( + fdivf128 + SRCS + fdivf128.cpp + HDRS + ../fdivf128.h + COMPILE_OPTIONS + -O3 + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.div +) + +add_entrypoint_object( + ffma + SRCS + ffma.cpp + HDRS + ../ffma.h + COMPILE_OPTIONS + -O3 + DEPENDS + libc.src.__support.FPUtil.fma +) + +add_entrypoint_object( + ffmal + SRCS + ffmal.cpp + HDRS + ../ffmal.h + COMPILE_OPTIONS + -O3 + DEPENDS + libc.src.__support.FPUtil.fma +) + +add_entrypoint_object( + ffmaf128 + SRCS + ffmaf128.cpp + HDRS + ../ffmaf128.h + COMPILE_OPTIONS + -O3 + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.fma +) + add_entrypoint_object( hypot SRCS diff --git a/libc/src/math/generic/fdiv.cpp b/libc/src/math/generic/fdiv.cpp new file mode 100644 index 0000000000000..1d97fade22a37 --- /dev/null +++ b/libc/src/math/generic/fdiv.cpp @@ -0,0 +1,20 @@ +//===-- Implementation of fdiv 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/fdiv.h" +#include "src/__support/FPUtil/generic/div.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, fdiv, (double x, double y)) { + return fputil::generic::div(x, y); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/fdivf128.cpp b/libc/src/math/generic/fdivf128.cpp new file mode 100644 index 0000000000000..192f13f5de10e --- /dev/null +++ b/libc/src/math/generic/fdivf128.cpp @@ -0,0 +1,20 @@ +//===-- Implementation of fdivf128 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/fdivf128.h" +#include "src/__support/FPUtil/generic/div.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, fdivf128, (float128 x, float128 y)) { + return fputil::generic::div(x, y); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/fdivl.cpp b/libc/src/math/generic/fdivl.cpp new file mode 100644 index 0000000000000..dcd5debc2acd9 --- /dev/null +++ b/libc/src/math/generic/fdivl.cpp @@ -0,0 +1,20 @@ +//===-- Implementation of fdivl 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/fdivl.h" +#include "src/__support/FPUtil/generic/div.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, fdivl, (long double x, long double y)) { + return fputil::generic::div(x, y); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/ffma.cpp b/libc/src/math/generic/ffma.cpp new file mode 100644 index 0000000000000..a4c834ddd7986 --- /dev/null +++ b/libc/src/math/generic/ffma.cpp @@ -0,0 +1,20 @@ +//===-- Implementation of ffma 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/ffma.h" +#include "src/__support/FPUtil/FMA.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, ffma, (double x, double y, double z)) { + return fputil::fma(x, y, z); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/ffmaf128.cpp b/libc/src/math/generic/ffmaf128.cpp new file mode 100644 index 0000000000000..55da93020faf3 --- /dev/null +++ b/libc/src/math/generic/ffmaf128.cpp @@ -0,0 +1,20 @@ +//===-- Implementation of ffmaf128 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/ffmaf128.h" +#include "src/__support/FPUtil/FMA.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, ffmaf128, (float128 x, float128 y, float128 z)) { + return fputil::fma(x, y, z); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/ffmal.cpp b/libc/src/math/generic/ffmal.cpp new file mode 100644 index 0000000000000..d5cd4f763cbe5 --- /dev/null +++ b/libc/src/math/generic/ffmal.cpp @@ -0,0 +1,21 @@ +//===-- Implementation of ffmal 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/ffmal.h" +#include "src/__support/FPUtil/FMA.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(float, ffmal, + (long double x, long double y, long double z)) { + return fputil::fma(x, y, z); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt index 2fbfa741c037e..fab09a50ac114 100644 --- a/libc/test/src/math/CMakeLists.txt +++ b/libc/test/src/math/CMakeLists.txt @@ -2433,6 +2433,63 @@ add_fp_unittest( libc.src.math.dsubl ) +add_fp_unittest( + fdiv_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + fdiv_test.cpp + HDRS + DivTest.h + DEPENDS + libc.src.math.fdiv +) + +add_fp_unittest( + fdivl_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + fdivl_test.cpp + HDRS + DivTest.h + DEPENDS + libc.src.math.fdivl +) + + +add_fp_unittest( + ffma_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + ffma_test.cpp + HDRS + FmaTest.h + DEPENDS + libc.src.math.ffma + libc.src.stdlib.rand + libc.src.stdlib.srand +) + +add_fp_unittest( + ffmal_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + ffmal_test.cpp + HDRS + FmaTest.h + DEPENDS + libc.src.math.ffmal + libc.src.stdlib.rand + libc.src.stdlib.srand +) + add_subdirectory(generic) add_subdirectory(smoke) diff --git a/libc/test/src/math/fdiv_test.cpp b/libc/test/src/math/fdiv_test.cpp new file mode 100644 index 0000000000000..f0bd602003b28 --- /dev/null +++ b/libc/test/src/math/fdiv_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fdiv ------------------------------------------------===// +// +// 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 "DivTest.h" + +#include "src/math/fdiv.h" + +LIST_DIV_TESTS(float, double, LIBC_NAMESPACE::fdiv) diff --git a/libc/test/src/math/fdivl_test.cpp b/libc/test/src/math/fdivl_test.cpp new file mode 100644 index 0000000000000..bc2b0e4d9f060 --- /dev/null +++ b/libc/test/src/math/fdivl_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fdivl -----------------------------------------------===// +// +// 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 "DivTest.h" + +#include "src/math/fdivl.h" + +LIST_DIV_TESTS(float, long double, LIBC_NAMESPACE::fdivl) diff --git a/libc/test/src/math/ffma_test.cpp b/libc/test/src/math/ffma_test.cpp new file mode 100644 index 0000000000000..4b6a25c50d15c --- /dev/null +++ b/libc/test/src/math/ffma_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for ffma ------------------------------------------------===// +// +// 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 "FmaTest.h" + +#include "src/math/ffma.h" + +LIST_NARROWING_FMA_TESTS(float, double, LIBC_NAMESPACE::ffma) diff --git a/libc/test/src/math/ffmal_test.cpp b/libc/test/src/math/ffmal_test.cpp new file mode 100644 index 0000000000000..200d9e16839d0 --- /dev/null +++ b/libc/test/src/math/ffmal_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for ffmal -----------------------------------------------===// +// +// 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 "FmaTest.h" + +#include "src/math/ffmal.h" + +LIST_NARROWING_FMA_TESTS(float, long double, LIBC_NAMESPACE::ffmal) diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index 2aba5abb5a4d8..c2832d4e07aae 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -4047,8 +4047,8 @@ add_fp_unittest( HDRS DivTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.__support.FPUtil.basic_operations libc.src.math.f16div ) @@ -4061,8 +4061,8 @@ add_fp_unittest( HDRS DivTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.__support.FPUtil.basic_operations libc.src.math.f16divf ) @@ -4075,8 +4075,8 @@ add_fp_unittest( HDRS DivTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.__support.FPUtil.basic_operations libc.src.math.f16divl ) @@ -4089,8 +4089,8 @@ add_fp_unittest( HDRS DivTest.h DEPENDS + libc.hdr.errno_macros libc.hdr.fenv_macros - libc.src.__support.FPUtil.basic_operations libc.src.math.f16divf128 ) @@ -4190,6 +4190,84 @@ add_fp_unittest( libc.src.math.f16sqrtf128 ) +add_fp_unittest( + fdiv_test + SUITE + libc-math-smoke-tests + SRCS + fdiv_test.cpp + HDRS + DivTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.fdiv +) + +add_fp_unittest( + fdivl_test + SUITE + libc-math-smoke-tests + SRCS + fdivl_test.cpp + HDRS + DivTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.fdivl +) + +add_fp_unittest( + fdivf128_test + SUITE + libc-math-smoke-tests + SRCS + fdivf128_test.cpp + HDRS + DivTest.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.math.fdivf128 +) + +add_fp_unittest( + ffma_test + SUITE + libc-math-smoke-tests + SRCS + ffma_test.cpp + HDRS + FmaTest.h + DEPENDS + libc.src.math.ffma +) + +add_fp_unittest( + ffmal_test + SUITE + libc-math-smoke-tests + SRCS + ffmal_test.cpp + HDRS + FmaTest.h + DEPENDS + libc.src.math.ffmal +) + +add_fp_unittest( + ffmaf128_test + SUITE + libc-math-smoke-tests + SRCS + ffmaf128_test.cpp + HDRS + FmaTest.h + DEPENDS + libc.src.math.ffmaf128 +) + add_fp_unittest( fsqrt_test SUITE diff --git a/libc/test/src/math/smoke/DivTest.h b/libc/test/src/math/smoke/DivTest.h index b30fc17aac1d5..666179628c55f 100644 --- a/libc/test/src/math/smoke/DivTest.h +++ b/libc/test/src/math/smoke/DivTest.h @@ -9,8 +9,8 @@ #ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_DIVTEST_H #define LLVM_LIBC_TEST_SRC_MATH_SMOKE_DIVTEST_H +#include "hdr/errno_macros.h" #include "hdr/fenv_macros.h" -#include "src/__support/FPUtil/BasicOperations.h" #include "test/UnitTest/FEnvSafeTest.h" #include "test/UnitTest/FPMatcher.h" #include "test/UnitTest/RoundingModeUtils.h" diff --git a/libc/test/src/math/smoke/fdiv_test.cpp b/libc/test/src/math/smoke/fdiv_test.cpp new file mode 100644 index 0000000000000..f0bd602003b28 --- /dev/null +++ b/libc/test/src/math/smoke/fdiv_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fdiv ------------------------------------------------===// +// +// 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 "DivTest.h" + +#include "src/math/fdiv.h" + +LIST_DIV_TESTS(float, double, LIBC_NAMESPACE::fdiv) diff --git a/libc/test/src/math/smoke/fdivf128_test.cpp b/libc/test/src/math/smoke/fdivf128_test.cpp new file mode 100644 index 0000000000000..a687e079b597e --- /dev/null +++ b/libc/test/src/math/smoke/fdivf128_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fdivf128 --------------------------------------------===// +// +// 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 "DivTest.h" + +#include "src/math/fdivf128.h" + +LIST_DIV_TESTS(float, float128, LIBC_NAMESPACE::fdivf128) diff --git a/libc/test/src/math/smoke/fdivl_test.cpp b/libc/test/src/math/smoke/fdivl_test.cpp new file mode 100644 index 0000000000000..bc2b0e4d9f060 --- /dev/null +++ b/libc/test/src/math/smoke/fdivl_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for fdivl -----------------------------------------------===// +// +// 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 "DivTest.h" + +#include "src/math/fdivl.h" + +LIST_DIV_TESTS(float, long double, LIBC_NAMESPACE::fdivl) diff --git a/libc/test/src/math/smoke/ffma_test.cpp b/libc/test/src/math/smoke/ffma_test.cpp new file mode 100644 index 0000000000000..4b6a25c50d15c --- /dev/null +++ b/libc/test/src/math/smoke/ffma_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for ffma ------------------------------------------------===// +// +// 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 "FmaTest.h" + +#include "src/math/ffma.h" + +LIST_NARROWING_FMA_TESTS(float, double, LIBC_NAMESPACE::ffma) diff --git a/libc/test/src/math/smoke/ffmaf128_test.cpp b/libc/test/src/math/smoke/ffmaf128_test.cpp new file mode 100644 index 0000000000000..a8f81e253df2f --- /dev/null +++ b/libc/test/src/math/smoke/ffmaf128_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for ffmaf128 --------------------------------------------===// +// +// 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 "FmaTest.h" + +#include "src/math/ffmaf128.h" + +LIST_NARROWING_FMA_TESTS(float, float128, LIBC_NAMESPACE::ffmaf128) diff --git a/libc/test/src/math/smoke/ffmal_test.cpp b/libc/test/src/math/smoke/ffmal_test.cpp new file mode 100644 index 0000000000000..200d9e16839d0 --- /dev/null +++ b/libc/test/src/math/smoke/ffmal_test.cpp @@ -0,0 +1,13 @@ +//===-- Unittests for ffmal -----------------------------------------------===// +// +// 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 "FmaTest.h" + +#include "src/math/ffmal.h" + +LIST_NARROWING_FMA_TESTS(float, long double, LIBC_NAMESPACE::ffmal) diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp index 4263c9dccb6a5..7ce6a70d09316 100644 --- a/libc/utils/MPFRWrapper/MPFRUtils.cpp +++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp @@ -1080,15 +1080,19 @@ void explain_ternary_operation_one_output_error( template void explain_ternary_operation_one_output_error( Operation, const TernaryInput &, float, double, RoundingMode); +template void explain_ternary_operation_one_output_error( + Operation, const TernaryInput &, float, double, RoundingMode); template void explain_ternary_operation_one_output_error( Operation, const TernaryInput &, double, double, RoundingMode); +template void explain_ternary_operation_one_output_error( + Operation, const TernaryInput &, float, double, RoundingMode); +template void explain_ternary_operation_one_output_error( + Operation, const TernaryInput &, double, double, RoundingMode); template void explain_ternary_operation_one_output_error(Operation, const TernaryInput &, long double, double, RoundingMode); -template void explain_ternary_operation_one_output_error( - Operation, const TernaryInput &, double, double, RoundingMode); #ifdef LIBC_TYPES_HAS_FLOAT16 template void explain_ternary_operation_one_output_error( Operation, const TernaryInput &, float16, double, RoundingMode); @@ -1266,17 +1270,22 @@ bool compare_ternary_operation_one_output(Operation op, template bool compare_ternary_operation_one_output(Operation, const TernaryInput &, float, double, RoundingMode); +template bool compare_ternary_operation_one_output(Operation, + const TernaryInput &, + float, double, RoundingMode); template bool compare_ternary_operation_one_output(Operation, const TernaryInput &, double, double, RoundingMode); +template bool compare_ternary_operation_one_output( + Operation, const TernaryInput &, float, double, RoundingMode); +template bool compare_ternary_operation_one_output( + Operation, const TernaryInput &, double, double, RoundingMode); template bool compare_ternary_operation_one_output(Operation, const TernaryInput &, long double, double, RoundingMode); -template bool compare_ternary_operation_one_output( - Operation, const TernaryInput &, double, double, RoundingMode); #ifdef LIBC_TYPES_HAS_FLOAT16 template bool compare_ternary_operation_one_output(Operation, const TernaryInput &,