public void DominanceFrontier() { graph.AddEdge("entry", "split"); graph.AddEdge("split", "left"); graph.AddEdge("split", "right"); graph.AddEdge("left", "join"); graph.AddEdge("right", "join"); CompileTest(graph, "entry"); //DumpDominatorFrontier(pdg); Assert.AreEqual(1, pdg.DominatorFrontier("left").Count); Assert.AreEqual("join", pdg.DominatorFrontier("left")[0]); }
// Use for debugging, but don't leave in the unit tests to avoid // useless "spew". private void DumpDominatorFrontier(DominatorGraph <string> pdg) { foreach (var n in graph.Nodes) { Console.Write("{0}:", n); foreach (var df in pdg.DominatorFrontier(n)) { Console.Write(" {0}", df); } Console.WriteLine(); } }
/// <summary> /// Inserts the instr d of the identifier v at statement S. /// </summary> /// <param name="d"></param> /// <param name="v"></param> /// <param name="S"></param> public void Insert(Instruction d, Identifier v, Statement S) { // Insert new phi-functions. foreach (var dfFode in DomGraph.DominatorFrontier(S.Block)) { // If there is no phi-function for v // create new phi-function for v. (which is an insert, so call self recursively) // All input operands of the new phi-finctions are initually assumed to be // uses of r. // Update uses sets for all uses dominated by S, or the new phi statements. // This is done by walking down the dominator tree from each def and find uses // that along wit the def match property 1. // Update each use that is a parameter of a newly created phi-function, according // to property 2. } }
private void DumpDominatorFrontier(DominatorGraph<string> pdg) { foreach (var n in graph.Nodes) { Console.Write("{0}:", n); foreach (var df in pdg.DominatorFrontier(n)) { Console.Write(" {0}", df); } Console.WriteLine(); } }