예제 #1
0
        public void FindNoLoopInInterval()
        {
            ProcedureBuilder m = new ProcedureBuilder();
            m.Return();

            StructureNode node = new StructureNode(m.Procedure.ControlGraph.Blocks[1], 3);
            node.Order = 0;
            Interval interval = new Interval(1, node);

            var nodesInInterval = interval.FindIntervalNodes(0);
            SccLoopFinder finder = new SccLoopFinder(interval, nodesInInterval);
            var loopNodes = finder.FindLoop();
            Assert.AreEqual(0, loopNodes.Count);
        }
예제 #2
0
        public void FindSelfLoopInInterval()
        {
            ProcedureStructure proc = CompileTest(delegate(ProcedureBuilder m)
            {
                m.Label("lupe");
                m.BranchIf(m.LocalBool("f"), "lupe");
                m.Return();
            });

            SccLoopFinder finder    = CreateSccLoopFinder(proc, proc.DerivedGraphs[0].Intervals[1], 0);
            var           loopNodes = finder.FindLoop();

            Assert.AreEqual(1, loopNodes.Count);
            var aNodes = new List <StructureNode>(loopNodes);

            Assert.AreEqual("lupe", aNodes[0].Block.Name);
        }
예제 #3
0
        public void FindNoLoopInInterval()
        {
            ProcedureBuilder m = new ProcedureBuilder();

            m.Return();

            StructureNode node = new StructureNode(m.Procedure.ControlGraph.Blocks[1], 3);

            node.Order = 0;
            Interval interval = new Interval(1, node);

            var           nodesInInterval = interval.FindIntervalNodes(0);
            SccLoopFinder finder          = new SccLoopFinder(interval, nodesInInterval);
            var           loopNodes       = finder.FindLoop();

            Assert.AreEqual(0, loopNodes.Count);
        }
예제 #4
0
        public void Reg00013()
        {
            ProcedureStructure proc = CompileTest("Fragments/regressions/r00013.asm");

            proc.DumpDerivedSequence(Console.Out);
            for (int j = 0; j < proc.DerivedGraphs.Count; ++j)
            {
                for (int i = 0; i < proc.DerivedGraphs[j].Intervals.Count; ++i)
                {
                    Interval      interval  = proc.DerivedGraphs[j].Intervals[i];
                    SccLoopFinder finder    = CreateSccLoopFinder(proc, interval, j);
                    var           loopNodes = finder.FindLoop();
                    var           items     = new List <StructureNode>(loopNodes);
                    items.Sort(delegate(StructureNode a, StructureNode b) { return(string.Compare(a.Name, b.Name)); });
                    foreach (StructureNode sn in items)
                    {
                        Console.Out.Write(sn.Name + " ");
                    }
                    Console.Out.WriteLine();
                }
            }
        }
예제 #5
0
        public void FindMultiNodeLoop()
        {
            ProcedureStructure proc = CompileTest(delegate(ProcedureBuilder m)
            {
                m.Label("lupe");
                m.BranchIf(m.LocalBool("a"), "branch_true");

                m.SideEffect(m.Fn("foo"));
                m.Jump("join");
                m.Label("branch_true");
                m.SideEffect(m.Fn("bar"));
                m.Label("join");
                m.BranchIf(m.LocalBool("b"), "lupe");
                m.Return();
            });

            SccLoopFinder finder    = CreateSccLoopFinder(proc, proc.DerivedGraphs[0].Intervals[1], 0);
            var           loopNodes = finder.FindLoop();

            Assert.AreEqual(4, loopNodes.Count);
            Assert.IsTrue(loopNodes.Contains(proc.Nodes[2]));
        }