aboutsummaryrefslogtreecommitdiff
path: root/sim/testsuite/mips/fpu64-ps.s
blob: ad493b8ac3104f02ba369bbe94297967c308167d (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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# mips test sanity, expected to pass.
# mach:	 mips64 sb1
# as:		-mabi=eabi
# ld:		-N -Ttext=0x80010000
# output:	*\\npass\\n

	.include "testutils.inc"

        .macro check_ps psval, upperval, lowerval
	.set push
	.set noreorder
	cvt.s.pu	$f0, \psval		# upper
	cvt.s.pl	$f2, \psval		# lower
	li.s		$f4, \upperval
	li.s		$f6, \lowerval
	c.eq.s		$fcc0, $f0, $f4
	bc1f		$fcc0, _fail
	 c.eq.s		$fcc0, $f2, $f6
	bc1f		$fcc0, _fail
	 nop
	.set pop
        .endm

	setup

	.set noreorder

	.ent DIAG
DIAG:

	# make sure that Status.FR and .CU1 are set.
	mfc0	$2, $12
	or	$2, $2, (1 << 26) | (1 << 29)
	mtc0	$2, $12


	writemsg "ldc1"

	.data
1:	.dword	0xc1a8000042200000		# -21.0, 40.0
	.text
	la	$2, 1b
	ldc1	$f8, 0($2)
	check_ps $f8, -21.0, 40.0


	writemsg "cvt.ps.s"

	li.s	$f10, 1.0
	li.s	$f12, 3.0
	cvt.ps.s $f8, $f10, $f12		# upper, lower
	check_ps $f8, 1.0, 3.0


	writemsg "cvt.ps.s, sdc1, copy, ldc1"

	.data
1:	.dword	0
	.dword	0
	.text
	la	$2, 1b
	li.s	$f12, -4.0
	li.s	$f14, 32.0
	cvt.ps.s $f10, $f12, $f14		# upper, lower
	sdc1	$f10, 8($2)
	lw	$3, 8($2)
	lw	$4, 12($2)
	sw	$3, 0($2)
	sw	$4, 4($2)
	ldc1	$f8, 0($2)
	check_ps $f8, -4.0, 32.0


	# Load some constants for later use

	li.s	$f10, 4.0
	li.s	$f12, 16.0
	cvt.ps.s $f20, $f10, $f12		# $f20: u=4.0, l=16.0

	li.s	$f10, -1.0
	li.s	$f12, 2.0
	cvt.ps.s $f22, $f10, $f12		# $f22: u=-1.0, l=2.0

	li.s	$f10, 17.0
	li.s	$f12, -8.0
	cvt.ps.s $f24, $f10, $f12		# $f24: u=17.0, l=-8.0


	writemsg "pll.ps"

	pll.ps	$f8, $f20, $f22
	check_ps $f8, 16.0, 2.0


	writemsg "plu.ps"

	plu.ps	$f8, $f20, $f22
	check_ps $f8, 16.0, -1.0


	writemsg "pul.ps"

	pul.ps	$f8, $f20, $f22
	check_ps $f8, 4.0, 2.0


	writemsg "puu.ps"

	puu.ps	$f8, $f20, $f22
	check_ps $f8, 4.0, -1.0


	writemsg "abs.ps"

	abs.ps	$f8, $f22
	check_ps $f8, 1.0, 2.0


	writemsg "mov.ps"

	mov.ps	$f8, $f22
	check_ps $f8, -1.0, 2.0


	writemsg "neg.ps"

	neg.ps	$f8, $f22
	check_ps $f8, 1.0, -2.0


	writemsg "add.ps"

	add.ps	$f8, $f20, $f22
	check_ps $f8, 3.0, 18.0


	writemsg "mul.ps"

	mul.ps	$f8, $f20, $f22
	check_ps $f8, -4.0, 32.0


	writemsg "sub.ps"

	sub.ps	$f8, $f20, $f22
	check_ps $f8, 5.0, 14.0


	writemsg "madd.ps"

	madd.ps	$f8, $f24, $f20, $f22
	check_ps $f8, 13.0, 24.0


	writemsg "msub.ps"

	msub.ps	$f8, $f24, $f20, $f22
	check_ps $f8, -21.0, 40.0


	writemsg "nmadd.ps"

	nmadd.ps $f8, $f24, $f20, $f22
	check_ps $f8, -13.0, -24.0


	writemsg "nmsub.ps"

	nmsub.ps $f8, $f24, $f20, $f22
	check_ps $f8, 21.0, -40.0


	writemsg "movn.ps (n)"

	li	$2, 0
	mov.ps	$f8, $f20
	movn.ps	$f8, $f22, $2		# doesn't move
	check_ps $f8, 4.0, 16.0


	writemsg "movn.ps (y)"

	li	$2, 1
	mov.ps	$f8, $f20
	movn.ps	$f8, $f22, $2		# does move
	check_ps $f8, -1.0, 2.0


	writemsg "movz.ps (y)"

	li	$2, 0
	mov.ps	$f8, $f20
	movz.ps	$f8, $f22, $2		# does move
	check_ps $f8, -1.0, 2.0


	writemsg "movz.ps (n)"

	li	$2, 1
	mov.ps	$f8, $f20
	movz.ps	$f8, $f22, $2		# doesn't move
	check_ps $f8, 4.0, 16.0


	writemsg "movf.ps (y,y)"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (1 << 25)
	xor	$2, $2, (1 << 23) | (1 << 25)
	ctc1	$2, $31			# clear fcc0, clear fcc1
	mov.ps	$f8, $f20
	movf.ps	$f8, $f22, $fcc0	# moves both halves
	check_ps $f8, -1.0, 2.0


	writemsg "movf.ps (y,n)"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (1 << 25)
	xor	$2, $2, (0 << 23) | (1 << 25)
	ctc1	$2, $31			# set fcc0, clear fcc1
	mov.ps	$f8, $f20
	movf.ps	$f8, $f22, $fcc0	# moves upper half only
	check_ps $f8, -1.0, 16.0


	writemsg "movf.ps (n,y)"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (1 << 25)
	xor	$2, $2, (1 << 23) | (0 << 25)
	ctc1	$2, $31			# clear fcc0, set fcc1
	mov.ps	$f8, $f20
	movf.ps	$f8, $f22, $fcc0	# moves lower half only
	check_ps $f8, 4.0, 2.0


	writemsg "movf.ps (n,n)"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (1 << 25)
	xor	$2, $2, (0 << 23) | (0 << 25)
	ctc1	$2, $31			# set fcc0, set fcc1
	mov.ps	$f8, $f20
	movf.ps	$f8, $f22, $fcc0	# doesn't move either half
	check_ps $f8, 4.0, 16.0


	writemsg "movt.ps (n,n)"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (1 << 25)
	xor	$2, $2, (1 << 23) | (1 << 25)
	ctc1	$2, $31			# clear fcc0, clear fcc1
	mov.ps	$f8, $f20
	movt.ps	$f8, $f22, $fcc0	# doesn't move either half
	check_ps $f8, 4.0, 16.0


	writemsg "movt.ps (n,y)"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (1 << 25)
	xor	$2, $2, (0 << 23) | (1 << 25)
	ctc1	$2, $31			# set fcc0, clear fcc1
	mov.ps	$f8, $f20
	movt.ps	$f8, $f22, $fcc0	# moves lower half only
	check_ps $f8, 4.0, 2.0


	writemsg "movt.ps (y,n)"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (1 << 25)
	xor	$2, $2, (1 << 23) | (0 << 25)
	ctc1	$2, $31			# clear fcc0, set fcc1
	mov.ps	$f8, $f20
	movt.ps	$f8, $f22, $fcc0	# moves upper half only
	check_ps $f8, -1.0, 16.0


	writemsg "movt.ps (y,y)"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (1 << 25)
	xor	$2, $2, (0 << 23) | (0 << 25)
	ctc1	$2, $31			# set fcc0, set fcc1
	mov.ps	$f8, $f20
	movt.ps	$f8, $f22, $fcc0	# moves both halves
	check_ps $f8, -1.0, 2.0


	writemsg "alnv.ps (aligned)"

	.data
1:	.dword	0xc1a8000042200000		# -21.0, 40.0
	.dword	0xc228000041a00000		# -42.0, 20.0
	.text
	la	$2, 1b
	li	$3, 0
	addu	$4, $3, 8
	luxc1	$f10, $3($2)
	luxc1	$f12, $4($2)
	alnv.ps	$f8, $f10, $f12, $3
	check_ps $f8, -21.0, 40.0


	writemsg "alnv.ps (unaligned)"

	.data
1:	.dword	0xc1a8000042200000		# -21.0, 40.0
	.dword	0xc228000041a00000		# -42.0, 20.0
	.hword	0x0001
	.text
	la	$2, 1b
	li	$3, 4
	addu	$4, $3, 8
	luxc1	$f10, $3($2)
	luxc1	$f12, $4($2)
	alnv.ps	$f8, $f10, $f12, $3

	lb	$5, 16($2)
	bnez	$5, 2f				# little endian
	 nop

	# big endian
	check_ps $f8, 40.0, -42.0
	b	3f
	 nop
2:
	# little endian
	check_ps $f8, 20.0, -21.0
3:


	# We test c.cond.ps only lightly, just to make sure it modifies
	# two bits and compares the halves separately.  Perhaps it should
	# be tested more thoroughly.

	writemsg "c.f.ps"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (0x7f << 25)
	ctc1	$2, $31			# set all fcc bits
	c.f.ps	$fcc0, $f8, $f8		# -> f, f
	bc1t	$fcc0, _fail
	 nop
	bc1t	$fcc1, _fail
	 nop

	
	writemsg "c.olt.ps"

	cfc1	$2, $31	
	or	$2, $2, (1 << 23) | (0x7f << 25)
	xor	$2, $2, (1 << 23) | (0x7f << 25)
	ctc1	$2, $31			# clear all fcc bits
	c.lt.ps $fcc0, $f22, $f24	# -> f, t
	bc1t	$fcc0, _fail
	 nop
	bc1f	$fcc1, _fail
	 nop
	

	pass

	.end DIAG