Ejemplo n.º 1
0
        /// <summary>
        /// Finds all interprocedural register dependencies (in- and out-parameters) and
        /// abstracts them away by rewriting as calls.
        /// </summary>
        /// <returns>A RegisterLiveness object that summarizes the interprocedural register
        /// liveness analysis. This information can be used to generate SSA form.
        /// </returns>
        public void UntangleProcedures()
        {
            eventListener.ShowStatus("Eliminating intra-block dead registers.");
            IntraBlockDeadRegisters.Apply(program);
            eventListener.ShowStatus("Finding terminating procedures.");
            var term = new TerminationAnalysis(flow);

            term.Analyze(program);
            eventListener.ShowStatus("Finding trashed registers.");
            var trf = new TrashedRegisterFinder(program, program.Procedures.Values, flow, eventListener);

            trf.Compute();
            eventListener.ShowStatus("Rewriting affine expressions.");
            trf.RewriteBasicBlocks();
            eventListener.ShowStatus("Computing register liveness.");
            var rl = RegisterLiveness.Compute(program, flow, eventListener);

            eventListener.ShowStatus("Rewriting calls.");
            GlobalCallRewriter.Rewrite(program, flow);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds all interprocedural register dependencies (in- and out-parameters) and
        /// abstracts them away by rewriting as calls.
        /// </summary>
        /// <returns>A RegisterLiveness object that summarizes the interprocedural register
        /// liveness analysis. This information can be used to generate SSA form.
        /// </returns>
        public void UntangleProcedures()
        {
            eventListener.ShowStatus("Eliminating intra-block dead registers.");
            var usb = new UserSignatureBuilder(program);

            usb.BuildSignatures(eventListener);
            CallRewriter.Rewrite(program, eventListener);
            IntraBlockDeadRegisters.Apply(program, eventListener);
            AdjacentBranchCollector.Transform(program, eventListener);
            eventListener.ShowStatus("Finding terminating procedures.");
            var term = new TerminationAnalysis(flow, eventListener);

            term.Analyze(program);
            eventListener.ShowStatus("Finding trashed registers.");
            var trf = new TrashedRegisterFinder(program, program.Procedures.Values, flow, eventListener);

            trf.Compute();
            eventListener.ShowStatus("Rewriting affine expressions.");
            trf.RewriteBasicBlocks();
            eventListener.ShowStatus("Computing register liveness.");
            RegisterLiveness.Compute(program, flow, eventListener);
            eventListener.ShowStatus("Rewriting calls.");
            GlobalCallRewriter.Rewrite(program, flow, eventListener);
        }