brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · d95b1db Raw
61 lines · plain
1//===-- aeabi_idivmod.S - EABI idivmod 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 { int quot, int rem} __aeabi_idivmod(int numerator, int denominator) {12//   int rem, quot;13//   quot = __divmodsi4(numerator, denominator, &rem);14//   return {quot, rem};15// }16 17#if defined(__MINGW32__)18#define __aeabi_idivmod __rt_sdiv19#endif20 21        .syntax unified22        .text23        DEFINE_CODE_STATE24        .p2align 225DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)26#if defined(USE_THUMB_1)27        push    {r0, r1, lr}28        bl      SYMBOL_NAME(__divsi3)29        pop     {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom30        muls    r2, r0, r2   // r2 = quot * denom31        subs    r1, r1, r232        JMP     (r3)33#else  // defined(USE_THUMB_1)34        PACBTI_LANDING35#if defined(__ARM_FEATURE_PAC_DEFAULT)36        push    { r12, lr }37#else38        push    { lr }39#endif40        sub     sp, sp, #441        mov     r2, sp42#if defined(__MINGW32__)43        mov     r3, r044        mov     r0, r145        mov     r1, r346#endif47        bl      SYMBOL_NAME(__divmodsi4)48        ldr     r1, [sp]49        add     sp, sp, #450#if defined(__ARM_FEATURE_PAC_DEFAULT)51        pop     { r12, lr }52        PAC_RETURN53#else54        pop     { pc }55#endif56#endif //  defined(USE_THUMB_1)57END_COMPILERRT_FUNCTION(__aeabi_idivmod)58 59NO_EXEC_STACK_DIRECTIVE60 61