public StrengthReduction(SsaState ssa, LinearInductionVariable liv, LinearInductionVariableContext ctx) { this.ssa = ssa; this.liv = liv; this.ctx = ctx; incrUses = new List<IncrementedUse>(); }
public Coalescer(Procedure proc, SsaState ssa) { this.proc = proc; this.ssa = ssa; this.sef = new SideEffectFinder(); this.defsByStatement = new Dictionary<Statement, List<SsaIdentifier>>(); foreach (SsaIdentifier sid in ssa.Identifiers) { if (sid.DefStatement != null) SetDefStatement(sid.DefStatement, sid); } }
public IdentifierReplacer(SsaState ssaIds, Statement use, Identifier idOld, Expression exprNew) { this.ssaIds = ssaIds; this.use = use; this.idOld = idOld; this.exprNew = exprNew; }
public UnSSA(SsaState ssa) { this.ssa = ssa; }
private void DumpProc(Procedure proc, SsaState ssa, TextWriter writer) { ssa.Write(writer); proc.Write(false, writer); }
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(); } }
private void RunUnitTest(ProcedureBuilder m, string outfile) { var proc = m.Procedure; var sst = new SsaTransform(new ProgramDataFlow(), proc, proc.CreateBlockDominatorGraph()); ssa = sst.SsaState; using (var fut = new FileUnitTester(outfile)) { ssa.Write(fut.TextWriter); proc.Write(false, fut.TextWriter); fut.AssertFilesEqual(); } }
/// <summary> /// Walks the dominator tree, renaming the different definitions of variables /// (including phi-functions). /// </summary> /// <param name="ssa">SSA identifiers</param> /// <param name="p">procedure to rename</param> public VariableRenamer(SsaTransform ssaXform) { this.programFlow = ssaXform.programFlow; this.ssa = ssaXform.SsaState; this.renameFrameAccess = ssaXform.RenameFrameAccesses; this.addUseInstructions = ssaXform.AddUseInstructions; this.proc = ssaXform.proc; this.rename = new Dictionary<Identifier, Identifier>(); this.stmCur = null; this.existingDefs = proc.EntryBlock.Statements .Select(s => s.Instruction as DefInstruction) .Where(d => d != null) .Select(d => d.Expression) .ToHashSet(); }
public LocateDefinedVariables(SsaTransform ssaXform, Dictionary<Expression, byte>[] defOrig) { this.programFlow = ssaXform.programFlow; this.proc = ssaXform.proc; this.ssa = ssaXform.SsaState; this.frameVariables = ssaXform.RenameFrameAccesses; this.defVars = defOrig; this.definitions = new List<Identifier>(); this.inDefinitions = new HashSet<Identifier>(); }
public static void Eliminate(Procedure proc, SsaState ssa) { new DeadCode(proc, ssa).Eliminate(); }
private DeadCode(Procedure proc, SsaState ssa) { this.proc = proc; this.ssa = ssa; this.critical = new CriticalInstruction(); }
protected void DumpSsaTypes(SsaState ssa, TextWriter writer) { foreach (SsaIdentifier id in ssa.Identifiers) { if (id.Identifier.TypeVariable != null) writer.WriteLine("{0}: {1}", id.Identifier, id.Identifier.TypeVariable); } }
protected void DumpSsaInfo(Procedure proc, SsaState ssa, TextWriter writer) { writer.WriteLine("// {0} ////////////////////////////////", proc.Name); DumpSsaTypes(ssa, writer); proc.Write(false, writer); writer.WriteLine(); }
private void Build(Procedure proc, IProcessorArchitecture arch) { var platform = new DefaultPlatform(null, arch); this.proc = proc; Aliases alias = new Aliases(proc, arch); alias.Transform(); SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, proc.CreateBlockDominatorGraph()); ssa = sst.SsaState; ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa.Identifiers, platform); cce.Transform(); ValuePropagator vp = new ValuePropagator(ssa.Identifiers, proc); vp.Transform(); DeadCode.Eliminate(proc, ssa); Coalescer coa = new Coalescer(proc, ssa); coa.Transform(); DeadCode.Eliminate(proc, ssa); sla = new SsaLivenessAnalysis(proc, ssa.Identifiers); sla2 = new SsaLivenessAnalysis2(proc, ssa.Identifiers); sla2.Analyze(); }