[compiler-rt] r287465 - builtins: Allow building windows arm functions for mingw
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 19 13:22:39 PST 2016
Author: mstorsjo
Date: Sat Nov 19 15:22:38 2016
New Revision: 287465
URL: http://llvm.org/viewvc/llvm-project?rev=287465&view=rev
Log:
builtins: Allow building windows arm functions for mingw
When building with clang/LLVM in MSVC mode, the msvcrt libraries contain
these functions.
When building in a mingw environment, we need to provide them somehow,
e.g. via compiler-rt.
The aeabi divmod functions work in the same way as the corresponding
__rt_*div* functions for windows, but their parameters are swapped.
The functions for converting float to integer and vice versa are the
same as their aeabi equivalents, only with different function names.
Differential Revision: https://reviews.llvm.org/D26183
Added:
compiler-rt/trunk/lib/builtins/mingw_fixfloat.c
Modified:
compiler-rt/trunk/lib/builtins/CMakeLists.txt
compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S
compiler-rt/trunk/lib/builtins/arm/aeabi_ldivmod.S
compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S
compiler-rt/trunk/lib/builtins/arm/aeabi_uldivmod.S
Modified: compiler-rt/trunk/lib/builtins/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/CMakeLists.txt?rev=287465&r1=287464&r2=287465&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/builtins/CMakeLists.txt Sat Nov 19 15:22:38 2016
@@ -371,7 +371,31 @@ set(arm_Thumb1_SOURCES
${arm_Thumb1_VFPv2_SOURCES}
${arm_Thumb1_icache_SOURCES})
-if(NOT WIN32)
+if(MINGW)
+ set(arm_SOURCES
+ arm/aeabi_idivmod.S
+ arm/aeabi_ldivmod.S
+ arm/aeabi_uidivmod.S
+ arm/aeabi_uldivmod.S
+ divmoddi4.c
+ divmodsi4.c
+ divdi3.c
+ divsi3.c
+ fixdfdi.c
+ fixsfdi.c
+ fixunsdfdi.c
+ fixunssfdi.c
+ floatdidf.c
+ floatdisf.c
+ floatundidf.c
+ floatundisf.c
+ mingw_fixfloat.c
+ moddi3.c
+ udivmoddi4.c
+ udivmodsi4.c
+ udivsi3.c
+ umoddi3.c)
+else(MINGW)
# TODO the EABI sources should only be added to EABI targets
set(arm_SOURCES
${arm_SOURCES}
Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S?rev=287465&r1=287464&r2=287465&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S (original)
+++ compiler-rt/trunk/lib/builtins/arm/aeabi_idivmod.S Sat Nov 19 15:22:38 2016
@@ -15,12 +15,21 @@
// return {quot, rem};
// }
+#if defined(__MINGW32__)
+#define __aeabi_idivmod __rt_sdiv
+#endif
+
.syntax unified
.p2align 2
DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
push { lr }
sub sp, sp, #4
mov r2, sp
+#if defined(__MINGW32__)
+ mov r3, r0
+ mov r0, r1
+ mov r1, r3
+#endif
bl SYMBOL_NAME(__divmodsi4)
ldr r1, [sp]
add sp, sp, #4
Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_ldivmod.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_ldivmod.S?rev=287465&r1=287464&r2=287465&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/arm/aeabi_ldivmod.S (original)
+++ compiler-rt/trunk/lib/builtins/arm/aeabi_ldivmod.S Sat Nov 19 15:22:38 2016
@@ -16,6 +16,10 @@
// return {quot, rem};
// }
+#if defined(__MINGW32__)
+#define __aeabi_ldivmod __rt_sdiv64
+#endif
+
.syntax unified
.p2align 2
DEFINE_COMPILERRT_FUNCTION(__aeabi_ldivmod)
@@ -23,6 +27,14 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_ldivm
sub sp, sp, #16
add r12, sp, #8
str r12, [sp]
+#if defined(__MINGW32__)
+ mov r12, r0
+ mov r0, r2
+ mov r2, r12
+ mov r12, r1
+ mov r1, r3
+ mov r3, r12
+#endif
bl SYMBOL_NAME(__divmoddi4)
ldr r2, [sp, #8]
ldr r3, [sp, #12]
Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S?rev=287465&r1=287464&r2=287465&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S (original)
+++ compiler-rt/trunk/lib/builtins/arm/aeabi_uidivmod.S Sat Nov 19 15:22:38 2016
@@ -16,12 +16,21 @@
// return {quot, rem};
// }
+#if defined(__MINGW32__)
+#define __aeabi_uidivmod __rt_udiv
+#endif
+
.syntax unified
.p2align 2
DEFINE_COMPILERRT_FUNCTION(__aeabi_uidivmod)
push { lr }
sub sp, sp, #4
mov r2, sp
+#if defined(__MINGW32__)
+ mov r3, r0
+ mov r0, r1
+ mov r1, r3
+#endif
bl SYMBOL_NAME(__udivmodsi4)
ldr r1, [sp]
add sp, sp, #4
Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_uldivmod.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_uldivmod.S?rev=287465&r1=287464&r2=287465&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/arm/aeabi_uldivmod.S (original)
+++ compiler-rt/trunk/lib/builtins/arm/aeabi_uldivmod.S Sat Nov 19 15:22:38 2016
@@ -16,6 +16,10 @@
// return {quot, rem};
// }
+#if defined(__MINGW32__)
+#define __aeabi_uldivmod __rt_udiv64
+#endif
+
.syntax unified
.p2align 2
DEFINE_COMPILERRT_FUNCTION(__aeabi_uldivmod)
@@ -23,6 +27,14 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_uldiv
sub sp, sp, #16
add r12, sp, #8
str r12, [sp]
+#if defined(__MINGW32__)
+ mov r12, r0
+ mov r0, r2
+ mov r2, r12
+ mov r12, r1
+ mov r1, r3
+ mov r3, r12
+#endif
bl SYMBOL_NAME(__udivmoddi4)
ldr r2, [sp, #8]
ldr r3, [sp, #12]
Added: compiler-rt/trunk/lib/builtins/mingw_fixfloat.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/mingw_fixfloat.c?rev=287465&view=auto
==============================================================================
--- compiler-rt/trunk/lib/builtins/mingw_fixfloat.c (added)
+++ compiler-rt/trunk/lib/builtins/mingw_fixfloat.c Sat Nov 19 15:22:38 2016
@@ -0,0 +1,36 @@
+/* ===-- mingw_fixfloat.c - Wrap int/float conversions for arm/windows -----===
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+#include "int_lib.h"
+
+COMPILER_RT_ABI di_int __fixdfdi(double a);
+COMPILER_RT_ABI di_int __fixsfdi(float a);
+COMPILER_RT_ABI du_int __fixunsdfdi(double a);
+COMPILER_RT_ABI du_int __fixunssfdi(float a);
+COMPILER_RT_ABI double __floatdidf(di_int a);
+COMPILER_RT_ABI float __floatdisf(di_int a);
+COMPILER_RT_ABI double __floatundidf(du_int a);
+COMPILER_RT_ABI float __floatundisf(du_int a);
+
+COMPILER_RT_ABI di_int __dtoi64(double a) { return __fixdfdi(a); }
+
+COMPILER_RT_ABI di_int __stoi64(float a) { return __fixsfdi(a); }
+
+COMPILER_RT_ABI du_int __dtou64(double a) { return __fixunsdfdi(a); }
+
+COMPILER_RT_ABI du_int __stou64(float a) { return __fixunssfdi(a); }
+
+COMPILER_RT_ABI double __i64tod(di_int a) { return __floatdidf(a); }
+
+COMPILER_RT_ABI float __i64tos(di_int a) { return __floatdisf(a); }
+
+COMPILER_RT_ABI double __u64tod(du_int a) { return __floatundidf(a); }
+
+COMPILER_RT_ABI float __u64tos(du_int a) { return __floatundisf(a); }
More information about the llvm-commits
mailing list