[compiler-rt] [builtins] Support building the 128-bit float functions on i386 (PR #122658)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 12 18:48:39 PST 2025


https://github.com/zhangtianhao6 created https://github.com/llvm/llvm-project/pull/122658

GCC provides these functions (e.g.__subtf3) in libgcc on i386.
 Since Clang supports float128, we can also enable the existing code in i386 for ABI compatible.

https://github.com/llvm/llvm-project/issues/121757

>From b1dd80a9d9d1bfcb81d07ca71d57d03e5bf178c0 Mon Sep 17 00:00:00 2001
From: zhangtianhao6 <zhangtianhao6 at huawei.com>
Date: Mon, 13 Jan 2025 10:34:37 +0800
Subject: [PATCH] [builtins] Support building the 128-bit float functions on
 i386

GCC provides these functions (e.g.__subtf3) in libgcc on i386.
Since Clang supports float128, we can also enable the existing code in i386 for ABI compatible.
---
 compiler-rt/lib/builtins/CMakeLists.txt | 3 ++-
 compiler-rt/lib/builtins/extendxftf2.c  | 2 +-
 compiler-rt/lib/builtins/trunctfxf2.c   | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 19316c52d12ce8..f8a3b5c7f7271e 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -356,6 +356,7 @@ if (NOT MSVC)
   set(i386_SOURCES
     ${GENERIC_SOURCES}
     ${x86_ARCH_SOURCES}
+    ${GENERIC_TF_SOURCES}
     i386/ashldi3.S
     i386/ashrdi3.S
     i386/divdi3.S
@@ -906,7 +907,7 @@ else ()
 
       # For RISCV32, we must force enable int128 for compiling long
       # double routines.
-      if(COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" STREQUAL "riscv32")
+      if(COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" STREQUAL "riscv32" OR "${arch}" STREQUAL "i386")
         list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128)
       endif()
 
diff --git a/compiler-rt/lib/builtins/extendxftf2.c b/compiler-rt/lib/builtins/extendxftf2.c
index c1d97b5cfa1515..77c6b227876655 100644
--- a/compiler-rt/lib/builtins/extendxftf2.c
+++ b/compiler-rt/lib/builtins/extendxftf2.c
@@ -12,7 +12,7 @@
 #define QUAD_PRECISION
 #include "fp_lib.h"
 
-#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
+#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && (defined(__x86_64__) && defined(__i386__))
 #define SRC_80
 #define DST_QUAD
 #include "fp_extend_impl.inc"
diff --git a/compiler-rt/lib/builtins/trunctfxf2.c b/compiler-rt/lib/builtins/trunctfxf2.c
index 49bd32d42aacb8..10a354edaf4ce7 100644
--- a/compiler-rt/lib/builtins/trunctfxf2.c
+++ b/compiler-rt/lib/builtins/trunctfxf2.c
@@ -12,7 +12,7 @@
 #define QUAD_PRECISION
 #include "fp_lib.h"
 
-#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
+#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && (defined(__x86_64__) && defined(__i386__))
 
 #define SRC_QUAD
 #define DST_80



More information about the llvm-commits mailing list