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