aboutsummaryrefslogtreecommitdiff
path: root/src/ARMeilleure/Decoders/OpCodeSimdMemMs.cs
blob: c05b52494865a8bfb495c35520fd20703e5b5780 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
namespace ARMeilleure.Decoders
{
    class OpCodeSimdMemMs : OpCodeMemReg, IOpCodeSimd
    {
        public int Reps { get; }
        public int SElems { get; }
        public int Elems { get; }
        public bool WBack { get; }

        public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCodeSimdMemMs(inst, address, opCode);

        public OpCodeSimdMemMs(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
        {
            switch ((opCode >> 12) & 0xf)
            {
                case 0b0000:
                    Reps = 1;
                    SElems = 4;
                    break;
                case 0b0010:
                    Reps = 4;
                    SElems = 1;
                    break;
                case 0b0100:
                    Reps = 1;
                    SElems = 3;
                    break;
                case 0b0110:
                    Reps = 3;
                    SElems = 1;
                    break;
                case 0b0111:
                    Reps = 1;
                    SElems = 1;
                    break;
                case 0b1000:
                    Reps = 1;
                    SElems = 2;
                    break;
                case 0b1010:
                    Reps = 2;
                    SElems = 1;
                    break;

                default:
                    Instruction = InstDescriptor.Undefined;
                    return;
            }

            Size = (opCode >> 10) & 3;
            WBack = ((opCode >> 23) & 1) != 0;

            bool q = ((opCode >> 30) & 1) != 0;

            if (!q && Size == 3 && SElems != 1)
            {
                Instruction = InstDescriptor.Undefined;

                return;
            }

            Extend64 = false;

            RegisterSize = q
                ? RegisterSize.Simd128
                : RegisterSize.Simd64;

            Elems = (GetBitsCount() >> 3) >> Size;
        }
    }
}