Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/arm/aeabi_idivmod.S
35292 views
//===-- aeabi_idivmod.S - EABI idivmod implementation ---------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "../assembly.h"910// struct { int quot, int rem} __aeabi_idivmod(int numerator, int denominator) {11// int rem, quot;12// quot = __divmodsi4(numerator, denominator, &rem);13// return {quot, rem};14// }1516#if defined(__MINGW32__)17#define __aeabi_idivmod __rt_sdiv18#endif1920.syntax unified21.text22DEFINE_CODE_STATE23.p2align 224DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)25#if defined(USE_THUMB_1)26push {r0, r1, lr}27bl SYMBOL_NAME(__divsi3)28pop {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom29muls r2, r0, r2 // r2 = quot * denom30subs r1, r1, r231JMP (r3)32#else // defined(USE_THUMB_1)33push { lr }34sub sp, sp, #435mov r2, sp36#if defined(__MINGW32__)37mov r3, r038mov r0, r139mov r1, r340#endif41bl SYMBOL_NAME(__divmodsi4)42ldr r1, [sp]43add sp, sp, #444pop { pc }45#endif // defined(USE_THUMB_1)46END_COMPILERRT_FUNCTION(__aeabi_idivmod)4748NO_EXEC_STACK_DIRECTIVE49505152