68 lines · plain
1//===-- aeabi_uidivmod.S - EABI uidivmod 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-exception6//7//===----------------------------------------------------------------------===//8 9#include "../assembly.h"10 11// struct { unsigned quot, unsigned rem}12// __aeabi_uidivmod(unsigned numerator, unsigned denominator) {13// unsigned rem, quot;14// quot = __udivmodsi4(numerator, denominator, &rem);15// return {quot, rem};16// }17 18#if defined(__MINGW32__)19#define __aeabi_uidivmod __rt_udiv20#endif21 22 .syntax unified23 .text24 DEFINE_CODE_STATE25 .p2align 226DEFINE_COMPILERRT_FUNCTION(__aeabi_uidivmod)27#if defined(USE_THUMB_1)28 cmp r0, r129 bcc LOCAL_LABEL(case_denom_larger)30 push {r0, r1, lr}31 bl SYMBOL_NAME(__aeabi_uidiv)32 pop {r1, r2, r3}33 muls r2, r0, r2 // r2 = quot * denom34 subs r1, r1, r235 JMP (r3)36LOCAL_LABEL(case_denom_larger):37 movs r1, r038 movs r0, #039 JMP (lr)40#else // defined(USE_THUMB_1)41 PACBTI_LANDING42#if defined(__ARM_FEATURE_PAC_DEFAULT)43 push { r12, lr }44#else45 push { lr }46#endif47 sub sp, sp, #448 mov r2, sp49#if defined(__MINGW32__)50 mov r3, r051 mov r0, r152 mov r1, r353#endif54 bl SYMBOL_NAME(__udivmodsi4)55 ldr r1, [sp]56 add sp, sp, #457#if defined(__ARM_FEATURE_PAC_DEFAULT)58 pop { r12, lr }59 PAC_RETURN60#else61 pop { pc }62#endif63#endif64END_COMPILERRT_FUNCTION(__aeabi_uidivmod)65 66NO_EXEC_STACK_DIRECTIVE67 68