Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc/config/baremetal/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/baremetal/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/baremetal/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/darwin/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/darwin/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/gpu/amdgpu/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/gpu/nvptx/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/linux/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
2 changes: 2 additions & 0 deletions libc/config/windows/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.rintbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.scalblnbf16
libc.src.math.scalbnbf16
libc.src.math.setpayloadbf16
libc.src.math.setpayloadsigbf16
libc.src.math.truncbf16
Expand Down
4 changes: 2 additions & 2 deletions libc/docs/headers/math/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| roundeven | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.9.8 | F.10.6.8 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| scalbln | |check| | |check| | |check| | |check| | |check| | | 7.12.6.19 | F.10.3.19 |
| scalbln | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.6.19 | F.10.3.19 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| scalbn | |check| | |check| | |check| | |check| | |check| | | 7.12.6.19 | F.10.3.19 |
| scalbn | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.6.19 | F.10.3.19 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| setpayload | |check| | |check| | |check| | |check| | |check| | |check| | F.10.13.2 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
Expand Down
2 changes: 2 additions & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,14 @@ add_math_entrypoint_object(scalblnf)
add_math_entrypoint_object(scalblnl)
add_math_entrypoint_object(scalblnf16)
add_math_entrypoint_object(scalblnf128)
add_math_entrypoint_object(scalblnbf16)

add_math_entrypoint_object(scalbn)
add_math_entrypoint_object(scalbnf)
add_math_entrypoint_object(scalbnl)
add_math_entrypoint_object(scalbnf16)
add_math_entrypoint_object(scalbnf128)
add_math_entrypoint_object(scalbnbf16)

add_math_entrypoint_object(setpayload)
add_math_entrypoint_object(setpayloadf)
Expand Down
30 changes: 30 additions & 0 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4646,6 +4646,21 @@ add_entrypoint_object(
libc.src.__support.FPUtil.manipulation_functions
)

add_entrypoint_object(
scalblnbf16
SRCS
scalblnbf16.cpp
HDRS
../scalblnbf16.h
DEPENDS
libc.hdr.float_macros
libc.src.__support.common
libc.src.__support.macros.config
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.manipulation_functions
)

add_entrypoint_object(
scalbn
SRCS
Expand Down Expand Up @@ -4703,6 +4718,21 @@ add_entrypoint_object(
libc.src.__support.FPUtil.manipulation_functions
)

add_entrypoint_object(
scalbnbf16
SRCS
scalbnbf16.cpp
HDRS
../scalblnbf16.h
DEPENDS
libc.hdr.float_macros
libc.src.__support.common
libc.src.__support.macros.config
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.manipulation_functions
)

add_entrypoint_object(
fmaf
SRCS
Expand Down
26 changes: 26 additions & 0 deletions libc/src/math/generic/scalblnbf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//===-- Implementation of scalblnbf16 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/scalblnbf16.h"
#include "hdr/float_macros.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

#if FLT_RADIX != 2
#error "FLT_RADIX != 2 is not supported."
#endif

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(bfloat16, scalblnbf16, (bfloat16 x, long n)) {
return fputil::ldexp(x, n);
}

} // namespace LIBC_NAMESPACE_DECL
26 changes: 26 additions & 0 deletions libc/src/math/generic/scalbnbf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//===-- Implementation of scalbnbf16 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/scalbnbf16.h"
#include "hdr/float_macros.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

#if FLT_RADIX != 2
#error "FLT_RADIX != 2 is not supported."
#endif

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(bfloat16, scalbnbf16, (bfloat16 x, int n)) {
return fputil::ldexp(x, n);
}

} // namespace LIBC_NAMESPACE_DECL
21 changes: 21 additions & 0 deletions libc/src/math/scalblnbf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for scalblnbf16 -------------------*- 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_SCALBLNBF16_H
#define LLVM_LIBC_SRC_MATH_SCALBLNBF16_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

bfloat16 scalblnbf16(bfloat16 x, long n);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_SCALBLNBF16_H
21 changes: 21 additions & 0 deletions libc/src/math/scalbnbf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for scalbnbf16 --------------------*- 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_SCALBNBF16_H
#define LLVM_LIBC_SRC_MATH_SCALBNBF16_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

bfloat16 scalbnbf16(bfloat16 x, int n);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_SCALBNBF16_H
32 changes: 32 additions & 0 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4881,6 +4881,22 @@ add_fp_unittest(
libc.src.__support.FPUtil.normal_float
)

add_fp_unittest(
scalblnbf16_test
SUITE
libc-math-smoke-tests
SRCS
scalblnbf16_test.cpp
HDRS
ScalbnTest.h
DEPENDS
libc.src.math.scalblnbf16
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(
scalbn_test
SUITE
Expand Down Expand Up @@ -4956,6 +4972,22 @@ add_fp_unittest(
libc.src.__support.FPUtil.normal_float
)

add_fp_unittest(
scalbnbf16_test
SUITE
libc-math-smoke-tests
SRCS
scalbnbf16_test.cpp
HDRS
ScalbnTest.h
DEPENDS
libc.src.math.scalbnbf16
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(
erff_test
SUITE
Expand Down
5 changes: 5 additions & 0 deletions libc/test/src/math/smoke/TotalOrderMagTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ class TotalOrderMagTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {

void testNaNPayloads(TotalOrderMagFunc func) {

T qnan_0x15 = FPBits::quiet_nan(Sign::POS, 0x15).get_val();
T neg_qnan_0x15 = FPBits::quiet_nan(Sign::NEG, 0x15).get_val();
T snan_0x15 = FPBits::signaling_nan(Sign::POS, 0x15).get_val();
T neg_snan_0x15 = FPBits::signaling_nan(Sign::NEG, 0x15).get_val();

EXPECT_TRUE(funcWrapper(func, aNaN, aNaN));
EXPECT_TRUE(funcWrapper(func, sNaN, sNaN));

Expand Down
5 changes: 5 additions & 0 deletions libc/test/src/math/smoke/TotalOrderTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class TotalOrderTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {

void testNaNPayloads(TotalOrderFunc func) {

T qnan_0x15 = FPBits::quiet_nan(Sign::POS, 0x15).get_val();
T neg_qnan_0x15 = FPBits::quiet_nan(Sign::NEG, 0x15).get_val();
T snan_0x15 = FPBits::signaling_nan(Sign::POS, 0x15).get_val();
T neg_snan_0x15 = FPBits::signaling_nan(Sign::NEG, 0x15).get_val();

EXPECT_TRUE(funcWrapper(func, aNaN, aNaN));
EXPECT_TRUE(funcWrapper(func, sNaN, sNaN));

Expand Down
14 changes: 14 additions & 0 deletions libc/test/src/math/smoke/scalblnbf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//===-- Unittests for scalblnbf16 -----------------------------------------===//
//
// 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 "ScalbnTest.h"

#include "src/__support/FPUtil/bfloat16.h"
#include "src/math/scalblnbf16.h"

LIST_SCALBN_TESTS(bfloat16, long, LIBC_NAMESPACE::scalblnbf16)
14 changes: 14 additions & 0 deletions libc/test/src/math/smoke/scalbnbf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//===-- Unittests for scalbnbf16 ------------------------------------------===//
//
// 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 "ScalbnTest.h"

#include "src/__support/FPUtil/bfloat16.h"
#include "src/math/scalbnbf16.h"

LIST_SCALBN_TESTS(bfloat16, int, LIBC_NAMESPACE::scalbnbf16)
Loading