[libc-commits] [libc] [llvm] [libc][math] Refactor float16 operations to header-only (PR #181745)
via libc-commits
libc-commits at lists.llvm.org
Mon Feb 16 13:05:25 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Anonmiraj (AnonMiraj)
<details>
<summary>Changes</summary>
closes: #<!-- -->181744
---
Patch is 70.93 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/181745.diff
57 Files Affected:
- (modified) libc/shared/math.h (+17)
- (added) libc/shared/math/f16add.h (+28)
- (added) libc/shared/math/f16addf.h (+28)
- (added) libc/shared/math/f16addf128.h (+31)
- (added) libc/shared/math/f16addl.h (+28)
- (added) libc/shared/math/f16div.h (+28)
- (added) libc/shared/math/f16divf.h (+28)
- (added) libc/shared/math/f16divf128.h (+31)
- (added) libc/shared/math/f16divl.h (+28)
- (added) libc/shared/math/f16mul.h (+28)
- (added) libc/shared/math/f16mulf.h (+28)
- (added) libc/shared/math/f16mulf128.h (+31)
- (added) libc/shared/math/f16mull.h (+28)
- (added) libc/shared/math/f16sqrtf128.h (+31)
- (added) libc/shared/math/f16sub.h (+28)
- (added) libc/shared/math/f16subf.h (+28)
- (added) libc/shared/math/f16subf128.h (+31)
- (added) libc/shared/math/f16subl.h (+28)
- (modified) libc/src/__support/math/CMakeLists.txt (+175)
- (added) libc/src/__support/math/f16add.h (+32)
- (added) libc/src/__support/math/f16addf.h (+32)
- (added) libc/src/__support/math/f16addf128.h (+35)
- (added) libc/src/__support/math/f16addl.h (+32)
- (added) libc/src/__support/math/f16div.h (+32)
- (added) libc/src/__support/math/f16divf.h (+32)
- (added) libc/src/__support/math/f16divf128.h (+35)
- (added) libc/src/__support/math/f16divl.h (+32)
- (added) libc/src/__support/math/f16mul.h (+32)
- (added) libc/src/__support/math/f16mulf.h (+32)
- (added) libc/src/__support/math/f16mulf128.h (+35)
- (added) libc/src/__support/math/f16mull.h (+32)
- (added) libc/src/__support/math/f16sqrtf128.h (+35)
- (added) libc/src/__support/math/f16sub.h (+32)
- (added) libc/src/__support/math/f16subf.h (+32)
- (added) libc/src/__support/math/f16subf128.h (+35)
- (added) libc/src/__support/math/f16subl.h (+32)
- (modified) libc/src/math/generic/CMakeLists.txt (+17-34)
- (modified) libc/src/math/generic/f16add.cpp (+2-4)
- (modified) libc/src/math/generic/f16addf.cpp (+2-4)
- (modified) libc/src/math/generic/f16addf128.cpp (+2-4)
- (modified) libc/src/math/generic/f16addl.cpp (+2-4)
- (modified) libc/src/math/generic/f16div.cpp (+2-4)
- (modified) libc/src/math/generic/f16divf.cpp (+2-4)
- (modified) libc/src/math/generic/f16divf128.cpp (+2-4)
- (modified) libc/src/math/generic/f16divl.cpp (+2-4)
- (modified) libc/src/math/generic/f16mul.cpp (+2-4)
- (modified) libc/src/math/generic/f16mulf.cpp (+2-4)
- (modified) libc/src/math/generic/f16mulf128.cpp (+2-4)
- (modified) libc/src/math/generic/f16mull.cpp (+2-4)
- (modified) libc/src/math/generic/f16sqrtf128.cpp (+2-4)
- (modified) libc/src/math/generic/f16sub.cpp (+2-4)
- (modified) libc/src/math/generic/f16subf.cpp (+2-4)
- (modified) libc/src/math/generic/f16subf128.cpp (+2-4)
- (modified) libc/src/math/generic/f16subl.cpp (+2-4)
- (modified) libc/test/shared/CMakeLists.txt (+17)
- (modified) libc/test/shared/shared_math_test.cpp (+39-1)
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+274-17)
``````````diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 93f7d6a8156cf..f11e28b6d3133 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -67,13 +67,30 @@
#include "math/expm1.h"
#include "math/expm1f.h"
#include "math/expm1f16.h"
+#include "math/f16add.h"
+#include "math/f16addf.h"
+#include "math/f16addf128.h"
+#include "math/f16addl.h"
+#include "math/f16div.h"
+#include "math/f16divf.h"
+#include "math/f16divf128.h"
+#include "math/f16divl.h"
#include "math/f16fma.h"
#include "math/f16fmaf.h"
#include "math/f16fmaf128.h"
#include "math/f16fmal.h"
+#include "math/f16mul.h"
+#include "math/f16mulf.h"
+#include "math/f16mulf128.h"
+#include "math/f16mull.h"
#include "math/f16sqrt.h"
#include "math/f16sqrtf.h"
+#include "math/f16sqrtf128.h"
#include "math/f16sqrtl.h"
+#include "math/f16sub.h"
+#include "math/f16subf.h"
+#include "math/f16subf128.h"
+#include "math/f16subl.h"
#include "math/ffma.h"
#include "math/ffmal.h"
#include "math/frexpf.h"
diff --git a/libc/shared/math/f16add.h b/libc/shared/math/f16add.h
new file mode 100644
index 0000000000000..f83d685086716
--- /dev/null
+++ b/libc/shared/math/f16add.h
@@ -0,0 +1,28 @@
+//===-- Shared f16add 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_F16ADD_H
+#define LLVM_LIBC_SHARED_MATH_F16ADD_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16add.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16add;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16ADD_H
diff --git a/libc/shared/math/f16addf.h b/libc/shared/math/f16addf.h
new file mode 100644
index 0000000000000..b75b0755c464a
--- /dev/null
+++ b/libc/shared/math/f16addf.h
@@ -0,0 +1,28 @@
+//===-- Shared f16addf 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_F16ADDF_H
+#define LLVM_LIBC_SHARED_MATH_F16ADDF_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16addf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16addf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16ADDF_H
diff --git a/libc/shared/math/f16addf128.h b/libc/shared/math/f16addf128.h
new file mode 100644
index 0000000000000..353686a9529f4
--- /dev/null
+++ b/libc/shared/math/f16addf128.h
@@ -0,0 +1,31 @@
+//===-- Shared f16addf128 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_F16ADDF128_H
+#define LLVM_LIBC_SHARED_MATH_F16ADDF128_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/math/f16addf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16addf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16ADDF128_H
diff --git a/libc/shared/math/f16addl.h b/libc/shared/math/f16addl.h
new file mode 100644
index 0000000000000..817380d81bfae
--- /dev/null
+++ b/libc/shared/math/f16addl.h
@@ -0,0 +1,28 @@
+//===-- Shared f16addl 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_F16ADDL_H
+#define LLVM_LIBC_SHARED_MATH_F16ADDL_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16addl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16addl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16ADDL_H
diff --git a/libc/shared/math/f16div.h b/libc/shared/math/f16div.h
new file mode 100644
index 0000000000000..cf889e050116b
--- /dev/null
+++ b/libc/shared/math/f16div.h
@@ -0,0 +1,28 @@
+//===-- Shared f16div 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_F16DIV_H
+#define LLVM_LIBC_SHARED_MATH_F16DIV_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16div.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16div;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16DIV_H
diff --git a/libc/shared/math/f16divf.h b/libc/shared/math/f16divf.h
new file mode 100644
index 0000000000000..d021f25aa2b6f
--- /dev/null
+++ b/libc/shared/math/f16divf.h
@@ -0,0 +1,28 @@
+//===-- Shared f16divf 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_F16DIVF_H
+#define LLVM_LIBC_SHARED_MATH_F16DIVF_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16divf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16divf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16DIVF_H
diff --git a/libc/shared/math/f16divf128.h b/libc/shared/math/f16divf128.h
new file mode 100644
index 0000000000000..2b00589c7a0e0
--- /dev/null
+++ b/libc/shared/math/f16divf128.h
@@ -0,0 +1,31 @@
+//===-- Shared f16divf128 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_F16DIVF128_H
+#define LLVM_LIBC_SHARED_MATH_F16DIVF128_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/math/f16divf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16divf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16DIVF128_H
diff --git a/libc/shared/math/f16divl.h b/libc/shared/math/f16divl.h
new file mode 100644
index 0000000000000..be3e377231849
--- /dev/null
+++ b/libc/shared/math/f16divl.h
@@ -0,0 +1,28 @@
+//===-- Shared f16divl 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_F16DIVL_H
+#define LLVM_LIBC_SHARED_MATH_F16DIVL_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16divl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16divl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16DIVL_H
diff --git a/libc/shared/math/f16mul.h b/libc/shared/math/f16mul.h
new file mode 100644
index 0000000000000..9cd6afee68307
--- /dev/null
+++ b/libc/shared/math/f16mul.h
@@ -0,0 +1,28 @@
+//===-- Shared f16mul 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_F16MUL_H
+#define LLVM_LIBC_SHARED_MATH_F16MUL_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16mul.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16mul;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16MUL_H
diff --git a/libc/shared/math/f16mulf.h b/libc/shared/math/f16mulf.h
new file mode 100644
index 0000000000000..629e23ea76777
--- /dev/null
+++ b/libc/shared/math/f16mulf.h
@@ -0,0 +1,28 @@
+//===-- Shared f16mulf 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_F16MULF_H
+#define LLVM_LIBC_SHARED_MATH_F16MULF_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16mulf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16mulf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16MULF_H
diff --git a/libc/shared/math/f16mulf128.h b/libc/shared/math/f16mulf128.h
new file mode 100644
index 0000000000000..6052e0421692a
--- /dev/null
+++ b/libc/shared/math/f16mulf128.h
@@ -0,0 +1,31 @@
+//===-- Shared f16mulf128 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_F16MULF128_H
+#define LLVM_LIBC_SHARED_MATH_F16MULF128_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/math/f16mulf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16mulf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16MULF128_H
diff --git a/libc/shared/math/f16mull.h b/libc/shared/math/f16mull.h
new file mode 100644
index 0000000000000..58237afd62ea4
--- /dev/null
+++ b/libc/shared/math/f16mull.h
@@ -0,0 +1,28 @@
+//===-- Shared f16mull 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_F16MULL_H
+#define LLVM_LIBC_SHARED_MATH_F16MULL_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16mull.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16mull;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16MULL_H
diff --git a/libc/shared/math/f16sqrtf128.h b/libc/shared/math/f16sqrtf128.h
new file mode 100644
index 0000000000000..fba8f202f89a2
--- /dev/null
+++ b/libc/shared/math/f16sqrtf128.h
@@ -0,0 +1,31 @@
+//===-- Shared f16sqrtf128 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_F16SQRTF128_H
+#define LLVM_LIBC_SHARED_MATH_F16SQRTF128_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/math/f16sqrtf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16sqrtf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16SQRTF128_H
diff --git a/libc/shared/math/f16sub.h b/libc/shared/math/f16sub.h
new file mode 100644
index 0000000000000..3481ee121d0f7
--- /dev/null
+++ b/libc/shared/math/f16sub.h
@@ -0,0 +1,28 @@
+//===-- Shared f16sub 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_F16SUB_H
+#define LLVM_LIBC_SHARED_MATH_F16SUB_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16sub.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16sub;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16SUB_H
diff --git a/libc/shared/math/f16subf.h b/libc/shared/math/f16subf.h
new file mode 100644
index 0000000000000..14015df03cc0c
--- /dev/null
+++ b/libc/shared/math/f16subf.h
@@ -0,0 +1,28 @@
+//===-- Shared f16subf 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_F16SUBF_H
+#define LLVM_LIBC_SHARED_MATH_F16SUBF_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16subf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16subf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16SUBF_H
diff --git a/libc/shared/math/f16subf128.h b/libc/shared/math/f16subf128.h
new file mode 100644
index 0000000000000..f9a6426bfa1e2
--- /dev/null
+++ b/libc/shared/math/f16subf128.h
@@ -0,0 +1,31 @@
+//===-- Shared f16subf128 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_F16SUBF128_H
+#define LLVM_LIBC_SHARED_MATH_F16SUBF128_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/math/f16subf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16subf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16SUBF128_H
diff --git a/libc/shared/math/f16subl.h b/libc/shared/math/f16subl.h
new file mode 100644
index 0000000000000..f4918af8705f4
--- /dev/null
+++ b/libc/shared/math/f16subl.h
@@ -0,0 +1,28 @@
+//===-- Shared f16subl 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_F16SUBL_H
+#define LLVM_LIBC_SHARED_MATH_F16SUBL_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/f16subl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16subl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_F16SUBL_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index aaab78c01a891..df1bbc5d7b706 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -669,6 +669,181 @@ add_header_library(
libc.src.__support.math.expf16_utils
libc.src.__support.math.exp10_float16_constants
)
+add_header_library(
+ f16add
+ HDRS
+ f16add.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ f16addf
+ HDRS
+ f16addf.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ f16addf128
+ HDRS
+ f16addf128.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ f16addl
+ HDRS
+ f16addl.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ f16div
+ HDRS
+ f16div.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.generic.div
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ f16divf
+ HDRS
+ f16divf.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.generic.div
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ f16divf128
+ HDRS
+ f16divf128.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.include.llvm-libc-types.flo...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/181745
More information about the libc-commits
mailing list