Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/compiler-rt/lib/builtins/arm/aeabi_idivmod.S
4396 views
1
//===-- aeabi_idivmod.S - EABI idivmod implementation ---------------------===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is dual licensed under the MIT and the University of Illinois Open
6
// Source Licenses. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#include "../assembly.h"
11
12
// struct { int quot, int rem} __aeabi_idivmod(int numerator, int denominator) {
13
// int rem, quot;
14
// quot = __divmodsi4(numerator, denominator, &rem);
15
// return {quot, rem};
16
// }
17
18
#if defined(_WIN32)
19
#define __aeabi_idivmod __rt_sdiv
20
#endif
21
22
.syntax unified
23
.text
24
DEFINE_CODE_STATE
25
.p2align 2
26
DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
27
#if defined(USE_THUMB_1)
28
push {r0, r1, lr}
29
bl SYMBOL_NAME(__divsi3)
30
pop {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom
31
muls r2, r0, r2 // r2 = quot * denom
32
subs r1, r1, r2
33
JMP (r3)
34
#else // defined(USE_THUMB_1)
35
push { lr }
36
sub sp, sp, #4
37
mov r2, sp
38
#if defined(_WIN32)
39
mov r3, r0
40
mov r0, r1
41
mov r1, r3
42
#endif
43
bl SYMBOL_NAME(__divmodsi4)
44
ldr r1, [sp]
45
add sp, sp, #4
46
pop { pc }
47
#endif // defined(USE_THUMB_1)
48
END_COMPILERRT_FUNCTION(__aeabi_idivmod)
49
50
NO_EXEC_STACK_DIRECTIVE
51
52