xref: /openbmc/qemu/target/mips/tcg/msa_translate.c (revision a2b0a27d)
1*a2b0a27dSPhilippe Mathieu-Daudé /*
2*a2b0a27dSPhilippe Mathieu-Daudé  *  MIPS SIMD Architecture (MSA) translation routines
3*a2b0a27dSPhilippe Mathieu-Daudé  *
4*a2b0a27dSPhilippe Mathieu-Daudé  *  Copyright (c) 2004-2005 Jocelyn Mayer
5*a2b0a27dSPhilippe Mathieu-Daudé  *  Copyright (c) 2006 Marius Groeger (FPU operations)
6*a2b0a27dSPhilippe Mathieu-Daudé  *  Copyright (c) 2006 Thiemo Seufer (MIPS32R2 support)
7*a2b0a27dSPhilippe Mathieu-Daudé  *  Copyright (c) 2009 CodeSourcery (MIPS16 and microMIPS support)
8*a2b0a27dSPhilippe Mathieu-Daudé  *  Copyright (c) 2012 Jia Liu & Dongxue Zhang (MIPS ASE DSP support)
9*a2b0a27dSPhilippe Mathieu-Daudé  *  Copyright (c) 2020 Philippe Mathieu-Daudé
10*a2b0a27dSPhilippe Mathieu-Daudé  *
11*a2b0a27dSPhilippe Mathieu-Daudé  * SPDX-License-Identifier: LGPL-2.1-or-later
12*a2b0a27dSPhilippe Mathieu-Daudé  */
13*a2b0a27dSPhilippe Mathieu-Daudé #include "qemu/osdep.h"
14*a2b0a27dSPhilippe Mathieu-Daudé #include "tcg/tcg-op.h"
15*a2b0a27dSPhilippe Mathieu-Daudé #include "exec/helper-gen.h"
16*a2b0a27dSPhilippe Mathieu-Daudé #include "translate.h"
17*a2b0a27dSPhilippe Mathieu-Daudé #include "fpu_helper.h"
18*a2b0a27dSPhilippe Mathieu-Daudé #include "internal.h"
19*a2b0a27dSPhilippe Mathieu-Daudé 
20*a2b0a27dSPhilippe Mathieu-Daudé /* Include the auto-generated decoder.  */
21*a2b0a27dSPhilippe Mathieu-Daudé #include "decode-msa32.c.inc"
22*a2b0a27dSPhilippe Mathieu-Daudé #include "decode-msa64.c.inc"
23*a2b0a27dSPhilippe Mathieu-Daudé 
24*a2b0a27dSPhilippe Mathieu-Daudé #define OPC_MSA (0x1E << 26)
25*a2b0a27dSPhilippe Mathieu-Daudé 
26*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_MINOR(op)          (MASK_OP_MAJOR(op) | (op & 0x3F))
27*a2b0a27dSPhilippe Mathieu-Daudé enum {
28*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_I8_00   = 0x00 | OPC_MSA,
29*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_I8_01   = 0x01 | OPC_MSA,
30*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_I8_02   = 0x02 | OPC_MSA,
31*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_I5_06   = 0x06 | OPC_MSA,
32*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_I5_07   = 0x07 | OPC_MSA,
33*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_BIT_09  = 0x09 | OPC_MSA,
34*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_BIT_0A  = 0x0A | OPC_MSA,
35*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3R_0D   = 0x0D | OPC_MSA,
36*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3R_0E   = 0x0E | OPC_MSA,
37*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3R_0F   = 0x0F | OPC_MSA,
38*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3R_10   = 0x10 | OPC_MSA,
39*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3R_11   = 0x11 | OPC_MSA,
40*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3R_12   = 0x12 | OPC_MSA,
41*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3R_13   = 0x13 | OPC_MSA,
42*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3R_14   = 0x14 | OPC_MSA,
43*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3R_15   = 0x15 | OPC_MSA,
44*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_ELM     = 0x19 | OPC_MSA,
45*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3RF_1A  = 0x1A | OPC_MSA,
46*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3RF_1B  = 0x1B | OPC_MSA,
47*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_3RF_1C  = 0x1C | OPC_MSA,
48*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_VEC     = 0x1E | OPC_MSA,
49*a2b0a27dSPhilippe Mathieu-Daudé 
50*a2b0a27dSPhilippe Mathieu-Daudé     /* MI10 instruction */
51*a2b0a27dSPhilippe Mathieu-Daudé     OPC_LD_B        = (0x20) | OPC_MSA,
52*a2b0a27dSPhilippe Mathieu-Daudé     OPC_LD_H        = (0x21) | OPC_MSA,
53*a2b0a27dSPhilippe Mathieu-Daudé     OPC_LD_W        = (0x22) | OPC_MSA,
54*a2b0a27dSPhilippe Mathieu-Daudé     OPC_LD_D        = (0x23) | OPC_MSA,
55*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ST_B        = (0x24) | OPC_MSA,
56*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ST_H        = (0x25) | OPC_MSA,
57*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ST_W        = (0x26) | OPC_MSA,
58*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ST_D        = (0x27) | OPC_MSA,
59*a2b0a27dSPhilippe Mathieu-Daudé };
60*a2b0a27dSPhilippe Mathieu-Daudé 
61*a2b0a27dSPhilippe Mathieu-Daudé enum {
62*a2b0a27dSPhilippe Mathieu-Daudé     /* I5 instruction df(bits 22..21) = _b, _h, _w, _d */
63*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ADDVI_df    = (0x0 << 23) | OPC_MSA_I5_06,
64*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CEQI_df     = (0x0 << 23) | OPC_MSA_I5_07,
65*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SUBVI_df    = (0x1 << 23) | OPC_MSA_I5_06,
66*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MAXI_S_df   = (0x2 << 23) | OPC_MSA_I5_06,
67*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CLTI_S_df   = (0x2 << 23) | OPC_MSA_I5_07,
68*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MAXI_U_df   = (0x3 << 23) | OPC_MSA_I5_06,
69*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CLTI_U_df   = (0x3 << 23) | OPC_MSA_I5_07,
70*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MINI_S_df   = (0x4 << 23) | OPC_MSA_I5_06,
71*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CLEI_S_df   = (0x4 << 23) | OPC_MSA_I5_07,
72*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MINI_U_df   = (0x5 << 23) | OPC_MSA_I5_06,
73*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CLEI_U_df   = (0x5 << 23) | OPC_MSA_I5_07,
74*a2b0a27dSPhilippe Mathieu-Daudé     OPC_LDI_df      = (0x6 << 23) | OPC_MSA_I5_07,
75*a2b0a27dSPhilippe Mathieu-Daudé 
76*a2b0a27dSPhilippe Mathieu-Daudé     /* I8 instruction */
77*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ANDI_B      = (0x0 << 24) | OPC_MSA_I8_00,
78*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BMNZI_B     = (0x0 << 24) | OPC_MSA_I8_01,
79*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SHF_B       = (0x0 << 24) | OPC_MSA_I8_02,
80*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ORI_B       = (0x1 << 24) | OPC_MSA_I8_00,
81*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BMZI_B      = (0x1 << 24) | OPC_MSA_I8_01,
82*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SHF_H       = (0x1 << 24) | OPC_MSA_I8_02,
83*a2b0a27dSPhilippe Mathieu-Daudé     OPC_NORI_B      = (0x2 << 24) | OPC_MSA_I8_00,
84*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BSELI_B     = (0x2 << 24) | OPC_MSA_I8_01,
85*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SHF_W       = (0x2 << 24) | OPC_MSA_I8_02,
86*a2b0a27dSPhilippe Mathieu-Daudé     OPC_XORI_B      = (0x3 << 24) | OPC_MSA_I8_00,
87*a2b0a27dSPhilippe Mathieu-Daudé 
88*a2b0a27dSPhilippe Mathieu-Daudé     /* VEC/2R/2RF instruction */
89*a2b0a27dSPhilippe Mathieu-Daudé     OPC_AND_V       = (0x00 << 21) | OPC_MSA_VEC,
90*a2b0a27dSPhilippe Mathieu-Daudé     OPC_OR_V        = (0x01 << 21) | OPC_MSA_VEC,
91*a2b0a27dSPhilippe Mathieu-Daudé     OPC_NOR_V       = (0x02 << 21) | OPC_MSA_VEC,
92*a2b0a27dSPhilippe Mathieu-Daudé     OPC_XOR_V       = (0x03 << 21) | OPC_MSA_VEC,
93*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BMNZ_V      = (0x04 << 21) | OPC_MSA_VEC,
94*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BMZ_V       = (0x05 << 21) | OPC_MSA_VEC,
95*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BSEL_V      = (0x06 << 21) | OPC_MSA_VEC,
96*a2b0a27dSPhilippe Mathieu-Daudé 
97*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_2R      = (0x18 << 21) | OPC_MSA_VEC,
98*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSA_2RF     = (0x19 << 21) | OPC_MSA_VEC,
99*a2b0a27dSPhilippe Mathieu-Daudé 
100*a2b0a27dSPhilippe Mathieu-Daudé     /* 2R instruction df(bits 17..16) = _b, _h, _w, _d */
101*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FILL_df     = (0x00 << 18) | OPC_MSA_2R,
102*a2b0a27dSPhilippe Mathieu-Daudé     OPC_PCNT_df     = (0x01 << 18) | OPC_MSA_2R,
103*a2b0a27dSPhilippe Mathieu-Daudé     OPC_NLOC_df     = (0x02 << 18) | OPC_MSA_2R,
104*a2b0a27dSPhilippe Mathieu-Daudé     OPC_NLZC_df     = (0x03 << 18) | OPC_MSA_2R,
105*a2b0a27dSPhilippe Mathieu-Daudé 
106*a2b0a27dSPhilippe Mathieu-Daudé     /* 2RF instruction df(bit 16) = _w, _d */
107*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCLASS_df   = (0x00 << 17) | OPC_MSA_2RF,
108*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FTRUNC_S_df = (0x01 << 17) | OPC_MSA_2RF,
109*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FTRUNC_U_df = (0x02 << 17) | OPC_MSA_2RF,
110*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSQRT_df    = (0x03 << 17) | OPC_MSA_2RF,
111*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FRSQRT_df   = (0x04 << 17) | OPC_MSA_2RF,
112*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FRCP_df     = (0x05 << 17) | OPC_MSA_2RF,
113*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FRINT_df    = (0x06 << 17) | OPC_MSA_2RF,
114*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FLOG2_df    = (0x07 << 17) | OPC_MSA_2RF,
115*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FEXUPL_df   = (0x08 << 17) | OPC_MSA_2RF,
116*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FEXUPR_df   = (0x09 << 17) | OPC_MSA_2RF,
117*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FFQL_df     = (0x0A << 17) | OPC_MSA_2RF,
118*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FFQR_df     = (0x0B << 17) | OPC_MSA_2RF,
119*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FTINT_S_df  = (0x0C << 17) | OPC_MSA_2RF,
120*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FTINT_U_df  = (0x0D << 17) | OPC_MSA_2RF,
121*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FFINT_S_df  = (0x0E << 17) | OPC_MSA_2RF,
122*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FFINT_U_df  = (0x0F << 17) | OPC_MSA_2RF,
123*a2b0a27dSPhilippe Mathieu-Daudé 
124*a2b0a27dSPhilippe Mathieu-Daudé     /* 3R instruction df(bits 22..21) = _b, _h, _w, d */
125*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SLL_df      = (0x0 << 23) | OPC_MSA_3R_0D,
126*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ADDV_df     = (0x0 << 23) | OPC_MSA_3R_0E,
127*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CEQ_df      = (0x0 << 23) | OPC_MSA_3R_0F,
128*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ADD_A_df    = (0x0 << 23) | OPC_MSA_3R_10,
129*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SUBS_S_df   = (0x0 << 23) | OPC_MSA_3R_11,
130*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MULV_df     = (0x0 << 23) | OPC_MSA_3R_12,
131*a2b0a27dSPhilippe Mathieu-Daudé     OPC_DOTP_S_df   = (0x0 << 23) | OPC_MSA_3R_13,
132*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SLD_df      = (0x0 << 23) | OPC_MSA_3R_14,
133*a2b0a27dSPhilippe Mathieu-Daudé     OPC_VSHF_df     = (0x0 << 23) | OPC_MSA_3R_15,
134*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SRA_df      = (0x1 << 23) | OPC_MSA_3R_0D,
135*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SUBV_df     = (0x1 << 23) | OPC_MSA_3R_0E,
136*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ADDS_A_df   = (0x1 << 23) | OPC_MSA_3R_10,
137*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SUBS_U_df   = (0x1 << 23) | OPC_MSA_3R_11,
138*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MADDV_df    = (0x1 << 23) | OPC_MSA_3R_12,
139*a2b0a27dSPhilippe Mathieu-Daudé     OPC_DOTP_U_df   = (0x1 << 23) | OPC_MSA_3R_13,
140*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SPLAT_df    = (0x1 << 23) | OPC_MSA_3R_14,
141*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SRAR_df     = (0x1 << 23) | OPC_MSA_3R_15,
142*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SRL_df      = (0x2 << 23) | OPC_MSA_3R_0D,
143*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MAX_S_df    = (0x2 << 23) | OPC_MSA_3R_0E,
144*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CLT_S_df    = (0x2 << 23) | OPC_MSA_3R_0F,
145*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ADDS_S_df   = (0x2 << 23) | OPC_MSA_3R_10,
146*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SUBSUS_U_df = (0x2 << 23) | OPC_MSA_3R_11,
147*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSUBV_df    = (0x2 << 23) | OPC_MSA_3R_12,
148*a2b0a27dSPhilippe Mathieu-Daudé     OPC_DPADD_S_df  = (0x2 << 23) | OPC_MSA_3R_13,
149*a2b0a27dSPhilippe Mathieu-Daudé     OPC_PCKEV_df    = (0x2 << 23) | OPC_MSA_3R_14,
150*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SRLR_df     = (0x2 << 23) | OPC_MSA_3R_15,
151*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BCLR_df     = (0x3 << 23) | OPC_MSA_3R_0D,
152*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MAX_U_df    = (0x3 << 23) | OPC_MSA_3R_0E,
153*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CLT_U_df    = (0x3 << 23) | OPC_MSA_3R_0F,
154*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ADDS_U_df   = (0x3 << 23) | OPC_MSA_3R_10,
155*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SUBSUU_S_df = (0x3 << 23) | OPC_MSA_3R_11,
156*a2b0a27dSPhilippe Mathieu-Daudé     OPC_DPADD_U_df  = (0x3 << 23) | OPC_MSA_3R_13,
157*a2b0a27dSPhilippe Mathieu-Daudé     OPC_PCKOD_df    = (0x3 << 23) | OPC_MSA_3R_14,
158*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BSET_df     = (0x4 << 23) | OPC_MSA_3R_0D,
159*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MIN_S_df    = (0x4 << 23) | OPC_MSA_3R_0E,
160*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CLE_S_df    = (0x4 << 23) | OPC_MSA_3R_0F,
161*a2b0a27dSPhilippe Mathieu-Daudé     OPC_AVE_S_df    = (0x4 << 23) | OPC_MSA_3R_10,
162*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ASUB_S_df   = (0x4 << 23) | OPC_MSA_3R_11,
163*a2b0a27dSPhilippe Mathieu-Daudé     OPC_DIV_S_df    = (0x4 << 23) | OPC_MSA_3R_12,
164*a2b0a27dSPhilippe Mathieu-Daudé     OPC_DPSUB_S_df  = (0x4 << 23) | OPC_MSA_3R_13,
165*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ILVL_df     = (0x4 << 23) | OPC_MSA_3R_14,
166*a2b0a27dSPhilippe Mathieu-Daudé     OPC_HADD_S_df   = (0x4 << 23) | OPC_MSA_3R_15,
167*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BNEG_df     = (0x5 << 23) | OPC_MSA_3R_0D,
168*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MIN_U_df    = (0x5 << 23) | OPC_MSA_3R_0E,
169*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CLE_U_df    = (0x5 << 23) | OPC_MSA_3R_0F,
170*a2b0a27dSPhilippe Mathieu-Daudé     OPC_AVE_U_df    = (0x5 << 23) | OPC_MSA_3R_10,
171*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ASUB_U_df   = (0x5 << 23) | OPC_MSA_3R_11,
172*a2b0a27dSPhilippe Mathieu-Daudé     OPC_DIV_U_df    = (0x5 << 23) | OPC_MSA_3R_12,
173*a2b0a27dSPhilippe Mathieu-Daudé     OPC_DPSUB_U_df  = (0x5 << 23) | OPC_MSA_3R_13,
174*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ILVR_df     = (0x5 << 23) | OPC_MSA_3R_14,
175*a2b0a27dSPhilippe Mathieu-Daudé     OPC_HADD_U_df   = (0x5 << 23) | OPC_MSA_3R_15,
176*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BINSL_df    = (0x6 << 23) | OPC_MSA_3R_0D,
177*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MAX_A_df    = (0x6 << 23) | OPC_MSA_3R_0E,
178*a2b0a27dSPhilippe Mathieu-Daudé     OPC_AVER_S_df   = (0x6 << 23) | OPC_MSA_3R_10,
179*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MOD_S_df    = (0x6 << 23) | OPC_MSA_3R_12,
180*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ILVEV_df    = (0x6 << 23) | OPC_MSA_3R_14,
181*a2b0a27dSPhilippe Mathieu-Daudé     OPC_HSUB_S_df   = (0x6 << 23) | OPC_MSA_3R_15,
182*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BINSR_df    = (0x7 << 23) | OPC_MSA_3R_0D,
183*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MIN_A_df    = (0x7 << 23) | OPC_MSA_3R_0E,
184*a2b0a27dSPhilippe Mathieu-Daudé     OPC_AVER_U_df   = (0x7 << 23) | OPC_MSA_3R_10,
185*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MOD_U_df    = (0x7 << 23) | OPC_MSA_3R_12,
186*a2b0a27dSPhilippe Mathieu-Daudé     OPC_ILVOD_df    = (0x7 << 23) | OPC_MSA_3R_14,
187*a2b0a27dSPhilippe Mathieu-Daudé     OPC_HSUB_U_df   = (0x7 << 23) | OPC_MSA_3R_15,
188*a2b0a27dSPhilippe Mathieu-Daudé 
189*a2b0a27dSPhilippe Mathieu-Daudé     /* ELM instructions df(bits 21..16) = _b, _h, _w, _d */
190*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SLDI_df     = (0x0 << 22) | (0x00 << 16) | OPC_MSA_ELM,
191*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CTCMSA      = (0x0 << 22) | (0x3E << 16) | OPC_MSA_ELM,
192*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SPLATI_df   = (0x1 << 22) | (0x00 << 16) | OPC_MSA_ELM,
193*a2b0a27dSPhilippe Mathieu-Daudé     OPC_CFCMSA      = (0x1 << 22) | (0x3E << 16) | OPC_MSA_ELM,
194*a2b0a27dSPhilippe Mathieu-Daudé     OPC_COPY_S_df   = (0x2 << 22) | (0x00 << 16) | OPC_MSA_ELM,
195*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MOVE_V      = (0x2 << 22) | (0x3E << 16) | OPC_MSA_ELM,
196*a2b0a27dSPhilippe Mathieu-Daudé     OPC_COPY_U_df   = (0x3 << 22) | (0x00 << 16) | OPC_MSA_ELM,
197*a2b0a27dSPhilippe Mathieu-Daudé     OPC_INSERT_df   = (0x4 << 22) | (0x00 << 16) | OPC_MSA_ELM,
198*a2b0a27dSPhilippe Mathieu-Daudé     OPC_INSVE_df    = (0x5 << 22) | (0x00 << 16) | OPC_MSA_ELM,
199*a2b0a27dSPhilippe Mathieu-Daudé 
200*a2b0a27dSPhilippe Mathieu-Daudé     /* 3RF instruction _df(bit 21) = _w, _d */
201*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCAF_df     = (0x0 << 22) | OPC_MSA_3RF_1A,
202*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FADD_df     = (0x0 << 22) | OPC_MSA_3RF_1B,
203*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCUN_df     = (0x1 << 22) | OPC_MSA_3RF_1A,
204*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSUB_df     = (0x1 << 22) | OPC_MSA_3RF_1B,
205*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCOR_df     = (0x1 << 22) | OPC_MSA_3RF_1C,
206*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCEQ_df     = (0x2 << 22) | OPC_MSA_3RF_1A,
207*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FMUL_df     = (0x2 << 22) | OPC_MSA_3RF_1B,
208*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCUNE_df    = (0x2 << 22) | OPC_MSA_3RF_1C,
209*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCUEQ_df    = (0x3 << 22) | OPC_MSA_3RF_1A,
210*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FDIV_df     = (0x3 << 22) | OPC_MSA_3RF_1B,
211*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCNE_df     = (0x3 << 22) | OPC_MSA_3RF_1C,
212*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCLT_df     = (0x4 << 22) | OPC_MSA_3RF_1A,
213*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FMADD_df    = (0x4 << 22) | OPC_MSA_3RF_1B,
214*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MUL_Q_df    = (0x4 << 22) | OPC_MSA_3RF_1C,
215*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCULT_df    = (0x5 << 22) | OPC_MSA_3RF_1A,
216*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FMSUB_df    = (0x5 << 22) | OPC_MSA_3RF_1B,
217*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MADD_Q_df   = (0x5 << 22) | OPC_MSA_3RF_1C,
218*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCLE_df     = (0x6 << 22) | OPC_MSA_3RF_1A,
219*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSUB_Q_df   = (0x6 << 22) | OPC_MSA_3RF_1C,
220*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FCULE_df    = (0x7 << 22) | OPC_MSA_3RF_1A,
221*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FEXP2_df    = (0x7 << 22) | OPC_MSA_3RF_1B,
222*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSAF_df     = (0x8 << 22) | OPC_MSA_3RF_1A,
223*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FEXDO_df    = (0x8 << 22) | OPC_MSA_3RF_1B,
224*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSUN_df     = (0x9 << 22) | OPC_MSA_3RF_1A,
225*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSOR_df     = (0x9 << 22) | OPC_MSA_3RF_1C,
226*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSEQ_df     = (0xA << 22) | OPC_MSA_3RF_1A,
227*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FTQ_df      = (0xA << 22) | OPC_MSA_3RF_1B,
228*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSUNE_df    = (0xA << 22) | OPC_MSA_3RF_1C,
229*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSUEQ_df    = (0xB << 22) | OPC_MSA_3RF_1A,
230*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSNE_df     = (0xB << 22) | OPC_MSA_3RF_1C,
231*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSLT_df     = (0xC << 22) | OPC_MSA_3RF_1A,
232*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FMIN_df     = (0xC << 22) | OPC_MSA_3RF_1B,
233*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MULR_Q_df   = (0xC << 22) | OPC_MSA_3RF_1C,
234*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSULT_df    = (0xD << 22) | OPC_MSA_3RF_1A,
235*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FMIN_A_df   = (0xD << 22) | OPC_MSA_3RF_1B,
236*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MADDR_Q_df  = (0xD << 22) | OPC_MSA_3RF_1C,
237*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSLE_df     = (0xE << 22) | OPC_MSA_3RF_1A,
238*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FMAX_df     = (0xE << 22) | OPC_MSA_3RF_1B,
239*a2b0a27dSPhilippe Mathieu-Daudé     OPC_MSUBR_Q_df  = (0xE << 22) | OPC_MSA_3RF_1C,
240*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FSULE_df    = (0xF << 22) | OPC_MSA_3RF_1A,
241*a2b0a27dSPhilippe Mathieu-Daudé     OPC_FMAX_A_df   = (0xF << 22) | OPC_MSA_3RF_1B,
242*a2b0a27dSPhilippe Mathieu-Daudé 
243*a2b0a27dSPhilippe Mathieu-Daudé     /* BIT instruction df(bits 22..16) = _B _H _W _D */
244*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SLLI_df     = (0x0 << 23) | OPC_MSA_BIT_09,
245*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SAT_S_df    = (0x0 << 23) | OPC_MSA_BIT_0A,
246*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SRAI_df     = (0x1 << 23) | OPC_MSA_BIT_09,
247*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SAT_U_df    = (0x1 << 23) | OPC_MSA_BIT_0A,
248*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SRLI_df     = (0x2 << 23) | OPC_MSA_BIT_09,
249*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SRARI_df    = (0x2 << 23) | OPC_MSA_BIT_0A,
250*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BCLRI_df    = (0x3 << 23) | OPC_MSA_BIT_09,
251*a2b0a27dSPhilippe Mathieu-Daudé     OPC_SRLRI_df    = (0x3 << 23) | OPC_MSA_BIT_0A,
252*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BSETI_df    = (0x4 << 23) | OPC_MSA_BIT_09,
253*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BNEGI_df    = (0x5 << 23) | OPC_MSA_BIT_09,
254*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BINSLI_df   = (0x6 << 23) | OPC_MSA_BIT_09,
255*a2b0a27dSPhilippe Mathieu-Daudé     OPC_BINSRI_df   = (0x7 << 23) | OPC_MSA_BIT_09,
256*a2b0a27dSPhilippe Mathieu-Daudé };
257*a2b0a27dSPhilippe Mathieu-Daudé 
258*a2b0a27dSPhilippe Mathieu-Daudé static const char * const msaregnames[] = {
259*a2b0a27dSPhilippe Mathieu-Daudé     "w0.d0",  "w0.d1",  "w1.d0",  "w1.d1",
260*a2b0a27dSPhilippe Mathieu-Daudé     "w2.d0",  "w2.d1",  "w3.d0",  "w3.d1",
261*a2b0a27dSPhilippe Mathieu-Daudé     "w4.d0",  "w4.d1",  "w5.d0",  "w5.d1",
262*a2b0a27dSPhilippe Mathieu-Daudé     "w6.d0",  "w6.d1",  "w7.d0",  "w7.d1",
263*a2b0a27dSPhilippe Mathieu-Daudé     "w8.d0",  "w8.d1",  "w9.d0",  "w9.d1",
264*a2b0a27dSPhilippe Mathieu-Daudé     "w10.d0", "w10.d1", "w11.d0", "w11.d1",
265*a2b0a27dSPhilippe Mathieu-Daudé     "w12.d0", "w12.d1", "w13.d0", "w13.d1",
266*a2b0a27dSPhilippe Mathieu-Daudé     "w14.d0", "w14.d1", "w15.d0", "w15.d1",
267*a2b0a27dSPhilippe Mathieu-Daudé     "w16.d0", "w16.d1", "w17.d0", "w17.d1",
268*a2b0a27dSPhilippe Mathieu-Daudé     "w18.d0", "w18.d1", "w19.d0", "w19.d1",
269*a2b0a27dSPhilippe Mathieu-Daudé     "w20.d0", "w20.d1", "w21.d0", "w21.d1",
270*a2b0a27dSPhilippe Mathieu-Daudé     "w22.d0", "w22.d1", "w23.d0", "w23.d1",
271*a2b0a27dSPhilippe Mathieu-Daudé     "w24.d0", "w24.d1", "w25.d0", "w25.d1",
272*a2b0a27dSPhilippe Mathieu-Daudé     "w26.d0", "w26.d1", "w27.d0", "w27.d1",
273*a2b0a27dSPhilippe Mathieu-Daudé     "w28.d0", "w28.d1", "w29.d0", "w29.d1",
274*a2b0a27dSPhilippe Mathieu-Daudé     "w30.d0", "w30.d1", "w31.d0", "w31.d1",
275*a2b0a27dSPhilippe Mathieu-Daudé };
276*a2b0a27dSPhilippe Mathieu-Daudé 
277*a2b0a27dSPhilippe Mathieu-Daudé static TCGv_i64 msa_wr_d[64];
278*a2b0a27dSPhilippe Mathieu-Daudé 
279*a2b0a27dSPhilippe Mathieu-Daudé void msa_translate_init(void)
280*a2b0a27dSPhilippe Mathieu-Daudé {
281*a2b0a27dSPhilippe Mathieu-Daudé     int i;
282*a2b0a27dSPhilippe Mathieu-Daudé 
283*a2b0a27dSPhilippe Mathieu-Daudé     for (i = 0; i < 32; i++) {
284*a2b0a27dSPhilippe Mathieu-Daudé         int off = offsetof(CPUMIPSState, active_fpu.fpr[i].wr.d[0]);
285*a2b0a27dSPhilippe Mathieu-Daudé 
286*a2b0a27dSPhilippe Mathieu-Daudé         /*
287*a2b0a27dSPhilippe Mathieu-Daudé          * The MSA vector registers are mapped on the
288*a2b0a27dSPhilippe Mathieu-Daudé          * scalar floating-point unit (FPU) registers.
289*a2b0a27dSPhilippe Mathieu-Daudé          */
290*a2b0a27dSPhilippe Mathieu-Daudé         msa_wr_d[i * 2] = fpu_f64[i];
291*a2b0a27dSPhilippe Mathieu-Daudé         off = offsetof(CPUMIPSState, active_fpu.fpr[i].wr.d[1]);
292*a2b0a27dSPhilippe Mathieu-Daudé         msa_wr_d[i * 2 + 1] =
293*a2b0a27dSPhilippe Mathieu-Daudé                 tcg_global_mem_new_i64(cpu_env, off, msaregnames[i * 2 + 1]);
294*a2b0a27dSPhilippe Mathieu-Daudé     }
295*a2b0a27dSPhilippe Mathieu-Daudé }
296*a2b0a27dSPhilippe Mathieu-Daudé 
297*a2b0a27dSPhilippe Mathieu-Daudé static inline int check_msa_access(DisasContext *ctx)
298*a2b0a27dSPhilippe Mathieu-Daudé {
299*a2b0a27dSPhilippe Mathieu-Daudé     if (unlikely((ctx->hflags & MIPS_HFLAG_FPU) &&
300*a2b0a27dSPhilippe Mathieu-Daudé                  !(ctx->hflags & MIPS_HFLAG_F64))) {
301*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
302*a2b0a27dSPhilippe Mathieu-Daudé         return 0;
303*a2b0a27dSPhilippe Mathieu-Daudé     }
304*a2b0a27dSPhilippe Mathieu-Daudé 
305*a2b0a27dSPhilippe Mathieu-Daudé     if (unlikely(!(ctx->hflags & MIPS_HFLAG_MSA))) {
306*a2b0a27dSPhilippe Mathieu-Daudé         generate_exception_end(ctx, EXCP_MSADIS);
307*a2b0a27dSPhilippe Mathieu-Daudé         return 0;
308*a2b0a27dSPhilippe Mathieu-Daudé     }
309*a2b0a27dSPhilippe Mathieu-Daudé     return 1;
310*a2b0a27dSPhilippe Mathieu-Daudé }
311*a2b0a27dSPhilippe Mathieu-Daudé 
312*a2b0a27dSPhilippe Mathieu-Daudé static void gen_check_zero_element(TCGv tresult, uint8_t df, uint8_t wt,
313*a2b0a27dSPhilippe Mathieu-Daudé                                    TCGCond cond)
314*a2b0a27dSPhilippe Mathieu-Daudé {
315*a2b0a27dSPhilippe Mathieu-Daudé     /* generates tcg ops to check if any element is 0 */
316*a2b0a27dSPhilippe Mathieu-Daudé     /* Note this function only works with MSA_WRLEN = 128 */
317*a2b0a27dSPhilippe Mathieu-Daudé     uint64_t eval_zero_or_big = 0;
318*a2b0a27dSPhilippe Mathieu-Daudé     uint64_t eval_big = 0;
319*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i64 t0 = tcg_temp_new_i64();
320*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i64 t1 = tcg_temp_new_i64();
321*a2b0a27dSPhilippe Mathieu-Daudé     switch (df) {
322*a2b0a27dSPhilippe Mathieu-Daudé     case DF_BYTE:
323*a2b0a27dSPhilippe Mathieu-Daudé         eval_zero_or_big = 0x0101010101010101ULL;
324*a2b0a27dSPhilippe Mathieu-Daudé         eval_big = 0x8080808080808080ULL;
325*a2b0a27dSPhilippe Mathieu-Daudé         break;
326*a2b0a27dSPhilippe Mathieu-Daudé     case DF_HALF:
327*a2b0a27dSPhilippe Mathieu-Daudé         eval_zero_or_big = 0x0001000100010001ULL;
328*a2b0a27dSPhilippe Mathieu-Daudé         eval_big = 0x8000800080008000ULL;
329*a2b0a27dSPhilippe Mathieu-Daudé         break;
330*a2b0a27dSPhilippe Mathieu-Daudé     case DF_WORD:
331*a2b0a27dSPhilippe Mathieu-Daudé         eval_zero_or_big = 0x0000000100000001ULL;
332*a2b0a27dSPhilippe Mathieu-Daudé         eval_big = 0x8000000080000000ULL;
333*a2b0a27dSPhilippe Mathieu-Daudé         break;
334*a2b0a27dSPhilippe Mathieu-Daudé     case DF_DOUBLE:
335*a2b0a27dSPhilippe Mathieu-Daudé         eval_zero_or_big = 0x0000000000000001ULL;
336*a2b0a27dSPhilippe Mathieu-Daudé         eval_big = 0x8000000000000000ULL;
337*a2b0a27dSPhilippe Mathieu-Daudé         break;
338*a2b0a27dSPhilippe Mathieu-Daudé     }
339*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_subi_i64(t0, msa_wr_d[wt << 1], eval_zero_or_big);
340*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_andc_i64(t0, t0, msa_wr_d[wt << 1]);
341*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_andi_i64(t0, t0, eval_big);
342*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_subi_i64(t1, msa_wr_d[(wt << 1) + 1], eval_zero_or_big);
343*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_andc_i64(t1, t1, msa_wr_d[(wt << 1) + 1]);
344*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_andi_i64(t1, t1, eval_big);
345*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_or_i64(t0, t0, t1);
346*a2b0a27dSPhilippe Mathieu-Daudé     /* if all bits are zero then all elements are not zero */
347*a2b0a27dSPhilippe Mathieu-Daudé     /* if some bit is non-zero then some element is zero */
348*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_setcondi_i64(cond, t0, t0, 0);
349*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_trunc_i64_tl(tresult, t0);
350*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i64(t0);
351*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i64(t1);
352*a2b0a27dSPhilippe Mathieu-Daudé }
353*a2b0a27dSPhilippe Mathieu-Daudé 
354*a2b0a27dSPhilippe Mathieu-Daudé static bool gen_msa_BxZ_V(DisasContext *ctx, int wt, int s16, TCGCond cond)
355*a2b0a27dSPhilippe Mathieu-Daudé {
356*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i64 t0;
357*a2b0a27dSPhilippe Mathieu-Daudé 
358*a2b0a27dSPhilippe Mathieu-Daudé     check_msa_access(ctx);
359*a2b0a27dSPhilippe Mathieu-Daudé 
360*a2b0a27dSPhilippe Mathieu-Daudé     if (ctx->hflags & MIPS_HFLAG_BMASK) {
361*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
362*a2b0a27dSPhilippe Mathieu-Daudé         return true;
363*a2b0a27dSPhilippe Mathieu-Daudé     }
364*a2b0a27dSPhilippe Mathieu-Daudé     t0 = tcg_temp_new_i64();
365*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_or_i64(t0, msa_wr_d[wt << 1], msa_wr_d[(wt << 1) + 1]);
366*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_setcondi_i64(cond, t0, t0, 0);
367*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_trunc_i64_tl(bcond, t0);
368*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i64(t0);
369*a2b0a27dSPhilippe Mathieu-Daudé 
370*a2b0a27dSPhilippe Mathieu-Daudé     ctx->btarget = ctx->base.pc_next + (s16 << 2) + 4;
371*a2b0a27dSPhilippe Mathieu-Daudé 
372*a2b0a27dSPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BC;
373*a2b0a27dSPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BDS32;
374*a2b0a27dSPhilippe Mathieu-Daudé 
375*a2b0a27dSPhilippe Mathieu-Daudé     return true;
376*a2b0a27dSPhilippe Mathieu-Daudé }
377*a2b0a27dSPhilippe Mathieu-Daudé 
378*a2b0a27dSPhilippe Mathieu-Daudé static bool trans_BZ_V(DisasContext *ctx, arg_msa_bz *a)
379*a2b0a27dSPhilippe Mathieu-Daudé {
380*a2b0a27dSPhilippe Mathieu-Daudé     return gen_msa_BxZ_V(ctx, a->wt, a->s16, TCG_COND_EQ);
381*a2b0a27dSPhilippe Mathieu-Daudé }
382*a2b0a27dSPhilippe Mathieu-Daudé 
383*a2b0a27dSPhilippe Mathieu-Daudé static bool trans_BNZ_V(DisasContext *ctx, arg_msa_bz *a)
384*a2b0a27dSPhilippe Mathieu-Daudé {
385*a2b0a27dSPhilippe Mathieu-Daudé     return gen_msa_BxZ_V(ctx, a->wt, a->s16, TCG_COND_NE);
386*a2b0a27dSPhilippe Mathieu-Daudé }
387*a2b0a27dSPhilippe Mathieu-Daudé 
388*a2b0a27dSPhilippe Mathieu-Daudé static bool gen_msa_BxZ(DisasContext *ctx, int df, int wt, int s16, bool if_not)
389*a2b0a27dSPhilippe Mathieu-Daudé {
390*a2b0a27dSPhilippe Mathieu-Daudé     check_msa_access(ctx);
391*a2b0a27dSPhilippe Mathieu-Daudé 
392*a2b0a27dSPhilippe Mathieu-Daudé     if (ctx->hflags & MIPS_HFLAG_BMASK) {
393*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
394*a2b0a27dSPhilippe Mathieu-Daudé         return true;
395*a2b0a27dSPhilippe Mathieu-Daudé     }
396*a2b0a27dSPhilippe Mathieu-Daudé 
397*a2b0a27dSPhilippe Mathieu-Daudé     gen_check_zero_element(bcond, df, wt, if_not ? TCG_COND_EQ : TCG_COND_NE);
398*a2b0a27dSPhilippe Mathieu-Daudé 
399*a2b0a27dSPhilippe Mathieu-Daudé     ctx->btarget = ctx->base.pc_next + (s16 << 2) + 4;
400*a2b0a27dSPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BC;
401*a2b0a27dSPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BDS32;
402*a2b0a27dSPhilippe Mathieu-Daudé 
403*a2b0a27dSPhilippe Mathieu-Daudé     return true;
404*a2b0a27dSPhilippe Mathieu-Daudé }
405*a2b0a27dSPhilippe Mathieu-Daudé 
406*a2b0a27dSPhilippe Mathieu-Daudé static bool trans_BZ_x(DisasContext *ctx, arg_msa_bz *a)
407*a2b0a27dSPhilippe Mathieu-Daudé {
408*a2b0a27dSPhilippe Mathieu-Daudé     return gen_msa_BxZ(ctx, a->df, a->wt, a->s16, false);
409*a2b0a27dSPhilippe Mathieu-Daudé }
410*a2b0a27dSPhilippe Mathieu-Daudé 
411*a2b0a27dSPhilippe Mathieu-Daudé static bool trans_BNZ_x(DisasContext *ctx, arg_msa_bz *a)
412*a2b0a27dSPhilippe Mathieu-Daudé {
413*a2b0a27dSPhilippe Mathieu-Daudé     return gen_msa_BxZ(ctx, a->df, a->wt, a->s16, true);
414*a2b0a27dSPhilippe Mathieu-Daudé }
415*a2b0a27dSPhilippe Mathieu-Daudé 
416*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_i8(DisasContext *ctx)
417*a2b0a27dSPhilippe Mathieu-Daudé {
418*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_I8(op)    (MASK_MSA_MINOR(op) | (op & (0x03 << 24)))
419*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t i8 = (ctx->opcode >> 16) & 0xff;
420*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
421*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
422*a2b0a27dSPhilippe Mathieu-Daudé 
423*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
424*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
425*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 ti8 = tcg_const_i32(i8);
426*a2b0a27dSPhilippe Mathieu-Daudé 
427*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_I8(ctx->opcode)) {
428*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ANDI_B:
429*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_andi_b(cpu_env, twd, tws, ti8);
430*a2b0a27dSPhilippe Mathieu-Daudé         break;
431*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ORI_B:
432*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ori_b(cpu_env, twd, tws, ti8);
433*a2b0a27dSPhilippe Mathieu-Daudé         break;
434*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_NORI_B:
435*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_nori_b(cpu_env, twd, tws, ti8);
436*a2b0a27dSPhilippe Mathieu-Daudé         break;
437*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_XORI_B:
438*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_xori_b(cpu_env, twd, tws, ti8);
439*a2b0a27dSPhilippe Mathieu-Daudé         break;
440*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BMNZI_B:
441*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_bmnzi_b(cpu_env, twd, tws, ti8);
442*a2b0a27dSPhilippe Mathieu-Daudé         break;
443*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BMZI_B:
444*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_bmzi_b(cpu_env, twd, tws, ti8);
445*a2b0a27dSPhilippe Mathieu-Daudé         break;
446*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BSELI_B:
447*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_bseli_b(cpu_env, twd, tws, ti8);
448*a2b0a27dSPhilippe Mathieu-Daudé         break;
449*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SHF_B:
450*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SHF_H:
451*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SHF_W:
452*a2b0a27dSPhilippe Mathieu-Daudé         {
453*a2b0a27dSPhilippe Mathieu-Daudé             uint8_t df = (ctx->opcode >> 24) & 0x3;
454*a2b0a27dSPhilippe Mathieu-Daudé             if (df == DF_DOUBLE) {
455*a2b0a27dSPhilippe Mathieu-Daudé                 gen_reserved_instruction(ctx);
456*a2b0a27dSPhilippe Mathieu-Daudé             } else {
457*a2b0a27dSPhilippe Mathieu-Daudé                 TCGv_i32 tdf = tcg_const_i32(df);
458*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_shf_df(cpu_env, tdf, twd, tws, ti8);
459*a2b0a27dSPhilippe Mathieu-Daudé                 tcg_temp_free_i32(tdf);
460*a2b0a27dSPhilippe Mathieu-Daudé             }
461*a2b0a27dSPhilippe Mathieu-Daudé         }
462*a2b0a27dSPhilippe Mathieu-Daudé         break;
463*a2b0a27dSPhilippe Mathieu-Daudé     default:
464*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
465*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
466*a2b0a27dSPhilippe Mathieu-Daudé         break;
467*a2b0a27dSPhilippe Mathieu-Daudé     }
468*a2b0a27dSPhilippe Mathieu-Daudé 
469*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
470*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
471*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(ti8);
472*a2b0a27dSPhilippe Mathieu-Daudé }
473*a2b0a27dSPhilippe Mathieu-Daudé 
474*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_i5(DisasContext *ctx)
475*a2b0a27dSPhilippe Mathieu-Daudé {
476*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_I5(op)    (MASK_MSA_MINOR(op) | (op & (0x7 << 23)))
477*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 21) & 0x3;
478*a2b0a27dSPhilippe Mathieu-Daudé     int8_t s5 = (int8_t) sextract32(ctx->opcode, 16, 5);
479*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t u5 = (ctx->opcode >> 16) & 0x1f;
480*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
481*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
482*a2b0a27dSPhilippe Mathieu-Daudé 
483*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df);
484*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
485*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
486*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 timm = tcg_temp_new_i32();
487*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_movi_i32(timm, u5);
488*a2b0a27dSPhilippe Mathieu-Daudé 
489*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_I5(ctx->opcode)) {
490*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ADDVI_df:
491*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_addvi_df(cpu_env, tdf, twd, tws, timm);
492*a2b0a27dSPhilippe Mathieu-Daudé         break;
493*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SUBVI_df:
494*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_subvi_df(cpu_env, tdf, twd, tws, timm);
495*a2b0a27dSPhilippe Mathieu-Daudé         break;
496*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MAXI_S_df:
497*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
498*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_maxi_s_df(cpu_env, tdf, twd, tws, timm);
499*a2b0a27dSPhilippe Mathieu-Daudé         break;
500*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MAXI_U_df:
501*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_maxi_u_df(cpu_env, tdf, twd, tws, timm);
502*a2b0a27dSPhilippe Mathieu-Daudé         break;
503*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MINI_S_df:
504*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
505*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_mini_s_df(cpu_env, tdf, twd, tws, timm);
506*a2b0a27dSPhilippe Mathieu-Daudé         break;
507*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MINI_U_df:
508*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_mini_u_df(cpu_env, tdf, twd, tws, timm);
509*a2b0a27dSPhilippe Mathieu-Daudé         break;
510*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CEQI_df:
511*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
512*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ceqi_df(cpu_env, tdf, twd, tws, timm);
513*a2b0a27dSPhilippe Mathieu-Daudé         break;
514*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CLTI_S_df:
515*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
516*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_clti_s_df(cpu_env, tdf, twd, tws, timm);
517*a2b0a27dSPhilippe Mathieu-Daudé         break;
518*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CLTI_U_df:
519*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_clti_u_df(cpu_env, tdf, twd, tws, timm);
520*a2b0a27dSPhilippe Mathieu-Daudé         break;
521*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CLEI_S_df:
522*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
523*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_clei_s_df(cpu_env, tdf, twd, tws, timm);
524*a2b0a27dSPhilippe Mathieu-Daudé         break;
525*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CLEI_U_df:
526*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_clei_u_df(cpu_env, tdf, twd, tws, timm);
527*a2b0a27dSPhilippe Mathieu-Daudé         break;
528*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_LDI_df:
529*a2b0a27dSPhilippe Mathieu-Daudé         {
530*a2b0a27dSPhilippe Mathieu-Daudé             int32_t s10 = sextract32(ctx->opcode, 11, 10);
531*a2b0a27dSPhilippe Mathieu-Daudé             tcg_gen_movi_i32(timm, s10);
532*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ldi_df(cpu_env, tdf, twd, timm);
533*a2b0a27dSPhilippe Mathieu-Daudé         }
534*a2b0a27dSPhilippe Mathieu-Daudé         break;
535*a2b0a27dSPhilippe Mathieu-Daudé     default:
536*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
537*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
538*a2b0a27dSPhilippe Mathieu-Daudé         break;
539*a2b0a27dSPhilippe Mathieu-Daudé     }
540*a2b0a27dSPhilippe Mathieu-Daudé 
541*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
542*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
543*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
544*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(timm);
545*a2b0a27dSPhilippe Mathieu-Daudé }
546*a2b0a27dSPhilippe Mathieu-Daudé 
547*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_bit(DisasContext *ctx)
548*a2b0a27dSPhilippe Mathieu-Daudé {
549*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_BIT(op)    (MASK_MSA_MINOR(op) | (op & (0x7 << 23)))
550*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t dfm = (ctx->opcode >> 16) & 0x7f;
551*a2b0a27dSPhilippe Mathieu-Daudé     uint32_t df = 0, m = 0;
552*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
553*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
554*a2b0a27dSPhilippe Mathieu-Daudé 
555*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tdf;
556*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tm;
557*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twd;
558*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tws;
559*a2b0a27dSPhilippe Mathieu-Daudé 
560*a2b0a27dSPhilippe Mathieu-Daudé     if ((dfm & 0x40) == 0x00) {
561*a2b0a27dSPhilippe Mathieu-Daudé         m = dfm & 0x3f;
562*a2b0a27dSPhilippe Mathieu-Daudé         df = DF_DOUBLE;
563*a2b0a27dSPhilippe Mathieu-Daudé     } else if ((dfm & 0x60) == 0x40) {
564*a2b0a27dSPhilippe Mathieu-Daudé         m = dfm & 0x1f;
565*a2b0a27dSPhilippe Mathieu-Daudé         df = DF_WORD;
566*a2b0a27dSPhilippe Mathieu-Daudé     } else if ((dfm & 0x70) == 0x60) {
567*a2b0a27dSPhilippe Mathieu-Daudé         m = dfm & 0x0f;
568*a2b0a27dSPhilippe Mathieu-Daudé         df = DF_HALF;
569*a2b0a27dSPhilippe Mathieu-Daudé     } else if ((dfm & 0x78) == 0x70) {
570*a2b0a27dSPhilippe Mathieu-Daudé         m = dfm & 0x7;
571*a2b0a27dSPhilippe Mathieu-Daudé         df = DF_BYTE;
572*a2b0a27dSPhilippe Mathieu-Daudé     } else {
573*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
574*a2b0a27dSPhilippe Mathieu-Daudé         return;
575*a2b0a27dSPhilippe Mathieu-Daudé     }
576*a2b0a27dSPhilippe Mathieu-Daudé 
577*a2b0a27dSPhilippe Mathieu-Daudé     tdf = tcg_const_i32(df);
578*a2b0a27dSPhilippe Mathieu-Daudé     tm  = tcg_const_i32(m);
579*a2b0a27dSPhilippe Mathieu-Daudé     twd = tcg_const_i32(wd);
580*a2b0a27dSPhilippe Mathieu-Daudé     tws = tcg_const_i32(ws);
581*a2b0a27dSPhilippe Mathieu-Daudé 
582*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_BIT(ctx->opcode)) {
583*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SLLI_df:
584*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_slli_df(cpu_env, tdf, twd, tws, tm);
585*a2b0a27dSPhilippe Mathieu-Daudé         break;
586*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SRAI_df:
587*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_srai_df(cpu_env, tdf, twd, tws, tm);
588*a2b0a27dSPhilippe Mathieu-Daudé         break;
589*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SRLI_df:
590*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_srli_df(cpu_env, tdf, twd, tws, tm);
591*a2b0a27dSPhilippe Mathieu-Daudé         break;
592*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BCLRI_df:
593*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_bclri_df(cpu_env, tdf, twd, tws, tm);
594*a2b0a27dSPhilippe Mathieu-Daudé         break;
595*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BSETI_df:
596*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_bseti_df(cpu_env, tdf, twd, tws, tm);
597*a2b0a27dSPhilippe Mathieu-Daudé         break;
598*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BNEGI_df:
599*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_bnegi_df(cpu_env, tdf, twd, tws, tm);
600*a2b0a27dSPhilippe Mathieu-Daudé         break;
601*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BINSLI_df:
602*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_binsli_df(cpu_env, tdf, twd, tws, tm);
603*a2b0a27dSPhilippe Mathieu-Daudé         break;
604*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BINSRI_df:
605*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_binsri_df(cpu_env, tdf, twd, tws, tm);
606*a2b0a27dSPhilippe Mathieu-Daudé         break;
607*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SAT_S_df:
608*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_sat_s_df(cpu_env, tdf, twd, tws, tm);
609*a2b0a27dSPhilippe Mathieu-Daudé         break;
610*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SAT_U_df:
611*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_sat_u_df(cpu_env, tdf, twd, tws, tm);
612*a2b0a27dSPhilippe Mathieu-Daudé         break;
613*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SRARI_df:
614*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_srari_df(cpu_env, tdf, twd, tws, tm);
615*a2b0a27dSPhilippe Mathieu-Daudé         break;
616*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SRLRI_df:
617*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_srlri_df(cpu_env, tdf, twd, tws, tm);
618*a2b0a27dSPhilippe Mathieu-Daudé         break;
619*a2b0a27dSPhilippe Mathieu-Daudé     default:
620*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
621*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
622*a2b0a27dSPhilippe Mathieu-Daudé         break;
623*a2b0a27dSPhilippe Mathieu-Daudé     }
624*a2b0a27dSPhilippe Mathieu-Daudé 
625*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
626*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tm);
627*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
628*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
629*a2b0a27dSPhilippe Mathieu-Daudé }
630*a2b0a27dSPhilippe Mathieu-Daudé 
631*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_3r(DisasContext *ctx)
632*a2b0a27dSPhilippe Mathieu-Daudé {
633*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_3R(op)    (MASK_MSA_MINOR(op) | (op & (0x7 << 23)))
634*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 21) & 0x3;
635*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
636*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
637*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
638*a2b0a27dSPhilippe Mathieu-Daudé 
639*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df);
640*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
641*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
642*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
643*a2b0a27dSPhilippe Mathieu-Daudé 
644*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_3R(ctx->opcode)) {
645*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BINSL_df:
646*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
647*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
648*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_binsl_b(cpu_env, twd, tws, twt);
649*a2b0a27dSPhilippe Mathieu-Daudé             break;
650*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
651*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_binsl_h(cpu_env, twd, tws, twt);
652*a2b0a27dSPhilippe Mathieu-Daudé             break;
653*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
654*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_binsl_w(cpu_env, twd, tws, twt);
655*a2b0a27dSPhilippe Mathieu-Daudé             break;
656*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
657*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_binsl_d(cpu_env, twd, tws, twt);
658*a2b0a27dSPhilippe Mathieu-Daudé             break;
659*a2b0a27dSPhilippe Mathieu-Daudé         }
660*a2b0a27dSPhilippe Mathieu-Daudé         break;
661*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BINSR_df:
662*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
663*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
664*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_binsr_b(cpu_env, twd, tws, twt);
665*a2b0a27dSPhilippe Mathieu-Daudé             break;
666*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
667*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_binsr_h(cpu_env, twd, tws, twt);
668*a2b0a27dSPhilippe Mathieu-Daudé             break;
669*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
670*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_binsr_w(cpu_env, twd, tws, twt);
671*a2b0a27dSPhilippe Mathieu-Daudé             break;
672*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
673*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_binsr_d(cpu_env, twd, tws, twt);
674*a2b0a27dSPhilippe Mathieu-Daudé             break;
675*a2b0a27dSPhilippe Mathieu-Daudé         }
676*a2b0a27dSPhilippe Mathieu-Daudé         break;
677*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BCLR_df:
678*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
679*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
680*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bclr_b(cpu_env, twd, tws, twt);
681*a2b0a27dSPhilippe Mathieu-Daudé             break;
682*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
683*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bclr_h(cpu_env, twd, tws, twt);
684*a2b0a27dSPhilippe Mathieu-Daudé             break;
685*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
686*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bclr_w(cpu_env, twd, tws, twt);
687*a2b0a27dSPhilippe Mathieu-Daudé             break;
688*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
689*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bclr_d(cpu_env, twd, tws, twt);
690*a2b0a27dSPhilippe Mathieu-Daudé             break;
691*a2b0a27dSPhilippe Mathieu-Daudé         }
692*a2b0a27dSPhilippe Mathieu-Daudé         break;
693*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BNEG_df:
694*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
695*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
696*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bneg_b(cpu_env, twd, tws, twt);
697*a2b0a27dSPhilippe Mathieu-Daudé             break;
698*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
699*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bneg_h(cpu_env, twd, tws, twt);
700*a2b0a27dSPhilippe Mathieu-Daudé             break;
701*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
702*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bneg_w(cpu_env, twd, tws, twt);
703*a2b0a27dSPhilippe Mathieu-Daudé             break;
704*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
705*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bneg_d(cpu_env, twd, tws, twt);
706*a2b0a27dSPhilippe Mathieu-Daudé             break;
707*a2b0a27dSPhilippe Mathieu-Daudé         }
708*a2b0a27dSPhilippe Mathieu-Daudé         break;
709*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BSET_df:
710*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
711*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
712*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bset_b(cpu_env, twd, tws, twt);
713*a2b0a27dSPhilippe Mathieu-Daudé             break;
714*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
715*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bset_h(cpu_env, twd, tws, twt);
716*a2b0a27dSPhilippe Mathieu-Daudé             break;
717*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
718*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bset_w(cpu_env, twd, tws, twt);
719*a2b0a27dSPhilippe Mathieu-Daudé             break;
720*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
721*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_bset_d(cpu_env, twd, tws, twt);
722*a2b0a27dSPhilippe Mathieu-Daudé             break;
723*a2b0a27dSPhilippe Mathieu-Daudé         }
724*a2b0a27dSPhilippe Mathieu-Daudé         break;
725*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ADD_A_df:
726*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
727*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
728*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_add_a_b(cpu_env, twd, tws, twt);
729*a2b0a27dSPhilippe Mathieu-Daudé             break;
730*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
731*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_add_a_h(cpu_env, twd, tws, twt);
732*a2b0a27dSPhilippe Mathieu-Daudé             break;
733*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
734*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_add_a_w(cpu_env, twd, tws, twt);
735*a2b0a27dSPhilippe Mathieu-Daudé             break;
736*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
737*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_add_a_d(cpu_env, twd, tws, twt);
738*a2b0a27dSPhilippe Mathieu-Daudé             break;
739*a2b0a27dSPhilippe Mathieu-Daudé         }
740*a2b0a27dSPhilippe Mathieu-Daudé         break;
741*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ADDS_A_df:
742*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
743*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
744*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_b(cpu_env, twd, tws, twt);
745*a2b0a27dSPhilippe Mathieu-Daudé             break;
746*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
747*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_h(cpu_env, twd, tws, twt);
748*a2b0a27dSPhilippe Mathieu-Daudé             break;
749*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
750*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_w(cpu_env, twd, tws, twt);
751*a2b0a27dSPhilippe Mathieu-Daudé             break;
752*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
753*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_d(cpu_env, twd, tws, twt);
754*a2b0a27dSPhilippe Mathieu-Daudé             break;
755*a2b0a27dSPhilippe Mathieu-Daudé         }
756*a2b0a27dSPhilippe Mathieu-Daudé         break;
757*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ADDS_S_df:
758*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
759*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
760*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_b(cpu_env, twd, tws, twt);
761*a2b0a27dSPhilippe Mathieu-Daudé             break;
762*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
763*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_h(cpu_env, twd, tws, twt);
764*a2b0a27dSPhilippe Mathieu-Daudé             break;
765*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
766*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_w(cpu_env, twd, tws, twt);
767*a2b0a27dSPhilippe Mathieu-Daudé             break;
768*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
769*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_d(cpu_env, twd, tws, twt);
770*a2b0a27dSPhilippe Mathieu-Daudé             break;
771*a2b0a27dSPhilippe Mathieu-Daudé         }
772*a2b0a27dSPhilippe Mathieu-Daudé         break;
773*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ADDS_U_df:
774*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
775*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
776*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_b(cpu_env, twd, tws, twt);
777*a2b0a27dSPhilippe Mathieu-Daudé             break;
778*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
779*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_h(cpu_env, twd, tws, twt);
780*a2b0a27dSPhilippe Mathieu-Daudé             break;
781*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
782*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_w(cpu_env, twd, tws, twt);
783*a2b0a27dSPhilippe Mathieu-Daudé             break;
784*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
785*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_d(cpu_env, twd, tws, twt);
786*a2b0a27dSPhilippe Mathieu-Daudé             break;
787*a2b0a27dSPhilippe Mathieu-Daudé         }
788*a2b0a27dSPhilippe Mathieu-Daudé         break;
789*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ADDV_df:
790*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
791*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
792*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_addv_b(cpu_env, twd, tws, twt);
793*a2b0a27dSPhilippe Mathieu-Daudé             break;
794*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
795*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_addv_h(cpu_env, twd, tws, twt);
796*a2b0a27dSPhilippe Mathieu-Daudé             break;
797*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
798*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_addv_w(cpu_env, twd, tws, twt);
799*a2b0a27dSPhilippe Mathieu-Daudé             break;
800*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
801*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_addv_d(cpu_env, twd, tws, twt);
802*a2b0a27dSPhilippe Mathieu-Daudé             break;
803*a2b0a27dSPhilippe Mathieu-Daudé         }
804*a2b0a27dSPhilippe Mathieu-Daudé         break;
805*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_AVE_S_df:
806*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
807*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
808*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_b(cpu_env, twd, tws, twt);
809*a2b0a27dSPhilippe Mathieu-Daudé             break;
810*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
811*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_h(cpu_env, twd, tws, twt);
812*a2b0a27dSPhilippe Mathieu-Daudé             break;
813*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
814*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_w(cpu_env, twd, tws, twt);
815*a2b0a27dSPhilippe Mathieu-Daudé             break;
816*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
817*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_d(cpu_env, twd, tws, twt);
818*a2b0a27dSPhilippe Mathieu-Daudé             break;
819*a2b0a27dSPhilippe Mathieu-Daudé         }
820*a2b0a27dSPhilippe Mathieu-Daudé         break;
821*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_AVE_U_df:
822*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
823*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
824*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_b(cpu_env, twd, tws, twt);
825*a2b0a27dSPhilippe Mathieu-Daudé             break;
826*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
827*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_h(cpu_env, twd, tws, twt);
828*a2b0a27dSPhilippe Mathieu-Daudé             break;
829*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
830*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_w(cpu_env, twd, tws, twt);
831*a2b0a27dSPhilippe Mathieu-Daudé             break;
832*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
833*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_d(cpu_env, twd, tws, twt);
834*a2b0a27dSPhilippe Mathieu-Daudé             break;
835*a2b0a27dSPhilippe Mathieu-Daudé         }
836*a2b0a27dSPhilippe Mathieu-Daudé         break;
837*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_AVER_S_df:
838*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
839*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
840*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_b(cpu_env, twd, tws, twt);
841*a2b0a27dSPhilippe Mathieu-Daudé             break;
842*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
843*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_h(cpu_env, twd, tws, twt);
844*a2b0a27dSPhilippe Mathieu-Daudé             break;
845*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
846*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_w(cpu_env, twd, tws, twt);
847*a2b0a27dSPhilippe Mathieu-Daudé             break;
848*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
849*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_d(cpu_env, twd, tws, twt);
850*a2b0a27dSPhilippe Mathieu-Daudé             break;
851*a2b0a27dSPhilippe Mathieu-Daudé         }
852*a2b0a27dSPhilippe Mathieu-Daudé         break;
853*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_AVER_U_df:
854*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
855*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
856*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_b(cpu_env, twd, tws, twt);
857*a2b0a27dSPhilippe Mathieu-Daudé             break;
858*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
859*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_h(cpu_env, twd, tws, twt);
860*a2b0a27dSPhilippe Mathieu-Daudé             break;
861*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
862*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_w(cpu_env, twd, tws, twt);
863*a2b0a27dSPhilippe Mathieu-Daudé             break;
864*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
865*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_d(cpu_env, twd, tws, twt);
866*a2b0a27dSPhilippe Mathieu-Daudé             break;
867*a2b0a27dSPhilippe Mathieu-Daudé         }
868*a2b0a27dSPhilippe Mathieu-Daudé         break;
869*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CEQ_df:
870*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
871*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
872*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ceq_b(cpu_env, twd, tws, twt);
873*a2b0a27dSPhilippe Mathieu-Daudé             break;
874*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
875*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ceq_h(cpu_env, twd, tws, twt);
876*a2b0a27dSPhilippe Mathieu-Daudé             break;
877*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
878*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ceq_w(cpu_env, twd, tws, twt);
879*a2b0a27dSPhilippe Mathieu-Daudé             break;
880*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
881*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ceq_d(cpu_env, twd, tws, twt);
882*a2b0a27dSPhilippe Mathieu-Daudé             break;
883*a2b0a27dSPhilippe Mathieu-Daudé         }
884*a2b0a27dSPhilippe Mathieu-Daudé         break;
885*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CLE_S_df:
886*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
887*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
888*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_b(cpu_env, twd, tws, twt);
889*a2b0a27dSPhilippe Mathieu-Daudé             break;
890*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
891*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_h(cpu_env, twd, tws, twt);
892*a2b0a27dSPhilippe Mathieu-Daudé             break;
893*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
894*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_w(cpu_env, twd, tws, twt);
895*a2b0a27dSPhilippe Mathieu-Daudé             break;
896*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
897*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_d(cpu_env, twd, tws, twt);
898*a2b0a27dSPhilippe Mathieu-Daudé             break;
899*a2b0a27dSPhilippe Mathieu-Daudé         }
900*a2b0a27dSPhilippe Mathieu-Daudé         break;
901*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CLE_U_df:
902*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
903*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
904*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_b(cpu_env, twd, tws, twt);
905*a2b0a27dSPhilippe Mathieu-Daudé             break;
906*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
907*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_h(cpu_env, twd, tws, twt);
908*a2b0a27dSPhilippe Mathieu-Daudé             break;
909*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
910*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_w(cpu_env, twd, tws, twt);
911*a2b0a27dSPhilippe Mathieu-Daudé             break;
912*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
913*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_d(cpu_env, twd, tws, twt);
914*a2b0a27dSPhilippe Mathieu-Daudé             break;
915*a2b0a27dSPhilippe Mathieu-Daudé         }
916*a2b0a27dSPhilippe Mathieu-Daudé         break;
917*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CLT_S_df:
918*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
919*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
920*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_b(cpu_env, twd, tws, twt);
921*a2b0a27dSPhilippe Mathieu-Daudé             break;
922*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
923*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_h(cpu_env, twd, tws, twt);
924*a2b0a27dSPhilippe Mathieu-Daudé             break;
925*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
926*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_w(cpu_env, twd, tws, twt);
927*a2b0a27dSPhilippe Mathieu-Daudé             break;
928*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
929*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_d(cpu_env, twd, tws, twt);
930*a2b0a27dSPhilippe Mathieu-Daudé             break;
931*a2b0a27dSPhilippe Mathieu-Daudé         }
932*a2b0a27dSPhilippe Mathieu-Daudé         break;
933*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CLT_U_df:
934*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
935*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
936*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_b(cpu_env, twd, tws, twt);
937*a2b0a27dSPhilippe Mathieu-Daudé             break;
938*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
939*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_h(cpu_env, twd, tws, twt);
940*a2b0a27dSPhilippe Mathieu-Daudé             break;
941*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
942*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_w(cpu_env, twd, tws, twt);
943*a2b0a27dSPhilippe Mathieu-Daudé             break;
944*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
945*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_d(cpu_env, twd, tws, twt);
946*a2b0a27dSPhilippe Mathieu-Daudé             break;
947*a2b0a27dSPhilippe Mathieu-Daudé         }
948*a2b0a27dSPhilippe Mathieu-Daudé         break;
949*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_DIV_S_df:
950*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
951*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
952*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_div_s_b(cpu_env, twd, tws, twt);
953*a2b0a27dSPhilippe Mathieu-Daudé             break;
954*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
955*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_div_s_h(cpu_env, twd, tws, twt);
956*a2b0a27dSPhilippe Mathieu-Daudé             break;
957*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
958*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_div_s_w(cpu_env, twd, tws, twt);
959*a2b0a27dSPhilippe Mathieu-Daudé             break;
960*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
961*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_div_s_d(cpu_env, twd, tws, twt);
962*a2b0a27dSPhilippe Mathieu-Daudé             break;
963*a2b0a27dSPhilippe Mathieu-Daudé         }
964*a2b0a27dSPhilippe Mathieu-Daudé         break;
965*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_DIV_U_df:
966*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
967*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
968*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_div_u_b(cpu_env, twd, tws, twt);
969*a2b0a27dSPhilippe Mathieu-Daudé             break;
970*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
971*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_div_u_h(cpu_env, twd, tws, twt);
972*a2b0a27dSPhilippe Mathieu-Daudé             break;
973*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
974*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_div_u_w(cpu_env, twd, tws, twt);
975*a2b0a27dSPhilippe Mathieu-Daudé             break;
976*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
977*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_div_u_d(cpu_env, twd, tws, twt);
978*a2b0a27dSPhilippe Mathieu-Daudé             break;
979*a2b0a27dSPhilippe Mathieu-Daudé         }
980*a2b0a27dSPhilippe Mathieu-Daudé         break;
981*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MAX_A_df:
982*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
983*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
984*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_a_b(cpu_env, twd, tws, twt);
985*a2b0a27dSPhilippe Mathieu-Daudé             break;
986*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
987*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_a_h(cpu_env, twd, tws, twt);
988*a2b0a27dSPhilippe Mathieu-Daudé             break;
989*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
990*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_a_w(cpu_env, twd, tws, twt);
991*a2b0a27dSPhilippe Mathieu-Daudé             break;
992*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
993*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_a_d(cpu_env, twd, tws, twt);
994*a2b0a27dSPhilippe Mathieu-Daudé             break;
995*a2b0a27dSPhilippe Mathieu-Daudé         }
996*a2b0a27dSPhilippe Mathieu-Daudé         break;
997*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MAX_S_df:
998*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
999*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1000*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_s_b(cpu_env, twd, tws, twt);
1001*a2b0a27dSPhilippe Mathieu-Daudé             break;
1002*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1003*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_s_h(cpu_env, twd, tws, twt);
1004*a2b0a27dSPhilippe Mathieu-Daudé             break;
1005*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1006*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_s_w(cpu_env, twd, tws, twt);
1007*a2b0a27dSPhilippe Mathieu-Daudé             break;
1008*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1009*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_s_d(cpu_env, twd, tws, twt);
1010*a2b0a27dSPhilippe Mathieu-Daudé             break;
1011*a2b0a27dSPhilippe Mathieu-Daudé         }
1012*a2b0a27dSPhilippe Mathieu-Daudé         break;
1013*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MAX_U_df:
1014*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1015*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1016*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_u_b(cpu_env, twd, tws, twt);
1017*a2b0a27dSPhilippe Mathieu-Daudé             break;
1018*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1019*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_u_h(cpu_env, twd, tws, twt);
1020*a2b0a27dSPhilippe Mathieu-Daudé             break;
1021*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1022*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_u_w(cpu_env, twd, tws, twt);
1023*a2b0a27dSPhilippe Mathieu-Daudé             break;
1024*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1025*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_max_u_d(cpu_env, twd, tws, twt);
1026*a2b0a27dSPhilippe Mathieu-Daudé             break;
1027*a2b0a27dSPhilippe Mathieu-Daudé         }
1028*a2b0a27dSPhilippe Mathieu-Daudé         break;
1029*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MIN_A_df:
1030*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1031*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1032*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_a_b(cpu_env, twd, tws, twt);
1033*a2b0a27dSPhilippe Mathieu-Daudé             break;
1034*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1035*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_a_h(cpu_env, twd, tws, twt);
1036*a2b0a27dSPhilippe Mathieu-Daudé             break;
1037*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1038*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_a_w(cpu_env, twd, tws, twt);
1039*a2b0a27dSPhilippe Mathieu-Daudé             break;
1040*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1041*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_a_d(cpu_env, twd, tws, twt);
1042*a2b0a27dSPhilippe Mathieu-Daudé             break;
1043*a2b0a27dSPhilippe Mathieu-Daudé         }
1044*a2b0a27dSPhilippe Mathieu-Daudé         break;
1045*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MIN_S_df:
1046*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1047*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1048*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_s_b(cpu_env, twd, tws, twt);
1049*a2b0a27dSPhilippe Mathieu-Daudé             break;
1050*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1051*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_s_h(cpu_env, twd, tws, twt);
1052*a2b0a27dSPhilippe Mathieu-Daudé             break;
1053*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1054*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_s_w(cpu_env, twd, tws, twt);
1055*a2b0a27dSPhilippe Mathieu-Daudé             break;
1056*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1057*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_s_d(cpu_env, twd, tws, twt);
1058*a2b0a27dSPhilippe Mathieu-Daudé             break;
1059*a2b0a27dSPhilippe Mathieu-Daudé         }
1060*a2b0a27dSPhilippe Mathieu-Daudé         break;
1061*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MIN_U_df:
1062*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1063*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1064*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_u_b(cpu_env, twd, tws, twt);
1065*a2b0a27dSPhilippe Mathieu-Daudé             break;
1066*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1067*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_u_h(cpu_env, twd, tws, twt);
1068*a2b0a27dSPhilippe Mathieu-Daudé             break;
1069*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1070*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_u_w(cpu_env, twd, tws, twt);
1071*a2b0a27dSPhilippe Mathieu-Daudé             break;
1072*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1073*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_min_u_d(cpu_env, twd, tws, twt);
1074*a2b0a27dSPhilippe Mathieu-Daudé             break;
1075*a2b0a27dSPhilippe Mathieu-Daudé         }
1076*a2b0a27dSPhilippe Mathieu-Daudé         break;
1077*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MOD_S_df:
1078*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1079*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1080*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_b(cpu_env, twd, tws, twt);
1081*a2b0a27dSPhilippe Mathieu-Daudé             break;
1082*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1083*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_h(cpu_env, twd, tws, twt);
1084*a2b0a27dSPhilippe Mathieu-Daudé             break;
1085*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1086*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_w(cpu_env, twd, tws, twt);
1087*a2b0a27dSPhilippe Mathieu-Daudé             break;
1088*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1089*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_d(cpu_env, twd, tws, twt);
1090*a2b0a27dSPhilippe Mathieu-Daudé             break;
1091*a2b0a27dSPhilippe Mathieu-Daudé         }
1092*a2b0a27dSPhilippe Mathieu-Daudé         break;
1093*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MOD_U_df:
1094*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1095*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1096*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_b(cpu_env, twd, tws, twt);
1097*a2b0a27dSPhilippe Mathieu-Daudé             break;
1098*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1099*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_h(cpu_env, twd, tws, twt);
1100*a2b0a27dSPhilippe Mathieu-Daudé             break;
1101*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1102*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_w(cpu_env, twd, tws, twt);
1103*a2b0a27dSPhilippe Mathieu-Daudé             break;
1104*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1105*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_d(cpu_env, twd, tws, twt);
1106*a2b0a27dSPhilippe Mathieu-Daudé             break;
1107*a2b0a27dSPhilippe Mathieu-Daudé         }
1108*a2b0a27dSPhilippe Mathieu-Daudé         break;
1109*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MADDV_df:
1110*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1111*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1112*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_maddv_b(cpu_env, twd, tws, twt);
1113*a2b0a27dSPhilippe Mathieu-Daudé             break;
1114*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1115*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_maddv_h(cpu_env, twd, tws, twt);
1116*a2b0a27dSPhilippe Mathieu-Daudé             break;
1117*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1118*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_maddv_w(cpu_env, twd, tws, twt);
1119*a2b0a27dSPhilippe Mathieu-Daudé             break;
1120*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1121*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_maddv_d(cpu_env, twd, tws, twt);
1122*a2b0a27dSPhilippe Mathieu-Daudé             break;
1123*a2b0a27dSPhilippe Mathieu-Daudé         }
1124*a2b0a27dSPhilippe Mathieu-Daudé         break;
1125*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSUBV_df:
1126*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1127*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1128*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_msubv_b(cpu_env, twd, tws, twt);
1129*a2b0a27dSPhilippe Mathieu-Daudé             break;
1130*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1131*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_msubv_h(cpu_env, twd, tws, twt);
1132*a2b0a27dSPhilippe Mathieu-Daudé             break;
1133*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1134*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_msubv_w(cpu_env, twd, tws, twt);
1135*a2b0a27dSPhilippe Mathieu-Daudé             break;
1136*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1137*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_msubv_d(cpu_env, twd, tws, twt);
1138*a2b0a27dSPhilippe Mathieu-Daudé             break;
1139*a2b0a27dSPhilippe Mathieu-Daudé         }
1140*a2b0a27dSPhilippe Mathieu-Daudé         break;
1141*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ASUB_S_df:
1142*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1143*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1144*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_b(cpu_env, twd, tws, twt);
1145*a2b0a27dSPhilippe Mathieu-Daudé             break;
1146*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1147*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_h(cpu_env, twd, tws, twt);
1148*a2b0a27dSPhilippe Mathieu-Daudé             break;
1149*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1150*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_w(cpu_env, twd, tws, twt);
1151*a2b0a27dSPhilippe Mathieu-Daudé             break;
1152*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1153*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_d(cpu_env, twd, tws, twt);
1154*a2b0a27dSPhilippe Mathieu-Daudé             break;
1155*a2b0a27dSPhilippe Mathieu-Daudé         }
1156*a2b0a27dSPhilippe Mathieu-Daudé         break;
1157*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ASUB_U_df:
1158*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1159*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1160*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_b(cpu_env, twd, tws, twt);
1161*a2b0a27dSPhilippe Mathieu-Daudé             break;
1162*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1163*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_h(cpu_env, twd, tws, twt);
1164*a2b0a27dSPhilippe Mathieu-Daudé             break;
1165*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1166*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_w(cpu_env, twd, tws, twt);
1167*a2b0a27dSPhilippe Mathieu-Daudé             break;
1168*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1169*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_d(cpu_env, twd, tws, twt);
1170*a2b0a27dSPhilippe Mathieu-Daudé             break;
1171*a2b0a27dSPhilippe Mathieu-Daudé         }
1172*a2b0a27dSPhilippe Mathieu-Daudé         break;
1173*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ILVEV_df:
1174*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1175*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1176*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_b(cpu_env, twd, tws, twt);
1177*a2b0a27dSPhilippe Mathieu-Daudé             break;
1178*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1179*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_h(cpu_env, twd, tws, twt);
1180*a2b0a27dSPhilippe Mathieu-Daudé             break;
1181*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1182*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_w(cpu_env, twd, tws, twt);
1183*a2b0a27dSPhilippe Mathieu-Daudé             break;
1184*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1185*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_d(cpu_env, twd, tws, twt);
1186*a2b0a27dSPhilippe Mathieu-Daudé             break;
1187*a2b0a27dSPhilippe Mathieu-Daudé         }
1188*a2b0a27dSPhilippe Mathieu-Daudé         break;
1189*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ILVOD_df:
1190*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1191*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1192*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_b(cpu_env, twd, tws, twt);
1193*a2b0a27dSPhilippe Mathieu-Daudé             break;
1194*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1195*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_h(cpu_env, twd, tws, twt);
1196*a2b0a27dSPhilippe Mathieu-Daudé             break;
1197*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1198*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_w(cpu_env, twd, tws, twt);
1199*a2b0a27dSPhilippe Mathieu-Daudé             break;
1200*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1201*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_d(cpu_env, twd, tws, twt);
1202*a2b0a27dSPhilippe Mathieu-Daudé             break;
1203*a2b0a27dSPhilippe Mathieu-Daudé         }
1204*a2b0a27dSPhilippe Mathieu-Daudé         break;
1205*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ILVL_df:
1206*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1207*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1208*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_b(cpu_env, twd, tws, twt);
1209*a2b0a27dSPhilippe Mathieu-Daudé             break;
1210*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1211*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_h(cpu_env, twd, tws, twt);
1212*a2b0a27dSPhilippe Mathieu-Daudé             break;
1213*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1214*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_w(cpu_env, twd, tws, twt);
1215*a2b0a27dSPhilippe Mathieu-Daudé             break;
1216*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1217*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_d(cpu_env, twd, tws, twt);
1218*a2b0a27dSPhilippe Mathieu-Daudé             break;
1219*a2b0a27dSPhilippe Mathieu-Daudé         }
1220*a2b0a27dSPhilippe Mathieu-Daudé         break;
1221*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ILVR_df:
1222*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1223*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1224*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_b(cpu_env, twd, tws, twt);
1225*a2b0a27dSPhilippe Mathieu-Daudé             break;
1226*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1227*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_h(cpu_env, twd, tws, twt);
1228*a2b0a27dSPhilippe Mathieu-Daudé             break;
1229*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1230*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_w(cpu_env, twd, tws, twt);
1231*a2b0a27dSPhilippe Mathieu-Daudé             break;
1232*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1233*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_d(cpu_env, twd, tws, twt);
1234*a2b0a27dSPhilippe Mathieu-Daudé             break;
1235*a2b0a27dSPhilippe Mathieu-Daudé         }
1236*a2b0a27dSPhilippe Mathieu-Daudé         break;
1237*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_PCKEV_df:
1238*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1239*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1240*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pckev_b(cpu_env, twd, tws, twt);
1241*a2b0a27dSPhilippe Mathieu-Daudé             break;
1242*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1243*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pckev_h(cpu_env, twd, tws, twt);
1244*a2b0a27dSPhilippe Mathieu-Daudé             break;
1245*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1246*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pckev_w(cpu_env, twd, tws, twt);
1247*a2b0a27dSPhilippe Mathieu-Daudé             break;
1248*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1249*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pckev_d(cpu_env, twd, tws, twt);
1250*a2b0a27dSPhilippe Mathieu-Daudé             break;
1251*a2b0a27dSPhilippe Mathieu-Daudé         }
1252*a2b0a27dSPhilippe Mathieu-Daudé         break;
1253*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_PCKOD_df:
1254*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1255*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1256*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pckod_b(cpu_env, twd, tws, twt);
1257*a2b0a27dSPhilippe Mathieu-Daudé             break;
1258*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1259*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pckod_h(cpu_env, twd, tws, twt);
1260*a2b0a27dSPhilippe Mathieu-Daudé             break;
1261*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1262*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pckod_w(cpu_env, twd, tws, twt);
1263*a2b0a27dSPhilippe Mathieu-Daudé             break;
1264*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1265*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pckod_d(cpu_env, twd, tws, twt);
1266*a2b0a27dSPhilippe Mathieu-Daudé             break;
1267*a2b0a27dSPhilippe Mathieu-Daudé         }
1268*a2b0a27dSPhilippe Mathieu-Daudé         break;
1269*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SLL_df:
1270*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1271*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1272*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_sll_b(cpu_env, twd, tws, twt);
1273*a2b0a27dSPhilippe Mathieu-Daudé             break;
1274*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1275*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_sll_h(cpu_env, twd, tws, twt);
1276*a2b0a27dSPhilippe Mathieu-Daudé             break;
1277*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1278*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_sll_w(cpu_env, twd, tws, twt);
1279*a2b0a27dSPhilippe Mathieu-Daudé             break;
1280*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1281*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_sll_d(cpu_env, twd, tws, twt);
1282*a2b0a27dSPhilippe Mathieu-Daudé             break;
1283*a2b0a27dSPhilippe Mathieu-Daudé         }
1284*a2b0a27dSPhilippe Mathieu-Daudé         break;
1285*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SRA_df:
1286*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1287*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1288*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_sra_b(cpu_env, twd, tws, twt);
1289*a2b0a27dSPhilippe Mathieu-Daudé             break;
1290*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1291*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_sra_h(cpu_env, twd, tws, twt);
1292*a2b0a27dSPhilippe Mathieu-Daudé             break;
1293*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1294*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_sra_w(cpu_env, twd, tws, twt);
1295*a2b0a27dSPhilippe Mathieu-Daudé             break;
1296*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1297*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_sra_d(cpu_env, twd, tws, twt);
1298*a2b0a27dSPhilippe Mathieu-Daudé             break;
1299*a2b0a27dSPhilippe Mathieu-Daudé         }
1300*a2b0a27dSPhilippe Mathieu-Daudé         break;
1301*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SRAR_df:
1302*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1303*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1304*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srar_b(cpu_env, twd, tws, twt);
1305*a2b0a27dSPhilippe Mathieu-Daudé             break;
1306*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1307*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srar_h(cpu_env, twd, tws, twt);
1308*a2b0a27dSPhilippe Mathieu-Daudé             break;
1309*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1310*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srar_w(cpu_env, twd, tws, twt);
1311*a2b0a27dSPhilippe Mathieu-Daudé             break;
1312*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1313*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srar_d(cpu_env, twd, tws, twt);
1314*a2b0a27dSPhilippe Mathieu-Daudé             break;
1315*a2b0a27dSPhilippe Mathieu-Daudé         }
1316*a2b0a27dSPhilippe Mathieu-Daudé         break;
1317*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SRL_df:
1318*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1319*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1320*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srl_b(cpu_env, twd, tws, twt);
1321*a2b0a27dSPhilippe Mathieu-Daudé             break;
1322*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1323*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srl_h(cpu_env, twd, tws, twt);
1324*a2b0a27dSPhilippe Mathieu-Daudé             break;
1325*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1326*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srl_w(cpu_env, twd, tws, twt);
1327*a2b0a27dSPhilippe Mathieu-Daudé             break;
1328*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1329*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srl_d(cpu_env, twd, tws, twt);
1330*a2b0a27dSPhilippe Mathieu-Daudé             break;
1331*a2b0a27dSPhilippe Mathieu-Daudé         }
1332*a2b0a27dSPhilippe Mathieu-Daudé         break;
1333*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SRLR_df:
1334*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1335*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1336*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srlr_b(cpu_env, twd, tws, twt);
1337*a2b0a27dSPhilippe Mathieu-Daudé             break;
1338*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1339*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srlr_h(cpu_env, twd, tws, twt);
1340*a2b0a27dSPhilippe Mathieu-Daudé             break;
1341*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1342*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srlr_w(cpu_env, twd, tws, twt);
1343*a2b0a27dSPhilippe Mathieu-Daudé             break;
1344*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1345*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_srlr_d(cpu_env, twd, tws, twt);
1346*a2b0a27dSPhilippe Mathieu-Daudé             break;
1347*a2b0a27dSPhilippe Mathieu-Daudé         }
1348*a2b0a27dSPhilippe Mathieu-Daudé         break;
1349*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SUBS_S_df:
1350*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1351*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1352*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_b(cpu_env, twd, tws, twt);
1353*a2b0a27dSPhilippe Mathieu-Daudé             break;
1354*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1355*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_h(cpu_env, twd, tws, twt);
1356*a2b0a27dSPhilippe Mathieu-Daudé             break;
1357*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1358*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_w(cpu_env, twd, tws, twt);
1359*a2b0a27dSPhilippe Mathieu-Daudé             break;
1360*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1361*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_d(cpu_env, twd, tws, twt);
1362*a2b0a27dSPhilippe Mathieu-Daudé             break;
1363*a2b0a27dSPhilippe Mathieu-Daudé         }
1364*a2b0a27dSPhilippe Mathieu-Daudé         break;
1365*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MULV_df:
1366*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1367*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1368*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mulv_b(cpu_env, twd, tws, twt);
1369*a2b0a27dSPhilippe Mathieu-Daudé             break;
1370*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1371*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mulv_h(cpu_env, twd, tws, twt);
1372*a2b0a27dSPhilippe Mathieu-Daudé             break;
1373*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1374*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mulv_w(cpu_env, twd, tws, twt);
1375*a2b0a27dSPhilippe Mathieu-Daudé             break;
1376*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1377*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_mulv_d(cpu_env, twd, tws, twt);
1378*a2b0a27dSPhilippe Mathieu-Daudé             break;
1379*a2b0a27dSPhilippe Mathieu-Daudé         }
1380*a2b0a27dSPhilippe Mathieu-Daudé         break;
1381*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SLD_df:
1382*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_sld_df(cpu_env, tdf, twd, tws, twt);
1383*a2b0a27dSPhilippe Mathieu-Daudé         break;
1384*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_VSHF_df:
1385*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_vshf_df(cpu_env, tdf, twd, tws, twt);
1386*a2b0a27dSPhilippe Mathieu-Daudé         break;
1387*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SUBV_df:
1388*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1389*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1390*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subv_b(cpu_env, twd, tws, twt);
1391*a2b0a27dSPhilippe Mathieu-Daudé             break;
1392*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1393*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subv_h(cpu_env, twd, tws, twt);
1394*a2b0a27dSPhilippe Mathieu-Daudé             break;
1395*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1396*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subv_w(cpu_env, twd, tws, twt);
1397*a2b0a27dSPhilippe Mathieu-Daudé             break;
1398*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1399*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subv_d(cpu_env, twd, tws, twt);
1400*a2b0a27dSPhilippe Mathieu-Daudé             break;
1401*a2b0a27dSPhilippe Mathieu-Daudé         }
1402*a2b0a27dSPhilippe Mathieu-Daudé         break;
1403*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SUBS_U_df:
1404*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1405*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1406*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_b(cpu_env, twd, tws, twt);
1407*a2b0a27dSPhilippe Mathieu-Daudé             break;
1408*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1409*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_h(cpu_env, twd, tws, twt);
1410*a2b0a27dSPhilippe Mathieu-Daudé             break;
1411*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1412*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_w(cpu_env, twd, tws, twt);
1413*a2b0a27dSPhilippe Mathieu-Daudé             break;
1414*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1415*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_d(cpu_env, twd, tws, twt);
1416*a2b0a27dSPhilippe Mathieu-Daudé             break;
1417*a2b0a27dSPhilippe Mathieu-Daudé         }
1418*a2b0a27dSPhilippe Mathieu-Daudé         break;
1419*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SPLAT_df:
1420*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_splat_df(cpu_env, tdf, twd, tws, twt);
1421*a2b0a27dSPhilippe Mathieu-Daudé         break;
1422*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SUBSUS_U_df:
1423*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1424*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1425*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_b(cpu_env, twd, tws, twt);
1426*a2b0a27dSPhilippe Mathieu-Daudé             break;
1427*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1428*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_h(cpu_env, twd, tws, twt);
1429*a2b0a27dSPhilippe Mathieu-Daudé             break;
1430*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1431*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_w(cpu_env, twd, tws, twt);
1432*a2b0a27dSPhilippe Mathieu-Daudé             break;
1433*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1434*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_d(cpu_env, twd, tws, twt);
1435*a2b0a27dSPhilippe Mathieu-Daudé             break;
1436*a2b0a27dSPhilippe Mathieu-Daudé         }
1437*a2b0a27dSPhilippe Mathieu-Daudé         break;
1438*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SUBSUU_S_df:
1439*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1440*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1441*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_b(cpu_env, twd, tws, twt);
1442*a2b0a27dSPhilippe Mathieu-Daudé             break;
1443*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1444*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_h(cpu_env, twd, tws, twt);
1445*a2b0a27dSPhilippe Mathieu-Daudé             break;
1446*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1447*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_w(cpu_env, twd, tws, twt);
1448*a2b0a27dSPhilippe Mathieu-Daudé             break;
1449*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1450*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_d(cpu_env, twd, tws, twt);
1451*a2b0a27dSPhilippe Mathieu-Daudé             break;
1452*a2b0a27dSPhilippe Mathieu-Daudé         }
1453*a2b0a27dSPhilippe Mathieu-Daudé         break;
1454*a2b0a27dSPhilippe Mathieu-Daudé 
1455*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_DOTP_S_df:
1456*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_DOTP_U_df:
1457*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_DPADD_S_df:
1458*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_DPADD_U_df:
1459*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_DPSUB_S_df:
1460*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_HADD_S_df:
1461*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_DPSUB_U_df:
1462*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_HADD_U_df:
1463*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_HSUB_S_df:
1464*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_HSUB_U_df:
1465*a2b0a27dSPhilippe Mathieu-Daudé         if (df == DF_BYTE) {
1466*a2b0a27dSPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
1467*a2b0a27dSPhilippe Mathieu-Daudé             break;
1468*a2b0a27dSPhilippe Mathieu-Daudé         }
1469*a2b0a27dSPhilippe Mathieu-Daudé         switch (MASK_MSA_3R(ctx->opcode)) {
1470*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_HADD_S_df:
1471*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1472*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1473*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_s_h(cpu_env, twd, tws, twt);
1474*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1475*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1476*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_s_w(cpu_env, twd, tws, twt);
1477*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1478*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1479*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_s_d(cpu_env, twd, tws, twt);
1480*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1481*a2b0a27dSPhilippe Mathieu-Daudé             }
1482*a2b0a27dSPhilippe Mathieu-Daudé             break;
1483*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_HADD_U_df:
1484*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1485*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1486*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_u_h(cpu_env, twd, tws, twt);
1487*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1488*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1489*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_u_w(cpu_env, twd, tws, twt);
1490*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1491*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1492*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_u_d(cpu_env, twd, tws, twt);
1493*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1494*a2b0a27dSPhilippe Mathieu-Daudé             }
1495*a2b0a27dSPhilippe Mathieu-Daudé             break;
1496*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_HSUB_S_df:
1497*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1498*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1499*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_s_h(cpu_env, twd, tws, twt);
1500*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1501*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1502*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_s_w(cpu_env, twd, tws, twt);
1503*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1504*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1505*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_s_d(cpu_env, twd, tws, twt);
1506*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1507*a2b0a27dSPhilippe Mathieu-Daudé             }
1508*a2b0a27dSPhilippe Mathieu-Daudé             break;
1509*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_HSUB_U_df:
1510*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1511*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1512*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_u_h(cpu_env, twd, tws, twt);
1513*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1514*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1515*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_u_w(cpu_env, twd, tws, twt);
1516*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1517*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1518*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_u_d(cpu_env, twd, tws, twt);
1519*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1520*a2b0a27dSPhilippe Mathieu-Daudé             }
1521*a2b0a27dSPhilippe Mathieu-Daudé             break;
1522*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_DOTP_S_df:
1523*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1524*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1525*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_s_h(cpu_env, twd, tws, twt);
1526*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1527*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1528*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_s_w(cpu_env, twd, tws, twt);
1529*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1530*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1531*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_s_d(cpu_env, twd, tws, twt);
1532*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1533*a2b0a27dSPhilippe Mathieu-Daudé             }
1534*a2b0a27dSPhilippe Mathieu-Daudé             break;
1535*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_DOTP_U_df:
1536*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1537*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1538*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_u_h(cpu_env, twd, tws, twt);
1539*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1540*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1541*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_u_w(cpu_env, twd, tws, twt);
1542*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1543*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1544*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_u_d(cpu_env, twd, tws, twt);
1545*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1546*a2b0a27dSPhilippe Mathieu-Daudé             }
1547*a2b0a27dSPhilippe Mathieu-Daudé             break;
1548*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_DPADD_S_df:
1549*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1550*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1551*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_s_h(cpu_env, twd, tws, twt);
1552*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1553*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1554*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_s_w(cpu_env, twd, tws, twt);
1555*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1556*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1557*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_s_d(cpu_env, twd, tws, twt);
1558*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1559*a2b0a27dSPhilippe Mathieu-Daudé             }
1560*a2b0a27dSPhilippe Mathieu-Daudé             break;
1561*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_DPADD_U_df:
1562*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1563*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1564*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_u_h(cpu_env, twd, tws, twt);
1565*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1566*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1567*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_u_w(cpu_env, twd, tws, twt);
1568*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1569*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1570*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_u_d(cpu_env, twd, tws, twt);
1571*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1572*a2b0a27dSPhilippe Mathieu-Daudé             }
1573*a2b0a27dSPhilippe Mathieu-Daudé             break;
1574*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_DPSUB_S_df:
1575*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1576*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1577*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_s_h(cpu_env, twd, tws, twt);
1578*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1579*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1580*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_s_w(cpu_env, twd, tws, twt);
1581*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1582*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1583*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_s_d(cpu_env, twd, tws, twt);
1584*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1585*a2b0a27dSPhilippe Mathieu-Daudé             }
1586*a2b0a27dSPhilippe Mathieu-Daudé             break;
1587*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_DPSUB_U_df:
1588*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1589*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1590*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_u_h(cpu_env, twd, tws, twt);
1591*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1592*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1593*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_u_w(cpu_env, twd, tws, twt);
1594*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1595*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1596*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_u_d(cpu_env, twd, tws, twt);
1597*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1598*a2b0a27dSPhilippe Mathieu-Daudé             }
1599*a2b0a27dSPhilippe Mathieu-Daudé             break;
1600*a2b0a27dSPhilippe Mathieu-Daudé         }
1601*a2b0a27dSPhilippe Mathieu-Daudé         break;
1602*a2b0a27dSPhilippe Mathieu-Daudé     default:
1603*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
1604*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
1605*a2b0a27dSPhilippe Mathieu-Daudé         break;
1606*a2b0a27dSPhilippe Mathieu-Daudé     }
1607*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
1608*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
1609*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
1610*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
1611*a2b0a27dSPhilippe Mathieu-Daudé }
1612*a2b0a27dSPhilippe Mathieu-Daudé 
1613*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_elm_3e(DisasContext *ctx)
1614*a2b0a27dSPhilippe Mathieu-Daudé {
1615*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_ELM_DF3E(op)   (MASK_MSA_MINOR(op) | (op & (0x3FF << 16)))
1616*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t source = (ctx->opcode >> 11) & 0x1f;
1617*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t dest = (ctx->opcode >> 6) & 0x1f;
1618*a2b0a27dSPhilippe Mathieu-Daudé     TCGv telm = tcg_temp_new();
1619*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tsr = tcg_const_i32(source);
1620*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tdt = tcg_const_i32(dest);
1621*a2b0a27dSPhilippe Mathieu-Daudé 
1622*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_ELM_DF3E(ctx->opcode)) {
1623*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CTCMSA:
1624*a2b0a27dSPhilippe Mathieu-Daudé         gen_load_gpr(telm, source);
1625*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ctcmsa(cpu_env, telm, tdt);
1626*a2b0a27dSPhilippe Mathieu-Daudé         break;
1627*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_CFCMSA:
1628*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_cfcmsa(telm, cpu_env, tsr);
1629*a2b0a27dSPhilippe Mathieu-Daudé         gen_store_gpr(telm, dest);
1630*a2b0a27dSPhilippe Mathieu-Daudé         break;
1631*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MOVE_V:
1632*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_move_v(cpu_env, tdt, tsr);
1633*a2b0a27dSPhilippe Mathieu-Daudé         break;
1634*a2b0a27dSPhilippe Mathieu-Daudé     default:
1635*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
1636*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
1637*a2b0a27dSPhilippe Mathieu-Daudé         break;
1638*a2b0a27dSPhilippe Mathieu-Daudé     }
1639*a2b0a27dSPhilippe Mathieu-Daudé 
1640*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free(telm);
1641*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdt);
1642*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tsr);
1643*a2b0a27dSPhilippe Mathieu-Daudé }
1644*a2b0a27dSPhilippe Mathieu-Daudé 
1645*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_elm_df(DisasContext *ctx, uint32_t df, uint32_t n)
1646*a2b0a27dSPhilippe Mathieu-Daudé {
1647*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_ELM(op)    (MASK_MSA_MINOR(op) | (op & (0xf << 22)))
1648*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
1649*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
1650*a2b0a27dSPhilippe Mathieu-Daudé 
1651*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
1652*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
1653*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tn  = tcg_const_i32(n);
1654*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df);
1655*a2b0a27dSPhilippe Mathieu-Daudé 
1656*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_ELM(ctx->opcode)) {
1657*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SLDI_df:
1658*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_sldi_df(cpu_env, tdf, twd, tws, tn);
1659*a2b0a27dSPhilippe Mathieu-Daudé         break;
1660*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_SPLATI_df:
1661*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_splati_df(cpu_env, tdf, twd, tws, tn);
1662*a2b0a27dSPhilippe Mathieu-Daudé         break;
1663*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_INSVE_df:
1664*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_insve_df(cpu_env, tdf, twd, tws, tn);
1665*a2b0a27dSPhilippe Mathieu-Daudé         break;
1666*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_COPY_S_df:
1667*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_COPY_U_df:
1668*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_INSERT_df:
1669*a2b0a27dSPhilippe Mathieu-Daudé #if !defined(TARGET_MIPS64)
1670*a2b0a27dSPhilippe Mathieu-Daudé         /* Double format valid only for MIPS64 */
1671*a2b0a27dSPhilippe Mathieu-Daudé         if (df == DF_DOUBLE) {
1672*a2b0a27dSPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
1673*a2b0a27dSPhilippe Mathieu-Daudé             break;
1674*a2b0a27dSPhilippe Mathieu-Daudé         }
1675*a2b0a27dSPhilippe Mathieu-Daudé         if ((MASK_MSA_ELM(ctx->opcode) == OPC_COPY_U_df) &&
1676*a2b0a27dSPhilippe Mathieu-Daudé               (df == DF_WORD)) {
1677*a2b0a27dSPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
1678*a2b0a27dSPhilippe Mathieu-Daudé             break;
1679*a2b0a27dSPhilippe Mathieu-Daudé         }
1680*a2b0a27dSPhilippe Mathieu-Daudé #endif
1681*a2b0a27dSPhilippe Mathieu-Daudé         switch (MASK_MSA_ELM(ctx->opcode)) {
1682*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_COPY_S_df:
1683*a2b0a27dSPhilippe Mathieu-Daudé             if (likely(wd != 0)) {
1684*a2b0a27dSPhilippe Mathieu-Daudé                 switch (df) {
1685*a2b0a27dSPhilippe Mathieu-Daudé                 case DF_BYTE:
1686*a2b0a27dSPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_b(cpu_env, twd, tws, tn);
1687*a2b0a27dSPhilippe Mathieu-Daudé                     break;
1688*a2b0a27dSPhilippe Mathieu-Daudé                 case DF_HALF:
1689*a2b0a27dSPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_h(cpu_env, twd, tws, tn);
1690*a2b0a27dSPhilippe Mathieu-Daudé                     break;
1691*a2b0a27dSPhilippe Mathieu-Daudé                 case DF_WORD:
1692*a2b0a27dSPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_w(cpu_env, twd, tws, tn);
1693*a2b0a27dSPhilippe Mathieu-Daudé                     break;
1694*a2b0a27dSPhilippe Mathieu-Daudé #if defined(TARGET_MIPS64)
1695*a2b0a27dSPhilippe Mathieu-Daudé                 case DF_DOUBLE:
1696*a2b0a27dSPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_d(cpu_env, twd, tws, tn);
1697*a2b0a27dSPhilippe Mathieu-Daudé                     break;
1698*a2b0a27dSPhilippe Mathieu-Daudé #endif
1699*a2b0a27dSPhilippe Mathieu-Daudé                 default:
1700*a2b0a27dSPhilippe Mathieu-Daudé                     assert(0);
1701*a2b0a27dSPhilippe Mathieu-Daudé                 }
1702*a2b0a27dSPhilippe Mathieu-Daudé             }
1703*a2b0a27dSPhilippe Mathieu-Daudé             break;
1704*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_COPY_U_df:
1705*a2b0a27dSPhilippe Mathieu-Daudé             if (likely(wd != 0)) {
1706*a2b0a27dSPhilippe Mathieu-Daudé                 switch (df) {
1707*a2b0a27dSPhilippe Mathieu-Daudé                 case DF_BYTE:
1708*a2b0a27dSPhilippe Mathieu-Daudé                     gen_helper_msa_copy_u_b(cpu_env, twd, tws, tn);
1709*a2b0a27dSPhilippe Mathieu-Daudé                     break;
1710*a2b0a27dSPhilippe Mathieu-Daudé                 case DF_HALF:
1711*a2b0a27dSPhilippe Mathieu-Daudé                     gen_helper_msa_copy_u_h(cpu_env, twd, tws, tn);
1712*a2b0a27dSPhilippe Mathieu-Daudé                     break;
1713*a2b0a27dSPhilippe Mathieu-Daudé #if defined(TARGET_MIPS64)
1714*a2b0a27dSPhilippe Mathieu-Daudé                 case DF_WORD:
1715*a2b0a27dSPhilippe Mathieu-Daudé                     gen_helper_msa_copy_u_w(cpu_env, twd, tws, tn);
1716*a2b0a27dSPhilippe Mathieu-Daudé                     break;
1717*a2b0a27dSPhilippe Mathieu-Daudé #endif
1718*a2b0a27dSPhilippe Mathieu-Daudé                 default:
1719*a2b0a27dSPhilippe Mathieu-Daudé                     assert(0);
1720*a2b0a27dSPhilippe Mathieu-Daudé                 }
1721*a2b0a27dSPhilippe Mathieu-Daudé             }
1722*a2b0a27dSPhilippe Mathieu-Daudé             break;
1723*a2b0a27dSPhilippe Mathieu-Daudé         case OPC_INSERT_df:
1724*a2b0a27dSPhilippe Mathieu-Daudé             switch (df) {
1725*a2b0a27dSPhilippe Mathieu-Daudé             case DF_BYTE:
1726*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_insert_b(cpu_env, twd, tws, tn);
1727*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1728*a2b0a27dSPhilippe Mathieu-Daudé             case DF_HALF:
1729*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_insert_h(cpu_env, twd, tws, tn);
1730*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1731*a2b0a27dSPhilippe Mathieu-Daudé             case DF_WORD:
1732*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_insert_w(cpu_env, twd, tws, tn);
1733*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1734*a2b0a27dSPhilippe Mathieu-Daudé #if defined(TARGET_MIPS64)
1735*a2b0a27dSPhilippe Mathieu-Daudé             case DF_DOUBLE:
1736*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_insert_d(cpu_env, twd, tws, tn);
1737*a2b0a27dSPhilippe Mathieu-Daudé                 break;
1738*a2b0a27dSPhilippe Mathieu-Daudé #endif
1739*a2b0a27dSPhilippe Mathieu-Daudé             default:
1740*a2b0a27dSPhilippe Mathieu-Daudé                 assert(0);
1741*a2b0a27dSPhilippe Mathieu-Daudé             }
1742*a2b0a27dSPhilippe Mathieu-Daudé             break;
1743*a2b0a27dSPhilippe Mathieu-Daudé         }
1744*a2b0a27dSPhilippe Mathieu-Daudé         break;
1745*a2b0a27dSPhilippe Mathieu-Daudé     default:
1746*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
1747*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
1748*a2b0a27dSPhilippe Mathieu-Daudé     }
1749*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
1750*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
1751*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tn);
1752*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
1753*a2b0a27dSPhilippe Mathieu-Daudé }
1754*a2b0a27dSPhilippe Mathieu-Daudé 
1755*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_elm(DisasContext *ctx)
1756*a2b0a27dSPhilippe Mathieu-Daudé {
1757*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t dfn = (ctx->opcode >> 16) & 0x3f;
1758*a2b0a27dSPhilippe Mathieu-Daudé     uint32_t df = 0, n = 0;
1759*a2b0a27dSPhilippe Mathieu-Daudé 
1760*a2b0a27dSPhilippe Mathieu-Daudé     if ((dfn & 0x30) == 0x00) {
1761*a2b0a27dSPhilippe Mathieu-Daudé         n = dfn & 0x0f;
1762*a2b0a27dSPhilippe Mathieu-Daudé         df = DF_BYTE;
1763*a2b0a27dSPhilippe Mathieu-Daudé     } else if ((dfn & 0x38) == 0x20) {
1764*a2b0a27dSPhilippe Mathieu-Daudé         n = dfn & 0x07;
1765*a2b0a27dSPhilippe Mathieu-Daudé         df = DF_HALF;
1766*a2b0a27dSPhilippe Mathieu-Daudé     } else if ((dfn & 0x3c) == 0x30) {
1767*a2b0a27dSPhilippe Mathieu-Daudé         n = dfn & 0x03;
1768*a2b0a27dSPhilippe Mathieu-Daudé         df = DF_WORD;
1769*a2b0a27dSPhilippe Mathieu-Daudé     } else if ((dfn & 0x3e) == 0x38) {
1770*a2b0a27dSPhilippe Mathieu-Daudé         n = dfn & 0x01;
1771*a2b0a27dSPhilippe Mathieu-Daudé         df = DF_DOUBLE;
1772*a2b0a27dSPhilippe Mathieu-Daudé     } else if (dfn == 0x3E) {
1773*a2b0a27dSPhilippe Mathieu-Daudé         /* CTCMSA, CFCMSA, MOVE.V */
1774*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_elm_3e(ctx);
1775*a2b0a27dSPhilippe Mathieu-Daudé         return;
1776*a2b0a27dSPhilippe Mathieu-Daudé     } else {
1777*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
1778*a2b0a27dSPhilippe Mathieu-Daudé         return;
1779*a2b0a27dSPhilippe Mathieu-Daudé     }
1780*a2b0a27dSPhilippe Mathieu-Daudé 
1781*a2b0a27dSPhilippe Mathieu-Daudé     gen_msa_elm_df(ctx, df, n);
1782*a2b0a27dSPhilippe Mathieu-Daudé }
1783*a2b0a27dSPhilippe Mathieu-Daudé 
1784*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_3rf(DisasContext *ctx)
1785*a2b0a27dSPhilippe Mathieu-Daudé {
1786*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_3RF(op)    (MASK_MSA_MINOR(op) | (op & (0xf << 22)))
1787*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 21) & 0x1;
1788*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
1789*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
1790*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
1791*a2b0a27dSPhilippe Mathieu-Daudé 
1792*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
1793*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
1794*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
1795*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_temp_new_i32();
1796*a2b0a27dSPhilippe Mathieu-Daudé 
1797*a2b0a27dSPhilippe Mathieu-Daudé     /* adjust df value for floating-point instruction */
1798*a2b0a27dSPhilippe Mathieu-Daudé     tcg_gen_movi_i32(tdf, df + 2);
1799*a2b0a27dSPhilippe Mathieu-Daudé 
1800*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_3RF(ctx->opcode)) {
1801*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCAF_df:
1802*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fcaf_df(cpu_env, tdf, twd, tws, twt);
1803*a2b0a27dSPhilippe Mathieu-Daudé         break;
1804*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FADD_df:
1805*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fadd_df(cpu_env, tdf, twd, tws, twt);
1806*a2b0a27dSPhilippe Mathieu-Daudé         break;
1807*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCUN_df:
1808*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fcun_df(cpu_env, tdf, twd, tws, twt);
1809*a2b0a27dSPhilippe Mathieu-Daudé         break;
1810*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSUB_df:
1811*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsub_df(cpu_env, tdf, twd, tws, twt);
1812*a2b0a27dSPhilippe Mathieu-Daudé         break;
1813*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCOR_df:
1814*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fcor_df(cpu_env, tdf, twd, tws, twt);
1815*a2b0a27dSPhilippe Mathieu-Daudé         break;
1816*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCEQ_df:
1817*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fceq_df(cpu_env, tdf, twd, tws, twt);
1818*a2b0a27dSPhilippe Mathieu-Daudé         break;
1819*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FMUL_df:
1820*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fmul_df(cpu_env, tdf, twd, tws, twt);
1821*a2b0a27dSPhilippe Mathieu-Daudé         break;
1822*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCUNE_df:
1823*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fcune_df(cpu_env, tdf, twd, tws, twt);
1824*a2b0a27dSPhilippe Mathieu-Daudé         break;
1825*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCUEQ_df:
1826*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fcueq_df(cpu_env, tdf, twd, tws, twt);
1827*a2b0a27dSPhilippe Mathieu-Daudé         break;
1828*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FDIV_df:
1829*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fdiv_df(cpu_env, tdf, twd, tws, twt);
1830*a2b0a27dSPhilippe Mathieu-Daudé         break;
1831*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCNE_df:
1832*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fcne_df(cpu_env, tdf, twd, tws, twt);
1833*a2b0a27dSPhilippe Mathieu-Daudé         break;
1834*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCLT_df:
1835*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fclt_df(cpu_env, tdf, twd, tws, twt);
1836*a2b0a27dSPhilippe Mathieu-Daudé         break;
1837*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FMADD_df:
1838*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fmadd_df(cpu_env, tdf, twd, tws, twt);
1839*a2b0a27dSPhilippe Mathieu-Daudé         break;
1840*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MUL_Q_df:
1841*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
1842*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_mul_q_df(cpu_env, tdf, twd, tws, twt);
1843*a2b0a27dSPhilippe Mathieu-Daudé         break;
1844*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCULT_df:
1845*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fcult_df(cpu_env, tdf, twd, tws, twt);
1846*a2b0a27dSPhilippe Mathieu-Daudé         break;
1847*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FMSUB_df:
1848*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fmsub_df(cpu_env, tdf, twd, tws, twt);
1849*a2b0a27dSPhilippe Mathieu-Daudé         break;
1850*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MADD_Q_df:
1851*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
1852*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_madd_q_df(cpu_env, tdf, twd, tws, twt);
1853*a2b0a27dSPhilippe Mathieu-Daudé         break;
1854*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCLE_df:
1855*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fcle_df(cpu_env, tdf, twd, tws, twt);
1856*a2b0a27dSPhilippe Mathieu-Daudé         break;
1857*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSUB_Q_df:
1858*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
1859*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_msub_q_df(cpu_env, tdf, twd, tws, twt);
1860*a2b0a27dSPhilippe Mathieu-Daudé         break;
1861*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCULE_df:
1862*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fcule_df(cpu_env, tdf, twd, tws, twt);
1863*a2b0a27dSPhilippe Mathieu-Daudé         break;
1864*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FEXP2_df:
1865*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fexp2_df(cpu_env, tdf, twd, tws, twt);
1866*a2b0a27dSPhilippe Mathieu-Daudé         break;
1867*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSAF_df:
1868*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsaf_df(cpu_env, tdf, twd, tws, twt);
1869*a2b0a27dSPhilippe Mathieu-Daudé         break;
1870*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FEXDO_df:
1871*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fexdo_df(cpu_env, tdf, twd, tws, twt);
1872*a2b0a27dSPhilippe Mathieu-Daudé         break;
1873*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSUN_df:
1874*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsun_df(cpu_env, tdf, twd, tws, twt);
1875*a2b0a27dSPhilippe Mathieu-Daudé         break;
1876*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSOR_df:
1877*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsor_df(cpu_env, tdf, twd, tws, twt);
1878*a2b0a27dSPhilippe Mathieu-Daudé         break;
1879*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSEQ_df:
1880*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fseq_df(cpu_env, tdf, twd, tws, twt);
1881*a2b0a27dSPhilippe Mathieu-Daudé         break;
1882*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FTQ_df:
1883*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ftq_df(cpu_env, tdf, twd, tws, twt);
1884*a2b0a27dSPhilippe Mathieu-Daudé         break;
1885*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSUNE_df:
1886*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsune_df(cpu_env, tdf, twd, tws, twt);
1887*a2b0a27dSPhilippe Mathieu-Daudé         break;
1888*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSUEQ_df:
1889*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsueq_df(cpu_env, tdf, twd, tws, twt);
1890*a2b0a27dSPhilippe Mathieu-Daudé         break;
1891*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSNE_df:
1892*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsne_df(cpu_env, tdf, twd, tws, twt);
1893*a2b0a27dSPhilippe Mathieu-Daudé         break;
1894*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSLT_df:
1895*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fslt_df(cpu_env, tdf, twd, tws, twt);
1896*a2b0a27dSPhilippe Mathieu-Daudé         break;
1897*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FMIN_df:
1898*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fmin_df(cpu_env, tdf, twd, tws, twt);
1899*a2b0a27dSPhilippe Mathieu-Daudé         break;
1900*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MULR_Q_df:
1901*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
1902*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_mulr_q_df(cpu_env, tdf, twd, tws, twt);
1903*a2b0a27dSPhilippe Mathieu-Daudé         break;
1904*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSULT_df:
1905*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsult_df(cpu_env, tdf, twd, tws, twt);
1906*a2b0a27dSPhilippe Mathieu-Daudé         break;
1907*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FMIN_A_df:
1908*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fmin_a_df(cpu_env, tdf, twd, tws, twt);
1909*a2b0a27dSPhilippe Mathieu-Daudé         break;
1910*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MADDR_Q_df:
1911*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
1912*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_maddr_q_df(cpu_env, tdf, twd, tws, twt);
1913*a2b0a27dSPhilippe Mathieu-Daudé         break;
1914*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSLE_df:
1915*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsle_df(cpu_env, tdf, twd, tws, twt);
1916*a2b0a27dSPhilippe Mathieu-Daudé         break;
1917*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FMAX_df:
1918*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fmax_df(cpu_env, tdf, twd, tws, twt);
1919*a2b0a27dSPhilippe Mathieu-Daudé         break;
1920*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSUBR_Q_df:
1921*a2b0a27dSPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
1922*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_msubr_q_df(cpu_env, tdf, twd, tws, twt);
1923*a2b0a27dSPhilippe Mathieu-Daudé         break;
1924*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSULE_df:
1925*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsule_df(cpu_env, tdf, twd, tws, twt);
1926*a2b0a27dSPhilippe Mathieu-Daudé         break;
1927*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FMAX_A_df:
1928*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fmax_a_df(cpu_env, tdf, twd, tws, twt);
1929*a2b0a27dSPhilippe Mathieu-Daudé         break;
1930*a2b0a27dSPhilippe Mathieu-Daudé     default:
1931*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
1932*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
1933*a2b0a27dSPhilippe Mathieu-Daudé         break;
1934*a2b0a27dSPhilippe Mathieu-Daudé     }
1935*a2b0a27dSPhilippe Mathieu-Daudé 
1936*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
1937*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
1938*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
1939*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
1940*a2b0a27dSPhilippe Mathieu-Daudé }
1941*a2b0a27dSPhilippe Mathieu-Daudé 
1942*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_2r(DisasContext *ctx)
1943*a2b0a27dSPhilippe Mathieu-Daudé {
1944*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_2R(op)     (MASK_MSA_MINOR(op) | (op & (0x1f << 21)) | \
1945*a2b0a27dSPhilippe Mathieu-Daudé                             (op & (0x7 << 18)))
1946*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
1947*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
1948*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
1949*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 16) & 0x3;
1950*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
1951*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
1952*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
1953*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df);
1954*a2b0a27dSPhilippe Mathieu-Daudé 
1955*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_2R(ctx->opcode)) {
1956*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FILL_df:
1957*a2b0a27dSPhilippe Mathieu-Daudé #if !defined(TARGET_MIPS64)
1958*a2b0a27dSPhilippe Mathieu-Daudé         /* Double format valid only for MIPS64 */
1959*a2b0a27dSPhilippe Mathieu-Daudé         if (df == DF_DOUBLE) {
1960*a2b0a27dSPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
1961*a2b0a27dSPhilippe Mathieu-Daudé             break;
1962*a2b0a27dSPhilippe Mathieu-Daudé         }
1963*a2b0a27dSPhilippe Mathieu-Daudé #endif
1964*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fill_df(cpu_env, tdf, twd, tws); /* trs */
1965*a2b0a27dSPhilippe Mathieu-Daudé         break;
1966*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_NLOC_df:
1967*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1968*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1969*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_nloc_b(cpu_env, twd, tws);
1970*a2b0a27dSPhilippe Mathieu-Daudé             break;
1971*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1972*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_nloc_h(cpu_env, twd, tws);
1973*a2b0a27dSPhilippe Mathieu-Daudé             break;
1974*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1975*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_nloc_w(cpu_env, twd, tws);
1976*a2b0a27dSPhilippe Mathieu-Daudé             break;
1977*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1978*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_nloc_d(cpu_env, twd, tws);
1979*a2b0a27dSPhilippe Mathieu-Daudé             break;
1980*a2b0a27dSPhilippe Mathieu-Daudé         }
1981*a2b0a27dSPhilippe Mathieu-Daudé         break;
1982*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_NLZC_df:
1983*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
1984*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
1985*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_nlzc_b(cpu_env, twd, tws);
1986*a2b0a27dSPhilippe Mathieu-Daudé             break;
1987*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
1988*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_nlzc_h(cpu_env, twd, tws);
1989*a2b0a27dSPhilippe Mathieu-Daudé             break;
1990*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
1991*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_nlzc_w(cpu_env, twd, tws);
1992*a2b0a27dSPhilippe Mathieu-Daudé             break;
1993*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
1994*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_nlzc_d(cpu_env, twd, tws);
1995*a2b0a27dSPhilippe Mathieu-Daudé             break;
1996*a2b0a27dSPhilippe Mathieu-Daudé         }
1997*a2b0a27dSPhilippe Mathieu-Daudé         break;
1998*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_PCNT_df:
1999*a2b0a27dSPhilippe Mathieu-Daudé         switch (df) {
2000*a2b0a27dSPhilippe Mathieu-Daudé         case DF_BYTE:
2001*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pcnt_b(cpu_env, twd, tws);
2002*a2b0a27dSPhilippe Mathieu-Daudé             break;
2003*a2b0a27dSPhilippe Mathieu-Daudé         case DF_HALF:
2004*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pcnt_h(cpu_env, twd, tws);
2005*a2b0a27dSPhilippe Mathieu-Daudé             break;
2006*a2b0a27dSPhilippe Mathieu-Daudé         case DF_WORD:
2007*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pcnt_w(cpu_env, twd, tws);
2008*a2b0a27dSPhilippe Mathieu-Daudé             break;
2009*a2b0a27dSPhilippe Mathieu-Daudé         case DF_DOUBLE:
2010*a2b0a27dSPhilippe Mathieu-Daudé             gen_helper_msa_pcnt_d(cpu_env, twd, tws);
2011*a2b0a27dSPhilippe Mathieu-Daudé             break;
2012*a2b0a27dSPhilippe Mathieu-Daudé         }
2013*a2b0a27dSPhilippe Mathieu-Daudé         break;
2014*a2b0a27dSPhilippe Mathieu-Daudé     default:
2015*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
2016*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
2017*a2b0a27dSPhilippe Mathieu-Daudé         break;
2018*a2b0a27dSPhilippe Mathieu-Daudé     }
2019*a2b0a27dSPhilippe Mathieu-Daudé 
2020*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
2021*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
2022*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
2023*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
2024*a2b0a27dSPhilippe Mathieu-Daudé }
2025*a2b0a27dSPhilippe Mathieu-Daudé 
2026*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_2rf(DisasContext *ctx)
2027*a2b0a27dSPhilippe Mathieu-Daudé {
2028*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_2RF(op)    (MASK_MSA_MINOR(op) | (op & (0x1f << 21)) | \
2029*a2b0a27dSPhilippe Mathieu-Daudé                             (op & (0xf << 17)))
2030*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
2031*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
2032*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
2033*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 16) & 0x1;
2034*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
2035*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
2036*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
2037*a2b0a27dSPhilippe Mathieu-Daudé     /* adjust df value for floating-point instruction */
2038*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df + 2);
2039*a2b0a27dSPhilippe Mathieu-Daudé 
2040*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_2RF(ctx->opcode)) {
2041*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FCLASS_df:
2042*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fclass_df(cpu_env, tdf, twd, tws);
2043*a2b0a27dSPhilippe Mathieu-Daudé         break;
2044*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FTRUNC_S_df:
2045*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ftrunc_s_df(cpu_env, tdf, twd, tws);
2046*a2b0a27dSPhilippe Mathieu-Daudé         break;
2047*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FTRUNC_U_df:
2048*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ftrunc_u_df(cpu_env, tdf, twd, tws);
2049*a2b0a27dSPhilippe Mathieu-Daudé         break;
2050*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FSQRT_df:
2051*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fsqrt_df(cpu_env, tdf, twd, tws);
2052*a2b0a27dSPhilippe Mathieu-Daudé         break;
2053*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FRSQRT_df:
2054*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_frsqrt_df(cpu_env, tdf, twd, tws);
2055*a2b0a27dSPhilippe Mathieu-Daudé         break;
2056*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FRCP_df:
2057*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_frcp_df(cpu_env, tdf, twd, tws);
2058*a2b0a27dSPhilippe Mathieu-Daudé         break;
2059*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FRINT_df:
2060*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_frint_df(cpu_env, tdf, twd, tws);
2061*a2b0a27dSPhilippe Mathieu-Daudé         break;
2062*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FLOG2_df:
2063*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_flog2_df(cpu_env, tdf, twd, tws);
2064*a2b0a27dSPhilippe Mathieu-Daudé         break;
2065*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FEXUPL_df:
2066*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fexupl_df(cpu_env, tdf, twd, tws);
2067*a2b0a27dSPhilippe Mathieu-Daudé         break;
2068*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FEXUPR_df:
2069*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_fexupr_df(cpu_env, tdf, twd, tws);
2070*a2b0a27dSPhilippe Mathieu-Daudé         break;
2071*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FFQL_df:
2072*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ffql_df(cpu_env, tdf, twd, tws);
2073*a2b0a27dSPhilippe Mathieu-Daudé         break;
2074*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FFQR_df:
2075*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ffqr_df(cpu_env, tdf, twd, tws);
2076*a2b0a27dSPhilippe Mathieu-Daudé         break;
2077*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FTINT_S_df:
2078*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ftint_s_df(cpu_env, tdf, twd, tws);
2079*a2b0a27dSPhilippe Mathieu-Daudé         break;
2080*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FTINT_U_df:
2081*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ftint_u_df(cpu_env, tdf, twd, tws);
2082*a2b0a27dSPhilippe Mathieu-Daudé         break;
2083*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FFINT_S_df:
2084*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ffint_s_df(cpu_env, tdf, twd, tws);
2085*a2b0a27dSPhilippe Mathieu-Daudé         break;
2086*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_FFINT_U_df:
2087*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_ffint_u_df(cpu_env, tdf, twd, tws);
2088*a2b0a27dSPhilippe Mathieu-Daudé         break;
2089*a2b0a27dSPhilippe Mathieu-Daudé     }
2090*a2b0a27dSPhilippe Mathieu-Daudé 
2091*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
2092*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
2093*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
2094*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
2095*a2b0a27dSPhilippe Mathieu-Daudé }
2096*a2b0a27dSPhilippe Mathieu-Daudé 
2097*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_vec_v(DisasContext *ctx)
2098*a2b0a27dSPhilippe Mathieu-Daudé {
2099*a2b0a27dSPhilippe Mathieu-Daudé #define MASK_MSA_VEC(op)    (MASK_MSA_MINOR(op) | (op & (0x1f << 21)))
2100*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
2101*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
2102*a2b0a27dSPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
2103*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
2104*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
2105*a2b0a27dSPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
2106*a2b0a27dSPhilippe Mathieu-Daudé 
2107*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_VEC(ctx->opcode)) {
2108*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_AND_V:
2109*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_and_v(cpu_env, twd, tws, twt);
2110*a2b0a27dSPhilippe Mathieu-Daudé         break;
2111*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_OR_V:
2112*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_or_v(cpu_env, twd, tws, twt);
2113*a2b0a27dSPhilippe Mathieu-Daudé         break;
2114*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_NOR_V:
2115*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_nor_v(cpu_env, twd, tws, twt);
2116*a2b0a27dSPhilippe Mathieu-Daudé         break;
2117*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_XOR_V:
2118*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_xor_v(cpu_env, twd, tws, twt);
2119*a2b0a27dSPhilippe Mathieu-Daudé         break;
2120*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BMNZ_V:
2121*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_bmnz_v(cpu_env, twd, tws, twt);
2122*a2b0a27dSPhilippe Mathieu-Daudé         break;
2123*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BMZ_V:
2124*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_bmz_v(cpu_env, twd, tws, twt);
2125*a2b0a27dSPhilippe Mathieu-Daudé         break;
2126*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BSEL_V:
2127*a2b0a27dSPhilippe Mathieu-Daudé         gen_helper_msa_bsel_v(cpu_env, twd, tws, twt);
2128*a2b0a27dSPhilippe Mathieu-Daudé         break;
2129*a2b0a27dSPhilippe Mathieu-Daudé     default:
2130*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
2131*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
2132*a2b0a27dSPhilippe Mathieu-Daudé         break;
2133*a2b0a27dSPhilippe Mathieu-Daudé     }
2134*a2b0a27dSPhilippe Mathieu-Daudé 
2135*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
2136*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
2137*a2b0a27dSPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
2138*a2b0a27dSPhilippe Mathieu-Daudé }
2139*a2b0a27dSPhilippe Mathieu-Daudé 
2140*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa_vec(DisasContext *ctx)
2141*a2b0a27dSPhilippe Mathieu-Daudé {
2142*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_VEC(ctx->opcode)) {
2143*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_AND_V:
2144*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_OR_V:
2145*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_NOR_V:
2146*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_XOR_V:
2147*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BMNZ_V:
2148*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BMZ_V:
2149*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_BSEL_V:
2150*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_vec_v(ctx);
2151*a2b0a27dSPhilippe Mathieu-Daudé         break;
2152*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_2R:
2153*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_2r(ctx);
2154*a2b0a27dSPhilippe Mathieu-Daudé         break;
2155*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_2RF:
2156*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_2rf(ctx);
2157*a2b0a27dSPhilippe Mathieu-Daudé         break;
2158*a2b0a27dSPhilippe Mathieu-Daudé     default:
2159*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
2160*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
2161*a2b0a27dSPhilippe Mathieu-Daudé         break;
2162*a2b0a27dSPhilippe Mathieu-Daudé     }
2163*a2b0a27dSPhilippe Mathieu-Daudé }
2164*a2b0a27dSPhilippe Mathieu-Daudé 
2165*a2b0a27dSPhilippe Mathieu-Daudé static void gen_msa(DisasContext *ctx)
2166*a2b0a27dSPhilippe Mathieu-Daudé {
2167*a2b0a27dSPhilippe Mathieu-Daudé     uint32_t opcode = ctx->opcode;
2168*a2b0a27dSPhilippe Mathieu-Daudé 
2169*a2b0a27dSPhilippe Mathieu-Daudé     check_msa_access(ctx);
2170*a2b0a27dSPhilippe Mathieu-Daudé 
2171*a2b0a27dSPhilippe Mathieu-Daudé     switch (MASK_MSA_MINOR(opcode)) {
2172*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_I8_00:
2173*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_I8_01:
2174*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_I8_02:
2175*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_i8(ctx);
2176*a2b0a27dSPhilippe Mathieu-Daudé         break;
2177*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_I5_06:
2178*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_I5_07:
2179*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_i5(ctx);
2180*a2b0a27dSPhilippe Mathieu-Daudé         break;
2181*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_BIT_09:
2182*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_BIT_0A:
2183*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_bit(ctx);
2184*a2b0a27dSPhilippe Mathieu-Daudé         break;
2185*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3R_0D:
2186*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3R_0E:
2187*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3R_0F:
2188*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3R_10:
2189*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3R_11:
2190*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3R_12:
2191*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3R_13:
2192*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3R_14:
2193*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3R_15:
2194*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_3r(ctx);
2195*a2b0a27dSPhilippe Mathieu-Daudé         break;
2196*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_ELM:
2197*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_elm(ctx);
2198*a2b0a27dSPhilippe Mathieu-Daudé         break;
2199*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3RF_1A:
2200*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3RF_1B:
2201*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_3RF_1C:
2202*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_3rf(ctx);
2203*a2b0a27dSPhilippe Mathieu-Daudé         break;
2204*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_MSA_VEC:
2205*a2b0a27dSPhilippe Mathieu-Daudé         gen_msa_vec(ctx);
2206*a2b0a27dSPhilippe Mathieu-Daudé         break;
2207*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_LD_B:
2208*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_LD_H:
2209*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_LD_W:
2210*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_LD_D:
2211*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ST_B:
2212*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ST_H:
2213*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ST_W:
2214*a2b0a27dSPhilippe Mathieu-Daudé     case OPC_ST_D:
2215*a2b0a27dSPhilippe Mathieu-Daudé         {
2216*a2b0a27dSPhilippe Mathieu-Daudé             int32_t s10 = sextract32(ctx->opcode, 16, 10);
2217*a2b0a27dSPhilippe Mathieu-Daudé             uint8_t rs = (ctx->opcode >> 11) & 0x1f;
2218*a2b0a27dSPhilippe Mathieu-Daudé             uint8_t wd = (ctx->opcode >> 6) & 0x1f;
2219*a2b0a27dSPhilippe Mathieu-Daudé             uint8_t df = (ctx->opcode >> 0) & 0x3;
2220*a2b0a27dSPhilippe Mathieu-Daudé 
2221*a2b0a27dSPhilippe Mathieu-Daudé             TCGv_i32 twd = tcg_const_i32(wd);
2222*a2b0a27dSPhilippe Mathieu-Daudé             TCGv taddr = tcg_temp_new();
2223*a2b0a27dSPhilippe Mathieu-Daudé             gen_base_offset_addr(ctx, taddr, rs, s10 << df);
2224*a2b0a27dSPhilippe Mathieu-Daudé 
2225*a2b0a27dSPhilippe Mathieu-Daudé             switch (MASK_MSA_MINOR(opcode)) {
2226*a2b0a27dSPhilippe Mathieu-Daudé             case OPC_LD_B:
2227*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_ld_b(cpu_env, twd, taddr);
2228*a2b0a27dSPhilippe Mathieu-Daudé                 break;
2229*a2b0a27dSPhilippe Mathieu-Daudé             case OPC_LD_H:
2230*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_ld_h(cpu_env, twd, taddr);
2231*a2b0a27dSPhilippe Mathieu-Daudé                 break;
2232*a2b0a27dSPhilippe Mathieu-Daudé             case OPC_LD_W:
2233*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_ld_w(cpu_env, twd, taddr);
2234*a2b0a27dSPhilippe Mathieu-Daudé                 break;
2235*a2b0a27dSPhilippe Mathieu-Daudé             case OPC_LD_D:
2236*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_ld_d(cpu_env, twd, taddr);
2237*a2b0a27dSPhilippe Mathieu-Daudé                 break;
2238*a2b0a27dSPhilippe Mathieu-Daudé             case OPC_ST_B:
2239*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_st_b(cpu_env, twd, taddr);
2240*a2b0a27dSPhilippe Mathieu-Daudé                 break;
2241*a2b0a27dSPhilippe Mathieu-Daudé             case OPC_ST_H:
2242*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_st_h(cpu_env, twd, taddr);
2243*a2b0a27dSPhilippe Mathieu-Daudé                 break;
2244*a2b0a27dSPhilippe Mathieu-Daudé             case OPC_ST_W:
2245*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_st_w(cpu_env, twd, taddr);
2246*a2b0a27dSPhilippe Mathieu-Daudé                 break;
2247*a2b0a27dSPhilippe Mathieu-Daudé             case OPC_ST_D:
2248*a2b0a27dSPhilippe Mathieu-Daudé                 gen_helper_msa_st_d(cpu_env, twd, taddr);
2249*a2b0a27dSPhilippe Mathieu-Daudé                 break;
2250*a2b0a27dSPhilippe Mathieu-Daudé             }
2251*a2b0a27dSPhilippe Mathieu-Daudé 
2252*a2b0a27dSPhilippe Mathieu-Daudé             tcg_temp_free_i32(twd);
2253*a2b0a27dSPhilippe Mathieu-Daudé             tcg_temp_free(taddr);
2254*a2b0a27dSPhilippe Mathieu-Daudé         }
2255*a2b0a27dSPhilippe Mathieu-Daudé         break;
2256*a2b0a27dSPhilippe Mathieu-Daudé     default:
2257*a2b0a27dSPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
2258*a2b0a27dSPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
2259*a2b0a27dSPhilippe Mathieu-Daudé         break;
2260*a2b0a27dSPhilippe Mathieu-Daudé     }
2261*a2b0a27dSPhilippe Mathieu-Daudé }
2262*a2b0a27dSPhilippe Mathieu-Daudé 
2263*a2b0a27dSPhilippe Mathieu-Daudé static bool trans_MSA(DisasContext *ctx, arg_MSA *a)
2264*a2b0a27dSPhilippe Mathieu-Daudé {
2265*a2b0a27dSPhilippe Mathieu-Daudé     gen_msa(ctx);
2266*a2b0a27dSPhilippe Mathieu-Daudé 
2267*a2b0a27dSPhilippe Mathieu-Daudé     return true;
2268*a2b0a27dSPhilippe Mathieu-Daudé }
2269*a2b0a27dSPhilippe Mathieu-Daudé 
2270*a2b0a27dSPhilippe Mathieu-Daudé static bool trans_LSA(DisasContext *ctx, arg_rtype *a)
2271*a2b0a27dSPhilippe Mathieu-Daudé {
2272*a2b0a27dSPhilippe Mathieu-Daudé     return gen_lsa(ctx, a->rd, a->rt, a->rs, a->sa);
2273*a2b0a27dSPhilippe Mathieu-Daudé }
2274*a2b0a27dSPhilippe Mathieu-Daudé 
2275*a2b0a27dSPhilippe Mathieu-Daudé static bool trans_DLSA(DisasContext *ctx, arg_rtype *a)
2276*a2b0a27dSPhilippe Mathieu-Daudé {
2277*a2b0a27dSPhilippe Mathieu-Daudé     return gen_dlsa(ctx, a->rd, a->rt, a->rs, a->sa);
2278*a2b0a27dSPhilippe Mathieu-Daudé }
2279*a2b0a27dSPhilippe Mathieu-Daudé 
2280*a2b0a27dSPhilippe Mathieu-Daudé bool decode_ase_msa(DisasContext *ctx, uint32_t insn)
2281*a2b0a27dSPhilippe Mathieu-Daudé {
2282*a2b0a27dSPhilippe Mathieu-Daudé     if (TARGET_LONG_BITS == 64 && decode_msa64(ctx, insn)) {
2283*a2b0a27dSPhilippe Mathieu-Daudé         return true;
2284*a2b0a27dSPhilippe Mathieu-Daudé     }
2285*a2b0a27dSPhilippe Mathieu-Daudé     return decode_msa32(ctx, insn);
2286*a2b0a27dSPhilippe Mathieu-Daudé }
2287