xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/arm/aeabi_ldivmod.S (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric//===-- aeabi_ldivmod.S - EABI ldivmod implementation ---------------------===//
2*0b57cec5SDimitry Andric//
3*0b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric//
7*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric
9*0b57cec5SDimitry Andric#include "../assembly.h"
10*0b57cec5SDimitry Andric
11*0b57cec5SDimitry Andric// struct { int64_t quot, int64_t rem}
12*0b57cec5SDimitry Andric//        __aeabi_ldivmod(int64_t numerator, int64_t denominator) {
13*0b57cec5SDimitry Andric//   int64_t rem, quot;
14*0b57cec5SDimitry Andric//   quot = __divmoddi4(numerator, denominator, &rem);
15*0b57cec5SDimitry Andric//   return {quot, rem};
16*0b57cec5SDimitry Andric// }
17*0b57cec5SDimitry Andric
18*0b57cec5SDimitry Andric#if defined(__MINGW32__)
19*0b57cec5SDimitry Andric#define __aeabi_ldivmod __rt_sdiv64
20*0b57cec5SDimitry Andric#endif
21*0b57cec5SDimitry Andric
22*0b57cec5SDimitry Andric        .syntax unified
23*0b57cec5SDimitry Andric        .p2align 2
24*0b57cec5SDimitry AndricDEFINE_COMPILERRT_FUNCTION(__aeabi_ldivmod)
25*0b57cec5SDimitry Andric        push    {r6, lr}
26*0b57cec5SDimitry Andric        sub     sp, sp, #16
27*0b57cec5SDimitry Andric        add     r6, sp, #8
28*0b57cec5SDimitry Andric        str     r6, [sp]
29*0b57cec5SDimitry Andric#if defined(__MINGW32__)
30*0b57cec5SDimitry Andric        movs    r6, r0
31*0b57cec5SDimitry Andric        movs    r0, r2
32*0b57cec5SDimitry Andric        movs    r2, r6
33*0b57cec5SDimitry Andric        movs    r6, r1
34*0b57cec5SDimitry Andric        movs    r1, r3
35*0b57cec5SDimitry Andric        movs    r3, r6
36*0b57cec5SDimitry Andric#endif
37*0b57cec5SDimitry Andric        bl      SYMBOL_NAME(__divmoddi4)
38*0b57cec5SDimitry Andric        ldr     r2, [sp, #8]
39*0b57cec5SDimitry Andric        ldr     r3, [sp, #12]
40*0b57cec5SDimitry Andric        add     sp, sp, #16
41*0b57cec5SDimitry Andric        pop     {r6, pc}
42*0b57cec5SDimitry AndricEND_COMPILERRT_FUNCTION(__aeabi_ldivmod)
43*0b57cec5SDimitry Andric
44*0b57cec5SDimitry AndricNO_EXEC_STACK_DIRECTIVE
45*0b57cec5SDimitry Andric
46