1 //===-- aeabi_idivmod.S - EABI idivmod implementation ---------------------===//
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-exception
7 //===----------------------------------------------------------------------===//
9 #include "../assembly.h"
11 // struct { int quot, int rem} __aeabi_idivmod(int numerator, int denominator) {
13 // quot = __divmodsi4(numerator, denominator, &rem);
14 // return {quot, rem};
17 #if defined(__MINGW32__)
18 #define __aeabi_idivmod __rt_sdiv
25 DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
26 #if defined(USE_THUMB_1)
28 bl SYMBOL_NAME(__divsi3)
29 pop {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom
30 muls r2, r0, r2 // r2 = quot * denom
33 #else // defined(USE_THUMB_1)
37 #if defined(__MINGW32__)
42 bl SYMBOL_NAME(__divmodsi4)
46 #endif // defined(USE_THUMB_1)
47 END_COMPILERRT_FUNCTION(__aeabi_idivmod)
49 NO_EXEC_STACK_DIRECTIVE