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
1 change: 1 addition & 0 deletions libc/shared/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#include "math/ldexpf16.h"
#include "math/llogb.h"
#include "math/llogbf.h"
#include "math/llogbf16.h"
#include "math/log.h"
#include "math/log10.h"
#include "math/log1p.h"
Expand Down
29 changes: 29 additions & 0 deletions libc/shared/math/llogbf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//===-- Shared llogbf16 function --------------------------------*- 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_SHARED_MATH_LLOGBF16_H
#define LLVM_LIBC_SHARED_MATH_LLOGBF16_H

#include "include/llvm-libc-macros/float16-macros.h"

#ifdef LIBC_TYPES_HAS_FLOAT16

#include "shared/libc_common.h"
#include "src/__support/math/llogbf16.h"

namespace LIBC_NAMESPACE_DECL {
namespace shared {

using math::llogbf16;

} // namespace shared
} // namespace LIBC_NAMESPACE_DECL

#endif // LIBC_TYPES_HAS_FLOAT16

#endif // LLVM_LIBC_SHARED_MATH_LLOGBF16_H
10 changes: 10 additions & 0 deletions libc/src/__support/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,16 @@ add_header_library(
libc.include.llvm-libc-types.float128
)

add_header_library(
llogbf16
HDRS
llogbf16.h
DEPENDS
libc.src.__support.macros.config
libc.src.__support.FPUtil.manipulation_functions
libc.include.llvm-libc-macros.float16_macros
)

add_header_library(
ilogbf
HDRS
Expand Down
34 changes: 34 additions & 0 deletions libc/src/__support/math/llogbf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//===-- Implementation header for llogbf16 ----------------------*- 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___SUPPORT_MATH_LLOGBF16_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF16_H

#include "include/llvm-libc-macros/float16-macros.h"

#ifdef LIBC_TYPES_HAS_FLOAT16

#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

namespace math {

LIBC_INLINE static constexpr long llogbf16(float16 x) {
return fputil::intlogb<long>(x);
}

} // namespace math

} // namespace LIBC_NAMESPACE_DECL

#endif // LIBC_TYPES_HAS_FLOAT16

#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF16_H
3 changes: 1 addition & 2 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1832,8 +1832,7 @@ add_entrypoint_object(
HDRS
../llogbf16.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.math.llogbf16
)

add_entrypoint_object(
Expand Down
8 changes: 2 additions & 6 deletions libc/src/math/generic/llogbf16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
//===----------------------------------------------------------------------===//

#include "src/math/llogbf16.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/__support/math/llogbf16.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(long, llogbf16, (float16 x)) {
return fputil::intlogb<long>(x);
}
LLVM_LIBC_FUNCTION(long, llogbf16, (float16 x)) { return math::llogbf16(x); }

} // namespace LIBC_NAMESPACE_DECL
1 change: 1 addition & 0 deletions libc/test/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ add_fp_unittest(
libc.src.__support.math.ldexpf128
libc.src.__support.math.ldexpf16
libc.src.__support.math.llogbf
libc.src.__support.math.llogbf16
libc.src.__support.math.rsqrtf
libc.src.__support.math.rsqrtf16
libc.src.__support.math.sin
Expand Down
1 change: 1 addition & 0 deletions libc/test/shared/shared_math_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {

EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbf16(1.0f16));
EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::logbf16(1.0f16));
EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbf16(1.0f16));

EXPECT_FP_EQ(0x1.921fb6p+0f16, LIBC_NAMESPACE::shared::acosf16(0.0f16));
EXPECT_FP_EQ(0x1p+0f16, LIBC_NAMESPACE::shared::f16sqrtl(1.0L));
Expand Down
16 changes: 15 additions & 1 deletion utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,17 @@ libc_support_library(
],
)

libc_support_library(
name = "__support_math_llogbf16",
hdrs = ["src/__support/math/llogbf16.h"],
deps = [
":__support_common",
":__support_fputil_manipulation_functions",
":__support_macros_config",
":llvm_libc_macros_float16_macros",
],
)

libc_support_library(
name = "__support_math_log",
hdrs = ["src/__support/math/log.h"],
Expand Down Expand Up @@ -4761,7 +4772,10 @@ libc_math_function(name = "llogbl")

libc_math_function(name = "llogbf128")

libc_math_function(name = "llogbf16")
libc_math_function(
name = "llogbf16",
additional_deps = [":__support_math_llogbf16"],
)

libc_math_function(name = "llrint")

Expand Down
Loading