CpuTestAlu32.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #define Alu32
  2. using NUnit.Framework;
  3. using System;
  4. namespace Ryujinx.Tests.Cpu
  5. {
  6. [Category("Alu32")]
  7. public sealed class CpuTestAlu32 : CpuTest32
  8. {
  9. #if Alu32
  10. #region "ValueSource (Opcodes)"
  11. private static uint[] _Lsr_Lsl_Asr_Ror_()
  12. {
  13. return new uint[]
  14. {
  15. 0xe1b00030u, // LSRS R0, R0, R0
  16. 0xe1b00010u, // LSLS R0, R0, R0
  17. 0xe1b00050u, // ASRS R0, R0, R0
  18. 0xe1b00070u // RORS R0, R0, R0
  19. };
  20. }
  21. #endregion
  22. private const int RndCnt = 2;
  23. [Test, Pairwise, Description("RBIT <Rd>, <Rn>")]
  24. public void Rbit_32bit([Values(0u, 0xdu)] uint rd,
  25. [Values(1u, 0xdu)] uint rm,
  26. [Values(0x00000000u, 0x7FFFFFFFu,
  27. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn)
  28. {
  29. uint opcode = 0xe6ff0f30u; // RBIT R0, R0
  30. opcode |= ((rm & 15) << 0) | ((rd & 15) << 12);
  31. uint w31 = TestContext.CurrentContext.Random.NextUInt();
  32. SingleOpcode(opcode, r1: wn, sp: w31);
  33. CompareAgainstUnicorn();
  34. }
  35. [Test, Pairwise]
  36. public void Lsr_Lsl_Asr_Ror([ValueSource("_Lsr_Lsl_Asr_Ror_")] uint opcode,
  37. [Values(0x00000000u, 0x7FFFFFFFu,
  38. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint shiftValue,
  39. [Range(0, 31)] [Values(32, 256, 768, -1, -23)] int shiftAmount)
  40. {
  41. uint rd = 0;
  42. uint rm = 1;
  43. uint rs = 2;
  44. opcode |= ((rm & 15) << 0) | ((rd & 15) << 12) | ((rs & 15) << 8);
  45. SingleOpcode(opcode, r1: shiftValue, r2: (uint)shiftAmount);
  46. CompareAgainstUnicorn();
  47. }
  48. #endif
  49. }
  50. }