diff --git a/test/riscv-tests/fclassd.s b/test/riscv-tests/fclassd.s new file mode 100644 index 00000000..b2f6e091 --- /dev/null +++ b/test/riscv-tests/fclassd.s @@ -0,0 +1,119 @@ +.text + + + #------------------------------------------------------------- + # Arithmetic tests + #------------------------------------------------------------- + + test_2: la a0, test_2_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 1 + li gp, 2 + bne a0, x29, fail + .data + .align 3 + test_2_data: .word 0, 0xfff00000 + .text + test_3: la a0, test_3_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 2 + li gp, 3 + bne a0, x29, fail + .data + .align 3 + test_3_data: .word 0, 0xbff00000 + .text + test_4: la a0, test_4_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 4 + li gp, 4 + bne a0, x29, fail + .data + .align 3 + test_4_data: .word -1, 0x800fffff + .text + test_5: la a0, test_5_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 8 + li gp, 5 + bne a0, x29, fail + .data + .align 3 + test_5_data: .word 0, 0x80000000 + .text + test_6: la a0, test_6_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 16 + li gp, 6 + bne a0, x29, fail + .data + .align 3 + test_6_data: .word 0,0 + .text + test_7: la a0, test_7_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 32 + li gp, 7 + bne a0, x29, fail + .data + .align 3 + test_7_data: .word -1, 0x000fffff + .text + test_8: la a0, test_8_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 64 + li gp, 8 + bne a0, x29, fail + .data + .align 3 + test_8_data: .word 0, 0x3ff00000 + .text + test_9: la a0, test_9_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 128 + li gp, 9 + bne a0, x29, fail + .data + .align 3 + test_9_data: .word 0, 0x7ff00000 + .text + test_10: la a0, test_10_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 256 + li gp, 10 + bne a0, x29, fail + .data + .align 3 + test_10_data: .word 1, 0x7ff00000 + .text + test_11: la a0, test_11_data + fld fa0, 0(a0) + fclass.d a0, fa0 + li x29, 512 + li gp, 11 + bne a0, x29, fail + .data + .align 3 + test_11_data: .word 0, 0x7ff80000 + .text + + j success +fail: + li a0, 0 + li a7, 93 + ecall + +success: + li a0, 42 + li a7, 93 + ecall + diff --git a/test/riscv-tests/fcvt_wd.s b/test/riscv-tests/fcvt_wd.s new file mode 100644 index 00000000..efcb41ea --- /dev/null +++ b/test/riscv-tests/fcvt_wd.s @@ -0,0 +1,413 @@ + +.text + #------------------------------------------------------------- + # Arithmetic tests + #------------------------------------------------------------- + + test_2: li gp, 2 + la a0, test_2_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.w.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x01 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_2_data: .double -1.1 + .double 0.0 + .double 0.0 + .word -1 + .text + + test_3: li gp, 3 + la a0, test_3_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.w.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x00 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_3_data: .double -1.0 + .double 0.0 + .double 0.0 + .word -1 + .text + + test_4: li gp, 4 + la a0, test_4_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.w.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x01 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_4_data: .double -0.9 + .double 0.0 + .double 0.0 + .word 0 + .text + + test_5: li gp, 5 + la a0, test_5_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.w.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x01 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_5_data: .double 0.9 + .double 0.0 + .double 0.0 + .word 0 + .text + + test_6: li gp, 6 + la a0, test_6_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.w.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x00 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_6_data: .double 1.0 + .double 0.0 + .double 0.0 + .word 1 + .text + + test_7: li gp, 7 + la a0, test_7_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.w.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x01 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_7_data: .double 1.1 + .double 0.0 + .double 0.0 + .word 1 + .text + + test_8: li gp, 8 + la a0, test_8_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.w.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x10 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_8_data: .double -3e9 + .double 0.0 + .double 0.0 + .word 0x80000000 + .text + + test_9: li gp, 9 + la a0, test_9_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.w.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x10 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_9_data: .double 3e9 + .double 0.0 + .double 0.0 + .word 0x7FFFFFFF + .text + + + test_12: li gp, 12 + la a0, test_12_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.wu.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x10 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_12_data: .double -3.0 + .double 0.0 + .double 0.0 + .word 0 + .text + + test_13: li gp, 13 + la a0, test_13_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.wu.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x10 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_13_data: .double -1.0 + .double 0.0 + .double 0.0 + .word 0 + .text + + test_14: li gp, 14 + la a0, test_14_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.wu.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x01 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_14_data: .double -0.9 + .double 0.0 + .double 0.0 + .word 0 + .text + + test_15: li gp, 15 + la a0, test_15_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.wu.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x01 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_15_data: .double 0.9 + .double 0.0 + .double 0.0 + .word 0 + .text + + test_16: li gp, 16 + la a0, test_16_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.wu.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x00 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_16_data: .double 1.0 + .double 0.0 + .double 0.0 + .word 1 + .text + + test_17: li gp, 17 + la a0, test_17_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.wu.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x01 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_17_data: .double 1.1 + .double 0.0 + .double 0.0 + .word 1 + .text + + test_18: li gp, 18 + la a0, test_18_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.wu.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x10 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_18_data: .double -3e9 + .double 0.0 + .double 0.0 + .word 0 + .text + + test_19: li gp, 19 + la a0, test_19_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + fcvt.wu.d a0, f0, rtz + fsflags a1, x0 + li a2, 0x00 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 3 + test_19_data: .double 3e9 + .double 0.0 + .double 0.0 + .word 0xb2d05e00 + + .text + +# 60 "isa/rv32ud/../rv64ud/fcvt_w.S" + # test negative NaN, negative infinity conversion + test_42: la x1, tdat_d + fld f1, 0(x1) + fcvt.w.d x1, f1 + li x29, 0x7fffffff + li gp, 42 + bne x1, x29, fail + + test_44: la x1, tdat_d + fld f1, 16(x1) + fcvt.w.d x1, f1 + li x29, 0x80000000 + li gp, 44 + bne x1, x29, fail + + + # test positive NaN, positive infinity conversion + test_52: la x1, tdat_d + fld f1, 8(x1) + fcvt.w.d x1, f1 + li x29, 0x7fffffff + li gp, 52 + bne x1, x29, fail + + + + + test_54: la x1, tdat_d + fld f1, 24(x1) + fcvt.w.d x1, f1 + li x29, 0x7fffffff + li gp, 54 + bne x1, x29, fail + + + + + + # test NaN, infinity conversions to unsigned integer + test_62: la x1, tdat_d + fld f1, 0(x1) + fcvt.wu.d x1, f1 + li x29, -1 + li gp, 62 + bne x1, x29, fail + + test_63: la x1, tdat_d + fld f1, 8(x1) + fcvt.wu.d x1, f1 + li x29, -1 + li gp, 63 + bne x1, x29, fail + + test_64: la x1, tdat_d + fld f1, 16(x1) + fcvt.wu.d x1, f1 + li x29, 0 + li gp, 64 + bne x1, x29, fail + + test_65: la x1, tdat_d + fld f1, 24(x1) + fcvt.wu.d x1, f1 + li x29, -1 + li gp, 65 + bne x1, x29, fail + +.text + + j success +fail: + li a0, 0 + li a7, 93 + ecall + +success: + li a0, 42 + li a7, 93 + ecall + + + + + + + + +.data + # -NaN, NaN, -inf, +inf +tdat: +.word 0xffffffff +.word 0x7fffffff +.word 0xff800000 +.word 0x7f800000 + +tdat_d: +.word -1, -1 +.word -1, 0x7fffffff +.word 0, 0xfff00000 +.word 0, 0x7ff00000 diff --git a/test/riscv-tests/fcvtd.s b/test/riscv-tests/fcvtd.s new file mode 100644 index 00000000..642c4833 --- /dev/null +++ b/test/riscv-tests/fcvtd.s @@ -0,0 +1,153 @@ +.text + + #------------------------------------------------------------- + # Arithmetic tests + #------------------------------------------------------------- + + test_2: li gp, 2 + la a0, test_2_data + lw a3, 0(a0) + lw a4, 4(a0) + li a1, 2 + fcvt.d.w f0, a1 + fsd f0, 0(a0) + lw a1, 4(a0) + lw a0, 0(a0) + fsflags x0 + bne a0, a3, fail + bne a1, a4, fail + .data + .align 3 + test_2_data: .double 2.0 + .text + + test_3: li gp, 3 + la a0, test_3_data + lw a3, 0(a0) + lw a4, 4(a0) + li a1, -2 + fcvt.d.w f0, a1 + fsd f0, 0(a0) + lw a1, 4(a0) + lw a0, 0(a0) + fsflags x0 + bne a0, a3, fail + bne a1, a4, fail + .data + .align 3 + test_3_data: .double -2.0 + .text + + + test_4: li gp, 4 + la a0, test_4_data + lw a3, 0(a0) + lw a4, 4(a0) + li a1, 2 + fcvt.d.wu f0, a1 + fsd f0, 0(a0) + lw a1, 4(a0) + lw a0, 0(a0) + fsflags x0 + bne a0, a3, fail + bne a1, a4, fail + .data + .align 3 + test_4_data: .double 2.0 + .text + + test_5: li gp, 5 + la a0, test_5_data + lw a3, 0(a0) + lw a4, 4(a0) + li a1, -2 + fcvt.d.wu f0, a1 + fsd f0, 0(a0) + lw a1, 4(a0) + lw a0, 0(a0) + fsflags x0 + bne a0, a3, fail + bne a1, a4, fail + .data + .align 3 + test_5_data: .double 4294967294 + .text + +# 43 "isa/rv32ud/../rv64ud/fcvt.S" + test_10: li gp, 10 + la a0, test_10_data + fld f0, 0(a0) + fld f1, 8(a0) + fld f2, 16(a0) + lw a3, 24(a0) + lw t1, 28(a0) + fcvt.s.d f3, f0 + fcvt.d.s f3, f3 + fsd f3, 0(a0) + lw t2, 4(a0) + lw a0, 0(a0) + fsflags a1, x0 + li a2, 0 + bne a0, a3, fail + bne t1, t2, fail + bne a1, a2, fail + .data + .align 3 + test_10_data: .double -1.5 + .double 0.0 + .double 0.0 + .double -1.5 + .text + test_11: li gp, 11 + la a0, test_11_data + flw f0, 0(a0) + flw f1, 4(a0) + flw f2, 8(a0) + lw a3, 12(a0) + fcvt.d.s f3, f0 + fcvt.s.d f3, f3 + fmv.x.s a0, f3 + fsflags a1, x0 + li a2, 0 + bne a0, a3, fail + bne a1, a2, fail + .data + .align 2 + test_11_data: .float -1.5 + .float 0.0 + .float 0.0 + .float -1.5 + .text +# 56 "isa/rv32ud/../rv64ud/fcvt.S" + test_12: la a1, test_data_22 + fld f2, 0(a1) + fcvt.s.d f2, f2 + fcvt.d.s f2, f2 + fsd f2, 0(a1) + lw a0, 0(a1) + lw a1, 4(a1) + la x15, test_12_data + lw x29, 0(x15) + lw x15, 4(x15) + li gp, 12 + bne a0, x29, fail + bne a1, x15, fail + .data + .align 3 + test_12_data: .word 0, 0x7ff80000 +.text + + j success +fail: + li a0, 0 + li a7, 93 + ecall + +success: + li a0, 42 + li a7, 93 + ecall + +.data +test_data_22: + .word 0xffff8004, 0x7ffcffff diff --git a/test/riscv-tests/ldstd.s b/test/riscv-tests/ldstd.s new file mode 100644 index 00000000..ec29bffd --- /dev/null +++ b/test/riscv-tests/ldstd.s @@ -0,0 +1,94 @@ +.text + + la s0, tdat + test_2: fld f2, 0(s0) + fsd f2, 16(s0) + lw a0, 16(s0) + lw a1, 20(s0) + la x15, test_2_data + lw x29, 0(x15) + lw x15, 4(x15) + li gp, 2 + bne a0, x29, fail + bne a1, x15, fail + .data + .align 3 + test_2_data: .word 0xbf800000, 0x40000000 + .text + test_3: fld f2, 0(s0) + fsw f2, 16(s0) + lw a0, 16(s0) + lw a1, 20(s0) + la x15, test_3_data + lw x29, 0(x15) + lw x15, 4(x15) + li gp, 3 + bne a0, x29, fail + bne a1, x15, fail + .data + .align 3 + test_3_data: .word 0xbf800000, 0x40000000 + .text + test_4: flw f2, 0(s0) + fsw f2, 16(s0) + lw a0, 16(s0) + lw a1, 20(s0) + la x15, test_4_data + lw x29, 0(x15) + lw x15, 4(x15) + li gp, 4 + bne a0, x29, fail + bne a1, x15, fail + .data + .align 3 + test_4_data: .word 0xbf800000, 0x40000000 + .text + test_5: fld f2, 8(s0) + fsd f2, 16(s0) + lw a0, 16(s0) + lw a1, 20(s0) + la x15, test_5_data + lw x29, 0(x15) + lw x15, 4(x15) + li gp, 5 + bne a0, x29, fail + bne a1, x15, fail + .data + .align 3 + test_5_data: .word 0x40400000, 0xc0800000 + .text + test_6: flw f2, 8(s0) + fsd f2, 16(s0) + lw a0, 16(s0) + lw a1, 20(s0) + la x15, test_6_data + lw x29, 0(x15) + lw x15, 4(x15) + li gp, 6 + bne a0, x29, fail + bne a1, x15, fail + .data + .align 3 + test_6_data: .word 0x40400000, 0xffffffff + .text + j success +fail: + li a0, 0 + li a7, 93 + ecall + +success: + li a0, 42 + li a7, 93 + ecall + +.data +tdat: +.word 0xbf800000 +.word 0x40000000 +.word 0x40400000 +.word 0xc0800000 +.word 0xdeadbeef +.word 0xcafebabe +.word 0xabad1dea +.word 0x1337d00d \ No newline at end of file diff --git a/test/riscv-tests/recodingd.s b/test/riscv-tests/recodingd.s new file mode 100644 index 00000000..f21e4639 --- /dev/null +++ b/test/riscv-tests/recodingd.s @@ -0,0 +1,86 @@ +.text + + # Make sure infinities with different mantissas compare as equal. + fld f0, minf, a0 + fld f1, three, a0 + fmul.d f1, f1, f0 + test_2: feq.d a0, f0, f1 + li x29, 1 + li gp, 2 + bne a0, x29, fail + + test_3: fle.d a0, f0, f1 + li x29, 1 + li gp, 3 + bne a0, x29, fail + + test_4: flt.d a0, f0, f1 + li x29, 0 + li gp, 4 + bne a0, x29, fail + + + # Likewise, but for zeroes. + fcvt.d.w f0, x0 + li a0, 1 + fcvt.d.w f1, a0 + fmul.d f1, f1, f0 + test_5: feq.d a0, f0, f1 + li x29, 1 + li gp, 5 + bne a0, x29, fail + + test_6: fle.d a0, f0, f1 + li x29, 1 + li gp, 6 + bne a0, x29, fail + + test_7: flt.d a0, f0, f1 + li x29, 0 + li gp, 7 + bne a0, x29, fail + + + # When converting small doubles to single-precision subnormals, + # ensure that the extra precision is discarded. + flw f0, big, a0 + fld f1, tiny, a0 + fcvt.s.d f1, f1 + fmul.s f0, f0, f1 + fmv.x.s a0, f0 + lw a1, small + test_10: sub a0, a0, a1 + li x29, 0 + li gp, 10 + bne a0, x29, fail + + + # Make sure FSD+FLD correctly saves and restores a single-precision value. + flw f0, three, a0 + fadd.s f1, f0, f0 + fadd.s f0, f0, f0 + fsd f0, tiny, a0 + fld f0, tiny, a0 + test_20: feq.s a0, f0, f1 + li x29, 1 + li gp, 20 + bne a0, x29, fail + + j success +fail: + li a0, 0 + li a7, 93 + ecall + +success: + li a0, 42 + li a7, 93 + ecall + + +.data +minf: .double -Inf +three: .double 3.0 +big: .float 1221 +small: .float 2.9133121e-37 +tiny: .double 2.3860049081905093e-40