コード例 #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);
            }
        }
コード例 #2
0
 public StrengthReduction(SsaState ssa, LinearInductionVariable liv, LinearInductionVariableContext ctx)
 {
     this.ssa = ssa;
     this.liv = liv;
     this.ctx = ctx;
     incrUses = new List <IncrementedUse>();
 }
コード例 #3
0
ファイル: StrengthReduction.cs プロジェクト: nemerle/reko
 public StrengthReduction(SsaState ssa, LinearInductionVariable liv, LinearInductionVariableContext ctx)
 {
     this.ssa = ssa;
     this.liv = liv;
     this.ctx = ctx;
     incrUses = new List<IncrementedUse>();
 }
コード例 #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>();
 }
コード例 #5
0
 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>();
 }
コード例 #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);
     }
 }
コード例 #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);
     }
 }