Updated README to recursively initialize repos
[riscv-tests.git] / isa / macros / scalar / test_macros.h
1 #ifndef __TEST_MACROS_SCALAR_H
2 #define __TEST_MACROS_SCALAR_H
3
4
5 #-----------------------------------------------------------------------
6 # Helper macros
7 #-----------------------------------------------------------------------
8
9 #define TEST_CASE( testnum, testreg, correctval, code... ) \
10 test_ ## testnum: \
11 code; \
12 li x29, correctval; \
13 li x28, testnum; \
14 bne testreg, x29, fail;
15
16 #define TEST_CASE_JUMP( testnum, testreg, correctval, code... ) \
17 test_ ## testnum: \
18 code; \
19 li x29, correctval; \
20 li x28, testnum; \
21 beq testreg, x29, pass_ ## testnum; \
22 j fail; \
23 pass_ ## testnum: \
24
25 # We use a macro hack to simpify code generation for various numbers
26 # of bubble cycles.
27
28 #define TEST_INSERT_NOPS_0
29 #define TEST_INSERT_NOPS_1 nop; TEST_INSERT_NOPS_0
30 #define TEST_INSERT_NOPS_2 nop; TEST_INSERT_NOPS_1
31 #define TEST_INSERT_NOPS_3 nop; TEST_INSERT_NOPS_2
32 #define TEST_INSERT_NOPS_4 nop; TEST_INSERT_NOPS_3
33 #define TEST_INSERT_NOPS_5 nop; TEST_INSERT_NOPS_4
34 #define TEST_INSERT_NOPS_6 nop; TEST_INSERT_NOPS_5
35 #define TEST_INSERT_NOPS_7 nop; TEST_INSERT_NOPS_6
36 #define TEST_INSERT_NOPS_8 nop; TEST_INSERT_NOPS_7
37 #define TEST_INSERT_NOPS_9 nop; TEST_INSERT_NOPS_8
38 #define TEST_INSERT_NOPS_10 nop; TEST_INSERT_NOPS_9
39
40
41 #-----------------------------------------------------------------------
42 # RV64UI MACROS
43 #-----------------------------------------------------------------------
44
45 #-----------------------------------------------------------------------
46 # Tests for instructions with immediate operand
47 #-----------------------------------------------------------------------
48
49 #define SEXT_IMM(x) ((x) | (-(((x) >> 11) & 1) << 11))
50
51 #define TEST_IMM_OP( testnum, inst, result, val1, imm ) \
52 TEST_CASE( testnum, x3, result, \
53 li x1, val1; \
54 inst x3, x1, SEXT_IMM(imm); \
55 )
56
57 #define TEST_IMM_SRC1_EQ_DEST( testnum, inst, result, val1, imm ) \
58 TEST_CASE( testnum, x1, result, \
59 li x1, val1; \
60 inst x1, x1, SEXT_IMM(imm); \
61 )
62
63 #define TEST_IMM_DEST_BYPASS( testnum, nop_cycles, inst, result, val1, imm ) \
64 TEST_CASE( testnum, x6, result, \
65 li x4, 0; \
66 1: li x1, val1; \
67 inst x3, x1, SEXT_IMM(imm); \
68 TEST_INSERT_NOPS_ ## nop_cycles \
69 addi x6, x3, 0; \
70 addi x4, x4, 1; \
71 li x5, 2; \
72 bne x4, x5, 1b \
73 )
74
75 #define TEST_IMM_SRC1_BYPASS( testnum, nop_cycles, inst, result, val1, imm ) \
76 TEST_CASE( testnum, x3, result, \
77 li x4, 0; \
78 1: li x1, val1; \
79 TEST_INSERT_NOPS_ ## nop_cycles \
80 inst x3, x1, SEXT_IMM(imm); \
81 addi x4, x4, 1; \
82 li x5, 2; \
83 bne x4, x5, 1b \
84 )
85
86 #define TEST_IMM_ZEROSRC1( testnum, inst, result, imm ) \
87 TEST_CASE( testnum, x1, result, \
88 inst x1, x0, SEXT_IMM(imm); \
89 )
90
91 #define TEST_IMM_ZERODEST( testnum, inst, val1, imm ) \
92 TEST_CASE( testnum, x0, 0, \
93 li x1, val1; \
94 inst x0, x1, SEXT_IMM(imm); \
95 )
96
97 #-----------------------------------------------------------------------
98 # Tests for vector config instructions
99 #-----------------------------------------------------------------------
100
101 #define TEST_VSETCFGIVL( testnum, nxpr, nfpr, bank, vl, result ) \
102 TEST_CASE_JUMP( testnum, x1, result, \
103 li x1, (bank << 12); \
104 vsetcfg x1,nxpr,nfpr; \
105 li x1, vl; \
106 vsetvl x1,x1; \
107 )
108
109 #define TEST_VVCFG( testnum, nxpr, nfpr, bank, vl, result ) \
110 TEST_CASE_JUMP( testnum, x1, result, \
111 li x1, (bank << 12) | (nfpr << 6) | nxpr; \
112 vsetcfg x1; \
113 li x1, vl; \
114 vsetvl x1,x1; \
115 )
116
117 #define TEST_VSETVL( testnum, nxpr, nfpr, bank, vl, result ) \
118 TEST_CASE_JUMP( testnum, x1, result, \
119 li x1, (bank << 12); \
120 vsetcfg x1,nxpr,nfpr; \
121 li x1, vl; \
122 vsetvl x1, x1; \
123 )
124
125 #-----------------------------------------------------------------------
126 # Tests for an instruction with register operands
127 #-----------------------------------------------------------------------
128
129 #define TEST_R_OP( testnum, inst, result, val1 ) \
130 TEST_CASE( testnum, x3, result, \
131 li x1, val1; \
132 inst x3, x1; \
133 )
134
135 #define TEST_R_SRC1_EQ_DEST( testnum, inst, result, val1 ) \
136 TEST_CASE( testnum, x1, result, \
137 li x1, val1; \
138 inst x1, x1; \
139 )
140
141 #define TEST_R_DEST_BYPASS( testnum, nop_cycles, inst, result, val1 ) \
142 TEST_CASE( testnum, x6, result, \
143 li x4, 0; \
144 1: li x1, val1; \
145 inst x3, x1; \
146 TEST_INSERT_NOPS_ ## nop_cycles \
147 addi x6, x3, 0; \
148 addi x4, x4, 1; \
149 li x5, 2; \
150 bne x4, x5, 1b \
151 )
152
153 #-----------------------------------------------------------------------
154 # Tests for an instruction with register-register operands
155 #-----------------------------------------------------------------------
156
157 #define TEST_RR_OP( testnum, inst, result, val1, val2 ) \
158 TEST_CASE( testnum, x3, result, \
159 li x1, val1; \
160 li x2, val2; \
161 inst x3, x1, x2; \
162 )
163
164 #define TEST_RR_SRC1_EQ_DEST( testnum, inst, result, val1, val2 ) \
165 TEST_CASE( testnum, x1, result, \
166 li x1, val1; \
167 li x2, val2; \
168 inst x1, x1, x2; \
169 )
170
171 #define TEST_RR_SRC2_EQ_DEST( testnum, inst, result, val1, val2 ) \
172 TEST_CASE( testnum, x2, result, \
173 li x1, val1; \
174 li x2, val2; \
175 inst x2, x1, x2; \
176 )
177
178 #define TEST_RR_SRC12_EQ_DEST( testnum, inst, result, val1 ) \
179 TEST_CASE( testnum, x1, result, \
180 li x1, val1; \
181 inst x1, x1, x1; \
182 )
183
184 #define TEST_RR_DEST_BYPASS( testnum, nop_cycles, inst, result, val1, val2 ) \
185 TEST_CASE( testnum, x6, result, \
186 li x4, 0; \
187 1: li x1, val1; \
188 li x2, val2; \
189 inst x3, x1, x2; \
190 TEST_INSERT_NOPS_ ## nop_cycles \
191 addi x6, x3, 0; \
192 addi x4, x4, 1; \
193 li x5, 2; \
194 bne x4, x5, 1b \
195 )
196
197 #define TEST_RR_SRC12_BYPASS( testnum, src1_nops, src2_nops, inst, result, val1, val2 ) \
198 TEST_CASE( testnum, x3, result, \
199 li x4, 0; \
200 1: li x1, val1; \
201 TEST_INSERT_NOPS_ ## src1_nops \
202 li x2, val2; \
203 TEST_INSERT_NOPS_ ## src2_nops \
204 inst x3, x1, x2; \
205 addi x4, x4, 1; \
206 li x5, 2; \
207 bne x4, x5, 1b \
208 )
209
210 #define TEST_RR_SRC21_BYPASS( testnum, src1_nops, src2_nops, inst, result, val1, val2 ) \
211 TEST_CASE( testnum, x3, result, \
212 li x4, 0; \
213 1: li x2, val2; \
214 TEST_INSERT_NOPS_ ## src1_nops \
215 li x1, val1; \
216 TEST_INSERT_NOPS_ ## src2_nops \
217 inst x3, x1, x2; \
218 addi x4, x4, 1; \
219 li x5, 2; \
220 bne x4, x5, 1b \
221 )
222
223 #define TEST_RR_ZEROSRC1( testnum, inst, result, val ) \
224 TEST_CASE( testnum, x2, result, \
225 li x1, val; \
226 inst x2, x0, x1; \
227 )
228
229 #define TEST_RR_ZEROSRC2( testnum, inst, result, val ) \
230 TEST_CASE( testnum, x2, result, \
231 li x1, val; \
232 inst x2, x1, x0; \
233 )
234
235 #define TEST_RR_ZEROSRC12( testnum, inst, result ) \
236 TEST_CASE( testnum, x1, result, \
237 inst x1, x0, x0; \
238 )
239
240 #define TEST_RR_ZERODEST( testnum, inst, val1, val2 ) \
241 TEST_CASE( testnum, x0, 0, \
242 li x1, val1; \
243 li x2, val2; \
244 inst x0, x1, x2; \
245 )
246
247 #-----------------------------------------------------------------------
248 # Test memory instructions
249 #-----------------------------------------------------------------------
250
251 #define TEST_LD_OP( testnum, inst, result, offset, base ) \
252 TEST_CASE( testnum, x3, result, \
253 la x1, base; \
254 inst x3, offset(x1); \
255 )
256
257 #define TEST_ST_OP( testnum, load_inst, store_inst, result, offset, base ) \
258 TEST_CASE( testnum, x3, result, \
259 la x1, base; \
260 li x2, result; \
261 store_inst x2, offset(x1); \
262 load_inst x3, offset(x1); \
263 )
264
265 #define TEST_LD_DEST_BYPASS( testnum, nop_cycles, inst, result, offset, base ) \
266 test_ ## testnum: \
267 li x28, testnum; \
268 li x4, 0; \
269 1: la x1, base; \
270 inst x3, offset(x1); \
271 TEST_INSERT_NOPS_ ## nop_cycles \
272 addi x6, x3, 0; \
273 li x29, result; \
274 bne x6, x29, fail; \
275 addi x4, x4, 1; \
276 li x5, 2; \
277 bne x4, x5, 1b; \
278
279 #define TEST_LD_SRC1_BYPASS( testnum, nop_cycles, inst, result, offset, base ) \
280 test_ ## testnum: \
281 li x28, testnum; \
282 li x4, 0; \
283 1: la x1, base; \
284 TEST_INSERT_NOPS_ ## nop_cycles \
285 inst x3, offset(x1); \
286 li x29, result; \
287 bne x3, x29, fail; \
288 addi x4, x4, 1; \
289 li x5, 2; \
290 bne x4, x5, 1b \
291
292 #define TEST_ST_SRC12_BYPASS( testnum, src1_nops, src2_nops, load_inst, store_inst, result, offset, base ) \
293 test_ ## testnum: \
294 li x28, testnum; \
295 li x4, 0; \
296 1: la x1, result; \
297 TEST_INSERT_NOPS_ ## src1_nops \
298 la x2, base; \
299 TEST_INSERT_NOPS_ ## src2_nops \
300 store_inst x1, offset(x2); \
301 load_inst x3, offset(x2); \
302 li x29, result; \
303 bne x3, x29, fail; \
304 addi x4, x4, 1; \
305 li x5, 2; \
306 bne x4, x5, 1b \
307
308 #define TEST_ST_SRC21_BYPASS( testnum, src1_nops, src2_nops, load_inst, store_inst, result, offset, base ) \
309 test_ ## testnum: \
310 li x28, testnum; \
311 li x4, 0; \
312 1: la x2, base; \
313 TEST_INSERT_NOPS_ ## src1_nops \
314 la x1, result; \
315 TEST_INSERT_NOPS_ ## src2_nops \
316 store_inst x1, offset(x2); \
317 load_inst x3, offset(x2); \
318 li x29, result; \
319 bne x3, x29, fail; \
320 addi x4, x4, 1; \
321 li x5, 2; \
322 bne x4, x5, 1b \
323
324 #-----------------------------------------------------------------------
325 # Test branch instructions
326 #-----------------------------------------------------------------------
327
328 #define TEST_BR1_OP_TAKEN( testnum, inst, val1 ) \
329 test_ ## testnum: \
330 li x28, testnum; \
331 li x1, val1; \
332 inst x1, 2f; \
333 bne x0, x28, fail; \
334 1: bne x0, x28, 3f; \
335 2: inst x1, 1b; \
336 bne x0, x28, fail; \
337 3:
338
339 #define TEST_BR1_OP_NOTTAKEN( testnum, inst, val1 ) \
340 test_ ## testnum: \
341 li x28, testnum; \
342 li x1, val1; \
343 inst x1, 1f; \
344 bne x0, x28, 2f; \
345 1: bne x0, x28, fail; \
346 2: inst x1, 1b; \
347 3:
348
349 #define TEST_BR1_SRC1_BYPASS( testnum, nop_cycles, inst, val1 ) \
350 test_ ## testnum: \
351 li x28, testnum; \
352 li x4, 0; \
353 1: li x1, val1; \
354 TEST_INSERT_NOPS_ ## nop_cycles \
355 inst x1, fail; \
356 addi x4, x4, 1; \
357 li x5, 2; \
358 bne x4, x5, 1b \
359
360 #define TEST_BR2_OP_TAKEN( testnum, inst, val1, val2 ) \
361 test_ ## testnum: \
362 li x28, testnum; \
363 li x1, val1; \
364 li x2, val2; \
365 inst x1, x2, 2f; \
366 bne x0, x28, fail; \
367 1: bne x0, x28, 3f; \
368 2: inst x1, x2, 1b; \
369 bne x0, x28, fail; \
370 3:
371
372 #define TEST_BR2_OP_NOTTAKEN( testnum, inst, val1, val2 ) \
373 test_ ## testnum: \
374 li x28, testnum; \
375 li x1, val1; \
376 li x2, val2; \
377 inst x1, x2, 1f; \
378 bne x0, x28, 2f; \
379 1: bne x0, x28, fail; \
380 2: inst x1, x2, 1b; \
381 3:
382
383 #define TEST_BR2_SRC12_BYPASS( testnum, src1_nops, src2_nops, inst, val1, val2 ) \
384 test_ ## testnum: \
385 li x28, testnum; \
386 li x4, 0; \
387 1: li x1, val1; \
388 TEST_INSERT_NOPS_ ## src1_nops \
389 li x2, val2; \
390 TEST_INSERT_NOPS_ ## src2_nops \
391 inst x1, x2, fail; \
392 addi x4, x4, 1; \
393 li x5, 2; \
394 bne x4, x5, 1b \
395
396 #define TEST_BR2_SRC21_BYPASS( testnum, src1_nops, src2_nops, inst, val1, val2 ) \
397 test_ ## testnum: \
398 li x28, testnum; \
399 li x4, 0; \
400 1: li x2, val2; \
401 TEST_INSERT_NOPS_ ## src1_nops \
402 li x1, val1; \
403 TEST_INSERT_NOPS_ ## src2_nops \
404 inst x1, x2, fail; \
405 addi x4, x4, 1; \
406 li x5, 2; \
407 bne x4, x5, 1b \
408
409 #-----------------------------------------------------------------------
410 # Test jump instructions
411 #-----------------------------------------------------------------------
412
413 #define TEST_JR_SRC1_BYPASS( testnum, nop_cycles, inst ) \
414 test_ ## testnum: \
415 li x28, testnum; \
416 li x4, 0; \
417 1: la x6, 2f; \
418 TEST_INSERT_NOPS_ ## nop_cycles \
419 inst x6; \
420 bne x0, x28, fail; \
421 2: addi x4, x4, 1; \
422 li x5, 2; \
423 bne x4, x5, 1b \
424
425 #define TEST_JALR_SRC1_BYPASS( testnum, nop_cycles, inst ) \
426 test_ ## testnum: \
427 li x28, testnum; \
428 li x4, 0; \
429 1: la x6, 2f; \
430 TEST_INSERT_NOPS_ ## nop_cycles \
431 inst x19, x6, 0; \
432 bne x0, x28, fail; \
433 2: addi x4, x4, 1; \
434 li x5, 2; \
435 bne x4, x5, 1b \
436
437
438 #-----------------------------------------------------------------------
439 # RV64UF MACROS
440 #-----------------------------------------------------------------------
441
442 #-----------------------------------------------------------------------
443 # Tests floating-point instructions
444 #-----------------------------------------------------------------------
445
446 #define TEST_FP_OP_S_INTERNAL( testnum, result, val1, val2, val3, code... ) \
447 test_ ## testnum: \
448 li x28, testnum; \
449 la a0, test_ ## testnum ## _data ;\
450 flw f0, 0(a0); \
451 flw f1, 4(a0); \
452 flw f2, 8(a0); \
453 lw a3, 12(a0); \
454 code; \
455 bne a0, a3, fail; \
456 b 1f; \
457 .align 2; \
458 test_ ## testnum ## _data: \
459 .float val1; \
460 .float val2; \
461 .float val3; \
462 .result; \
463 1:
464
465 #define TEST_FP_OP_D_INTERNAL( testnum, result, val1, val2, val3, code... ) \
466 test_ ## testnum: \
467 li x28, testnum; \
468 la a0, test_ ## testnum ## _data ;\
469 fld f0, 0(a0); \
470 fld f1, 8(a0); \
471 fld f2, 16(a0); \
472 ld a3, 24(a0); \
473 code; \
474 bne a0, a3, fail; \
475 b 1f; \
476 .align 3; \
477 test_ ## testnum ## _data: \
478 .double val1; \
479 .double val2; \
480 .double val3; \
481 .result; \
482 1:
483
484 #define TEST_FCVT_S_D( testnum, result, val1 ) \
485 TEST_FP_OP_D_INTERNAL( testnum, double result, val1, 0.0, 0.0, \
486 fcvt.s.d f3, f0; fcvt.d.s f3, f3; fmv.x.d a0, f3)
487
488 #define TEST_FCVT_D_S( testnum, result, val1 ) \
489 TEST_FP_OP_S_INTERNAL( testnum, float result, val1, 0.0, 0.0, \
490 fcvt.d.s f3, f0; fcvt.s.d f3, f3; fmv.x.s a0, f3)
491
492 #define TEST_FP_OP1_S( testnum, inst, result, val1 ) \
493 TEST_FP_OP_S_INTERNAL( testnum, float result, val1, 0.0, 0.0, \
494 inst f3, f0; fmv.x.s a0, f3)
495
496 #define TEST_FP_OP1_D( testnum, inst, result, val1 ) \
497 TEST_FP_OP_D_INTERNAL( testnum, double result, val1, 0.0, 0.0, \
498 inst f3, f0; fmv.x.d a0, f3)
499
500 #define TEST_FP_OP2_S( testnum, inst, result, val1, val2 ) \
501 TEST_FP_OP_S_INTERNAL( testnum, float result, val1, val2, 0.0, \
502 inst f3, f0, f1; fmv.x.s a0, f3)
503
504 #define TEST_FP_OP2_D( testnum, inst, result, val1, val2 ) \
505 TEST_FP_OP_D_INTERNAL( testnum, double result, val1, val2, 0.0, \
506 inst f3, f0, f1; fmv.x.d a0, f3)
507
508 #define TEST_FP_OP3_S( testnum, inst, result, val1, val2, val3 ) \
509 TEST_FP_OP_S_INTERNAL( testnum, float result, val1, val2, val3, \
510 inst f3, f0, f1, f2; fmv.x.s a0, f3)
511
512 #define TEST_FP_OP3_D( testnum, inst, result, val1, val2, val3 ) \
513 TEST_FP_OP_D_INTERNAL( testnum, double result, val1, val2, val3, \
514 inst f3, f0, f1, f2; fmv.x.d a0, f3)
515
516 #define TEST_FP_INT_OP_S( testnum, inst, result, val1, rm ) \
517 TEST_FP_OP_S_INTERNAL( testnum, word result, val1, 0.0, 0.0, \
518 inst a0, f0, rm)
519
520 #define TEST_FP_INT_OP_D( testnum, inst, result, val1, rm ) \
521 TEST_FP_OP_D_INTERNAL( testnum, dword result, val1, 0.0, 0.0, \
522 inst a0, f0, rm)
523
524 #define TEST_FP_CMP_OP_S( testnum, inst, result, val1, val2 ) \
525 TEST_FP_OP_S_INTERNAL( testnum, word result, val1, val2, 0.0, \
526 inst a0, f0, f1)
527
528 #define TEST_FP_CMP_OP_D( testnum, inst, result, val1, val2 ) \
529 TEST_FP_OP_D_INTERNAL( testnum, dword result, val1, val2, 0.0, \
530 inst a0, f0, f1)
531
532 #define TEST_INT_FP_OP_S( testnum, inst, result, val1 ) \
533 test_ ## testnum: \
534 li x28, testnum; \
535 la a0, test_ ## testnum ## _data ;\
536 lw a3, 0(a0); \
537 li a0, val1; \
538 inst f0, a0; \
539 fmv.x.s a0, f0; \
540 bne a0, a3, fail; \
541 b 1f; \
542 .align 2; \
543 test_ ## testnum ## _data: \
544 .float result; \
545 1:
546
547 #define TEST_INT_FP_OP_D( testnum, inst, result, val1 ) \
548 test_ ## testnum: \
549 li x28, testnum; \
550 la a0, test_ ## testnum ## _data ;\
551 ld a3, 0(a0); \
552 li a0, val1; \
553 inst f0, a0; \
554 fmv.x.d a0, f0; \
555 bne a0, a3, fail; \
556 b 1f; \
557 .align 3; \
558 test_ ## testnum ## _data: \
559 .double result; \
560 1:
561
562
563 #-----------------------------------------------------------------------
564 # RV64SV MACROS
565 #-----------------------------------------------------------------------
566
567 #define TEST_ILLEGAL_TVEC_REGID( testnum, nxreg, nfreg, inst, reg1, reg2) \
568 csrs status, SR_EI; \
569 la a0, handler ## testnum; \
570 csrw evec, a0; \
571 vsetcfg nxreg, nfreg; \
572 li a0, 4; \
573 vsetvl a0, a0; \
574 la a0, src1; \
575 la a1, src2; \
576 vld vx2, a0; \
577 vld vx3, a1; \
578 lui a0,%hi(vtcode1 ## testnum); \
579 vf %lo(vtcode1 ## testnum)(a0); \
580 la reg2, dest; \
581 illegal ## testnum: \
582 inst reg1, reg2; \
583 la a3, dest; \
584 vsd vx2, a3; \
585 fence; \
586 vtcode1 ## testnum: \
587 add x2, x2, x3; \
588 stop; \
589 vtcode2 ## testnum: \
590 add x2, x2, x3; \
591 stop; \
592 handler ## testnum: \
593 vxcptkill; \
594 li x28,2; \
595 vxcptcause a0; \
596 li a1,HWACHA_CAUSE_TVEC_ILLEGAL_REGID; \
597 bne a0,a1,fail; \
598 vxcptaux a0; \
599 la a1, illegal ## testnum; \
600 lw a2, 0(a1); \
601 bne a0, a2, fail; \
602 vsetcfg 32,0; \
603 li a0,4; \
604 vsetvl a0,a0; \
605 la a0,src1; \
606 la a1,src2; \
607 vld vx2,a0; \
608 vld vx3,a1; \
609 lui a0,%hi(vtcode2 ## testnum); \
610 vf %lo(vtcode2 ## testnum)(a0); \
611 la a3,dest; \
612 vsd vx2,a3; \
613 fence; \
614 ld a1,0(a3); \
615 li a2,5; \
616 li x28,2; \
617 bne a1,a2,fail; \
618 ld a1,8(a3); \
619 li x28,3; \
620 bne a1,a2,fail; \
621 ld a1,16(a3); \
622 li x28,4; \
623 bne a1,a2,fail; \
624 ld a1,24(a3); \
625 li x28,5; \
626 bne a1,a2,fail; \
627
628 #define TEST_ILLEGAL_VT_REGID( testnum, nxreg, nfreg, inst, reg1, reg2, reg3) \
629 csrs status, SR_EI; \
630 la a0, handler ## testnum; \
631 csrw evec, a0; \
632 vsetcfg nxreg, nfreg; \
633 li a0, 4; \
634 vsetvl a0, a0; \
635 la a0, src1; \
636 la a1, src2; \
637 vld vx2, a0; \
638 vld vx3, a1; \
639 lui a0,%hi(vtcode1 ## testnum); \
640 vf %lo(vtcode1 ## testnum)(a0); \
641 la a3, dest; \
642 vsd vx2, a3; \
643 fence; \
644 vtcode1 ## testnum: \
645 add x2, x2, x3; \
646 illegal ## testnum: \
647 inst reg1, reg2, reg3; \
648 stop; \
649 vtcode2 ## testnum: \
650 add x2, x2, x3; \
651 stop; \
652 handler ## testnum: \
653 vxcptkill; \
654 li x28,2; \
655 vxcptcause a0; \
656 li a1,HWACHA_CAUSE_VF_ILLEGAL_REGID; \
657 bne a0,a1,fail; \
658 vxcptaux a0; \
659 la a1,illegal ## testnum; \
660 bne a0,a1,fail; \
661 vsetcfg 32,0; \
662 li a0,4; \
663 vsetvl a0,a0; \
664 la a0,src1; \
665 la a1,src2; \
666 vld vx2,a0; \
667 vld vx3,a1; \
668 lui a0,%hi(vtcode2 ## testnum); \
669 vf %lo(vtcode2 ## testnum)(a0); \
670 la a3,dest; \
671 vsd vx2,a3; \
672 fence; \
673 ld a1,0(a3); \
674 li a2,5; \
675 li x28,2; \
676 bne a1,a2,fail; \
677 ld a1,8(a3); \
678 li x28,3; \
679 bne a1,a2,fail; \
680 ld a1,16(a3); \
681 li x28,4; \
682 bne a1,a2,fail; \
683 ld a1,24(a3); \
684 li x28,5; \
685 bne a1,a2,fail; \
686
687 #-----------------------------------------------------------------------
688 # Pass and fail code (assumes test num is in x28)
689 #-----------------------------------------------------------------------
690
691 #define TEST_PASSFAIL \
692 bne x0, x28, pass; \
693 fail: \
694 RVTEST_FAIL \
695 pass: \
696 RVTEST_PASS \
697
698
699 #-----------------------------------------------------------------------
700 # Test data section
701 #-----------------------------------------------------------------------
702
703 #define TEST_DATA
704
705 #endif