CpuTestMov.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #define Mov
  2. using NUnit.Framework;
  3. namespace Ryujinx.Tests.Cpu
  4. {
  5. [Category("Mov")]
  6. public sealed class CpuTestMov : CpuTest
  7. {
  8. #if Mov
  9. private const int RndCnt = 2;
  10. private const int RndCntImm = 2;
  11. [Test, Pairwise, Description("MOVK <Xd>, #<imm>{, LSL #<shift>}")]
  12. public void Movk_64bit([Values(0u, 31u)] uint rd,
  13. [Random(RndCnt)] ulong xd,
  14. [Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
  15. [Values(0u, 16u, 32u, 48u)] uint shift)
  16. {
  17. uint opcode = 0xF2800000; // MOVK X0, #0, LSL #0
  18. opcode |= ((rd & 31) << 0);
  19. opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
  20. ulong x31 = TestContext.CurrentContext.Random.NextULong();
  21. SingleOpcode(opcode, x0: xd, x31: x31);
  22. CompareAgainstUnicorn();
  23. }
  24. [Test, Pairwise, Description("MOVK <Wd>, #<imm>{, LSL #<shift>}")]
  25. public void Movk_32bit([Values(0u, 31u)] uint rd,
  26. [Random(RndCnt)] uint wd,
  27. [Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
  28. [Values(0u, 16u)] uint shift)
  29. {
  30. uint opcode = 0x72800000; // MOVK W0, #0, LSL #0
  31. opcode |= ((rd & 31) << 0);
  32. opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
  33. uint w31 = TestContext.CurrentContext.Random.NextUInt();
  34. SingleOpcode(opcode, x0: wd, x31: w31);
  35. CompareAgainstUnicorn();
  36. }
  37. [Test, Pairwise, Description("MOVN <Xd>, #<imm>{, LSL #<shift>}")]
  38. public void Movn_64bit([Values(0u, 31u)] uint rd,
  39. [Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
  40. [Values(0u, 16u, 32u, 48u)] uint shift)
  41. {
  42. uint opcode = 0x92800000; // MOVN X0, #0, LSL #0
  43. opcode |= ((rd & 31) << 0);
  44. opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
  45. ulong x31 = TestContext.CurrentContext.Random.NextULong();
  46. SingleOpcode(opcode, x31: x31);
  47. CompareAgainstUnicorn();
  48. }
  49. [Test, Pairwise, Description("MOVN <Wd>, #<imm>{, LSL #<shift>}")]
  50. public void Movn_32bit([Values(0u, 31u)] uint rd,
  51. [Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
  52. [Values(0u, 16u)] uint shift)
  53. {
  54. uint opcode = 0x12800000; // MOVN W0, #0, LSL #0
  55. opcode |= ((rd & 31) << 0);
  56. opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
  57. uint w31 = TestContext.CurrentContext.Random.NextUInt();
  58. SingleOpcode(opcode, x31: w31);
  59. CompareAgainstUnicorn();
  60. }
  61. [Test, Pairwise, Description("MOVZ <Xd>, #<imm>{, LSL #<shift>}")]
  62. public void Movz_64bit([Values(0u, 31u)] uint rd,
  63. [Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
  64. [Values(0u, 16u, 32u, 48u)] uint shift)
  65. {
  66. uint opcode = 0xD2800000; // MOVZ X0, #0, LSL #0
  67. opcode |= ((rd & 31) << 0);
  68. opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
  69. ulong x31 = TestContext.CurrentContext.Random.NextULong();
  70. SingleOpcode(opcode, x31: x31);
  71. CompareAgainstUnicorn();
  72. }
  73. [Test, Pairwise, Description("MOVZ <Wd>, #<imm>{, LSL #<shift>}")]
  74. public void Movz_32bit([Values(0u, 31u)] uint rd,
  75. [Values(0u, 65535u)] [Random(0u, 65535u, RndCntImm)] uint imm,
  76. [Values(0u, 16u)] uint shift)
  77. {
  78. uint opcode = 0x52800000; // MOVZ W0, #0, LSL #0
  79. opcode |= ((rd & 31) << 0);
  80. opcode |= (((shift / 16) & 3) << 21) | ((imm & 65535) << 5);
  81. uint w31 = TestContext.CurrentContext.Random.NextUInt();
  82. SingleOpcode(opcode, x31: w31);
  83. CompareAgainstUnicorn();
  84. }
  85. #endif
  86. }
  87. }