2018-09-08 18:23:07 +01:00
|
|
|
#define Alu
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-06-18 18:55:26 +01:00
|
|
|
using ChocolArm64.State;
|
|
|
|
|
2018-02-16 00:04:38 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace Ryujinx.Tests.Cpu
|
|
|
|
{
|
2018-09-08 18:23:07 +01:00
|
|
|
[Category("Alu")] // Tested: second half of 2018.
|
2018-04-18 21:22:45 +01:00
|
|
|
public sealed class CpuTestAlu : CpuTest
|
2018-02-16 00:04:38 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
#if Alu
|
2018-09-08 18:23:07 +01:00
|
|
|
private const int RndCnt = 2;
|
2018-02-25 01:50:58 +00:00
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("CLS <Xd>, <Xn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Cls_64bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong Xn)
|
2018-02-25 01:50:58 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0xDAC01400; // CLS X0, X0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
ulong _X31 = TestContext.CurrentContext.Random.NextULong();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Xn, X31: _X31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-02-23 14:53:32 +00:00
|
|
|
}
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("CLS <Wd>, <Wn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Cls_32bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint Wn)
|
2018-02-16 00:04:38 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0x5AC01400; // CLS W0, W0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
uint _W31 = TestContext.CurrentContext.Random.NextUInt();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Wn, X31: _W31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("CLZ <Xd>, <Xn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Clz_64bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong Xn)
|
2018-02-25 01:50:58 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0xDAC01000; // CLZ X0, X0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
ulong _X31 = TestContext.CurrentContext.Random.NextULong();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Xn, X31: _X31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-02-25 01:50:58 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("CLZ <Wd>, <Wn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Clz_32bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint Wn)
|
2018-02-16 00:04:38 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0x5AC01000; // CLZ W0, W0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
uint _W31 = TestContext.CurrentContext.Random.NextUInt();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Wn, X31: _W31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("RBIT <Xd>, <Xn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Rbit_64bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong Xn)
|
2018-02-16 00:04:38 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0xDAC00000; // RBIT X0, X0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
ulong _X31 = TestContext.CurrentContext.Random.NextULong();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Xn, X31: _X31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-03-05 12:21:19 +00:00
|
|
|
}
|
2018-02-23 12:29:20 +00:00
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("RBIT <Wd>, <Wn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Rbit_32bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint Wn)
|
2018-03-05 12:21:19 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0x5AC00000; // RBIT W0, W0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
uint _W31 = TestContext.CurrentContext.Random.NextUInt();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Wn, X31: _W31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 21:22:45 +01:00
|
|
|
}
|
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("REV16 <Xd>, <Xn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Rev16_64bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong Xn)
|
2018-04-18 21:22:45 +01:00
|
|
|
{
|
|
|
|
uint Opcode = 0xDAC00400; // REV16 X0, X0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
ulong _X31 = TestContext.CurrentContext.Random.NextULong();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Xn, X31: _X31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-03-05 12:21:19 +00:00
|
|
|
}
|
2018-02-23 12:29:20 +00:00
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("REV16 <Wd>, <Wn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Rev16_32bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint Wn)
|
2018-03-05 12:21:19 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0x5AC00400; // REV16 W0, W0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
uint _W31 = TestContext.CurrentContext.Random.NextUInt();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Wn, X31: _W31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("REV32 <Xd>, <Xn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Rev32_64bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong Xn)
|
2018-02-16 00:04:38 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0xDAC00800; // REV32 X0, X0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
ulong _X31 = TestContext.CurrentContext.Random.NextULong();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Xn, X31: _X31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("REV <Wd>, <Wn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Rev32_32bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x00000000u, 0x7FFFFFFFu,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint Wn)
|
2018-02-16 00:04:38 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0x5AC00800; // REV W0, W0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
uint _W31 = TestContext.CurrentContext.Random.NextUInt();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Wn, X31: _W31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
2018-02-25 01:50:58 +00:00
|
|
|
|
2018-09-08 18:23:07 +01:00
|
|
|
[Test, Pairwise, Description("REV64 <Xd>, <Xn>")]
|
2018-04-18 21:22:45 +01:00
|
|
|
public void Rev64_64bit([Values(0u, 31u)] uint Rd,
|
|
|
|
[Values(1u, 31u)] uint Rn,
|
|
|
|
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
|
2018-09-08 18:23:07 +01:00
|
|
|
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong Xn)
|
2018-02-25 01:50:58 +00:00
|
|
|
{
|
2018-04-18 21:22:45 +01:00
|
|
|
uint Opcode = 0xDAC00C00; // REV64 X0, X0
|
|
|
|
Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
|
|
|
|
|
|
|
|
ulong _X31 = TestContext.CurrentContext.Random.NextULong();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X1: Xn, X31: _X31);
|
2018-04-18 21:22:45 +01:00
|
|
|
|
2018-09-01 15:24:05 +01:00
|
|
|
CompareAgainstUnicorn();
|
2018-02-25 01:50:58 +00:00
|
|
|
}
|
2018-04-18 21:22:45 +01:00
|
|
|
#endif
|
2018-02-16 00:04:38 +00:00
|
|
|
}
|
|
|
|
}
|