public static void Vrev(ArmEmitterContext context)
        {
            OpCode32Simd op = (OpCode32Simd)context.CurrOp;

            EmitVectorUnaryOpZx32(context, (op1) =>
            {
                switch (op.Opc)
                {
                case 0:
                    switch (op.Size)     // Swap bytes.
                    {
                    default:
                        return(op1);

                    case 1:
                        return(InstEmitAluHelper.EmitReverseBytes16_32Op(context, op1));

                    case 2:
                    case 3:
                        return(context.ByteSwap(op1));
                    }

                case 1:
                    switch (op.Size)
                    {
                    default:
                        return(op1);

                    case 2:
                        return(context.BitwiseOr(context.ShiftRightUI(context.BitwiseAnd(op1, Const(0xffff0000)), Const(16)),
                                                 context.ShiftLeft(context.BitwiseAnd(op1, Const(0x0000ffff)), Const(16))));

                    case 3:
                        return(context.BitwiseOr(
                                   context.BitwiseOr(context.ShiftRightUI(context.BitwiseAnd(op1, Const(0xffff000000000000ul)), Const(48)),
                                                     context.ShiftLeft(context.BitwiseAnd(op1, Const(0x000000000000fffful)), Const(48))),
                                   context.BitwiseOr(context.ShiftRightUI(context.BitwiseAnd(op1, Const(0x0000ffff00000000ul)), Const(16)),
                                                     context.ShiftLeft(context.BitwiseAnd(op1, Const(0x00000000ffff0000ul)), Const(16)))));
                    }

                case 2:
                    // Swap upper and lower halves.
                    return(context.BitwiseOr(context.ShiftRightUI(context.BitwiseAnd(op1, Const(0xffffffff00000000ul)), Const(32)),
                                             context.ShiftLeft(context.BitwiseAnd(op1, Const(0x00000000fffffffful)), Const(32))));
                }

                return(op1);
            });
        }
Beispiel #2
0
        public static Operand GetMShiftedByImmediate(ArmEmitterContext context, OpCode32MemRsImm op, bool setCarry)
        {
            Operand m = GetIntA32(context, op.Rm);

            int shift = op.Immediate;

            if (shift == 0)
            {
                switch (op.ShiftType)
                {
                case ShiftType.Lsr: shift = 32; break;

                case ShiftType.Asr: shift = 32; break;

                case ShiftType.Ror: shift = 1; break;
                }
            }

            if (shift != 0)
            {
                setCarry &= false;

                switch (op.ShiftType)
                {
                case ShiftType.Lsl: m = InstEmitAluHelper.GetLslC(context, m, setCarry, shift); break;

                case ShiftType.Lsr: m = InstEmitAluHelper.GetLsrC(context, m, setCarry, shift); break;

                case ShiftType.Asr: m = InstEmitAluHelper.GetAsrC(context, m, setCarry, shift); break;

                case ShiftType.Ror:
                    if (op.Immediate != 0)
                    {
                        m = InstEmitAluHelper.GetRorC(context, m, setCarry, shift);
                    }
                    else
                    {
                        m = InstEmitAluHelper.GetRrxC(context, m, setCarry);
                    }
                    break;
                }
            }

            return(m);
        }