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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
{
static class InstEmitNeonShift
{
public static void Vshll(CodeGenContext context, uint rd, uint rm, uint imm6, bool u)
{
uint size = InstEmitNeonCommon.GetSizeFromImm7(imm6);
uint shift = GetShiftLeft(imm6, size);
InstEmitNeonCommon.EmitVectorBinaryLongShift(context, rd, rm, shift, size, isShl: true, u ? context.Arm64Assembler.Ushll : context.Arm64Assembler.Sshll);
}
public static void Vshll2(CodeGenContext context, uint rd, uint rm, uint size)
{
// Shift can't be encoded, so shift by value - 1 first, then first again by 1.
// Doesn't matter if we do a signed or unsigned shift in this case since all sign bits will be shifted out.
uint shift = 8u << (int)size;
InstEmitNeonCommon.EmitVectorBinaryLongShift(context, rd, rm, shift - 1, size, isShl: true, context.Arm64Assembler.Sshll);
InstEmitNeonCommon.EmitVectorBinaryLongShift(context, rd, rd, 1, size, isShl: true, context.Arm64Assembler.Sshll);
}
public static void VshlI(CodeGenContext context, uint rd, uint rm, uint l, uint imm6, uint q)
{
uint size = InstEmitNeonCommon.GetSizeFromImm7(imm6 | (l << 6));
uint shift = GetShiftLeft(imm6, size);
InstEmitNeonCommon.EmitVectorBinaryShift(context, rd, rm, shift, size, q, isShl: true, context.Arm64Assembler.ShlV, context.Arm64Assembler.ShlS);
}
public static void VshlR(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.UshlV : context.Arm64Assembler.SshlV,
u ? context.Arm64Assembler.UshlS : context.Arm64Assembler.SshlS);
}
public static void Vshr(CodeGenContext context, uint rd, uint rm, bool u, uint l, uint imm6, uint q)
{
uint size = InstEmitNeonCommon.GetSizeFromImm7(imm6 | (l << 6));
uint shift = GetShiftRight(imm6, size);
InstEmitNeonCommon.EmitVectorBinaryShift(
context,
rd,
rm,
shift,
size,
q,
isShl: false,
u ? context.Arm64Assembler.UshrV : context.Arm64Assembler.SshrV,
u ? context.Arm64Assembler.UshrS : context.Arm64Assembler.SshrS);
}
public static void Vshrn(CodeGenContext context, uint rd, uint rm, uint imm6)
{
uint size = InstEmitNeonCommon.GetSizeFromImm6(imm6);
uint shift = GetShiftRight(imm6, size);
InstEmitNeonCommon.EmitVectorBinaryNarrowShift(context, rd, rm, shift, size, isShl: false, context.Arm64Assembler.Shrn);
}
public static void Vsli(CodeGenContext context, uint rd, uint rm, uint l, uint imm6, uint q)
{
uint size = InstEmitNeonCommon.GetSizeFromImm7(imm6 | (l << 6));
uint shift = GetShiftLeft(imm6, size);
InstEmitNeonCommon.EmitVectorBinaryShift(
context,
rd,
rm,
shift,
size,
q,
isShl: true,
context.Arm64Assembler.SliV,
context.Arm64Assembler.SliS);
}
public static void Vsra(CodeGenContext context, uint rd, uint rm, bool u, uint l, uint imm6, uint q)
{
uint size = InstEmitNeonCommon.GetSizeFromImm7(imm6 | (l << 6));
uint shift = GetShiftRight(imm6, size);
InstEmitNeonCommon.EmitVectorTernaryRdShift(
context,
rd,
rm,
shift,
size,
q,
isShl: false,
u ? context.Arm64Assembler.UsraV : context.Arm64Assembler.SsraV,
u ? context.Arm64Assembler.UsraS : context.Arm64Assembler.SsraS);
}
public static void Vsri(CodeGenContext context, uint rd, uint rm, uint l, uint imm6, uint q)
{
uint size = InstEmitNeonCommon.GetSizeFromImm7(imm6 | (l << 6));
uint shift = GetShiftRight(imm6, size);
InstEmitNeonCommon.EmitVectorBinaryShift(context, rd, rm, shift, size, q, isShl: false, context.Arm64Assembler.SriV, context.Arm64Assembler.SriS);
}
public static uint GetShiftLeft(uint imm6, uint size)
{
return size < 3 ? imm6 - (8u << (int)size) : imm6;
}
public static uint GetShiftRight(uint imm6, uint size)
{
return (size == 3 ? 64u : (16u << (int)size)) - imm6;
;
}
}
}
|