internal void generate() { ast.translate(directTranslation); directTranslation.ResolveLabel(); // directTranslation.ConstructFlowGraph(); // directTranslation.CalculateLiveSpan(); List <FunctionTranslation> list = new List <FunctionTranslation>(); Dictionary <string, (SortedSet <int> s, SortedSet <int> v)> rlist = new Dictionary <string, (SortedSet <int> s, SortedSet <int> v)>(); for (int i = 0; i < directTranslation.ListOfList.Count; i++) { var item = directTranslation.ListOfList[i]; var f = new FunctionTranslation(item, directTranslation.LabelReferences, directTranslation.Functions[i]); list.Add(f); rlist.Add(item[0].Label, RegisterAllocator.fk(f)); } foreach (var item in list) { item.CalculateLiveSpan2(); item.ResolveCallerSave(rlist); } foreach (var item in directTranslation.FunctionStackWaiting) { int size = item.Key.StackSize; if (size % 4 != 0) { size = size - (size % 4) + 4; } item.Value.Operands[2] = size.ToString(); } list[0].List.AddFirst(new Assembly("s_mov", new List <string> { "RS2", "RS28" })); list[0].List.AddFirst(new Assembly("s_mov", new List <string> { "RS28", "RS29" })); foreach (var item in list) { item.ResolvePhysicalRegister(); item.Output(Console.Out); } // directTranslation.Print(); }