-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[libc][math][c++23] Add f{max,min}imum{,_mag,_mag_num,_num}bf16 math functions #152881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+793
−0
Conversation
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
Signed-off-by: Krishna Pandey <[email protected]>
Signed-off-by: Krishna Pandey <[email protected]>
Signed-off-by: Krishna Pandey <[email protected]>
Signed-off-by: Krishna Pandey <[email protected]>
Signed-off-by: Krishna Pandey <[email protected]>
Signed-off-by: Krishna Pandey <[email protected]>
Signed-off-by: Krishna Pandey <[email protected]>
Signed-off-by: Krishna Pandey <[email protected]>
@llvm/pr-subscribers-libc @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 40.68 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/152881.diff 39 Files Affected:
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 82aa94b39f2f8..5c489576f8289 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -767,7 +767,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 603a97486bca6..4f05cc6825d7b 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -770,7 +770,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 5c28a12a1caf9..bdf46cf2e5a2d 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -770,7 +770,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index e293db45e82e5..b785ae88f0ee7 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -600,7 +600,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 22c793272806d..3ec2bef0ff81b 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -243,7 +243,16 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
+
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index c466225771785..03c4689a1d73b 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -626,7 +626,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 30f3090bacaa5..81ada2b6aaa00 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -627,7 +627,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 154e1b1c96f34..9ebdffc7228d2 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -854,7 +854,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 7b177fc7c8e30..3e51de0af944c 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -470,7 +470,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 5b0f90dc371b8..f33128e643c36 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -873,7 +873,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 66fa3c5668f9a..3d7974cfb7403 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -905,7 +905,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index b4aa0a9ec2a54..3efd86d806ae4 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -316,7 +316,15 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fabsbf16
libc.src.math.floorbf16
libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 6b684f43c143d..5e531d9a7fb89 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -240,48 +240,56 @@ add_math_entrypoint_object(fmaximumf)
add_math_entrypoint_object(fmaximuml)
add_math_entrypoint_object(fmaximumf16)
add_math_entrypoint_object(fmaximumf128)
+add_math_entrypoint_object(fmaximumbf16)
add_math_entrypoint_object(fmaximum_num)
add_math_entrypoint_object(fmaximum_numf)
add_math_entrypoint_object(fmaximum_numl)
add_math_entrypoint_object(fmaximum_numf16)
add_math_entrypoint_object(fmaximum_numf128)
+add_math_entrypoint_object(fmaximum_numbf16)
add_math_entrypoint_object(fmaximum_mag)
add_math_entrypoint_object(fmaximum_magf)
add_math_entrypoint_object(fmaximum_magl)
add_math_entrypoint_object(fmaximum_magf16)
add_math_entrypoint_object(fmaximum_magf128)
+add_math_entrypoint_object(fmaximum_magbf16)
add_math_entrypoint_object(fmaximum_mag_num)
add_math_entrypoint_object(fmaximum_mag_numf)
add_math_entrypoint_object(fmaximum_mag_numl)
add_math_entrypoint_object(fmaximum_mag_numf16)
add_math_entrypoint_object(fmaximum_mag_numf128)
+add_math_entrypoint_object(fmaximum_mag_numbf16)
add_math_entrypoint_object(fminimum)
add_math_entrypoint_object(fminimumf)
add_math_entrypoint_object(fminimuml)
add_math_entrypoint_object(fminimumf16)
add_math_entrypoint_object(fminimumf128)
+add_math_entrypoint_object(fminimumbf16)
add_math_entrypoint_object(fminimum_num)
add_math_entrypoint_object(fminimum_numf)
add_math_entrypoint_object(fminimum_numl)
add_math_entrypoint_object(fminimum_numf16)
add_math_entrypoint_object(fminimum_numf128)
+add_math_entrypoint_object(fminimum_numbf16)
add_math_entrypoint_object(fminimum_mag)
add_math_entrypoint_object(fminimum_magf)
add_math_entrypoint_object(fminimum_magl)
add_math_entrypoint_object(fminimum_magf16)
add_math_entrypoint_object(fminimum_magf128)
+add_math_entrypoint_object(fminimum_magbf16)
add_math_entrypoint_object(fminimum_mag_num)
add_math_entrypoint_object(fminimum_mag_numf)
add_math_entrypoint_object(fminimum_mag_numl)
add_math_entrypoint_object(fminimum_mag_numf16)
add_math_entrypoint_object(fminimum_mag_numf128)
+add_math_entrypoint_object(fminimum_mag_numbf16)
add_math_entrypoint_object(fmul)
add_math_entrypoint_object(fmull)
diff --git a/libc/src/math/fmaximum_mag_numbf16.h b/libc/src/math/fmaximum_mag_numbf16.h
new file mode 100644
index 0000000000000..766352595e4f2
--- /dev/null
+++ b/libc/src/math/fmaximum_mag_numbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fmaximum_mag_numbf16 ----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_FMAXIMUM_MAG_NUMBF16_H
+#define LLVM_LIBC_SRC_MATH_FMAXIMUM_MAG_NUMBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 fmaximum_mag_numbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMAXIMUM_MAG_NUMBF16_H
diff --git a/libc/src/math/fmaximum_magbf16.h b/libc/src/math/fmaximum_magbf16.h
new file mode 100644
index 0000000000000..ff0ff1a33ff49
--- /dev/null
+++ b/libc/src/math/fmaximum_magbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fmaximum_magbf16 --------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_FMAXIMUM_MAGBF16_H
+#define LLVM_LIBC_SRC_MATH_FMAXIMUM_MAGBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 fmaximum_magbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMAXIMUM_MAGBF16_H
diff --git a/libc/src/math/fmaximum_numbf16.h b/libc/src/math/fmaximum_numbf16.h
new file mode 100644
index 0000000000000..f23bc525298a1
--- /dev/null
+++ b/libc/src/math/fmaximum_numbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fmaximum_numbf16 --------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_FMAXIMUM_NUMBF16_H
+#define LLVM_LIBC_SRC_MATH_FMAXIMUM_NUMBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 fmaximum_numbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMAXIMUM_NUMBF16_H
diff --git a/libc/src/math/fmaximumbf16.h b/libc/src/math/fmaximumbf16.h
new file mode 100644
index 0000000000000..9842e99d43a20
--- /dev/null
+++ b/libc/src/math/fmaximumbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fmaximumbf16 ------------------*- 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_FMAXIMUMBF16_H
+#define LLVM_LIBC_SRC_MATH_FMAXIMUMBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 fmaximumbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMAXIMUMBF16_H
diff --git a/libc/src/math/fminimum_mag_numbf16.h b/libc/src/math/fminimum_mag_numbf16.h
new file mode 100644
index 0000000000000..2773381efbcef
--- /dev/null
+++ b/libc/src/math/fminimum_mag_numbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fminimum_mag_numbf16 ----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_FMINIMUM_MAG_NUMBF16_H
+#define LLVM_LIBC_SRC_MATH_FMINIMUM_MAG_NUMBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 fminimum_mag_numbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMINIMUM_MAG_NUMBF16_H
diff --git a/libc/src/math/fminimum_magbf16.h b/libc/src/math/fminimum_magbf16.h
new file mode 100644
index 0000000000000..fee5c4c8b1a1c
--- /dev/null
+++ b/libc/src/math/fminimum_magbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fminimum_magbf16 --------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_FMINIMUM_MAGBF16_H
+#define LLVM_LIBC_SRC_MATH_FMINIMUM_MAGBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 fminimum_magbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMINIMUM_MAGBF16_H
diff --git a/libc/src/math/fminimum_numbf16.h b/libc/src/math/fminimum_numbf16.h
new file mode 100644
index 0000000000000..a3fd47403c415
--- /dev/null
+++ b/libc/src/math/fminimum_numbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fminimum_numbf16 --------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_FMINIMUM_NUMBF16_H
+#define LLVM_LIBC_SRC_MATH_FMINIMUM_NUMBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 fminimum_numbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMINIMUM_NUMBF16_H
diff --git a/libc/src/math/fminimumbf16.h b/libc/src/math/fminimumbf16.h
new file mode 100644
index 0000000000000..07f1adaa4f075
--- /dev/null
+++ b/libc/src/math/fminimumbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fminimumbf16 ------------------*- 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_FMINIMUMBF16_H
+#define LLVM_LIBC_SRC_MATH_FMINIMUMBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 fminimumbf16(bfloat16 x, bfloat16 y);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FMINIMUMBF16_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index c8a8c2bfd3306..b51b89524bb0a 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2471,6 +2471,21 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
)
+add_entrypoint_object(
+ fmaximumbf16
+ SRCS
+ fmaximumbf16.cpp
+ HDRS
+ ../fmaximumbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+ FLAGS
+ MISC_MATH_BASIC_OPS_OPT
+)
+
add_entrypoint_object(
fmaximum_num
SRCS
@@ -2529,6 +2544,21 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
)
+add_entrypoint_object(
+ fmaximum_numbf16
+ SRCS
+ fmaximum_numbf16.cpp
+ HDRS
+ ../fmaximum_numbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+ FLAGS
+ MISC_MATH_BASIC_OPS_OPT
+)
+
add_entrypoint_object(
fmaximum_mag
SRCS
@@ -2587,6 +2617,21 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
)
+add_entrypoint_object(
+ fmaximum_magbf16
+ SRCS
+ fmaximum_magbf16.cpp
+ HDRS
+ ../fmaximum_magbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc...
[truncated]
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Signed-off-by: Krishna Pandey <[email protected]>
Signed-off-by: Krishna Pandey <[email protected]>
lntue
approved these changes
Aug 11, 2025
overmighty
approved these changes
Aug 11, 2025
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: