OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / config / arm / bpabi-v6m.S
1 /* Miscellaneous BPABI functions.  ARMv6M implementation
2
3    Copyright (C) 2006, 2008  Free Software Foundation, Inc.
4    Contributed by CodeSourcery.
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
8    Free Software Foundation; either version 2, or (at your option) any
9    later version.
10
11    In addition to the permissions in the GNU General Public License, the
12    Free Software Foundation gives you unlimited permission to link the
13    compiled version of this file into combinations with other programs,
14    and to distribute those combinations without any restriction coming
15    from the use of this file.  (The General Public License restrictions
16    do apply in other respects; for example, they cover modification of
17    the file, and distribution when not linked into a combine
18    executable.)
19
20    This file is distributed in the hope that it will be useful, but
21    WITHOUT ANY WARRANTY; without even the implied warranty of
22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23    General Public License for more details.
24
25    You should have received a copy of the GNU General Public License
26    along with this program; see the file COPYING.  If not, write to
27    the Free Software Foundation, 51 Franklin Street, Fifth Floor,
28    Boston, MA 02110-1301, USA.  */
29
30 #ifdef L_aeabi_lcmp
31
32 FUNC_START aeabi_lcmp
33         cmp     xxh, yyh
34         beq     1f
35         bgt     2f
36         mov     r0, #1
37         neg     r0, r0
38         RET
39 2:
40         mov     r0, #1
41         RET
42 1:
43         sub     r0, xxl, yyl
44         beq     1f
45         bhi     2f
46         mov     r0, #1
47         neg     r0, r0
48         RET
49 2:
50         mov     r0, #1
51 1:
52         RET
53         FUNC_END aeabi_lcmp
54
55 #endif /* L_aeabi_lcmp */
56         
57 #ifdef L_aeabi_ulcmp
58
59 FUNC_START aeabi_ulcmp
60         cmp     xxh, yyh
61         bne     1f
62         sub     r0, xxl, yyl
63         beq     2f
64 1:
65         bcs     1f
66         mov     r0, #1
67         neg     r0, r0
68         RET
69 1:
70         mov     r0, #1
71 2:
72         RET
73         FUNC_END aeabi_ulcmp
74
75 #endif /* L_aeabi_ulcmp */
76
77 #ifdef L_aeabi_ldivmod
78
79 FUNC_START aeabi_ldivmod
80         push {r0, r1}
81         mov r0, sp
82         push {r0, lr}
83         ldr r0, [sp, #8]
84         bl SYM(__gnu_ldivmod_helper)
85         ldr r3, [sp, #4]
86         mov lr, r3
87         add sp, sp, #8
88         pop {r2, r3}
89         RET
90         FUNC_END aeabi_ldivmod
91
92 #endif /* L_aeabi_ldivmod */
93
94 #ifdef L_aeabi_uldivmod
95
96 FUNC_START aeabi_uldivmod
97         push {r0, r1}
98         mov r0, sp
99         push {r0, lr}
100         ldr r0, [sp, #8]
101         bl SYM(__gnu_uldivmod_helper)
102         ldr r3, [sp, #4]
103         mov lr, r3
104         add sp, sp, #8
105         pop {r2, r3}
106         RET
107         FUNC_END aeabi_uldivmod
108         
109 #endif /* L_aeabi_uldivmod */
110
111 #ifdef L_arm_addsubsf3
112
113 FUNC_START aeabi_frsub
114
115       push      {r4, lr}
116       mov       r4, #1
117       lsl       r4, #31
118       eor       r0, r0, r4
119       bl        __aeabi_fadd
120       pop       {r4, pc}
121
122       FUNC_END aeabi_frsub
123
124 #endif /* L_arm_addsubsf3 */
125
126 #ifdef L_arm_cmpsf2
127
128 FUNC_START aeabi_cfrcmple
129
130         mov     ip, r0
131         mov     r0, r1
132         mov     r1, ip
133         b       6f
134
135 FUNC_START aeabi_cfcmpeq
136 FUNC_ALIAS aeabi_cfcmple aeabi_cfcmpeq
137
138         @ The status-returning routines are required to preserve all
139         @ registers except ip, lr, and cpsr.
140 6:      push    {r0, r1, r2, r3, r4, lr}
141         bl      __lesf2
142         @ Set the Z flag correctly, and the C flag unconditionally.
143         cmp     r0, #0
144         @ Clear the C flag if the return value was -1, indicating
145         @ that the first operand was smaller than the second.
146         bmi 1f
147         mov     r1, #0
148         cmn     r0, r1
149 1:
150         pop     {r0, r1, r2, r3, r4, pc}
151
152         FUNC_END aeabi_cfcmple
153         FUNC_END aeabi_cfcmpeq
154         FUNC_END aeabi_cfrcmple
155
156 FUNC_START      aeabi_fcmpeq
157
158         push    {r4, lr}
159         bl      __eqsf2
160         neg     r0, r0
161         add     r0, r0, #1
162         pop     {r4, pc}
163
164         FUNC_END aeabi_fcmpeq
165
166 .macro COMPARISON cond, helper, mode=sf2
167 FUNC_START      aeabi_fcmp\cond
168
169         push    {r4, lr}
170         bl      __\helper\mode
171         cmp     r0, #0
172         b\cond  1f
173         mov     r0, #0
174         pop     {r4, pc}
175 1:
176         mov     r0, #1
177         pop     {r4, pc}
178
179         FUNC_END aeabi_fcmp\cond
180 .endm
181
182 COMPARISON lt, le
183 COMPARISON le, le
184 COMPARISON gt, ge
185 COMPARISON ge, ge
186
187 #endif /* L_arm_cmpsf2 */
188
189 #ifdef L_arm_addsubdf3
190
191 FUNC_START aeabi_drsub
192
193       push      {r4, lr}
194       mov       r4, #1
195       lsl       r4, #31
196       eor       xxh, xxh, r4
197       bl        __aeabi_dadd
198       pop       {r4, pc}
199
200       FUNC_END aeabi_drsub
201
202 #endif /* L_arm_addsubdf3 */
203
204 #ifdef L_arm_cmpdf2
205
206 FUNC_START aeabi_cdrcmple
207
208         mov     ip, r0
209         mov     r0, r2
210         mov     r2, ip
211         mov     ip, r1
212         mov     r1, r3
213         mov     r3, ip
214         b       6f
215
216 FUNC_START aeabi_cdcmpeq
217 FUNC_ALIAS aeabi_cdcmple aeabi_cdcmpeq
218
219         @ The status-returning routines are required to preserve all
220         @ registers except ip, lr, and cpsr.
221 6:      push    {r0, r1, r2, r3, r4, lr}
222         bl      __ledf2
223         @ Set the Z flag correctly, and the C flag unconditionally.
224         cmp     r0, #0
225         @ Clear the C flag if the return value was -1, indicating
226         @ that the first operand was smaller than the second.
227         bmi 1f
228         mov     r1, #0
229         cmn     r0, r1
230 1:
231         pop     {r0, r1, r2, r3, r4, pc}
232
233         FUNC_END aeabi_cdcmple
234         FUNC_END aeabi_cdcmpeq
235         FUNC_END aeabi_cdrcmple
236
237 FUNC_START      aeabi_dcmpeq
238
239         push    {r4, lr}
240         bl      __eqdf2
241         neg     r0, r0
242         add     r0, r0, #1
243         pop     {r4, pc}
244
245         FUNC_END aeabi_dcmpeq
246
247 .macro COMPARISON cond, helper, mode=df2
248 FUNC_START      aeabi_dcmp\cond
249
250         push    {r4, lr}
251         bl      __\helper\mode
252         cmp     r0, #0
253         b\cond  1f
254         mov     r0, #0
255         pop     {r4, pc}
256 1:
257         mov     r0, #1
258         pop     {r4, pc}
259
260         FUNC_END aeabi_dcmp\cond
261 .endm
262
263 COMPARISON lt, le
264 COMPARISON le, le
265 COMPARISON gt, ge
266 COMPARISON ge, ge
267
268 #endif /* L_arm_cmpdf2 */