aboutsummaryrefslogtreecommitdiff
path: root/src/ARMeilleure/Instructions/InstEmitHash32.cs
blob: 5d39f8afcdeb48b57e4101edbd54e46dd3fa0c03 (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
using ARMeilleure.Decoders;
using ARMeilleure.IntermediateRepresentation;
using ARMeilleure.Translation;
using static ARMeilleure.Instructions.InstEmitHashHelper;
using static ARMeilleure.Instructions.InstEmitHelper;

namespace ARMeilleure.Instructions
{
    static partial class InstEmit32
    {
        public static void Crc32b(ArmEmitterContext context)
        {
            EmitCrc32Call(context, ByteSizeLog2, false);
        }

        public static void Crc32h(ArmEmitterContext context)
        {
            EmitCrc32Call(context, HWordSizeLog2, false);
        }

        public static void Crc32w(ArmEmitterContext context)
        {
            EmitCrc32Call(context, WordSizeLog2, false);
        }

        public static void Crc32cb(ArmEmitterContext context)
        {
            EmitCrc32Call(context, ByteSizeLog2, true);
        }

        public static void Crc32ch(ArmEmitterContext context)
        {
            EmitCrc32Call(context, HWordSizeLog2, true);
        }

        public static void Crc32cw(ArmEmitterContext context)
        {
            EmitCrc32Call(context, WordSizeLog2, true);
        }

        private static void EmitCrc32Call(ArmEmitterContext context, int size, bool c)
        {
            IOpCode32AluReg op = (IOpCode32AluReg)context.CurrOp;

            Operand n = GetIntA32(context, op.Rn);
            Operand m = GetIntA32(context, op.Rm);

            Operand d = EmitCrc32(context, n, m, size, c);

            EmitAluStore(context, d);
        }
    }
}