| 1 | //===-- aeabi_ldivmod.S - EABI ldivmod implementation ---------------------===// |
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "../assembly.h" |
| 10 | |
| 11 | // struct { int64_t quot, int64_t rem} |
| 12 | // __aeabi_ldivmod(int64_t numerator, int64_t denominator) { |
| 13 | // int64_t rem, quot; |
| 14 | // quot = __divmoddi4(numerator, denominator, &rem); |
| 15 | // return {quot, rem}; |
| 16 | // } |
| 17 | |
| 18 | #if defined(__MINGW32__) |
| 19 | #define __aeabi_ldivmod __rt_sdiv64 |
| 20 | #endif |
| 21 | |
| 22 | .syntax unified |
| 23 | .p2align 2 |
| 24 | DEFINE_COMPILERRT_FUNCTION(__aeabi_ldivmod) |
| 25 | PACBTI_LANDING |
| 26 | #if defined(__ARM_FEATURE_PAC_DEFAULT) |
| 27 | push {r6, r12, lr} |
| 28 | #else |
| 29 | push {r6, lr} |
| 30 | #endif |
| 31 | sub sp, sp, #16 |
| 32 | add r6, sp, #8 |
| 33 | str r6, [sp] |
| 34 | #if defined(__MINGW32__) |
| 35 | movs r6, r0 |
| 36 | movs r0, r2 |
| 37 | movs r2, r6 |
| 38 | movs r6, r1 |
| 39 | movs r1, r3 |
| 40 | movs r3, r6 |
| 41 | #endif |
| 42 | bl SYMBOL_NAME(__divmoddi4) |
| 43 | ldr r2, [sp, #8] |
| 44 | ldr r3, [sp, #12] |
| 45 | add sp, sp, #16 |
| 46 | #if defined(__ARM_FEATURE_PAC_DEFAULT) |
| 47 | pop {r6, r12, lr} |
| 48 | bxaut r12, lr, sp |
| 49 | #else |
| 50 | pop {r6, pc} |
| 51 | #endif |
| 52 | END_COMPILERRT_FUNCTION(__aeabi_ldivmod) |
| 53 | |
| 54 | NO_EXEC_STACK_DIRECTIVE |
| 55 | |
| 56 | |