diff options
author | Chih-Min Chao <48193236+chihminchao@users.noreply.github.com> | 2020-11-11 17:09:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-11 01:09:15 -0800 |
commit | 5f8a4918c6482e65c67a2b7decd5c2af3e3fe0e5 (patch) | |
tree | 4a9483bc0b6fe2c770d8844534f89a88adbdce7d /isa/macros | |
parent | c4217d88bce9f805a81f42e86ff56ed363931d69 (diff) | |
download | riscv-tests-5f8a4918c6482e65c67a2b7decd5c2af3e3fe0e5.zip riscv-tests-5f8a4918c6482e65c67a2b7decd5c2af3e3fe0e5.tar.gz riscv-tests-5f8a4918c6482e65c67a2b7decd5c2af3e3fe0e5.tar.bz2 |
add zfh (float16) test case and related macros (#301)
* ext: add zfh extension test case and related macro
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
* build: add zfh to target
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'isa/macros')
-rw-r--r-- | isa/macros/scalar/test_macros.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/isa/macros/scalar/test_macros.h b/isa/macros/scalar/test_macros.h index ed4cab0..a8a78a7 100644 --- a/isa/macros/scalar/test_macros.h +++ b/isa/macros/scalar/test_macros.h @@ -374,11 +374,35 @@ test_ ## testnum: \ # Tests floating-point instructions #----------------------------------------------------------------------- +#define qNaNh 0h:7e00 +#define sNaNh 0h:7c01 #define qNaNf 0f:7fc00000 #define sNaNf 0f:7f800001 #define qNaN 0d:7ff8000000000000 #define sNaN 0d:7ff0000000000001 +#define TEST_FP_OP_H_INTERNAL( testnum, flags, result, val1, val2, val3, code... ) \ +test_ ## testnum: \ + li TESTNUM, testnum; \ + la a0, test_ ## testnum ## _data ;\ + flh f0, 0(a0); \ + flh f1, 2(a0); \ + flh f2, 4(a0); \ + lh a3, 6(a0); \ + code; \ + fsflags a1, x0; \ + li a2, flags; \ + bne a0, a3, fail; \ + bne a1, a2, fail; \ + .pushsection .data; \ + .align 1; \ + test_ ## testnum ## _data: \ + .float16 val1; \ + .float16 val2; \ + .float16 val3; \ + .result; \ + .popsection + #define TEST_FP_OP_S_INTERNAL( testnum, flags, result, val1, val2, val3, code... ) \ test_ ## testnum: \ li TESTNUM, testnum; \ @@ -460,6 +484,19 @@ test_ ## testnum: \ TEST_FP_OP_S_INTERNAL( testnum, 0, float result, val1, 0.0, 0.0, \ fcvt.d.s f3, f0; fcvt.s.d f3, f3; fmv.x.s a0, f3) +#define TEST_FCVT_H_S( testnum, result, val1 ) \ + TEST_FP_OP_H_INTERNAL( testnum, 0, float16 result, val1, 0.0, 0.0, \ + fcvt.s.h f3, f0; fcvt.h.s f3, f3; fmv.x.h a0, f3) + +#define TEST_FCVT_H_D( testnum, result, val1 ) \ + TEST_FP_OP_H_INTERNAL( testnum, 0, float16 result, val1, 0.0, 0.0, \ + fcvt.d.h f3, f0; fcvt.h.d f3, f3; fmv.x.h a0, f3) + + +#define TEST_FP_OP1_H( testnum, inst, flags, result, val1 ) \ + TEST_FP_OP_H_INTERNAL( testnum, flags, float16 result, val1, 0.0, 0.0, \ + inst f3, f0; fmv.x.h a0, f3;) + #define TEST_FP_OP1_S( testnum, inst, flags, result, val1 ) \ TEST_FP_OP_S_INTERNAL( testnum, flags, float result, val1, 0.0, 0.0, \ inst f3, f0; fmv.x.s a0, f3) @@ -477,6 +514,10 @@ test_ ## testnum: \ TEST_FP_OP_S_INTERNAL( testnum, flags, dword result, val1, 0.0, 0.0, \ inst f3, f0; fmv.x.s a0, f3) +#define TEST_FP_OP1_H_DWORD_RESULT( testnum, inst, flags, result, val1 ) \ + TEST_FP_OP_H_INTERNAL( testnum, flags, word result, val1, 0.0, 0.0, \ + inst f3, f0; fmv.x.h a0, f3) + #define TEST_FP_OP1_D32_DWORD_RESULT( testnum, inst, flags, result, val1 ) \ TEST_FP_OP_D32_INTERNAL( testnum, flags, dword result, val1, 0.0, 0.0, \ inst f3, f0; fsd f3, 0(a0); lw t2, 4(a0); lw a0, 0(a0)) @@ -490,6 +531,10 @@ test_ ## testnum: \ TEST_FP_OP_S_INTERNAL( testnum, flags, float result, val1, val2, 0.0, \ inst f3, f0, f1; fmv.x.s a0, f3) +#define TEST_FP_OP2_H( testnum, inst, flags, result, val1, val2 ) \ + TEST_FP_OP_H_INTERNAL( testnum, flags, float16 result, val1, val2, 0.0, \ + inst f3, f0, f1; fmv.x.h a0, f3) + #define TEST_FP_OP2_D32( testnum, inst, flags, result, val1, val2 ) \ TEST_FP_OP_D32_INTERNAL( testnum, flags, double result, val1, val2, 0.0, \ inst f3, f0, f1; fsd f3, 0(a0); lw t2, 4(a0); lw a0, 0(a0)) @@ -503,6 +548,10 @@ test_ ## testnum: \ TEST_FP_OP_S_INTERNAL( testnum, flags, float result, val1, val2, val3, \ inst f3, f0, f1, f2; fmv.x.s a0, f3) +#define TEST_FP_OP3_H( testnum, inst, flags, result, val1, val2, val3 ) \ + TEST_FP_OP_H_INTERNAL( testnum, flags, float16 result, val1, val2, val3, \ + inst f3, f0, f1, f2; fmv.x.h a0, f3) + #define TEST_FP_OP3_D32( testnum, inst, flags, result, val1, val2, val3 ) \ TEST_FP_OP_D32_INTERNAL( testnum, flags, double result, val1, val2, val3, \ inst f3, f0, f1, f2; fsd f3, 0(a0); lw t2, 4(a0); lw a0, 0(a0)) @@ -516,6 +565,10 @@ test_ ## testnum: \ TEST_FP_OP_S_INTERNAL( testnum, flags, word result, val1, 0.0, 0.0, \ inst a0, f0, rm) +#define TEST_FP_INT_OP_H( testnum, inst, flags, result, val1, rm ) \ + TEST_FP_OP_H_INTERNAL( testnum, flags, word result, val1, 0.0, 0.0, \ + inst a0, f0, rm) + #define TEST_FP_INT_OP_D32( testnum, inst, flags, result, val1, rm ) \ TEST_FP_OP_D32_INTERNAL( testnum, flags, dword result, val1, 0.0, 0.0, \ inst a0, f0, f1; li t2, 0) @@ -528,6 +581,10 @@ test_ ## testnum: \ TEST_FP_OP_S_INTERNAL( testnum, flags, word result, val1, val2, 0.0, \ inst a0, f0, f1) +#define TEST_FP_CMP_OP_H( testnum, inst, flags, result, val1, val2 ) \ + TEST_FP_OP_H_INTERNAL( testnum, flags, hword result, val1, val2, 0.0, \ + inst a0, f0, f1) + #define TEST_FP_CMP_OP_D32( testnum, inst, flags, result, val1, val2 ) \ TEST_FP_OP_D32_INTERNAL( testnum, flags, dword result, val1, val2, 0.0, \ inst a0, f0, f1; li t2, 0) @@ -571,6 +628,22 @@ test_ ## testnum: \ .float result; \ .popsection +#define TEST_INT_FP_OP_H( testnum, inst, result, val1 ) \ +test_ ## testnum: \ + li TESTNUM, testnum; \ + la a0, test_ ## testnum ## _data ;\ + lh a3, 0(a0); \ + li a0, val1; \ + inst f0, a0; \ + fsflags x0; \ + fmv.x.h a0, f0; \ + bne a0, a3, fail; \ + .pushsection .data; \ + .align 1; \ + test_ ## testnum ## _data: \ + .float16 result; \ + .popsection + #define TEST_INT_FP_OP_D32( testnum, inst, result, val1 ) \ test_ ## testnum: \ li TESTNUM, testnum; \ |