CpuTestAluImm32.cs 1.8 KB

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