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_uidivmod.S
4396 views
1
//===-- aeabi_uidivmod.S - EABI uidivmod 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 { unsigned quot, unsigned rem}
13
// __aeabi_uidivmod(unsigned numerator, unsigned denominator) {
14
// unsigned rem, quot;
15
// quot = __udivmodsi4(numerator, denominator, &rem);
16
// return {quot, rem};
17
// }
18
19
#if defined(_WIN32)
20
#define __aeabi_uidivmod __rt_udiv
21
#endif
22
23
.syntax unified
24
.text
25
DEFINE_CODE_STATE
26
.p2align 2
27
DEFINE_COMPILERRT_FUNCTION(__aeabi_uidivmod)
28
#if defined(USE_THUMB_1)
29
cmp r0, r1
30
bcc LOCAL_LABEL(case_denom_larger)
31
push {r0, r1, lr}
32
bl SYMBOL_NAME(__aeabi_uidiv)
33
pop {r1, r2, r3}
34
muls r2, r0, r2 // r2 = quot * denom
35
subs r1, r1, r2
36
JMP (r3)
37
LOCAL_LABEL(case_denom_larger):
38
movs r1, r0
39
movs r0, #0
40
JMP (lr)
41
#else // defined(USE_THUMB_1)
42
push { lr }
43
sub sp, sp, #4
44
mov r2, sp
45
#if defined(_WIN32)
46
mov r3, r0
47
mov r0, r1
48
mov r1, r3
49
#endif
50
bl SYMBOL_NAME(__udivmodsi4)
51
ldr r1, [sp]
52
add sp, sp, #4
53
pop { pc }
54
#endif
55
END_COMPILERRT_FUNCTION(__aeabi_uidivmod)
56
57
NO_EXEC_STACK_DIRECTIVE
58
59