]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/frv/lib1funcs.asm
re PR testsuite/39696 (gcc.dg/tree-ssa/ssa-ccp-25.c scan-tree-dump doesn't work on...
[thirdparty/gcc.git] / gcc / config / frv / lib1funcs.asm
CommitLineData
36a05131 1/* Library functions.
66647d44 2 Copyright (C) 2000, 2003, 2008 Free Software Foundation, Inc.
36a05131
BS
3 Contributed by Red Hat, Inc.
4
7ec022b2 5 This file is part of GCC.
36a05131 6
7ec022b2 7 GCC is free software ; you can redistribute it and/or modify
36a05131
BS
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.
11
7ec022b2 12 GCC is distributed in the hope that it will be useful,
36a05131
BS
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.
16
17 You should have received a copy of the GNU General Public License
7ec022b2 18 along with GCC; see the file COPYING. If not, write to
39d14dda
KC
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
36a05131 21
00051260
JW
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. */
28
36a05131
BS
29#include <frv-asm.h>
30
31\f
32#ifdef L_cmpll
33/* icc0 = __cmpll (long long a, long long b) */
34
36a05131
BS
35 .globl EXT(__cmpll)
36 .type EXT(__cmpll),@function
37 .text
38 .p2align 4
39EXT(__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 */
47\f
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. */
52
36a05131
BS
53 .globl EXT(__cmpf)
54 .type EXT(__cmpf),@function
55 .text
56 .p2align 4
57EXT(__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
86\f
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. */
91
36a05131
BS
92 .globl EXT(__cmpd)
93 .type EXT(__cmpd),@function
94 .text
95 .p2align 4
96EXT(__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
108 ret
109.Lend:
110 .size EXT(__cmpd),.Lend-EXT(__cmpd)
111#endif
112\f
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. */
117
36a05131
BS
118 .globl EXT(__addll)
119 .type EXT(__addll),@function
120 .text
121 .p2align
122EXT(__addll):
123 addcc gr9, gr11, gr9, icc0
124 addx gr8, gr10, gr8, icc0
125 ret
126.Lend:
127 .size EXT(__addll),.Lend-EXT(__addll)
128#endif
129\f
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. */
134
36a05131
BS
135 .globl EXT(__subll)
136 .type EXT(__subll),@function
137 .text
138 .p2align 4
139EXT(__subll):
140 subcc gr9, gr11, gr9, icc0
141 subx gr8, gr10, gr8, icc0
142 ret
143.Lend:
144 .size EXT(__subll),.Lend-EXT(__subll)
145#endif
146\f
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. */
151
36a05131
BS
152 .globl EXT(__andll)
153 .type EXT(__andll),@function
154 .text
155 .p2align 4
156EXT(__andll):
157 P(and) gr9, gr11, gr9
158 P2(and) gr8, gr10, gr8
159 ret
160.Lend:
161 .size EXT(__andll),.Lend-EXT(__andll)
162#endif
163\f
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. */
168
36a05131
BS
169 .globl EXT(__orll)
170 .type EXT(__orll),@function
171 .text
172 .p2align 4
173EXT(__orll):
174 P(or) gr9, gr11, gr9
175 P2(or) gr8, gr10, gr8
176 ret
177.Lend:
178 .size EXT(__orll),.Lend-EXT(__orll)
179#endif
180\f
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. */
185
36a05131
BS
186 .globl EXT(__xorll)
187 .type EXT(__xorll),@function
188 .text
189 .p2align 4
190EXT(__xorll):
191 P(xor) gr9, gr11, gr9
192 P2(xor) gr8, gr10, gr8
193 ret
194.Lend:
195 .size EXT(__xorll),.Lend-EXT(__xorll)
196#endif
197\f
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. */
202
36a05131
BS
203 .globl EXT(__notll)
204 .type EXT(__notll),@function
205 .text
206 .p2align 4
207EXT(__notll):
208 P(not) gr9, gr9
209 P2(not) gr8, gr8
210 ret
211.Lend:
212 .size EXT(__notll),.Lend-EXT(__notll)
213#endif
214\f
215#ifdef L_cmov
216/* (void) __cmov (char *dest, const char *src, size_t len) */
217/*
218 * void __cmov (char *dest, const char *src, size_t len)
219 * {
220 * size_t i;
221 *
222 * if (dest < src || dest > src+len)
223 * {
224 * for (i = 0; i < len; i++)
225 * dest[i] = src[i];
226 * }
227 * else
228 * {
229 * while (len-- > 0)
230 * dest[len] = src[len];
231 * }
232 * }
233 */
234
36a05131
BS
235 .globl EXT(__cmov)
236 .type EXT(__cmov),@function
237 .text
238 .p2align 4
239EXT(__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
259 ret
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:
269 ret
270.Lend:
271 .size EXT(__cmov),.Lend-EXT(__cmov)
272#endif