private RegisterAllocation(CFGNode[] cfgNodes, Dictionary <Variable, IMemory> preallocatedValues)
        {
            CFGNodes = cfgNodes;

            LiveIntervalsByVariable = new Dictionary <Variable, (int First, int Last)>();

            CalculateLiveIntervals();

            LiveIntervals = LiveIntervalsByVariable
                            .Select(x => new LiveInterval(x.Key, x.Value.First, x.Value.Last))
                            .OrderBy(x => x.FirstIndex)
                            .ToList();

            AssignedLocation            = preallocatedValues ?? new Dictionary <Variable, IMemory>();
            FreeGeneralPurposeRegisters = new Stack <Register>(
                Register.All
                .Where(x => x.Size == RegisterSize.Bytes8 && (x.Flags & RegisterFlags.GeneralPurpose) != 0 &&
                       !AssignedLocation.ContainsValue(x)));

            Active = new List <LiveInterval>();

            AllocateRegisters();
            //AssignedLocation = LiveIntervalsByVariable.ToDictionary(x => x.Key, _ => (IMemory)StackAlloc(8));
        }