CpuTestSimdLogical32.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 (Opcodes)"
  12. private static uint[] _Vbif_Vbit_Vbsl_Vand_Vorr_Veor_()
  13. {
  14. return new uint[]
  15. {
  16. 0xf3300110u, // VBIF D0, D0, D0
  17. 0xf3200110u, // VBIT D0, D0, D0
  18. 0xf3100110u, // VBSL D0, D0, D0
  19. 0xf2000110u, // VAND D0, D0, D0
  20. 0xf2200110u, // VORR D0, D0, D0
  21. 0xf3000110u // VEOR D0, D0, D0
  22. };
  23. }
  24. #endregion
  25. private const int RndCnt = 2;
  26. [Test, Pairwise]
  27. public void Vbif_Vbit_Vbsl_Vand_Vorr_Veor([ValueSource("_Vbif_Vbit_Vbsl_Vand_Vorr_Veor_")] uint opcode,
  28. [Range(0u, 4u)] uint rd,
  29. [Range(0u, 4u)] uint rn,
  30. [Range(0u, 4u)] uint rm,
  31. [Random(RndCnt)] ulong z,
  32. [Random(RndCnt)] ulong a,
  33. [Random(RndCnt)] ulong b,
  34. [Values] bool q)
  35. {
  36. if (q)
  37. {
  38. opcode |= 1 << 6;
  39. rm <<= 1;
  40. rn <<= 1;
  41. rd <<= 1;
  42. }
  43. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  44. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  45. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  46. V128 v0 = MakeVectorE0E1(z, z);
  47. V128 v1 = MakeVectorE0E1(a, z);
  48. V128 v2 = MakeVectorE0E1(b, z);
  49. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  50. CompareAgainstUnicorn();
  51. }
  52. [Test, Pairwise, Description("VORR.I32 <Vd>, #<imm>")]
  53. public void Vorr_II([Range(0u, 4u)] uint rd,
  54. [Random(RndCnt)] ulong z,
  55. [Random(RndCnt)] byte imm,
  56. [Values(0u, 1u, 2u, 3u)] uint cMode,
  57. [Values] bool q)
  58. {
  59. uint opcode = 0xf2800110u; // VORR.I32 D0, #0
  60. if (q)
  61. {
  62. opcode |= 1 << 6;
  63. rd <<= 1;
  64. }
  65. opcode |= (uint)(imm & 0xf) << 0;
  66. opcode |= (uint)(imm & 0x70) << 12;
  67. opcode |= (uint)(imm & 0x80) << 17;
  68. opcode |= (cMode & 0x3) << 9;
  69. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  70. V128 v0 = MakeVectorE0E1(z, z);
  71. SingleOpcode(opcode, v0: v0);
  72. CompareAgainstUnicorn();
  73. }
  74. #endif
  75. }
  76. }