1#define GEN_VR_LDX(name, opc2, opc3)                                          \
2GEN_HANDLER(name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC)
3#define GEN_VR_STX(name, opc2, opc3)                                          \
4GEN_HANDLER(st##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC)
5#define GEN_VR_LVE(name, opc2, opc3)                                    \
6    GEN_HANDLER(lve##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC)
7#define GEN_VR_STVE(name, opc2, opc3)                                   \
8    GEN_HANDLER(stve##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC)
9GEN_VR_LDX(lvx, 0x07, 0x03),
10GEN_VR_LDX(lvxl, 0x07, 0x0B),
11GEN_VR_LVE(bx, 0x07, 0x00),
12GEN_VR_LVE(hx, 0x07, 0x01),
13GEN_VR_LVE(wx, 0x07, 0x02),
14GEN_VR_STX(svx, 0x07, 0x07),
15GEN_VR_STX(svxl, 0x07, 0x0F),
16GEN_VR_STVE(bx, 0x07, 0x04),
17GEN_VR_STVE(hx, 0x07, 0x05),
18GEN_VR_STVE(wx, 0x07, 0x06),
19
20#define GEN_VX_LOGICAL(name, tcg_op, opc2, opc3)                        \
21GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
22
23#define GEN_VX_LOGICAL_207(name, tcg_op, opc2, opc3) \
24GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207)
25
26GEN_VX_LOGICAL(vand, tcg_gen_and_i64, 2, 16),
27GEN_VX_LOGICAL(vandc, tcg_gen_andc_i64, 2, 17),
28GEN_VX_LOGICAL(vor, tcg_gen_or_i64, 2, 18),
29GEN_VX_LOGICAL(vxor, tcg_gen_xor_i64, 2, 19),
30GEN_VX_LOGICAL(vnor, tcg_gen_nor_i64, 2, 20),
31GEN_VX_LOGICAL_207(veqv, tcg_gen_eqv_i64, 2, 26),
32GEN_VX_LOGICAL_207(vnand, tcg_gen_nand_i64, 2, 22),
33GEN_VX_LOGICAL_207(vorc, tcg_gen_orc_i64, 2, 21),
34
35#define GEN_VXFORM(name, opc2, opc3)                                    \
36GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
37
38#define GEN_VXFORM_207(name, opc2, opc3) \
39GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207)
40
41#define GEN_VXFORM_300(name, opc2, opc3)                                \
42GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ISA300)
43
44#define GEN_VXFORM_300_EXT(name, opc2, opc3, inval)                     \
45GEN_HANDLER_E(name, 0x04, opc2, opc3, inval, PPC_NONE, PPC2_ISA300)
46
47#define GEN_VXFORM_300_EO(name, opc2, opc3, opc4)                     \
48GEN_HANDLER_E_2(name, 0x04, opc2, opc3, opc4, 0x00000000, PPC_NONE,     \
49                                                       PPC2_ISA300)
50
51#define GEN_VXFORM_310(name, opc2, opc3)                                \
52GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ISA310)
53
54#define GEN_VXFORM_DUAL(name0, name1, opc2, opc3, type0, type1) \
55GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, type0, type1)
56
57#define GEN_VXRFORM_DUAL(name0, name1, opc2, opc3, tp0, tp1) \
58GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, tp0, tp1), \
59GEN_HANDLER_E(name0##_##name1, 0x4, opc2, (opc3 | 0x10), 0x00000000, tp0, tp1),
60
61GEN_VXFORM_DUAL(vaddubm, vmul10cuq, 0, 0, PPC_ALTIVEC, PPC_NONE),
62GEN_VXFORM_DUAL(vadduhm, vmul10ecuq, 0, 1, PPC_ALTIVEC, PPC_NONE),
63GEN_VXFORM(vadduwm, 0, 2),
64GEN_VXFORM_207(vaddudm, 0, 3),
65GEN_VXFORM_DUAL(vsububm, bcdadd, 0, 16, PPC_ALTIVEC, PPC_NONE),
66GEN_VXFORM_DUAL(vsubuhm, bcdsub, 0, 17, PPC_ALTIVEC, PPC_NONE),
67GEN_VXFORM_DUAL(vsubuwm, bcdus, 0, 18, PPC_ALTIVEC, PPC2_ISA300),
68GEN_VXFORM_DUAL(vsubudm, bcds, 0, 19, PPC2_ALTIVEC_207, PPC2_ISA300),
69GEN_VXFORM_300(bcds, 0, 27),
70GEN_VXFORM(vmaxub, 1, 0),
71GEN_VXFORM(vmaxuh, 1, 1),
72GEN_VXFORM(vmaxuw, 1, 2),
73GEN_VXFORM_207(vmaxud, 1, 3),
74GEN_VXFORM(vmaxsb, 1, 4),
75GEN_VXFORM(vmaxsh, 1, 5),
76GEN_VXFORM(vmaxsw, 1, 6),
77GEN_VXFORM_207(vmaxsd, 1, 7),
78GEN_VXFORM(vminub, 1, 8),
79GEN_VXFORM(vminuh, 1, 9),
80GEN_VXFORM(vminuw, 1, 10),
81GEN_VXFORM_207(vminud, 1, 11),
82GEN_VXFORM(vminsb, 1, 12),
83GEN_VXFORM(vminsh, 1, 13),
84GEN_VXFORM(vminsw, 1, 14),
85GEN_VXFORM_207(vminsd, 1, 15),
86GEN_VXFORM(vmrghb, 6, 0),
87GEN_VXFORM(vmrghh, 6, 1),
88GEN_VXFORM(vmrghw, 6, 2),
89GEN_VXFORM(vmrglb, 6, 4),
90GEN_VXFORM(vmrglh, 6, 5),
91GEN_VXFORM(vmrglw, 6, 6),
92GEN_VXFORM_300(vextublx, 6, 24),
93GEN_VXFORM_300(vextuhlx, 6, 25),
94GEN_VXFORM_DUAL(vmrgow, vextuwlx, 6, 26, PPC_NONE, PPC2_ALTIVEC_207),
95GEN_VXFORM_300(vextubrx, 6, 28),
96GEN_VXFORM_300(vextuhrx, 6, 29),
97GEN_VXFORM_DUAL(vmrgew, vextuwrx, 6, 30, PPC_NONE, PPC2_ALTIVEC_207),
98GEN_VXFORM_207(vmuluwm, 4, 2),
99GEN_VXFORM_300(vsrv, 2, 28),
100GEN_VXFORM_300(vslv, 2, 29),
101GEN_VXFORM(vslo, 6, 16),
102GEN_VXFORM(vsro, 6, 17),
103
104GEN_VXFORM(xpnd04_1, 0, 22),
105GEN_VXFORM_300(bcdsr, 0, 23),
106GEN_VXFORM_300(bcdsr, 0, 31),
107GEN_VXFORM_DUAL(vaddubs, vmul10uq, 0, 8, PPC_ALTIVEC, PPC_NONE),
108GEN_VXFORM_DUAL(vadduhs, vmul10euq, 0, 9, PPC_ALTIVEC, PPC_NONE),
109GEN_VXFORM(vadduws, 0, 10),
110GEN_VXFORM(vaddsbs, 0, 12),
111GEN_VXFORM_DUAL(vaddshs, bcdcpsgn, 0, 13, PPC_ALTIVEC, PPC_NONE),
112GEN_VXFORM(vaddsws, 0, 14),
113GEN_VXFORM_DUAL(vsububs, bcdadd, 0, 24, PPC_ALTIVEC, PPC_NONE),
114GEN_VXFORM_DUAL(vsubuhs, bcdsub, 0, 25, PPC_ALTIVEC, PPC_NONE),
115GEN_VXFORM(vsubuws, 0, 26),
116GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
117GEN_VXFORM(vsubshs, 0, 29),
118GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
119GEN_VXFORM_300(bcdtrunc, 0, 20),
120GEN_VXFORM_300(bcdutrunc, 0, 21),
121GEN_VXFORM(vsl, 2, 7),
122GEN_VXFORM(vsr, 2, 11),
123GEN_VXFORM(vpkuhum, 7, 0),
124GEN_VXFORM(vpkuwum, 7, 1),
125GEN_VXFORM_207(vpkudum, 7, 17),
126GEN_VXFORM(vpkuhus, 7, 2),
127GEN_VXFORM(vpkuwus, 7, 3),
128GEN_VXFORM_207(vpkudus, 7, 19),
129GEN_VXFORM(vpkshus, 7, 4),
130GEN_VXFORM(vpkswus, 7, 5),
131GEN_VXFORM_207(vpksdus, 7, 21),
132GEN_VXFORM(vpkshss, 7, 6),
133GEN_VXFORM(vpkswss, 7, 7),
134GEN_VXFORM_207(vpksdss, 7, 23),
135GEN_VXFORM(vpkpx, 7, 12),
136GEN_VXFORM(vsum4ubs, 4, 24),
137GEN_VXFORM(vsum4sbs, 4, 28),
138GEN_VXFORM(vsum4shs, 4, 25),
139GEN_VXFORM(vsum2sws, 4, 26),
140GEN_VXFORM(vsumsws, 4, 30),
141GEN_VXFORM(vaddfp, 5, 0),
142GEN_VXFORM(vsubfp, 5, 1),
143GEN_VXFORM(vmaxfp, 5, 16),
144GEN_VXFORM(vminfp, 5, 17),
145
146#define GEN_VXRFORM1(opname, name, str, opc2, opc3)                     \
147    GEN_HANDLER2(name, str, 0x4, opc2, opc3, 0x00000000, PPC_ALTIVEC),
148#define GEN_VXRFORM1_300(opname, name, str, opc2, opc3)                 \
149GEN_HANDLER2_E(name, str, 0x4, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ISA300),
150#define GEN_VXRFORM(name, opc2, opc3)                                \
151    GEN_VXRFORM1(name, name, #name, opc2, opc3)                      \
152    GEN_VXRFORM1(name##_dot, name##_, #name ".", opc2, (opc3 | (0x1 << 4)))
153#define GEN_VXRFORM_300(name, opc2, opc3)                                   \
154    GEN_VXRFORM1_300(name, name, #name, opc2, opc3)                         \
155    GEN_VXRFORM1_300(name##_dot, name##_, #name ".", opc2, (opc3 | (0x1 << 4)))
156
157GEN_VXRFORM(vcmpeqfp, 3, 3)
158GEN_VXRFORM(vcmpgefp, 3, 7)
159GEN_VXRFORM(vcmpgtfp, 3, 11)
160GEN_VXRFORM(vcmpbfp, 3, 15)
161
162#define GEN_VXFORM_DUAL_INV(name0, name1, opc2, opc3, inval0, inval1, type) \
163GEN_OPCODE_DUAL(name0##_##name1, 0x04, opc2, opc3, inval0, inval1, type, \
164                                                               PPC_NONE)
165GEN_VXFORM_DUAL_INV(vspltb, vextractub, 6, 8, 0x00000000, 0x100000,
166                                               PPC_ALTIVEC),
167GEN_VXFORM_DUAL_INV(vsplth, vextractuh, 6, 9, 0x00000000, 0x100000,
168                                               PPC_ALTIVEC),
169GEN_VXFORM_DUAL_INV(vspltw, vextractuw, 6, 10, 0x00000000, 0x100000,
170                                               PPC_ALTIVEC),
171GEN_VXFORM_300_EXT(vextractd, 6, 11, 0x100000),
172GEN_VXFORM(vspltisb, 6, 12),
173GEN_VXFORM(vspltish, 6, 13),
174GEN_VXFORM(vspltisw, 6, 14),
175GEN_VXFORM_300_EO(vctzb, 0x01, 0x18, 0x1C),
176GEN_VXFORM_300_EO(vctzh, 0x01, 0x18, 0x1D),
177GEN_VXFORM_300_EO(vctzw, 0x01, 0x18, 0x1E),
178GEN_VXFORM_300_EO(vctzd, 0x01, 0x18, 0x1F),
179GEN_VXFORM_300_EO(vclzlsbb, 0x01, 0x18, 0x0),
180GEN_VXFORM_300_EO(vctzlsbb, 0x01, 0x18, 0x1),
181
182#define GEN_VXFORM_NOA(name, opc2, opc3)                                \
183    GEN_HANDLER(name, 0x04, opc2, opc3, 0x001f0000, PPC_ALTIVEC)
184GEN_VXFORM_NOA(vupkhsb, 7, 8),
185GEN_VXFORM_NOA(vupkhsh, 7, 9),
186GEN_VXFORM_207(vupkhsw, 7, 25),
187GEN_VXFORM_NOA(vupklsb, 7, 10),
188GEN_VXFORM_NOA(vupklsh, 7, 11),
189GEN_VXFORM_207(vupklsw, 7, 27),
190GEN_VXFORM_NOA(vupkhpx, 7, 13),
191GEN_VXFORM_NOA(vupklpx, 7, 15),
192GEN_VXFORM_NOA(vrefp, 5, 4),
193GEN_VXFORM_NOA(vrsqrtefp, 5, 5),
194GEN_VXFORM_NOA(vexptefp, 5, 6),
195GEN_VXFORM_NOA(vlogefp, 5, 7),
196GEN_VXFORM_NOA(vrfim, 5, 11),
197GEN_VXFORM_NOA(vrfin, 5, 8),
198GEN_VXFORM_NOA(vrfip, 5, 10),
199GEN_VXFORM_NOA(vrfiz, 5, 9),
200
201#define GEN_VXFORM_UIMM(name, opc2, opc3)                               \
202    GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
203GEN_VXFORM_UIMM(vcfux, 5, 12),
204GEN_VXFORM_UIMM(vcfsx, 5, 13),
205GEN_VXFORM_UIMM(vctuxs, 5, 14),
206GEN_VXFORM_UIMM(vctsxs, 5, 15),
207
208#define GEN_VAFORM_PAIRED(name0, name1, opc2)                           \
209    GEN_HANDLER(name0##_##name1, 0x04, opc2, 0xFF, 0x00000000, PPC_ALTIVEC)
210GEN_VAFORM_PAIRED(vmaddfp, vnmsubfp, 23),
211
212GEN_VXFORM_DUAL(vclzb, vpopcntb, 1, 28, PPC_NONE, PPC2_ALTIVEC_207),
213GEN_VXFORM_DUAL(vclzh, vpopcnth, 1, 29, PPC_NONE, PPC2_ALTIVEC_207),
214GEN_VXFORM_DUAL(vclzw, vpopcntw, 1, 30, PPC_NONE, PPC2_ALTIVEC_207),
215GEN_VXFORM_DUAL(vclzd, vpopcntd, 1, 31, PPC_NONE, PPC2_ALTIVEC_207),
216
217GEN_VXFORM_300(vbpermd, 6, 23),
218GEN_VXFORM_207(vbpermq, 6, 21),
219GEN_VXFORM_207(vgbbd, 6, 20),
220GEN_VXFORM_207(vpmsumb, 4, 16),
221GEN_VXFORM_207(vpmsumh, 4, 17),
222GEN_VXFORM_207(vpmsumw, 4, 18),
223
224GEN_VXFORM_207(vsbox, 4, 23),
225
226GEN_VXFORM_DUAL(vcipher, vcipherlast, 4, 20, PPC_NONE, PPC2_ALTIVEC_207),
227GEN_VXFORM_DUAL(vncipher, vncipherlast, 4, 21, PPC_NONE, PPC2_ALTIVEC_207),
228
229GEN_VXFORM_207(vshasigmaw, 1, 26),
230GEN_VXFORM_207(vshasigmad, 1, 27),
231
232GEN_VXFORM_DUAL(vsldoi, vpermxor, 22, 0xFF, PPC_ALTIVEC, PPC_NONE),
233