1
1
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2025-02-07 00:21:08 -06:00
ryujinx/src/Ryujinx.Tests/Cpu/CpuTestBfm.cs
TSRBerry e9848339dd
[Ryujinx.Tests] Address dotnet-format issues (#5389)
* dotnet format style --severity info

Some changes were manually reverted.

* dotnet format analyzers --serverity info

Some changes have been minimally adapted.

* Restore a few unused methods and variables

* Fix new dotnet-format issues after rebase

* Address review comments

* Address most dotnet format whitespace warnings

* Apply dotnet format whitespace formatting

A few of them have been manually reverted and the corresponding warning was silenced

* Format if-blocks correctly

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Add comments to disabled warnings

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* cpu tests: Disable CA2211 for CodeBaseAddress and DataBaseAddress

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* Apply suggestions from code review

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* First dotnet format pass

* Fix naming rule violations

* Remove naming rule violation exceptions

* Fix comment style

* Use targeted new

* Remove redundant code

* Remove comment alignment

* Remove naming rule exceptions

* Add trailing commas

* Use nameof expression

* Reformat to add remaining trailing commas

---------

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2023-07-01 02:14:34 +00:00

131 lines
5.3 KiB
C#

#define Bfm
using NUnit.Framework;
namespace Ryujinx.Tests.Cpu
{
[Category("Bfm")]
public sealed class CpuTestBfm : CpuTest
{
#if Bfm
private const int RndCnt = 2;
[Test, Pairwise, Description("BFM <Xd>, <Xn>, #<immr>, #<imms>")]
public void Bfm_64bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Random(RndCnt)] ulong xd,
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
[Values(0u, 31u, 32u, 63u)] uint immr,
[Values(0u, 31u, 32u, 63u)] uint imms)
{
uint opcode = 0xB3400000; // BFM X0, X0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
ulong x31 = TestContext.CurrentContext.Random.NextULong();
SingleOpcode(opcode, x0: xd, x1: xn, x31: x31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("BFM <Wd>, <Wn>, #<immr>, #<imms>")]
public void Bfm_32bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Random(RndCnt)] uint wd,
[Values(0x00000000u, 0x7FFFFFFFu,
0x80000000u, 0xFFFFFFFFu)] uint wn,
[Values(0u, 15u, 16u, 31u)] uint immr,
[Values(0u, 15u, 16u, 31u)] uint imms)
{
uint opcode = 0x33000000; // BFM W0, W0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
uint w31 = TestContext.CurrentContext.Random.NextUInt();
SingleOpcode(opcode, x0: wd, x1: wn, x31: w31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("SBFM <Xd>, <Xn>, #<immr>, #<imms>")]
public void Sbfm_64bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
[Values(0u, 31u, 32u, 63u)] uint immr,
[Values(0u, 31u, 32u, 63u)] uint imms)
{
uint opcode = 0x93400000; // SBFM X0, X0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
ulong x31 = TestContext.CurrentContext.Random.NextULong();
SingleOpcode(opcode, x1: xn, x31: x31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("SBFM <Wd>, <Wn>, #<immr>, #<imms>")]
public void Sbfm_32bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Values(0x00000000u, 0x7FFFFFFFu,
0x80000000u, 0xFFFFFFFFu)] uint wn,
[Values(0u, 15u, 16u, 31u)] uint immr,
[Values(0u, 15u, 16u, 31u)] uint imms)
{
uint opcode = 0x13000000; // SBFM W0, W0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
uint w31 = TestContext.CurrentContext.Random.NextUInt();
SingleOpcode(opcode, x1: wn, x31: w31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("UBFM <Xd>, <Xn>, #<immr>, #<imms>")]
public void Ubfm_64bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
[Values(0u, 31u, 32u, 63u)] uint immr,
[Values(0u, 31u, 32u, 63u)] uint imms)
{
uint opcode = 0xD3400000; // UBFM X0, X0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
ulong x31 = TestContext.CurrentContext.Random.NextULong();
SingleOpcode(opcode, x1: xn, x31: x31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("UBFM <Wd>, <Wn>, #<immr>, #<imms>")]
public void Ubfm_32bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Values(0x00000000u, 0x7FFFFFFFu,
0x80000000u, 0xFFFFFFFFu)] uint wn,
[Values(0u, 15u, 16u, 31u)] uint immr,
[Values(0u, 15u, 16u, 31u)] uint imms)
{
uint opcode = 0x53000000; // UBFM W0, W0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
uint w31 = TestContext.CurrentContext.Random.NextUInt();
SingleOpcode(opcode, x1: wn, x31: w31);
CompareAgainstUnicorn();
}
#endif
}
}