CpuTestMov.cs 4.1 KB

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