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 @@ -66,6 +66,7 @@
#include "math/frexpf16.h"
#include "math/fsqrt.h"
#include "math/fsqrtf128.h"
#include "math/fsqrtl.h"
#include "math/hypotf.h"
#include "math/ilogbf.h"
#include "math/ilogbf16.h"
Expand Down
24 changes: 24 additions & 0 deletions libc/shared/math/fsqrtl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===-- Shared header for fsqrtl --------------------------------*- 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_FSQRTL_H
#define LLVM_LIBC_SHARED_MATH_FSQRTL_H

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

namespace LIBC_NAMESPACE_DECL {

namespace shared {

using math::fsqrtl;

} // namespace shared
} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SHARED_MATH_FSQRTL_H
8 changes: 8 additions & 0 deletions libc/src/__support/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,14 @@ add_header_library(
libc.src.__support.FPUtil.generic.sqrt
)

add_header_library(
fsqrtl
HDRS
fsqrtl.h
DEPENDS
libc.src.__support.FPUtil.generic.sqrt
)

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

#include "src/__support/FPUtil/generic/sqrt.h"

namespace LIBC_NAMESPACE_DECL {

namespace math {

LIBC_INLINE static constexpr float fsqrtl(long double x) {
return fputil::sqrt<float>(x);
}

} // namespace math

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FSQRTL_H
2 changes: 1 addition & 1 deletion libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5187,7 +5187,7 @@ add_entrypoint_object(
HDRS
../fsqrtl.h
DEPENDS
libc.src.__support.FPUtil.generic.sqrt
libc.src.__support.math.fsqrtl
)

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

#include "src/math/fsqrtl.h"
#include "src/__support/FPUtil/generic/sqrt.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/__support/math/fsqrtl.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(float, fsqrtl, (long double x)) {
return fputil::sqrt<float>(x);
}
LLVM_LIBC_FUNCTION(float, fsqrtl, (long double x)) { return math::fsqrtl(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 @@ -62,6 +62,7 @@ add_fp_unittest(
libc.src.__support.math.frexpf16
libc.src.__support.math.fsqrt
libc.src.__support.math.fsqrtf128
libc.src.__support.math.fsqrtl
libc.src.__support.math.hypotf
libc.src.__support.math.ilogbf
libc.src.__support.math.ilogbf16
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 @@ -116,6 +116,7 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
TEST(LlvmLibcSharedMathTest, AllLongDouble) {
EXPECT_FP_EQ(0x0p+0L,
LIBC_NAMESPACE::shared::dfmal(0x0.p+0L, 0x0.p+0L, 0x0.p+0L));
EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::fsqrtl(0.0L));
EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbl(0x1.p+0L));
}

Expand Down
10 changes: 9 additions & 1 deletion utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2915,6 +2915,14 @@ libc_support_library(
],
)

libc_support_library(
name = "__support_math_fsqrtl",
hdrs = ["src/__support/math/fsqrtl.h"],
deps = [
":__support_fputil_sqrt",
],
)

libc_support_library(
name = "__support_math_inv_trigf_utils",
hdrs = ["src/__support/math/inv_trigf_utils.h"],
Expand Down Expand Up @@ -4553,7 +4561,7 @@ libc_math_function(
libc_math_function(
name = "fsqrtl",
additional_deps = [
":__support_fputil_sqrt",
":__support_math_fsqrtl",
],
)

Expand Down
Loading