void combine(int u, int v)
 {
     if (freezeWorklist.Contains(v))
     {
         freezeWorklist.Remove(v);
     }
     else
     {
         spillWorklist.Remove(v);
     }
     coalescedNodes.Add(v);
     alias[v] = u;
     moveList[u].UnionWith(moveList[v]);
     enableMoves(v);
     foreach (var t in adjacent(v))
     {
         bool aa = precolored.Contains(t);
         bool bb = precolored.Contains(u);
         graph.AddEdgeP(t, u, aa, bb);
         for (int i = 0; i < graph.AdjacentListBuilder.Length; i++)
         {
             graph.AdjacentList[i] = graph.AdjacentListBuilder[i].ToImmutable();
         }
         decrementDegree(t);
     }
     if (graph.Degree[u] >= RegisterNumber && freezeWorklist.Contains(u))
     {
         freezeWorklist.Remove(u);
         spillWorklist.Add(u);
     }
 }
Ejemplo n.º 2
0
        // v_get_from_s always appear consecutively on same temp var, so there will be no inference

        internal (InferenceGraph sgraph, InferenceGraph vgraph) CreateInferenceGraph(HashSet <string> spre, HashSet <string> vpre)
        {
            ConstructFlowGraph();
            do
            {
                CalculateLiveSpan2();
            }while (DeleteStupidLine());
            InferenceGraph sgraph = new InferenceGraph(SIns, SOuts, spre);
            InferenceGraph vgraph = new InferenceGraph(VIns, VOuts, vpre);

            foreach (var ins in List)
            {
                if (ins.OPCode.Contains("mov"))
                {
                    ins.SOut = ins.SOut.Except(ins.SUse);
                    ins.VOut = ins.VOut.Except(ins.VUse);
                    if (ins.OPCode[0] == 's')
                    {
                        if (ins.SDef.Overlaps(ins.SOut)) // if define is used
                        {
                            sgraph.AddToWorklistMoves(ins.SDef, ins.SUse);
                            foreach (var item in ins.SUse.Union(ins.SDef))
                            {
                                sgraph.AddToMoveList(item, ins.SDef, ins.SUse);
                            }
                        }
                    }
                    else
                    {
                        if (ins.VDef.Overlaps(ins.VOut))
                        {
                            vgraph.AddToWorklistMoves(ins.VDef, ins.VUse);
                            foreach (var item in ins.VUse.Union(ins.VDef))
                            {
                                vgraph.AddToMoveList(item, ins.VDef, ins.VUse);
                            }
                        }
                    }
                }
                // if define is not used
                if (ins.SDef.Overlaps(ins.SOut))
                {
                    foreach (var a in ins.SDef)
                    {
                        foreach (var b in ins.SOut)
                        {
                            bool aa = a[0] == 'R';
                            bool bb = b[0] == 'R';
                            sgraph.AddEdgeP(a, b, aa, bb);
                        }
                    }
                }
                if (ins.VDef.Overlaps(ins.VOut))
                {
                    foreach (var a in ins.VDef)
                    {
                        foreach (var b in ins.VOut)
                        {
                            bool aa = a[0] == 'R';
                            bool bb = b[0] == 'R';
                            vgraph.AddEdgeP(a, b, aa, bb);
                        }
                    }
                }
            }
            return(sgraph, vgraph);
        }