blob: bc26e5674ca0bbcf49b868f3d8d1706dd7868d20 [file] [log] [blame]
Anton Korobeynikov28037ce2012-01-30 10:21:51 +00001//===-- aeabi_uldivmod.S - EABI uldivmod 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 { uint64_t quot, uint64_t rem}
13// __aeabi_uldivmod(uint64_t numerator, uint64_t denominator) {
14// uint64_t rem, quot;
15// quot = __udivmoddi4(numerator, denominator, &rem);
16// return {quot, rem};
17// }
18
Martin Storsjo8c596802016-11-19 21:22:38 +000019#if defined(__MINGW32__)
20#define __aeabi_uldivmod __rt_udiv64
21#endif
22
Anton Korobeynikov28037ce2012-01-30 10:21:51 +000023 .syntax unified
Saleem Abdulrasool310874a2014-05-12 15:23:37 +000024 .p2align 2
Anton Korobeynikov28037ce2012-01-30 10:21:51 +000025DEFINE_COMPILERRT_FUNCTION(__aeabi_uldivmod)
26 push {r11, lr}
27 sub sp, sp, #16
28 add r12, sp, #8
29 str r12, [sp]
Martin Storsjo8c596802016-11-19 21:22:38 +000030#if defined(__MINGW32__)
31 mov r12, r0
32 mov r0, r2
33 mov r2, r12
34 mov r12, r1
35 mov r1, r3
36 mov r3, r12
37#endif
Anton Korobeynikov28037ce2012-01-30 10:21:51 +000038 bl SYMBOL_NAME(__udivmoddi4)
39 ldr r2, [sp, #8]
40 ldr r3, [sp, #12]
41 add sp, sp, #16
Joerg Sonnenberger171e9cf2014-01-24 14:33:42 +000042 pop {r11, pc}
43END_COMPILERRT_FUNCTION(__aeabi_uldivmod)
Saleem Abdulrasool590e85b2016-06-22 22:09:42 +000044
45NO_EXEC_STACK_DIRECTIVE
46