Пример #1
0
        public void UseExpression(Expression exp)
        {
            if (Statement == null)
            {
                return;
            }
            var xu = new InstructionUseAdder(Statement, ssaIds);

            exp.Accept(xu);
        }
Пример #2
0
            /// <summary>
            /// Given an sequence of adjacent slices, rewrite the sequence a single
            /// slice. If the slice is a no-op, just return the underlying storage.
            /// </summary>
            /// <param name="sids"></param>
            /// <param name="slices"></param>
            /// <returns></returns>
            private Expression RewriteSeqOfSlices(DataType dtSequence, SsaIdentifier[] sids, Slice[] slices)
            {
                // We have:
                //  sid_1 = SLICE(sid_0,...)
                //  sid_2 = SLICE(sid_0,...)
                //  ...
                //  ...SEQ(sid_1, sid_2)
                // We want:
                // ...SLICE(sid_0, ...)
                // and ideally
                // ...sid_0
                foreach (var sid in sids)
                {
                    sid.Uses.Remove(this.Statement);
                }
                var totalSliceSize   = slices.Sum(s => s.DataType.BitSize);
                var totalSliceOffset = slices[slices.Length - 1].Offset;
                var expWide          = slices[0].Expression;
                var ua = new InstructionUseAdder(this.Statement, ssa.Identifiers);

                expWide.Accept(ua);
                if (expWide is Identifier idWide)
                {
                    if ((int)idWide.Storage.BitAddress == totalSliceOffset &&
                        (int)idWide.Storage.BitSize == totalSliceSize)
                    {
                        return(idWide);
                    }
                }
                else
                {
                    if (expWide.DataType.BitSize == totalSliceSize)
                    {
                        return(expWide);
                    }
                }
                return(new Slice(dtSequence, expWide, totalSliceOffset));
            }
Пример #3
0
        private void Use(Expression expr, Statement stm)
        {
            var eua = new InstructionUseAdder(stm, ssaIds);

            expr.Accept(eua);
        }
Пример #4
0
        /// <summary>
        /// Add all identifiers used in <paramref name="stm"/>.
        /// </summary>
        /// <param name="stm"></param>
        public void AddUses(Statement stm)
        {
            var iua = new InstructionUseAdder(stm, Identifiers);

            stm.Instruction.Accept(iua);
        }
Пример #5
0
        public void AddUses(Statement stmUsing, Expression e)
        {
            var iua = new InstructionUseAdder(stmUsing, Identifiers);

            e.Accept(iua);
        }