[libc-commits] [libc] c11acac - [libc][math][c++23] Add {frexp, ilogb, ldexp, llogb, logb}bf16 math functions (#154427)

via libc-commits libc-commits at lists.llvm.org
Sun Aug 24 23:16:28 PDT 2025


Author: Krishna Pandey
Date: 2025-08-25T11:46:25+05:30
New Revision: c11acac4dca452103c1f4c2a449dd89626845326

URL: https://github.com/llvm/llvm-project/commit/c11acac4dca452103c1f4c2a449dd89626845326
DIFF: https://github.com/llvm/llvm-project/commit/c11acac4dca452103c1f4c2a449dd89626845326.diff

LOG: [libc][math][c++23] Add {frexp,ilogb,ldexp,llogb,logb}bf16 math functions (#154427)

This PR adds the following basic math functions for BFloat16 type along
with the tests:
- frexpbf16
- ilobbf16
- ldexpbf16
- llogbbf16
- logbbf16

---------

Signed-off-by: Krishna Pandey <kpandey81930 at gmail.com>

Added: 
    libc/src/math/frexpbf16.h
    libc/src/math/generic/frexpbf16.cpp
    libc/src/math/generic/ilogbbf16.cpp
    libc/src/math/generic/ldexpbf16.cpp
    libc/src/math/generic/llogbbf16.cpp
    libc/src/math/generic/logbbf16.cpp
    libc/src/math/ilogbbf16.h
    libc/src/math/ldexpbf16.h
    libc/src/math/llogbbf16.h
    libc/src/math/logbbf16.h
    libc/test/src/math/smoke/frexpbf16_test.cpp
    libc/test/src/math/smoke/ilogbbf16_test.cpp
    libc/test/src/math/smoke/ldexpbf16_test.cpp
    libc/test/src/math/smoke/llogbbf16_test.cpp
    libc/test/src/math/smoke/logbbf16_test.cpp

Modified: 
    libc/config/baremetal/aarch64/entrypoints.txt
    libc/config/baremetal/arm/entrypoints.txt
    libc/config/baremetal/riscv/entrypoints.txt
    libc/config/darwin/aarch64/entrypoints.txt
    libc/config/darwin/x86_64/entrypoints.txt
    libc/config/gpu/amdgpu/entrypoints.txt
    libc/config/gpu/nvptx/entrypoints.txt
    libc/config/linux/aarch64/entrypoints.txt
    libc/config/linux/arm/entrypoints.txt
    libc/config/linux/riscv/entrypoints.txt
    libc/config/linux/x86_64/entrypoints.txt
    libc/config/windows/entrypoints.txt
    libc/docs/headers/math/index.rst
    libc/src/__support/FPUtil/BasicOperations.h
    libc/src/__support/FPUtil/bfloat16.h
    libc/src/math/CMakeLists.txt
    libc/src/math/generic/CMakeLists.txt
    libc/test/src/math/smoke/CMakeLists.txt
    libc/test/src/math/smoke/LdExpTest.h

Removed: 
    


################################################################################
diff  --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 1784e108d6acd..5649c2b31f101 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -785,6 +785,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -792,6 +793,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 9a58ebd28ea64..ad3ceab3c6b01 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -788,6 +788,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -795,6 +796,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 2422551137052..8c50fd1e41df5 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -788,6 +788,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -795,6 +796,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index a3e7aad86235d..08bc10b403e56 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -618,6 +618,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -625,6 +626,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 2343a3d6185f9..49f440404b9dd 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -261,6 +261,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -268,6 +269,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 7b9ee44f5013c..b557046598392 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -644,6 +644,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -651,6 +652,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 5b724a3bdeae3..f1eac1f3fe6d9 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -646,6 +646,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -653,6 +654,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 1f2c58cf11dd0..63471f9905988 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -873,6 +873,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -880,6 +881,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index daeeee5cc96c8..5f95c80166941 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -488,6 +488,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -495,6 +496,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 3a42342fd0ded..7c4a287c4a330 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -891,6 +891,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -898,6 +899,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index fc52bf6f60c25..5e8bfc6341b47 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -924,6 +924,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -931,6 +932,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 413a7a3c48f70..8a61845b750ce 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -334,6 +334,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fminimum_magbf16
   libc.src.math.fminimum_mag_numbf16
   libc.src.math.fminimum_numbf16
+  libc.src.math.frexpbf16
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.lrintbf16
@@ -341,6 +342,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.fromfpbf16
   libc.src.math.fromfpxbf16
   libc.src.math.getpayloadbf16
+  libc.src.math.ilogbbf16
+  libc.src.math.ldexpbf16
+  libc.src.math.llogbbf16
+  libc.src.math.logbbf16
   libc.src.math.nanbf16
   libc.src.math.nearbyintbf16
   libc.src.math.nextafterbf16

diff  --git a/libc/docs/headers/math/index.rst b/libc/docs/headers/math/index.rst
index b0fd807845b99..6a2699e88aa9f 100644
--- a/libc/docs/headers/math/index.rst
+++ b/libc/docs/headers/math/index.rst
@@ -179,7 +179,7 @@ Basic Operations
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | fmul             | N/A              | |check|         | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.3              | F.10.11                    |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
-| frexp            | |check|          | |check|         | |check|                | |check|              | |check|                |                        | 7.12.6.7               | F.10.3.7                   |
+| frexp            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.7               | F.10.3.7                   |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | fromfp           | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.10              | F.10.6.10                  |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
@@ -189,21 +189,21 @@ Basic Operations
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | getpayload       | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | F.10.13.1              | N/A                        |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
-| ilogb            | |check|          | |check|         | |check|                | |check|              | |check|                |                        | 7.12.6.8               | F.10.3.8                   |
+| ilogb            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.8               | F.10.3.8                   |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | iscanonical      | |check|          | |check|         | |check|                | |check|              | |check|                |                        | 7.12.3.2               | N/A                        |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | issignaling      | |check|          | |check|         | |check|                | |check|              | |check|                |                        | 7.12.3.8               | N/A                        |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
-| ldexp            | |check|          | |check|         | |check|                | |check|              | |check|                |                        | 7.12.6.9               | F.10.3.9                   |
+| ldexp            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.9               | F.10.3.9                   |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
-| llogb            | |check|          | |check|         | |check|                | |check|              | |check|                |                        | 7.12.6.10              | F.10.3.10                  |
+| llogb            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.10              | F.10.3.10                  |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | llrint           | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.5               | F.10.6.5                   |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | llround          | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.7               | F.10.6.7                   |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
-| logb             | |check|          | |check|         | |check|                | |check|              | |check|                |                        | 7.12.6.17              | F.10.3.17                  |
+| logb             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.17              | F.10.3.17                  |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
 | lrint            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.5               | F.10.6.5                   |
 +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+

diff  --git a/libc/src/__support/FPUtil/BasicOperations.h b/libc/src/__support/FPUtil/BasicOperations.h
index 994237ba8492e..2357b053b60b8 100644
--- a/libc/src/__support/FPUtil/BasicOperations.h
+++ b/libc/src/__support/FPUtil/BasicOperations.h
@@ -354,10 +354,7 @@ LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, T> getpayload(T x) {
 
     return static_cast<T>(payload_dfloat);
   } else {
-    if constexpr (cpp::is_same_v<T, bfloat16>)
-      return T(static_cast<int>(payload));
-    else
-      return static_cast<T>(payload);
+    return static_cast<T>(payload);
   }
 }
 

diff  --git a/libc/src/__support/FPUtil/bfloat16.h b/libc/src/__support/FPUtil/bfloat16.h
index ba97b42e23218..b607fd68e838b 100644
--- a/libc/src/__support/FPUtil/bfloat16.h
+++ b/libc/src/__support/FPUtil/bfloat16.h
@@ -46,6 +46,8 @@ struct BFloat16 {
           xd(sign, 0, value);
       bits = xd.template as<bfloat16, /*ShouldSignalExceptions=*/true>().bits;
 
+    } else if constexpr (cpp::is_convertible_v<T, BFloat16>) {
+      bits = value.operator BFloat16().bits;
     } else {
       bits = fputil::cast<bfloat16>(static_cast<float>(value)).bits;
     }

diff  --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 2fe3d194e1344..cbafa63b9c0d6 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -308,6 +308,7 @@ add_math_entrypoint_object(frexpf)
 add_math_entrypoint_object(frexpl)
 add_math_entrypoint_object(frexpf16)
 add_math_entrypoint_object(frexpf128)
+add_math_entrypoint_object(frexpbf16)
 
 add_math_entrypoint_object(fromfp)
 add_math_entrypoint_object(fromfpf)
@@ -343,6 +344,7 @@ add_math_entrypoint_object(ilogbf)
 add_math_entrypoint_object(ilogbl)
 add_math_entrypoint_object(ilogbf16)
 add_math_entrypoint_object(ilogbf128)
+add_math_entrypoint_object(ilogbbf16)
 
 add_math_entrypoint_object(isnan)
 add_math_entrypoint_object(isnanf)
@@ -359,12 +361,14 @@ add_math_entrypoint_object(llogbf)
 add_math_entrypoint_object(llogbl)
 add_math_entrypoint_object(llogbf16)
 add_math_entrypoint_object(llogbf128)
+add_math_entrypoint_object(llogbbf16)
 
 add_math_entrypoint_object(ldexp)
 add_math_entrypoint_object(ldexpf)
 add_math_entrypoint_object(ldexpl)
 add_math_entrypoint_object(ldexpf16)
 add_math_entrypoint_object(ldexpf128)
+add_math_entrypoint_object(ldexpbf16)
 
 add_math_entrypoint_object(log10)
 add_math_entrypoint_object(log10f)
@@ -386,6 +390,7 @@ add_math_entrypoint_object(logbf)
 add_math_entrypoint_object(logbl)
 add_math_entrypoint_object(logbf16)
 add_math_entrypoint_object(logbf128)
+add_math_entrypoint_object(logbbf16)
 
 add_math_entrypoint_object(llrint)
 add_math_entrypoint_object(llrintf)

diff  --git a/libc/src/math/frexpbf16.h b/libc/src/math/frexpbf16.h
new file mode 100644
index 0000000000000..1e9bba16ea6c4
--- /dev/null
+++ b/libc/src/math/frexpbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for frexpbf16 ---------------------*- 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_FREXPFB16_H
+#define LLVM_LIBC_SRC_MATH_FREXPFB16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 frexpbf16(bfloat16 x, int *exp);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FREXPFB16_H

diff  --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 1a61ccb107bcf..7f4f250025dc3 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1798,6 +1798,20 @@ add_entrypoint_object(
     libc.src.__support.math.frexpf128
 )
 
+add_entrypoint_object(
+  frexpbf16
+  SRCS
+    frexpbf16.cpp
+  HDRS
+    ../frexpbf16.h
+  DEPENDS
+    libc.src.__support.common
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
+
 add_entrypoint_object(
   ilogb
   SRCS
@@ -1850,6 +1864,20 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_entrypoint_object(
+  ilogbbf16
+  SRCS
+    ilogbbf16.cpp
+  HDRS
+    ../ilogbbf16.h
+  DEPENDS
+    libc.src.__support.common
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
+
 add_entrypoint_object(
   llogb
   SRCS
@@ -1902,6 +1930,20 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_entrypoint_object(
+  llogbbf16
+  SRCS
+    llogbbf16.cpp
+  HDRS
+    ../llogbbf16.h
+  DEPENDS
+    libc.src.__support.common
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
+
 add_entrypoint_object(
   ldexp
   SRCS
@@ -1952,6 +1994,20 @@ add_entrypoint_object(
     libc.src.__support.math.ldexpf128
 )
 
+add_entrypoint_object(
+  ldexpbf16
+  SRCS
+    ldexpbf16.cpp
+  HDRS
+    ../ldexpbf16.h
+  DEPENDS
+    libc.src.__support.common
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
+
 add_object_library(
   common_constants
   HDRS
@@ -2224,6 +2280,20 @@ add_entrypoint_object(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_entrypoint_object(
+  logbbf16
+  SRCS
+    logbbf16.cpp
+  HDRS
+    ../logbbf16.h
+  DEPENDS
+    libc.src.__support.common
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
+
 add_entrypoint_object(
   modf
   SRCS

diff  --git a/libc/src/math/generic/frexpbf16.cpp b/libc/src/math/generic/frexpbf16.cpp
new file mode 100644
index 0000000000000..004f64f282f7d
--- /dev/null
+++ b/libc/src/math/generic/frexpbf16.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of frexpbf16 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/frexpbf16.h"
+#include "src/__support/FPUtil/ManipulationFunctions.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, frexpbf16, (bfloat16 x, int *exp)) {
+  return fputil::frexp(x, *exp);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/math/generic/ilogbbf16.cpp b/libc/src/math/generic/ilogbbf16.cpp
new file mode 100644
index 0000000000000..6811139c6dcfd
--- /dev/null
+++ b/libc/src/math/generic/ilogbbf16.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of ilogbbf16 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/ilogbbf16.h"
+#include "src/__support/FPUtil/ManipulationFunctions.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(int, ilogbbf16, (bfloat16 x)) {
+  return fputil::intlogb<int>(x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/math/generic/ldexpbf16.cpp b/libc/src/math/generic/ldexpbf16.cpp
new file mode 100644
index 0000000000000..42a5039e81bc0
--- /dev/null
+++ b/libc/src/math/generic/ldexpbf16.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of ldexpbf16 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/ldexpbf16.h"
+#include "src/__support/FPUtil/ManipulationFunctions.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, ldexpbf16, (bfloat16 x, int exp)) {
+  return fputil::ldexp(x, exp);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/math/generic/llogbbf16.cpp b/libc/src/math/generic/llogbbf16.cpp
new file mode 100644
index 0000000000000..74c27620053da
--- /dev/null
+++ b/libc/src/math/generic/llogbbf16.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of llogbbf16 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/llogbbf16.h"
+#include "src/__support/FPUtil/ManipulationFunctions.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(long, llogbbf16, (bfloat16 x)) {
+  return fputil::intlogb<long>(x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/math/generic/logbbf16.cpp b/libc/src/math/generic/logbbf16.cpp
new file mode 100644
index 0000000000000..5a43ddfafde75
--- /dev/null
+++ b/libc/src/math/generic/logbbf16.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of logbbf16 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/logbbf16.h"
+#include "src/__support/FPUtil/ManipulationFunctions.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, logbbf16, (bfloat16 x)) { return fputil::logb(x); }
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/math/ilogbbf16.h b/libc/src/math/ilogbbf16.h
new file mode 100644
index 0000000000000..da2384b6d62f6
--- /dev/null
+++ b/libc/src/math/ilogbbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for ilogbbf16 ---------------------*- 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_ILOGBBF16_H
+#define LLVM_LIBC_SRC_MATH_ILOGBBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int ilogbbf16(bfloat16 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_ILOGBBF16_H

diff  --git a/libc/src/math/ldexpbf16.h b/libc/src/math/ldexpbf16.h
new file mode 100644
index 0000000000000..7436d8dc5c149
--- /dev/null
+++ b/libc/src/math/ldexpbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for ldexpbf16 ---------------------*- 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_LDEXPBF16_H
+#define LLVM_LIBC_SRC_MATH_LDEXPBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 ldexpbf16(bfloat16 x, int exp);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_LDEXPBF16_H

diff  --git a/libc/src/math/llogbbf16.h b/libc/src/math/llogbbf16.h
new file mode 100644
index 0000000000000..13f0570585d82
--- /dev/null
+++ b/libc/src/math/llogbbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for llogbbf16 ---------------------*- 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_LLOGBBF16_H
+#define LLVM_LIBC_SRC_MATH_LLOGBBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+long llogbbf16(bfloat16 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_LLOGBBF16_H

diff  --git a/libc/src/math/logbbf16.h b/libc/src/math/logbbf16.h
new file mode 100644
index 0000000000000..2c0d77e9df8af
--- /dev/null
+++ b/libc/src/math/logbbf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for logbbf16 ----------------------*- 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_LOGBBF16_H
+#define LLVM_LIBC_SRC_MATH_LOGBBF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+bfloat16 logbbf16(bfloat16 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_LOGBBF16_H

diff  --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 929d7b02fa962..f9da396202337 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1619,6 +1619,19 @@ add_fp_unittest(
     libc.src.math.frexpf128
 )
 
+add_fp_unittest(
+  frexpbf16_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    frexpbf16_test.cpp
+  HDRS
+    FrexpTest.h
+  DEPENDS
+    libc.src.math.frexpbf16
+    libc.src.__support.FPUtil.bfloat16
+)
+
 add_fp_unittest(
   fromfp_test
   SUITE
@@ -1987,6 +2000,22 @@ add_fp_unittest(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_fp_unittest(
+  ilogbbf16_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    ilogbbf16_test.cpp
+  HDRS
+    ILogbTest.h
+  DEPENDS
+    libc.src.math.ilogbbf16
+    libc.src.__support.CPP.algorithm
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.manipulation_functions
+)
+
 add_fp_unittest(
   issignaling_test
   SUITE
@@ -2122,6 +2151,22 @@ add_fp_unittest(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_fp_unittest(
+  llogbbf16_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    llogbbf16_test.cpp
+  HDRS
+    ILogbTest.h
+  DEPENDS
+    libc.src.math.llogbbf16
+    libc.src.__support.CPP.algorithm
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.manipulation_functions
+)
+
 add_fp_unittest(
   ldexp_test
   SUITE
@@ -2132,6 +2177,7 @@ add_fp_unittest(
     LdExpTest.h
   DEPENDS
     libc.src.math.ldexp
+    libc.src.__support.CPP.algorithm
     libc.src.__support.CPP.limits
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.normal_float
@@ -2147,6 +2193,7 @@ add_fp_unittest(
     LdExpTest.h
   DEPENDS
     libc.src.math.ldexpf
+    libc.src.__support.CPP.algorithm
     libc.src.__support.CPP.limits
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.normal_float
@@ -2162,6 +2209,7 @@ add_fp_unittest(
     LdExpTest.h
   DEPENDS
     libc.src.math.ldexpl
+    libc.src.__support.CPP.algorithm
     libc.src.__support.CPP.limits
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.normal_float
@@ -2177,6 +2225,7 @@ add_fp_unittest(
     LdExpTest.h
   DEPENDS
     libc.src.math.ldexpf16
+    libc.src.__support.CPP.algorithm
     libc.src.__support.CPP.limits
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.normal_float
@@ -2192,11 +2241,29 @@ add_fp_unittest(
     LdExpTest.h
   DEPENDS
     libc.src.math.ldexpf128
+    libc.src.__support.CPP.algorithm
     libc.src.__support.CPP.limits
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.normal_float
 )
 
+add_fp_unittest(
+  ldexpbf16_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    ldexpbf16_test.cpp
+  HDRS
+    LdExpTest.h
+  DEPENDS
+    libc.src.math.ldexpbf16
+    libc.src.__support.CPP.algorithm
+    libc.src.__support.CPP.limits
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.normal_float
+)
+
 add_fp_unittest(
   logb_test
   SUITE
@@ -2267,6 +2334,21 @@ add_fp_unittest(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_fp_unittest(
+  logbbf16_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    logbbf16_test.cpp
+  HDRS
+    LogbTest.h
+  DEPENDS
+    libc.src.math.logbbf16
+    libc.src.__support.CPP.algorithm
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.FPUtil.manipulation_functions
+)
+
 add_fp_unittest(
   modf_test
   SUITE

diff  --git a/libc/test/src/math/smoke/LdExpTest.h b/libc/test/src/math/smoke/LdExpTest.h
index 8de70ad161ad6..d005f053c0c91 100644
--- a/libc/test/src/math/smoke/LdExpTest.h
+++ b/libc/test/src/math/smoke/LdExpTest.h
@@ -10,7 +10,8 @@
 #define LLVM_LIBC_TEST_SRC_MATH_LDEXPTEST_H
 
 #include "hdr/stdint_proxy.h"
-#include "src/__support/CPP/limits.h" // INT_MAX
+#include "src/__support/CPP/algorithm.h" // cpp::min
+#include "src/__support/CPP/limits.h"    // INT_MAX
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/NormalFloat.h"
 #include "test/UnitTest/FEnvSafeTest.h"
@@ -135,8 +136,8 @@ class LdExpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
     // Normal which trigger mantissa overflow.
     T x = NormalFloat(Sign::POS, -FPBits::EXP_BIAS + 1,
                       StorageType(2) * NormalFloat::ONE - StorageType(1));
-    ASSERT_FP_EQ(func(x, -1), x / 2);
-    ASSERT_FP_EQ(func(-x, -1), -x / 2);
+    ASSERT_FP_EQ(func(x, -1), T(x / 2));
+    ASSERT_FP_EQ(func(-x, -1), -T(x / 2));
 
     // Start with a normal number high exponent but pass a very low number for
     // exp. The result should be a subnormal number.
@@ -154,7 +155,9 @@ class LdExpTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
 
     // Start with a subnormal number but pass a very high number for exponent.
     // The result should not be infinity.
-    x = NormalFloat(Sign::POS, -FPBits::EXP_BIAS + 1, NormalFloat::ONE >> 10);
+    x = NormalFloat(Sign::POS, -FPBits::EXP_BIAS + 1,
+                    NormalFloat::ONE >>
+                        LIBC_NAMESPACE::cpp::min(FPBits::FRACTION_LEN, 10));
     exp = FPBits::MAX_BIASED_EXPONENT + 5;
     ASSERT_FALSE(FPBits(func(x, exp)).is_inf());
     // But if the exp is large enough to oversome than the normalization shift,

diff  --git a/libc/test/src/math/smoke/frexpbf16_test.cpp b/libc/test/src/math/smoke/frexpbf16_test.cpp
new file mode 100644
index 0000000000000..3c80edbb433ba
--- /dev/null
+++ b/libc/test/src/math/smoke/frexpbf16_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for frexpbf16 -------------------------------------------===//
+//
+// 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 "FrexpTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/frexpbf16.h"
+
+LIST_FREXP_TESTS(bfloat16, LIBC_NAMESPACE::frexpbf16);

diff  --git a/libc/test/src/math/smoke/ilogbbf16_test.cpp b/libc/test/src/math/smoke/ilogbbf16_test.cpp
new file mode 100644
index 0000000000000..d9fa03a2e50cb
--- /dev/null
+++ b/libc/test/src/math/smoke/ilogbbf16_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for ilogbbf16 -------------------------------------------===//
+//
+// 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 "ILogbTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/ilogbbf16.h"
+
+LIST_INTLOGB_TESTS(int, bfloat16, LIBC_NAMESPACE::ilogbbf16);

diff  --git a/libc/test/src/math/smoke/ldexpbf16_test.cpp b/libc/test/src/math/smoke/ldexpbf16_test.cpp
new file mode 100644
index 0000000000000..2e57eb8460c9e
--- /dev/null
+++ b/libc/test/src/math/smoke/ldexpbf16_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for ldexpbf16 -------------------------------------------===//
+//
+// 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 "LdExpTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/ldexpbf16.h"
+
+LIST_LDEXP_TESTS(bfloat16, LIBC_NAMESPACE::ldexpbf16);

diff  --git a/libc/test/src/math/smoke/llogbbf16_test.cpp b/libc/test/src/math/smoke/llogbbf16_test.cpp
new file mode 100644
index 0000000000000..4454fbfb0644b
--- /dev/null
+++ b/libc/test/src/math/smoke/llogbbf16_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for llogbbf16 -------------------------------------------===//
+//
+// 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 "ILogbTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/llogbbf16.h"
+
+LIST_INTLOGB_TESTS(long, bfloat16, LIBC_NAMESPACE::llogbbf16);

diff  --git a/libc/test/src/math/smoke/logbbf16_test.cpp b/libc/test/src/math/smoke/logbbf16_test.cpp
new file mode 100644
index 0000000000000..4ceec3d6984dd
--- /dev/null
+++ b/libc/test/src/math/smoke/logbbf16_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for logbbf16 --------------------------------------------===//
+//
+// 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 "LogbTest.h"
+
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/math/logbbf16.h"
+
+LIST_LOGB_TESTS(bfloat16, LIBC_NAMESPACE::logbbf16)


        


More information about the libc-commits mailing list