Skip to content

Commit fe61e4a

Browse files
committed
[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.
1 parent 211bcf6 commit fe61e4a

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ if (NOT MSVC)
356356
set(i386_SOURCES
357357
${GENERIC_SOURCES}
358358
${x86_ARCH_SOURCES}
359+
${GENERIC_TF_SOURCES}
359360
i386/ashldi3.S
360361
i386/ashrdi3.S
361362
i386/divdi3.S
@@ -906,7 +907,7 @@ else ()
906907

907908
# For RISCV32, we must force enable int128 for compiling long
908909
# double routines.
909-
if(COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" STREQUAL "riscv32")
910+
if(COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" STREQUAL "riscv32" OR "${arch}" STREQUAL "i386")
910911
list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128)
911912
endif()
912913

compiler-rt/lib/builtins/extendxftf2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#define QUAD_PRECISION
1313
#include "fp_lib.h"
1414

15-
#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
15+
#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && \
16+
(defined(__x86_64__) || defined(__i386__))
1617
#define SRC_80
1718
#define DST_QUAD
1819
#include "fp_extend_impl.inc"

compiler-rt/lib/builtins/trunctfxf2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#define QUAD_PRECISION
1313
#include "fp_lib.h"
1414

15-
#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
15+
#if defined(CRT_HAS_TF_MODE) && __LDBL_MANT_DIG__ == 64 && \
16+
(defined(__x86_64__) || defined(__i386__))
1617

1718
#define SRC_QUAD
1819
#define DST_80

compiler-rt/test/builtins/Unit/extendxftf2_test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %clang_builtins %s %librt -o %t && %run %t
1+
// RUN: %clang_builtins %s %librt -fforce-enable-int128 -o %t && %run %t
22
// REQUIRES: librt_has_extendxftf2
33

44
#include "int_lib.h"
55
#include <stdio.h>
66

7-
#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__) && \
7+
#if __LDBL_MANT_DIG__ == 64 && (defined(__x86_64__) || defined(__i386__)) && \
88
(defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
99

1010
#include "fp_test.h"
@@ -28,7 +28,7 @@ char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
2828
#endif
2929

3030
int main() {
31-
#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__) && \
31+
#if __LDBL_MANT_DIG__ == 64 && (defined(__x86_64__) || defined(__i386__)) && \
3232
(defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
3333
// qNaN
3434
if (test__extendxftf2(makeQNaN80(), UINT64_C(0x7fff800000000000),

compiler-rt/test/builtins/Unit/trunctfxf2_test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %clang_builtins %s %librt -o %t && %run %t
1+
// RUN: %clang_builtins %s %librt -fforce-enable-int128 -o %t && %run %t
22
// REQUIRES: librt_has_trunctfxf2
33

44
#include "int_lib.h"
55
#include <stdio.h>
66

7-
#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__) && \
7+
#if __LDBL_MANT_DIG__ == 64 && (defined(__x86_64__) || defined(__i386__)) && \
88
(defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
99

1010
#include "fp_test.h"
@@ -28,7 +28,7 @@ char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
2828
#endif
2929

3030
int main() {
31-
#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__) && \
31+
#if __LDBL_MANT_DIG__ == 64 && (defined(__x86_64__) || defined(__i386__)) && \
3232
(defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
3333
// qNaN
3434
if (test__trunctfxf2(makeQNaN128(), UINT64_C(0x7FFF),

0 commit comments

Comments
 (0)