[libc-commits] [libc] [libc][math][c23] Add ffma{, l, f128} and fdiv{, l, f128} C23 math functions #101089 (PR #101253)
via libc-commits
libc-commits at lists.llvm.org
Mon Aug 5 11:35:46 PDT 2024
https://github.com/aaryanshukla updated https://github.com/llvm/llvm-project/pull/101253
>From 1da499ef15990d0d0738a27a9c2cea0c4e5af446 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Mon, 29 Jul 2024 21:50:15 +0000
Subject: [PATCH 01/21] finishing fdiv
---
libc/config/baremetal/arm/entrypoints.txt | 4 +++
libc/config/baremetal/riscv/entrypoints.txt | 4 +++
libc/config/darwin/arm/entrypoints.txt | 4 +++
libc/config/darwin/x86_64/entrypoints.txt | 4 +++
libc/config/linux/aarch64/entrypoints.txt | 6 ++++
libc/config/linux/arm/entrypoints.txt | 4 +++
libc/config/linux/riscv/entrypoints.txt | 6 ++++
libc/config/linux/x86_64/entrypoints.txt | 6 ++++
libc/config/windows/entrypoints.txt | 4 +++
libc/src/math/CMakeLists.txt | 8 +++++
libc/src/math/fdiv.h | 20 ++++++++++++
libc/src/math/fdivf128.h | 21 ++++++++++++
libc/src/math/fdivl.h | 20 ++++++++++++
libc/src/math/generic/CMakeLists.txt | 36 +++++++++++++++++++++
libc/src/math/generic/fdiv.cpp | 20 ++++++++++++
libc/src/math/generic/fdivf128.cpp | 20 ++++++++++++
libc/src/math/generic/fdivl.cpp | 20 ++++++++++++
17 files changed, 207 insertions(+)
create mode 100644 libc/src/math/fdiv.h
create mode 100644 libc/src/math/fdivf128.h
create mode 100644 libc/src/math/fdivl.h
create mode 100644 libc/src/math/generic/fdiv.cpp
create mode 100644 libc/src/math/generic/fdivf128.cpp
create mode 100644 libc/src/math/generic/fdivl.cpp
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 8025ac09b9f82..30d8ec87029e5 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -263,6 +263,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/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index fb0308c953746..8c3e78b33bd71 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -259,6 +259,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/arm/entrypoints.txt b/libc/config/darwin/arm/entrypoints.txt
index 38eace26f10ab..132241c20ea21 100644
--- a/libc/config/darwin/arm/entrypoints.txt
+++ b/libc/config/darwin/arm/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/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index df9f9bfd54e81..38aced9574feb 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -129,6 +129,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 cfc280da27f4b..ea3aaa2cd1bbc 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -553,6 +553,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
@@ -611,6 +615,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/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 8e77105fdb13e..98265b6248c7a 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -245,6 +245,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 04b8b3bc4ce39..77965d6695d37 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -402,6 +402,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
@@ -566,6 +570,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 fa656d946eceb..1964df6b45d07 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -402,6 +402,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
@@ -652,6 +656,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/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 06c3682255c45..f2d0b8f35e48c 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -149,6 +149,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/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index d70af33522d2b..cbd75e7d6d45d 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -156,6 +156,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/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 27b5b945e278c..39fed299e380f 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2989,6 +2989,42 @@ 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.FPUtil.generic.div
+)
+
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<float>(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<float>(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<float>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
>From 4537494a83fa731b8d4b4ca189ec6cbe2aab3682 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Tue, 30 Jul 2024 19:52:40 +0000
Subject: [PATCH 02/21] added to spec file
---
libc/config/baremetal/riscv/entrypoints.txt | 4 ----
libc/spec/stdc.td | 8 ++++++++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 8c3e78b33bd71..fb0308c953746 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -259,10 +259,6 @@ 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/spec/stdc.td b/libc/spec/stdc.td
index 9c84accd72cff..ecf41cd5bdc7b 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -409,6 +409,14 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"fdiml", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
GuardedFunctionSpec<"fdimf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"fdimf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
+
+ FunctionSpec<"fdiv", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
+ FunctionSpec<"fdivl", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"fdivf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128type>], "LIBC_TYPES_HAS_FLOAT128">,
+
+ FunctionSpec<"ffma", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
+ FunctionSpec<"ffmal", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"ffmaf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"floor", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"floorf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
>From 3318e964781fb6551e722e11339763908a849c38 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Tue, 30 Jul 2024 22:01:23 +0000
Subject: [PATCH 03/21] opk
---
libc/spec/stdc.td | 8 +--
libc/src/math/ffma.h | 20 ++++++
libc/src/math/ffmaf128.h | 21 +++++++
libc/src/math/ffmal.h | 20 ++++++
libc/src/math/generic/CMakeLists.txt | 38 ++++++++++++
libc/src/math/generic/ffma.cpp | 20 ++++++
libc/src/math/generic/ffmaf128.cpp | 20 ++++++
libc/src/math/generic/ffmal.cpp | 21 +++++++
libc/test/src/math/CMakeLists.txt | 54 ++++++++++++++++
libc/test/src/math/fdiv_test.cpp | 13 ++++
libc/test/src/math/fdivl_test.cpp | 13 ++++
libc/test/src/math/ffma_test.cpp | 13 ++++
libc/test/src/math/ffmal_test.cpp | 13 ++++
libc/test/src/math/smoke/CMakeLists.txt | 72 ++++++++++++++++++++++
libc/test/src/math/smoke/fdiv_test.cpp | 13 ++++
libc/test/src/math/smoke/fdivf128_test.cpp | 13 ++++
libc/test/src/math/smoke/fdivl_test.cpp | 13 ++++
libc/test/src/math/smoke/ffma_test.cpp | 13 ++++
libc/test/src/math/smoke/ffmaf128_test.cpp | 13 ++++
libc/test/src/math/smoke/ffmal_test.cpp | 13 ++++
20 files changed, 420 insertions(+), 4 deletions(-)
create mode 100644 libc/src/math/ffma.h
create mode 100644 libc/src/math/ffmaf128.h
create mode 100644 libc/src/math/ffmal.h
create mode 100644 libc/src/math/generic/ffma.cpp
create mode 100644 libc/src/math/generic/ffmaf128.cpp
create mode 100644 libc/src/math/generic/ffmal.cpp
create mode 100644 libc/test/src/math/fdiv_test.cpp
create mode 100644 libc/test/src/math/fdivl_test.cpp
create mode 100644 libc/test/src/math/ffma_test.cpp
create mode 100644 libc/test/src/math/ffmal_test.cpp
create mode 100644 libc/test/src/math/smoke/fdiv_test.cpp
create mode 100644 libc/test/src/math/smoke/fdivf128_test.cpp
create mode 100644 libc/test/src/math/smoke/fdivl_test.cpp
create mode 100644 libc/test/src/math/smoke/ffma_test.cpp
create mode 100644 libc/test/src/math/smoke/ffmaf128_test.cpp
create mode 100644 libc/test/src/math/smoke/ffmal_test.cpp
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index ecf41cd5bdc7b..0b54a7f53c581 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -412,11 +412,11 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"fdiv", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
FunctionSpec<"fdivl", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
- GuardedFunctionSpec<"fdivf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128type>], "LIBC_TYPES_HAS_FLOAT128">,
+ GuardedFunctionSpec<"fdivf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
- FunctionSpec<"ffma", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
- FunctionSpec<"ffmal", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
- GuardedFunctionSpec<"ffmaf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
+ FunctionSpec<"ffma", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
+ FunctionSpec<"ffmal", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"ffmaf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"floor", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"floorf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
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 39fed299e380f..3aabc78df0ddc 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3022,9 +3022,47 @@ add_entrypoint_object(
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/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<float>(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<float>(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<float>(x, y, z);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 380d283763afa..ad454da8e0461 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2380,6 +2380,60 @@ add_fp_unittest(
libc.src.stdlib.srand
)
+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
+ DivTest.h
+ DEPENDS
+ libc.src.math.ffma
+)
+
+add_fp_unittest(
+ ffmal_test
+ NEED_MPFR
+ SUITE
+ libc-math-unittests
+ SRCS
+ ffmal_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.src.math.ffmal
+)
+
+
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..ebf497ea6a3e1
--- /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, double, LIBC_NAMESPACE::ffmal)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 8b2942343409d..f940b5f918f62 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4017,6 +4017,78 @@ 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.src.math.fdiv
+)
+
+add_fp_unittest(
+ fdivl_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ fdivl_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.src.math.fdivl
+)
+
+add_fp_unittest(
+ fdivf128_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ fdivf128_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ 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/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)
>From dcf69a7d6b926d16190ead807febe418b3637165 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Tue, 30 Jul 2024 22:04:54 +0000
Subject: [PATCH 04/21] removed entrypoints in baremetal
---
libc/config/baremetal/arm/entrypoints.txt | 4 ----
1 file changed, 4 deletions(-)
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 30d8ec87029e5..8025ac09b9f82 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -263,10 +263,6 @@ 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
>From 85e2ceab39f1227077ee267bd97475f040f2dc17 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Tue, 30 Jul 2024 23:22:34 +0000
Subject: [PATCH 05/21] fixed wrong input value
---
libc/test/src/math/ffmal_test.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/test/src/math/ffmal_test.cpp b/libc/test/src/math/ffmal_test.cpp
index ebf497ea6a3e1..200d9e16839d0 100644
--- a/libc/test/src/math/ffmal_test.cpp
+++ b/libc/test/src/math/ffmal_test.cpp
@@ -10,4 +10,4 @@
#include "src/math/ffmal.h"
-LIST_NARROWING_FMA_TESTS(float, double, LIBC_NAMESPACE::ffmal)
+LIST_NARROWING_FMA_TESTS(float, long double, LIBC_NAMESPACE::ffmal)
>From ffc5c286fee78aa402ff16059035c8982c2fa01e Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Wed, 31 Jul 2024 11:24:14 -0700
Subject: [PATCH 06/21] Update libc/test/src/math/smoke/CMakeLists.txt
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/test/src/math/smoke/CMakeLists.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index f940b5f918f62..cd6be31ce8499 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4050,6 +4050,8 @@ add_fp_unittest(
HDRS
DivTest.h
DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
libc.src.math.fdivf128
)
>From 8147210bd9d3525d83e2f221c2c4e03ece707df1 Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Wed, 31 Jul 2024 11:24:24 -0700
Subject: [PATCH 07/21] Update libc/test/src/math/smoke/CMakeLists.txt
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/test/src/math/smoke/CMakeLists.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index cd6be31ce8499..4349e2720ee57 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4026,6 +4026,8 @@ add_fp_unittest(
HDRS
DivTest.h
DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
libc.src.math.fdiv
)
>From 6e87b0e49078c6fb7fec38a7e5c6e3b246edb23a Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Wed, 31 Jul 2024 11:24:49 -0700
Subject: [PATCH 08/21] Update libc/test/src/math/CMakeLists.txt
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/test/src/math/CMakeLists.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index ad454da8e0461..029084f75a4d6 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2428,9 +2428,11 @@ add_fp_unittest(
SRCS
ffmal_test.cpp
HDRS
- DivTest.h
+ FmaTest.h
DEPENDS
libc.src.math.ffmal
+ libc.src.stdlib.rand
+ libc.src.stdlib.srand
)
>From 2c516617c9c61fcf23fc3b8c36bc249bfcc4de9f Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Wed, 31 Jul 2024 11:24:56 -0700
Subject: [PATCH 09/21] Update libc/test/src/math/CMakeLists.txt
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/test/src/math/CMakeLists.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 029084f75a4d6..b497225ecb82f 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2415,9 +2415,11 @@ add_fp_unittest(
SRCS
ffma_test.cpp
HDRS
- DivTest.h
+ FmaTest.h
DEPENDS
libc.src.math.ffma
+ libc.src.stdlib.rand
+ libc.src.stdlib.srand
)
add_fp_unittest(
>From 12e35f4056f792a2785444c32cac728b29fcab70 Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Wed, 31 Jul 2024 11:25:03 -0700
Subject: [PATCH 10/21] Update libc/test/src/math/smoke/CMakeLists.txt
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/test/src/math/smoke/CMakeLists.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 4349e2720ee57..c58a68eefe440 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -4040,6 +4040,8 @@ add_fp_unittest(
HDRS
DivTest.h
DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
libc.src.math.fdivl
)
>From 4ae5bfef45a1a21a76b12b5f686799bed78eeabc Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Wed, 31 Jul 2024 18:34:20 +0000
Subject: [PATCH 11/21] changed dependencies in smoke cmake and f16div
---
libc/test/src/math/smoke/CMakeLists.txt | 8 ++++----
libc/test/src/math/smoke/DivTest.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index c58a68eefe440..6f21d3e43bda1 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3874,8 +3874,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
)
@@ -3888,8 +3888,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
)
@@ -3902,8 +3902,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
)
@@ -3916,8 +3916,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
)
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"
>From 3c0fc85c6c2cf2bb15bd9fa9f2948a781bca611e Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 1 Aug 2024 17:22:59 +0000
Subject: [PATCH 12/21] added specific input/output to MPFR
---
libc/utils/MPFRWrapper/MPFRUtils.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index f88ee2af35c52..49bf1982a2d69 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -1086,6 +1086,9 @@ template void
explain_ternary_operation_one_output_error(Operation,
const TernaryInput<long double> &,
long double, double, RoundingMode);
+explain_ternary_operation_one_output_error(Operation,
+ const TernaryInput<double> &, float,
+ double, RoundingMode);
#ifdef LIBC_TYPES_HAS_FLOAT16
template void explain_ternary_operation_one_output_error(
Operation, const TernaryInput<float> &, float16, double, RoundingMode);
@@ -1280,6 +1283,10 @@ template bool compare_ternary_operation_one_output(Operation,
const TernaryInput<double> &,
float16, double,
RoundingMode);
+template bool compare_ternary_operation_one_output(Operation,
+ const TernaryInput<double> &,
+ float, double, RoundingMode);
+
template bool
compare_ternary_operation_one_output(Operation,
const TernaryInput<long double> &, float16,
>From 0244b2800e23910a6a8dafe3fdad5809e7d468cc Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Thu, 1 Aug 2024 20:34:20 +0000
Subject: [PATCH 13/21] added template void to MPFR
---
libc/utils/MPFRWrapper/MPFRUtils.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 49bf1982a2d69..a4988b258e0af 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -1086,6 +1086,7 @@ template void
explain_ternary_operation_one_output_error(Operation,
const TernaryInput<long double> &,
long double, double, RoundingMode);
+template void
explain_ternary_operation_one_output_error(Operation,
const TernaryInput<double> &, float,
double, RoundingMode);
>From a38e6765ec799aa11652098b9e6e6072d5d2a69d Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Thu, 1 Aug 2024 16:23:15 -0700
Subject: [PATCH 14/21] Update CMakeLists.txt
---
libc/test/src/math/CMakeLists.txt | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 1423b500afd7e..108c908f9763f 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2408,7 +2408,7 @@ add_fp_unittest(
add_fp_unittest(
dfmal_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
dfmal_test.cpp
HDRS
@@ -2420,7 +2420,7 @@ add_fp_unittest(
add_fp_unittest(
dfmaf128_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
dfmaf128_test.cpp
HDRS
@@ -2432,7 +2432,7 @@ add_fp_unittest(
add_fp_unittest(
dsubl_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
dsubl_test.cpp
HDRS
@@ -2446,7 +2446,7 @@ add_fp_unittest(
add_fp_unittest(
dsubf128_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
dsubf128_test.cpp
HDRS
@@ -2460,7 +2460,7 @@ add_fp_unittest(
add_fp_unittest(
fdiv_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
fdiv_test.cpp
HDRS
@@ -2474,7 +2474,7 @@ add_fp_unittest(
add_fp_unittest(
fdivl_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
fdivl_test.cpp
HDRS
@@ -2488,7 +2488,7 @@ add_fp_unittest(
add_fp_unittest(
fdivf128_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
fdivf128_test.cpp
HDRS
@@ -2502,7 +2502,7 @@ add_fp_unittest(
add_fp_unittest(
ffma_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
ffma_test.cpp
HDRS
@@ -2514,7 +2514,7 @@ add_fp_unittest(
add_fp_unittest(
ffmal_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
ffmal_test.cpp
HDRS
@@ -2526,7 +2526,7 @@ add_fp_unittest(
add_fp_unittest(
ffmaf128_test
SUITE
- libc-math-smoke-tests
+ libc-math-unittests
SRCS
ffmaf128_test.cpp
HDRS
>From 7cb17a667b3c778263d4a2316d26ef5e469258f7 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Fri, 2 Aug 2024 08:19:28 +0000
Subject: [PATCH 15/21] added <long double> to <float>
- added rand and srand to ffma functions
---
libc/test/src/math/CMakeLists.txt | 63 ++++++----------------------
libc/utils/MPFRWrapper/MPFRUtils.cpp | 11 +++--
2 files changed, 19 insertions(+), 55 deletions(-)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 108c908f9763f..730cd316e3f97 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2407,6 +2407,7 @@ add_fp_unittest(
add_fp_unittest(
dfmal_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -2415,22 +2416,13 @@ add_fp_unittest(
FmaTest.h
DEPENDS
libc.src.math.dfmal
-)
-
-add_fp_unittest(
- dfmaf128_test
- SUITE
- libc-math-unittests
- SRCS
- dfmaf128_test.cpp
- HDRS
- FmaTest.h
- DEPENDS
- libc.src.math.dfmaf128
+ libc.src.stdlib.rand
+ libc.src.stdlib.srand
)
add_fp_unittest(
dsubl_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -2443,22 +2435,9 @@ add_fp_unittest(
libc.src.math.dsubl
)
-add_fp_unittest(
- dsubf128_test
- SUITE
- libc-math-unittests
- SRCS
- dsubf128_test.cpp
- HDRS
- SubTest.h
- DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
- libc.src.math.dsubf128
-)
-
add_fp_unittest(
fdiv_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -2473,6 +2452,7 @@ add_fp_unittest(
add_fp_unittest(
fdivl_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -2485,22 +2465,10 @@ add_fp_unittest(
libc.src.math.fdivl
)
-add_fp_unittest(
- fdivf128_test
- SUITE
- libc-math-unittests
- 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
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -2509,10 +2477,13 @@ add_fp_unittest(
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
@@ -2521,18 +2492,8 @@ add_fp_unittest(
FmaTest.h
DEPENDS
libc.src.math.ffmal
-)
-
-add_fp_unittest(
- ffmaf128_test
- SUITE
- libc-math-unittests
- SRCS
- ffmaf128_test.cpp
- HDRS
- FmaTest.h
- DEPENDS
- libc.src.math.ffmaf128
+ libc.src.stdlib.rand
+ libc.src.stdlib.srand
)
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 1872d8b943556..1695354565f56 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -1086,13 +1086,14 @@ template void
explain_ternary_operation_one_output_error(Operation,
const TernaryInput<long double> &,
long double, double, RoundingMode);
-template void
-explain_ternary_operation_one_output_error(Operation,
- const TernaryInput<double> &, float,
- double, RoundingMode);
+template void explain_ternary_operation_one_output_error(
+ Operation, const TernaryInput<double> &, float, double, RoundingMode);
+template void explain_ternary_operation_one_output_error(
+ Operation, const TernaryInput<long double> &, float, double, RoundingMode);
template void explain_ternary_operation_one_output_error(
Operation, const TernaryInput<long double> &, double, double, RoundingMode);
+
#ifdef LIBC_TYPES_HAS_FLOAT16
template void explain_ternary_operation_one_output_error(
Operation, const TernaryInput<float> &, float16, double, RoundingMode);
@@ -1281,6 +1282,8 @@ compare_ternary_operation_one_output(Operation,
template bool compare_ternary_operation_one_output(
Operation, const TernaryInput<long double> &, double, double, RoundingMode);
+template bool compare_ternary_operation_one_output(
+ Operation, const TernaryInput<long double> &, float, double, RoundingMode);
#ifdef LIBC_TYPES_HAS_FLOAT16
template bool compare_ternary_operation_one_output(Operation,
const TernaryInput<float> &,
>From 6e5069966c5c9272735ae0009c7a766a285d6c0d Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Fri, 2 Aug 2024 22:40:00 +0000
Subject: [PATCH 16/21] updated index.rst
---
libc/docs/math/index.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index defd075d10997..3ae1dbc824683 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 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
>From 2685839b612cf33ff2a79d1bf3b9f98bee0e9417 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Fri, 2 Aug 2024 22:52:36 +0000
Subject: [PATCH 17/21] updated rst
---
libc/docs/math/index.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 3ae1dbc824683..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 | |check| | |check| | N/A | |check|\* | 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 | |check| | |check| | N/A | |check|\* | 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 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
>From 66f4339df9001f988b37d8566c72f3881b3902f6 Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Sun, 4 Aug 2024 19:26:52 -0700
Subject: [PATCH 18/21] Update libc/test/src/math/CMakeLists.txt
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/test/src/math/CMakeLists.txt | 2 --
1 file changed, 2 deletions(-)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 730cd316e3f97..77f41d49cafcd 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2430,8 +2430,6 @@ add_fp_unittest(
HDRS
SubTest.h
DEPENDS
- libc.src.errno.errno
- libc.hdr.fenv_macros
libc.src.math.dsubl
)
>From e48a6a950b4c4f1a46e92e33944b951b7e1b2556 Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Sun, 4 Aug 2024 19:27:00 -0700
Subject: [PATCH 19/21] Update libc/test/src/math/CMakeLists.txt
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/test/src/math/CMakeLists.txt | 2 --
1 file changed, 2 deletions(-)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 77f41d49cafcd..3c82d25915fb7 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2443,8 +2443,6 @@ add_fp_unittest(
HDRS
DivTest.h
DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
libc.src.math.fdiv
)
>From 102957871cfc88407ff3cb0b2990209e4fc241de Mon Sep 17 00:00:00 2001
From: aaryanshukla <53713108+aaryanshukla at users.noreply.github.com>
Date: Sun, 4 Aug 2024 19:27:16 -0700
Subject: [PATCH 20/21] Update libc/test/src/math/CMakeLists.txt
Co-authored-by: OverMighty <its.overmighty at gmail.com>
---
libc/test/src/math/CMakeLists.txt | 2 --
1 file changed, 2 deletions(-)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 3c82d25915fb7..fab09a50ac114 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2456,8 +2456,6 @@ add_fp_unittest(
HDRS
DivTest.h
DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
libc.src.math.fdivl
)
>From 86a3e9f1cfad657a42a0a42e3bdfd8a681b4abcb Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Mon, 5 Aug 2024 18:34:46 +0000
Subject: [PATCH 21/21] reordered MPFRwrapper and added headersa
---
libc/newhdrgen/yaml/math.yaml | 47 ++++++++++++++++++++++++++++
libc/spec/llvm_libc_ext.td | 4 +++
libc/spec/stdc.td | 2 --
libc/utils/MPFRWrapper/MPFRUtils.cpp | 28 ++++++++---------
4 files changed, 64 insertions(+), 17 deletions(-)
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<Float16Type>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"f16subf", RetValSpec<Float16Type>, [ArgSpec<FloatType>, ArgSpec<FloatType>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"f16subl", RetValSpec<Float16Type>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
+
+ GuardedFunctionSpec<"fdivf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
+
+ GuardedFunctionSpec<"ffmaf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
GuardedFunctionSpec<"fmulf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 862429c3f2cef..f46f4bae18000 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -417,11 +417,9 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"fdiv", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
FunctionSpec<"fdivl", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
- GuardedFunctionSpec<"fdivf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"ffma", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
FunctionSpec<"ffmal", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
- GuardedFunctionSpec<"ffmaf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"floor", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"floorf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 1695354565f56..cf6a316936d0c 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -1080,19 +1080,18 @@ void explain_ternary_operation_one_output_error(
template void explain_ternary_operation_one_output_error(
Operation, const TernaryInput<float> &, float, double, RoundingMode);
-template void explain_ternary_operation_one_output_error(
- Operation, const TernaryInput<double> &, double, double, RoundingMode);
-template void
-explain_ternary_operation_one_output_error(Operation,
- const TernaryInput<long double> &,
- long double, double, RoundingMode);
template void explain_ternary_operation_one_output_error(
Operation, const TernaryInput<double> &, float, double, RoundingMode);
+template void explain_ternary_operation_one_output_error(
+ Operation, const TernaryInput<double> &, double, double, RoundingMode);
template void explain_ternary_operation_one_output_error(
Operation, const TernaryInput<long double> &, float, double, RoundingMode);
-
template void explain_ternary_operation_one_output_error(
Operation, const TernaryInput<long double> &, double, double, RoundingMode);
+template void
+explain_ternary_operation_one_output_error(Operation,
+ const TernaryInput<long double> &,
+ long double, double, RoundingMode);
#ifdef LIBC_TYPES_HAS_FLOAT16
template void explain_ternary_operation_one_output_error(
@@ -1271,19 +1270,22 @@ bool compare_ternary_operation_one_output(Operation op,
template bool compare_ternary_operation_one_output(Operation,
const TernaryInput<float> &,
float, double, RoundingMode);
+template bool compare_ternary_operation_one_output(Operation,
+ const TernaryInput<double> &,
+ float, double, RoundingMode);
template bool compare_ternary_operation_one_output(Operation,
const TernaryInput<double> &,
double, double,
RoundingMode);
+template bool compare_ternary_operation_one_output(
+ Operation, const TernaryInput<long double> &, double, double, RoundingMode);
+template bool compare_ternary_operation_one_output(
+ Operation, const TernaryInput<long double> &, float, double, RoundingMode);
template bool
compare_ternary_operation_one_output(Operation,
const TernaryInput<long double> &,
long double, double, RoundingMode);
-template bool compare_ternary_operation_one_output(
- Operation, const TernaryInput<long double> &, double, double, RoundingMode);
-template bool compare_ternary_operation_one_output(
- Operation, const TernaryInput<long double> &, float, double, RoundingMode);
#ifdef LIBC_TYPES_HAS_FLOAT16
template bool compare_ternary_operation_one_output(Operation,
const TernaryInput<float> &,
@@ -1293,10 +1295,6 @@ template bool compare_ternary_operation_one_output(Operation,
const TernaryInput<double> &,
float16, double,
RoundingMode);
-template bool compare_ternary_operation_one_output(Operation,
- const TernaryInput<double> &,
- float, double, RoundingMode);
-
template bool
compare_ternary_operation_one_output(Operation,
const TernaryInput<long double> &, float16,
More information about the libc-commits
mailing list