[libc-commits] [compiler-rt] [libc] [compiler-rt][builtins] libc-backed floating-point extend/trunct builtins (PR #209984)
via libc-commits
libc-commits at lists.llvm.org
Fri Jul 17 14:04:51 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: hulxv (hulxv)
<details>
<summary>Changes</summary>
Add libc-backed floating-point extend/truncate builtins
Part of #<!-- -->197824
---
Patch is 42.26 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/209984.diff
30 Files Affected:
- (modified) compiler-rt/lib/builtins/CMakeLists.txt (+29-21)
- (added) compiler-rt/lib/builtins/extenddftf2.cpp (+25)
- (added) compiler-rt/lib/builtins/extendsfdf2.cpp (+21)
- (added) compiler-rt/lib/builtins/extendsftf2.cpp (+25)
- (added) compiler-rt/lib/builtins/extendxftf2.cpp (+25)
- (added) compiler-rt/lib/builtins/truncdfsf2.cpp (+21)
- (added) compiler-rt/lib/builtins/trunctfdf2.cpp (+25)
- (added) compiler-rt/lib/builtins/trunctfsf2.cpp (+25)
- (added) compiler-rt/lib/builtins/trunctfxf2.cpp (+25)
- (modified) libc/shared/builtins.h (+8)
- (added) libc/shared/builtins/extenddftf2.h (+35)
- (added) libc/shared/builtins/extendsfdf2.h (+29)
- (added) libc/shared/builtins/extendsftf2.h (+35)
- (added) libc/shared/builtins/extendxftf2.h (+37)
- (added) libc/shared/builtins/truncdfsf2.h (+29)
- (added) libc/shared/builtins/trunctfdf2.h (+35)
- (added) libc/shared/builtins/trunctfsf2.h (+35)
- (added) libc/shared/builtins/trunctfxf2.h (+37)
- (modified) libc/src/__support/builtins/CMakeLists.txt (+96)
- (added) libc/src/__support/builtins/extenddftf2.h (+36)
- (added) libc/src/__support/builtins/extendsfdf2.h (+30)
- (added) libc/src/__support/builtins/extendsftf2.h (+36)
- (added) libc/src/__support/builtins/extendxftf2.h (+40)
- (added) libc/src/__support/builtins/fpconvert_helper.h (+79)
- (added) libc/src/__support/builtins/truncdfsf2.h (+30)
- (added) libc/src/__support/builtins/trunctfdf2.h (+36)
- (added) libc/src/__support/builtins/trunctfsf2.h (+36)
- (added) libc/src/__support/builtins/trunctfxf2.h (+40)
- (modified) libc/test/shared/CMakeLists.txt (+8)
- (modified) libc/test/shared/shared_builtins_test.cpp (+24)
``````````diff
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index ea21c36d3d31f..acf7e7d278f6c 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -243,6 +243,27 @@ set(GENERIC_TF_SOURCES
trunctfsf2.c
)
+# Implement extended-precision builtins, assuming long double is 80 bits.
+# long double is not 80 bits on Android or MSVC.
+set(x86_80_BIT_SOURCES
+ divxc3.c
+ extendhfxf2.c
+ extendxftf2.c
+ fixxfdi.c
+ fixxfti.c
+ fixunsxfdi.c
+ fixunsxfsi.c
+ fixunsxfti.c
+ floatdixf.c
+ floattixf.c
+ floatundixf.c
+ floatuntixf.c
+ mulxc3.c
+ powixf2.c
+ trunctfxf2.c
+ truncxfhf2.c
+)
+
option(COMPILER_RT_USE_LIBC_MATH
"Use LLVM libc math routines for floating-point builtins" OFF)
@@ -265,6 +286,14 @@ if(COMPILER_RT_USE_LIBC_MATH)
add_definitions(-DCOMPILER_RT_USE_LIBC_MATH)
use_libc_builtin(GENERIC_TF_SOURCES addtf3)
+ use_libc_builtin(GENERIC_TF_SOURCES extenddftf2)
+ use_libc_builtin(GENERIC_SOURCES extendsfdf2)
+ use_libc_builtin(GENERIC_TF_SOURCES extendsftf2)
+ use_libc_builtin(x86_80_BIT_SOURCES extendxftf2)
+ use_libc_builtin(GENERIC_SOURCES truncdfsf2)
+ use_libc_builtin(GENERIC_TF_SOURCES trunctfdf2)
+ use_libc_builtin(GENERIC_TF_SOURCES trunctfsf2)
+ use_libc_builtin(x86_80_BIT_SOURCES trunctfxf2)
endif()
option(COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN
@@ -336,27 +365,6 @@ if (NOT MSVC)
)
endif ()
-# Implement extended-precision builtins, assuming long double is 80 bits.
-# long double is not 80 bits on Android or MSVC.
-set(x86_80_BIT_SOURCES
- divxc3.c
- extendhfxf2.c
- extendxftf2.c
- fixxfdi.c
- fixxfti.c
- fixunsxfdi.c
- fixunsxfsi.c
- fixunsxfti.c
- floatdixf.c
- floattixf.c
- floatundixf.c
- floatuntixf.c
- mulxc3.c
- powixf2.c
- trunctfxf2.c
- truncxfhf2.c
-)
-
if (NOT MSVC)
set(x86_64_SOURCES
${GENERIC_SOURCES}
diff --git a/compiler-rt/lib/builtins/extenddftf2.cpp b/compiler-rt/lib/builtins/extenddftf2.cpp
new file mode 100644
index 0000000000000..268ca6cdde6b8
--- /dev/null
+++ b/compiler-rt/lib/builtins/extenddftf2.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 file implements compiler-rt's __extenddftf2, extend double to float128,
+/// on top of LLVM-libc's shared::extenddftf2.
+///
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/extenddftf2.h"
+
+#if defined(CRT_HAS_TF_MODE)
+extern "C" COMPILER_RT_ABI tf_float __extenddftf2(double a) {
+ return LIBC_NAMESPACE::shared::extenddftf2(a);
+}
+#endif
diff --git a/compiler-rt/lib/builtins/extendsfdf2.cpp b/compiler-rt/lib/builtins/extendsfdf2.cpp
new file mode 100644
index 0000000000000..e7c48dbac0cd8
--- /dev/null
+++ b/compiler-rt/lib/builtins/extendsfdf2.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 file implements compiler-rt's __extendsfdf2, extend float to double, on
+/// top of LLVM-libc's shared::extendsfdf2.
+///
+//===----------------------------------------------------------------------===//
+
+#include "shared/builtins/extendsfdf2.h"
+#include "fp_libc_config.h"
+#include "int_lib.h"
+
+extern "C" COMPILER_RT_ABI double __extendsfdf2(float a) {
+ return LIBC_NAMESPACE::shared::extendsfdf2(a);
+}
diff --git a/compiler-rt/lib/builtins/extendsftf2.cpp b/compiler-rt/lib/builtins/extendsftf2.cpp
new file mode 100644
index 0000000000000..8f90aa6282009
--- /dev/null
+++ b/compiler-rt/lib/builtins/extendsftf2.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 file implements compiler-rt's __extendsftf2, extend float to float128,
+/// on top of LLVM-libc's shared::extendsftf2.
+///
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/extendsftf2.h"
+
+#if defined(CRT_HAS_TF_MODE)
+extern "C" COMPILER_RT_ABI tf_float __extendsftf2(float a) {
+ return LIBC_NAMESPACE::shared::extendsftf2(a);
+}
+#endif
diff --git a/compiler-rt/lib/builtins/extendxftf2.cpp b/compiler-rt/lib/builtins/extendxftf2.cpp
new file mode 100644
index 0000000000000..5c0c91118ecbe
--- /dev/null
+++ b/compiler-rt/lib/builtins/extendxftf2.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 file implements compiler-rt's __extendxftf2, extend long double to
+/// float128, on top of LLVM-libc's shared::extendxftf2.
+///
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/extendxftf2.h"
+
+#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
+extern "C" COMPILER_RT_ABI tf_float __extendxftf2(xf_float a) {
+ return LIBC_NAMESPACE::shared::extendxftf2(a);
+}
+#endif
diff --git a/compiler-rt/lib/builtins/truncdfsf2.cpp b/compiler-rt/lib/builtins/truncdfsf2.cpp
new file mode 100644
index 0000000000000..775526dbff96a
--- /dev/null
+++ b/compiler-rt/lib/builtins/truncdfsf2.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 file implements compiler-rt's __truncdfsf2, truncate double to float,
+/// on top of LLVM-libc's shared::truncdfsf2.
+///
+//===----------------------------------------------------------------------===//
+
+#include "shared/builtins/truncdfsf2.h"
+#include "fp_libc_config.h"
+#include "int_lib.h"
+
+extern "C" COMPILER_RT_ABI float __truncdfsf2(double a) {
+ return LIBC_NAMESPACE::shared::truncdfsf2(a);
+}
diff --git a/compiler-rt/lib/builtins/trunctfdf2.cpp b/compiler-rt/lib/builtins/trunctfdf2.cpp
new file mode 100644
index 0000000000000..f381d2768d6b1
--- /dev/null
+++ b/compiler-rt/lib/builtins/trunctfdf2.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 file implements compiler-rt's __trunctfdf2, truncate float128 to
+/// double, on top of LLVM-libc's shared::trunctfdf2.
+///
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/trunctfdf2.h"
+
+#if defined(CRT_HAS_TF_MODE)
+extern "C" COMPILER_RT_ABI double __trunctfdf2(tf_float a) {
+ return LIBC_NAMESPACE::shared::trunctfdf2(a);
+}
+#endif
diff --git a/compiler-rt/lib/builtins/trunctfsf2.cpp b/compiler-rt/lib/builtins/trunctfsf2.cpp
new file mode 100644
index 0000000000000..aac13c25b4b28
--- /dev/null
+++ b/compiler-rt/lib/builtins/trunctfsf2.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 file implements compiler-rt's __trunctfsf2, truncate float128 to float,
+/// on top of LLVM-libc's shared::trunctfsf2.
+///
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/trunctfsf2.h"
+
+#if defined(CRT_HAS_TF_MODE)
+extern "C" COMPILER_RT_ABI float __trunctfsf2(tf_float a) {
+ return LIBC_NAMESPACE::shared::trunctfsf2(a);
+}
+#endif
diff --git a/compiler-rt/lib/builtins/trunctfxf2.cpp b/compiler-rt/lib/builtins/trunctfxf2.cpp
new file mode 100644
index 0000000000000..88dae578025bc
--- /dev/null
+++ b/compiler-rt/lib/builtins/trunctfxf2.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 file implements compiler-rt's __trunctfxf2, truncate float128 to long
+/// double, on top of LLVM-libc's shared::trunctfxf2.
+///
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/trunctfxf2.h"
+
+#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
+extern "C" COMPILER_RT_ABI xf_float __trunctfxf2(tf_float a) {
+ return LIBC_NAMESPACE::shared::trunctfxf2(a);
+}
+#endif
diff --git a/libc/shared/builtins.h b/libc/shared/builtins.h
index ced054cb02582..0b1cc7974d284 100644
--- a/libc/shared/builtins.h
+++ b/libc/shared/builtins.h
@@ -23,11 +23,19 @@
#include "builtins/divdf3.h"
#include "builtins/divsf3.h"
#include "builtins/divtf3.h"
+#include "builtins/extenddftf2.h"
+#include "builtins/extendsfdf2.h"
+#include "builtins/extendsftf2.h"
+#include "builtins/extendxftf2.h"
#include "builtins/muldf3.h"
#include "builtins/mulsf3.h"
#include "builtins/multf3.h"
#include "builtins/subdf3.h"
#include "builtins/subsf3.h"
#include "builtins/subtf3.h"
+#include "builtins/truncdfsf2.h"
+#include "builtins/trunctfdf2.h"
+#include "builtins/trunctfsf2.h"
+#include "builtins/trunctfxf2.h"
#endif // LLVM_LIBC_SHARED_BUILTINS_H
diff --git a/libc/shared/builtins/extenddftf2.h b/libc/shared/builtins/extenddftf2.h
new file mode 100644
index 0000000000000..4790d48371eef
--- /dev/null
+++ b/libc/shared/builtins/extenddftf2.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 __extenddftf2 implementation as
+/// shared::extenddftf2 so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_EXTENDDFTF2_H
+#define LLVM_LIBC_SHARED_BUILTINS_EXTENDDFTF2_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/extenddftf2.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::extenddftf2;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_EXTENDDFTF2_H
diff --git a/libc/shared/builtins/extendsfdf2.h b/libc/shared/builtins/extendsfdf2.h
new file mode 100644
index 0000000000000..4f361ff9b4b9e
--- /dev/null
+++ b/libc/shared/builtins/extendsfdf2.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 __extendsfdf2 implementation as
+/// shared::extendsfdf2 so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_EXTENDSFDF2_H
+#define LLVM_LIBC_SHARED_BUILTINS_EXTENDSFDF2_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/extendsfdf2.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::extendsfdf2;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_EXTENDSFDF2_H
diff --git a/libc/shared/builtins/extendsftf2.h b/libc/shared/builtins/extendsftf2.h
new file mode 100644
index 0000000000000..93395df407981
--- /dev/null
+++ b/libc/shared/builtins/extendsftf2.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 __extendsftf2 implementation as
+/// shared::extendsftf2 so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_EXTENDSFTF2_H
+#define LLVM_LIBC_SHARED_BUILTINS_EXTENDSFTF2_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/extendsftf2.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::extendsftf2;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_EXTENDSFTF2_H
diff --git a/libc/shared/builtins/extendxftf2.h b/libc/shared/builtins/extendxftf2.h
new file mode 100644
index 0000000000000..d1631c8c46f1e
--- /dev/null
+++ b/libc/shared/builtins/extendxftf2.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __extendxftf2 implementation as
+/// shared::extendxftf2 so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_EXTENDXFTF2_H
+#define LLVM_LIBC_SHARED_BUILTINS_EXTENDXFTF2_H
+
+#include "include/llvm-libc-types/float128.h"
+#include "src/__support/macros/properties/types.h"
+
+#if defined(LIBC_TYPES_HAS_FLOAT128) && \
+ defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/extendxftf2.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::extendxftf2;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128 && LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_EXTENDXFTF2_H
diff --git a/libc/shared/builtins/truncdfsf2.h b/libc/shared/builtins/truncdfsf2.h
new file mode 100644
index 0000000000000..7145b45c5ed0c
--- /dev/null
+++ b/libc/shared/builtins/truncdfsf2.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 __truncdfsf2 implementation as
+/// shared::truncdfsf2 so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_TRUNCDFSF2_H
+#define LLVM_LIBC_SHARED_BUILTINS_TRUNCDFSF2_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/truncdfsf2.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::truncdfsf2;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_TRUNCDFSF2_H
diff --git a/libc/shared/builtins/trunctfdf2.h b/libc/shared/builtins/trunctfdf2.h
new file mode 100644
index 0000000000000..5e8b34f3cecd6
--- /dev/null
+++ b/libc/shared/builtins/trunctfdf2.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 __trunctfdf2 implementation as
+/// shared::trunctfdf2 so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_TRUNCTFDF2_H
+#define LLVM_LIBC_SHARED_BUILTINS_TRUNCTFDF2_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/trunctfdf2.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::trunctfdf2;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_TRUNCTFDF2_H
diff --git a/libc/shared/builtins/trunctfsf2.h b/libc/shared/builtins/trunctfsf2.h
new file mode 100644
index 0000000000000..4d0f64b399279
--- /dev/null
+++ b/libc/shared/builtins/trunctfsf2.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 __trunctfsf2 implementation as
+/// shared::trunctfsf2 so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_TRUNCTFSF2_H
+#define LLVM_LIBC_SHARED_BUILTINS_TRUNCT...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/209984
More information about the libc-commits
mailing list