public void RemoveExitBlock(BasicBlock exitBlock) { if (exitBlocks == null) return; exitBlocks.Remove(exitBlock); }
public void RemoveEntryBlock(BasicBlock insBlock) { if (entryBlocks == null) return; entryBlocks.Remove(insBlock); }
/// <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); }
/// <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); }
public HashSet<BasicBlock> GetReachableBlocks(BasicBlock basicBlock) { if (_reachableBlocks == null) CalculateReachableBlocks(); return _reachableBlocks[basicBlock]; }
/// <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; }
public InstructionInBlock(Instruction instruction, BasicBlock block) { Instruction = instruction; Block = block; }
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; }