CpuTestAluImm32.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #define AluRs32
  2. using NUnit.Framework;
  3. namespace Ryujinx.Tests.Cpu
  4. {
  5. [Category("AluImm32")]
  6. public sealed class CpuTestAluImm32 : CpuTest32
  7. {
  8. #if AluRs32
  9. #region "ValueSource (Opcodes)"
  10. private static uint[] _opcodes()
  11. {
  12. return new uint[]
  13. {
  14. 0xe2a00000u, // ADC R0, R0, #0
  15. 0xe2b00000u, // ADCS R0, R0, #0
  16. 0xe2800000u, // ADD R0, R0, #0
  17. 0xe2900000u, // ADDS R0, R0, #0
  18. 0xe3c00000u, // BIC R0, R0, #0
  19. 0xe3d00000u, // BICS R0, R0, #0
  20. 0xe2600000u, // RSB R0, R0, #0
  21. 0xe2700000u, // RSBS R0, R0, #0
  22. 0xe2e00000u, // RSC R0, R0, #0
  23. 0xe2f00000u, // RSCS R0, R0, #0
  24. 0xe2c00000u, // SBC R0, R0, #0
  25. 0xe2d00000u, // SBCS R0, R0, #0
  26. 0xe2400000u, // SUB R0, R0, #0
  27. 0xe2500000u, // SUBS R0, R0, #0
  28. };
  29. }
  30. #endregion
  31. private const int RndCnt = 2;
  32. private const int RndCntAmount = 2;
  33. [Test, Pairwise]
  34. public void TestCpuTestAluImm32([ValueSource("_opcodes")] uint opcode,
  35. [Values(0u, 13u)] uint rd,
  36. [Values(1u, 13u)] uint rn,
  37. [Random(RndCnt)] uint imm,
  38. [Random(RndCnt)] uint wn,
  39. [Values(true, false)] bool carryIn)
  40. {
  41. opcode |= ((imm & 0xfff) << 0) | ((rn & 15) << 16) | ((rd & 15) << 12);
  42. uint sp = TestContext.CurrentContext.Random.NextUInt();
  43. SingleOpcode(opcode, r1: wn, sp: sp, carry: carryIn);
  44. CompareAgainstUnicorn();
  45. }
  46. #endif
  47. }
  48. }