public static SortedSet<IRBlock> FindReachableBlocks(IRGraph cfg, int ignoreBlockIndex) { IRBlock head = cfg.GetGraphHead(); SortedSet<IRBlock> reachable = new SortedSet<IRBlock>(); reachable.Add(head); // if you can't use head you should ge no where if (head.GetIndex() == ignoreBlockIndex) return reachable; return FindReachableBlocks(reachable, head, ignoreBlockIndex); }
public static SortedSet <IRBlock> FindReachableBlocks(IRGraph cfg, int ignoreBlockIndex) { IRBlock head = cfg.GetGraphHead(); SortedSet <IRBlock> reachable = new SortedSet <IRBlock>(); reachable.Add(head); // if you can't use head you should ge no where if (head.GetIndex() == ignoreBlockIndex) { return(reachable); } return(FindReachableBlocks(reachable, head, ignoreBlockIndex)); }
private static void RenameVariables(IRGraph graph, DominatorTree dominatorTree) { // setup data structures Dictionary <Ident, int> count = new Dictionary <Ident, int>(); Dictionary <Ident, Stack <int> > stack = new Dictionary <Ident, Stack <int> >(); foreach (Ident ident in graph.GetDefinedVars()) { count[ident] = 0; stack[ident] = new Stack <int>(); stack[ident].Push(0); } // recursively walk the dominator tree in-order starting with the root node Search(graph.GetGraphHead(), dominatorTree, count, stack); }
/* * Test the dominance set */ private static void TestDomaintes(int index, SortedSet <int> expected) { IRGraph cfg = BuildSampleCFG(); SortedSet <IRBlock> V = cfg.GetSetOfAllBlocks(); SortedSet <IRBlock> VSansR = new SortedSet <IRBlock>(); VSansR.UnionWith(V); VSansR.Remove(cfg.GetGraphHead()); SortedSet <IRBlock> result = DominatorTree.CalculateDominatesSet(cfg, V, VSansR, cfg.GetBlock(index)); SortedSet <int> intResult = ConvertToIndexSet(result); if (!intResult.SetEquals(expected)) { throw new Exception("Dominates blocks for block " + index + " is " + ConvertSetToString(intResult) + " should be " + ConvertSetToString(expected)); } }
private static void RenameVariables(IRGraph graph, DominatorTree dominatorTree) { // setup data structures Dictionary<Ident, int> count = new Dictionary<Ident, int>(); Dictionary<Ident, Stack<int>> stack = new Dictionary<Ident, Stack<int>>(); foreach (Ident ident in graph.GetDefinedVars()) { count[ident] = 0; stack[ident] = new Stack<int>(); stack[ident].Push(0); } // recursively walk the dominator tree in-order starting with the root node Search(graph.GetGraphHead(), dominatorTree, count, stack); }