aboutsummaryrefslogblamecommitdiff
path: root/ARMeilleure/IntermediateRepresentation/Register.cs
blob: 745b315382672a5c4cde2e7300205c3a82fa538c (plain) (tree)









































                                                              
using System;

namespace ARMeilleure.IntermediateRepresentation
{
    struct Register : IEquatable<Register>
    {
        public int Index { get; }

        public RegisterType Type { get; }

        public Register(int index, RegisterType type)
        {
            Index = index;
            Type  = type;
        }

        public override int GetHashCode()
        {
            return (ushort)Index | ((int)Type << 16);
        }

        public static bool operator ==(Register x, Register y)
        {
            return x.Equals(y);
        }

        public static bool operator !=(Register x, Register y)
        {
            return !x.Equals(y);
        }

        public override bool Equals(object obj)
        {
            return obj is Register reg && Equals(reg);
        }

        public bool Equals(Register other)
        {
            return other.Index == Index &&
                   other.Type  == Type;
        }
    }
}