Repository navigation
[libc][math][c++23] Add bf16div{,f,l,f128} math functions - #153191
Merged
Merged
Conversation
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
Member
|
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-backend-risc-v Author: Krishna Pandey (krishna2803) ChangesThis PR adds the following basic math functions for BFloat16 type along with the tests:
Patch is 25.98 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/153191.diff 32 Files Affected:
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 58d41a29c716f..6886dde65513b 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -760,6 +760,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
@@ -780,6 +783,7 @@ 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.bf16mulf128
libc.src.math.bf16subf128
)
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 08d0292760540..55dbff145a664 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -763,6 +763,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
@@ -783,6 +786,7 @@ 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.bf16mulf128
libc.src.math.bf16subf128
)
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 8afdfc5b469be..1ef84836b900b 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -763,6 +763,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
@@ -783,6 +786,7 @@ 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.bf16mulf128
libc.src.math.bf16subf128
)
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 25e847a4b92b3..f77a279273aba 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -593,6 +593,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 42fe5f6a1f859..85fc6d99d0c91 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -236,6 +236,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 23e11aaac0ba8..60634ca7a7a8a 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -619,6 +619,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 16193add75e0a..cd311431a9065 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -620,6 +620,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 47d5120d5d880..8acce57633928 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -847,6 +847,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
@@ -867,6 +870,7 @@ 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.bf16mulf128
libc.src.math.bf16subf128
)
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 1442e787a0d9c..1f0d5f53d84b9 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -463,6 +463,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 4ce1be3d7e213..9623e07b2dd15 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -866,6 +866,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
@@ -886,6 +889,7 @@ 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.bf16mulf128
libc.src.math.bf16subf128
)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 1d24e117d925a..e47403c3f36e2 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -898,6 +898,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
@@ -918,6 +921,7 @@ 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.bf16mulf128
libc.src.math.bf16subf128
)
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 21a04a626155a..3578ef72cd8ae 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -309,6 +309,9 @@ 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.bf16mul
libc.src.math.bf16mulf
libc.src.math.bf16mull
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index fa02a06bd05c0..df133537d41fb 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -571,6 +571,11 @@ add_math_entrypoint_object(bf16addf)
add_math_entrypoint_object(bf16addl)
add_math_entrypoint_object(bf16addf128)
+add_math_entrypoint_object(bf16div)
+add_math_entrypoint_object(bf16divf)
+add_math_entrypoint_object(bf16divl)
+add_math_entrypoint_object(bf16divf128)
+
add_math_entrypoint_object(bf16mul)
add_math_entrypoint_object(bf16mulf)
add_math_entrypoint_object(bf16mull)
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/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 9f1514531bdaf..9e4d9340cfa56 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4929,6 +4929,61 @@ add_entrypoint_object(
libc.src.__support.macros.properties.types
)
+add_entrypoint_object(
+ bf16div
+ SRCS
+ bf16div.cpp
+ HDRS
+ ../bf16div.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.div
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_entrypoint_object(
+ bf16divf
+ SRCS
+ bf16divf.cpp
+ HDRS
+ ../bf16divf.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.div
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_entrypoint_object(
+ bf16divl
+ SRCS
+ bf16divl.cpp
+ HDRS
+ ../bf16divl.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.div
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_entrypoint_object(
+ bf16divf128
+ SRCS
+ bf16divf128.cpp
+ HDRS
+ ../bf16divf128.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.generic.div
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
add_entrypoint_object(
bf16sub
diff --git a/libc/src/math/generic/bf16div.cpp b/libc/src/math/generic/bf16div.cpp
new file mode 100644
index 0000000000000..dc927f26886bd
--- /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/common.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/div.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..47037f0f1e51f
--- /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/common.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/div.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..652b612b3439d
--- /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/common.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/div.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..0015dc1354c66
--- /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/common.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/FPUtil/generic/div.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/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 899d54dd3108c..85dddfb88d7e6 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -3028,6 +3028,62 @@ add_fp_unittest(
libc.src.__support.FPUtil.bfloat16
)
+add_fp_unittest(
+ bf16div_test
+ NEED_MPFR
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16div_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.src.math.bf16div
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16divf_test
+ NEED_MPFR
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16divf_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.src.math.bf16divf
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16divl_test
+ NEED_MPFR
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16divl_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.src.math.bf16divl
+ libc.src.__support.FPUtil.bfloat16
+)
+
+add_fp_unittest(
+ bf16divf128_test
+ NEED_MPFR
+ SUITE
+ libc-math-unittests
+ SRCS
+ bf16divf128_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.src.math.bf16divf128
+ libc.src.__support.FPUtil.bfloat16
+)
+
add_fp_unittest(
bf16mul_test
NEED_MPFR
diff --git a/libc/test/src/math/bf16div_test.cpp b/libc/test/src/math/bf16div_test.cpp
new file mode 100644
index 0000000000000..4516351fb93a3
--- /dev/null
+++ b/libc/test/src/math/bf16div_test.cpp
@@ -0,0 +1,14 @@
+//===-- 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/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16div.h"
+
+LIST_DIV_TESTS(bfloat16, double, LIBC_NAMESPACE::bf16div)
diff --git a/libc/test/src/math/bf16divf128_test.cpp b/libc/test/src/math/bf16divf128_test.cpp
new file mode 100644
index 0000000000000..c42c5bb067050
--- /dev/null
+++ b/libc/test/src/math/bf16divf128_test.cpp
@@ -0,0 +1,14 @@
+//===-- 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/__support/FPUtil/bfloat16.h"
+#include "src/math/bf16divf128.h"
+
+LIST_DIV_TESTS(bfloat16, float128, LIBC_NAMESPACE::bf16divf128)
diff --git a/libc/test/src/math/bf16divf_test.cpp b/libc/test/src/math/bf16divf_test.cpp
new file mode 1006...
[truncated]
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
overmighty
approved these changes
Aug 12, 2025
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/math/bf16div.h" | ||
|
|
Member
There was a problem hiding this comment.
Nit: there's usually no blank line here. Same for the other new libc/src/math/generic/*.cpp files.
Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
lntue
approved these changes
Aug 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the following basic math functions for BFloat16 type along with the tests: