aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Tests/Cpu/CpuTestAlu32.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-02-29 17:51:55 -0300
committerGitHub <noreply@github.com>2020-03-01 07:51:55 +1100
commitfb0939f9b68d7fb83d863b22ef99af93452bb4bf (patch)
tree1be02b3674c8b94fee0cb12503bd00060810ccb5 /Ryujinx.Tests/Cpu/CpuTestAlu32.cs
parentb8ee5b15abc750e0484195633e6c4bb6e05eab6f (diff)
Add SSAT, SSAT16, USAT and USAT16 ARM32 instructions (#954)
* Implement SMULWB, SMULWT, SMLAWB, SMLAWT, and add tests for some multiply instructions * Improve test descriptions * Rename SMULH to SMUL__ * Add SSAT, SSAT16, USAT and USAT16 ARM32 instructions * Fix new tests * Replace AND 0xFFFF with 16-bits zero extension (more efficient)
Diffstat (limited to 'Ryujinx.Tests/Cpu/CpuTestAlu32.cs')
-rw-r--r--Ryujinx.Tests/Cpu/CpuTestAlu32.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/Ryujinx.Tests/Cpu/CpuTestAlu32.cs b/Ryujinx.Tests/Cpu/CpuTestAlu32.cs
index 145417ae..c21bbe10 100644
--- a/Ryujinx.Tests/Cpu/CpuTestAlu32.cs
+++ b/Ryujinx.Tests/Cpu/CpuTestAlu32.cs
@@ -11,6 +11,26 @@ namespace Ryujinx.Tests.Cpu
#if Alu32
#region "ValueSource (Opcodes)"
+ private static uint[] _Ssat_Usat_()
+ {
+ return new uint[]
+ {
+ 0xe6a00010u, // SSAT R0, #1, R0, LSL #0
+ 0xe6a00050u, // SSAT R0, #1, R0, ASR #32
+ 0xe6e00010u, // USAT R0, #0, R0, LSL #0
+ 0xe6e00050u // USAT R0, #0, R0, ASR #32
+ };
+ }
+
+ private static uint[] _Ssat16_Usat16_()
+ {
+ return new uint[]
+ {
+ 0xe6a00f30u, // SSAT16 R0, #1, R0
+ 0xe6e00f30u, // USAT16 R0, #0, R0
+ };
+ }
+
private static uint[] _Lsr_Lsl_Asr_Ror_()
{
return new uint[]
@@ -56,6 +76,41 @@ namespace Ryujinx.Tests.Cpu
CompareAgainstUnicorn();
}
+
+ [Test, Pairwise]
+ public void Ssat_Usat([ValueSource("_Ssat_Usat_")] uint opcode,
+ [Values(0u, 0xdu)] uint rd,
+ [Values(1u, 0xdu)] uint rn,
+ [Values(0u, 7u, 8u, 0xfu, 0x10u, 0x1fu)] uint sat,
+ [Values(0u, 7u, 8u, 0xfu, 0x10u, 0x1fu)] uint shift,
+ [Values(0x00000000u, 0x7FFFFFFFu,
+ 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn)
+ {
+ opcode |= ((rn & 15) << 0) | ((shift & 31) << 7) | ((rd & 15) << 12) | ((sat & 31) << 16);
+
+ uint w31 = TestContext.CurrentContext.Random.NextUInt();
+
+ SingleOpcode(opcode, r1: wn, sp: w31);
+
+ CompareAgainstUnicorn();
+ }
+
+ [Test, Pairwise]
+ public void Ssat16_Usat16([ValueSource("_Ssat16_Usat16_")] uint opcode,
+ [Values(0u, 0xdu)] uint rd,
+ [Values(1u, 0xdu)] uint rn,
+ [Values(0u, 7u, 8u, 0xfu)] uint sat,
+ [Values(0x00000000u, 0x7FFFFFFFu,
+ 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn)
+ {
+ opcode |= ((rn & 15) << 0) | ((rd & 15) << 12) | ((sat & 15) << 16);
+
+ uint w31 = TestContext.CurrentContext.Random.NextUInt();
+
+ SingleOpcode(opcode, r1: wn, sp: w31);
+
+ CompareAgainstUnicorn();
+ }
#endif
}
}