diff options
author | OverMighty <its.overmighty@gmail.com> | 2024-07-03 01:27:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-02 19:27:09 -0400 |
commit | 4e567242133678c88a6cb5aeb979c6148f6a7035 (patch) | |
tree | 40edd48dacb95ff0e44c9aea4ad31b71cff45d24 /libc/src | |
parent | 4b28b3fae4eb0808a135a7ec73a2f4a7257a6652 (diff) | |
download | llvm-4e567242133678c88a6cb5aeb979c6148f6a7035.zip llvm-4e567242133678c88a6cb5aeb979c6148f6a7035.tar.gz llvm-4e567242133678c88a6cb5aeb979c6148f6a7035.tar.bz2 |
[libc][math][c23] Add f16{add,sub}{,l,f128} C23 math functions (#97072)
Part of #93566.
Diffstat (limited to 'libc/src')
-rw-r--r-- | libc/src/math/CMakeLists.txt | 6 | ||||
-rw-r--r-- | libc/src/math/f16add.h | 20 | ||||
-rw-r--r-- | libc/src/math/f16addf128.h | 20 | ||||
-rw-r--r-- | libc/src/math/f16addl.h | 20 | ||||
-rw-r--r-- | libc/src/math/f16sub.h | 20 | ||||
-rw-r--r-- | libc/src/math/f16subf128.h | 20 | ||||
-rw-r--r-- | libc/src/math/f16subl.h | 20 | ||||
-rw-r--r-- | libc/src/math/generic/CMakeLists.txt | 78 | ||||
-rw-r--r-- | libc/src/math/generic/f16add.cpp | 19 | ||||
-rw-r--r-- | libc/src/math/generic/f16addf128.cpp | 19 | ||||
-rw-r--r-- | libc/src/math/generic/f16addl.cpp | 19 | ||||
-rw-r--r-- | libc/src/math/generic/f16sub.cpp | 19 | ||||
-rw-r--r-- | libc/src/math/generic/f16subf128.cpp | 19 | ||||
-rw-r--r-- | libc/src/math/generic/f16subl.cpp | 19 |
14 files changed, 318 insertions, 0 deletions
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index 5b20913..0983d26 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -99,7 +99,10 @@ add_math_entrypoint_object(exp10f) add_math_entrypoint_object(expm1) add_math_entrypoint_object(expm1f) +add_math_entrypoint_object(f16add) add_math_entrypoint_object(f16addf) +add_math_entrypoint_object(f16addl) +add_math_entrypoint_object(f16addf128) add_math_entrypoint_object(f16div) add_math_entrypoint_object(f16divf) @@ -116,7 +119,10 @@ add_math_entrypoint_object(f16sqrtf) add_math_entrypoint_object(f16sqrtl) add_math_entrypoint_object(f16sqrtf128) +add_math_entrypoint_object(f16sub) add_math_entrypoint_object(f16subf) +add_math_entrypoint_object(f16subl) +add_math_entrypoint_object(f16subf128) add_math_entrypoint_object(fabs) add_math_entrypoint_object(fabsf) diff --git a/libc/src/math/f16add.h b/libc/src/math/f16add.h new file mode 100644 index 0000000..763a078 --- /dev/null +++ b/libc/src/math/f16add.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16add ------------------------*- 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_F16ADD_H +#define LLVM_LIBC_SRC_MATH_F16ADD_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16add(double x, double y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16ADD_H diff --git a/libc/src/math/f16addf128.h b/libc/src/math/f16addf128.h new file mode 100644 index 0000000..284ce1d --- /dev/null +++ b/libc/src/math/f16addf128.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16addf128 --------------------*- 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_F16ADDF128_H +#define LLVM_LIBC_SRC_MATH_F16ADDF128_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16addf128(float128 x, float128 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16ADDF128_H diff --git a/libc/src/math/f16addl.h b/libc/src/math/f16addl.h new file mode 100644 index 0000000..6a7267a --- /dev/null +++ b/libc/src/math/f16addl.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16addl -----------------------*- 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_F16ADDL_H +#define LLVM_LIBC_SRC_MATH_F16ADDL_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16addl(long double x, long double y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16ADDL_H diff --git a/libc/src/math/f16sub.h b/libc/src/math/f16sub.h new file mode 100644 index 0000000..66f82da --- /dev/null +++ b/libc/src/math/f16sub.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16sub ------------------------*- 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_F16SUB_H +#define LLVM_LIBC_SRC_MATH_F16SUB_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16sub(double x, double y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16SUB_H diff --git a/libc/src/math/f16subf128.h b/libc/src/math/f16subf128.h new file mode 100644 index 0000000..eb67429 --- /dev/null +++ b/libc/src/math/f16subf128.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16subf128 --------------------*- 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_F16SUBF128_H +#define LLVM_LIBC_SRC_MATH_F16SUBF128_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16subf128(float128 x, float128 y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16SUBF128_H diff --git a/libc/src/math/f16subl.h b/libc/src/math/f16subl.h new file mode 100644 index 0000000..43b44a5 --- /dev/null +++ b/libc/src/math/f16subl.h @@ -0,0 +1,20 @@ +//===-- Implementation header for f16subl -----------------------*- 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_F16SUBL_H +#define LLVM_LIBC_SRC_MATH_F16SUBL_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float16 f16subl(long double x, long double y); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_F16SUBL_H diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index d6ea8c5..2e4ed8f 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -3796,6 +3796,19 @@ add_entrypoint_object( ) add_entrypoint_object( + f16add + SRCS + f16add.cpp + HDRS + ../f16add.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( f16addf SRCS f16addf.cpp @@ -3809,6 +3822,45 @@ add_entrypoint_object( ) add_entrypoint_object( + f16addl + SRCS + f16addl.cpp + HDRS + ../f16addl.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( + f16addf128 + SRCS + f16addf128.cpp + HDRS + ../f16addf128.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( + f16sub + SRCS + f16sub.cpp + HDRS + ../f16sub.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( f16subf SRCS f16subf.cpp @@ -3822,6 +3874,32 @@ add_entrypoint_object( ) add_entrypoint_object( + f16subl + SRCS + f16subl.cpp + HDRS + ../f16subl.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( + f16subf128 + SRCS + f16subf128.cpp + HDRS + ../f16subf128.h + DEPENDS + libc.src.__support.macros.properties.types + libc.src.__support.FPUtil.generic.add_sub + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( f16div SRCS f16div.cpp diff --git a/libc/src/math/generic/f16add.cpp b/libc/src/math/generic/f16add.cpp new file mode 100644 index 0000000..ef9b43e --- /dev/null +++ b/libc/src/math/generic/f16add.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16add 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/f16add.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16add, (double x, double y)) { + return fputil::generic::add<float16>(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16addf128.cpp b/libc/src/math/generic/f16addf128.cpp new file mode 100644 index 0000000..61c458f --- /dev/null +++ b/libc/src/math/generic/f16addf128.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16addf128 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/f16addf128.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16addf128, (float128 x, float128 y)) { + return fputil::generic::add<float16>(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16addl.cpp b/libc/src/math/generic/f16addl.cpp new file mode 100644 index 0000000..d32d09d --- /dev/null +++ b/libc/src/math/generic/f16addl.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16addl 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/f16addl.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16addl, (long double x, long double y)) { + return fputil::generic::add<float16>(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16sub.cpp b/libc/src/math/generic/f16sub.cpp new file mode 100644 index 0000000..114c8ad --- /dev/null +++ b/libc/src/math/generic/f16sub.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16sub 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/f16sub.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16sub, (double x, double y)) { + return fputil::generic::sub<float16>(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16subf128.cpp b/libc/src/math/generic/f16subf128.cpp new file mode 100644 index 0000000..1f9ff28 --- /dev/null +++ b/libc/src/math/generic/f16subf128.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16subf128 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/f16subf128.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16subf128, (float128 x, float128 y)) { + return fputil::generic::sub<float16>(x, y); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/generic/f16subl.cpp b/libc/src/math/generic/f16subl.cpp new file mode 100644 index 0000000..31970af --- /dev/null +++ b/libc/src/math/generic/f16subl.cpp @@ -0,0 +1,19 @@ +//===-- Implementation of f16subl 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/f16subl.h" +#include "src/__support/FPUtil/generic/add_sub.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float16, f16subl, (long double x, long double y)) { + return fputil::generic::sub<float16>(x, y); +} + +} // namespace LIBC_NAMESPACE |