aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Instructions/InstEmitHash.cs
blob: 0be8458e20b67534f7436607118ffb801f34c7d3 (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
using ARMeilleure.Decoders;
using ARMeilleure.IntermediateRepresentation;
using ARMeilleure.Translation;
using System;

using static ARMeilleure.Instructions.InstEmitHelper;

namespace ARMeilleure.Instructions
{
    static partial class InstEmit
    {
        public static void Crc32b(ArmEmitterContext context)
        {
            EmitCrc32Call(context, new _U32_U32_U8(SoftFallback.Crc32b));
        }

        public static void Crc32h(ArmEmitterContext context)
        {
            EmitCrc32Call(context, new _U32_U32_U16(SoftFallback.Crc32h));
        }

        public static void Crc32w(ArmEmitterContext context)
        {
            EmitCrc32Call(context, new _U32_U32_U32(SoftFallback.Crc32w));
        }

        public static void Crc32x(ArmEmitterContext context)
        {
            EmitCrc32Call(context, new _U32_U32_U64(SoftFallback.Crc32x));
        }

        public static void Crc32cb(ArmEmitterContext context)
        {
            EmitCrc32Call(context, new _U32_U32_U8(SoftFallback.Crc32cb));
        }

        public static void Crc32ch(ArmEmitterContext context)
        {
            EmitCrc32Call(context, new _U32_U32_U16(SoftFallback.Crc32ch));
        }

        public static void Crc32cw(ArmEmitterContext context)
        {
            EmitCrc32Call(context, new _U32_U32_U32(SoftFallback.Crc32cw));
        }

        public static void Crc32cx(ArmEmitterContext context)
        {
            EmitCrc32Call(context, new _U32_U32_U64(SoftFallback.Crc32cx));
        }

        private static void EmitCrc32Call(ArmEmitterContext context, Delegate dlg)
        {
            OpCodeAluBinary op = (OpCodeAluBinary)context.CurrOp;

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

            Operand d = context.Call(dlg, n, m);

            SetIntOrZR(context, op.Rd, d);
        }
    }
}