[compiler-rt] [libc] [compiler-rt][builtins] add libc-backed fixint/fixuint builtins (PR #207543)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 4 14:07:54 PDT 2026


https://github.com/hulxv created https://github.com/llvm/llvm-project/pull/207543

Add libc-backed double/float to integer conversion builtins 

Part of #197824

>From 6951303e4ea5f5aa5f32f1b33d7421b4f357eb41 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Sat, 4 Jul 2026 23:28:22 +0300
Subject: [PATCH] [compiler-rt][builtins] add libc-backed fixint/fixuint
 builtins

---
 compiler-rt/lib/builtins/CMakeLists.txt     |  12 ++
 compiler-rt/lib/builtins/fixdfdi.cpp        |  22 ++++
 compiler-rt/lib/builtins/fixdfsi.cpp        |  22 ++++
 compiler-rt/lib/builtins/fixdfti.cpp        |  26 ++++
 compiler-rt/lib/builtins/fixsfdi.cpp        |  22 ++++
 compiler-rt/lib/builtins/fixsfsi.cpp        |  22 ++++
 compiler-rt/lib/builtins/fixsfti.cpp        |  26 ++++
 compiler-rt/lib/builtins/fixunsdfdi.cpp     |  22 ++++
 compiler-rt/lib/builtins/fixunsdfsi.cpp     |  22 ++++
 compiler-rt/lib/builtins/fixunsdfti.cpp     |  26 ++++
 compiler-rt/lib/builtins/fixunssfdi.cpp     |  22 ++++
 compiler-rt/lib/builtins/fixunssfsi.cpp     |  22 ++++
 compiler-rt/lib/builtins/fixunssfti.cpp     |  26 ++++
 libc/shared/builtins.h                      |  12 ++
 libc/shared/builtins/fixdfdi.h              |  29 +++++
 libc/shared/builtins/fixdfsi.h              |  29 +++++
 libc/shared/builtins/fixdfti.h              |  35 ++++++
 libc/shared/builtins/fixsfdi.h              |  29 +++++
 libc/shared/builtins/fixsfsi.h              |  29 +++++
 libc/shared/builtins/fixsfti.h              |  35 ++++++
 libc/shared/builtins/fixunsdfdi.h           |  29 +++++
 libc/shared/builtins/fixunsdfsi.h           |  29 +++++
 libc/shared/builtins/fixunsdfti.h           |  35 ++++++
 libc/shared/builtins/fixunssfdi.h           |  29 +++++
 libc/shared/builtins/fixunssfsi.h           |  29 +++++
 libc/shared/builtins/fixunssfti.h           |  35 ++++++
 libc/src/__support/builtins/CMakeLists.txt  | 124 ++++++++++++++++++++
 libc/src/__support/builtins/fixdfdi.h       |  34 ++++++
 libc/src/__support/builtins/fixdfsi.h       |  34 ++++++
 libc/src/__support/builtins/fixdfti.h       |  40 +++++++
 libc/src/__support/builtins/fixint_helper.h |  78 ++++++++++++
 libc/src/__support/builtins/fixsfdi.h       |  34 ++++++
 libc/src/__support/builtins/fixsfsi.h       |  34 ++++++
 libc/src/__support/builtins/fixsfti.h       |  40 +++++++
 libc/src/__support/builtins/fixunsdfdi.h    |  34 ++++++
 libc/src/__support/builtins/fixunsdfsi.h    |  34 ++++++
 libc/src/__support/builtins/fixunsdfti.h    |  40 +++++++
 libc/src/__support/builtins/fixunssfdi.h    |  34 ++++++
 libc/src/__support/builtins/fixunssfsi.h    |  34 ++++++
 libc/src/__support/builtins/fixunssfti.h    |  40 +++++++
 libc/test/shared/CMakeLists.txt             |  12 ++
 libc/test/shared/shared_builtins_test.cpp   |  29 +++++
 42 files changed, 1351 insertions(+)
 create mode 100644 compiler-rt/lib/builtins/fixdfdi.cpp
 create mode 100644 compiler-rt/lib/builtins/fixdfsi.cpp
 create mode 100644 compiler-rt/lib/builtins/fixdfti.cpp
 create mode 100644 compiler-rt/lib/builtins/fixsfdi.cpp
 create mode 100644 compiler-rt/lib/builtins/fixsfsi.cpp
 create mode 100644 compiler-rt/lib/builtins/fixsfti.cpp
 create mode 100644 compiler-rt/lib/builtins/fixunsdfdi.cpp
 create mode 100644 compiler-rt/lib/builtins/fixunsdfsi.cpp
 create mode 100644 compiler-rt/lib/builtins/fixunsdfti.cpp
 create mode 100644 compiler-rt/lib/builtins/fixunssfdi.cpp
 create mode 100644 compiler-rt/lib/builtins/fixunssfsi.cpp
 create mode 100644 compiler-rt/lib/builtins/fixunssfti.cpp
 create mode 100644 libc/shared/builtins/fixdfdi.h
 create mode 100644 libc/shared/builtins/fixdfsi.h
 create mode 100644 libc/shared/builtins/fixdfti.h
 create mode 100644 libc/shared/builtins/fixsfdi.h
 create mode 100644 libc/shared/builtins/fixsfsi.h
 create mode 100644 libc/shared/builtins/fixsfti.h
 create mode 100644 libc/shared/builtins/fixunsdfdi.h
 create mode 100644 libc/shared/builtins/fixunsdfsi.h
 create mode 100644 libc/shared/builtins/fixunsdfti.h
 create mode 100644 libc/shared/builtins/fixunssfdi.h
 create mode 100644 libc/shared/builtins/fixunssfsi.h
 create mode 100644 libc/shared/builtins/fixunssfti.h
 create mode 100644 libc/src/__support/builtins/fixdfdi.h
 create mode 100644 libc/src/__support/builtins/fixdfsi.h
 create mode 100644 libc/src/__support/builtins/fixdfti.h
 create mode 100644 libc/src/__support/builtins/fixint_helper.h
 create mode 100644 libc/src/__support/builtins/fixsfdi.h
 create mode 100644 libc/src/__support/builtins/fixsfsi.h
 create mode 100644 libc/src/__support/builtins/fixsfti.h
 create mode 100644 libc/src/__support/builtins/fixunsdfdi.h
 create mode 100644 libc/src/__support/builtins/fixunsdfsi.h
 create mode 100644 libc/src/__support/builtins/fixunsdfti.h
 create mode 100644 libc/src/__support/builtins/fixunssfdi.h
 create mode 100644 libc/src/__support/builtins/fixunssfsi.h
 create mode 100644 libc/src/__support/builtins/fixunssfti.h

diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index e128fea6a3415..e7178f846da24 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -265,6 +265,18 @@ if(COMPILER_RT_USE_LIBC_MATH)
   add_definitions(-DCOMPILER_RT_USE_LIBC_MATH)
 
   use_libc_builtin(GENERIC_TF_SOURCES addtf3)
+  use_libc_builtin(GENERIC_SOURCES fixdfsi)
+  use_libc_builtin(GENERIC_SOURCES fixdfdi)
+  use_libc_builtin(GENERIC_SOURCES fixdfti)
+  use_libc_builtin(GENERIC_SOURCES fixsfsi)
+  use_libc_builtin(GENERIC_SOURCES fixsfdi)
+  use_libc_builtin(GENERIC_SOURCES fixsfti)
+  use_libc_builtin(GENERIC_SOURCES fixunsdfsi)
+  use_libc_builtin(GENERIC_SOURCES fixunsdfdi)
+  use_libc_builtin(GENERIC_SOURCES fixunsdfti)
+  use_libc_builtin(GENERIC_SOURCES fixunssfsi)
+  use_libc_builtin(GENERIC_SOURCES fixunssfdi)
+  use_libc_builtin(GENERIC_SOURCES fixunssfti)
 endif()
 
 option(COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN
diff --git a/compiler-rt/lib/builtins/fixdfdi.cpp b/compiler-rt/lib/builtins/fixdfdi.cpp
new file mode 100644
index 0000000000000..7f384b3cd4ee3
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixdfdi.cpp
@@ -0,0 +1,22 @@
+//===-- lib/fixdfdi.cpp - libc-backed __fixdfdi -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixdfdi implemented on top of LLVM-libc's shared::fixdfdi.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/fixdfdi.h"
+
+extern "C" COMPILER_RT_ABI di_int __fixdfdi(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixdfdi(a);
+}
diff --git a/compiler-rt/lib/builtins/fixdfsi.cpp b/compiler-rt/lib/builtins/fixdfsi.cpp
new file mode 100644
index 0000000000000..3b597b0226c5d
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixdfsi.cpp
@@ -0,0 +1,22 @@
+//===-- lib/fixdfsi.cpp - libc-backed __fixdfsi -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixdfsi implemented on top of LLVM-libc's shared::fixdfsi.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/fixdfsi.h"
+
+extern "C" COMPILER_RT_ABI si_int __fixdfsi(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixdfsi(a);
+}
diff --git a/compiler-rt/lib/builtins/fixdfti.cpp b/compiler-rt/lib/builtins/fixdfti.cpp
new file mode 100644
index 0000000000000..17f4447db71c5
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixdfti.cpp
@@ -0,0 +1,26 @@
+//===-- lib/fixdfti.cpp - libc-backed __fixdfti -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixdfti implemented on top of LLVM-libc's shared::fixdfti.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+
+#ifdef CRT_HAS_128BIT
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/fixdfti.h"
+
+extern "C" COMPILER_RT_ABI ti_int __fixdfti(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixdfti(a);
+}
+
+#endif // CRT_HAS_128BIT
diff --git a/compiler-rt/lib/builtins/fixsfdi.cpp b/compiler-rt/lib/builtins/fixsfdi.cpp
new file mode 100644
index 0000000000000..9e649bc501e5b
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixsfdi.cpp
@@ -0,0 +1,22 @@
+//===-- lib/fixsfdi.cpp - libc-backed __fixsfdi -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixsfdi implemented on top of LLVM-libc's shared::fixsfdi.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/fixsfdi.h"
+
+extern "C" COMPILER_RT_ABI di_int __fixsfdi(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixsfdi(a);
+}
diff --git a/compiler-rt/lib/builtins/fixsfsi.cpp b/compiler-rt/lib/builtins/fixsfsi.cpp
new file mode 100644
index 0000000000000..579fb45c28a76
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixsfsi.cpp
@@ -0,0 +1,22 @@
+//===-- lib/fixsfsi.cpp - libc-backed __fixsfsi -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixsfsi implemented on top of LLVM-libc's shared::fixsfsi.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/fixsfsi.h"
+
+extern "C" COMPILER_RT_ABI si_int __fixsfsi(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixsfsi(a);
+}
diff --git a/compiler-rt/lib/builtins/fixsfti.cpp b/compiler-rt/lib/builtins/fixsfti.cpp
new file mode 100644
index 0000000000000..e3592e94b5196
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixsfti.cpp
@@ -0,0 +1,26 @@
+//===-- lib/fixsfti.cpp - libc-backed __fixsfti -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixsfti implemented on top of LLVM-libc's shared::fixsfti.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+
+#ifdef CRT_HAS_128BIT
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/fixsfti.h"
+
+extern "C" COMPILER_RT_ABI ti_int __fixsfti(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixsfti(a);
+}
+
+#endif // CRT_HAS_128BIT
diff --git a/compiler-rt/lib/builtins/fixunsdfdi.cpp b/compiler-rt/lib/builtins/fixunsdfdi.cpp
new file mode 100644
index 0000000000000..9a31f0744e9df
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixunsdfdi.cpp
@@ -0,0 +1,22 @@
+//===-- lib/fixunsdfdi.cpp - libc-backed __fixunsdfdi -----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixunsdfdi implemented on top of LLVM-libc's shared::fixunsdfdi.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/fixunsdfdi.h"
+
+extern "C" COMPILER_RT_ABI du_int __fixunsdfdi(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixunsdfdi(a);
+}
diff --git a/compiler-rt/lib/builtins/fixunsdfsi.cpp b/compiler-rt/lib/builtins/fixunsdfsi.cpp
new file mode 100644
index 0000000000000..c23f40dd8ea7b
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixunsdfsi.cpp
@@ -0,0 +1,22 @@
+//===-- lib/fixunsdfsi.cpp - libc-backed __fixunsdfsi -----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixunsdfsi implemented on top of LLVM-libc's shared::fixunsdfsi.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/fixunsdfsi.h"
+
+extern "C" COMPILER_RT_ABI su_int __fixunsdfsi(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixunsdfsi(a);
+}
diff --git a/compiler-rt/lib/builtins/fixunsdfti.cpp b/compiler-rt/lib/builtins/fixunsdfti.cpp
new file mode 100644
index 0000000000000..9db9a6f1d873e
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixunsdfti.cpp
@@ -0,0 +1,26 @@
+//===-- lib/fixunsdfti.cpp - libc-backed __fixunsdfti -----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixunsdfti implemented on top of LLVM-libc's shared::fixunsdfti.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+
+#ifdef CRT_HAS_128BIT
+#define DOUBLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/fixunsdfti.h"
+
+extern "C" COMPILER_RT_ABI tu_int __fixunsdfti(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixunsdfti(a);
+}
+
+#endif // CRT_HAS_128BIT
diff --git a/compiler-rt/lib/builtins/fixunssfdi.cpp b/compiler-rt/lib/builtins/fixunssfdi.cpp
new file mode 100644
index 0000000000000..eb21e38c4f575
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixunssfdi.cpp
@@ -0,0 +1,22 @@
+//===-- lib/fixunssfdi.cpp - libc-backed __fixunssfdi -----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixunssfdi implemented on top of LLVM-libc's shared::fixunssfdi.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/fixunssfdi.h"
+
+extern "C" COMPILER_RT_ABI du_int __fixunssfdi(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixunssfdi(a);
+}
diff --git a/compiler-rt/lib/builtins/fixunssfsi.cpp b/compiler-rt/lib/builtins/fixunssfsi.cpp
new file mode 100644
index 0000000000000..7ee2dfd8a03c6
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixunssfsi.cpp
@@ -0,0 +1,22 @@
+//===-- lib/fixunssfsi.cpp - libc-backed __fixunssfsi -----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixunssfsi implemented on top of LLVM-libc's shared::fixunssfsi.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/fixunssfsi.h"
+
+extern "C" COMPILER_RT_ABI su_int __fixunssfsi(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixunssfsi(a);
+}
diff --git a/compiler-rt/lib/builtins/fixunssfti.cpp b/compiler-rt/lib/builtins/fixunssfti.cpp
new file mode 100644
index 0000000000000..c577cc957786c
--- /dev/null
+++ b/compiler-rt/lib/builtins/fixunssfti.cpp
@@ -0,0 +1,26 @@
+//===-- lib/fixunssfti.cpp - libc-backed __fixunssfti -----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// __fixunssfti implemented on top of LLVM-libc's shared::fixunssfti.
+//
+//===----------------------------------------------------------------------===//
+
+#include "int_lib.h"
+
+#ifdef CRT_HAS_128BIT
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "shared/builtins/fixunssfti.h"
+
+extern "C" COMPILER_RT_ABI tu_int __fixunssfti(fp_t a) {
+  return LIBC_NAMESPACE::shared::fixunssfti(a);
+}
+
+#endif // CRT_HAS_128BIT
diff --git a/libc/shared/builtins.h b/libc/shared/builtins.h
index a6a8973beda25..e6e435480d527 100644
--- a/libc/shared/builtins.h
+++ b/libc/shared/builtins.h
@@ -22,6 +22,18 @@
 #include "builtins/addtf3.h"
 #include "builtins/divdf3.h"
 #include "builtins/divtf3.h"
+#include "builtins/fixdfdi.h"
+#include "builtins/fixdfsi.h"
+#include "builtins/fixdfti.h"
+#include "builtins/fixsfdi.h"
+#include "builtins/fixsfsi.h"
+#include "builtins/fixsfti.h"
+#include "builtins/fixunsdfdi.h"
+#include "builtins/fixunsdfsi.h"
+#include "builtins/fixunsdfti.h"
+#include "builtins/fixunssfdi.h"
+#include "builtins/fixunssfsi.h"
+#include "builtins/fixunssfti.h"
 #include "builtins/muldf3.h"
 #include "builtins/multf3.h"
 #include "builtins/subdf3.h"
diff --git a/libc/shared/builtins/fixdfdi.h b/libc/shared/builtins/fixdfdi.h
new file mode 100644
index 0000000000000..2a0eb4da645a1
--- /dev/null
+++ b/libc/shared/builtins/fixdfdi.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 __fixdfdi implementation as shared::fixdfdi
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXDFDI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXDFDI_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixdfdi.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixdfdi;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXDFDI_H
diff --git a/libc/shared/builtins/fixdfsi.h b/libc/shared/builtins/fixdfsi.h
new file mode 100644
index 0000000000000..ab7dae3688c5c
--- /dev/null
+++ b/libc/shared/builtins/fixdfsi.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 __fixdfsi implementation as shared::fixdfsi
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXDFSI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXDFSI_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixdfsi.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixdfsi;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXDFSI_H
diff --git a/libc/shared/builtins/fixdfti.h b/libc/shared/builtins/fixdfti.h
new file mode 100644
index 0000000000000..bd83e706fd9a7
--- /dev/null
+++ b/libc/shared/builtins/fixdfti.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 __fixdfti implementation as shared::fixdfti
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXDFTI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXDFTI_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixdfti.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixdfti;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXDFTI_H
diff --git a/libc/shared/builtins/fixsfdi.h b/libc/shared/builtins/fixsfdi.h
new file mode 100644
index 0000000000000..ff969a6551a44
--- /dev/null
+++ b/libc/shared/builtins/fixsfdi.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 __fixsfdi implementation as shared::fixsfdi
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXSFDI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXSFDI_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixsfdi.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixsfdi;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXSFDI_H
diff --git a/libc/shared/builtins/fixsfsi.h b/libc/shared/builtins/fixsfsi.h
new file mode 100644
index 0000000000000..debd82aefc8eb
--- /dev/null
+++ b/libc/shared/builtins/fixsfsi.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 __fixsfsi implementation as shared::fixsfsi
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXSFSI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXSFSI_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixsfsi.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixsfsi;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXSFSI_H
diff --git a/libc/shared/builtins/fixsfti.h b/libc/shared/builtins/fixsfti.h
new file mode 100644
index 0000000000000..191fb5292b92b
--- /dev/null
+++ b/libc/shared/builtins/fixsfti.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 __fixsfti implementation as shared::fixsfti
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXSFTI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXSFTI_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixsfti.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixsfti;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXSFTI_H
diff --git a/libc/shared/builtins/fixunsdfdi.h b/libc/shared/builtins/fixunsdfdi.h
new file mode 100644
index 0000000000000..9c2472e771ac4
--- /dev/null
+++ b/libc/shared/builtins/fixunsdfdi.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 __fixunsdfdi implementation as
+/// shared::fixunsdfdi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXUNSDFDI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXUNSDFDI_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixunsdfdi.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixunsdfdi;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXUNSDFDI_H
diff --git a/libc/shared/builtins/fixunsdfsi.h b/libc/shared/builtins/fixunsdfsi.h
new file mode 100644
index 0000000000000..c463298e576fd
--- /dev/null
+++ b/libc/shared/builtins/fixunsdfsi.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 __fixunsdfsi implementation as
+/// shared::fixunsdfsi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXUNSDFSI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXUNSDFSI_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixunsdfsi.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixunsdfsi;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXUNSDFSI_H
diff --git a/libc/shared/builtins/fixunsdfti.h b/libc/shared/builtins/fixunsdfti.h
new file mode 100644
index 0000000000000..5929f93781446
--- /dev/null
+++ b/libc/shared/builtins/fixunsdfti.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 __fixunsdfti implementation as
+/// shared::fixunsdfti so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXUNSDFTI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXUNSDFTI_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixunsdfti.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixunsdfti;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXUNSDFTI_H
diff --git a/libc/shared/builtins/fixunssfdi.h b/libc/shared/builtins/fixunssfdi.h
new file mode 100644
index 0000000000000..7a1b16cb6bcf9
--- /dev/null
+++ b/libc/shared/builtins/fixunssfdi.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 __fixunssfdi implementation as
+/// shared::fixunssfdi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXUNSSFDI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXUNSSFDI_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixunssfdi.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixunssfdi;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXUNSSFDI_H
diff --git a/libc/shared/builtins/fixunssfsi.h b/libc/shared/builtins/fixunssfsi.h
new file mode 100644
index 0000000000000..8ed7ed6103d51
--- /dev/null
+++ b/libc/shared/builtins/fixunssfsi.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 __fixunssfsi implementation as
+/// shared::fixunssfsi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXUNSSFSI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXUNSSFSI_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixunssfsi.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixunssfsi;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXUNSSFSI_H
diff --git a/libc/shared/builtins/fixunssfti.h b/libc/shared/builtins/fixunssfti.h
new file mode 100644
index 0000000000000..b47dd08ab04f6
--- /dev/null
+++ b/libc/shared/builtins/fixunssfti.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 __fixunssfti implementation as
+/// shared::fixunssfti so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_FIXUNSSFTI_H
+#define LLVM_LIBC_SHARED_BUILTINS_FIXUNSSFTI_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/fixunssfti.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::fixunssfti;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_FIXUNSSFTI_H
diff --git a/libc/src/__support/builtins/CMakeLists.txt b/libc/src/__support/builtins/CMakeLists.txt
index 69d714b9fa207..83d6cefc4df2a 100644
--- a/libc/src/__support/builtins/CMakeLists.txt
+++ b/libc/src/__support/builtins/CMakeLists.txt
@@ -82,3 +82,127 @@ add_header_library(
     libc.src.__support.FPUtil.generic.add_sub
     libc.src.__support.macros.config
 )
+
+add_header_library(
+  fixdfsi
+  HDRS
+    fixdfsi.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  fixdfdi
+  HDRS
+    fixdfdi.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  fixdfti
+  HDRS
+    fixdfti.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
+
+add_header_library(
+  fixsfsi
+  HDRS
+    fixsfsi.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  fixsfdi
+  HDRS
+    fixsfdi.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  fixsfti
+  HDRS
+    fixsfti.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
+
+add_header_library(
+  fixunsdfsi
+  HDRS
+    fixunsdfsi.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  fixunsdfdi
+  HDRS
+    fixunsdfdi.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  fixunsdfti
+  HDRS
+    fixunsdfti.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
+
+add_header_library(
+  fixunssfsi
+  HDRS
+    fixunssfsi.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  fixunssfdi
+  HDRS
+    fixunssfdi.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+)
+
+add_header_library(
+  fixunssfti
+  HDRS
+    fixunssfti.h
+  DEPENDS
+    libc.hdr.stdint_proxy
+    libc.src.__support.builtins.fixint_helper
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
diff --git a/libc/src/__support/builtins/fixdfdi.h b/libc/src/__support/builtins/fixdfdi.h
new file mode 100644
index 0000000000000..c78d0fe666ad1
--- /dev/null
+++ b/libc/src/__support/builtins/fixdfdi.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixdfdi implementation as
+/// builtins::fixdfdi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXDFDI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXDFDI_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating double -> int64_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixdfdi.
+LIBC_INLINE int64_t fixdfdi(double x) {
+  return fixint<int64_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXDFDI_H
diff --git a/libc/src/__support/builtins/fixdfsi.h b/libc/src/__support/builtins/fixdfsi.h
new file mode 100644
index 0000000000000..565eb018a5d9e
--- /dev/null
+++ b/libc/src/__support/builtins/fixdfsi.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixdfsi implementation as
+/// builtins::fixdfsi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXDFSI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXDFSI_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating double -> int32_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixdfsi.
+LIBC_INLINE int32_t fixdfsi(double x) {
+  return fixint<int32_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXDFSI_H
diff --git a/libc/src/__support/builtins/fixdfti.h b/libc/src/__support/builtins/fixdfti.h
new file mode 100644
index 0000000000000..0da1d0aab1485
--- /dev/null
+++ b/libc/src/__support/builtins/fixdfti.h
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixdfti implementation as
+/// builtins::fixdfti so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXDFTI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXDFTI_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating double -> __int128_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixdfti.
+LIBC_INLINE __int128_t fixdfti(double x) {
+  return fixint<__int128_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXDFTI_H
diff --git a/libc/src/__support/builtins/fixint_helper.h b/libc/src/__support/builtins/fixint_helper.h
new file mode 100644
index 0000000000000..4718cc979d2ca
--- /dev/null
+++ b/libc/src/__support/builtins/fixint_helper.h
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 truncating float-to-integer conversions, saturating on overflow.
+/// These mirror compiler-rt's __fix<f><i> / __fixuns<f><i> builtins via an
+/// FPBits unpack + shift, so they can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXINT_HELPER_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXINT_HELPER_H
+
+#include "src/__support/CPP/type_traits.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating conversion of F to the signed integer I (round toward zero).
+// Out-of-range magnitudes saturate to I's min/max; mirrors compiler-rt __fix*.
+template <typename I, typename F> LIBC_INLINE constexpr I fixint(F a) {
+  using FPBits = fputil::FPBits<F>;
+  using UI = cpp::make_unsigned_t<I>;
+  constexpr I FIXINT_MAX = static_cast<I>(~UI(0) >> 1);
+  constexpr I FIXINT_MIN = -FIXINT_MAX - 1;
+
+  const FPBits bits(a);
+  const I sign = bits.is_neg() ? -1 : 1;
+  const int exponent = bits.get_exponent();
+  const typename FPBits::StorageType significand = bits.get_explicit_mantissa();
+
+  if (exponent < 0)
+    return 0;
+
+  if (static_cast<unsigned>(exponent) >= sizeof(I) * 8)
+    return sign == 1 ? FIXINT_MAX : FIXINT_MIN;
+
+  if (exponent < FPBits::FRACTION_LEN)
+    return sign *
+           static_cast<I>(significand >> (FPBits::FRACTION_LEN - exponent));
+  return sign * static_cast<I>(static_cast<UI>(significand)
+                               << (exponent - FPBits::FRACTION_LEN));
+}
+
+// Truncating conversion of F to the unsigned integer U (round toward zero).
+// Negative or out-of-range values yield 0 / U's max; mirrors compiler-rt
+// __fixuns*.
+template <typename U, typename F> LIBC_INLINE constexpr U fixuint(F a) {
+  using FPBits = fputil::FPBits<F>;
+
+  const FPBits bits(a);
+  const int exponent = bits.get_exponent();
+  const typename FPBits::StorageType significand = bits.get_explicit_mantissa();
+
+  if (bits.is_neg() || exponent < 0)
+    return 0;
+
+  if (static_cast<unsigned>(exponent) >= sizeof(U) * 8)
+    return ~U(0);
+
+  if (exponent < FPBits::FRACTION_LEN)
+    return static_cast<U>(significand >> (FPBits::FRACTION_LEN - exponent));
+  return static_cast<U>(static_cast<U>(significand)
+                        << (exponent - FPBits::FRACTION_LEN));
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXINT_HELPER_H
diff --git a/libc/src/__support/builtins/fixsfdi.h b/libc/src/__support/builtins/fixsfdi.h
new file mode 100644
index 0000000000000..3842640fb6aef
--- /dev/null
+++ b/libc/src/__support/builtins/fixsfdi.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixsfdi implementation as
+/// builtins::fixsfdi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXSFDI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXSFDI_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating float -> int64_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixsfdi.
+LIBC_INLINE int64_t fixsfdi(float x) {
+  return fixint<int64_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXSFDI_H
diff --git a/libc/src/__support/builtins/fixsfsi.h b/libc/src/__support/builtins/fixsfsi.h
new file mode 100644
index 0000000000000..e708931eb4c8f
--- /dev/null
+++ b/libc/src/__support/builtins/fixsfsi.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixsfsi implementation as
+/// builtins::fixsfsi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXSFSI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXSFSI_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating float -> int32_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixsfsi.
+LIBC_INLINE int32_t fixsfsi(float x) {
+  return fixint<int32_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXSFSI_H
diff --git a/libc/src/__support/builtins/fixsfti.h b/libc/src/__support/builtins/fixsfti.h
new file mode 100644
index 0000000000000..bcf946e92997c
--- /dev/null
+++ b/libc/src/__support/builtins/fixsfti.h
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixsfti implementation as
+/// builtins::fixsfti so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXSFTI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXSFTI_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating float -> __int128_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixsfti.
+LIBC_INLINE __int128_t fixsfti(float x) {
+  return fixint<__int128_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXSFTI_H
diff --git a/libc/src/__support/builtins/fixunsdfdi.h b/libc/src/__support/builtins/fixunsdfdi.h
new file mode 100644
index 0000000000000..62279d0b7aeff
--- /dev/null
+++ b/libc/src/__support/builtins/fixunsdfdi.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixunsdfdi implementation as
+/// builtins::fixunsdfdi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSDFDI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSDFDI_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating double -> uint64_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixunsdfdi.
+LIBC_INLINE uint64_t fixunsdfdi(double x) {
+  return fixuint<uint64_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSDFDI_H
diff --git a/libc/src/__support/builtins/fixunsdfsi.h b/libc/src/__support/builtins/fixunsdfsi.h
new file mode 100644
index 0000000000000..c43f056d6b15d
--- /dev/null
+++ b/libc/src/__support/builtins/fixunsdfsi.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixunsdfsi implementation as
+/// builtins::fixunsdfsi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSDFSI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSDFSI_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating double -> uint32_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixunsdfsi.
+LIBC_INLINE uint32_t fixunsdfsi(double x) {
+  return fixuint<uint32_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSDFSI_H
diff --git a/libc/src/__support/builtins/fixunsdfti.h b/libc/src/__support/builtins/fixunsdfti.h
new file mode 100644
index 0000000000000..7dda88016a54c
--- /dev/null
+++ b/libc/src/__support/builtins/fixunsdfti.h
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixunsdfti implementation as
+/// builtins::fixunsdfti so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSDFTI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSDFTI_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating double -> __uint128_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixunsdfti.
+LIBC_INLINE __uint128_t fixunsdfti(double x) {
+  return fixuint<__uint128_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSDFTI_H
diff --git a/libc/src/__support/builtins/fixunssfdi.h b/libc/src/__support/builtins/fixunssfdi.h
new file mode 100644
index 0000000000000..f5f36d8bb7787
--- /dev/null
+++ b/libc/src/__support/builtins/fixunssfdi.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixunssfdi implementation as
+/// builtins::fixunssfdi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSSFDI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSSFDI_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating float -> uint64_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixunssfdi.
+LIBC_INLINE uint64_t fixunssfdi(float x) {
+  return fixuint<uint64_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSSFDI_H
diff --git a/libc/src/__support/builtins/fixunssfsi.h b/libc/src/__support/builtins/fixunssfsi.h
new file mode 100644
index 0000000000000..9c33a28ed6868
--- /dev/null
+++ b/libc/src/__support/builtins/fixunssfsi.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixunssfsi implementation as
+/// builtins::fixunssfsi so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSSFSI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSSFSI_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating float -> uint32_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixunssfsi.
+LIBC_INLINE uint32_t fixunssfsi(float x) {
+  return fixuint<uint32_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSSFSI_H
diff --git a/libc/src/__support/builtins/fixunssfti.h b/libc/src/__support/builtins/fixunssfti.h
new file mode 100644
index 0000000000000..6d3a4d6323ce5
--- /dev/null
+++ b/libc/src/__support/builtins/fixunssfti.h
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 __fixunssfti implementation as
+/// builtins::fixunssfti so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSSFTI_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSSFTI_H
+
+#include "src/__support/macros/properties/types.h"
+
+#ifdef LIBC_TYPES_HAS_INT128
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/builtins/fixint_helper.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Truncating float -> __uint128_t conversion, saturating on overflow.
+// Mirrors compiler-rt's __fixunssfti.
+LIBC_INLINE __uint128_t fixunssfti(float x) {
+  return fixuint<__uint128_t>(x);
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_INT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_FIXUNSSFTI_H
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index aeb573474d6ef..49ea5af427242 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -832,6 +832,18 @@ add_fp_unittest(
     libc.src.__support.builtins.addtf3
     libc.src.__support.builtins.divdf3
     libc.src.__support.builtins.divtf3
+    libc.src.__support.builtins.fixdfdi
+    libc.src.__support.builtins.fixdfsi
+    libc.src.__support.builtins.fixdfti
+    libc.src.__support.builtins.fixsfdi
+    libc.src.__support.builtins.fixsfsi
+    libc.src.__support.builtins.fixsfti
+    libc.src.__support.builtins.fixunsdfdi
+    libc.src.__support.builtins.fixunsdfsi
+    libc.src.__support.builtins.fixunsdfti
+    libc.src.__support.builtins.fixunssfdi
+    libc.src.__support.builtins.fixunssfsi
+    libc.src.__support.builtins.fixunssfti
     libc.src.__support.builtins.muldf3
     libc.src.__support.builtins.multf3
     libc.src.__support.builtins.subdf3
diff --git a/libc/test/shared/shared_builtins_test.cpp b/libc/test/shared/shared_builtins_test.cpp
index 20e79498b4cfb..6d8599677cdda 100644
--- a/libc/test/shared/shared_builtins_test.cpp
+++ b/libc/test/shared/shared_builtins_test.cpp
@@ -35,3 +35,32 @@ TEST(LlvmLibcSharedBuiltinsTest, AllFloat128) {
 }
 
 #endif // LIBC_TYPES_HAS_FLOAT128
+
+TEST(LlvmLibcSharedBuiltinsTest, FloatToIntConversion) {
+  EXPECT_EQ(int64_t(12), LIBC_NAMESPACE::shared::fixsfdi(12.5f));
+  EXPECT_EQ(int32_t(12), LIBC_NAMESPACE::shared::fixsfsi(12.5f));
+#ifdef LIBC_TYPES_HAS_INT128
+  EXPECT_EQ(static_cast<__int128_t>(12),
+            LIBC_NAMESPACE::shared::fixsfti(12.5f));
+#endif // LIBC_TYPES_HAS_INT128
+  EXPECT_EQ(uint64_t(12), LIBC_NAMESPACE::shared::fixunssfdi(12.5f));
+  EXPECT_EQ(uint32_t(12), LIBC_NAMESPACE::shared::fixunssfsi(12.5f));
+#ifdef LIBC_TYPES_HAS_INT128
+  EXPECT_EQ(static_cast<__uint128_t>(12),
+            LIBC_NAMESPACE::shared::fixunssfti(12.5f));
+#endif // LIBC_TYPES_HAS_INT128
+}
+
+TEST(LlvmLibcSharedBuiltinsTest, DoubleToIntConversion) {
+  EXPECT_EQ(int64_t(12), LIBC_NAMESPACE::shared::fixdfdi(12.5));
+  EXPECT_EQ(int32_t(12), LIBC_NAMESPACE::shared::fixdfsi(12.5));
+#ifdef LIBC_TYPES_HAS_INT128
+  EXPECT_EQ(static_cast<__int128_t>(12), LIBC_NAMESPACE::shared::fixdfti(12.5));
+#endif // LIBC_TYPES_HAS_INT128
+  EXPECT_EQ(uint64_t(12), LIBC_NAMESPACE::shared::fixunsdfdi(12.5));
+  EXPECT_EQ(uint32_t(12), LIBC_NAMESPACE::shared::fixunsdfsi(12.5));
+#ifdef LIBC_TYPES_HAS_INT128
+  EXPECT_EQ(static_cast<__uint128_t>(12),
+            LIBC_NAMESPACE::shared::fixunsdfti(12.5));
+#endif // LIBC_TYPES_HAS_INT128
+}



More information about the llvm-commits mailing list