/// <summary> /// Traverses the call graph, and for each strongly connected /// component (SCC) performs SSA transformation and detection of /// trashed and preserved registers. /// </summary> /// <returns></returns> public List <SsaTransform> RewriteProceduresToSsa() { this.ssts = new List <SsaTransform>(); var sscf = new SccFinder <Procedure>(new ProcedureGraph(program), UntangleProcedureScc); sscf.FindAll(); return(ssts); }
/// <summary> /// Writes the strongly-connected components (SCCs) of the given <see cref="Program"/>'s /// call graph. /// </summary> /// <remarks> /// The entries are reverse depth first ordered, which means leaf procedures are written /// before their callers. The intent is to assist in debugging large program with deep /// call hierarchies. /// </remarks> public void WriteSccs(Program program) { var filename = Path.ChangeExtension(Path.GetFileName(program.Filename), "sccs"); var globalsPath = Path.Combine(program.SourceDirectory, filename); using (TextWriter output = host.CreateTextWriter(globalsPath)) { var sscf = new SccFinder <Procedure>(new ProcedureGraph(program), procs => { output.WriteLine("== {0} procedures ===", procs.Count); procs = procs.OrderBy(p => p.EntryAddress).ToList(); foreach (var proc in procs) { output.Write(proc.Name); if (program.EntryPoints.ContainsKey(proc.EntryAddress)) { output.Write(" (Entry point)"); } output.WriteLine(); } }); sscf.FindAll(); } }