2018-09-08 17:23:07 +00:00
|
|
|
#define Mov
|
2018-04-18 20:22:45 +00:00
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
using ChocolArm64.State;
|
|
|
|
|
2018-04-18 20:22:45 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace Ryujinx.Tests.Cpu
|
|
|
|
{
|
2018-09-08 17:23:07 +00:00
|
|
|
[Category("Mov")] // Tested: second half of 2018.
|
2018-04-18 20:22:45 +00:00
|
|
|
public sealed class CpuTestMov : CpuTest
|
|
|
|
{
|
|
|
|
#if Mov
|
2018-09-08 17:23:07 +00:00
|
|
|
private const int RndCntImm = 2;
|
2018-04-18 20:22:45 +00:00
|
|
|
|
2018-09-08 17:23:07 +00:00
|
|
|
[Test, Pairwise, Description("MOVK <Xd>, #<imm>{, LSL #<shift>}")]
|
2018-04-18 20:22:45 +00:00
|
|
|
public void Movk_64bit([Values(0u, 31u)] uint Rd,
|
2018-09-08 17:23:07 +00:00
|
|
|
[Random(RndCntImm)] ulong _Xd,
|
|
|
|
[Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
|
2018-04-18 20:22:45 +00:00
|
|
|
[Values(0u, 16u, 32u, 48u)] uint shift)
|
|
|
|
{
|
|
|
|
uint Opcode = 0xF2800000; // MOVK X0, #0, LSL #0
|
|
|
|
Opcode |= ((Rd & 31) << 0);
|
|
|
|
Opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
|
|
|
|
|
|
|
|
ulong _X31 = TestContext.CurrentContext.Random.NextULong();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X0: _Xd, X31: _X31);
|
2018-04-18 20:22:45 +00:00
|
|
|
|
2018-09-01 14:24:05 +00:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 20:22:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 17:23:07 +00:00
|
|
|
[Test, Pairwise, Description("MOVK <Wd>, #<imm>{, LSL #<shift>}")]
|
2018-04-18 20:22:45 +00:00
|
|
|
public void Movk_32bit([Values(0u, 31u)] uint Rd,
|
2018-09-08 17:23:07 +00:00
|
|
|
[Random(RndCntImm)] uint _Wd,
|
|
|
|
[Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
|
2018-04-18 20:22:45 +00:00
|
|
|
[Values(0u, 16u)] uint shift)
|
|
|
|
{
|
|
|
|
uint Opcode = 0x72800000; // MOVK W0, #0, LSL #0
|
|
|
|
Opcode |= ((Rd & 31) << 0);
|
|
|
|
Opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
|
|
|
|
|
|
|
|
uint _W31 = TestContext.CurrentContext.Random.NextUInt();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X0: _Wd, X31: _W31);
|
2018-04-18 20:22:45 +00:00
|
|
|
|
2018-09-01 14:24:05 +00:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 20:22:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 17:23:07 +00:00
|
|
|
[Test, Pairwise, Description("MOVN <Xd>, #<imm>{, LSL #<shift>}")]
|
2018-04-18 20:22:45 +00:00
|
|
|
public void Movn_64bit([Values(0u, 31u)] uint Rd,
|
2018-09-08 17:23:07 +00:00
|
|
|
[Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
|
2018-04-18 20:22:45 +00:00
|
|
|
[Values(0u, 16u, 32u, 48u)] uint shift)
|
|
|
|
{
|
|
|
|
uint Opcode = 0x92800000; // MOVN X0, #0, LSL #0
|
|
|
|
Opcode |= ((Rd & 31) << 0);
|
|
|
|
Opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
|
|
|
|
|
|
|
|
ulong _X31 = TestContext.CurrentContext.Random.NextULong();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X31: _X31);
|
2018-04-18 20:22:45 +00:00
|
|
|
|
2018-09-01 14:24:05 +00:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 20:22:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 17:23:07 +00:00
|
|
|
[Test, Pairwise, Description("MOVN <Wd>, #<imm>{, LSL #<shift>}")]
|
2018-04-18 20:22:45 +00:00
|
|
|
public void Movn_32bit([Values(0u, 31u)] uint Rd,
|
2018-09-08 17:23:07 +00:00
|
|
|
[Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
|
2018-04-18 20:22:45 +00:00
|
|
|
[Values(0u, 16u)] uint shift)
|
|
|
|
{
|
|
|
|
uint Opcode = 0x12800000; // MOVN W0, #0, LSL #0
|
|
|
|
Opcode |= ((Rd & 31) << 0);
|
|
|
|
Opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
|
|
|
|
|
|
|
|
uint _W31 = TestContext.CurrentContext.Random.NextUInt();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X31: _W31);
|
2018-04-18 20:22:45 +00:00
|
|
|
|
2018-09-01 14:24:05 +00:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 20:22:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 17:23:07 +00:00
|
|
|
[Test, Pairwise, Description("MOVZ <Xd>, #<imm>{, LSL #<shift>}")]
|
2018-04-18 20:22:45 +00:00
|
|
|
public void Movz_64bit([Values(0u, 31u)] uint Rd,
|
2018-09-08 17:23:07 +00:00
|
|
|
[Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
|
2018-04-18 20:22:45 +00:00
|
|
|
[Values(0u, 16u, 32u, 48u)] uint shift)
|
|
|
|
{
|
|
|
|
uint Opcode = 0xD2800000; // MOVZ X0, #0, LSL #0
|
|
|
|
Opcode |= ((Rd & 31) << 0);
|
|
|
|
Opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
|
|
|
|
|
|
|
|
ulong _X31 = TestContext.CurrentContext.Random.NextULong();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X31: _X31);
|
2018-04-18 20:22:45 +00:00
|
|
|
|
2018-09-01 14:24:05 +00:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 20:22:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 17:23:07 +00:00
|
|
|
[Test, Pairwise, Description("MOVZ <Wd>, #<imm>{, LSL #<shift>}")]
|
2018-04-18 20:22:45 +00:00
|
|
|
public void Movz_32bit([Values(0u, 31u)] uint Rd,
|
2018-09-08 17:23:07 +00:00
|
|
|
[Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
|
2018-04-18 20:22:45 +00:00
|
|
|
[Values(0u, 16u)] uint shift)
|
|
|
|
{
|
|
|
|
uint Opcode = 0x52800000; // MOVZ W0, #0, LSL #0
|
|
|
|
Opcode |= ((Rd & 31) << 0);
|
|
|
|
Opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
|
|
|
|
|
|
|
|
uint _W31 = TestContext.CurrentContext.Random.NextUInt();
|
|
|
|
|
2018-10-31 01:43:02 +00:00
|
|
|
CpuThreadState ThreadState = SingleOpcode(Opcode, X31: _W31);
|
2018-04-18 20:22:45 +00:00
|
|
|
|
2018-09-01 14:24:05 +00:00
|
|
|
CompareAgainstUnicorn();
|
2018-04-18 20:22:45 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|