Пример #1
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);
        }