CpuTestSimdLogical32.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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_Vorn_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. 0xf2300110u, // VORN D0, D0, D0
  31. 0xf2200110u, // VORR D0, D0, D0
  32. 0xf3000110u // VEOR D0, D0, D0
  33. };
  34. }
  35. private static uint[] _Vbic_Vorr_II_()
  36. {
  37. return new uint[]
  38. {
  39. 0xf2800130u, // VBIC.I32 D0, #0 (A1)
  40. 0xf2800930u, // VBIC.I16 D0, #0 (A2)
  41. 0xf2800110u, // VORR.I32 D0, #0 (A1)
  42. 0xf2800910u // VORR.I16 D0, #0 (A2)
  43. };
  44. }
  45. #endregion
  46. private const int RndCnt = 2;
  47. [Test, Pairwise]
  48. public void Vbic_Vbif_Vbit_Vbsl_Vand_Vorn_Vorr_Veor_I([ValueSource("_Vbic_Vbif_Vbit_Vbsl_Vand_Vorn_Vorr_Veor_I_")] uint opcode,
  49. [Range(0u, 5u)] uint rd,
  50. [Range(0u, 5u)] uint rn,
  51. [Range(0u, 5u)] uint rm,
  52. [Values(ulong.MinValue, ulong.MaxValue)] [Random(RndCnt)] ulong z,
  53. [Values(ulong.MinValue, ulong.MaxValue)] [Random(RndCnt)] ulong a,
  54. [Values(ulong.MinValue, ulong.MaxValue)] [Random(RndCnt)] ulong b,
  55. [Values] bool q)
  56. {
  57. if (q)
  58. {
  59. opcode |= 1 << 6;
  60. rd >>= 1; rd <<= 1;
  61. rn >>= 1; rn <<= 1;
  62. rm >>= 1; rm <<= 1;
  63. }
  64. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  65. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  66. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  67. V128 v0 = MakeVectorE0E1(z, ~z);
  68. V128 v1 = MakeVectorE0E1(a, ~a);
  69. V128 v2 = MakeVectorE0E1(b, ~b);
  70. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  71. CompareAgainstUnicorn();
  72. }
  73. [Test, Pairwise]
  74. public void Vbic_Vorr_II([ValueSource("_Vbic_Vorr_II_")] uint opcode,
  75. [Values(0u, 1u)] uint rd,
  76. [Values(ulong.MinValue, ulong.MaxValue)] [Random(RndCnt)] ulong z,
  77. [Values(byte.MinValue, byte.MaxValue)] [Random(RndCnt)] byte imm,
  78. [Values(0u, 1u, 2u, 3u)] uint cMode,
  79. [Values] bool q)
  80. {
  81. if ((opcode & 0x800) != 0) // cmode<3> == '1' (A2)
  82. {
  83. cMode &= 1;
  84. }
  85. if (q)
  86. {
  87. opcode |= 1 << 6;
  88. rd >>= 1; rd <<= 1;
  89. }
  90. opcode |= ((uint)imm & 0xf) << 0;
  91. opcode |= ((uint)imm & 0x70) << 12;
  92. opcode |= ((uint)imm & 0x80) << 17;
  93. opcode |= (cMode & 0x3) << 9;
  94. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  95. V128 v0 = MakeVectorE0E1(z, ~z);
  96. SingleOpcode(opcode, v0: v0);
  97. CompareAgainstUnicorn();
  98. }
  99. [Test, Pairwise, Description("VTST.<dt> <Vd>, <Vn>, <Vm>")]
  100. public void Vtst([Range(0u, 5u)] uint rd,
  101. [Range(0u, 5u)] uint rn,
  102. [Range(0u, 5u)] uint rm,
  103. [ValueSource("_8B4H2S_")] [Random(RndCnt)] ulong z,
  104. [ValueSource("_8B4H2S_")] [Random(RndCnt)] ulong a,
  105. [ValueSource("_8B4H2S_")] [Random(RndCnt)] ulong b,
  106. [Values(0u, 1u, 2u)] uint size,
  107. [Values] bool q)
  108. {
  109. uint opcode = 0xf2000810u; // VTST.8 D0, D0, D0
  110. if (q)
  111. {
  112. opcode |= 1 << 6;
  113. rd >>= 1; rd <<= 1;
  114. rn >>= 1; rn <<= 1;
  115. rm >>= 1; rm <<= 1;
  116. }
  117. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  118. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  119. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  120. opcode |= (size & 0x3) << 20;
  121. V128 v0 = MakeVectorE0E1(z, ~z);
  122. V128 v1 = MakeVectorE0E1(a, ~a);
  123. V128 v2 = MakeVectorE0E1(b, ~b);
  124. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  125. CompareAgainstUnicorn();
  126. }
  127. #endif
  128. }
  129. }