diff --git a/Ryujinx.Tests/Cpu/CpuTestSimd.cs b/Ryujinx.Tests/Cpu/CpuTestSimd.cs index 54889eee34..6a2b96b79d 100644 --- a/Ryujinx.Tests/Cpu/CpuTestSimd.cs +++ b/Ryujinx.Tests/Cpu/CpuTestSimd.cs @@ -256,6 +256,112 @@ namespace Ryujinx.Tests.Cpu #endregion #region "ValueSource (Opcodes)" + private static uint[] _F_Abs_Neg_Recpx_Sqrt_S_S_() + { + return new uint[] + { + 0x1E20C020u, // FABS S0, S1 + 0x1E214020u, // FNEG S0, S1 + 0x5EA1F820u, // FRECPX S0, S1 + 0x1E21C020u // FSQRT S0, S1 + }; + } + + private static uint[] _F_Abs_Neg_Recpx_Sqrt_S_D_() + { + return new uint[] + { + 0x1E60C020u, // FABS D0, D1 + 0x1E614020u, // FNEG D0, D1 + 0x5EE1F820u, // FRECPX D0, D1 + 0x1E61C020u // FSQRT D0, D1 + }; + } + + private static uint[] _F_Abs_Neg_Sqrt_V_2S_4S_() + { + return new uint[] + { + 0x0EA0F800u, // FABS V0.2S, V0.2S + 0x2EA0F800u, // FNEG V0.2S, V0.2S + 0x2EA1F800u // FSQRT V0.2S, V0.2S + }; + } + + private static uint[] _F_Abs_Neg_Sqrt_V_2D_() + { + return new uint[] + { + 0x4EE0F800u, // FABS V0.2D, V0.2D + 0x6EE0F800u, // FNEG V0.2D, V0.2D + 0x6EE1F800u // FSQRT V0.2D, V0.2D + }; + } + + private static uint[] _F_Add_P_S_2SS_() + { + return new uint[] + { + 0x7E30D820u // FADDP S0, V1.2S + }; + } + + private static uint[] _F_Add_P_S_2DD_() + { + return new uint[] + { + 0x7E70D820u // FADDP D0, V1.2D + }; + } + + private static uint[] _F_Cm_EqGeGtLeLt_S_S_() + { + return new uint[] + { + 0x5EA0D820u, // FCMEQ S0, S1, #0.0 + 0x7EA0C820u, // FCMGE S0, S1, #0.0 + 0x5EA0C820u, // FCMGT S0, S1, #0.0 + 0x7EA0D820u, // FCMLE S0, S1, #0.0 + 0x5EA0E820u // FCMLT S0, S1, #0.0 + }; + } + + private static uint[] _F_Cm_EqGeGtLeLt_S_D_() + { + return new uint[] + { + 0x5EE0D820u, // FCMEQ D0, D1, #0.0 + 0x7EE0C820u, // FCMGE D0, D1, #0.0 + 0x5EE0C820u, // FCMGT D0, D1, #0.0 + 0x7EE0D820u, // FCMLE D0, D1, #0.0 + 0x5EE0E820u // FCMLT D0, D1, #0.0 + }; + } + + private static uint[] _F_Cm_EqGeGtLeLt_V_2S_4S_() + { + return new uint[] + { + 0x0EA0D800u, // FCMEQ V0.2S, V0.2S, #0.0 + 0x2EA0C800u, // FCMGE V0.2S, V0.2S, #0.0 + 0x0EA0C800u, // FCMGT V0.2S, V0.2S, #0.0 + 0x2EA0D800u, // FCMLE V0.2S, V0.2S, #0.0 + 0x0EA0E800u // FCMLT V0.2S, V0.2S, #0.0 + }; + } + + private static uint[] _F_Cm_EqGeGtLeLt_V_2D_() + { + return new uint[] + { + 0x4EE0D800u, // FCMEQ V0.2D, V0.2D, #0.0 + 0x6EE0C800u, // FCMGE V0.2D, V0.2D, #0.0 + 0x4EE0C800u, // FCMGT V0.2D, V0.2D, #0.0 + 0x6EE0D800u, // FCMLE V0.2D, V0.2D, #0.0 + 0x4EE0E800u // FCMLT V0.2D, V0.2D, #0.0 + }; + } + private static uint[] _F_Cmp_Cmpe_S_S_() { return new uint[] @@ -366,48 +472,6 @@ namespace Ryujinx.Tests.Cpu }; } - private static uint[] _F_Abs_Neg_Recpx_Sqrt_S_S_() - { - return new uint[] - { - 0x1E20C020u, // FABS S0, S1 - 0x1E214020u, // FNEG S0, S1 - 0x5EA1F820u, // FRECPX S0, S1 - 0x1E21C020u // FSQRT S0, S1 - }; - } - - private static uint[] _F_Abs_Neg_Recpx_Sqrt_S_D_() - { - return new uint[] - { - 0x1E60C020u, // FABS D0, D1 - 0x1E614020u, // FNEG D0, D1 - 0x5EE1F820u, // FRECPX D0, D1 - 0x1E61C020u // FSQRT D0, D1 - }; - } - - private static uint[] _F_Abs_Neg_Sqrt_V_2S_4S_() - { - return new uint[] - { - 0x0EA0F800u, // FABS V0.2S, V0.2S - 0x2EA0F800u, // FNEG V0.2S, V0.2S - 0x2EA1F800u // FSQRT V0.2S, V0.2S - }; - } - - private static uint[] _F_Abs_Neg_Sqrt_V_2D_() - { - return new uint[] - { - 0x4EE0F800u, // FABS V0.2D, V0.2D - 0x6EE0F800u, // FNEG V0.2D, V0.2D - 0x6EE1F800u // FSQRT V0.2D, V0.2D - }; - } - private static uint[] _SU_Cvt_F_S_S_() { return new uint[] @@ -963,6 +1027,202 @@ namespace Ryujinx.Tests.Cpu CompareAgainstUnicorn(); } + [Test, Pairwise] [Explicit] + public void F_Abs_Neg_Recpx_Sqrt_S_S([ValueSource("_F_Abs_Neg_Recpx_Sqrt_S_S_")] uint opcodes, + [ValueSource("_1S_F_")] ulong a) + { + ulong z = TestContext.CurrentContext.Random.NextULong(); + Vector128 v0 = MakeVectorE0E1(z, z); + Vector128 v1 = MakeVectorE0E1(a, z); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + fpcr |= rnd & (1 << (int)Fpcr.Dn); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + + [Test, Pairwise] [Explicit] + public void F_Abs_Neg_Recpx_Sqrt_S_D([ValueSource("_F_Abs_Neg_Recpx_Sqrt_S_D_")] uint opcodes, + [ValueSource("_1D_F_")] ulong a) + { + ulong z = TestContext.CurrentContext.Random.NextULong(); + Vector128 v0 = MakeVectorE1(z); + Vector128 v1 = MakeVectorE0E1(a, z); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + fpcr |= rnd & (1 << (int)Fpcr.Dn); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + + [Test, Pairwise] [Explicit] + public void F_Abs_Neg_Sqrt_V_2S_4S([ValueSource("_F_Abs_Neg_Sqrt_V_2S_4S_")] uint opcodes, + [Values(0u)] uint rd, + [Values(1u, 0u)] uint rn, + [ValueSource("_2S_F_")] ulong z, + [ValueSource("_2S_F_")] ulong a, + [Values(0b0u, 0b1u)] uint q) // <2S, 4S> + { + opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); + opcodes |= ((q & 1) << 30); + + Vector128 v0 = MakeVectorE0E1(z, z); + Vector128 v1 = MakeVectorE0E1(a, a * q); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + fpcr |= rnd & (1 << (int)Fpcr.Dn); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + + [Test, Pairwise] [Explicit] + public void F_Abs_Neg_Sqrt_V_2D([ValueSource("_F_Abs_Neg_Sqrt_V_2D_")] uint opcodes, + [Values(0u)] uint rd, + [Values(1u, 0u)] uint rn, + [ValueSource("_1D_F_")] ulong z, + [ValueSource("_1D_F_")] ulong a) + { + opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); + + Vector128 v0 = MakeVectorE0E1(z, z); + Vector128 v1 = MakeVectorE0E1(a, a); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + fpcr |= rnd & (1 << (int)Fpcr.Dn); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + + [Test, Pairwise] [Explicit] + public void F_Add_P_S_2SS([ValueSource("_F_Add_P_S_2SS_")] uint opcodes, + [ValueSource("_2S_F_")] ulong a) + { + ulong z = TestContext.CurrentContext.Random.NextULong(); + Vector128 v0 = MakeVectorE0E1(z, z); + Vector128 v1 = MakeVectorE0(a); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + fpcr |= rnd & (1 << (int)Fpcr.Dn); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + + [Test, Pairwise] [Explicit] + public void F_Add_P_S_2DD([ValueSource("_F_Add_P_S_2DD_")] uint opcodes, + [ValueSource("_1D_F_")] ulong a) + { + ulong z = TestContext.CurrentContext.Random.NextULong(); + Vector128 v0 = MakeVectorE1(z); + Vector128 v1 = MakeVectorE0E1(a, a); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + fpcr |= rnd & (1 << (int)Fpcr.Dn); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + + [Test, Pairwise] [Explicit] + public void F_Cm_EqGeGtLeLt_S_S([ValueSource("_F_Cm_EqGeGtLeLt_S_S_")] uint opcodes, + [ValueSource("_1S_F_")] ulong a) + { + ulong z = TestContext.CurrentContext.Random.NextULong(); + Vector128 v0 = MakeVectorE0E1(z, z); + Vector128 v1 = MakeVectorE0(a); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + + [Test, Pairwise] [Explicit] + public void F_Cm_EqGeGtLeLt_S_D([ValueSource("_F_Cm_EqGeGtLeLt_S_D_")] uint opcodes, + [ValueSource("_1D_F_")] ulong a) + { + ulong z = TestContext.CurrentContext.Random.NextULong(); + Vector128 v0 = MakeVectorE1(z); + Vector128 v1 = MakeVectorE0(a); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + + [Test, Pairwise] [Explicit] + public void F_Cm_EqGeGtLeLt_V_2S_4S([ValueSource("_F_Cm_EqGeGtLeLt_V_2S_4S_")] uint opcodes, + [Values(0u)] uint rd, + [Values(1u, 0u)] uint rn, + [ValueSource("_2S_F_")] ulong z, + [ValueSource("_2S_F_")] ulong a, + [Values(0b0u, 0b1u)] uint q) // <2S, 4S> + { + opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); + opcodes |= ((q & 1) << 30); + + Vector128 v0 = MakeVectorE0E1(z, z); + Vector128 v1 = MakeVectorE0E1(a, a * q); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + + [Test, Pairwise] [Explicit] + public void F_Cm_EqGeGtLeLt_V_2D([ValueSource("_F_Cm_EqGeGtLeLt_V_2D_")] uint opcodes, + [Values(0u)] uint rd, + [Values(1u, 0u)] uint rn, + [ValueSource("_1D_F_")] ulong z, + [ValueSource("_1D_F_")] ulong a) + { + opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); + + Vector128 v0 = MakeVectorE0E1(z, z); + Vector128 v1 = MakeVectorE0E1(a, a); + + int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); + + int fpcr = rnd & (1 << (int)Fpcr.Fz); + + SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); + + CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); + } + [Test, Pairwise] [Explicit] public void F_Cmp_Cmpe_S_S([ValueSource("_F_Cmp_Cmpe_S_S_")] uint opcodes, [ValueSource("_1S_F_")] ulong a) @@ -1089,13 +1349,13 @@ namespace Ryujinx.Tests.Cpu [Values(1u, 0u)] uint rn, [ValueSource("_4H_F_")] ulong z, [ValueSource("_4H_F_")] ulong a, - [Values(0b0u, 0b1u)] uint q, // <4H, 8H> + [Values(0b0u, 0b1u)] uint q, // <4H4S, 8H4S> [Values(RMode.Rn)] RMode rMode) { opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); opcodes |= ((q & 1) << 30); - Vector128 v0 = MakeVectorE0E1(q == 0u ? z : 0ul, q == 1u ? z : 0ul); + Vector128 v0 = MakeVectorE0E1(z, z); Vector128 v1 = MakeVectorE0E1(q == 0u ? a : 0ul, q == 1u ? a : 0ul); int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); @@ -1116,12 +1376,12 @@ namespace Ryujinx.Tests.Cpu [Values(1u, 0u)] uint rn, [ValueSource("_2S_F_")] ulong z, [ValueSource("_2S_F_")] ulong a, - [Values(0b0u, 0b1u)] uint q) // <2S, 4S> + [Values(0b0u, 0b1u)] uint q) // <2S2D, 4S2D> { opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); opcodes |= ((q & 1) << 30); - Vector128 v0 = MakeVectorE0E1(q == 0u ? z : 0ul, q == 1u ? z : 0ul); + Vector128 v0 = MakeVectorE0E1(z, z); Vector128 v1 = MakeVectorE0E1(q == 0u ? a : 0ul, q == 1u ? a : 0ul); SingleOpcode(opcodes, v0: v0, v1: v1); @@ -1135,7 +1395,7 @@ namespace Ryujinx.Tests.Cpu [Values(1u, 0u)] uint rn, [ValueSource("_2S_F_")] ulong z, [ValueSource("_2S_F_")] ulong a, - [Values(0b0u, 0b1u)] uint q, // <4H, 8H> + [Values(0b0u, 0b1u)] uint q, // <4S4H, 4S8H> [Values(RMode.Rn)] RMode rMode) { opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); @@ -1162,7 +1422,7 @@ namespace Ryujinx.Tests.Cpu [Values(1u, 0u)] uint rn, [ValueSource("_1D_F_")] ulong z, [ValueSource("_1D_F_")] ulong a, - [Values(0b0u, 0b1u)] uint q) // <2S, 4S> + [Values(0b0u, 0b1u)] uint q) // <2D2S, 2D4S> { opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); opcodes |= ((q & 1) << 30); @@ -1175,88 +1435,6 @@ namespace Ryujinx.Tests.Cpu CompareAgainstUnicorn(); } - [Test, Pairwise] [Explicit] - public void F_Abs_Neg_Recpx_Sqrt_S_S([ValueSource("_F_Abs_Neg_Recpx_Sqrt_S_S_")] uint opcodes, - [ValueSource("_1S_F_")] ulong a) - { - ulong z = TestContext.CurrentContext.Random.NextULong(); - Vector128 v0 = MakeVectorE0E1(z, z); - Vector128 v1 = MakeVectorE0E1(a, z); - - int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); - - int fpcr = rnd & (1 << (int)Fpcr.Fz); - fpcr |= rnd & (1 << (int)Fpcr.Dn); - - SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); - - CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); - } - - [Test, Pairwise] [Explicit] - public void F_Abs_Neg_Recpx_Sqrt_S_D([ValueSource("_F_Abs_Neg_Recpx_Sqrt_S_D_")] uint opcodes, - [ValueSource("_1D_F_")] ulong a) - { - ulong z = TestContext.CurrentContext.Random.NextULong(); - Vector128 v0 = MakeVectorE1(z); - Vector128 v1 = MakeVectorE0E1(a, z); - - int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); - - int fpcr = rnd & (1 << (int)Fpcr.Fz); - fpcr |= rnd & (1 << (int)Fpcr.Dn); - - SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); - - CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); - } - - [Test, Pairwise] [Explicit] - public void F_Abs_Neg_Sqrt_V_2S_4S([ValueSource("_F_Abs_Neg_Sqrt_V_2S_4S_")] uint opcodes, - [Values(0u)] uint rd, - [Values(1u, 0u)] uint rn, - [ValueSource("_2S_F_")] ulong z, - [ValueSource("_2S_F_")] ulong a, - [Values(0b0u, 0b1u)] uint q) // <2S, 4S> - { - opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); - opcodes |= ((q & 1) << 30); - - Vector128 v0 = MakeVectorE0E1(z, z); - Vector128 v1 = MakeVectorE0E1(a, a * q); - - int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); - - int fpcr = rnd & (1 << (int)Fpcr.Fz); - fpcr |= rnd & (1 << (int)Fpcr.Dn); - - SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); - - CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); - } - - [Test, Pairwise] [Explicit] - public void F_Abs_Neg_Sqrt_V_2D([ValueSource("_F_Abs_Neg_Sqrt_V_2D_")] uint opcodes, - [Values(0u)] uint rd, - [Values(1u, 0u)] uint rn, - [ValueSource("_1D_F_")] ulong z, - [ValueSource("_1D_F_")] ulong a) - { - opcodes |= ((rn & 31) << 5) | ((rd & 31) << 0); - - Vector128 v0 = MakeVectorE0E1(z, z); - Vector128 v1 = MakeVectorE0E1(a, a); - - int rnd = (int)TestContext.CurrentContext.Random.NextUInt(); - - int fpcr = rnd & (1 << (int)Fpcr.Fz); - fpcr |= rnd & (1 << (int)Fpcr.Dn); - - SingleOpcode(opcodes, v0: v0, v1: v1, fpcr: fpcr); - - CompareAgainstUnicorn(fpsrMask: Fpsr.Ioc | Fpsr.Idc); - } - [Test, Pairwise, Description("NEG , ")] public void Neg_S_D([Values(0u)] uint rd, [Values(1u, 0u)] uint rn, @@ -1662,6 +1840,27 @@ namespace Ryujinx.Tests.Cpu CompareAgainstUnicorn(); } + [Test, Pairwise, Description("SHLL{2} ., ., #")] + public void Shll_V([Values(0u)] uint rd, + [Values(1u, 0u)] uint rn, + [ValueSource("_8B4H2S_")] [Random(RndCnt)] ulong z, + [ValueSource("_8B4H2S_")] [Random(RndCnt)] ulong a, + [Values(0b00u, 0b01u, 0b10u)] uint size, // + [Values(0b0u, 0b1u)] uint q) + { + uint opcode = 0x2E213800; // SHLL V0.8H, V0.8B, #8 + opcode |= ((rn & 31) << 5) | ((rd & 31) << 0); + opcode |= ((size & 3) << 22); + opcode |= ((q & 1) << 30); + + Vector128 v0 = MakeVectorE0E1(z, z); + Vector128 v1 = MakeVectorE0E1(q == 0u ? a : 0ul, q == 1u ? a : 0ul); + + SingleOpcode(opcode, v0: v0, v1: v1); + + CompareAgainstUnicorn(); + } + [Test, Pairwise, Description("SQABS , ")] public void Sqabs_S_B_H_S_D([Values(0u)] uint rd, [Values(1u, 0u)] uint rn,