Merged revisions 143552,143554,143557,143560,143562,143564-143567,143570-143573,14357...
[official-gcc.git] / gcc / config / frv / lib1funcs.asm
blob9b8f553ac08c47fc3338add5fafa23008b5143d2
1 /* Library functions.
2 Copyright (C) 2000, 2003, 2008 Free Software Foundation, Inc.
3 Contributed by Red Hat, Inc.
5 This file is part of GCC.
7 GCC is free software ; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation * either version 2, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY ; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 /* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License. */
29 #include <frv-asm.h>
32 #ifdef L_cmpll
33 /* icc0 = __cmpll (long long a, long long b) */
35 .globl EXT(__cmpll)
36 .type EXT(__cmpll),@function
37 .text
38 .p2align 4
39 EXT(__cmpll):
40 cmp gr8, gr10, icc0
41 ckeq icc0, cc4
42 P(ccmp) gr9, gr11, cc4, 1
43 ret
44 .Lend:
45 .size EXT(__cmpll),.Lend-EXT(__cmpll)
46 #endif /* L_cmpll */
48 #ifdef L_cmpf
49 /* icc0 = __cmpf (float a, float b) */
50 /* Note, because this function returns the result in ICC0, it means it can't
51 handle NaNs. */
53 .globl EXT(__cmpf)
54 .type EXT(__cmpf),@function
55 .text
56 .p2align 4
57 EXT(__cmpf):
58 #ifdef __FRV_HARD_FLOAT__ /* floating point instructions available */
59 movgf gr8, fr0
60 P(movgf) gr9, fr1
61 setlos #1, gr8
62 fcmps fr0, fr1, fcc0
63 P(fcklt) fcc0, cc0
64 fckeq fcc0, cc1
65 csub gr0, gr8, gr8, cc0, 1
66 cmov gr0, gr8, cc1, 1
67 cmpi gr8, 0, icc0
68 ret
69 #else /* no floating point instructions available */
70 movsg lr, gr4
71 addi sp, #-16, sp
72 sti gr4, @(sp, 8)
73 st fp, @(sp, gr0)
74 mov sp, fp
75 call EXT(__cmpsf2)
76 cmpi gr8, #0, icc0
77 ldi @(sp, 8), gr4
78 movgs gr4, lr
79 ld @(sp,gr0), fp
80 addi sp, #16, sp
81 ret
82 #endif
83 .Lend:
84 .size EXT(__cmpf),.Lend-EXT(__cmpf)
85 #endif
87 #ifdef L_cmpd
88 /* icc0 = __cmpd (double a, double b) */
89 /* Note, because this function returns the result in ICC0, it means it can't
90 handle NaNs. */
92 .globl EXT(__cmpd)
93 .type EXT(__cmpd),@function
94 .text
95 .p2align 4
96 EXT(__cmpd):
97 movsg lr, gr4
98 addi sp, #-16, sp
99 sti gr4, @(sp, 8)
100 st fp, @(sp, gr0)
101 mov sp, fp
102 call EXT(__cmpdf2)
103 cmpi gr8, #0, icc0
104 ldi @(sp, 8), gr4
105 movgs gr4, lr
106 ld @(sp,gr0), fp
107 addi sp, #16, sp
109 .Lend:
110 .size EXT(__cmpd),.Lend-EXT(__cmpd)
111 #endif
113 #ifdef L_addll
114 /* gr8,gr9 = __addll (long long a, long long b) */
115 /* Note, gcc will never call this function, but it is present in case an
116 ABI program calls it. */
118 .globl EXT(__addll)
119 .type EXT(__addll),@function
120 .text
121 .p2align
122 EXT(__addll):
123 addcc gr9, gr11, gr9, icc0
124 addx gr8, gr10, gr8, icc0
126 .Lend:
127 .size EXT(__addll),.Lend-EXT(__addll)
128 #endif
130 #ifdef L_subll
131 /* gr8,gr9 = __subll (long long a, long long b) */
132 /* Note, gcc will never call this function, but it is present in case an
133 ABI program calls it. */
135 .globl EXT(__subll)
136 .type EXT(__subll),@function
137 .text
138 .p2align 4
139 EXT(__subll):
140 subcc gr9, gr11, gr9, icc0
141 subx gr8, gr10, gr8, icc0
143 .Lend:
144 .size EXT(__subll),.Lend-EXT(__subll)
145 #endif
147 #ifdef L_andll
148 /* gr8,gr9 = __andll (long long a, long long b) */
149 /* Note, gcc will never call this function, but it is present in case an
150 ABI program calls it. */
152 .globl EXT(__andll)
153 .type EXT(__andll),@function
154 .text
155 .p2align 4
156 EXT(__andll):
157 P(and) gr9, gr11, gr9
158 P2(and) gr8, gr10, gr8
160 .Lend:
161 .size EXT(__andll),.Lend-EXT(__andll)
162 #endif
164 #ifdef L_orll
165 /* gr8,gr9 = __orll (long long a, long long b) */
166 /* Note, gcc will never call this function, but it is present in case an
167 ABI program calls it. */
169 .globl EXT(__orll)
170 .type EXT(__orll),@function
171 .text
172 .p2align 4
173 EXT(__orll):
174 P(or) gr9, gr11, gr9
175 P2(or) gr8, gr10, gr8
177 .Lend:
178 .size EXT(__orll),.Lend-EXT(__orll)
179 #endif
181 #ifdef L_xorll
182 /* gr8,gr9 = __xorll (long long a, long long b) */
183 /* Note, gcc will never call this function, but it is present in case an
184 ABI program calls it. */
186 .globl EXT(__xorll)
187 .type EXT(__xorll),@function
188 .text
189 .p2align 4
190 EXT(__xorll):
191 P(xor) gr9, gr11, gr9
192 P2(xor) gr8, gr10, gr8
194 .Lend:
195 .size EXT(__xorll),.Lend-EXT(__xorll)
196 #endif
198 #ifdef L_notll
199 /* gr8,gr9 = __notll (long long a) */
200 /* Note, gcc will never call this function, but it is present in case an
201 ABI program calls it. */
203 .globl EXT(__notll)
204 .type EXT(__notll),@function
205 .text
206 .p2align 4
207 EXT(__notll):
208 P(not) gr9, gr9
209 P2(not) gr8, gr8
211 .Lend:
212 .size EXT(__notll),.Lend-EXT(__notll)
213 #endif
215 #ifdef L_cmov
216 /* (void) __cmov (char *dest, const char *src, size_t len) */
218 * void __cmov (char *dest, const char *src, size_t len)
220 * size_t i;
222 * if (dest < src || dest > src+len)
224 * for (i = 0; i < len; i++)
225 * dest[i] = src[i];
227 * else
229 * while (len-- > 0)
230 * dest[len] = src[len];
235 .globl EXT(__cmov)
236 .type EXT(__cmov),@function
237 .text
238 .p2align 4
239 EXT(__cmov):
240 P(cmp) gr8, gr9, icc0
241 add gr9, gr10, gr4
242 P(cmp) gr8, gr4, icc1
243 bc icc0, 0, .Lfwd
244 bls icc1, 0, .Lback
245 .Lfwd:
246 /* move bytes in a forward direction */
247 P(setlos) #0, gr5
248 cmp gr0, gr10, icc0
249 P(subi) gr9, #1, gr9
250 P2(subi) gr8, #1, gr8
251 bnc icc0, 0, .Lret
252 .Lfloop:
253 /* forward byte move loop */
254 addi gr5, #1, gr5
255 P(ldsb) @(gr9, gr5), gr4
256 cmp gr5, gr10, icc0
257 P(stb) gr4, @(gr8, gr5)
258 bc icc0, 0, .Lfloop
260 .Lbloop:
261 /* backward byte move loop body */
262 ldsb @(gr9,gr10),gr4
263 stb gr4,@(gr8,gr10)
264 .Lback:
265 P(cmpi) gr10, #0, icc0
266 addi gr10, #-1, gr10
267 bne icc0, 0, .Lbloop
268 .Lret:
270 .Lend:
271 .size EXT(__cmov),.Lend-EXT(__cmov)
272 #endif