Ejemplo n.º 1
0
        public virtual void ProcessScc(IList <SsaIdentifier> scc)
        {
            if (scc.Count <= 1)
            {
                return;
            }

            ctx = new LinearInductionVariableContext();
            PhiFunction?phi = FindPhiFunction(scc);

            if (phi == null)
            {
                return;
            }
            ctx.DeltaValue = FindLinearIncrement(scc);
            if (ctx.DeltaValue == null)
            {
                return;
            }
            ctx.InitialValue = FindInitialValue(phi);
            ctx.TestValue    = FindFinalValue(scc);
            LinearInductionVariable?iv = CreateInductionVariable();

            if (iv != null)
            {
                foreach (SsaIdentifier sid in scc)
                {
                    sid.InductionVariable = iv;
                }
                ivs.Add(iv);
                contexts.Add(iv, ctx);
            }
        }
Ejemplo n.º 2
0
 public StrengthReduction(SsaState ssa, LinearInductionVariable liv, LinearInductionVariableContext ctx)
 {
     this.ssa = ssa;
     this.liv = liv;
     this.ctx = ctx;
     incrUses = new List <IncrementedUse>();
 }
Ejemplo n.º 3
0
 public StrengthReduction(SsaState ssa, LinearInductionVariable liv, LinearInductionVariableContext ctx)
 {
     this.ssa = ssa;
     this.liv = liv;
     this.ctx = ctx;
     incrUses = new List<IncrementedUse>();
 }
Ejemplo n.º 4
0
 public LinearInductionVariableFinder(SsaState ssa, BlockDominatorGraph doms)
 {
     this.ssa      = ssa;
     this.doms     = doms;
     this.ctx      = new LinearInductionVariableContext();
     this.ivs      = new List <LinearInductionVariable>();
     this.contexts = new Dictionary <LinearInductionVariable, LinearInductionVariableContext>();
 }
 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>();
 }
Ejemplo n.º 6
0
 private void ModifyTest(LinearInductionVariableContext ctx, IncrementedUse use)
 {
     if (ctx.TestStatement == null)
     {
         return;
     }
     if (ctx.TestStatement.Instruction is Branch branch &&
         branch.Condition is BinaryExpression exp &&
         exp.Right is Constant c)
     {
         exp.Right = Operator.ISub.ApplyConstants(c, use.Increment);
     }
 }
Ejemplo n.º 7
0
 private void ModifyTest(LinearInductionVariableContext ctx, IncrementedUse use)
 {
     if (ctx.TestStatement == null)
         return;
     Branch branch;
     BinaryExpression exp ;
     Constant c ;
     if (ctx.TestStatement.Instruction.As(out branch) &&
         branch.Condition.As(out exp) &&
         exp.Right.As(out c))
     {
         exp.Right = Operator.ISub.ApplyConstants(c, use.Increment);
     }
 }