xref: /qemu/target/mips/tcg/msa_translate.c (revision c7a9ef75173f090616328d6870f71e8da2b6bd50)
180e64a38SPhilippe Mathieu-Daudé /*
280e64a38SPhilippe Mathieu-Daudé  *  MIPS SIMD Architecture (MSA) translation routines
380e64a38SPhilippe Mathieu-Daudé  *
480e64a38SPhilippe Mathieu-Daudé  *  Copyright (c) 2004-2005 Jocelyn Mayer
580e64a38SPhilippe Mathieu-Daudé  *  Copyright (c) 2006 Marius Groeger (FPU operations)
680e64a38SPhilippe Mathieu-Daudé  *  Copyright (c) 2006 Thiemo Seufer (MIPS32R2 support)
780e64a38SPhilippe Mathieu-Daudé  *  Copyright (c) 2009 CodeSourcery (MIPS16 and microMIPS support)
880e64a38SPhilippe Mathieu-Daudé  *  Copyright (c) 2012 Jia Liu & Dongxue Zhang (MIPS ASE DSP support)
9*c7a9ef75SPhilippe Mathieu-Daudé  *  Copyright (c) 2020 Philippe Mathieu-Daudé
1080e64a38SPhilippe Mathieu-Daudé  *
1180e64a38SPhilippe Mathieu-Daudé  * SPDX-License-Identifier: LGPL-2.1-or-later
1280e64a38SPhilippe Mathieu-Daudé  */
1380e64a38SPhilippe Mathieu-Daudé #include "qemu/osdep.h"
1480e64a38SPhilippe Mathieu-Daudé #include "tcg/tcg-op.h"
1580e64a38SPhilippe Mathieu-Daudé #include "exec/helper-gen.h"
1680e64a38SPhilippe Mathieu-Daudé #include "translate.h"
1780e64a38SPhilippe Mathieu-Daudé #include "fpu_helper.h"
1880e64a38SPhilippe Mathieu-Daudé #include "internal.h"
1980e64a38SPhilippe Mathieu-Daudé 
20*c7a9ef75SPhilippe Mathieu-Daudé /* Include the auto-generated decoder.  */
21*c7a9ef75SPhilippe Mathieu-Daudé #include "decode-msa32.c.inc"
22*c7a9ef75SPhilippe Mathieu-Daudé 
2380e64a38SPhilippe Mathieu-Daudé #define OPC_MSA (0x1E << 26)
2480e64a38SPhilippe Mathieu-Daudé 
2580e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_MINOR(op)          (MASK_OP_MAJOR(op) | (op & 0x3F))
2680e64a38SPhilippe Mathieu-Daudé enum {
2780e64a38SPhilippe Mathieu-Daudé     OPC_MSA_I8_00   = 0x00 | OPC_MSA,
2880e64a38SPhilippe Mathieu-Daudé     OPC_MSA_I8_01   = 0x01 | OPC_MSA,
2980e64a38SPhilippe Mathieu-Daudé     OPC_MSA_I8_02   = 0x02 | OPC_MSA,
3080e64a38SPhilippe Mathieu-Daudé     OPC_MSA_I5_06   = 0x06 | OPC_MSA,
3180e64a38SPhilippe Mathieu-Daudé     OPC_MSA_I5_07   = 0x07 | OPC_MSA,
3280e64a38SPhilippe Mathieu-Daudé     OPC_MSA_BIT_09  = 0x09 | OPC_MSA,
3380e64a38SPhilippe Mathieu-Daudé     OPC_MSA_BIT_0A  = 0x0A | OPC_MSA,
3480e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_0D   = 0x0D | OPC_MSA,
3580e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_0E   = 0x0E | OPC_MSA,
3680e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_0F   = 0x0F | OPC_MSA,
3780e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_10   = 0x10 | OPC_MSA,
3880e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_11   = 0x11 | OPC_MSA,
3980e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_12   = 0x12 | OPC_MSA,
4080e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_13   = 0x13 | OPC_MSA,
4180e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_14   = 0x14 | OPC_MSA,
4280e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_15   = 0x15 | OPC_MSA,
4380e64a38SPhilippe Mathieu-Daudé     OPC_MSA_ELM     = 0x19 | OPC_MSA,
4480e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3RF_1A  = 0x1A | OPC_MSA,
4580e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3RF_1B  = 0x1B | OPC_MSA,
4680e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3RF_1C  = 0x1C | OPC_MSA,
4780e64a38SPhilippe Mathieu-Daudé     OPC_MSA_VEC     = 0x1E | OPC_MSA,
4880e64a38SPhilippe Mathieu-Daudé 
4980e64a38SPhilippe Mathieu-Daudé     /* MI10 instruction */
5080e64a38SPhilippe Mathieu-Daudé     OPC_LD_B        = (0x20) | OPC_MSA,
5180e64a38SPhilippe Mathieu-Daudé     OPC_LD_H        = (0x21) | OPC_MSA,
5280e64a38SPhilippe Mathieu-Daudé     OPC_LD_W        = (0x22) | OPC_MSA,
5380e64a38SPhilippe Mathieu-Daudé     OPC_LD_D        = (0x23) | OPC_MSA,
5480e64a38SPhilippe Mathieu-Daudé     OPC_ST_B        = (0x24) | OPC_MSA,
5580e64a38SPhilippe Mathieu-Daudé     OPC_ST_H        = (0x25) | OPC_MSA,
5680e64a38SPhilippe Mathieu-Daudé     OPC_ST_W        = (0x26) | OPC_MSA,
5780e64a38SPhilippe Mathieu-Daudé     OPC_ST_D        = (0x27) | OPC_MSA,
5880e64a38SPhilippe Mathieu-Daudé };
5980e64a38SPhilippe Mathieu-Daudé 
6080e64a38SPhilippe Mathieu-Daudé enum {
6180e64a38SPhilippe Mathieu-Daudé     /* I5 instruction df(bits 22..21) = _b, _h, _w, _d */
6280e64a38SPhilippe Mathieu-Daudé     OPC_ADDVI_df    = (0x0 << 23) | OPC_MSA_I5_06,
6380e64a38SPhilippe Mathieu-Daudé     OPC_CEQI_df     = (0x0 << 23) | OPC_MSA_I5_07,
6480e64a38SPhilippe Mathieu-Daudé     OPC_SUBVI_df    = (0x1 << 23) | OPC_MSA_I5_06,
6580e64a38SPhilippe Mathieu-Daudé     OPC_MAXI_S_df   = (0x2 << 23) | OPC_MSA_I5_06,
6680e64a38SPhilippe Mathieu-Daudé     OPC_CLTI_S_df   = (0x2 << 23) | OPC_MSA_I5_07,
6780e64a38SPhilippe Mathieu-Daudé     OPC_MAXI_U_df   = (0x3 << 23) | OPC_MSA_I5_06,
6880e64a38SPhilippe Mathieu-Daudé     OPC_CLTI_U_df   = (0x3 << 23) | OPC_MSA_I5_07,
6980e64a38SPhilippe Mathieu-Daudé     OPC_MINI_S_df   = (0x4 << 23) | OPC_MSA_I5_06,
7080e64a38SPhilippe Mathieu-Daudé     OPC_CLEI_S_df   = (0x4 << 23) | OPC_MSA_I5_07,
7180e64a38SPhilippe Mathieu-Daudé     OPC_MINI_U_df   = (0x5 << 23) | OPC_MSA_I5_06,
7280e64a38SPhilippe Mathieu-Daudé     OPC_CLEI_U_df   = (0x5 << 23) | OPC_MSA_I5_07,
7380e64a38SPhilippe Mathieu-Daudé     OPC_LDI_df      = (0x6 << 23) | OPC_MSA_I5_07,
7480e64a38SPhilippe Mathieu-Daudé 
7580e64a38SPhilippe Mathieu-Daudé     /* I8 instruction */
7680e64a38SPhilippe Mathieu-Daudé     OPC_ANDI_B      = (0x0 << 24) | OPC_MSA_I8_00,
7780e64a38SPhilippe Mathieu-Daudé     OPC_BMNZI_B     = (0x0 << 24) | OPC_MSA_I8_01,
7880e64a38SPhilippe Mathieu-Daudé     OPC_SHF_B       = (0x0 << 24) | OPC_MSA_I8_02,
7980e64a38SPhilippe Mathieu-Daudé     OPC_ORI_B       = (0x1 << 24) | OPC_MSA_I8_00,
8080e64a38SPhilippe Mathieu-Daudé     OPC_BMZI_B      = (0x1 << 24) | OPC_MSA_I8_01,
8180e64a38SPhilippe Mathieu-Daudé     OPC_SHF_H       = (0x1 << 24) | OPC_MSA_I8_02,
8280e64a38SPhilippe Mathieu-Daudé     OPC_NORI_B      = (0x2 << 24) | OPC_MSA_I8_00,
8380e64a38SPhilippe Mathieu-Daudé     OPC_BSELI_B     = (0x2 << 24) | OPC_MSA_I8_01,
8480e64a38SPhilippe Mathieu-Daudé     OPC_SHF_W       = (0x2 << 24) | OPC_MSA_I8_02,
8580e64a38SPhilippe Mathieu-Daudé     OPC_XORI_B      = (0x3 << 24) | OPC_MSA_I8_00,
8680e64a38SPhilippe Mathieu-Daudé 
8780e64a38SPhilippe Mathieu-Daudé     /* VEC/2R/2RF instruction */
8880e64a38SPhilippe Mathieu-Daudé     OPC_AND_V       = (0x00 << 21) | OPC_MSA_VEC,
8980e64a38SPhilippe Mathieu-Daudé     OPC_OR_V        = (0x01 << 21) | OPC_MSA_VEC,
9080e64a38SPhilippe Mathieu-Daudé     OPC_NOR_V       = (0x02 << 21) | OPC_MSA_VEC,
9180e64a38SPhilippe Mathieu-Daudé     OPC_XOR_V       = (0x03 << 21) | OPC_MSA_VEC,
9280e64a38SPhilippe Mathieu-Daudé     OPC_BMNZ_V      = (0x04 << 21) | OPC_MSA_VEC,
9380e64a38SPhilippe Mathieu-Daudé     OPC_BMZ_V       = (0x05 << 21) | OPC_MSA_VEC,
9480e64a38SPhilippe Mathieu-Daudé     OPC_BSEL_V      = (0x06 << 21) | OPC_MSA_VEC,
9580e64a38SPhilippe Mathieu-Daudé 
9680e64a38SPhilippe Mathieu-Daudé     OPC_MSA_2R      = (0x18 << 21) | OPC_MSA_VEC,
9780e64a38SPhilippe Mathieu-Daudé     OPC_MSA_2RF     = (0x19 << 21) | OPC_MSA_VEC,
9880e64a38SPhilippe Mathieu-Daudé 
9980e64a38SPhilippe Mathieu-Daudé     /* 2R instruction df(bits 17..16) = _b, _h, _w, _d */
10080e64a38SPhilippe Mathieu-Daudé     OPC_FILL_df     = (0x00 << 18) | OPC_MSA_2R,
10180e64a38SPhilippe Mathieu-Daudé     OPC_PCNT_df     = (0x01 << 18) | OPC_MSA_2R,
10280e64a38SPhilippe Mathieu-Daudé     OPC_NLOC_df     = (0x02 << 18) | OPC_MSA_2R,
10380e64a38SPhilippe Mathieu-Daudé     OPC_NLZC_df     = (0x03 << 18) | OPC_MSA_2R,
10480e64a38SPhilippe Mathieu-Daudé 
10580e64a38SPhilippe Mathieu-Daudé     /* 2RF instruction df(bit 16) = _w, _d */
10680e64a38SPhilippe Mathieu-Daudé     OPC_FCLASS_df   = (0x00 << 17) | OPC_MSA_2RF,
10780e64a38SPhilippe Mathieu-Daudé     OPC_FTRUNC_S_df = (0x01 << 17) | OPC_MSA_2RF,
10880e64a38SPhilippe Mathieu-Daudé     OPC_FTRUNC_U_df = (0x02 << 17) | OPC_MSA_2RF,
10980e64a38SPhilippe Mathieu-Daudé     OPC_FSQRT_df    = (0x03 << 17) | OPC_MSA_2RF,
11080e64a38SPhilippe Mathieu-Daudé     OPC_FRSQRT_df   = (0x04 << 17) | OPC_MSA_2RF,
11180e64a38SPhilippe Mathieu-Daudé     OPC_FRCP_df     = (0x05 << 17) | OPC_MSA_2RF,
11280e64a38SPhilippe Mathieu-Daudé     OPC_FRINT_df    = (0x06 << 17) | OPC_MSA_2RF,
11380e64a38SPhilippe Mathieu-Daudé     OPC_FLOG2_df    = (0x07 << 17) | OPC_MSA_2RF,
11480e64a38SPhilippe Mathieu-Daudé     OPC_FEXUPL_df   = (0x08 << 17) | OPC_MSA_2RF,
11580e64a38SPhilippe Mathieu-Daudé     OPC_FEXUPR_df   = (0x09 << 17) | OPC_MSA_2RF,
11680e64a38SPhilippe Mathieu-Daudé     OPC_FFQL_df     = (0x0A << 17) | OPC_MSA_2RF,
11780e64a38SPhilippe Mathieu-Daudé     OPC_FFQR_df     = (0x0B << 17) | OPC_MSA_2RF,
11880e64a38SPhilippe Mathieu-Daudé     OPC_FTINT_S_df  = (0x0C << 17) | OPC_MSA_2RF,
11980e64a38SPhilippe Mathieu-Daudé     OPC_FTINT_U_df  = (0x0D << 17) | OPC_MSA_2RF,
12080e64a38SPhilippe Mathieu-Daudé     OPC_FFINT_S_df  = (0x0E << 17) | OPC_MSA_2RF,
12180e64a38SPhilippe Mathieu-Daudé     OPC_FFINT_U_df  = (0x0F << 17) | OPC_MSA_2RF,
12280e64a38SPhilippe Mathieu-Daudé 
12380e64a38SPhilippe Mathieu-Daudé     /* 3R instruction df(bits 22..21) = _b, _h, _w, d */
12480e64a38SPhilippe Mathieu-Daudé     OPC_SLL_df      = (0x0 << 23) | OPC_MSA_3R_0D,
12580e64a38SPhilippe Mathieu-Daudé     OPC_ADDV_df     = (0x0 << 23) | OPC_MSA_3R_0E,
12680e64a38SPhilippe Mathieu-Daudé     OPC_CEQ_df      = (0x0 << 23) | OPC_MSA_3R_0F,
12780e64a38SPhilippe Mathieu-Daudé     OPC_ADD_A_df    = (0x0 << 23) | OPC_MSA_3R_10,
12880e64a38SPhilippe Mathieu-Daudé     OPC_SUBS_S_df   = (0x0 << 23) | OPC_MSA_3R_11,
12980e64a38SPhilippe Mathieu-Daudé     OPC_MULV_df     = (0x0 << 23) | OPC_MSA_3R_12,
13080e64a38SPhilippe Mathieu-Daudé     OPC_DOTP_S_df   = (0x0 << 23) | OPC_MSA_3R_13,
13180e64a38SPhilippe Mathieu-Daudé     OPC_SLD_df      = (0x0 << 23) | OPC_MSA_3R_14,
13280e64a38SPhilippe Mathieu-Daudé     OPC_VSHF_df     = (0x0 << 23) | OPC_MSA_3R_15,
13380e64a38SPhilippe Mathieu-Daudé     OPC_SRA_df      = (0x1 << 23) | OPC_MSA_3R_0D,
13480e64a38SPhilippe Mathieu-Daudé     OPC_SUBV_df     = (0x1 << 23) | OPC_MSA_3R_0E,
13580e64a38SPhilippe Mathieu-Daudé     OPC_ADDS_A_df   = (0x1 << 23) | OPC_MSA_3R_10,
13680e64a38SPhilippe Mathieu-Daudé     OPC_SUBS_U_df   = (0x1 << 23) | OPC_MSA_3R_11,
13780e64a38SPhilippe Mathieu-Daudé     OPC_MADDV_df    = (0x1 << 23) | OPC_MSA_3R_12,
13880e64a38SPhilippe Mathieu-Daudé     OPC_DOTP_U_df   = (0x1 << 23) | OPC_MSA_3R_13,
13980e64a38SPhilippe Mathieu-Daudé     OPC_SPLAT_df    = (0x1 << 23) | OPC_MSA_3R_14,
14080e64a38SPhilippe Mathieu-Daudé     OPC_SRAR_df     = (0x1 << 23) | OPC_MSA_3R_15,
14180e64a38SPhilippe Mathieu-Daudé     OPC_SRL_df      = (0x2 << 23) | OPC_MSA_3R_0D,
14280e64a38SPhilippe Mathieu-Daudé     OPC_MAX_S_df    = (0x2 << 23) | OPC_MSA_3R_0E,
14380e64a38SPhilippe Mathieu-Daudé     OPC_CLT_S_df    = (0x2 << 23) | OPC_MSA_3R_0F,
14480e64a38SPhilippe Mathieu-Daudé     OPC_ADDS_S_df   = (0x2 << 23) | OPC_MSA_3R_10,
14580e64a38SPhilippe Mathieu-Daudé     OPC_SUBSUS_U_df = (0x2 << 23) | OPC_MSA_3R_11,
14680e64a38SPhilippe Mathieu-Daudé     OPC_MSUBV_df    = (0x2 << 23) | OPC_MSA_3R_12,
14780e64a38SPhilippe Mathieu-Daudé     OPC_DPADD_S_df  = (0x2 << 23) | OPC_MSA_3R_13,
14880e64a38SPhilippe Mathieu-Daudé     OPC_PCKEV_df    = (0x2 << 23) | OPC_MSA_3R_14,
14980e64a38SPhilippe Mathieu-Daudé     OPC_SRLR_df     = (0x2 << 23) | OPC_MSA_3R_15,
15080e64a38SPhilippe Mathieu-Daudé     OPC_BCLR_df     = (0x3 << 23) | OPC_MSA_3R_0D,
15180e64a38SPhilippe Mathieu-Daudé     OPC_MAX_U_df    = (0x3 << 23) | OPC_MSA_3R_0E,
15280e64a38SPhilippe Mathieu-Daudé     OPC_CLT_U_df    = (0x3 << 23) | OPC_MSA_3R_0F,
15380e64a38SPhilippe Mathieu-Daudé     OPC_ADDS_U_df   = (0x3 << 23) | OPC_MSA_3R_10,
15480e64a38SPhilippe Mathieu-Daudé     OPC_SUBSUU_S_df = (0x3 << 23) | OPC_MSA_3R_11,
15580e64a38SPhilippe Mathieu-Daudé     OPC_DPADD_U_df  = (0x3 << 23) | OPC_MSA_3R_13,
15680e64a38SPhilippe Mathieu-Daudé     OPC_PCKOD_df    = (0x3 << 23) | OPC_MSA_3R_14,
15780e64a38SPhilippe Mathieu-Daudé     OPC_BSET_df     = (0x4 << 23) | OPC_MSA_3R_0D,
15880e64a38SPhilippe Mathieu-Daudé     OPC_MIN_S_df    = (0x4 << 23) | OPC_MSA_3R_0E,
15980e64a38SPhilippe Mathieu-Daudé     OPC_CLE_S_df    = (0x4 << 23) | OPC_MSA_3R_0F,
16080e64a38SPhilippe Mathieu-Daudé     OPC_AVE_S_df    = (0x4 << 23) | OPC_MSA_3R_10,
16180e64a38SPhilippe Mathieu-Daudé     OPC_ASUB_S_df   = (0x4 << 23) | OPC_MSA_3R_11,
16280e64a38SPhilippe Mathieu-Daudé     OPC_DIV_S_df    = (0x4 << 23) | OPC_MSA_3R_12,
16380e64a38SPhilippe Mathieu-Daudé     OPC_DPSUB_S_df  = (0x4 << 23) | OPC_MSA_3R_13,
16480e64a38SPhilippe Mathieu-Daudé     OPC_ILVL_df     = (0x4 << 23) | OPC_MSA_3R_14,
16580e64a38SPhilippe Mathieu-Daudé     OPC_HADD_S_df   = (0x4 << 23) | OPC_MSA_3R_15,
16680e64a38SPhilippe Mathieu-Daudé     OPC_BNEG_df     = (0x5 << 23) | OPC_MSA_3R_0D,
16780e64a38SPhilippe Mathieu-Daudé     OPC_MIN_U_df    = (0x5 << 23) | OPC_MSA_3R_0E,
16880e64a38SPhilippe Mathieu-Daudé     OPC_CLE_U_df    = (0x5 << 23) | OPC_MSA_3R_0F,
16980e64a38SPhilippe Mathieu-Daudé     OPC_AVE_U_df    = (0x5 << 23) | OPC_MSA_3R_10,
17080e64a38SPhilippe Mathieu-Daudé     OPC_ASUB_U_df   = (0x5 << 23) | OPC_MSA_3R_11,
17180e64a38SPhilippe Mathieu-Daudé     OPC_DIV_U_df    = (0x5 << 23) | OPC_MSA_3R_12,
17280e64a38SPhilippe Mathieu-Daudé     OPC_DPSUB_U_df  = (0x5 << 23) | OPC_MSA_3R_13,
17380e64a38SPhilippe Mathieu-Daudé     OPC_ILVR_df     = (0x5 << 23) | OPC_MSA_3R_14,
17480e64a38SPhilippe Mathieu-Daudé     OPC_HADD_U_df   = (0x5 << 23) | OPC_MSA_3R_15,
17580e64a38SPhilippe Mathieu-Daudé     OPC_BINSL_df    = (0x6 << 23) | OPC_MSA_3R_0D,
17680e64a38SPhilippe Mathieu-Daudé     OPC_MAX_A_df    = (0x6 << 23) | OPC_MSA_3R_0E,
17780e64a38SPhilippe Mathieu-Daudé     OPC_AVER_S_df   = (0x6 << 23) | OPC_MSA_3R_10,
17880e64a38SPhilippe Mathieu-Daudé     OPC_MOD_S_df    = (0x6 << 23) | OPC_MSA_3R_12,
17980e64a38SPhilippe Mathieu-Daudé     OPC_ILVEV_df    = (0x6 << 23) | OPC_MSA_3R_14,
18080e64a38SPhilippe Mathieu-Daudé     OPC_HSUB_S_df   = (0x6 << 23) | OPC_MSA_3R_15,
18180e64a38SPhilippe Mathieu-Daudé     OPC_BINSR_df    = (0x7 << 23) | OPC_MSA_3R_0D,
18280e64a38SPhilippe Mathieu-Daudé     OPC_MIN_A_df    = (0x7 << 23) | OPC_MSA_3R_0E,
18380e64a38SPhilippe Mathieu-Daudé     OPC_AVER_U_df   = (0x7 << 23) | OPC_MSA_3R_10,
18480e64a38SPhilippe Mathieu-Daudé     OPC_MOD_U_df    = (0x7 << 23) | OPC_MSA_3R_12,
18580e64a38SPhilippe Mathieu-Daudé     OPC_ILVOD_df    = (0x7 << 23) | OPC_MSA_3R_14,
18680e64a38SPhilippe Mathieu-Daudé     OPC_HSUB_U_df   = (0x7 << 23) | OPC_MSA_3R_15,
18780e64a38SPhilippe Mathieu-Daudé 
18880e64a38SPhilippe Mathieu-Daudé     /* ELM instructions df(bits 21..16) = _b, _h, _w, _d */
18980e64a38SPhilippe Mathieu-Daudé     OPC_SLDI_df     = (0x0 << 22) | (0x00 << 16) | OPC_MSA_ELM,
19080e64a38SPhilippe Mathieu-Daudé     OPC_CTCMSA      = (0x0 << 22) | (0x3E << 16) | OPC_MSA_ELM,
19180e64a38SPhilippe Mathieu-Daudé     OPC_SPLATI_df   = (0x1 << 22) | (0x00 << 16) | OPC_MSA_ELM,
19280e64a38SPhilippe Mathieu-Daudé     OPC_CFCMSA      = (0x1 << 22) | (0x3E << 16) | OPC_MSA_ELM,
19380e64a38SPhilippe Mathieu-Daudé     OPC_COPY_S_df   = (0x2 << 22) | (0x00 << 16) | OPC_MSA_ELM,
19480e64a38SPhilippe Mathieu-Daudé     OPC_MOVE_V      = (0x2 << 22) | (0x3E << 16) | OPC_MSA_ELM,
19580e64a38SPhilippe Mathieu-Daudé     OPC_COPY_U_df   = (0x3 << 22) | (0x00 << 16) | OPC_MSA_ELM,
19680e64a38SPhilippe Mathieu-Daudé     OPC_INSERT_df   = (0x4 << 22) | (0x00 << 16) | OPC_MSA_ELM,
19780e64a38SPhilippe Mathieu-Daudé     OPC_INSVE_df    = (0x5 << 22) | (0x00 << 16) | OPC_MSA_ELM,
19880e64a38SPhilippe Mathieu-Daudé 
19980e64a38SPhilippe Mathieu-Daudé     /* 3RF instruction _df(bit 21) = _w, _d */
20080e64a38SPhilippe Mathieu-Daudé     OPC_FCAF_df     = (0x0 << 22) | OPC_MSA_3RF_1A,
20180e64a38SPhilippe Mathieu-Daudé     OPC_FADD_df     = (0x0 << 22) | OPC_MSA_3RF_1B,
20280e64a38SPhilippe Mathieu-Daudé     OPC_FCUN_df     = (0x1 << 22) | OPC_MSA_3RF_1A,
20380e64a38SPhilippe Mathieu-Daudé     OPC_FSUB_df     = (0x1 << 22) | OPC_MSA_3RF_1B,
20480e64a38SPhilippe Mathieu-Daudé     OPC_FCOR_df     = (0x1 << 22) | OPC_MSA_3RF_1C,
20580e64a38SPhilippe Mathieu-Daudé     OPC_FCEQ_df     = (0x2 << 22) | OPC_MSA_3RF_1A,
20680e64a38SPhilippe Mathieu-Daudé     OPC_FMUL_df     = (0x2 << 22) | OPC_MSA_3RF_1B,
20780e64a38SPhilippe Mathieu-Daudé     OPC_FCUNE_df    = (0x2 << 22) | OPC_MSA_3RF_1C,
20880e64a38SPhilippe Mathieu-Daudé     OPC_FCUEQ_df    = (0x3 << 22) | OPC_MSA_3RF_1A,
20980e64a38SPhilippe Mathieu-Daudé     OPC_FDIV_df     = (0x3 << 22) | OPC_MSA_3RF_1B,
21080e64a38SPhilippe Mathieu-Daudé     OPC_FCNE_df     = (0x3 << 22) | OPC_MSA_3RF_1C,
21180e64a38SPhilippe Mathieu-Daudé     OPC_FCLT_df     = (0x4 << 22) | OPC_MSA_3RF_1A,
21280e64a38SPhilippe Mathieu-Daudé     OPC_FMADD_df    = (0x4 << 22) | OPC_MSA_3RF_1B,
21380e64a38SPhilippe Mathieu-Daudé     OPC_MUL_Q_df    = (0x4 << 22) | OPC_MSA_3RF_1C,
21480e64a38SPhilippe Mathieu-Daudé     OPC_FCULT_df    = (0x5 << 22) | OPC_MSA_3RF_1A,
21580e64a38SPhilippe Mathieu-Daudé     OPC_FMSUB_df    = (0x5 << 22) | OPC_MSA_3RF_1B,
21680e64a38SPhilippe Mathieu-Daudé     OPC_MADD_Q_df   = (0x5 << 22) | OPC_MSA_3RF_1C,
21780e64a38SPhilippe Mathieu-Daudé     OPC_FCLE_df     = (0x6 << 22) | OPC_MSA_3RF_1A,
21880e64a38SPhilippe Mathieu-Daudé     OPC_MSUB_Q_df   = (0x6 << 22) | OPC_MSA_3RF_1C,
21980e64a38SPhilippe Mathieu-Daudé     OPC_FCULE_df    = (0x7 << 22) | OPC_MSA_3RF_1A,
22080e64a38SPhilippe Mathieu-Daudé     OPC_FEXP2_df    = (0x7 << 22) | OPC_MSA_3RF_1B,
22180e64a38SPhilippe Mathieu-Daudé     OPC_FSAF_df     = (0x8 << 22) | OPC_MSA_3RF_1A,
22280e64a38SPhilippe Mathieu-Daudé     OPC_FEXDO_df    = (0x8 << 22) | OPC_MSA_3RF_1B,
22380e64a38SPhilippe Mathieu-Daudé     OPC_FSUN_df     = (0x9 << 22) | OPC_MSA_3RF_1A,
22480e64a38SPhilippe Mathieu-Daudé     OPC_FSOR_df     = (0x9 << 22) | OPC_MSA_3RF_1C,
22580e64a38SPhilippe Mathieu-Daudé     OPC_FSEQ_df     = (0xA << 22) | OPC_MSA_3RF_1A,
22680e64a38SPhilippe Mathieu-Daudé     OPC_FTQ_df      = (0xA << 22) | OPC_MSA_3RF_1B,
22780e64a38SPhilippe Mathieu-Daudé     OPC_FSUNE_df    = (0xA << 22) | OPC_MSA_3RF_1C,
22880e64a38SPhilippe Mathieu-Daudé     OPC_FSUEQ_df    = (0xB << 22) | OPC_MSA_3RF_1A,
22980e64a38SPhilippe Mathieu-Daudé     OPC_FSNE_df     = (0xB << 22) | OPC_MSA_3RF_1C,
23080e64a38SPhilippe Mathieu-Daudé     OPC_FSLT_df     = (0xC << 22) | OPC_MSA_3RF_1A,
23180e64a38SPhilippe Mathieu-Daudé     OPC_FMIN_df     = (0xC << 22) | OPC_MSA_3RF_1B,
23280e64a38SPhilippe Mathieu-Daudé     OPC_MULR_Q_df   = (0xC << 22) | OPC_MSA_3RF_1C,
23380e64a38SPhilippe Mathieu-Daudé     OPC_FSULT_df    = (0xD << 22) | OPC_MSA_3RF_1A,
23480e64a38SPhilippe Mathieu-Daudé     OPC_FMIN_A_df   = (0xD << 22) | OPC_MSA_3RF_1B,
23580e64a38SPhilippe Mathieu-Daudé     OPC_MADDR_Q_df  = (0xD << 22) | OPC_MSA_3RF_1C,
23680e64a38SPhilippe Mathieu-Daudé     OPC_FSLE_df     = (0xE << 22) | OPC_MSA_3RF_1A,
23780e64a38SPhilippe Mathieu-Daudé     OPC_FMAX_df     = (0xE << 22) | OPC_MSA_3RF_1B,
23880e64a38SPhilippe Mathieu-Daudé     OPC_MSUBR_Q_df  = (0xE << 22) | OPC_MSA_3RF_1C,
23980e64a38SPhilippe Mathieu-Daudé     OPC_FSULE_df    = (0xF << 22) | OPC_MSA_3RF_1A,
24080e64a38SPhilippe Mathieu-Daudé     OPC_FMAX_A_df   = (0xF << 22) | OPC_MSA_3RF_1B,
24180e64a38SPhilippe Mathieu-Daudé 
24280e64a38SPhilippe Mathieu-Daudé     /* BIT instruction df(bits 22..16) = _B _H _W _D */
24380e64a38SPhilippe Mathieu-Daudé     OPC_SLLI_df     = (0x0 << 23) | OPC_MSA_BIT_09,
24480e64a38SPhilippe Mathieu-Daudé     OPC_SAT_S_df    = (0x0 << 23) | OPC_MSA_BIT_0A,
24580e64a38SPhilippe Mathieu-Daudé     OPC_SRAI_df     = (0x1 << 23) | OPC_MSA_BIT_09,
24680e64a38SPhilippe Mathieu-Daudé     OPC_SAT_U_df    = (0x1 << 23) | OPC_MSA_BIT_0A,
24780e64a38SPhilippe Mathieu-Daudé     OPC_SRLI_df     = (0x2 << 23) | OPC_MSA_BIT_09,
24880e64a38SPhilippe Mathieu-Daudé     OPC_SRARI_df    = (0x2 << 23) | OPC_MSA_BIT_0A,
24980e64a38SPhilippe Mathieu-Daudé     OPC_BCLRI_df    = (0x3 << 23) | OPC_MSA_BIT_09,
25080e64a38SPhilippe Mathieu-Daudé     OPC_SRLRI_df    = (0x3 << 23) | OPC_MSA_BIT_0A,
25180e64a38SPhilippe Mathieu-Daudé     OPC_BSETI_df    = (0x4 << 23) | OPC_MSA_BIT_09,
25280e64a38SPhilippe Mathieu-Daudé     OPC_BNEGI_df    = (0x5 << 23) | OPC_MSA_BIT_09,
25380e64a38SPhilippe Mathieu-Daudé     OPC_BINSLI_df   = (0x6 << 23) | OPC_MSA_BIT_09,
25480e64a38SPhilippe Mathieu-Daudé     OPC_BINSRI_df   = (0x7 << 23) | OPC_MSA_BIT_09,
25580e64a38SPhilippe Mathieu-Daudé };
25680e64a38SPhilippe Mathieu-Daudé 
25780e64a38SPhilippe Mathieu-Daudé static const char * const msaregnames[] = {
25880e64a38SPhilippe Mathieu-Daudé     "w0.d0",  "w0.d1",  "w1.d0",  "w1.d1",
25980e64a38SPhilippe Mathieu-Daudé     "w2.d0",  "w2.d1",  "w3.d0",  "w3.d1",
26080e64a38SPhilippe Mathieu-Daudé     "w4.d0",  "w4.d1",  "w5.d0",  "w5.d1",
26180e64a38SPhilippe Mathieu-Daudé     "w6.d0",  "w6.d1",  "w7.d0",  "w7.d1",
26280e64a38SPhilippe Mathieu-Daudé     "w8.d0",  "w8.d1",  "w9.d0",  "w9.d1",
26380e64a38SPhilippe Mathieu-Daudé     "w10.d0", "w10.d1", "w11.d0", "w11.d1",
26480e64a38SPhilippe Mathieu-Daudé     "w12.d0", "w12.d1", "w13.d0", "w13.d1",
26580e64a38SPhilippe Mathieu-Daudé     "w14.d0", "w14.d1", "w15.d0", "w15.d1",
26680e64a38SPhilippe Mathieu-Daudé     "w16.d0", "w16.d1", "w17.d0", "w17.d1",
26780e64a38SPhilippe Mathieu-Daudé     "w18.d0", "w18.d1", "w19.d0", "w19.d1",
26880e64a38SPhilippe Mathieu-Daudé     "w20.d0", "w20.d1", "w21.d0", "w21.d1",
26980e64a38SPhilippe Mathieu-Daudé     "w22.d0", "w22.d1", "w23.d0", "w23.d1",
27080e64a38SPhilippe Mathieu-Daudé     "w24.d0", "w24.d1", "w25.d0", "w25.d1",
27180e64a38SPhilippe Mathieu-Daudé     "w26.d0", "w26.d1", "w27.d0", "w27.d1",
27280e64a38SPhilippe Mathieu-Daudé     "w28.d0", "w28.d1", "w29.d0", "w29.d1",
27380e64a38SPhilippe Mathieu-Daudé     "w30.d0", "w30.d1", "w31.d0", "w31.d1",
27480e64a38SPhilippe Mathieu-Daudé };
27580e64a38SPhilippe Mathieu-Daudé 
27680e64a38SPhilippe Mathieu-Daudé static TCGv_i64 msa_wr_d[64];
27780e64a38SPhilippe Mathieu-Daudé 
27880e64a38SPhilippe Mathieu-Daudé void msa_translate_init(void)
27980e64a38SPhilippe Mathieu-Daudé {
28080e64a38SPhilippe Mathieu-Daudé     int i;
28180e64a38SPhilippe Mathieu-Daudé 
28280e64a38SPhilippe Mathieu-Daudé     for (i = 0; i < 32; i++) {
28380e64a38SPhilippe Mathieu-Daudé         int off = offsetof(CPUMIPSState, active_fpu.fpr[i].wr.d[0]);
28480e64a38SPhilippe Mathieu-Daudé 
28580e64a38SPhilippe Mathieu-Daudé         /*
28680e64a38SPhilippe Mathieu-Daudé          * The MSA vector registers are mapped on the
28780e64a38SPhilippe Mathieu-Daudé          * scalar floating-point unit (FPU) registers.
28880e64a38SPhilippe Mathieu-Daudé          */
28980e64a38SPhilippe Mathieu-Daudé         msa_wr_d[i * 2] = fpu_f64[i];
29080e64a38SPhilippe Mathieu-Daudé         off = offsetof(CPUMIPSState, active_fpu.fpr[i].wr.d[1]);
29180e64a38SPhilippe Mathieu-Daudé         msa_wr_d[i * 2 + 1] =
29280e64a38SPhilippe Mathieu-Daudé                 tcg_global_mem_new_i64(cpu_env, off, msaregnames[i * 2 + 1]);
29380e64a38SPhilippe Mathieu-Daudé     }
29480e64a38SPhilippe Mathieu-Daudé }
29580e64a38SPhilippe Mathieu-Daudé 
29680e64a38SPhilippe Mathieu-Daudé static inline int check_msa_access(DisasContext *ctx)
29780e64a38SPhilippe Mathieu-Daudé {
29880e64a38SPhilippe Mathieu-Daudé     if (unlikely((ctx->hflags & MIPS_HFLAG_FPU) &&
29980e64a38SPhilippe Mathieu-Daudé                  !(ctx->hflags & MIPS_HFLAG_F64))) {
30080e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
30180e64a38SPhilippe Mathieu-Daudé         return 0;
30280e64a38SPhilippe Mathieu-Daudé     }
30380e64a38SPhilippe Mathieu-Daudé 
30480e64a38SPhilippe Mathieu-Daudé     if (unlikely(!(ctx->hflags & MIPS_HFLAG_MSA))) {
30580e64a38SPhilippe Mathieu-Daudé         generate_exception_end(ctx, EXCP_MSADIS);
30680e64a38SPhilippe Mathieu-Daudé         return 0;
30780e64a38SPhilippe Mathieu-Daudé     }
30880e64a38SPhilippe Mathieu-Daudé     return 1;
30980e64a38SPhilippe Mathieu-Daudé }
31080e64a38SPhilippe Mathieu-Daudé 
311878b87b5SPhilippe Mathieu-Daudé static void gen_check_zero_element(TCGv tresult, uint8_t df, uint8_t wt,
312878b87b5SPhilippe Mathieu-Daudé                                    TCGCond cond)
31380e64a38SPhilippe Mathieu-Daudé {
31480e64a38SPhilippe Mathieu-Daudé     /* generates tcg ops to check if any element is 0 */
31580e64a38SPhilippe Mathieu-Daudé     /* Note this function only works with MSA_WRLEN = 128 */
31680e64a38SPhilippe Mathieu-Daudé     uint64_t eval_zero_or_big = 0;
31780e64a38SPhilippe Mathieu-Daudé     uint64_t eval_big = 0;
31880e64a38SPhilippe Mathieu-Daudé     TCGv_i64 t0 = tcg_temp_new_i64();
31980e64a38SPhilippe Mathieu-Daudé     TCGv_i64 t1 = tcg_temp_new_i64();
32080e64a38SPhilippe Mathieu-Daudé     switch (df) {
32180e64a38SPhilippe Mathieu-Daudé     case DF_BYTE:
32280e64a38SPhilippe Mathieu-Daudé         eval_zero_or_big = 0x0101010101010101ULL;
32380e64a38SPhilippe Mathieu-Daudé         eval_big = 0x8080808080808080ULL;
32480e64a38SPhilippe Mathieu-Daudé         break;
32580e64a38SPhilippe Mathieu-Daudé     case DF_HALF:
32680e64a38SPhilippe Mathieu-Daudé         eval_zero_or_big = 0x0001000100010001ULL;
32780e64a38SPhilippe Mathieu-Daudé         eval_big = 0x8000800080008000ULL;
32880e64a38SPhilippe Mathieu-Daudé         break;
32980e64a38SPhilippe Mathieu-Daudé     case DF_WORD:
33080e64a38SPhilippe Mathieu-Daudé         eval_zero_or_big = 0x0000000100000001ULL;
33180e64a38SPhilippe Mathieu-Daudé         eval_big = 0x8000000080000000ULL;
33280e64a38SPhilippe Mathieu-Daudé         break;
33380e64a38SPhilippe Mathieu-Daudé     case DF_DOUBLE:
33480e64a38SPhilippe Mathieu-Daudé         eval_zero_or_big = 0x0000000000000001ULL;
33580e64a38SPhilippe Mathieu-Daudé         eval_big = 0x8000000000000000ULL;
33680e64a38SPhilippe Mathieu-Daudé         break;
33780e64a38SPhilippe Mathieu-Daudé     }
33880e64a38SPhilippe Mathieu-Daudé     tcg_gen_subi_i64(t0, msa_wr_d[wt << 1], eval_zero_or_big);
33980e64a38SPhilippe Mathieu-Daudé     tcg_gen_andc_i64(t0, t0, msa_wr_d[wt << 1]);
34080e64a38SPhilippe Mathieu-Daudé     tcg_gen_andi_i64(t0, t0, eval_big);
34180e64a38SPhilippe Mathieu-Daudé     tcg_gen_subi_i64(t1, msa_wr_d[(wt << 1) + 1], eval_zero_or_big);
34280e64a38SPhilippe Mathieu-Daudé     tcg_gen_andc_i64(t1, t1, msa_wr_d[(wt << 1) + 1]);
34380e64a38SPhilippe Mathieu-Daudé     tcg_gen_andi_i64(t1, t1, eval_big);
34480e64a38SPhilippe Mathieu-Daudé     tcg_gen_or_i64(t0, t0, t1);
34580e64a38SPhilippe Mathieu-Daudé     /* if all bits are zero then all elements are not zero */
34680e64a38SPhilippe Mathieu-Daudé     /* if some bit is non-zero then some element is zero */
347878b87b5SPhilippe Mathieu-Daudé     tcg_gen_setcondi_i64(cond, t0, t0, 0);
34880e64a38SPhilippe Mathieu-Daudé     tcg_gen_trunc_i64_tl(tresult, t0);
34980e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i64(t0);
35080e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i64(t1);
35180e64a38SPhilippe Mathieu-Daudé }
35280e64a38SPhilippe Mathieu-Daudé 
35380e64a38SPhilippe Mathieu-Daudé static bool gen_msa_BxZ_V(DisasContext *ctx, int wt, int s16, TCGCond cond)
35480e64a38SPhilippe Mathieu-Daudé {
35580e64a38SPhilippe Mathieu-Daudé     TCGv_i64 t0;
35680e64a38SPhilippe Mathieu-Daudé 
35780e64a38SPhilippe Mathieu-Daudé     check_msa_access(ctx);
35880e64a38SPhilippe Mathieu-Daudé 
35980e64a38SPhilippe Mathieu-Daudé     if (ctx->hflags & MIPS_HFLAG_BMASK) {
36080e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
36180e64a38SPhilippe Mathieu-Daudé         return true;
36280e64a38SPhilippe Mathieu-Daudé     }
36380e64a38SPhilippe Mathieu-Daudé     t0 = tcg_temp_new_i64();
36480e64a38SPhilippe Mathieu-Daudé     tcg_gen_or_i64(t0, msa_wr_d[wt << 1], msa_wr_d[(wt << 1) + 1]);
36580e64a38SPhilippe Mathieu-Daudé     tcg_gen_setcondi_i64(cond, t0, t0, 0);
36680e64a38SPhilippe Mathieu-Daudé     tcg_gen_trunc_i64_tl(bcond, t0);
36780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i64(t0);
36880e64a38SPhilippe Mathieu-Daudé 
36980e64a38SPhilippe Mathieu-Daudé     ctx->btarget = ctx->base.pc_next + (s16 << 2) + 4;
37080e64a38SPhilippe Mathieu-Daudé 
37180e64a38SPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BC;
37280e64a38SPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BDS32;
37380e64a38SPhilippe Mathieu-Daudé 
37480e64a38SPhilippe Mathieu-Daudé     return true;
37580e64a38SPhilippe Mathieu-Daudé }
37680e64a38SPhilippe Mathieu-Daudé 
377*c7a9ef75SPhilippe Mathieu-Daudé static bool trans_BZ_V(DisasContext *ctx, arg_msa_bz *a)
378*c7a9ef75SPhilippe Mathieu-Daudé {
379*c7a9ef75SPhilippe Mathieu-Daudé     return gen_msa_BxZ_V(ctx, a->wt, a->s16, TCG_COND_EQ);
380*c7a9ef75SPhilippe Mathieu-Daudé }
381*c7a9ef75SPhilippe Mathieu-Daudé 
382*c7a9ef75SPhilippe Mathieu-Daudé static bool trans_BNZ_V(DisasContext *ctx, arg_msa_bz *a)
383*c7a9ef75SPhilippe Mathieu-Daudé {
384*c7a9ef75SPhilippe Mathieu-Daudé     return gen_msa_BxZ_V(ctx, a->wt, a->s16, TCG_COND_NE);
385*c7a9ef75SPhilippe Mathieu-Daudé }
386*c7a9ef75SPhilippe Mathieu-Daudé 
38780e64a38SPhilippe Mathieu-Daudé static bool gen_msa_BxZ(DisasContext *ctx, int df, int wt, int s16, bool if_not)
38880e64a38SPhilippe Mathieu-Daudé {
38980e64a38SPhilippe Mathieu-Daudé     check_msa_access(ctx);
39080e64a38SPhilippe Mathieu-Daudé 
39180e64a38SPhilippe Mathieu-Daudé     if (ctx->hflags & MIPS_HFLAG_BMASK) {
39280e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
39380e64a38SPhilippe Mathieu-Daudé         return true;
39480e64a38SPhilippe Mathieu-Daudé     }
39580e64a38SPhilippe Mathieu-Daudé 
396878b87b5SPhilippe Mathieu-Daudé     gen_check_zero_element(bcond, df, wt, if_not ? TCG_COND_EQ : TCG_COND_NE);
39780e64a38SPhilippe Mathieu-Daudé 
39880e64a38SPhilippe Mathieu-Daudé     ctx->btarget = ctx->base.pc_next + (s16 << 2) + 4;
39980e64a38SPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BC;
40080e64a38SPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BDS32;
40180e64a38SPhilippe Mathieu-Daudé 
40280e64a38SPhilippe Mathieu-Daudé     return true;
40380e64a38SPhilippe Mathieu-Daudé }
40480e64a38SPhilippe Mathieu-Daudé 
405*c7a9ef75SPhilippe Mathieu-Daudé static bool trans_BZ_x(DisasContext *ctx, arg_msa_bz *a)
406*c7a9ef75SPhilippe Mathieu-Daudé {
407*c7a9ef75SPhilippe Mathieu-Daudé     return gen_msa_BxZ(ctx, a->df, a->wt, a->s16, false);
408*c7a9ef75SPhilippe Mathieu-Daudé }
409*c7a9ef75SPhilippe Mathieu-Daudé 
410*c7a9ef75SPhilippe Mathieu-Daudé static bool trans_BNZ_x(DisasContext *ctx, arg_msa_bz *a)
411*c7a9ef75SPhilippe Mathieu-Daudé {
412*c7a9ef75SPhilippe Mathieu-Daudé     return gen_msa_BxZ(ctx, a->df, a->wt, a->s16, true);
413*c7a9ef75SPhilippe Mathieu-Daudé }
414*c7a9ef75SPhilippe Mathieu-Daudé 
41580e64a38SPhilippe Mathieu-Daudé void gen_msa_branch(DisasContext *ctx, uint32_t op1)
41680e64a38SPhilippe Mathieu-Daudé {
41780e64a38SPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 21) & 0x3;
41880e64a38SPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
41980e64a38SPhilippe Mathieu-Daudé     int64_t s16 = (int16_t)ctx->opcode;
42080e64a38SPhilippe Mathieu-Daudé 
42180e64a38SPhilippe Mathieu-Daudé     switch (op1) {
42280e64a38SPhilippe Mathieu-Daudé     case OPC_BZ_V:
42380e64a38SPhilippe Mathieu-Daudé     case OPC_BNZ_V:
42480e64a38SPhilippe Mathieu-Daudé         gen_msa_BxZ_V(ctx, wt, s16, (op1 == OPC_BZ_V) ?
42580e64a38SPhilippe Mathieu-Daudé                                     TCG_COND_EQ : TCG_COND_NE);
42680e64a38SPhilippe Mathieu-Daudé         break;
42780e64a38SPhilippe Mathieu-Daudé     case OPC_BZ_B:
42880e64a38SPhilippe Mathieu-Daudé     case OPC_BZ_H:
42980e64a38SPhilippe Mathieu-Daudé     case OPC_BZ_W:
43080e64a38SPhilippe Mathieu-Daudé     case OPC_BZ_D:
43180e64a38SPhilippe Mathieu-Daudé         gen_msa_BxZ(ctx, df, wt, s16, false);
43280e64a38SPhilippe Mathieu-Daudé         break;
43380e64a38SPhilippe Mathieu-Daudé     case OPC_BNZ_B:
43480e64a38SPhilippe Mathieu-Daudé     case OPC_BNZ_H:
43580e64a38SPhilippe Mathieu-Daudé     case OPC_BNZ_W:
43680e64a38SPhilippe Mathieu-Daudé     case OPC_BNZ_D:
43780e64a38SPhilippe Mathieu-Daudé         gen_msa_BxZ(ctx, df, wt, s16, true);
43880e64a38SPhilippe Mathieu-Daudé         break;
43980e64a38SPhilippe Mathieu-Daudé     }
44080e64a38SPhilippe Mathieu-Daudé }
44180e64a38SPhilippe Mathieu-Daudé 
44280e64a38SPhilippe Mathieu-Daudé static void gen_msa_i8(DisasContext *ctx)
44380e64a38SPhilippe Mathieu-Daudé {
44480e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_I8(op)    (MASK_MSA_MINOR(op) | (op & (0x03 << 24)))
44580e64a38SPhilippe Mathieu-Daudé     uint8_t i8 = (ctx->opcode >> 16) & 0xff;
44680e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
44780e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
44880e64a38SPhilippe Mathieu-Daudé 
44980e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
45080e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
45180e64a38SPhilippe Mathieu-Daudé     TCGv_i32 ti8 = tcg_const_i32(i8);
45280e64a38SPhilippe Mathieu-Daudé 
45380e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_I8(ctx->opcode)) {
45480e64a38SPhilippe Mathieu-Daudé     case OPC_ANDI_B:
45580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_andi_b(cpu_env, twd, tws, ti8);
45680e64a38SPhilippe Mathieu-Daudé         break;
45780e64a38SPhilippe Mathieu-Daudé     case OPC_ORI_B:
45880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ori_b(cpu_env, twd, tws, ti8);
45980e64a38SPhilippe Mathieu-Daudé         break;
46080e64a38SPhilippe Mathieu-Daudé     case OPC_NORI_B:
46180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_nori_b(cpu_env, twd, tws, ti8);
46280e64a38SPhilippe Mathieu-Daudé         break;
46380e64a38SPhilippe Mathieu-Daudé     case OPC_XORI_B:
46480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_xori_b(cpu_env, twd, tws, ti8);
46580e64a38SPhilippe Mathieu-Daudé         break;
46680e64a38SPhilippe Mathieu-Daudé     case OPC_BMNZI_B:
46780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_bmnzi_b(cpu_env, twd, tws, ti8);
46880e64a38SPhilippe Mathieu-Daudé         break;
46980e64a38SPhilippe Mathieu-Daudé     case OPC_BMZI_B:
47080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_bmzi_b(cpu_env, twd, tws, ti8);
47180e64a38SPhilippe Mathieu-Daudé         break;
47280e64a38SPhilippe Mathieu-Daudé     case OPC_BSELI_B:
47380e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_bseli_b(cpu_env, twd, tws, ti8);
47480e64a38SPhilippe Mathieu-Daudé         break;
47580e64a38SPhilippe Mathieu-Daudé     case OPC_SHF_B:
47680e64a38SPhilippe Mathieu-Daudé     case OPC_SHF_H:
47780e64a38SPhilippe Mathieu-Daudé     case OPC_SHF_W:
47880e64a38SPhilippe Mathieu-Daudé         {
47980e64a38SPhilippe Mathieu-Daudé             uint8_t df = (ctx->opcode >> 24) & 0x3;
48080e64a38SPhilippe Mathieu-Daudé             if (df == DF_DOUBLE) {
48180e64a38SPhilippe Mathieu-Daudé                 gen_reserved_instruction(ctx);
48280e64a38SPhilippe Mathieu-Daudé             } else {
48380e64a38SPhilippe Mathieu-Daudé                 TCGv_i32 tdf = tcg_const_i32(df);
48480e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_shf_df(cpu_env, tdf, twd, tws, ti8);
48580e64a38SPhilippe Mathieu-Daudé                 tcg_temp_free_i32(tdf);
48680e64a38SPhilippe Mathieu-Daudé             }
48780e64a38SPhilippe Mathieu-Daudé         }
48880e64a38SPhilippe Mathieu-Daudé         break;
48980e64a38SPhilippe Mathieu-Daudé     default:
49080e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
49180e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
49280e64a38SPhilippe Mathieu-Daudé         break;
49380e64a38SPhilippe Mathieu-Daudé     }
49480e64a38SPhilippe Mathieu-Daudé 
49580e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
49680e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
49780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(ti8);
49880e64a38SPhilippe Mathieu-Daudé }
49980e64a38SPhilippe Mathieu-Daudé 
50080e64a38SPhilippe Mathieu-Daudé static void gen_msa_i5(DisasContext *ctx)
50180e64a38SPhilippe Mathieu-Daudé {
50280e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_I5(op)    (MASK_MSA_MINOR(op) | (op & (0x7 << 23)))
50380e64a38SPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 21) & 0x3;
50480e64a38SPhilippe Mathieu-Daudé     int8_t s5 = (int8_t) sextract32(ctx->opcode, 16, 5);
50580e64a38SPhilippe Mathieu-Daudé     uint8_t u5 = (ctx->opcode >> 16) & 0x1f;
50680e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
50780e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
50880e64a38SPhilippe Mathieu-Daudé 
50980e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df);
51080e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
51180e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
51280e64a38SPhilippe Mathieu-Daudé     TCGv_i32 timm = tcg_temp_new_i32();
51380e64a38SPhilippe Mathieu-Daudé     tcg_gen_movi_i32(timm, u5);
51480e64a38SPhilippe Mathieu-Daudé 
51580e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_I5(ctx->opcode)) {
51680e64a38SPhilippe Mathieu-Daudé     case OPC_ADDVI_df:
51780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_addvi_df(cpu_env, tdf, twd, tws, timm);
51880e64a38SPhilippe Mathieu-Daudé         break;
51980e64a38SPhilippe Mathieu-Daudé     case OPC_SUBVI_df:
52080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_subvi_df(cpu_env, tdf, twd, tws, timm);
52180e64a38SPhilippe Mathieu-Daudé         break;
52280e64a38SPhilippe Mathieu-Daudé     case OPC_MAXI_S_df:
52380e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
52480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_maxi_s_df(cpu_env, tdf, twd, tws, timm);
52580e64a38SPhilippe Mathieu-Daudé         break;
52680e64a38SPhilippe Mathieu-Daudé     case OPC_MAXI_U_df:
52780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_maxi_u_df(cpu_env, tdf, twd, tws, timm);
52880e64a38SPhilippe Mathieu-Daudé         break;
52980e64a38SPhilippe Mathieu-Daudé     case OPC_MINI_S_df:
53080e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
53180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_mini_s_df(cpu_env, tdf, twd, tws, timm);
53280e64a38SPhilippe Mathieu-Daudé         break;
53380e64a38SPhilippe Mathieu-Daudé     case OPC_MINI_U_df:
53480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_mini_u_df(cpu_env, tdf, twd, tws, timm);
53580e64a38SPhilippe Mathieu-Daudé         break;
53680e64a38SPhilippe Mathieu-Daudé     case OPC_CEQI_df:
53780e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
53880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ceqi_df(cpu_env, tdf, twd, tws, timm);
53980e64a38SPhilippe Mathieu-Daudé         break;
54080e64a38SPhilippe Mathieu-Daudé     case OPC_CLTI_S_df:
54180e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
54280e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_clti_s_df(cpu_env, tdf, twd, tws, timm);
54380e64a38SPhilippe Mathieu-Daudé         break;
54480e64a38SPhilippe Mathieu-Daudé     case OPC_CLTI_U_df:
54580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_clti_u_df(cpu_env, tdf, twd, tws, timm);
54680e64a38SPhilippe Mathieu-Daudé         break;
54780e64a38SPhilippe Mathieu-Daudé     case OPC_CLEI_S_df:
54880e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(timm, s5);
54980e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_clei_s_df(cpu_env, tdf, twd, tws, timm);
55080e64a38SPhilippe Mathieu-Daudé         break;
55180e64a38SPhilippe Mathieu-Daudé     case OPC_CLEI_U_df:
55280e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_clei_u_df(cpu_env, tdf, twd, tws, timm);
55380e64a38SPhilippe Mathieu-Daudé         break;
55480e64a38SPhilippe Mathieu-Daudé     case OPC_LDI_df:
55580e64a38SPhilippe Mathieu-Daudé         {
55680e64a38SPhilippe Mathieu-Daudé             int32_t s10 = sextract32(ctx->opcode, 11, 10);
55780e64a38SPhilippe Mathieu-Daudé             tcg_gen_movi_i32(timm, s10);
55880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ldi_df(cpu_env, tdf, twd, timm);
55980e64a38SPhilippe Mathieu-Daudé         }
56080e64a38SPhilippe Mathieu-Daudé         break;
56180e64a38SPhilippe Mathieu-Daudé     default:
56280e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
56380e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
56480e64a38SPhilippe Mathieu-Daudé         break;
56580e64a38SPhilippe Mathieu-Daudé     }
56680e64a38SPhilippe Mathieu-Daudé 
56780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
56880e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
56980e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
57080e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(timm);
57180e64a38SPhilippe Mathieu-Daudé }
57280e64a38SPhilippe Mathieu-Daudé 
57380e64a38SPhilippe Mathieu-Daudé static void gen_msa_bit(DisasContext *ctx)
57480e64a38SPhilippe Mathieu-Daudé {
57580e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_BIT(op)    (MASK_MSA_MINOR(op) | (op & (0x7 << 23)))
57680e64a38SPhilippe Mathieu-Daudé     uint8_t dfm = (ctx->opcode >> 16) & 0x7f;
57780e64a38SPhilippe Mathieu-Daudé     uint32_t df = 0, m = 0;
57880e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
57980e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
58080e64a38SPhilippe Mathieu-Daudé 
58180e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdf;
58280e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tm;
58380e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd;
58480e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws;
58580e64a38SPhilippe Mathieu-Daudé 
58680e64a38SPhilippe Mathieu-Daudé     if ((dfm & 0x40) == 0x00) {
58780e64a38SPhilippe Mathieu-Daudé         m = dfm & 0x3f;
58880e64a38SPhilippe Mathieu-Daudé         df = DF_DOUBLE;
58980e64a38SPhilippe Mathieu-Daudé     } else if ((dfm & 0x60) == 0x40) {
59080e64a38SPhilippe Mathieu-Daudé         m = dfm & 0x1f;
59180e64a38SPhilippe Mathieu-Daudé         df = DF_WORD;
59280e64a38SPhilippe Mathieu-Daudé     } else if ((dfm & 0x70) == 0x60) {
59380e64a38SPhilippe Mathieu-Daudé         m = dfm & 0x0f;
59480e64a38SPhilippe Mathieu-Daudé         df = DF_HALF;
59580e64a38SPhilippe Mathieu-Daudé     } else if ((dfm & 0x78) == 0x70) {
59680e64a38SPhilippe Mathieu-Daudé         m = dfm & 0x7;
59780e64a38SPhilippe Mathieu-Daudé         df = DF_BYTE;
59880e64a38SPhilippe Mathieu-Daudé     } else {
59980e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
60080e64a38SPhilippe Mathieu-Daudé         return;
60180e64a38SPhilippe Mathieu-Daudé     }
60280e64a38SPhilippe Mathieu-Daudé 
60380e64a38SPhilippe Mathieu-Daudé     tdf = tcg_const_i32(df);
60480e64a38SPhilippe Mathieu-Daudé     tm  = tcg_const_i32(m);
60580e64a38SPhilippe Mathieu-Daudé     twd = tcg_const_i32(wd);
60680e64a38SPhilippe Mathieu-Daudé     tws = tcg_const_i32(ws);
60780e64a38SPhilippe Mathieu-Daudé 
60880e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_BIT(ctx->opcode)) {
60980e64a38SPhilippe Mathieu-Daudé     case OPC_SLLI_df:
61080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_slli_df(cpu_env, tdf, twd, tws, tm);
61180e64a38SPhilippe Mathieu-Daudé         break;
61280e64a38SPhilippe Mathieu-Daudé     case OPC_SRAI_df:
61380e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_srai_df(cpu_env, tdf, twd, tws, tm);
61480e64a38SPhilippe Mathieu-Daudé         break;
61580e64a38SPhilippe Mathieu-Daudé     case OPC_SRLI_df:
61680e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_srli_df(cpu_env, tdf, twd, tws, tm);
61780e64a38SPhilippe Mathieu-Daudé         break;
61880e64a38SPhilippe Mathieu-Daudé     case OPC_BCLRI_df:
61980e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_bclri_df(cpu_env, tdf, twd, tws, tm);
62080e64a38SPhilippe Mathieu-Daudé         break;
62180e64a38SPhilippe Mathieu-Daudé     case OPC_BSETI_df:
62280e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_bseti_df(cpu_env, tdf, twd, tws, tm);
62380e64a38SPhilippe Mathieu-Daudé         break;
62480e64a38SPhilippe Mathieu-Daudé     case OPC_BNEGI_df:
62580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_bnegi_df(cpu_env, tdf, twd, tws, tm);
62680e64a38SPhilippe Mathieu-Daudé         break;
62780e64a38SPhilippe Mathieu-Daudé     case OPC_BINSLI_df:
62880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_binsli_df(cpu_env, tdf, twd, tws, tm);
62980e64a38SPhilippe Mathieu-Daudé         break;
63080e64a38SPhilippe Mathieu-Daudé     case OPC_BINSRI_df:
63180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_binsri_df(cpu_env, tdf, twd, tws, tm);
63280e64a38SPhilippe Mathieu-Daudé         break;
63380e64a38SPhilippe Mathieu-Daudé     case OPC_SAT_S_df:
63480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_sat_s_df(cpu_env, tdf, twd, tws, tm);
63580e64a38SPhilippe Mathieu-Daudé         break;
63680e64a38SPhilippe Mathieu-Daudé     case OPC_SAT_U_df:
63780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_sat_u_df(cpu_env, tdf, twd, tws, tm);
63880e64a38SPhilippe Mathieu-Daudé         break;
63980e64a38SPhilippe Mathieu-Daudé     case OPC_SRARI_df:
64080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_srari_df(cpu_env, tdf, twd, tws, tm);
64180e64a38SPhilippe Mathieu-Daudé         break;
64280e64a38SPhilippe Mathieu-Daudé     case OPC_SRLRI_df:
64380e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_srlri_df(cpu_env, tdf, twd, tws, tm);
64480e64a38SPhilippe Mathieu-Daudé         break;
64580e64a38SPhilippe Mathieu-Daudé     default:
64680e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
64780e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
64880e64a38SPhilippe Mathieu-Daudé         break;
64980e64a38SPhilippe Mathieu-Daudé     }
65080e64a38SPhilippe Mathieu-Daudé 
65180e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
65280e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tm);
65380e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
65480e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
65580e64a38SPhilippe Mathieu-Daudé }
65680e64a38SPhilippe Mathieu-Daudé 
65780e64a38SPhilippe Mathieu-Daudé static void gen_msa_3r(DisasContext *ctx)
65880e64a38SPhilippe Mathieu-Daudé {
65980e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_3R(op)    (MASK_MSA_MINOR(op) | (op & (0x7 << 23)))
66080e64a38SPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 21) & 0x3;
66180e64a38SPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
66280e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
66380e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
66480e64a38SPhilippe Mathieu-Daudé 
66580e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df);
66680e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
66780e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
66880e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
66980e64a38SPhilippe Mathieu-Daudé 
67080e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_3R(ctx->opcode)) {
67180e64a38SPhilippe Mathieu-Daudé     case OPC_BINSL_df:
67280e64a38SPhilippe Mathieu-Daudé         switch (df) {
67380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
67480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsl_b(cpu_env, twd, tws, twt);
67580e64a38SPhilippe Mathieu-Daudé             break;
67680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
67780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsl_h(cpu_env, twd, tws, twt);
67880e64a38SPhilippe Mathieu-Daudé             break;
67980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
68080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsl_w(cpu_env, twd, tws, twt);
68180e64a38SPhilippe Mathieu-Daudé             break;
68280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
68380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsl_d(cpu_env, twd, tws, twt);
68480e64a38SPhilippe Mathieu-Daudé             break;
68580e64a38SPhilippe Mathieu-Daudé         }
68680e64a38SPhilippe Mathieu-Daudé         break;
68780e64a38SPhilippe Mathieu-Daudé     case OPC_BINSR_df:
68880e64a38SPhilippe Mathieu-Daudé         switch (df) {
68980e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
69080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsr_b(cpu_env, twd, tws, twt);
69180e64a38SPhilippe Mathieu-Daudé             break;
69280e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
69380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsr_h(cpu_env, twd, tws, twt);
69480e64a38SPhilippe Mathieu-Daudé             break;
69580e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
69680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsr_w(cpu_env, twd, tws, twt);
69780e64a38SPhilippe Mathieu-Daudé             break;
69880e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
69980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsr_d(cpu_env, twd, tws, twt);
70080e64a38SPhilippe Mathieu-Daudé             break;
70180e64a38SPhilippe Mathieu-Daudé         }
70280e64a38SPhilippe Mathieu-Daudé         break;
70380e64a38SPhilippe Mathieu-Daudé     case OPC_BCLR_df:
70480e64a38SPhilippe Mathieu-Daudé         switch (df) {
70580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
70680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bclr_b(cpu_env, twd, tws, twt);
70780e64a38SPhilippe Mathieu-Daudé             break;
70880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
70980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bclr_h(cpu_env, twd, tws, twt);
71080e64a38SPhilippe Mathieu-Daudé             break;
71180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
71280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bclr_w(cpu_env, twd, tws, twt);
71380e64a38SPhilippe Mathieu-Daudé             break;
71480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
71580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bclr_d(cpu_env, twd, tws, twt);
71680e64a38SPhilippe Mathieu-Daudé             break;
71780e64a38SPhilippe Mathieu-Daudé         }
71880e64a38SPhilippe Mathieu-Daudé         break;
71980e64a38SPhilippe Mathieu-Daudé     case OPC_BNEG_df:
72080e64a38SPhilippe Mathieu-Daudé         switch (df) {
72180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
72280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bneg_b(cpu_env, twd, tws, twt);
72380e64a38SPhilippe Mathieu-Daudé             break;
72480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
72580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bneg_h(cpu_env, twd, tws, twt);
72680e64a38SPhilippe Mathieu-Daudé             break;
72780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
72880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bneg_w(cpu_env, twd, tws, twt);
72980e64a38SPhilippe Mathieu-Daudé             break;
73080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
73180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bneg_d(cpu_env, twd, tws, twt);
73280e64a38SPhilippe Mathieu-Daudé             break;
73380e64a38SPhilippe Mathieu-Daudé         }
73480e64a38SPhilippe Mathieu-Daudé         break;
73580e64a38SPhilippe Mathieu-Daudé     case OPC_BSET_df:
73680e64a38SPhilippe Mathieu-Daudé         switch (df) {
73780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
73880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bset_b(cpu_env, twd, tws, twt);
73980e64a38SPhilippe Mathieu-Daudé             break;
74080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
74180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bset_h(cpu_env, twd, tws, twt);
74280e64a38SPhilippe Mathieu-Daudé             break;
74380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
74480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bset_w(cpu_env, twd, tws, twt);
74580e64a38SPhilippe Mathieu-Daudé             break;
74680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
74780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bset_d(cpu_env, twd, tws, twt);
74880e64a38SPhilippe Mathieu-Daudé             break;
74980e64a38SPhilippe Mathieu-Daudé         }
75080e64a38SPhilippe Mathieu-Daudé         break;
75180e64a38SPhilippe Mathieu-Daudé     case OPC_ADD_A_df:
75280e64a38SPhilippe Mathieu-Daudé         switch (df) {
75380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
75480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_add_a_b(cpu_env, twd, tws, twt);
75580e64a38SPhilippe Mathieu-Daudé             break;
75680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
75780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_add_a_h(cpu_env, twd, tws, twt);
75880e64a38SPhilippe Mathieu-Daudé             break;
75980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
76080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_add_a_w(cpu_env, twd, tws, twt);
76180e64a38SPhilippe Mathieu-Daudé             break;
76280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
76380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_add_a_d(cpu_env, twd, tws, twt);
76480e64a38SPhilippe Mathieu-Daudé             break;
76580e64a38SPhilippe Mathieu-Daudé         }
76680e64a38SPhilippe Mathieu-Daudé         break;
76780e64a38SPhilippe Mathieu-Daudé     case OPC_ADDS_A_df:
76880e64a38SPhilippe Mathieu-Daudé         switch (df) {
76980e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
77080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_b(cpu_env, twd, tws, twt);
77180e64a38SPhilippe Mathieu-Daudé             break;
77280e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
77380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_h(cpu_env, twd, tws, twt);
77480e64a38SPhilippe Mathieu-Daudé             break;
77580e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
77680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_w(cpu_env, twd, tws, twt);
77780e64a38SPhilippe Mathieu-Daudé             break;
77880e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
77980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_d(cpu_env, twd, tws, twt);
78080e64a38SPhilippe Mathieu-Daudé             break;
78180e64a38SPhilippe Mathieu-Daudé         }
78280e64a38SPhilippe Mathieu-Daudé         break;
78380e64a38SPhilippe Mathieu-Daudé     case OPC_ADDS_S_df:
78480e64a38SPhilippe Mathieu-Daudé         switch (df) {
78580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
78680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_b(cpu_env, twd, tws, twt);
78780e64a38SPhilippe Mathieu-Daudé             break;
78880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
78980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_h(cpu_env, twd, tws, twt);
79080e64a38SPhilippe Mathieu-Daudé             break;
79180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
79280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_w(cpu_env, twd, tws, twt);
79380e64a38SPhilippe Mathieu-Daudé             break;
79480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
79580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_d(cpu_env, twd, tws, twt);
79680e64a38SPhilippe Mathieu-Daudé             break;
79780e64a38SPhilippe Mathieu-Daudé         }
79880e64a38SPhilippe Mathieu-Daudé         break;
79980e64a38SPhilippe Mathieu-Daudé     case OPC_ADDS_U_df:
80080e64a38SPhilippe Mathieu-Daudé         switch (df) {
80180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
80280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_b(cpu_env, twd, tws, twt);
80380e64a38SPhilippe Mathieu-Daudé             break;
80480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
80580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_h(cpu_env, twd, tws, twt);
80680e64a38SPhilippe Mathieu-Daudé             break;
80780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
80880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_w(cpu_env, twd, tws, twt);
80980e64a38SPhilippe Mathieu-Daudé             break;
81080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
81180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_d(cpu_env, twd, tws, twt);
81280e64a38SPhilippe Mathieu-Daudé             break;
81380e64a38SPhilippe Mathieu-Daudé         }
81480e64a38SPhilippe Mathieu-Daudé         break;
81580e64a38SPhilippe Mathieu-Daudé     case OPC_ADDV_df:
81680e64a38SPhilippe Mathieu-Daudé         switch (df) {
81780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
81880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_addv_b(cpu_env, twd, tws, twt);
81980e64a38SPhilippe Mathieu-Daudé             break;
82080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
82180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_addv_h(cpu_env, twd, tws, twt);
82280e64a38SPhilippe Mathieu-Daudé             break;
82380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
82480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_addv_w(cpu_env, twd, tws, twt);
82580e64a38SPhilippe Mathieu-Daudé             break;
82680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
82780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_addv_d(cpu_env, twd, tws, twt);
82880e64a38SPhilippe Mathieu-Daudé             break;
82980e64a38SPhilippe Mathieu-Daudé         }
83080e64a38SPhilippe Mathieu-Daudé         break;
83180e64a38SPhilippe Mathieu-Daudé     case OPC_AVE_S_df:
83280e64a38SPhilippe Mathieu-Daudé         switch (df) {
83380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
83480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_b(cpu_env, twd, tws, twt);
83580e64a38SPhilippe Mathieu-Daudé             break;
83680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
83780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_h(cpu_env, twd, tws, twt);
83880e64a38SPhilippe Mathieu-Daudé             break;
83980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
84080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_w(cpu_env, twd, tws, twt);
84180e64a38SPhilippe Mathieu-Daudé             break;
84280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
84380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_d(cpu_env, twd, tws, twt);
84480e64a38SPhilippe Mathieu-Daudé             break;
84580e64a38SPhilippe Mathieu-Daudé         }
84680e64a38SPhilippe Mathieu-Daudé         break;
84780e64a38SPhilippe Mathieu-Daudé     case OPC_AVE_U_df:
84880e64a38SPhilippe Mathieu-Daudé         switch (df) {
84980e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
85080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_b(cpu_env, twd, tws, twt);
85180e64a38SPhilippe Mathieu-Daudé             break;
85280e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
85380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_h(cpu_env, twd, tws, twt);
85480e64a38SPhilippe Mathieu-Daudé             break;
85580e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
85680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_w(cpu_env, twd, tws, twt);
85780e64a38SPhilippe Mathieu-Daudé             break;
85880e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
85980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_d(cpu_env, twd, tws, twt);
86080e64a38SPhilippe Mathieu-Daudé             break;
86180e64a38SPhilippe Mathieu-Daudé         }
86280e64a38SPhilippe Mathieu-Daudé         break;
86380e64a38SPhilippe Mathieu-Daudé     case OPC_AVER_S_df:
86480e64a38SPhilippe Mathieu-Daudé         switch (df) {
86580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
86680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_b(cpu_env, twd, tws, twt);
86780e64a38SPhilippe Mathieu-Daudé             break;
86880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
86980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_h(cpu_env, twd, tws, twt);
87080e64a38SPhilippe Mathieu-Daudé             break;
87180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
87280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_w(cpu_env, twd, tws, twt);
87380e64a38SPhilippe Mathieu-Daudé             break;
87480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
87580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_d(cpu_env, twd, tws, twt);
87680e64a38SPhilippe Mathieu-Daudé             break;
87780e64a38SPhilippe Mathieu-Daudé         }
87880e64a38SPhilippe Mathieu-Daudé         break;
87980e64a38SPhilippe Mathieu-Daudé     case OPC_AVER_U_df:
88080e64a38SPhilippe Mathieu-Daudé         switch (df) {
88180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
88280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_b(cpu_env, twd, tws, twt);
88380e64a38SPhilippe Mathieu-Daudé             break;
88480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
88580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_h(cpu_env, twd, tws, twt);
88680e64a38SPhilippe Mathieu-Daudé             break;
88780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
88880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_w(cpu_env, twd, tws, twt);
88980e64a38SPhilippe Mathieu-Daudé             break;
89080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
89180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_d(cpu_env, twd, tws, twt);
89280e64a38SPhilippe Mathieu-Daudé             break;
89380e64a38SPhilippe Mathieu-Daudé         }
89480e64a38SPhilippe Mathieu-Daudé         break;
89580e64a38SPhilippe Mathieu-Daudé     case OPC_CEQ_df:
89680e64a38SPhilippe Mathieu-Daudé         switch (df) {
89780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
89880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ceq_b(cpu_env, twd, tws, twt);
89980e64a38SPhilippe Mathieu-Daudé             break;
90080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
90180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ceq_h(cpu_env, twd, tws, twt);
90280e64a38SPhilippe Mathieu-Daudé             break;
90380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
90480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ceq_w(cpu_env, twd, tws, twt);
90580e64a38SPhilippe Mathieu-Daudé             break;
90680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
90780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ceq_d(cpu_env, twd, tws, twt);
90880e64a38SPhilippe Mathieu-Daudé             break;
90980e64a38SPhilippe Mathieu-Daudé         }
91080e64a38SPhilippe Mathieu-Daudé         break;
91180e64a38SPhilippe Mathieu-Daudé     case OPC_CLE_S_df:
91280e64a38SPhilippe Mathieu-Daudé         switch (df) {
91380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
91480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_b(cpu_env, twd, tws, twt);
91580e64a38SPhilippe Mathieu-Daudé             break;
91680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
91780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_h(cpu_env, twd, tws, twt);
91880e64a38SPhilippe Mathieu-Daudé             break;
91980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
92080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_w(cpu_env, twd, tws, twt);
92180e64a38SPhilippe Mathieu-Daudé             break;
92280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
92380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_d(cpu_env, twd, tws, twt);
92480e64a38SPhilippe Mathieu-Daudé             break;
92580e64a38SPhilippe Mathieu-Daudé         }
92680e64a38SPhilippe Mathieu-Daudé         break;
92780e64a38SPhilippe Mathieu-Daudé     case OPC_CLE_U_df:
92880e64a38SPhilippe Mathieu-Daudé         switch (df) {
92980e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
93080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_b(cpu_env, twd, tws, twt);
93180e64a38SPhilippe Mathieu-Daudé             break;
93280e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
93380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_h(cpu_env, twd, tws, twt);
93480e64a38SPhilippe Mathieu-Daudé             break;
93580e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
93680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_w(cpu_env, twd, tws, twt);
93780e64a38SPhilippe Mathieu-Daudé             break;
93880e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
93980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_d(cpu_env, twd, tws, twt);
94080e64a38SPhilippe Mathieu-Daudé             break;
94180e64a38SPhilippe Mathieu-Daudé         }
94280e64a38SPhilippe Mathieu-Daudé         break;
94380e64a38SPhilippe Mathieu-Daudé     case OPC_CLT_S_df:
94480e64a38SPhilippe Mathieu-Daudé         switch (df) {
94580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
94680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_b(cpu_env, twd, tws, twt);
94780e64a38SPhilippe Mathieu-Daudé             break;
94880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
94980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_h(cpu_env, twd, tws, twt);
95080e64a38SPhilippe Mathieu-Daudé             break;
95180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
95280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_w(cpu_env, twd, tws, twt);
95380e64a38SPhilippe Mathieu-Daudé             break;
95480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
95580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_d(cpu_env, twd, tws, twt);
95680e64a38SPhilippe Mathieu-Daudé             break;
95780e64a38SPhilippe Mathieu-Daudé         }
95880e64a38SPhilippe Mathieu-Daudé         break;
95980e64a38SPhilippe Mathieu-Daudé     case OPC_CLT_U_df:
96080e64a38SPhilippe Mathieu-Daudé         switch (df) {
96180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
96280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_b(cpu_env, twd, tws, twt);
96380e64a38SPhilippe Mathieu-Daudé             break;
96480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
96580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_h(cpu_env, twd, tws, twt);
96680e64a38SPhilippe Mathieu-Daudé             break;
96780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
96880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_w(cpu_env, twd, tws, twt);
96980e64a38SPhilippe Mathieu-Daudé             break;
97080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
97180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_d(cpu_env, twd, tws, twt);
97280e64a38SPhilippe Mathieu-Daudé             break;
97380e64a38SPhilippe Mathieu-Daudé         }
97480e64a38SPhilippe Mathieu-Daudé         break;
97580e64a38SPhilippe Mathieu-Daudé     case OPC_DIV_S_df:
97680e64a38SPhilippe Mathieu-Daudé         switch (df) {
97780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
97880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_s_b(cpu_env, twd, tws, twt);
97980e64a38SPhilippe Mathieu-Daudé             break;
98080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
98180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_s_h(cpu_env, twd, tws, twt);
98280e64a38SPhilippe Mathieu-Daudé             break;
98380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
98480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_s_w(cpu_env, twd, tws, twt);
98580e64a38SPhilippe Mathieu-Daudé             break;
98680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
98780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_s_d(cpu_env, twd, tws, twt);
98880e64a38SPhilippe Mathieu-Daudé             break;
98980e64a38SPhilippe Mathieu-Daudé         }
99080e64a38SPhilippe Mathieu-Daudé         break;
99180e64a38SPhilippe Mathieu-Daudé     case OPC_DIV_U_df:
99280e64a38SPhilippe Mathieu-Daudé         switch (df) {
99380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
99480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_u_b(cpu_env, twd, tws, twt);
99580e64a38SPhilippe Mathieu-Daudé             break;
99680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
99780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_u_h(cpu_env, twd, tws, twt);
99880e64a38SPhilippe Mathieu-Daudé             break;
99980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
100080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_u_w(cpu_env, twd, tws, twt);
100180e64a38SPhilippe Mathieu-Daudé             break;
100280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
100380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_u_d(cpu_env, twd, tws, twt);
100480e64a38SPhilippe Mathieu-Daudé             break;
100580e64a38SPhilippe Mathieu-Daudé         }
100680e64a38SPhilippe Mathieu-Daudé         break;
100780e64a38SPhilippe Mathieu-Daudé     case OPC_MAX_A_df:
100880e64a38SPhilippe Mathieu-Daudé         switch (df) {
100980e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
101080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_a_b(cpu_env, twd, tws, twt);
101180e64a38SPhilippe Mathieu-Daudé             break;
101280e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
101380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_a_h(cpu_env, twd, tws, twt);
101480e64a38SPhilippe Mathieu-Daudé             break;
101580e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
101680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_a_w(cpu_env, twd, tws, twt);
101780e64a38SPhilippe Mathieu-Daudé             break;
101880e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
101980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_a_d(cpu_env, twd, tws, twt);
102080e64a38SPhilippe Mathieu-Daudé             break;
102180e64a38SPhilippe Mathieu-Daudé         }
102280e64a38SPhilippe Mathieu-Daudé         break;
102380e64a38SPhilippe Mathieu-Daudé     case OPC_MAX_S_df:
102480e64a38SPhilippe Mathieu-Daudé         switch (df) {
102580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
102680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_s_b(cpu_env, twd, tws, twt);
102780e64a38SPhilippe Mathieu-Daudé             break;
102880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
102980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_s_h(cpu_env, twd, tws, twt);
103080e64a38SPhilippe Mathieu-Daudé             break;
103180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
103280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_s_w(cpu_env, twd, tws, twt);
103380e64a38SPhilippe Mathieu-Daudé             break;
103480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
103580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_s_d(cpu_env, twd, tws, twt);
103680e64a38SPhilippe Mathieu-Daudé             break;
103780e64a38SPhilippe Mathieu-Daudé         }
103880e64a38SPhilippe Mathieu-Daudé         break;
103980e64a38SPhilippe Mathieu-Daudé     case OPC_MAX_U_df:
104080e64a38SPhilippe Mathieu-Daudé         switch (df) {
104180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
104280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_u_b(cpu_env, twd, tws, twt);
104380e64a38SPhilippe Mathieu-Daudé             break;
104480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
104580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_u_h(cpu_env, twd, tws, twt);
104680e64a38SPhilippe Mathieu-Daudé             break;
104780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
104880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_u_w(cpu_env, twd, tws, twt);
104980e64a38SPhilippe Mathieu-Daudé             break;
105080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
105180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_u_d(cpu_env, twd, tws, twt);
105280e64a38SPhilippe Mathieu-Daudé             break;
105380e64a38SPhilippe Mathieu-Daudé         }
105480e64a38SPhilippe Mathieu-Daudé         break;
105580e64a38SPhilippe Mathieu-Daudé     case OPC_MIN_A_df:
105680e64a38SPhilippe Mathieu-Daudé         switch (df) {
105780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
105880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_a_b(cpu_env, twd, tws, twt);
105980e64a38SPhilippe Mathieu-Daudé             break;
106080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
106180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_a_h(cpu_env, twd, tws, twt);
106280e64a38SPhilippe Mathieu-Daudé             break;
106380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
106480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_a_w(cpu_env, twd, tws, twt);
106580e64a38SPhilippe Mathieu-Daudé             break;
106680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
106780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_a_d(cpu_env, twd, tws, twt);
106880e64a38SPhilippe Mathieu-Daudé             break;
106980e64a38SPhilippe Mathieu-Daudé         }
107080e64a38SPhilippe Mathieu-Daudé         break;
107180e64a38SPhilippe Mathieu-Daudé     case OPC_MIN_S_df:
107280e64a38SPhilippe Mathieu-Daudé         switch (df) {
107380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
107480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_s_b(cpu_env, twd, tws, twt);
107580e64a38SPhilippe Mathieu-Daudé             break;
107680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
107780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_s_h(cpu_env, twd, tws, twt);
107880e64a38SPhilippe Mathieu-Daudé             break;
107980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
108080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_s_w(cpu_env, twd, tws, twt);
108180e64a38SPhilippe Mathieu-Daudé             break;
108280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
108380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_s_d(cpu_env, twd, tws, twt);
108480e64a38SPhilippe Mathieu-Daudé             break;
108580e64a38SPhilippe Mathieu-Daudé         }
108680e64a38SPhilippe Mathieu-Daudé         break;
108780e64a38SPhilippe Mathieu-Daudé     case OPC_MIN_U_df:
108880e64a38SPhilippe Mathieu-Daudé         switch (df) {
108980e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
109080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_u_b(cpu_env, twd, tws, twt);
109180e64a38SPhilippe Mathieu-Daudé             break;
109280e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
109380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_u_h(cpu_env, twd, tws, twt);
109480e64a38SPhilippe Mathieu-Daudé             break;
109580e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
109680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_u_w(cpu_env, twd, tws, twt);
109780e64a38SPhilippe Mathieu-Daudé             break;
109880e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
109980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_u_d(cpu_env, twd, tws, twt);
110080e64a38SPhilippe Mathieu-Daudé             break;
110180e64a38SPhilippe Mathieu-Daudé         }
110280e64a38SPhilippe Mathieu-Daudé         break;
110380e64a38SPhilippe Mathieu-Daudé     case OPC_MOD_S_df:
110480e64a38SPhilippe Mathieu-Daudé         switch (df) {
110580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
110680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_b(cpu_env, twd, tws, twt);
110780e64a38SPhilippe Mathieu-Daudé             break;
110880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
110980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_h(cpu_env, twd, tws, twt);
111080e64a38SPhilippe Mathieu-Daudé             break;
111180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
111280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_w(cpu_env, twd, tws, twt);
111380e64a38SPhilippe Mathieu-Daudé             break;
111480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
111580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_d(cpu_env, twd, tws, twt);
111680e64a38SPhilippe Mathieu-Daudé             break;
111780e64a38SPhilippe Mathieu-Daudé         }
111880e64a38SPhilippe Mathieu-Daudé         break;
111980e64a38SPhilippe Mathieu-Daudé     case OPC_MOD_U_df:
112080e64a38SPhilippe Mathieu-Daudé         switch (df) {
112180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
112280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_b(cpu_env, twd, tws, twt);
112380e64a38SPhilippe Mathieu-Daudé             break;
112480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
112580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_h(cpu_env, twd, tws, twt);
112680e64a38SPhilippe Mathieu-Daudé             break;
112780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
112880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_w(cpu_env, twd, tws, twt);
112980e64a38SPhilippe Mathieu-Daudé             break;
113080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
113180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_d(cpu_env, twd, tws, twt);
113280e64a38SPhilippe Mathieu-Daudé             break;
113380e64a38SPhilippe Mathieu-Daudé         }
113480e64a38SPhilippe Mathieu-Daudé         break;
113580e64a38SPhilippe Mathieu-Daudé     case OPC_MADDV_df:
113680e64a38SPhilippe Mathieu-Daudé         switch (df) {
113780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
113880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_maddv_b(cpu_env, twd, tws, twt);
113980e64a38SPhilippe Mathieu-Daudé             break;
114080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
114180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_maddv_h(cpu_env, twd, tws, twt);
114280e64a38SPhilippe Mathieu-Daudé             break;
114380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
114480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_maddv_w(cpu_env, twd, tws, twt);
114580e64a38SPhilippe Mathieu-Daudé             break;
114680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
114780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_maddv_d(cpu_env, twd, tws, twt);
114880e64a38SPhilippe Mathieu-Daudé             break;
114980e64a38SPhilippe Mathieu-Daudé         }
115080e64a38SPhilippe Mathieu-Daudé         break;
115180e64a38SPhilippe Mathieu-Daudé     case OPC_MSUBV_df:
115280e64a38SPhilippe Mathieu-Daudé         switch (df) {
115380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
115480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_msubv_b(cpu_env, twd, tws, twt);
115580e64a38SPhilippe Mathieu-Daudé             break;
115680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
115780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_msubv_h(cpu_env, twd, tws, twt);
115880e64a38SPhilippe Mathieu-Daudé             break;
115980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
116080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_msubv_w(cpu_env, twd, tws, twt);
116180e64a38SPhilippe Mathieu-Daudé             break;
116280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
116380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_msubv_d(cpu_env, twd, tws, twt);
116480e64a38SPhilippe Mathieu-Daudé             break;
116580e64a38SPhilippe Mathieu-Daudé         }
116680e64a38SPhilippe Mathieu-Daudé         break;
116780e64a38SPhilippe Mathieu-Daudé     case OPC_ASUB_S_df:
116880e64a38SPhilippe Mathieu-Daudé         switch (df) {
116980e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
117080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_b(cpu_env, twd, tws, twt);
117180e64a38SPhilippe Mathieu-Daudé             break;
117280e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
117380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_h(cpu_env, twd, tws, twt);
117480e64a38SPhilippe Mathieu-Daudé             break;
117580e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
117680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_w(cpu_env, twd, tws, twt);
117780e64a38SPhilippe Mathieu-Daudé             break;
117880e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
117980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_d(cpu_env, twd, tws, twt);
118080e64a38SPhilippe Mathieu-Daudé             break;
118180e64a38SPhilippe Mathieu-Daudé         }
118280e64a38SPhilippe Mathieu-Daudé         break;
118380e64a38SPhilippe Mathieu-Daudé     case OPC_ASUB_U_df:
118480e64a38SPhilippe Mathieu-Daudé         switch (df) {
118580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
118680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_b(cpu_env, twd, tws, twt);
118780e64a38SPhilippe Mathieu-Daudé             break;
118880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
118980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_h(cpu_env, twd, tws, twt);
119080e64a38SPhilippe Mathieu-Daudé             break;
119180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
119280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_w(cpu_env, twd, tws, twt);
119380e64a38SPhilippe Mathieu-Daudé             break;
119480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
119580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_d(cpu_env, twd, tws, twt);
119680e64a38SPhilippe Mathieu-Daudé             break;
119780e64a38SPhilippe Mathieu-Daudé         }
119880e64a38SPhilippe Mathieu-Daudé         break;
119980e64a38SPhilippe Mathieu-Daudé     case OPC_ILVEV_df:
120080e64a38SPhilippe Mathieu-Daudé         switch (df) {
120180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
120280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_b(cpu_env, twd, tws, twt);
120380e64a38SPhilippe Mathieu-Daudé             break;
120480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
120580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_h(cpu_env, twd, tws, twt);
120680e64a38SPhilippe Mathieu-Daudé             break;
120780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
120880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_w(cpu_env, twd, tws, twt);
120980e64a38SPhilippe Mathieu-Daudé             break;
121080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
121180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_d(cpu_env, twd, tws, twt);
121280e64a38SPhilippe Mathieu-Daudé             break;
121380e64a38SPhilippe Mathieu-Daudé         }
121480e64a38SPhilippe Mathieu-Daudé         break;
121580e64a38SPhilippe Mathieu-Daudé     case OPC_ILVOD_df:
121680e64a38SPhilippe Mathieu-Daudé         switch (df) {
121780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
121880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_b(cpu_env, twd, tws, twt);
121980e64a38SPhilippe Mathieu-Daudé             break;
122080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
122180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_h(cpu_env, twd, tws, twt);
122280e64a38SPhilippe Mathieu-Daudé             break;
122380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
122480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_w(cpu_env, twd, tws, twt);
122580e64a38SPhilippe Mathieu-Daudé             break;
122680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
122780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_d(cpu_env, twd, tws, twt);
122880e64a38SPhilippe Mathieu-Daudé             break;
122980e64a38SPhilippe Mathieu-Daudé         }
123080e64a38SPhilippe Mathieu-Daudé         break;
123180e64a38SPhilippe Mathieu-Daudé     case OPC_ILVL_df:
123280e64a38SPhilippe Mathieu-Daudé         switch (df) {
123380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
123480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_b(cpu_env, twd, tws, twt);
123580e64a38SPhilippe Mathieu-Daudé             break;
123680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
123780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_h(cpu_env, twd, tws, twt);
123880e64a38SPhilippe Mathieu-Daudé             break;
123980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
124080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_w(cpu_env, twd, tws, twt);
124180e64a38SPhilippe Mathieu-Daudé             break;
124280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
124380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_d(cpu_env, twd, tws, twt);
124480e64a38SPhilippe Mathieu-Daudé             break;
124580e64a38SPhilippe Mathieu-Daudé         }
124680e64a38SPhilippe Mathieu-Daudé         break;
124780e64a38SPhilippe Mathieu-Daudé     case OPC_ILVR_df:
124880e64a38SPhilippe Mathieu-Daudé         switch (df) {
124980e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
125080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_b(cpu_env, twd, tws, twt);
125180e64a38SPhilippe Mathieu-Daudé             break;
125280e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
125380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_h(cpu_env, twd, tws, twt);
125480e64a38SPhilippe Mathieu-Daudé             break;
125580e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
125680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_w(cpu_env, twd, tws, twt);
125780e64a38SPhilippe Mathieu-Daudé             break;
125880e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
125980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_d(cpu_env, twd, tws, twt);
126080e64a38SPhilippe Mathieu-Daudé             break;
126180e64a38SPhilippe Mathieu-Daudé         }
126280e64a38SPhilippe Mathieu-Daudé         break;
126380e64a38SPhilippe Mathieu-Daudé     case OPC_PCKEV_df:
126480e64a38SPhilippe Mathieu-Daudé         switch (df) {
126580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
126680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckev_b(cpu_env, twd, tws, twt);
126780e64a38SPhilippe Mathieu-Daudé             break;
126880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
126980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckev_h(cpu_env, twd, tws, twt);
127080e64a38SPhilippe Mathieu-Daudé             break;
127180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
127280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckev_w(cpu_env, twd, tws, twt);
127380e64a38SPhilippe Mathieu-Daudé             break;
127480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
127580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckev_d(cpu_env, twd, tws, twt);
127680e64a38SPhilippe Mathieu-Daudé             break;
127780e64a38SPhilippe Mathieu-Daudé         }
127880e64a38SPhilippe Mathieu-Daudé         break;
127980e64a38SPhilippe Mathieu-Daudé     case OPC_PCKOD_df:
128080e64a38SPhilippe Mathieu-Daudé         switch (df) {
128180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
128280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckod_b(cpu_env, twd, tws, twt);
128380e64a38SPhilippe Mathieu-Daudé             break;
128480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
128580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckod_h(cpu_env, twd, tws, twt);
128680e64a38SPhilippe Mathieu-Daudé             break;
128780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
128880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckod_w(cpu_env, twd, tws, twt);
128980e64a38SPhilippe Mathieu-Daudé             break;
129080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
129180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckod_d(cpu_env, twd, tws, twt);
129280e64a38SPhilippe Mathieu-Daudé             break;
129380e64a38SPhilippe Mathieu-Daudé         }
129480e64a38SPhilippe Mathieu-Daudé         break;
129580e64a38SPhilippe Mathieu-Daudé     case OPC_SLL_df:
129680e64a38SPhilippe Mathieu-Daudé         switch (df) {
129780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
129880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sll_b(cpu_env, twd, tws, twt);
129980e64a38SPhilippe Mathieu-Daudé             break;
130080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
130180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sll_h(cpu_env, twd, tws, twt);
130280e64a38SPhilippe Mathieu-Daudé             break;
130380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
130480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sll_w(cpu_env, twd, tws, twt);
130580e64a38SPhilippe Mathieu-Daudé             break;
130680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
130780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sll_d(cpu_env, twd, tws, twt);
130880e64a38SPhilippe Mathieu-Daudé             break;
130980e64a38SPhilippe Mathieu-Daudé         }
131080e64a38SPhilippe Mathieu-Daudé         break;
131180e64a38SPhilippe Mathieu-Daudé     case OPC_SRA_df:
131280e64a38SPhilippe Mathieu-Daudé         switch (df) {
131380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
131480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sra_b(cpu_env, twd, tws, twt);
131580e64a38SPhilippe Mathieu-Daudé             break;
131680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
131780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sra_h(cpu_env, twd, tws, twt);
131880e64a38SPhilippe Mathieu-Daudé             break;
131980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
132080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sra_w(cpu_env, twd, tws, twt);
132180e64a38SPhilippe Mathieu-Daudé             break;
132280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
132380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sra_d(cpu_env, twd, tws, twt);
132480e64a38SPhilippe Mathieu-Daudé             break;
132580e64a38SPhilippe Mathieu-Daudé         }
132680e64a38SPhilippe Mathieu-Daudé         break;
132780e64a38SPhilippe Mathieu-Daudé     case OPC_SRAR_df:
132880e64a38SPhilippe Mathieu-Daudé         switch (df) {
132980e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
133080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srar_b(cpu_env, twd, tws, twt);
133180e64a38SPhilippe Mathieu-Daudé             break;
133280e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
133380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srar_h(cpu_env, twd, tws, twt);
133480e64a38SPhilippe Mathieu-Daudé             break;
133580e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
133680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srar_w(cpu_env, twd, tws, twt);
133780e64a38SPhilippe Mathieu-Daudé             break;
133880e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
133980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srar_d(cpu_env, twd, tws, twt);
134080e64a38SPhilippe Mathieu-Daudé             break;
134180e64a38SPhilippe Mathieu-Daudé         }
134280e64a38SPhilippe Mathieu-Daudé         break;
134380e64a38SPhilippe Mathieu-Daudé     case OPC_SRL_df:
134480e64a38SPhilippe Mathieu-Daudé         switch (df) {
134580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
134680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srl_b(cpu_env, twd, tws, twt);
134780e64a38SPhilippe Mathieu-Daudé             break;
134880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
134980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srl_h(cpu_env, twd, tws, twt);
135080e64a38SPhilippe Mathieu-Daudé             break;
135180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
135280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srl_w(cpu_env, twd, tws, twt);
135380e64a38SPhilippe Mathieu-Daudé             break;
135480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
135580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srl_d(cpu_env, twd, tws, twt);
135680e64a38SPhilippe Mathieu-Daudé             break;
135780e64a38SPhilippe Mathieu-Daudé         }
135880e64a38SPhilippe Mathieu-Daudé         break;
135980e64a38SPhilippe Mathieu-Daudé     case OPC_SRLR_df:
136080e64a38SPhilippe Mathieu-Daudé         switch (df) {
136180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
136280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srlr_b(cpu_env, twd, tws, twt);
136380e64a38SPhilippe Mathieu-Daudé             break;
136480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
136580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srlr_h(cpu_env, twd, tws, twt);
136680e64a38SPhilippe Mathieu-Daudé             break;
136780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
136880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srlr_w(cpu_env, twd, tws, twt);
136980e64a38SPhilippe Mathieu-Daudé             break;
137080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
137180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srlr_d(cpu_env, twd, tws, twt);
137280e64a38SPhilippe Mathieu-Daudé             break;
137380e64a38SPhilippe Mathieu-Daudé         }
137480e64a38SPhilippe Mathieu-Daudé         break;
137580e64a38SPhilippe Mathieu-Daudé     case OPC_SUBS_S_df:
137680e64a38SPhilippe Mathieu-Daudé         switch (df) {
137780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
137880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_b(cpu_env, twd, tws, twt);
137980e64a38SPhilippe Mathieu-Daudé             break;
138080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
138180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_h(cpu_env, twd, tws, twt);
138280e64a38SPhilippe Mathieu-Daudé             break;
138380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
138480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_w(cpu_env, twd, tws, twt);
138580e64a38SPhilippe Mathieu-Daudé             break;
138680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
138780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_d(cpu_env, twd, tws, twt);
138880e64a38SPhilippe Mathieu-Daudé             break;
138980e64a38SPhilippe Mathieu-Daudé         }
139080e64a38SPhilippe Mathieu-Daudé         break;
139180e64a38SPhilippe Mathieu-Daudé     case OPC_MULV_df:
139280e64a38SPhilippe Mathieu-Daudé         switch (df) {
139380e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
139480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mulv_b(cpu_env, twd, tws, twt);
139580e64a38SPhilippe Mathieu-Daudé             break;
139680e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
139780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mulv_h(cpu_env, twd, tws, twt);
139880e64a38SPhilippe Mathieu-Daudé             break;
139980e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
140080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mulv_w(cpu_env, twd, tws, twt);
140180e64a38SPhilippe Mathieu-Daudé             break;
140280e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
140380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mulv_d(cpu_env, twd, tws, twt);
140480e64a38SPhilippe Mathieu-Daudé             break;
140580e64a38SPhilippe Mathieu-Daudé         }
140680e64a38SPhilippe Mathieu-Daudé         break;
140780e64a38SPhilippe Mathieu-Daudé     case OPC_SLD_df:
140880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_sld_df(cpu_env, tdf, twd, tws, twt);
140980e64a38SPhilippe Mathieu-Daudé         break;
141080e64a38SPhilippe Mathieu-Daudé     case OPC_VSHF_df:
141180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_vshf_df(cpu_env, tdf, twd, tws, twt);
141280e64a38SPhilippe Mathieu-Daudé         break;
141380e64a38SPhilippe Mathieu-Daudé     case OPC_SUBV_df:
141480e64a38SPhilippe Mathieu-Daudé         switch (df) {
141580e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
141680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subv_b(cpu_env, twd, tws, twt);
141780e64a38SPhilippe Mathieu-Daudé             break;
141880e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
141980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subv_h(cpu_env, twd, tws, twt);
142080e64a38SPhilippe Mathieu-Daudé             break;
142180e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
142280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subv_w(cpu_env, twd, tws, twt);
142380e64a38SPhilippe Mathieu-Daudé             break;
142480e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
142580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subv_d(cpu_env, twd, tws, twt);
142680e64a38SPhilippe Mathieu-Daudé             break;
142780e64a38SPhilippe Mathieu-Daudé         }
142880e64a38SPhilippe Mathieu-Daudé         break;
142980e64a38SPhilippe Mathieu-Daudé     case OPC_SUBS_U_df:
143080e64a38SPhilippe Mathieu-Daudé         switch (df) {
143180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
143280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_b(cpu_env, twd, tws, twt);
143380e64a38SPhilippe Mathieu-Daudé             break;
143480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
143580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_h(cpu_env, twd, tws, twt);
143680e64a38SPhilippe Mathieu-Daudé             break;
143780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
143880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_w(cpu_env, twd, tws, twt);
143980e64a38SPhilippe Mathieu-Daudé             break;
144080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
144180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_d(cpu_env, twd, tws, twt);
144280e64a38SPhilippe Mathieu-Daudé             break;
144380e64a38SPhilippe Mathieu-Daudé         }
144480e64a38SPhilippe Mathieu-Daudé         break;
144580e64a38SPhilippe Mathieu-Daudé     case OPC_SPLAT_df:
144680e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_splat_df(cpu_env, tdf, twd, tws, twt);
144780e64a38SPhilippe Mathieu-Daudé         break;
144880e64a38SPhilippe Mathieu-Daudé     case OPC_SUBSUS_U_df:
144980e64a38SPhilippe Mathieu-Daudé         switch (df) {
145080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
145180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_b(cpu_env, twd, tws, twt);
145280e64a38SPhilippe Mathieu-Daudé             break;
145380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
145480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_h(cpu_env, twd, tws, twt);
145580e64a38SPhilippe Mathieu-Daudé             break;
145680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
145780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_w(cpu_env, twd, tws, twt);
145880e64a38SPhilippe Mathieu-Daudé             break;
145980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
146080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_d(cpu_env, twd, tws, twt);
146180e64a38SPhilippe Mathieu-Daudé             break;
146280e64a38SPhilippe Mathieu-Daudé         }
146380e64a38SPhilippe Mathieu-Daudé         break;
146480e64a38SPhilippe Mathieu-Daudé     case OPC_SUBSUU_S_df:
146580e64a38SPhilippe Mathieu-Daudé         switch (df) {
146680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
146780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_b(cpu_env, twd, tws, twt);
146880e64a38SPhilippe Mathieu-Daudé             break;
146980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
147080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_h(cpu_env, twd, tws, twt);
147180e64a38SPhilippe Mathieu-Daudé             break;
147280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
147380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_w(cpu_env, twd, tws, twt);
147480e64a38SPhilippe Mathieu-Daudé             break;
147580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
147680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_d(cpu_env, twd, tws, twt);
147780e64a38SPhilippe Mathieu-Daudé             break;
147880e64a38SPhilippe Mathieu-Daudé         }
147980e64a38SPhilippe Mathieu-Daudé         break;
148080e64a38SPhilippe Mathieu-Daudé 
148180e64a38SPhilippe Mathieu-Daudé     case OPC_DOTP_S_df:
148280e64a38SPhilippe Mathieu-Daudé     case OPC_DOTP_U_df:
148380e64a38SPhilippe Mathieu-Daudé     case OPC_DPADD_S_df:
148480e64a38SPhilippe Mathieu-Daudé     case OPC_DPADD_U_df:
148580e64a38SPhilippe Mathieu-Daudé     case OPC_DPSUB_S_df:
148680e64a38SPhilippe Mathieu-Daudé     case OPC_HADD_S_df:
148780e64a38SPhilippe Mathieu-Daudé     case OPC_DPSUB_U_df:
148880e64a38SPhilippe Mathieu-Daudé     case OPC_HADD_U_df:
148980e64a38SPhilippe Mathieu-Daudé     case OPC_HSUB_S_df:
149080e64a38SPhilippe Mathieu-Daudé     case OPC_HSUB_U_df:
149180e64a38SPhilippe Mathieu-Daudé         if (df == DF_BYTE) {
149280e64a38SPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
149380e64a38SPhilippe Mathieu-Daudé             break;
149480e64a38SPhilippe Mathieu-Daudé         }
149580e64a38SPhilippe Mathieu-Daudé         switch (MASK_MSA_3R(ctx->opcode)) {
149680e64a38SPhilippe Mathieu-Daudé         case OPC_HADD_S_df:
149780e64a38SPhilippe Mathieu-Daudé             switch (df) {
149880e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
149980e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_s_h(cpu_env, twd, tws, twt);
150080e64a38SPhilippe Mathieu-Daudé                 break;
150180e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
150280e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_s_w(cpu_env, twd, tws, twt);
150380e64a38SPhilippe Mathieu-Daudé                 break;
150480e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
150580e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_s_d(cpu_env, twd, tws, twt);
150680e64a38SPhilippe Mathieu-Daudé                 break;
150780e64a38SPhilippe Mathieu-Daudé             }
150880e64a38SPhilippe Mathieu-Daudé             break;
150980e64a38SPhilippe Mathieu-Daudé         case OPC_HADD_U_df:
151080e64a38SPhilippe Mathieu-Daudé             switch (df) {
151180e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
151280e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_u_h(cpu_env, twd, tws, twt);
151380e64a38SPhilippe Mathieu-Daudé                 break;
151480e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
151580e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_u_w(cpu_env, twd, tws, twt);
151680e64a38SPhilippe Mathieu-Daudé                 break;
151780e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
151880e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_u_d(cpu_env, twd, tws, twt);
151980e64a38SPhilippe Mathieu-Daudé                 break;
152080e64a38SPhilippe Mathieu-Daudé             }
152180e64a38SPhilippe Mathieu-Daudé             break;
152280e64a38SPhilippe Mathieu-Daudé         case OPC_HSUB_S_df:
152380e64a38SPhilippe Mathieu-Daudé             switch (df) {
152480e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
152580e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_s_h(cpu_env, twd, tws, twt);
152680e64a38SPhilippe Mathieu-Daudé                 break;
152780e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
152880e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_s_w(cpu_env, twd, tws, twt);
152980e64a38SPhilippe Mathieu-Daudé                 break;
153080e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
153180e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_s_d(cpu_env, twd, tws, twt);
153280e64a38SPhilippe Mathieu-Daudé                 break;
153380e64a38SPhilippe Mathieu-Daudé             }
153480e64a38SPhilippe Mathieu-Daudé             break;
153580e64a38SPhilippe Mathieu-Daudé         case OPC_HSUB_U_df:
153680e64a38SPhilippe Mathieu-Daudé             switch (df) {
153780e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
153880e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_u_h(cpu_env, twd, tws, twt);
153980e64a38SPhilippe Mathieu-Daudé                 break;
154080e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
154180e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_u_w(cpu_env, twd, tws, twt);
154280e64a38SPhilippe Mathieu-Daudé                 break;
154380e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
154480e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_u_d(cpu_env, twd, tws, twt);
154580e64a38SPhilippe Mathieu-Daudé                 break;
154680e64a38SPhilippe Mathieu-Daudé             }
154780e64a38SPhilippe Mathieu-Daudé             break;
154880e64a38SPhilippe Mathieu-Daudé         case OPC_DOTP_S_df:
154980e64a38SPhilippe Mathieu-Daudé             switch (df) {
155080e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
155180e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_s_h(cpu_env, twd, tws, twt);
155280e64a38SPhilippe Mathieu-Daudé                 break;
155380e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
155480e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_s_w(cpu_env, twd, tws, twt);
155580e64a38SPhilippe Mathieu-Daudé                 break;
155680e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
155780e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_s_d(cpu_env, twd, tws, twt);
155880e64a38SPhilippe Mathieu-Daudé                 break;
155980e64a38SPhilippe Mathieu-Daudé             }
156080e64a38SPhilippe Mathieu-Daudé             break;
156180e64a38SPhilippe Mathieu-Daudé         case OPC_DOTP_U_df:
156280e64a38SPhilippe Mathieu-Daudé             switch (df) {
156380e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
156480e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_u_h(cpu_env, twd, tws, twt);
156580e64a38SPhilippe Mathieu-Daudé                 break;
156680e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
156780e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_u_w(cpu_env, twd, tws, twt);
156880e64a38SPhilippe Mathieu-Daudé                 break;
156980e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
157080e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_u_d(cpu_env, twd, tws, twt);
157180e64a38SPhilippe Mathieu-Daudé                 break;
157280e64a38SPhilippe Mathieu-Daudé             }
157380e64a38SPhilippe Mathieu-Daudé             break;
157480e64a38SPhilippe Mathieu-Daudé         case OPC_DPADD_S_df:
157580e64a38SPhilippe Mathieu-Daudé             switch (df) {
157680e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
157780e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_s_h(cpu_env, twd, tws, twt);
157880e64a38SPhilippe Mathieu-Daudé                 break;
157980e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
158080e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_s_w(cpu_env, twd, tws, twt);
158180e64a38SPhilippe Mathieu-Daudé                 break;
158280e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
158380e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_s_d(cpu_env, twd, tws, twt);
158480e64a38SPhilippe Mathieu-Daudé                 break;
158580e64a38SPhilippe Mathieu-Daudé             }
158680e64a38SPhilippe Mathieu-Daudé             break;
158780e64a38SPhilippe Mathieu-Daudé         case OPC_DPADD_U_df:
158880e64a38SPhilippe Mathieu-Daudé             switch (df) {
158980e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
159080e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_u_h(cpu_env, twd, tws, twt);
159180e64a38SPhilippe Mathieu-Daudé                 break;
159280e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
159380e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_u_w(cpu_env, twd, tws, twt);
159480e64a38SPhilippe Mathieu-Daudé                 break;
159580e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
159680e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_u_d(cpu_env, twd, tws, twt);
159780e64a38SPhilippe Mathieu-Daudé                 break;
159880e64a38SPhilippe Mathieu-Daudé             }
159980e64a38SPhilippe Mathieu-Daudé             break;
160080e64a38SPhilippe Mathieu-Daudé         case OPC_DPSUB_S_df:
160180e64a38SPhilippe Mathieu-Daudé             switch (df) {
160280e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
160380e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_s_h(cpu_env, twd, tws, twt);
160480e64a38SPhilippe Mathieu-Daudé                 break;
160580e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
160680e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_s_w(cpu_env, twd, tws, twt);
160780e64a38SPhilippe Mathieu-Daudé                 break;
160880e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
160980e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_s_d(cpu_env, twd, tws, twt);
161080e64a38SPhilippe Mathieu-Daudé                 break;
161180e64a38SPhilippe Mathieu-Daudé             }
161280e64a38SPhilippe Mathieu-Daudé             break;
161380e64a38SPhilippe Mathieu-Daudé         case OPC_DPSUB_U_df:
161480e64a38SPhilippe Mathieu-Daudé             switch (df) {
161580e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
161680e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_u_h(cpu_env, twd, tws, twt);
161780e64a38SPhilippe Mathieu-Daudé                 break;
161880e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
161980e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_u_w(cpu_env, twd, tws, twt);
162080e64a38SPhilippe Mathieu-Daudé                 break;
162180e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
162280e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_u_d(cpu_env, twd, tws, twt);
162380e64a38SPhilippe Mathieu-Daudé                 break;
162480e64a38SPhilippe Mathieu-Daudé             }
162580e64a38SPhilippe Mathieu-Daudé             break;
162680e64a38SPhilippe Mathieu-Daudé         }
162780e64a38SPhilippe Mathieu-Daudé         break;
162880e64a38SPhilippe Mathieu-Daudé     default:
162980e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
163080e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
163180e64a38SPhilippe Mathieu-Daudé         break;
163280e64a38SPhilippe Mathieu-Daudé     }
163380e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
163480e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
163580e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
163680e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
163780e64a38SPhilippe Mathieu-Daudé }
163880e64a38SPhilippe Mathieu-Daudé 
163980e64a38SPhilippe Mathieu-Daudé static void gen_msa_elm_3e(DisasContext *ctx)
164080e64a38SPhilippe Mathieu-Daudé {
164180e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_ELM_DF3E(op)   (MASK_MSA_MINOR(op) | (op & (0x3FF << 16)))
164280e64a38SPhilippe Mathieu-Daudé     uint8_t source = (ctx->opcode >> 11) & 0x1f;
164380e64a38SPhilippe Mathieu-Daudé     uint8_t dest = (ctx->opcode >> 6) & 0x1f;
164480e64a38SPhilippe Mathieu-Daudé     TCGv telm = tcg_temp_new();
164580e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tsr = tcg_const_i32(source);
164680e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdt = tcg_const_i32(dest);
164780e64a38SPhilippe Mathieu-Daudé 
164880e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_ELM_DF3E(ctx->opcode)) {
164980e64a38SPhilippe Mathieu-Daudé     case OPC_CTCMSA:
165080e64a38SPhilippe Mathieu-Daudé         gen_load_gpr(telm, source);
165180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ctcmsa(cpu_env, telm, tdt);
165280e64a38SPhilippe Mathieu-Daudé         break;
165380e64a38SPhilippe Mathieu-Daudé     case OPC_CFCMSA:
165480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_cfcmsa(telm, cpu_env, tsr);
165580e64a38SPhilippe Mathieu-Daudé         gen_store_gpr(telm, dest);
165680e64a38SPhilippe Mathieu-Daudé         break;
165780e64a38SPhilippe Mathieu-Daudé     case OPC_MOVE_V:
165880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_move_v(cpu_env, tdt, tsr);
165980e64a38SPhilippe Mathieu-Daudé         break;
166080e64a38SPhilippe Mathieu-Daudé     default:
166180e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
166280e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
166380e64a38SPhilippe Mathieu-Daudé         break;
166480e64a38SPhilippe Mathieu-Daudé     }
166580e64a38SPhilippe Mathieu-Daudé 
166680e64a38SPhilippe Mathieu-Daudé     tcg_temp_free(telm);
166780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdt);
166880e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tsr);
166980e64a38SPhilippe Mathieu-Daudé }
167080e64a38SPhilippe Mathieu-Daudé 
167180e64a38SPhilippe Mathieu-Daudé static void gen_msa_elm_df(DisasContext *ctx, uint32_t df, uint32_t n)
167280e64a38SPhilippe Mathieu-Daudé {
167380e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_ELM(op)    (MASK_MSA_MINOR(op) | (op & (0xf << 22)))
167480e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
167580e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
167680e64a38SPhilippe Mathieu-Daudé 
167780e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
167880e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
167980e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tn  = tcg_const_i32(n);
168080e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df);
168180e64a38SPhilippe Mathieu-Daudé 
168280e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_ELM(ctx->opcode)) {
168380e64a38SPhilippe Mathieu-Daudé     case OPC_SLDI_df:
168480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_sldi_df(cpu_env, tdf, twd, tws, tn);
168580e64a38SPhilippe Mathieu-Daudé         break;
168680e64a38SPhilippe Mathieu-Daudé     case OPC_SPLATI_df:
168780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_splati_df(cpu_env, tdf, twd, tws, tn);
168880e64a38SPhilippe Mathieu-Daudé         break;
168980e64a38SPhilippe Mathieu-Daudé     case OPC_INSVE_df:
169080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_insve_df(cpu_env, tdf, twd, tws, tn);
169180e64a38SPhilippe Mathieu-Daudé         break;
169280e64a38SPhilippe Mathieu-Daudé     case OPC_COPY_S_df:
169380e64a38SPhilippe Mathieu-Daudé     case OPC_COPY_U_df:
169480e64a38SPhilippe Mathieu-Daudé     case OPC_INSERT_df:
169580e64a38SPhilippe Mathieu-Daudé #if !defined(TARGET_MIPS64)
169680e64a38SPhilippe Mathieu-Daudé         /* Double format valid only for MIPS64 */
169780e64a38SPhilippe Mathieu-Daudé         if (df == DF_DOUBLE) {
169880e64a38SPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
169980e64a38SPhilippe Mathieu-Daudé             break;
170080e64a38SPhilippe Mathieu-Daudé         }
170180e64a38SPhilippe Mathieu-Daudé         if ((MASK_MSA_ELM(ctx->opcode) == OPC_COPY_U_df) &&
170280e64a38SPhilippe Mathieu-Daudé               (df == DF_WORD)) {
170380e64a38SPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
170480e64a38SPhilippe Mathieu-Daudé             break;
170580e64a38SPhilippe Mathieu-Daudé         }
170680e64a38SPhilippe Mathieu-Daudé #endif
170780e64a38SPhilippe Mathieu-Daudé         switch (MASK_MSA_ELM(ctx->opcode)) {
170880e64a38SPhilippe Mathieu-Daudé         case OPC_COPY_S_df:
170980e64a38SPhilippe Mathieu-Daudé             if (likely(wd != 0)) {
171080e64a38SPhilippe Mathieu-Daudé                 switch (df) {
171180e64a38SPhilippe Mathieu-Daudé                 case DF_BYTE:
171280e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_b(cpu_env, twd, tws, tn);
171380e64a38SPhilippe Mathieu-Daudé                     break;
171480e64a38SPhilippe Mathieu-Daudé                 case DF_HALF:
171580e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_h(cpu_env, twd, tws, tn);
171680e64a38SPhilippe Mathieu-Daudé                     break;
171780e64a38SPhilippe Mathieu-Daudé                 case DF_WORD:
171880e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_w(cpu_env, twd, tws, tn);
171980e64a38SPhilippe Mathieu-Daudé                     break;
172080e64a38SPhilippe Mathieu-Daudé #if defined(TARGET_MIPS64)
172180e64a38SPhilippe Mathieu-Daudé                 case DF_DOUBLE:
172280e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_d(cpu_env, twd, tws, tn);
172380e64a38SPhilippe Mathieu-Daudé                     break;
172480e64a38SPhilippe Mathieu-Daudé #endif
172580e64a38SPhilippe Mathieu-Daudé                 default:
172680e64a38SPhilippe Mathieu-Daudé                     assert(0);
172780e64a38SPhilippe Mathieu-Daudé                 }
172880e64a38SPhilippe Mathieu-Daudé             }
172980e64a38SPhilippe Mathieu-Daudé             break;
173080e64a38SPhilippe Mathieu-Daudé         case OPC_COPY_U_df:
173180e64a38SPhilippe Mathieu-Daudé             if (likely(wd != 0)) {
173280e64a38SPhilippe Mathieu-Daudé                 switch (df) {
173380e64a38SPhilippe Mathieu-Daudé                 case DF_BYTE:
173480e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_u_b(cpu_env, twd, tws, tn);
173580e64a38SPhilippe Mathieu-Daudé                     break;
173680e64a38SPhilippe Mathieu-Daudé                 case DF_HALF:
173780e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_u_h(cpu_env, twd, tws, tn);
173880e64a38SPhilippe Mathieu-Daudé                     break;
173980e64a38SPhilippe Mathieu-Daudé #if defined(TARGET_MIPS64)
174080e64a38SPhilippe Mathieu-Daudé                 case DF_WORD:
174180e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_u_w(cpu_env, twd, tws, tn);
174280e64a38SPhilippe Mathieu-Daudé                     break;
174380e64a38SPhilippe Mathieu-Daudé #endif
174480e64a38SPhilippe Mathieu-Daudé                 default:
174580e64a38SPhilippe Mathieu-Daudé                     assert(0);
174680e64a38SPhilippe Mathieu-Daudé                 }
174780e64a38SPhilippe Mathieu-Daudé             }
174880e64a38SPhilippe Mathieu-Daudé             break;
174980e64a38SPhilippe Mathieu-Daudé         case OPC_INSERT_df:
175080e64a38SPhilippe Mathieu-Daudé             switch (df) {
175180e64a38SPhilippe Mathieu-Daudé             case DF_BYTE:
175280e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_insert_b(cpu_env, twd, tws, tn);
175380e64a38SPhilippe Mathieu-Daudé                 break;
175480e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
175580e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_insert_h(cpu_env, twd, tws, tn);
175680e64a38SPhilippe Mathieu-Daudé                 break;
175780e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
175880e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_insert_w(cpu_env, twd, tws, tn);
175980e64a38SPhilippe Mathieu-Daudé                 break;
176080e64a38SPhilippe Mathieu-Daudé #if defined(TARGET_MIPS64)
176180e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
176280e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_insert_d(cpu_env, twd, tws, tn);
176380e64a38SPhilippe Mathieu-Daudé                 break;
176480e64a38SPhilippe Mathieu-Daudé #endif
176580e64a38SPhilippe Mathieu-Daudé             default:
176680e64a38SPhilippe Mathieu-Daudé                 assert(0);
176780e64a38SPhilippe Mathieu-Daudé             }
176880e64a38SPhilippe Mathieu-Daudé             break;
176980e64a38SPhilippe Mathieu-Daudé         }
177080e64a38SPhilippe Mathieu-Daudé         break;
177180e64a38SPhilippe Mathieu-Daudé     default:
177280e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
177380e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
177480e64a38SPhilippe Mathieu-Daudé     }
177580e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
177680e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
177780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tn);
177880e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
177980e64a38SPhilippe Mathieu-Daudé }
178080e64a38SPhilippe Mathieu-Daudé 
178180e64a38SPhilippe Mathieu-Daudé static void gen_msa_elm(DisasContext *ctx)
178280e64a38SPhilippe Mathieu-Daudé {
178380e64a38SPhilippe Mathieu-Daudé     uint8_t dfn = (ctx->opcode >> 16) & 0x3f;
178480e64a38SPhilippe Mathieu-Daudé     uint32_t df = 0, n = 0;
178580e64a38SPhilippe Mathieu-Daudé 
178680e64a38SPhilippe Mathieu-Daudé     if ((dfn & 0x30) == 0x00) {
178780e64a38SPhilippe Mathieu-Daudé         n = dfn & 0x0f;
178880e64a38SPhilippe Mathieu-Daudé         df = DF_BYTE;
178980e64a38SPhilippe Mathieu-Daudé     } else if ((dfn & 0x38) == 0x20) {
179080e64a38SPhilippe Mathieu-Daudé         n = dfn & 0x07;
179180e64a38SPhilippe Mathieu-Daudé         df = DF_HALF;
179280e64a38SPhilippe Mathieu-Daudé     } else if ((dfn & 0x3c) == 0x30) {
179380e64a38SPhilippe Mathieu-Daudé         n = dfn & 0x03;
179480e64a38SPhilippe Mathieu-Daudé         df = DF_WORD;
179580e64a38SPhilippe Mathieu-Daudé     } else if ((dfn & 0x3e) == 0x38) {
179680e64a38SPhilippe Mathieu-Daudé         n = dfn & 0x01;
179780e64a38SPhilippe Mathieu-Daudé         df = DF_DOUBLE;
179880e64a38SPhilippe Mathieu-Daudé     } else if (dfn == 0x3E) {
179980e64a38SPhilippe Mathieu-Daudé         /* CTCMSA, CFCMSA, MOVE.V */
180080e64a38SPhilippe Mathieu-Daudé         gen_msa_elm_3e(ctx);
180180e64a38SPhilippe Mathieu-Daudé         return;
180280e64a38SPhilippe Mathieu-Daudé     } else {
180380e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
180480e64a38SPhilippe Mathieu-Daudé         return;
180580e64a38SPhilippe Mathieu-Daudé     }
180680e64a38SPhilippe Mathieu-Daudé 
180780e64a38SPhilippe Mathieu-Daudé     gen_msa_elm_df(ctx, df, n);
180880e64a38SPhilippe Mathieu-Daudé }
180980e64a38SPhilippe Mathieu-Daudé 
181080e64a38SPhilippe Mathieu-Daudé static void gen_msa_3rf(DisasContext *ctx)
181180e64a38SPhilippe Mathieu-Daudé {
181280e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_3RF(op)    (MASK_MSA_MINOR(op) | (op & (0xf << 22)))
181380e64a38SPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 21) & 0x1;
181480e64a38SPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
181580e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
181680e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
181780e64a38SPhilippe Mathieu-Daudé 
181880e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
181980e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
182080e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
182180e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_temp_new_i32();
182280e64a38SPhilippe Mathieu-Daudé 
182380e64a38SPhilippe Mathieu-Daudé     /* adjust df value for floating-point instruction */
182480e64a38SPhilippe Mathieu-Daudé     tcg_gen_movi_i32(tdf, df + 2);
182580e64a38SPhilippe Mathieu-Daudé 
182680e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_3RF(ctx->opcode)) {
182780e64a38SPhilippe Mathieu-Daudé     case OPC_FCAF_df:
182880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fcaf_df(cpu_env, tdf, twd, tws, twt);
182980e64a38SPhilippe Mathieu-Daudé         break;
183080e64a38SPhilippe Mathieu-Daudé     case OPC_FADD_df:
183180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fadd_df(cpu_env, tdf, twd, tws, twt);
183280e64a38SPhilippe Mathieu-Daudé         break;
183380e64a38SPhilippe Mathieu-Daudé     case OPC_FCUN_df:
183480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fcun_df(cpu_env, tdf, twd, tws, twt);
183580e64a38SPhilippe Mathieu-Daudé         break;
183680e64a38SPhilippe Mathieu-Daudé     case OPC_FSUB_df:
183780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsub_df(cpu_env, tdf, twd, tws, twt);
183880e64a38SPhilippe Mathieu-Daudé         break;
183980e64a38SPhilippe Mathieu-Daudé     case OPC_FCOR_df:
184080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fcor_df(cpu_env, tdf, twd, tws, twt);
184180e64a38SPhilippe Mathieu-Daudé         break;
184280e64a38SPhilippe Mathieu-Daudé     case OPC_FCEQ_df:
184380e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fceq_df(cpu_env, tdf, twd, tws, twt);
184480e64a38SPhilippe Mathieu-Daudé         break;
184580e64a38SPhilippe Mathieu-Daudé     case OPC_FMUL_df:
184680e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fmul_df(cpu_env, tdf, twd, tws, twt);
184780e64a38SPhilippe Mathieu-Daudé         break;
184880e64a38SPhilippe Mathieu-Daudé     case OPC_FCUNE_df:
184980e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fcune_df(cpu_env, tdf, twd, tws, twt);
185080e64a38SPhilippe Mathieu-Daudé         break;
185180e64a38SPhilippe Mathieu-Daudé     case OPC_FCUEQ_df:
185280e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fcueq_df(cpu_env, tdf, twd, tws, twt);
185380e64a38SPhilippe Mathieu-Daudé         break;
185480e64a38SPhilippe Mathieu-Daudé     case OPC_FDIV_df:
185580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fdiv_df(cpu_env, tdf, twd, tws, twt);
185680e64a38SPhilippe Mathieu-Daudé         break;
185780e64a38SPhilippe Mathieu-Daudé     case OPC_FCNE_df:
185880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fcne_df(cpu_env, tdf, twd, tws, twt);
185980e64a38SPhilippe Mathieu-Daudé         break;
186080e64a38SPhilippe Mathieu-Daudé     case OPC_FCLT_df:
186180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fclt_df(cpu_env, tdf, twd, tws, twt);
186280e64a38SPhilippe Mathieu-Daudé         break;
186380e64a38SPhilippe Mathieu-Daudé     case OPC_FMADD_df:
186480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fmadd_df(cpu_env, tdf, twd, tws, twt);
186580e64a38SPhilippe Mathieu-Daudé         break;
186680e64a38SPhilippe Mathieu-Daudé     case OPC_MUL_Q_df:
186780e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
186880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_mul_q_df(cpu_env, tdf, twd, tws, twt);
186980e64a38SPhilippe Mathieu-Daudé         break;
187080e64a38SPhilippe Mathieu-Daudé     case OPC_FCULT_df:
187180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fcult_df(cpu_env, tdf, twd, tws, twt);
187280e64a38SPhilippe Mathieu-Daudé         break;
187380e64a38SPhilippe Mathieu-Daudé     case OPC_FMSUB_df:
187480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fmsub_df(cpu_env, tdf, twd, tws, twt);
187580e64a38SPhilippe Mathieu-Daudé         break;
187680e64a38SPhilippe Mathieu-Daudé     case OPC_MADD_Q_df:
187780e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
187880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_madd_q_df(cpu_env, tdf, twd, tws, twt);
187980e64a38SPhilippe Mathieu-Daudé         break;
188080e64a38SPhilippe Mathieu-Daudé     case OPC_FCLE_df:
188180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fcle_df(cpu_env, tdf, twd, tws, twt);
188280e64a38SPhilippe Mathieu-Daudé         break;
188380e64a38SPhilippe Mathieu-Daudé     case OPC_MSUB_Q_df:
188480e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
188580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_msub_q_df(cpu_env, tdf, twd, tws, twt);
188680e64a38SPhilippe Mathieu-Daudé         break;
188780e64a38SPhilippe Mathieu-Daudé     case OPC_FCULE_df:
188880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fcule_df(cpu_env, tdf, twd, tws, twt);
188980e64a38SPhilippe Mathieu-Daudé         break;
189080e64a38SPhilippe Mathieu-Daudé     case OPC_FEXP2_df:
189180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fexp2_df(cpu_env, tdf, twd, tws, twt);
189280e64a38SPhilippe Mathieu-Daudé         break;
189380e64a38SPhilippe Mathieu-Daudé     case OPC_FSAF_df:
189480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsaf_df(cpu_env, tdf, twd, tws, twt);
189580e64a38SPhilippe Mathieu-Daudé         break;
189680e64a38SPhilippe Mathieu-Daudé     case OPC_FEXDO_df:
189780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fexdo_df(cpu_env, tdf, twd, tws, twt);
189880e64a38SPhilippe Mathieu-Daudé         break;
189980e64a38SPhilippe Mathieu-Daudé     case OPC_FSUN_df:
190080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsun_df(cpu_env, tdf, twd, tws, twt);
190180e64a38SPhilippe Mathieu-Daudé         break;
190280e64a38SPhilippe Mathieu-Daudé     case OPC_FSOR_df:
190380e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsor_df(cpu_env, tdf, twd, tws, twt);
190480e64a38SPhilippe Mathieu-Daudé         break;
190580e64a38SPhilippe Mathieu-Daudé     case OPC_FSEQ_df:
190680e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fseq_df(cpu_env, tdf, twd, tws, twt);
190780e64a38SPhilippe Mathieu-Daudé         break;
190880e64a38SPhilippe Mathieu-Daudé     case OPC_FTQ_df:
190980e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ftq_df(cpu_env, tdf, twd, tws, twt);
191080e64a38SPhilippe Mathieu-Daudé         break;
191180e64a38SPhilippe Mathieu-Daudé     case OPC_FSUNE_df:
191280e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsune_df(cpu_env, tdf, twd, tws, twt);
191380e64a38SPhilippe Mathieu-Daudé         break;
191480e64a38SPhilippe Mathieu-Daudé     case OPC_FSUEQ_df:
191580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsueq_df(cpu_env, tdf, twd, tws, twt);
191680e64a38SPhilippe Mathieu-Daudé         break;
191780e64a38SPhilippe Mathieu-Daudé     case OPC_FSNE_df:
191880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsne_df(cpu_env, tdf, twd, tws, twt);
191980e64a38SPhilippe Mathieu-Daudé         break;
192080e64a38SPhilippe Mathieu-Daudé     case OPC_FSLT_df:
192180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fslt_df(cpu_env, tdf, twd, tws, twt);
192280e64a38SPhilippe Mathieu-Daudé         break;
192380e64a38SPhilippe Mathieu-Daudé     case OPC_FMIN_df:
192480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fmin_df(cpu_env, tdf, twd, tws, twt);
192580e64a38SPhilippe Mathieu-Daudé         break;
192680e64a38SPhilippe Mathieu-Daudé     case OPC_MULR_Q_df:
192780e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
192880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_mulr_q_df(cpu_env, tdf, twd, tws, twt);
192980e64a38SPhilippe Mathieu-Daudé         break;
193080e64a38SPhilippe Mathieu-Daudé     case OPC_FSULT_df:
193180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsult_df(cpu_env, tdf, twd, tws, twt);
193280e64a38SPhilippe Mathieu-Daudé         break;
193380e64a38SPhilippe Mathieu-Daudé     case OPC_FMIN_A_df:
193480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fmin_a_df(cpu_env, tdf, twd, tws, twt);
193580e64a38SPhilippe Mathieu-Daudé         break;
193680e64a38SPhilippe Mathieu-Daudé     case OPC_MADDR_Q_df:
193780e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
193880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_maddr_q_df(cpu_env, tdf, twd, tws, twt);
193980e64a38SPhilippe Mathieu-Daudé         break;
194080e64a38SPhilippe Mathieu-Daudé     case OPC_FSLE_df:
194180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsle_df(cpu_env, tdf, twd, tws, twt);
194280e64a38SPhilippe Mathieu-Daudé         break;
194380e64a38SPhilippe Mathieu-Daudé     case OPC_FMAX_df:
194480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fmax_df(cpu_env, tdf, twd, tws, twt);
194580e64a38SPhilippe Mathieu-Daudé         break;
194680e64a38SPhilippe Mathieu-Daudé     case OPC_MSUBR_Q_df:
194780e64a38SPhilippe Mathieu-Daudé         tcg_gen_movi_i32(tdf, df + 1);
194880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_msubr_q_df(cpu_env, tdf, twd, tws, twt);
194980e64a38SPhilippe Mathieu-Daudé         break;
195080e64a38SPhilippe Mathieu-Daudé     case OPC_FSULE_df:
195180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsule_df(cpu_env, tdf, twd, tws, twt);
195280e64a38SPhilippe Mathieu-Daudé         break;
195380e64a38SPhilippe Mathieu-Daudé     case OPC_FMAX_A_df:
195480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fmax_a_df(cpu_env, tdf, twd, tws, twt);
195580e64a38SPhilippe Mathieu-Daudé         break;
195680e64a38SPhilippe Mathieu-Daudé     default:
195780e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
195880e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
195980e64a38SPhilippe Mathieu-Daudé         break;
196080e64a38SPhilippe Mathieu-Daudé     }
196180e64a38SPhilippe Mathieu-Daudé 
196280e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
196380e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
196480e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
196580e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
196680e64a38SPhilippe Mathieu-Daudé }
196780e64a38SPhilippe Mathieu-Daudé 
196880e64a38SPhilippe Mathieu-Daudé static void gen_msa_2r(DisasContext *ctx)
196980e64a38SPhilippe Mathieu-Daudé {
197080e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_2R(op)     (MASK_MSA_MINOR(op) | (op & (0x1f << 21)) | \
197180e64a38SPhilippe Mathieu-Daudé                             (op & (0x7 << 18)))
197280e64a38SPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
197380e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
197480e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
197580e64a38SPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 16) & 0x3;
197680e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
197780e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
197880e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
197980e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df);
198080e64a38SPhilippe Mathieu-Daudé 
198180e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_2R(ctx->opcode)) {
198280e64a38SPhilippe Mathieu-Daudé     case OPC_FILL_df:
198380e64a38SPhilippe Mathieu-Daudé #if !defined(TARGET_MIPS64)
198480e64a38SPhilippe Mathieu-Daudé         /* Double format valid only for MIPS64 */
198580e64a38SPhilippe Mathieu-Daudé         if (df == DF_DOUBLE) {
198680e64a38SPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
198780e64a38SPhilippe Mathieu-Daudé             break;
198880e64a38SPhilippe Mathieu-Daudé         }
198980e64a38SPhilippe Mathieu-Daudé #endif
199080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fill_df(cpu_env, tdf, twd, tws); /* trs */
199180e64a38SPhilippe Mathieu-Daudé         break;
199280e64a38SPhilippe Mathieu-Daudé     case OPC_NLOC_df:
199380e64a38SPhilippe Mathieu-Daudé         switch (df) {
199480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
199580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_nloc_b(cpu_env, twd, tws);
199680e64a38SPhilippe Mathieu-Daudé             break;
199780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
199880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_nloc_h(cpu_env, twd, tws);
199980e64a38SPhilippe Mathieu-Daudé             break;
200080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
200180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_nloc_w(cpu_env, twd, tws);
200280e64a38SPhilippe Mathieu-Daudé             break;
200380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
200480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_nloc_d(cpu_env, twd, tws);
200580e64a38SPhilippe Mathieu-Daudé             break;
200680e64a38SPhilippe Mathieu-Daudé         }
200780e64a38SPhilippe Mathieu-Daudé         break;
200880e64a38SPhilippe Mathieu-Daudé     case OPC_NLZC_df:
200980e64a38SPhilippe Mathieu-Daudé         switch (df) {
201080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
201180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_nlzc_b(cpu_env, twd, tws);
201280e64a38SPhilippe Mathieu-Daudé             break;
201380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
201480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_nlzc_h(cpu_env, twd, tws);
201580e64a38SPhilippe Mathieu-Daudé             break;
201680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
201780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_nlzc_w(cpu_env, twd, tws);
201880e64a38SPhilippe Mathieu-Daudé             break;
201980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
202080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_nlzc_d(cpu_env, twd, tws);
202180e64a38SPhilippe Mathieu-Daudé             break;
202280e64a38SPhilippe Mathieu-Daudé         }
202380e64a38SPhilippe Mathieu-Daudé         break;
202480e64a38SPhilippe Mathieu-Daudé     case OPC_PCNT_df:
202580e64a38SPhilippe Mathieu-Daudé         switch (df) {
202680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
202780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pcnt_b(cpu_env, twd, tws);
202880e64a38SPhilippe Mathieu-Daudé             break;
202980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
203080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pcnt_h(cpu_env, twd, tws);
203180e64a38SPhilippe Mathieu-Daudé             break;
203280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
203380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pcnt_w(cpu_env, twd, tws);
203480e64a38SPhilippe Mathieu-Daudé             break;
203580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
203680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pcnt_d(cpu_env, twd, tws);
203780e64a38SPhilippe Mathieu-Daudé             break;
203880e64a38SPhilippe Mathieu-Daudé         }
203980e64a38SPhilippe Mathieu-Daudé         break;
204080e64a38SPhilippe Mathieu-Daudé     default:
204180e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
204280e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
204380e64a38SPhilippe Mathieu-Daudé         break;
204480e64a38SPhilippe Mathieu-Daudé     }
204580e64a38SPhilippe Mathieu-Daudé 
204680e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
204780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
204880e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
204980e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
205080e64a38SPhilippe Mathieu-Daudé }
205180e64a38SPhilippe Mathieu-Daudé 
205280e64a38SPhilippe Mathieu-Daudé static void gen_msa_2rf(DisasContext *ctx)
205380e64a38SPhilippe Mathieu-Daudé {
205480e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_2RF(op)    (MASK_MSA_MINOR(op) | (op & (0x1f << 21)) | \
205580e64a38SPhilippe Mathieu-Daudé                             (op & (0xf << 17)))
205680e64a38SPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
205780e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
205880e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
205980e64a38SPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 16) & 0x1;
206080e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
206180e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
206280e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
206380e64a38SPhilippe Mathieu-Daudé     /* adjust df value for floating-point instruction */
206480e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df + 2);
206580e64a38SPhilippe Mathieu-Daudé 
206680e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_2RF(ctx->opcode)) {
206780e64a38SPhilippe Mathieu-Daudé     case OPC_FCLASS_df:
206880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fclass_df(cpu_env, tdf, twd, tws);
206980e64a38SPhilippe Mathieu-Daudé         break;
207080e64a38SPhilippe Mathieu-Daudé     case OPC_FTRUNC_S_df:
207180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ftrunc_s_df(cpu_env, tdf, twd, tws);
207280e64a38SPhilippe Mathieu-Daudé         break;
207380e64a38SPhilippe Mathieu-Daudé     case OPC_FTRUNC_U_df:
207480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ftrunc_u_df(cpu_env, tdf, twd, tws);
207580e64a38SPhilippe Mathieu-Daudé         break;
207680e64a38SPhilippe Mathieu-Daudé     case OPC_FSQRT_df:
207780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fsqrt_df(cpu_env, tdf, twd, tws);
207880e64a38SPhilippe Mathieu-Daudé         break;
207980e64a38SPhilippe Mathieu-Daudé     case OPC_FRSQRT_df:
208080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_frsqrt_df(cpu_env, tdf, twd, tws);
208180e64a38SPhilippe Mathieu-Daudé         break;
208280e64a38SPhilippe Mathieu-Daudé     case OPC_FRCP_df:
208380e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_frcp_df(cpu_env, tdf, twd, tws);
208480e64a38SPhilippe Mathieu-Daudé         break;
208580e64a38SPhilippe Mathieu-Daudé     case OPC_FRINT_df:
208680e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_frint_df(cpu_env, tdf, twd, tws);
208780e64a38SPhilippe Mathieu-Daudé         break;
208880e64a38SPhilippe Mathieu-Daudé     case OPC_FLOG2_df:
208980e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_flog2_df(cpu_env, tdf, twd, tws);
209080e64a38SPhilippe Mathieu-Daudé         break;
209180e64a38SPhilippe Mathieu-Daudé     case OPC_FEXUPL_df:
209280e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fexupl_df(cpu_env, tdf, twd, tws);
209380e64a38SPhilippe Mathieu-Daudé         break;
209480e64a38SPhilippe Mathieu-Daudé     case OPC_FEXUPR_df:
209580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_fexupr_df(cpu_env, tdf, twd, tws);
209680e64a38SPhilippe Mathieu-Daudé         break;
209780e64a38SPhilippe Mathieu-Daudé     case OPC_FFQL_df:
209880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ffql_df(cpu_env, tdf, twd, tws);
209980e64a38SPhilippe Mathieu-Daudé         break;
210080e64a38SPhilippe Mathieu-Daudé     case OPC_FFQR_df:
210180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ffqr_df(cpu_env, tdf, twd, tws);
210280e64a38SPhilippe Mathieu-Daudé         break;
210380e64a38SPhilippe Mathieu-Daudé     case OPC_FTINT_S_df:
210480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ftint_s_df(cpu_env, tdf, twd, tws);
210580e64a38SPhilippe Mathieu-Daudé         break;
210680e64a38SPhilippe Mathieu-Daudé     case OPC_FTINT_U_df:
210780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ftint_u_df(cpu_env, tdf, twd, tws);
210880e64a38SPhilippe Mathieu-Daudé         break;
210980e64a38SPhilippe Mathieu-Daudé     case OPC_FFINT_S_df:
211080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ffint_s_df(cpu_env, tdf, twd, tws);
211180e64a38SPhilippe Mathieu-Daudé         break;
211280e64a38SPhilippe Mathieu-Daudé     case OPC_FFINT_U_df:
211380e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ffint_u_df(cpu_env, tdf, twd, tws);
211480e64a38SPhilippe Mathieu-Daudé         break;
211580e64a38SPhilippe Mathieu-Daudé     }
211680e64a38SPhilippe Mathieu-Daudé 
211780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
211880e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
211980e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
212080e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
212180e64a38SPhilippe Mathieu-Daudé }
212280e64a38SPhilippe Mathieu-Daudé 
212380e64a38SPhilippe Mathieu-Daudé static void gen_msa_vec_v(DisasContext *ctx)
212480e64a38SPhilippe Mathieu-Daudé {
212580e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_VEC(op)    (MASK_MSA_MINOR(op) | (op & (0x1f << 21)))
212680e64a38SPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
212780e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
212880e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
212980e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
213080e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
213180e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
213280e64a38SPhilippe Mathieu-Daudé 
213380e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_VEC(ctx->opcode)) {
213480e64a38SPhilippe Mathieu-Daudé     case OPC_AND_V:
213580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_and_v(cpu_env, twd, tws, twt);
213680e64a38SPhilippe Mathieu-Daudé         break;
213780e64a38SPhilippe Mathieu-Daudé     case OPC_OR_V:
213880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_or_v(cpu_env, twd, tws, twt);
213980e64a38SPhilippe Mathieu-Daudé         break;
214080e64a38SPhilippe Mathieu-Daudé     case OPC_NOR_V:
214180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_nor_v(cpu_env, twd, tws, twt);
214280e64a38SPhilippe Mathieu-Daudé         break;
214380e64a38SPhilippe Mathieu-Daudé     case OPC_XOR_V:
214480e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_xor_v(cpu_env, twd, tws, twt);
214580e64a38SPhilippe Mathieu-Daudé         break;
214680e64a38SPhilippe Mathieu-Daudé     case OPC_BMNZ_V:
214780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_bmnz_v(cpu_env, twd, tws, twt);
214880e64a38SPhilippe Mathieu-Daudé         break;
214980e64a38SPhilippe Mathieu-Daudé     case OPC_BMZ_V:
215080e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_bmz_v(cpu_env, twd, tws, twt);
215180e64a38SPhilippe Mathieu-Daudé         break;
215280e64a38SPhilippe Mathieu-Daudé     case OPC_BSEL_V:
215380e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_bsel_v(cpu_env, twd, tws, twt);
215480e64a38SPhilippe Mathieu-Daudé         break;
215580e64a38SPhilippe Mathieu-Daudé     default:
215680e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
215780e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
215880e64a38SPhilippe Mathieu-Daudé         break;
215980e64a38SPhilippe Mathieu-Daudé     }
216080e64a38SPhilippe Mathieu-Daudé 
216180e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
216280e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
216380e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
216480e64a38SPhilippe Mathieu-Daudé }
216580e64a38SPhilippe Mathieu-Daudé 
216680e64a38SPhilippe Mathieu-Daudé static void gen_msa_vec(DisasContext *ctx)
216780e64a38SPhilippe Mathieu-Daudé {
216880e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_VEC(ctx->opcode)) {
216980e64a38SPhilippe Mathieu-Daudé     case OPC_AND_V:
217080e64a38SPhilippe Mathieu-Daudé     case OPC_OR_V:
217180e64a38SPhilippe Mathieu-Daudé     case OPC_NOR_V:
217280e64a38SPhilippe Mathieu-Daudé     case OPC_XOR_V:
217380e64a38SPhilippe Mathieu-Daudé     case OPC_BMNZ_V:
217480e64a38SPhilippe Mathieu-Daudé     case OPC_BMZ_V:
217580e64a38SPhilippe Mathieu-Daudé     case OPC_BSEL_V:
217680e64a38SPhilippe Mathieu-Daudé         gen_msa_vec_v(ctx);
217780e64a38SPhilippe Mathieu-Daudé         break;
217880e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_2R:
217980e64a38SPhilippe Mathieu-Daudé         gen_msa_2r(ctx);
218080e64a38SPhilippe Mathieu-Daudé         break;
218180e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_2RF:
218280e64a38SPhilippe Mathieu-Daudé         gen_msa_2rf(ctx);
218380e64a38SPhilippe Mathieu-Daudé         break;
218480e64a38SPhilippe Mathieu-Daudé     default:
218580e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
218680e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
218780e64a38SPhilippe Mathieu-Daudé         break;
218880e64a38SPhilippe Mathieu-Daudé     }
218980e64a38SPhilippe Mathieu-Daudé }
219080e64a38SPhilippe Mathieu-Daudé 
219180e64a38SPhilippe Mathieu-Daudé void gen_msa(DisasContext *ctx)
219280e64a38SPhilippe Mathieu-Daudé {
219380e64a38SPhilippe Mathieu-Daudé     uint32_t opcode = ctx->opcode;
219480e64a38SPhilippe Mathieu-Daudé 
219580e64a38SPhilippe Mathieu-Daudé     check_msa_access(ctx);
219680e64a38SPhilippe Mathieu-Daudé 
219780e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_MINOR(opcode)) {
219880e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_I8_00:
219980e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_I8_01:
220080e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_I8_02:
220180e64a38SPhilippe Mathieu-Daudé         gen_msa_i8(ctx);
220280e64a38SPhilippe Mathieu-Daudé         break;
220380e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_I5_06:
220480e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_I5_07:
220580e64a38SPhilippe Mathieu-Daudé         gen_msa_i5(ctx);
220680e64a38SPhilippe Mathieu-Daudé         break;
220780e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_BIT_09:
220880e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_BIT_0A:
220980e64a38SPhilippe Mathieu-Daudé         gen_msa_bit(ctx);
221080e64a38SPhilippe Mathieu-Daudé         break;
221180e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_0D:
221280e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_0E:
221380e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_0F:
221480e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_10:
221580e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_11:
221680e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_12:
221780e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_13:
221880e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_14:
221980e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_15:
222080e64a38SPhilippe Mathieu-Daudé         gen_msa_3r(ctx);
222180e64a38SPhilippe Mathieu-Daudé         break;
222280e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_ELM:
222380e64a38SPhilippe Mathieu-Daudé         gen_msa_elm(ctx);
222480e64a38SPhilippe Mathieu-Daudé         break;
222580e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3RF_1A:
222680e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3RF_1B:
222780e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3RF_1C:
222880e64a38SPhilippe Mathieu-Daudé         gen_msa_3rf(ctx);
222980e64a38SPhilippe Mathieu-Daudé         break;
223080e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_VEC:
223180e64a38SPhilippe Mathieu-Daudé         gen_msa_vec(ctx);
223280e64a38SPhilippe Mathieu-Daudé         break;
223380e64a38SPhilippe Mathieu-Daudé     case OPC_LD_B:
223480e64a38SPhilippe Mathieu-Daudé     case OPC_LD_H:
223580e64a38SPhilippe Mathieu-Daudé     case OPC_LD_W:
223680e64a38SPhilippe Mathieu-Daudé     case OPC_LD_D:
223780e64a38SPhilippe Mathieu-Daudé     case OPC_ST_B:
223880e64a38SPhilippe Mathieu-Daudé     case OPC_ST_H:
223980e64a38SPhilippe Mathieu-Daudé     case OPC_ST_W:
224080e64a38SPhilippe Mathieu-Daudé     case OPC_ST_D:
224180e64a38SPhilippe Mathieu-Daudé         {
224280e64a38SPhilippe Mathieu-Daudé             int32_t s10 = sextract32(ctx->opcode, 16, 10);
224380e64a38SPhilippe Mathieu-Daudé             uint8_t rs = (ctx->opcode >> 11) & 0x1f;
224480e64a38SPhilippe Mathieu-Daudé             uint8_t wd = (ctx->opcode >> 6) & 0x1f;
224580e64a38SPhilippe Mathieu-Daudé             uint8_t df = (ctx->opcode >> 0) & 0x3;
224680e64a38SPhilippe Mathieu-Daudé 
224780e64a38SPhilippe Mathieu-Daudé             TCGv_i32 twd = tcg_const_i32(wd);
224880e64a38SPhilippe Mathieu-Daudé             TCGv taddr = tcg_temp_new();
224980e64a38SPhilippe Mathieu-Daudé             gen_base_offset_addr(ctx, taddr, rs, s10 << df);
225080e64a38SPhilippe Mathieu-Daudé 
225180e64a38SPhilippe Mathieu-Daudé             switch (MASK_MSA_MINOR(opcode)) {
225280e64a38SPhilippe Mathieu-Daudé             case OPC_LD_B:
225380e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_ld_b(cpu_env, twd, taddr);
225480e64a38SPhilippe Mathieu-Daudé                 break;
225580e64a38SPhilippe Mathieu-Daudé             case OPC_LD_H:
225680e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_ld_h(cpu_env, twd, taddr);
225780e64a38SPhilippe Mathieu-Daudé                 break;
225880e64a38SPhilippe Mathieu-Daudé             case OPC_LD_W:
225980e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_ld_w(cpu_env, twd, taddr);
226080e64a38SPhilippe Mathieu-Daudé                 break;
226180e64a38SPhilippe Mathieu-Daudé             case OPC_LD_D:
226280e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_ld_d(cpu_env, twd, taddr);
226380e64a38SPhilippe Mathieu-Daudé                 break;
226480e64a38SPhilippe Mathieu-Daudé             case OPC_ST_B:
226580e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_st_b(cpu_env, twd, taddr);
226680e64a38SPhilippe Mathieu-Daudé                 break;
226780e64a38SPhilippe Mathieu-Daudé             case OPC_ST_H:
226880e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_st_h(cpu_env, twd, taddr);
226980e64a38SPhilippe Mathieu-Daudé                 break;
227080e64a38SPhilippe Mathieu-Daudé             case OPC_ST_W:
227180e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_st_w(cpu_env, twd, taddr);
227280e64a38SPhilippe Mathieu-Daudé                 break;
227380e64a38SPhilippe Mathieu-Daudé             case OPC_ST_D:
227480e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_st_d(cpu_env, twd, taddr);
227580e64a38SPhilippe Mathieu-Daudé                 break;
227680e64a38SPhilippe Mathieu-Daudé             }
227780e64a38SPhilippe Mathieu-Daudé 
227880e64a38SPhilippe Mathieu-Daudé             tcg_temp_free_i32(twd);
227980e64a38SPhilippe Mathieu-Daudé             tcg_temp_free(taddr);
228080e64a38SPhilippe Mathieu-Daudé         }
228180e64a38SPhilippe Mathieu-Daudé         break;
228280e64a38SPhilippe Mathieu-Daudé     default:
228380e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
228480e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
228580e64a38SPhilippe Mathieu-Daudé         break;
228680e64a38SPhilippe Mathieu-Daudé     }
228780e64a38SPhilippe Mathieu-Daudé }
2288*c7a9ef75SPhilippe Mathieu-Daudé 
2289*c7a9ef75SPhilippe Mathieu-Daudé static bool trans_MSA(DisasContext *ctx, arg_MSA *a)
2290*c7a9ef75SPhilippe Mathieu-Daudé {
2291*c7a9ef75SPhilippe Mathieu-Daudé     gen_msa(ctx);
2292*c7a9ef75SPhilippe Mathieu-Daudé 
2293*c7a9ef75SPhilippe Mathieu-Daudé     return true;
2294*c7a9ef75SPhilippe Mathieu-Daudé }
2295*c7a9ef75SPhilippe Mathieu-Daudé 
2296*c7a9ef75SPhilippe Mathieu-Daudé bool decode_ase_msa(DisasContext *ctx, uint32_t insn)
2297*c7a9ef75SPhilippe Mathieu-Daudé {
2298*c7a9ef75SPhilippe Mathieu-Daudé     return decode_msa32(ctx, insn);
2299*c7a9ef75SPhilippe Mathieu-Daudé }
2300