1#define GEN_VXFORM(name, opc2, opc3)                                    \
2GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
3
4#define GEN_VXFORM_207(name, opc2, opc3) \
5GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207)
6
7#define GEN_VXFORM_300(name, opc2, opc3)                                \
8GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ISA300)
9
10#define GEN_VXFORM_300_EXT(name, opc2, opc3, inval)                     \
11GEN_HANDLER_E(name, 0x04, opc2, opc3, inval, PPC_NONE, PPC2_ISA300)
12
13#define GEN_VXFORM_300_EO(name, opc2, opc3, opc4)                     \
14GEN_HANDLER_E_2(name, 0x04, opc2, opc3, opc4, 0x00000000, PPC_NONE,     \
15                                                       PPC2_ISA300)
16
17#define GEN_VXFORM_310(name, opc2, opc3)                                \
18GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ISA310)
19
20#define GEN_VXFORM_DUAL(name0, name1, opc2, opc3, type0, type1) \
21GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, type0, type1)
22
23#define GEN_VXRFORM_DUAL(name0, name1, opc2, opc3, tp0, tp1) \
24GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, tp0, tp1), \
25GEN_HANDLER_E(name0##_##name1, 0x4, opc2, (opc3 | 0x10), 0x00000000, tp0, tp1),
26
27GEN_VXFORM_DUAL(vaddubm, vmul10cuq, 0, 0, PPC_ALTIVEC, PPC_NONE),
28GEN_VXFORM_DUAL(vadduhm, vmul10ecuq, 0, 1, PPC_ALTIVEC, PPC_NONE),
29GEN_VXFORM(vadduwm, 0, 2),
30GEN_VXFORM_207(vaddudm, 0, 3),
31GEN_VXFORM_DUAL(vsububm, bcdadd, 0, 16, PPC_ALTIVEC, PPC_NONE),
32GEN_VXFORM_DUAL(vsubuhm, bcdsub, 0, 17, PPC_ALTIVEC, PPC_NONE),
33GEN_VXFORM_DUAL(vsubuwm, bcdus, 0, 18, PPC_ALTIVEC, PPC2_ISA300),
34GEN_VXFORM_DUAL(vsubudm, bcds, 0, 19, PPC2_ALTIVEC_207, PPC2_ISA300),
35GEN_VXFORM_300(bcds, 0, 27),
36GEN_VXFORM(vmrghb, 6, 0),
37GEN_VXFORM(vmrghh, 6, 1),
38GEN_VXFORM(vmrghw, 6, 2),
39GEN_VXFORM(vmrglb, 6, 4),
40GEN_VXFORM(vmrglh, 6, 5),
41GEN_VXFORM(vmrglw, 6, 6),
42GEN_VXFORM_300(vextublx, 6, 24),
43GEN_VXFORM_300(vextuhlx, 6, 25),
44GEN_VXFORM_DUAL(vmrgow, vextuwlx, 6, 26, PPC_NONE, PPC2_ALTIVEC_207),
45GEN_VXFORM_300(vextubrx, 6, 28),
46GEN_VXFORM_300(vextuhrx, 6, 29),
47GEN_VXFORM_DUAL(vmrgew, vextuwrx, 6, 30, PPC_NONE, PPC2_ALTIVEC_207),
48GEN_VXFORM_207(vmuluwm, 4, 2),
49GEN_VXFORM_300(vsrv, 2, 28),
50GEN_VXFORM_300(vslv, 2, 29),
51GEN_VXFORM(vslo, 6, 16),
52GEN_VXFORM(vsro, 6, 17),
53
54GEN_VXFORM(xpnd04_1, 0, 22),
55GEN_VXFORM_300(bcdsr, 0, 23),
56GEN_VXFORM_300(bcdsr, 0, 31),
57GEN_VXFORM_DUAL(vaddubs, vmul10uq, 0, 8, PPC_ALTIVEC, PPC_NONE),
58GEN_VXFORM_DUAL(vadduhs, vmul10euq, 0, 9, PPC_ALTIVEC, PPC_NONE),
59GEN_VXFORM(vadduws, 0, 10),
60GEN_VXFORM(vaddsbs, 0, 12),
61GEN_VXFORM_DUAL(vaddshs, bcdcpsgn, 0, 13, PPC_ALTIVEC, PPC_NONE),
62GEN_VXFORM(vaddsws, 0, 14),
63GEN_VXFORM_DUAL(vsububs, bcdadd, 0, 24, PPC_ALTIVEC, PPC_NONE),
64GEN_VXFORM_DUAL(vsubuhs, bcdsub, 0, 25, PPC_ALTIVEC, PPC_NONE),
65GEN_VXFORM(vsubuws, 0, 26),
66GEN_VXFORM_DUAL(vsubsbs, bcdtrunc, 0, 28, PPC_ALTIVEC, PPC2_ISA300),
67GEN_VXFORM(vsubshs, 0, 29),
68GEN_VXFORM_DUAL(vsubsws, xpnd04_2, 0, 30, PPC_ALTIVEC, PPC_NONE),
69GEN_VXFORM_300(bcdtrunc, 0, 20),
70GEN_VXFORM_300(bcdutrunc, 0, 21),
71GEN_VXFORM(vsl, 2, 7),
72GEN_VXFORM(vsr, 2, 11),
73GEN_VXFORM(vpkuhum, 7, 0),
74GEN_VXFORM(vpkuwum, 7, 1),
75GEN_VXFORM_207(vpkudum, 7, 17),
76GEN_VXFORM(vpkuhus, 7, 2),
77GEN_VXFORM(vpkuwus, 7, 3),
78GEN_VXFORM_207(vpkudus, 7, 19),
79GEN_VXFORM(vpkshus, 7, 4),
80GEN_VXFORM(vpkswus, 7, 5),
81GEN_VXFORM_207(vpksdus, 7, 21),
82GEN_VXFORM(vpkshss, 7, 6),
83GEN_VXFORM(vpkswss, 7, 7),
84GEN_VXFORM_207(vpksdss, 7, 23),
85GEN_VXFORM(vpkpx, 7, 12),
86GEN_VXFORM(vsum4ubs, 4, 24),
87GEN_VXFORM(vsum4sbs, 4, 28),
88GEN_VXFORM(vsum4shs, 4, 25),
89GEN_VXFORM(vsum2sws, 4, 26),
90GEN_VXFORM(vsumsws, 4, 30),
91GEN_VXFORM(vaddfp, 5, 0),
92GEN_VXFORM(vsubfp, 5, 1),
93GEN_VXFORM(vmaxfp, 5, 16),
94GEN_VXFORM(vminfp, 5, 17),
95
96#define GEN_VXRFORM1(opname, name, str, opc2, opc3)                     \
97    GEN_HANDLER2(name, str, 0x4, opc2, opc3, 0x00000000, PPC_ALTIVEC),
98#define GEN_VXRFORM1_300(opname, name, str, opc2, opc3)                 \
99GEN_HANDLER2_E(name, str, 0x4, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ISA300),
100#define GEN_VXRFORM(name, opc2, opc3)                                \
101    GEN_VXRFORM1(name, name, #name, opc2, opc3)                      \
102    GEN_VXRFORM1(name##_dot, name##_, #name ".", opc2, (opc3 | (0x1 << 4)))
103#define GEN_VXRFORM_300(name, opc2, opc3)                                   \
104    GEN_VXRFORM1_300(name, name, #name, opc2, opc3)                         \
105    GEN_VXRFORM1_300(name##_dot, name##_, #name ".", opc2, (opc3 | (0x1 << 4)))
106
107GEN_VXRFORM(vcmpeqfp, 3, 3)
108GEN_VXRFORM(vcmpgefp, 3, 7)
109GEN_VXRFORM(vcmpgtfp, 3, 11)
110GEN_VXRFORM(vcmpbfp, 3, 15)
111
112#define GEN_VXFORM_DUAL_INV(name0, name1, opc2, opc3, inval0, inval1, type) \
113GEN_OPCODE_DUAL(name0##_##name1, 0x04, opc2, opc3, inval0, inval1, type, \
114                                                               PPC_NONE)
115GEN_VXFORM_DUAL_INV(vspltb, vextractub, 6, 8, 0x00000000, 0x100000,
116                                               PPC_ALTIVEC),
117GEN_VXFORM_DUAL_INV(vsplth, vextractuh, 6, 9, 0x00000000, 0x100000,
118                                               PPC_ALTIVEC),
119GEN_VXFORM_DUAL_INV(vspltw, vextractuw, 6, 10, 0x00000000, 0x100000,
120                                               PPC_ALTIVEC),
121GEN_VXFORM_300_EXT(vextractd, 6, 11, 0x100000),
122GEN_VXFORM(vspltisb, 6, 12),
123GEN_VXFORM(vspltish, 6, 13),
124GEN_VXFORM(vspltisw, 6, 14),
125GEN_VXFORM_300_EO(vctzb, 0x01, 0x18, 0x1C),
126GEN_VXFORM_300_EO(vctzh, 0x01, 0x18, 0x1D),
127GEN_VXFORM_300_EO(vctzw, 0x01, 0x18, 0x1E),
128GEN_VXFORM_300_EO(vctzd, 0x01, 0x18, 0x1F),
129GEN_VXFORM_300_EO(vclzlsbb, 0x01, 0x18, 0x0),
130GEN_VXFORM_300_EO(vctzlsbb, 0x01, 0x18, 0x1),
131
132#define GEN_VXFORM_NOA(name, opc2, opc3)                                \
133    GEN_HANDLER(name, 0x04, opc2, opc3, 0x001f0000, PPC_ALTIVEC)
134GEN_VXFORM_NOA(vupkhsb, 7, 8),
135GEN_VXFORM_NOA(vupkhsh, 7, 9),
136GEN_VXFORM_207(vupkhsw, 7, 25),
137GEN_VXFORM_NOA(vupklsb, 7, 10),
138GEN_VXFORM_NOA(vupklsh, 7, 11),
139GEN_VXFORM_207(vupklsw, 7, 27),
140GEN_VXFORM_NOA(vupkhpx, 7, 13),
141GEN_VXFORM_NOA(vupklpx, 7, 15),
142GEN_VXFORM_NOA(vrefp, 5, 4),
143GEN_VXFORM_NOA(vrsqrtefp, 5, 5),
144GEN_VXFORM_NOA(vexptefp, 5, 6),
145GEN_VXFORM_NOA(vlogefp, 5, 7),
146GEN_VXFORM_NOA(vrfim, 5, 11),
147GEN_VXFORM_NOA(vrfin, 5, 8),
148GEN_VXFORM_NOA(vrfip, 5, 10),
149GEN_VXFORM_NOA(vrfiz, 5, 9),
150
151#define GEN_VXFORM_UIMM(name, opc2, opc3)                               \
152    GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
153GEN_VXFORM_UIMM(vcfux, 5, 12),
154GEN_VXFORM_UIMM(vcfsx, 5, 13),
155GEN_VXFORM_UIMM(vctuxs, 5, 14),
156GEN_VXFORM_UIMM(vctsxs, 5, 15),
157
158#define GEN_VAFORM_PAIRED(name0, name1, opc2)                           \
159    GEN_HANDLER(name0##_##name1, 0x04, opc2, 0xFF, 0x00000000, PPC_ALTIVEC)
160GEN_VAFORM_PAIRED(vmaddfp, vnmsubfp, 23),
161
162GEN_VXFORM_DUAL(vclzb, vpopcntb, 1, 28, PPC_NONE, PPC2_ALTIVEC_207),
163GEN_VXFORM_DUAL(vclzh, vpopcnth, 1, 29, PPC_NONE, PPC2_ALTIVEC_207),
164GEN_VXFORM_DUAL(vclzw, vpopcntw, 1, 30, PPC_NONE, PPC2_ALTIVEC_207),
165GEN_VXFORM_DUAL(vclzd, vpopcntd, 1, 31, PPC_NONE, PPC2_ALTIVEC_207),
166
167GEN_VXFORM_300(vbpermd, 6, 23),
168GEN_VXFORM_207(vbpermq, 6, 21),
169GEN_VXFORM_207(vgbbd, 6, 20),
170GEN_VXFORM_207(vpmsumb, 4, 16),
171GEN_VXFORM_207(vpmsumh, 4, 17),
172GEN_VXFORM_207(vpmsumw, 4, 18),
173
174GEN_VXFORM_207(vsbox, 4, 23),
175
176GEN_VXFORM_DUAL(vcipher, vcipherlast, 4, 20, PPC_NONE, PPC2_ALTIVEC_207),
177GEN_VXFORM_DUAL(vncipher, vncipherlast, 4, 21, PPC_NONE, PPC2_ALTIVEC_207),
178
179GEN_VXFORM_207(vshasigmaw, 1, 26),
180GEN_VXFORM_207(vshasigmad, 1, 27),
181
182GEN_VXFORM_DUAL(vsldoi, vpermxor, 22, 0xFF, PPC_ALTIVEC, PPC_NONE),
183