aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitNeonRound.cs
blob: 3c6ca65d0e8c475b4933c4a062e547251f5e11ed (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
{
    static class InstEmitNeonRound
    {
        public static void Vraddhn(CodeGenContext context, uint rd, uint rn, uint rm, uint size)
        {
            InstEmitNeonCommon.EmitVectorBinaryNarrow(context, rd, rn, rm, size, context.Arm64Assembler.Raddhn);
        }

        public static void Vrhadd(CodeGenContext context, uint rd, uint rn, uint rm, bool u, uint size, uint q)
        {
            InstEmitNeonCommon.EmitVectorBinary(context, rd, rn, rm, size, q, u ? context.Arm64Assembler.Urhadd : context.Arm64Assembler.Srhadd, null);
        }

        public static void Vrshl(CodeGenContext context, uint rd, uint rn, uint rm, bool u, uint size, uint q)
        {
            InstEmitNeonCommon.EmitVectorBinary(
                context,
                rd,
                rm,
                rn,
                size,
                q,
                u ? context.Arm64Assembler.UrshlV : context.Arm64Assembler.SrshlV,
                u ? context.Arm64Assembler.UrshlS : context.Arm64Assembler.SrshlS);
        }

        public static void Vrshr(CodeGenContext context, uint rd, uint rm, bool u, uint l, uint imm6, uint q)
        {
            uint size = InstEmitNeonCommon.GetSizeFromImm7(imm6 | (l << 6));
            uint shift = InstEmitNeonShift.GetShiftRight(imm6, size);

            InstEmitNeonCommon.EmitVectorBinaryShift(
                context,
                rd,
                rm,
                shift,
                size,
                q,
                isShl: false,
                u ? context.Arm64Assembler.UrshrV : context.Arm64Assembler.SrshrV,
                u ? context.Arm64Assembler.UrshrS : context.Arm64Assembler.SrshrS);
        }

        public static void Vrshrn(CodeGenContext context, uint rd, uint rm, uint imm6)
        {
            uint size = InstEmitNeonCommon.GetSizeFromImm6(imm6);
            uint shift = InstEmitNeonShift.GetShiftRight(imm6, size);

            InstEmitNeonCommon.EmitVectorBinaryNarrowShift(context, rd, rm, shift, size, isShl: false, context.Arm64Assembler.Rshrn);
        }

        public static void Vrsra(CodeGenContext context, uint rd, uint rm, bool u, uint l, uint imm6, uint q)
        {
            uint size = InstEmitNeonCommon.GetSizeFromImm7(imm6 | (l << 6));
            uint shift = InstEmitNeonShift.GetShiftRight(imm6, size);

            InstEmitNeonCommon.EmitVectorTernaryRdShift(
                context,
                rd,
                rm,
                shift,
                size,
                q,
                isShl: false,
                u ? context.Arm64Assembler.UrsraV : context.Arm64Assembler.SrsraV,
                u ? context.Arm64Assembler.UrsraS : context.Arm64Assembler.SrsraS);
        }

        public static void Vrsubhn(CodeGenContext context, uint rd, uint rn, uint rm, uint size)
        {
            InstEmitNeonCommon.EmitVectorBinaryNarrow(context, rd, rn, rm, size, context.Arm64Assembler.Rsubhn);
        }

        public static void Vrinta(CodeGenContext context, uint rd, uint rm, uint size, uint q)
        {
            InstEmitNeonCommon.EmitVectorUnaryAnyF(context, rd, rm, size, q, context.Arm64Assembler.FrintaSingleAndDouble, context.Arm64Assembler.FrintaHalf);
        }

        public static void Vrintm(CodeGenContext context, uint rd, uint rm, uint size, uint q)
        {
            InstEmitNeonCommon.EmitVectorUnaryAnyF(context, rd, rm, size, q, context.Arm64Assembler.FrintmSingleAndDouble, context.Arm64Assembler.FrintmHalf);
        }

        public static void Vrintn(CodeGenContext context, uint rd, uint rm, uint size, uint q)
        {
            InstEmitNeonCommon.EmitVectorUnaryAnyF(context, rd, rm, size, q, context.Arm64Assembler.FrintnSingleAndDouble, context.Arm64Assembler.FrintnHalf);
        }

        public static void Vrintp(CodeGenContext context, uint rd, uint rm, uint size, uint q)
        {
            InstEmitNeonCommon.EmitVectorUnaryAnyF(context, rd, rm, size, q, context.Arm64Assembler.FrintpSingleAndDouble, context.Arm64Assembler.FrintpHalf);
        }

        public static void Vrintx(CodeGenContext context, uint rd, uint rm, uint size, uint q)
        {
            InstEmitNeonCommon.EmitVectorUnaryAnyF(context, rd, rm, size, q, context.Arm64Assembler.FrintxSingleAndDouble, context.Arm64Assembler.FrintxHalf);
        }

        public static void Vrintz(CodeGenContext context, uint rd, uint rm, uint size, uint q)
        {
            InstEmitNeonCommon.EmitVectorUnaryAnyF(context, rd, rm, size, q, context.Arm64Assembler.FrintzSingleAndDouble, context.Arm64Assembler.FrintzHalf);
        }
    }
}