예제 #1
0
        private void InitLoopInfo()
        {
            // Compute the basic blocks that escape loops
            foreach (var impl in Prog.Implementations)
            {
                var CFG = Program.GraphFromImpl(impl);
                CFG.ComputeLoops();
                foreach (var Header in CFG.Headers)
                {
                    var allBlocksInThisLoop = new HashSet <Block>();
                    foreach (var BackEdge in CFG.BackEdgeNodes(Header))
                    {
                        foreach (var block in CFG.NaturalLoops(Header, BackEdge))
                        {
                            allBlocksInThisLoop.Add(block);
                        }
                    }

                    var escapingBlocks = new HashSet <Block>();
                    foreach (var b in allBlocksInThisLoop)
                    {
                        var gotoCmd = b.TransferCmd as GotoCmd;
                        if (gotoCmd != null)
                        {
                            foreach (var gotoTargetBlock in gotoCmd.labelTargets)
                            {
                                if (!(allBlocksInThisLoop.Contains(gotoTargetBlock)))
                                {
                                    // Blocks reachable from inside the loop that
                                    // are not part of the loop are escaping blocks
                                    escapingBlocks.Add(gotoTargetBlock);
                                }
                            }
                        }
                    }
                    // Create LoopInfo
                    var loopInfo = new LoopInfo(Header, allBlocksInThisLoop, escapingBlocks);
                    HeaderToLoopInfo.Add(Header, loopInfo);
                }
            }
        }
예제 #2
0
 public ExecutionStateSingleLoopInfo(StackFrame stack, LoopInfo li)
 {
     Stack   = stack;
     LInfo   = li;
     Counter = 0;
 }