1 //===-- aeabi_idivmod.S - EABI idivmod implementation ---------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "../assembly.h"
12 // struct { int quot, int rem} __aeabi_idivmod(int numerator, int denominator) {
14 // quot = __divmodsi4(numerator, denominator, &rem);
15 // return {quot, rem};
18 #if defined(__MINGW32__)
19 #define __aeabi_idivmod __rt_sdiv
25 #if defined(USE_THUMB_PROLOGUE)
29 #if defined(USE_THUMB_PROLOGUE)
30 DEFINE_COMPILERRT_THUMB_FUNCTION(__aeabi_idivmod)
32 DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
34 #if defined(USE_THUMB_1)
36 bl SYMBOL_NAME(__divsi3)
37 pop {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom
38 muls r2, r2, r0 // r2 = quot * denom
41 #else // defined(USE_THUMB_1)
45 #if defined(__MINGW32__)
50 bl SYMBOL_NAME(__divmodsi4)
54 #endif // defined(USE_THUMB_1)
55 END_COMPILERRT_FUNCTION(__aeabi_idivmod)
57 NO_EXEC_STACK_DIRECTIVE