]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/arm/aeabi_uidivmod.S
Merge compiler-rt r291274.
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / builtins / arm / aeabi_uidivmod.S
1 //===-- aeabi_uidivmod.S - EABI uidivmod 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 { unsigned quot, unsigned rem}
13 //        __aeabi_uidivmod(unsigned numerator, unsigned denominator) {
14 //   unsigned rem, quot;
15 //   quot = __udivmodsi4(numerator, denominator, &rem);
16 //   return {quot, rem};
17 // }
18
19 #if defined(__MINGW32__)
20 #define __aeabi_uidivmod __rt_udiv
21 #endif
22
23         .syntax unified
24         .p2align 2
25 DEFINE_COMPILERRT_FUNCTION(__aeabi_uidivmod)
26 #if __ARM_ARCH_ISA_THUMB == 1
27         cmp     r0, r1
28         bcc     LOCAL_LABEL(case_denom_larger)
29         push    {r0, r1, lr}
30         bl      SYMBOL_NAME(__aeabi_uidiv)
31         pop     {r1, r2, r3}
32         muls    r2, r2, r0 // r2 = quot * denom
33         subs    r1, r1, r2
34         JMP     (r3)
35 LOCAL_LABEL(case_denom_larger):
36         movs    r1, r0
37         movs    r0, #0
38         JMP     (lr)
39 #else
40         push    { lr }
41         sub     sp, sp, #4
42         mov     r2, sp
43 #if defined(__MINGW32__)
44         mov     r3, r0
45         mov     r0, r1
46         mov     r1, r3
47 #endif
48         bl      SYMBOL_NAME(__udivmodsi4)
49         ldr     r1, [sp]
50         add     sp, sp, #4
51         pop     { pc }
52 #endif
53 END_COMPILERRT_FUNCTION(__aeabi_uidivmod)
54
55 NO_EXEC_STACK_DIRECTIVE
56