xref: /rk3399_ARM-atf/lib/compiler-rt/builtins/arm/aeabi_uldivmod.S (revision 9900d4eb06605c6ff79801c4371445d245b7b2fb)
10e14a7fbSdp-arm//===-- aeabi_uldivmod.S - EABI uldivmod implementation -------------------===//
20e14a7fbSdp-arm//
3*8a6a9560SDaniel Boulby// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*8a6a9560SDaniel Boulby// See https://llvm.org/LICENSE.txt for license information.
5*8a6a9560SDaniel Boulby// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60e14a7fbSdp-arm//
70e14a7fbSdp-arm//===----------------------------------------------------------------------===//
80e14a7fbSdp-arm
90e14a7fbSdp-arm#include "../assembly.h"
100e14a7fbSdp-arm
110e14a7fbSdp-arm// struct { uint64_t quot, uint64_t rem}
120e14a7fbSdp-arm//        __aeabi_uldivmod(uint64_t numerator, uint64_t denominator) {
130e14a7fbSdp-arm//   uint64_t rem, quot;
140e14a7fbSdp-arm//   quot = __udivmoddi4(numerator, denominator, &rem);
150e14a7fbSdp-arm//   return {quot, rem};
160e14a7fbSdp-arm// }
170e14a7fbSdp-arm
180e14a7fbSdp-arm#if defined(__MINGW32__)
190e14a7fbSdp-arm#define __aeabi_uldivmod __rt_udiv64
200e14a7fbSdp-arm#endif
210e14a7fbSdp-arm
220e14a7fbSdp-arm        .syntax unified
230e14a7fbSdp-arm        .p2align 2
240e14a7fbSdp-armDEFINE_COMPILERRT_FUNCTION(__aeabi_uldivmod)
250e14a7fbSdp-arm        push	{r6, lr}
260e14a7fbSdp-arm        sub	sp, sp, #16
270e14a7fbSdp-arm        add	r6, sp, #8
280e14a7fbSdp-arm        str	r6, [sp]
290e14a7fbSdp-arm#if defined(__MINGW32__)
300e14a7fbSdp-arm        movs    r6, r0
310e14a7fbSdp-arm        movs    r0, r2
320e14a7fbSdp-arm        movs    r2, r6
330e14a7fbSdp-arm        movs    r6, r1
340e14a7fbSdp-arm        movs    r1, r3
350e14a7fbSdp-arm        movs    r3, r6
360e14a7fbSdp-arm#endif
370e14a7fbSdp-arm        bl	SYMBOL_NAME(__udivmoddi4)
380e14a7fbSdp-arm        ldr	r2, [sp, #8]
390e14a7fbSdp-arm        ldr	r3, [sp, #12]
400e14a7fbSdp-arm        add	sp, sp, #16
410e14a7fbSdp-arm        pop	{r6, pc}
420e14a7fbSdp-armEND_COMPILERRT_FUNCTION(__aeabi_uldivmod)
430e14a7fbSdp-arm
440e14a7fbSdp-armNO_EXEC_STACK_DIRECTIVE
450e14a7fbSdp-arm
46