CpuTestSimdLogical32.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #define SimdLogical32
  2. using ARMeilleure.State;
  3. using NUnit.Framework;
  4. namespace Ryujinx.Tests.Cpu
  5. {
  6. [Category("SimdLogical32")]
  7. public sealed class CpuTestSimdLogical32 : CpuTest32
  8. {
  9. #if SimdLogical32
  10. #region "ValueSource (Types)"
  11. private static ulong[] _8B4H2S_()
  12. {
  13. return new[] { 0x0000000000000000ul, 0x7F7F7F7F7F7F7F7Ful,
  14. 0x8080808080808080ul, 0x7FFF7FFF7FFF7FFFul,
  15. 0x8000800080008000ul, 0x7FFFFFFF7FFFFFFFul,
  16. 0x8000000080000000ul, 0xFFFFFFFFFFFFFFFFul };
  17. }
  18. #endregion
  19. #region "ValueSource (Opcodes)"
  20. private static uint[] _Vbic_Vbif_Vbit_Vbsl_Vand_Vorn_Vorr_Veor_I_()
  21. {
  22. return new[]
  23. {
  24. 0xf2100110u, // VBIC D0, D0, D0
  25. 0xf3300110u, // VBIF D0, D0, D0
  26. 0xf3200110u, // VBIT D0, D0, D0
  27. 0xf3100110u, // VBSL D0, D0, D0
  28. 0xf2000110u, // VAND D0, D0, D0
  29. 0xf2300110u, // VORN D0, D0, D0
  30. 0xf2200110u, // VORR D0, D0, D0
  31. 0xf3000110u // VEOR D0, D0, D0
  32. };
  33. }
  34. private static uint[] _Vbic_Vorr_II_()
  35. {
  36. return new[]
  37. {
  38. 0xf2800130u, // VBIC.I32 D0, #0 (A1)
  39. 0xf2800930u, // VBIC.I16 D0, #0 (A2)
  40. 0xf2800110u, // VORR.I32 D0, #0 (A1)
  41. 0xf2800910u // VORR.I16 D0, #0 (A2)
  42. };
  43. }
  44. #endregion
  45. [Test, Pairwise]
  46. public void Vbic_Vbif_Vbit_Vbsl_Vand_Vorn_Vorr_Veor_I([ValueSource(nameof(_Vbic_Vbif_Vbit_Vbsl_Vand_Vorn_Vorr_Veor_I_))] uint opcode,
  47. [Range(0u, 5u)] uint rd,
  48. [Range(0u, 5u)] uint rn,
  49. [Range(0u, 5u)] uint rm,
  50. [Values(ulong.MinValue, ulong.MaxValue)] ulong z,
  51. [Values(ulong.MinValue, ulong.MaxValue)] ulong a,
  52. [Values(ulong.MinValue, ulong.MaxValue)] ulong b,
  53. [Values] bool q)
  54. {
  55. if (q)
  56. {
  57. opcode |= 1 << 6;
  58. rd >>= 1; rd <<= 1;
  59. rn >>= 1; rn <<= 1;
  60. rm >>= 1; rm <<= 1;
  61. }
  62. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  63. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  64. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  65. V128 v0 = MakeVectorE0E1(z, ~z);
  66. V128 v1 = MakeVectorE0E1(a, ~a);
  67. V128 v2 = MakeVectorE0E1(b, ~b);
  68. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  69. CompareAgainstUnicorn();
  70. }
  71. [Test, Pairwise]
  72. public void Vbic_Vorr_II([ValueSource(nameof(_Vbic_Vorr_II_))] uint opcode,
  73. [Values(0u, 1u)] uint rd,
  74. [Values(ulong.MinValue, ulong.MaxValue)] ulong z,
  75. [Values(byte.MinValue, byte.MaxValue)] byte imm,
  76. [Values(0u, 1u, 2u, 3u)] uint cMode,
  77. [Values] bool q)
  78. {
  79. if ((opcode & 0x800) != 0) // cmode<3> == '1' (A2)
  80. {
  81. cMode &= 1;
  82. }
  83. if (q)
  84. {
  85. opcode |= 1 << 6;
  86. rd >>= 1; rd <<= 1;
  87. }
  88. opcode |= ((uint)imm & 0xf) << 0;
  89. opcode |= ((uint)imm & 0x70) << 12;
  90. opcode |= ((uint)imm & 0x80) << 17;
  91. opcode |= (cMode & 0x3) << 9;
  92. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  93. V128 v0 = MakeVectorE0E1(z, ~z);
  94. SingleOpcode(opcode, v0: v0);
  95. CompareAgainstUnicorn();
  96. }
  97. [Test, Pairwise, Description("VTST.<dt> <Vd>, <Vn>, <Vm>")]
  98. public void Vtst([Range(0u, 5u)] uint rd,
  99. [Range(0u, 5u)] uint rn,
  100. [Range(0u, 5u)] uint rm,
  101. [ValueSource(nameof(_8B4H2S_))] ulong z,
  102. [ValueSource(nameof(_8B4H2S_))] ulong a,
  103. [ValueSource(nameof(_8B4H2S_))] ulong b,
  104. [Values(0u, 1u, 2u)] uint size,
  105. [Values] bool q)
  106. {
  107. uint opcode = 0xf2000810u; // VTST.8 D0, D0, D0
  108. if (q)
  109. {
  110. opcode |= 1 << 6;
  111. rd >>= 1; rd <<= 1;
  112. rn >>= 1; rn <<= 1;
  113. rm >>= 1; rm <<= 1;
  114. }
  115. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  116. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  117. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  118. opcode |= (size & 0x3) << 20;
  119. V128 v0 = MakeVectorE0E1(z, ~z);
  120. V128 v1 = MakeVectorE0E1(a, ~a);
  121. V128 v2 = MakeVectorE0E1(b, ~b);
  122. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  123. CompareAgainstUnicorn();
  124. }
  125. #endif
  126. }
  127. }