]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/arm/aeabi_idivmod.S
Merge ^/head r314420 through r314481.
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / builtins / arm / aeabi_idivmod.S
1 //===-- aeabi_idivmod.S - EABI idivmod implementation ---------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "../assembly.h"
11
12 // struct { int quot, int rem} __aeabi_idivmod(int numerator, int denominator) {
13 //   int rem, quot;
14 //   quot = __divmodsi4(numerator, denominator, &rem);
15 //   return {quot, rem};
16 // }
17
18 #if defined(__MINGW32__)
19 #define __aeabi_idivmod __rt_sdiv
20 #endif
21
22         .syntax unified
23         .p2align 2
24 DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
25 #if __ARM_ARCH_ISA_THUMB == 1
26         push    {r0, r1, lr}
27         bl      SYMBOL_NAME(__divsi3)
28         pop     {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom
29         muls    r2, r2, r0   // r2 = quot * denom
30         subs    r1, r1, r2
31         JMP     (r3)
32 #else
33         push    { lr }
34         sub     sp, sp, #4
35         mov     r2, sp
36 #if defined(__MINGW32__)
37         mov     r3, r0
38         mov     r0, r1
39         mov     r1, r3
40 #endif
41         bl      SYMBOL_NAME(__divmodsi4)
42         ldr     r1, [sp]
43         add     sp, sp, #4
44         pop     { pc }
45 #endif // __ARM_ARCH_ISA_THUMB == 1
46 END_COMPILERRT_FUNCTION(__aeabi_idivmod)
47
48 NO_EXEC_STACK_DIRECTIVE
49