CpuTestSimdLogical32.cs 2.7 KB

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