[libc][math][c++23] Add {modf,remainder,remquo}bf16 math functions (#154652)

This PR adds the following basic math functions for BFloat16 type along
with the tests:
- modfbf16
- remainderbf16
- remquobf16

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
Co-authored-by: OverMighty <its.overmighty@gmail.com>
This commit is contained in:
Krishna Pandey 2025-08-27 11:42:09 +05:30 committed by GitHub
parent a0c472d50f
commit f005e2cb7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 338 additions and 66 deletions

View File

@ -786,26 +786,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -789,26 +789,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -789,26 +789,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -619,26 +619,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -262,26 +262,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -645,26 +645,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -647,26 +647,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -874,26 +874,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -489,26 +489,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -892,26 +892,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -925,26 +925,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -335,26 +335,29 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
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
libc.src.math.lroundbf16
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.llrintbf16
libc.src.math.llroundbf16
libc.src.math.logbbf16
libc.src.math.lrintbf16
libc.src.math.lroundbf16
libc.src.math.modfbf16
libc.src.math.nanbf16
libc.src.math.nearbyintbf16
libc.src.math.nextafterbf16
libc.src.math.nextdownbf16
libc.src.math.nexttowardbf16
libc.src.math.nextupbf16
libc.src.math.remainderbf16
libc.src.math.remquobf16
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.rintbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16

View File

@ -209,7 +209,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| lround | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.9.7 | F.10.6.7 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| modf | |check| | |check| | |check| | |check| | |check| | | 7.12.6.18 | F.10.3.18 |
| modf | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.6.18 | F.10.3.18 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| nan | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.11.2 | F.10.8.2 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
@ -223,9 +223,9 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| nextup | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.11.5 | F.10.8.5 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| remainder | |check| | |check| | |check| | |check| | |check| | | 7.12.10.2 | F.10.7.2 |
| remainder | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.10.2 | F.10.7.2 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| remquo | |check| | |check| | |check| | |check| | |check| | | 7.12.10.3 | F.10.7.3 |
| remquo | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.10.3 | F.10.7.3 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| rint | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.9.4 | F.10.6.4 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+

View File

@ -425,6 +425,7 @@ add_math_entrypoint_object(modff)
add_math_entrypoint_object(modfl)
add_math_entrypoint_object(modff16)
add_math_entrypoint_object(modff128)
add_math_entrypoint_object(modfbf16)
add_math_entrypoint_object(nan)
add_math_entrypoint_object(nanf)
@ -477,12 +478,14 @@ add_math_entrypoint_object(remainderf)
add_math_entrypoint_object(remainderl)
add_math_entrypoint_object(remainderf16)
add_math_entrypoint_object(remainderf128)
add_math_entrypoint_object(remainderbf16)
add_math_entrypoint_object(remquo)
add_math_entrypoint_object(remquof)
add_math_entrypoint_object(remquof128)
add_math_entrypoint_object(remquol)
add_math_entrypoint_object(remquof16)
add_math_entrypoint_object(remquof128)
add_math_entrypoint_object(remquobf16)
add_math_entrypoint_object(rint)
add_math_entrypoint_object(rintf)

View File

@ -2346,6 +2346,20 @@ add_entrypoint_object(
libc.src.__support.FPUtil.manipulation_functions
)
add_entrypoint_object(
modfbf16
SRCS
modfbf16.cpp
HDRS
../modfbf16.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(
fmin
SRCS
@ -3250,6 +3264,20 @@ add_entrypoint_object(
libc.src.__support.FPUtil.division_and_remainder_operations
)
add_entrypoint_object(
remquobf16
SRCS
remquobf16.cpp
HDRS
../remquobf16.h
DEPENDS
libc.src.__support.common
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.division_and_remainder_operations
libc.src.__support.macros.properties.types
libc.src.__support.macros.config
)
add_entrypoint_object(
remainderf
SRCS
@ -3302,6 +3330,20 @@ add_entrypoint_object(
libc.src.__support.FPUtil.division_and_remainder_operations
)
add_entrypoint_object(
remainderbf16
SRCS
remainderbf16.cpp
HDRS
../remainderbf16.h
DEPENDS
libc.src.__support.common
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.division_and_remainder_operations
libc.src.__support.macros.properties.types
libc.src.__support.macros.config
)
add_entrypoint_object(
hypotf
SRCS

View File

@ -0,0 +1,21 @@
//===-- Implementation of modfbf16 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/modfbf16.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, modfbf16, (bfloat16 x, bfloat16 *iptr)) {
return fputil::modf(x, *iptr);
}
} // namespace LIBC_NAMESPACE_DECL

View File

@ -0,0 +1,22 @@
//===-- Implementation of remainderbf16 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/remainderbf16.h"
#include "src/__support/FPUtil/DivisionAndRemainderOperations.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, remainderbf16, (bfloat16 x, bfloat16 y)) {
int quotient;
return fputil::remquo(x, y, quotient);
}
} // namespace LIBC_NAMESPACE_DECL

View File

@ -0,0 +1,21 @@
//===-- Implementation of remquobf16 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/remquobf16.h"
#include "src/__support/FPUtil/DivisionAndRemainderOperations.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, remquobf16, (bfloat16 x, bfloat16 y, int *exp)) {
return fputil::remquo(x, y, *exp);
}
} // namespace LIBC_NAMESPACE_DECL

21
libc/src/math/modfbf16.h Normal file
View File

@ -0,0 +1,21 @@
//===-- Implementation header for modfbf16 ----------------------*- 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_MODFBF16_H
#define LLVM_LIBC_SRC_MATH_MODFBF16_H
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
bfloat16 modfbf16(bfloat16 x, bfloat16 *iptr);
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_MATH_MODFBF16_H

View File

@ -0,0 +1,21 @@
//===-- Implementation header for remainderbf16 -----------------*- 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_REMAINDERBF16_H
#define LLVM_LIBC_SRC_MATH_REMAINDERBF16_H
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
bfloat16 remainderbf16(bfloat16 x, bfloat16 y);
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_MATH_REMAINDERBF16_H

View File

@ -0,0 +1,21 @@
//===-- Implementation header for remquobf16 --------------------*- 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_REMQUOBF16_H
#define LLVM_LIBC_SRC_MATH_REMQUOBF16_H
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
bfloat16 remquobf16(bfloat16 x, bfloat16 y, int *exp);
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_MATH_REMQUOBF16_H

View File

@ -2424,6 +2424,22 @@ add_fp_unittest(
libc.src.__support.FPUtil.nearest_integer_operations
)
add_fp_unittest(
modfbf16_test
SUITE
libc-math-smoke-tests
SRCS
modfbf16_test.cpp
HDRS
ModfTest.h
DEPENDS
libc.src.math.modfbf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.nearest_integer_operations
)
add_fp_unittest(
fdimf_test
SUITE
@ -3564,6 +3580,20 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
add_fp_unittest(
remquobf16_test
SUITE
libc-math-smoke-tests
SRCS
remquobf16_test.cpp
HDRS
RemQuoTest.h
DEPENDS
libc.src.math.remquobf16
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.fp_bits
)
add_fp_unittest(
hypotf_test
SUITE

View File

@ -76,10 +76,16 @@ public:
EXPECT_FP_EQ(T(-0.75), func(T(-10.75), &integral));
EXPECT_FP_EQ(integral, T(-10.0));
EXPECT_FP_EQ(T(0.125), func(T(100.125), &integral));
EXPECT_FP_EQ(T(0.125), func(T(31.125), &integral));
EXPECT_FP_EQ(integral, T(31.0));
EXPECT_FP_EQ(T(-0.125), func(T(-31.125), &integral));
EXPECT_FP_EQ(integral, T(-31.0));
EXPECT_FP_EQ(T(0.5), func(T(100.5), &integral));
EXPECT_FP_EQ(integral, T(100.0));
EXPECT_FP_EQ(T(-0.125), func(T(-100.125), &integral));
EXPECT_FP_EQ(T(-0.5), func(T(-100.5), &integral));
EXPECT_FP_EQ(integral, T(-100.0));
}

View File

@ -0,0 +1,14 @@
//===-- Unittests for modfbf16 --------------------------------------------===//
//
// 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 "ModfTest.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/math/modfbf16.h"
LIST_MODF_TESTS(bfloat16, LIBC_NAMESPACE::modfbf16)

View File

@ -0,0 +1,14 @@
//===-- Unittests for remquobf16 ------------------------------------------===//
//
// 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 "RemQuoTest.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/math/remquobf16.h"
LIST_REMQUO_TESTS(bfloat16, LIBC_NAMESPACE::remquobf16)