2018-09-08 19:23:07 +02:00
|
|
|
#define Mul
|
2018-04-18 22:22:45 +02:00
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace Ryujinx.Tests.Cpu
|
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
[Category("Mul")]
|
2018-04-18 22:22:45 +02:00
|
|
|
public sealed class CpuTestMul : CpuTest
|
|
|
|
{
|
|
|
|
#if Mul
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("MADD <Xd>, <Xn>, <Xm>, <Xa>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Madd_64bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
|
|
|
[Values(3u, 31u)] uint ra,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xa)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x9B000000; // MADD X0, X0, X0, X0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((ra & 31) << 10) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
ulong x31 = TestContext.CurrentContext.Random.NextULong();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: xn, x2: xm, x3: xa, x31: x31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("MADD <Wd>, <Wn>, <Wm>, <Wa>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Madd_32bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
|
|
|
[Values(3u, 31u)] uint ra,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wa)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x1B000000; // MADD W0, W0, W0, W0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((ra & 31) << 10) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
uint w31 = TestContext.CurrentContext.Random.NextUInt();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: wn, x2: wm, x3: wa, x31: w31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("MSUB <Xd>, <Xn>, <Xm>, <Xa>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Msub_64bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
|
|
|
[Values(3u, 31u)] uint ra,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xa)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x9B008000; // MSUB X0, X0, X0, X0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((ra & 31) << 10) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
ulong x31 = TestContext.CurrentContext.Random.NextULong();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: xn, x2: xm, x3: xa, x31: x31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("MSUB <Wd>, <Wn>, <Wm>, <Wa>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Msub_32bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
|
|
|
[Values(3u, 31u)] uint ra,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wa)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x1B008000; // MSUB W0, W0, W0, W0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((ra & 31) << 10) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
uint w31 = TestContext.CurrentContext.Random.NextUInt();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: wn, x2: wm, x3: wa, x31: w31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("SMADDL <Xd>, <Wn>, <Wm>, <Xa>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Smaddl_64bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
|
|
|
[Values(3u, 31u)] uint ra,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xa)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x9B200000; // SMADDL X0, W0, W0, X0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((ra & 31) << 10) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
ulong x31 = TestContext.CurrentContext.Random.NextULong();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: wn, x2: wm, x3: xa, x31: x31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("UMADDL <Xd>, <Wn>, <Wm>, <Xa>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Umaddl_64bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
|
|
|
[Values(3u, 31u)] uint ra,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xa)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x9BA00000; // UMADDL X0, W0, W0, X0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((ra & 31) << 10) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
ulong x31 = TestContext.CurrentContext.Random.NextULong();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: wn, x2: wm, x3: xa, x31: x31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("SMSUBL <Xd>, <Wn>, <Wm>, <Xa>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Smsubl_64bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
|
|
|
[Values(3u, 31u)] uint ra,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xa)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x9B208000; // SMSUBL X0, W0, W0, X0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((ra & 31) << 10) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
ulong x31 = TestContext.CurrentContext.Random.NextULong();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: wn, x2: wm, x3: xa, x31: x31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("UMSUBL <Xd>, <Wn>, <Wm>, <Xa>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Umsubl_64bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
|
|
|
[Values(3u, 31u)] uint ra,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] uint wm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xa)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x9BA08000; // UMSUBL X0, W0, W0, X0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((ra & 31) << 10) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
ulong x31 = TestContext.CurrentContext.Random.NextULong();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: wn, x2: wm, x3: xa, x31: x31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("SMULH <Xd>, <Xn>, <Xm>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Smulh_64bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x9B407C00; // SMULH X0, X0, X0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
ulong x31 = TestContext.CurrentContext.Random.NextULong();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: xn, x2: xm, x31: x31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:23:07 +02:00
|
|
|
[Test, Pairwise, Description("UMULH <Xd>, <Xn>, <Xm>")]
|
2018-11-01 05:22:09 +01:00
|
|
|
public void Umulh_64bit([Values(0u, 31u)] uint rd,
|
|
|
|
[Values(1u, 31u)] uint rn,
|
|
|
|
[Values(2u, 31u)] uint rm,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
|
2018-04-18 22:22:45 +02:00
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2023-02-09 02:24:32 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm)
|
2018-04-18 22:22:45 +02:00
|
|
|
{
|
2018-11-01 05:22:09 +01:00
|
|
|
uint opcode = 0x9BC07C00; // UMULH X0, X0, X0
|
|
|
|
opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
ulong x31 = TestContext.CurrentContext.Random.NextULong();
|
2018-09-08 19:23:07 +02:00
|
|
|
|
2018-11-01 05:22:09 +01:00
|
|
|
SingleOpcode(opcode, x1: xn, x2: xm, x31: x31);
|
2018-04-18 22:22:45 +02:00
|
|
|
|
2018-09-01 16:24:05 +02:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 22:22:45 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2023-07-01 04:14:34 +02:00
|
|
|
}
|