1152661Sjhb# mips test sanity, expected to pass.
2152661Sjhb# mach:	 mips64 sb1
3152661Sjhb# as:		-mabi=eabi
4152661Sjhb# ld:		-N -Ttext=0x80010000
5152661Sjhb# output:	*\\npass\\n
6152865Sru
7152661Sjhb	.include "testutils.inc"
8152661Sjhb
9152661Sjhb        .macro check_ps psval, upperval, lowerval
10159537Simp	.set push
11159537Simp	.set noreorder
12159537Simp	cvt.s.pu	$f0, \psval		# upper
13159537Simp	cvt.s.pl	$f2, \psval		# lower
14159537Simp	li.s		$f4, \upperval
15	li.s		$f6, \lowerval
16	c.eq.s		$fcc0, $f0, $f4
17	bc1f		$fcc0, _fail
18	 c.eq.s		$fcc0, $f2, $f6
19	bc1f		$fcc0, _fail
20	 nop
21	.set pop
22        .endm
23
24	setup
25
26	.set noreorder
27
28	.ent DIAG
29DIAG:
30
31	# make sure that Status.FR and .CU1 are set.
32	mfc0	$2, $12
33	or	$2, $2, (1 << 26) | (1 << 29)
34	mtc0	$2, $12
35
36
37	writemsg "ldc1"
38
39	.data
401:	.dword	0xc1a8000042200000		# -21.0, 40.0
41	.text
42	la	$2, 1b
43	ldc1	$f8, 0($2)
44	check_ps $f8, -21.0, 40.0
45
46
47	writemsg "cvt.ps.s"
48
49	li.s	$f10, 1.0
50	li.s	$f12, 3.0
51	cvt.ps.s $f8, $f10, $f12		# upper, lower
52	check_ps $f8, 1.0, 3.0
53
54
55	writemsg "cvt.ps.s, sdc1, copy, ldc1"
56
57	.data
581:	.dword	0
59	.dword	0
60	.text
61	la	$2, 1b
62	li.s	$f12, -4.0
63	li.s	$f14, 32.0
64	cvt.ps.s $f10, $f12, $f14		# upper, lower
65	sdc1	$f10, 8($2)
66	lw	$3, 8($2)
67	lw	$4, 12($2)
68	sw	$3, 0($2)
69	sw	$4, 4($2)
70	ldc1	$f8, 0($2)
71	check_ps $f8, -4.0, 32.0
72
73
74	# Load some constants for later use
75
76	li.s	$f10, 4.0
77	li.s	$f12, 16.0
78	cvt.ps.s $f20, $f10, $f12		# $f20: u=4.0, l=16.0
79
80	li.s	$f10, -1.0
81	li.s	$f12, 2.0
82	cvt.ps.s $f22, $f10, $f12		# $f22: u=-1.0, l=2.0
83
84	li.s	$f10, 17.0
85	li.s	$f12, -8.0
86	cvt.ps.s $f24, $f10, $f12		# $f24: u=17.0, l=-8.0
87
88
89	writemsg "pll.ps"
90
91	pll.ps	$f8, $f20, $f22
92	check_ps $f8, 16.0, 2.0
93
94
95	writemsg "plu.ps"
96
97	plu.ps	$f8, $f20, $f22
98	check_ps $f8, 16.0, -1.0
99
100
101	writemsg "pul.ps"
102
103	pul.ps	$f8, $f20, $f22
104	check_ps $f8, 4.0, 2.0
105
106
107	writemsg "puu.ps"
108
109	puu.ps	$f8, $f20, $f22
110	check_ps $f8, 4.0, -1.0
111
112
113	writemsg "abs.ps"
114
115	abs.ps	$f8, $f22
116	check_ps $f8, 1.0, 2.0
117
118
119	writemsg "mov.ps"
120
121	mov.ps	$f8, $f22
122	check_ps $f8, -1.0, 2.0
123
124
125	writemsg "neg.ps"
126
127	neg.ps	$f8, $f22
128	check_ps $f8, 1.0, -2.0
129
130
131	writemsg "add.ps"
132
133	add.ps	$f8, $f20, $f22
134	check_ps $f8, 3.0, 18.0
135
136
137	writemsg "mul.ps"
138
139	mul.ps	$f8, $f20, $f22
140	check_ps $f8, -4.0, 32.0
141
142
143	writemsg "sub.ps"
144
145	sub.ps	$f8, $f20, $f22
146	check_ps $f8, 5.0, 14.0
147
148
149	writemsg "madd.ps"
150
151	madd.ps	$f8, $f24, $f20, $f22
152	check_ps $f8, 13.0, 24.0
153
154
155	writemsg "msub.ps"
156
157	msub.ps	$f8, $f24, $f20, $f22
158	check_ps $f8, -21.0, 40.0
159
160
161	writemsg "nmadd.ps"
162
163	nmadd.ps $f8, $f24, $f20, $f22
164	check_ps $f8, -13.0, -24.0
165
166
167	writemsg "nmsub.ps"
168
169	nmsub.ps $f8, $f24, $f20, $f22
170	check_ps $f8, 21.0, -40.0
171
172
173	writemsg "movn.ps (n)"
174
175	li	$2, 0
176	mov.ps	$f8, $f20
177	movn.ps	$f8, $f22, $2		# doesn't move
178	check_ps $f8, 4.0, 16.0
179
180
181	writemsg "movn.ps (y)"
182
183	li	$2, 1
184	mov.ps	$f8, $f20
185	movn.ps	$f8, $f22, $2		# does move
186	check_ps $f8, -1.0, 2.0
187
188
189	writemsg "movz.ps (y)"
190
191	li	$2, 0
192	mov.ps	$f8, $f20
193	movz.ps	$f8, $f22, $2		# does move
194	check_ps $f8, -1.0, 2.0
195
196
197	writemsg "movz.ps (n)"
198
199	li	$2, 1
200	mov.ps	$f8, $f20
201	movz.ps	$f8, $f22, $2		# doesn't move
202	check_ps $f8, 4.0, 16.0
203
204
205	writemsg "movf.ps (y,y)"
206
207	cfc1	$2, $31
208	or	$2, $2, (1 << 23) | (1 << 25)
209	xor	$2, $2, (1 << 23) | (1 << 25)
210	ctc1	$2, $31			# clear fcc0, clear fcc1
211	mov.ps	$f8, $f20
212	movf.ps	$f8, $f22, $fcc0	# moves both halves
213	check_ps $f8, -1.0, 2.0
214
215
216	writemsg "movf.ps (y,n)"
217
218	cfc1	$2, $31
219	or	$2, $2, (1 << 23) | (1 << 25)
220	xor	$2, $2, (0 << 23) | (1 << 25)
221	ctc1	$2, $31			# set fcc0, clear fcc1
222	mov.ps	$f8, $f20
223	movf.ps	$f8, $f22, $fcc0	# moves upper half only
224	check_ps $f8, -1.0, 16.0
225
226
227	writemsg "movf.ps (n,y)"
228
229	cfc1	$2, $31
230	or	$2, $2, (1 << 23) | (1 << 25)
231	xor	$2, $2, (1 << 23) | (0 << 25)
232	ctc1	$2, $31			# clear fcc0, set fcc1
233	mov.ps	$f8, $f20
234	movf.ps	$f8, $f22, $fcc0	# moves lower half only
235	check_ps $f8, 4.0, 2.0
236
237
238	writemsg "movf.ps (n,n)"
239
240	cfc1	$2, $31
241	or	$2, $2, (1 << 23) | (1 << 25)
242	xor	$2, $2, (0 << 23) | (0 << 25)
243	ctc1	$2, $31			# set fcc0, set fcc1
244	mov.ps	$f8, $f20
245	movf.ps	$f8, $f22, $fcc0	# doesn't move either half
246	check_ps $f8, 4.0, 16.0
247
248
249	writemsg "movt.ps (n,n)"
250
251	cfc1	$2, $31
252	or	$2, $2, (1 << 23) | (1 << 25)
253	xor	$2, $2, (1 << 23) | (1 << 25)
254	ctc1	$2, $31			# clear fcc0, clear fcc1
255	mov.ps	$f8, $f20
256	movt.ps	$f8, $f22, $fcc0	# doesn't move either half
257	check_ps $f8, 4.0, 16.0
258
259
260	writemsg "movt.ps (n,y)"
261
262	cfc1	$2, $31
263	or	$2, $2, (1 << 23) | (1 << 25)
264	xor	$2, $2, (0 << 23) | (1 << 25)
265	ctc1	$2, $31			# set fcc0, clear fcc1
266	mov.ps	$f8, $f20
267	movt.ps	$f8, $f22, $fcc0	# moves lower half only
268	check_ps $f8, 4.0, 2.0
269
270
271	writemsg "movt.ps (y,n)"
272
273	cfc1	$2, $31
274	or	$2, $2, (1 << 23) | (1 << 25)
275	xor	$2, $2, (1 << 23) | (0 << 25)
276	ctc1	$2, $31			# clear fcc0, set fcc1
277	mov.ps	$f8, $f20
278	movt.ps	$f8, $f22, $fcc0	# moves upper half only
279	check_ps $f8, -1.0, 16.0
280
281
282	writemsg "movt.ps (y,y)"
283
284	cfc1	$2, $31
285	or	$2, $2, (1 << 23) | (1 << 25)
286	xor	$2, $2, (0 << 23) | (0 << 25)
287	ctc1	$2, $31			# set fcc0, set fcc1
288	mov.ps	$f8, $f20
289	movt.ps	$f8, $f22, $fcc0	# moves both halves
290	check_ps $f8, -1.0, 2.0
291
292
293	writemsg "alnv.ps (aligned)"
294
295	.data
2961:	.dword	0xc1a8000042200000		# -21.0, 40.0
297	.dword	0xc228000041a00000		# -42.0, 20.0
298	.text
299	la	$2, 1b
300	li	$3, 0
301	addu	$4, $3, 8
302	luxc1	$f10, $3($2)
303	luxc1	$f12, $4($2)
304	alnv.ps	$f8, $f10, $f12, $3
305	check_ps $f8, -21.0, 40.0
306
307
308	writemsg "alnv.ps (unaligned)"
309
310	.data
3111:	.dword	0xc1a8000042200000		# -21.0, 40.0
312	.dword	0xc228000041a00000		# -42.0, 20.0
313	.hword	0x0001
314	.text
315	la	$2, 1b
316	li	$3, 4
317	addu	$4, $3, 8
318	luxc1	$f10, $3($2)
319	luxc1	$f12, $4($2)
320	alnv.ps	$f8, $f10, $f12, $3
321
322	lb	$5, 16($2)
323	bnez	$5, 2f				# little endian
324	 nop
325
326	# big endian
327	check_ps $f8, 40.0, -42.0
328	b	3f
329	 nop
3302:
331	# little endian
332	check_ps $f8, 20.0, -21.0
3333:
334
335
336	# We test c.cond.ps only lightly, just to make sure it modifies
337	# two bits and compares the halves separately.  Perhaps it should
338	# be tested more thoroughly.
339
340	writemsg "c.f.ps"
341
342	cfc1	$2, $31
343	or	$2, $2, (1 << 23) | (0x7f << 25)
344	ctc1	$2, $31			# set all fcc bits
345	c.f.ps	$fcc0, $f8, $f8		# -> f, f
346	bc1t	$fcc0, _fail
347	 nop
348	bc1t	$fcc1, _fail
349	 nop
350
351
352	writemsg "c.olt.ps"
353
354	cfc1	$2, $31
355	or	$2, $2, (1 << 23) | (0x7f << 25)
356	xor	$2, $2, (1 << 23) | (0x7f << 25)
357	ctc1	$2, $31			# clear all fcc bits
358	c.lt.ps $fcc0, $f22, $f24	# -> f, t
359	bc1t	$fcc0, _fail
360	 nop
361	bc1f	$fcc1, _fail
362	 nop
363
364
365	pass
366
367	.end DIAG
368