diff options
author | Fredrik Noring <noring@nocrew.org> | 2018-10-21 17:41:32 +0200 |
---|---|---|
committer | Aleksandar Markovic <amarkovic@wavecomp.com> | 2018-10-24 15:20:31 +0200 |
commit | bec4d66b2488c58e36554c70466c0e09d99c0888 (patch) | |
tree | ca2bb7abe6cc8b17f163ebd36a4d2f2b704e38bc /tests | |
parent | cb56125eea7710a84703a3d274c7bcc38f180175 (diff) | |
download | qemu-bec4d66b2488c58e36554c70466c0e09d99c0888.zip qemu-bec4d66b2488c58e36554c70466c0e09d99c0888.tar.gz qemu-bec4d66b2488c58e36554c70466c0e09d99c0888.tar.bz2 |
tests/tcg/mips: Add tests for R5900 three-operand MULTU1
Add a test for MULTU1.
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')
-rw-r--r-- | tests/tcg/mips/mipsr5900/multu.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/tests/tcg/mips/mipsr5900/multu.c b/tests/tcg/mips/mipsr5900/multu.c index 3a59675..f043904 100644 --- a/tests/tcg/mips/mipsr5900/multu.c +++ b/tests/tcg/mips/mipsr5900/multu.c @@ -1,5 +1,5 @@ /* - * Test R5900-specific three-operand MULTU. + * Test R5900-specific three-operand MULTU and MULTU1. */ #include <stdio.h> @@ -25,15 +25,44 @@ static uint64_t multu(uint32_t rs, uint32_t rt) return r; } +static uint64_t multu1(uint32_t rs, uint32_t rt) +{ + uint32_t rd, lo, hi; + uint64_t r; + + __asm__ __volatile__ ( + " multu1 %0, %3, %4\n" + " mflo1 %1\n" + " mfhi1 %2\n" + : "=r" (rd), "=r" (lo), "=r" (hi) + : "r" (rs), "r" (rt)); + r = ((uint64_t)hi << 32) | (uint32_t)lo; + + assert((uint64_t)rs * rt == r); + assert(rd == lo); + + return r; +} + +static uint64_t multu_variants(uint32_t rs, uint32_t rt) +{ + uint64_t rd = multu(rs, rt); + uint64_t rd1 = multu1(rs, rt); + + assert(rd == rd1); + + return rd; +} + int main() { - assert(multu(17, 19) == 323); - assert(multu(77773, 99991) == 7776600043); - assert(multu(12207031, 305175781) == 3725290219116211); + assert(multu_variants(17, 19) == 323); + assert(multu_variants(77773, 99991) == 7776600043); + assert(multu_variants(12207031, 305175781) == 3725290219116211); - assert(multu(0x80000000U, 0x7FFFFFFF) == 0x3FFFFFFF80000000); - assert(multu(0x80000000U, 0x80000000U) == 0x4000000000000000); - assert(multu(0xFFFFFFFFU, 0xFFFFFFFFU) == 0xFFFFFFFE00000001U); + assert(multu_variants(0x80000000U, 0x7FFFFFFF) == 0x3FFFFFFF80000000); + assert(multu_variants(0x80000000U, 0x80000000U) == 0x4000000000000000); + assert(multu_variants(0xFFFFFFFFU, 0xFFFFFFFFU) == 0xFFFFFFFE00000001U); return 0; } |