]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/arm/aeabi_uidivmod.S
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r305145, and update
[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         .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_uidivmod)
31 #else
32 DEFINE_COMPILERRT_FUNCTION(__aeabi_uidivmod)
33 #endif
34 #if __ARM_ARCH_ISA_THUMB == 1
35         cmp     r0, r1
36         bcc     LOCAL_LABEL(case_denom_larger)
37         push    {r0, r1, lr}
38         bl      SYMBOL_NAME(__aeabi_uidiv)
39         pop     {r1, r2, r3}
40         muls    r2, r0, r2 // r2 = quot * denom
41         subs    r1, r1, r2
42         JMP     (r3)
43 LOCAL_LABEL(case_denom_larger):
44         movs    r1, r0
45         movs    r0, #0
46         JMP     (lr)
47 #else
48         push    { lr }
49         sub     sp, sp, #4
50         mov     r2, sp
51 #if defined(__MINGW32__)
52         mov     r3, r0
53         mov     r0, r1
54         mov     r1, r3
55 #endif
56         bl      SYMBOL_NAME(__udivmodsi4)
57         ldr     r1, [sp]
58         add     sp, sp, #4
59         pop     { pc }
60 #endif
61 END_COMPILERRT_FUNCTION(__aeabi_uidivmod)
62
63 NO_EXEC_STACK_DIRECTIVE
64