private void UpdateMoveHints(LiveInterval liveInterval)
        {
            if (moveHints.TryGetValue(liveInterval.Start, out MoveHint MoveHint))
            {
                MoveHint.Update(liveInterval);
            }

            if (moveHints.TryGetValue(liveInterval.End, out MoveHint))
            {
                MoveHint.Update(liveInterval);
            }
        }
        private MoveHint[] GetMoveHints(LiveInterval liveInterval)
        {
            MoveHint startMoveHint = null;
            MoveHint endMoveHint   = null;

            moveHints.TryGetValue(liveInterval.Start, out startMoveHint);

            if (!liveInterval.End.IsBlockStartInstruction)
            {
                moveHints.TryGetValue(liveInterval.End, out endMoveHint);
            }

            int cnt = (startMoveHint == null ? 0 : 1) + (endMoveHint == null ? 0 : 1);

            if (cnt == 0)
            {
                return(null);
            }

            var hints = new MoveHint[cnt];

            if (startMoveHint != null && endMoveHint != null)
            {
                // sorted by bonus
                if (startMoveHint.Bonus > endMoveHint.Bonus)
                {
                    hints[0] = startMoveHint;
                    hints[1] = endMoveHint;
                }
                else
                {
                    hints[0] = endMoveHint;
                    hints[1] = startMoveHint;
                }
            }
            else
            {
                if (startMoveHint != null)
                {
                    hints[0] = startMoveHint;
                }
                else
                {
                    hints[0] = endMoveHint;
                }
            }

            return(hints);
        }
        private MoveHint[] GetMoveHints(LiveInterval liveInterval)
        {
            MoveHint startMoveHint = null;
            MoveHint endMoveHint = null;
            moveHints.TryGetValue(liveInterval.Start, out startMoveHint);

            if (!liveInterval.End.IsBlockStartInstruction)
                moveHints.TryGetValue(liveInterval.End.Previous, out endMoveHint);

            int cnt = (startMoveHint == null ? 0 : 1) + (endMoveHint == null ? 0 : 1);

            if (cnt == 0)
                return null;

            MoveHint[] hints = new MoveHint[cnt];

            if (startMoveHint != null && endMoveHint != null)
            {
                // sorted by bonus
                if (startMoveHint.Bonus > endMoveHint.Bonus)
                {
                    hints[0] = startMoveHint;
                    hints[1] = endMoveHint;
                }
                else
                {
                    hints[0] = endMoveHint;
                    hints[1] = startMoveHint;
                }
            }
            else
            {
                if (startMoveHint != null)
                {
                    hints[0] = startMoveHint;
                }
                else
                {
                    hints[0] = endMoveHint;
                }
            }

            return hints;
        }
        private bool PlaceLiveIntervalOnTrack(LiveInterval liveInterval, MoveHint[] hints)
        {
            if (hints == null)
                return false;

            foreach (var moveHint in hints)
            {
                LiveIntervalTrack track = null;

                var register = (liveInterval.Start == moveHint.Slot) ? moveHint.FromRegister : moveHint.ToRegister;

                if (register == null)
                    continue;	// no usable hint

                if (trace.Active) trace.Log("  Trying move hint: " + register.ToString() + "  [ " + moveHint.ToString() + " ]");

                if (PlaceLiveIntervalOnTrack(liveInterval, liveIntervalTracks[register.Index]))
                {
                    return true;
                }
            }

            return false;
        }
        private void UpdateMoveHints(LiveInterval liveInterval, MoveHint[] moveHints)
        {
            if (moveHints == null)
                return;

            if (moveHints.Length >= 1)
                moveHints[0].Update(liveInterval);
            else
                if (moveHints.Length >= 2)
                    moveHints[1].Update(liveInterval);
        }