summaryrefslogtreecommitdiff
path: root/gcc/config/frv/lib1funcs.asm
blob: 87666f48dc06c66c9cfbfe35ad6051befef64955 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/* Library functions.
   Copyright (C) 2000, 2003 Free Software Foundation, Inc.
   Contributed by Red Hat, Inc.
  
   This file is part of GCC.
  
   GCC is free software ; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation * either version 2, or (at your option)
   any later version.
  
   GCC is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY ; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
  
   You should have received a copy of the GNU General Public License
   along with GCC; see the file COPYING.  If not, write to
   the Free Software Foundation, 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* As a special exception, if you link this library with other files,
   some of which are compiled with GCC, to produce an executable,
   this library does not by itself cause the resulting executable
   to be covered by the GNU General Public License.
   This exception does not however invalidate any other reasons why
   the executable file might be covered by the GNU General Public License.  */

#include <frv-asm.h>


#ifdef L_cmpll
/* icc0 = __cmpll (long long a, long long b)  */

	.file	"_cmpll.s"
	.globl	EXT(__cmpll)
	.type	EXT(__cmpll),@function
	.text
	.p2align 4
EXT(__cmpll):
	cmp	gr8, gr10, icc0
	ckeq	icc0, cc4
	P(ccmp)	gr9, gr11, cc4, 1
	ret
.Lend:
	.size	EXT(__cmpll),.Lend-EXT(__cmpll)
#endif /* L_cmpll */

#ifdef L_cmpf
/* icc0 = __cmpf (float a, float b) */
/* Note, because this function returns the result in ICC0, it means it can't
   handle NaNs.  */

	.file	"_cmpf.s"
	.globl	EXT(__cmpf)
	.type	EXT(__cmpf),@function
	.text
	.p2align 4
EXT(__cmpf):
#ifdef __FRV_HARD_FLOAT__	/* floating point instructions available */
	movgf	gr8, fr0
	P(movgf) gr9, fr1
	setlos	#1, gr8
	fcmps	fr0, fr1, fcc0
	P(fcklt) fcc0, cc0
	fckeq	fcc0, cc1
	csub	gr0, gr8, gr8, cc0, 1
	cmov	gr0, gr8, cc1, 1
	cmpi	gr8, 0, icc0
	ret
#else				/* no floating point instructions available */
	movsg	lr, gr4
	addi	sp, #-16, sp
	sti	gr4, @(sp, 8)
	st	fp, @(sp, gr0)
	mov	sp, fp
	call	EXT(__cmpsf2)
	cmpi	gr8, #0, icc0
	ldi	@(sp, 8), gr4
	movgs	gr4, lr
	ld	@(sp,gr0), fp
	addi	sp, #16, sp
	ret
#endif
.Lend:
	.size	EXT(__cmpf),.Lend-EXT(__cmpf)
#endif

#ifdef L_cmpd
/* icc0 = __cmpd (double a, double b) */
/* Note, because this function returns the result in ICC0, it means it can't
   handle NaNs.  */

	.file	"_cmpd.s"
	.globl	EXT(__cmpd)
	.type	EXT(__cmpd),@function
	.text
	.p2align 4
EXT(__cmpd):
	movsg	lr, gr4
	addi	sp, #-16, sp
	sti	gr4, @(sp, 8)
	st	fp, @(sp, gr0)
	mov	sp, fp
	call	EXT(__cmpdf2)
	cmpi	gr8, #0, icc0
	ldi	@(sp, 8), gr4
	movgs	gr4, lr
	ld	@(sp,gr0), fp
	addi	sp, #16, sp
	ret
.Lend:
	.size	EXT(__cmpd),.Lend-EXT(__cmpd)
#endif

#ifdef L_addll
/* gr8,gr9 = __addll (long long a, long long b) */
/* Note, gcc will never call this function, but it is present in case an
   ABI program calls it.  */

	.file	"_addll.s"
	.globl	EXT(__addll)
	.type	EXT(__addll),@function
	.text
	.p2align
EXT(__addll):
	addcc	gr9, gr11, gr9, icc0
	addx	gr8, gr10, gr8, icc0
	ret
.Lend:
	.size	EXT(__addll),.Lend-EXT(__addll)
#endif

#ifdef L_subll
/* gr8,gr9 = __subll (long long a, long long b) */
/* Note, gcc will never call this function, but it is present in case an
   ABI program calls it.  */

	.file	"_subll.s"
	.globl	EXT(__subll)
	.type	EXT(__subll),@function
	.text
	.p2align 4
EXT(__subll):
	subcc	gr9, gr11, gr9, icc0
	subx	gr8, gr10, gr8, icc0
	ret
.Lend:
	.size	EXT(__subll),.Lend-EXT(__subll)
#endif

#ifdef L_andll
/* gr8,gr9 = __andll (long long a, long long b) */
/* Note, gcc will never call this function, but it is present in case an
   ABI program calls it.  */

	.file	"_andll.s"
	.globl	EXT(__andll)
	.type	EXT(__andll),@function
	.text
	.p2align 4
EXT(__andll):
	P(and)	gr9, gr11, gr9
	P2(and)	gr8, gr10, gr8
	ret
.Lend:
	.size	EXT(__andll),.Lend-EXT(__andll)
#endif

#ifdef L_orll
/* gr8,gr9 = __orll (long long a, long long b) */
/* Note, gcc will never call this function, but it is present in case an
   ABI program calls it.  */

	.file	"_orll.s"
	.globl	EXT(__orll)
	.type	EXT(__orll),@function
	.text
	.p2align 4
EXT(__orll):
	P(or)	gr9, gr11, gr9
	P2(or)	gr8, gr10, gr8
	ret
.Lend:
	.size	EXT(__orll),.Lend-EXT(__orll)
#endif

#ifdef L_xorll
/* gr8,gr9 = __xorll (long long a, long long b) */
/* Note, gcc will never call this function, but it is present in case an
   ABI program calls it.  */

	.file	"_xorll.s"
	.globl	EXT(__xorll)
	.type	EXT(__xorll),@function
	.text
	.p2align 4
EXT(__xorll):
	P(xor)	gr9, gr11, gr9
	P2(xor)	gr8, gr10, gr8
	ret
.Lend:
	.size	EXT(__xorll),.Lend-EXT(__xorll)
#endif

#ifdef L_notll
/* gr8,gr9 = __notll (long long a) */
/* Note, gcc will never call this function, but it is present in case an
   ABI program calls it.  */

	.file	"_notll.s"
	.globl	EXT(__notll)
	.type	EXT(__notll),@function
	.text
	.p2align 4
EXT(__notll):
	P(not)	gr9, gr9
	P2(not)	gr8, gr8
	ret
.Lend:
	.size	EXT(__notll),.Lend-EXT(__notll)
#endif

#ifdef L_cmov
/* (void) __cmov (char *dest, const char *src, size_t len) */
/*
 * void __cmov (char *dest, const char *src, size_t len)
 * {
 *   size_t i;
 * 
 *   if (dest < src || dest > src+len)
 *     {
 *	 for (i = 0; i < len; i++)
 *	 dest[i] = src[i];
 *     }
 *   else
 *     {
 *	 while (len-- > 0)
 *	 dest[len] = src[len];
 *     }
 * }
 */

	.file	"_cmov.s"
	.globl	EXT(__cmov)
	.type	EXT(__cmov),@function
	.text
	.p2align 4
EXT(__cmov):
	P(cmp)	gr8, gr9, icc0
	add	gr9, gr10, gr4
	P(cmp)	gr8, gr4, icc1
	bc	icc0, 0, .Lfwd
	bls	icc1, 0, .Lback
.Lfwd:
	/* move bytes in a forward direction */
	P(setlos) #0, gr5
	cmp	gr0, gr10, icc0
	P(subi)	gr9, #1, gr9
	P2(subi) gr8, #1, gr8
	bnc	icc0, 0, .Lret
.Lfloop:
	/* forward byte move loop */
	addi	gr5, #1, gr5
	P(ldsb)	@(gr9, gr5), gr4
	cmp	gr5, gr10, icc0
	P(stb)	gr4, @(gr8, gr5)
	bc	icc0, 0, .Lfloop
	ret
.Lbloop:
	/* backward byte move loop body */
	ldsb	@(gr9,gr10),gr4
	stb	gr4,@(gr8,gr10)
.Lback:
	P(cmpi)	gr10, #0, icc0
	addi	gr10, #-1, gr10
	bne	icc0, 0, .Lbloop
.Lret:
	ret
.Lend:
	.size	 EXT(__cmov),.Lend-EXT(__cmov)
#endif