CpuTestSimdIns.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #define SimdIns
  2. using ChocolArm64.State;
  3. using NUnit.Framework;
  4. using System.Runtime.Intrinsics;
  5. namespace Ryujinx.Tests.Cpu
  6. {
  7. [Category("SimdIns")] // Tested: second half of 2018.
  8. public sealed class CpuTestSimdIns : CpuTest
  9. {
  10. #if SimdIns
  11. #region "ValueSource"
  12. private static uint[] _W_()
  13. {
  14. return new uint[] { 0x00000000u, 0x0000007Fu,
  15. 0x00000080u, 0x000000FFu,
  16. 0x00007FFFu, 0x00008000u,
  17. 0x0000FFFFu, 0x7FFFFFFFu,
  18. 0x80000000u, 0xFFFFFFFFu };
  19. }
  20. private static ulong[] _X_()
  21. {
  22. return new ulong[] { 0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
  23. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul };
  24. }
  25. #endregion
  26. private const int RndCnt = 2;
  27. [Test, Pairwise, Description("DUP <Vd>.<T>, <R><n>")]
  28. public void Dup_Gp_W([Values(0u)] uint Rd,
  29. [Values(1u, 31u)] uint Rn,
  30. [ValueSource("_W_")] [Random(RndCnt)] uint Wn,
  31. [Values(0, 1, 2)] int Size, // Q0: <8B, 4H, 2S>
  32. [Values(0b0u, 0b1u)] uint Q) // Q1: <16B, 8H, 4S>
  33. {
  34. uint Imm5 = (1U << Size) & 0x1F;
  35. uint Opcode = 0x0E000C00; // RESERVED
  36. Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
  37. Opcode |= (Imm5 << 16);
  38. Opcode |= ((Q & 1) << 30);
  39. ulong Z = TestContext.CurrentContext.Random.NextULong();
  40. Vector128<float> V0 = MakeVectorE0E1(Z, Z);
  41. AThreadState ThreadState = SingleOpcode(Opcode, X1: Wn, V0: V0);
  42. CompareAgainstUnicorn();
  43. }
  44. [Test, Pairwise, Description("DUP <Vd>.<T>, <R><n>")]
  45. public void Dup_Gp_X([Values(0u)] uint Rd,
  46. [Values(1u, 31u)] uint Rn,
  47. [ValueSource("_X_")] [Random(RndCnt)] ulong Xn)
  48. {
  49. uint Opcode = 0x4E080C00; // DUP V0.2D, X0
  50. Opcode |= ((Rn & 31) << 5) | ((Rd & 31) << 0);
  51. ulong Z = TestContext.CurrentContext.Random.NextULong();
  52. Vector128<float> V0 = MakeVectorE0E1(Z, Z);
  53. AThreadState ThreadState = SingleOpcode(Opcode, X1: Xn, V0: V0);
  54. CompareAgainstUnicorn();
  55. }
  56. #endif
  57. }
  58. }