lib1funcs.S revision 1.1.1.7 1 /* Library functions.
2 Copyright (C) 2000-2018 Free Software Foundation, Inc.
3 Contributed by Red Hat, Inc.
4
5 This file is part of GCC.
6
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 3, or (at your option)
10 any later version.
11
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.
16
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
20
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
25
26 #include <frv-asm.h>
27
28
29 #ifdef L_cmpll
31 /* icc0 = __cmpll (long long a, long long b) */
32
33 .globl EXT(__cmpll)
34 .type EXT(__cmpll),@function
35 .text
36 .p2align 4
37 EXT(__cmpll):
38 cmp gr8, gr10, icc0
39 ckeq icc0, cc4
40 P(ccmp) gr9, gr11, cc4, 1
41 ret
42 .Lend:
43 .size EXT(__cmpll),.Lend-EXT(__cmpll)
44 #endif /* L_cmpll */
45
46 #ifdef L_cmpf
48 /* icc0 = __cmpf (float a, float b) */
49 /* Note, because this function returns the result in ICC0, it means it can't
50 handle NaNs. */
51
52 .globl EXT(__cmpf)
53 .type EXT(__cmpf),@function
54 .text
55 .p2align 4
56 EXT(__cmpf):
57 #ifdef __FRV_HARD_FLOAT__ /* floating point instructions available */
58 movgf gr8, fr0
59 P(movgf) gr9, fr1
60 setlos #1, gr8
61 fcmps fr0, fr1, fcc0
62 P(fcklt) fcc0, cc0
63 fckeq fcc0, cc1
64 csub gr0, gr8, gr8, cc0, 1
65 cmov gr0, gr8, cc1, 1
66 cmpi gr8, 0, icc0
67 ret
68 #else /* no floating point instructions available */
69 movsg lr, gr4
70 addi sp, #-16, sp
71 sti gr4, @(sp, 8)
72 st fp, @(sp, gr0)
73 mov sp, fp
74 call EXT(__cmpsf2)
75 cmpi gr8, #0, icc0
76 ldi @(sp, 8), gr4
77 movgs gr4, lr
78 ld @(sp,gr0), fp
79 addi sp, #16, sp
80 ret
81 #endif
82 .Lend:
83 .size EXT(__cmpf),.Lend-EXT(__cmpf)
84 #endif
85
86 #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
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
108 ret
109 .Lend:
110 .size EXT(__cmpd),.Lend-EXT(__cmpd)
111 #endif
112
113 #ifdef L_addll
115 /* gr8,gr9 = __addll (long long a, long long b) */
116 /* Note, gcc will never call this function, but it is present in case an
117 ABI program calls it. */
118
119 .globl EXT(__addll)
120 .type EXT(__addll),@function
121 .text
122 .p2align
123 EXT(__addll):
124 addcc gr9, gr11, gr9, icc0
125 addx gr8, gr10, gr8, icc0
126 ret
127 .Lend:
128 .size EXT(__addll),.Lend-EXT(__addll)
129 #endif
130
131 #ifdef L_subll
133 /* gr8,gr9 = __subll (long long a, long long b) */
134 /* Note, gcc will never call this function, but it is present in case an
135 ABI program calls it. */
136
137 .globl EXT(__subll)
138 .type EXT(__subll),@function
139 .text
140 .p2align 4
141 EXT(__subll):
142 subcc gr9, gr11, gr9, icc0
143 subx gr8, gr10, gr8, icc0
144 ret
145 .Lend:
146 .size EXT(__subll),.Lend-EXT(__subll)
147 #endif
148
149 #ifdef L_andll
151 /* gr8,gr9 = __andll (long long a, long long b) */
152 /* Note, gcc will never call this function, but it is present in case an
153 ABI program calls it. */
154
155 .globl EXT(__andll)
156 .type EXT(__andll),@function
157 .text
158 .p2align 4
159 EXT(__andll):
160 P(and) gr9, gr11, gr9
161 P2(and) gr8, gr10, gr8
162 ret
163 .Lend:
164 .size EXT(__andll),.Lend-EXT(__andll)
165 #endif
166
167 #ifdef L_orll
169 /* gr8,gr9 = __orll (long long a, long long b) */
170 /* Note, gcc will never call this function, but it is present in case an
171 ABI program calls it. */
172
173 .globl EXT(__orll)
174 .type EXT(__orll),@function
175 .text
176 .p2align 4
177 EXT(__orll):
178 P(or) gr9, gr11, gr9
179 P2(or) gr8, gr10, gr8
180 ret
181 .Lend:
182 .size EXT(__orll),.Lend-EXT(__orll)
183 #endif
184
185 #ifdef L_xorll
187 /* gr8,gr9 = __xorll (long long a, long long b) */
188 /* Note, gcc will never call this function, but it is present in case an
189 ABI program calls it. */
190
191 .globl EXT(__xorll)
192 .type EXT(__xorll),@function
193 .text
194 .p2align 4
195 EXT(__xorll):
196 P(xor) gr9, gr11, gr9
197 P2(xor) gr8, gr10, gr8
198 ret
199 .Lend:
200 .size EXT(__xorll),.Lend-EXT(__xorll)
201 #endif
202
203 #ifdef L_notll
205 /* gr8,gr9 = __notll (long long a) */
206 /* Note, gcc will never call this function, but it is present in case an
207 ABI program calls it. */
208
209 .globl EXT(__notll)
210 .type EXT(__notll),@function
211 .text
212 .p2align 4
213 EXT(__notll):
214 P(not) gr9, gr9
215 P2(not) gr8, gr8
216 ret
217 .Lend:
218 .size EXT(__notll),.Lend-EXT(__notll)
219 #endif
220
221 #ifdef L_cmov
223 /* (void) __cmov (char *dest, const char *src, size_t len) */
224 /*
225 * void __cmov (char *dest, const char *src, size_t len)
226 * {
227 * size_t i;
228 *
229 * if (dest < src || dest > src+len)
230 * {
231 * for (i = 0; i < len; i++)
232 * dest[i] = src[i];
233 * }
234 * else
235 * {
236 * while (len-- > 0)
237 * dest[len] = src[len];
238 * }
239 * }
240 */
241
242 .globl EXT(__cmov)
243 .type EXT(__cmov),@function
244 .text
245 .p2align 4
246 EXT(__cmov):
247 P(cmp) gr8, gr9, icc0
248 add gr9, gr10, gr4
249 P(cmp) gr8, gr4, icc1
250 bc icc0, 0, .Lfwd
251 bls icc1, 0, .Lback
252 .Lfwd:
253 /* move bytes in a forward direction */
254 P(setlos) #0, gr5
255 cmp gr0, gr10, icc0
256 P(subi) gr9, #1, gr9
257 P2(subi) gr8, #1, gr8
258 bnc icc0, 0, .Lret
259 .Lfloop:
260 /* forward byte move loop */
261 addi gr5, #1, gr5
262 P(ldsb) @(gr9, gr5), gr4
263 cmp gr5, gr10, icc0
264 P(stb) gr4, @(gr8, gr5)
265 bc icc0, 0, .Lfloop
266 ret
267 .Lbloop:
268 /* backward byte move loop body */
269 ldsb @(gr9,gr10),gr4
270 stb gr4,@(gr8,gr10)
271 .Lback:
272 P(cmpi) gr10, #0, icc0
273 addi gr10, #-1, gr10
274 bne icc0, 0, .Lbloop
275 .Lret:
276 ret
277 .Lend:
278 .size EXT(__cmov),.Lend-EXT(__cmov)
279 #endif
280