12d934b59SBastian Koppelmann /* Helpers */ 22d934b59SBastian Koppelmann #define LI(reg, val) \ 32d934b59SBastian Koppelmann mov.u reg, lo:val; \ 42d934b59SBastian Koppelmann movh DREG_TEMP_LI, up:val; \ 52d934b59SBastian Koppelmann or reg, reg, DREG_TEMP_LI; \ 62d934b59SBastian Koppelmann 7*6dcb9922SBastian Koppelmann #define LIA(reg, val) \ 8*6dcb9922SBastian Koppelmann LI(DREG_TEMP, val) \ 9*6dcb9922SBastian Koppelmann mov.a reg, DREG_TEMP; 10*6dcb9922SBastian Koppelmann 112d934b59SBastian Koppelmann /* Address definitions */ 122d934b59SBastian Koppelmann #define TESTDEV_ADDR 0xf0000000 132d934b59SBastian Koppelmann /* Register definitions */ 142d934b59SBastian Koppelmann #define DREG_RS1 %d0 15f271aa62SBastian Koppelmann #define DREG_RS2 %d1 16fa581531SBastian Koppelmann #define DREG_RS3 %d2 17fa581531SBastian Koppelmann #define DREG_CALC_RESULT %d3 18fa581531SBastian Koppelmann #define DREG_CALC_PSW %d4 19fa581531SBastian Koppelmann #define DREG_CORRECT_PSW %d5 202d934b59SBastian Koppelmann #define DREG_TEMP_LI %d10 212d934b59SBastian Koppelmann #define DREG_TEMP %d11 222d934b59SBastian Koppelmann #define DREG_TEST_NUM %d14 232d934b59SBastian Koppelmann #define DREG_CORRECT_RESULT %d15 242d934b59SBastian Koppelmann 25*6dcb9922SBastian Koppelmann #define AREG_ADDR %a0 26*6dcb9922SBastian Koppelmann #define AREG_CORRECT_RESULT %a3 27*6dcb9922SBastian Koppelmann #define MEM_BASE_ADDR 0xd0000000 28*6dcb9922SBastian Koppelmann 292d934b59SBastian Koppelmann #define DREG_DEV_ADDR %a15 302d934b59SBastian Koppelmann 31d6f1593aSBastian Koppelmann #define EREG_RS1 %e6 32d6f1593aSBastian Koppelmann #define EREG_RS1_LO %d6 33d6f1593aSBastian Koppelmann #define EREG_RS1_HI %d7 34d6f1593aSBastian Koppelmann #define EREG_RS2 %e8 35d6f1593aSBastian Koppelmann #define EREG_RS2_LO %d8 36d6f1593aSBastian Koppelmann #define EREG_RS2_HI %d9 37d6f1593aSBastian Koppelmann #define EREG_CALC_RESULT %e8 38d6f1593aSBastian Koppelmann #define EREG_CALC_RESULT_HI %d9 39d6f1593aSBastian Koppelmann #define EREG_CALC_RESULT_LO %d8 40d6f1593aSBastian Koppelmann #define EREG_CORRECT_RESULT_LO %d0 41d6f1593aSBastian Koppelmann #define EREG_CORRECT_RESULT_HI %d1 42d6f1593aSBastian Koppelmann 432d934b59SBastian Koppelmann /* Test case wrappers */ 442d934b59SBastian Koppelmann #define TEST_CASE(num, testreg, correct, code...) \ 452d934b59SBastian Koppelmann test_ ## num: \ 462d934b59SBastian Koppelmann code; \ 472d934b59SBastian Koppelmann LI(DREG_CORRECT_RESULT, correct) \ 482d934b59SBastian Koppelmann mov DREG_TEST_NUM, num; \ 492d934b59SBastian Koppelmann jne testreg, DREG_CORRECT_RESULT, fail \ 502d934b59SBastian Koppelmann 51d6f1593aSBastian Koppelmann #define TEST_CASE_E(num, correct_lo, correct_hi, code...) \ 52d6f1593aSBastian Koppelmann test_ ## num: \ 53d6f1593aSBastian Koppelmann code; \ 54d6f1593aSBastian Koppelmann mov DREG_TEST_NUM, num; \ 55d6f1593aSBastian Koppelmann LI(EREG_CORRECT_RESULT_LO, correct_lo) \ 56d6f1593aSBastian Koppelmann jne EREG_CALC_RESULT_LO, EREG_CORRECT_RESULT_LO, fail; \ 57d6f1593aSBastian Koppelmann LI(EREG_CORRECT_RESULT_HI, correct_hi) \ 58d6f1593aSBastian Koppelmann jne EREG_CALC_RESULT_HI, EREG_CORRECT_RESULT_HI, fail; 59d6f1593aSBastian Koppelmann 60f271aa62SBastian Koppelmann #define TEST_CASE_PSW(num, testreg, correct, correct_psw, code...) \ 61f271aa62SBastian Koppelmann test_ ## num: \ 62f271aa62SBastian Koppelmann code; \ 63f271aa62SBastian Koppelmann LI(DREG_CORRECT_RESULT, correct) \ 64f271aa62SBastian Koppelmann mov DREG_TEST_NUM, num; \ 65f271aa62SBastian Koppelmann jne testreg, DREG_CORRECT_RESULT, fail; \ 66f271aa62SBastian Koppelmann mfcr DREG_CALC_PSW, $psw; \ 67f271aa62SBastian Koppelmann LI(DREG_CORRECT_PSW, correct_psw) \ 68f271aa62SBastian Koppelmann mov DREG_TEST_NUM, num; \ 69f271aa62SBastian Koppelmann jne DREG_CALC_PSW, DREG_CORRECT_PSW, fail; 70f271aa62SBastian Koppelmann 71*6dcb9922SBastian Koppelmann #define TEST_LD(insn, num, result, addr_result, ld_pattern) \ 72*6dcb9922SBastian Koppelmann test_ ## num: \ 73*6dcb9922SBastian Koppelmann LIA(AREG_ADDR, test_data) \ 74*6dcb9922SBastian Koppelmann insn DREG_CALC_RESULT, ld_pattern; \ 75*6dcb9922SBastian Koppelmann LI(DREG_CORRECT_RESULT, result) \ 76*6dcb9922SBastian Koppelmann mov DREG_TEST_NUM, num; \ 77*6dcb9922SBastian Koppelmann jne DREG_CALC_RESULT, DREG_CORRECT_RESULT, fail; \ 78*6dcb9922SBastian Koppelmann mov.d DREG_CALC_RESULT, AREG_ADDR; \ 79*6dcb9922SBastian Koppelmann LI(DREG_CORRECT_RESULT, addr_result) \ 80*6dcb9922SBastian Koppelmann jne DREG_CALC_RESULT, DREG_CORRECT_RESULT, fail; 81*6dcb9922SBastian Koppelmann 822d934b59SBastian Koppelmann /* Actual test case type 832d934b59SBastian Koppelmann * e.g inst %dX, %dY -> TEST_D_D 842d934b59SBastian Koppelmann * inst %dX, %dY, %dZ -> TEST_D_DD 852d934b59SBastian Koppelmann * inst %eX, %dY, %dZ -> TEST_E_DD 862d934b59SBastian Koppelmann */ 87*6dcb9922SBastian Koppelmann 88*6dcb9922SBastian Koppelmann 892d934b59SBastian Koppelmann #define TEST_D_D(insn, num, result, rs1) \ 902d934b59SBastian Koppelmann TEST_CASE(num, DREG_CALC_RESULT, result, \ 912d934b59SBastian Koppelmann LI(DREG_RS1, rs1); \ 922d934b59SBastian Koppelmann insn DREG_CALC_RESULT, DREG_RS1; \ 932d934b59SBastian Koppelmann ) 942d934b59SBastian Koppelmann 9555f037a5SBastian Koppelmann #define TEST_D_D_PSW(insn, num, result, psw, rs1) \ 9655f037a5SBastian Koppelmann TEST_CASE_PSW(num, DREG_CALC_RESULT, result, psw, \ 9755f037a5SBastian Koppelmann LI(DREG_RS1, rs1); \ 9855f037a5SBastian Koppelmann rstv; \ 9955f037a5SBastian Koppelmann insn DREG_CORRECT_RESULT, DREG_RS1; \ 10055f037a5SBastian Koppelmann ) 10155f037a5SBastian Koppelmann 1027ebe4cb3SBastian Koppelmann #define TEST_D_DDD(insn, num, result, rs1, rs2, rs3) \ 1037ebe4cb3SBastian Koppelmann TEST_CASE(num, DREG_CALC_RESULT, result, \ 1047ebe4cb3SBastian Koppelmann LI(DREG_RS1, rs1); \ 1057ebe4cb3SBastian Koppelmann LI(DREG_RS2, rs2); \ 1067ebe4cb3SBastian Koppelmann LI(DREG_RS3, rs3); \ 1077ebe4cb3SBastian Koppelmann rstv; \ 1087ebe4cb3SBastian Koppelmann insn DREG_CALC_RESULT, DREG_RS1, DREG_RS2, DREG_RS3; \ 1097ebe4cb3SBastian Koppelmann ) 1107ebe4cb3SBastian Koppelmann 111f271aa62SBastian Koppelmann #define TEST_D_DD_PSW(insn, num, result, psw, rs1, rs2) \ 112f271aa62SBastian Koppelmann TEST_CASE_PSW(num, DREG_CALC_RESULT, result, psw, \ 113f271aa62SBastian Koppelmann LI(DREG_RS1, rs1); \ 114f271aa62SBastian Koppelmann LI(DREG_RS2, rs2); \ 115f271aa62SBastian Koppelmann rstv; \ 116f271aa62SBastian Koppelmann insn DREG_CALC_RESULT, DREG_RS1, DREG_RS2; \ 117f271aa62SBastian Koppelmann ) 118f271aa62SBastian Koppelmann 1196ad6701cSBastian Koppelmann #define TEST_D_DDD_PSW(insn, num, result, psw, rs1, rs2, rs3) \ 1206ad6701cSBastian Koppelmann TEST_CASE_PSW(num, DREG_CALC_RESULT, result, psw, \ 1216ad6701cSBastian Koppelmann LI(DREG_RS1, rs1); \ 1226ad6701cSBastian Koppelmann LI(DREG_RS2, rs2); \ 1236ad6701cSBastian Koppelmann LI(DREG_RS3, rs3); \ 1246ad6701cSBastian Koppelmann rstv; \ 1256ad6701cSBastian Koppelmann insn DREG_CALC_RESULT, DREG_RS1, DREG_RS2, DREG_RS3; \ 1266ad6701cSBastian Koppelmann ) 1276ad6701cSBastian Koppelmann 12870447df9SBastian Koppelmann #define TEST_D_DDI(insn, num, result, rs1, rs2, imm) \ 12970447df9SBastian Koppelmann TEST_CASE(num, DREG_CALC_RESULT, result, \ 13070447df9SBastian Koppelmann LI(DREG_RS1, rs1); \ 13170447df9SBastian Koppelmann LI(DREG_RS2, rs2); \ 13270447df9SBastian Koppelmann rstv; \ 13370447df9SBastian Koppelmann insn DREG_CALC_RESULT, DREG_RS1, DREG_RS2, imm; \ 13470447df9SBastian Koppelmann ) 13570447df9SBastian Koppelmann 1366ad6701cSBastian Koppelmann #define TEST_D_DDI_PSW(insn, num, result, psw, rs1, rs2, imm) \ 1376ad6701cSBastian Koppelmann TEST_CASE_PSW(num, DREG_CALC_RESULT, result, psw, \ 1386ad6701cSBastian Koppelmann LI(DREG_RS1, rs1); \ 1396ad6701cSBastian Koppelmann LI(DREG_RS2, rs2); \ 1406ad6701cSBastian Koppelmann rstv; \ 1416ad6701cSBastian Koppelmann insn DREG_CALC_RESULT, DREG_RS1, DREG_RS2, imm; \ 1426ad6701cSBastian Koppelmann ) 1436ad6701cSBastian Koppelmann 144fa581531SBastian Koppelmann #define TEST_D_DIDI(insn, num, result, rs1, imm1, rs2, imm2) \ 145fa581531SBastian Koppelmann TEST_CASE(num, DREG_CALC_RESULT, result, \ 146fa581531SBastian Koppelmann LI(DREG_RS1, rs1); \ 147fa581531SBastian Koppelmann LI(DREG_RS2, rs1); \ 148fa581531SBastian Koppelmann rstv; \ 149fa581531SBastian Koppelmann insn DREG_CALC_RESULT, DREG_RS1, imm1, DREG_RS2, imm2; \ 150fa581531SBastian Koppelmann ) 151fa581531SBastian Koppelmann 152d6f1593aSBastian Koppelmann #define TEST_E_ED(insn, num, res_hi, res_lo, rs1_hi, rs1_lo, rs2) \ 153d6f1593aSBastian Koppelmann TEST_CASE_E(num, res_lo, res_hi, \ 154d6f1593aSBastian Koppelmann LI(EREG_RS1_LO, rs1_lo); \ 155d6f1593aSBastian Koppelmann LI(EREG_RS1_HI, rs1_hi); \ 156d6f1593aSBastian Koppelmann LI(DREG_RS2, rs2); \ 157d6f1593aSBastian Koppelmann insn EREG_CALC_RESULT, EREG_RS1, DREG_RS2; \ 158d6f1593aSBastian Koppelmann ) 159f271aa62SBastian Koppelmann 16076f7f548SBastian Koppelmann #define TEST_E_IDI(insn, num, res_hi, res_lo, imm1, rs1, imm2) \ 16176f7f548SBastian Koppelmann TEST_CASE_E(num, res_lo, res_hi, \ 16276f7f548SBastian Koppelmann LI(DREG_RS1, rs1); \ 16376f7f548SBastian Koppelmann rstv; \ 16476f7f548SBastian Koppelmann insn EREG_CALC_RESULT, imm1, DREG_RS1, imm2); \ 16576f7f548SBastian Koppelmann ) 16676f7f548SBastian Koppelmann 167*6dcb9922SBastian Koppelmann 168*6dcb9922SBastian Koppelmann 1692d934b59SBastian Koppelmann /* Pass/Fail handling part */ 1702d934b59SBastian Koppelmann #define TEST_PASSFAIL \ 1712d934b59SBastian Koppelmann j pass; \ 1722d934b59SBastian Koppelmann fail: \ 1732d934b59SBastian Koppelmann LI(DREG_TEMP, TESTDEV_ADDR) \ 1742d934b59SBastian Koppelmann mov.a DREG_DEV_ADDR, DREG_TEMP; \ 1752d934b59SBastian Koppelmann st.w [DREG_DEV_ADDR], DREG_TEST_NUM;\ 1762d934b59SBastian Koppelmann debug; \ 1772d934b59SBastian Koppelmann j fail; \ 1782d934b59SBastian Koppelmann pass: \ 1792d934b59SBastian Koppelmann LI(DREG_TEMP, TESTDEV_ADDR) \ 1802d934b59SBastian Koppelmann mov.a DREG_DEV_ADDR, DREG_TEMP; \ 1812d934b59SBastian Koppelmann mov DREG_TEST_NUM, 0; \ 1822d934b59SBastian Koppelmann st.w [DREG_DEV_ADDR], DREG_TEST_NUM;\ 1832d934b59SBastian Koppelmann debug; \ 1842d934b59SBastian Koppelmann j pass; 185