]>
Commit | Line | Data |
---|---|---|
b3f8d95d MM |
1 | /* Miscellaneous BPABI functions. |
2 | ||
748086b7 | 3 | Copyright (C) 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc. |
b3f8d95d MM |
4 | Contributed by CodeSourcery, LLC. |
5 | ||
6 | This file is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU General Public License as published by the | |
748086b7 | 8 | Free Software Foundation; either version 3, or (at your option) any |
b3f8d95d MM |
9 | later version. |
10 | ||
b3f8d95d MM |
11 | This file is distributed in the hope that it will be useful, but |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | General Public License for more details. | |
15 | ||
748086b7 JJ |
16 | Under Section 7 of GPL version 3, you are granted additional |
17 | permissions described in the GCC Runtime Library Exception, version | |
18 | 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | You should have received a copy of the GNU General Public License and | |
21 | a copy of the GCC Runtime Library Exception along with this program; | |
22 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | <http://www.gnu.org/licenses/>. */ | |
b3f8d95d | 24 | |
b3f8d95d MM |
25 | #ifdef L_aeabi_lcmp |
26 | ||
27 | ARM_FUNC_START aeabi_lcmp | |
ad1ec76f PB |
28 | cmp xxh, yyh |
29 | do_it lt | |
30 | movlt r0, #-1 | |
31 | do_it gt | |
32 | movgt r0, #1 | |
33 | do_it ne | |
34 | RETc(ne) | |
35 | subs r0, xxl, yyl | |
36 | do_it lo | |
37 | movlo r0, #-1 | |
38 | do_it hi | |
39 | movhi r0, #1 | |
b3f8d95d MM |
40 | RET |
41 | FUNC_END aeabi_lcmp | |
42 | ||
43 | #endif /* L_aeabi_lcmp */ | |
44 | ||
45 | #ifdef L_aeabi_ulcmp | |
46 | ||
47 | ARM_FUNC_START aeabi_ulcmp | |
48 | cmp xxh, yyh | |
5b3e6663 | 49 | do_it lo |
b3f8d95d | 50 | movlo r0, #-1 |
5b3e6663 | 51 | do_it hi |
b3f8d95d | 52 | movhi r0, #1 |
5b3e6663 | 53 | do_it ne |
b3f8d95d MM |
54 | RETc(ne) |
55 | cmp xxl, yyl | |
5b3e6663 | 56 | do_it lo |
b3f8d95d | 57 | movlo r0, #-1 |
5b3e6663 | 58 | do_it hi |
b3f8d95d | 59 | movhi r0, #1 |
5b3e6663 | 60 | do_it eq |
b3f8d95d MM |
61 | moveq r0, #0 |
62 | RET | |
63 | FUNC_END aeabi_ulcmp | |
64 | ||
65 | #endif /* L_aeabi_ulcmp */ | |
66 | ||
0c23e1be JB |
67 | .macro test_div_by_zero signed |
68 | /* Tail-call to divide-by-zero handlers which may be overridden by the user, | |
69 | so unwinding works properly. */ | |
70 | #if defined(__thumb2__) | |
71 | cbnz yyh, 1f | |
72 | cbnz yyl, 1f | |
73 | cmp xxh, #0 | |
74 | do_it eq | |
75 | cmpeq xxl, #0 | |
76 | .ifc \signed, unsigned | |
77 | beq 2f | |
78 | mov xxh, #0xffffffff | |
79 | mov xxl, xxh | |
80 | 2: | |
81 | .else | |
82 | do_it lt, t | |
83 | movlt xxl, #0 | |
84 | movlt xxh, #0x80000000 | |
85 | do_it gt, t | |
86 | movgt xxh, #0x7fffffff | |
87 | movgt xxl, #0xffffffff | |
88 | .endif | |
89 | b SYM (__aeabi_ldiv0) __PLT__ | |
90 | 1: | |
91 | #else | |
92 | /* Note: Thumb-1 code calls via an ARM shim on processors which | |
93 | support ARM mode. */ | |
94 | cmp yyh, #0 | |
95 | cmpeq yyl, #0 | |
96 | bne 2f | |
97 | cmp xxh, #0 | |
98 | cmpeq xxl, #0 | |
99 | .ifc \signed, unsigned | |
100 | movne xxh, #0xffffffff | |
101 | movne xxl, #0xffffffff | |
102 | .else | |
103 | movlt xxh, #0x80000000 | |
104 | movlt xxl, #0 | |
105 | movgt xxh, #0x7fffffff | |
106 | movgt xxl, #0xffffffff | |
107 | .endif | |
108 | b SYM (__aeabi_ldiv0) __PLT__ | |
109 | 2: | |
110 | #endif | |
111 | .endm | |
112 | ||
b3f8d95d MM |
113 | #ifdef L_aeabi_ldivmod |
114 | ||
115 | ARM_FUNC_START aeabi_ldivmod | |
0c23e1be JB |
116 | test_div_by_zero signed |
117 | ||
b3f8d95d | 118 | sub sp, sp, #8 |
5b3e6663 PB |
119 | #if defined(__thumb2__) |
120 | mov ip, sp | |
121 | push {ip, lr} | |
122 | #else | |
123 | do_push {sp, lr} | |
124 | #endif | |
b3f8d95d MM |
125 | bl SYM(__gnu_ldivmod_helper) __PLT__ |
126 | ldr lr, [sp, #4] | |
127 | add sp, sp, #8 | |
5b3e6663 | 128 | do_pop {r2, r3} |
b3f8d95d MM |
129 | RET |
130 | ||
131 | #endif /* L_aeabi_ldivmod */ | |
132 | ||
133 | #ifdef L_aeabi_uldivmod | |
134 | ||
135 | ARM_FUNC_START aeabi_uldivmod | |
0c23e1be JB |
136 | test_div_by_zero unsigned |
137 | ||
b3f8d95d | 138 | sub sp, sp, #8 |
5b3e6663 PB |
139 | #if defined(__thumb2__) |
140 | mov ip, sp | |
141 | push {ip, lr} | |
142 | #else | |
143 | do_push {sp, lr} | |
144 | #endif | |
b3f8d95d MM |
145 | bl SYM(__gnu_uldivmod_helper) __PLT__ |
146 | ldr lr, [sp, #4] | |
147 | add sp, sp, #8 | |
5b3e6663 | 148 | do_pop {r2, r3} |
b3f8d95d MM |
149 | RET |
150 | ||
151 | #endif /* L_aeabi_divmod */ | |
152 |