diff options
author | Fredrik Noring | 2018-10-21 17:41:21 +0200 |
---|---|---|
committer | Aleksandar Markovic | 2018-10-24 15:20:31 +0200 |
commit | cb56125eea7710a84703a3d274c7bcc38f180175 (patch) | |
tree | 638cf8fc0f0697132d0d20f229debedaf34c5cd8 /tests/tcg | |
parent | tests/tcg/mips: Add tests for R5900 three-operand MULTU (diff) | |
download | qemu-cb56125eea7710a84703a3d274c7bcc38f180175.tar.gz qemu-cb56125eea7710a84703a3d274c7bcc38f180175.tar.xz qemu-cb56125eea7710a84703a3d274c7bcc38f180175.zip |
tests/tcg/mips: Add tests for R5900 three-operand MULT1
Add a test for MULT1.
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Fredrik Noring <noring@nocrew.org>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Diffstat (limited to 'tests/tcg')
-rw-r--r-- | tests/tcg/mips/mipsr5900/mult.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/tests/tcg/mips/mipsr5900/mult.c b/tests/tcg/mips/mipsr5900/mult.c index 2c0c16d232..5710b395e6 100644 --- a/tests/tcg/mips/mipsr5900/mult.c +++ b/tests/tcg/mips/mipsr5900/mult.c @@ -1,5 +1,5 @@ /* - * Test R5900-specific three-operand MULT. + * Test R5900-specific three-operand MULT and MULT1. */ #include <stdio.h> @@ -25,12 +25,41 @@ static int64_t mult(int32_t rs, int32_t rt) return r; } +static int64_t mult1(int32_t rs, int32_t rt) +{ + int32_t rd, lo, hi; + int64_t r; + + __asm__ __volatile__ ( + " mult1 %0, %3, %4\n" + " mflo1 %1\n" + " mfhi1 %2\n" + : "=r" (rd), "=r" (lo), "=r" (hi) + : "r" (rs), "r" (rt)); + r = ((int64_t)hi << 32) | (uint32_t)lo; + + assert((int64_t)rs * rt == r); + assert(rd == lo); + + return r; +} + +static int64_t mult_variants(int32_t rs, int32_t rt) +{ + int64_t rd = mult(rs, rt); + int64_t rd1 = mult1(rs, rt); + + assert(rd == rd1); + + return rd; +} + static void verify_mult_negations(int32_t rs, int32_t rt, int64_t expected) { - assert(mult(rs, rt) == expected); - assert(mult(-rs, rt) == -expected); - assert(mult(rs, -rt) == -expected); - assert(mult(-rs, -rt) == expected); + assert(mult_variants(rs, rt) == expected); + assert(mult_variants(-rs, rt) == -expected); + assert(mult_variants(rs, -rt) == -expected); + assert(mult_variants(-rs, -rt) == expected); } int main() @@ -39,9 +68,9 @@ int main() verify_mult_negations(77773, 99991, 7776600043); verify_mult_negations(12207031, 305175781, 3725290219116211); - assert(mult(-0x80000000, 0x7FFFFFFF) == -0x3FFFFFFF80000000); - assert(mult(-0x80000000, -0x7FFFFFFF) == 0x3FFFFFFF80000000); - assert(mult(-0x80000000, -0x80000000) == 0x4000000000000000); + assert(mult_variants(-0x80000000, 0x7FFFFFFF) == -0x3FFFFFFF80000000); + assert(mult_variants(-0x80000000, -0x7FFFFFFF) == 0x3FFFFFFF80000000); + assert(mult_variants(-0x80000000, -0x80000000) == 0x4000000000000000); return 0; } |