Esempio n. 1
0
        private Expression RewriteExtract(Domain domain, Expression expression, MachineOperand[] operands)
        {
            var dt = PrimitiveType.Create(domain, operands[0].Width.BitSize);

            if (operands[1] is RegisterPairOperand pair)
            {
                var offset = binder.EnsureRegister(pair.LowRegister);
                var width  = binder.EnsureRegister(pair.HighRegister);
                return(m.And(
                           m.Shl(expression, offset),
                           m.ISub(m.Shl(Constant.UInt64(1), width), 1)));
            }
            else
            {
                var width   = ((ImmediateOperand)operands[2]).Value.ToInt32();
                var offset  = ((ImmediateOperand)operands[1]).Value.ToInt32();
                var dtSlice = PrimitiveType.CreateBitSlice(width);
                var slice   = m.Slice(dtSlice, expression, offset);
                return(m.Convert(slice, dtSlice, dt));
            }
        }
Esempio n. 2
0
        public Slice Slice(Expression value, int bitOffset, int bitlength)
        {
            var type = PrimitiveType.CreateBitSlice(bitlength);

            return(new Slice(type, value, bitOffset));
        }