xref: /rk3399_ARM-atf/lib/compiler-rt/builtins/arm/aeabi_uldivmod.S (revision 0e14a7fbeb3014e719302c9b7f6a24c4030dfaf0)
1*0e14a7fbSdp-arm//===-- aeabi_uldivmod.S - EABI uldivmod implementation -------------------===//
2*0e14a7fbSdp-arm//
3*0e14a7fbSdp-arm//                     The LLVM Compiler Infrastructure
4*0e14a7fbSdp-arm//
5*0e14a7fbSdp-arm// This file is dual licensed under the MIT and the University of Illinois Open
6*0e14a7fbSdp-arm// Source Licenses. See LICENSE.TXT for details.
7*0e14a7fbSdp-arm//
8*0e14a7fbSdp-arm//===----------------------------------------------------------------------===//
9*0e14a7fbSdp-arm
10*0e14a7fbSdp-arm#include "../assembly.h"
11*0e14a7fbSdp-arm
12*0e14a7fbSdp-arm// struct { uint64_t quot, uint64_t rem}
13*0e14a7fbSdp-arm//        __aeabi_uldivmod(uint64_t numerator, uint64_t denominator) {
14*0e14a7fbSdp-arm//   uint64_t rem, quot;
15*0e14a7fbSdp-arm//   quot = __udivmoddi4(numerator, denominator, &rem);
16*0e14a7fbSdp-arm//   return {quot, rem};
17*0e14a7fbSdp-arm// }
18*0e14a7fbSdp-arm
19*0e14a7fbSdp-arm#if defined(__MINGW32__)
20*0e14a7fbSdp-arm#define __aeabi_uldivmod __rt_udiv64
21*0e14a7fbSdp-arm#endif
22*0e14a7fbSdp-arm
23*0e14a7fbSdp-arm        .syntax unified
24*0e14a7fbSdp-arm        .p2align 2
25*0e14a7fbSdp-armDEFINE_COMPILERRT_FUNCTION(__aeabi_uldivmod)
26*0e14a7fbSdp-arm        push	{r6, lr}
27*0e14a7fbSdp-arm        sub	sp, sp, #16
28*0e14a7fbSdp-arm        add	r6, sp, #8
29*0e14a7fbSdp-arm        str	r6, [sp]
30*0e14a7fbSdp-arm#if defined(__MINGW32__)
31*0e14a7fbSdp-arm        movs    r6, r0
32*0e14a7fbSdp-arm        movs    r0, r2
33*0e14a7fbSdp-arm        movs    r2, r6
34*0e14a7fbSdp-arm        movs    r6, r1
35*0e14a7fbSdp-arm        movs    r1, r3
36*0e14a7fbSdp-arm        movs    r3, r6
37*0e14a7fbSdp-arm#endif
38*0e14a7fbSdp-arm        bl	SYMBOL_NAME(__udivmoddi4)
39*0e14a7fbSdp-arm        ldr	r2, [sp, #8]
40*0e14a7fbSdp-arm        ldr	r3, [sp, #12]
41*0e14a7fbSdp-arm        add	sp, sp, #16
42*0e14a7fbSdp-arm        pop	{r6, pc}
43*0e14a7fbSdp-armEND_COMPILERRT_FUNCTION(__aeabi_uldivmod)
44*0e14a7fbSdp-arm
45*0e14a7fbSdp-armNO_EXEC_STACK_DIRECTIVE
46*0e14a7fbSdp-arm
47