aboutsummaryrefslogtreecommitdiff
path: root/libc/src
diff options
context:
space:
mode:
authorJob Henandez Lara <hj93@protonmail.com>2024-07-21 08:17:41 -0700
committerGitHub <noreply@github.com>2024-07-21 11:17:41 -0400
commitaf0f58cf14329f5e0fe56fed7c9eb4cd3107a1ce (patch)
tree6aeb41fcf05ae890472e528593291cb78b249110 /libc/src
parentc8c0b18b5d58415b79ea13b62eee70c130c26a0a (diff)
downloadllvm-af0f58cf14329f5e0fe56fed7c9eb4cd3107a1ce.zip
llvm-af0f58cf14329f5e0fe56fed7c9eb4cd3107a1ce.tar.gz
llvm-af0f58cf14329f5e0fe56fed7c9eb4cd3107a1ce.tar.bz2
[libc][math][c23] Add entrypoints and tests for fsqrt{,l,f128} (#99669)
Diffstat (limited to 'libc/src')
-rw-r--r--libc/src/math/CMakeLists.txt4
-rw-r--r--libc/src/math/fsqrt.h20
-rw-r--r--libc/src/math/fsqrtf128.h21
-rw-r--r--libc/src/math/fsqrtl.h20
-rw-r--r--libc/src/math/generic/CMakeLists.txt37
-rw-r--r--libc/src/math/generic/fsqrt.cpp18
-rw-r--r--libc/src/math/generic/fsqrtf128.cpp20
-rw-r--r--libc/src/math/generic/fsqrtl.cpp20
8 files changed, 160 insertions, 0 deletions
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 050bf0f..82dd231 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -131,6 +131,10 @@ add_math_entrypoint_object(f16sqrtf)
add_math_entrypoint_object(f16sqrtl)
add_math_entrypoint_object(f16sqrtf128)
+add_math_entrypoint_object(fsqrt)
+add_math_entrypoint_object(fsqrtl)
+add_math_entrypoint_object(fsqrtf128)
+
add_math_entrypoint_object(f16sub)
add_math_entrypoint_object(f16subf)
add_math_entrypoint_object(f16subl)
diff --git a/libc/src/math/fsqrt.h b/libc/src/math/fsqrt.h
new file mode 100644
index 0000000..e6a8c31
--- /dev/null
+++ b/libc/src/math/fsqrt.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for fsqrt -------------------------*- 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_FSQRT_H
+#define LLVM_LIBC_SRC_MATH_FSQRT_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float fsqrt(double x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FSQRT_H
diff --git a/libc/src/math/fsqrtf128.h b/libc/src/math/fsqrtf128.h
new file mode 100644
index 0000000..5286cbc
--- /dev/null
+++ b/libc/src/math/fsqrtf128.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for fsqrtf128 ---------------------*- 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_FSQRTF128_H
+#define LLVM_LIBC_SRC_MATH_FSQRTF128_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float fsqrtf128(float128 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FSQRTF128_H
diff --git a/libc/src/math/fsqrtl.h b/libc/src/math/fsqrtl.h
new file mode 100644
index 0000000..a50eea3
--- /dev/null
+++ b/libc/src/math/fsqrtl.h
@@ -0,0 +1,20 @@
+//===-- 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_MATH_FSQRTL_H
+#define LLVM_LIBC_SRC_MATH_FSQRTL_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float fsqrtl(long double x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FSQRTL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 8e8ffb0..7712a6d 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4202,6 +4202,43 @@ add_entrypoint_object(
)
add_entrypoint_object(
+ fsqrt
+ SRCS
+ fsqrt.cpp
+ HDRS
+ ../fsqrt.h
+ DEPENDS
+ libc.src.__support.FPUtil.generic.sqrt
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
+ fsqrtl
+ SRCS
+ fsqrtl.cpp
+ HDRS
+ ../fsqrtl.h
+ DEPENDS
+ libc.src.__support.FPUtil.generic.sqrt
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
+ fsqrtf128
+ SRCS
+ fsqrtf128.cpp
+ HDRS
+ ../fsqrtf128.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.generic.sqrt
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
cbrtf
SRCS
cbrtf.cpp
diff --git a/libc/src/math/generic/fsqrt.cpp b/libc/src/math/generic/fsqrt.cpp
new file mode 100644
index 0000000..d54471f
--- /dev/null
+++ b/libc/src/math/generic/fsqrt.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of fsqrt 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/fsqrt.h"
+#include "src/__support/FPUtil/generic/sqrt.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fsqrt, (double x)) { return fputil::sqrt<float>(x); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fsqrtf128.cpp b/libc/src/math/generic/fsqrtf128.cpp
new file mode 100644
index 0000000..f2c0495
--- /dev/null
+++ b/libc/src/math/generic/fsqrtf128.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of fsqrt128 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/fsqrtf128.h"
+#include "src/__support/FPUtil/generic/sqrt.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fsqrtf128, (float128 x)) {
+ return fputil::sqrt<float>(x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fsqrtl.cpp b/libc/src/math/generic/fsqrtl.cpp
new file mode 100644
index 0000000..b896a84
--- /dev/null
+++ b/libc/src/math/generic/fsqrtl.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of fsqrtl 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/fsqrtl.h"
+#include "src/__support/FPUtil/generic/sqrt.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float, fsqrtl, (long double x)) {
+ return fputil::sqrt<float>(x);
+}
+
+} // namespace LIBC_NAMESPACE_DECL