Esempio n. 1
0
        public void calcDFs(ControlFlowGraph CFG)
        {
            int countNodes    = CFG.getCountNodes();
            var nodes         = Enumerable.Range(0, countNodes);
            var dommTree      = CFG.CalcDommTree();
            var lineToIdBlock = CFG.getLineToIdBlock();

            foreach (var n in nodes)
            {
                DFs.Add(new HashSet <int>());
            }

            foreach (var n in nodes)
            {
                var preds = CFG.Prev.Values.ElementAt(n);

                if (preds.Count > 1)
                {
                    foreach (var p in preds)
                    {
                        var r = lineToIdBlock[p];

                        while (r != dommTree[n])
                        {
                            DFs[r].Add(n);
                            r = dommTree[r];
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void initCountersAndStacks(FrontOnDominance Fod, ControlFlowGraph CFG)
        {
            counters = new Dictionary <string, int>();
            stacks   = new Dictionary <string, Stack <string> >();
            foreach (string i in Fod.globals)
            {
                counters.Add(i, 0);
                stacks.Add(i, new Stack <string>());
            }

            CFG_ins = CFG;

            Idom = CFG_ins.CalcDommTree();

            succesor_list_cfg = CFG_ins.Next;
            Dom        = CFG_ins.FindDommBlocks();
            countNodes = CFG_ins.getCountNodes();
            var nodes = Enumerable.Range(0, countNodes);

            succesor_list_dom = new Dictionary <int, List <int> >();
            foreach (var n in nodes)
            {
                var tmp_list = new List <int>();
                for (int boxIndex = 0; boxIndex < CFG_ins.getCountNodes(); boxIndex++) //построение списка Succ дерева доминаторов
                {
                    if (boxIndex == n)
                    {
                        continue;
                    }
                    if (Idom[boxIndex] == n)
                    {
                        tmp_list.Add(boxIndex);
                    }
                }
                succesor_list_dom.Add(n, tmp_list);
            }
        }