[libc-commits] [libc] f9b0ba3 - [compiler-rt][builtins] libc-backed int-to-double/float builtins (#209900)
via libc-commits
libc-commits at lists.llvm.org
Sat Aug 8 14:24:19 PDT 2026
Author: hulxv
Date: 2026-08-08T21:24:13Z
New Revision: f9b0ba3fdae3df4e6e1559b243d6bc786bc90807
URL: https://github.com/llvm/llvm-project/commit/f9b0ba3fdae3df4e6e1559b243d6bc786bc90807
DIFF: https://github.com/llvm/llvm-project/commit/f9b0ba3fdae3df4e6e1559b243d6bc786bc90807.diff
LOG: [compiler-rt][builtins] libc-backed int-to-double/float builtins (#209900)
Add libc-backed integer to double/float conversion builtins
Part of #197824
Added:
compiler-rt/lib/builtins/floatdidf.cpp
compiler-rt/lib/builtins/floatdisf.cpp
compiler-rt/lib/builtins/floatsidf.cpp
compiler-rt/lib/builtins/floatsisf.cpp
compiler-rt/lib/builtins/floattidf.cpp
compiler-rt/lib/builtins/floattisf.cpp
compiler-rt/lib/builtins/floatundidf.cpp
compiler-rt/lib/builtins/floatundisf.cpp
compiler-rt/lib/builtins/floatunsidf.cpp
compiler-rt/lib/builtins/floatunsisf.cpp
compiler-rt/lib/builtins/floatuntidf.cpp
compiler-rt/lib/builtins/floatuntisf.cpp
libc/shared/builtins/floatdidf.h
libc/shared/builtins/floatdisf.h
libc/shared/builtins/floatsidf.h
libc/shared/builtins/floatsisf.h
libc/shared/builtins/floattidf.h
libc/shared/builtins/floattisf.h
libc/shared/builtins/floatundidf.h
libc/shared/builtins/floatundisf.h
libc/shared/builtins/floatunsidf.h
libc/shared/builtins/floatunsisf.h
libc/shared/builtins/floatuntidf.h
libc/shared/builtins/floatuntisf.h
libc/src/__support/builtins/floatdidf.h
libc/src/__support/builtins/floatdisf.h
libc/src/__support/builtins/floatint_helper.h
libc/src/__support/builtins/floatsidf.h
libc/src/__support/builtins/floatsisf.h
libc/src/__support/builtins/floattidf.h
libc/src/__support/builtins/floattisf.h
libc/src/__support/builtins/floatundidf.h
libc/src/__support/builtins/floatundisf.h
libc/src/__support/builtins/floatunsidf.h
libc/src/__support/builtins/floatunsisf.h
libc/src/__support/builtins/floatuntidf.h
libc/src/__support/builtins/floatuntisf.h
Modified:
compiler-rt/lib/builtins/CMakeLists.txt
libc/shared/builtins.h
libc/src/__support/builtins/CMakeLists.txt
libc/test/shared/CMakeLists.txt
Removed:
################################################################################
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 1134115934df5..e7827f2201b43 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -307,6 +307,18 @@ if(COMPILER_RT_USE_LIBC_MATH)
use_libc_builtin(GENERIC_SOURCES fixunssfsi)
use_libc_builtin(GENERIC_SOURCES fixunssfdi)
use_libc_builtin(GENERIC_SOURCES fixunssfti)
+ use_libc_builtin(GENERIC_SOURCES floatsidf)
+ use_libc_builtin(GENERIC_SOURCES floatdidf)
+ use_libc_builtin(GENERIC_SOURCES floattidf)
+ use_libc_builtin(GENERIC_SOURCES floatsisf)
+ use_libc_builtin(GENERIC_SOURCES floatdisf)
+ use_libc_builtin(GENERIC_SOURCES floattisf)
+ use_libc_builtin(GENERIC_SOURCES floatunsidf)
+ use_libc_builtin(GENERIC_SOURCES floatundidf)
+ use_libc_builtin(GENERIC_SOURCES floatuntidf)
+ use_libc_builtin(GENERIC_SOURCES floatunsisf)
+ use_libc_builtin(GENERIC_SOURCES floatundisf)
+ use_libc_builtin(GENERIC_SOURCES floatuntisf)
use_libc_builtin(GENERIC_SOURCES muldf3)
use_libc_builtin(GENERIC_SOURCES mulsf3)
use_libc_builtin(GENERIC_TF_SOURCES multf3)
diff --git a/compiler-rt/lib/builtins/floatdidf.cpp b/compiler-rt/lib/builtins/floatdidf.cpp
new file mode 100644
index 0000000000000..4bc0a12090f1d
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatdidf.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __floatdidf, int64_t -> double conversion
+/// (round to nearest), on top of LLVM-libc's shared::floatdidf.
+///
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/floatdidf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatdidf(di_int a) {
+ return LIBC_NAMESPACE::shared::floatdidf(a);
+}
diff --git a/compiler-rt/lib/builtins/floatdisf.cpp b/compiler-rt/lib/builtins/floatdisf.cpp
new file mode 100644
index 0000000000000..bfe1b8be533c1
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatdisf.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __floatdisf, int64_t -> float conversion
+/// (round to nearest), on top of LLVM-libc's shared::floatdisf.
+///
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/floatdisf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatdisf(di_int a) {
+ return LIBC_NAMESPACE::shared::floatdisf(a);
+}
diff --git a/compiler-rt/lib/builtins/floatsidf.cpp b/compiler-rt/lib/builtins/floatsidf.cpp
new file mode 100644
index 0000000000000..cac1a66b0869c
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatsidf.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __floatsidf, int32_t -> double conversion
+/// (round to nearest), on top of LLVM-libc's shared::floatsidf.
+///
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/floatsidf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatsidf(si_int a) {
+ return LIBC_NAMESPACE::shared::floatsidf(a);
+}
diff --git a/compiler-rt/lib/builtins/floatsisf.cpp b/compiler-rt/lib/builtins/floatsisf.cpp
new file mode 100644
index 0000000000000..5229ffc3614af
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatsisf.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __floatsisf, int32_t -> float conversion
+/// (round to nearest), on top of LLVM-libc's shared::floatsisf.
+///
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/floatsisf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatsisf(si_int a) {
+ return LIBC_NAMESPACE::shared::floatsisf(a);
+}
diff --git a/compiler-rt/lib/builtins/floattidf.cpp b/compiler-rt/lib/builtins/floattidf.cpp
new file mode 100644
index 0000000000000..f92d1e2659460
--- /dev/null
+++ b/compiler-rt/lib/builtins/floattidf.cpp
@@ -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 file implements compiler-rt's __floattidf, __int128_t -> double
+/// conversion (round to nearest), on top of LLVM-libc's shared::floattidf.
+///
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+
+#ifdef CRT_HAS_128BIT
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/floattidf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floattidf(ti_int a) {
+ return LIBC_NAMESPACE::shared::floattidf(a);
+}
+
+#endif // CRT_HAS_128BIT
diff --git a/compiler-rt/lib/builtins/floattisf.cpp b/compiler-rt/lib/builtins/floattisf.cpp
new file mode 100644
index 0000000000000..324b32d641dfc
--- /dev/null
+++ b/compiler-rt/lib/builtins/floattisf.cpp
@@ -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 file implements compiler-rt's __floattisf, __int128_t -> float
+/// conversion (round to nearest), on top of LLVM-libc's shared::floattisf.
+///
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+
+#ifdef CRT_HAS_128BIT
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/floattisf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floattisf(ti_int a) {
+ return LIBC_NAMESPACE::shared::floattisf(a);
+}
+
+#endif // CRT_HAS_128BIT
diff --git a/compiler-rt/lib/builtins/floatundidf.cpp b/compiler-rt/lib/builtins/floatundidf.cpp
new file mode 100644
index 0000000000000..3a5b5b85047aa
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatundidf.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __floatundidf, uint64_t -> double
+/// conversion (round to nearest), on top of LLVM-libc's shared::floatundidf.
+///
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/floatundidf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatundidf(du_int a) {
+ return LIBC_NAMESPACE::shared::floatundidf(a);
+}
diff --git a/compiler-rt/lib/builtins/floatundisf.cpp b/compiler-rt/lib/builtins/floatundisf.cpp
new file mode 100644
index 0000000000000..60844ce1b9cd6
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatundisf.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __floatundisf, uint64_t -> float
+/// conversion (round to nearest), on top of LLVM-libc's shared::floatundisf.
+///
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/floatundisf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatundisf(du_int a) {
+ return LIBC_NAMESPACE::shared::floatundisf(a);
+}
diff --git a/compiler-rt/lib/builtins/floatunsidf.cpp b/compiler-rt/lib/builtins/floatunsidf.cpp
new file mode 100644
index 0000000000000..4cdff38e3e793
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatunsidf.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __floatunsidf, uint32_t -> double
+/// conversion (round to nearest), on top of LLVM-libc's shared::floatunsidf.
+///
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/floatunsidf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatunsidf(su_int a) {
+ return LIBC_NAMESPACE::shared::floatunsidf(a);
+}
diff --git a/compiler-rt/lib/builtins/floatunsisf.cpp b/compiler-rt/lib/builtins/floatunsisf.cpp
new file mode 100644
index 0000000000000..aac12daa3d1aa
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatunsisf.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __floatunsisf, uint32_t -> float
+/// conversion (round to nearest), on top of LLVM-libc's shared::floatunsisf.
+///
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/floatunsisf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatunsisf(su_int a) {
+ return LIBC_NAMESPACE::shared::floatunsisf(a);
+}
diff --git a/compiler-rt/lib/builtins/floatuntidf.cpp b/compiler-rt/lib/builtins/floatuntidf.cpp
new file mode 100644
index 0000000000000..22c9c443e3079
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatuntidf.cpp
@@ -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 file implements compiler-rt's __floatuntidf, __uint128_t -> double
+/// conversion (round to nearest), on top of LLVM-libc's shared::floatuntidf.
+///
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+
+#ifdef CRT_HAS_128BIT
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/floatuntidf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatuntidf(tu_int a) {
+ return LIBC_NAMESPACE::shared::floatuntidf(a);
+}
+
+#endif // CRT_HAS_128BIT
diff --git a/compiler-rt/lib/builtins/floatuntisf.cpp b/compiler-rt/lib/builtins/floatuntisf.cpp
new file mode 100644
index 0000000000000..4a8d32c089def
--- /dev/null
+++ b/compiler-rt/lib/builtins/floatuntisf.cpp
@@ -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 file implements compiler-rt's __floatuntisf, __uint128_t -> float
+/// conversion (round to nearest), on top of LLVM-libc's shared::floatuntisf.
+///
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+
+#ifdef CRT_HAS_128BIT
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/floatuntisf.h"
+
+extern "C" COMPILER_RT_ABI fp_t __floatuntisf(tu_int a) {
+ return LIBC_NAMESPACE::shared::floatuntisf(a);
+}
+
+#endif // CRT_HAS_128BIT
diff --git a/libc/shared/builtins.h b/libc/shared/builtins.h
index e13ef6b84a6de..21c2bed4a0af1 100644
--- a/libc/shared/builtins.h
+++ b/libc/shared/builtins.h
@@ -39,6 +39,18 @@
#include "builtins/fixunssfdi.h"
#include "builtins/fixunssfsi.h"
#include "builtins/fixunssfti.h"
+#include "builtins/floatdidf.h"
+#include "builtins/floatdisf.h"
+#include "builtins/floatsidf.h"
+#include "builtins/floatsisf.h"
+#include "builtins/floattidf.h"
+#include "builtins/floattisf.h"
+#include "builtins/floatundidf.h"
+#include "builtins/floatundisf.h"
+#include "builtins/floatunsidf.h"
+#include "builtins/floatunsisf.h"
+#include "builtins/floatuntidf.h"
+#include "builtins/floatuntisf.h"
#include "builtins/muldf3.h"
#include "builtins/mulsf3.h"
#include "builtins/multf3.h"
diff --git a/libc/shared/builtins/floatdidf.h b/libc/shared/builtins/floatdidf.h
new file mode 100644
index 0000000000000..6d5d54994cff3
--- /dev/null
+++ b/libc/shared/builtins/floatdidf.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 __floatdidf implementation as
+/// shared::floatdidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATDIDF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATDIDF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatdidf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatdidf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATDIDF_H
diff --git a/libc/shared/builtins/floatdisf.h b/libc/shared/builtins/floatdisf.h
new file mode 100644
index 0000000000000..b0f29485dc985
--- /dev/null
+++ b/libc/shared/builtins/floatdisf.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 __floatdisf implementation as
+/// shared::floatdisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATDISF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATDISF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatdisf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatdisf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATDISF_H
diff --git a/libc/shared/builtins/floatsidf.h b/libc/shared/builtins/floatsidf.h
new file mode 100644
index 0000000000000..f1d4708ac667b
--- /dev/null
+++ b/libc/shared/builtins/floatsidf.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 __floatsidf implementation as
+/// shared::floatsidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATSIDF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATSIDF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatsidf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatsidf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATSIDF_H
diff --git a/libc/shared/builtins/floatsisf.h b/libc/shared/builtins/floatsisf.h
new file mode 100644
index 0000000000000..0d318b26cd7ab
--- /dev/null
+++ b/libc/shared/builtins/floatsisf.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 __floatsisf implementation as
+/// shared::floatsisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATSISF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATSISF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatsisf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatsisf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATSISF_H
diff --git a/libc/shared/builtins/floattidf.h b/libc/shared/builtins/floattidf.h
new file mode 100644
index 0000000000000..4aaecb88d479f
--- /dev/null
+++ b/libc/shared/builtins/floattidf.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 __floattidf implementation as
+/// shared::floattidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATTIDF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATTIDF_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floattidf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floattidf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATTIDF_H
diff --git a/libc/shared/builtins/floattisf.h b/libc/shared/builtins/floattisf.h
new file mode 100644
index 0000000000000..d2667cbb6d1be
--- /dev/null
+++ b/libc/shared/builtins/floattisf.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 __floattisf implementation as
+/// shared::floattisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATTISF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATTISF_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floattisf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floattisf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATTISF_H
diff --git a/libc/shared/builtins/floatundidf.h b/libc/shared/builtins/floatundidf.h
new file mode 100644
index 0000000000000..34f78a01f6af7
--- /dev/null
+++ b/libc/shared/builtins/floatundidf.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 __floatundidf implementation as
+/// shared::floatundidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATUNDIDF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATUNDIDF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatundidf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatundidf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATUNDIDF_H
diff --git a/libc/shared/builtins/floatundisf.h b/libc/shared/builtins/floatundisf.h
new file mode 100644
index 0000000000000..3905e4157f168
--- /dev/null
+++ b/libc/shared/builtins/floatundisf.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 __floatundisf implementation as
+/// shared::floatundisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATUNDISF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATUNDISF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatundisf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatundisf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATUNDISF_H
diff --git a/libc/shared/builtins/floatunsidf.h b/libc/shared/builtins/floatunsidf.h
new file mode 100644
index 0000000000000..a1509fa1a6b7d
--- /dev/null
+++ b/libc/shared/builtins/floatunsidf.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 __floatunsidf implementation as
+/// shared::floatunsidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATUNSIDF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATUNSIDF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatunsidf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatunsidf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATUNSIDF_H
diff --git a/libc/shared/builtins/floatunsisf.h b/libc/shared/builtins/floatunsisf.h
new file mode 100644
index 0000000000000..c2190df469dd1
--- /dev/null
+++ b/libc/shared/builtins/floatunsisf.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 __floatunsisf implementation as
+/// shared::floatunsisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATUNSISF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATUNSISF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatunsisf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatunsisf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATUNSISF_H
diff --git a/libc/shared/builtins/floatuntidf.h b/libc/shared/builtins/floatuntidf.h
new file mode 100644
index 0000000000000..4a3f1ebaa7486
--- /dev/null
+++ b/libc/shared/builtins/floatuntidf.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 __floatuntidf implementation as
+/// shared::floatuntidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATUNTIDF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATUNTIDF_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatuntidf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatuntidf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATUNTIDF_H
diff --git a/libc/shared/builtins/floatuntisf.h b/libc/shared/builtins/floatuntisf.h
new file mode 100644
index 0000000000000..100924f91a9dd
--- /dev/null
+++ b/libc/shared/builtins/floatuntisf.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 __floatuntisf implementation as
+/// shared::floatuntisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FLOATUNTISF_H
+#define LLVM_LIBC_SHARED_BUILTINS_FLOATUNTISF_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/floatuntisf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::floatuntisf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FLOATUNTISF_H
diff --git a/libc/src/__support/builtins/CMakeLists.txt b/libc/src/__support/builtins/CMakeLists.txt
index 51212c4bff34c..a3e6303f09169 100644
--- a/libc/src/__support/builtins/CMakeLists.txt
+++ b/libc/src/__support/builtins/CMakeLists.txt
@@ -1,3 +1,15 @@
+add_header_library(
+ floatint_helper
+ HDRS
+ floatint_helper.h
+ DEPENDS
+ libc.src.__support.CPP.type_traits
+ libc.src.__support.FPUtil.dyadic_float
+ libc.src.__support.macros.attributes
+ libc.src.__support.macros.config
+ libc.src.__support.sign
+)
+
add_header_library(
fpconvert_helper
HDRS
@@ -350,3 +362,127 @@ add_header_library(
libc.src.__support.macros.properties.types
libc.src.__support.uint128
)
+
+add_header_library(
+ floatsidf
+ HDRS
+ floatsidf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ floatdidf
+ HDRS
+ floatdidf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ floattidf
+ HDRS
+ floattidf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_header_library(
+ floatsisf
+ HDRS
+ floatsisf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ floatdisf
+ HDRS
+ floatdisf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ floattisf
+ HDRS
+ floattisf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_header_library(
+ floatunsidf
+ HDRS
+ floatunsidf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ floatundidf
+ HDRS
+ floatundidf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ floatuntidf
+ HDRS
+ floatuntidf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
+
+add_header_library(
+ floatunsisf
+ HDRS
+ floatunsisf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ floatundisf
+ HDRS
+ floatundisf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ floatuntisf
+ HDRS
+ floatuntisf.h
+ DEPENDS
+ libc.hdr.stdint_proxy
+ libc.src.__support.builtins.floatint_helper
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+)
diff --git a/libc/src/__support/builtins/floatdidf.h b/libc/src/__support/builtins/floatdidf.h
new file mode 100644
index 0000000000000..c9843d53d5598
--- /dev/null
+++ b/libc/src/__support/builtins/floatdidf.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 __floatdidf implementation as
+/// builtins::floatdidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATDIDF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATDIDF_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// double <- int64_t conversion, round to nearest.
+// Mirrors compiler-rt's __floatdidf.
+LIBC_INLINE double floatdidf(int64_t x) { return floatint<double>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATDIDF_H
diff --git a/libc/src/__support/builtins/floatdisf.h b/libc/src/__support/builtins/floatdisf.h
new file mode 100644
index 0000000000000..b53595a782c7f
--- /dev/null
+++ b/libc/src/__support/builtins/floatdisf.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 __floatdisf implementation as
+/// builtins::floatdisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATDISF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATDISF_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// float <- int64_t conversion, round to nearest.
+// Mirrors compiler-rt's __floatdisf.
+LIBC_INLINE float floatdisf(int64_t x) { return floatint<float>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATDISF_H
diff --git a/libc/src/__support/builtins/floatint_helper.h b/libc/src/__support/builtins/floatint_helper.h
new file mode 100644
index 0000000000000..8aaf9f78e8d32
--- /dev/null
+++ b/libc/src/__support/builtins/floatint_helper.h
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Shared integer-to-floating-point conversions, rounded to nearest with ties
+/// to even. These mirror compiler-rt's __float<i><f> / __floatun<i><f>
+/// builtins via an LLVM-libc DyadicFloat, so they can be reused by
+/// compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATINT_HELPER_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATINT_HELPER_H
+
+#include "src/__support/CPP/type_traits.h"
+#include "src/__support/FPUtil/dyadic_float.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/sign.h"
+
+#include <stddef.h>
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// TODO: use constructors after adding Float128/64/32/16 classes.
+
+// Convert the integer I to the floating-point type F, rounding to nearest
+// (ties to even) per the current rounding mode. Handles signed and unsigned
+// I alike; mirrors compiler-rt's __float<i><f> / __floatun<i><f>.
+template <typename F, typename I> LIBC_INLINE constexpr F floatint(I x) {
+ using UI = cpp::make_unsigned_t<I>;
+
+ Sign sign = Sign::POS;
+ UI mag = static_cast<UI>(x);
+ if constexpr (cpp::is_signed_v<I>) {
+ if (x < 0) {
+ sign = Sign::NEG;
+ mag = static_cast<UI>(-mag); // modular negation; correct for I's min too
+ }
+ }
+
+ // A mantissa wide enough for I and for F's fraction, rounded up to a whole
+ // number of 64-bit words (UInt's width requirement). With exponent 0 the
+ // dyadic value is exactly `mag`, which as<F>() then rounds to F.
+ constexpr size_t NEED = (sizeof(I) > sizeof(F) ? sizeof(I) : sizeof(F)) * 8;
+ constexpr size_t BITS = ((NEED + 63) / 64) * 64;
+ return static_cast<F>(fputil::DyadicFloat<BITS>(sign, 0, mag));
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATINT_HELPER_H
diff --git a/libc/src/__support/builtins/floatsidf.h b/libc/src/__support/builtins/floatsidf.h
new file mode 100644
index 0000000000000..28b0c27bb5948
--- /dev/null
+++ b/libc/src/__support/builtins/floatsidf.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 __floatsidf implementation as
+/// builtins::floatsidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATSIDF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATSIDF_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// double <- int32_t conversion, round to nearest.
+// Mirrors compiler-rt's __floatsidf.
+LIBC_INLINE double floatsidf(int32_t x) { return floatint<double>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATSIDF_H
diff --git a/libc/src/__support/builtins/floatsisf.h b/libc/src/__support/builtins/floatsisf.h
new file mode 100644
index 0000000000000..75ab24c7680a5
--- /dev/null
+++ b/libc/src/__support/builtins/floatsisf.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 __floatsisf implementation as
+/// builtins::floatsisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATSISF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATSISF_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// float <- int32_t conversion, round to nearest.
+// Mirrors compiler-rt's __floatsisf.
+LIBC_INLINE float floatsisf(int32_t x) { return floatint<float>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATSISF_H
diff --git a/libc/src/__support/builtins/floattidf.h b/libc/src/__support/builtins/floattidf.h
new file mode 100644
index 0000000000000..2e6d85fa3324a
--- /dev/null
+++ b/libc/src/__support/builtins/floattidf.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 __floattidf implementation as
+/// builtins::floattidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATTIDF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATTIDF_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// double <- Int128 conversion, round to nearest.
+// Mirrors compiler-rt's __floattidf.
+LIBC_INLINE double floattidf(Int128 x) { return floatint<double>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATTIDF_H
diff --git a/libc/src/__support/builtins/floattisf.h b/libc/src/__support/builtins/floattisf.h
new file mode 100644
index 0000000000000..7bb8d8adc1183
--- /dev/null
+++ b/libc/src/__support/builtins/floattisf.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 __floattisf implementation as
+/// builtins::floattisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATTISF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATTISF_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// float <- Int128 conversion, round to nearest.
+// Mirrors compiler-rt's __floattisf.
+LIBC_INLINE float floattisf(Int128 x) { return floatint<float>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATTISF_H
diff --git a/libc/src/__support/builtins/floatundidf.h b/libc/src/__support/builtins/floatundidf.h
new file mode 100644
index 0000000000000..c368602892b38
--- /dev/null
+++ b/libc/src/__support/builtins/floatundidf.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 __floatundidf implementation as
+/// builtins::floatundidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNDIDF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNDIDF_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// double <- uint64_t conversion, round to nearest.
+// Mirrors compiler-rt's __floatundidf.
+LIBC_INLINE double floatundidf(uint64_t x) { return floatint<double>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNDIDF_H
diff --git a/libc/src/__support/builtins/floatundisf.h b/libc/src/__support/builtins/floatundisf.h
new file mode 100644
index 0000000000000..ba450937ff73b
--- /dev/null
+++ b/libc/src/__support/builtins/floatundisf.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 __floatundisf implementation as
+/// builtins::floatundisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNDISF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNDISF_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// float <- uint64_t conversion, round to nearest.
+// Mirrors compiler-rt's __floatundisf.
+LIBC_INLINE float floatundisf(uint64_t x) { return floatint<float>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNDISF_H
diff --git a/libc/src/__support/builtins/floatunsidf.h b/libc/src/__support/builtins/floatunsidf.h
new file mode 100644
index 0000000000000..5fa90c640772e
--- /dev/null
+++ b/libc/src/__support/builtins/floatunsidf.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 __floatunsidf implementation as
+/// builtins::floatunsidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNSIDF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNSIDF_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// double <- uint32_t conversion, round to nearest.
+// Mirrors compiler-rt's __floatunsidf.
+LIBC_INLINE double floatunsidf(uint32_t x) { return floatint<double>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNSIDF_H
diff --git a/libc/src/__support/builtins/floatunsisf.h b/libc/src/__support/builtins/floatunsisf.h
new file mode 100644
index 0000000000000..cb8bd27a044e6
--- /dev/null
+++ b/libc/src/__support/builtins/floatunsisf.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 __floatunsisf implementation as
+/// builtins::floatunsisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNSISF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNSISF_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// float <- uint32_t conversion, round to nearest.
+// Mirrors compiler-rt's __floatunsisf.
+LIBC_INLINE float floatunsisf(uint32_t x) { return floatint<float>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNSISF_H
diff --git a/libc/src/__support/builtins/floatuntidf.h b/libc/src/__support/builtins/floatuntidf.h
new file mode 100644
index 0000000000000..105ba292bff0d
--- /dev/null
+++ b/libc/src/__support/builtins/floatuntidf.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 __floatuntidf implementation as
+/// builtins::floatuntidf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNTIDF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNTIDF_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// double <- UInt128 conversion, round to nearest.
+// Mirrors compiler-rt's __floatuntidf.
+LIBC_INLINE double floatuntidf(UInt128 x) { return floatint<double>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNTIDF_H
diff --git a/libc/src/__support/builtins/floatuntisf.h b/libc/src/__support/builtins/floatuntisf.h
new file mode 100644
index 0000000000000..c244ee1d53440
--- /dev/null
+++ b/libc/src/__support/builtins/floatuntisf.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 __floatuntisf implementation as
+/// builtins::floatuntisf so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNTISF_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNTISF_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/floatint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// float <- UInt128 conversion, round to nearest.
+// Mirrors compiler-rt's __floatuntisf.
+LIBC_INLINE float floatuntisf(UInt128 x) { return floatint<float>(x); }
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FLOATUNTISF_H
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 04b6a6e3aed91..49232caf377bc 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -850,6 +850,18 @@ add_fp_unittest(
libc.src.__support.builtins.fixunssfdi
libc.src.__support.builtins.fixunssfsi
libc.src.__support.builtins.fixunssfti
+ libc.src.__support.builtins.floatdidf
+ libc.src.__support.builtins.floatdisf
+ libc.src.__support.builtins.floatsidf
+ libc.src.__support.builtins.floatsisf
+ libc.src.__support.builtins.floattidf
+ libc.src.__support.builtins.floattisf
+ libc.src.__support.builtins.floatundidf
+ libc.src.__support.builtins.floatundisf
+ libc.src.__support.builtins.floatunsidf
+ libc.src.__support.builtins.floatunsisf
+ libc.src.__support.builtins.floatuntidf
+ libc.src.__support.builtins.floatuntisf
libc.src.__support.builtins.muldf3
libc.src.__support.builtins.mulsf3
libc.src.__support.builtins.multf3
More information about the libc-commits
mailing list