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