diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2019-03-05 21:07:29 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2019-03-05 21:07:29 +0000 |
commit | b5b6b2b912bbcd3953407da938a8f969577ad3a1 (patch) | |
tree | 57900df799ddbb06c25c34bf0a90842646806f63 | |
parent | a3e3b0a7bd5de211a62cdf2d6c12b96d3c403560 (diff) | |
parent | 0fdd986a6c8f921693d025c3f095a0eaf628b6b6 (diff) |
Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-mar-05-2019' into staging
MIPS queue for March 5th, 2019
# gpg: Signature made Tue 05 Mar 2019 16:06:34 GMT
# gpg: using RSA key D4972A8967F75A65
# gpg: Good signature from "Aleksandar Markovic <amarkovic@wavecomp.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8526 FBF1 5DA3 811F 4A01 DD75 D497 2A89 67F7 5A65
* remotes/amarkovic/tags/mips-queue-mar-05-2019:
target/mips: Add tests for integer add MSA instruction group
tests/tcg: target/mips: Add tests for MSA pack instructions
tests/tcg: target/mips: Add tests for MIPS64R6 int multiply instructions
tests/tcg: target/mips: Add tests for MIPS64R6 shift instructions
tests/tcg: target/mips: Add tests for MIPS64R6 bit count instructions
tests/tcg: target/mips: Add tests for MIPS64R6 bit swap instructions
tests/tcg: target/mips: Add tests for MIPS64R6 logic instructions
tests/tcg: target/mips: Add wrappers for some MIPS64R6 instructions
tests/tcg: target/mips: Extend functionality of MSA wrapper macros
tests/tcg: target/mips: Fix test utilities for 128-bit tests
tests/tcg: target/mips: Add test utilities for 64-bit tests
tests/tcg: target/mips: Add test utilities for 32-bit tests
tests/tcg: target/mips: Add wrappers for various MSA instructions
disas: nanoMIPS: Add graphical description of pool organization
disas: nanoMIPS: Correct comments to handlers of some DSP instructions
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
71 files changed, 10376 insertions, 213 deletions
diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp index f090f61c76..c8495b1a19 100644 --- a/disas/nanomips.cpp +++ b/disas/nanomips.cpp @@ -3452,14 +3452,14 @@ std::string NMD::BNEZC_16_(uint64 instruction) /* - * + * [DSP] BPOSGE32C offset - Branch on greater than or equal to value 32 in + * DSPControl Pos field * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 - * rt ----- - * rs ----- - * rd ----- + * 100010xxxxx0010001 + * s[13:1] ------------- + * s[14] - */ std::string NMD::BPOSGE32C(uint64 instruction) { @@ -3872,14 +3872,13 @@ std::string NMD::CMP_EQ_D(uint64 instruction) /* - * + * [DSP] CMP.EQ.PH rs, rt - Compare vectors of signed integer halfword values * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 xxxxxx0000000101 * rt ----- * rs ----- - * rd ----- */ std::string NMD::CMP_EQ_PH(uint64 instruction) { @@ -3942,14 +3941,13 @@ std::string NMD::CMP_LE_D(uint64 instruction) /* - * + * [DSP] CMP.LE.PH rs, rt - Compare vectors of signed integer halfword values * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 xxxxxx0010000101 * rt ----- * rs ----- - * rd ----- */ std::string NMD::CMP_LE_PH(uint64 instruction) { @@ -4012,14 +4010,13 @@ std::string NMD::CMP_LT_D(uint64 instruction) /* - * + * [DSP] CMP.LT.PH rs, rt - Compare vectors of signed integer halfword values * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 xxxxxx0001000101 * rt ----- * rs ----- - * rd ----- */ std::string NMD::CMP_LT_PH(uint64 instruction) { @@ -4922,11 +4919,12 @@ std::string NMD::CMP_UN_S(uint64 instruction) /* - * + * [DSP] CMPGDU.EQ.QB rd, rs, rt - Compare unsigned vector of + * four bytes and write result to GPR and DSPControl * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x0110000101 * rt ----- * rs ----- * rd ----- @@ -4946,11 +4944,12 @@ std::string NMD::CMPGDU_EQ_QB(uint64 instruction) /* - * + * [DSP] CMPGDU.LE.QB rd, rs, rt - Compare unsigned vector of + * four bytes and write result to GPR and DSPControl * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x1000000101 * rt ----- * rs ----- * rd ----- @@ -4970,11 +4969,12 @@ std::string NMD::CMPGDU_LE_QB(uint64 instruction) /* - * + * [DSP] CMPGDU.EQ.QB rd, rs, rt - Compare unsigned vector of + * four bytes and write result to GPR and DSPControl * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x0111000101 * rt ----- * rs ----- * rd ----- @@ -4994,11 +4994,12 @@ std::string NMD::CMPGDU_LT_QB(uint64 instruction) /* - * + * [DSP] CMPGU.EQ.QB rd, rs, rt - Compare vectors of unsigned + * byte values and write result to a GPR * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x0011000101 * rt ----- * rs ----- * rd ----- @@ -5018,11 +5019,12 @@ std::string NMD::CMPGU_EQ_QB(uint64 instruction) /* - * + * [DSP] CMPGU.LE.QB rd, rs, rt - Compare vectors of unsigned + * byte values and write result to a GPR * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x0101000101 * rt ----- * rs ----- * rd ----- @@ -5042,11 +5044,12 @@ std::string NMD::CMPGU_LE_QB(uint64 instruction) /* - * + * [DSP] CMPGU.LT.QB rd, rs, rt - Compare vectors of unsigned + * byte values and write result to a GPR * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x0100000101 * rt ----- * rs ----- * rd ----- @@ -5066,14 +5069,14 @@ std::string NMD::CMPGU_LT_QB(uint64 instruction) /* - * + * [DSP] CMPU.EQ.QB rd, rs, rt - Compare vectors of unsigned + * byte values * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 xxxxxx1001000101 * rt ----- * rs ----- - * rd ----- */ std::string NMD::CMPU_EQ_QB(uint64 instruction) { @@ -5088,14 +5091,14 @@ std::string NMD::CMPU_EQ_QB(uint64 instruction) /* - * + * [DSP] CMPU.LE.QB rd, rs, rt - Compare vectors of unsigned + * byte values * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 xxxxxx1011000101 * rt ----- * rs ----- - * rd ----- */ std::string NMD::CMPU_LE_QB(uint64 instruction) { @@ -5110,14 +5113,14 @@ std::string NMD::CMPU_LE_QB(uint64 instruction) /* - * + * [DSP] CMPU.LT.QB rd, rs, rt - Compare vectors of unsigned + * byte values * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 xxxxxx1010000101 * rt ----- * rs ----- - * rd ----- */ std::string NMD::CMPU_LT_QB(uint64 instruction) { @@ -6362,14 +6365,15 @@ std::string NMD::DMULU(uint64 instruction) /* - * + * [DSP] DPA.W.PH ac, rs, rt - Dot product with accumulate on + * vector integer halfword elements * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 00000010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::DPA_W_PH(uint64 instruction) { @@ -7456,14 +7460,15 @@ std::string NMD::EXTPV(uint64 instruction) /* - * + * [DSP] EXTR_RS.W rt, ac, shift - Extract word value from accumulator to GPR + * with right shift * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 10111001111111 * rt ----- - * rs ----- - * rd ----- + * shift ----- + * ac -- */ std::string NMD::EXTR_RS_W(uint64 instruction) { @@ -7480,14 +7485,15 @@ std::string NMD::EXTR_RS_W(uint64 instruction) /* - * + * [DSP] EXTR_R.W rt, ac, shift - Extract word value from accumulator to GPR + * with right shift * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 01111001111111 * rt ----- - * rs ----- - * rd ----- + * shift ----- + * ac -- */ std::string NMD::EXTR_R_W(uint64 instruction) { @@ -7504,14 +7510,15 @@ std::string NMD::EXTR_R_W(uint64 instruction) /* - * + * [DSP] EXTR_S.H rt, ac, shift - Extract halfword value from accumulator + * to GPR with right shift and saturate * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 11111001111111 * rt ----- - * rs ----- - * rd ----- + * shift ----- + * ac -- */ std::string NMD::EXTR_S_H(uint64 instruction) { @@ -7528,14 +7535,15 @@ std::string NMD::EXTR_S_H(uint64 instruction) /* - * + * [DSP] EXTR.W rt, ac, shift - Extract word value from accumulator to GPR + * with right shift * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 00111001111111 * rt ----- - * rs ----- - * rd ----- + * shift ----- + * ac -- */ std::string NMD::EXTR_W(uint64 instruction) { @@ -7552,14 +7560,15 @@ std::string NMD::EXTR_W(uint64 instruction) /* - * + * [DSP] EXTRV_RS.W rt, ac, rs - Extract word value with variable + * right shift from accumulator to GPR * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 10111010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::EXTRV_RS_W(uint64 instruction) { @@ -7576,14 +7585,15 @@ std::string NMD::EXTRV_RS_W(uint64 instruction) /* - * + * [DSP] EXTRV_R.W rt, ac, rs - Extract word value with variable + * right shift from accumulator to GPR * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 01111010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::EXTRV_R_W(uint64 instruction) { @@ -7600,14 +7610,15 @@ std::string NMD::EXTRV_R_W(uint64 instruction) /* - * + * [DSP] EXTRV_S.H rt, ac, rs - Extract halfword value variable from + * accumulator to GPR with right shift and saturate * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 11111010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::EXTRV_S_H(uint64 instruction) { @@ -7624,14 +7635,15 @@ std::string NMD::EXTRV_S_H(uint64 instruction) /* - * + * [DSP] EXTRV.W rt, ac, rs - Extract word value with variable + * right shift from accumulator to GPR * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 00111010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::EXTRV_W(uint64 instruction) { @@ -7855,14 +7867,13 @@ std::string NMD::INS(uint64 instruction) /* - * [DSP] INSV - Insert bit field variable + * [DSP] INSV rt, rs - Insert bit field variable * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 0100000100111111 * rt ----- * rs ----- - * rd ----- */ std::string NMD::INSV(uint64 instruction) { @@ -10183,14 +10194,13 @@ std::string NMD::MFHGC0(uint64 instruction) /* - * + * [DSP] MFHI rs, ac - Move from HI register * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 xxxxx 00000001111111 * rt ----- - * rs ----- - * rd ----- + * ac -- */ std::string NMD::MFHI_DSP_(uint64 instruction) { @@ -10231,14 +10241,13 @@ std::string NMD::MFHTR(uint64 instruction) /* - * + * [DSP] MFLO rs, ac - Move from HI register * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 xxxxx 01000001111111 * rt ----- - * rs ----- - * rd ----- + * ac -- */ std::string NMD::MFLO_DSP_(uint64 instruction) { @@ -10399,7 +10408,7 @@ std::string NMD::MOD(uint64 instruction) /* - * + * [DSP] MODSUB rd, rs, rt - Modular subtraction on an index value * * 3 2 1 * 10987654321098765432109876543210 @@ -10427,7 +10436,7 @@ std::string NMD::MODSUB(uint64 instruction) * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x1010010101 * rt ----- * rs ----- * rd ----- @@ -10639,14 +10648,14 @@ std::string NMD::MOVZ(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MSUB ac, rs, rt - Multiply word and subtract from accumulator * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 10101010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::MSUB_DSP_(uint64 instruction) { @@ -10711,14 +10720,14 @@ std::string NMD::MSUBF_S(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MSUBU ac, rs, rt - Multiply word and add to accumulator * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 11101010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::MSUBU_DSP_(uint64 instruction) { @@ -10919,14 +10928,13 @@ std::string NMD::MTHGC0(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MTHI rs, ac - Move to HI register * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 - * rt ----- + * 001000xxxxx 10000001111111 * rs ----- - * rd ----- + * ac -- */ std::string NMD::MTHI_DSP_(uint64 instruction) { @@ -10941,14 +10949,13 @@ std::string NMD::MTHI_DSP_(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MTHLIP rs, ac - Copy LO to HI and a GPR to LO and increment pos by 32 * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 - * rt ----- + * 001000xxxxx 00001001111111 * rs ----- - * rd ----- + * ac -- */ std::string NMD::MTHLIP(uint64 instruction) { @@ -10989,14 +10996,13 @@ std::string NMD::MTHTR(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MTLO rs, ac - Move to LO register * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 - * rt ----- + * 001000xxxxx 11000001111111 * rs ----- - * rd ----- + * ac -- */ std::string NMD::MTLO_DSP_(uint64 instruction) { @@ -11155,11 +11161,12 @@ std::string NMD::MUL_D(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MUL.PH rd, rs, rt - Multiply vector integer half words to same size + * products * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 00000101101 * rt ----- * rs ----- * rd ----- @@ -11179,11 +11186,12 @@ std::string NMD::MUL_PH(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MUL_S.PH rd, rs, rt - Multiply vector integer half words to same size + * products (saturated) * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 10000101101 * rt ----- * rs ----- * rd ----- @@ -11227,11 +11235,12 @@ std::string NMD::MUL_S(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULEQ_S.W.PHL rd, rs, rt - Multiply vector fractional left halfwords + * to expanded width products * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 x0000100101 * rt ----- * rs ----- * rd ----- @@ -11251,11 +11260,12 @@ std::string NMD::MULEQ_S_W_PHL(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULEQ_S.W.PHR rd, rs, rt - Multiply vector fractional right halfwords + * to expanded width products * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 x0001100101 * rt ----- * rs ----- * rd ----- @@ -11275,11 +11285,12 @@ std::string NMD::MULEQ_S_W_PHR(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULEU_S.PH.QBL rd, rs, rt - Multiply vector fractional left bytes + * by halfwords to halfword products * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 x0010010101 * rt ----- * rs ----- * rd ----- @@ -11299,11 +11310,12 @@ std::string NMD::MULEU_S_PH_QBL(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULEU_S.PH.QBR rd, rs, rt - Multiply vector fractional right bytes + * by halfwords to halfword products * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 x0011010101 * rt ----- * rs ----- * rd ----- @@ -11323,11 +11335,12 @@ std::string NMD::MULEU_S_PH_QBR(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULQ_RS.PH rd, rs, rt - Multiply vector fractional halfwords + * to fractional halfword products * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 x0100010101 * rt ----- * rs ----- * rd ----- @@ -11347,11 +11360,12 @@ std::string NMD::MULQ_RS_PH(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULQ_RS.W rd, rs, rt - Multiply fractional words to same size + * product with saturation and rounding * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 x0110010101 * rt ----- * rs ----- * rd ----- @@ -11371,11 +11385,12 @@ std::string NMD::MULQ_RS_W(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULQ_S.PH rd, rs, rt - Multiply fractional halfwords to same size + * products * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 x0101010101 * rt ----- * rs ----- * rd ----- @@ -11395,11 +11410,12 @@ std::string NMD::MULQ_S_PH(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULQ_S.W rd, rs, rt - Multiply fractional words to same size product + * with saturation * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 x0111010101 * rt ----- * rs ----- * rd ----- @@ -11419,14 +11435,15 @@ std::string NMD::MULQ_S_W(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULSA.W.PH ac, rs, rt - Multiply and subtract vector integer halfword + * elements and accumulate * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 10110010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::MULSA_W_PH(uint64 instruction) { @@ -11443,14 +11460,15 @@ std::string NMD::MULSA_W_PH(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULSAQ_S.W.PH ac, rs, rt - Multiply and subtract vector fractional + * halfwords and accumulate * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 11110010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::MULSAQ_S_W_PH(uint64 instruction) { @@ -11467,14 +11485,14 @@ std::string NMD::MULSAQ_S_W_PH(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULT ac, rs, rt - Multiply word * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 00110010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::MULT_DSP_(uint64 instruction) { @@ -11491,14 +11509,14 @@ std::string NMD::MULT_DSP_(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] MULTU ac, rs, rt - Multiply unsigned word * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 01110010111111 * rt ----- * rs ----- - * rd ----- + * ac -- */ std::string NMD::MULTU_DSP_(uint64 instruction) { @@ -12060,11 +12078,12 @@ std::string NMD::PRECEU_PH_QBR(uint64 instruction) /* - * ADDQH_R.W rd, rt, rs - Add Fractional Words And Shift Right to Halve Results + * [DSP] PRECR.QB.PH rd, rs, rt - Reduce the precision of four integer + * halfwords to four bytes * * 3 2 1 * 10987654321098765432109876543210 - * 001000 00010001101 + * 001000 x0001101101 * rt ----- * rs ----- * rd ----- @@ -12084,7 +12103,8 @@ std::string NMD::PRECR_QB_PH(uint64 instruction) /* - * + * [DSP] PRECR_SRA.PH.W rt, rs, sa - Reduce the precision of two integer + * words to halfwords after a right shift * * 3 2 1 * 10987654321098765432109876543210 @@ -12108,7 +12128,8 @@ std::string NMD::PRECR_SRA_PH_W(uint64 instruction) /* - * + * [DSP] PRECR_SRA_R.PH.W rt, rs, sa - Reduce the precision of two integer + * words to halfwords after a right shift with rounding * * 3 2 1 * 10987654321098765432109876543210 @@ -12132,7 +12153,8 @@ std::string NMD::PRECR_SRA_R_PH_W(uint64 instruction) /* - * + * [DSP] PRECRQ.PH.W rd, rs, rt - Reduce the precision of fractional + * words to fractional halfwords * * 3 2 1 * 10987654321098765432109876543210 @@ -12156,11 +12178,12 @@ std::string NMD::PRECRQ_PH_W(uint64 instruction) /* - * + * [DSP] PRECRQ.QB.PH rd, rs, rt - Reduce the precision of four fractional + * halfwords to four bytes * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x0010101101 * rt ----- * rs ----- * rd ----- @@ -12180,7 +12203,8 @@ std::string NMD::PRECRQ_QB_PH(uint64 instruction) /* - * + * [DSP] PRECRQ_RS.PH.W rd, rs, rt - Reduce the precision of fractional + * words to halfwords with rounding and saturation * * 3 2 1 * 10987654321098765432109876543210 @@ -12204,7 +12228,8 @@ std::string NMD::PRECRQ_RS_PH_W(uint64 instruction) /* - * + * [DSP] PRECRQU_S.QB.PH rd, rs, rt - Reduce the precision of fractional + * halfwords to unsigned bytes with saturation * * 3 2 1 * 10987654321098765432109876543210 @@ -12300,7 +12325,7 @@ std::string NMD::PREFE(uint64 instruction) /* - * + * [DSP] PREPEND rt, rs, sa - Right shift and prepend bits to the MSB * * 3 2 1 * 10987654321098765432109876543210 @@ -12324,14 +12349,13 @@ std::string NMD::PREPEND(uint64 instruction) /* - * + * [DSP] RADDU.W.QB rt, rs - Unsigned reduction add of vector quad bytes * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 1111000100111111 * rt ----- * rs ----- - * rd ----- */ std::string NMD::RADDU_W_QB(uint64 instruction) { @@ -12346,14 +12370,13 @@ std::string NMD::RADDU_W_QB(uint64 instruction) /* - * + * [DSP] RDDSP rt, mask - Read DSPControl register fields to a GPR * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 00011001111111 * rt ----- - * rs ----- - * rd ----- + * mask ------- */ std::string NMD::RDDSP(uint64 instruction) { @@ -12458,14 +12481,14 @@ std::string NMD::RECIP_S(uint64 instruction) /* - * + * [DSP] REPL.PH rd, s - Replicate immediate integer into all vector element + * positions * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x0000111101 * rt ----- - * rs ----- - * rd ----- + * s ---------- */ std::string NMD::REPL_PH(uint64 instruction) { @@ -12480,14 +12503,14 @@ std::string NMD::REPL_PH(uint64 instruction) /* - * + * [DSP] REPL.QB rd, u - Replicate immediate integer into all vector element + * positions * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 x010111111111 * rt ----- - * rs ----- - * rd ----- + * u -------- */ std::string NMD::REPL_QB(uint64 instruction) { @@ -12502,14 +12525,14 @@ std::string NMD::REPL_QB(uint64 instruction) /* - * + * [DSP] REPLV.PH rt, rs - Replicate a halfword into all vector element + * positions * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 0000001100111111 * rt ----- * rs ----- - * rd ----- */ std::string NMD::REPLV_PH(uint64 instruction) { @@ -12524,14 +12547,13 @@ std::string NMD::REPLV_PH(uint64 instruction) /* - * + * [DSP] REPLV.QB rt, rs - Replicate byte into all vector element positions * * 3 2 1 * 10987654321098765432109876543210 - * 001000 x1110000101 + * 001000 0001001100111111 * rt ----- * rs ----- - * rd ----- */ std::string NMD::REPLV_QB(uint64 instruction) { @@ -13920,8 +13942,8 @@ std::string NMD::SHE(uint64 instruction) /* - * SHILO ac, shift - Shift an Accumulator Value Leaving the Result in the Same - * Accumulator + * [DSP] SHILO ac, shift - Shift an accumulator value leaving the result in + * the same accumulator * * 3 2 1 * 10987654321098765432109876543210 @@ -13942,8 +13964,8 @@ std::string NMD::SHILO(uint64 instruction) /* - * SHILOV ac, rs - Variable Shift of Accumulator Value Leaving the Result in - * the Same Accumulator + * [DSP] SHILOV ac, rs - Variable shift of accumulator value leaving the result + * in the same accumulator * * 3 2 1 * 10987654321098765432109876543210 @@ -13964,7 +13986,7 @@ std::string NMD::SHILOV(uint64 instruction) /* - * SHLL.PH rt, rs, sa - Shift Left Logical Vector Pair Halfwords + * [DSP] SHLL.PH rt, rs, sa - Shift left logical vector pair halfwords * * 3 2 1 * 10987654321098765432109876543210 @@ -13988,7 +14010,7 @@ std::string NMD::SHLL_PH(uint64 instruction) /* - * SHLL.QB rt, rs, sa - Shift Left Logical Vector Quad Bytes + * [DSP] SHLL.QB rt, rs, sa - Shift left logical vector quad bytes * * 3 2 1 * 10987654321098765432109876543210 @@ -14012,7 +14034,8 @@ std::string NMD::SHLL_QB(uint64 instruction) /* - * SHLL_S.PH rt, rs, sa - Shift Left Logical Vector Pair Halfwords (saturated) + * [DSP] SHLL_S.PH rt, rs, sa - Shift left logical vector pair halfwords + * with saturation * * 3 2 1 * 10987654321098765432109876543210 @@ -14036,14 +14059,14 @@ std::string NMD::SHLL_S_PH(uint64 instruction) /* - * + * [DSP] SHLL_S.PH rt, rs, sa - Shift left logical word with saturation * * 3 2 1 * 10987654321098765432109876543210 - * 001000 01001001101 + * 001000 x1111110101 * rt ----- * rs ----- - * rd ----- + * sa ----- */ std::string NMD::SHLL_S_W(uint64 instruction) { @@ -14060,11 +14083,12 @@ std::string NMD::SHLL_S_W(uint64 instruction) /* - * + * [DSP] SHLLV.PH rd, rt, rs - Shift left logical variable vector pair + * halfwords * * 3 2 1 * 10987654321098765432109876543210 - * 001000 01001001101 + * 001000 01110001101 * rt ----- * rs ----- * rd ----- @@ -14084,11 +14108,11 @@ std::string NMD::SHLLV_PH(uint64 instruction) /* - * + * [DSP] SHLLV_S.QB rd, rt, rs - Shift left logical variable vector quad bytes * * 3 2 1 * 10987654321098765432109876543210 - * 001000 01001001101 + * 001000 x1110010101 * rt ----- * rs ----- * rd ----- @@ -14108,11 +14132,12 @@ std::string NMD::SHLLV_QB(uint64 instruction) /* - * + * [DSP] SHLLV.PH rd, rt, rs - Shift left logical variable vector pair + * halfwords with saturation * * 3 2 1 * 10987654321098765432109876543210 - * 001000 01001001101 + * 001000 11110001101 * rt ----- * rs ----- * rd ----- @@ -14132,11 +14157,11 @@ std::string NMD::SHLLV_S_PH(uint64 instruction) /* - * + * [DSP] SHLLV_S.W rd, rt, rs - Shift left logical variable vector word * * 3 2 1 * 10987654321098765432109876543210 - * 001000 01001001101 + * 001000 x1111010101 * rt ----- * rs ----- * rd ----- @@ -14396,14 +14421,14 @@ std::string NMD::SHRAV_R_W(uint64 instruction) /* - * + * [DSP] SHRL.PH rt, rs, sa - Shift right logical two halfwords * * 3 2 1 * 10987654321098765432109876543210 - * 001000 01001001101 + * 001000 001111111111 * rt ----- * rs ----- - * rd ----- + * sa ---- */ std::string NMD::SHRL_PH(uint64 instruction) { @@ -14420,14 +14445,14 @@ std::string NMD::SHRL_PH(uint64 instruction) /* - * + * [DSP] SHRL.QB rt, rs, sa - Shift right logical vector quad bytes * * 3 2 1 * 10987654321098765432109876543210 - * 001000 01001001101 + * 001000 1100001111111 * rt ----- * rs ----- - * rd ----- + * sa --- */ std::string NMD::SHRL_QB(uint64 instruction) { @@ -14444,11 +14469,12 @@ std::string NMD::SHRL_QB(uint64 instruction) /* - * + * [DSP] SHLLV.PH rd, rt, rs - Shift right logical variable vector pair of + * halfwords * * 3 2 1 * 10987654321098765432109876543210 - * 001000 01001001101 + * 001000 x1100010101 * rt ----- * rs ----- * rd ----- @@ -14468,11 +14494,11 @@ std::string NMD::SHRLV_PH(uint64 instruction) /* - * + * [DSP] SHLLV.QB rd, rt, rs - Shift right logical variable vector quad bytes * * 3 2 1 * 10987654321098765432109876543210 - * 001000 01001001101 + * 001000 x1101010101 * rt ----- * rs ----- * rd ----- @@ -15032,8 +15058,8 @@ std::string NMD::SUBQ_PH(uint64 instruction) /* - * SUBQH.PH rd, rt, rs - Subtract Fractional Halfword Vectors And Shift Right - * to Halve Results + * [DSP] SUBQ.S.PH rd, rt, rs - Subtract fractional halfword vectors and shift + * right to halve results * * 3 2 1 * 10987654321098765432109876543210 @@ -15057,8 +15083,8 @@ std::string NMD::SUBQ_S_PH(uint64 instruction) /* - * SUBQH.PH rd, rt, rs - Subtract Fractional Halfword Vectors And Shift Right - * to Halve Results + * [DSP] SUBQ.S.W rd, rt, rs - Subtract fractional halfword vectors and shift + * right to halve results * * 3 2 1 * 10987654321098765432109876543210 @@ -15082,8 +15108,8 @@ std::string NMD::SUBQ_S_W(uint64 instruction) /* - * SUBQH.PH rd, rt, rs - Subtract Fractional Halfword Vectors And Shift Right - * to Halve Results + * [DSP] SUBQH.PH rd, rt, rs - Subtract fractional halfword vectors and shift + * right to halve results * * 3 2 1 * 10987654321098765432109876543210 @@ -15107,8 +15133,8 @@ std::string NMD::SUBQH_PH(uint64 instruction) /* - * SUBQH.PH rd, rt, rs - Subtract Fractional Halfword Vectors And Shift Right - * to Halve Results + * [DSP] SUBQH_R.PH rd, rt, rs - Subtract fractional halfword vectors and shift + * right to halve results * * 3 2 1 * 10987654321098765432109876543210 @@ -15132,8 +15158,8 @@ std::string NMD::SUBQH_R_PH(uint64 instruction) /* - * SUBQH_R.PH rd, rt, rs - Subtract Fractional Halfword Vectors And Shift Right - * to Halve Results (rounding) + * [DSP] SUBQH_R.W rd, rt, rs - Subtract fractional halfword vectors and shift + * right to halve results with rounding * * 3 2 1 * 10987654321098765432109876543210 @@ -15157,8 +15183,8 @@ std::string NMD::SUBQH_R_W(uint64 instruction) /* - * SUBQH.W rd, rs, rt - Subtract Fractional Words And Shift Right to Halve - * Results + * [DSP] SUBQH.W rd, rs, rt - Subtract fractional words and shift right to + * halve results * * 3 2 1 * 10987654321098765432109876543210 @@ -15279,7 +15305,7 @@ std::string NMD::SUBU_QB(uint64 instruction) /* * [DSP] SUBU_S.PH rd, rs, rt - Subtract unsigned unsigned halfwords with - * 8-bit saturation + * 8-bit saturation * * 3 2 1 * 10987654321098765432109876543210 @@ -15304,7 +15330,7 @@ std::string NMD::SUBU_S_PH(uint64 instruction) /* * [DSP] SUBU_S.QB rd, rs, rt - Subtract unsigned quad byte vectors with - * 8-bit saturation + * 8-bit saturation * * 3 2 1 * 10987654321098765432109876543210 @@ -15329,7 +15355,7 @@ std::string NMD::SUBU_S_QB(uint64 instruction) /* * [DSP] SUBUH.QB rd, rs, rt - Subtract unsigned bytes and right shift - * to halve results + * to halve results * * 3 2 1 * 10987654321098765432109876543210 @@ -15354,7 +15380,7 @@ std::string NMD::SUBUH_QB(uint64 instruction) /* * [DSP] SUBUH_R.QB rd, rs, rt - Subtract unsigned bytes and right shift - * to halve results with rounding + * to halve results with rounding * * 3 2 1 * 10987654321098765432109876543210 @@ -16577,6 +16603,108 @@ std::string NMD::YIELD(uint64 instruction) +/* + * nanoMIPS instruction pool organization + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * + * ┌─ P.ADDIU ─── P.RI ─── P.SYSCALL + * │ + * │ ┌─ P.TRAP + * │ │ + * │ ┌─ _POOL32A0_0 ─┼─ P.CMOVE + * │ │ │ + * │ │ └─ P.SLTU + * │ ┌─ _POOL32A0 ─┤ + * │ │ │ + * │ │ │ + * │ │ └─ _POOL32A0_1 ─── CRC32 + * │ │ + * ├─ P32A ─┤ + * │ │ ┌─ PP.LSX + * │ │ ┌─ P.LSX ─────┤ + * │ │ │ └─ PP.LSXS + * │ └─ _POOL32A7 ─┤ + * │ │ ┌─ POOL32Axf_4 + * │ └─ POOL32Axf ─┤ + * │ └─ POOL32Axf_5 + * │ + * ├─ PBAL + * │ + * ├─ P.GP.W ┌─ PP.LSX + * ┌─ P32 ─┤ │ + * │ ├─ P.GP.BH ─┴─ PP.LSXS + * │ │ + * │ ├─ P.J ─────── PP.BALRSC + * │ │ + * │ ├─ P48I + * │ │ ┌─ P.SR + * │ │ │ + * │ │ ├─ P.SHIFT + * │ │ │ + * │ ├─ P.U12 ───┼─ P.ROTX + * │ │ │ + * │ │ ├─ P.INS + * │ │ │ + * │ │ └─ P.EXT + * │ │ + * │ ├─ P.LS.U12 ── P.PREF.U12 + * │ │ + * │ ├─ P.BR1 ───── P.BR3A + * │ │ + * │ │ ┌─ P.LS.S0 ─── P16.SYSCALL + * │ │ │ + * │ │ │ ┌─ P.LL + * │ │ ├─ P.LS.S1 ─┤ + * │ │ │ └─ P.SC + * │ │ │ + * │ │ │ ┌─ P.PREFE + * MAJOR ─┤ ├─ P.LS.S9 ─┤ │ + * │ │ ├─ P.LS.E0 ─┼─ P.LLE + * │ │ │ │ + * │ │ │ └─ P.SCE + * │ │ │ + * │ │ ├─ P.LS.WM + * │ │ │ + * │ │ └─ P.LS.UAWM + * │ │ + * │ │ + * │ ├─ P.BR2 + * │ │ + * │ ├─ P.BRI + * │ │ + * │ └─ P.LUI + * │ + * │ + * │ ┌─ P16.MV ──── P16.RI ─── P16.SYSCALL + * │ │ + * │ ├─ P16.SR + * │ │ + * │ ├─ P16.SHIFT + * │ │ + * │ ├─ P16.4x4 + * │ │ + * │ ├─ P16C ────── POOL16C_0 ── POOL16C_00 + * │ │ + * └─ P16 ─┼─ P16.LB + * │ + * ├─ P16.A1 + * │ + * ├─ P16.LH + * │ + * ├─ P16.A2 ──── P.ADDIU[RS5] + * │ + * ├─ P16.ADDU + * │ + * └─ P16.BR ──┬─ P16.JRC + * │ + * └─ P16.BR1 + * + * + * (FP, DPS, and some minor instruction pools are omitted from the diagram) + * + */ + NMD::Pool NMD::P_SYSCALL[2] = { { instruction , 0 , 0 , 32, 0xfffc0000, 0x00080000, &NMD::SYSCALL_32_ , 0, diff --git a/tests/tcg/mips/include/test_inputs.h b/tests/tcg/mips/include/test_inputs.h index c173d589ff..5406e4e2df 100644 --- a/tests/tcg/mips/include/test_inputs.h +++ b/tests/tcg/mips/include/test_inputs.h @@ -28,7 +28,7 @@ #define PATTERN_INPUTS_COUNT 64 #define PATTERN_INPUTS_SHORT_COUNT 8 -uint64_t b128_pattern[PATTERN_INPUTS_COUNT][2] = { +static const uint64_t b128_pattern[PATTERN_INPUTS_COUNT][2] = { { 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, }, /* 0 */ { 0x0000000000000000ULL, 0x0000000000000000ULL, }, { 0xAAAAAAAAAAAAAAAAULL, 0xAAAAAAAAAAAAAAAAULL, }, @@ -99,7 +99,7 @@ uint64_t b128_pattern[PATTERN_INPUTS_COUNT][2] = { #define RANDOM_INPUTS_COUNT 16 #define RANDOM_INPUTS_SHORT_COUNT 4 -uint64_t b128_random[RANDOM_INPUTS_COUNT][2] = { +static const uint64_t b128_random[RANDOM_INPUTS_COUNT][2] = { { 0x886AE6CC28625540ULL, 0x4B670B5EFE7BB00CULL, }, /* 0 */ { 0xFBBE00634D93C708ULL, 0x12F7BB1A153F52FCULL, }, { 0xAC5AAEAAB9CF8B80ULL, 0x27D8C6FFAB2B2514ULL, }, diff --git a/tests/tcg/mips/include/test_inputs_32.h b/tests/tcg/mips/include/test_inputs_32.h new file mode 100644 index 0000000000..a3b7e5464a --- /dev/null +++ b/tests/tcg/mips/include/test_inputs_32.h @@ -0,0 +1,122 @@ +/* + * Header file for pattern and random test inputs + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#ifndef TEST_INPUTS_32_H +#define TEST_INPUTS_32_H + +#include <stdint.h> + + +#define PATTERN_INPUTS_32_COUNT 64 +#define PATTERN_INPUTS_32_SHORT_COUNT 8 + +static const uint32_t b32_pattern[PATTERN_INPUTS_32_COUNT] = { + 0xFFFFFFFF, /* 0 */ + 0x00000000, + 0xAAAAAAAA, + 0x55555555, + 0xCCCCCCCC, + 0x33333333, + 0xE38E38E3, + 0x1C71C71C, + 0xF0F0F0F0, /* 8 */ + 0x0F0F0F0F, + 0xF83E0F83, + 0x07C1F07C, + 0xFC0FC0FC, + 0x03F03F03, + 0xFE03F80F, + 0x01FC07F0, + 0xFF00FF00, /* 16 */ + 0x00FF00FF, + 0xFF803FE0, + 0x007FC01F, + 0xFFC00FFC, + 0x003FF003, + 0xFFE003FF, + 0x001FFC00, + 0xFFF000FF, /* 24 */ + 0x000FFF00, + 0xFFF8003F, + 0x0007FFC0, + 0xFFFC000F, + 0x0003FFF0, + 0xFFFE0003, + 0x0001FFFC, + 0xFFFF0000, /* 32 */ + 0x0000FFFF, + 0xFFFF8000, + 0x00007FFF, + 0xFFFFC000, + 0x00003FFF, + 0xFFFFE000, + 0x00001FFF, + 0xFFFFF000, /* 40 */ + 0x00000FFF, + 0xFFFFF800, + 0x000007FF, + 0xFFFFFC00, + 0x000003FF, + 0xFFFFFE00, + 0x000001FF, + 0xFFFFFF00, /* 48 */ + 0x000000FF, + 0xFFFFFF80, + 0x0000007F, + 0xFFFFFFC0, + 0x0000003F, + 0xFFFFFFE0, + 0x0000001F, + 0xFFFFFFF0, /* 56 */ + 0x0000000F, + 0xFFFFFFF8, + 0x00000007, + 0xFFFFFFFC, + 0x00000003, + 0xFFFFFFFE, + 0x00000001, +}; + + +#define RANDOM_INPUTS_32_COUNT 16 +#define RANDOM_INPUTS_32_SHORT_COUNT 4 + +static const uint32_t b32_random[RANDOM_INPUTS_32_COUNT] = { + 0x886AE6CC, /* 0 */ + 0xFBBE0063, + 0xAC5AAEAA, + 0x704F164D, + 0xB9926B7C, + 0xD027BE89, + 0xB83B5806, + 0xFC8F23F0, + 0x201E09CD, /* 8 */ + 0xA57CD913, + 0xA2E8F6F5, + 0xA89CF2F1, + 0xE61438E9, + 0x944A35FD, + 0x46304263, + 0x8B5AA7A2, +}; + + +#endif diff --git a/tests/tcg/mips/include/test_inputs_64.h b/tests/tcg/mips/include/test_inputs_64.h new file mode 100644 index 0000000000..6891a362a3 --- /dev/null +++ b/tests/tcg/mips/include/test_inputs_64.h @@ -0,0 +1,208 @@ +/* + * Header file for pattern and random test inputs + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#ifndef TEST_INPUTS_64_H +#define TEST_INPUTS_64_H + +#include <stdint.h> + + +#define PATTERN_INPUTS_64_COUNT 64 +#define PATTERN_INPUTS_64_SHORT_COUNT 8 + +static const uint64_t b64_pattern[PATTERN_INPUTS_64_COUNT] = { + 0xFFFFFFFFFFFFFFFFULL, /* 0 */ + 0x0000000000000000ULL, + 0xAAAAAAAAAAAAAAAAULL, + 0x5555555555555555ULL, + 0xCCCCCCCCCCCCCCCCULL, + 0x3333333333333333ULL, + 0xE38E38E38E38E38EULL, + 0x1C71C71C71C71C71ULL, + 0xF0F0F0F0F0F0F0F0ULL, /* 8 */ + 0x0F0F0F0F0F0F0F0FULL, + 0xF83E0F83E0F83E0FULL, + 0x07C1F07C1F07C1F0ULL, + 0xFC0FC0FC0FC0FC0FULL, + 0x03F03F03F03F03F0ULL, + 0xFE03F80FE03F80FEULL, + 0x01FC07F01FC07F01ULL, + 0xFF00FF00FF00FF00ULL, /* 16 */ + 0x00FF00FF00FF00FFULL, + 0xFF803FE00FF803FEULL, + 0x007FC01FF007FC01ULL, + 0xFFC00FFC00FFC00FULL, + 0x003FF003FF003FF0ULL, + 0xFFE003FF800FFE00ULL, + 0x001FFC007FF001FFULL, + 0xFFF000FFF000FFF0ULL, /* 24 */ + 0x000FFF000FFF000FULL, + 0xFFF8003FFE000FFFULL, + 0x0007FFC001FFF000ULL, + 0xFFFC000FFFC000FFULL, + 0x0003FFF0003FFF00ULL, + 0xFFFE0003FFF8000FULL, + 0x0001FFFC0007FFF0ULL, + 0xFFFF0000FFFF0000ULL, /* 32 */ + 0x0000FFFF0000FFFFULL, + 0xFFFF80003FFFE000ULL, + 0x00007FFFC0001FFFULL, + 0xFFFFC0000FFFFC00ULL, + 0x00003FFFF00003FFULL, + 0xFFFFE00003FFFF80ULL, + 0x00001FFFFC00007FULL, + 0xFFFFF00000FFFFF0ULL, /* 40 */ + 0x00000FFFFF00000FULL, + 0xFFFFF800003FFFFEULL, + 0x000007FFFFC00001ULL, + 0xFFFFFC00000FFFFFULL, + 0x000003FFFFF00000ULL, + 0xFFFFFE000003FFFFULL, + 0x000001FFFFFC0000ULL, + 0xFFFFFF000000FFFFULL, /* 48 */ + 0x000000FFFFFF0000ULL, + 0xFFFFFF8000003FFFULL, + 0x0000007FFFFFC000ULL, + 0xFFFFFFC000000FFFULL, + 0x0000003FFFFFF000ULL, + 0xFFFFFFE0000003FFULL, + 0x0000001FFFFFFC00ULL, + 0xFFFFFFF0000000FFULL, /* 56 */ + 0x0000000FFFFFFF00ULL, + 0xFFFFFFF80000003FULL, + 0x00000007FFFFFFC0ULL, + 0xFFFFFFFC0000000FULL, + 0x00000003FFFFFFF0ULL, + 0xFFFFFFFE00000003ULL, + 0x00000001FFFFFFFCULL, +}; + +static const uint64_t b64_pattern_se[PATTERN_INPUTS_64_COUNT] = { + 0xFFFFFFFFFFFFFFFFULL, /* 0 */ + 0x0000000000000000ULL, + 0xFFFFFFFFAAAAAAAAULL, + 0x0000000055555555ULL, + 0xFFFFFFFFCCCCCCCCULL, + 0x0000000033333333ULL, + 0xFFFFFFFFE38E38E3ULL, + 0x000000001C71C71CULL, + 0xFFFFFFFFF0F0F0F0ULL, /* 8 */ + 0x000000000F0F0F0FULL, + 0xFFFFFFFFF83E0F83ULL, + 0x0000000007C1F07CULL, + 0xFFFFFFFFFC0FC0FCULL, + 0x0000000003F03F03ULL, + 0xFFFFFFFFFE03F80FULL, + 0x0000000001FC07F0ULL, + 0xFFFFFFFFFF00FF00ULL, /* 16 */ + 0x0000000000FF00FFULL, + 0xFFFFFFFFFF803FE0ULL, + 0x00000000007FC01FULL, + 0xFFFFFFFFFFC00FFCULL, + 0x00000000003FF003ULL, + 0xFFFFFFFFFFE003FFULL, + 0x00000000001FFC00ULL, + 0xFFFFFFFFFFF000FFULL, /* 24 */ + 0x00000000000FFF00ULL, + 0xFFFFFFFFFFF8003FULL, + 0x000000000007FFC0ULL, + 0xFFFFFFFFFFFC000FULL, + 0x000000000003FFF0ULL, + 0xFFFFFFFFFFFE0003ULL, + 0x000000000001FFFCULL, + 0xFFFFFFFFFFFF0000ULL, /* 32 */ + 0x000000000000FFFFULL, + 0xFFFFFFFFFFFF8000ULL, + 0x0000000000007FFFULL, + 0xFFFFFFFFFFFFC000ULL, + 0x0000000000003FFFULL, + 0xFFFFFFFFFFFFE000ULL, + 0x0000000000001FFFULL, + 0xFFFFFFFFFFFFF000ULL, /* 40 */ + 0x0000000000000FFFULL, + 0xFFFFFFFFFFFFF800ULL, + 0x00000000000007FFULL, + 0xFFFFFFFFFFFFFC00ULL, + 0x00000000000003FFULL, + 0xFFFFFFFFFFFFFE00ULL, + 0x00000000000001FFULL, + 0xFFFFFFFFFFFFFF00ULL, /* 48 */ + 0x00000000000000FFULL, + 0xFFFFFFFFFFFFFF80ULL, + 0x000000000000007FULL, + 0xFFFFFFFFFFFFFFC0ULL, + 0x000000000000003FULL, + 0xFFFFFFFFFFFFFFE0ULL, + 0x000000000000001FULL, + 0xFFFFFFFFFFFFFFF0ULL, /* 56 */ + 0x000000000000000FULL, + 0xFFFFFFFFFFFFFFF8ULL, + 0x0000000000000007ULL, + 0xFFFFFFFFFFFFFFFCULL, + 0x0000000000000003ULL, + 0xFFFFFFFFFFFFFFFEULL, + 0x0000000000000001ULL, +}; + + +#define RANDOM_INPUTS_64_COUNT 16 +#define RANDOM_INPUTS_64_SHORT_COUNT 4 + +static const uint64_t b64_random[RANDOM_INPUTS_64_COUNT] = { + 0x886AE6CC28625540ULL, /* 0 */ + 0xFBBE00634D93C708ULL, + 0xAC5AAEAAB9CF8B80ULL, + 0x704F164D5E31E24EULL, + 0xB9926B7C7DAF4258ULL, + 0xD027BE89FF0A2EF9ULL, + 0xB83B580665CABC4AULL, + 0xFC8F23F09AA6B782ULL, + 0x201E09CD56AEE649ULL, /* 8 */ + 0xA57CD91365D9E5D7ULL, + 0xA2E8F6F5C9CBC61BULL, + 0xA89CF2F131A864AEULL, + 0xE61438E9A652EA0AULL, + 0x944A35FD192361A8ULL, + 0x4630426322BEF79CULL, + 0x8B5AA7A2F259DEADULL, +}; + +static const uint64_t b64_random_se[RANDOM_INPUTS_64_COUNT] = { + 0xFFFFFFFF886AE6CCULL, /* 0 */ + 0xFFFFFFFFFBBE0063ULL, + 0xFFFFFFFFAC5AAEAAULL, + 0x00000000704F164DULL, + 0xFFFFFFFFB9926B7CULL, + 0xFFFFFFFFD027BE89ULL, + 0xFFFFFFFFB83B5806ULL, + 0xFFFFFFFFFC8F23F0ULL, + 0x00000000201E09CDULL, /* 8 */ + 0xFFFFFFFFA57CD913ULL, + 0xFFFFFFFFA2E8F6F5ULL, + 0xFFFFFFFFA89CF2F1ULL, + 0xFFFFFFFFE61438E9ULL, + 0xFFFFFFFF944A35FDULL, + 0x0000000046304263ULL, + 0xFFFFFFFF8B5AA7A2ULL, +}; + + +#endif diff --git a/tests/tcg/mips/include/test_utils.h b/tests/tcg/mips/include/test_utils.h index 82f4b5b1ef..9672903eb5 100644 --- a/tests/tcg/mips/include/test_utils.h +++ b/tests/tcg/mips/include/test_utils.h @@ -27,14 +27,14 @@ #include <inttypes.h> #include <string.h> -#define PRINT_RESULTS 1 +#define PRINT_RESULTS 0 -static inline int32_t check_results(char *instruction_name, - uint32_t test_count, - double elapsed_time, - uint64_t *b128_result, - uint64_t *b128_expect) +static inline int32_t check_results(const char *instruction_name, + const uint32_t test_count, + const double elapsed_time, + const uint64_t *b128_result, + const uint64_t *b128_expect) { #if PRINT_RESULTS uint32_t ii; @@ -58,7 +58,8 @@ static inline int32_t check_results(char *instruction_name, printf("%s: ", instruction_name); for (i = 0; i < test_count; i++) { - if (b128_result[i] == b128_expect[i]) { + if ((b128_result[2 * i] == b128_expect[2 * i]) && + (b128_result[2 * i + 1] == b128_expect[2 * i + 1])) { pass_count++; } else { fail_count++; diff --git a/tests/tcg/mips/include/test_utils_32.h b/tests/tcg/mips/include/test_utils_32.h new file mode 100644 index 0000000000..c33990c0c5 --- /dev/null +++ b/tests/tcg/mips/include/test_utils_32.h @@ -0,0 +1,78 @@ +/* + * Header file for test utilities + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#ifndef TEST_UTILS_32_H +#define TEST_UTILS_32_H + +#include <stdio.h> +#include <stdint.h> +#include <inttypes.h> +#include <string.h> + +#define PRINT_RESULTS 0 + + +static inline int32_t check_results_32(const char *instruction_name, + const uint32_t test_count, + const double elapsed_time, + const uint32_t *b32_result, + const uint32_t *b32_expect) +{ +#if PRINT_RESULTS + uint32_t ii; + printf("\n"); + for (ii = 0; ii < test_count; ii++) { + uint64_t a; + memcpy(&a, (b32_result + ii), 8); + if (ii % 8 != 0) { + printf(" 0x%08lxULL,\n", a); + } else { + printf(" 0x%08lxULL, /* %3d */\n", + a, ii); + } + } + printf("\n"); +#endif + uint32_t i; + uint32_t pass_count = 0; + uint32_t fail_count = 0; + + printf("%s: ", instruction_name); + for (i = 0; i < test_count; i++) { + if (b32_result[i] == b32_expect[i]) { + pass_count++; + } else { + fail_count++; + } + } + + printf("PASS: %3d FAIL: %3d elapsed time: %5.2f ms\n", + pass_count, fail_count, elapsed_time); + + if (fail_count > 0) { + return -1; + } else { + return 0; + } +} + + +#endif diff --git a/tests/tcg/mips/include/test_utils_64.h b/tests/tcg/mips/include/test_utils_64.h new file mode 100644 index 0000000000..ee3828472c --- /dev/null +++ b/tests/tcg/mips/include/test_utils_64.h @@ -0,0 +1,78 @@ +/* + * Header file for test utilities + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#ifndef TEST_UTILS_64_H +#define TEST_UTILS_64_H + +#include <stdio.h> +#include <stdint.h> +#include <inttypes.h> +#include <string.h> + +#define PRINT_RESULTS 0 + + +static inline int32_t check_results_64(const char *instruction_name, + const uint32_t test_count, + const double elapsed_time, + const uint64_t *b64_result, + const uint64_t *b64_expect) +{ +#if PRINT_RESULTS + uint32_t ii; + printf("\n"); + for (ii = 0; ii < test_count; ii++) { + uint64_t a; + memcpy(&a, (b64_result + ii), 8); + if (ii % 8 != 0) { + printf(" 0x%016llxULL,\n", a); + } else { + printf(" 0x%016llxULL, /* %3d */\n", + a, ii); + } + } + printf("\n"); +#endif + uint32_t i; + uint32_t pass_count = 0; + uint32_t fail_count = 0; + + printf("%s: ", instruction_name); + for (i = 0; i < test_count; i++) { + if (b64_result[i] == b64_expect[i]) { + pass_count++; + } else { + fail_count++; + } + } + + printf("PASS: %3d FAIL: %3d elapsed time: %5.2f ms\n", + pass_count, fail_count, elapsed_time); + + if (fail_count > 0) { + return -1; + } else { + return 0; + } +} + + +#endif diff --git a/tests/tcg/mips/include/wrappers_mips64r6.h b/tests/tcg/mips/include/wrappers_mips64r6.h new file mode 100644 index 0000000000..d1e5edb632 --- /dev/null +++ b/tests/tcg/mips/include/wrappers_mips64r6.h @@ -0,0 +1,83 @@ +/* + * Header file for wrappers around MIPS64R6 instructions assembler + * invocations + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#ifndef WRAPPERS_MIPS64R6_H +#define WRAPPERS_MIPS64R6_H + + +#define DO_MIPS64R6__RD__RS(suffix, mnemonic) \ +static inline void do_mips64r6_##suffix(const void *input, \ + void *output) \ +{ \ + __asm__ volatile ( \ + "ld $t1, 0(%0)\n\t" \ + #mnemonic " $t0, $t1\n\t" \ + "sd $t0, 0(%1)\n\t" \ + : \ + : "r" (input), "r" (output) \ + : "t0", "t1", "memory" \ + ); \ +} + +DO_MIPS64R6__RD__RS(CLO, clo) +DO_MIPS64R6__RD__RS(CLZ, clz) +DO_MIPS64R6__RD__RS(DCLO, dclo) +DO_MIPS64R6__RD__RS(DCLZ, dclz) + +DO_MIPS64R6__RD__RS(BITSWAP, bitswap) +DO_MIPS64R6__RD__RS(DBITSWAP, dbitswap) + + +#define DO_MIPS64R6__RD__RS_RT(suffix, mnemonic) \ +static inline void do_mips64r6_##suffix(const void *input1, \ + const void *input2, \ + void *output) \ +{ \ + __asm__ volatile ( \ + "ld $t1, 0(%0)\n\t" \ + "ld $t2, 0(%1)\n\t" \ + #mnemonic " $t0, $t1, $t2\n\t" \ + "sd $t0, 0(%2)\n\t" \ + : \ + : "r" (input1), "r" (input2), "r" (output) \ + : "t0", "t1", "memory" \ + ); \ +} + +DO_MIPS64R6__RD__RS_RT(SLLV, sllv) +DO_MIPS64R6__RD__RS_RT(SRLV, srlv) +DO_MIPS64R6__RD__RS_RT(SRAV, srav) +DO_MIPS64R6__RD__RS_RT(DSLLV, dsllv) +DO_MIPS64R6__RD__RS_RT(DSRLV, dsrlv) +DO_MIPS64R6__RD__RS_RT(DSRAV, dsrav) + +DO_MIPS64R6__RD__RS_RT(MUL, mul) +DO_MIPS64R6__RD__RS_RT(MUH, muh) +DO_MIPS64R6__RD__RS_RT(MULU, mulu) +DO_MIPS64R6__RD__RS_RT(MUHU, muhu) +DO_MIPS64R6__RD__RS_RT(DMUL, dmul) +DO_MIPS64R6__RD__RS_RT(DMUH, dmuh) +DO_MIPS64R6__RD__RS_RT(DMULU, dmulu) +DO_MIPS64R6__RD__RS_RT(DMUHU, dmuhu) + + +#endif diff --git a/tests/tcg/mips/include/wrappers_msa.h b/tests/tcg/mips/include/wrappers_msa.h index 302f0ab54c..9cffd55591 100644 --- a/tests/tcg/mips/include/wrappers_msa.h +++ b/tests/tcg/mips/include/wrappers_msa.h @@ -38,6 +38,21 @@ static inline void do_msa_##suffix(void *input, void *output) \ ); \ } +#define DO_MSA__WD__WD(suffix, mnemonic) \ +static inline void do_msa_##suffix(void *input, void *output) \ +{ \ + __asm__ volatile ( \ + "move $t0, %0\n\t" \ + "ld.d $w11, 0($t0)\n\t" \ + #mnemonic " $w10, $w10\n\t" \ + "move $t0, %1\n\t" \ + "st.d $w10, 0($t0)\n\t" \ + : \ + : "r" (input), "r" (output) \ + : "t0", "memory" \ + ); \ +} + DO_MSA__WD__WS(NLOC_B, nloc.b) DO_MSA__WD__WS(NLOC_H, nloc.h) DO_MSA__WD__WS(NLOC_W, nloc.w) @@ -72,6 +87,42 @@ static inline void do_msa_##suffix(void *input1, void *input2, \ ); \ } +#define DO_MSA__WD__WD_WT(suffix, mnemonic) \ +static inline void do_msa_##suffix(void *input1, void *input2, \ + void *output) \ +{ \ + __asm__ volatile ( \ + "move $t0, %0\n\t" \ + "ld.d $w11, 0($t0)\n\t" \ + "move $t0, %1\n\t" \ + "ld.d $w12, 0($t0)\n\t" \ + #mnemonic " $w10, $w10, $w12\n\t" \ + "move $t0, %2\n\t" \ + "st.d $w10, 0($t0)\n\t" \ + : \ + : "r" (input1), "r" (input2), "r" (output) \ + : "t0", "memory" \ + ); \ +} + +#define DO_MSA__WD__WS_WD(suffix, mnemonic) \ +static inline void do_msa_##suffix(void *input1, void *input2, \ + void *output) \ +{ \ + __asm__ volatile ( \ + "move $t0, %0\n\t" \ + "ld.d $w11, 0($t0)\n\t" \ + "move $t0, %1\n\t" \ + "ld.d $w12, 0($t0)\n\t" \ + #mnemonic " $w10, $w11, $w10\n\t" \ + "move $t0, %2\n\t" \ + "st.d $w10, 0($t0)\n\t" \ + : \ + : "r" (input1), "r" (input2), "r" (output) \ + : "t0", "memory" \ + ); \ +} + DO_MSA__WD__WS_WT(ILVEV_B, ilvev.b) DO_MSA__WD__WS_WT(ILVEV_H, ilvev.h) DO_MSA__WD__WS_WT(ILVEV_W, ilvev.w) @@ -152,5 +203,75 @@ DO_MSA__WD__WS_WT(MIN_U_H, min_u.h) DO_MSA__WD__WS_WT(MIN_U_W, min_u.w) DO_MSA__WD__WS_WT(MIN_U_D, min_u.d) +DO_MSA__WD__WS_WT(BCLR_B, bclr.b) +DO_MSA__WD__WS_WT(BCLR_H, bclr.h) +DO_MSA__WD__WS_WT(BCLR_W, bclr.w) +DO_MSA__WD__WS_WT(BCLR_D, bclr.d) + +DO_MSA__WD__WS_WT(BSET_B, bset.b) +DO_MSA__WD__WS_WT(BSET_H, bset.h) +DO_MSA__WD__WS_WT(BSET_W, bset.w) +DO_MSA__WD__WS_WT(BSET_D, bset.d) + +DO_MSA__WD__WS_WT(BNEG_B, bneg.b) +DO_MSA__WD__WS_WT(BNEG_H, bneg.h) +DO_MSA__WD__WS_WT(BNEG_W, bneg.w) +DO_MSA__WD__WS_WT(BNEG_D, bneg.d) + +DO_MSA__WD__WS_WT(PCKEV_B, pckev.b) +DO_MSA__WD__WS_WT(PCKEV_H, pckev.h) +DO_MSA__WD__WS_WT(PCKEV_W, pckev.w) +DO_MSA__WD__WS_WT(PCKEV_D, pckev.d) + +DO_MSA__WD__WS_WT(PCKOD_B, pckod.b) +DO_MSA__WD__WS_WT(PCKOD_H, pckod.h) +DO_MSA__WD__WS_WT(PCKOD_W, pckod.w) +DO_MSA__WD__WS_WT(PCKOD_D, pckod.d) + +DO_MSA__WD__WS_WT(VSHF_B, vshf.b) +DO_MSA__WD__WS_WT(VSHF_H, vshf.h) +DO_MSA__WD__WS_WT(VSHF_W, vshf.w) +DO_MSA__WD__WS_WT(VSHF_D, vshf.d) + +DO_MSA__WD__WS_WT(SLL_B, sll.b) +DO_MSA__WD__WS_WT(SLL_H, sll.h) +DO_MSA__WD__WS_WT(SLL_W, sll.w) +DO_MSA__WD__WS_WT(SLL_D, sll.d) + +DO_MSA__WD__WS_WT(SRA_B, sra.b) +DO_MSA__WD__WS_WT(SRA_H, sra.h) +DO_MSA__WD__WS_WT(SRA_W, sra.w) +DO_MSA__WD__WS_WT(SRA_D, sra.d) + +DO_MSA__WD__WS_WT(SRAR_B, srar.b) +DO_MSA__WD__WS_WT(SRAR_H, srar.h) +DO_MSA__WD__WS_WT(SRAR_W, srar.w) +DO_MSA__WD__WS_WT(SRAR_D, srar.d) + +DO_MSA__WD__WS_WT(SRL_B, srl.b) +DO_MSA__WD__WS_WT(SRL_H, srl.h) +DO_MSA__WD__WS_WT(SRL_W, srl.w) +DO_MSA__WD__WS_WT(SRL_D, srl.d) + +DO_MSA__WD__WS_WT(SRLR_B, srlr.b) +DO_MSA__WD__WS_WT(SRLR_H, srlr.h) +DO_MSA__WD__WS_WT(SRLR_W, srlr.w) +DO_MSA__WD__WS_WT(SRLR_D, srlr.d) + +DO_MSA__WD__WS_WT(BMNZ_V, bmnz.v) +DO_MSA__WD__WS_WT(BMZ_V, bmz.v) + +DO_MSA__WD__WS_WT(FMAX_W, fmax.w) +DO_MSA__WD__WS_WT(FMAX_D, fmax.d) + +DO_MSA__WD__WS_WT(FMAX_A_W, fmax_a.w) +DO_MSA__WD__WS_WT(FMAX_A_D, fmax_a.d) + +DO_MSA__WD__WS_WT(FMIN_W, fmin.w) +DO_MSA__WD__WS_WT(FMIN_D, fmin.d) + +DO_MSA__WD__WS_WT(FMIN_A_W, fmin_a.w) +DO_MSA__WD__WS_WT(FMIN_A_D, fmin_a.d) + #endif diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_b.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_b.c new file mode 100644 index 0000000000..9dca167638 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_b.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADD_A.B + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADD_A.B"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0202020202020202ULL, 0x0202020202020202ULL, }, /* 0 */ + { 0x0101010101010101ULL, 0x0101010101010101ULL, }, + { 0x5757575757575757ULL, 0x5757575757575757ULL, }, + { 0x5656565656565656ULL, 0x5656565656565656ULL, }, + { 0x3535353535353535ULL, 0x3535353535353535ULL, }, + { 0x3434343434343434ULL, 0x3434343434343434ULL, }, + { 0x1e73391e73391e73ULL, 0x391e73391e73391eULL, }, + { 0x1d723a1d723a1d72ULL, 0x3a1d723a1d723a1dULL, }, + { 0x0101010101010101ULL, 0x0101010101010101ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5656565656565656ULL, 0x5656565656565656ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x3434343434343434ULL, 0x3434343434343434ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x1d72381d72381d72ULL, 0x381d72381d72381dULL, }, + { 0x1c71391c71391c71ULL, 0x391c71391c71391cULL, }, + { 0x5757575757575757ULL, 0x5757575757575757ULL, }, /* 16 */ + { 0x5656565656565656ULL, 0x5656565656565656ULL, }, + { 0xacacacacacacacacULL, 0xacacacacacacacacULL, }, + { 0xababababababababULL, 0xababababababababULL, }, + { 0x8a8a8a8a8a8a8a8aULL, 0x8a8a8a8a8a8a8a8aULL, }, + { 0x8989898989898989ULL, 0x8989898989898989ULL, }, + { 0x73c88e73c88e73c8ULL, 0x8e73c88e73c88e73ULL, }, + { 0x72c78f72c78f72c7ULL, 0x8f72c78f72c78f72ULL, }, + { 0x5656565656565656ULL, 0x5656565656565656ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xababababababababULL, 0xababababababababULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x8989898989898989ULL, 0x8989898989898989ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x72c78d72c78d72c7ULL, 0x8d72c78d72c78d72ULL, }, + { 0x71c68e71c68e71c6ULL, 0x8e71c68e71c68e71ULL, }, + { 0x3535353535353535ULL, 0x3535353535353535ULL, }, /* 32 */ + { 0x3434343434343434ULL, 0x3434343434343434ULL, }, + { 0x8a8a8a8a8a8a8a8aULL, 0x8a8a8a8a8a8a8a8aULL, }, + { 0x8989898989898989ULL, 0x8989898989898989ULL, }, + { 0x6868686868686868ULL, 0x6868686868686868ULL, }, + { 0x6767676767676767ULL, 0x6767676767676767ULL, }, + { 0x51a66c51a66c51a6ULL, 0x6c51a66c51a66c51ULL, }, + { 0x50a56d50a56d50a5ULL, 0x6d50a56d50a56d50ULL, }, + { 0x3434343434343434ULL, 0x3434343434343434ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x8989898989898989ULL, 0x8989898989898989ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x6767676767676767ULL, 0x6767676767676767ULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x50a56b50a56b50a5ULL, 0x6b50a56b50a56b50ULL, }, + { 0x4fa46c4fa46c4fa4ULL, 0x6c4fa46c4fa46c4fULL, }, + { 0x1e73391e73391e73ULL, 0x391e73391e73391eULL, }, /* 48 */ + { 0x1d72381d72381d72ULL, 0x381d72381d72381dULL, }, + { 0x73c88e73c88e73c8ULL, 0x8e73c88e73c88e73ULL, }, + { 0x72c78d72c78d72c7ULL, 0x8d72c78d72c78d72ULL, }, + { 0x51a66c51a66c51a6ULL, 0x6c51a66c51a66c51ULL, }, + { 0x50a56b50a56b50a5ULL, 0x6b50a56b50a56b50ULL, }, + { 0x3ae4703ae4703ae4ULL, 0x703ae4703ae4703aULL, }, + { 0x39e37139e37139e3ULL, 0x7139e37139e37139ULL, }, + { 0x1d723a1d723a1d72ULL, 0x3a1d723a1d723a1dULL, }, /* 56 */ + { 0x1c71391c71391c71ULL, 0x391c71391c71391cULL, }, + { 0x72c78f72c78f72c7ULL, 0x8f72c78f72c78f72ULL, }, + { 0x71c68e71c68e71c6ULL, 0x8e71c68e71c68e71ULL, }, + { 0x50a56d50a56d50a5ULL, 0x6d50a56d50a56d50ULL, }, + { 0x4fa46c4fa46c4fa4ULL, 0x6c4fa46c4fa46c4fULL, }, + { 0x39e37139e37139e3ULL, 0x7139e37139e37139ULL, }, + { 0x38e27238e27238e2ULL, 0x7238e27238e27238ULL, }, + { 0xf0d4346850c4aa80ULL, 0x96ce16bc04f6a018ULL, }, /* 64 */ + { 0x7dac1a9775cf8e48ULL, 0x5d70507817baa210ULL, }, + { 0xccc46c8a6f93cac0ULL, 0x728f455f57a67520ULL, }, + { 0xe8b930818693738eULL, 0xbe76838659bd6e6cULL, }, + { 0x7dac1a9775cf8e48ULL, 0x5d70507817baa210ULL, }, + { 0x0a8400c69ada7210ULL, 0x24128a342a7ea408ULL, }, + { 0x599c52b9949eae88ULL, 0x39317f1b6a6a7718ULL, }, + { 0x759116b0ab9e5756ULL, 0x8518bd426c817064ULL, }, + { 0xccc46c8a6f93cac0ULL, 0x728f455f57a67520ULL, }, /* 72 */ + { 0x599c52b9949eae88ULL, 0x39317f1b6a6a7718ULL, }, + { 0xa8b4a4ac8e62ea00ULL, 0x4e507402aa564a28ULL, }, + { 0xc4a968a3a56293ceULL, 0x9a37b229ac6d4374ULL, }, + { 0xe8b930818693738eULL, 0xbe76838659bd6e6cULL, }, + { 0x759116b0ab9e5756ULL, 0x8518bd426c817064ULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADD_A_B(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADD_A_B(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_d.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_d.c new file mode 100644 index 0000000000..06a7a502a0 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_d.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADD_A.D + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADD_A.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0000000000000002ULL, 0x0000000000000002ULL, }, /* 0 */ + { 0x0000000000000001ULL, 0x0000000000000001ULL, }, + { 0x5555555555555557ULL, 0x5555555555555557ULL, }, + { 0x5555555555555556ULL, 0x5555555555555556ULL, }, + { 0x3333333333333335ULL, 0x3333333333333335ULL, }, + { 0x3333333333333334ULL, 0x3333333333333334ULL, }, + { 0x1c71c71c71c71c73ULL, 0x38e38e38e38e38e4ULL, }, + { 0x1c71c71c71c71c72ULL, 0x38e38e38e38e38e5ULL, }, + { 0x0000000000000001ULL, 0x0000000000000001ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5555555555555556ULL, 0x5555555555555556ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x3333333333333334ULL, 0x3333333333333334ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x1c71c71c71c71c72ULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0x38e38e38e38e38e4ULL, }, + { 0x5555555555555557ULL, 0x5555555555555557ULL, }, /* 16 */ + { 0x5555555555555556ULL, 0x5555555555555556ULL, }, + { 0xaaaaaaaaaaaaaaacULL, 0xaaaaaaaaaaaaaaacULL, }, + { 0xaaaaaaaaaaaaaaabULL, 0xaaaaaaaaaaaaaaabULL, }, + { 0x888888888888888aULL, 0x888888888888888aULL, }, + { 0x8888888888888889ULL, 0x8888888888888889ULL, }, + { 0x71c71c71c71c71c8ULL, 0x8e38e38e38e38e39ULL, }, + { 0x71c71c71c71c71c7ULL, 0x8e38e38e38e38e3aULL, }, + { 0x5555555555555556ULL, 0x5555555555555556ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaaaaaaaaaabULL, 0xaaaaaaaaaaaaaaabULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x8888888888888889ULL, 0x8888888888888889ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x71c71c71c71c71c7ULL, 0x8e38e38e38e38e38ULL, }, + { 0x71c71c71c71c71c6ULL, 0x8e38e38e38e38e39ULL, }, + { 0x3333333333333335ULL, 0x3333333333333335ULL, }, /* 32 */ + { 0x3333333333333334ULL, 0x3333333333333334ULL, }, + { 0x888888888888888aULL, 0x888888888888888aULL, }, + { 0x8888888888888889ULL, 0x8888888888888889ULL, }, + { 0x6666666666666668ULL, 0x6666666666666668ULL, }, + { 0x6666666666666667ULL, 0x6666666666666667ULL, }, + { 0x4fa4fa4fa4fa4fa6ULL, 0x6c16c16c16c16c17ULL, }, + { 0x4fa4fa4fa4fa4fa5ULL, 0x6c16c16c16c16c18ULL, }, + { 0x3333333333333334ULL, 0x3333333333333334ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x8888888888888889ULL, 0x8888888888888889ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x6666666666666667ULL, 0x6666666666666667ULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x4fa4fa4fa4fa4fa5ULL, 0x6c16c16c16c16c16ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c16c16c17ULL, }, + { 0x1c71c71c71c71c73ULL, 0x38e38e38e38e38e4ULL, }, /* 48 */ + { 0x1c71c71c71c71c72ULL, 0x38e38e38e38e38e3ULL, }, + { 0x71c71c71c71c71c8ULL, 0x8e38e38e38e38e39ULL, }, + { 0x71c71c71c71c71c7ULL, 0x8e38e38e38e38e38ULL, }, + { 0x4fa4fa4fa4fa4fa6ULL, 0x6c16c16c16c16c17ULL, }, + { 0x4fa4fa4fa4fa4fa5ULL, 0x6c16c16c16c16c16ULL, }, + { 0x38e38e38e38e38e4ULL, 0x71c71c71c71c71c6ULL, }, + { 0x38e38e38e38e38e3ULL, 0x71c71c71c71c71c7ULL, }, + { 0x1c71c71c71c71c72ULL, 0x38e38e38e38e38e5ULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0x38e38e38e38e38e4ULL, }, + { 0x71c71c71c71c71c7ULL, 0x8e38e38e38e38e3aULL, }, + { 0x71c71c71c71c71c6ULL, 0x8e38e38e38e38e39ULL, }, + { 0x4fa4fa4fa4fa4fa5ULL, 0x6c16c16c16c16c18ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c16c16c17ULL, }, + { 0x38e38e38e38e38e3ULL, 0x71c71c71c71c71c7ULL, }, + { 0x38e38e38e38e38e2ULL, 0x71c71c71c71c71c8ULL, }, + { 0xef2a3267af3b5580ULL, 0x96ce16bdfcf76018ULL, }, /* 64 */ + { 0x7bd718d08a09e3b8ULL, 0x5e5ec67913bb0308ULL, }, + { 0xcb3a6a891dce1f40ULL, 0x733fd25ea9a6d520ULL, }, + { 0xe7e42f8135cf8d0eULL, 0xbd7582865538cd6cULL, }, + { 0x7bd718d08a09e3b8ULL, 0x5e5ec67913bb0308ULL, }, + { 0x0883ff3964d871f0ULL, 0x25ef76342a7ea5f8ULL, }, + { 0x57e750f1f89cad78ULL, 0x3ad08219c06a7810ULL, }, + { 0x749115ea109e1b46ULL, 0x850632416bfc705cULL, }, + { 0xcb3a6a891dce1f40ULL, 0x733fd25ea9a6d520ULL, }, /* 72 */ + { 0x57e750f1f89cad78ULL, 0x3ad08219c06a7810ULL, }, + { 0xa74aa2aa8c60e900ULL, 0x4fb18dff56564a28ULL, }, + { 0xc3f467a2a46256ceULL, 0x99e73e2701e84274ULL, }, + { 0xe7e42f8135cf8d0eULL, 0xbd7582865538cd6cULL, }, + { 0x749115ea109e1b46ULL, 0x850632416bfc705cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADD_A_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADD_A_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_h.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_h.c new file mode 100644 index 0000000000..5e591425aa --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_h.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADD_A.H + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADD_A.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0002000200020002ULL, 0x0002000200020002ULL, }, /* 0 */ + { 0x0001000100010001ULL, 0x0001000100010001ULL, }, + { 0x5557555755575557ULL, 0x5557555755575557ULL, }, + { 0x5556555655565556ULL, 0x5556555655565556ULL, }, + { 0x3335333533353335ULL, 0x3335333533353335ULL, }, + { 0x3334333433343334ULL, 0x3334333433343334ULL, }, + { 0x1c7338e471c91c73ULL, 0x38e471c91c7338e4ULL, }, + { 0x1c7238e571c81c72ULL, 0x38e571c81c7238e5ULL, }, + { 0x0001000100010001ULL, 0x0001000100010001ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5556555655565556ULL, 0x5556555655565556ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x3334333433343334ULL, 0x3334333433343334ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x1c7238e371c81c72ULL, 0x38e371c81c7238e3ULL, }, + { 0x1c7138e471c71c71ULL, 0x38e471c71c7138e4ULL, }, + { 0x5557555755575557ULL, 0x5557555755575557ULL, }, /* 16 */ + { 0x5556555655565556ULL, 0x5556555655565556ULL, }, + { 0xaaacaaacaaacaaacULL, 0xaaacaaacaaacaaacULL, }, + { 0xaaabaaabaaabaaabULL, 0xaaabaaabaaabaaabULL, }, + { 0x888a888a888a888aULL, 0x888a888a888a888aULL, }, + { 0x8889888988898889ULL, 0x8889888988898889ULL, }, + { 0x71c88e39c71e71c8ULL, 0x8e39c71e71c88e39ULL, }, + { 0x71c78e3ac71d71c7ULL, 0x8e3ac71d71c78e3aULL, }, + { 0x5556555655565556ULL, 0x5556555655565556ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xaaabaaabaaabaaabULL, 0xaaabaaabaaabaaabULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x8889888988898889ULL, 0x8889888988898889ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x71c78e38c71d71c7ULL, 0x8e38c71d71c78e38ULL, }, + { 0x71c68e39c71c71c6ULL, 0x8e39c71c71c68e39ULL, }, + { 0x3335333533353335ULL, 0x3335333533353335ULL, }, /* 32 */ + { 0x3334333433343334ULL, 0x3334333433343334ULL, }, + { 0x888a888a888a888aULL, 0x888a888a888a888aULL, }, + { 0x8889888988898889ULL, 0x8889888988898889ULL, }, + { 0x6668666866686668ULL, 0x6668666866686668ULL, }, + { 0x6667666766676667ULL, 0x6667666766676667ULL, }, + { 0x4fa66c17a4fc4fa6ULL, 0x6c17a4fc4fa66c17ULL, }, + { 0x4fa56c18a4fb4fa5ULL, 0x6c18a4fb4fa56c18ULL, }, + { 0x3334333433343334ULL, 0x3334333433343334ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x8889888988898889ULL, 0x8889888988898889ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x6667666766676667ULL, 0x6667666766676667ULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x4fa56c16a4fb4fa5ULL, 0x6c16a4fb4fa56c16ULL, }, + { 0x4fa46c17a4fa4fa4ULL, 0x6c17a4fa4fa46c17ULL, }, + { 0x1c7338e471c91c73ULL, 0x38e471c91c7338e4ULL, }, /* 48 */ + { 0x1c7238e371c81c72ULL, 0x38e371c81c7238e3ULL, }, + { 0x71c88e39c71e71c8ULL, 0x8e39c71e71c88e39ULL, }, + { 0x71c78e38c71d71c7ULL, 0x8e38c71d71c78e38ULL, }, + { 0x4fa66c17a4fc4fa6ULL, 0x6c17a4fc4fa66c17ULL, }, + { 0x4fa56c16a4fb4fa5ULL, 0x6c16a4fb4fa56c16ULL, }, + { 0x38e471c6e39038e4ULL, 0x71c6e39038e471c6ULL, }, + { 0x38e371c7e38f38e3ULL, 0x71c7e38f38e371c7ULL, }, + { 0x1c7238e571c81c72ULL, 0x38e571c81c7238e5ULL, }, /* 56 */ + { 0x1c7138e471c71c71ULL, 0x38e471c71c7138e4ULL, }, + { 0x71c78e3ac71d71c7ULL, 0x8e3ac71d71c78e3aULL, }, + { 0x71c68e39c71c71c6ULL, 0x8e39c71c71c68e39ULL, }, + { 0x4fa56c18a4fb4fa5ULL, 0x6c18a4fb4fa56c18ULL, }, + { 0x4fa46c17a4fa4fa4ULL, 0x6c17a4fa4fa46c17ULL, }, + { 0x38e371c7e38f38e3ULL, 0x71c7e38f38e371c7ULL, }, + { 0x38e271c8e38e38e2ULL, 0x71c8e38e38e271c8ULL, }, + { 0xef2c326850c4aa80ULL, 0x96ce16bc030a9fe8ULL, }, /* 64 */ + { 0x7bd8199775f58e38ULL, 0x5e5e504416c4a2f0ULL, }, + { 0xcb3c6a8a6e93c9c0ULL, 0x733f445f565a7508ULL, }, + { 0xe7e52f81869372f2ULL, 0xbd76828658436d54ULL, }, + { 0x7bd8199775f58e38ULL, 0x5e5e504416c4a2f0ULL, }, + { 0x088400c69b2671f0ULL, 0x25ee89cc2a7ea5f8ULL, }, + { 0x57e851b993c4ad78ULL, 0x3acf7de76a147810ULL, }, + { 0x749116b0abc456aaULL, 0x8506bc0e6bfd705cULL, }, + { 0xcb3c6a8a6e93c9c0ULL, 0x733f445f565a7508ULL, }, /* 72 */ + { 0x57e851b993c4ad78ULL, 0x3acf7de76a147810ULL, }, + { 0xa74ca2ac8c62e900ULL, 0x4fb07202a9aa4a28ULL, }, + { 0xc3f567a3a4629232ULL, 0x99e7b029ab934274ULL, }, + { 0xe7e52f81869372f2ULL, 0xbd76828658436d54ULL, }, + { 0x749116b0abc456aaULL, 0x8506bc0e6bfd705cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADD_A_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADD_A_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_w.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_w.c new file mode 100644 index 0000000000..a12f9b9ac7 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_add_a_w.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADD_A.W + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADD_A.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0000000200000002ULL, 0x0000000200000002ULL, }, /* 0 */ + { 0x0000000100000001ULL, 0x0000000100000001ULL, }, + { 0x5555555755555557ULL, 0x5555555755555557ULL, }, + { 0x5555555655555556ULL, 0x5555555655555556ULL, }, + { 0x3333333533333335ULL, 0x3333333533333335ULL, }, + { 0x3333333433333334ULL, 0x3333333433333334ULL, }, + { 0x1c71c71e71c71c73ULL, 0x38e38e391c71c71eULL, }, + { 0x1c71c71d71c71c72ULL, 0x38e38e3a1c71c71dULL, }, + { 0x0000000100000001ULL, 0x0000000100000001ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5555555655555556ULL, 0x5555555655555556ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x3333333433333334ULL, 0x3333333433333334ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x1c71c71d71c71c72ULL, 0x38e38e381c71c71dULL, }, + { 0x1c71c71c71c71c71ULL, 0x38e38e391c71c71cULL, }, + { 0x5555555755555557ULL, 0x5555555755555557ULL, }, /* 16 */ + { 0x5555555655555556ULL, 0x5555555655555556ULL, }, + { 0xaaaaaaacaaaaaaacULL, 0xaaaaaaacaaaaaaacULL, }, + { 0xaaaaaaabaaaaaaabULL, 0xaaaaaaabaaaaaaabULL, }, + { 0x8888888a8888888aULL, 0x8888888a8888888aULL, }, + { 0x8888888988888889ULL, 0x8888888988888889ULL, }, + { 0x71c71c73c71c71c8ULL, 0x8e38e38e71c71c73ULL, }, + { 0x71c71c72c71c71c7ULL, 0x8e38e38f71c71c72ULL, }, + { 0x5555555655555556ULL, 0x5555555655555556ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaabaaaaaaabULL, 0xaaaaaaabaaaaaaabULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x8888888988888889ULL, 0x8888888988888889ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x71c71c72c71c71c7ULL, 0x8e38e38d71c71c72ULL, }, + { 0x71c71c71c71c71c6ULL, 0x8e38e38e71c71c71ULL, }, + { 0x3333333533333335ULL, 0x3333333533333335ULL, }, /* 32 */ + { 0x3333333433333334ULL, 0x3333333433333334ULL, }, + { 0x8888888a8888888aULL, 0x8888888a8888888aULL, }, + { 0x8888888988888889ULL, 0x8888888988888889ULL, }, + { 0x6666666866666668ULL, 0x6666666866666668ULL, }, + { 0x6666666766666667ULL, 0x6666666766666667ULL, }, + { 0x4fa4fa51a4fa4fa6ULL, 0x6c16c16c4fa4fa51ULL, }, + { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16d4fa4fa50ULL, }, + { 0x3333333433333334ULL, 0x3333333433333334ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x8888888988888889ULL, 0x8888888988888889ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x6666666766666667ULL, 0x6666666766666667ULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16b4fa4fa50ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c4fa4fa4fULL, }, + { 0x1c71c71e71c71c73ULL, 0x38e38e391c71c71eULL, }, /* 48 */ + { 0x1c71c71d71c71c72ULL, 0x38e38e381c71c71dULL, }, + { 0x71c71c73c71c71c8ULL, 0x8e38e38e71c71c73ULL, }, + { 0x71c71c72c71c71c7ULL, 0x8e38e38d71c71c72ULL, }, + { 0x4fa4fa51a4fa4fa6ULL, 0x6c16c16c4fa4fa51ULL, }, + { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16b4fa4fa50ULL, }, + { 0x38e38e3ae38e38e4ULL, 0x71c71c7038e38e3aULL, }, + { 0x38e38e39e38e38e3ULL, 0x71c71c7138e38e39ULL, }, + { 0x1c71c71d71c71c72ULL, 0x38e38e3a1c71c71dULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0x38e38e391c71c71cULL, }, + { 0x71c71c72c71c71c7ULL, 0x8e38e38f71c71c72ULL, }, + { 0x71c71c71c71c71c6ULL, 0x8e38e38e71c71c71ULL, }, + { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16d4fa4fa50ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c4fa4fa4fULL, }, + { 0x38e38e39e38e38e3ULL, 0x71c71c7138e38e39ULL, }, + { 0x38e38e38e38e38e2ULL, 0x71c71c7238e38e38ULL, }, + { 0xef2a326850c4aa80ULL, 0x96ce16bc03089fe8ULL, }, /* 64 */ + { 0x7bd718d175f61c48ULL, 0x5e5ec67816c3a2f0ULL, }, + { 0xcb3a6a8a6e92c9c0ULL, 0x733fd25d56592ae0ULL, }, + { 0xe7e42f818694378eULL, 0xbd75828658416d54ULL, }, + { 0x7bd718d175f61c48ULL, 0x5e5ec67816c3a2f0ULL, }, + { 0x0883ff3a9b278e10ULL, 0x25ef76342a7ea5f8ULL, }, + { 0x57e750f393c43b88ULL, 0x3ad082196a142de8ULL, }, + { 0x749115eaabc5a956ULL, 0x850632426bfc705cULL, }, + { 0xcb3a6a8a6e92c9c0ULL, 0x733fd25d56592ae0ULL, }, /* 72 */ + { 0x57e750f393c43b88ULL, 0x3ad082196a142de8ULL, }, + { 0xa74aa2ac8c60e900ULL, 0x4fb18dfea9a9b5d8ULL, }, + { 0xc3f467a3a46256ceULL, 0x99e73e27ab91f84cULL, }, + { 0xe7e42f818694378eULL, 0xbd75828658416d54ULL, }, + { 0x749115eaabc5a956ULL, 0x850632426bfc705cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADD_A_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADD_A_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_b.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_b.c new file mode 100644 index 0000000000..61b8e6e768 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_b.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_A.B + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_A.B"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0202020202020202ULL, 0x0202020202020202ULL, }, /* 0 */ + { 0x0101010101010101ULL, 0x0101010101010101ULL, }, + { 0x5757575757575757ULL, 0x5757575757575757ULL, }, + { 0x5656565656565656ULL, 0x5656565656565656ULL, }, + { 0x3535353535353535ULL, 0x3535353535353535ULL, }, + { 0x3434343434343434ULL, 0x3434343434343434ULL, }, + { 0x1e73391e73391e73ULL, 0x391e73391e73391eULL, }, + { 0x1d723a1d723a1d72ULL, 0x3a1d723a1d723a1dULL, }, + { 0x0101010101010101ULL, 0x0101010101010101ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5656565656565656ULL, 0x5656565656565656ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x3434343434343434ULL, 0x3434343434343434ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x1d72381d72381d72ULL, 0x381d72381d72381dULL, }, + { 0x1c71391c71391c71ULL, 0x391c71391c71391cULL, }, + { 0x5757575757575757ULL, 0x5757575757575757ULL, }, /* 16 */ + { 0x5656565656565656ULL, 0x5656565656565656ULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x737f7f737f7f737fULL, 0x7f737f7f737f7f73ULL, }, + { 0x727f7f727f7f727fULL, 0x7f727f7f727f7f72ULL, }, + { 0x5656565656565656ULL, 0x5656565656565656ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x727f7f727f7f727fULL, 0x7f727f7f727f7f72ULL, }, + { 0x717f7f717f7f717fULL, 0x7f717f7f717f7f71ULL, }, + { 0x3535353535353535ULL, 0x3535353535353535ULL, }, /* 32 */ + { 0x3434343434343434ULL, 0x3434343434343434ULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x6868686868686868ULL, 0x6868686868686868ULL, }, + { 0x6767676767676767ULL, 0x6767676767676767ULL, }, + { 0x517f6c517f6c517fULL, 0x6c517f6c517f6c51ULL, }, + { 0x507f6d507f6d507fULL, 0x6d507f6d507f6d50ULL, }, + { 0x3434343434343434ULL, 0x3434343434343434ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x6767676767676767ULL, 0x6767676767676767ULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x507f6b507f6b507fULL, 0x6b507f6b507f6b50ULL, }, + { 0x4f7f6c4f7f6c4f7fULL, 0x6c4f7f6c4f7f6c4fULL, }, + { 0x1e73391e73391e73ULL, 0x391e73391e73391eULL, }, /* 48 */ + { 0x1d72381d72381d72ULL, 0x381d72381d72381dULL, }, + { 0x737f7f737f7f737fULL, 0x7f737f7f737f7f73ULL, }, + { 0x727f7f727f7f727fULL, 0x7f727f7f727f7f72ULL, }, + { 0x517f6c517f6c517fULL, 0x6c517f6c517f6c51ULL, }, + { 0x507f6b507f6b507fULL, 0x6b507f6b507f6b50ULL, }, + { 0x3a7f703a7f703a7fULL, 0x703a7f703a7f703aULL, }, + { 0x397f71397f71397fULL, 0x71397f71397f7139ULL, }, + { 0x1d723a1d723a1d72ULL, 0x3a1d723a1d723a1dULL, }, /* 56 */ + { 0x1c71391c71391c71ULL, 0x391c71391c71391cULL, }, + { 0x727f7f727f7f727fULL, 0x7f727f7f727f7f72ULL, }, + { 0x717f7f717f7f717fULL, 0x7f717f7f717f7f71ULL, }, + { 0x507f6d507f6d507fULL, 0x6d507f6d507f6d50ULL, }, + { 0x4f7f6c4f7f6c4f7fULL, 0x6c4f7f6c4f7f6c4fULL, }, + { 0x397f71397f71397fULL, 0x71397f71397f7139ULL, }, + { 0x387f72387f72387fULL, 0x72387f72387f7238ULL, }, + { 0x7f7f3468507f7f7fULL, 0x7f7f167f047f7f18ULL, }, /* 64 */ + { 0x7d7f1a7f757f7f48ULL, 0x5d705078177f7f10ULL, }, + { 0x7f7f6c7f6f7f7f7fULL, 0x727f455f577f7520ULL, }, + { 0x7f7f307f7f7f737fULL, 0x7f767f7f597f6e6cULL, }, + { 0x7d7f1a7f757f7f48ULL, 0x5d705078177f7f10ULL, }, + { 0x0a7f007f7f7f7210ULL, 0x24127f342a7e7f08ULL, }, + { 0x597f527f7f7f7f7fULL, 0x39317f1b6a6a7718ULL, }, + { 0x757f167f7f7f5756ULL, 0x7f187f426c7f7064ULL, }, + { 0x7f7f6c7f6f7f7f7fULL, 0x727f455f577f7520ULL, }, /* 72 */ + { 0x597f527f7f7f7f7fULL, 0x39317f1b6a6a7718ULL, }, + { 0x7f7f7f7f7f627f7fULL, 0x4e5074027f564a28ULL, }, + { 0x7f7f687f7f627f7fULL, 0x7f377f297f6d4374ULL, }, + { 0x7f7f307f7f7f737fULL, 0x7f767f7f597f6e6cULL, }, + { 0x757f167f7f7f5756ULL, 0x7f187f426c7f7064ULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_A_B(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_A_B(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_d.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_d.c new file mode 100644 index 0000000000..8350f8f266 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_d.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_A.D + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_A.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0000000000000002ULL, 0x0000000000000002ULL, }, /* 0 */ + { 0x0000000000000001ULL, 0x0000000000000001ULL, }, + { 0x5555555555555557ULL, 0x5555555555555557ULL, }, + { 0x5555555555555556ULL, 0x5555555555555556ULL, }, + { 0x3333333333333335ULL, 0x3333333333333335ULL, }, + { 0x3333333333333334ULL, 0x3333333333333334ULL, }, + { 0x1c71c71c71c71c73ULL, 0x38e38e38e38e38e4ULL, }, + { 0x1c71c71c71c71c72ULL, 0x38e38e38e38e38e5ULL, }, + { 0x0000000000000001ULL, 0x0000000000000001ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5555555555555556ULL, 0x5555555555555556ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x3333333333333334ULL, 0x3333333333333334ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x1c71c71c71c71c72ULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0x38e38e38e38e38e4ULL, }, + { 0x5555555555555557ULL, 0x5555555555555557ULL, }, /* 16 */ + { 0x5555555555555556ULL, 0x5555555555555556ULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x71c71c71c71c71c8ULL, 0x7fffffffffffffffULL, }, + { 0x71c71c71c71c71c7ULL, 0x7fffffffffffffffULL, }, + { 0x5555555555555556ULL, 0x5555555555555556ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x71c71c71c71c71c7ULL, 0x7fffffffffffffffULL, }, + { 0x71c71c71c71c71c6ULL, 0x7fffffffffffffffULL, }, + { 0x3333333333333335ULL, 0x3333333333333335ULL, }, /* 32 */ + { 0x3333333333333334ULL, 0x3333333333333334ULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x6666666666666668ULL, 0x6666666666666668ULL, }, + { 0x6666666666666667ULL, 0x6666666666666667ULL, }, + { 0x4fa4fa4fa4fa4fa6ULL, 0x6c16c16c16c16c17ULL, }, + { 0x4fa4fa4fa4fa4fa5ULL, 0x6c16c16c16c16c18ULL, }, + { 0x3333333333333334ULL, 0x3333333333333334ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x6666666666666667ULL, 0x6666666666666667ULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x4fa4fa4fa4fa4fa5ULL, 0x6c16c16c16c16c16ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c16c16c17ULL, }, + { 0x1c71c71c71c71c73ULL, 0x38e38e38e38e38e4ULL, }, /* 48 */ + { 0x1c71c71c71c71c72ULL, 0x38e38e38e38e38e3ULL, }, + { 0x71c71c71c71c71c8ULL, 0x7fffffffffffffffULL, }, + { 0x71c71c71c71c71c7ULL, 0x7fffffffffffffffULL, }, + { 0x4fa4fa4fa4fa4fa6ULL, 0x6c16c16c16c16c17ULL, }, + { 0x4fa4fa4fa4fa4fa5ULL, 0x6c16c16c16c16c16ULL, }, + { 0x38e38e38e38e38e4ULL, 0x71c71c71c71c71c6ULL, }, + { 0x38e38e38e38e38e3ULL, 0x71c71c71c71c71c7ULL, }, + { 0x1c71c71c71c71c72ULL, 0x38e38e38e38e38e5ULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0x38e38e38e38e38e4ULL, }, + { 0x71c71c71c71c71c7ULL, 0x7fffffffffffffffULL, }, + { 0x71c71c71c71c71c6ULL, 0x7fffffffffffffffULL, }, + { 0x4fa4fa4fa4fa4fa5ULL, 0x6c16c16c16c16c18ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c16c16c17ULL, }, + { 0x38e38e38e38e38e3ULL, 0x71c71c71c71c71c7ULL, }, + { 0x38e38e38e38e38e2ULL, 0x71c71c71c71c71c8ULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, /* 64 */ + { 0x7bd718d08a09e3b8ULL, 0x5e5ec67913bb0308ULL, }, + { 0x7fffffffffffffffULL, 0x733fd25ea9a6d520ULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7bd718d08a09e3b8ULL, 0x5e5ec67913bb0308ULL, }, + { 0x0883ff3964d871f0ULL, 0x25ef76342a7ea5f8ULL, }, + { 0x57e750f1f89cad78ULL, 0x3ad08219c06a7810ULL, }, + { 0x749115ea109e1b46ULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x733fd25ea9a6d520ULL, }, /* 72 */ + { 0x57e750f1f89cad78ULL, 0x3ad08219c06a7810ULL, }, + { 0x7fffffffffffffffULL, 0x4fb18dff56564a28ULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x749115ea109e1b46ULL, 0x7fffffffffffffffULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_A_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_A_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_h.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_h.c new file mode 100644 index 0000000000..952f9f892c --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_h.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_A.H + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_A.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0002000200020002ULL, 0x0002000200020002ULL, }, /* 0 */ + { 0x0001000100010001ULL, 0x0001000100010001ULL, }, + { 0x5557555755575557ULL, 0x5557555755575557ULL, }, + { 0x5556555655565556ULL, 0x5556555655565556ULL, }, + { 0x3335333533353335ULL, 0x3335333533353335ULL, }, + { 0x3334333433343334ULL, 0x3334333433343334ULL, }, + { 0x1c7338e471c91c73ULL, 0x38e471c91c7338e4ULL, }, + { 0x1c7238e571c81c72ULL, 0x38e571c81c7238e5ULL, }, + { 0x0001000100010001ULL, 0x0001000100010001ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5556555655565556ULL, 0x5556555655565556ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x3334333433343334ULL, 0x3334333433343334ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x1c7238e371c81c72ULL, 0x38e371c81c7238e3ULL, }, + { 0x1c7138e471c71c71ULL, 0x38e471c71c7138e4ULL, }, + { 0x5557555755575557ULL, 0x5557555755575557ULL, }, /* 16 */ + { 0x5556555655565556ULL, 0x5556555655565556ULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x71c87fff7fff71c8ULL, 0x7fff7fff71c87fffULL, }, + { 0x71c77fff7fff71c7ULL, 0x7fff7fff71c77fffULL, }, + { 0x5556555655565556ULL, 0x5556555655565556ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x71c77fff7fff71c7ULL, 0x7fff7fff71c77fffULL, }, + { 0x71c67fff7fff71c6ULL, 0x7fff7fff71c67fffULL, }, + { 0x3335333533353335ULL, 0x3335333533353335ULL, }, /* 32 */ + { 0x3334333433343334ULL, 0x3334333433343334ULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x6668666866686668ULL, 0x6668666866686668ULL, }, + { 0x6667666766676667ULL, 0x6667666766676667ULL, }, + { 0x4fa66c177fff4fa6ULL, 0x6c177fff4fa66c17ULL, }, + { 0x4fa56c187fff4fa5ULL, 0x6c187fff4fa56c18ULL, }, + { 0x3334333433343334ULL, 0x3334333433343334ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x6667666766676667ULL, 0x6667666766676667ULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x4fa56c167fff4fa5ULL, 0x6c167fff4fa56c16ULL, }, + { 0x4fa46c177fff4fa4ULL, 0x6c177fff4fa46c17ULL, }, + { 0x1c7338e471c91c73ULL, 0x38e471c91c7338e4ULL, }, /* 48 */ + { 0x1c7238e371c81c72ULL, 0x38e371c81c7238e3ULL, }, + { 0x71c87fff7fff71c8ULL, 0x7fff7fff71c87fffULL, }, + { 0x71c77fff7fff71c7ULL, 0x7fff7fff71c77fffULL, }, + { 0x4fa66c177fff4fa6ULL, 0x6c177fff4fa66c17ULL, }, + { 0x4fa56c167fff4fa5ULL, 0x6c167fff4fa56c16ULL, }, + { 0x38e471c67fff38e4ULL, 0x71c67fff38e471c6ULL, }, + { 0x38e371c77fff38e3ULL, 0x71c77fff38e371c7ULL, }, + { 0x1c7238e571c81c72ULL, 0x38e571c81c7238e5ULL, }, /* 56 */ + { 0x1c7138e471c71c71ULL, 0x38e471c71c7138e4ULL, }, + { 0x71c77fff7fff71c7ULL, 0x7fff7fff71c77fffULL, }, + { 0x71c67fff7fff71c6ULL, 0x7fff7fff71c67fffULL, }, + { 0x4fa56c187fff4fa5ULL, 0x6c187fff4fa56c18ULL, }, + { 0x4fa46c177fff4fa4ULL, 0x6c177fff4fa46c17ULL, }, + { 0x38e371c77fff38e3ULL, 0x71c77fff38e371c7ULL, }, + { 0x38e271c87fff38e2ULL, 0x71c87fff38e271c8ULL, }, + { 0x7fff326850c47fffULL, 0x7fff16bc030a7fffULL, }, /* 64 */ + { 0x7bd8199775f57fffULL, 0x5e5e504416c47fffULL, }, + { 0x7fff6a8a6e937fffULL, 0x733f445f565a7508ULL, }, + { 0x7fff2f817fff72f2ULL, 0x7fff7fff58436d54ULL, }, + { 0x7bd8199775f57fffULL, 0x5e5e504416c47fffULL, }, + { 0x088400c67fff71f0ULL, 0x25ee7fff2a7e7fffULL, }, + { 0x57e851b97fff7fffULL, 0x3acf7de76a147810ULL, }, + { 0x749116b07fff56aaULL, 0x7fff7fff6bfd705cULL, }, + { 0x7fff6a8a6e937fffULL, 0x733f445f565a7508ULL, }, /* 72 */ + { 0x57e851b97fff7fffULL, 0x3acf7de76a147810ULL, }, + { 0x7fff7fff7fff7fffULL, 0x4fb072027fff4a28ULL, }, + { 0x7fff67a37fff7fffULL, 0x7fff7fff7fff4274ULL, }, + { 0x7fff2f817fff72f2ULL, 0x7fff7fff58436d54ULL, }, + { 0x749116b07fff56aaULL, 0x7fff7fff6bfd705cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_A_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_A_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_w.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_w.c new file mode 100644 index 0000000000..d058c64cc4 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_a_w.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_A.W + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_A.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0000000200000002ULL, 0x0000000200000002ULL, }, /* 0 */ + { 0x0000000100000001ULL, 0x0000000100000001ULL, }, + { 0x5555555755555557ULL, 0x5555555755555557ULL, }, + { 0x5555555655555556ULL, 0x5555555655555556ULL, }, + { 0x3333333533333335ULL, 0x3333333533333335ULL, }, + { 0x3333333433333334ULL, 0x3333333433333334ULL, }, + { 0x1c71c71e71c71c73ULL, 0x38e38e391c71c71eULL, }, + { 0x1c71c71d71c71c72ULL, 0x38e38e3a1c71c71dULL, }, + { 0x0000000100000001ULL, 0x0000000100000001ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5555555655555556ULL, 0x5555555655555556ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x3333333433333334ULL, 0x3333333433333334ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x1c71c71d71c71c72ULL, 0x38e38e381c71c71dULL, }, + { 0x1c71c71c71c71c71ULL, 0x38e38e391c71c71cULL, }, + { 0x5555555755555557ULL, 0x5555555755555557ULL, }, /* 16 */ + { 0x5555555655555556ULL, 0x5555555655555556ULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x71c71c737fffffffULL, 0x7fffffff71c71c73ULL, }, + { 0x71c71c727fffffffULL, 0x7fffffff71c71c72ULL, }, + { 0x5555555655555556ULL, 0x5555555655555556ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x71c71c727fffffffULL, 0x7fffffff71c71c72ULL, }, + { 0x71c71c717fffffffULL, 0x7fffffff71c71c71ULL, }, + { 0x3333333533333335ULL, 0x3333333533333335ULL, }, /* 32 */ + { 0x3333333433333334ULL, 0x3333333433333334ULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x6666666866666668ULL, 0x6666666866666668ULL, }, + { 0x6666666766666667ULL, 0x6666666766666667ULL, }, + { 0x4fa4fa517fffffffULL, 0x6c16c16c4fa4fa51ULL, }, + { 0x4fa4fa507fffffffULL, 0x6c16c16d4fa4fa50ULL, }, + { 0x3333333433333334ULL, 0x3333333433333334ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x6666666766666667ULL, 0x6666666766666667ULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x4fa4fa507fffffffULL, 0x6c16c16b4fa4fa50ULL, }, + { 0x4fa4fa4f7fffffffULL, 0x6c16c16c4fa4fa4fULL, }, + { 0x1c71c71e71c71c73ULL, 0x38e38e391c71c71eULL, }, /* 48 */ + { 0x1c71c71d71c71c72ULL, 0x38e38e381c71c71dULL, }, + { 0x71c71c737fffffffULL, 0x7fffffff71c71c73ULL, }, + { 0x71c71c727fffffffULL, 0x7fffffff71c71c72ULL, }, + { 0x4fa4fa517fffffffULL, 0x6c16c16c4fa4fa51ULL, }, + { 0x4fa4fa507fffffffULL, 0x6c16c16b4fa4fa50ULL, }, + { 0x38e38e3a7fffffffULL, 0x71c71c7038e38e3aULL, }, + { 0x38e38e397fffffffULL, 0x71c71c7138e38e39ULL, }, + { 0x1c71c71d71c71c72ULL, 0x38e38e3a1c71c71dULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0x38e38e391c71c71cULL, }, + { 0x71c71c727fffffffULL, 0x7fffffff71c71c72ULL, }, + { 0x71c71c717fffffffULL, 0x7fffffff71c71c71ULL, }, + { 0x4fa4fa507fffffffULL, 0x6c16c16d4fa4fa50ULL, }, + { 0x4fa4fa4f7fffffffULL, 0x6c16c16c4fa4fa4fULL, }, + { 0x38e38e397fffffffULL, 0x71c71c7138e38e39ULL, }, + { 0x38e38e387fffffffULL, 0x71c71c7238e38e38ULL, }, + { 0x7fffffff50c4aa80ULL, 0x7fffffff03089fe8ULL, }, /* 64 */ + { 0x7bd718d175f61c48ULL, 0x5e5ec67816c3a2f0ULL, }, + { 0x7fffffff6e92c9c0ULL, 0x733fd25d56592ae0ULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff58416d54ULL, }, + { 0x7bd718d175f61c48ULL, 0x5e5ec67816c3a2f0ULL, }, + { 0x0883ff3a7fffffffULL, 0x25ef76342a7ea5f8ULL, }, + { 0x57e750f37fffffffULL, 0x3ad082196a142de8ULL, }, + { 0x749115ea7fffffffULL, 0x7fffffff6bfc705cULL, }, + { 0x7fffffff6e92c9c0ULL, 0x733fd25d56592ae0ULL, }, /* 72 */ + { 0x57e750f37fffffffULL, 0x3ad082196a142de8ULL, }, + { 0x7fffffff7fffffffULL, 0x4fb18dfe7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff58416d54ULL, }, + { 0x749115ea7fffffffULL, 0x7fffffff6bfc705cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_A_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_A_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_b.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_b.c new file mode 100644 index 0000000000..63e27da626 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_b.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_S.B + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_S.B"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfefefefefefefefeULL, 0xfefefefefefefefeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xa9a9a9a9a9a9a9a9ULL, 0xa9a9a9a9a9a9a9a9ULL, }, + { 0x5454545454545454ULL, 0x5454545454545454ULL, }, + { 0xcbcbcbcbcbcbcbcbULL, 0xcbcbcbcbcbcbcbcbULL, }, + { 0x3232323232323232ULL, 0x3232323232323232ULL, }, + { 0xe28d37e28d37e28dULL, 0x37e28d37e28d37e2ULL, }, + { 0x1b70c61b70c61b70ULL, 0xc61b70c61b70c61bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xa9a9a9a9a9a9a9a9ULL, 0xa9a9a9a9a9a9a9a9ULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x8080808080808080ULL, 0x8080808080808080ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x8080808080808080ULL, 0x8080808080808080ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8d80e28d80e28d80ULL, 0xe28d80e28d80e28dULL, }, + { 0xc61b80c61b80c61bULL, 0x80c61b80c61b80c6ULL, }, + { 0x5454545454545454ULL, 0x5454545454545454ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x2121212121212121ULL, 0x2121212121212121ULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0x38e37f38e37f38e3ULL, 0x7f38e37f38e37f38ULL, }, + { 0x717f1c717f1c717fULL, 0x1c717f1c717f1c71ULL, }, + { 0xcbcbcbcbcbcbcbcbULL, 0xcbcbcbcbcbcbcbcbULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x8080808080808080ULL, 0x8080808080808080ULL, }, + { 0x2121212121212121ULL, 0x2121212121212121ULL, }, + { 0x9898989898989898ULL, 0x9898989898989898ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaf8004af8004af80ULL, 0x04af8004af8004afULL, }, + { 0xe83d93e83d93e83dULL, 0x93e83d93e83d93e8ULL, }, + { 0x3232323232323232ULL, 0x3232323232323232ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x16c16b16c16b16c1ULL, 0x6b16c16b16c16b16ULL, }, + { 0x4f7ffa4f7ffa4f7fULL, 0xfa4f7ffa4f7ffa4fULL, }, + { 0xe28d37e28d37e28dULL, 0x37e28d37e28d37e2ULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x8d80e28d80e28d80ULL, 0xe28d80e28d80e28dULL, }, + { 0x38e37f38e37f38e3ULL, 0x7f38e37f38e37f38ULL, }, + { 0xaf8004af8004af80ULL, 0x04af8004af8004afULL, }, + { 0x16c16b16c16b16c1ULL, 0x6b16c16b16c16b16ULL, }, + { 0xc68070c68070c680ULL, 0x70c68070c68070c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x1b70c61b70c61b70ULL, 0xc61b70c61b70c61bULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc61b80c61b80c61bULL, 0x80c61b80c61b80c6ULL, }, + { 0x717f1c717f1c717fULL, 0x1c717f1c717f1c71ULL, }, + { 0xe83d93e83d93e83dULL, 0x93e83d93e83d93e8ULL, }, + { 0x4f7ffa4f7ffa4f7fULL, 0xfa4f7ffa4f7ffa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x387f8e387f8e387fULL, 0x8e387f8e387f8e38ULL, }, + { 0x807fcc98507f7f7fULL, 0x7f7f167ffc7f8018ULL, }, /* 64 */ + { 0x8328e62f75f51c48ULL, 0x5d5ec678137f0208ULL, }, + { 0x807f9480e131e0c0ULL, 0x723fd15da97fd520ULL, }, + { 0xf87ffc197f7f377fULL, 0xd8589336a77f92acULL, }, + { 0x8328e62f75f51c48ULL, 0x5d5ec678137f0208ULL, }, + { 0xf680007f7f808e10ULL, 0x24ee80342a7e7ff8ULL, }, + { 0xa718ae0d06808088ULL, 0x39cf8119c06a7710ULL, }, + { 0x6b0d167f7fc4a956ULL, 0x9fe880f2be7f349cULL, }, + { 0x807f9480e131e0c0ULL, 0x723fd15da97fd520ULL, }, /* 72 */ + { 0xa718ae0d06808088ULL, 0x39cf8119c06a7710ULL, }, + { 0x807f8080809e8080ULL, 0x4eb08cfe80564a28ULL, }, + { 0x1c7fc4f7170080ceULL, 0xb4c980d7806d07b4ULL, }, + { 0xf87ffc197f7f377fULL, 0xd8589336a77f92acULL, }, + { 0x6b0d167f7fc4a956ULL, 0x9fe880f2be7f349cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_S_B(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_S_B(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_d.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_d.c new file mode 100644 index 0000000000..2719cee6d6 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_d.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_S.D + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_S.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfffffffffffffffeULL, 0xfffffffffffffffeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaa9ULL, 0xaaaaaaaaaaaaaaa9ULL, }, + { 0x5555555555555554ULL, 0x5555555555555554ULL, }, + { 0xcccccccccccccccbULL, 0xcccccccccccccccbULL, }, + { 0x3333333333333332ULL, 0x3333333333333332ULL, }, + { 0xe38e38e38e38e38dULL, 0x38e38e38e38e38e2ULL, }, + { 0x1c71c71c71c71c70ULL, 0xc71c71c71c71c71bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xaaaaaaaaaaaaaaa9ULL, 0xaaaaaaaaaaaaaaa9ULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x8000000000000000ULL, 0x8000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x8000000000000000ULL, 0x8000000000000000ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8e38e38e38e38e38ULL, 0xe38e38e38e38e38dULL, }, + { 0xc71c71c71c71c71bULL, 0x8000000000000000ULL, }, + { 0x5555555555555554ULL, 0x5555555555555554ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x2222222222222221ULL, 0x2222222222222221ULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0x38e38e38e38e38e3ULL, 0x7fffffffffffffffULL, }, + { 0x71c71c71c71c71c6ULL, 0x1c71c71c71c71c71ULL, }, + { 0xcccccccccccccccbULL, 0xcccccccccccccccbULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x8000000000000000ULL, 0x8000000000000000ULL, }, + { 0x2222222222222221ULL, 0x2222222222222221ULL, }, + { 0x9999999999999998ULL, 0x9999999999999998ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xb05b05b05b05b05aULL, 0x05b05b05b05b05afULL, }, + { 0xe93e93e93e93e93dULL, 0x93e93e93e93e93e8ULL, }, + { 0x3333333333333332ULL, 0x3333333333333332ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x7fffffffffffffffULL, 0x7fffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x16c16c16c16c16c1ULL, 0x6c16c16c16c16c16ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xe38e38e38e38e38dULL, 0x38e38e38e38e38e2ULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x8e38e38e38e38e38ULL, 0xe38e38e38e38e38dULL, }, + { 0x38e38e38e38e38e3ULL, 0x7fffffffffffffffULL, }, + { 0xb05b05b05b05b05aULL, 0x05b05b05b05b05afULL, }, + { 0x16c16c16c16c16c1ULL, 0x6c16c16c16c16c16ULL, }, + { 0xc71c71c71c71c71cULL, 0x71c71c71c71c71c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x1c71c71c71c71c70ULL, 0xc71c71c71c71c71bULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71c71c71c71c71bULL, 0x8000000000000000ULL, }, + { 0x71c71c71c71c71c6ULL, 0x1c71c71c71c71c71ULL, }, + { 0xe93e93e93e93e93dULL, 0x93e93e93e93e93e8ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e38e38e38e38e2ULL, 0x8e38e38e38e38e38ULL, }, + { 0x8000000000000000ULL, 0x7fffffffffffffffULL, }, /* 64 */ + { 0x8428e72f75f61c48ULL, 0x5e5ec67913bb0308ULL, }, + { 0x8000000000000000ULL, 0x733fd25ea9a6d520ULL, }, + { 0xf8b9fd198694378eULL, 0xd9589437a7be92acULL, }, + { 0x8428e72f75f61c48ULL, 0x5e5ec67913bb0308ULL, }, + { 0xf77c00c69b278e10ULL, 0x25ef76342a7ea5f8ULL, }, + { 0xa818af0e07635288ULL, 0x3ad08219c06a7810ULL, }, + { 0x6c0d16b0abc5a956ULL, 0xa0e943f2be82359cULL, }, + { 0x8000000000000000ULL, 0x733fd25ea9a6d520ULL, }, /* 72 */ + { 0xa818af0e07635288ULL, 0x3ad08219c06a7810ULL, }, + { 0x8000000000000000ULL, 0x4fb18dff56564a28ULL, }, + { 0x1ca9c4f818016dceULL, 0xb5ca4fd8546e07b4ULL, }, + { 0xf8b9fd198694378eULL, 0xd9589437a7be92acULL, }, + { 0x6c0d16b0abc5a956ULL, 0xa0e943f2be82359cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_S_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_S_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_h.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_h.c new file mode 100644 index 0000000000..52740964a9 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_h.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_S.H + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_S.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfffefffefffefffeULL, 0xfffefffefffefffeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaa9aaa9aaa9aaa9ULL, 0xaaa9aaa9aaa9aaa9ULL, }, + { 0x5554555455545554ULL, 0x5554555455545554ULL, }, + { 0xcccbcccbcccbcccbULL, 0xcccbcccbcccbcccbULL, }, + { 0x3332333233323332ULL, 0x3332333233323332ULL, }, + { 0xe38d38e28e37e38dULL, 0x38e28e37e38d38e2ULL, }, + { 0x1c70c71b71c61c70ULL, 0xc71b71c61c70c71bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xaaa9aaa9aaa9aaa9ULL, 0xaaa9aaa9aaa9aaa9ULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x8000800080008000ULL, 0x8000800080008000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x8000800080008000ULL, 0x8000800080008000ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8e38e38d80008e38ULL, 0xe38d80008e38e38dULL, }, + { 0xc71b80001c71c71bULL, 0x80001c71c71b8000ULL, }, + { 0x5554555455545554ULL, 0x5554555455545554ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x2221222122212221ULL, 0x2221222122212221ULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0x38e37fffe38d38e3ULL, 0x7fffe38d38e37fffULL, }, + { 0x71c61c717fff71c6ULL, 0x1c717fff71c61c71ULL, }, + { 0xcccbcccbcccbcccbULL, 0xcccbcccbcccbcccbULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x8000800080008000ULL, 0x8000800080008000ULL, }, + { 0x2221222122212221ULL, 0x2221222122212221ULL, }, + { 0x9998999899989998ULL, 0x9998999899989998ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xb05a05af8000b05aULL, 0x05af8000b05a05afULL, }, + { 0xe93d93e83e93e93dULL, 0x93e83e93e93d93e8ULL, }, + { 0x3332333233323332ULL, 0x3332333233323332ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x7fff7fff7fff7fffULL, 0x7fff7fff7fff7fffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x16c16c16c16b16c1ULL, 0x6c16c16b16c16c16ULL, }, + { 0x4fa4fa4f7fff4fa4ULL, 0xfa4f7fff4fa4fa4fULL, }, + { 0xe38d38e28e37e38dULL, 0x38e28e37e38d38e2ULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x8e38e38d80008e38ULL, 0xe38d80008e38e38dULL, }, + { 0x38e37fffe38d38e3ULL, 0x7fffe38d38e37fffULL, }, + { 0xb05a05af8000b05aULL, 0x05af8000b05a05afULL, }, + { 0x16c16c16c16b16c1ULL, 0x6c16c16b16c16c16ULL, }, + { 0xc71c71c68000c71cULL, 0x71c68000c71c71c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x1c70c71b71c61c70ULL, 0xc71b71c61c70c71bULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71b80001c71c71bULL, 0x80001c71c71b8000ULL, }, + { 0x71c61c717fff71c6ULL, 0x1c717fff71c61c71ULL, }, + { 0xe93d93e83e93e93dULL, 0x93e83e93e93d93e8ULL, }, + { 0x4fa4fa4f7fff4fa4ULL, 0xfa4f7fff4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e28e387fff38e2ULL, 0x8e387fff38e28e38ULL, }, + { 0x8000cd9850c47fffULL, 0x7fff16bcfcf68000ULL, }, /* 64 */ + { 0x8428e72f75f51c48ULL, 0x5e5ec67813ba0308ULL, }, + { 0x80009576e231e0c0ULL, 0x733fd25da9a6d520ULL, }, + { 0xf8b9fd197fff378eULL, 0xd9589436a7bd92acULL, }, + { 0x8428e72f75f51c48ULL, 0x5e5ec67813ba0308ULL, }, + { 0xf77c00c67fff8e10ULL, 0x25ee80002a7e7fffULL, }, + { 0xa818af0d07628000ULL, 0x3acf8219c06a7810ULL, }, + { 0x6c0d16b07fffa956ULL, 0xa0e88000be81359cULL, }, + { 0x80009576e231e0c0ULL, 0x733fd25da9a6d520ULL, }, /* 72 */ + { 0xa818af0d07628000ULL, 0x3acf8219c06a7810ULL, }, + { 0x8000800080008000ULL, 0x4fb08dfe80004a28ULL, }, + { 0x1ca9c4f718008000ULL, 0xb5c98000800007b4ULL, }, + { 0xf8b9fd197fff378eULL, 0xd9589436a7bd92acULL, }, + { 0x6c0d16b07fffa956ULL, 0xa0e88000be81359cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_S_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_S_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_w.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_w.c new file mode 100644 index 0000000000..c3a6292d89 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_s_w.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_S.W + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_S.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfffffffefffffffeULL, 0xfffffffefffffffeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaa9aaaaaaa9ULL, 0xaaaaaaa9aaaaaaa9ULL, }, + { 0x5555555455555554ULL, 0x5555555455555554ULL, }, + { 0xcccccccbcccccccbULL, 0xcccccccbcccccccbULL, }, + { 0x3333333233333332ULL, 0x3333333233333332ULL, }, + { 0xe38e38e28e38e38dULL, 0x38e38e37e38e38e2ULL, }, + { 0x1c71c71b71c71c70ULL, 0xc71c71c61c71c71bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xaaaaaaa9aaaaaaa9ULL, 0xaaaaaaa9aaaaaaa9ULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x8000000080000000ULL, 0x8000000080000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x8000000080000000ULL, 0x8000000080000000ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8e38e38d80000000ULL, 0xe38e38e28e38e38dULL, }, + { 0xc71c71c61c71c71bULL, 0x80000000c71c71c6ULL, }, + { 0x5555555455555554ULL, 0x5555555455555554ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x2222222122222221ULL, 0x2222222122222221ULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0x38e38e38e38e38e3ULL, 0x7fffffff38e38e38ULL, }, + { 0x71c71c717fffffffULL, 0x1c71c71c71c71c71ULL, }, + { 0xcccccccbcccccccbULL, 0xcccccccbcccccccbULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x8000000080000000ULL, 0x8000000080000000ULL, }, + { 0x2222222122222221ULL, 0x2222222122222221ULL, }, + { 0x9999999899999998ULL, 0x9999999899999998ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xb05b05af80000000ULL, 0x05b05b04b05b05afULL, }, + { 0xe93e93e83e93e93dULL, 0x93e93e93e93e93e8ULL, }, + { 0x3333333233333332ULL, 0x3333333233333332ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x7fffffff7fffffffULL, 0x7fffffff7fffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x16c16c16c16c16c1ULL, 0x6c16c16b16c16c16ULL, }, + { 0x4fa4fa4f7fffffffULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xe38e38e28e38e38dULL, 0x38e38e37e38e38e2ULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x8e38e38d80000000ULL, 0xe38e38e28e38e38dULL, }, + { 0x38e38e38e38e38e3ULL, 0x7fffffff38e38e38ULL, }, + { 0xb05b05af80000000ULL, 0x05b05b04b05b05afULL, }, + { 0x16c16c16c16c16c1ULL, 0x6c16c16b16c16c16ULL, }, + { 0xc71c71c680000000ULL, 0x71c71c70c71c71c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x1c71c71b71c71c70ULL, 0xc71c71c61c71c71bULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71c71c61c71c71bULL, 0x80000000c71c71c6ULL, }, + { 0x71c71c717fffffffULL, 0x1c71c71c71c71c71ULL, }, + { 0xe93e93e83e93e93dULL, 0x93e93e93e93e93e8ULL, }, + { 0x4fa4fa4f7fffffffULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e38e387fffffffULL, 0x8e38e38e38e38e38ULL, }, + { 0x8000000050c4aa80ULL, 0x7ffffffffcf76018ULL, }, /* 64 */ + { 0x8428e72f75f61c48ULL, 0x5e5ec67813bb0308ULL, }, + { 0x80000000e231e0c0ULL, 0x733fd25da9a6d520ULL, }, + { 0xf8b9fd197fffffffULL, 0xd9589436a7be92acULL, }, + { 0x8428e72f75f61c48ULL, 0x5e5ec67813bb0308ULL, }, + { 0xf77c00c67fffffffULL, 0x25ef76342a7ea5f8ULL, }, + { 0xa818af0d07635288ULL, 0x3ad08219c06a7810ULL, }, + { 0x6c0d16b07fffffffULL, 0xa0e943f2be82359cULL, }, + { 0x80000000e231e0c0ULL, 0x733fd25da9a6d520ULL, }, /* 72 */ + { 0xa818af0d07635288ULL, 0x3ad08219c06a7810ULL, }, + { 0x8000000080000000ULL, 0x4fb18dfe80000000ULL, }, + { 0x1ca9c4f718016dceULL, 0xb5ca4fd780000000ULL, }, + { 0xf8b9fd197fffffffULL, 0xd9589436a7be92acULL, }, + { 0x6c0d16b07fffffffULL, 0xa0e943f2be82359cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_S_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_S_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_b.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_b.c new file mode 100644 index 0000000000..df5d85f2e9 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_b.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_U.B + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_U.B"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0xffffe2ffffe2ffffULL, 0xe2ffffe2ffffe2ffULL, }, + { 0xc6ffffc6ffffc6ffULL, 0xffc6ffffc6ffffc6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffe38dffe38dffe3ULL, 0x8dffe38dffe38dffULL, }, + { 0x71c6ff71c6ff71c6ULL, 0xff71c6ff71c6ff71ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xe8ffffe8ffffe8ffULL, 0xffe8ffffe8ffffe8ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0xffc16bffc16bffc1ULL, 0x6bffc16bffc16bffULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0xffffe2ffffe2ffffULL, 0xe2ffffe2ffffe2ffULL, }, + { 0xffe38dffe38dffe3ULL, 0x8dffe38dffe38dffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffc16bffc16bffc1ULL, 0x6bffc16bffc16bffULL, }, + { 0xffff70ffff70ffffULL, 0x70ffff70ffff70ffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc6ffffc6ffffc6ffULL, 0xffc6ffffc6ffffc6ULL, }, + { 0x71c6ff71c6ff71c6ULL, 0xff71c6ff71c6ff71ULL, }, + { 0xe8ffffe8ffffe8ffULL, 0xffe8ffffe8ffffe8ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e2ff38e2ff38e2ULL, 0xff38e2ff38e2ff38ULL, }, + { 0xffd4ffff50c4aa80ULL, 0x96ce16bcfff6ff18ULL, }, /* 64 */ + { 0xffffe6ff75f5ff48ULL, 0x5dffc678ffbaffffULL, }, + { 0xffc4ffffe1ffe0c0ULL, 0x72ffd1ffffa6d520ULL, }, + { 0xf8b9fcff8693ff8eULL, 0xd8ff93ffffbdffacULL, }, + { 0xffffe6ff75f5ff48ULL, 0x5dffc678ffbaffffULL, }, + { 0xffff00c69affff10ULL, 0x24ffff342a7ea4ffULL, }, + { 0xffffaeffffffff88ULL, 0x39ffffffc06a77ffULL, }, + { 0xffff16b0abc4ff56ULL, 0x9ffffff2be81ffffULL, }, + { 0xffc4ffffe1ffe0c0ULL, 0x72ffd1ffffa6d520ULL, }, /* 72 */ + { 0xffffaeffffffff88ULL, 0x39ffffffc06a77ffULL, }, + { 0xffb4ffffffffffffULL, 0x4effffffff564a28ULL, }, + { 0xffa9c4f7ffffffceULL, 0xb4ffffffff6dffb4ULL, }, + { 0xf8b9fcff8693ff8eULL, 0xd8ff93ffffbdffacULL, }, + { 0xffff16b0abc4ff56ULL, 0x9ffffff2be81ffffULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_U_B(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_U_B(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_d.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_d.c new file mode 100644 index 0000000000..10c665bcd7 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_d.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_U.D + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_U.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0xffffffffffffffffULL, 0xe38e38e38e38e38dULL, }, + { 0xc71c71c71c71c71bULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffffffffffULL, 0x8e38e38e38e38e38ULL, }, + { 0x71c71c71c71c71c6ULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xe93e93e93e93e93dULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0xffffffffffffffffULL, 0x6c16c16c16c16c16ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0xffffffffffffffffULL, 0xe38e38e38e38e38dULL, }, + { 0xffffffffffffffffULL, 0x8e38e38e38e38e38ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x6c16c16c16c16c16ULL, }, + { 0xffffffffffffffffULL, 0x71c71c71c71c71c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71c71c71c71c71bULL, 0xffffffffffffffffULL, }, + { 0x71c71c71c71c71c6ULL, 0xffffffffffffffffULL, }, + { 0xe93e93e93e93e93dULL, 0xffffffffffffffffULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e38e38e38e38e2ULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x96ce16bdfcf76018ULL, }, /* 64 */ + { 0xffffffffffffffffULL, 0x5e5ec67913bb0308ULL, }, + { 0xffffffffffffffffULL, 0x733fd25ea9a6d520ULL, }, + { 0xf8b9fd198694378eULL, 0xd9589437a7be92acULL, }, + { 0xffffffffffffffffULL, 0x5e5ec67913bb0308ULL, }, + { 0xffffffffffffffffULL, 0x25ef76342a7ea5f8ULL, }, + { 0xffffffffffffffffULL, 0x3ad08219c06a7810ULL, }, + { 0xffffffffffffffffULL, 0xa0e943f2be82359cULL, }, + { 0xffffffffffffffffULL, 0x733fd25ea9a6d520ULL, }, /* 72 */ + { 0xffffffffffffffffULL, 0x3ad08219c06a7810ULL, }, + { 0xffffffffffffffffULL, 0x4fb18dff56564a28ULL, }, + { 0xffffffffffffffffULL, 0xb5ca4fd8546e07b4ULL, }, + { 0xf8b9fd198694378eULL, 0xd9589437a7be92acULL, }, + { 0xffffffffffffffffULL, 0xa0e943f2be82359cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_U_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_U_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_h.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_h.c new file mode 100644 index 0000000000..1e32f000a8 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_h.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_U.H + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_U.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0xffffe38dffffffffULL, 0xe38dffffffffe38dULL, }, + { 0xc71bffffffffc71bULL, 0xffffffffc71bffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffff8e38e38dffffULL, 0x8e38e38dffff8e38ULL, }, + { 0x71c6ffffc71c71c6ULL, 0xffffc71c71c6ffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xe93dffffffffe93dULL, 0xffffffffe93dffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0xffff6c16c16bffffULL, 0x6c16c16bffff6c16ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0xffffe38dffffffffULL, 0xe38dffffffffe38dULL, }, + { 0xffff8e38e38dffffULL, 0x8e38e38dffff8e38ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffff6c16c16bffffULL, 0x6c16c16bffff6c16ULL, }, + { 0xffff71c6ffffffffULL, 0x71c6ffffffff71c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71bffffffffc71bULL, 0xffffffffc71bffffULL, }, + { 0x71c6ffffc71c71c6ULL, 0xffffc71c71c6ffffULL, }, + { 0xe93dffffffffe93dULL, 0xffffffffe93dffffULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e2ffffe38e38e2ULL, 0xffffe38e38e2ffffULL, }, + { 0xffffffff50c4aa80ULL, 0x96ce16bcffffffffULL, }, /* 64 */ + { 0xffffe72f75f5ffffULL, 0x5e5ec678ffffffffULL, }, + { 0xffffffffe231e0c0ULL, 0x733fd25dffffd520ULL, }, + { 0xf8b9fd198693ffffULL, 0xd9589436ffffffffULL, }, + { 0xffffe72f75f5ffffULL, 0x5e5ec678ffffffffULL, }, + { 0xffff00c69b26ffffULL, 0x25eeffff2a7ea5f8ULL, }, + { 0xffffaf0dffffffffULL, 0x3acfffffc06a7810ULL, }, + { 0xffff16b0abc4ffffULL, 0xa0e8ffffbe81ffffULL, }, + { 0xffffffffe231e0c0ULL, 0x733fd25dffffd520ULL, }, /* 72 */ + { 0xffffaf0dffffffffULL, 0x3acfffffc06a7810ULL, }, + { 0xffffffffffffffffULL, 0x4fb0ffffffff4a28ULL, }, + { 0xffffc4f7ffffffffULL, 0xb5c9ffffffffffffULL, }, + { 0xf8b9fd198693ffffULL, 0xd9589436ffffffffULL, }, + { 0xffff16b0abc4ffffULL, 0xa0e8ffffbe81ffffULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_U_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_U_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_w.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_w.c new file mode 100644 index 0000000000..938d2da8f4 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_adds_u_w.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDS_U.W + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDS_U.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0xffffffffffffffffULL, 0xe38e38e2ffffffffULL, }, + { 0xc71c71c6ffffffffULL, 0xffffffffc71c71c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffe38e38e3ULL, 0x8e38e38dffffffffULL, }, + { 0x71c71c71c71c71c6ULL, 0xffffffff71c71c71ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xe93e93e8ffffffffULL, 0xffffffffe93e93e8ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0xffffffffc16c16c1ULL, 0x6c16c16bffffffffULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0xffffffffffffffffULL, 0xe38e38e2ffffffffULL, }, + { 0xffffffffe38e38e3ULL, 0x8e38e38dffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffc16c16c1ULL, 0x6c16c16bffffffffULL, }, + { 0xffffffffffffffffULL, 0x71c71c70ffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71c71c6ffffffffULL, 0xffffffffc71c71c6ULL, }, + { 0x71c71c71c71c71c6ULL, 0xffffffff71c71c71ULL, }, + { 0xe93e93e8ffffffffULL, 0xffffffffe93e93e8ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e38e38e38e38e2ULL, 0xffffffff38e38e38ULL, }, + { 0xffffffff50c4aa80ULL, 0x96ce16bcffffffffULL, }, /* 64 */ + { 0xffffffff75f61c48ULL, 0x5e5ec678ffffffffULL, }, + { 0xffffffffe231e0c0ULL, 0x733fd25dffffffffULL, }, + { 0xf8b9fd198694378eULL, 0xd9589436ffffffffULL, }, + { 0xffffffff75f61c48ULL, 0x5e5ec678ffffffffULL, }, + { 0xffffffff9b278e10ULL, 0x25ef76342a7ea5f8ULL, }, + { 0xffffffffffffffffULL, 0x3ad08219c06a7810ULL, }, + { 0xffffffffabc5a956ULL, 0xa0e943f2be82359cULL, }, + { 0xffffffffe231e0c0ULL, 0x733fd25dffffffffULL, }, /* 72 */ + { 0xffffffffffffffffULL, 0x3ad08219c06a7810ULL, }, + { 0xffffffffffffffffULL, 0x4fb18dfeffffffffULL, }, + { 0xffffffffffffffffULL, 0xb5ca4fd7ffffffffULL, }, + { 0xf8b9fd198694378eULL, 0xd9589436ffffffffULL, }, + { 0xffffffffabc5a956ULL, 0xa0e943f2be82359cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_U_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDS_U_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_b.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_b.c new file mode 100644 index 0000000000..5dba38661d --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_b.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDV.B + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDV.B"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfefefefefefefefeULL, 0xfefefefefefefefeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xa9a9a9a9a9a9a9a9ULL, 0xa9a9a9a9a9a9a9a9ULL, }, + { 0x5454545454545454ULL, 0x5454545454545454ULL, }, + { 0xcbcbcbcbcbcbcbcbULL, 0xcbcbcbcbcbcbcbcbULL, }, + { 0x3232323232323232ULL, 0x3232323232323232ULL, }, + { 0xe28d37e28d37e28dULL, 0x37e28d37e28d37e2ULL, }, + { 0x1b70c61b70c61b70ULL, 0xc61b70c61b70c61bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xa9a9a9a9a9a9a9a9ULL, 0xa9a9a9a9a9a9a9a9ULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5454545454545454ULL, 0x5454545454545454ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x7676767676767676ULL, 0x7676767676767676ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8d38e28d38e28d38ULL, 0xe28d38e28d38e28dULL, }, + { 0xc61b71c61b71c61bULL, 0x71c61b71c61b71c6ULL, }, + { 0x5454545454545454ULL, 0x5454545454545454ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x2121212121212121ULL, 0x2121212121212121ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x38e38d38e38d38e3ULL, 0x8d38e38d38e38d38ULL, }, + { 0x71c61c71c61c71c6ULL, 0x1c71c61c71c61c71ULL, }, + { 0xcbcbcbcbcbcbcbcbULL, 0xcbcbcbcbcbcbcbcbULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x7676767676767676ULL, 0x7676767676767676ULL, }, + { 0x2121212121212121ULL, 0x2121212121212121ULL, }, + { 0x9898989898989898ULL, 0x9898989898989898ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaf5a04af5a04af5aULL, 0x04af5a04af5a04afULL, }, + { 0xe83d93e83d93e83dULL, 0x93e83d93e83d93e8ULL, }, + { 0x3232323232323232ULL, 0x3232323232323232ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x16c16b16c16b16c1ULL, 0x6b16c16b16c16b16ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xe28d37e28d37e28dULL, 0x37e28d37e28d37e2ULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x8d38e28d38e28d38ULL, 0xe28d38e28d38e28dULL, }, + { 0x38e38d38e38d38e3ULL, 0x8d38e38d38e38d38ULL, }, + { 0xaf5a04af5a04af5aULL, 0x04af5a04af5a04afULL, }, + { 0x16c16b16c16b16c1ULL, 0x6b16c16b16c16b16ULL, }, + { 0xc61c70c61c70c61cULL, 0x70c61c70c61c70c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x1b70c61b70c61b70ULL, 0xc61b70c61b70c61bULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc61b71c61b71c61bULL, 0x71c61b71c61b71c6ULL, }, + { 0x71c61c71c61c71c6ULL, 0x1c71c61c71c61c71ULL, }, + { 0xe83d93e83d93e83dULL, 0x93e83d93e83d93e8ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e28e38e28e38e2ULL, 0x8e38e28e38e28e38ULL, }, + { 0x10d4cc9850c4aa80ULL, 0x96ce16bcfcf66018ULL, }, /* 64 */ + { 0x8328e62f75f51c48ULL, 0x5d5ec67813ba0208ULL, }, + { 0x34c49476e131e0c0ULL, 0x723fd15da9a6d520ULL, }, + { 0xf8b9fc198693378eULL, 0xd8589336a7bd92acULL, }, + { 0x8328e62f75f51c48ULL, 0x5d5ec67813ba0208ULL, }, + { 0xf67c00c69a268e10ULL, 0x24ee76342a7ea4f8ULL, }, + { 0xa718ae0d06625288ULL, 0x39cf8119c06a7710ULL, }, + { 0x6b0d16b0abc4a956ULL, 0x9fe843f2be81349cULL, }, + { 0x34c49476e131e0c0ULL, 0x723fd15da9a6d520ULL, }, /* 72 */ + { 0xa718ae0d06625288ULL, 0x39cf8119c06a7710ULL, }, + { 0x58b45c54729e1600ULL, 0x4eb08cfe56564a28ULL, }, + { 0x1ca9c4f717006dceULL, 0xb4c94ed7546d07b4ULL, }, + { 0xf8b9fc198693378eULL, 0xd8589336a7bd92acULL, }, + { 0x6b0d16b0abc4a956ULL, 0x9fe843f2be81349cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDV_B(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDV_B(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_d.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_d.c new file mode 100644 index 0000000000..339878c608 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_d.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDV.D + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDV.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfffffffffffffffeULL, 0xfffffffffffffffeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaa9ULL, 0xaaaaaaaaaaaaaaa9ULL, }, + { 0x5555555555555554ULL, 0x5555555555555554ULL, }, + { 0xcccccccccccccccbULL, 0xcccccccccccccccbULL, }, + { 0x3333333333333332ULL, 0x3333333333333332ULL, }, + { 0xe38e38e38e38e38dULL, 0x38e38e38e38e38e2ULL, }, + { 0x1c71c71c71c71c70ULL, 0xc71c71c71c71c71bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xaaaaaaaaaaaaaaa9ULL, 0xaaaaaaaaaaaaaaa9ULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555554ULL, 0x5555555555555554ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x7777777777777776ULL, 0x7777777777777776ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8e38e38e38e38e38ULL, 0xe38e38e38e38e38dULL, }, + { 0xc71c71c71c71c71bULL, 0x71c71c71c71c71c6ULL, }, + { 0x5555555555555554ULL, 0x5555555555555554ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x2222222222222221ULL, 0x2222222222222221ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x38e38e38e38e38e3ULL, 0x8e38e38e38e38e38ULL, }, + { 0x71c71c71c71c71c6ULL, 0x1c71c71c71c71c71ULL, }, + { 0xcccccccccccccccbULL, 0xcccccccccccccccbULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x7777777777777776ULL, 0x7777777777777776ULL, }, + { 0x2222222222222221ULL, 0x2222222222222221ULL, }, + { 0x9999999999999998ULL, 0x9999999999999998ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xb05b05b05b05b05aULL, 0x05b05b05b05b05afULL, }, + { 0xe93e93e93e93e93dULL, 0x93e93e93e93e93e8ULL, }, + { 0x3333333333333332ULL, 0x3333333333333332ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x16c16c16c16c16c1ULL, 0x6c16c16c16c16c16ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xe38e38e38e38e38dULL, 0x38e38e38e38e38e2ULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x8e38e38e38e38e38ULL, 0xe38e38e38e38e38dULL, }, + { 0x38e38e38e38e38e3ULL, 0x8e38e38e38e38e38ULL, }, + { 0xb05b05b05b05b05aULL, 0x05b05b05b05b05afULL, }, + { 0x16c16c16c16c16c1ULL, 0x6c16c16c16c16c16ULL, }, + { 0xc71c71c71c71c71cULL, 0x71c71c71c71c71c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x1c71c71c71c71c70ULL, 0xc71c71c71c71c71bULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71c71c71c71c71bULL, 0x71c71c71c71c71c6ULL, }, + { 0x71c71c71c71c71c6ULL, 0x1c71c71c71c71c71ULL, }, + { 0xe93e93e93e93e93dULL, 0x93e93e93e93e93e8ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e38e38e38e38e2ULL, 0x8e38e38e38e38e38ULL, }, + { 0x10d5cd9850c4aa80ULL, 0x96ce16bdfcf76018ULL, }, /* 64 */ + { 0x8428e72f75f61c48ULL, 0x5e5ec67913bb0308ULL, }, + { 0x34c59576e231e0c0ULL, 0x733fd25ea9a6d520ULL, }, + { 0xf8b9fd198694378eULL, 0xd9589437a7be92acULL, }, + { 0x8428e72f75f61c48ULL, 0x5e5ec67913bb0308ULL, }, + { 0xf77c00c69b278e10ULL, 0x25ef76342a7ea5f8ULL, }, + { 0xa818af0e07635288ULL, 0x3ad08219c06a7810ULL, }, + { 0x6c0d16b0abc5a956ULL, 0xa0e943f2be82359cULL, }, + { 0x34c59576e231e0c0ULL, 0x733fd25ea9a6d520ULL, }, /* 72 */ + { 0xa818af0e07635288ULL, 0x3ad08219c06a7810ULL, }, + { 0x58b55d55739f1700ULL, 0x4fb18dff56564a28ULL, }, + { 0x1ca9c4f818016dceULL, 0xb5ca4fd8546e07b4ULL, }, + { 0xf8b9fd198694378eULL, 0xd9589437a7be92acULL, }, + { 0x6c0d16b0abc5a956ULL, 0xa0e943f2be82359cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDV_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDV_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_h.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_h.c new file mode 100644 index 0000000000..3add379f19 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_h.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDV.H + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDV.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfffefffefffefffeULL, 0xfffefffefffefffeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaa9aaa9aaa9aaa9ULL, 0xaaa9aaa9aaa9aaa9ULL, }, + { 0x5554555455545554ULL, 0x5554555455545554ULL, }, + { 0xcccbcccbcccbcccbULL, 0xcccbcccbcccbcccbULL, }, + { 0x3332333233323332ULL, 0x3332333233323332ULL, }, + { 0xe38d38e28e37e38dULL, 0x38e28e37e38d38e2ULL, }, + { 0x1c70c71b71c61c70ULL, 0xc71b71c61c70c71bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xaaa9aaa9aaa9aaa9ULL, 0xaaa9aaa9aaa9aaa9ULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5554555455545554ULL, 0x5554555455545554ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x7776777677767776ULL, 0x7776777677767776ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8e38e38d38e28e38ULL, 0xe38d38e28e38e38dULL, }, + { 0xc71b71c61c71c71bULL, 0x71c61c71c71b71c6ULL, }, + { 0x5554555455545554ULL, 0x5554555455545554ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x2221222122212221ULL, 0x2221222122212221ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x38e38e38e38d38e3ULL, 0x8e38e38d38e38e38ULL, }, + { 0x71c61c71c71c71c6ULL, 0x1c71c71c71c61c71ULL, }, + { 0xcccbcccbcccbcccbULL, 0xcccbcccbcccbcccbULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x7776777677767776ULL, 0x7776777677767776ULL, }, + { 0x2221222122212221ULL, 0x2221222122212221ULL, }, + { 0x9998999899989998ULL, 0x9998999899989998ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xb05a05af5b04b05aULL, 0x05af5b04b05a05afULL, }, + { 0xe93d93e83e93e93dULL, 0x93e83e93e93d93e8ULL, }, + { 0x3332333233323332ULL, 0x3332333233323332ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x16c16c16c16b16c1ULL, 0x6c16c16b16c16c16ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xe38d38e28e37e38dULL, 0x38e28e37e38d38e2ULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x8e38e38d38e28e38ULL, 0xe38d38e28e38e38dULL, }, + { 0x38e38e38e38d38e3ULL, 0x8e38e38d38e38e38ULL, }, + { 0xb05a05af5b04b05aULL, 0x05af5b04b05a05afULL, }, + { 0x16c16c16c16b16c1ULL, 0x6c16c16b16c16c16ULL, }, + { 0xc71c71c61c70c71cULL, 0x71c61c70c71c71c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x1c70c71b71c61c70ULL, 0xc71b71c61c70c71bULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71b71c61c71c71bULL, 0x71c61c71c71b71c6ULL, }, + { 0x71c61c71c71c71c6ULL, 0x1c71c71c71c61c71ULL, }, + { 0xe93d93e83e93e93dULL, 0x93e83e93e93d93e8ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e28e38e38e38e2ULL, 0x8e38e38e38e28e38ULL, }, + { 0x10d4cd9850c4aa80ULL, 0x96ce16bcfcf66018ULL, }, /* 64 */ + { 0x8428e72f75f51c48ULL, 0x5e5ec67813ba0308ULL, }, + { 0x34c49576e231e0c0ULL, 0x733fd25da9a6d520ULL, }, + { 0xf8b9fd198693378eULL, 0xd9589436a7bd92acULL, }, + { 0x8428e72f75f51c48ULL, 0x5e5ec67813ba0308ULL, }, + { 0xf77c00c69b268e10ULL, 0x25ee76342a7ea5f8ULL, }, + { 0xa818af0d07625288ULL, 0x3acf8219c06a7810ULL, }, + { 0x6c0d16b0abc4a956ULL, 0xa0e843f2be81359cULL, }, + { 0x34c49576e231e0c0ULL, 0x733fd25da9a6d520ULL, }, /* 72 */ + { 0xa818af0d07625288ULL, 0x3acf8219c06a7810ULL, }, + { 0x58b45d54739e1700ULL, 0x4fb08dfe56564a28ULL, }, + { 0x1ca9c4f718006dceULL, 0xb5c94fd7546d07b4ULL, }, + { 0xf8b9fd198693378eULL, 0xd9589436a7bd92acULL, }, + { 0x6c0d16b0abc4a956ULL, 0xa0e843f2be81359cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDV_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDV_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_w.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_w.c new file mode 100644 index 0000000000..41f86abb18 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_addv_w.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction ADDV.W + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "ADDV.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfffffffefffffffeULL, 0xfffffffefffffffeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaa9aaaaaaa9ULL, 0xaaaaaaa9aaaaaaa9ULL, }, + { 0x5555555455555554ULL, 0x5555555455555554ULL, }, + { 0xcccccccbcccccccbULL, 0xcccccccbcccccccbULL, }, + { 0x3333333233333332ULL, 0x3333333233333332ULL, }, + { 0xe38e38e28e38e38dULL, 0x38e38e37e38e38e2ULL, }, + { 0x1c71c71b71c71c70ULL, 0xc71c71c61c71c71bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xaaaaaaa9aaaaaaa9ULL, 0xaaaaaaa9aaaaaaa9ULL, }, /* 16 */ + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555455555554ULL, 0x5555555455555554ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x7777777677777776ULL, 0x7777777677777776ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8e38e38d38e38e38ULL, 0xe38e38e28e38e38dULL, }, + { 0xc71c71c61c71c71bULL, 0x71c71c71c71c71c6ULL, }, + { 0x5555555455555554ULL, 0x5555555455555554ULL, }, /* 24 */ + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x2222222122222221ULL, 0x2222222122222221ULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0x38e38e38e38e38e3ULL, 0x8e38e38d38e38e38ULL, }, + { 0x71c71c71c71c71c6ULL, 0x1c71c71c71c71c71ULL, }, + { 0xcccccccbcccccccbULL, 0xcccccccbcccccccbULL, }, /* 32 */ + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x7777777677777776ULL, 0x7777777677777776ULL, }, + { 0x2222222122222221ULL, 0x2222222122222221ULL, }, + { 0x9999999899999998ULL, 0x9999999899999998ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xb05b05af5b05b05aULL, 0x05b05b04b05b05afULL, }, + { 0xe93e93e83e93e93dULL, 0x93e93e93e93e93e8ULL, }, + { 0x3333333233333332ULL, 0x3333333233333332ULL, }, /* 40 */ + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, + { 0x8888888888888888ULL, 0x8888888888888888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x6666666666666666ULL, 0x6666666666666666ULL, }, + { 0x16c16c16c16c16c1ULL, 0x6c16c16b16c16c16ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xe38e38e28e38e38dULL, 0x38e38e37e38e38e2ULL, }, /* 48 */ + { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, + { 0x8e38e38d38e38e38ULL, 0xe38e38e28e38e38dULL, }, + { 0x38e38e38e38e38e3ULL, 0x8e38e38d38e38e38ULL, }, + { 0xb05b05af5b05b05aULL, 0x05b05b04b05b05afULL, }, + { 0x16c16c16c16c16c1ULL, 0x6c16c16b16c16c16ULL, }, + { 0xc71c71c61c71c71cULL, 0x71c71c70c71c71c6ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x1c71c71b71c71c70ULL, 0xc71c71c61c71c71bULL, }, /* 56 */ + { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71c71c61c71c71bULL, 0x71c71c71c71c71c6ULL, }, + { 0x71c71c71c71c71c6ULL, 0x1c71c71c71c71c71ULL, }, + { 0xe93e93e83e93e93dULL, 0x93e93e93e93e93e8ULL, }, + { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x38e38e38e38e38e2ULL, 0x8e38e38e38e38e38ULL, }, + { 0x10d5cd9850c4aa80ULL, 0x96ce16bcfcf76018ULL, }, /* 64 */ + { 0x8428e72f75f61c48ULL, 0x5e5ec67813bb0308ULL, }, + { 0x34c59576e231e0c0ULL, 0x733fd25da9a6d520ULL, }, + { 0xf8b9fd198694378eULL, 0xd9589436a7be92acULL, }, + { 0x8428e72f75f61c48ULL, 0x5e5ec67813bb0308ULL, }, + { 0xf77c00c69b278e10ULL, 0x25ef76342a7ea5f8ULL, }, + { 0xa818af0d07635288ULL, 0x3ad08219c06a7810ULL, }, + { 0x6c0d16b0abc5a956ULL, 0xa0e943f2be82359cULL, }, + { 0x34c59576e231e0c0ULL, 0x733fd25da9a6d520ULL, }, /* 72 */ + { 0xa818af0d07635288ULL, 0x3ad08219c06a7810ULL, }, + { 0x58b55d54739f1700ULL, 0x4fb18dfe56564a28ULL, }, + { 0x1ca9c4f718016dceULL, 0xb5ca4fd7546e07b4ULL, }, + { 0xf8b9fd198694378eULL, 0xd9589436a7be92acULL, }, + { 0x6c0d16b0abc5a956ULL, 0xa0e943f2be82359cULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDV_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_ADDV_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_s_d.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_s_d.c new file mode 100644 index 0000000000..a6975e7931 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_s_d.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction HADD_S.D + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "HADD_S.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfffffffffffffffeULL, 0xfffffffffffffffeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffffaaaaaaa9ULL, 0xffffffffaaaaaaa9ULL, }, + { 0x0000000055555554ULL, 0x0000000055555554ULL, }, + { 0xffffffffcccccccbULL, 0xffffffffcccccccbULL, }, + { 0x0000000033333332ULL, 0x0000000033333332ULL, }, + { 0xffffffff8e38e38dULL, 0xffffffffe38e38e2ULL, }, + { 0x0000000071c71c70ULL, 0x000000001c71c71bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, + { 0x0000000055555555ULL, 0x0000000055555555ULL, }, + { 0xffffffffccccccccULL, 0xffffffffccccccccULL, }, + { 0x0000000033333333ULL, 0x0000000033333333ULL, }, + { 0xffffffff8e38e38eULL, 0xffffffffe38e38e3ULL, }, + { 0x0000000071c71c71ULL, 0x000000001c71c71cULL, }, + { 0xffffffffaaaaaaa9ULL, 0xffffffffaaaaaaa9ULL, }, /* 16 */ + { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, + { 0xffffffff55555554ULL, 0xffffffff55555554ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffff77777776ULL, 0xffffffff77777776ULL, }, + { 0xffffffffddddddddULL, 0xffffffffddddddddULL, }, + { 0xffffffff38e38e38ULL, 0xffffffff8e38e38dULL, }, + { 0x000000001c71c71bULL, 0xffffffffc71c71c6ULL, }, + { 0x0000000055555554ULL, 0x0000000055555554ULL, }, /* 24 */ + { 0x0000000055555555ULL, 0x0000000055555555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x00000000aaaaaaaaULL, 0x00000000aaaaaaaaULL, }, + { 0x0000000022222221ULL, 0x0000000022222221ULL, }, + { 0x0000000088888888ULL, 0x0000000088888888ULL, }, + { 0xffffffffe38e38e3ULL, 0x0000000038e38e38ULL, }, + { 0x00000000c71c71c6ULL, 0x0000000071c71c71ULL, }, + { 0xffffffffcccccccbULL, 0xffffffffcccccccbULL, }, /* 32 */ + { 0xffffffffccccccccULL, 0xffffffffccccccccULL, }, + { 0xffffffff77777776ULL, 0xffffffff77777776ULL, }, + { 0x0000000022222221ULL, 0x0000000022222221ULL, }, + { 0xffffffff99999998ULL, 0xffffffff99999998ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffffff5b05b05aULL, 0xffffffffb05b05afULL, }, + { 0x000000003e93e93dULL, 0xffffffffe93e93e8ULL, }, + { 0x0000000033333332ULL, 0x0000000033333332ULL, }, /* 40 */ + { 0x0000000033333333ULL, 0x0000000033333333ULL, }, + { 0xffffffffddddddddULL, 0xffffffffddddddddULL, }, + { 0x0000000088888888ULL, 0x0000000088888888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x0000000066666666ULL, 0x0000000066666666ULL, }, + { 0xffffffffc16c16c1ULL, 0x0000000016c16c16ULL, }, + { 0x00000000a4fa4fa4ULL, 0x000000004fa4fa4fULL, }, + { 0xffffffffe38e38e2ULL, 0x0000000038e38e37ULL, }, /* 48 */ + { 0xffffffffe38e38e3ULL, 0x0000000038e38e38ULL, }, + { 0xffffffff8e38e38dULL, 0xffffffffe38e38e2ULL, }, + { 0x0000000038e38e38ULL, 0x000000008e38e38dULL, }, + { 0xffffffffb05b05afULL, 0x0000000005b05b04ULL, }, + { 0x0000000016c16c16ULL, 0x000000006c16c16bULL, }, + { 0xffffffff71c71c71ULL, 0x000000001c71c71bULL, }, + { 0x0000000055555554ULL, 0x0000000055555554ULL, }, + { 0x000000001c71c71bULL, 0xffffffffc71c71c6ULL, }, /* 56 */ + { 0x000000001c71c71cULL, 0xffffffffc71c71c7ULL, }, + { 0xffffffffc71c71c6ULL, 0xffffffff71c71c71ULL, }, + { 0x0000000071c71c71ULL, 0x000000001c71c71cULL, }, + { 0xffffffffe93e93e8ULL, 0xffffffff93e93e93ULL, }, + { 0x000000004fa4fa4fULL, 0xfffffffffa4fa4faULL, }, + { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, + { 0x000000008e38e38dULL, 0xffffffffe38e38e3ULL, }, + { 0xffffffffb0cd3c0cULL, 0x0000000049e2bb6aULL, }, /* 64 */ + { 0xffffffffd5feadd4ULL, 0x0000000060a65e5aULL, }, + { 0xffffffff423a724cULL, 0xfffffffff6923072ULL, }, + { 0xffffffffe69cc91aULL, 0xfffffffff4a9edfeULL, }, + { 0x00000000242055a3ULL, 0x0000000011736b26ULL, }, + { 0x000000004951c76bULL, 0x0000000028370e16ULL, }, + { 0xffffffffb58d8be3ULL, 0xffffffffbe22e02eULL, }, + { 0x0000000059efe2b1ULL, 0xffffffffbc3a9dbaULL, }, + { 0xffffffffd4bd03eaULL, 0x000000002654770bULL, }, /* 72 */ + { 0xfffffffff9ee75b2ULL, 0x000000003d1819fbULL, }, + { 0xffffffff662a3a2aULL, 0xffffffffd303ec13ULL, }, + { 0x000000000a8c90f8ULL, 0xffffffffd11ba99fULL, }, + { 0x0000000098b16b8dULL, 0xffffffff8c6d38e4ULL, }, + { 0x00000000bde2dd55ULL, 0xffffffffa330dbd4ULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_S_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_S_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_s_h.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_s_h.c new file mode 100644 index 0000000000..3b95551d4d --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_s_h.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction HADD_S.H + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "HADD_S.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfffefffefffefffeULL, 0xfffefffefffefffeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffa9ffa9ffa9ffa9ULL, 0xffa9ffa9ffa9ffa9ULL, }, + { 0x0054005400540054ULL, 0x0054005400540054ULL, }, + { 0xffcbffcbffcbffcbULL, 0xffcbffcbffcbffcbULL, }, + { 0x0032003200320032ULL, 0x0032003200320032ULL, }, + { 0xff8dffe20037ff8dULL, 0xffe20037ff8dffe2ULL, }, + { 0x0070001bffc60070ULL, 0x001bffc60070001bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffaaffaaffaaffaaULL, 0xffaaffaaffaaffaaULL, }, + { 0x0055005500550055ULL, 0x0055005500550055ULL, }, + { 0xffccffccffccffccULL, 0xffccffccffccffccULL, }, + { 0x0033003300330033ULL, 0x0033003300330033ULL, }, + { 0xff8effe30038ff8eULL, 0xffe30038ff8effe3ULL, }, + { 0x0071001cffc70071ULL, 0x001cffc70071001cULL, }, + { 0xffa9ffa9ffa9ffa9ULL, 0xffa9ffa9ffa9ffa9ULL, }, /* 16 */ + { 0xffaaffaaffaaffaaULL, 0xffaaffaaffaaffaaULL, }, + { 0xff54ff54ff54ff54ULL, 0xff54ff54ff54ff54ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xff76ff76ff76ff76ULL, 0xff76ff76ff76ff76ULL, }, + { 0xffddffddffddffddULL, 0xffddffddffddffddULL, }, + { 0xff38ff8dffe2ff38ULL, 0xff8dffe2ff38ff8dULL, }, + { 0x001bffc6ff71001bULL, 0xffc6ff71001bffc6ULL, }, + { 0x0054005400540054ULL, 0x0054005400540054ULL, }, /* 24 */ + { 0x0055005500550055ULL, 0x0055005500550055ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x00aa00aa00aa00aaULL, 0x00aa00aa00aa00aaULL, }, + { 0x0021002100210021ULL, 0x0021002100210021ULL, }, + { 0x0088008800880088ULL, 0x0088008800880088ULL, }, + { 0xffe30038008dffe3ULL, 0x0038008dffe30038ULL, }, + { 0x00c60071001c00c6ULL, 0x0071001c00c60071ULL, }, + { 0xffcbffcbffcbffcbULL, 0xffcbffcbffcbffcbULL, }, /* 32 */ + { 0xffccffccffccffccULL, 0xffccffccffccffccULL, }, + { 0xff76ff76ff76ff76ULL, 0xff76ff76ff76ff76ULL, }, + { 0x0021002100210021ULL, 0x0021002100210021ULL, }, + { 0xff98ff98ff98ff98ULL, 0xff98ff98ff98ff98ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xff5affaf0004ff5aULL, 0xffaf0004ff5affafULL, }, + { 0x003dffe8ff93003dULL, 0xffe8ff93003dffe8ULL, }, + { 0x0032003200320032ULL, 0x0032003200320032ULL, }, /* 40 */ + { 0x0033003300330033ULL, 0x0033003300330033ULL, }, + { 0xffddffddffddffddULL, 0xffddffddffddffddULL, }, + { 0x0088008800880088ULL, 0x0088008800880088ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x0066006600660066ULL, 0x0066006600660066ULL, }, + { 0xffc10016006bffc1ULL, 0x0016006bffc10016ULL, }, + { 0x00a4004ffffa00a4ULL, 0x004ffffa00a4004fULL, }, + { 0xffe20037ff8dffe2ULL, 0x0037ff8dffe20037ULL, }, /* 48 */ + { 0xffe30038ff8effe3ULL, 0x0038ff8effe30038ULL, }, + { 0xff8dffe2ff38ff8dULL, 0xffe2ff38ff8dffe2ULL, }, + { 0x0038008dffe30038ULL, 0x008dffe30038008dULL, }, + { 0xffaf0004ff5affafULL, 0x0004ff5affaf0004ULL, }, + { 0x0016006bffc10016ULL, 0x006bffc10016006bULL, }, + { 0xff71001bffc6ff71ULL, 0x001bffc6ff71001bULL, }, + { 0x00540054ff550054ULL, 0x0054ff5500540054ULL, }, + { 0x001bffc60070001bULL, 0xffc60070001bffc6ULL, }, /* 56 */ + { 0x001cffc70071001cULL, 0xffc70071001cffc7ULL, }, + { 0xffc6ff71001bffc6ULL, 0xff71001bffc6ff71ULL, }, + { 0x0071001c00c60071ULL, 0x001c00c60071001cULL, }, + { 0xffe8ff93003dffe8ULL, 0xff93003dffe8ff93ULL, }, + { 0x004ffffa00a4004fULL, 0xfffa00a4004ffffaULL, }, + { 0xffaaffaa00a9ffaaULL, 0xffaa00a9ffaaffaaULL, }, + { 0x008dffe30038008dULL, 0xffe30038008dffe3ULL, }, + { 0xfff2ffb2008a0095ULL, 0x00b200690079ffbcULL, }, /* 64 */ + { 0xff460049ffbb005dULL, 0x00420025003dffacULL, }, + { 0xffe2ff90fff7ffd5ULL, 0x0023000a0029ffc4ULL, }, + { 0xffd70033005900a3ULL, 0x003cffe30040ff50ULL, }, + { 0x0065ffcc00af0007ULL, 0x007900190090005eULL, }, + { 0xffb90063ffe0ffcfULL, 0x0009ffd50054004eULL, }, + { 0x0055ffaa001cff47ULL, 0xffeaffba00400066ULL, }, + { 0x004a004d007e0015ULL, 0x0003ff930057fff2ULL, }, + { 0x0016ff7a001bffcbULL, 0x008e002400260031ULL, }, /* 72 */ + { 0xff6a0011ff4cff93ULL, 0x001effe0ffea0021ULL, }, + { 0x0006ff58ff88ff0bULL, 0xffffffc5ffd60039ULL, }, + { 0xfffbfffbffeaffd9ULL, 0x0018ff9effedffc5ULL, }, + { 0x00daffe200c00022ULL, 0xfff4ffe60024ffeeULL, }, + { 0x002e0079fff1ffeaULL, 0xff84ffa2ffe8ffdeULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_S_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_S_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_s_w.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_s_w.c new file mode 100644 index 0000000000..7a940b23cf --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_s_w.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction HADD_S.W + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "HADD_S.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xfffffffefffffffeULL, 0xfffffffefffffffeULL, }, /* 0 */ + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffffaaa9ffffaaa9ULL, 0xffffaaa9ffffaaa9ULL, }, + { 0x0000555400005554ULL, 0x0000555400005554ULL, }, + { 0xffffcccbffffcccbULL, 0xffffcccbffffcccbULL, }, + { 0x0000333200003332ULL, 0x0000333200003332ULL, }, + { 0x000038e2ffffe38dULL, 0xffff8e37000038e2ULL, }, + { 0xffffc71b00001c70ULL, 0x000071c6ffffc71bULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffaaaaffffaaaaULL, 0xffffaaaaffffaaaaULL, }, + { 0x0000555500005555ULL, 0x0000555500005555ULL, }, + { 0xffffccccffffccccULL, 0xffffccccffffccccULL, }, + { 0x0000333300003333ULL, 0x0000333300003333ULL, }, + { 0x000038e3ffffe38eULL, 0xffff8e38000038e3ULL, }, + { 0xffffc71c00001c71ULL, 0x000071c7ffffc71cULL, }, + { 0xffffaaa9ffffaaa9ULL, 0xffffaaa9ffffaaa9ULL, }, /* 16 */ + { 0xffffaaaaffffaaaaULL, 0xffffaaaaffffaaaaULL, }, + { 0xffff5554ffff5554ULL, 0xffff5554ffff5554ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0xffff7776ffff7776ULL, 0xffff7776ffff7776ULL, }, + { 0xffffddddffffddddULL, 0xffffddddffffddddULL, }, + { 0xffffe38dffff8e38ULL, 0xffff38e2ffffe38dULL, }, + { 0xffff71c6ffffc71bULL, 0x00001c71ffff71c6ULL, }, + { 0x0000555400005554ULL, 0x0000555400005554ULL, }, /* 24 */ + { 0x0000555500005555ULL, 0x0000555500005555ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x0000aaaa0000aaaaULL, 0x0000aaaa0000aaaaULL, }, + { 0x0000222100002221ULL, 0x0000222100002221ULL, }, + { 0x0000888800008888ULL, 0x0000888800008888ULL, }, + { 0x00008e38000038e3ULL, 0xffffe38d00008e38ULL, }, + { 0x00001c71000071c6ULL, 0x0000c71c00001c71ULL, }, + { 0xffffcccbffffcccbULL, 0xffffcccbffffcccbULL, }, /* 32 */ + { 0xffffccccffffccccULL, 0xffffccccffffccccULL, }, + { 0xffff7776ffff7776ULL, 0xffff7776ffff7776ULL, }, + { 0x0000222100002221ULL, 0x0000222100002221ULL, }, + { 0xffff9998ffff9998ULL, 0xffff9998ffff9998ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x000005afffffb05aULL, 0xffff5b04000005afULL, }, + { 0xffff93e8ffffe93dULL, 0x00003e93ffff93e8ULL, }, + { 0x0000333200003332ULL, 0x0000333200003332ULL, }, /* 40 */ + { 0x0000333300003333ULL, 0x0000333300003333ULL, }, + { 0xffffddddffffddddULL, 0xffffddddffffddddULL, }, + { 0x0000888800008888ULL, 0x0000888800008888ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, + { 0x0000666600006666ULL, 0x0000666600006666ULL, }, + { 0x00006c16000016c1ULL, 0xffffc16b00006c16ULL, }, + { 0xfffffa4f00004fa4ULL, 0x0000a4fafffffa4fULL, }, + { 0xffffe38dffff8e37ULL, 0x000038e2ffffe38dULL, }, /* 48 */ + { 0xffffe38effff8e38ULL, 0x000038e3ffffe38eULL, }, + { 0xffff8e38ffff38e2ULL, 0xffffe38dffff8e38ULL, }, + { 0x000038e3ffffe38dULL, 0x00008e38000038e3ULL, }, + { 0xffffb05affff5b04ULL, 0x000005afffffb05aULL, }, + { 0x000016c1ffffc16bULL, 0x00006c16000016c1ULL, }, + { 0x00001c71ffff71c6ULL, 0xffffc71b00001c71ULL, }, + { 0xffffaaaaffffaaa9ULL, 0x0000aaaaffffaaaaULL, }, + { 0x00001c70000071c6ULL, 0xffffc71b00001c70ULL, }, /* 56 */ + { 0x00001c71000071c7ULL, 0xffffc71c00001c71ULL, }, + { 0xffffc71b00001c71ULL, 0xffff71c6ffffc71bULL, }, + { 0x000071c60000c71cULL, 0x00001c71000071c6ULL, }, + { 0xffffe93d00003e93ULL, 0xffff93e8ffffe93dULL, }, + { 0x00004fa40000a4faULL, 0xfffffa4f00004fa4ULL, }, + { 0x0000555400005555ULL, 0xffff555400005554ULL, }, + { 0xffffe38d00008e38ULL, 0x000038e3ffffe38dULL, }, + { 0xffff6f3600007da2ULL, 0x000056c5ffffae87ULL, }, /* 64 */ + { 0xffff88cdffffef6aULL, 0x0000068100005177ULL, }, + { 0xffff3714ffffb3e2ULL, 0x000012660000238fULL, }, + { 0xffff9eb700000ab0ULL, 0xffffd43fffffe11bULL, }, + { 0xffffe28a0000a2d3ULL, 0x00001e55ffffc54bULL, }, + { 0xfffffc210000149bULL, 0xffffce110000683bULL, }, + { 0xffffaa68ffffd913ULL, 0xffffd9f600003a53ULL, }, + { 0x0000120b00002fe1ULL, 0xffff9bcffffff7dfULL, }, + { 0xffff932600000f0fULL, 0x00003336ffff5b37ULL, }, /* 72 */ + { 0xffffacbdffff80d7ULL, 0xffffe2f2fffffe27ULL, }, + { 0xffff5b04ffff454fULL, 0xffffeed7ffffd03fULL, }, + { 0xffffc2a7ffff9c1dULL, 0xffffb0b0ffff8dcbULL, }, + { 0x0000571b0000b371ULL, 0xffff994fffff594eULL, }, + { 0x000070b200002539ULL, 0xffff490bfffffc3eULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_S_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_S_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_u_d.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_u_d.c new file mode 100644 index 0000000000..d4cbe44dfd --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_u_d.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction HADD_U.D + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "HADD_U.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x00000001fffffffeULL, 0x00000001fffffffeULL, }, /* 0 */ + { 0x00000000ffffffffULL, 0x00000000ffffffffULL, }, + { 0x00000001aaaaaaa9ULL, 0x00000001aaaaaaa9ULL, }, + { 0x0000000155555554ULL, 0x0000000155555554ULL, }, + { 0x00000001cccccccbULL, 0x00000001cccccccbULL, }, + { 0x0000000133333332ULL, 0x0000000133333332ULL, }, + { 0x000000018e38e38dULL, 0x00000001e38e38e2ULL, }, + { 0x0000000171c71c70ULL, 0x000000011c71c71bULL, }, + { 0x00000000ffffffffULL, 0x00000000ffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x00000000aaaaaaaaULL, 0x00000000aaaaaaaaULL, }, + { 0x0000000055555555ULL, 0x0000000055555555ULL, }, + { 0x00000000ccccccccULL, 0x00000000ccccccccULL, }, + { 0x0000000033333333ULL, 0x0000000033333333ULL, }, + { 0x000000008e38e38eULL, 0x00000000e38e38e3ULL, }, + { 0x0000000071c71c71ULL, 0x000000001c71c71cULL, }, + { 0x00000001aaaaaaa9ULL, 0x00000001aaaaaaa9ULL, }, /* 16 */ + { 0x00000000aaaaaaaaULL, 0x00000000aaaaaaaaULL, }, + { 0x0000000155555554ULL, 0x0000000155555554ULL, }, + { 0x00000000ffffffffULL, 0x00000000ffffffffULL, }, + { 0x0000000177777776ULL, 0x0000000177777776ULL, }, + { 0x00000000ddddddddULL, 0x00000000ddddddddULL, }, + { 0x0000000138e38e38ULL, 0x000000018e38e38dULL, }, + { 0x000000011c71c71bULL, 0x00000000c71c71c6ULL, }, + { 0x0000000155555554ULL, 0x0000000155555554ULL, }, /* 24 */ + { 0x0000000055555555ULL, 0x0000000055555555ULL, }, + { 0x00000000ffffffffULL, 0x00000000ffffffffULL, }, + { 0x00000000aaaaaaaaULL, 0x00000000aaaaaaaaULL, }, + { 0x0000000122222221ULL, 0x0000000122222221ULL, }, + { 0x0000000088888888ULL, 0x0000000088888888ULL, }, + { 0x00000000e38e38e3ULL, 0x0000000138e38e38ULL, }, + { 0x00000000c71c71c6ULL, 0x0000000071c71c71ULL, }, + { 0x00000001cccccccbULL, 0x00000001cccccccbULL, }, /* 32 */ + { 0x00000000ccccccccULL, 0x00000000ccccccccULL, }, + { 0x0000000177777776ULL, 0x0000000177777776ULL, }, + { 0x0000000122222221ULL, 0x0000000122222221ULL, }, + { 0x0000000199999998ULL, 0x0000000199999998ULL, }, + { 0x00000000ffffffffULL, 0x00000000ffffffffULL, }, + { 0x000000015b05b05aULL, 0x00000001b05b05afULL, }, + { 0x000000013e93e93dULL, 0x00000000e93e93e8ULL, }, + { 0x0000000133333332ULL, 0x0000000133333332ULL, }, /* 40 */ + { 0x0000000033333333ULL, 0x0000000033333333ULL, }, + { 0x00000000ddddddddULL, 0x00000000ddddddddULL, }, + { 0x0000000088888888ULL, 0x0000000088888888ULL, }, + { 0x00000000ffffffffULL, 0x00000000ffffffffULL, }, + { 0x0000000066666666ULL, 0x0000000066666666ULL, }, + { 0x00000000c16c16c1ULL, 0x0000000116c16c16ULL, }, + { 0x00000000a4fa4fa4ULL, 0x000000004fa4fa4fULL, }, + { 0x00000001e38e38e2ULL, 0x0000000138e38e37ULL, }, /* 48 */ + { 0x00000000e38e38e3ULL, 0x0000000038e38e38ULL, }, + { 0x000000018e38e38dULL, 0x00000000e38e38e2ULL, }, + { 0x0000000138e38e38ULL, 0x000000008e38e38dULL, }, + { 0x00000001b05b05afULL, 0x0000000105b05b04ULL, }, + { 0x0000000116c16c16ULL, 0x000000006c16c16bULL, }, + { 0x0000000171c71c71ULL, 0x000000011c71c71bULL, }, + { 0x0000000155555554ULL, 0x0000000055555554ULL, }, + { 0x000000011c71c71bULL, 0x00000001c71c71c6ULL, }, /* 56 */ + { 0x000000001c71c71cULL, 0x00000000c71c71c7ULL, }, + { 0x00000000c71c71c6ULL, 0x0000000171c71c71ULL, }, + { 0x0000000071c71c71ULL, 0x000000011c71c71cULL, }, + { 0x00000000e93e93e8ULL, 0x0000000193e93e93ULL, }, + { 0x000000004fa4fa4fULL, 0x00000000fa4fa4faULL, }, + { 0x00000000aaaaaaaaULL, 0x00000001aaaaaaaaULL, }, + { 0x000000008e38e38dULL, 0x00000000e38e38e3ULL, }, + { 0x00000000b0cd3c0cULL, 0x0000000149e2bb6aULL, }, /* 64 */ + { 0x00000000d5feadd4ULL, 0x0000000060a65e5aULL, }, + { 0x00000001423a724cULL, 0x00000000f6923072ULL, }, + { 0x00000000e69cc91aULL, 0x00000000f4a9edfeULL, }, + { 0x00000001242055a3ULL, 0x0000000111736b26ULL, }, + { 0x000000014951c76bULL, 0x0000000028370e16ULL, }, + { 0x00000001b58d8be3ULL, 0x00000000be22e02eULL, }, + { 0x0000000159efe2b1ULL, 0x00000000bc3a9dbaULL, }, + { 0x00000000d4bd03eaULL, 0x000000012654770bULL, }, /* 72 */ + { 0x00000000f9ee75b2ULL, 0x000000003d1819fbULL, }, + { 0x00000001662a3a2aULL, 0x00000000d303ec13ULL, }, + { 0x000000010a8c90f8ULL, 0x00000000d11ba99fULL, }, + { 0x0000000098b16b8dULL, 0x000000018c6d38e4ULL, }, + { 0x00000000bde2dd55ULL, 0x00000000a330dbd4ULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_U_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_U_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_u_h.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_u_h.c new file mode 100644 index 0000000000..ca250575ed --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_u_h.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction HADD_U.H + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "HADD_U.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x01fe01fe01fe01feULL, 0x01fe01fe01fe01feULL, }, /* 0 */ + { 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, }, + { 0x01a901a901a901a9ULL, 0x01a901a901a901a9ULL, }, + { 0x0154015401540154ULL, 0x0154015401540154ULL, }, + { 0x01cb01cb01cb01cbULL, 0x01cb01cb01cb01cbULL, }, + { 0x0132013201320132ULL, 0x0132013201320132ULL, }, + { 0x018d01e20137018dULL, 0x01e20137018d01e2ULL, }, + { 0x0170011b01c60170ULL, 0x011b01c60170011bULL, }, + { 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x00aa00aa00aa00aaULL, 0x00aa00aa00aa00aaULL, }, + { 0x0055005500550055ULL, 0x0055005500550055ULL, }, + { 0x00cc00cc00cc00ccULL, 0x00cc00cc00cc00ccULL, }, + { 0x0033003300330033ULL, 0x0033003300330033ULL, }, + { 0x008e00e30038008eULL, 0x00e30038008e00e3ULL, }, + { 0x0071001c00c70071ULL, 0x001c00c70071001cULL, }, + { 0x01a901a901a901a9ULL, 0x01a901a901a901a9ULL, }, /* 16 */ + { 0x00aa00aa00aa00aaULL, 0x00aa00aa00aa00aaULL, }, + { 0x0154015401540154ULL, 0x0154015401540154ULL, }, + { 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, }, + { 0x0176017601760176ULL, 0x0176017601760176ULL, }, + { 0x00dd00dd00dd00ddULL, 0x00dd00dd00dd00ddULL, }, + { 0x0138018d00e20138ULL, 0x018d00e20138018dULL, }, + { 0x011b00c60171011bULL, 0x00c60171011b00c6ULL, }, + { 0x0154015401540154ULL, 0x0154015401540154ULL, }, /* 24 */ + { 0x0055005500550055ULL, 0x0055005500550055ULL, }, + { 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, }, + { 0x00aa00aa00aa00aaULL, 0x00aa00aa00aa00aaULL, }, + { 0x0121012101210121ULL, 0x0121012101210121ULL, }, + { 0x0088008800880088ULL, 0x0088008800880088ULL, }, + { 0x00e30138008d00e3ULL, 0x0138008d00e30138ULL, }, + { 0x00c60071011c00c6ULL, 0x0071011c00c60071ULL, }, + { 0x01cb01cb01cb01cbULL, 0x01cb01cb01cb01cbULL, }, /* 32 */ + { 0x00cc00cc00cc00ccULL, 0x00cc00cc00cc00ccULL, }, + { 0x0176017601760176ULL, 0x0176017601760176ULL, }, + { 0x0121012101210121ULL, 0x0121012101210121ULL, }, + { 0x0198019801980198ULL, 0x0198019801980198ULL, }, + { 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, }, + { 0x015a01af0104015aULL, 0x01af0104015a01afULL, }, + { 0x013d00e80193013dULL, 0x00e80193013d00e8ULL, }, + { 0x0132013201320132ULL, 0x0132013201320132ULL, }, /* 40 */ + { 0x0033003300330033ULL, 0x0033003300330033ULL, }, + { 0x00dd00dd00dd00ddULL, 0x00dd00dd00dd00ddULL, }, + { 0x0088008800880088ULL, 0x0088008800880088ULL, }, + { 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, }, + { 0x0066006600660066ULL, 0x0066006600660066ULL, }, + { 0x00c10116006b00c1ULL, 0x0116006b00c10116ULL, }, + { 0x00a4004f00fa00a4ULL, 0x004f00fa00a4004fULL, }, + { 0x01e20137018d01e2ULL, 0x0137018d01e20137ULL, }, /* 48 */ + { 0x00e30038008e00e3ULL, 0x0038008e00e30038ULL, }, + { 0x018d00e20138018dULL, 0x00e20138018d00e2ULL, }, + { 0x0138008d00e30138ULL, 0x008d00e30138008dULL, }, + { 0x01af0104015a01afULL, 0x0104015a01af0104ULL, }, + { 0x0116006b00c10116ULL, 0x006b00c10116006bULL, }, + { 0x0171011b00c60171ULL, 0x011b00c60171011bULL, }, + { 0x0154005401550154ULL, 0x0054015501540054ULL, }, + { 0x011b01c60170011bULL, 0x01c60170011b01c6ULL, }, /* 56 */ + { 0x001c00c70071001cULL, 0x00c70071001c00c7ULL, }, + { 0x00c60171011b00c6ULL, 0x0171011b00c60171ULL, }, + { 0x0071011c00c60071ULL, 0x011c00c60071011cULL, }, + { 0x00e80193013d00e8ULL, 0x0193013d00e80193ULL, }, + { 0x004f00fa00a4004fULL, 0x00fa00a4004f00faULL, }, + { 0x00aa01aa00a900aaULL, 0x01aa00a900aa01aaULL, }, + { 0x008d00e30138008dULL, 0x00e30138008d00e3ULL, }, + { 0x00f201b2008a0095ULL, 0x00b20069017900bcULL, }, /* 64 */ + { 0x0146014900bb005dULL, 0x01420025013d01acULL, }, + { 0x00e2019000f700d5ULL, 0x0123010a012900c4ULL, }, + { 0x00d70133005900a3ULL, 0x013c00e301400150ULL, }, + { 0x016500cc00af0107ULL, 0x007901190090005eULL, }, + { 0x01b9006300e000cfULL, 0x010900d50054014eULL, }, + { 0x015500aa011c0147ULL, 0x00ea01ba00400066ULL, }, + { 0x014a004d007e0115ULL, 0x01030193005700f2ULL, }, + { 0x0116017a011b00cbULL, 0x008e012401260031ULL, }, /* 72 */ + { 0x016a0111014c0093ULL, 0x011e00e000ea0121ULL, }, + { 0x010601580188010bULL, 0x00ff01c500d60039ULL, }, + { 0x00fb00fb00ea00d9ULL, 0x0118019e00ed00c5ULL, }, + { 0x00da00e200c00122ULL, 0x00f400e6012400eeULL, }, + { 0x012e007900f100eaULL, 0x018400a200e801deULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_U_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_U_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_u_w.c b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_u_w.c new file mode 100644 index 0000000000..b302727f29 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/int-add/test_msa_hadd_u_w.c @@ -0,0 +1,151 @@ +/* + * Test program for MSA instruction HADD_U.W + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "HADD_U.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0001fffe0001fffeULL, 0x0001fffe0001fffeULL, }, /* 0 */ + { 0x0000ffff0000ffffULL, 0x0000ffff0000ffffULL, }, + { 0x0001aaa90001aaa9ULL, 0x0001aaa90001aaa9ULL, }, + { 0x0001555400015554ULL, 0x0001555400015554ULL, }, + { 0x0001cccb0001cccbULL, 0x0001cccb0001cccbULL, }, + { 0x0001333200013332ULL, 0x0001333200013332ULL, }, + { 0x000138e20001e38dULL, 0x00018e37000138e2ULL, }, + { 0x0001c71b00011c70ULL, 0x000171c60001c71bULL, }, + { 0x0000ffff0000ffffULL, 0x0000ffff0000ffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x0000aaaa0000aaaaULL, 0x0000aaaa0000aaaaULL, }, + { 0x0000555500005555ULL, 0x0000555500005555ULL, }, + { 0x0000cccc0000ccccULL, 0x0000cccc0000ccccULL, }, + { 0x0000333300003333ULL, 0x0000333300003333ULL, }, + { 0x000038e30000e38eULL, 0x00008e38000038e3ULL, }, + { 0x0000c71c00001c71ULL, 0x000071c70000c71cULL, }, + { 0x0001aaa90001aaa9ULL, 0x0001aaa90001aaa9ULL, }, /* 16 */ + { 0x0000aaaa0000aaaaULL, 0x0000aaaa0000aaaaULL, }, + { 0x0001555400015554ULL, 0x0001555400015554ULL, }, + { 0x0000ffff0000ffffULL, 0x0000ffff0000ffffULL, }, + { 0x0001777600017776ULL, 0x0001777600017776ULL, }, + { 0x0000dddd0000ddddULL, 0x0000dddd0000ddddULL, }, + { 0x0000e38d00018e38ULL, 0x000138e20000e38dULL, }, + { 0x000171c60000c71bULL, 0x00011c71000171c6ULL, }, + { 0x0001555400015554ULL, 0x0001555400015554ULL, }, /* 24 */ + { 0x0000555500005555ULL, 0x0000555500005555ULL, }, + { 0x0000ffff0000ffffULL, 0x0000ffff0000ffffULL, }, + { 0x0000aaaa0000aaaaULL, 0x0000aaaa0000aaaaULL, }, + { 0x0001222100012221ULL, 0x0001222100012221ULL, }, + { 0x0000888800008888ULL, 0x0000888800008888ULL, }, + { 0x00008e38000138e3ULL, 0x0000e38d00008e38ULL, }, + { 0x00011c71000071c6ULL, 0x0000c71c00011c71ULL, }, + { 0x0001cccb0001cccbULL, 0x0001cccb0001cccbULL, }, /* 32 */ + { 0x0000cccc0000ccccULL, 0x0000cccc0000ccccULL, }, + { 0x0001777600017776ULL, 0x0001777600017776ULL, }, + { 0x0001222100012221ULL, 0x0001222100012221ULL, }, + { 0x0001999800019998ULL, 0x0001999800019998ULL, }, + { 0x0000ffff0000ffffULL, 0x0000ffff0000ffffULL, }, + { 0x000105af0001b05aULL, 0x00015b04000105afULL, }, + { 0x000193e80000e93dULL, 0x00013e93000193e8ULL, }, + { 0x0001333200013332ULL, 0x0001333200013332ULL, }, /* 40 */ + { 0x0000333300003333ULL, 0x0000333300003333ULL, }, + { 0x0000dddd0000ddddULL, 0x0000dddd0000ddddULL, }, + { 0x0000888800008888ULL, 0x0000888800008888ULL, }, + { 0x0000ffff0000ffffULL, 0x0000ffff0000ffffULL, }, + { 0x0000666600006666ULL, 0x0000666600006666ULL, }, + { 0x00006c16000116c1ULL, 0x0000c16b00006c16ULL, }, + { 0x0000fa4f00004fa4ULL, 0x0000a4fa0000fa4fULL, }, + { 0x0001e38d00018e37ULL, 0x000138e20001e38dULL, }, /* 48 */ + { 0x0000e38e00008e38ULL, 0x000038e30000e38eULL, }, + { 0x00018e38000138e2ULL, 0x0000e38d00018e38ULL, }, + { 0x000138e30000e38dULL, 0x00008e38000138e3ULL, }, + { 0x0001b05a00015b04ULL, 0x000105af0001b05aULL, }, + { 0x000116c10000c16bULL, 0x00006c16000116c1ULL, }, + { 0x00011c71000171c6ULL, 0x0000c71b00011c71ULL, }, + { 0x0001aaaa0000aaa9ULL, 0x0000aaaa0001aaaaULL, }, + { 0x00011c70000171c6ULL, 0x0001c71b00011c70ULL, }, /* 56 */ + { 0x00001c71000071c7ULL, 0x0000c71c00001c71ULL, }, + { 0x0000c71b00011c71ULL, 0x000171c60000c71bULL, }, + { 0x000071c60000c71cULL, 0x00011c71000071c6ULL, }, + { 0x0000e93d00013e93ULL, 0x000193e80000e93dULL, }, + { 0x00004fa40000a4faULL, 0x0000fa4f00004fa4ULL, }, + { 0x0000555400015555ULL, 0x0001555400005554ULL, }, + { 0x0000e38d00008e38ULL, 0x000138e30000e38dULL, }, + { 0x00016f3600007da2ULL, 0x000056c50001ae87ULL, }, /* 64 */ + { 0x000088cd0000ef6aULL, 0x0001068100015177ULL, }, + { 0x000137140000b3e2ULL, 0x000112660001238fULL, }, + { 0x00009eb700010ab0ULL, 0x0000d43f0001e11bULL, }, + { 0x0001e28a0000a2d3ULL, 0x00001e550000c54bULL, }, + { 0x0000fc210001149bULL, 0x0000ce110000683bULL, }, + { 0x0001aa680000d913ULL, 0x0000d9f600003a53ULL, }, + { 0x0001120b00012fe1ULL, 0x00009bcf0000f7dfULL, }, + { 0x0001932600010f0fULL, 0x0000333600015b37ULL, }, /* 72 */ + { 0x0000acbd000180d7ULL, 0x0000e2f20000fe27ULL, }, + { 0x00015b040001454fULL, 0x0000eed70000d03fULL, }, + { 0x0000c2a700019c1dULL, 0x0000b0b000018dcbULL, }, + { 0x0001571b0000b371ULL, 0x0000994f0001594eULL, }, + { 0x000070b200012539ULL, 0x0001490b0000fc3eULL, }, +}; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_U_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_HADD_U_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_b.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_b.c new file mode 100644 index 0000000000..d98dd224d7 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_b.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction PCKEV.B + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "PCKEV.B"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0x0000000000000000ULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xffffffffffffffffULL, }, + { 0x5555555555555555ULL, 0xffffffffffffffffULL, }, + { 0xccccccccccccccccULL, 0xffffffffffffffffULL, }, + { 0x3333333333333333ULL, 0xffffffffffffffffULL, }, + { 0xe3388ee38ee3388eULL, 0xffffffffffffffffULL, }, + { 0x1cc7711c711cc771ULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x0000000000000000ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x0000000000000000ULL, }, + { 0x5555555555555555ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0x0000000000000000ULL, }, + { 0x3333333333333333ULL, 0x0000000000000000ULL, }, + { 0xe3388ee38ee3388eULL, 0x0000000000000000ULL, }, + { 0x1cc7711c711cc771ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ + { 0x0000000000000000ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xccccccccccccccccULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x3333333333333333ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xe3388ee38ee3388eULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x1cc7711c711cc771ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0x5555555555555555ULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0x5555555555555555ULL, }, + { 0x3333333333333333ULL, 0x5555555555555555ULL, }, + { 0xe3388ee38ee3388eULL, 0x5555555555555555ULL, }, + { 0x1cc7711c711cc771ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xccccccccccccccccULL, }, /* 32 */ + { 0x0000000000000000ULL, 0xccccccccccccccccULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xccccccccccccccccULL, }, + { 0x5555555555555555ULL, 0xccccccccccccccccULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0xccccccccccccccccULL, }, + { 0xe3388ee38ee3388eULL, 0xccccccccccccccccULL, }, + { 0x1cc7711c711cc771ULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0x3333333333333333ULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x3333333333333333ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x3333333333333333ULL, }, + { 0x5555555555555555ULL, 0x3333333333333333ULL, }, + { 0xccccccccccccccccULL, 0x3333333333333333ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe3388ee38ee3388eULL, 0x3333333333333333ULL, }, + { 0x1cc7711c711cc771ULL, 0x3333333333333333ULL, }, + { 0xffffffffffffffffULL, 0xe3388ee38ee3388eULL, }, /* 48 */ + { 0x0000000000000000ULL, 0xe3388ee38ee3388eULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xe3388ee38ee3388eULL, }, + { 0x5555555555555555ULL, 0xe3388ee38ee3388eULL, }, + { 0xccccccccccccccccULL, 0xe3388ee38ee3388eULL, }, + { 0x3333333333333333ULL, 0xe3388ee38ee3388eULL, }, + { 0xe3388ee38ee3388eULL, 0xe3388ee38ee3388eULL, }, + { 0x1cc7711c711cc771ULL, 0xe3388ee38ee3388eULL, }, + { 0xffffffffffffffffULL, 0x1cc7711c711cc771ULL, }, /* 56 */ + { 0x0000000000000000ULL, 0x1cc7711c711cc771ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x1cc7711c711cc771ULL, }, + { 0x5555555555555555ULL, 0x1cc7711c711cc771ULL, }, + { 0xccccccccccccccccULL, 0x1cc7711c711cc771ULL, }, + { 0x3333333333333333ULL, 0x1cc7711c711cc771ULL, }, + { 0xe3388ee38ee3388eULL, 0x1cc7711c711cc771ULL, }, + { 0x1cc7711c711cc771ULL, 0x1cc7711c711cc771ULL, }, + { 0x675e7b0c6acc6240ULL, 0x675e7b0c6acc6240ULL, }, /* 64 */ + { 0xf71a3ffcbe639308ULL, 0x675e7b0c6acc6240ULL, }, + { 0xd8ff2b145aaacf80ULL, 0x675e7b0c6acc6240ULL, }, + { 0xf1d842a04f4d314eULL, 0x675e7b0c6acc6240ULL, }, + { 0x675e7b0c6acc6240ULL, 0xf71a3ffcbe639308ULL, }, + { 0xf71a3ffcbe639308ULL, 0xf71a3ffcbe639308ULL, }, + { 0xd8ff2b145aaacf80ULL, 0xf71a3ffcbe639308ULL, }, + { 0xf1d842a04f4d314eULL, 0xf71a3ffcbe639308ULL, }, + { 0x675e7b0c6acc6240ULL, 0xd8ff2b145aaacf80ULL, }, /* 72 */ + { 0xf71a3ffcbe639308ULL, 0xd8ff2b145aaacf80ULL, }, + { 0xd8ff2b145aaacf80ULL, 0xd8ff2b145aaacf80ULL, }, + { 0xf1d842a04f4d314eULL, 0xd8ff2b145aaacf80ULL, }, + { 0x675e7b0c6acc6240ULL, 0xf1d842a04f4d314eULL, }, + { 0xf71a3ffcbe639308ULL, 0xf1d842a04f4d314eULL, }, + { 0xd8ff2b145aaacf80ULL, 0xf1d842a04f4d314eULL, }, + { 0xf1d842a04f4d314eULL, 0xf1d842a04f4d314eULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKEV_B(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKEV_B(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_d.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_d.c new file mode 100644 index 0000000000..543fb6ae5e --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_d.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction PCKEV.D + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "PCKEV.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0x0000000000000000ULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xffffffffffffffffULL, }, + { 0x5555555555555555ULL, 0xffffffffffffffffULL, }, + { 0xccccccccccccccccULL, 0xffffffffffffffffULL, }, + { 0x3333333333333333ULL, 0xffffffffffffffffULL, }, + { 0xe38e38e38e38e38eULL, 0xffffffffffffffffULL, }, + { 0x1c71c71c71c71c71ULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x0000000000000000ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x0000000000000000ULL, }, + { 0x5555555555555555ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0x0000000000000000ULL, }, + { 0x3333333333333333ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0x0000000000000000ULL, }, + { 0x1c71c71c71c71c71ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ + { 0x0000000000000000ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xccccccccccccccccULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x3333333333333333ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xe38e38e38e38e38eULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x1c71c71c71c71c71ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0x5555555555555555ULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0x5555555555555555ULL, }, + { 0x3333333333333333ULL, 0x5555555555555555ULL, }, + { 0xe38e38e38e38e38eULL, 0x5555555555555555ULL, }, + { 0x1c71c71c71c71c71ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xccccccccccccccccULL, }, /* 32 */ + { 0x0000000000000000ULL, 0xccccccccccccccccULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xccccccccccccccccULL, }, + { 0x5555555555555555ULL, 0xccccccccccccccccULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0xccccccccccccccccULL, }, + { 0xe38e38e38e38e38eULL, 0xccccccccccccccccULL, }, + { 0x1c71c71c71c71c71ULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0x3333333333333333ULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x3333333333333333ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x3333333333333333ULL, }, + { 0x5555555555555555ULL, 0x3333333333333333ULL, }, + { 0xccccccccccccccccULL, 0x3333333333333333ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x3333333333333333ULL, }, + { 0x1c71c71c71c71c71ULL, 0x3333333333333333ULL, }, + { 0xffffffffffffffffULL, 0xe38e38e38e38e38eULL, }, /* 48 */ + { 0x0000000000000000ULL, 0xe38e38e38e38e38eULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xe38e38e38e38e38eULL, }, + { 0x5555555555555555ULL, 0xe38e38e38e38e38eULL, }, + { 0xccccccccccccccccULL, 0xe38e38e38e38e38eULL, }, + { 0x3333333333333333ULL, 0xe38e38e38e38e38eULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x1c71c71c71c71c71ULL, 0xe38e38e38e38e38eULL, }, + { 0xffffffffffffffffULL, 0x1c71c71c71c71c71ULL, }, /* 56 */ + { 0x0000000000000000ULL, 0x1c71c71c71c71c71ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x1c71c71c71c71c71ULL, }, + { 0x5555555555555555ULL, 0x1c71c71c71c71c71ULL, }, + { 0xccccccccccccccccULL, 0x1c71c71c71c71c71ULL, }, + { 0x3333333333333333ULL, 0x1c71c71c71c71c71ULL, }, + { 0xe38e38e38e38e38eULL, 0x1c71c71c71c71c71ULL, }, + { 0x1c71c71c71c71c71ULL, 0x1c71c71c71c71c71ULL, }, + { 0x886ae6cc28625540ULL, 0x886ae6cc28625540ULL, }, /* 64 */ + { 0xfbbe00634d93c708ULL, 0x886ae6cc28625540ULL, }, + { 0xac5aaeaab9cf8b80ULL, 0x886ae6cc28625540ULL, }, + { 0x704f164d5e31e24eULL, 0x886ae6cc28625540ULL, }, + { 0x886ae6cc28625540ULL, 0xfbbe00634d93c708ULL, }, + { 0xfbbe00634d93c708ULL, 0xfbbe00634d93c708ULL, }, + { 0xac5aaeaab9cf8b80ULL, 0xfbbe00634d93c708ULL, }, + { 0x704f164d5e31e24eULL, 0xfbbe00634d93c708ULL, }, + { 0x886ae6cc28625540ULL, 0xac5aaeaab9cf8b80ULL, }, /* 72 */ + { 0xfbbe00634d93c708ULL, 0xac5aaeaab9cf8b80ULL, }, + { 0xac5aaeaab9cf8b80ULL, 0xac5aaeaab9cf8b80ULL, }, + { 0x704f164d5e31e24eULL, 0xac5aaeaab9cf8b80ULL, }, + { 0x886ae6cc28625540ULL, 0x704f164d5e31e24eULL, }, + { 0xfbbe00634d93c708ULL, 0x704f164d5e31e24eULL, }, + { 0xac5aaeaab9cf8b80ULL, 0x704f164d5e31e24eULL, }, + { 0x704f164d5e31e24eULL, 0x704f164d5e31e24eULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKEV_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKEV_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_h.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_h.c new file mode 100644 index 0000000000..64a18c02f0 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_h.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction PCKEV.H + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "PCKEV.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0x0000000000000000ULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xffffffffffffffffULL, }, + { 0x5555555555555555ULL, 0xffffffffffffffffULL, }, + { 0xccccccccccccccccULL, 0xffffffffffffffffULL, }, + { 0x3333333333333333ULL, 0xffffffffffffffffULL, }, + { 0x8e3838e338e3e38eULL, 0xffffffffffffffffULL, }, + { 0x71c7c71cc71c1c71ULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x0000000000000000ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x0000000000000000ULL, }, + { 0x5555555555555555ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0x0000000000000000ULL, }, + { 0x3333333333333333ULL, 0x0000000000000000ULL, }, + { 0x8e3838e338e3e38eULL, 0x0000000000000000ULL, }, + { 0x71c7c71cc71c1c71ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ + { 0x0000000000000000ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xccccccccccccccccULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x3333333333333333ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x8e3838e338e3e38eULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x71c7c71cc71c1c71ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0x5555555555555555ULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0x5555555555555555ULL, }, + { 0x3333333333333333ULL, 0x5555555555555555ULL, }, + { 0x8e3838e338e3e38eULL, 0x5555555555555555ULL, }, + { 0x71c7c71cc71c1c71ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xccccccccccccccccULL, }, /* 32 */ + { 0x0000000000000000ULL, 0xccccccccccccccccULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xccccccccccccccccULL, }, + { 0x5555555555555555ULL, 0xccccccccccccccccULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0xccccccccccccccccULL, }, + { 0x8e3838e338e3e38eULL, 0xccccccccccccccccULL, }, + { 0x71c7c71cc71c1c71ULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0x3333333333333333ULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x3333333333333333ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x3333333333333333ULL, }, + { 0x5555555555555555ULL, 0x3333333333333333ULL, }, + { 0xccccccccccccccccULL, 0x3333333333333333ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x8e3838e338e3e38eULL, 0x3333333333333333ULL, }, + { 0x71c7c71cc71c1c71ULL, 0x3333333333333333ULL, }, + { 0xffffffffffffffffULL, 0x8e3838e338e3e38eULL, }, /* 48 */ + { 0x0000000000000000ULL, 0x8e3838e338e3e38eULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x8e3838e338e3e38eULL, }, + { 0x5555555555555555ULL, 0x8e3838e338e3e38eULL, }, + { 0xccccccccccccccccULL, 0x8e3838e338e3e38eULL, }, + { 0x3333333333333333ULL, 0x8e3838e338e3e38eULL, }, + { 0x8e3838e338e3e38eULL, 0x8e3838e338e3e38eULL, }, + { 0x71c7c71cc71c1c71ULL, 0x8e3838e338e3e38eULL, }, + { 0xffffffffffffffffULL, 0x71c7c71cc71c1c71ULL, }, /* 56 */ + { 0x0000000000000000ULL, 0x71c7c71cc71c1c71ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x71c7c71cc71c1c71ULL, }, + { 0x5555555555555555ULL, 0x71c7c71cc71c1c71ULL, }, + { 0xccccccccccccccccULL, 0x71c7c71cc71c1c71ULL, }, + { 0x3333333333333333ULL, 0x71c7c71cc71c1c71ULL, }, + { 0x8e3838e338e3e38eULL, 0x71c7c71cc71c1c71ULL, }, + { 0x71c7c71cc71c1c71ULL, 0x71c7c71cc71c1c71ULL, }, + { 0x0b5eb00ce6cc5540ULL, 0x0b5eb00ce6cc5540ULL, }, /* 64 */ + { 0xbb1a52fc0063c708ULL, 0x0b5eb00ce6cc5540ULL, }, + { 0xc6ff2514aeaa8b80ULL, 0x0b5eb00ce6cc5540ULL, }, + { 0x88d8e2a0164de24eULL, 0x0b5eb00ce6cc5540ULL, }, + { 0x0b5eb00ce6cc5540ULL, 0xbb1a52fc0063c708ULL, }, + { 0xbb1a52fc0063c708ULL, 0xbb1a52fc0063c708ULL, }, + { 0xc6ff2514aeaa8b80ULL, 0xbb1a52fc0063c708ULL, }, + { 0x88d8e2a0164de24eULL, 0xbb1a52fc0063c708ULL, }, + { 0x0b5eb00ce6cc5540ULL, 0xc6ff2514aeaa8b80ULL, }, /* 72 */ + { 0xbb1a52fc0063c708ULL, 0xc6ff2514aeaa8b80ULL, }, + { 0xc6ff2514aeaa8b80ULL, 0xc6ff2514aeaa8b80ULL, }, + { 0x88d8e2a0164de24eULL, 0xc6ff2514aeaa8b80ULL, }, + { 0x0b5eb00ce6cc5540ULL, 0x88d8e2a0164de24eULL, }, + { 0xbb1a52fc0063c708ULL, 0x88d8e2a0164de24eULL, }, + { 0xc6ff2514aeaa8b80ULL, 0x88d8e2a0164de24eULL, }, + { 0x88d8e2a0164de24eULL, 0x88d8e2a0164de24eULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKEV_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKEV_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_w.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_w.c new file mode 100644 index 0000000000..a0acacdf26 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckev_w.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction PCKEV.W + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "PCKEV.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0x0000000000000000ULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xffffffffffffffffULL, }, + { 0x5555555555555555ULL, 0xffffffffffffffffULL, }, + { 0xccccccccccccccccULL, 0xffffffffffffffffULL, }, + { 0x3333333333333333ULL, 0xffffffffffffffffULL, }, + { 0xe38e38e38e38e38eULL, 0xffffffffffffffffULL, }, + { 0x1c71c71c71c71c71ULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x0000000000000000ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x0000000000000000ULL, }, + { 0x5555555555555555ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0x0000000000000000ULL, }, + { 0x3333333333333333ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0x0000000000000000ULL, }, + { 0x1c71c71c71c71c71ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ + { 0x0000000000000000ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xccccccccccccccccULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x3333333333333333ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xe38e38e38e38e38eULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x1c71c71c71c71c71ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0x5555555555555555ULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0x5555555555555555ULL, }, + { 0x3333333333333333ULL, 0x5555555555555555ULL, }, + { 0xe38e38e38e38e38eULL, 0x5555555555555555ULL, }, + { 0x1c71c71c71c71c71ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xccccccccccccccccULL, }, /* 32 */ + { 0x0000000000000000ULL, 0xccccccccccccccccULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xccccccccccccccccULL, }, + { 0x5555555555555555ULL, 0xccccccccccccccccULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0xccccccccccccccccULL, }, + { 0xe38e38e38e38e38eULL, 0xccccccccccccccccULL, }, + { 0x1c71c71c71c71c71ULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0x3333333333333333ULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x3333333333333333ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x3333333333333333ULL, }, + { 0x5555555555555555ULL, 0x3333333333333333ULL, }, + { 0xccccccccccccccccULL, 0x3333333333333333ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0xe38e38e38e38e38eULL, 0x3333333333333333ULL, }, + { 0x1c71c71c71c71c71ULL, 0x3333333333333333ULL, }, + { 0xffffffffffffffffULL, 0xe38e38e38e38e38eULL, }, /* 48 */ + { 0x0000000000000000ULL, 0xe38e38e38e38e38eULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xe38e38e38e38e38eULL, }, + { 0x5555555555555555ULL, 0xe38e38e38e38e38eULL, }, + { 0xccccccccccccccccULL, 0xe38e38e38e38e38eULL, }, + { 0x3333333333333333ULL, 0xe38e38e38e38e38eULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x1c71c71c71c71c71ULL, 0xe38e38e38e38e38eULL, }, + { 0xffffffffffffffffULL, 0x1c71c71c71c71c71ULL, }, /* 56 */ + { 0x0000000000000000ULL, 0x1c71c71c71c71c71ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x1c71c71c71c71c71ULL, }, + { 0x5555555555555555ULL, 0x1c71c71c71c71c71ULL, }, + { 0xccccccccccccccccULL, 0x1c71c71c71c71c71ULL, }, + { 0x3333333333333333ULL, 0x1c71c71c71c71c71ULL, }, + { 0xe38e38e38e38e38eULL, 0x1c71c71c71c71c71ULL, }, + { 0x1c71c71c71c71c71ULL, 0x1c71c71c71c71c71ULL, }, + { 0xfe7bb00c28625540ULL, 0xfe7bb00c28625540ULL, }, /* 64 */ + { 0x153f52fc4d93c708ULL, 0xfe7bb00c28625540ULL, }, + { 0xab2b2514b9cf8b80ULL, 0xfe7bb00c28625540ULL, }, + { 0xa942e2a05e31e24eULL, 0xfe7bb00c28625540ULL, }, + { 0xfe7bb00c28625540ULL, 0x153f52fc4d93c708ULL, }, + { 0x153f52fc4d93c708ULL, 0x153f52fc4d93c708ULL, }, + { 0xab2b2514b9cf8b80ULL, 0x153f52fc4d93c708ULL, }, + { 0xa942e2a05e31e24eULL, 0x153f52fc4d93c708ULL, }, + { 0xfe7bb00c28625540ULL, 0xab2b2514b9cf8b80ULL, }, /* 72 */ + { 0x153f52fc4d93c708ULL, 0xab2b2514b9cf8b80ULL, }, + { 0xab2b2514b9cf8b80ULL, 0xab2b2514b9cf8b80ULL, }, + { 0xa942e2a05e31e24eULL, 0xab2b2514b9cf8b80ULL, }, + { 0xfe7bb00c28625540ULL, 0xa942e2a05e31e24eULL, }, + { 0x153f52fc4d93c708ULL, 0xa942e2a05e31e24eULL, }, + { 0xab2b2514b9cf8b80ULL, 0xa942e2a05e31e24eULL, }, + { 0xa942e2a05e31e24eULL, 0xa942e2a05e31e24eULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKEV_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKEV_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_b.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_b.c new file mode 100644 index 0000000000..7bf86fccbd --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_b.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction PCKOD.B + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "PCKOD.B"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0x0000000000000000ULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xffffffffffffffffULL, }, + { 0x5555555555555555ULL, 0xffffffffffffffffULL, }, + { 0xccccccccccccccccULL, 0xffffffffffffffffULL, }, + { 0x3333333333333333ULL, 0xffffffffffffffffULL, }, + { 0x388ee338e3388ee3ULL, 0xffffffffffffffffULL, }, + { 0xc7711cc71cc7711cULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x0000000000000000ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x0000000000000000ULL, }, + { 0x5555555555555555ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0x0000000000000000ULL, }, + { 0x3333333333333333ULL, 0x0000000000000000ULL, }, + { 0x388ee338e3388ee3ULL, 0x0000000000000000ULL, }, + { 0xc7711cc71cc7711cULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ + { 0x0000000000000000ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xccccccccccccccccULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x3333333333333333ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x388ee338e3388ee3ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xc7711cc71cc7711cULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0x5555555555555555ULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0x5555555555555555ULL, }, + { 0x3333333333333333ULL, 0x5555555555555555ULL, }, + { 0x388ee338e3388ee3ULL, 0x5555555555555555ULL, }, + { 0xc7711cc71cc7711cULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xccccccccccccccccULL, }, /* 32 */ + { 0x0000000000000000ULL, 0xccccccccccccccccULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xccccccccccccccccULL, }, + { 0x5555555555555555ULL, 0xccccccccccccccccULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0xccccccccccccccccULL, }, + { 0x388ee338e3388ee3ULL, 0xccccccccccccccccULL, }, + { 0xc7711cc71cc7711cULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0x3333333333333333ULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x3333333333333333ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x3333333333333333ULL, }, + { 0x5555555555555555ULL, 0x3333333333333333ULL, }, + { 0xccccccccccccccccULL, 0x3333333333333333ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x388ee338e3388ee3ULL, 0x3333333333333333ULL, }, + { 0xc7711cc71cc7711cULL, 0x3333333333333333ULL, }, + { 0xffffffffffffffffULL, 0x388ee338e3388ee3ULL, }, /* 48 */ + { 0x0000000000000000ULL, 0x388ee338e3388ee3ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x388ee338e3388ee3ULL, }, + { 0x5555555555555555ULL, 0x388ee338e3388ee3ULL, }, + { 0xccccccccccccccccULL, 0x388ee338e3388ee3ULL, }, + { 0x3333333333333333ULL, 0x388ee338e3388ee3ULL, }, + { 0x388ee338e3388ee3ULL, 0x388ee338e3388ee3ULL, }, + { 0xc7711cc71cc7711cULL, 0x388ee338e3388ee3ULL, }, + { 0xffffffffffffffffULL, 0xc7711cc71cc7711cULL, }, /* 56 */ + { 0x0000000000000000ULL, 0xc7711cc71cc7711cULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xc7711cc71cc7711cULL, }, + { 0x5555555555555555ULL, 0xc7711cc71cc7711cULL, }, + { 0xccccccccccccccccULL, 0xc7711cc71cc7711cULL, }, + { 0x3333333333333333ULL, 0xc7711cc71cc7711cULL, }, + { 0x388ee338e3388ee3ULL, 0xc7711cc71cc7711cULL, }, + { 0xc7711cc71cc7711cULL, 0xc7711cc71cc7711cULL, }, + { 0x4b0bfeb088e62855ULL, 0x4b0bfeb088e62855ULL, }, /* 64 */ + { 0x12bb1552fb004dc7ULL, 0x4b0bfeb088e62855ULL, }, + { 0x27c6ab25acaeb98bULL, 0x4b0bfeb088e62855ULL, }, + { 0x8d88a9e270165ee2ULL, 0x4b0bfeb088e62855ULL, }, + { 0x4b0bfeb088e62855ULL, 0x12bb1552fb004dc7ULL, }, + { 0x12bb1552fb004dc7ULL, 0x12bb1552fb004dc7ULL, }, + { 0x27c6ab25acaeb98bULL, 0x12bb1552fb004dc7ULL, }, + { 0x8d88a9e270165ee2ULL, 0x12bb1552fb004dc7ULL, }, + { 0x4b0bfeb088e62855ULL, 0x27c6ab25acaeb98bULL, }, /* 72 */ + { 0x12bb1552fb004dc7ULL, 0x27c6ab25acaeb98bULL, }, + { 0x27c6ab25acaeb98bULL, 0x27c6ab25acaeb98bULL, }, + { 0x8d88a9e270165ee2ULL, 0x27c6ab25acaeb98bULL, }, + { 0x4b0bfeb088e62855ULL, 0x8d88a9e270165ee2ULL, }, + { 0x12bb1552fb004dc7ULL, 0x8d88a9e270165ee2ULL, }, + { 0x27c6ab25acaeb98bULL, 0x8d88a9e270165ee2ULL, }, + { 0x8d88a9e270165ee2ULL, 0x8d88a9e270165ee2ULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKOD_B(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKOD_B(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_d.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_d.c new file mode 100644 index 0000000000..3c4d55b694 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_d.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction PCKOD.D + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "PCKOD.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0x0000000000000000ULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xffffffffffffffffULL, }, + { 0x5555555555555555ULL, 0xffffffffffffffffULL, }, + { 0xccccccccccccccccULL, 0xffffffffffffffffULL, }, + { 0x3333333333333333ULL, 0xffffffffffffffffULL, }, + { 0x38e38e38e38e38e3ULL, 0xffffffffffffffffULL, }, + { 0xc71c71c71c71c71cULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x0000000000000000ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x0000000000000000ULL, }, + { 0x5555555555555555ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0x0000000000000000ULL, }, + { 0x3333333333333333ULL, 0x0000000000000000ULL, }, + { 0x38e38e38e38e38e3ULL, 0x0000000000000000ULL, }, + { 0xc71c71c71c71c71cULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ + { 0x0000000000000000ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xccccccccccccccccULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x3333333333333333ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x38e38e38e38e38e3ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xc71c71c71c71c71cULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0x5555555555555555ULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0x5555555555555555ULL, }, + { 0x3333333333333333ULL, 0x5555555555555555ULL, }, + { 0x38e38e38e38e38e3ULL, 0x5555555555555555ULL, }, + { 0xc71c71c71c71c71cULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xccccccccccccccccULL, }, /* 32 */ + { 0x0000000000000000ULL, 0xccccccccccccccccULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xccccccccccccccccULL, }, + { 0x5555555555555555ULL, 0xccccccccccccccccULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0xccccccccccccccccULL, }, + { 0x38e38e38e38e38e3ULL, 0xccccccccccccccccULL, }, + { 0xc71c71c71c71c71cULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0x3333333333333333ULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x3333333333333333ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x3333333333333333ULL, }, + { 0x5555555555555555ULL, 0x3333333333333333ULL, }, + { 0xccccccccccccccccULL, 0x3333333333333333ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x38e38e38e38e38e3ULL, 0x3333333333333333ULL, }, + { 0xc71c71c71c71c71cULL, 0x3333333333333333ULL, }, + { 0xffffffffffffffffULL, 0x38e38e38e38e38e3ULL, }, /* 48 */ + { 0x0000000000000000ULL, 0x38e38e38e38e38e3ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x38e38e38e38e38e3ULL, }, + { 0x5555555555555555ULL, 0x38e38e38e38e38e3ULL, }, + { 0xccccccccccccccccULL, 0x38e38e38e38e38e3ULL, }, + { 0x3333333333333333ULL, 0x38e38e38e38e38e3ULL, }, + { 0x38e38e38e38e38e3ULL, 0x38e38e38e38e38e3ULL, }, + { 0xc71c71c71c71c71cULL, 0x38e38e38e38e38e3ULL, }, + { 0xffffffffffffffffULL, 0xc71c71c71c71c71cULL, }, /* 56 */ + { 0x0000000000000000ULL, 0xc71c71c71c71c71cULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xc71c71c71c71c71cULL, }, + { 0x5555555555555555ULL, 0xc71c71c71c71c71cULL, }, + { 0xccccccccccccccccULL, 0xc71c71c71c71c71cULL, }, + { 0x3333333333333333ULL, 0xc71c71c71c71c71cULL, }, + { 0x38e38e38e38e38e3ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71c71c71c71c71cULL, 0xc71c71c71c71c71cULL, }, + { 0x4b670b5efe7bb00cULL, 0x4b670b5efe7bb00cULL, }, /* 64 */ + { 0x12f7bb1a153f52fcULL, 0x4b670b5efe7bb00cULL, }, + { 0x27d8c6ffab2b2514ULL, 0x4b670b5efe7bb00cULL, }, + { 0x8df188d8a942e2a0ULL, 0x4b670b5efe7bb00cULL, }, + { 0x4b670b5efe7bb00cULL, 0x12f7bb1a153f52fcULL, }, + { 0x12f7bb1a153f52fcULL, 0x12f7bb1a153f52fcULL, }, + { 0x27d8c6ffab2b2514ULL, 0x12f7bb1a153f52fcULL, }, + { 0x8df188d8a942e2a0ULL, 0x12f7bb1a153f52fcULL, }, + { 0x4b670b5efe7bb00cULL, 0x27d8c6ffab2b2514ULL, }, /* 72 */ + { 0x12f7bb1a153f52fcULL, 0x27d8c6ffab2b2514ULL, }, + { 0x27d8c6ffab2b2514ULL, 0x27d8c6ffab2b2514ULL, }, + { 0x8df188d8a942e2a0ULL, 0x27d8c6ffab2b2514ULL, }, + { 0x4b670b5efe7bb00cULL, 0x8df188d8a942e2a0ULL, }, + { 0x12f7bb1a153f52fcULL, 0x8df188d8a942e2a0ULL, }, + { 0x27d8c6ffab2b2514ULL, 0x8df188d8a942e2a0ULL, }, + { 0x8df188d8a942e2a0ULL, 0x8df188d8a942e2a0ULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKOD_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKOD_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_h.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_h.c new file mode 100644 index 0000000000..5c3c529f22 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_h.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction PCKOD.H + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "PCKOD.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0x0000000000000000ULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xffffffffffffffffULL, }, + { 0x5555555555555555ULL, 0xffffffffffffffffULL, }, + { 0xccccccccccccccccULL, 0xffffffffffffffffULL, }, + { 0x3333333333333333ULL, 0xffffffffffffffffULL, }, + { 0x38e3e38ee38e8e38ULL, 0xffffffffffffffffULL, }, + { 0xc71c1c711c7171c7ULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x0000000000000000ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x0000000000000000ULL, }, + { 0x5555555555555555ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0x0000000000000000ULL, }, + { 0x3333333333333333ULL, 0x0000000000000000ULL, }, + { 0x38e3e38ee38e8e38ULL, 0x0000000000000000ULL, }, + { 0xc71c1c711c7171c7ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ + { 0x0000000000000000ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xccccccccccccccccULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x3333333333333333ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x38e3e38ee38e8e38ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xc71c1c711c7171c7ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0x5555555555555555ULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0x5555555555555555ULL, }, + { 0x3333333333333333ULL, 0x5555555555555555ULL, }, + { 0x38e3e38ee38e8e38ULL, 0x5555555555555555ULL, }, + { 0xc71c1c711c7171c7ULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xccccccccccccccccULL, }, /* 32 */ + { 0x0000000000000000ULL, 0xccccccccccccccccULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xccccccccccccccccULL, }, + { 0x5555555555555555ULL, 0xccccccccccccccccULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0xccccccccccccccccULL, }, + { 0x38e3e38ee38e8e38ULL, 0xccccccccccccccccULL, }, + { 0xc71c1c711c7171c7ULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0x3333333333333333ULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x3333333333333333ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x3333333333333333ULL, }, + { 0x5555555555555555ULL, 0x3333333333333333ULL, }, + { 0xccccccccccccccccULL, 0x3333333333333333ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x38e3e38ee38e8e38ULL, 0x3333333333333333ULL, }, + { 0xc71c1c711c7171c7ULL, 0x3333333333333333ULL, }, + { 0xffffffffffffffffULL, 0x38e3e38ee38e8e38ULL, }, /* 48 */ + { 0x0000000000000000ULL, 0x38e3e38ee38e8e38ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x38e3e38ee38e8e38ULL, }, + { 0x5555555555555555ULL, 0x38e3e38ee38e8e38ULL, }, + { 0xccccccccccccccccULL, 0x38e3e38ee38e8e38ULL, }, + { 0x3333333333333333ULL, 0x38e3e38ee38e8e38ULL, }, + { 0x38e3e38ee38e8e38ULL, 0x38e3e38ee38e8e38ULL, }, + { 0xc71c1c711c7171c7ULL, 0x38e3e38ee38e8e38ULL, }, + { 0xffffffffffffffffULL, 0xc71c1c711c7171c7ULL, }, /* 56 */ + { 0x0000000000000000ULL, 0xc71c1c711c7171c7ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xc71c1c711c7171c7ULL, }, + { 0x5555555555555555ULL, 0xc71c1c711c7171c7ULL, }, + { 0xccccccccccccccccULL, 0xc71c1c711c7171c7ULL, }, + { 0x3333333333333333ULL, 0xc71c1c711c7171c7ULL, }, + { 0x38e3e38ee38e8e38ULL, 0xc71c1c711c7171c7ULL, }, + { 0xc71c1c711c7171c7ULL, 0xc71c1c711c7171c7ULL, }, + { 0x4b67fe7b886a2862ULL, 0x4b67fe7b886a2862ULL, }, /* 64 */ + { 0x12f7153ffbbe4d93ULL, 0x4b67fe7b886a2862ULL, }, + { 0x27d8ab2bac5ab9cfULL, 0x4b67fe7b886a2862ULL, }, + { 0x8df1a942704f5e31ULL, 0x4b67fe7b886a2862ULL, }, + { 0x4b67fe7b886a2862ULL, 0x12f7153ffbbe4d93ULL, }, + { 0x12f7153ffbbe4d93ULL, 0x12f7153ffbbe4d93ULL, }, + { 0x27d8ab2bac5ab9cfULL, 0x12f7153ffbbe4d93ULL, }, + { 0x8df1a942704f5e31ULL, 0x12f7153ffbbe4d93ULL, }, + { 0x4b67fe7b886a2862ULL, 0x27d8ab2bac5ab9cfULL, }, /* 72 */ + { 0x12f7153ffbbe4d93ULL, 0x27d8ab2bac5ab9cfULL, }, + { 0x27d8ab2bac5ab9cfULL, 0x27d8ab2bac5ab9cfULL, }, + { 0x8df1a942704f5e31ULL, 0x27d8ab2bac5ab9cfULL, }, + { 0x4b67fe7b886a2862ULL, 0x8df1a942704f5e31ULL, }, + { 0x12f7153ffbbe4d93ULL, 0x8df1a942704f5e31ULL, }, + { 0x27d8ab2bac5ab9cfULL, 0x8df1a942704f5e31ULL, }, + { 0x8df1a942704f5e31ULL, 0x8df1a942704f5e31ULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKOD_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKOD_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_w.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_w.c new file mode 100644 index 0000000000..9275890214 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_pckod_w.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction PCKOD.W + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "PCKOD.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ + { 0x0000000000000000ULL, 0xffffffffffffffffULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xffffffffffffffffULL, }, + { 0x5555555555555555ULL, 0xffffffffffffffffULL, }, + { 0xccccccccccccccccULL, 0xffffffffffffffffULL, }, + { 0x3333333333333333ULL, 0xffffffffffffffffULL, }, + { 0x38e38e38e38e38e3ULL, 0xffffffffffffffffULL, }, + { 0xc71c71c71c71c71cULL, 0xffffffffffffffffULL, }, + { 0xffffffffffffffffULL, 0x0000000000000000ULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x0000000000000000ULL, }, + { 0x5555555555555555ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0x0000000000000000ULL, }, + { 0x3333333333333333ULL, 0x0000000000000000ULL, }, + { 0x38e38e38e38e38e3ULL, 0x0000000000000000ULL, }, + { 0xc71c71c71c71c71cULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ + { 0x0000000000000000ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x5555555555555555ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xccccccccccccccccULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x3333333333333333ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x38e38e38e38e38e3ULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xc71c71c71c71c71cULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0xffffffffffffffffULL, 0x5555555555555555ULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x5555555555555555ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL, }, + { 0x5555555555555555ULL, 0x5555555555555555ULL, }, + { 0xccccccccccccccccULL, 0x5555555555555555ULL, }, + { 0x3333333333333333ULL, 0x5555555555555555ULL, }, + { 0x38e38e38e38e38e3ULL, 0x5555555555555555ULL, }, + { 0xc71c71c71c71c71cULL, 0x5555555555555555ULL, }, + { 0xffffffffffffffffULL, 0xccccccccccccccccULL, }, /* 32 */ + { 0x0000000000000000ULL, 0xccccccccccccccccULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xccccccccccccccccULL, }, + { 0x5555555555555555ULL, 0xccccccccccccccccULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x3333333333333333ULL, 0xccccccccccccccccULL, }, + { 0x38e38e38e38e38e3ULL, 0xccccccccccccccccULL, }, + { 0xc71c71c71c71c71cULL, 0xccccccccccccccccULL, }, + { 0xffffffffffffffffULL, 0x3333333333333333ULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x3333333333333333ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x3333333333333333ULL, }, + { 0x5555555555555555ULL, 0x3333333333333333ULL, }, + { 0xccccccccccccccccULL, 0x3333333333333333ULL, }, + { 0x3333333333333333ULL, 0x3333333333333333ULL, }, + { 0x38e38e38e38e38e3ULL, 0x3333333333333333ULL, }, + { 0xc71c71c71c71c71cULL, 0x3333333333333333ULL, }, + { 0xffffffffffffffffULL, 0x38e38e38e38e38e3ULL, }, /* 48 */ + { 0x0000000000000000ULL, 0x38e38e38e38e38e3ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0x38e38e38e38e38e3ULL, }, + { 0x5555555555555555ULL, 0x38e38e38e38e38e3ULL, }, + { 0xccccccccccccccccULL, 0x38e38e38e38e38e3ULL, }, + { 0x3333333333333333ULL, 0x38e38e38e38e38e3ULL, }, + { 0x38e38e38e38e38e3ULL, 0x38e38e38e38e38e3ULL, }, + { 0xc71c71c71c71c71cULL, 0x38e38e38e38e38e3ULL, }, + { 0xffffffffffffffffULL, 0xc71c71c71c71c71cULL, }, /* 56 */ + { 0x0000000000000000ULL, 0xc71c71c71c71c71cULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xc71c71c71c71c71cULL, }, + { 0x5555555555555555ULL, 0xc71c71c71c71c71cULL, }, + { 0xccccccccccccccccULL, 0xc71c71c71c71c71cULL, }, + { 0x3333333333333333ULL, 0xc71c71c71c71c71cULL, }, + { 0x38e38e38e38e38e3ULL, 0xc71c71c71c71c71cULL, }, + { 0xc71c71c71c71c71cULL, 0xc71c71c71c71c71cULL, }, + { 0x4b670b5e886ae6ccULL, 0x4b670b5e886ae6ccULL, }, /* 64 */ + { 0x12f7bb1afbbe0063ULL, 0x4b670b5e886ae6ccULL, }, + { 0x27d8c6ffac5aaeaaULL, 0x4b670b5e886ae6ccULL, }, + { 0x8df188d8704f164dULL, 0x4b670b5e886ae6ccULL, }, + { 0x4b670b5e886ae6ccULL, 0x12f7bb1afbbe0063ULL, }, + { 0x12f7bb1afbbe0063ULL, 0x12f7bb1afbbe0063ULL, }, + { 0x27d8c6ffac5aaeaaULL, 0x12f7bb1afbbe0063ULL, }, + { 0x8df188d8704f164dULL, 0x12f7bb1afbbe0063ULL, }, + { 0x4b670b5e886ae6ccULL, 0x27d8c6ffac5aaeaaULL, }, /* 72 */ + { 0x12f7bb1afbbe0063ULL, 0x27d8c6ffac5aaeaaULL, }, + { 0x27d8c6ffac5aaeaaULL, 0x27d8c6ffac5aaeaaULL, }, + { 0x8df188d8704f164dULL, 0x27d8c6ffac5aaeaaULL, }, + { 0x4b670b5e886ae6ccULL, 0x8df188d8704f164dULL, }, + { 0x12f7bb1afbbe0063ULL, 0x8df188d8704f164dULL, }, + { 0x27d8c6ffac5aaeaaULL, 0x8df188d8704f164dULL, }, + { 0x8df188d8704f164dULL, 0x8df188d8704f164dULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKOD_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_PCKOD_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_b.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_b.c new file mode 100644 index 0000000000..fcf857a6c0 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_b.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction VSHF.B + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "VSHF.B"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 0 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e8e8e8e8e8e8e8eULL, 0x8e8e8e8e8e8e8e8eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e8e8e8e8e8e8e8eULL, 0x8e8e8e8e8e8e8e8eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e8e8e8e8e8e8e8eULL, 0x8e8e8e8e8e8e8e8eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e8e8e8e8e8e8e8eULL, 0x8e8e8e8e8e8e8e8eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e8e8e8e8e8e8e8eULL, 0x8e8e8e8e8e8e8e8eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e8e8e8e8e8e8e8eULL, 0x8e8e8e8e8e8e8e8eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e8e8e8e8e8e8e8eULL, 0x8e8e8e8e8e8e8e8eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e8e8e8e8e8e8e8eULL, 0x8e8e8e8e8e8e8e8eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x4040404040404040ULL, 0x4040404040404040ULL, }, /* 64 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8080808080808080ULL, 0x8080808080808080ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x4040404040404040ULL, 0x4040404040404040ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8080808080808080ULL, 0x8080808080808080ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x4040404040404040ULL, 0x4040404040404040ULL, }, /* 72 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8080808080808080ULL, 0x8080808080808080ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x4040404040404040ULL, 0x4040404040404040ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8080808080808080ULL, 0x8080808080808080ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_VSHF_B(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_VSHF_B(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_d.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_d.c new file mode 100644 index 0000000000..700c1596a2 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_d.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction VSHF.D + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "VSHF.D"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 0 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38e38e38e38e38eULL, 0xe38e38e38e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x886ae6cc28625540ULL, 0x886ae6cc28625540ULL, }, /* 64 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xac5aaeaab9cf8b80ULL, 0xac5aaeaab9cf8b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x886ae6cc28625540ULL, 0x886ae6cc28625540ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xac5aaeaab9cf8b80ULL, 0xac5aaeaab9cf8b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x886ae6cc28625540ULL, 0x886ae6cc28625540ULL, }, /* 72 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xac5aaeaab9cf8b80ULL, 0xac5aaeaab9cf8b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x886ae6cc28625540ULL, 0x886ae6cc28625540ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xac5aaeaab9cf8b80ULL, 0xac5aaeaab9cf8b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_VSHF_D(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_VSHF_D(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_h.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_h.c new file mode 100644 index 0000000000..3d6c1dc5be --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_h.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction VSHF.H + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "VSHF.H"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 0 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38ee38ee38ee38eULL, 0xe38ee38ee38ee38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38ee38ee38ee38eULL, 0xe38ee38ee38ee38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38ee38ee38ee38eULL, 0xe38ee38ee38ee38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38ee38ee38ee38eULL, 0xe38ee38ee38ee38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38ee38ee38ee38eULL, 0xe38ee38ee38ee38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38ee38ee38ee38eULL, 0xe38ee38ee38ee38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38ee38ee38ee38eULL, 0xe38ee38ee38ee38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xe38ee38ee38ee38eULL, 0xe38ee38ee38ee38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5540554055405540ULL, 0x5540554055405540ULL, }, /* 64 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8b808b808b808b80ULL, 0x8b808b808b808b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5540554055405540ULL, 0x5540554055405540ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8b808b808b808b80ULL, 0x8b808b808b808b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5540554055405540ULL, 0x5540554055405540ULL, }, /* 72 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8b808b808b808b80ULL, 0x8b808b808b808b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x5540554055405540ULL, 0x5540554055405540ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8b808b808b808b80ULL, 0x8b808b808b808b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_VSHF_H(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_VSHF_H(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_w.c b/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_w.c new file mode 100644 index 0000000000..6030762855 --- /dev/null +++ b/tests/tcg/mips/user/ase/msa/pack/test_msa_vshf_w.c @@ -0,0 +1,153 @@ +/* + * Test program for MSA instruction VSHF.W + * + * Copyright (C) 2018 Wave Computing, Inc. + * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + *` + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_msa.h" +#include "../../../../include/test_inputs.h" +#include "../../../../include/test_utils.h" + +#define TEST_COUNT_TOTAL ( \ + (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ + (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) + + +int32_t main(void) +{ + char *instruction_name = "VSHF.W"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b128_result[TEST_COUNT_TOTAL][2]; + uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 0 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e38e38e8e38e38eULL, 0x8e38e38e8e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e38e38e8e38e38eULL, 0x8e38e38e8e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e38e38e8e38e38eULL, 0x8e38e38e8e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e38e38e8e38e38eULL, 0x8e38e38e8e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e38e38e8e38e38eULL, 0x8e38e38e8e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e38e38e8e38e38eULL, 0x8e38e38e8e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e38e38e8e38e38eULL, 0x8e38e38e8e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x8e38e38e8e38e38eULL, 0x8e38e38e8e38e38eULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x2862554028625540ULL, 0x2862554028625540ULL, }, /* 64 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xb9cf8b80b9cf8b80ULL, 0xb9cf8b80b9cf8b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x2862554028625540ULL, 0x2862554028625540ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xb9cf8b80b9cf8b80ULL, 0xb9cf8b80b9cf8b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x2862554028625540ULL, 0x2862554028625540ULL, }, /* 72 */ + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xb9cf8b80b9cf8b80ULL, 0xb9cf8b80b9cf8b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0x2862554028625540ULL, 0x2862554028625540ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + { 0xb9cf8b80b9cf8b80ULL, 0xb9cf8b80b9cf8b80ULL, }, + { 0x0000000000000000ULL, 0x0000000000000000ULL, }, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { + do_msa_VSHF_W(b128_pattern[i], b128_pattern[j], + b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); + } + } + + for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { + do_msa_VSHF_W(b128_random[i], b128_random[j], + b128_result[((PATTERN_INPUTS_SHORT_COUNT) * + (PATTERN_INPUTS_SHORT_COUNT)) + + RANDOM_INPUTS_SHORT_COUNT * i + j]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + &b128_result[0][0], &b128_expect[0][0]); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_clo.c b/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_clo.c new file mode 100644 index 0000000000..ca9a739c50 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_clo.c @@ -0,0 +1,144 @@ +/* + * Test program for MIPS64R6 instruction CLO + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "CLO"; + int32_t ret; + uint32_t i; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000020ULL, /* 0 */ + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000002ULL, + 0x0000000000000000ULL, + 0x0000000000000003ULL, + 0x0000000000000000ULL, + 0x0000000000000004ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000005ULL, + 0x0000000000000000ULL, + 0x0000000000000006ULL, + 0x0000000000000000ULL, + 0x0000000000000007ULL, + 0x0000000000000000ULL, + 0x0000000000000008ULL, /* 16 */ + 0x0000000000000000ULL, + 0x0000000000000009ULL, + 0x0000000000000000ULL, + 0x000000000000000aULL, + 0x0000000000000000ULL, + 0x000000000000000bULL, + 0x0000000000000000ULL, + 0x000000000000000cULL, /* 24 */ + 0x0000000000000000ULL, + 0x000000000000000dULL, + 0x0000000000000000ULL, + 0x000000000000000eULL, + 0x0000000000000000ULL, + 0x000000000000000fULL, + 0x0000000000000000ULL, + 0x0000000000000010ULL, /* 32 */ + 0x0000000000000000ULL, + 0x0000000000000011ULL, + 0x0000000000000000ULL, + 0x0000000000000012ULL, + 0x0000000000000000ULL, + 0x0000000000000013ULL, + 0x0000000000000000ULL, + 0x0000000000000014ULL, /* 40 */ + 0x0000000000000000ULL, + 0x0000000000000015ULL, + 0x0000000000000000ULL, + 0x0000000000000016ULL, + 0x0000000000000000ULL, + 0x0000000000000017ULL, + 0x0000000000000000ULL, + 0x0000000000000018ULL, /* 48 */ + 0x0000000000000000ULL, + 0x0000000000000019ULL, + 0x0000000000000000ULL, + 0x000000000000001aULL, + 0x0000000000000000ULL, + 0x000000000000001bULL, + 0x0000000000000000ULL, + 0x000000000000001cULL, /* 56 */ + 0x0000000000000000ULL, + 0x000000000000001dULL, + 0x0000000000000000ULL, + 0x000000000000001eULL, + 0x0000000000000000ULL, + 0x000000000000001fULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, /* 64 */ + 0x0000000000000005ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000002ULL, + 0x0000000000000001ULL, + 0x0000000000000006ULL, + 0x0000000000000000ULL, /* 72 */ + 0x0000000000000001ULL, + 0x0000000000000001ULL, + 0x0000000000000001ULL, + 0x0000000000000003ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < TEST_COUNT_TOTAL; i++) { + if (i < PATTERN_INPUTS_64_COUNT) { + do_mips64r6_CLO(b64_pattern_se + i, b64_result + i); + } else { + do_mips64r6_CLO(b64_random_se + (i - PATTERN_INPUTS_64_COUNT), + b64_result + i); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_clz.c b/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_clz.c new file mode 100644 index 0000000000..0a7d21dcbd --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_clz.c @@ -0,0 +1,144 @@ +/* + * Test program for MIPS64R6 instruction CLZ + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "CLZ"; + int32_t ret; + uint32_t i; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000000ULL, /* 0 */ + 0x0000000000000020ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000002ULL, + 0x0000000000000000ULL, + 0x0000000000000003ULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000004ULL, + 0x0000000000000000ULL, + 0x0000000000000005ULL, + 0x0000000000000000ULL, + 0x0000000000000006ULL, + 0x0000000000000000ULL, + 0x0000000000000007ULL, + 0x0000000000000000ULL, /* 16 */ + 0x0000000000000008ULL, + 0x0000000000000000ULL, + 0x0000000000000009ULL, + 0x0000000000000000ULL, + 0x000000000000000aULL, + 0x0000000000000000ULL, + 0x000000000000000bULL, + 0x0000000000000000ULL, /* 24 */ + 0x000000000000000cULL, + 0x0000000000000000ULL, + 0x000000000000000dULL, + 0x0000000000000000ULL, + 0x000000000000000eULL, + 0x0000000000000000ULL, + 0x000000000000000fULL, + 0x0000000000000000ULL, /* 32 */ + 0x0000000000000010ULL, + 0x0000000000000000ULL, + 0x0000000000000011ULL, + 0x0000000000000000ULL, + 0x0000000000000012ULL, + 0x0000000000000000ULL, + 0x0000000000000013ULL, + 0x0000000000000000ULL, /* 40 */ + 0x0000000000000014ULL, + 0x0000000000000000ULL, + 0x0000000000000015ULL, + 0x0000000000000000ULL, + 0x0000000000000016ULL, + 0x0000000000000000ULL, + 0x0000000000000017ULL, + 0x0000000000000000ULL, /* 48 */ + 0x0000000000000018ULL, + 0x0000000000000000ULL, + 0x0000000000000019ULL, + 0x0000000000000000ULL, + 0x000000000000001aULL, + 0x0000000000000000ULL, + 0x000000000000001bULL, + 0x0000000000000000ULL, /* 56 */ + 0x000000000000001cULL, + 0x0000000000000000ULL, + 0x000000000000001dULL, + 0x0000000000000000ULL, + 0x000000000000001eULL, + 0x0000000000000000ULL, + 0x000000000000001fULL, + 0x0000000000000000ULL, /* 64 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000002ULL, /* 72 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < TEST_COUNT_TOTAL; i++) { + if (i < PATTERN_INPUTS_64_COUNT) { + do_mips64r6_CLZ(b64_pattern_se + i, b64_result + i); + } else { + do_mips64r6_CLZ(b64_random_se + (i - PATTERN_INPUTS_64_COUNT), + b64_result + i); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_dclo.c b/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_dclo.c new file mode 100644 index 0000000000..72bb473f66 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_dclo.c @@ -0,0 +1,144 @@ +/* + * Test program for MIPS64R6 instruction DCLO + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DCLO"; + int32_t ret; + uint32_t i; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000040ULL, /* 0 */ + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000002ULL, + 0x0000000000000000ULL, + 0x0000000000000003ULL, + 0x0000000000000000ULL, + 0x0000000000000004ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000005ULL, + 0x0000000000000000ULL, + 0x0000000000000006ULL, + 0x0000000000000000ULL, + 0x0000000000000007ULL, + 0x0000000000000000ULL, + 0x0000000000000008ULL, /* 16 */ + 0x0000000000000000ULL, + 0x0000000000000009ULL, + 0x0000000000000000ULL, + 0x000000000000000aULL, + 0x0000000000000000ULL, + 0x000000000000000bULL, + 0x0000000000000000ULL, + 0x000000000000000cULL, /* 24 */ + 0x0000000000000000ULL, + 0x000000000000000dULL, + 0x0000000000000000ULL, + 0x000000000000000eULL, + 0x0000000000000000ULL, + 0x000000000000000fULL, + 0x0000000000000000ULL, + 0x0000000000000010ULL, /* 32 */ + 0x0000000000000000ULL, + 0x0000000000000011ULL, + 0x0000000000000000ULL, + 0x0000000000000012ULL, + 0x0000000000000000ULL, + 0x0000000000000013ULL, + 0x0000000000000000ULL, + 0x0000000000000014ULL, /* 40 */ + 0x0000000000000000ULL, + 0x0000000000000015ULL, + 0x0000000000000000ULL, + 0x0000000000000016ULL, + 0x0000000000000000ULL, + 0x0000000000000017ULL, + 0x0000000000000000ULL, + 0x0000000000000018ULL, /* 48 */ + 0x0000000000000000ULL, + 0x0000000000000019ULL, + 0x0000000000000000ULL, + 0x000000000000001aULL, + 0x0000000000000000ULL, + 0x000000000000001bULL, + 0x0000000000000000ULL, + 0x000000000000001cULL, /* 56 */ + 0x0000000000000000ULL, + 0x000000000000001dULL, + 0x0000000000000000ULL, + 0x000000000000001eULL, + 0x0000000000000000ULL, + 0x000000000000001fULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, /* 64 */ + 0x0000000000000005ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000002ULL, + 0x0000000000000001ULL, + 0x0000000000000006ULL, + 0x0000000000000000ULL, /* 72 */ + 0x0000000000000001ULL, + 0x0000000000000001ULL, + 0x0000000000000001ULL, + 0x0000000000000003ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < TEST_COUNT_TOTAL; i++) { + if (i < PATTERN_INPUTS_64_COUNT) { + do_mips64r6_DCLO((void *)&b64_pattern[i], (void *)&b64_result[i]); + } else { + do_mips64r6_DCLO((void *)&b64_random[i - PATTERN_INPUTS_64_COUNT], + (void *)&b64_result[i]); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_dclz.c b/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_dclz.c new file mode 100644 index 0000000000..87df12b36c --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/bit-count/test_mips64r6_dclz.c @@ -0,0 +1,144 @@ +/* + * Test program for MIPS64R6 instruction DCLZ + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DCLZ"; + int32_t ret; + uint32_t i; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000000ULL, /* 0 */ + 0x0000000000000040ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000002ULL, + 0x0000000000000000ULL, + 0x0000000000000003ULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000004ULL, + 0x0000000000000000ULL, + 0x0000000000000005ULL, + 0x0000000000000000ULL, + 0x0000000000000006ULL, + 0x0000000000000000ULL, + 0x0000000000000007ULL, + 0x0000000000000000ULL, /* 16 */ + 0x0000000000000008ULL, + 0x0000000000000000ULL, + 0x0000000000000009ULL, + 0x0000000000000000ULL, + 0x000000000000000aULL, + 0x0000000000000000ULL, + 0x000000000000000bULL, + 0x0000000000000000ULL, /* 24 */ + 0x000000000000000cULL, + 0x0000000000000000ULL, + 0x000000000000000dULL, + 0x0000000000000000ULL, + 0x000000000000000eULL, + 0x0000000000000000ULL, + 0x000000000000000fULL, + 0x0000000000000000ULL, /* 32 */ + 0x0000000000000010ULL, + 0x0000000000000000ULL, + 0x0000000000000011ULL, + 0x0000000000000000ULL, + 0x0000000000000012ULL, + 0x0000000000000000ULL, + 0x0000000000000013ULL, + 0x0000000000000000ULL, /* 40 */ + 0x0000000000000014ULL, + 0x0000000000000000ULL, + 0x0000000000000015ULL, + 0x0000000000000000ULL, + 0x0000000000000016ULL, + 0x0000000000000000ULL, + 0x0000000000000017ULL, + 0x0000000000000000ULL, /* 48 */ + 0x0000000000000018ULL, + 0x0000000000000000ULL, + 0x0000000000000019ULL, + 0x0000000000000000ULL, + 0x000000000000001aULL, + 0x0000000000000000ULL, + 0x000000000000001bULL, + 0x0000000000000000ULL, /* 56 */ + 0x000000000000001cULL, + 0x0000000000000000ULL, + 0x000000000000001dULL, + 0x0000000000000000ULL, + 0x000000000000001eULL, + 0x0000000000000000ULL, + 0x000000000000001fULL, + 0x0000000000000000ULL, /* 64 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000002ULL, /* 72 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000000ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < TEST_COUNT_TOTAL; i++) { + if (i < PATTERN_INPUTS_64_COUNT) { + do_mips64r6_DCLZ(b64_pattern + i, b64_result + i); + } else { + do_mips64r6_DCLZ(b64_random + (i - PATTERN_INPUTS_64_COUNT), + b64_result + i); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/bit-swap/test_mips64r6_bitswap.c b/tests/tcg/mips/user/isa/mips64r6/bit-swap/test_mips64r6_bitswap.c new file mode 100644 index 0000000000..639850df6a --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/bit-swap/test_mips64r6_bitswap.c @@ -0,0 +1,144 @@ +/* + * Test program for MIPS64R6 instruction BITSWAP + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "BITSWAP"; + int32_t ret; + uint32_t i; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0xffffffffffffffffULL, /* 0 */ + 0x0000000000000000ULL, + 0x0000000055555555ULL, + 0xffffffffaaaaaaaaULL, + 0x0000000033333333ULL, + 0xffffffffccccccccULL, + 0x00000000711cc771ULL, + 0xffffffff8ee3388eULL, + 0x000000000f0f0f0fULL, /* 8 */ + 0xfffffffff0f0f0f0ULL, + 0x00000000071f7cf0ULL, + 0xfffffffff8e0830fULL, + 0xfffffffff0033ff0ULL, + 0x000000000ffcc00fULL, + 0x0000000007fc017fULL, + 0xfffffffff803fe80ULL, + 0xffffffffff00ff00ULL, /* 16 */ + 0x0000000000ff00ffULL, + 0xfffffffff01fc07fULL, + 0x000000000fe03f80ULL, + 0x0000000000ff03f0ULL, + 0xffffffffff00fc0fULL, + 0x0000000001f07f00ULL, + 0xfffffffffe0f80ffULL, + 0x000000000f00ff0fULL, /* 24 */ + 0xfffffffff0ff00f0ULL, + 0x000000007f00f0ffULL, + 0xffffffff80ff0f00ULL, + 0xffffffffff0300ffULL, + 0x0000000000fcff00ULL, + 0xffffffffff1f00f0ULL, + 0x0000000000e0ff0fULL, + 0xffffffffffff0000ULL, /* 32 */ + 0x000000000000ffffULL, + 0xfffffffffcff0700ULL, + 0x000000000300f8ffULL, + 0xfffffffff0ff3f00ULL, + 0x000000000f00c0ffULL, + 0xffffffffc0ffff01ULL, + 0x000000003f0000feULL, + 0x0000000000ffff0fULL, /* 40 */ + 0xffffffffff0000f0ULL, + 0x0000000000fcff7fULL, + 0xffffffffff030080ULL, + 0x0000000000f0ffffULL, + 0xffffffffff0f0000ULL, + 0x0000000000c0ffffULL, + 0xffffffffff3f0000ULL, + 0x000000000000ffffULL, /* 48 */ + 0xffffffffffff0000ULL, + 0x000000000000fcffULL, + 0xffffffffffff0300ULL, + 0x000000000000f0ffULL, + 0xffffffffffff0f00ULL, + 0x000000000000c0ffULL, + 0xffffffffffff3f00ULL, + 0x00000000000000ffULL, /* 56 */ + 0xffffffffffffff00ULL, + 0x00000000000000fcULL, + 0xffffffffffffff03ULL, + 0x00000000000000f0ULL, + 0xffffffffffffff0fULL, + 0x00000000000000c0ULL, + 0xffffffffffffff3fULL, + 0x000000001446aa02ULL, /* 64 */ + 0xffffffffb2c9e310ULL, + 0xffffffff9df3d101ULL, + 0x000000007a8c4772ULL, + 0xffffffffbef5421aULL, + 0xffffffffff50749fULL, + 0xffffffffa6533d52ULL, + 0x000000005965ed41ULL, + 0x000000006a756792ULL, /* 72 */ + 0xffffffffa69ba7ebULL, + 0xffffffff93d363d8ULL, + 0xffffffff8c152675ULL, + 0x00000000654a5750ULL, + 0xffffffff98c48615ULL, + 0x00000000447def39ULL, + 0x000000004f9a7bb5ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < TEST_COUNT_TOTAL; i++) { + if (i < PATTERN_INPUTS_64_COUNT) { + do_mips64r6_BITSWAP(b64_pattern + i, b64_result + i); + } else { + do_mips64r6_BITSWAP(b64_random + (i - PATTERN_INPUTS_64_COUNT), + b64_result + i); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/bit-swap/test_mips64r6_dbitswap.c b/tests/tcg/mips/user/isa/mips64r6/bit-swap/test_mips64r6_dbitswap.c new file mode 100644 index 0000000000..366fe61a95 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/bit-swap/test_mips64r6_dbitswap.c @@ -0,0 +1,144 @@ +/* + * Test program for MIPS64R6 instruction DBITSWAP + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DBITSWAP"; + int32_t ret; + uint32_t i; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0xffffffffffffffffULL, /* 0 */ + 0x0000000000000000ULL, + 0x5555555555555555ULL, + 0xaaaaaaaaaaaaaaaaULL, + 0x3333333333333333ULL, + 0xccccccccccccccccULL, + 0xc7711cc7711cc771ULL, + 0x388ee3388ee3388eULL, + 0x0f0f0f0f0f0f0f0fULL, /* 8 */ + 0xf0f0f0f0f0f0f0f0ULL, + 0x1f7cf0c1071f7cf0ULL, + 0xe0830f3ef8e0830fULL, + 0x3ff0033ff0033ff0ULL, + 0xc00ffcc00ffcc00fULL, + 0x7fc01ff007fc017fULL, + 0x803fe00ff803fe80ULL, + 0xff00ff00ff00ff00ULL, /* 16 */ + 0x00ff00ff00ff00ffULL, + 0xff01fc07f01fc07fULL, + 0x00fe03f80fe03f80ULL, + 0xff03f03f00ff03f0ULL, + 0x00fc0fc0ff00fc0fULL, + 0xff07c0ff01f07f00ULL, + 0x00f83f00fe0f80ffULL, + 0xff0f00ff0f00ff0fULL, /* 24 */ + 0x00f0ff00f0ff00f0ULL, + 0xff1f00fc7f00f0ffULL, + 0x00e0ff0380ff0f00ULL, + 0xff3f00f0ff0300ffULL, + 0x00c0ff0f00fcff00ULL, + 0xff7f00c0ff1f00f0ULL, + 0x0080ff3f00e0ff0fULL, + 0xffff0000ffff0000ULL, /* 32 */ + 0x0000ffff0000ffffULL, + 0xffff0100fcff0700ULL, + 0x0000feff0300f8ffULL, + 0xffff0300f0ff3f00ULL, + 0x0000fcff0f00c0ffULL, + 0xffff0700c0ffff01ULL, + 0x0000f8ff3f0000feULL, + 0xffff0f0000ffff0fULL, /* 40 */ + 0x0000f0ffff0000f0ULL, + 0xffff1f0000fcff7fULL, + 0x0000e0ffff030080ULL, + 0xffff3f0000f0ffffULL, + 0x0000c0ffff0f0000ULL, + 0xffff7f0000c0ffffULL, + 0x000080ffff3f0000ULL, + 0xffffff000000ffffULL, /* 48 */ + 0x000000ffffff0000ULL, + 0xffffff010000fcffULL, + 0x000000feffff0300ULL, + 0xffffff030000f0ffULL, + 0x000000fcffff0f00ULL, + 0xffffff070000c0ffULL, + 0x000000f8ffff3f00ULL, + 0xffffff0f000000ffULL, /* 56 */ + 0x000000f0ffffff00ULL, + 0xffffff1f000000fcULL, + 0x000000e0ffffff03ULL, + 0xffffff3f000000f0ULL, + 0x000000c0ffffff0fULL, + 0xffffff7f000000c0ULL, + 0x00000080ffffff3fULL, + 0x115667331446aa02ULL, /* 64 */ + 0xdf7d00c6b2c9e310ULL, + 0x355a75559df3d101ULL, + 0x0ef268b27a8c4772ULL, + 0x9d49d63ebef5421aULL, + 0x0be47d91ff50749fULL, + 0x1ddc1a60a6533d52ULL, + 0x3ff1c40f5965ed41ULL, + 0x047890b36a756792ULL, /* 72 */ + 0xa53e9bc8a69ba7ebULL, + 0x45176faf93d363d8ULL, + 0x15394f8f8c152675ULL, + 0x67281c97654a5750ULL, + 0x2952acbf98c48615ULL, + 0x620c42c6447def39ULL, + 0xd15ae5454f9a7bb5ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < TEST_COUNT_TOTAL; i++) { + if (i < PATTERN_INPUTS_64_COUNT) { + do_mips64r6_DBITSWAP(b64_pattern + i, b64_result + i); + } else { + do_mips64r6_DBITSWAP(b64_random + (i - PATTERN_INPUTS_64_COUNT), + b64_result + i); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmuh.c b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmuh.c new file mode 100644 index 0000000000..c049378573 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmuh.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction DMUH + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DMUH"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000000ULL, /* 0 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0xffffffffffffffffULL, + 0x0000000000000000ULL, + 0xffffffffffffffffULL, + 0x0000000000000000ULL, + 0xffffffffffffffffULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, /* 16 */ + 0x0000000000000000ULL, + 0x1c71c71c71c71c72ULL, + 0xe38e38e38e38e38eULL, + 0x1111111111111111ULL, + 0xeeeeeeeeeeeeeeeeULL, + 0x097b425ed097b426ULL, + 0xf684bda12f684bdaULL, + 0xffffffffffffffffULL, /* 24 */ + 0x0000000000000000ULL, + 0xe38e38e38e38e38eULL, + 0x1c71c71c71c71c71ULL, + 0xeeeeeeeeeeeeeeeeULL, + 0x1111111111111110ULL, + 0xf684bda12f684bdaULL, + 0x097b425ed097b425ULL, + 0x0000000000000000ULL, /* 32 */ + 0x0000000000000000ULL, + 0x1111111111111111ULL, + 0xeeeeeeeeeeeeeeeeULL, + 0x0a3d70a3d70a3d70ULL, + 0xf5c28f5c28f5c28fULL, + 0x05b05b05b05b05b0ULL, + 0xfa4fa4fa4fa4fa4fULL, + 0xffffffffffffffffULL, /* 40 */ + 0x0000000000000000ULL, + 0xeeeeeeeeeeeeeeeeULL, + 0x1111111111111110ULL, + 0xf5c28f5c28f5c28fULL, + 0x0a3d70a3d70a3d70ULL, + 0xfa4fa4fa4fa4fa4fULL, + 0x05b05b05b05b05b0ULL, + 0x0000000000000000ULL, /* 48 */ + 0x0000000000000000ULL, + 0x097b425ed097b426ULL, + 0xf684bda12f684bdaULL, + 0x05b05b05b05b05b0ULL, + 0xfa4fa4fa4fa4fa4fULL, + 0x0329161f9add3c0cULL, + 0xfcd6e9e06522c3f3ULL, + 0xffffffffffffffffULL, /* 56 */ + 0x0000000000000000ULL, + 0xf684bda12f684bdaULL, + 0x097b425ed097b425ULL, + 0xfa4fa4fa4fa4fa4fULL, + 0x05b05b05b05b05b0ULL, + 0xfcd6e9e06522c3f3ULL, + 0x0329161f9add3c0cULL, + 0x37dbf4448b48bce3ULL, /* 64 */ + 0x01fd28a6ebd66e19ULL, + 0x271290430f9643afULL, + 0xcb89d38b96a86603ULL, + 0x01fd28a6ebd66e19ULL, + 0x00122100b25f881aULL, + 0x016425c3dacd63e9ULL, + 0xfe21cf6e9b332df5ULL, + 0x271290430f9643afULL, /* 72 */ + 0x016425c3dacd63e9ULL, + 0x1b549d7f3d46f8d3ULL, + 0xdb4dd51d1b7c58f2ULL, + 0xcb89d38b96a86603ULL, + 0xfe21cf6e9b332df5ULL, + 0xdb4dd51d1b7c58f2ULL, + 0x31454bf2781d2c60ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DMUH(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DMUH(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmuhu.c b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmuhu.c new file mode 100644 index 0000000000..dfb41951b1 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmuhu.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction DMUHU + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DMUHU"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0xfffffffffffffffeULL, /* 0 */ + 0x0000000000000000ULL, + 0xaaaaaaaaaaaaaaa9ULL, + 0x5555555555555554ULL, + 0xcccccccccccccccbULL, + 0x3333333333333332ULL, + 0xe38e38e38e38e38dULL, + 0x1c71c71c71c71c70ULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0xaaaaaaaaaaaaaaa9ULL, /* 16 */ + 0x0000000000000000ULL, + 0x71c71c71c71c71c6ULL, + 0x38e38e38e38e38e3ULL, + 0x8888888888888887ULL, + 0x2222222222222221ULL, + 0x97b425ed097b425eULL, + 0x12f684bda12f684bULL, + 0x5555555555555554ULL, /* 24 */ + 0x0000000000000000ULL, + 0x38e38e38e38e38e3ULL, + 0x1c71c71c71c71c71ULL, + 0x4444444444444443ULL, + 0x1111111111111110ULL, + 0x4bda12f684bda12fULL, + 0x097b425ed097b425ULL, + 0xcccccccccccccccbULL, /* 32 */ + 0x0000000000000000ULL, + 0x8888888888888887ULL, + 0x4444444444444443ULL, + 0xa3d70a3d70a3d708ULL, + 0x28f5c28f5c28f5c2ULL, + 0xb60b60b60b60b60aULL, + 0x16c16c16c16c16c0ULL, + 0x3333333333333332ULL, /* 40 */ + 0x0000000000000000ULL, + 0x2222222222222221ULL, + 0x1111111111111110ULL, + 0x28f5c28f5c28f5c2ULL, + 0x0a3d70a3d70a3d70ULL, + 0x2d82d82d82d82d82ULL, + 0x05b05b05b05b05b0ULL, + 0xe38e38e38e38e38dULL, /* 48 */ + 0x0000000000000000ULL, + 0x97b425ed097b425eULL, + 0x4bda12f684bda12fULL, + 0xb60b60b60b60b60aULL, + 0x2d82d82d82d82d82ULL, + 0xca4587e6b74f0328ULL, + 0x1948b0fcd6e9e064ULL, + 0x1c71c71c71c71c70ULL, /* 56 */ + 0x0000000000000000ULL, + 0x12f684bda12f684bULL, + 0x097b425ed097b425ULL, + 0x16c16c16c16c16c0ULL, + 0x05b05b05b05b05b0ULL, + 0x1948b0fcd6e9e064ULL, + 0x0329161f9add3c0cULL, + 0x48b1c1dcdc0d6763ULL, /* 64 */ + 0x86260fd661cc8a61ULL, + 0x5bd825b9f1c8246fULL, + 0x3bd8e9d8f4da4851ULL, + 0x86260fd661cc8a61ULL, + 0xf78e21c74d87162aULL, + 0xa97cd4d1e230b671ULL, + 0x6e70e5bbf9651043ULL, + 0x5bd825b9f1c8246fULL, /* 72 */ + 0xa97cd4d1e230b671ULL, + 0x7409fad4b0e60fd3ULL, + 0x4b9ceb6a79ae3b40ULL, + 0x3bd8e9d8f4da4851ULL, + 0x6e70e5bbf9651043ULL, + 0x4b9ceb6a79ae3b40ULL, + 0x31454bf2781d2c60ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DMUHU(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DMUHU(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmul.c b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmul.c new file mode 100644 index 0000000000..3c337dd648 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmul.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction DMUL + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DMUL"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000001ULL, /* 0 */ + 0x0000000000000000ULL, + 0x5555555555555556ULL, + 0xaaaaaaaaaaaaaaabULL, + 0x3333333333333334ULL, + 0xcccccccccccccccdULL, + 0x1c71c71c71c71c72ULL, + 0xe38e38e38e38e38fULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x5555555555555556ULL, /* 16 */ + 0x0000000000000000ULL, + 0x38e38e38e38e38e4ULL, + 0x1c71c71c71c71c72ULL, + 0x7777777777777778ULL, + 0xdddddddddddddddeULL, + 0x12f684bda12f684cULL, + 0x425ed097b425ed0aULL, + 0xaaaaaaaaaaaaaaabULL, /* 24 */ + 0x0000000000000000ULL, + 0x1c71c71c71c71c72ULL, + 0x8e38e38e38e38e39ULL, + 0xbbbbbbbbbbbbbbbcULL, + 0xeeeeeeeeeeeeeeefULL, + 0x097b425ed097b426ULL, + 0xa12f684bda12f685ULL, + 0x3333333333333334ULL, /* 32 */ + 0x0000000000000000ULL, + 0x7777777777777778ULL, + 0xbbbbbbbbbbbbbbbcULL, + 0xf5c28f5c28f5c290ULL, + 0x3d70a3d70a3d70a4ULL, + 0x7d27d27d27d27d28ULL, + 0xb60b60b60b60b60cULL, + 0xcccccccccccccccdULL, /* 40 */ + 0x0000000000000000ULL, + 0xdddddddddddddddeULL, + 0xeeeeeeeeeeeeeeefULL, + 0x3d70a3d70a3d70a4ULL, + 0x8f5c28f5c28f5c29ULL, + 0x9f49f49f49f49f4aULL, + 0x2d82d82d82d82d83ULL, + 0x1c71c71c71c71c72ULL, /* 48 */ + 0x0000000000000000ULL, + 0x12f684bda12f684cULL, + 0x097b425ed097b426ULL, + 0x7d27d27d27d27d28ULL, + 0x9f49f49f49f49f4aULL, + 0xb0fcd6e9e06522c4ULL, + 0x6b74f0329161f9aeULL, + 0xe38e38e38e38e38fULL, /* 56 */ + 0x0000000000000000ULL, + 0x425ed097b425ed0aULL, + 0xa12f684bda12f685ULL, + 0xb60b60b60b60b60cULL, + 0x2d82d82d82d82d83ULL, + 0x6b74f0329161f9aeULL, + 0x781948b0fcd6e9e1ULL, + 0xad45be6961639000ULL, /* 64 */ + 0xefa7a5a0e7176a00ULL, + 0x08c6139fc4346000ULL, + 0xfbe1883aee787980ULL, + 0xefa7a5a0e7176a00ULL, + 0x37ae2b38fded7040ULL, + 0x6acb3d68be6cdc00ULL, + 0xedbf72842143b470ULL, + 0x08c6139fc4346000ULL, /* 72 */ + 0x6acb3d68be6cdc00ULL, + 0x8624e5e1e5044000ULL, + 0x76a5ab8089e38100ULL, + 0xfbe1883aee787980ULL, + 0xedbf72842143b470ULL, + 0x76a5ab8089e38100ULL, + 0x4bb436d5b1e9cfc4ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DMUL(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DMUL(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmulu.c b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmulu.c new file mode 100644 index 0000000000..b20a1bafc1 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_dmulu.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction DMULU + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DMULU"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000001ULL, /* 0 */ + 0x0000000000000000ULL, + 0x5555555555555556ULL, + 0xaaaaaaaaaaaaaaabULL, + 0x3333333333333334ULL, + 0xcccccccccccccccdULL, + 0x1c71c71c71c71c72ULL, + 0xe38e38e38e38e38fULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x5555555555555556ULL, /* 16 */ + 0x0000000000000000ULL, + 0x38e38e38e38e38e4ULL, + 0x1c71c71c71c71c72ULL, + 0x7777777777777778ULL, + 0xdddddddddddddddeULL, + 0x12f684bda12f684cULL, + 0x425ed097b425ed0aULL, + 0xaaaaaaaaaaaaaaabULL, /* 24 */ + 0x0000000000000000ULL, + 0x1c71c71c71c71c72ULL, + 0x8e38e38e38e38e39ULL, + 0xbbbbbbbbbbbbbbbcULL, + 0xeeeeeeeeeeeeeeefULL, + 0x097b425ed097b426ULL, + 0xa12f684bda12f685ULL, + 0x3333333333333334ULL, /* 32 */ + 0x0000000000000000ULL, + 0x7777777777777778ULL, + 0xbbbbbbbbbbbbbbbcULL, + 0xf5c28f5c28f5c290ULL, + 0x3d70a3d70a3d70a4ULL, + 0x7d27d27d27d27d28ULL, + 0xb60b60b60b60b60cULL, + 0xcccccccccccccccdULL, /* 40 */ + 0x0000000000000000ULL, + 0xdddddddddddddddeULL, + 0xeeeeeeeeeeeeeeefULL, + 0x3d70a3d70a3d70a4ULL, + 0x8f5c28f5c28f5c29ULL, + 0x9f49f49f49f49f4aULL, + 0x2d82d82d82d82d83ULL, + 0x1c71c71c71c71c72ULL, /* 48 */ + 0x0000000000000000ULL, + 0x12f684bda12f684cULL, + 0x097b425ed097b426ULL, + 0x7d27d27d27d27d28ULL, + 0x9f49f49f49f49f4aULL, + 0xb0fcd6e9e06522c4ULL, + 0x6b74f0329161f9aeULL, + 0xe38e38e38e38e38fULL, /* 56 */ + 0x0000000000000000ULL, + 0x425ed097b425ed0aULL, + 0xa12f684bda12f685ULL, + 0xb60b60b60b60b60cULL, + 0x2d82d82d82d82d83ULL, + 0x6b74f0329161f9aeULL, + 0x781948b0fcd6e9e1ULL, + 0xad45be6961639000ULL, /* 64 */ + 0xefa7a5a0e7176a00ULL, + 0x08c6139fc4346000ULL, + 0xfbe1883aee787980ULL, + 0xefa7a5a0e7176a00ULL, + 0x37ae2b38fded7040ULL, + 0x6acb3d68be6cdc00ULL, + 0xedbf72842143b470ULL, + 0x08c6139fc4346000ULL, /* 72 */ + 0x6acb3d68be6cdc00ULL, + 0x8624e5e1e5044000ULL, + 0x76a5ab8089e38100ULL, + 0xfbe1883aee787980ULL, + 0xedbf72842143b470ULL, + 0x76a5ab8089e38100ULL, + 0x4bb436d5b1e9cfc4ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DMULU(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DMULU(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_muh.c b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_muh.c new file mode 100644 index 0000000000..91340749b2 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_muh.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction MUH + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "MUH"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000000ULL, /* 0 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0xffffffffffffffffULL, + 0x0000000000000000ULL, + 0xffffffffffffffffULL, + 0x0000000000000000ULL, + 0xffffffffffffffffULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, /* 16 */ + 0x0000000000000000ULL, + 0x000000001c71c71cULL, + 0xffffffffe38e38e3ULL, + 0x0000000011111111ULL, + 0xffffffffeeeeeeeeULL, + 0x00000000097b425fULL, + 0xfffffffff684bda1ULL, + 0xffffffffffffffffULL, /* 24 */ + 0x0000000000000000ULL, + 0xffffffffe38e38e3ULL, + 0x000000001c71c71cULL, + 0xffffffffeeeeeeeeULL, + 0x0000000011111110ULL, + 0xfffffffff684bda1ULL, + 0x00000000097b425eULL, + 0x0000000000000000ULL, /* 32 */ + 0x0000000000000000ULL, + 0x0000000011111111ULL, + 0xffffffffeeeeeeeeULL, + 0x000000000a3d70a4ULL, + 0xfffffffff5c28f5cULL, + 0x0000000005b05b05ULL, + 0xfffffffffa4fa4faULL, + 0xffffffffffffffffULL, /* 40 */ + 0x0000000000000000ULL, + 0xffffffffeeeeeeeeULL, + 0x0000000011111110ULL, + 0xfffffffff5c28f5cULL, + 0x000000000a3d70a3ULL, + 0xfffffffffa4fa4faULL, + 0x0000000005b05b05ULL, + 0x0000000000000000ULL, /* 48 */ + 0x0000000000000000ULL, + 0x00000000097b425fULL, + 0xfffffffff684bda1ULL, + 0x0000000005b05b05ULL, + 0xfffffffffa4fa4faULL, + 0x000000000329161fULL, + 0xfffffffffcd6e9e0ULL, + 0xffffffffffffffffULL, /* 56 */ + 0x0000000000000000ULL, + 0xfffffffff684bda1ULL, + 0x00000000097b425eULL, + 0xfffffffffa4fa4faULL, + 0x0000000005b05b05ULL, + 0xfffffffffcd6e9e0ULL, + 0x000000000329161fULL, + 0x0000000037dbf444ULL, /* 64 */ + 0x0000000001fd28a7ULL, + 0x0000000027129043ULL, + 0xffffffffcb89d38bULL, + 0x0000000001fd28a7ULL, + 0x0000000000122100ULL, + 0x00000000016425c3ULL, + 0xfffffffffe21cf6eULL, + 0x0000000027129043ULL, /* 72 */ + 0x00000000016425c3ULL, + 0x000000001b549d7fULL, + 0xffffffffdb4dd51cULL, + 0xffffffffcb89d38bULL, + 0xfffffffffe21cf6eULL, + 0xffffffffdb4dd51cULL, + 0x0000000031454bf2ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_MUH(b64_pattern_se + i, b64_pattern_se + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_MUH(b64_random_se + i, b64_random_se + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_muhu.c b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_muhu.c new file mode 100644 index 0000000000..24850609c9 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_muhu.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction MUHU + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "MUHU"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0xfffffffffffffffeULL, /* 0 */ + 0x0000000000000000ULL, + 0xffffffffaaaaaaa9ULL, + 0x0000000055555554ULL, + 0xffffffffcccccccbULL, + 0x0000000033333332ULL, + 0xffffffffe38e38e2ULL, + 0x000000001c71c71bULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0xffffffffaaaaaaa9ULL, /* 16 */ + 0x0000000000000000ULL, + 0x0000000071c71c70ULL, + 0x0000000038e38e38ULL, + 0xffffffff88888887ULL, + 0x0000000022222221ULL, + 0xffffffff97b425ecULL, + 0x0000000012f684bdULL, + 0x0000000055555554ULL, /* 24 */ + 0x0000000000000000ULL, + 0x0000000038e38e38ULL, + 0x000000001c71c71cULL, + 0x0000000044444443ULL, + 0x0000000011111110ULL, + 0x000000004bda12f6ULL, + 0x00000000097b425eULL, + 0xffffffffcccccccbULL, /* 32 */ + 0x0000000000000000ULL, + 0xffffffff88888887ULL, + 0x0000000044444443ULL, + 0xffffffffa3d70a3cULL, + 0x0000000028f5c28fULL, + 0xffffffffb60b60b4ULL, + 0x0000000016c16c16ULL, + 0x0000000033333332ULL, /* 40 */ + 0x0000000000000000ULL, + 0x0000000022222221ULL, + 0x0000000011111110ULL, + 0x0000000028f5c28fULL, + 0x000000000a3d70a3ULL, + 0x000000002d82d82dULL, + 0x0000000005b05b05ULL, + 0xffffffffe38e38e2ULL, /* 48 */ + 0x0000000000000000ULL, + 0xffffffff97b425ecULL, + 0x000000004bda12f6ULL, + 0xffffffffb60b60b4ULL, + 0x000000002d82d82dULL, + 0xffffffffca4587e5ULL, + 0x000000001948b0fcULL, + 0x000000001c71c71bULL, /* 56 */ + 0x0000000000000000ULL, + 0x0000000012f684bdULL, + 0x00000000097b425eULL, + 0x0000000016c16c16ULL, + 0x0000000005b05b05ULL, + 0x000000001948b0fcULL, + 0x000000000329161fULL, + 0x0000000048b1c1dcULL, /* 64 */ + 0xffffffff86260fd6ULL, + 0x000000005bd825b9ULL, + 0x000000003bd8e9d8ULL, + 0xffffffff86260fd6ULL, + 0xfffffffff78e21c6ULL, + 0xffffffffa97cd4d0ULL, + 0x000000006e70e5bbULL, + 0x000000005bd825b9ULL, /* 72 */ + 0xffffffffa97cd4d0ULL, + 0x000000007409fad3ULL, + 0x000000004b9ceb69ULL, + 0x000000003bd8e9d8ULL, + 0x000000006e70e5bbULL, + 0x000000004b9ceb69ULL, + 0x0000000031454bf2ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_MUHU(b64_pattern_se + i, b64_pattern_se + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_MUHU(b64_random_se + i, b64_random_se + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_mul.c b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_mul.c new file mode 100644 index 0000000000..acf779c6d9 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_mul.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction MUL + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "MUL"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000001ULL, /* 0 */ + 0x0000000000000000ULL, + 0x0000000055555556ULL, + 0xffffffffaaaaaaabULL, + 0x0000000033333334ULL, + 0xffffffffcccccccdULL, + 0x0000000071c71c72ULL, + 0xffffffff8e38e38fULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000055555556ULL, /* 16 */ + 0x0000000000000000ULL, + 0xffffffffe38e38e4ULL, + 0x0000000071c71c72ULL, + 0x0000000077777778ULL, + 0xffffffffdddddddeULL, + 0xffffffffa12f684cULL, + 0xffffffffb425ed0aULL, + 0xffffffffaaaaaaabULL, /* 24 */ + 0x0000000000000000ULL, + 0x0000000071c71c72ULL, + 0x0000000038e38e39ULL, + 0xffffffffbbbbbbbcULL, + 0xffffffffeeeeeeefULL, + 0xffffffffd097b426ULL, + 0xffffffffda12f685ULL, + 0x0000000033333334ULL, /* 32 */ + 0x0000000000000000ULL, + 0x0000000077777778ULL, + 0xffffffffbbbbbbbcULL, + 0x0000000028f5c290ULL, + 0x000000000a3d70a4ULL, + 0x0000000027d27d28ULL, + 0x000000000b60b60cULL, + 0xffffffffcccccccdULL, /* 40 */ + 0x0000000000000000ULL, + 0xffffffffdddddddeULL, + 0xffffffffeeeeeeefULL, + 0x000000000a3d70a4ULL, + 0xffffffffc28f5c29ULL, + 0x0000000049f49f4aULL, + 0xffffffff82d82d83ULL, + 0x0000000071c71c72ULL, /* 48 */ + 0x0000000000000000ULL, + 0xffffffffa12f684cULL, + 0xffffffffd097b426ULL, + 0x0000000027d27d28ULL, + 0x0000000049f49f4aULL, + 0xffffffffe06522c4ULL, + 0xffffffff9161f9aeULL, + 0xffffffff8e38e38fULL, /* 56 */ + 0x0000000000000000ULL, + 0xffffffffb425ed0aULL, + 0xffffffffda12f685ULL, + 0x000000000b60b60cULL, + 0xffffffff82d82d83ULL, + 0xffffffff9161f9aeULL, + 0xfffffffffcd6e9e1ULL, + 0x0000000061639000ULL, /* 64 */ + 0xffffffffe7176a00ULL, + 0xffffffffc4346000ULL, + 0xffffffffee787980ULL, + 0xffffffffe7176a00ULL, + 0xfffffffffded7040ULL, + 0xffffffffbe6cdc00ULL, + 0x000000002143b470ULL, + 0xffffffffc4346000ULL, /* 72 */ + 0xffffffffbe6cdc00ULL, + 0xffffffffe5044000ULL, + 0xffffffff89e38100ULL, + 0xffffffffee787980ULL, + 0x000000002143b470ULL, + 0xffffffff89e38100ULL, + 0xffffffffb1e9cfc4ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_MUL(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_MUL(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_mulu.c b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_mulu.c new file mode 100644 index 0000000000..65d5803eef --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/int-multiply/test_mips64r6_mulu.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction MULU + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "MULU"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000001ULL, /* 0 */ + 0x0000000000000000ULL, + 0x0000000055555556ULL, + 0xffffffffaaaaaaabULL, + 0x0000000033333334ULL, + 0xffffffffcccccccdULL, + 0x0000000071c71c72ULL, + 0xffffffff8e38e38fULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000055555556ULL, /* 16 */ + 0x0000000000000000ULL, + 0xffffffffe38e38e4ULL, + 0x0000000071c71c72ULL, + 0x0000000077777778ULL, + 0xffffffffdddddddeULL, + 0xffffffffa12f684cULL, + 0xffffffffb425ed0aULL, + 0xffffffffaaaaaaabULL, /* 24 */ + 0x0000000000000000ULL, + 0x0000000071c71c72ULL, + 0x0000000038e38e39ULL, + 0xffffffffbbbbbbbcULL, + 0xffffffffeeeeeeefULL, + 0xffffffffd097b426ULL, + 0xffffffffda12f685ULL, + 0x0000000033333334ULL, /* 32 */ + 0x0000000000000000ULL, + 0x0000000077777778ULL, + 0xffffffffbbbbbbbcULL, + 0x0000000028f5c290ULL, + 0x000000000a3d70a4ULL, + 0x0000000027d27d28ULL, + 0x000000000b60b60cULL, + 0xffffffffcccccccdULL, /* 40 */ + 0x0000000000000000ULL, + 0xffffffffdddddddeULL, + 0xffffffffeeeeeeefULL, + 0x000000000a3d70a4ULL, + 0xffffffffc28f5c29ULL, + 0x0000000049f49f4aULL, + 0xffffffff82d82d83ULL, + 0x0000000071c71c72ULL, /* 48 */ + 0x0000000000000000ULL, + 0xffffffffa12f684cULL, + 0xffffffffd097b426ULL, + 0x0000000027d27d28ULL, + 0x0000000049f49f4aULL, + 0xffffffffe06522c4ULL, + 0xffffffff9161f9aeULL, + 0xffffffff8e38e38fULL, /* 56 */ + 0x0000000000000000ULL, + 0xffffffffb425ed0aULL, + 0xffffffffda12f685ULL, + 0x000000000b60b60cULL, + 0xffffffff82d82d83ULL, + 0xffffffff9161f9aeULL, + 0xfffffffffcd6e9e1ULL, + 0x0000000061639000ULL, /* 64 */ + 0xffffffffe7176a00ULL, + 0xffffffffc4346000ULL, + 0xffffffffee787980ULL, + 0xffffffffe7176a00ULL, + 0xfffffffffded7040ULL, + 0xffffffffbe6cdc00ULL, + 0x000000002143b470ULL, + 0xffffffffc4346000ULL, /* 72 */ + 0xffffffffbe6cdc00ULL, + 0xffffffffe5044000ULL, + 0xffffffff89e38100ULL, + 0xffffffffee787980ULL, + 0x000000002143b470ULL, + 0xffffffff89e38100ULL, + 0xffffffffb1e9cfc4ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_MULU(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_MULU(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_and.c b/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_and.c new file mode 100644 index 0000000000..2039dd9899 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_and.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction AND + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "AND"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x8000000000000000ULL, /* 0 */ + 0xffffffffffffffffULL, + 0xfffffc0000000000ULL, + 0xffffffffffe00000ULL, + 0xfffffffffffff000ULL, + 0xfff8000000000000ULL, + 0xffffffffffffc000ULL, + 0xfffe000000000000ULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, /* 16 */ + 0xaaaaaaaaaaaaaaaaULL, + 0xaaaaa80000000000ULL, + 0x5555555555400000ULL, + 0xaaaaaaaaaaaaa000ULL, + 0x5550000000000000ULL, + 0xaaaaaaaaaaaa8000ULL, + 0x5554000000000000ULL, + 0x8000000000000000ULL, /* 24 */ + 0x5555555555555555ULL, + 0x5555540000000000ULL, + 0xaaaaaaaaaaa00000ULL, + 0x5555555555555000ULL, + 0xaaa8000000000000ULL, + 0x5555555555554000ULL, + 0xaaaa000000000000ULL, + 0x0000000000000000ULL, /* 32 */ + 0xccccccccccccccccULL, + 0x3333300000000000ULL, + 0x9999999999800000ULL, + 0xccccccccccccc000ULL, + 0x6660000000000000ULL, + 0x3333333333330000ULL, + 0x9998000000000000ULL, + 0x8000000000000000ULL, /* 40 */ + 0x3333333333333333ULL, + 0xcccccc0000000000ULL, + 0x6666666666600000ULL, + 0x3333333333333000ULL, + 0x9998000000000000ULL, + 0xccccccccccccc000ULL, + 0x6666000000000000ULL, + 0x0000000000000000ULL, /* 48 */ + 0xe38e38e38e38e38eULL, + 0xe38e380000000000ULL, + 0x1c71c71c71c00000ULL, + 0xe38e38e38e38e000ULL, + 0x1c70000000000000ULL, + 0x8e38e38e38e38000ULL, + 0xc71c000000000000ULL, + 0x8000000000000000ULL, /* 56 */ + 0x1c71c71c71c71c71ULL, + 0x1c71c40000000000ULL, + 0xe38e38e38e200000ULL, + 0x1c71c71c71c71000ULL, + 0xe388000000000000ULL, + 0x71c71c71c71c4000ULL, + 0x38e2000000000000ULL, + 0x886ae6cc28625540ULL, /* 64 */ + 0x6ae6cc2862554000ULL, + 0x886ae6cc28625540ULL, + 0xb9b30a1895500000ULL, + 0xfbbe00634d93c708ULL, + 0xbe00634d93c70800ULL, + 0xfbbe00634d93c708ULL, + 0x8018d364f1c20000ULL, + 0xac5aaeaab9cf8b80ULL, /* 72 */ + 0x5aaeaab9cf8b8000ULL, + 0xac5aaeaab9cf8b80ULL, + 0xabaaae73e2e00000ULL, + 0x704f164d5e31e24eULL, + 0x4f164d5e31e24e00ULL, + 0x704f164d5e31e24eULL, + 0xc593578c78938000ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_AND(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_AND(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_nor.c b/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_nor.c new file mode 100644 index 0000000000..f22393b6c7 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_nor.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction NOR + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "NOR"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x8000000000000000ULL, /* 0 */ + 0xffffffffffffffffULL, + 0xfffffc0000000000ULL, + 0xffffffffffe00000ULL, + 0xfffffffffffff000ULL, + 0xfff8000000000000ULL, + 0xffffffffffffc000ULL, + 0xfffe000000000000ULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, /* 16 */ + 0xaaaaaaaaaaaaaaaaULL, + 0xaaaaa80000000000ULL, + 0x5555555555400000ULL, + 0xaaaaaaaaaaaaa000ULL, + 0x5550000000000000ULL, + 0xaaaaaaaaaaaa8000ULL, + 0x5554000000000000ULL, + 0x8000000000000000ULL, /* 24 */ + 0x5555555555555555ULL, + 0x5555540000000000ULL, + 0xaaaaaaaaaaa00000ULL, + 0x5555555555555000ULL, + 0xaaa8000000000000ULL, + 0x5555555555554000ULL, + 0xaaaa000000000000ULL, + 0x0000000000000000ULL, /* 32 */ + 0xccccccccccccccccULL, + 0x3333300000000000ULL, + 0x9999999999800000ULL, + 0xccccccccccccc000ULL, + 0x6660000000000000ULL, + 0x3333333333330000ULL, + 0x9998000000000000ULL, + 0x8000000000000000ULL, /* 40 */ + 0x3333333333333333ULL, + 0xcccccc0000000000ULL, + 0x6666666666600000ULL, + 0x3333333333333000ULL, + 0x9998000000000000ULL, + 0xccccccccccccc000ULL, + 0x6666000000000000ULL, + 0x0000000000000000ULL, /* 48 */ + 0xe38e38e38e38e38eULL, + 0xe38e380000000000ULL, + 0x1c71c71c71c00000ULL, + 0xe38e38e38e38e000ULL, + 0x1c70000000000000ULL, + 0x8e38e38e38e38000ULL, + 0xc71c000000000000ULL, + 0x8000000000000000ULL, /* 56 */ + 0x1c71c71c71c71c71ULL, + 0x1c71c40000000000ULL, + 0xe38e38e38e200000ULL, + 0x1c71c71c71c71000ULL, + 0xe388000000000000ULL, + 0x71c71c71c71c4000ULL, + 0x38e2000000000000ULL, + 0x886ae6cc28625540ULL, /* 64 */ + 0x6ae6cc2862554000ULL, + 0x886ae6cc28625540ULL, + 0xb9b30a1895500000ULL, + 0xfbbe00634d93c708ULL, + 0xbe00634d93c70800ULL, + 0xfbbe00634d93c708ULL, + 0x8018d364f1c20000ULL, + 0xac5aaeaab9cf8b80ULL, /* 72 */ + 0x5aaeaab9cf8b8000ULL, + 0xac5aaeaab9cf8b80ULL, + 0xabaaae73e2e00000ULL, + 0x704f164d5e31e24eULL, + 0x4f164d5e31e24e00ULL, + 0x704f164d5e31e24eULL, + 0xc593578c78938000ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_NOR(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_NOR(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_or.c b/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_or.c new file mode 100644 index 0000000000..ed8bac1c9c --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_or.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction OR + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "OR"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x8000000000000000ULL, /* 0 */ + 0xffffffffffffffffULL, + 0xfffffc0000000000ULL, + 0xffffffffffe00000ULL, + 0xfffffffffffff000ULL, + 0xfff8000000000000ULL, + 0xffffffffffffc000ULL, + 0xfffe000000000000ULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, /* 16 */ + 0xaaaaaaaaaaaaaaaaULL, + 0xaaaaa80000000000ULL, + 0x5555555555400000ULL, + 0xaaaaaaaaaaaaa000ULL, + 0x5550000000000000ULL, + 0xaaaaaaaaaaaa8000ULL, + 0x5554000000000000ULL, + 0x8000000000000000ULL, /* 24 */ + 0x5555555555555555ULL, + 0x5555540000000000ULL, + 0xaaaaaaaaaaa00000ULL, + 0x5555555555555000ULL, + 0xaaa8000000000000ULL, + 0x5555555555554000ULL, + 0xaaaa000000000000ULL, + 0x0000000000000000ULL, /* 32 */ + 0xccccccccccccccccULL, + 0x3333300000000000ULL, + 0x9999999999800000ULL, + 0xccccccccccccc000ULL, + 0x6660000000000000ULL, + 0x3333333333330000ULL, + 0x9998000000000000ULL, + 0x8000000000000000ULL, /* 40 */ + 0x3333333333333333ULL, + 0xcccccc0000000000ULL, + 0x6666666666600000ULL, + 0x3333333333333000ULL, + 0x9998000000000000ULL, + 0xccccccccccccc000ULL, + 0x6666000000000000ULL, + 0x0000000000000000ULL, /* 48 */ + 0xe38e38e38e38e38eULL, + 0xe38e380000000000ULL, + 0x1c71c71c71c00000ULL, + 0xe38e38e38e38e000ULL, + 0x1c70000000000000ULL, + 0x8e38e38e38e38000ULL, + 0xc71c000000000000ULL, + 0x8000000000000000ULL, /* 56 */ + 0x1c71c71c71c71c71ULL, + 0x1c71c40000000000ULL, + 0xe38e38e38e200000ULL, + 0x1c71c71c71c71000ULL, + 0xe388000000000000ULL, + 0x71c71c71c71c4000ULL, + 0x38e2000000000000ULL, + 0x886ae6cc28625540ULL, /* 64 */ + 0x6ae6cc2862554000ULL, + 0x886ae6cc28625540ULL, + 0xb9b30a1895500000ULL, + 0xfbbe00634d93c708ULL, + 0xbe00634d93c70800ULL, + 0xfbbe00634d93c708ULL, + 0x8018d364f1c20000ULL, + 0xac5aaeaab9cf8b80ULL, /* 72 */ + 0x5aaeaab9cf8b8000ULL, + 0xac5aaeaab9cf8b80ULL, + 0xabaaae73e2e00000ULL, + 0x704f164d5e31e24eULL, + 0x4f164d5e31e24e00ULL, + 0x704f164d5e31e24eULL, + 0xc593578c78938000ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_OR(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_OR(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_xor.c b/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_xor.c new file mode 100644 index 0000000000..a8ba2b4ed1 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/logic/test_mips64r6_xor.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction XOR + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "XOR"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x8000000000000000ULL, /* 0 */ + 0xffffffffffffffffULL, + 0xfffffc0000000000ULL, + 0xffffffffffe00000ULL, + 0xfffffffffffff000ULL, + 0xfff8000000000000ULL, + 0xffffffffffffc000ULL, + 0xfffe000000000000ULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, /* 16 */ + 0xaaaaaaaaaaaaaaaaULL, + 0xaaaaa80000000000ULL, + 0x5555555555400000ULL, + 0xaaaaaaaaaaaaa000ULL, + 0x5550000000000000ULL, + 0xaaaaaaaaaaaa8000ULL, + 0x5554000000000000ULL, + 0x8000000000000000ULL, /* 24 */ + 0x5555555555555555ULL, + 0x5555540000000000ULL, + 0xaaaaaaaaaaa00000ULL, + 0x5555555555555000ULL, + 0xaaa8000000000000ULL, + 0x5555555555554000ULL, + 0xaaaa000000000000ULL, + 0x0000000000000000ULL, /* 32 */ + 0xccccccccccccccccULL, + 0x3333300000000000ULL, + 0x9999999999800000ULL, + 0xccccccccccccc000ULL, + 0x6660000000000000ULL, + 0x3333333333330000ULL, + 0x9998000000000000ULL, + 0x8000000000000000ULL, /* 40 */ + 0x3333333333333333ULL, + 0xcccccc0000000000ULL, + 0x6666666666600000ULL, + 0x3333333333333000ULL, + 0x9998000000000000ULL, + 0xccccccccccccc000ULL, + 0x6666000000000000ULL, + 0x0000000000000000ULL, /* 48 */ + 0xe38e38e38e38e38eULL, + 0xe38e380000000000ULL, + 0x1c71c71c71c00000ULL, + 0xe38e38e38e38e000ULL, + 0x1c70000000000000ULL, + 0x8e38e38e38e38000ULL, + 0xc71c000000000000ULL, + 0x8000000000000000ULL, /* 56 */ + 0x1c71c71c71c71c71ULL, + 0x1c71c40000000000ULL, + 0xe38e38e38e200000ULL, + 0x1c71c71c71c71000ULL, + 0xe388000000000000ULL, + 0x71c71c71c71c4000ULL, + 0x38e2000000000000ULL, + 0x886ae6cc28625540ULL, /* 64 */ + 0x6ae6cc2862554000ULL, + 0x886ae6cc28625540ULL, + 0xb9b30a1895500000ULL, + 0xfbbe00634d93c708ULL, + 0xbe00634d93c70800ULL, + 0xfbbe00634d93c708ULL, + 0x8018d364f1c20000ULL, + 0xac5aaeaab9cf8b80ULL, /* 72 */ + 0x5aaeaab9cf8b8000ULL, + 0xac5aaeaab9cf8b80ULL, + 0xabaaae73e2e00000ULL, + 0x704f164d5e31e24eULL, + 0x4f164d5e31e24e00ULL, + 0x704f164d5e31e24eULL, + 0xc593578c78938000ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_XOR(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_XOR(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_dsllv.c b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_dsllv.c new file mode 100644 index 0000000000..b3eb86edb7 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_dsllv.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction DSLLV + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DSLLV"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x8000000000000000ULL, /* 0 */ + 0xffffffffffffffffULL, + 0xfffffc0000000000ULL, + 0xffffffffffe00000ULL, + 0xfffffffffffff000ULL, + 0xfff8000000000000ULL, + 0xffffffffffffc000ULL, + 0xfffe000000000000ULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, /* 16 */ + 0xaaaaaaaaaaaaaaaaULL, + 0xaaaaa80000000000ULL, + 0x5555555555400000ULL, + 0xaaaaaaaaaaaaa000ULL, + 0x5550000000000000ULL, + 0xaaaaaaaaaaaa8000ULL, + 0x5554000000000000ULL, + 0x8000000000000000ULL, /* 24 */ + 0x5555555555555555ULL, + 0x5555540000000000ULL, + 0xaaaaaaaaaaa00000ULL, + 0x5555555555555000ULL, + 0xaaa8000000000000ULL, + 0x5555555555554000ULL, + 0xaaaa000000000000ULL, + 0x0000000000000000ULL, /* 32 */ + 0xccccccccccccccccULL, + 0x3333300000000000ULL, + 0x9999999999800000ULL, + 0xccccccccccccc000ULL, + 0x6660000000000000ULL, + 0x3333333333330000ULL, + 0x9998000000000000ULL, + 0x8000000000000000ULL, /* 40 */ + 0x3333333333333333ULL, + 0xcccccc0000000000ULL, + 0x6666666666600000ULL, + 0x3333333333333000ULL, + 0x9998000000000000ULL, + 0xccccccccccccc000ULL, + 0x6666000000000000ULL, + 0x0000000000000000ULL, /* 48 */ + 0xe38e38e38e38e38eULL, + 0xe38e380000000000ULL, + 0x1c71c71c71c00000ULL, + 0xe38e38e38e38e000ULL, + 0x1c70000000000000ULL, + 0x8e38e38e38e38000ULL, + 0xc71c000000000000ULL, + 0x8000000000000000ULL, /* 56 */ + 0x1c71c71c71c71c71ULL, + 0x1c71c40000000000ULL, + 0xe38e38e38e200000ULL, + 0x1c71c71c71c71000ULL, + 0xe388000000000000ULL, + 0x71c71c71c71c4000ULL, + 0x38e2000000000000ULL, + 0x886ae6cc28625540ULL, /* 64 */ + 0x6ae6cc2862554000ULL, + 0x886ae6cc28625540ULL, + 0xb9b30a1895500000ULL, + 0xfbbe00634d93c708ULL, + 0xbe00634d93c70800ULL, + 0xfbbe00634d93c708ULL, + 0x8018d364f1c20000ULL, + 0xac5aaeaab9cf8b80ULL, /* 72 */ + 0x5aaeaab9cf8b8000ULL, + 0xac5aaeaab9cf8b80ULL, + 0xabaaae73e2e00000ULL, + 0x704f164d5e31e24eULL, + 0x4f164d5e31e24e00ULL, + 0x704f164d5e31e24eULL, + 0xc593578c78938000ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DSLLV(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DSLLV(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_dsrav.c b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_dsrav.c new file mode 100644 index 0000000000..025e8f8163 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_dsrav.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction DSRAV + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DSRAV"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0xffffffffffffffffULL, /* 0 */ + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0xffffffffffffffffULL, /* 16 */ + 0xaaaaaaaaaaaaaaaaULL, + 0xffffffffffeaaaaaULL, + 0xfffffd5555555555ULL, + 0xfffaaaaaaaaaaaaaULL, + 0xfffffffffffff555ULL, + 0xfffeaaaaaaaaaaaaULL, + 0xffffffffffffd555ULL, + 0x0000000000000000ULL, /* 24 */ + 0x5555555555555555ULL, + 0x0000000000155555ULL, + 0x000002aaaaaaaaaaULL, + 0x0005555555555555ULL, + 0x0000000000000aaaULL, + 0x0001555555555555ULL, + 0x0000000000002aaaULL, + 0xffffffffffffffffULL, /* 32 */ + 0xccccccccccccccccULL, + 0xfffffffffff33333ULL, + 0xfffffe6666666666ULL, + 0xfffcccccccccccccULL, + 0xfffffffffffff999ULL, + 0xffff333333333333ULL, + 0xffffffffffffe666ULL, + 0x0000000000000000ULL, /* 40 */ + 0x3333333333333333ULL, + 0x00000000000cccccULL, + 0x0000019999999999ULL, + 0x0003333333333333ULL, + 0x0000000000000666ULL, + 0x0000ccccccccccccULL, + 0x0000000000001999ULL, + 0xffffffffffffffffULL, /* 48 */ + 0xe38e38e38e38e38eULL, + 0xfffffffffff8e38eULL, + 0xffffff1c71c71c71ULL, + 0xfffe38e38e38e38eULL, + 0xfffffffffffffc71ULL, + 0xffff8e38e38e38e3ULL, + 0xfffffffffffff1c7ULL, + 0x0000000000000000ULL, /* 56 */ + 0x1c71c71c71c71c71ULL, + 0x0000000000071c71ULL, + 0x000000e38e38e38eULL, + 0x0001c71c71c71c71ULL, + 0x000000000000038eULL, + 0x000071c71c71c71cULL, + 0x0000000000000e38ULL, + 0x886ae6cc28625540ULL, /* 64 */ + 0xff886ae6cc286255ULL, + 0x886ae6cc28625540ULL, + 0xfffe21ab9b30a189ULL, + 0xfbbe00634d93c708ULL, + 0xfffbbe00634d93c7ULL, + 0xfbbe00634d93c708ULL, + 0xffffeef8018d364fULL, + 0xac5aaeaab9cf8b80ULL, /* 72 */ + 0xffac5aaeaab9cf8bULL, + 0xac5aaeaab9cf8b80ULL, + 0xfffeb16abaaae73eULL, + 0x704f164d5e31e24eULL, + 0x00704f164d5e31e2ULL, + 0x704f164d5e31e24eULL, + 0x0001c13c593578c7ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DSRAV(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DSRAV(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_dsrlv.c b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_dsrlv.c new file mode 100644 index 0000000000..680f8a1845 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_dsrlv.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction DSRLV + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "DSRLV"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000001ULL, /* 0 */ + 0xffffffffffffffffULL, + 0x00000000003fffffULL, + 0x000007ffffffffffULL, + 0x000fffffffffffffULL, + 0x0000000000001fffULL, + 0x0003ffffffffffffULL, + 0x0000000000007fffULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, /* 16 */ + 0xaaaaaaaaaaaaaaaaULL, + 0x00000000002aaaaaULL, + 0x0000055555555555ULL, + 0x000aaaaaaaaaaaaaULL, + 0x0000000000001555ULL, + 0x0002aaaaaaaaaaaaULL, + 0x0000000000005555ULL, + 0x0000000000000000ULL, /* 24 */ + 0x5555555555555555ULL, + 0x0000000000155555ULL, + 0x000002aaaaaaaaaaULL, + 0x0005555555555555ULL, + 0x0000000000000aaaULL, + 0x0001555555555555ULL, + 0x0000000000002aaaULL, + 0x0000000000000001ULL, /* 32 */ + 0xccccccccccccccccULL, + 0x0000000000333333ULL, + 0x0000066666666666ULL, + 0x000cccccccccccccULL, + 0x0000000000001999ULL, + 0x0003333333333333ULL, + 0x0000000000006666ULL, + 0x0000000000000000ULL, /* 40 */ + 0x3333333333333333ULL, + 0x00000000000cccccULL, + 0x0000019999999999ULL, + 0x0003333333333333ULL, + 0x0000000000000666ULL, + 0x0000ccccccccccccULL, + 0x0000000000001999ULL, + 0x0000000000000001ULL, /* 48 */ + 0xe38e38e38e38e38eULL, + 0x000000000038e38eULL, + 0x0000071c71c71c71ULL, + 0x000e38e38e38e38eULL, + 0x0000000000001c71ULL, + 0x00038e38e38e38e3ULL, + 0x00000000000071c7ULL, + 0x0000000000000000ULL, /* 56 */ + 0x1c71c71c71c71c71ULL, + 0x0000000000071c71ULL, + 0x000000e38e38e38eULL, + 0x0001c71c71c71c71ULL, + 0x000000000000038eULL, + 0x000071c71c71c71cULL, + 0x0000000000000e38ULL, + 0x886ae6cc28625540ULL, /* 64 */ + 0x00886ae6cc286255ULL, + 0x886ae6cc28625540ULL, + 0x000221ab9b30a189ULL, + 0xfbbe00634d93c708ULL, + 0x00fbbe00634d93c7ULL, + 0xfbbe00634d93c708ULL, + 0x0003eef8018d364fULL, + 0xac5aaeaab9cf8b80ULL, /* 72 */ + 0x00ac5aaeaab9cf8bULL, + 0xac5aaeaab9cf8b80ULL, + 0x0002b16abaaae73eULL, + 0x704f164d5e31e24eULL, + 0x00704f164d5e31e2ULL, + 0x704f164d5e31e24eULL, + 0x0001c13c593578c7ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DSRLV(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_DSRLV(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_sllv.c b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_sllv.c new file mode 100644 index 0000000000..288d087773 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_sllv.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction SLLV + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "SLLV"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0xffffffff80000000ULL, /* 0 */ + 0xffffffffffffffffULL, + 0xfffffffffffffc00ULL, + 0xffffffffffe00000ULL, + 0xfffffffffffff000ULL, + 0xfffffffffff80000ULL, + 0xffffffffffffc000ULL, + 0xfffffffffffe0000ULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, /* 16 */ + 0xffffffffaaaaaaaaULL, + 0xffffffffaaaaa800ULL, + 0x0000000055400000ULL, + 0xffffffffaaaaa000ULL, + 0x0000000055500000ULL, + 0xffffffffaaaa8000ULL, + 0x0000000055540000ULL, + 0xffffffff80000000ULL, /* 24 */ + 0x0000000055555555ULL, + 0x0000000055555400ULL, + 0xffffffffaaa00000ULL, + 0x0000000055555000ULL, + 0xffffffffaaa80000ULL, + 0x0000000055554000ULL, + 0xffffffffaaaa0000ULL, + 0x0000000000000000ULL, /* 32 */ + 0xffffffffccccccccULL, + 0x0000000033333000ULL, + 0xffffffff99800000ULL, + 0xffffffffccccc000ULL, + 0x0000000066600000ULL, + 0x0000000033330000ULL, + 0xffffffff99980000ULL, + 0xffffffff80000000ULL, /* 40 */ + 0x0000000033333333ULL, + 0xffffffffcccccc00ULL, + 0x0000000066600000ULL, + 0x0000000033333000ULL, + 0xffffffff99980000ULL, + 0xffffffffccccc000ULL, + 0x0000000066660000ULL, + 0x0000000000000000ULL, /* 48 */ + 0xffffffff8e38e38eULL, + 0xffffffffe38e3800ULL, + 0x0000000071c00000ULL, + 0xffffffff8e38e000ULL, + 0x000000001c700000ULL, + 0x0000000038e38000ULL, + 0xffffffffc71c0000ULL, + 0xffffffff80000000ULL, /* 56 */ + 0x0000000071c71c71ULL, + 0x000000001c71c400ULL, + 0xffffffff8e200000ULL, + 0x0000000071c71000ULL, + 0xffffffffe3880000ULL, + 0xffffffffc71c4000ULL, + 0x0000000038e20000ULL, + 0x0000000028625540ULL, /* 64 */ + 0x0000000062554000ULL, + 0x0000000028625540ULL, + 0xffffffff95500000ULL, + 0x000000004d93c708ULL, + 0xffffffff93c70800ULL, + 0x000000004d93c708ULL, + 0xfffffffff1c20000ULL, + 0xffffffffb9cf8b80ULL, /* 72 */ + 0xffffffffcf8b8000ULL, + 0xffffffffb9cf8b80ULL, + 0xffffffffe2e00000ULL, + 0x000000005e31e24eULL, + 0x0000000031e24e00ULL, + 0x000000005e31e24eULL, + 0x0000000078938000ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_SLLV(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_SLLV(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_srav.c b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_srav.c new file mode 100644 index 0000000000..f547d9e408 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_srav.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction SRAV + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "SRAV"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0xffffffffffffffffULL, /* 0 */ + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0xffffffffffffffffULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0xffffffffffffffffULL, /* 16 */ + 0xffffffffaaaaaaaaULL, + 0xffffffffffeaaaaaULL, + 0xfffffffffffffd55ULL, + 0xfffffffffffaaaaaULL, + 0xfffffffffffff555ULL, + 0xfffffffffffeaaaaULL, + 0xffffffffffffd555ULL, + 0x0000000000000000ULL, /* 24 */ + 0x0000000055555555ULL, + 0x0000000000155555ULL, + 0x00000000000002aaULL, + 0x0000000000055555ULL, + 0x0000000000000aaaULL, + 0x0000000000015555ULL, + 0x0000000000002aaaULL, + 0xffffffffffffffffULL, /* 32 */ + 0xffffffffccccccccULL, + 0xfffffffffff33333ULL, + 0xfffffffffffffe66ULL, + 0xfffffffffffcccccULL, + 0xfffffffffffff999ULL, + 0xffffffffffff3333ULL, + 0xffffffffffffe666ULL, + 0x0000000000000000ULL, /* 40 */ + 0x0000000033333333ULL, + 0x00000000000cccccULL, + 0x0000000000000199ULL, + 0x0000000000033333ULL, + 0x0000000000000666ULL, + 0x000000000000ccccULL, + 0x0000000000001999ULL, + 0xffffffffffffffffULL, /* 48 */ + 0xffffffff8e38e38eULL, + 0xffffffffffe38e38ULL, + 0xfffffffffffffc71ULL, + 0xfffffffffff8e38eULL, + 0xfffffffffffff1c7ULL, + 0xfffffffffffe38e3ULL, + 0xffffffffffffc71cULL, + 0x0000000000000000ULL, /* 56 */ + 0x0000000071c71c71ULL, + 0x00000000001c71c7ULL, + 0x000000000000038eULL, + 0x0000000000071c71ULL, + 0x0000000000000e38ULL, + 0x000000000001c71cULL, + 0x00000000000038e3ULL, + 0x0000000028625540ULL, /* 64 */ + 0x0000000000286255ULL, + 0x0000000028625540ULL, + 0x000000000000a189ULL, + 0x000000004d93c708ULL, + 0x00000000004d93c7ULL, + 0x000000004d93c708ULL, + 0x000000000001364fULL, + 0xffffffffb9cf8b80ULL, /* 72 */ + 0xffffffffffb9cf8bULL, + 0xffffffffb9cf8b80ULL, + 0xfffffffffffee73eULL, + 0x000000005e31e24eULL, + 0x00000000005e31e2ULL, + 0x000000005e31e24eULL, + 0x00000000000178c7ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_SRAV(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_SRAV(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} diff --git a/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_srlv.c b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_srlv.c new file mode 100644 index 0000000000..8b8075ca40 --- /dev/null +++ b/tests/tcg/mips/user/isa/mips64r6/shift/test_mips64r6_srlv.c @@ -0,0 +1,151 @@ +/* + * Test program for MIPS64R6 instruction SRLV + * + * Copyright (C) 2019 Wave Computing, Inc. + * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +#include <sys/time.h> +#include <stdint.h> + +#include "../../../../include/wrappers_mips64r6.h" +#include "../../../../include/test_inputs_64.h" +#include "../../../../include/test_utils_64.h" + +#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT) + + +int32_t main(void) +{ + char *instruction_name = "SRLV"; + int32_t ret; + uint32_t i, j; + struct timeval start, end; + double elapsed_time; + + uint64_t b64_result[TEST_COUNT_TOTAL]; + uint64_t b64_expect[TEST_COUNT_TOTAL] = { + 0x0000000000000001ULL, /* 0 */ + 0xffffffffffffffffULL, + 0x00000000003fffffULL, + 0x00000000000007ffULL, + 0x00000000000fffffULL, + 0x0000000000001fffULL, + 0x000000000003ffffULL, + 0x0000000000007fffULL, + 0x0000000000000000ULL, /* 8 */ + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000000ULL, + 0x0000000000000001ULL, /* 16 */ + 0xffffffffaaaaaaaaULL, + 0x00000000002aaaaaULL, + 0x0000000000000555ULL, + 0x00000000000aaaaaULL, + 0x0000000000001555ULL, + 0x000000000002aaaaULL, + 0x0000000000005555ULL, + 0x0000000000000000ULL, /* 24 */ + 0x0000000055555555ULL, + 0x0000000000155555ULL, + 0x00000000000002aaULL, + 0x0000000000055555ULL, + 0x0000000000000aaaULL, + 0x0000000000015555ULL, + 0x0000000000002aaaULL, + 0x0000000000000001ULL, /* 32 */ + 0xffffffffccccccccULL, + 0x0000000000333333ULL, + 0x0000000000000666ULL, + 0x00000000000cccccULL, + 0x0000000000001999ULL, + 0x0000000000033333ULL, + 0x0000000000006666ULL, + 0x0000000000000000ULL, /* 40 */ + 0x0000000033333333ULL, + 0x00000000000cccccULL, + 0x0000000000000199ULL, + 0x0000000000033333ULL, + 0x0000000000000666ULL, + 0x000000000000ccccULL, + 0x0000000000001999ULL, + 0x0000000000000001ULL, /* 48 */ + 0xffffffff8e38e38eULL, + 0x0000000000238e38ULL, + 0x0000000000000471ULL, + 0x000000000008e38eULL, + 0x00000000000011c7ULL, + 0x00000000000238e3ULL, + 0x000000000000471cULL, + 0x0000000000000000ULL, /* 56 */ + 0x0000000071c71c71ULL, + 0x00000000001c71c7ULL, + 0x000000000000038eULL, + 0x0000000000071c71ULL, + 0x0000000000000e38ULL, + 0x000000000001c71cULL, + 0x00000000000038e3ULL, + 0x0000000028625540ULL, /* 64 */ + 0x0000000000286255ULL, + 0x0000000028625540ULL, + 0x000000000000a189ULL, + 0x000000004d93c708ULL, + 0x00000000004d93c7ULL, + 0x000000004d93c708ULL, + 0x000000000001364fULL, + 0xffffffffb9cf8b80ULL, /* 72 */ + 0x0000000000b9cf8bULL, + 0xffffffffb9cf8b80ULL, + 0x000000000002e73eULL, + 0x000000005e31e24eULL, + 0x00000000005e31e2ULL, + 0x000000005e31e24eULL, + 0x00000000000178c7ULL, + }; + + gettimeofday(&start, NULL); + + for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_SRLV(b64_pattern + i, b64_pattern + j, + b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) { + for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) { + do_mips64r6_SRLV(b64_random + i, b64_random + j, + b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) * + (PATTERN_INPUTS_64_SHORT_COUNT)) + + RANDOM_INPUTS_64_SHORT_COUNT * i + j)); + } + } + + gettimeofday(&end, NULL); + + elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; + elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; + + ret = check_results_64(instruction_name, TEST_COUNT_TOTAL, elapsed_time, + b64_result, b64_expect); + + return ret; +} |