Register.cs 933 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. namespace Ryujinx.Graphics.Shader.Decoders
  3. {
  4. readonly struct Register : IEquatable<Register>
  5. {
  6. public int Index { get; }
  7. public RegisterType Type { get; }
  8. public bool IsRZ => Type == RegisterType.Gpr && Index == RegisterConsts.RegisterZeroIndex;
  9. public bool IsPT => Type == RegisterType.Predicate && Index == RegisterConsts.PredicateTrueIndex;
  10. public Register(int index, RegisterType type)
  11. {
  12. Index = index;
  13. Type = type;
  14. }
  15. public override int GetHashCode()
  16. {
  17. return (ushort)Index | ((ushort)Type << 16);
  18. }
  19. public override bool Equals(object obj)
  20. {
  21. return obj is Register reg && Equals(reg);
  22. }
  23. public bool Equals(Register other)
  24. {
  25. return other.Index == Index &&
  26. other.Type == Type;
  27. }
  28. }
  29. }