10b57cec5SDimitry Andric//===-- aeabi_ldivmod.S - EABI ldivmod implementation ---------------------===// 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric#include "../assembly.h" 100b57cec5SDimitry Andric 110b57cec5SDimitry Andric// struct { int64_t quot, int64_t rem} 120b57cec5SDimitry Andric// __aeabi_ldivmod(int64_t numerator, int64_t denominator) { 130b57cec5SDimitry Andric// int64_t rem, quot; 140b57cec5SDimitry Andric// quot = __divmoddi4(numerator, denominator, &rem); 150b57cec5SDimitry Andric// return {quot, rem}; 160b57cec5SDimitry Andric// } 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric#if defined(__MINGW32__) 190b57cec5SDimitry Andric#define __aeabi_ldivmod __rt_sdiv64 200b57cec5SDimitry Andric#endif 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric .syntax unified 230b57cec5SDimitry Andric .p2align 2 240b57cec5SDimitry AndricDEFINE_COMPILERRT_FUNCTION(__aeabi_ldivmod) 250b57cec5SDimitry Andric push {r6, lr} 260b57cec5SDimitry Andric sub sp, sp, #16 270b57cec5SDimitry Andric add r6, sp, #8 280b57cec5SDimitry Andric str r6, [sp] 290b57cec5SDimitry Andric#if defined(__MINGW32__) 300b57cec5SDimitry Andric movs r6, r0 310b57cec5SDimitry Andric movs r0, r2 320b57cec5SDimitry Andric movs r2, r6 330b57cec5SDimitry Andric movs r6, r1 340b57cec5SDimitry Andric movs r1, r3 350b57cec5SDimitry Andric movs r3, r6 360b57cec5SDimitry Andric#endif 370b57cec5SDimitry Andric bl SYMBOL_NAME(__divmoddi4) 380b57cec5SDimitry Andric ldr r2, [sp, #8] 390b57cec5SDimitry Andric ldr r3, [sp, #12] 400b57cec5SDimitry Andric add sp, sp, #16 410b57cec5SDimitry Andric pop {r6, pc} 420b57cec5SDimitry AndricEND_COMPILERRT_FUNCTION(__aeabi_ldivmod) 430b57cec5SDimitry Andric 440b57cec5SDimitry AndricNO_EXEC_STACK_DIRECTIVE 450b57cec5SDimitry Andric 46