]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/arm/aeabi_idivmod.S
Merge bmake-20170420
[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         .syntax unified
24         .text
25 #if defined(USE_THUMB_PROLOGUE)
26         .thumb
27 #endif
28         .p2align 2
29 #if defined(USE_THUMB_PROLOGUE)
30 DEFINE_COMPILERRT_THUMB_FUNCTION(__aeabi_idivmod)
31 #else
32 DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
33 #endif
34 #if defined(USE_THUMB_1)
35         push    {r0, r1, lr}
36         bl      SYMBOL_NAME(__divsi3)
37         pop     {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom
38         muls    r2, r2, r0   // r2 = quot * denom
39         subs    r1, r1, r2
40         JMP     (r3)
41 #else  // defined(USE_THUMB_1)
42         push    { lr }
43         sub     sp, sp, #4
44         mov     r2, sp
45 #if defined(__MINGW32__)
46         mov     r3, r0
47         mov     r0, r1
48         mov     r1, r3
49 #endif
50         bl      SYMBOL_NAME(__divmodsi4)
51         ldr     r1, [sp]
52         add     sp, sp, #4
53         pop     { pc }
54 #endif //  defined(USE_THUMB_1)
55 END_COMPILERRT_FUNCTION(__aeabi_idivmod)
56
57 NO_EXEC_STACK_DIRECTIVE
58