protected override void RunTest(Program prog, TextWriter writer) { var flow = new ProgramDataFlow(prog); var eventListener = new FakeDecompilerEventListener(); var importResolver = MockRepository.GenerateStub <IImportResolver>(); importResolver.Replay(); var trf = new TrashedRegisterFinder(prog, prog.Procedures.Values, flow, eventListener); trf.Compute(); trf.RewriteBasicBlocks(); Dump(prog.CallGraph); RegisterLiveness.Compute(prog, flow, eventListener); GlobalCallRewriter.Rewrite(prog, flow, eventListener); foreach (Procedure proc in prog.Procedures.Values) { Aliases alias = new Aliases(proc, prog.Architecture); alias.Transform(); var gr = proc.CreateBlockDominatorGraph(); SsaTransform sst = new SsaTransform( flow, proc, importResolver, gr, new HashSet <RegisterStorage>()); ssa = sst.SsaState; ssa.Write(writer); proc.Write(false, true, writer); writer.WriteLine(); ssa.CheckUses(s => Assert.Fail(s)); } }
protected override void RunTest(Program prog, TextWriter writer) { var flow = new ProgramDataFlow(prog); var eventListener = new FakeDecompilerEventListener(); var trf = new TrashedRegisterFinder(prog, prog.Procedures.Values, flow, eventListener); trf.Compute(); trf.RewriteBasicBlocks(); Dump(prog.CallGraph); var rl = RegisterLiveness.Compute(prog, flow, eventListener); GlobalCallRewriter.Rewrite(prog, flow); foreach (Procedure proc in prog.Procedures.Values) { Aliases alias = new Aliases(proc, prog.Architecture); alias.Transform(); var gr = proc.CreateBlockDominatorGraph(); SsaTransform sst = new SsaTransform(flow, proc, gr); ssa = sst.SsaState; ssa.Write(writer); proc.Write(false, true, writer); writer.WriteLine(); } }
protected override void RunTest(Program prog, TextWriter writer) { var eventListener = new FakeDecompilerEventListener(); var dfa = new DataFlowAnalysis(prog, eventListener); var trf = new TrashedRegisterFinder(prog, prog.Procedures.Values, dfa.ProgramDataFlow, eventListener); trf.Compute(); trf.RewriteBasicBlocks(); var rl = RegisterLiveness.Compute(prog, dfa.ProgramDataFlow, eventListener); DumpProcedureFlows(prog, dfa, rl, writer); }
protected override void RunTest(Program prog, TextWriter writer) { var eventListener = new FakeDecompilerEventListener(); var dfa = new DataFlowAnalysis(prog, null, eventListener); var trf = new TrashedRegisterFinder(prog, prog.Procedures.Values, dfa.ProgramDataFlow, eventListener); trf.Compute(); trf.RewriteBasicBlocks(); var rl = RegisterLiveness.Compute(prog, dfa.ProgramDataFlow, eventListener); DumpProcedureFlows(prog, dfa, rl, writer); }
private void RunTest(Program prog, TextWriter writer) { flow = new ProgramDataFlow(prog); trf = new TrashedRegisterFinder(prog, prog.Procedures.Values, this.flow, new FakeDecompilerEventListener()); trf.Compute(); trf.RewriteBasicBlocks(); foreach (var proc in prog.Procedures.Values) { flow[proc].EmitRegisters(arch, "// Trashed", flow[proc].TrashedRegisters); proc.Write(false, writer); writer.WriteLine(); } }
private void RunTest(Program prog, TextWriter writer) { flow = new ProgramDataFlow(prog); trf = new TrashedRegisterFinder(prog, prog.Procedures.Values, this.flow, new FakeDecompilerEventListener()); trf.Compute(); trf.RewriteBasicBlocks(); foreach (var proc in prog.Procedures.Values) { flow[proc].EmitRegisters(arch, "// Trashed", flow[proc].TrashedRegisters); proc.Write(false, writer); writer.WriteLine(); } }
protected override void RunTest(Program prog, TextWriter writer) { var dfa = new DataFlowAnalysis(prog, new FakeDecompilerEventListener()); var eventListener = new FakeDecompilerEventListener(); var trf = new TrashedRegisterFinder(prog, prog.Procedures.Values, dfa.ProgramDataFlow, eventListener); trf.Compute(); trf.RewriteBasicBlocks(); RegisterLiveness rl = RegisterLiveness.Compute(prog, dfa.ProgramDataFlow, eventListener); foreach (Procedure proc in prog.Procedures.Values) { LongAddRewriter larw = new LongAddRewriter(proc, prog.Architecture); larw.Transform(); proc.Write(false, writer); writer.WriteLine(); } }
protected override void RunTest(Program prog, TextWriter writer) { var eventListener = new FakeDecompilerEventListener(); var dfa = new DataFlowAnalysis(prog, null, eventListener); var trf = new TrashedRegisterFinder(prog, prog.Procedures.Values, dfa.ProgramDataFlow, eventListener); trf.Compute(); trf.RewriteBasicBlocks(); RegisterLiveness rl = RegisterLiveness.Compute(prog, dfa.ProgramDataFlow, eventListener); foreach (Procedure proc in prog.Procedures.Values) { LongAddRewriter larw = new LongAddRewriter(proc, prog.Architecture); larw.Transform(); proc.Write(false, writer); writer.WriteLine(); } }
/// <summary> /// Finds all interprocedural register dependencies (in- and out-parameters) and /// abstracts them away by rewriting as calls. /// </summary> /// <returns>A RegisterLiveness object that summarizes the interprocedural register /// liveness analysis. This information can be used to generate SSA form. /// </returns> public void UntangleProcedures() { eventListener.ShowStatus("Eliminating intra-block dead registers."); var usb = new UserSignatureBuilder(program); usb.BuildSignatures(); CallRewriter.Rewrite(program); IntraBlockDeadRegisters.Apply(program); eventListener.ShowStatus("Finding terminating procedures."); var term = new TerminationAnalysis(flow); term.Analyze(program); eventListener.ShowStatus("Finding trashed registers."); var trf = new TrashedRegisterFinder(program, program.Procedures.Values, flow, eventListener); trf.Compute(); eventListener.ShowStatus("Rewriting affine expressions."); trf.RewriteBasicBlocks(); eventListener.ShowStatus("Computing register liveness."); var rl = RegisterLiveness.Compute(program, flow, eventListener); eventListener.ShowStatus("Rewriting calls."); GlobalCallRewriter.Rewrite(program, flow); }
protected override void RunTest(Program prog, TextWriter writer) { var flow = new ProgramDataFlow(prog); var eventListener = new FakeDecompilerEventListener(); var importResolver = MockRepository.GenerateStub<IImportResolver>(); importResolver.Replay(); var trf = new TrashedRegisterFinder(prog, prog.Procedures.Values, flow, eventListener); trf.Compute(); trf.RewriteBasicBlocks(); Dump(prog.CallGraph); RegisterLiveness.Compute(prog, flow, eventListener); GlobalCallRewriter.Rewrite(prog, flow, eventListener); foreach (Procedure proc in prog.Procedures.Values) { Aliases alias = new Aliases(proc, prog.Architecture); alias.Transform(); var gr = proc.CreateBlockDominatorGraph(); SsaTransform sst = new SsaTransform( flow, proc, importResolver, gr, new HashSet<RegisterStorage>()); ssa = sst.SsaState; ssa.Write(writer); proc.Write(false, true, writer); writer.WriteLine(); } }