Пример #1
0
        /// <summary>
        /// Rewrites the blocks in the given cdfg so that every assignment to a local or parameter is to a new local (and thus each local is just
        /// assigned to in exactly one place in the graph). The new names introduced by the writes are connected to the reads in successor blocks
        /// by means of join points (a.k.a. Phi nodes) that are found in the Reads property of an SSABasicBlock.
        /// </summary>
        /// <param name="cdfg">
        /// A set of basic blocks, each of which has a list of successor blocks and some other information.
        /// Each block consists of a list of instructions, each of which can point to previous instructions that compute the operands it consumes.
        /// </param>
        /// <param name="cfgQueries">
        /// Presents information derived from a simple control flow graph. For example, traversal orders, predecessors, dominators and dominance frontiers.
        /// </param>
        /// <param name="nameTable">
        /// An extensible collection of IName instances that represent names that are commonly used during compilation.
        /// </param>
        /// <param name="sourceLocationProvider"></param>
        public static void GetInSingleAssignmentForm(INameTable nameTable, ControlAndDataFlowGraph <BasicBlock, Instruction> cdfg,
                                                     ControlGraphQueries <BasicBlock, Instruction> cfgQueries, ISourceLocationProvider sourceLocationProvider)
        {
            Contract.Requires(nameTable != null);
            Contract.Requires(cdfg != null);
            Contract.Requires(cfgQueries != null);

            var singleAssigner = new SingleAssigner <BasicBlock, Instruction>(nameTable, cdfg, cfgQueries, sourceLocationProvider);

            singleAssigner.GetInSingleAssignmentForm();
        }
Пример #2
0
        /// <summary>
        /// Initializes an instance of SingleAssigner.
        /// </summary>
        /// <param name="cdfg">
        /// A set of basic blocks, each of which has a list of successor blocks and some other information.
        /// Each block consists of a list of instructions, each of which can point to previous instructions that compute the operands it consumes.
        /// </param>
        /// <param name="nameTable">
        /// An extensible collection of IName instances that represent names that are commonly used during compilation.
        /// </param>
        /// <param name="cfgQueries"></param>
        /// <param name="sourceLocationProvider">An object that can map some kinds of ILocation objects to IPrimarySourceLocation objects. May be null.</param>
        private SingleAssigner(INameTable nameTable, ControlAndDataFlowGraph <BasicBlock, Instruction> cdfg,
                               ControlGraphQueries <BasicBlock, Instruction> cfgQueries, ISourceLocationProvider sourceLocationProvider)
        {
            Contract.Requires(nameTable != null);
            Contract.Requires(cdfg != null);
            Contract.Requires(cfgQueries != null);

            this.nameTable              = nameTable;
            this.cdfg                   = cdfg;
            this.cfgQueries             = cfgQueries;
            this.sourceLocationProvider = sourceLocationProvider;
        }