CpuTestAlu.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #define Alu
  2. using NUnit.Framework;
  3. namespace Ryujinx.Tests.Cpu
  4. {
  5. [Category("Alu")]
  6. public sealed class CpuTestAlu : CpuTest
  7. {
  8. #if Alu
  9. private const int RndCnt = 2;
  10. [Test, Pairwise, Description("CLS <Xd>, <Xn>")]
  11. public void Cls_64bit([Values(0u, 31u)] uint rd,
  12. [Values(1u, 31u)] uint rn,
  13. [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
  14. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong xn)
  15. {
  16. uint opcode = 0xDAC01400; // CLS X0, X0
  17. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  18. ulong x31 = TestContext.CurrentContext.Random.NextULong();
  19. SingleOpcode(opcode, x1: xn, x31: x31);
  20. CompareAgainstUnicorn();
  21. }
  22. [Test, Pairwise, Description("CLS <Wd>, <Wn>")]
  23. public void Cls_32bit([Values(0u, 31u)] uint rd,
  24. [Values(1u, 31u)] uint rn,
  25. [Values(0x00000000u, 0x7FFFFFFFu,
  26. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn)
  27. {
  28. uint opcode = 0x5AC01400; // CLS W0, W0
  29. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  30. uint w31 = TestContext.CurrentContext.Random.NextUInt();
  31. SingleOpcode(opcode, x1: wn, x31: w31);
  32. CompareAgainstUnicorn();
  33. }
  34. [Test, Pairwise, Description("CLZ <Xd>, <Xn>")]
  35. public void Clz_64bit([Values(0u, 31u)] uint rd,
  36. [Values(1u, 31u)] uint rn,
  37. [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
  38. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong xn)
  39. {
  40. uint opcode = 0xDAC01000; // CLZ X0, X0
  41. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  42. ulong x31 = TestContext.CurrentContext.Random.NextULong();
  43. SingleOpcode(opcode, x1: xn, x31: x31);
  44. CompareAgainstUnicorn();
  45. }
  46. [Test, Pairwise, Description("CLZ <Wd>, <Wn>")]
  47. public void Clz_32bit([Values(0u, 31u)] uint rd,
  48. [Values(1u, 31u)] uint rn,
  49. [Values(0x00000000u, 0x7FFFFFFFu,
  50. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn)
  51. {
  52. uint opcode = 0x5AC01000; // CLZ W0, W0
  53. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  54. uint w31 = TestContext.CurrentContext.Random.NextUInt();
  55. SingleOpcode(opcode, x1: wn, x31: w31);
  56. CompareAgainstUnicorn();
  57. }
  58. [Test, Pairwise, Description("RBIT <Xd>, <Xn>")]
  59. public void Rbit_64bit([Values(0u, 31u)] uint rd,
  60. [Values(1u, 31u)] uint rn,
  61. [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
  62. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong xn)
  63. {
  64. uint opcode = 0xDAC00000; // RBIT X0, X0
  65. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  66. ulong x31 = TestContext.CurrentContext.Random.NextULong();
  67. SingleOpcode(opcode, x1: xn, x31: x31);
  68. CompareAgainstUnicorn();
  69. }
  70. [Test, Pairwise, Description("RBIT <Wd>, <Wn>")]
  71. public void Rbit_32bit([Values(0u, 31u)] uint rd,
  72. [Values(1u, 31u)] uint rn,
  73. [Values(0x00000000u, 0x7FFFFFFFu,
  74. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn)
  75. {
  76. uint opcode = 0x5AC00000; // RBIT W0, W0
  77. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  78. uint w31 = TestContext.CurrentContext.Random.NextUInt();
  79. SingleOpcode(opcode, x1: wn, x31: w31);
  80. CompareAgainstUnicorn();
  81. }
  82. [Test, Pairwise, Description("REV16 <Xd>, <Xn>")]
  83. public void Rev16_64bit([Values(0u, 31u)] uint rd,
  84. [Values(1u, 31u)] uint rn,
  85. [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
  86. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong xn)
  87. {
  88. uint opcode = 0xDAC00400; // REV16 X0, X0
  89. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  90. ulong x31 = TestContext.CurrentContext.Random.NextULong();
  91. SingleOpcode(opcode, x1: xn, x31: x31);
  92. CompareAgainstUnicorn();
  93. }
  94. [Test, Pairwise, Description("REV16 <Wd>, <Wn>")]
  95. public void Rev16_32bit([Values(0u, 31u)] uint rd,
  96. [Values(1u, 31u)] uint rn,
  97. [Values(0x00000000u, 0x7FFFFFFFu,
  98. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn)
  99. {
  100. uint opcode = 0x5AC00400; // REV16 W0, W0
  101. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  102. uint w31 = TestContext.CurrentContext.Random.NextUInt();
  103. SingleOpcode(opcode, x1: wn, x31: w31);
  104. CompareAgainstUnicorn();
  105. }
  106. [Test, Pairwise, Description("REV32 <Xd>, <Xn>")]
  107. public void Rev32_64bit([Values(0u, 31u)] uint rd,
  108. [Values(1u, 31u)] uint rn,
  109. [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
  110. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong xn)
  111. {
  112. uint opcode = 0xDAC00800; // REV32 X0, X0
  113. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  114. ulong x31 = TestContext.CurrentContext.Random.NextULong();
  115. SingleOpcode(opcode, x1: xn, x31: x31);
  116. CompareAgainstUnicorn();
  117. }
  118. [Test, Pairwise, Description("REV <Wd>, <Wn>")]
  119. public void Rev32_32bit([Values(0u, 31u)] uint rd,
  120. [Values(1u, 31u)] uint rn,
  121. [Values(0x00000000u, 0x7FFFFFFFu,
  122. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn)
  123. {
  124. uint opcode = 0x5AC00800; // REV W0, W0
  125. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  126. uint w31 = TestContext.CurrentContext.Random.NextUInt();
  127. SingleOpcode(opcode, x1: wn, x31: w31);
  128. CompareAgainstUnicorn();
  129. }
  130. [Test, Pairwise, Description("REV64 <Xd>, <Xn>")]
  131. public void Rev64_64bit([Values(0u, 31u)] uint rd,
  132. [Values(1u, 31u)] uint rn,
  133. [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
  134. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] [Random(RndCnt)] ulong xn)
  135. {
  136. uint opcode = 0xDAC00C00; // REV64 X0, X0
  137. opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
  138. ulong x31 = TestContext.CurrentContext.Random.NextULong();
  139. SingleOpcode(opcode, x1: xn, x31: x31);
  140. CompareAgainstUnicorn();
  141. }
  142. #endif
  143. }
  144. }