Update CpuTest.cs
This commit is contained in:
parent
ec42844d14
commit
0d1b309843
1 changed files with 30 additions and 2 deletions
|
@ -93,6 +93,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
Vector128<float> V0 = default(Vector128<float>),
|
||||
Vector128<float> V1 = default(Vector128<float>),
|
||||
Vector128<float> V2 = default(Vector128<float>),
|
||||
Vector128<float> V3 = default(Vector128<float>),
|
||||
bool Overflow = false, bool Carry = false, bool Zero = false, bool Negative = false,
|
||||
int Fpcr = 0x0, int Fpsr = 0x0)
|
||||
{
|
||||
|
@ -106,6 +107,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
Thread.ThreadState.V0 = V0;
|
||||
Thread.ThreadState.V1 = V1;
|
||||
Thread.ThreadState.V2 = V2;
|
||||
Thread.ThreadState.V3 = V3;
|
||||
|
||||
Thread.ThreadState.Overflow = Overflow;
|
||||
Thread.ThreadState.Carry = Carry;
|
||||
|
@ -127,6 +129,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
UnicornEmu.Q[0] = V0;
|
||||
UnicornEmu.Q[1] = V1;
|
||||
UnicornEmu.Q[2] = V2;
|
||||
UnicornEmu.Q[3] = V3;
|
||||
|
||||
UnicornEmu.OverflowFlag = Overflow;
|
||||
UnicornEmu.CarryFlag = Carry;
|
||||
|
@ -162,13 +165,14 @@ namespace Ryujinx.Tests.Cpu
|
|||
Vector128<float> V0 = default(Vector128<float>),
|
||||
Vector128<float> V1 = default(Vector128<float>),
|
||||
Vector128<float> V2 = default(Vector128<float>),
|
||||
Vector128<float> V3 = default(Vector128<float>),
|
||||
bool Overflow = false, bool Carry = false, bool Zero = false, bool Negative = false,
|
||||
int Fpcr = 0x0, int Fpsr = 0x0)
|
||||
{
|
||||
this.Opcode(Opcode);
|
||||
this.Opcode(0xD4200000); // BRK #0
|
||||
this.Opcode(0xD65F03C0); // RET
|
||||
SetThreadState(X0, X1, X2, X3, X31, V0, V1, V2, Overflow, Carry, Zero, Negative, Fpcr, Fpsr);
|
||||
SetThreadState(X0, X1, X2, X3, X31, V0, V1, V2, V3, Overflow, Carry, Zero, Negative, Fpcr, Fpsr);
|
||||
ExecuteOpcodes();
|
||||
|
||||
return GetThreadState();
|
||||
|
@ -195,13 +199,25 @@ namespace Ryujinx.Tests.Cpu
|
|||
QC = 1 << 27
|
||||
}
|
||||
|
||||
protected void CompareAgainstUnicorn(FPSR FpsrMask = FPSR.None)
|
||||
protected enum FpSkips { None, IfNaN_S, IfNaN_D };
|
||||
|
||||
protected void CompareAgainstUnicorn(FPSR FpsrMask = FPSR.None, FpSkips FpSkips = FpSkips.None)
|
||||
{
|
||||
if (!UnicornAvailable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (FpSkips == FpSkips.IfNaN_S && float.IsNaN(VectorExtractSingle(UnicornEmu.Q[0], (byte)0)))
|
||||
{
|
||||
Assert.Ignore("NaN test.");
|
||||
}
|
||||
|
||||
if (FpSkips == FpSkips.IfNaN_D && double.IsNaN(VectorExtractDouble(UnicornEmu.Q[0], (byte)0)))
|
||||
{
|
||||
Assert.Ignore("NaN test.");
|
||||
}
|
||||
|
||||
Assert.That(Thread.ThreadState.X0, Is.EqualTo(UnicornEmu.X[0]));
|
||||
Assert.That(Thread.ThreadState.X1, Is.EqualTo(UnicornEmu.X[1]));
|
||||
Assert.That(Thread.ThreadState.X2, Is.EqualTo(UnicornEmu.X[2]));
|
||||
|
@ -310,6 +326,18 @@ namespace Ryujinx.Tests.Cpu
|
|||
return Sse.StaticCast<long, float>(Sse2.SetVector128(BitConverter.DoubleToInt64Bits(E1), 0));
|
||||
}
|
||||
|
||||
protected static float VectorExtractSingle(Vector128<float> Vector, byte Index)
|
||||
{
|
||||
if (!Sse41.IsSupported)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
int Value = Sse41.Extract(Sse.StaticCast<float, int>(Vector), Index);
|
||||
|
||||
return BitConverter.Int32BitsToSingle(Value);
|
||||
}
|
||||
|
||||
protected static double VectorExtractDouble(Vector128<float> Vector, byte Index)
|
||||
{
|
||||
if (!Sse41.IsSupported)
|
||||
|
|
Loading…
Add table
Reference in a new issue