예제 #1
0
 public void RemoveExitBlock(BasicBlock exitBlock)
 {
     if (exitBlocks == null)
         return;
     exitBlocks.Remove(exitBlock);
 }
예제 #2
0
 public void RemoveEntryBlock(BasicBlock insBlock)
 {
     if (entryBlocks == null) return;
     entryBlocks.Remove(insBlock);
 }
예제 #3
0
 /// <summary>
 /// Add the given block to my list of entry blocks.
 /// </summary>
 internal void AddEntryBlock(BasicBlock entryBlock)
 {
     entryBlocks = entryBlocks ?? new HashSet<BasicBlock>();
     entryBlocks.Add(entryBlock);
 }
예제 #4
0
 /// <summary>
 /// Add the given block to my list of exit blocks.
 /// </summary>
 internal void AddExitBlock(BasicBlock exitBlock)
 {
     exitBlocks = exitBlocks ?? new HashSet<BasicBlock>();
     exitBlocks.Add(exitBlock);
 }
예제 #5
0
 public HashSet<BasicBlock> GetReachableBlocks(BasicBlock basicBlock)
 {
     if (_reachableBlocks == null)
         CalculateReachableBlocks();
     return _reachableBlocks[basicBlock];
 }
예제 #6
0
 /// <summary>
 /// This method tests if 'target' can be reached from 'source' without passing through 'blocker'
 /// </summary>
 private bool IsReachable(BasicBlock target, BasicBlock source, BasicBlock blocker, HashSet<BasicBlock> visited)
 {
     foreach (var exit in source.ExitBlocks)
     {                
         if (exit == target)
             return true;
         if (exit == blocker || exit == source)
             continue;
         if (visited.Contains(exit))
             continue; 
         visited.Add(exit);
         if (IsReachable(target, exit, blocker, visited))
             return true;
     }
     return false;
 }
예제 #7
0
 public InstructionInBlock(Instruction instruction, BasicBlock block)
 {
     Instruction = instruction;
     Block = block;
 }
예제 #8
0
        private HashSet<BasicBlock> CalculateReachableBlocks(BasicBlock block, HashSet<BasicBlock> visited)
        {
            visited.Add(block);

            HashSet<BasicBlock> ret = new HashSet<BasicBlock>();

            foreach (var b in block.ExitBlocks)
            {
                if (visited.Contains(b))
                    continue;

                ret.Add(b);
                if (_reachableBlocks.ContainsKey(b))
                {
                    foreach (var bb in _reachableBlocks[b])
                        ret.Add(bb);
                }
                else
                {
                    foreach (var dep in CalculateReachableBlocks(b, visited))
                        ret.Add(dep);
                }
            }

            return ret;
        }
예제 #9
0
 public InstructionInBlock(Instruction instruction, BasicBlock block)
 {
     Instruction = instruction;
     Block       = block;
 }