[libc-commits] [libc] [libc][math][c++23] Add bf16{add, sub}{, f, l, f128} math functions (PR #152774)
Krishna Pandey via libc-commits
libc-commits at lists.llvm.org
Fri Aug 8 11:21:18 PDT 2025
https://github.com/krishna2803 created https://github.com/llvm/llvm-project/pull/152774
This PR adds implements following basic math functions for BFloat16 type along with the tests:
- bf16add
- bf16addf
- bf16addl
- bf16addf128
- bf16sub
- bf16subf
- bf16subl
- bf16subf128
>From 700255276668affe93b6775f21f4e1b91d9c96a5 Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81930 at gmail.com>
Date: Sun, 20 Jul 2025 18:58:56 +0530
Subject: [PATCH 1/6] feat: add bf16add{,f,l,f128} functions
Signed-off-by: Krishna Pandey <kpandey81930 at gmail.com>
---
libc/config/linux/x86_64/entrypoints.txt | 30 ++
libc/src/__support/FPUtil/bfloat16.h | 6 +
libc/src/math/CMakeLists.txt | 5 +
libc/src/math/bf16add.h | 21 ++
libc/src/math/bf16addf.h | 21 ++
libc/src/math/bf16addf128.h | 21 ++
libc/src/math/bf16addl.h | 21 ++
libc/src/math/bf16div.h | 21 ++
libc/src/math/bf16divf.h | 21 ++
libc/src/math/bf16divf128.h | 21 ++
libc/src/math/bf16divl.h | 21 ++
libc/src/math/bf16fma.h | 21 ++
libc/src/math/bf16fmaf.h | 21 ++
libc/src/math/bf16fmaf128.h | 21 ++
libc/src/math/bf16fmal.h | 21 ++
libc/src/math/bf16mul.h | 21 ++
libc/src/math/bf16mulf.h | 21 ++
libc/src/math/bf16mulf128.h | 21 ++
libc/src/math/bf16mull.h | 21 ++
libc/src/math/bf16sub.h | 21 ++
libc/src/math/bf16subf.h | 21 ++
libc/src/math/bf16subf128.h | 21 ++
libc/src/math/bf16subl.h | 21 ++
libc/src/math/generic/CMakeLists.txt | 56 ++++
libc/src/math/generic/bf16add.cpp | 22 ++
libc/src/math/generic/bf16addf.cpp | 22 ++
libc/src/math/generic/bf16addf128.cpp | 22 ++
libc/src/math/generic/bf16addl.cpp | 22 ++
libc/src/math/generic/bf16div.cpp | 22 ++
libc/src/math/generic/bf16divf.cpp | 22 ++
libc/src/math/generic/bf16divf128.cpp | 22 ++
libc/src/math/generic/bf16divl.cpp | 22 ++
libc/src/math/generic/bf16fma.cpp | 22 ++
libc/src/math/generic/bf16fmaf.cpp | 22 ++
libc/src/math/generic/bf16fmaf128.cpp | 23 ++
libc/src/math/generic/bf16fmal.cpp | 22 ++
libc/src/math/generic/bf16mul.cpp | 22 ++
libc/src/math/generic/bf16mulf.cpp | 22 ++
libc/src/math/generic/bf16mulf128.cpp | 22 ++
libc/src/math/generic/bf16mull.cpp | 22 ++
libc/src/math/generic/bf16sub.cpp | 22 ++
libc/src/math/generic/bf16subf.cpp | 22 ++
libc/src/math/generic/bf16subf128.cpp | 22 ++
libc/src/math/generic/bf16subl.cpp | 22 ++
libc/test/UnitTest/FPMatcher.h | 2 +-
libc/test/src/math/smoke/CMakeLists.txt | 256 ++++++++++++++++++
libc/test/src/math/smoke/bf16add_test.cpp | 15 +
libc/test/src/math/smoke/bf16addf128_test.cpp | 15 +
libc/test/src/math/smoke/bf16addf_test.cpp | 15 +
libc/test/src/math/smoke/bf16addl_test.cpp | 15 +
libc/test/src/math/smoke/bf16div_test.cpp | 15 +
libc/test/src/math/smoke/bf16divf128_test.cpp | 15 +
libc/test/src/math/smoke/bf16divf_test.cpp | 15 +
libc/test/src/math/smoke/bf16divl_test.cpp | 15 +
libc/test/src/math/smoke/bf16mul_test.cpp | 15 +
libc/test/src/math/smoke/bf16mulf128_test.cpp | 15 +
libc/test/src/math/smoke/bf16mulf_test.cpp | 15 +
libc/test/src/math/smoke/bf16mull_test.cpp | 15 +
libc/test/src/math/smoke/bf16sub_test.cpp | 15 +
libc/test/src/math/smoke/bf16subf128_test.cpp | 15 +
libc/test/src/math/smoke/bf16subf_test.cpp | 15 +
libc/test/src/math/smoke/bf16subl_test.cpp | 15 +
62 files changed, 1455 insertions(+), 1 deletion(-)
create mode 100644 libc/src/math/bf16add.h
create mode 100644 libc/src/math/bf16addf.h
create mode 100644 libc/src/math/bf16addf128.h
create mode 100644 libc/src/math/bf16addl.h
create mode 100644 libc/src/math/bf16div.h
create mode 100644 libc/src/math/bf16divf.h
create mode 100644 libc/src/math/bf16divf128.h
create mode 100644 libc/src/math/bf16divl.h
create mode 100644 libc/src/math/bf16fma.h
create mode 100644 libc/src/math/bf16fmaf.h
create mode 100644 libc/src/math/bf16fmaf128.h
create mode 100644 libc/src/math/bf16fmal.h
create mode 100644 libc/src/math/bf16mul.h
create mode 100644 libc/src/math/bf16mulf.h
create mode 100644 libc/src/math/bf16mulf128.h
create mode 100644 libc/src/math/bf16mull.h
create mode 100644 libc/src/math/bf16sub.h
create mode 100644 libc/src/math/bf16subf.h
create mode 100644 libc/src/math/bf16subf128.h
create mode 100644 libc/src/math/bf16subl.h
create mode 100644 libc/src/math/generic/bf16add.cpp
create mode 100644 libc/src/math/generic/bf16addf.cpp
create mode 100644 libc/src/math/generic/bf16addf128.cpp
create mode 100644 libc/src/math/generic/bf16addl.cpp
create mode 100644 libc/src/math/generic/bf16div.cpp
create mode 100644 libc/src/math/generic/bf16divf.cpp
create mode 100644 libc/src/math/generic/bf16divf128.cpp
create mode 100644 libc/src/math/generic/bf16divl.cpp
create mode 100644 libc/src/math/generic/bf16fma.cpp
create mode 100644 libc/src/math/generic/bf16fmaf.cpp
create mode 100644 libc/src/math/generic/bf16fmaf128.cpp
create mode 100644 libc/src/math/generic/bf16fmal.cpp
create mode 100644 libc/src/math/generic/bf16mul.cpp
create mode 100644 libc/src/math/generic/bf16mulf.cpp
create mode 100644 libc/src/math/generic/bf16mulf128.cpp
create mode 100644 libc/src/math/generic/bf16mull.cpp
create mode 100644 libc/src/math/generic/bf16sub.cpp
create mode 100644 libc/src/math/generic/bf16subf.cpp
create mode 100644 libc/src/math/generic/bf16subf128.cpp
create mode 100644 libc/src/math/generic/bf16subl.cpp
create mode 100644 libc/test/src/math/smoke/bf16add_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16addf128_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16addf_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16addl_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16div_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16divf128_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16divf_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16divl_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16mul_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16mulf128_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16mulf_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16mull_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16sub_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16subf128_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16subf_test.cpp
create mode 100644 libc/test/src/math/smoke/bf16subl_test.cpp
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 381359cec6f1d..b126053fc078c 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -891,6 +891,36 @@ if(LIBC_TYPES_HAS_FLOAT128)
)
endif()
+list(APPEND TARGET_LIBM_ENTRYPOINTS
+ # Bfloat16 Entrypoints
+ libc.src.math.bf16add
+ libc.src.math.bf16addf
+ libc.src.math.bf16addl
+ libc.src.math.bf16div
+ libc.src.math.bf16divf
+ libc.src.math.bf16divl
+ libc.src.math.bf16fma
+ libc.src.math.bf16fmaf
+ libc.src.math.bf16fmal
+ libc.src.math.bf16mul
+ libc.src.math.bf16mulf
+ libc.src.math.bf16mull
+ libc.src.math.bf16sub
+ libc.src.math.bf16subf
+ libc.src.math.bf16subl
+)
+
+if(LIBC_TYPES_HAS_FLOAT128)
+ list(APPEND TARGET_LIBM_ENTRYPOINTS
+ # math.h C++23 mixed bfloat16 and _Float128 entrypoints
+ libc.src.math.bf16addf128
+ libc.src.math.bf16divf128
+ libc.src.math.bf16fmaf128
+ libc.src.math.bf16mulf128
+ libc.src.math.bf16subf128
+ )
+endif()
+
if(LIBC_COMPILER_HAS_FIXED_POINT)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# stdfix.h _Fract and _Accum entrypoints
diff --git a/libc/src/__support/FPUtil/bfloat16.h b/libc/src/__support/FPUtil/bfloat16.h
index bc0b8b23896fc..7f42d3d8afafb 100644
--- a/libc/src/__support/FPUtil/bfloat16.h
+++ b/libc/src/__support/FPUtil/bfloat16.h
@@ -57,6 +57,12 @@ struct BFloat16 {
uint32_t x_bits = static_cast<uint32_t>(bits) << 16U;
return cpp::bit_cast<float>(x_bits);
}
+
+ LIBC_INLINE constexpr BFloat16 operator-() const {
+ fputil::FPBits<bfloat16> result(*this);
+ result.set_sign(result.is_pos() ? Sign::NEG : Sign::POS);
+ return result.get_val();
+ }
}; // struct BFloat16
} // namespace fputil
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 455ad3456573a..cc736cd5d1c13 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -557,3 +557,8 @@ add_math_entrypoint_object(ufromfpxf)
add_math_entrypoint_object(ufromfpxl)
add_math_entrypoint_object(ufromfpxf16)
add_math_entrypoint_object(ufromfpxf128)
+
+add_math_entrypoint_object(bf16add)
+add_math_entrypoint_object(bf16addf)
+add_math_entrypoint_object(bf16addl)
+add_math_entrypoint_object(bf16addf128)
diff --git a/libc/src/math/bf16add.h b/libc/src/math/bf16add.h
new file mode 100644
index 0000000000000..a29970eb334fa
--- /dev/null
+++ b/libc/src/math/bf16add.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16add -----------------------*- 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_BF16ADD_H
+#define LLVM_LIBC_SRC_MATH_BF16ADD_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16add(double x, double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16ADD_H
diff --git a/libc/src/math/bf16addf.h b/libc/src/math/bf16addf.h
new file mode 100644
index 0000000000000..80a5e2a7640df
--- /dev/null
+++ b/libc/src/math/bf16addf.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16addf ----------------------*- 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_BF16ADDF_H
+#define LLVM_LIBC_SRC_MATH_BF16ADDF_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16addf(float x, float y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16ADDF_H
diff --git a/libc/src/math/bf16addf128.h b/libc/src/math/bf16addf128.h
new file mode 100644
index 0000000000000..3c2f3a15eb39c
--- /dev/null
+++ b/libc/src/math/bf16addf128.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16addf128 -------------------*- 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_BF16ADDF128_H
+#define LLVM_LIBC_SRC_MATH_BF16ADDF128_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16addf128(float128 x, float128 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16ADDF128_H
diff --git a/libc/src/math/bf16addl.h b/libc/src/math/bf16addl.h
new file mode 100644
index 0000000000000..a9e7d68660728
--- /dev/null
+++ b/libc/src/math/bf16addl.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16addl ----------------------*- 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_BF16ADDL_H
+#define LLVM_LIBC_SRC_MATH_BF16ADDL_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16addl(long double x, long double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16ADDL_H
diff --git a/libc/src/math/bf16div.h b/libc/src/math/bf16div.h
new file mode 100644
index 0000000000000..ade9c067d3c3a
--- /dev/null
+++ b/libc/src/math/bf16div.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16div -----------------------*- 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_BF16DIV_H
+#define LLVM_LIBC_SRC_MATH_BF16DIV_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16div(double x, double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16DIV_H
diff --git a/libc/src/math/bf16divf.h b/libc/src/math/bf16divf.h
new file mode 100644
index 0000000000000..481b176e01ea3
--- /dev/null
+++ b/libc/src/math/bf16divf.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16divf ----------------------*- 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_BF16DIVF_H
+#define LLVM_LIBC_SRC_MATH_BF16DIVF_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16divf(float x, float y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16DIVF_H
diff --git a/libc/src/math/bf16divf128.h b/libc/src/math/bf16divf128.h
new file mode 100644
index 0000000000000..d99006695d1d7
--- /dev/null
+++ b/libc/src/math/bf16divf128.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16divf128 -------------------*- 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_BF16DIVF128_H
+#define LLVM_LIBC_SRC_MATH_BF16DIVF128_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16divf128(float128 x, float128 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16DIVF128_H
diff --git a/libc/src/math/bf16divl.h b/libc/src/math/bf16divl.h
new file mode 100644
index 0000000000000..b19ac873af3f0
--- /dev/null
+++ b/libc/src/math/bf16divl.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16divl ----------------------*- 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_BF16DIVL_H
+#define LLVM_LIBC_SRC_MATH_BF16DIVL_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16divl(long double x, long double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16DIVL_H
diff --git a/libc/src/math/bf16fma.h b/libc/src/math/bf16fma.h
new file mode 100644
index 0000000000000..aa54956ef4783
--- /dev/null
+++ b/libc/src/math/bf16fma.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16fma -----------------------*- 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_BF16FMA_H
+#define LLVM_LIBC_SRC_MATH_BF16FMA_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16fma(double x, double y, double z);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16FMA_H
diff --git a/libc/src/math/bf16fmaf.h b/libc/src/math/bf16fmaf.h
new file mode 100644
index 0000000000000..e8582bd6dff5f
--- /dev/null
+++ b/libc/src/math/bf16fmaf.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16fmaf ----------------------*- 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_BF16FMAF_H
+#define LLVM_LIBC_SRC_MATH_BF16FMAF_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16fmaf(float x, float y, float z);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16FMAF_H
diff --git a/libc/src/math/bf16fmaf128.h b/libc/src/math/bf16fmaf128.h
new file mode 100644
index 0000000000000..4215e54c82ff5
--- /dev/null
+++ b/libc/src/math/bf16fmaf128.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16fmaf128 -------------------*- 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_BF16FMAF128_H
+#define LLVM_LIBC_SRC_MATH_BF16FMAF128_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16fmaf128(float128 x, float128 y, float128 z);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16FMAF128_H
diff --git a/libc/src/math/bf16fmal.h b/libc/src/math/bf16fmal.h
new file mode 100644
index 0000000000000..b92f17b7ee8d6
--- /dev/null
+++ b/libc/src/math/bf16fmal.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16fmal ----------------------*- 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_BF16FMAL_H
+#define LLVM_LIBC_SRC_MATH_BF16FMAL_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16fmal(long double x, long double y, long double z);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16FMAL_H
diff --git a/libc/src/math/bf16mul.h b/libc/src/math/bf16mul.h
new file mode 100644
index 0000000000000..14e8a304c2b6c
--- /dev/null
+++ b/libc/src/math/bf16mul.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16mul -----------------------*- 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_BF16MUL_H
+#define LLVM_LIBC_SRC_MATH_BF16MUL_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16mul(double x, double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16MUL_H
diff --git a/libc/src/math/bf16mulf.h b/libc/src/math/bf16mulf.h
new file mode 100644
index 0000000000000..1d02c8e796b17
--- /dev/null
+++ b/libc/src/math/bf16mulf.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16mulf ----------------------*- 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_BF16MULF_H
+#define LLVM_LIBC_SRC_MATH_BF16MULF_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16mulf(float x, float y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16MULF_H
diff --git a/libc/src/math/bf16mulf128.h b/libc/src/math/bf16mulf128.h
new file mode 100644
index 0000000000000..6ba7cefb2ee8e
--- /dev/null
+++ b/libc/src/math/bf16mulf128.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16mulf128 -------------------*- 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_BF16MULF128_H
+#define LLVM_LIBC_SRC_MATH_BF16MULF128_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16mulf128(float128 x, float128 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16MULF128_H
diff --git a/libc/src/math/bf16mull.h b/libc/src/math/bf16mull.h
new file mode 100644
index 0000000000000..dad65236ce05d
--- /dev/null
+++ b/libc/src/math/bf16mull.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16mull ----------------------*- 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_BF16MULL_H
+#define LLVM_LIBC_SRC_MATH_BF16MULL_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16mull(long double x, long double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16MULL_H
diff --git a/libc/src/math/bf16sub.h b/libc/src/math/bf16sub.h
new file mode 100644
index 0000000000000..8108e9146859f
--- /dev/null
+++ b/libc/src/math/bf16sub.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16sub -----------------------*- 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_BF16SUB_H
+#define LLVM_LIBC_SRC_MATH_BF16SUB_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16sub(double x, double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16SUB_H
diff --git a/libc/src/math/bf16subf.h b/libc/src/math/bf16subf.h
new file mode 100644
index 0000000000000..1bd79bfe119ce
--- /dev/null
+++ b/libc/src/math/bf16subf.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16subf ----------------------*- 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_BF16SUBF_H
+#define LLVM_LIBC_SRC_MATH_BF16SUBF_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16subf(float x, float y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16SUBF_H
diff --git a/libc/src/math/bf16subf128.h b/libc/src/math/bf16subf128.h
new file mode 100644
index 0000000000000..19590e8c67508
--- /dev/null
+++ b/libc/src/math/bf16subf128.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16subf128 -------------------*- 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_BF16SUBF128_H
+#define LLVM_LIBC_SRC_MATH_BF16SUBF128_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16subf128(float128 x, float128 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16SUBF128_H
diff --git a/libc/src/math/bf16subl.h b/libc/src/math/bf16subl.h
new file mode 100644
index 0000000000000..13b2093a92ffa
--- /dev/null
+++ b/libc/src/math/bf16subl.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for bf16subl ----------------------*- 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_BF16SUBL_H
+#define LLVM_LIBC_SRC_MATH_BF16SUBL_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 bf16subl(long double x, long double y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_BF16SUBL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 7e6a32b7cdf16..4bc08552a7b3a 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4995,3 +4995,59 @@ add_header_library(
libc.src.__support.math.expf16_utils
libc.src.__support.math.exp10_float16_constants
)
+
+add_entrypoint_object(
+ bf16add
+ SRCS
+ bf16add.cpp
+ HDRS
+ ../bf16add.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_entrypoint_object(
+ bf16addf
+ SRCS
+ bf16addf.cpp
+ HDRS
+ ../bf16addf.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_entrypoint_object(
+ bf16addl
+ SRCS
+ bf16addl.cpp
+ HDRS
+ ../bf16addl.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_entrypoint_object(
+ bf16addf128
+ SRCS
+ bf16addf128.cpp
+ HDRS
+ ../bf16addf128.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
diff --git a/libc/src/math/generic/bf16add.cpp b/libc/src/math/generic/bf16add.cpp
new file mode 100644
index 0000000000000..6010135ddc1d8
--- /dev/null
+++ b/libc/src/math/generic/bf16add.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16add 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/bf16add.h"
+
+#include "src/__support/common.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16add, (double x, double y)) {
+ return fputil::generic::add<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16addf.cpp b/libc/src/math/generic/bf16addf.cpp
new file mode 100644
index 0000000000000..1e2a868bddef3
--- /dev/null
+++ b/libc/src/math/generic/bf16addf.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16addf 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/bf16addf.h"
+
+#include "src/__support/common.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16addf, (float x, float y)) {
+ return fputil::generic::add<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16addf128.cpp b/libc/src/math/generic/bf16addf128.cpp
new file mode 100644
index 0000000000000..aec690a5a7b93
--- /dev/null
+++ b/libc/src/math/generic/bf16addf128.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16addf128 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/bf16addf128.h"
+
+#include "src/__support/common.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16addf128, (float128 x, float128 y)) {
+ return fputil::generic::add<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16addl.cpp b/libc/src/math/generic/bf16addl.cpp
new file mode 100644
index 0000000000000..82007aed6c570
--- /dev/null
+++ b/libc/src/math/generic/bf16addl.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16addl 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/bf16addl.h"
+
+#include "src/__support/common.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16addl, (long double x, long double y)) {
+ return fputil::generic::add<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16div.cpp b/libc/src/math/generic/bf16div.cpp
new file mode 100644
index 0000000000000..c052d7bc7af16
--- /dev/null
+++ b/libc/src/math/generic/bf16div.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16div 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/bf16div.h"
+
+#include "src/__support/FPUtil/bfloat16.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(bfloat16, bf16div, (double x, double y)) {
+ return fputil::generic::div<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16divf.cpp b/libc/src/math/generic/bf16divf.cpp
new file mode 100644
index 0000000000000..a1e258a51fbdd
--- /dev/null
+++ b/libc/src/math/generic/bf16divf.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16divf 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/bf16divf.h"
+
+#include "src/__support/FPUtil/bfloat16.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(bfloat16, bf16divf, (float x, float y)) {
+ return fputil::generic::div<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16divf128.cpp b/libc/src/math/generic/bf16divf128.cpp
new file mode 100644
index 0000000000000..6ef6cb18af5bd
--- /dev/null
+++ b/libc/src/math/generic/bf16divf128.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16divf128 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/bf16divf128.h"
+
+#include "src/__support/FPUtil/bfloat16.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(bfloat16, bf16divf128, (float128 x, float128 y)) {
+ return fputil::generic::div<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16divl.cpp b/libc/src/math/generic/bf16divl.cpp
new file mode 100644
index 0000000000000..aca2c9e4aa66b
--- /dev/null
+++ b/libc/src/math/generic/bf16divl.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16divl 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/bf16divl.h"
+
+#include "src/__support/FPUtil/bfloat16.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(bfloat16, bf16divl, (long double x, long double y)) {
+ return fputil::generic::div<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16fma.cpp b/libc/src/math/generic/bf16fma.cpp
new file mode 100644
index 0000000000000..cd5b4bfbfc0f2
--- /dev/null
+++ b/libc/src/math/generic/bf16fma.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16fma 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/bf16fma.h"
+
+#include "src/__support/FPUtil/FMA.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16fma, (double x, double y, double z)) {
+ return fputil::fma<bfloat16>(x, y, z);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16fmaf.cpp b/libc/src/math/generic/bf16fmaf.cpp
new file mode 100644
index 0000000000000..421ec4421be98
--- /dev/null
+++ b/libc/src/math/generic/bf16fmaf.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16fmaf 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/bf16fmaf.h"
+
+#include "src/__support/FPUtil/FMA.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16fmaf, (float x, float y, float z)) {
+ return fputil::fma<bfloat16>(x, y, z);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16fmaf128.cpp b/libc/src/math/generic/bf16fmaf128.cpp
new file mode 100644
index 0000000000000..61f6538ca45a2
--- /dev/null
+++ b/libc/src/math/generic/bf16fmaf128.cpp
@@ -0,0 +1,23 @@
+//===-- Implementation of bf16fmaf128 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/bf16fmaf128.h"
+
+#include "src/__support/FPUtil/FMA.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16fmaf128,
+ (float128 x, float128 y, float128 z)) {
+ return fputil::fma<bfloat16>(x, y, z);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16fmal.cpp b/libc/src/math/generic/bf16fmal.cpp
new file mode 100644
index 0000000000000..f31ec6904760b
--- /dev/null
+++ b/libc/src/math/generic/bf16fmal.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16fmal 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/bf16fmal.h"
+
+#include "src/__support/FPUtil/FMA.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16fmal,
+ (long double x, long double y, long double z)) {
+ return fputil::fma<bfloat16>(x, y, z);
+}
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16mul.cpp b/libc/src/math/generic/bf16mul.cpp
new file mode 100644
index 0000000000000..37862cfa3f96c
--- /dev/null
+++ b/libc/src/math/generic/bf16mul.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16mul 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/bf16mul.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/mul.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16mul, (double x, double y)) {
+ return fputil::generic::mul<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16mulf.cpp b/libc/src/math/generic/bf16mulf.cpp
new file mode 100644
index 0000000000000..2cf70376949c2
--- /dev/null
+++ b/libc/src/math/generic/bf16mulf.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16mulf 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/bf16mulf.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/mul.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16mulf, (float x, float y)) {
+ return fputil::generic::mul<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16mulf128.cpp b/libc/src/math/generic/bf16mulf128.cpp
new file mode 100644
index 0000000000000..c34f760133388
--- /dev/null
+++ b/libc/src/math/generic/bf16mulf128.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16mulf128 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/bf16mulf128.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/mul.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16mulf128, (float128 x, float128 y)) {
+ return fputil::generic::mul<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16mull.cpp b/libc/src/math/generic/bf16mull.cpp
new file mode 100644
index 0000000000000..97a170152565b
--- /dev/null
+++ b/libc/src/math/generic/bf16mull.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16mull 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/bf16mull.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/mul.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16mull, (long double x, long double y)) {
+ return fputil::generic::mul<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16sub.cpp b/libc/src/math/generic/bf16sub.cpp
new file mode 100644
index 0000000000000..5148f3657abaf
--- /dev/null
+++ b/libc/src/math/generic/bf16sub.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16sub 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/bf16sub.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16sub, (double x, double y)) {
+ return fputil::generic::sub<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16subf.cpp b/libc/src/math/generic/bf16subf.cpp
new file mode 100644
index 0000000000000..dc303329b1dbd
--- /dev/null
+++ b/libc/src/math/generic/bf16subf.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16subf 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/bf16subf.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16subf, (float x, float y)) {
+ return fputil::generic::sub<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16subf128.cpp b/libc/src/math/generic/bf16subf128.cpp
new file mode 100644
index 0000000000000..931c952386597
--- /dev/null
+++ b/libc/src/math/generic/bf16subf128.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16subf128 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/bf16subf128.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16subf128, (float128 x, float128 y)) {
+ return fputil::generic::sub<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16subl.cpp b/libc/src/math/generic/bf16subl.cpp
new file mode 100644
index 0000000000000..315675640194f
--- /dev/null
+++ b/libc/src/math/generic/bf16subl.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of bf16subl 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/bf16subl.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(bfloat16, bf16subl, (long double x, long double y)) {
+ return fputil::generic::sub<bfloat16>(x, y);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h
index da15cf2907f7c..5f02b0ecdba26 100644
--- a/libc/test/UnitTest/FPMatcher.h
+++ b/libc/test/UnitTest/FPMatcher.h
@@ -262,7 +262,7 @@ struct ModifyMXCSR {
expected) \
.match(actual)
-#define EXPECT_FP_IS_NAN(actual) EXPECT_TRUE((actual) != (actual))
+#define EXPECT_FP_IS_NAN(actual) EXPECT_TRUE(FPBits(actual).is_nan())
#define ASSERT_FP_EQ(expected, actual) \
ASSERT_THAT(actual, LIBC_NAMESPACE::testing::getMatcher< \
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 4aafe03d1d08b..9949a9318e4c1 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -5329,3 +5329,259 @@ add_fp_unittest(
libc.src.__support.macros.properties.os
libc.src.__support.macros.properties.types
)
+
+add_fp_unittest(
+ bf16add_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16add_test.cpp
+ HDRS
+ AddTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16add
+)
+
+add_fp_unittest(
+ bf16addf_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16addf_test.cpp
+ HDRS
+ AddTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16addf
+)
+
+add_fp_unittest(
+ bf16addl_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16addl_test.cpp
+ HDRS
+ AddTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16addl
+)
+
+add_fp_unittest(
+ bf16addf128_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16addf128_test.cpp
+ HDRS
+ AddTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16addf128
+)
+
+add_fp_unittest(
+ bf16div_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16div_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16div
+)
+
+add_fp_unittest(
+ bf16divf_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16divf_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16divf
+)
+
+add_fp_unittest(
+ bf16divl_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16divl_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16divl
+)
+
+add_fp_unittest(
+ bf16divf128_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16divf128_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16divf128
+)
+
+add_fp_unittest(
+ bf16mul_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16mul_test.cpp
+ HDRS
+ MulTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16mul
+)
+
+add_fp_unittest(
+ bf16mulf_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16mulf_test.cpp
+ HDRS
+ MulTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16mulf
+)
+
+add_fp_unittest(
+ bf16mull_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16mull_test.cpp
+ HDRS
+ MulTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16mull
+)
+
+add_fp_unittest(
+ bf16mulf128_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16mulf128_test.cpp
+ HDRS
+ MulTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16mulf128
+)
+
+add_fp_unittest(
+ bf16sub_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16sub_test.cpp
+ HDRS
+ SubTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16sub
+)
+
+add_fp_unittest(
+ bf16subf_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16subf_test.cpp
+ HDRS
+ SubTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16subf
+)
+
+add_fp_unittest(
+ bf16subl_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16subl_test.cpp
+ HDRS
+ SubTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16subl
+)
+
+add_fp_unittest(
+ bf16subf128_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ bf16subf128_test.cpp
+ HDRS
+ SubTest.h
+ DEPENDS
+ libc.hdr.errno_macros
+ libc.hdr.fenv_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.properties.os
+ libc.src.math.bf16subf128
+)
diff --git a/libc/test/src/math/smoke/bf16add_test.cpp b/libc/test/src/math/smoke/bf16add_test.cpp
new file mode 100644
index 0000000000000..ff1e4ca325ab7
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16add_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16add ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AddTest.h"
+
+#include "src/math/bf16add.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_ADD_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16add)
diff --git a/libc/test/src/math/smoke/bf16addf128_test.cpp b/libc/test/src/math/smoke/bf16addf128_test.cpp
new file mode 100644
index 0000000000000..5a168604d9bfb
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16addf128_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16addf128 -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AddTest.h"
+
+#include "src/math/bf16addf128.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_ADD_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16addf128)
diff --git a/libc/test/src/math/smoke/bf16addf_test.cpp b/libc/test/src/math/smoke/bf16addf_test.cpp
new file mode 100644
index 0000000000000..a3fbd45275680
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16addf_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16addf --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AddTest.h"
+
+#include "src/math/bf16addf.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_ADD_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16addf)
diff --git a/libc/test/src/math/smoke/bf16addl_test.cpp b/libc/test/src/math/smoke/bf16addl_test.cpp
new file mode 100644
index 0000000000000..ad375a6e3914e
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16addl_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16addl --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AddTest.h"
+
+#include "src/math/bf16addl.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_ADD_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16addl)
diff --git a/libc/test/src/math/smoke/bf16div_test.cpp b/libc/test/src/math/smoke/bf16div_test.cpp
new file mode 100644
index 0000000000000..eb6b909270853
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16div_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16div ---------------------------------------------===//
+//
+// 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/bf16div.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_DIV_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16div)
diff --git a/libc/test/src/math/smoke/bf16divf128_test.cpp b/libc/test/src/math/smoke/bf16divf128_test.cpp
new file mode 100644
index 0000000000000..d907230c736a2
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16divf128_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16divf128 -----------------------------------------===//
+//
+// 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/bf16divf128.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_DIV_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16divf128)
diff --git a/libc/test/src/math/smoke/bf16divf_test.cpp b/libc/test/src/math/smoke/bf16divf_test.cpp
new file mode 100644
index 0000000000000..10194563d670c
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16divf_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16divf --------------------------------------------===//
+//
+// 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/bf16divf.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_DIV_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16divf)
diff --git a/libc/test/src/math/smoke/bf16divl_test.cpp b/libc/test/src/math/smoke/bf16divl_test.cpp
new file mode 100644
index 0000000000000..7261279bf9c81
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16divl_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16divl --------------------------------------------===//
+//
+// 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/bf16divl.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_DIV_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16divl)
diff --git a/libc/test/src/math/smoke/bf16mul_test.cpp b/libc/test/src/math/smoke/bf16mul_test.cpp
new file mode 100644
index 0000000000000..3682705556b0a
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16mul_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16mul ---------------------------------------------===//
+//
+// 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 "MulTest.h"
+
+#include "src/math/bf16mul.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_MUL_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16mul)
diff --git a/libc/test/src/math/smoke/bf16mulf128_test.cpp b/libc/test/src/math/smoke/bf16mulf128_test.cpp
new file mode 100644
index 0000000000000..6aee2687ae67a
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16mulf128_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16mulf128 -----------------------------------------===//
+//
+// 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 "MulTest.h"
+
+#include "src/math/bf16mulf128.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_MUL_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16mulf128)
diff --git a/libc/test/src/math/smoke/bf16mulf_test.cpp b/libc/test/src/math/smoke/bf16mulf_test.cpp
new file mode 100644
index 0000000000000..048b60f8e85cf
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16mulf_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16mulf --------------------------------------------===//
+//
+// 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 "MulTest.h"
+
+#include "src/math/bf16mulf.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_MUL_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16mulf)
diff --git a/libc/test/src/math/smoke/bf16mull_test.cpp b/libc/test/src/math/smoke/bf16mull_test.cpp
new file mode 100644
index 0000000000000..b8439b245c261
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16mull_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16mull --------------------------------------------===//
+//
+// 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 "MulTest.h"
+
+#include "src/math/bf16mull.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_MUL_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16mull)
diff --git a/libc/test/src/math/smoke/bf16sub_test.cpp b/libc/test/src/math/smoke/bf16sub_test.cpp
new file mode 100644
index 0000000000000..83b0315c217c3
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16sub_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16sub ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SubTest.h"
+
+#include "src/math/bf16sub.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_SUB_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16sub)
diff --git a/libc/test/src/math/smoke/bf16subf128_test.cpp b/libc/test/src/math/smoke/bf16subf128_test.cpp
new file mode 100644
index 0000000000000..e99d4d1bb3b2a
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16subf128_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16subf128 -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SubTest.h"
+
+#include "src/math/bf16subf128.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_SUB_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16subf128)
diff --git a/libc/test/src/math/smoke/bf16subf_test.cpp b/libc/test/src/math/smoke/bf16subf_test.cpp
new file mode 100644
index 0000000000000..df4edbdf34a21
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16subf_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16subf --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SubTest.h"
+
+#include "src/math/bf16subf.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_SUB_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16subf)
diff --git a/libc/test/src/math/smoke/bf16subl_test.cpp b/libc/test/src/math/smoke/bf16subl_test.cpp
new file mode 100644
index 0000000000000..81516e8706492
--- /dev/null
+++ b/libc/test/src/math/smoke/bf16subl_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for bf16subl --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SubTest.h"
+
+#include "src/math/bf16subl.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+
+LIST_SUB_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16subl)
>From 797815a175ef5b4bba080829b1419b8024bad2ff Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81930 at gmail.com>
Date: Sun, 20 Jul 2025 19:52:10 +0530
Subject: [PATCH 2/6] feat: implement bf16sub{,f,l,f128} functions
Signed-off-by: Krishna Pandey <kpandey81930 at gmail.com>
---
libc/config/linux/x86_64/entrypoints.txt | 12 -----
libc/src/math/CMakeLists.txt | 5 +++
libc/src/math/generic/CMakeLists.txt | 57 ++++++++++++++++++++++++
libc/src/math/generic/bf16add.cpp | 2 +-
libc/src/math/generic/bf16addf.cpp | 2 +-
libc/src/math/generic/bf16addf128.cpp | 2 +-
libc/src/math/generic/bf16addl.cpp | 2 +-
7 files changed, 66 insertions(+), 16 deletions(-)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index b126053fc078c..c353f8a0a8b32 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -896,15 +896,6 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16add
libc.src.math.bf16addf
libc.src.math.bf16addl
- libc.src.math.bf16div
- libc.src.math.bf16divf
- libc.src.math.bf16divl
- libc.src.math.bf16fma
- libc.src.math.bf16fmaf
- libc.src.math.bf16fmal
- libc.src.math.bf16mul
- libc.src.math.bf16mulf
- libc.src.math.bf16mull
libc.src.math.bf16sub
libc.src.math.bf16subf
libc.src.math.bf16subl
@@ -914,9 +905,6 @@ if(LIBC_TYPES_HAS_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C++23 mixed bfloat16 and _Float128 entrypoints
libc.src.math.bf16addf128
- libc.src.math.bf16divf128
- libc.src.math.bf16fmaf128
- libc.src.math.bf16mulf128
libc.src.math.bf16subf128
)
endif()
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index cc736cd5d1c13..36e7267beb576 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -562,3 +562,8 @@ add_math_entrypoint_object(bf16add)
add_math_entrypoint_object(bf16addf)
add_math_entrypoint_object(bf16addl)
add_math_entrypoint_object(bf16addf128)
+
+add_math_entrypoint_object(bf16sub)
+add_math_entrypoint_object(bf16subf)
+add_math_entrypoint_object(bf16subl)
+add_math_entrypoint_object(bf16subf128)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 4bc08552a7b3a..37f03ddf2610b 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -5051,3 +5051,60 @@ add_entrypoint_object(
libc.src.__support.macros.config
libc.src.__support.macros.properties.types
)
+
+
+add_entrypoint_object(
+ bf16sub
+ SRCS
+ bf16sub.cpp
+ HDRS
+ ../bf16sub.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_entrypoint_object(
+ bf16subf
+ SRCS
+ bf16subf.cpp
+ HDRS
+ ../bf16subf.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_entrypoint_object(
+ bf16subl
+ SRCS
+ bf16subl.cpp
+ HDRS
+ ../bf16subl.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_entrypoint_object(
+ bf16subf128
+ SRCS
+ bf16subf128.cpp
+ HDRS
+ ../bf16subf128.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
diff --git a/libc/src/math/generic/bf16add.cpp b/libc/src/math/generic/bf16add.cpp
index 6010135ddc1d8..686848576f7a5 100644
--- a/libc/src/math/generic/bf16add.cpp
+++ b/libc/src/math/generic/bf16add.cpp
@@ -8,9 +8,9 @@
#include "src/math/bf16add.h"
-#include "src/__support/common.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/math/generic/bf16addf.cpp b/libc/src/math/generic/bf16addf.cpp
index 1e2a868bddef3..cd57a5ffad53d 100644
--- a/libc/src/math/generic/bf16addf.cpp
+++ b/libc/src/math/generic/bf16addf.cpp
@@ -8,9 +8,9 @@
#include "src/math/bf16addf.h"
-#include "src/__support/common.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/math/generic/bf16addf128.cpp b/libc/src/math/generic/bf16addf128.cpp
index aec690a5a7b93..ff94d3aff1581 100644
--- a/libc/src/math/generic/bf16addf128.cpp
+++ b/libc/src/math/generic/bf16addf128.cpp
@@ -8,9 +8,9 @@
#include "src/math/bf16addf128.h"
-#include "src/__support/common.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/math/generic/bf16addl.cpp b/libc/src/math/generic/bf16addl.cpp
index 82007aed6c570..7f053c1870d9b 100644
--- a/libc/src/math/generic/bf16addl.cpp
+++ b/libc/src/math/generic/bf16addl.cpp
@@ -8,9 +8,9 @@
#include "src/math/bf16addl.h"
-#include "src/__support/common.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/common.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
>From 73a9b9c8ec14efd7d38d6c88b280b0f5aebf8fde Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81930 at gmail.com>
Date: Fri, 8 Aug 2025 22:11:50 +0530
Subject: [PATCH 3/6] refactor: remove redundant files
Signed-off-by: Krishna Pandey <kpandey81930 at gmail.com>
---
libc/src/math/bf16div.h | 21 ---
libc/src/math/bf16divf.h | 21 ---
libc/src/math/bf16divf128.h | 21 ---
libc/src/math/bf16divl.h | 21 ---
libc/src/math/bf16fma.h | 21 ---
libc/src/math/bf16fmaf.h | 21 ---
libc/src/math/bf16fmaf128.h | 21 ---
libc/src/math/bf16fmal.h | 21 ---
libc/src/math/bf16mul.h | 21 ---
libc/src/math/bf16mulf.h | 21 ---
libc/src/math/bf16mulf128.h | 21 ---
libc/src/math/bf16mull.h | 21 ---
libc/src/math/generic/bf16div.cpp | 22 ---
libc/src/math/generic/bf16divf.cpp | 22 ---
libc/src/math/generic/bf16divf128.cpp | 22 ---
libc/src/math/generic/bf16divl.cpp | 22 ---
libc/src/math/generic/bf16fma.cpp | 22 ---
libc/src/math/generic/bf16fmaf.cpp | 22 ---
libc/src/math/generic/bf16fmaf128.cpp | 23 ----
libc/src/math/generic/bf16fmal.cpp | 22 ---
libc/src/math/generic/bf16mul.cpp | 22 ---
libc/src/math/generic/bf16mulf.cpp | 22 ---
libc/src/math/generic/bf16mulf128.cpp | 22 ---
libc/src/math/generic/bf16mull.cpp | 22 ---
libc/test/src/math/smoke/CMakeLists.txt | 128 ------------------
libc/test/src/math/smoke/bf16div_test.cpp | 15 --
libc/test/src/math/smoke/bf16divf128_test.cpp | 15 --
libc/test/src/math/smoke/bf16divf_test.cpp | 15 --
libc/test/src/math/smoke/bf16divl_test.cpp | 15 --
libc/test/src/math/smoke/bf16mul_test.cpp | 15 --
libc/test/src/math/smoke/bf16mulf128_test.cpp | 15 --
libc/test/src/math/smoke/bf16mulf_test.cpp | 15 --
libc/test/src/math/smoke/bf16mull_test.cpp | 15 --
33 files changed, 765 deletions(-)
delete mode 100644 libc/src/math/bf16div.h
delete mode 100644 libc/src/math/bf16divf.h
delete mode 100644 libc/src/math/bf16divf128.h
delete mode 100644 libc/src/math/bf16divl.h
delete mode 100644 libc/src/math/bf16fma.h
delete mode 100644 libc/src/math/bf16fmaf.h
delete mode 100644 libc/src/math/bf16fmaf128.h
delete mode 100644 libc/src/math/bf16fmal.h
delete mode 100644 libc/src/math/bf16mul.h
delete mode 100644 libc/src/math/bf16mulf.h
delete mode 100644 libc/src/math/bf16mulf128.h
delete mode 100644 libc/src/math/bf16mull.h
delete mode 100644 libc/src/math/generic/bf16div.cpp
delete mode 100644 libc/src/math/generic/bf16divf.cpp
delete mode 100644 libc/src/math/generic/bf16divf128.cpp
delete mode 100644 libc/src/math/generic/bf16divl.cpp
delete mode 100644 libc/src/math/generic/bf16fma.cpp
delete mode 100644 libc/src/math/generic/bf16fmaf.cpp
delete mode 100644 libc/src/math/generic/bf16fmaf128.cpp
delete mode 100644 libc/src/math/generic/bf16fmal.cpp
delete mode 100644 libc/src/math/generic/bf16mul.cpp
delete mode 100644 libc/src/math/generic/bf16mulf.cpp
delete mode 100644 libc/src/math/generic/bf16mulf128.cpp
delete mode 100644 libc/src/math/generic/bf16mull.cpp
delete mode 100644 libc/test/src/math/smoke/bf16div_test.cpp
delete mode 100644 libc/test/src/math/smoke/bf16divf128_test.cpp
delete mode 100644 libc/test/src/math/smoke/bf16divf_test.cpp
delete mode 100644 libc/test/src/math/smoke/bf16divl_test.cpp
delete mode 100644 libc/test/src/math/smoke/bf16mul_test.cpp
delete mode 100644 libc/test/src/math/smoke/bf16mulf128_test.cpp
delete mode 100644 libc/test/src/math/smoke/bf16mulf_test.cpp
delete mode 100644 libc/test/src/math/smoke/bf16mull_test.cpp
diff --git a/libc/src/math/bf16div.h b/libc/src/math/bf16div.h
deleted file mode 100644
index ade9c067d3c3a..0000000000000
--- a/libc/src/math/bf16div.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16div -----------------------*- 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_BF16DIV_H
-#define LLVM_LIBC_SRC_MATH_BF16DIV_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16div(double x, double y);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16DIV_H
diff --git a/libc/src/math/bf16divf.h b/libc/src/math/bf16divf.h
deleted file mode 100644
index 481b176e01ea3..0000000000000
--- a/libc/src/math/bf16divf.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16divf ----------------------*- 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_BF16DIVF_H
-#define LLVM_LIBC_SRC_MATH_BF16DIVF_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16divf(float x, float y);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16DIVF_H
diff --git a/libc/src/math/bf16divf128.h b/libc/src/math/bf16divf128.h
deleted file mode 100644
index d99006695d1d7..0000000000000
--- a/libc/src/math/bf16divf128.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16divf128 -------------------*- 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_BF16DIVF128_H
-#define LLVM_LIBC_SRC_MATH_BF16DIVF128_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16divf128(float128 x, float128 y);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16DIVF128_H
diff --git a/libc/src/math/bf16divl.h b/libc/src/math/bf16divl.h
deleted file mode 100644
index b19ac873af3f0..0000000000000
--- a/libc/src/math/bf16divl.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16divl ----------------------*- 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_BF16DIVL_H
-#define LLVM_LIBC_SRC_MATH_BF16DIVL_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16divl(long double x, long double y);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16DIVL_H
diff --git a/libc/src/math/bf16fma.h b/libc/src/math/bf16fma.h
deleted file mode 100644
index aa54956ef4783..0000000000000
--- a/libc/src/math/bf16fma.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16fma -----------------------*- 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_BF16FMA_H
-#define LLVM_LIBC_SRC_MATH_BF16FMA_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16fma(double x, double y, double z);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16FMA_H
diff --git a/libc/src/math/bf16fmaf.h b/libc/src/math/bf16fmaf.h
deleted file mode 100644
index e8582bd6dff5f..0000000000000
--- a/libc/src/math/bf16fmaf.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16fmaf ----------------------*- 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_BF16FMAF_H
-#define LLVM_LIBC_SRC_MATH_BF16FMAF_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16fmaf(float x, float y, float z);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16FMAF_H
diff --git a/libc/src/math/bf16fmaf128.h b/libc/src/math/bf16fmaf128.h
deleted file mode 100644
index 4215e54c82ff5..0000000000000
--- a/libc/src/math/bf16fmaf128.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16fmaf128 -------------------*- 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_BF16FMAF128_H
-#define LLVM_LIBC_SRC_MATH_BF16FMAF128_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16fmaf128(float128 x, float128 y, float128 z);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16FMAF128_H
diff --git a/libc/src/math/bf16fmal.h b/libc/src/math/bf16fmal.h
deleted file mode 100644
index b92f17b7ee8d6..0000000000000
--- a/libc/src/math/bf16fmal.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16fmal ----------------------*- 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_BF16FMAL_H
-#define LLVM_LIBC_SRC_MATH_BF16FMAL_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16fmal(long double x, long double y, long double z);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16FMAL_H
diff --git a/libc/src/math/bf16mul.h b/libc/src/math/bf16mul.h
deleted file mode 100644
index 14e8a304c2b6c..0000000000000
--- a/libc/src/math/bf16mul.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16mul -----------------------*- 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_BF16MUL_H
-#define LLVM_LIBC_SRC_MATH_BF16MUL_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16mul(double x, double y);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16MUL_H
diff --git a/libc/src/math/bf16mulf.h b/libc/src/math/bf16mulf.h
deleted file mode 100644
index 1d02c8e796b17..0000000000000
--- a/libc/src/math/bf16mulf.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16mulf ----------------------*- 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_BF16MULF_H
-#define LLVM_LIBC_SRC_MATH_BF16MULF_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16mulf(float x, float y);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16MULF_H
diff --git a/libc/src/math/bf16mulf128.h b/libc/src/math/bf16mulf128.h
deleted file mode 100644
index 6ba7cefb2ee8e..0000000000000
--- a/libc/src/math/bf16mulf128.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16mulf128 -------------------*- 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_BF16MULF128_H
-#define LLVM_LIBC_SRC_MATH_BF16MULF128_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16mulf128(float128 x, float128 y);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16MULF128_H
diff --git a/libc/src/math/bf16mull.h b/libc/src/math/bf16mull.h
deleted file mode 100644
index dad65236ce05d..0000000000000
--- a/libc/src/math/bf16mull.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Implementation header for bf16mull ----------------------*- 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_BF16MULL_H
-#define LLVM_LIBC_SRC_MATH_BF16MULL_H
-
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-bfloat16 bf16mull(long double x, long double y);
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LLVM_LIBC_SRC_MATH_BF16MULL_H
diff --git a/libc/src/math/generic/bf16div.cpp b/libc/src/math/generic/bf16div.cpp
deleted file mode 100644
index c052d7bc7af16..0000000000000
--- a/libc/src/math/generic/bf16div.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16div 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/bf16div.h"
-
-#include "src/__support/FPUtil/bfloat16.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(bfloat16, bf16div, (double x, double y)) {
- return fputil::generic::div<bfloat16>(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16divf.cpp b/libc/src/math/generic/bf16divf.cpp
deleted file mode 100644
index a1e258a51fbdd..0000000000000
--- a/libc/src/math/generic/bf16divf.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16divf 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/bf16divf.h"
-
-#include "src/__support/FPUtil/bfloat16.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(bfloat16, bf16divf, (float x, float y)) {
- return fputil::generic::div<bfloat16>(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16divf128.cpp b/libc/src/math/generic/bf16divf128.cpp
deleted file mode 100644
index 6ef6cb18af5bd..0000000000000
--- a/libc/src/math/generic/bf16divf128.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16divf128 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/bf16divf128.h"
-
-#include "src/__support/FPUtil/bfloat16.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(bfloat16, bf16divf128, (float128 x, float128 y)) {
- return fputil::generic::div<bfloat16>(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16divl.cpp b/libc/src/math/generic/bf16divl.cpp
deleted file mode 100644
index aca2c9e4aa66b..0000000000000
--- a/libc/src/math/generic/bf16divl.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16divl 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/bf16divl.h"
-
-#include "src/__support/FPUtil/bfloat16.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(bfloat16, bf16divl, (long double x, long double y)) {
- return fputil::generic::div<bfloat16>(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16fma.cpp b/libc/src/math/generic/bf16fma.cpp
deleted file mode 100644
index cd5b4bfbfc0f2..0000000000000
--- a/libc/src/math/generic/bf16fma.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16fma 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/bf16fma.h"
-
-#include "src/__support/FPUtil/FMA.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(bfloat16, bf16fma, (double x, double y, double z)) {
- return fputil::fma<bfloat16>(x, y, z);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16fmaf.cpp b/libc/src/math/generic/bf16fmaf.cpp
deleted file mode 100644
index 421ec4421be98..0000000000000
--- a/libc/src/math/generic/bf16fmaf.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16fmaf 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/bf16fmaf.h"
-
-#include "src/__support/FPUtil/FMA.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(bfloat16, bf16fmaf, (float x, float y, float z)) {
- return fputil::fma<bfloat16>(x, y, z);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16fmaf128.cpp b/libc/src/math/generic/bf16fmaf128.cpp
deleted file mode 100644
index 61f6538ca45a2..0000000000000
--- a/libc/src/math/generic/bf16fmaf128.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-//===-- Implementation of bf16fmaf128 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/bf16fmaf128.h"
-
-#include "src/__support/FPUtil/FMA.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(bfloat16, bf16fmaf128,
- (float128 x, float128 y, float128 z)) {
- return fputil::fma<bfloat16>(x, y, z);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16fmal.cpp b/libc/src/math/generic/bf16fmal.cpp
deleted file mode 100644
index f31ec6904760b..0000000000000
--- a/libc/src/math/generic/bf16fmal.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16fmal 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/bf16fmal.h"
-
-#include "src/__support/FPUtil/FMA.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(bfloat16, bf16fmal,
- (long double x, long double y, long double z)) {
- return fputil::fma<bfloat16>(x, y, z);
-}
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16mul.cpp b/libc/src/math/generic/bf16mul.cpp
deleted file mode 100644
index 37862cfa3f96c..0000000000000
--- a/libc/src/math/generic/bf16mul.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16mul 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/bf16mul.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/FPUtil/generic/mul.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(bfloat16, bf16mul, (double x, double y)) {
- return fputil::generic::mul<bfloat16>(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16mulf.cpp b/libc/src/math/generic/bf16mulf.cpp
deleted file mode 100644
index 2cf70376949c2..0000000000000
--- a/libc/src/math/generic/bf16mulf.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16mulf 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/bf16mulf.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/FPUtil/generic/mul.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(bfloat16, bf16mulf, (float x, float y)) {
- return fputil::generic::mul<bfloat16>(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16mulf128.cpp b/libc/src/math/generic/bf16mulf128.cpp
deleted file mode 100644
index c34f760133388..0000000000000
--- a/libc/src/math/generic/bf16mulf128.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16mulf128 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/bf16mulf128.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/FPUtil/generic/mul.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(bfloat16, bf16mulf128, (float128 x, float128 y)) {
- return fputil::generic::mul<bfloat16>(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/bf16mull.cpp b/libc/src/math/generic/bf16mull.cpp
deleted file mode 100644
index 97a170152565b..0000000000000
--- a/libc/src/math/generic/bf16mull.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===-- Implementation of bf16mull 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/bf16mull.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/FPUtil/generic/mul.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(bfloat16, bf16mull, (long double x, long double y)) {
- return fputil::generic::mul<bfloat16>(x, y);
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 9949a9318e4c1..337283e72b3f5 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -5394,134 +5394,6 @@ add_fp_unittest(
libc.src.math.bf16addf128
)
-add_fp_unittest(
- bf16div_test
- SUITE
- libc-math-smoke-tests
- SRCS
- bf16div_test.cpp
- HDRS
- DivTest.h
- DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.properties.os
- libc.src.math.bf16div
-)
-
-add_fp_unittest(
- bf16divf_test
- SUITE
- libc-math-smoke-tests
- SRCS
- bf16divf_test.cpp
- HDRS
- DivTest.h
- DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.properties.os
- libc.src.math.bf16divf
-)
-
-add_fp_unittest(
- bf16divl_test
- SUITE
- libc-math-smoke-tests
- SRCS
- bf16divl_test.cpp
- HDRS
- DivTest.h
- DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.properties.os
- libc.src.math.bf16divl
-)
-
-add_fp_unittest(
- bf16divf128_test
- SUITE
- libc-math-smoke-tests
- SRCS
- bf16divf128_test.cpp
- HDRS
- DivTest.h
- DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.properties.os
- libc.src.math.bf16divf128
-)
-
-add_fp_unittest(
- bf16mul_test
- SUITE
- libc-math-smoke-tests
- SRCS
- bf16mul_test.cpp
- HDRS
- MulTest.h
- DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.properties.os
- libc.src.math.bf16mul
-)
-
-add_fp_unittest(
- bf16mulf_test
- SUITE
- libc-math-smoke-tests
- SRCS
- bf16mulf_test.cpp
- HDRS
- MulTest.h
- DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.properties.os
- libc.src.math.bf16mulf
-)
-
-add_fp_unittest(
- bf16mull_test
- SUITE
- libc-math-smoke-tests
- SRCS
- bf16mull_test.cpp
- HDRS
- MulTest.h
- DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.properties.os
- libc.src.math.bf16mull
-)
-
-add_fp_unittest(
- bf16mulf128_test
- SUITE
- libc-math-smoke-tests
- SRCS
- bf16mulf128_test.cpp
- HDRS
- MulTest.h
- DEPENDS
- libc.hdr.errno_macros
- libc.hdr.fenv_macros
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.properties.os
- libc.src.math.bf16mulf128
-)
-
add_fp_unittest(
bf16sub_test
SUITE
diff --git a/libc/test/src/math/smoke/bf16div_test.cpp b/libc/test/src/math/smoke/bf16div_test.cpp
deleted file mode 100644
index eb6b909270853..0000000000000
--- a/libc/test/src/math/smoke/bf16div_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- Unittests for bf16div ---------------------------------------------===//
-//
-// 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/bf16div.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-
-LIST_DIV_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16div)
diff --git a/libc/test/src/math/smoke/bf16divf128_test.cpp b/libc/test/src/math/smoke/bf16divf128_test.cpp
deleted file mode 100644
index d907230c736a2..0000000000000
--- a/libc/test/src/math/smoke/bf16divf128_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- Unittests for bf16divf128 -----------------------------------------===//
-//
-// 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/bf16divf128.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-
-LIST_DIV_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16divf128)
diff --git a/libc/test/src/math/smoke/bf16divf_test.cpp b/libc/test/src/math/smoke/bf16divf_test.cpp
deleted file mode 100644
index 10194563d670c..0000000000000
--- a/libc/test/src/math/smoke/bf16divf_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- Unittests for bf16divf --------------------------------------------===//
-//
-// 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/bf16divf.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-
-LIST_DIV_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16divf)
diff --git a/libc/test/src/math/smoke/bf16divl_test.cpp b/libc/test/src/math/smoke/bf16divl_test.cpp
deleted file mode 100644
index 7261279bf9c81..0000000000000
--- a/libc/test/src/math/smoke/bf16divl_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- Unittests for bf16divl --------------------------------------------===//
-//
-// 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/bf16divl.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-
-LIST_DIV_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16divl)
diff --git a/libc/test/src/math/smoke/bf16mul_test.cpp b/libc/test/src/math/smoke/bf16mul_test.cpp
deleted file mode 100644
index 3682705556b0a..0000000000000
--- a/libc/test/src/math/smoke/bf16mul_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- Unittests for bf16mul ---------------------------------------------===//
-//
-// 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 "MulTest.h"
-
-#include "src/math/bf16mul.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-
-LIST_MUL_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16mul)
diff --git a/libc/test/src/math/smoke/bf16mulf128_test.cpp b/libc/test/src/math/smoke/bf16mulf128_test.cpp
deleted file mode 100644
index 6aee2687ae67a..0000000000000
--- a/libc/test/src/math/smoke/bf16mulf128_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- Unittests for bf16mulf128 -----------------------------------------===//
-//
-// 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 "MulTest.h"
-
-#include "src/math/bf16mulf128.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-
-LIST_MUL_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16mulf128)
diff --git a/libc/test/src/math/smoke/bf16mulf_test.cpp b/libc/test/src/math/smoke/bf16mulf_test.cpp
deleted file mode 100644
index 048b60f8e85cf..0000000000000
--- a/libc/test/src/math/smoke/bf16mulf_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- Unittests for bf16mulf --------------------------------------------===//
-//
-// 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 "MulTest.h"
-
-#include "src/math/bf16mulf.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-
-LIST_MUL_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16mulf)
diff --git a/libc/test/src/math/smoke/bf16mull_test.cpp b/libc/test/src/math/smoke/bf16mull_test.cpp
deleted file mode 100644
index b8439b245c261..0000000000000
--- a/libc/test/src/math/smoke/bf16mull_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- Unittests for bf16mull --------------------------------------------===//
-//
-// 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 "MulTest.h"
-
-#include "src/math/bf16mull.h"
-
-#include "src/__support/FPUtil/bfloat16.h"
-
-LIST_MUL_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16mull)
>From f9bae64363f4498bcb0fc9321a37a9a6be943693 Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81930 at gmail.com>
Date: Fri, 8 Aug 2025 23:06:54 +0530
Subject: [PATCH 4/6] nit: reorder deps and includes
Signed-off-by: Krishna Pandey <kpandey81930 at gmail.com>
---
libc/test/src/math/smoke/CMakeLists.txt | 16 ++++++++--------
libc/test/src/math/smoke/bf16add_test.cpp | 3 +--
libc/test/src/math/smoke/bf16addf128_test.cpp | 3 +--
libc/test/src/math/smoke/bf16addf_test.cpp | 3 +--
libc/test/src/math/smoke/bf16addl_test.cpp | 3 +--
libc/test/src/math/smoke/bf16sub_test.cpp | 3 +--
libc/test/src/math/smoke/bf16subf128_test.cpp | 3 +--
libc/test/src/math/smoke/bf16subf_test.cpp | 3 +--
libc/test/src/math/smoke/bf16subl_test.cpp | 3 +--
9 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 337283e72b3f5..5add78cdf04c8 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -5341,9 +5341,9 @@ add_fp_unittest(
DEPENDS
libc.hdr.errno_macros
libc.hdr.fenv_macros
+ libc.src.math.bf16add
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.properties.os
- libc.src.math.bf16add
)
add_fp_unittest(
@@ -5357,9 +5357,9 @@ add_fp_unittest(
DEPENDS
libc.hdr.errno_macros
libc.hdr.fenv_macros
+ libc.src.math.bf16addf
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.properties.os
- libc.src.math.bf16addf
)
add_fp_unittest(
@@ -5373,9 +5373,9 @@ add_fp_unittest(
DEPENDS
libc.hdr.errno_macros
libc.hdr.fenv_macros
+ libc.src.math.bf16addl
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.properties.os
- libc.src.math.bf16addl
)
add_fp_unittest(
@@ -5389,9 +5389,9 @@ add_fp_unittest(
DEPENDS
libc.hdr.errno_macros
libc.hdr.fenv_macros
+ libc.src.math.bf16addf128
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.properties.os
- libc.src.math.bf16addf128
)
add_fp_unittest(
@@ -5405,9 +5405,9 @@ add_fp_unittest(
DEPENDS
libc.hdr.errno_macros
libc.hdr.fenv_macros
+ libc.src.math.bf16sub
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.properties.os
- libc.src.math.bf16sub
)
add_fp_unittest(
@@ -5421,9 +5421,9 @@ add_fp_unittest(
DEPENDS
libc.hdr.errno_macros
libc.hdr.fenv_macros
+ libc.src.math.bf16subf
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.properties.os
- libc.src.math.bf16subf
)
add_fp_unittest(
@@ -5437,9 +5437,9 @@ add_fp_unittest(
DEPENDS
libc.hdr.errno_macros
libc.hdr.fenv_macros
+ libc.src.math.bf16subl
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.properties.os
- libc.src.math.bf16subl
)
add_fp_unittest(
@@ -5453,7 +5453,7 @@ add_fp_unittest(
DEPENDS
libc.hdr.errno_macros
libc.hdr.fenv_macros
+ libc.src.math.bf16subf128
libc.src.__support.FPUtil.bfloat16
libc.src.__support.macros.properties.os
- libc.src.math.bf16subf128
)
diff --git a/libc/test/src/math/smoke/bf16add_test.cpp b/libc/test/src/math/smoke/bf16add_test.cpp
index ff1e4ca325ab7..9e9c594d7d7eb 100644
--- a/libc/test/src/math/smoke/bf16add_test.cpp
+++ b/libc/test/src/math/smoke/bf16add_test.cpp
@@ -8,8 +8,7 @@
#include "AddTest.h"
-#include "src/math/bf16add.h"
-
#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16add.h"
LIST_ADD_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16add)
diff --git a/libc/test/src/math/smoke/bf16addf128_test.cpp b/libc/test/src/math/smoke/bf16addf128_test.cpp
index 5a168604d9bfb..46f7ad329f237 100644
--- a/libc/test/src/math/smoke/bf16addf128_test.cpp
+++ b/libc/test/src/math/smoke/bf16addf128_test.cpp
@@ -8,8 +8,7 @@
#include "AddTest.h"
-#include "src/math/bf16addf128.h"
-
#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16addf128.h"
LIST_ADD_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16addf128)
diff --git a/libc/test/src/math/smoke/bf16addf_test.cpp b/libc/test/src/math/smoke/bf16addf_test.cpp
index a3fbd45275680..06d56cf21ebd2 100644
--- a/libc/test/src/math/smoke/bf16addf_test.cpp
+++ b/libc/test/src/math/smoke/bf16addf_test.cpp
@@ -8,8 +8,7 @@
#include "AddTest.h"
-#include "src/math/bf16addf.h"
-
#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16addf.h"
LIST_ADD_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16addf)
diff --git a/libc/test/src/math/smoke/bf16addl_test.cpp b/libc/test/src/math/smoke/bf16addl_test.cpp
index ad375a6e3914e..bf548272d31c1 100644
--- a/libc/test/src/math/smoke/bf16addl_test.cpp
+++ b/libc/test/src/math/smoke/bf16addl_test.cpp
@@ -8,8 +8,7 @@
#include "AddTest.h"
-#include "src/math/bf16addl.h"
-
#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16addl.h"
LIST_ADD_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16addl)
diff --git a/libc/test/src/math/smoke/bf16sub_test.cpp b/libc/test/src/math/smoke/bf16sub_test.cpp
index 83b0315c217c3..4a793dc493891 100644
--- a/libc/test/src/math/smoke/bf16sub_test.cpp
+++ b/libc/test/src/math/smoke/bf16sub_test.cpp
@@ -8,8 +8,7 @@
#include "SubTest.h"
-#include "src/math/bf16sub.h"
-
#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16sub.h"
LIST_SUB_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16sub)
diff --git a/libc/test/src/math/smoke/bf16subf128_test.cpp b/libc/test/src/math/smoke/bf16subf128_test.cpp
index e99d4d1bb3b2a..25d6711f71346 100644
--- a/libc/test/src/math/smoke/bf16subf128_test.cpp
+++ b/libc/test/src/math/smoke/bf16subf128_test.cpp
@@ -8,8 +8,7 @@
#include "SubTest.h"
-#include "src/math/bf16subf128.h"
-
#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16subf128.h"
LIST_SUB_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16subf128)
diff --git a/libc/test/src/math/smoke/bf16subf_test.cpp b/libc/test/src/math/smoke/bf16subf_test.cpp
index df4edbdf34a21..e8c7440230f1d 100644
--- a/libc/test/src/math/smoke/bf16subf_test.cpp
+++ b/libc/test/src/math/smoke/bf16subf_test.cpp
@@ -8,8 +8,7 @@
#include "SubTest.h"
-#include "src/math/bf16subf.h"
-
#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16subf.h"
LIST_SUB_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16subf)
diff --git a/libc/test/src/math/smoke/bf16subl_test.cpp b/libc/test/src/math/smoke/bf16subl_test.cpp
index 81516e8706492..299736949d713 100644
--- a/libc/test/src/math/smoke/bf16subl_test.cpp
+++ b/libc/test/src/math/smoke/bf16subl_test.cpp
@@ -8,8 +8,7 @@
#include "SubTest.h"
-#include "src/math/bf16subl.h"
-
#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16subl.h"
LIST_SUB_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16subl)
>From 33dfdf410b825afa944cbe206cd6089721d212bc Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81930 at gmail.com>
Date: Fri, 8 Aug 2025 23:08:08 +0530
Subject: [PATCH 5/6] chore: add general bf16{add,sub}{,f,l,f128} tests
Signed-off-by: Krishna Pandey <kpandey81930 at gmail.com>
---
libc/test/src/math/CMakeLists.txt | 104 ++++++++++++++++++++++++
libc/test/src/math/bf16add_test.cpp | 14 ++++
libc/test/src/math/bf16addf128_test.cpp | 14 ++++
libc/test/src/math/bf16addf_test.cpp | 14 ++++
libc/test/src/math/bf16addl_test.cpp | 14 ++++
libc/test/src/math/bf16sub_test.cpp | 14 ++++
libc/test/src/math/bf16subf128_test.cpp | 14 ++++
libc/test/src/math/bf16subf_test.cpp | 14 ++++
libc/test/src/math/bf16subl_test.cpp | 14 ++++
9 files changed, 216 insertions(+)
create mode 100644 libc/test/src/math/bf16add_test.cpp
create mode 100644 libc/test/src/math/bf16addf128_test.cpp
create mode 100644 libc/test/src/math/bf16addf_test.cpp
create mode 100644 libc/test/src/math/bf16addl_test.cpp
create mode 100644 libc/test/src/math/bf16sub_test.cpp
create mode 100644 libc/test/src/math/bf16subf128_test.cpp
create mode 100644 libc/test/src/math/bf16subf_test.cpp
create mode 100644 libc/test/src/math/bf16subl_test.cpp
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 43cde0d68873e..bbde0372f09de 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2972,6 +2972,110 @@ add_fp_unittest(
libc.src.__support.macros.properties.types
)
+add_fp_unittest(
+ bf16add_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16add_test.cpp
+ HDRS
+ AddTest.h
+ DEPENDS
+ libc.src.math.bf16add
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16addf_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16addf_test.cpp
+ HDRS
+ AddTest.h
+ DEPENDS
+ libc.src.math.bf16addf
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16addl_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16addl_test.cpp
+ HDRS
+ AddTest.h
+ DEPENDS
+ libc.src.math.bf16addl
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16addf128_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16addf128_test.cpp
+ HDRS
+ AddTest.h
+ DEPENDS
+ libc.src.math.bf16addf128
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16sub_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16sub_test.cpp
+ HDRS
+ SubTest.h
+ DEPENDS
+ libc.src.math.bf16sub
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16subf_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16subf_test.cpp
+ HDRS
+ SubTest.h
+ DEPENDS
+ libc.src.math.bf16subf
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16subl_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16subl_test.cpp
+ HDRS
+ SubTest.h
+ DEPENDS
+ libc.src.math.bf16subl
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16subf128_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16subf128_test.cpp
+ HDRS
+ SubTest.h
+ DEPENDS
+ libc.src.math.bf16subf128
+ libc.src.__support.FPUtil.bfloat16
+)
+
add_subdirectory(generic)
add_subdirectory(smoke)
diff --git a/libc/test/src/math/bf16add_test.cpp b/libc/test/src/math/bf16add_test.cpp
new file mode 100644
index 0000000000000..9e9c594d7d7eb
--- /dev/null
+++ b/libc/test/src/math/bf16add_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for bf16add ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AddTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16add.h"
+
+LIST_ADD_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16add)
diff --git a/libc/test/src/math/bf16addf128_test.cpp b/libc/test/src/math/bf16addf128_test.cpp
new file mode 100644
index 0000000000000..46f7ad329f237
--- /dev/null
+++ b/libc/test/src/math/bf16addf128_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for bf16addf128 -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AddTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16addf128.h"
+
+LIST_ADD_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16addf128)
diff --git a/libc/test/src/math/bf16addf_test.cpp b/libc/test/src/math/bf16addf_test.cpp
new file mode 100644
index 0000000000000..06d56cf21ebd2
--- /dev/null
+++ b/libc/test/src/math/bf16addf_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for bf16addf --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AddTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16addf.h"
+
+LIST_ADD_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16addf)
diff --git a/libc/test/src/math/bf16addl_test.cpp b/libc/test/src/math/bf16addl_test.cpp
new file mode 100644
index 0000000000000..bf548272d31c1
--- /dev/null
+++ b/libc/test/src/math/bf16addl_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for bf16addl --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AddTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16addl.h"
+
+LIST_ADD_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16addl)
diff --git a/libc/test/src/math/bf16sub_test.cpp b/libc/test/src/math/bf16sub_test.cpp
new file mode 100644
index 0000000000000..4a793dc493891
--- /dev/null
+++ b/libc/test/src/math/bf16sub_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for bf16sub ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SubTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16sub.h"
+
+LIST_SUB_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16sub)
diff --git a/libc/test/src/math/bf16subf128_test.cpp b/libc/test/src/math/bf16subf128_test.cpp
new file mode 100644
index 0000000000000..25d6711f71346
--- /dev/null
+++ b/libc/test/src/math/bf16subf128_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for bf16subf128 -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SubTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16subf128.h"
+
+LIST_SUB_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16subf128)
diff --git a/libc/test/src/math/bf16subf_test.cpp b/libc/test/src/math/bf16subf_test.cpp
new file mode 100644
index 0000000000000..e8c7440230f1d
--- /dev/null
+++ b/libc/test/src/math/bf16subf_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for bf16subf --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SubTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16subf.h"
+
+LIST_SUB_TESTS(bfloat16, float, LIBC_NAMESPACE::bf16subf)
diff --git a/libc/test/src/math/bf16subl_test.cpp b/libc/test/src/math/bf16subl_test.cpp
new file mode 100644
index 0000000000000..299736949d713
--- /dev/null
+++ b/libc/test/src/math/bf16subl_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for bf16subl --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SubTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16subl.h"
+
+LIST_SUB_TESTS(bfloat16, long double, LIBC_NAMESPACE::bf16subl)
>From 6d247ca78fcca93e6866d4f828ffbe0a73acf806 Mon Sep 17 00:00:00 2001
From: Krishna Pandey <kpandey81930 at gmail.com>
Date: Fri, 8 Aug 2025 23:44:41 +0530
Subject: [PATCH 6/6] fix: tests
Signed-off-by: Krishna Pandey <kpandey81930 at gmail.com>
---
libc/test/src/math/CMakeLists.txt | 8 +++++++
libc/utils/MPFRWrapper/MPFRUtils.cpp | 33 ++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index bbde0372f09de..a74f9fe471963 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2974,6 +2974,7 @@ add_fp_unittest(
add_fp_unittest(
bf16add_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -2987,6 +2988,7 @@ add_fp_unittest(
add_fp_unittest(
bf16addf_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -3000,6 +3002,7 @@ add_fp_unittest(
add_fp_unittest(
bf16addl_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -3013,6 +3016,7 @@ add_fp_unittest(
add_fp_unittest(
bf16addf128_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -3026,6 +3030,7 @@ add_fp_unittest(
add_fp_unittest(
bf16sub_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -3039,6 +3044,7 @@ add_fp_unittest(
add_fp_unittest(
bf16subf_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -3052,6 +3058,7 @@ add_fp_unittest(
add_fp_unittest(
bf16subl_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
@@ -3065,6 +3072,7 @@ add_fp_unittest(
add_fp_unittest(
bf16subf128_test
+ NEED_MPFR
SUITE
libc-math-unittests
SRCS
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index ae12a83e9faa1..3c6d7debd248b 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -411,6 +411,20 @@ template void explain_binary_operation_one_output_error(
#endif
template void explain_binary_operation_one_output_error(
Operation, const BinaryInput<bfloat16> &, bfloat16, double, RoundingMode);
+template void
+explain_binary_operation_one_output_error(Operation, const BinaryInput<float> &,
+ bfloat16, double, RoundingMode);
+template void explain_binary_operation_one_output_error(
+ Operation, const BinaryInput<double> &, bfloat16, double, RoundingMode);
+template void
+explain_binary_operation_one_output_error(Operation,
+ const BinaryInput<long double> &,
+ bfloat16, double, RoundingMode);
+#if defined(LIBC_TYPES_HAS_FLOAT128) && \
+ defined(LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE)
+template void explain_binary_operation_one_output_error(
+ Operation, const BinaryInput<float128> &, bfloat16, double, RoundingMode);
+#endif // LIBC_TYPES_HAS_FLOAT128
template <typename InputType, typename OutputType>
void explain_ternary_operation_one_output_error(
@@ -648,6 +662,25 @@ template bool compare_binary_operation_one_output(Operation,
const BinaryInput<bfloat16> &,
bfloat16, double,
RoundingMode);
+
+template bool compare_binary_operation_one_output(Operation,
+ const BinaryInput<float> &,
+ bfloat16, double,
+ RoundingMode);
+template bool compare_binary_operation_one_output(Operation,
+ const BinaryInput<double> &,
+ bfloat16, double,
+ RoundingMode);
+template bool
+compare_binary_operation_one_output(Operation, const BinaryInput<long double> &,
+ bfloat16, double, RoundingMode);
+#if defined(LIBC_TYPES_HAS_FLOAT128) && \
+ defined(LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE)
+template bool compare_binary_operation_one_output(Operation,
+ const BinaryInput<float128> &,
+ bfloat16, double,
+ RoundingMode);
+#endif // LIBC_TYPES_HAS_FLOAT128
template <typename InputType, typename OutputType>
bool compare_ternary_operation_one_output(Operation op,
const TernaryInput<InputType> &input,
More information about the libc-commits
mailing list