dp-arm | 75b6057 | 2017-05-04 12:12:06 +0100 | [diff] [blame] | 1 | //===-- aeabi_uldivmod.S - EABI uldivmod implementation -------------------===// |
| 2 | // |
Daniel Boulby | 318e7a5 | 2022-10-21 20:20:52 +0100 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
dp-arm | 75b6057 | 2017-05-04 12:12:06 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "../assembly.h" |
| 10 | |
| 11 | // struct { uint64_t quot, uint64_t rem} |
| 12 | // __aeabi_uldivmod(uint64_t numerator, uint64_t denominator) { |
| 13 | // uint64_t rem, quot; |
| 14 | // quot = __udivmoddi4(numerator, denominator, &rem); |
| 15 | // return {quot, rem}; |
| 16 | // } |
| 17 | |
| 18 | #if defined(__MINGW32__) |
| 19 | #define __aeabi_uldivmod __rt_udiv64 |
| 20 | #endif |
| 21 | |
| 22 | .syntax unified |
| 23 | .p2align 2 |
| 24 | DEFINE_COMPILERRT_FUNCTION(__aeabi_uldivmod) |
| 25 | push {r6, lr} |
| 26 | sub sp, sp, #16 |
| 27 | add r6, sp, #8 |
| 28 | str r6, [sp] |
| 29 | #if defined(__MINGW32__) |
| 30 | movs r6, r0 |
| 31 | movs r0, r2 |
| 32 | movs r2, r6 |
| 33 | movs r6, r1 |
| 34 | movs r1, r3 |
| 35 | movs r3, r6 |
| 36 | #endif |
| 37 | bl SYMBOL_NAME(__udivmoddi4) |
| 38 | ldr r2, [sp, #8] |
| 39 | ldr r3, [sp, #12] |
| 40 | add sp, sp, #16 |
| 41 | pop {r6, pc} |
| 42 | END_COMPILERRT_FUNCTION(__aeabi_uldivmod) |
| 43 | |
| 44 | NO_EXEC_STACK_DIRECTIVE |
| 45 | |