[libc-commits] [libc] [libc] add shared muldf3 builtin (PR #205674)
via libc-commits
libc-commits at lists.llvm.org
Wed Jun 24 14:52:25 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: hulxv (hulxv)
<details>
<summary>Changes</summary>
Re-exposes LLVM-libc's `__muldf3` as `shared::muldf3` for reuse by compiler-rt's builtins.
Stacked change - merge these first:
- #<!-- -->200094
- #<!-- -->205669
- #<!-- -->205670
- #<!-- -->205671
- #<!-- -->205672
- #<!-- -->205673
---
Patch is 25.45 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/205674.diff
21 Files Affected:
- (modified) libc/include/llvm-libc-macros/float-macros.h (+6)
- (added) libc/shared/builtins.h (+28)
- (added) libc/shared/builtins/adddf3.h (+29)
- (added) libc/shared/builtins/addtf3.h (+35)
- (added) libc/shared/builtins/divtf3.h (+35)
- (added) libc/shared/builtins/muldf3.h (+29)
- (added) libc/shared/builtins/multf3.h (+35)
- (added) libc/shared/builtins/subdf3.h (+29)
- (added) libc/shared/builtins/subtf3.h (+35)
- (modified) libc/src/__support/CMakeLists.txt (+1)
- (modified) libc/src/__support/FPUtil/dyadic_float.h (+3)
- (added) libc/src/__support/builtins/CMakeLists.txt (+66)
- (added) libc/src/__support/builtins/adddf3.h (+32)
- (added) libc/src/__support/builtins/addtf3.h (+38)
- (added) libc/src/__support/builtins/divtf3.h (+38)
- (added) libc/src/__support/builtins/muldf3.h (+32)
- (added) libc/src/__support/builtins/multf3.h (+38)
- (added) libc/src/__support/builtins/subdf3.h (+32)
- (added) libc/src/__support/builtins/subtf3.h (+38)
- (modified) libc/test/shared/CMakeLists.txt (+10)
- (added) libc/test/shared/shared_builtins_test.cpp (+77)
``````````diff
diff --git a/libc/include/llvm-libc-macros/float-macros.h b/libc/include/llvm-libc-macros/float-macros.h
index a25ef60a293d3..38a3a771cca54 100644
--- a/libc/include/llvm-libc-macros/float-macros.h
+++ b/libc/include/llvm-libc-macros/float-macros.h
@@ -9,6 +9,12 @@
#ifndef LLVM_LIBC_MACROS_FLOAT_MACROS_H
#define LLVM_LIBC_MACROS_FLOAT_MACROS_H
+// __has_builtin is a Clang extension; GCC < 10 doesn't define it, which
+// turns a bare `#if __has_builtin(...)` into a preprocessor syntax error.
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+
#ifndef FLT_RADIX
#define FLT_RADIX __FLT_RADIX__
#endif // FLT_RADIX
diff --git a/libc/shared/builtins.h b/libc/shared/builtins.h
new file mode 100644
index 0000000000000..2540be78519d7
--- /dev/null
+++ b/libc/shared/builtins.h
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header aggregates LLVM-libc's shared compiler-rt builtins so that
+/// they can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_H
+#define LLVM_LIBC_SHARED_BUILTINS_H
+
+#include "libc_common.h"
+
+#include "builtins/adddf3.h"
+#include "builtins/addtf3.h"
+#include "builtins/divtf3.h"
+#include "builtins/muldf3.h"
+#include "builtins/multf3.h"
+#include "builtins/subdf3.h"
+#include "builtins/subtf3.h"
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_H
diff --git a/libc/shared/builtins/adddf3.h b/libc/shared/builtins/adddf3.h
new file mode 100644
index 0000000000000..33936cb8b2486
--- /dev/null
+++ b/libc/shared/builtins/adddf3.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __adddf3 implementation as shared::adddf3 so
+/// that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_ADDDF3_H
+#define LLVM_LIBC_SHARED_BUILTINS_ADDDF3_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/adddf3.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::adddf3;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_ADDDF3_H
diff --git a/libc/shared/builtins/addtf3.h b/libc/shared/builtins/addtf3.h
new file mode 100644
index 0000000000000..33534beeb91c7
--- /dev/null
+++ b/libc/shared/builtins/addtf3.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __addtf3 implementation as shared::addtf3
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_ADDTF3_H
+#define LLVM_LIBC_SHARED_BUILTINS_ADDTF3_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/addtf3.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::addtf3;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_ADDTF3_H
diff --git a/libc/shared/builtins/divtf3.h b/libc/shared/builtins/divtf3.h
new file mode 100644
index 0000000000000..ca69e6f5fc0e7
--- /dev/null
+++ b/libc/shared/builtins/divtf3.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __divtf3 implementation as shared::divtf3 so
+/// that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_DIVTF3_H
+#define LLVM_LIBC_SHARED_BUILTINS_DIVTF3_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/divtf3.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::divtf3;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_DIVTF3_H
diff --git a/libc/shared/builtins/muldf3.h b/libc/shared/builtins/muldf3.h
new file mode 100644
index 0000000000000..702c73428e5f4
--- /dev/null
+++ b/libc/shared/builtins/muldf3.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __muldf3 implementation as shared::muldf3 so
+/// that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_MULDF3_H
+#define LLVM_LIBC_SHARED_BUILTINS_MULDF3_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/muldf3.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::muldf3;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_MULDF3_H
diff --git a/libc/shared/builtins/multf3.h b/libc/shared/builtins/multf3.h
new file mode 100644
index 0000000000000..cfc2964fd6a79
--- /dev/null
+++ b/libc/shared/builtins/multf3.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __multf3 implementation as shared::multf3 so
+/// that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_MULTF3_H
+#define LLVM_LIBC_SHARED_BUILTINS_MULTF3_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/multf3.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::multf3;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_MULTF3_H
diff --git a/libc/shared/builtins/subdf3.h b/libc/shared/builtins/subdf3.h
new file mode 100644
index 0000000000000..8cff7e3bfa28f
--- /dev/null
+++ b/libc/shared/builtins/subdf3.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __subdf3 implementation as shared::subdf3 so
+/// that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_SUBDF3_H
+#define LLVM_LIBC_SHARED_BUILTINS_SUBDF3_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/subdf3.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::subdf3;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_SUBDF3_H
diff --git a/libc/shared/builtins/subtf3.h b/libc/shared/builtins/subtf3.h
new file mode 100644
index 0000000000000..a7cecef8b0479
--- /dev/null
+++ b/libc/shared/builtins/subtf3.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __subtf3 implementation as shared::subtf3 so
+/// that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_SUBTF3_H
+#define LLVM_LIBC_SHARED_BUILTINS_SUBTF3_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/subtf3.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::subtf3;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_SUBTF3_H
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index 9d08b4bcf7303..c09ca012c3594 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -472,6 +472,7 @@ add_subdirectory(wchar)
add_subdirectory(wctype)
add_subdirectory(math)
+add_subdirectory(builtins)
if(LIBC_COMPILER_HAS_EXT_VECTOR_TYPE)
add_subdirectory(mathvec)
endif()
diff --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h
index 7e4ea2f1a81be..d99a14f35f38e 100644
--- a/libc/src/__support/FPUtil/dyadic_float.h
+++ b/libc/src/__support/FPUtil/dyadic_float.h
@@ -415,6 +415,9 @@ template <size_t Bits> struct DyadicFloat {
if constexpr (cpp::is_same_v<T, bfloat16>
#if defined(LIBC_TYPES_HAS_FLOAT16) && !defined(__LIBC_USE_FLOAT16_CONVERSION)
|| cpp::is_same_v<T, float16>
+#endif
+#if defined(LIBC_TYPES_HAS_FLOAT128)
+ || cpp::is_same_v<T, float128>
#endif
)
return generic_as<T, ShouldSignalExceptions>();
diff --git a/libc/src/__support/builtins/CMakeLists.txt b/libc/src/__support/builtins/CMakeLists.txt
new file mode 100644
index 0000000000000..179337c4d6cf0
--- /dev/null
+++ b/libc/src/__support/builtins/CMakeLists.txt
@@ -0,0 +1,66 @@
+add_header_library(
+ addtf3
+ HDRS
+ addtf3.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ subtf3
+ HDRS
+ subtf3.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ multf3
+ HDRS
+ multf3.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.generic.mul
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ divtf3
+ HDRS
+ divtf3.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.generic.div
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ adddf3
+ HDRS
+ adddf3.h
+ DEPENDS
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ subdf3
+ HDRS
+ subdf3.h
+ DEPENDS
+ libc.src.__support.FPUtil.generic.add_sub
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ muldf3
+ HDRS
+ muldf3.h
+ DEPENDS
+ libc.src.__support.FPUtil.generic.mul
+ libc.src.__support.macros.config
+)
diff --git a/libc/src/__support/builtins/adddf3.h b/libc/src/__support/builtins/adddf3.h
new file mode 100644
index 0000000000000..9fa60ca8d1c69
--- /dev/null
+++ b/libc/src/__support/builtins/adddf3.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __adddf3 implementation as builtins::adddf3
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_ADDDF3_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_ADDDF3_H
+
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Addition at double precision; mirrors compiler-rt's __adddf3.
+LIBC_INLINE double adddf3(double x, double y) {
+ return fputil::generic::add<double>(x, y);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_ADDDF3_H
diff --git a/libc/src/__support/builtins/addtf3.h b/libc/src/__support/builtins/addtf3.h
new file mode 100644
index 0000000000000..f33036f53ec30
--- /dev/null
+++ b/libc/src/__support/builtins/addtf3.h
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __addtf3 implementation as
+/// builtins::addtf3 so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_ADDTF3_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_ADDTF3_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Mirrors the compiler-rt __addtf3 ABI: a + b at float128 precision.
+LIBC_INLINE float128 addtf3(float128 x, float128 y) {
+ return fputil::generic::add<float128>(x, y);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_ADDTF3_H
diff --git a/libc/src/__support/builtins/divtf3.h b/libc/src/__support/builtins/divtf3.h
new file mode 100644
index 0000000000000..7f25586cde6c9
--- /dev/null
+++ b/libc/src/__support/builtins/divtf3.h
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __divtf3 implementation as builtins::divtf3
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_DIVTF3_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_DIVTF3_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/generic/div.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Division at float128 precision; mirrors compiler-rt's __divtf3.
+LIBC_INLINE float128 divtf3(float128 x, float128 y) {
+ return fputil::generic::div<float128>(x, y);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_DIVTF3_H
diff --git a/libc/src/__support/builtins/muldf3.h b/libc/src/__support/builtins/muldf3.h
new file mode 100644
index 0000000000000..b407b96ef90b4
--- /dev/null
+++ b/libc/src/__support/builtins/muldf3.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __muldf3 implementation as builtins::muldf3
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_MULDF3_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_MULDF3_H
+
+#include "src/__support/FPUtil/generic/mul.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Multiplication at double precision; mirrors compiler-rt's __muldf3.
+LIBC_INLINE double muldf3(double x, double y) {
+ return fputil::generic::mul<double>(x, y);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_MULDF3_H
diff --git a/libc/src/__support/builtins/multf3.h b/libc/src/__support/builtins/multf3.h
new file mode 100644
index 0000000000000..b6798325ff17d
--- /dev/null
+++ b/libc/src/__support/builtins/multf3.h
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __multf3 implementation as builtins::multf3
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_MULTF3_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_MULTF3_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/generic/mul.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Multiplication at float128 precision; mirrors compiler-rt's __multf3.
+LIBC_INLINE float128 multf3(float128 x, float128 y) {
+ return fputil::generic::mul<float128>(x, y);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_MULTF3_H
diff --git a/libc/src/__support/builtins/subdf3.h b/libc/src/__support/builtins/subdf3.h
new file mode 100644
index 0000000000000..5e704aa714af6
--- /dev/null
+++ b/libc/src/__support/builtins/subdf3.h
@@ -0,0 +1,32 @@
+//==...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/205674
More information about the libc-commits
mailing list