Esempio n. 1
0
 public LiveCopyInserter(Procedure proc, SsaIdentifierCollection ssaIds)
 {
     this.proc   = proc;
     this.ssaIds = ssaIds;
     this.sla    = new SsaLivenessAnalysis(proc, ssaIds);
     this.doms   = proc.CreateBlockDominatorGraph();
 }
 public ConditionCodeEliminator(SsaState ssa, IPlatform arch)
 {
     this.ssa      = ssa;
     this.ssaIds   = ssa.Identifiers;
     this.platform = arch;
     this.m        = new ExpressionEmitter();
 }
Esempio n. 3
0
 public LiveCopyInserter(SsaState ssa)
 {
     this.ssa    = ssa;
     this.ssaIds = ssa.Identifiers;
     this.sla    = new SsaLivenessAnalysis(ssa);
     this.doms   = ssa.Procedure.CreateBlockDominatorGraph();
 }
Esempio n. 4
0
 public SegmentedAccessClassifier(Procedure proc, SsaIdentifierCollection ssaIds)
 {
     this.proc   = proc;
     this.ssaIds = ssaIds;
     assocs      = new Dictionary <Identifier, Identifier>();
     consts      = new Dictionary <Identifier, Constant>();
 }
        public static List <Identifier> Find(SsaIdentifierCollection ssaIds, Expression exp)
        {
            var inst = new ExpressionIdentifierUseFinder(ssaIds);

            exp.Accept(inst);
            return(inst.identifiers);
        }
Esempio n. 6
0
 public ConditionCodeEliminator(SsaState ssa, IPlatform platform, DecompilerEventListener listener)
 {
     this.ssa      = ssa;
     this.ssaIds   = ssa.Identifiers;
     this.platform = platform;
     this.m        = new ExpressionEmitter();
 }
Esempio n. 7
0
 public ValuePropagator(SsaIdentifierCollection ssaIds, Procedure proc)
 {
     this.ssaIds  = ssaIds;
     this.proc    = proc;
     this.evalCtx = new SsaEvaluationContext(ssaIds);
     this.eval    = new ExpressionSimplifier(evalCtx);
 }
Esempio n. 8
0
 public IdentifierReplacer(SsaIdentifierCollection ssaIds, Statement use, Identifier idOld, Expression exprNew, bool replaceDefinitions)
 {
     this.ssaIds             = ssaIds;
     this.use                = use;
     this.idOld              = idOld;
     this.exprNew            = exprNew;
     this.replaceDefinitions = replaceDefinitions;
 }
Esempio n. 9
0
 public ExpressionUseRemover(Statement user, SsaIdentifierCollection ssaIds)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     this.user = user; this.ssaIds = ssaIds;
 }
Esempio n. 10
0
 public IdentifierTransformer(Identifier id, Statement stm, SsaTransform outer)
 {
     this.id          = id;
     this.stm         = stm;
     this.ssaIds      = outer.ssa.Identifiers;
     this.blockstates = outer.blockstates;
     this.outer       = outer;
 }
Esempio n. 11
0
 public InstructionUseAdder(Statement user, SsaIdentifierCollection ssaIds)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     this.user = user; this.ssaIds = ssaIds;
 }
Esempio n. 12
0
 public ConditionCodeEliminator(Program program, SsaState ssa, DecompilerEventListener listener)
 {
     this.ssa      = ssa;
     this.ssaIds   = ssa.Identifiers;
     this.program  = program;
     this.listener = listener;
     this.m        = new ExpressionEmitter();
     this.aliases  = new HashSet <Identifier>();
 }
Esempio n. 13
0
 public SsaLivenessAnalysis(Procedure proc, SsaIdentifierCollection ssaIds)
 {
     this.proc    = proc;
     this.ssaIds  = ssaIds;
     this.visited = new HashSet <Block>();
     BuildRecords(proc.ControlGraph.Blocks);
     BuildDefinedMap(ssaIds);
     BuildInterferenceGraph(ssaIds);
 }
Esempio n. 14
0
 public SsaEvaluationContext(
     IProcessorArchitecture arch,
     SsaIdentifierCollection ssaIds,
     IDynamicLinker dynamicLinker)
 {
     this.arch          = arch;
     this.ssaIds        = ssaIds;
     this.dynamicLinker = dynamicLinker;
 }
 public LinearInductionVariableFinder(Procedure proc, SsaIdentifierCollection ssaIds, BlockDominatorGraph doms)
 {
     this.proc     = proc;
     this.ssaIds   = ssaIds;
     this.doms     = doms;
     this.ctx      = new LinearInductionVariableContext();
     this.ivs      = new List <LinearInductionVariable>();
     this.contexts = new Dictionary <LinearInductionVariable, LinearInductionVariableContext>();
 }
Esempio n. 16
0
 public WebBuilder(Procedure proc, SsaIdentifierCollection ssaIds, Dictionary <Identifier, LinearInductionVariable> ivs)
 {
     this.proc   = proc;
     this.ssaIds = ssaIds;
     this.ivs    = ivs;
     this.sla    = new SsaLivenessAnalysis(proc, ssaIds);
     this.doms   = proc.CreateBlockDominatorGraph();
     this.webs   = new List <Web>();
 }
Esempio n. 17
0
 public SsaLivenessAnalysis(SsaState ssa)
 {
     this.ssa     = ssa;
     this.ssaIds  = ssa.Identifiers;
     this.visited = new HashSet <Block>();
     BuildRecords(ssa.Procedure.ControlGraph.Blocks);
     BuildDefinedMap(ssaIds);
     BuildInterferenceGraph(ssaIds);
 }
Esempio n. 18
0
 public SsaEvaluationContext(
     IProcessorArchitecture arch,
     SsaIdentifierCollection ssaIds,
     IImportResolver importResolver)
 {
     this.arch           = arch;
     this.ssaIds         = ssaIds;
     this.importResolver = importResolver;
 }
Esempio n. 19
0
 public WebBuilder(Program program, SsaState ssa, Dictionary <Identifier, LinearInductionVariable> ivs, DecompilerEventListener listener)
 {
     this.program  = program;
     this.ssa      = ssa;
     this.ssaIds   = ssa.Identifiers;
     this.ivs      = ivs;
     this.listener = listener;
     this.sla      = new SsaLivenessAnalysis(ssa);
     this.doms     = ssa.Procedure.CreateBlockDominatorGraph();
     this.webs     = new List <Web>();
 }
Esempio n. 20
0
        public SsaLivenessAnalysis(SsaState ssa)
        {
            this.ssaIds       = ssa.Identifiers;
            this.visited      = new HashSet <Block>();
            this.records      = new Dictionary <Block, Record>();
            this.defined      = new Dictionary <Statement, List <Identifier> >();
            this.interference = new InterferenceGraph();

            BuildRecords(ssa.Procedure.ControlGraph.Blocks);
            BuildDefinedMap(ssaIds);
            BuildInterferenceGraph(ssaIds);
        }
Esempio n. 21
0
 public TrashedRegisterFinder2(
     IProcessorArchitecture arch,
     ProgramDataFlow flow,
     Procedure proc,
     SsaIdentifierCollection ssa,
     DecompilerEventListener listener)
 {
     this.arch     = arch;
     this.progFlow = flow;
     this.proc     = proc;
     this.ssa      = ssa;
     this.decompilerEventListener = listener;
     this.flow = new ProcedureFlow2();
 }
Esempio n. 22
0
 public void BuildDefinedMap(SsaIdentifierCollection ssaIds)
 {
     foreach (SsaIdentifier ssa in ssaIds)
     {
         if (ssa.Uses.Count > 0 && ssa.DefStatement != null)
         {
             if (!defined.TryGetValue(ssa.DefStatement, out List <Identifier> al))
             {
                 al = new List <Identifier>();
                 defined.Add(ssa.DefStatement, al);
             }
             al.Add(ssa.Identifier);
         }
     }
 }
Esempio n. 23
0
 public void BuildInterferenceGraph(SsaIdentifierCollection ssaIds)
 {
     foreach (SsaIdentifier v in ssaIds)
     {
         visited.Clear();
         foreach (Statement s in v.Uses)
         {
             PhiFunction?phi = GetPhiFunction(s);
             if (phi != null)
             {
                 var p = phi.Arguments.First(e => e.Value == v.Identifier).Block;
                 LiveOutAtBlock(p, v);
             }
             else
             {
                 int i = s.Block.Statements.IndexOf(s);
                 LiveInAtStatement(s.Block, i, v);
             }
         }
     }
 }
Esempio n. 24
0
        public ValueNumbering(SsaIdentifierCollection ssaIds)
        {
            this.ssaIds = ssaIds;
            optimistic  = new Dictionary <Expression, Expression>();
            valid       = new Dictionary <Expression, Expression>();
            stack       = new Stack <Node>();


            // Set initial value numbers for all nodes (SSA identifiers).
            // Value numbers for the original values at procedure entry are just the
            // SSA identifiers, while any other values are undefined.

            AssignInitialValueNumbers();

            // Walk the SCC's of the node graph using Tarjan's algorithm.

            iDFS = 0;
            foreach (var id in nodes.Keys)
            {
                DFS(id);
            }
        }
Esempio n. 25
0
 public void BuildInterferenceGraph(SsaIdentifierCollection ssaIds)
 {
     interference = new InterferenceGraph();
     foreach (SsaIdentifier v in ssaIds)
     {
         visited = new HashSet <Block>();
         foreach (Statement s in v.Uses)
         {
             PhiFunction phi = GetPhiFunction(s);
             if (phi != null)
             {
                 int   i = Array.IndexOf(phi.Arguments, v.Identifier);
                 Block p = s.Block.Pred[i];
                 LiveOutAtBlock(p, v);
             }
             else
             {
                 int i = s.Block.Statements.IndexOf(s);
                 LiveInAtStatement(s.Block, i, v);
             }
         }
     }
 }
Esempio n. 26
0
 public SsaState(Procedure proc, DominatorGraph <Block> domGraph)
 {
     this.Procedure = proc;
     this.DomGraph  = domGraph;
     this.ids       = new SsaIdentifierCollection();
 }
Esempio n. 27
0
 public SsaGraph(SsaIdentifierCollection ssaIds)
 {
     this.ssaIds = ssaIds;
 }
Esempio n. 28
0
 public ExpressionUseRemover(Statement user, SsaIdentifierCollection ssaIds)
 {
     this.user   = user ?? throw new ArgumentNullException(nameof(user));
     this.ssaIds = ssaIds;
 }
Esempio n. 29
0
 public OutParameterTransformer(Procedure proc, SsaIdentifierCollection ssaIds)
 {
     this.proc   = proc;
     this.ssaIds = ssaIds;
 }
Esempio n. 30
0
 public GrfDefinitionFinder(SsaIdentifierCollection ssaIds)
 {
     this.ssaIds = ssaIds;
 }