1# See LICENSE for license details. 2 3#***************************************************************************** 4# move.S 5#----------------------------------------------------------------------------- 6# 7# This test verifies that fmv.d.x, fmv.x.d, and fsgnj[x|n].d work properly. 8# 9 10#include "riscv_test.h" 11#include "test_macros.h" 12 13RVTEST_RV64UF 14RVTEST_CODE_BEGIN 15 16#TODO: make 32-bit compatible version 17#define TEST_FSGNJD(n, insn, new_sign, rs1_sign, rs2_sign) \ 18 TEST_CASE(n, a0, 0x123456789abcdef0 | (-(new_sign) << 63), \ 19 li a1, ((rs1_sign) << 63) | 0x123456789abcdef0; \ 20 li a2, -(rs2_sign); \ 21 fmv.d.x f1, a1; \ 22 fmv.d.x f2, a2; \ 23 insn f0, f1, f2; \ 24 fmv.x.d a0, f0) 25 26 TEST_FSGNJD(10, fsgnj.d, 0, 0, 0) 27 TEST_FSGNJD(11, fsgnj.d, 1, 0, 1) 28 TEST_FSGNJD(12, fsgnj.d, 0, 1, 0) 29 TEST_FSGNJD(13, fsgnj.d, 1, 1, 1) 30 31 TEST_FSGNJD(20, fsgnjn.d, 1, 0, 0) 32 TEST_FSGNJD(21, fsgnjn.d, 0, 0, 1) 33 TEST_FSGNJD(22, fsgnjn.d, 1, 1, 0) 34 TEST_FSGNJD(23, fsgnjn.d, 0, 1, 1) 35 36 TEST_FSGNJD(30, fsgnjx.d, 0, 0, 0) 37 TEST_FSGNJD(31, fsgnjx.d, 1, 0, 1) 38 TEST_FSGNJD(32, fsgnjx.d, 1, 1, 0) 39 TEST_FSGNJD(33, fsgnjx.d, 0, 1, 1) 40 41// Test fsgnj.s in conjunction with double-precision moves 42#define TEST_FSGNJS(n, rd, rs1, rs2) \ 43 TEST_CASE(n, a0, (rd) | (-((rd) >> 31) << 32), \ 44 li a1, rs1; \ 45 li a2, rs2; \ 46 fmv.d.x f1, a1; \ 47 fmv.d.x f2, a2; \ 48 fsgnj.s f0, f1, f2; \ 49 fmv.x.s a0, f0); \ 50 TEST_CASE(1##n, a0, (rd) | 0xffffffff00000000, \ 51 li a1, rs1; \ 52 li a2, rs2; \ 53 fmv.d.x f1, a1; \ 54 fmv.d.x f2, a2; \ 55 fsgnj.s f0, f1, f2; \ 56 fmv.x.d a0, f0) 57 58 TEST_FSGNJS(40, 0x7fc00000, 0x7ffffffe12345678, 0) 59 TEST_FSGNJS(41, 0x7fc00000, 0xfffffffe12345678, 0) 60 TEST_FSGNJS(42, 0x7fc00000, 0x7fffffff12345678, 0) 61 TEST_FSGNJS(43, 0x12345678, 0xffffffff12345678, 0) 62 63 TEST_FSGNJS(50, 0x7fc00000, 0x7ffffffe12345678, 0x80000000) 64 TEST_FSGNJS(51, 0x7fc00000, 0xfffffffe12345678, 0x80000000) 65 TEST_FSGNJS(52, 0x7fc00000, 0x7fffffff12345678, 0x80000000) 66 TEST_FSGNJS(53, 0x12345678, 0xffffffff12345678, 0x80000000) 67 68 TEST_FSGNJS(60, 0xffc00000, 0x7ffffffe12345678, 0xffffffff80000000) 69 TEST_FSGNJS(61, 0xffc00000, 0xfffffffe12345678, 0xffffffff80000000) 70 TEST_FSGNJS(62, 0x92345678, 0xffffffff12345678, 0xffffffff80000000) 71 TEST_FSGNJS(63, 0x12345678, 0xffffffff12345678, 0x7fffffff80000000) 72 73// Test fsgnj.d in conjunction with single-precision moves 74#define TEST_FSGNJD_SP(n, isnan, rd, rs1, rs2) \ 75 TEST_CASE(n, a0, ((rd) & 0xffffffff) | (-(((rd) >> 31) & 1) << 32), \ 76 li a1, rs1; \ 77 li a2, rs2; \ 78 fmv.d.x f1, a1; \ 79 fmv.d.x f2, a2; \ 80 fsgnj.d f0, f1, f2; \ 81 feq.s a0, f0, f0; \ 82 addi a0, a0, -!(isnan); \ 83 bnez a0, 1f; \ 84 fmv.x.s a0, f0; \ 85 1:); \ 86 TEST_CASE(1##n, a0, rd, \ 87 li a1, rs1; \ 88 li a2, rs2; \ 89 fmv.d.x f1, a1; \ 90 fmv.d.x f2, a2; \ 91 fsgnj.d f0, f1, f2; \ 92 fmv.x.d a0, f0; \ 93 1:) 94 95 TEST_FSGNJD_SP(70, 0, 0xffffffff11111111, 0xffffffff11111111, 0xffffffff11111111) 96 TEST_FSGNJD_SP(71, 1, 0x7fffffff11111111, 0xffffffff11111111, 0x7fffffff11111111) 97 TEST_FSGNJD_SP(72, 0, 0xffffffff11111111, 0xffffffff11111111, 0xffffffff91111111) 98 TEST_FSGNJD_SP(73, 0, 0xffffffff11111111, 0xffffffff11111111, 0x8000000000000000) 99 TEST_FSGNJD_SP(74, 0, 0xffffffff11111111, 0x7fffffff11111111, 0xffffffff11111111) 100 TEST_FSGNJD_SP(75, 1, 0x7fffffff11111111, 0x7fffffff11111111, 0x7fffffff11111111) 101 TEST_FSGNJD_SP(76, 0, 0xffffffff11111111, 0x7fffffff11111111, 0xffffffff91111111) 102 TEST_FSGNJD_SP(77, 0, 0xffffffff11111111, 0x7fffffff11111111, 0x8000000000000000) 103 104 TEST_PASSFAIL 105 106RVTEST_CODE_END 107 108 .data 109RVTEST_DATA_BEGIN 110 111 TEST_DATA 112 113RVTEST_DATA_END 114