Esempio n. 1
0
 public static void Transform(ControlFlowGraph cfg, SsaForm ssa, bool optimize = true)
 {
     TransformToSsa transform = new TransformToSsa(cfg, ssa);
     transform.ConvertVariablesToSsa();
     SsaOptimization.RemoveDeadAssignments(ssa); // required so that 'MakeByRefCallsSimple' can detect more cases
     if (SimplifyByRefCalls.MakeByRefCallsSimple(ssa)) {
         transform.ConvertVariablesToSsa();
     }
     if (optimize)
         SsaOptimization.Optimize(ssa);
 }
Esempio n. 2
0
 public static SsaForm Build(MethodDefinition method)
 {
     if (method == null)
         throw new ArgumentNullException("method");
     var cfg = ControlFlowGraphBuilder.Build(method.Body);
     cfg.ComputeDominance();
     cfg.ComputeDominanceFrontier();
     var ssa = BuildRegisterIL(method, cfg);
     TransformToSsa.Transform(cfg, ssa);
     return ssa;
 }
Esempio n. 3
0
        public static void Transform(ControlFlowGraph cfg, SsaForm ssa, bool optimize = true)
        {
            TransformToSsa transform = new TransformToSsa(cfg, ssa);

            transform.ConvertVariablesToSsa();
            SsaOptimization.RemoveDeadAssignments(ssa);             // required so that 'MakeByRefCallsSimple' can detect more cases
            if (SimplifyByRefCalls.MakeByRefCallsSimple(ssa))
            {
                transform.ConvertVariablesToSsa();
            }
            if (optimize)
            {
                SsaOptimization.Optimize(ssa);
            }
        }
Esempio n. 4
0
            int[] versionCounters;             // specifies for each input variable the next version number

            // processVariable = specifies for each input variable whether we should rename it
            public VariableRenamer(TransformToSsa transform, bool[] processVariable)
            {
                this.transform = transform;
                inputVariables = transform.ssaForm.OriginalVariables;
                Debug.Assert(inputVariables.Count == processVariable.Length);
                versionCounters = new int[inputVariables.Count];
                versionStacks   = new Stack <SsaVariable> [inputVariables.Count];
                for (int i = 0; i < versionStacks.Length; i++)
                {
                    if (processVariable[i])
                    {
                        Debug.Assert(inputVariables[i].IsSingleAssignment == false);
                        // only create version stacks for the variables that we need to process and that weren't already processed earlier
                        versionStacks[i] = new Stack <SsaVariable>();
                        versionStacks[i].Push(inputVariables[i]);
                    }
                }
            }
Esempio n. 5
0
            int[] versionCounters; // specifies for each input variable the next version number

            #endregion Fields

            #region Constructors

            // processVariable = specifies for each input variable whether we should rename it
            public VariableRenamer(TransformToSsa transform, bool[] processVariable)
            {
                this.transform = transform;
                this.inputVariables = transform.ssaForm.OriginalVariables;
                Debug.Assert(inputVariables.Count == processVariable.Length);
                this.versionCounters = new int[inputVariables.Count];
                this.versionStacks = new Stack<SsaVariable>[inputVariables.Count];
                for (int i = 0; i < versionStacks.Length; i++) {
                    if (processVariable[i]) {
                        Debug.Assert(inputVariables[i].IsSingleAssignment == false);
                        // only create version stacks for the variables that we need to process and that weren't already processed earlier
                        versionStacks[i] = new Stack<SsaVariable>();
                        versionStacks[i].Push(inputVariables[i]);
                    }
                }
            }