From b16a53946888e056f9e8638eba8d0f1908e836f4 Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Sun, 9 Jul 2023 00:04:10 +0200 Subject: [PATCH] Convert ALU rs CPU tests to xUnit --- src/Ryujinx.Tests/Cpu/CpuTestAluRs.cs | 810 +++++++++++------------- src/Ryujinx.Tests/Cpu/CpuTestAluRs32.cs | 69 +- 2 files changed, 418 insertions(+), 461 deletions(-) diff --git a/src/Ryujinx.Tests/Cpu/CpuTestAluRs.cs b/src/Ryujinx.Tests/Cpu/CpuTestAluRs.cs index e8e60974e..a31a7f7b2 100644 --- a/src/Ryujinx.Tests/Cpu/CpuTestAluRs.cs +++ b/src/Ryujinx.Tests/Cpu/CpuTestAluRs.cs @@ -1,5 +1,6 @@ -// #define AluRs +#define AluRs +using System; using Xunit; namespace Ryujinx.Tests.Cpu @@ -9,882 +10,817 @@ namespace Ryujinx.Tests.Cpu { #if AluRs - [Test, Pairwise, Description("ADC , , ")] - public void Adc_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values] bool carryIn) + private static readonly uint[] _testData_rd = + { + 0u, 31u, + }; + private static readonly uint[] _testData_rn = + { + 1u, 31u, + }; + private static readonly uint[] _testData_rm = + { + 2u, 31u, + }; + private static readonly ulong[] _testData_xn = + { + 0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, + 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul, + }; + private static readonly bool[] _testData_bools = + { + false, + true, + }; + + public static readonly MatrixTheoryData TestData_Adc = new(_testData_rd, _testData_rn, _testData_rm, _testData_xn, _testData_xn, _testData_bools); + + [Theory(DisplayName = "ADC , , ")] + [MemberData(nameof(TestData_Adc))] + public void Adc_64bit(uint rd, uint rn, uint rm, ulong xn, ulong xm, bool carryIn) { uint opcode = 0x9A000000; // ADC X0, X0, X0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31, carry: carryIn); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ADC , , ")] - public void Adc_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values] bool carryIn) + private static readonly uint[] _testData_wn = { + 0x00000000u, 0x7FFFFFFFu, + 0x80000000u, 0xFFFFFFFFu, + }; + + public static readonly MatrixTheoryData TestData_Adc32 = new(_testData_rd, _testData_rn, _testData_rm, _testData_wn, _testData_wn, _testData_bools); + + [Theory(DisplayName = "ADC , , ")] + [MemberData(nameof(TestData_Adc32))] + public void Adc_32bit(uint rd, uint rn, uint rm, uint wn, uint wm, bool carryIn) { uint opcode = 0x1A000000; // ADC W0, W0, W0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31, carry: carryIn); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ADCS , , ")] - public void Adcs_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values] bool carryIn) + [Theory(DisplayName = "ADCS , , ")] + [MemberData(nameof(TestData_Adc))] + public void Adcs_64bit(uint rd, uint rn, uint rm, ulong xn, ulong xm, bool carryIn) { uint opcode = 0xBA000000; // ADCS X0, X0, X0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31, carry: carryIn); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ADCS , , ")] - public void Adcs_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values] bool carryIn) + [Theory(DisplayName = "ADCS , , ")] + [MemberData(nameof(TestData_Adc32))] + public void Adcs_32bit(uint rd, uint rn, uint rm, uint wn, uint wm, bool carryIn) { uint opcode = 0x3A000000; // ADCS W0, W0, W0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31, carry: carryIn); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ADD , , {, #}")] - public void Add_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + private static readonly uint[] _testData_shift = + { + 0b00u, 0b01u, 0b10u, // + }; + private static readonly uint[] _testData_amount = + { + 0u, 31u, 32u, 63u, + }; + + public static readonly MatrixTheoryData TestData_Add = new(_testData_rd, _testData_rn, _testData_rm, _testData_xn, _testData_xn, _testData_shift, _testData_amount); + + [Theory(DisplayName = "ADD , , {, #}")] + [MemberData(nameof(TestData_Add))] + public void Add_64bit(uint rd, uint rn, uint rm, ulong xn, ulong xm, uint shift, uint amount) { uint opcode = 0x8B000000; // ADD X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ADD , , {, #}")] - public void Add_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + public static readonly MatrixTheoryData TestData_Add32 = new(_testData_rd, _testData_rn, _testData_rm, _testData_wn, _testData_wn, _testData_shift, _testData_amount); + + [Theory(DisplayName = "ADD , , {, #}")] + [MemberData(nameof(TestData_Add32))] + public void Add_32bit(uint rd, uint rn, uint rm, uint wn, uint wm, uint shift, uint amount) { uint opcode = 0x0B000000; // ADD W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ADDS , , {, #}")] - public void Adds_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "ADDS , , {, #}")] + [MemberData(nameof(TestData_Add))] + public void Adds_64bit(uint rd, uint rn, uint rm, ulong xn, ulong xm, uint shift, uint amount) { uint opcode = 0xAB000000; // ADDS X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ADDS , , {, #}")] - public void Adds_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "ADDS , , {, #}")] + [MemberData(nameof(TestData_Add32))] + public void Adds_32bit(uint rd, uint rn, uint rm, uint wn, uint wm, uint shift, uint amount) { uint opcode = 0x2B000000; // ADDS W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("AND , , {, #}")] - public void And_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + private static readonly uint[] _testData_And_shift = { + 0b00u, 0b01u, 0b10u, 0b11u, // + }; + + public static readonly MatrixTheoryData TestData_And = new(_testData_rd, _testData_rn, _testData_rm, _testData_xn, _testData_xn, _testData_And_shift, _testData_amount); + + [Theory(DisplayName = "AND , , {, #}")] + [MemberData(nameof(TestData_And))] + public void And_64bit(uint rd, uint rn, uint rm, ulong xn, ulong xm, uint shift, uint amount) { uint opcode = 0x8A000000; // AND X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("AND , , {, #}")] - public void And_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + public static readonly MatrixTheoryData TestData_And32 = new(_testData_rd, _testData_rn, _testData_rm, _testData_wn, _testData_wn, _testData_And_shift, _testData_amount); + + [Theory(DisplayName = "AND , , {, #}")] + [MemberData(nameof(TestData_And32))] + public void And_32bit(uint rd, uint rn, uint rm, uint wn, uint wm, uint shift, uint amount) { uint opcode = 0x0A000000; // AND W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ANDS , , {, #}")] - public void Ands_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "ANDS , , {, #}")] + [MemberData(nameof(TestData_And))] + public void Ands_64bit(uint rd, uint rn, uint rm, ulong xn, ulong xm, uint shift, uint amount) { uint opcode = 0xEA000000; // ANDS X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ANDS , , {, #}")] - public void Ands_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "ANDS , , {, #}")] + [MemberData(nameof(TestData_And32))] + public void Ands_32bit(uint rd, uint rn, uint rm, uint wn, uint wm, uint shift, uint amount) { uint opcode = 0x6A000000; // ANDS W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ASRV , , ")] - public void Asrv_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0ul, 31ul, 32ul, 63ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm) + private static readonly ulong[] _testData_xm = { + 0ul, 31ul, 32ul, 63ul, 0x7FFFFFFFFFFFFFFFul, + 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul, + }; + + public static readonly MatrixTheoryData TestData_Asrv = new(_testData_rd, _testData_rn, _testData_rm, _testData_xn, _testData_xm); + + [Theory(DisplayName = "ASRV , , ")] + [MemberData(nameof(TestData_Asrv))] + public void Asrv_64bit(uint rd, uint rn, uint rm, ulong xn, ulong xm) { uint opcode = 0x9AC02800; // ASRV X0, X0, X0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ASRV , , ")] - public void Asrv_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0u, 15u, 16u, 31u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm) + private static readonly uint[] _testData_wm = { + 0u, 15u, 16u, 31u, 0x7FFFFFFFu, + 0x80000000u, 0xFFFFFFFFu, + }; + + public static readonly MatrixTheoryData TestData_Asrv32 = new(_testData_rd, _testData_rn, _testData_rm, _testData_wn, _testData_wm); + + [Theory(DisplayName = "ASRV , , ")] + [MemberData(nameof(TestData_Asrv32))] + public void Asrv_32bit(uint rd, uint rn, uint rm, uint wn, uint wm) { uint opcode = 0x1AC02800; // ASRV W0, W0, W0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("BIC , , {, #}")] - public void Bic_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "BIC , , {, #}")] + [MemberData(nameof(TestData_And))] + public void Bic_64bit(uint rd, uint rn, uint rm, ulong xn, ulong xm, uint shift, uint amount) { uint opcode = 0x8A200000; // BIC X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("BIC , , {, #}")] - public void Bic_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "BIC , , {, #}")] + [MemberData(nameof(TestData_And32))] + public void Bic_32bit(uint rd, uint rn, uint rm, uint wn, uint wm, uint shift, uint amount) { uint opcode = 0x0A200000; // BIC W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("BICS , , {, #}")] - public void Bics_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "BICS , , {, #}")] + [MemberData(nameof(TestData_And))] + public void Bics_64bit(uint rd, uint rn, uint rm, ulong xn, ulong xm, uint shift, uint amount) { uint opcode = 0xEA200000; // BICS X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("BICS , , {, #}")] - public void Bics_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "BICS , , {, #}")] + [MemberData(nameof(TestData_And32))] + public void Bics_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + uint shift, // + uint amount) { uint opcode = 0x6A200000; // BICS W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("EON , , {, #}")] - public void Eon_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "EON , , {, #}")] + [MemberData(nameof(TestData_And))] + public void Eon_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm, + uint shift, // + uint amount) { uint opcode = 0xCA200000; // EON X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("EON , , {, #}")] - public void Eon_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "EON , , {, #}")] + [MemberData(nameof(TestData_And32))] + public void Eon_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + uint shift, // + uint amount) { uint opcode = 0x4A200000; // EON W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("EOR , , {, #}")] - public void Eor_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "EOR , , {, #}")] + [MemberData(nameof(TestData_And))] + public void Eor_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm, + uint shift, // + uint amount) { uint opcode = 0xCA000000; // EOR X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("EOR , , {, #}")] - public void Eor_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "EOR , , {, #}")] + [MemberData(nameof(TestData_And32))] + public void Eor_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + uint shift, // + uint amount) { uint opcode = 0x4A000000; // EOR W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("EXTR , , , #")] - public void Extr_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0u, 31u, 32u, 63u)] uint lsb) + public static readonly MatrixTheoryData TestData_Extr = new(_testData_rd, _testData_rn, _testData_rm, _testData_xn, _testData_xn, _testData_amount); + + [Theory(DisplayName = "EXTR , , , #")] + [MemberData(nameof(TestData_Extr))] + public void Extr_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm, + uint lsb) { uint opcode = 0x93C00000; // EXTR X0, X0, X0, #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((lsb & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("EXTR , , , #")] - public void Extr_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0u, 15u, 16u, 31u)] uint lsb) + public static readonly MatrixTheoryData TestData_Extr32 = new(_testData_rd, _testData_rn, _testData_rm, _testData_wn, _testData_wn, _testData_amount); + + [Theory(DisplayName = "EXTR , , , #")] + [MemberData(nameof(TestData_Extr32))] + public void Extr_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + uint lsb) { uint opcode = 0x13800000; // EXTR W0, W0, W0, #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((lsb & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("LSLV , , ")] - public void Lslv_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0ul, 31ul, 32ul, 63ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm) + [Theory(DisplayName = "LSLV , , ")] + [MemberData(nameof(TestData_Asrv))] + public void Lslv_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm) { uint opcode = 0x9AC02000; // LSLV X0, X0, X0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("LSLV , , ")] - public void Lslv_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0u, 15u, 16u, 31u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm) + [Theory(DisplayName = "LSLV , , ")] + [MemberData(nameof(TestData_Asrv32))] + public void Lslv_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm) { uint opcode = 0x1AC02000; // LSLV W0, W0, W0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("LSRV , , ")] - public void Lsrv_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0ul, 31ul, 32ul, 63ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm) + [Theory(DisplayName = "LSRV , , ")] + [MemberData(nameof(TestData_Asrv))] + public void Lsrv_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm) { uint opcode = 0x9AC02400; // LSRV X0, X0, X0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("LSRV , , ")] - public void Lsrv_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0u, 15u, 16u, 31u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm) + [Theory(DisplayName = "LSRV , , ")] + [MemberData(nameof(TestData_Asrv32))] + public void Lsrv_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm) { uint opcode = 0x1AC02400; // LSRV W0, W0, W0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ORN , , {, #}")] - public void Orn_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "ORN , , {, #}")] + [MemberData(nameof(TestData_And))] + public void Orn_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm, + uint shift, // + uint amount) { uint opcode = 0xAA200000; // ORN X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ORN , , {, #}")] - public void Orn_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "ORN , , {, #}")] + [MemberData(nameof(TestData_And32))] + public void Orn_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + uint shift, // + uint amount) { uint opcode = 0x2A200000; // ORN W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ORR , , {, #}")] - public void Orr_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "ORR , , {, #}")] + [MemberData(nameof(TestData_And))] + public void Orr_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm, + uint shift, // + uint amount) { uint opcode = 0xAA000000; // ORR X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("ORR , , {, #}")] - public void Orr_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "ORR , , {, #}")] + [MemberData(nameof(TestData_And32))] + public void Orr_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + uint shift, // + uint amount) { uint opcode = 0x2A000000; // ORR W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("RORV , , ")] - public void Rorv_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0ul, 31ul, 32ul, 63ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm) + [Theory(DisplayName = "RORV , , ")] + [MemberData(nameof(TestData_Asrv))] + public void Rorv_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm) { uint opcode = 0x9AC02C00; // RORV X0, X0, X0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("RORV , , ")] - public void Rorv_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0u, 15u, 16u, 31u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm) + [Theory(DisplayName = "RORV , , ")] + [MemberData(nameof(TestData_Asrv32))] + public void Rorv_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm) { uint opcode = 0x1AC02C00; // RORV W0, W0, W0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("SBC , , ")] - public void Sbc_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values] bool carryIn) + [Theory(DisplayName = "SBC , , ")] + [MemberData(nameof(TestData_Adc))] + public void Sbc_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm, + bool carryIn) { uint opcode = 0xDA000000; // SBC X0, X0, X0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31, carry: carryIn); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("SBC , , ")] - public void Sbc_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values] bool carryIn) + [Theory(DisplayName = "SBC , , ")] + [MemberData(nameof(TestData_Adc32))] + public void Sbc_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + bool carryIn) { uint opcode = 0x5A000000; // SBC W0, W0, W0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31, carry: carryIn); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("SBCS , , ")] - public void Sbcs_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values] bool carryIn) + [Theory(DisplayName = "SBCS , , ")] + [MemberData(nameof(TestData_Adc))] + public void Sbcs_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm, + bool carryIn) { uint opcode = 0xFA000000; // SBCS X0, X0, X0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31, carry: carryIn); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("SBCS , , ")] - public void Sbcs_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values] bool carryIn) + [Theory(DisplayName = "SBCS , , ")] + [MemberData(nameof(TestData_Adc32))] + public void Sbcs_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + bool carryIn) { uint opcode = 0x7A000000; // SBCS W0, W0, W0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31, carry: carryIn); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("SUB , , {, #}")] - public void Sub_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "SUB , , {, #}")] + [MemberData(nameof(TestData_Add))] + public void Sub_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm, + uint shift, // + uint amount) { uint opcode = 0xCB000000; // SUB X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("SUB , , {, #}")] - public void Sub_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "SUB , , {, #}")] + [MemberData(nameof(TestData_Add32))] + public void Sub_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + uint shift, // + uint amount) { uint opcode = 0x4B000000; // SUB W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("SUBS , , {, #}")] - public void Subs_64bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn, - [Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul, - 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xm, - [Values(0b00u, 0b01u, 0b10u)] uint shift, // - [Values(0u, 31u, 32u, 63u)] uint amount) + [Theory(DisplayName = "SUBS , , {, #}")] + [MemberData(nameof(TestData_Add))] + public void Subs_64bit(uint rd, + uint rn, + uint rm, + ulong xn, + ulong xm, + uint shift, // + uint amount) { uint opcode = 0xEB000000; // SUBS X0, X0, X0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - ulong x31 = TestContext.CurrentContext.Random.NextULong(); + ulong x31 = Random.Shared.NextULong(); SingleOpcode(opcode, x1: xn, x2: xm, x31: x31); CompareAgainstUnicorn(); } - [Test, Pairwise, Description("SUBS , , {, #}")] - public void Subs_32bit([Values(0u, 31u)] uint rd, - [Values(1u, 31u)] uint rn, - [Values(2u, 31u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + [Theory(DisplayName = "SUBS , , {, #}")] + [MemberData(nameof(TestData_Add32))] + public void Subs_32bit(uint rd, + uint rn, + uint rm, + uint wn, + uint wm, + uint shift, // + uint amount) { uint opcode = 0x6B000000; // SUBS W0, W0, W0, LSL #0 opcode |= ((rm & 31) << 16) | ((rn & 31) << 5) | ((rd & 31) << 0); opcode |= ((shift & 3) << 22) | ((amount & 63) << 10); - uint w31 = TestContext.CurrentContext.Random.NextUInt(); + uint w31 = Random.Shared.NextUInt(); SingleOpcode(opcode, x1: wn, x2: wm, x31: w31); diff --git a/src/Ryujinx.Tests/Cpu/CpuTestAluRs32.cs b/src/Ryujinx.Tests/Cpu/CpuTestAluRs32.cs index 0d70ef890..1fe083b64 100644 --- a/src/Ryujinx.Tests/Cpu/CpuTestAluRs32.cs +++ b/src/Ryujinx.Tests/Cpu/CpuTestAluRs32.cs @@ -1,5 +1,6 @@ -// #define AluRs32 +#define AluRs32 +using System; using Xunit; namespace Ryujinx.Tests.Cpu @@ -35,43 +36,63 @@ namespace Ryujinx.Tests.Cpu } #endregion + private static readonly uint[] _testData_rd = + { + 0u, 13u, + }; + private static readonly uint[] _testData_rn = + { + 1u, 13u, + }; + private static readonly uint[] _testData_rm = + { + 2u, 13u, + }; + private static readonly uint[] _testData_wn = + { + 0x00000000u, 0x7FFFFFFFu, + 0x80000000u, 0xFFFFFFFFu, + }; + private static readonly bool[] _testData_carry = + { + false, + true, + }; - [Test, Pairwise] - public void Adc_Adcs_Rsc_Rscs_Sbc_Sbcs([ValueSource(nameof(_Adc_Adcs_Rsc_Rscs_Sbc_Sbcs_))] uint opcode, - [Values(0u, 13u)] uint rd, - [Values(1u, 13u)] uint rn, - [Values(2u, 13u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values] bool carryIn) + public static readonly MatrixTheoryData TestData = new(_Adc_Adcs_Rsc_Rscs_Sbc_Sbcs_(), _testData_rd, _testData_rn, _testData_rm, _testData_wn, _testData_wn, _testData_carry); + + [Theory] + [MemberData(nameof(TestData))] + public void Adc_Adcs_Rsc_Rscs_Sbc_Sbcs(uint opcode, uint rd, uint rn, uint rm, uint wn, uint wm, bool carryIn) { opcode |= ((rm & 15) << 0) | ((rn & 15) << 16) | ((rd & 15) << 12); - uint sp = TestContext.CurrentContext.Random.NextUInt(); + uint sp = Random.Shared.NextUInt(); SingleOpcode(opcode, r1: wn, r2: wm, sp: sp, carry: carryIn); CompareAgainstUnicorn(); } - [Test, Pairwise] - public void Add_Adds_Rsb_Rsbs([ValueSource(nameof(_Add_Adds_Rsb_Rsbs_))] uint opcode, - [Values(0u, 13u)] uint rd, - [Values(1u, 13u)] uint rn, - [Values(2u, 13u)] uint rm, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wn, - [Values(0x00000000u, 0x7FFFFFFFu, - 0x80000000u, 0xFFFFFFFFu)] uint wm, - [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // - [Values(0u, 15u, 16u, 31u)] uint amount) + private static readonly uint[] _testData_shift = + { + 0b00u, 0b01u, 0b10u, 0b11u, // + }; + private static readonly uint[] _testData_amount = + { + 0u, 15u, 16u, 31u, + }; + + public static readonly MatrixTheoryData TestData_Add = new(_Add_Adds_Rsb_Rsbs_(), _testData_rd, _testData_rn, _testData_rm, _testData_wn, _testData_wn, _testData_shift, _testData_amount); + + [Theory] + [MemberData(nameof(TestData_Add))] + public void Add_Adds_Rsb_Rsbs(uint opcode, uint rd, uint rn, uint rm, uint wn, uint wm, uint shift, uint amount) { opcode |= ((rm & 15) << 0) | ((rn & 15) << 16) | ((rd & 15) << 12); opcode |= ((shift & 3) << 5) | ((amount & 31) << 7); - uint sp = TestContext.CurrentContext.Random.NextUInt(); + uint sp = Random.Shared.NextUInt(); SingleOpcode(opcode, r1: wn, r2: wm, sp: sp);