CpuTestSimdLogical32.cs 5.3 KB

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