xref: /qemu/target/mips/tcg/msa_translate.c (revision 2d5246f30573c27cee609021850fdd3c56cda1ec)
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)
9c7a9ef75SPhilippe 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é 
204701d23aSPhilippe Mathieu-Daudé static int bit_m(DisasContext *ctx, int x);
214701d23aSPhilippe Mathieu-Daudé static int bit_df(DisasContext *ctx, int x);
224701d23aSPhilippe Mathieu-Daudé 
23ff29e5d3SPhilippe Mathieu-Daudé static inline int plus_1(DisasContext *s, int x)
24ff29e5d3SPhilippe Mathieu-Daudé {
25ff29e5d3SPhilippe Mathieu-Daudé     return x + 1;
26ff29e5d3SPhilippe Mathieu-Daudé }
27ff29e5d3SPhilippe Mathieu-Daudé 
285c5b6400SPhilippe Mathieu-Daudé static inline int plus_2(DisasContext *s, int x)
295c5b6400SPhilippe Mathieu-Daudé {
305c5b6400SPhilippe Mathieu-Daudé     return x + 2;
315c5b6400SPhilippe Mathieu-Daudé }
325c5b6400SPhilippe Mathieu-Daudé 
33c7a9ef75SPhilippe Mathieu-Daudé /* Include the auto-generated decoder.  */
34f5c6ee0cSPhilippe Mathieu-Daudé #include "decode-msa.c.inc"
35c7a9ef75SPhilippe Mathieu-Daudé 
3680e64a38SPhilippe Mathieu-Daudé #define OPC_MSA (0x1E << 26)
3780e64a38SPhilippe Mathieu-Daudé 
3880e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_MINOR(op)          (MASK_OP_MAJOR(op) | (op & 0x3F))
3980e64a38SPhilippe Mathieu-Daudé enum {
4080e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_0D   = 0x0D | OPC_MSA,
4180e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_0E   = 0x0E | OPC_MSA,
4280e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_0F   = 0x0F | OPC_MSA,
4380e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_10   = 0x10 | OPC_MSA,
4480e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_11   = 0x11 | OPC_MSA,
4580e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_12   = 0x12 | OPC_MSA,
4680e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_13   = 0x13 | OPC_MSA,
4780e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_14   = 0x14 | OPC_MSA,
4880e64a38SPhilippe Mathieu-Daudé     OPC_MSA_3R_15   = 0x15 | OPC_MSA,
4980e64a38SPhilippe Mathieu-Daudé     OPC_MSA_ELM     = 0x19 | OPC_MSA,
5080e64a38SPhilippe Mathieu-Daudé };
5180e64a38SPhilippe Mathieu-Daudé 
5280e64a38SPhilippe Mathieu-Daudé enum {
5380e64a38SPhilippe Mathieu-Daudé     /* 3R instruction df(bits 22..21) = _b, _h, _w, d */
5480e64a38SPhilippe Mathieu-Daudé     OPC_SLL_df      = (0x0 << 23) | OPC_MSA_3R_0D,
5580e64a38SPhilippe Mathieu-Daudé     OPC_ADDV_df     = (0x0 << 23) | OPC_MSA_3R_0E,
5680e64a38SPhilippe Mathieu-Daudé     OPC_CEQ_df      = (0x0 << 23) | OPC_MSA_3R_0F,
5780e64a38SPhilippe Mathieu-Daudé     OPC_ADD_A_df    = (0x0 << 23) | OPC_MSA_3R_10,
5880e64a38SPhilippe Mathieu-Daudé     OPC_SUBS_S_df   = (0x0 << 23) | OPC_MSA_3R_11,
5980e64a38SPhilippe Mathieu-Daudé     OPC_MULV_df     = (0x0 << 23) | OPC_MSA_3R_12,
6080e64a38SPhilippe Mathieu-Daudé     OPC_DOTP_S_df   = (0x0 << 23) | OPC_MSA_3R_13,
6180e64a38SPhilippe Mathieu-Daudé     OPC_SLD_df      = (0x0 << 23) | OPC_MSA_3R_14,
6280e64a38SPhilippe Mathieu-Daudé     OPC_VSHF_df     = (0x0 << 23) | OPC_MSA_3R_15,
6380e64a38SPhilippe Mathieu-Daudé     OPC_SRA_df      = (0x1 << 23) | OPC_MSA_3R_0D,
6480e64a38SPhilippe Mathieu-Daudé     OPC_SUBV_df     = (0x1 << 23) | OPC_MSA_3R_0E,
6580e64a38SPhilippe Mathieu-Daudé     OPC_ADDS_A_df   = (0x1 << 23) | OPC_MSA_3R_10,
6680e64a38SPhilippe Mathieu-Daudé     OPC_SUBS_U_df   = (0x1 << 23) | OPC_MSA_3R_11,
6780e64a38SPhilippe Mathieu-Daudé     OPC_MADDV_df    = (0x1 << 23) | OPC_MSA_3R_12,
6880e64a38SPhilippe Mathieu-Daudé     OPC_DOTP_U_df   = (0x1 << 23) | OPC_MSA_3R_13,
6980e64a38SPhilippe Mathieu-Daudé     OPC_SPLAT_df    = (0x1 << 23) | OPC_MSA_3R_14,
7080e64a38SPhilippe Mathieu-Daudé     OPC_SRAR_df     = (0x1 << 23) | OPC_MSA_3R_15,
7180e64a38SPhilippe Mathieu-Daudé     OPC_SRL_df      = (0x2 << 23) | OPC_MSA_3R_0D,
7280e64a38SPhilippe Mathieu-Daudé     OPC_MAX_S_df    = (0x2 << 23) | OPC_MSA_3R_0E,
7380e64a38SPhilippe Mathieu-Daudé     OPC_CLT_S_df    = (0x2 << 23) | OPC_MSA_3R_0F,
7480e64a38SPhilippe Mathieu-Daudé     OPC_ADDS_S_df   = (0x2 << 23) | OPC_MSA_3R_10,
7580e64a38SPhilippe Mathieu-Daudé     OPC_SUBSUS_U_df = (0x2 << 23) | OPC_MSA_3R_11,
7680e64a38SPhilippe Mathieu-Daudé     OPC_MSUBV_df    = (0x2 << 23) | OPC_MSA_3R_12,
7780e64a38SPhilippe Mathieu-Daudé     OPC_DPADD_S_df  = (0x2 << 23) | OPC_MSA_3R_13,
7880e64a38SPhilippe Mathieu-Daudé     OPC_PCKEV_df    = (0x2 << 23) | OPC_MSA_3R_14,
7980e64a38SPhilippe Mathieu-Daudé     OPC_SRLR_df     = (0x2 << 23) | OPC_MSA_3R_15,
8080e64a38SPhilippe Mathieu-Daudé     OPC_BCLR_df     = (0x3 << 23) | OPC_MSA_3R_0D,
8180e64a38SPhilippe Mathieu-Daudé     OPC_MAX_U_df    = (0x3 << 23) | OPC_MSA_3R_0E,
8280e64a38SPhilippe Mathieu-Daudé     OPC_CLT_U_df    = (0x3 << 23) | OPC_MSA_3R_0F,
8380e64a38SPhilippe Mathieu-Daudé     OPC_ADDS_U_df   = (0x3 << 23) | OPC_MSA_3R_10,
8480e64a38SPhilippe Mathieu-Daudé     OPC_SUBSUU_S_df = (0x3 << 23) | OPC_MSA_3R_11,
8580e64a38SPhilippe Mathieu-Daudé     OPC_DPADD_U_df  = (0x3 << 23) | OPC_MSA_3R_13,
8680e64a38SPhilippe Mathieu-Daudé     OPC_PCKOD_df    = (0x3 << 23) | OPC_MSA_3R_14,
8780e64a38SPhilippe Mathieu-Daudé     OPC_BSET_df     = (0x4 << 23) | OPC_MSA_3R_0D,
8880e64a38SPhilippe Mathieu-Daudé     OPC_MIN_S_df    = (0x4 << 23) | OPC_MSA_3R_0E,
8980e64a38SPhilippe Mathieu-Daudé     OPC_CLE_S_df    = (0x4 << 23) | OPC_MSA_3R_0F,
9080e64a38SPhilippe Mathieu-Daudé     OPC_AVE_S_df    = (0x4 << 23) | OPC_MSA_3R_10,
9180e64a38SPhilippe Mathieu-Daudé     OPC_ASUB_S_df   = (0x4 << 23) | OPC_MSA_3R_11,
9280e64a38SPhilippe Mathieu-Daudé     OPC_DIV_S_df    = (0x4 << 23) | OPC_MSA_3R_12,
9380e64a38SPhilippe Mathieu-Daudé     OPC_DPSUB_S_df  = (0x4 << 23) | OPC_MSA_3R_13,
9480e64a38SPhilippe Mathieu-Daudé     OPC_ILVL_df     = (0x4 << 23) | OPC_MSA_3R_14,
9580e64a38SPhilippe Mathieu-Daudé     OPC_HADD_S_df   = (0x4 << 23) | OPC_MSA_3R_15,
9680e64a38SPhilippe Mathieu-Daudé     OPC_BNEG_df     = (0x5 << 23) | OPC_MSA_3R_0D,
9780e64a38SPhilippe Mathieu-Daudé     OPC_MIN_U_df    = (0x5 << 23) | OPC_MSA_3R_0E,
9880e64a38SPhilippe Mathieu-Daudé     OPC_CLE_U_df    = (0x5 << 23) | OPC_MSA_3R_0F,
9980e64a38SPhilippe Mathieu-Daudé     OPC_AVE_U_df    = (0x5 << 23) | OPC_MSA_3R_10,
10080e64a38SPhilippe Mathieu-Daudé     OPC_ASUB_U_df   = (0x5 << 23) | OPC_MSA_3R_11,
10180e64a38SPhilippe Mathieu-Daudé     OPC_DIV_U_df    = (0x5 << 23) | OPC_MSA_3R_12,
10280e64a38SPhilippe Mathieu-Daudé     OPC_DPSUB_U_df  = (0x5 << 23) | OPC_MSA_3R_13,
10380e64a38SPhilippe Mathieu-Daudé     OPC_ILVR_df     = (0x5 << 23) | OPC_MSA_3R_14,
10480e64a38SPhilippe Mathieu-Daudé     OPC_HADD_U_df   = (0x5 << 23) | OPC_MSA_3R_15,
10580e64a38SPhilippe Mathieu-Daudé     OPC_BINSL_df    = (0x6 << 23) | OPC_MSA_3R_0D,
10680e64a38SPhilippe Mathieu-Daudé     OPC_MAX_A_df    = (0x6 << 23) | OPC_MSA_3R_0E,
10780e64a38SPhilippe Mathieu-Daudé     OPC_AVER_S_df   = (0x6 << 23) | OPC_MSA_3R_10,
10880e64a38SPhilippe Mathieu-Daudé     OPC_MOD_S_df    = (0x6 << 23) | OPC_MSA_3R_12,
10980e64a38SPhilippe Mathieu-Daudé     OPC_ILVEV_df    = (0x6 << 23) | OPC_MSA_3R_14,
11080e64a38SPhilippe Mathieu-Daudé     OPC_HSUB_S_df   = (0x6 << 23) | OPC_MSA_3R_15,
11180e64a38SPhilippe Mathieu-Daudé     OPC_BINSR_df    = (0x7 << 23) | OPC_MSA_3R_0D,
11280e64a38SPhilippe Mathieu-Daudé     OPC_MIN_A_df    = (0x7 << 23) | OPC_MSA_3R_0E,
11380e64a38SPhilippe Mathieu-Daudé     OPC_AVER_U_df   = (0x7 << 23) | OPC_MSA_3R_10,
11480e64a38SPhilippe Mathieu-Daudé     OPC_MOD_U_df    = (0x7 << 23) | OPC_MSA_3R_12,
11580e64a38SPhilippe Mathieu-Daudé     OPC_ILVOD_df    = (0x7 << 23) | OPC_MSA_3R_14,
11680e64a38SPhilippe Mathieu-Daudé     OPC_HSUB_U_df   = (0x7 << 23) | OPC_MSA_3R_15,
11780e64a38SPhilippe Mathieu-Daudé 
11880e64a38SPhilippe Mathieu-Daudé     /* ELM instructions df(bits 21..16) = _b, _h, _w, _d */
11980e64a38SPhilippe Mathieu-Daudé     OPC_SLDI_df     = (0x0 << 22) | (0x00 << 16) | OPC_MSA_ELM,
12080e64a38SPhilippe Mathieu-Daudé     OPC_CTCMSA      = (0x0 << 22) | (0x3E << 16) | OPC_MSA_ELM,
12180e64a38SPhilippe Mathieu-Daudé     OPC_SPLATI_df   = (0x1 << 22) | (0x00 << 16) | OPC_MSA_ELM,
12280e64a38SPhilippe Mathieu-Daudé     OPC_CFCMSA      = (0x1 << 22) | (0x3E << 16) | OPC_MSA_ELM,
12380e64a38SPhilippe Mathieu-Daudé     OPC_COPY_S_df   = (0x2 << 22) | (0x00 << 16) | OPC_MSA_ELM,
12480e64a38SPhilippe Mathieu-Daudé     OPC_MOVE_V      = (0x2 << 22) | (0x3E << 16) | OPC_MSA_ELM,
12580e64a38SPhilippe Mathieu-Daudé     OPC_COPY_U_df   = (0x3 << 22) | (0x00 << 16) | OPC_MSA_ELM,
12680e64a38SPhilippe Mathieu-Daudé     OPC_INSERT_df   = (0x4 << 22) | (0x00 << 16) | OPC_MSA_ELM,
12780e64a38SPhilippe Mathieu-Daudé     OPC_INSVE_df    = (0x5 << 22) | (0x00 << 16) | OPC_MSA_ELM,
12880e64a38SPhilippe Mathieu-Daudé };
12980e64a38SPhilippe Mathieu-Daudé 
13006106772SPhilippe Mathieu-Daudé static const char msaregnames[][6] = {
13180e64a38SPhilippe Mathieu-Daudé     "w0.d0",  "w0.d1",  "w1.d0",  "w1.d1",
13280e64a38SPhilippe Mathieu-Daudé     "w2.d0",  "w2.d1",  "w3.d0",  "w3.d1",
13380e64a38SPhilippe Mathieu-Daudé     "w4.d0",  "w4.d1",  "w5.d0",  "w5.d1",
13480e64a38SPhilippe Mathieu-Daudé     "w6.d0",  "w6.d1",  "w7.d0",  "w7.d1",
13580e64a38SPhilippe Mathieu-Daudé     "w8.d0",  "w8.d1",  "w9.d0",  "w9.d1",
13680e64a38SPhilippe Mathieu-Daudé     "w10.d0", "w10.d1", "w11.d0", "w11.d1",
13780e64a38SPhilippe Mathieu-Daudé     "w12.d0", "w12.d1", "w13.d0", "w13.d1",
13880e64a38SPhilippe Mathieu-Daudé     "w14.d0", "w14.d1", "w15.d0", "w15.d1",
13980e64a38SPhilippe Mathieu-Daudé     "w16.d0", "w16.d1", "w17.d0", "w17.d1",
14080e64a38SPhilippe Mathieu-Daudé     "w18.d0", "w18.d1", "w19.d0", "w19.d1",
14180e64a38SPhilippe Mathieu-Daudé     "w20.d0", "w20.d1", "w21.d0", "w21.d1",
14280e64a38SPhilippe Mathieu-Daudé     "w22.d0", "w22.d1", "w23.d0", "w23.d1",
14380e64a38SPhilippe Mathieu-Daudé     "w24.d0", "w24.d1", "w25.d0", "w25.d1",
14480e64a38SPhilippe Mathieu-Daudé     "w26.d0", "w26.d1", "w27.d0", "w27.d1",
14580e64a38SPhilippe Mathieu-Daudé     "w28.d0", "w28.d1", "w29.d0", "w29.d1",
14680e64a38SPhilippe Mathieu-Daudé     "w30.d0", "w30.d1", "w31.d0", "w31.d1",
14780e64a38SPhilippe Mathieu-Daudé };
14880e64a38SPhilippe Mathieu-Daudé 
1494701d23aSPhilippe Mathieu-Daudé /* Encoding of Operation Field (must be indexed by CPUMIPSMSADataFormat) */
1504701d23aSPhilippe Mathieu-Daudé struct dfe {
1514701d23aSPhilippe Mathieu-Daudé     int start;
1524701d23aSPhilippe Mathieu-Daudé     int length;
1534701d23aSPhilippe Mathieu-Daudé     uint32_t mask;
1544701d23aSPhilippe Mathieu-Daudé };
1554701d23aSPhilippe Mathieu-Daudé 
1564701d23aSPhilippe Mathieu-Daudé /*
1574701d23aSPhilippe Mathieu-Daudé  * Extract immediate from df/{m,n} format (used by ELM & BIT instructions).
1584701d23aSPhilippe Mathieu-Daudé  * Returns the immediate value, or -1 if the format does not match.
1594701d23aSPhilippe Mathieu-Daudé  */
1604701d23aSPhilippe Mathieu-Daudé static int df_extract_val(DisasContext *ctx, int x, const struct dfe *s)
1614701d23aSPhilippe Mathieu-Daudé {
1624701d23aSPhilippe Mathieu-Daudé     for (unsigned i = 0; i < 4; i++) {
1634701d23aSPhilippe Mathieu-Daudé         if (extract32(x, s->start, s->length) == s->mask) {
1644701d23aSPhilippe Mathieu-Daudé             return extract32(x, 0, s->start);
1654701d23aSPhilippe Mathieu-Daudé         }
1664701d23aSPhilippe Mathieu-Daudé     }
1674701d23aSPhilippe Mathieu-Daudé     return -1;
1684701d23aSPhilippe Mathieu-Daudé }
1694701d23aSPhilippe Mathieu-Daudé 
1704701d23aSPhilippe Mathieu-Daudé /*
1714701d23aSPhilippe Mathieu-Daudé  * Extract DataField from df/{m,n} format (used by ELM & BIT instructions).
1724701d23aSPhilippe Mathieu-Daudé  * Returns the DataField, or -1 if the format does not match.
1734701d23aSPhilippe Mathieu-Daudé  */
1744701d23aSPhilippe Mathieu-Daudé static int df_extract_df(DisasContext *ctx, int x, const struct dfe *s)
1754701d23aSPhilippe Mathieu-Daudé {
1764701d23aSPhilippe Mathieu-Daudé     for (unsigned i = 0; i < 4; i++) {
1774701d23aSPhilippe Mathieu-Daudé         if (extract32(x, s->start, s->length) == s->mask) {
1784701d23aSPhilippe Mathieu-Daudé             return i;
1794701d23aSPhilippe Mathieu-Daudé         }
1804701d23aSPhilippe Mathieu-Daudé     }
1814701d23aSPhilippe Mathieu-Daudé     return -1;
1824701d23aSPhilippe Mathieu-Daudé }
1834701d23aSPhilippe Mathieu-Daudé 
1844701d23aSPhilippe Mathieu-Daudé static const struct dfe df_bit[] = {
1854701d23aSPhilippe Mathieu-Daudé     /* Table 3.28 BIT Instruction Format */
1864701d23aSPhilippe Mathieu-Daudé     [DF_BYTE]   = {3, 4, 0b1110},
1874701d23aSPhilippe Mathieu-Daudé     [DF_HALF]   = {4, 3, 0b110},
1884701d23aSPhilippe Mathieu-Daudé     [DF_WORD]   = {5, 2, 0b10},
1894701d23aSPhilippe Mathieu-Daudé     [DF_DOUBLE] = {6, 1, 0b0}
1904701d23aSPhilippe Mathieu-Daudé };
1914701d23aSPhilippe Mathieu-Daudé 
1924701d23aSPhilippe Mathieu-Daudé static int bit_m(DisasContext *ctx, int x)
1934701d23aSPhilippe Mathieu-Daudé {
1944701d23aSPhilippe Mathieu-Daudé     return df_extract_val(ctx, x, df_bit);
1954701d23aSPhilippe Mathieu-Daudé }
1964701d23aSPhilippe Mathieu-Daudé 
1974701d23aSPhilippe Mathieu-Daudé static int bit_df(DisasContext *ctx, int x)
1984701d23aSPhilippe Mathieu-Daudé {
1994701d23aSPhilippe Mathieu-Daudé     return df_extract_df(ctx, x, df_bit);
2004701d23aSPhilippe Mathieu-Daudé }
2014701d23aSPhilippe Mathieu-Daudé 
20280e64a38SPhilippe Mathieu-Daudé static TCGv_i64 msa_wr_d[64];
20380e64a38SPhilippe Mathieu-Daudé 
20480e64a38SPhilippe Mathieu-Daudé void msa_translate_init(void)
20580e64a38SPhilippe Mathieu-Daudé {
20680e64a38SPhilippe Mathieu-Daudé     int i;
20780e64a38SPhilippe Mathieu-Daudé 
20880e64a38SPhilippe Mathieu-Daudé     for (i = 0; i < 32; i++) {
209bbc213b3SPhilippe Mathieu-Daudé         int off;
21080e64a38SPhilippe Mathieu-Daudé 
21180e64a38SPhilippe Mathieu-Daudé         /*
21280e64a38SPhilippe Mathieu-Daudé          * The MSA vector registers are mapped on the
21380e64a38SPhilippe Mathieu-Daudé          * scalar floating-point unit (FPU) registers.
21480e64a38SPhilippe Mathieu-Daudé          */
215bbc213b3SPhilippe Mathieu-Daudé         off = offsetof(CPUMIPSState, active_fpu.fpr[i].wr.d[0]);
21680e64a38SPhilippe Mathieu-Daudé         msa_wr_d[i * 2] = fpu_f64[i];
217bbc213b3SPhilippe Mathieu-Daudé 
21880e64a38SPhilippe Mathieu-Daudé         off = offsetof(CPUMIPSState, active_fpu.fpr[i].wr.d[1]);
21980e64a38SPhilippe Mathieu-Daudé         msa_wr_d[i * 2 + 1] =
22080e64a38SPhilippe Mathieu-Daudé                 tcg_global_mem_new_i64(cpu_env, off, msaregnames[i * 2 + 1]);
22180e64a38SPhilippe Mathieu-Daudé     }
22280e64a38SPhilippe Mathieu-Daudé }
22380e64a38SPhilippe Mathieu-Daudé 
224340ee8b3SPhilippe Mathieu-Daudé /*
225340ee8b3SPhilippe Mathieu-Daudé  * Check if MSA is enabled.
226340ee8b3SPhilippe Mathieu-Daudé  * This function is always called with MSA available.
227340ee8b3SPhilippe Mathieu-Daudé  * If MSA is disabled, raise an exception.
228340ee8b3SPhilippe Mathieu-Daudé  */
229340ee8b3SPhilippe Mathieu-Daudé static inline bool check_msa_enabled(DisasContext *ctx)
23080e64a38SPhilippe Mathieu-Daudé {
23180e64a38SPhilippe Mathieu-Daudé     if (unlikely((ctx->hflags & MIPS_HFLAG_FPU) &&
23280e64a38SPhilippe Mathieu-Daudé                  !(ctx->hflags & MIPS_HFLAG_F64))) {
23380e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
234340ee8b3SPhilippe Mathieu-Daudé         return false;
23580e64a38SPhilippe Mathieu-Daudé     }
23680e64a38SPhilippe Mathieu-Daudé 
23780e64a38SPhilippe Mathieu-Daudé     if (unlikely(!(ctx->hflags & MIPS_HFLAG_MSA))) {
23880e64a38SPhilippe Mathieu-Daudé         generate_exception_end(ctx, EXCP_MSADIS);
239340ee8b3SPhilippe Mathieu-Daudé         return false;
24080e64a38SPhilippe Mathieu-Daudé     }
241340ee8b3SPhilippe Mathieu-Daudé     return true;
24280e64a38SPhilippe Mathieu-Daudé }
24380e64a38SPhilippe Mathieu-Daudé 
244ce121fe2SPhilippe Mathieu-Daudé typedef void gen_helper_piv(TCGv_ptr, TCGv_i32, TCGv);
245adcff99aSPhilippe Mathieu-Daudé typedef void gen_helper_pii(TCGv_ptr, TCGv_i32, TCGv_i32);
2467cc351ffSPhilippe Mathieu-Daudé typedef void gen_helper_piii(TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32);
247b8e74816SPhilippe Mathieu-Daudé typedef void gen_helper_piiii(TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32, TCGv_i32);
248b8e74816SPhilippe Mathieu-Daudé 
249ce121fe2SPhilippe Mathieu-Daudé #define TRANS_DF_x(TYPE, NAME, trans_func, gen_func) \
250ce121fe2SPhilippe Mathieu-Daudé     static gen_helper_p##TYPE * const NAME##_tab[4] = { \
251ce121fe2SPhilippe Mathieu-Daudé         gen_func##_b, gen_func##_h, gen_func##_w, gen_func##_d \
252ce121fe2SPhilippe Mathieu-Daudé     }; \
253ce121fe2SPhilippe Mathieu-Daudé     TRANS(NAME, trans_func, NAME##_tab[a->df])
254ce121fe2SPhilippe Mathieu-Daudé 
255ce121fe2SPhilippe Mathieu-Daudé #define TRANS_DF_iv(NAME, trans_func, gen_func) \
256ce121fe2SPhilippe Mathieu-Daudé     TRANS_DF_x(iv, NAME, trans_func, gen_func)
257ce121fe2SPhilippe Mathieu-Daudé 
258adcff99aSPhilippe Mathieu-Daudé #define TRANS_DF_ii(NAME, trans_func, gen_func) \
259adcff99aSPhilippe Mathieu-Daudé     TRANS_DF_x(ii, NAME, trans_func, gen_func)
260adcff99aSPhilippe Mathieu-Daudé 
261878b87b5SPhilippe Mathieu-Daudé static void gen_check_zero_element(TCGv tresult, uint8_t df, uint8_t wt,
262878b87b5SPhilippe Mathieu-Daudé                                    TCGCond cond)
26380e64a38SPhilippe Mathieu-Daudé {
26480e64a38SPhilippe Mathieu-Daudé     /* generates tcg ops to check if any element is 0 */
26580e64a38SPhilippe Mathieu-Daudé     /* Note this function only works with MSA_WRLEN = 128 */
26640f75c02SPhilippe Mathieu-Daudé     uint64_t eval_zero_or_big = dup_const(df, 1);
26740f75c02SPhilippe Mathieu-Daudé     uint64_t eval_big = eval_zero_or_big << ((8 << df) - 1);
26880e64a38SPhilippe Mathieu-Daudé     TCGv_i64 t0 = tcg_temp_new_i64();
26980e64a38SPhilippe Mathieu-Daudé     TCGv_i64 t1 = tcg_temp_new_i64();
27040f75c02SPhilippe Mathieu-Daudé 
27180e64a38SPhilippe Mathieu-Daudé     tcg_gen_subi_i64(t0, msa_wr_d[wt << 1], eval_zero_or_big);
27280e64a38SPhilippe Mathieu-Daudé     tcg_gen_andc_i64(t0, t0, msa_wr_d[wt << 1]);
27380e64a38SPhilippe Mathieu-Daudé     tcg_gen_andi_i64(t0, t0, eval_big);
27480e64a38SPhilippe Mathieu-Daudé     tcg_gen_subi_i64(t1, msa_wr_d[(wt << 1) + 1], eval_zero_or_big);
27580e64a38SPhilippe Mathieu-Daudé     tcg_gen_andc_i64(t1, t1, msa_wr_d[(wt << 1) + 1]);
27680e64a38SPhilippe Mathieu-Daudé     tcg_gen_andi_i64(t1, t1, eval_big);
27780e64a38SPhilippe Mathieu-Daudé     tcg_gen_or_i64(t0, t0, t1);
27880e64a38SPhilippe Mathieu-Daudé     /* if all bits are zero then all elements are not zero */
27980e64a38SPhilippe Mathieu-Daudé     /* if some bit is non-zero then some element is zero */
280878b87b5SPhilippe Mathieu-Daudé     tcg_gen_setcondi_i64(cond, t0, t0, 0);
28180e64a38SPhilippe Mathieu-Daudé     tcg_gen_trunc_i64_tl(tresult, t0);
28280e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i64(t0);
28380e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i64(t1);
28480e64a38SPhilippe Mathieu-Daudé }
28580e64a38SPhilippe Mathieu-Daudé 
286d61566cfSPhilippe Mathieu-Daudé static bool gen_msa_BxZ_V(DisasContext *ctx, int wt, int sa, TCGCond cond)
28780e64a38SPhilippe Mathieu-Daudé {
28880e64a38SPhilippe Mathieu-Daudé     TCGv_i64 t0;
28980e64a38SPhilippe Mathieu-Daudé 
290340ee8b3SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
291340ee8b3SPhilippe Mathieu-Daudé         return true;
292340ee8b3SPhilippe Mathieu-Daudé     }
29380e64a38SPhilippe Mathieu-Daudé 
29480e64a38SPhilippe Mathieu-Daudé     if (ctx->hflags & MIPS_HFLAG_BMASK) {
29580e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
29680e64a38SPhilippe Mathieu-Daudé         return true;
29780e64a38SPhilippe Mathieu-Daudé     }
29880e64a38SPhilippe Mathieu-Daudé     t0 = tcg_temp_new_i64();
29980e64a38SPhilippe Mathieu-Daudé     tcg_gen_or_i64(t0, msa_wr_d[wt << 1], msa_wr_d[(wt << 1) + 1]);
30080e64a38SPhilippe Mathieu-Daudé     tcg_gen_setcondi_i64(cond, t0, t0, 0);
30180e64a38SPhilippe Mathieu-Daudé     tcg_gen_trunc_i64_tl(bcond, t0);
30280e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i64(t0);
30380e64a38SPhilippe Mathieu-Daudé 
304d61566cfSPhilippe Mathieu-Daudé     ctx->btarget = ctx->base.pc_next + (sa << 2) + 4;
30580e64a38SPhilippe Mathieu-Daudé 
30680e64a38SPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BC;
30780e64a38SPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BDS32;
30880e64a38SPhilippe Mathieu-Daudé 
30980e64a38SPhilippe Mathieu-Daudé     return true;
31080e64a38SPhilippe Mathieu-Daudé }
31180e64a38SPhilippe Mathieu-Daudé 
312c7a9ef75SPhilippe Mathieu-Daudé static bool trans_BZ_V(DisasContext *ctx, arg_msa_bz *a)
313c7a9ef75SPhilippe Mathieu-Daudé {
314d61566cfSPhilippe Mathieu-Daudé     return gen_msa_BxZ_V(ctx, a->wt, a->sa, TCG_COND_EQ);
315c7a9ef75SPhilippe Mathieu-Daudé }
316c7a9ef75SPhilippe Mathieu-Daudé 
317c7a9ef75SPhilippe Mathieu-Daudé static bool trans_BNZ_V(DisasContext *ctx, arg_msa_bz *a)
318c7a9ef75SPhilippe Mathieu-Daudé {
319d61566cfSPhilippe Mathieu-Daudé     return gen_msa_BxZ_V(ctx, a->wt, a->sa, TCG_COND_NE);
320c7a9ef75SPhilippe Mathieu-Daudé }
321c7a9ef75SPhilippe Mathieu-Daudé 
322d61566cfSPhilippe Mathieu-Daudé static bool gen_msa_BxZ(DisasContext *ctx, int df, int wt, int sa, bool if_not)
32380e64a38SPhilippe Mathieu-Daudé {
324340ee8b3SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
325340ee8b3SPhilippe Mathieu-Daudé         return true;
326340ee8b3SPhilippe Mathieu-Daudé     }
32780e64a38SPhilippe Mathieu-Daudé 
32880e64a38SPhilippe Mathieu-Daudé     if (ctx->hflags & MIPS_HFLAG_BMASK) {
32980e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
33080e64a38SPhilippe Mathieu-Daudé         return true;
33180e64a38SPhilippe Mathieu-Daudé     }
33280e64a38SPhilippe Mathieu-Daudé 
333878b87b5SPhilippe Mathieu-Daudé     gen_check_zero_element(bcond, df, wt, if_not ? TCG_COND_EQ : TCG_COND_NE);
33480e64a38SPhilippe Mathieu-Daudé 
335d61566cfSPhilippe Mathieu-Daudé     ctx->btarget = ctx->base.pc_next + (sa << 2) + 4;
33680e64a38SPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BC;
33780e64a38SPhilippe Mathieu-Daudé     ctx->hflags |= MIPS_HFLAG_BDS32;
33880e64a38SPhilippe Mathieu-Daudé 
33980e64a38SPhilippe Mathieu-Daudé     return true;
34080e64a38SPhilippe Mathieu-Daudé }
34180e64a38SPhilippe Mathieu-Daudé 
342d61566cfSPhilippe Mathieu-Daudé static bool trans_BZ(DisasContext *ctx, arg_msa_bz *a)
343c7a9ef75SPhilippe Mathieu-Daudé {
344d61566cfSPhilippe Mathieu-Daudé     return gen_msa_BxZ(ctx, a->df, a->wt, a->sa, false);
345c7a9ef75SPhilippe Mathieu-Daudé }
346c7a9ef75SPhilippe Mathieu-Daudé 
347d61566cfSPhilippe Mathieu-Daudé static bool trans_BNZ(DisasContext *ctx, arg_msa_bz *a)
348c7a9ef75SPhilippe Mathieu-Daudé {
349d61566cfSPhilippe Mathieu-Daudé     return gen_msa_BxZ(ctx, a->df, a->wt, a->sa, true);
350c7a9ef75SPhilippe Mathieu-Daudé }
351c7a9ef75SPhilippe Mathieu-Daudé 
3527cc351ffSPhilippe Mathieu-Daudé static bool trans_msa_i8(DisasContext *ctx, arg_msa_i *a,
3537cc351ffSPhilippe Mathieu-Daudé                          gen_helper_piii *gen_msa_i8)
35480e64a38SPhilippe Mathieu-Daudé {
3557cc351ffSPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
3567cc351ffSPhilippe Mathieu-Daudé         return true;
35780e64a38SPhilippe Mathieu-Daudé     }
35880e64a38SPhilippe Mathieu-Daudé 
3597cc351ffSPhilippe Mathieu-Daudé     gen_msa_i8(cpu_env,
3607cc351ffSPhilippe Mathieu-Daudé                tcg_constant_i32(a->wd),
3617cc351ffSPhilippe Mathieu-Daudé                tcg_constant_i32(a->ws),
3627cc351ffSPhilippe Mathieu-Daudé                tcg_constant_i32(a->sa));
3637cc351ffSPhilippe Mathieu-Daudé 
3647cc351ffSPhilippe Mathieu-Daudé     return true;
36580e64a38SPhilippe Mathieu-Daudé }
36680e64a38SPhilippe Mathieu-Daudé 
3677cc351ffSPhilippe Mathieu-Daudé TRANS(ANDI,     trans_msa_i8, gen_helper_msa_andi_b);
3687cc351ffSPhilippe Mathieu-Daudé TRANS(ORI,      trans_msa_i8, gen_helper_msa_ori_b);
3697cc351ffSPhilippe Mathieu-Daudé TRANS(NORI,     trans_msa_i8, gen_helper_msa_nori_b);
3707cc351ffSPhilippe Mathieu-Daudé TRANS(XORI,     trans_msa_i8, gen_helper_msa_xori_b);
3717cc351ffSPhilippe Mathieu-Daudé TRANS(BMNZI,    trans_msa_i8, gen_helper_msa_bmnzi_b);
3727cc351ffSPhilippe Mathieu-Daudé TRANS(BMZI,     trans_msa_i8, gen_helper_msa_bmzi_b);
3737cc351ffSPhilippe Mathieu-Daudé TRANS(BSELI,    trans_msa_i8, gen_helper_msa_bseli_b);
3747cc351ffSPhilippe Mathieu-Daudé 
375a9e17958SPhilippe Mathieu-Daudé static bool trans_SHF(DisasContext *ctx, arg_msa_i *a)
376a9e17958SPhilippe Mathieu-Daudé {
377a9e17958SPhilippe Mathieu-Daudé     if (a->df == DF_DOUBLE) {
378a9e17958SPhilippe Mathieu-Daudé         return false;
379a9e17958SPhilippe Mathieu-Daudé     }
380a9e17958SPhilippe Mathieu-Daudé 
381a9e17958SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
382a9e17958SPhilippe Mathieu-Daudé         return true;
383a9e17958SPhilippe Mathieu-Daudé     }
384a9e17958SPhilippe Mathieu-Daudé 
385a9e17958SPhilippe Mathieu-Daudé     gen_helper_msa_shf_df(cpu_env,
386a9e17958SPhilippe Mathieu-Daudé                           tcg_constant_i32(a->df),
387a9e17958SPhilippe Mathieu-Daudé                           tcg_constant_i32(a->wd),
388a9e17958SPhilippe Mathieu-Daudé                           tcg_constant_i32(a->ws),
389a9e17958SPhilippe Mathieu-Daudé                           tcg_constant_i32(a->sa));
390a9e17958SPhilippe Mathieu-Daudé 
391a9e17958SPhilippe Mathieu-Daudé     return true;
392a9e17958SPhilippe Mathieu-Daudé }
393a9e17958SPhilippe Mathieu-Daudé 
394b8e74816SPhilippe Mathieu-Daudé static bool trans_msa_i5(DisasContext *ctx, arg_msa_i *a,
395b8e74816SPhilippe Mathieu-Daudé                          gen_helper_piiii *gen_msa_i5)
39680e64a38SPhilippe Mathieu-Daudé {
397b8e74816SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
398b8e74816SPhilippe Mathieu-Daudé         return true;
39980e64a38SPhilippe Mathieu-Daudé     }
40080e64a38SPhilippe Mathieu-Daudé 
401b8e74816SPhilippe Mathieu-Daudé     gen_msa_i5(cpu_env,
402b8e74816SPhilippe Mathieu-Daudé                tcg_constant_i32(a->df),
403b8e74816SPhilippe Mathieu-Daudé                tcg_constant_i32(a->wd),
404b8e74816SPhilippe Mathieu-Daudé                tcg_constant_i32(a->ws),
405b8e74816SPhilippe Mathieu-Daudé                tcg_constant_i32(a->sa));
406b8e74816SPhilippe Mathieu-Daudé 
407b8e74816SPhilippe Mathieu-Daudé     return true;
40880e64a38SPhilippe Mathieu-Daudé }
40980e64a38SPhilippe Mathieu-Daudé 
410b8e74816SPhilippe Mathieu-Daudé TRANS(ADDVI,    trans_msa_i5, gen_helper_msa_addvi_df);
411b8e74816SPhilippe Mathieu-Daudé TRANS(SUBVI,    trans_msa_i5, gen_helper_msa_subvi_df);
412b8e74816SPhilippe Mathieu-Daudé TRANS(MAXI_S,   trans_msa_i5, gen_helper_msa_maxi_s_df);
413b8e74816SPhilippe Mathieu-Daudé TRANS(MAXI_U,   trans_msa_i5, gen_helper_msa_maxi_u_df);
414b8e74816SPhilippe Mathieu-Daudé TRANS(MINI_S,   trans_msa_i5, gen_helper_msa_mini_s_df);
415b8e74816SPhilippe Mathieu-Daudé TRANS(MINI_U,   trans_msa_i5, gen_helper_msa_mini_u_df);
416b8e74816SPhilippe Mathieu-Daudé TRANS(CLTI_S,   trans_msa_i5, gen_helper_msa_clti_s_df);
417b8e74816SPhilippe Mathieu-Daudé TRANS(CLTI_U,   trans_msa_i5, gen_helper_msa_clti_u_df);
418b8e74816SPhilippe Mathieu-Daudé TRANS(CLEI_S,   trans_msa_i5, gen_helper_msa_clei_s_df);
419b8e74816SPhilippe Mathieu-Daudé TRANS(CLEI_U,   trans_msa_i5, gen_helper_msa_clei_u_df);
420b8e74816SPhilippe Mathieu-Daudé TRANS(CEQI,     trans_msa_i5, gen_helper_msa_ceqi_df);
421b8e74816SPhilippe Mathieu-Daudé 
42275094c33SPhilippe Mathieu-Daudé static bool trans_LDI(DisasContext *ctx, arg_msa_ldi *a)
42375094c33SPhilippe Mathieu-Daudé {
42475094c33SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
42575094c33SPhilippe Mathieu-Daudé         return true;
42675094c33SPhilippe Mathieu-Daudé     }
42775094c33SPhilippe Mathieu-Daudé 
42875094c33SPhilippe Mathieu-Daudé     gen_helper_msa_ldi_df(cpu_env,
42975094c33SPhilippe Mathieu-Daudé                           tcg_constant_i32(a->df),
43075094c33SPhilippe Mathieu-Daudé                           tcg_constant_i32(a->wd),
43175094c33SPhilippe Mathieu-Daudé                           tcg_constant_i32(a->sa));
43275094c33SPhilippe Mathieu-Daudé 
43375094c33SPhilippe Mathieu-Daudé     return true;
43475094c33SPhilippe Mathieu-Daudé }
43575094c33SPhilippe Mathieu-Daudé 
4364701d23aSPhilippe Mathieu-Daudé static bool trans_msa_bit(DisasContext *ctx, arg_msa_bit *a,
4374701d23aSPhilippe Mathieu-Daudé                           gen_helper_piiii *gen_msa_bit)
43880e64a38SPhilippe Mathieu-Daudé {
4394701d23aSPhilippe Mathieu-Daudé     if (a->df < 0) {
4404701d23aSPhilippe Mathieu-Daudé         return false;
44180e64a38SPhilippe Mathieu-Daudé     }
44280e64a38SPhilippe Mathieu-Daudé 
4434701d23aSPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
4444701d23aSPhilippe Mathieu-Daudé         return true;
44580e64a38SPhilippe Mathieu-Daudé     }
44680e64a38SPhilippe Mathieu-Daudé 
4474701d23aSPhilippe Mathieu-Daudé     gen_msa_bit(cpu_env,
4484701d23aSPhilippe Mathieu-Daudé                 tcg_constant_i32(a->df),
4494701d23aSPhilippe Mathieu-Daudé                 tcg_constant_i32(a->wd),
4504701d23aSPhilippe Mathieu-Daudé                 tcg_constant_i32(a->ws),
4514701d23aSPhilippe Mathieu-Daudé                 tcg_constant_i32(a->m));
4524701d23aSPhilippe Mathieu-Daudé 
4534701d23aSPhilippe Mathieu-Daudé     return true;
45480e64a38SPhilippe Mathieu-Daudé }
45580e64a38SPhilippe Mathieu-Daudé 
4564701d23aSPhilippe Mathieu-Daudé TRANS(SLLI,     trans_msa_bit, gen_helper_msa_slli_df);
4574701d23aSPhilippe Mathieu-Daudé TRANS(SRAI,     trans_msa_bit, gen_helper_msa_srai_df);
4584701d23aSPhilippe Mathieu-Daudé TRANS(SRLI,     trans_msa_bit, gen_helper_msa_srli_df);
4594701d23aSPhilippe Mathieu-Daudé TRANS(BCLRI,    trans_msa_bit, gen_helper_msa_bclri_df);
4604701d23aSPhilippe Mathieu-Daudé TRANS(BSETI,    trans_msa_bit, gen_helper_msa_bseti_df);
4614701d23aSPhilippe Mathieu-Daudé TRANS(BNEGI,    trans_msa_bit, gen_helper_msa_bnegi_df);
4624701d23aSPhilippe Mathieu-Daudé TRANS(BINSLI,   trans_msa_bit, gen_helper_msa_binsli_df);
4634701d23aSPhilippe Mathieu-Daudé TRANS(BINSRI,   trans_msa_bit, gen_helper_msa_binsri_df);
4644701d23aSPhilippe Mathieu-Daudé TRANS(SAT_S,    trans_msa_bit, gen_helper_msa_sat_u_df);
4654701d23aSPhilippe Mathieu-Daudé TRANS(SAT_U,    trans_msa_bit, gen_helper_msa_sat_u_df);
4664701d23aSPhilippe Mathieu-Daudé TRANS(SRARI,    trans_msa_bit, gen_helper_msa_srari_df);
4674701d23aSPhilippe Mathieu-Daudé TRANS(SRLRI,    trans_msa_bit, gen_helper_msa_srlri_df);
4684701d23aSPhilippe Mathieu-Daudé 
469ff29e5d3SPhilippe Mathieu-Daudé static bool trans_msa_3rf(DisasContext *ctx, arg_msa_r *a,
470ff29e5d3SPhilippe Mathieu-Daudé                           gen_helper_piiii *gen_msa_3rf)
471ff29e5d3SPhilippe Mathieu-Daudé {
472ff29e5d3SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
473ff29e5d3SPhilippe Mathieu-Daudé         return true;
474ff29e5d3SPhilippe Mathieu-Daudé     }
475ff29e5d3SPhilippe Mathieu-Daudé 
476ff29e5d3SPhilippe Mathieu-Daudé     gen_msa_3rf(cpu_env,
477ff29e5d3SPhilippe Mathieu-Daudé                 tcg_constant_i32(a->df),
478ff29e5d3SPhilippe Mathieu-Daudé                 tcg_constant_i32(a->wd),
479ff29e5d3SPhilippe Mathieu-Daudé                 tcg_constant_i32(a->ws),
480ff29e5d3SPhilippe Mathieu-Daudé                 tcg_constant_i32(a->wt));
481ff29e5d3SPhilippe Mathieu-Daudé 
482ff29e5d3SPhilippe Mathieu-Daudé     return true;
483ff29e5d3SPhilippe Mathieu-Daudé }
484ff29e5d3SPhilippe Mathieu-Daudé 
4857acb5c78SPhilippe Mathieu-Daudé static bool trans_msa_3r(DisasContext *ctx, arg_msa_r *a,
4867acb5c78SPhilippe Mathieu-Daudé                          gen_helper_piii *gen_msa_3r)
4877acb5c78SPhilippe Mathieu-Daudé {
4887acb5c78SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
4897acb5c78SPhilippe Mathieu-Daudé         return true;
4907acb5c78SPhilippe Mathieu-Daudé     }
4917acb5c78SPhilippe Mathieu-Daudé 
4927acb5c78SPhilippe Mathieu-Daudé     gen_msa_3r(cpu_env,
4937acb5c78SPhilippe Mathieu-Daudé                tcg_constant_i32(a->wd),
4947acb5c78SPhilippe Mathieu-Daudé                tcg_constant_i32(a->ws),
4957acb5c78SPhilippe Mathieu-Daudé                tcg_constant_i32(a->wt));
4967acb5c78SPhilippe Mathieu-Daudé 
4977acb5c78SPhilippe Mathieu-Daudé     return true;
4987acb5c78SPhilippe Mathieu-Daudé }
4997acb5c78SPhilippe Mathieu-Daudé 
5007acb5c78SPhilippe Mathieu-Daudé TRANS(AND_V,            trans_msa_3r,   gen_helper_msa_and_v);
5017acb5c78SPhilippe Mathieu-Daudé TRANS(OR_V,             trans_msa_3r,   gen_helper_msa_or_v);
5027acb5c78SPhilippe Mathieu-Daudé TRANS(NOR_V,            trans_msa_3r,   gen_helper_msa_nor_v);
5037acb5c78SPhilippe Mathieu-Daudé TRANS(XOR_V,            trans_msa_3r,   gen_helper_msa_xor_v);
5047acb5c78SPhilippe Mathieu-Daudé TRANS(BMNZ_V,           trans_msa_3r,   gen_helper_msa_bmnz_v);
5057acb5c78SPhilippe Mathieu-Daudé TRANS(BMZ_V,            trans_msa_3r,   gen_helper_msa_bmz_v);
5067acb5c78SPhilippe Mathieu-Daudé TRANS(BSEL_V,           trans_msa_3r,   gen_helper_msa_bsel_v);
5077acb5c78SPhilippe Mathieu-Daudé 
50880e64a38SPhilippe Mathieu-Daudé static void gen_msa_3r(DisasContext *ctx)
50980e64a38SPhilippe Mathieu-Daudé {
51080e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_3R(op)    (MASK_MSA_MINOR(op) | (op & (0x7 << 23)))
51180e64a38SPhilippe Mathieu-Daudé     uint8_t df = (ctx->opcode >> 21) & 0x3;
51280e64a38SPhilippe Mathieu-Daudé     uint8_t wt = (ctx->opcode >> 16) & 0x1f;
51380e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
51480e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
51580e64a38SPhilippe Mathieu-Daudé 
51680e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_const_i32(df);
51780e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
51880e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
51980e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twt = tcg_const_i32(wt);
52080e64a38SPhilippe Mathieu-Daudé 
52180e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_3R(ctx->opcode)) {
52280e64a38SPhilippe Mathieu-Daudé     case OPC_BINSL_df:
52380e64a38SPhilippe Mathieu-Daudé         switch (df) {
52480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
52580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsl_b(cpu_env, twd, tws, twt);
52680e64a38SPhilippe Mathieu-Daudé             break;
52780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
52880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsl_h(cpu_env, twd, tws, twt);
52980e64a38SPhilippe Mathieu-Daudé             break;
53080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
53180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsl_w(cpu_env, twd, tws, twt);
53280e64a38SPhilippe Mathieu-Daudé             break;
53380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
53480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsl_d(cpu_env, twd, tws, twt);
53580e64a38SPhilippe Mathieu-Daudé             break;
53680e64a38SPhilippe Mathieu-Daudé         }
53780e64a38SPhilippe Mathieu-Daudé         break;
53880e64a38SPhilippe Mathieu-Daudé     case OPC_BINSR_df:
53980e64a38SPhilippe Mathieu-Daudé         switch (df) {
54080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
54180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsr_b(cpu_env, twd, tws, twt);
54280e64a38SPhilippe Mathieu-Daudé             break;
54380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
54480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsr_h(cpu_env, twd, tws, twt);
54580e64a38SPhilippe Mathieu-Daudé             break;
54680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
54780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsr_w(cpu_env, twd, tws, twt);
54880e64a38SPhilippe Mathieu-Daudé             break;
54980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
55080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_binsr_d(cpu_env, twd, tws, twt);
55180e64a38SPhilippe Mathieu-Daudé             break;
55280e64a38SPhilippe Mathieu-Daudé         }
55380e64a38SPhilippe Mathieu-Daudé         break;
55480e64a38SPhilippe Mathieu-Daudé     case OPC_BCLR_df:
55580e64a38SPhilippe Mathieu-Daudé         switch (df) {
55680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
55780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bclr_b(cpu_env, twd, tws, twt);
55880e64a38SPhilippe Mathieu-Daudé             break;
55980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
56080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bclr_h(cpu_env, twd, tws, twt);
56180e64a38SPhilippe Mathieu-Daudé             break;
56280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
56380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bclr_w(cpu_env, twd, tws, twt);
56480e64a38SPhilippe Mathieu-Daudé             break;
56580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
56680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bclr_d(cpu_env, twd, tws, twt);
56780e64a38SPhilippe Mathieu-Daudé             break;
56880e64a38SPhilippe Mathieu-Daudé         }
56980e64a38SPhilippe Mathieu-Daudé         break;
57080e64a38SPhilippe Mathieu-Daudé     case OPC_BNEG_df:
57180e64a38SPhilippe Mathieu-Daudé         switch (df) {
57280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
57380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bneg_b(cpu_env, twd, tws, twt);
57480e64a38SPhilippe Mathieu-Daudé             break;
57580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
57680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bneg_h(cpu_env, twd, tws, twt);
57780e64a38SPhilippe Mathieu-Daudé             break;
57880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
57980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bneg_w(cpu_env, twd, tws, twt);
58080e64a38SPhilippe Mathieu-Daudé             break;
58180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
58280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bneg_d(cpu_env, twd, tws, twt);
58380e64a38SPhilippe Mathieu-Daudé             break;
58480e64a38SPhilippe Mathieu-Daudé         }
58580e64a38SPhilippe Mathieu-Daudé         break;
58680e64a38SPhilippe Mathieu-Daudé     case OPC_BSET_df:
58780e64a38SPhilippe Mathieu-Daudé         switch (df) {
58880e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
58980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bset_b(cpu_env, twd, tws, twt);
59080e64a38SPhilippe Mathieu-Daudé             break;
59180e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
59280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bset_h(cpu_env, twd, tws, twt);
59380e64a38SPhilippe Mathieu-Daudé             break;
59480e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
59580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bset_w(cpu_env, twd, tws, twt);
59680e64a38SPhilippe Mathieu-Daudé             break;
59780e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
59880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_bset_d(cpu_env, twd, tws, twt);
59980e64a38SPhilippe Mathieu-Daudé             break;
60080e64a38SPhilippe Mathieu-Daudé         }
60180e64a38SPhilippe Mathieu-Daudé         break;
60280e64a38SPhilippe Mathieu-Daudé     case OPC_ADD_A_df:
60380e64a38SPhilippe Mathieu-Daudé         switch (df) {
60480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
60580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_add_a_b(cpu_env, twd, tws, twt);
60680e64a38SPhilippe Mathieu-Daudé             break;
60780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
60880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_add_a_h(cpu_env, twd, tws, twt);
60980e64a38SPhilippe Mathieu-Daudé             break;
61080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
61180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_add_a_w(cpu_env, twd, tws, twt);
61280e64a38SPhilippe Mathieu-Daudé             break;
61380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
61480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_add_a_d(cpu_env, twd, tws, twt);
61580e64a38SPhilippe Mathieu-Daudé             break;
61680e64a38SPhilippe Mathieu-Daudé         }
61780e64a38SPhilippe Mathieu-Daudé         break;
61880e64a38SPhilippe Mathieu-Daudé     case OPC_ADDS_A_df:
61980e64a38SPhilippe Mathieu-Daudé         switch (df) {
62080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
62180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_b(cpu_env, twd, tws, twt);
62280e64a38SPhilippe Mathieu-Daudé             break;
62380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
62480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_h(cpu_env, twd, tws, twt);
62580e64a38SPhilippe Mathieu-Daudé             break;
62680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
62780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_w(cpu_env, twd, tws, twt);
62880e64a38SPhilippe Mathieu-Daudé             break;
62980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
63080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_a_d(cpu_env, twd, tws, twt);
63180e64a38SPhilippe Mathieu-Daudé             break;
63280e64a38SPhilippe Mathieu-Daudé         }
63380e64a38SPhilippe Mathieu-Daudé         break;
63480e64a38SPhilippe Mathieu-Daudé     case OPC_ADDS_S_df:
63580e64a38SPhilippe Mathieu-Daudé         switch (df) {
63680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
63780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_b(cpu_env, twd, tws, twt);
63880e64a38SPhilippe Mathieu-Daudé             break;
63980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
64080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_h(cpu_env, twd, tws, twt);
64180e64a38SPhilippe Mathieu-Daudé             break;
64280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
64380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_w(cpu_env, twd, tws, twt);
64480e64a38SPhilippe Mathieu-Daudé             break;
64580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
64680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_s_d(cpu_env, twd, tws, twt);
64780e64a38SPhilippe Mathieu-Daudé             break;
64880e64a38SPhilippe Mathieu-Daudé         }
64980e64a38SPhilippe Mathieu-Daudé         break;
65080e64a38SPhilippe Mathieu-Daudé     case OPC_ADDS_U_df:
65180e64a38SPhilippe Mathieu-Daudé         switch (df) {
65280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
65380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_b(cpu_env, twd, tws, twt);
65480e64a38SPhilippe Mathieu-Daudé             break;
65580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
65680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_h(cpu_env, twd, tws, twt);
65780e64a38SPhilippe Mathieu-Daudé             break;
65880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
65980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_w(cpu_env, twd, tws, twt);
66080e64a38SPhilippe Mathieu-Daudé             break;
66180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
66280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_adds_u_d(cpu_env, twd, tws, twt);
66380e64a38SPhilippe Mathieu-Daudé             break;
66480e64a38SPhilippe Mathieu-Daudé         }
66580e64a38SPhilippe Mathieu-Daudé         break;
66680e64a38SPhilippe Mathieu-Daudé     case OPC_ADDV_df:
66780e64a38SPhilippe Mathieu-Daudé         switch (df) {
66880e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
66980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_addv_b(cpu_env, twd, tws, twt);
67080e64a38SPhilippe Mathieu-Daudé             break;
67180e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
67280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_addv_h(cpu_env, twd, tws, twt);
67380e64a38SPhilippe Mathieu-Daudé             break;
67480e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
67580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_addv_w(cpu_env, twd, tws, twt);
67680e64a38SPhilippe Mathieu-Daudé             break;
67780e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
67880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_addv_d(cpu_env, twd, tws, twt);
67980e64a38SPhilippe Mathieu-Daudé             break;
68080e64a38SPhilippe Mathieu-Daudé         }
68180e64a38SPhilippe Mathieu-Daudé         break;
68280e64a38SPhilippe Mathieu-Daudé     case OPC_AVE_S_df:
68380e64a38SPhilippe Mathieu-Daudé         switch (df) {
68480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
68580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_b(cpu_env, twd, tws, twt);
68680e64a38SPhilippe Mathieu-Daudé             break;
68780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
68880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_h(cpu_env, twd, tws, twt);
68980e64a38SPhilippe Mathieu-Daudé             break;
69080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
69180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_w(cpu_env, twd, tws, twt);
69280e64a38SPhilippe Mathieu-Daudé             break;
69380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
69480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_s_d(cpu_env, twd, tws, twt);
69580e64a38SPhilippe Mathieu-Daudé             break;
69680e64a38SPhilippe Mathieu-Daudé         }
69780e64a38SPhilippe Mathieu-Daudé         break;
69880e64a38SPhilippe Mathieu-Daudé     case OPC_AVE_U_df:
69980e64a38SPhilippe Mathieu-Daudé         switch (df) {
70080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
70180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_b(cpu_env, twd, tws, twt);
70280e64a38SPhilippe Mathieu-Daudé             break;
70380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
70480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_h(cpu_env, twd, tws, twt);
70580e64a38SPhilippe Mathieu-Daudé             break;
70680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
70780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_w(cpu_env, twd, tws, twt);
70880e64a38SPhilippe Mathieu-Daudé             break;
70980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
71080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ave_u_d(cpu_env, twd, tws, twt);
71180e64a38SPhilippe Mathieu-Daudé             break;
71280e64a38SPhilippe Mathieu-Daudé         }
71380e64a38SPhilippe Mathieu-Daudé         break;
71480e64a38SPhilippe Mathieu-Daudé     case OPC_AVER_S_df:
71580e64a38SPhilippe Mathieu-Daudé         switch (df) {
71680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
71780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_b(cpu_env, twd, tws, twt);
71880e64a38SPhilippe Mathieu-Daudé             break;
71980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
72080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_h(cpu_env, twd, tws, twt);
72180e64a38SPhilippe Mathieu-Daudé             break;
72280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
72380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_w(cpu_env, twd, tws, twt);
72480e64a38SPhilippe Mathieu-Daudé             break;
72580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
72680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_s_d(cpu_env, twd, tws, twt);
72780e64a38SPhilippe Mathieu-Daudé             break;
72880e64a38SPhilippe Mathieu-Daudé         }
72980e64a38SPhilippe Mathieu-Daudé         break;
73080e64a38SPhilippe Mathieu-Daudé     case OPC_AVER_U_df:
73180e64a38SPhilippe Mathieu-Daudé         switch (df) {
73280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
73380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_b(cpu_env, twd, tws, twt);
73480e64a38SPhilippe Mathieu-Daudé             break;
73580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
73680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_h(cpu_env, twd, tws, twt);
73780e64a38SPhilippe Mathieu-Daudé             break;
73880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
73980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_w(cpu_env, twd, tws, twt);
74080e64a38SPhilippe Mathieu-Daudé             break;
74180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
74280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_aver_u_d(cpu_env, twd, tws, twt);
74380e64a38SPhilippe Mathieu-Daudé             break;
74480e64a38SPhilippe Mathieu-Daudé         }
74580e64a38SPhilippe Mathieu-Daudé         break;
74680e64a38SPhilippe Mathieu-Daudé     case OPC_CEQ_df:
74780e64a38SPhilippe Mathieu-Daudé         switch (df) {
74880e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
74980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ceq_b(cpu_env, twd, tws, twt);
75080e64a38SPhilippe Mathieu-Daudé             break;
75180e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
75280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ceq_h(cpu_env, twd, tws, twt);
75380e64a38SPhilippe Mathieu-Daudé             break;
75480e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
75580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ceq_w(cpu_env, twd, tws, twt);
75680e64a38SPhilippe Mathieu-Daudé             break;
75780e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
75880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ceq_d(cpu_env, twd, tws, twt);
75980e64a38SPhilippe Mathieu-Daudé             break;
76080e64a38SPhilippe Mathieu-Daudé         }
76180e64a38SPhilippe Mathieu-Daudé         break;
76280e64a38SPhilippe Mathieu-Daudé     case OPC_CLE_S_df:
76380e64a38SPhilippe Mathieu-Daudé         switch (df) {
76480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
76580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_b(cpu_env, twd, tws, twt);
76680e64a38SPhilippe Mathieu-Daudé             break;
76780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
76880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_h(cpu_env, twd, tws, twt);
76980e64a38SPhilippe Mathieu-Daudé             break;
77080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
77180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_w(cpu_env, twd, tws, twt);
77280e64a38SPhilippe Mathieu-Daudé             break;
77380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
77480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_s_d(cpu_env, twd, tws, twt);
77580e64a38SPhilippe Mathieu-Daudé             break;
77680e64a38SPhilippe Mathieu-Daudé         }
77780e64a38SPhilippe Mathieu-Daudé         break;
77880e64a38SPhilippe Mathieu-Daudé     case OPC_CLE_U_df:
77980e64a38SPhilippe Mathieu-Daudé         switch (df) {
78080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
78180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_b(cpu_env, twd, tws, twt);
78280e64a38SPhilippe Mathieu-Daudé             break;
78380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
78480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_h(cpu_env, twd, tws, twt);
78580e64a38SPhilippe Mathieu-Daudé             break;
78680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
78780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_w(cpu_env, twd, tws, twt);
78880e64a38SPhilippe Mathieu-Daudé             break;
78980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
79080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_cle_u_d(cpu_env, twd, tws, twt);
79180e64a38SPhilippe Mathieu-Daudé             break;
79280e64a38SPhilippe Mathieu-Daudé         }
79380e64a38SPhilippe Mathieu-Daudé         break;
79480e64a38SPhilippe Mathieu-Daudé     case OPC_CLT_S_df:
79580e64a38SPhilippe Mathieu-Daudé         switch (df) {
79680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
79780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_b(cpu_env, twd, tws, twt);
79880e64a38SPhilippe Mathieu-Daudé             break;
79980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
80080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_h(cpu_env, twd, tws, twt);
80180e64a38SPhilippe Mathieu-Daudé             break;
80280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
80380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_w(cpu_env, twd, tws, twt);
80480e64a38SPhilippe Mathieu-Daudé             break;
80580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
80680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_s_d(cpu_env, twd, tws, twt);
80780e64a38SPhilippe Mathieu-Daudé             break;
80880e64a38SPhilippe Mathieu-Daudé         }
80980e64a38SPhilippe Mathieu-Daudé         break;
81080e64a38SPhilippe Mathieu-Daudé     case OPC_CLT_U_df:
81180e64a38SPhilippe Mathieu-Daudé         switch (df) {
81280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
81380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_b(cpu_env, twd, tws, twt);
81480e64a38SPhilippe Mathieu-Daudé             break;
81580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
81680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_h(cpu_env, twd, tws, twt);
81780e64a38SPhilippe Mathieu-Daudé             break;
81880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
81980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_w(cpu_env, twd, tws, twt);
82080e64a38SPhilippe Mathieu-Daudé             break;
82180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
82280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_clt_u_d(cpu_env, twd, tws, twt);
82380e64a38SPhilippe Mathieu-Daudé             break;
82480e64a38SPhilippe Mathieu-Daudé         }
82580e64a38SPhilippe Mathieu-Daudé         break;
82680e64a38SPhilippe Mathieu-Daudé     case OPC_DIV_S_df:
82780e64a38SPhilippe Mathieu-Daudé         switch (df) {
82880e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
82980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_s_b(cpu_env, twd, tws, twt);
83080e64a38SPhilippe Mathieu-Daudé             break;
83180e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
83280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_s_h(cpu_env, twd, tws, twt);
83380e64a38SPhilippe Mathieu-Daudé             break;
83480e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
83580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_s_w(cpu_env, twd, tws, twt);
83680e64a38SPhilippe Mathieu-Daudé             break;
83780e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
83880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_s_d(cpu_env, twd, tws, twt);
83980e64a38SPhilippe Mathieu-Daudé             break;
84080e64a38SPhilippe Mathieu-Daudé         }
84180e64a38SPhilippe Mathieu-Daudé         break;
84280e64a38SPhilippe Mathieu-Daudé     case OPC_DIV_U_df:
84380e64a38SPhilippe Mathieu-Daudé         switch (df) {
84480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
84580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_u_b(cpu_env, twd, tws, twt);
84680e64a38SPhilippe Mathieu-Daudé             break;
84780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
84880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_u_h(cpu_env, twd, tws, twt);
84980e64a38SPhilippe Mathieu-Daudé             break;
85080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
85180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_u_w(cpu_env, twd, tws, twt);
85280e64a38SPhilippe Mathieu-Daudé             break;
85380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
85480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_div_u_d(cpu_env, twd, tws, twt);
85580e64a38SPhilippe Mathieu-Daudé             break;
85680e64a38SPhilippe Mathieu-Daudé         }
85780e64a38SPhilippe Mathieu-Daudé         break;
85880e64a38SPhilippe Mathieu-Daudé     case OPC_MAX_A_df:
85980e64a38SPhilippe Mathieu-Daudé         switch (df) {
86080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
86180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_a_b(cpu_env, twd, tws, twt);
86280e64a38SPhilippe Mathieu-Daudé             break;
86380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
86480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_a_h(cpu_env, twd, tws, twt);
86580e64a38SPhilippe Mathieu-Daudé             break;
86680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
86780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_a_w(cpu_env, twd, tws, twt);
86880e64a38SPhilippe Mathieu-Daudé             break;
86980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
87080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_a_d(cpu_env, twd, tws, twt);
87180e64a38SPhilippe Mathieu-Daudé             break;
87280e64a38SPhilippe Mathieu-Daudé         }
87380e64a38SPhilippe Mathieu-Daudé         break;
87480e64a38SPhilippe Mathieu-Daudé     case OPC_MAX_S_df:
87580e64a38SPhilippe Mathieu-Daudé         switch (df) {
87680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
87780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_s_b(cpu_env, twd, tws, twt);
87880e64a38SPhilippe Mathieu-Daudé             break;
87980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
88080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_s_h(cpu_env, twd, tws, twt);
88180e64a38SPhilippe Mathieu-Daudé             break;
88280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
88380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_s_w(cpu_env, twd, tws, twt);
88480e64a38SPhilippe Mathieu-Daudé             break;
88580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
88680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_s_d(cpu_env, twd, tws, twt);
88780e64a38SPhilippe Mathieu-Daudé             break;
88880e64a38SPhilippe Mathieu-Daudé         }
88980e64a38SPhilippe Mathieu-Daudé         break;
89080e64a38SPhilippe Mathieu-Daudé     case OPC_MAX_U_df:
89180e64a38SPhilippe Mathieu-Daudé         switch (df) {
89280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
89380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_u_b(cpu_env, twd, tws, twt);
89480e64a38SPhilippe Mathieu-Daudé             break;
89580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
89680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_u_h(cpu_env, twd, tws, twt);
89780e64a38SPhilippe Mathieu-Daudé             break;
89880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
89980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_u_w(cpu_env, twd, tws, twt);
90080e64a38SPhilippe Mathieu-Daudé             break;
90180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
90280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_max_u_d(cpu_env, twd, tws, twt);
90380e64a38SPhilippe Mathieu-Daudé             break;
90480e64a38SPhilippe Mathieu-Daudé         }
90580e64a38SPhilippe Mathieu-Daudé         break;
90680e64a38SPhilippe Mathieu-Daudé     case OPC_MIN_A_df:
90780e64a38SPhilippe Mathieu-Daudé         switch (df) {
90880e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
90980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_a_b(cpu_env, twd, tws, twt);
91080e64a38SPhilippe Mathieu-Daudé             break;
91180e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
91280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_a_h(cpu_env, twd, tws, twt);
91380e64a38SPhilippe Mathieu-Daudé             break;
91480e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
91580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_a_w(cpu_env, twd, tws, twt);
91680e64a38SPhilippe Mathieu-Daudé             break;
91780e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
91880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_a_d(cpu_env, twd, tws, twt);
91980e64a38SPhilippe Mathieu-Daudé             break;
92080e64a38SPhilippe Mathieu-Daudé         }
92180e64a38SPhilippe Mathieu-Daudé         break;
92280e64a38SPhilippe Mathieu-Daudé     case OPC_MIN_S_df:
92380e64a38SPhilippe Mathieu-Daudé         switch (df) {
92480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
92580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_s_b(cpu_env, twd, tws, twt);
92680e64a38SPhilippe Mathieu-Daudé             break;
92780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
92880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_s_h(cpu_env, twd, tws, twt);
92980e64a38SPhilippe Mathieu-Daudé             break;
93080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
93180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_s_w(cpu_env, twd, tws, twt);
93280e64a38SPhilippe Mathieu-Daudé             break;
93380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
93480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_s_d(cpu_env, twd, tws, twt);
93580e64a38SPhilippe Mathieu-Daudé             break;
93680e64a38SPhilippe Mathieu-Daudé         }
93780e64a38SPhilippe Mathieu-Daudé         break;
93880e64a38SPhilippe Mathieu-Daudé     case OPC_MIN_U_df:
93980e64a38SPhilippe Mathieu-Daudé         switch (df) {
94080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
94180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_u_b(cpu_env, twd, tws, twt);
94280e64a38SPhilippe Mathieu-Daudé             break;
94380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
94480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_u_h(cpu_env, twd, tws, twt);
94580e64a38SPhilippe Mathieu-Daudé             break;
94680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
94780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_u_w(cpu_env, twd, tws, twt);
94880e64a38SPhilippe Mathieu-Daudé             break;
94980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
95080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_min_u_d(cpu_env, twd, tws, twt);
95180e64a38SPhilippe Mathieu-Daudé             break;
95280e64a38SPhilippe Mathieu-Daudé         }
95380e64a38SPhilippe Mathieu-Daudé         break;
95480e64a38SPhilippe Mathieu-Daudé     case OPC_MOD_S_df:
95580e64a38SPhilippe Mathieu-Daudé         switch (df) {
95680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
95780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_b(cpu_env, twd, tws, twt);
95880e64a38SPhilippe Mathieu-Daudé             break;
95980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
96080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_h(cpu_env, twd, tws, twt);
96180e64a38SPhilippe Mathieu-Daudé             break;
96280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
96380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_w(cpu_env, twd, tws, twt);
96480e64a38SPhilippe Mathieu-Daudé             break;
96580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
96680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_s_d(cpu_env, twd, tws, twt);
96780e64a38SPhilippe Mathieu-Daudé             break;
96880e64a38SPhilippe Mathieu-Daudé         }
96980e64a38SPhilippe Mathieu-Daudé         break;
97080e64a38SPhilippe Mathieu-Daudé     case OPC_MOD_U_df:
97180e64a38SPhilippe Mathieu-Daudé         switch (df) {
97280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
97380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_b(cpu_env, twd, tws, twt);
97480e64a38SPhilippe Mathieu-Daudé             break;
97580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
97680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_h(cpu_env, twd, tws, twt);
97780e64a38SPhilippe Mathieu-Daudé             break;
97880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
97980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_w(cpu_env, twd, tws, twt);
98080e64a38SPhilippe Mathieu-Daudé             break;
98180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
98280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mod_u_d(cpu_env, twd, tws, twt);
98380e64a38SPhilippe Mathieu-Daudé             break;
98480e64a38SPhilippe Mathieu-Daudé         }
98580e64a38SPhilippe Mathieu-Daudé         break;
98680e64a38SPhilippe Mathieu-Daudé     case OPC_MADDV_df:
98780e64a38SPhilippe Mathieu-Daudé         switch (df) {
98880e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
98980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_maddv_b(cpu_env, twd, tws, twt);
99080e64a38SPhilippe Mathieu-Daudé             break;
99180e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
99280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_maddv_h(cpu_env, twd, tws, twt);
99380e64a38SPhilippe Mathieu-Daudé             break;
99480e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
99580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_maddv_w(cpu_env, twd, tws, twt);
99680e64a38SPhilippe Mathieu-Daudé             break;
99780e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
99880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_maddv_d(cpu_env, twd, tws, twt);
99980e64a38SPhilippe Mathieu-Daudé             break;
100080e64a38SPhilippe Mathieu-Daudé         }
100180e64a38SPhilippe Mathieu-Daudé         break;
100280e64a38SPhilippe Mathieu-Daudé     case OPC_MSUBV_df:
100380e64a38SPhilippe Mathieu-Daudé         switch (df) {
100480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
100580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_msubv_b(cpu_env, twd, tws, twt);
100680e64a38SPhilippe Mathieu-Daudé             break;
100780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
100880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_msubv_h(cpu_env, twd, tws, twt);
100980e64a38SPhilippe Mathieu-Daudé             break;
101080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
101180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_msubv_w(cpu_env, twd, tws, twt);
101280e64a38SPhilippe Mathieu-Daudé             break;
101380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
101480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_msubv_d(cpu_env, twd, tws, twt);
101580e64a38SPhilippe Mathieu-Daudé             break;
101680e64a38SPhilippe Mathieu-Daudé         }
101780e64a38SPhilippe Mathieu-Daudé         break;
101880e64a38SPhilippe Mathieu-Daudé     case OPC_ASUB_S_df:
101980e64a38SPhilippe Mathieu-Daudé         switch (df) {
102080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
102180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_b(cpu_env, twd, tws, twt);
102280e64a38SPhilippe Mathieu-Daudé             break;
102380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
102480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_h(cpu_env, twd, tws, twt);
102580e64a38SPhilippe Mathieu-Daudé             break;
102680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
102780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_w(cpu_env, twd, tws, twt);
102880e64a38SPhilippe Mathieu-Daudé             break;
102980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
103080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_s_d(cpu_env, twd, tws, twt);
103180e64a38SPhilippe Mathieu-Daudé             break;
103280e64a38SPhilippe Mathieu-Daudé         }
103380e64a38SPhilippe Mathieu-Daudé         break;
103480e64a38SPhilippe Mathieu-Daudé     case OPC_ASUB_U_df:
103580e64a38SPhilippe Mathieu-Daudé         switch (df) {
103680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
103780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_b(cpu_env, twd, tws, twt);
103880e64a38SPhilippe Mathieu-Daudé             break;
103980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
104080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_h(cpu_env, twd, tws, twt);
104180e64a38SPhilippe Mathieu-Daudé             break;
104280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
104380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_w(cpu_env, twd, tws, twt);
104480e64a38SPhilippe Mathieu-Daudé             break;
104580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
104680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_asub_u_d(cpu_env, twd, tws, twt);
104780e64a38SPhilippe Mathieu-Daudé             break;
104880e64a38SPhilippe Mathieu-Daudé         }
104980e64a38SPhilippe Mathieu-Daudé         break;
105080e64a38SPhilippe Mathieu-Daudé     case OPC_ILVEV_df:
105180e64a38SPhilippe Mathieu-Daudé         switch (df) {
105280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
105380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_b(cpu_env, twd, tws, twt);
105480e64a38SPhilippe Mathieu-Daudé             break;
105580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
105680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_h(cpu_env, twd, tws, twt);
105780e64a38SPhilippe Mathieu-Daudé             break;
105880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
105980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_w(cpu_env, twd, tws, twt);
106080e64a38SPhilippe Mathieu-Daudé             break;
106180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
106280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvev_d(cpu_env, twd, tws, twt);
106380e64a38SPhilippe Mathieu-Daudé             break;
106480e64a38SPhilippe Mathieu-Daudé         }
106580e64a38SPhilippe Mathieu-Daudé         break;
106680e64a38SPhilippe Mathieu-Daudé     case OPC_ILVOD_df:
106780e64a38SPhilippe Mathieu-Daudé         switch (df) {
106880e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
106980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_b(cpu_env, twd, tws, twt);
107080e64a38SPhilippe Mathieu-Daudé             break;
107180e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
107280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_h(cpu_env, twd, tws, twt);
107380e64a38SPhilippe Mathieu-Daudé             break;
107480e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
107580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_w(cpu_env, twd, tws, twt);
107680e64a38SPhilippe Mathieu-Daudé             break;
107780e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
107880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvod_d(cpu_env, twd, tws, twt);
107980e64a38SPhilippe Mathieu-Daudé             break;
108080e64a38SPhilippe Mathieu-Daudé         }
108180e64a38SPhilippe Mathieu-Daudé         break;
108280e64a38SPhilippe Mathieu-Daudé     case OPC_ILVL_df:
108380e64a38SPhilippe Mathieu-Daudé         switch (df) {
108480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
108580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_b(cpu_env, twd, tws, twt);
108680e64a38SPhilippe Mathieu-Daudé             break;
108780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
108880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_h(cpu_env, twd, tws, twt);
108980e64a38SPhilippe Mathieu-Daudé             break;
109080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
109180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_w(cpu_env, twd, tws, twt);
109280e64a38SPhilippe Mathieu-Daudé             break;
109380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
109480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvl_d(cpu_env, twd, tws, twt);
109580e64a38SPhilippe Mathieu-Daudé             break;
109680e64a38SPhilippe Mathieu-Daudé         }
109780e64a38SPhilippe Mathieu-Daudé         break;
109880e64a38SPhilippe Mathieu-Daudé     case OPC_ILVR_df:
109980e64a38SPhilippe Mathieu-Daudé         switch (df) {
110080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
110180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_b(cpu_env, twd, tws, twt);
110280e64a38SPhilippe Mathieu-Daudé             break;
110380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
110480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_h(cpu_env, twd, tws, twt);
110580e64a38SPhilippe Mathieu-Daudé             break;
110680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
110780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_w(cpu_env, twd, tws, twt);
110880e64a38SPhilippe Mathieu-Daudé             break;
110980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
111080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_ilvr_d(cpu_env, twd, tws, twt);
111180e64a38SPhilippe Mathieu-Daudé             break;
111280e64a38SPhilippe Mathieu-Daudé         }
111380e64a38SPhilippe Mathieu-Daudé         break;
111480e64a38SPhilippe Mathieu-Daudé     case OPC_PCKEV_df:
111580e64a38SPhilippe Mathieu-Daudé         switch (df) {
111680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
111780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckev_b(cpu_env, twd, tws, twt);
111880e64a38SPhilippe Mathieu-Daudé             break;
111980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
112080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckev_h(cpu_env, twd, tws, twt);
112180e64a38SPhilippe Mathieu-Daudé             break;
112280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
112380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckev_w(cpu_env, twd, tws, twt);
112480e64a38SPhilippe Mathieu-Daudé             break;
112580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
112680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckev_d(cpu_env, twd, tws, twt);
112780e64a38SPhilippe Mathieu-Daudé             break;
112880e64a38SPhilippe Mathieu-Daudé         }
112980e64a38SPhilippe Mathieu-Daudé         break;
113080e64a38SPhilippe Mathieu-Daudé     case OPC_PCKOD_df:
113180e64a38SPhilippe Mathieu-Daudé         switch (df) {
113280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
113380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckod_b(cpu_env, twd, tws, twt);
113480e64a38SPhilippe Mathieu-Daudé             break;
113580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
113680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckod_h(cpu_env, twd, tws, twt);
113780e64a38SPhilippe Mathieu-Daudé             break;
113880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
113980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckod_w(cpu_env, twd, tws, twt);
114080e64a38SPhilippe Mathieu-Daudé             break;
114180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
114280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_pckod_d(cpu_env, twd, tws, twt);
114380e64a38SPhilippe Mathieu-Daudé             break;
114480e64a38SPhilippe Mathieu-Daudé         }
114580e64a38SPhilippe Mathieu-Daudé         break;
114680e64a38SPhilippe Mathieu-Daudé     case OPC_SLL_df:
114780e64a38SPhilippe Mathieu-Daudé         switch (df) {
114880e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
114980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sll_b(cpu_env, twd, tws, twt);
115080e64a38SPhilippe Mathieu-Daudé             break;
115180e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
115280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sll_h(cpu_env, twd, tws, twt);
115380e64a38SPhilippe Mathieu-Daudé             break;
115480e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
115580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sll_w(cpu_env, twd, tws, twt);
115680e64a38SPhilippe Mathieu-Daudé             break;
115780e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
115880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sll_d(cpu_env, twd, tws, twt);
115980e64a38SPhilippe Mathieu-Daudé             break;
116080e64a38SPhilippe Mathieu-Daudé         }
116180e64a38SPhilippe Mathieu-Daudé         break;
116280e64a38SPhilippe Mathieu-Daudé     case OPC_SRA_df:
116380e64a38SPhilippe Mathieu-Daudé         switch (df) {
116480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
116580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sra_b(cpu_env, twd, tws, twt);
116680e64a38SPhilippe Mathieu-Daudé             break;
116780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
116880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sra_h(cpu_env, twd, tws, twt);
116980e64a38SPhilippe Mathieu-Daudé             break;
117080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
117180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sra_w(cpu_env, twd, tws, twt);
117280e64a38SPhilippe Mathieu-Daudé             break;
117380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
117480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_sra_d(cpu_env, twd, tws, twt);
117580e64a38SPhilippe Mathieu-Daudé             break;
117680e64a38SPhilippe Mathieu-Daudé         }
117780e64a38SPhilippe Mathieu-Daudé         break;
117880e64a38SPhilippe Mathieu-Daudé     case OPC_SRAR_df:
117980e64a38SPhilippe Mathieu-Daudé         switch (df) {
118080e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
118180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srar_b(cpu_env, twd, tws, twt);
118280e64a38SPhilippe Mathieu-Daudé             break;
118380e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
118480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srar_h(cpu_env, twd, tws, twt);
118580e64a38SPhilippe Mathieu-Daudé             break;
118680e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
118780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srar_w(cpu_env, twd, tws, twt);
118880e64a38SPhilippe Mathieu-Daudé             break;
118980e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
119080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srar_d(cpu_env, twd, tws, twt);
119180e64a38SPhilippe Mathieu-Daudé             break;
119280e64a38SPhilippe Mathieu-Daudé         }
119380e64a38SPhilippe Mathieu-Daudé         break;
119480e64a38SPhilippe Mathieu-Daudé     case OPC_SRL_df:
119580e64a38SPhilippe Mathieu-Daudé         switch (df) {
119680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
119780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srl_b(cpu_env, twd, tws, twt);
119880e64a38SPhilippe Mathieu-Daudé             break;
119980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
120080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srl_h(cpu_env, twd, tws, twt);
120180e64a38SPhilippe Mathieu-Daudé             break;
120280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
120380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srl_w(cpu_env, twd, tws, twt);
120480e64a38SPhilippe Mathieu-Daudé             break;
120580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
120680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srl_d(cpu_env, twd, tws, twt);
120780e64a38SPhilippe Mathieu-Daudé             break;
120880e64a38SPhilippe Mathieu-Daudé         }
120980e64a38SPhilippe Mathieu-Daudé         break;
121080e64a38SPhilippe Mathieu-Daudé     case OPC_SRLR_df:
121180e64a38SPhilippe Mathieu-Daudé         switch (df) {
121280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
121380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srlr_b(cpu_env, twd, tws, twt);
121480e64a38SPhilippe Mathieu-Daudé             break;
121580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
121680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srlr_h(cpu_env, twd, tws, twt);
121780e64a38SPhilippe Mathieu-Daudé             break;
121880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
121980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srlr_w(cpu_env, twd, tws, twt);
122080e64a38SPhilippe Mathieu-Daudé             break;
122180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
122280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_srlr_d(cpu_env, twd, tws, twt);
122380e64a38SPhilippe Mathieu-Daudé             break;
122480e64a38SPhilippe Mathieu-Daudé         }
122580e64a38SPhilippe Mathieu-Daudé         break;
122680e64a38SPhilippe Mathieu-Daudé     case OPC_SUBS_S_df:
122780e64a38SPhilippe Mathieu-Daudé         switch (df) {
122880e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
122980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_b(cpu_env, twd, tws, twt);
123080e64a38SPhilippe Mathieu-Daudé             break;
123180e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
123280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_h(cpu_env, twd, tws, twt);
123380e64a38SPhilippe Mathieu-Daudé             break;
123480e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
123580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_w(cpu_env, twd, tws, twt);
123680e64a38SPhilippe Mathieu-Daudé             break;
123780e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
123880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_s_d(cpu_env, twd, tws, twt);
123980e64a38SPhilippe Mathieu-Daudé             break;
124080e64a38SPhilippe Mathieu-Daudé         }
124180e64a38SPhilippe Mathieu-Daudé         break;
124280e64a38SPhilippe Mathieu-Daudé     case OPC_MULV_df:
124380e64a38SPhilippe Mathieu-Daudé         switch (df) {
124480e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
124580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mulv_b(cpu_env, twd, tws, twt);
124680e64a38SPhilippe Mathieu-Daudé             break;
124780e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
124880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mulv_h(cpu_env, twd, tws, twt);
124980e64a38SPhilippe Mathieu-Daudé             break;
125080e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
125180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mulv_w(cpu_env, twd, tws, twt);
125280e64a38SPhilippe Mathieu-Daudé             break;
125380e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
125480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_mulv_d(cpu_env, twd, tws, twt);
125580e64a38SPhilippe Mathieu-Daudé             break;
125680e64a38SPhilippe Mathieu-Daudé         }
125780e64a38SPhilippe Mathieu-Daudé         break;
125880e64a38SPhilippe Mathieu-Daudé     case OPC_SLD_df:
125980e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_sld_df(cpu_env, tdf, twd, tws, twt);
126080e64a38SPhilippe Mathieu-Daudé         break;
126180e64a38SPhilippe Mathieu-Daudé     case OPC_VSHF_df:
126280e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_vshf_df(cpu_env, tdf, twd, tws, twt);
126380e64a38SPhilippe Mathieu-Daudé         break;
126480e64a38SPhilippe Mathieu-Daudé     case OPC_SUBV_df:
126580e64a38SPhilippe Mathieu-Daudé         switch (df) {
126680e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
126780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subv_b(cpu_env, twd, tws, twt);
126880e64a38SPhilippe Mathieu-Daudé             break;
126980e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
127080e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subv_h(cpu_env, twd, tws, twt);
127180e64a38SPhilippe Mathieu-Daudé             break;
127280e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
127380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subv_w(cpu_env, twd, tws, twt);
127480e64a38SPhilippe Mathieu-Daudé             break;
127580e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
127680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subv_d(cpu_env, twd, tws, twt);
127780e64a38SPhilippe Mathieu-Daudé             break;
127880e64a38SPhilippe Mathieu-Daudé         }
127980e64a38SPhilippe Mathieu-Daudé         break;
128080e64a38SPhilippe Mathieu-Daudé     case OPC_SUBS_U_df:
128180e64a38SPhilippe Mathieu-Daudé         switch (df) {
128280e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
128380e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_b(cpu_env, twd, tws, twt);
128480e64a38SPhilippe Mathieu-Daudé             break;
128580e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
128680e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_h(cpu_env, twd, tws, twt);
128780e64a38SPhilippe Mathieu-Daudé             break;
128880e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
128980e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_w(cpu_env, twd, tws, twt);
129080e64a38SPhilippe Mathieu-Daudé             break;
129180e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
129280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subs_u_d(cpu_env, twd, tws, twt);
129380e64a38SPhilippe Mathieu-Daudé             break;
129480e64a38SPhilippe Mathieu-Daudé         }
129580e64a38SPhilippe Mathieu-Daudé         break;
129680e64a38SPhilippe Mathieu-Daudé     case OPC_SPLAT_df:
129780e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_splat_df(cpu_env, tdf, twd, tws, twt);
129880e64a38SPhilippe Mathieu-Daudé         break;
129980e64a38SPhilippe Mathieu-Daudé     case OPC_SUBSUS_U_df:
130080e64a38SPhilippe Mathieu-Daudé         switch (df) {
130180e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
130280e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_b(cpu_env, twd, tws, twt);
130380e64a38SPhilippe Mathieu-Daudé             break;
130480e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
130580e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_h(cpu_env, twd, tws, twt);
130680e64a38SPhilippe Mathieu-Daudé             break;
130780e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
130880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_w(cpu_env, twd, tws, twt);
130980e64a38SPhilippe Mathieu-Daudé             break;
131080e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
131180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsus_u_d(cpu_env, twd, tws, twt);
131280e64a38SPhilippe Mathieu-Daudé             break;
131380e64a38SPhilippe Mathieu-Daudé         }
131480e64a38SPhilippe Mathieu-Daudé         break;
131580e64a38SPhilippe Mathieu-Daudé     case OPC_SUBSUU_S_df:
131680e64a38SPhilippe Mathieu-Daudé         switch (df) {
131780e64a38SPhilippe Mathieu-Daudé         case DF_BYTE:
131880e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_b(cpu_env, twd, tws, twt);
131980e64a38SPhilippe Mathieu-Daudé             break;
132080e64a38SPhilippe Mathieu-Daudé         case DF_HALF:
132180e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_h(cpu_env, twd, tws, twt);
132280e64a38SPhilippe Mathieu-Daudé             break;
132380e64a38SPhilippe Mathieu-Daudé         case DF_WORD:
132480e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_w(cpu_env, twd, tws, twt);
132580e64a38SPhilippe Mathieu-Daudé             break;
132680e64a38SPhilippe Mathieu-Daudé         case DF_DOUBLE:
132780e64a38SPhilippe Mathieu-Daudé             gen_helper_msa_subsuu_s_d(cpu_env, twd, tws, twt);
132880e64a38SPhilippe Mathieu-Daudé             break;
132980e64a38SPhilippe Mathieu-Daudé         }
133080e64a38SPhilippe Mathieu-Daudé         break;
133180e64a38SPhilippe Mathieu-Daudé 
133280e64a38SPhilippe Mathieu-Daudé     case OPC_DOTP_S_df:
133380e64a38SPhilippe Mathieu-Daudé     case OPC_DOTP_U_df:
133480e64a38SPhilippe Mathieu-Daudé     case OPC_DPADD_S_df:
133580e64a38SPhilippe Mathieu-Daudé     case OPC_DPADD_U_df:
133680e64a38SPhilippe Mathieu-Daudé     case OPC_DPSUB_S_df:
133780e64a38SPhilippe Mathieu-Daudé     case OPC_HADD_S_df:
133880e64a38SPhilippe Mathieu-Daudé     case OPC_DPSUB_U_df:
133980e64a38SPhilippe Mathieu-Daudé     case OPC_HADD_U_df:
134080e64a38SPhilippe Mathieu-Daudé     case OPC_HSUB_S_df:
134180e64a38SPhilippe Mathieu-Daudé     case OPC_HSUB_U_df:
134280e64a38SPhilippe Mathieu-Daudé         if (df == DF_BYTE) {
134380e64a38SPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
134480e64a38SPhilippe Mathieu-Daudé             break;
134580e64a38SPhilippe Mathieu-Daudé         }
134680e64a38SPhilippe Mathieu-Daudé         switch (MASK_MSA_3R(ctx->opcode)) {
134780e64a38SPhilippe Mathieu-Daudé         case OPC_HADD_S_df:
134880e64a38SPhilippe Mathieu-Daudé             switch (df) {
134980e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
135080e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_s_h(cpu_env, twd, tws, twt);
135180e64a38SPhilippe Mathieu-Daudé                 break;
135280e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
135380e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_s_w(cpu_env, twd, tws, twt);
135480e64a38SPhilippe Mathieu-Daudé                 break;
135580e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
135680e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_s_d(cpu_env, twd, tws, twt);
135780e64a38SPhilippe Mathieu-Daudé                 break;
135880e64a38SPhilippe Mathieu-Daudé             }
135980e64a38SPhilippe Mathieu-Daudé             break;
136080e64a38SPhilippe Mathieu-Daudé         case OPC_HADD_U_df:
136180e64a38SPhilippe Mathieu-Daudé             switch (df) {
136280e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
136380e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_u_h(cpu_env, twd, tws, twt);
136480e64a38SPhilippe Mathieu-Daudé                 break;
136580e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
136680e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_u_w(cpu_env, twd, tws, twt);
136780e64a38SPhilippe Mathieu-Daudé                 break;
136880e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
136980e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hadd_u_d(cpu_env, twd, tws, twt);
137080e64a38SPhilippe Mathieu-Daudé                 break;
137180e64a38SPhilippe Mathieu-Daudé             }
137280e64a38SPhilippe Mathieu-Daudé             break;
137380e64a38SPhilippe Mathieu-Daudé         case OPC_HSUB_S_df:
137480e64a38SPhilippe Mathieu-Daudé             switch (df) {
137580e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
137680e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_s_h(cpu_env, twd, tws, twt);
137780e64a38SPhilippe Mathieu-Daudé                 break;
137880e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
137980e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_s_w(cpu_env, twd, tws, twt);
138080e64a38SPhilippe Mathieu-Daudé                 break;
138180e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
138280e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_s_d(cpu_env, twd, tws, twt);
138380e64a38SPhilippe Mathieu-Daudé                 break;
138480e64a38SPhilippe Mathieu-Daudé             }
138580e64a38SPhilippe Mathieu-Daudé             break;
138680e64a38SPhilippe Mathieu-Daudé         case OPC_HSUB_U_df:
138780e64a38SPhilippe Mathieu-Daudé             switch (df) {
138880e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
138980e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_u_h(cpu_env, twd, tws, twt);
139080e64a38SPhilippe Mathieu-Daudé                 break;
139180e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
139280e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_u_w(cpu_env, twd, tws, twt);
139380e64a38SPhilippe Mathieu-Daudé                 break;
139480e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
139580e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_hsub_u_d(cpu_env, twd, tws, twt);
139680e64a38SPhilippe Mathieu-Daudé                 break;
139780e64a38SPhilippe Mathieu-Daudé             }
139880e64a38SPhilippe Mathieu-Daudé             break;
139980e64a38SPhilippe Mathieu-Daudé         case OPC_DOTP_S_df:
140080e64a38SPhilippe Mathieu-Daudé             switch (df) {
140180e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
140280e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_s_h(cpu_env, twd, tws, twt);
140380e64a38SPhilippe Mathieu-Daudé                 break;
140480e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
140580e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_s_w(cpu_env, twd, tws, twt);
140680e64a38SPhilippe Mathieu-Daudé                 break;
140780e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
140880e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_s_d(cpu_env, twd, tws, twt);
140980e64a38SPhilippe Mathieu-Daudé                 break;
141080e64a38SPhilippe Mathieu-Daudé             }
141180e64a38SPhilippe Mathieu-Daudé             break;
141280e64a38SPhilippe Mathieu-Daudé         case OPC_DOTP_U_df:
141380e64a38SPhilippe Mathieu-Daudé             switch (df) {
141480e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
141580e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_u_h(cpu_env, twd, tws, twt);
141680e64a38SPhilippe Mathieu-Daudé                 break;
141780e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
141880e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_u_w(cpu_env, twd, tws, twt);
141980e64a38SPhilippe Mathieu-Daudé                 break;
142080e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
142180e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dotp_u_d(cpu_env, twd, tws, twt);
142280e64a38SPhilippe Mathieu-Daudé                 break;
142380e64a38SPhilippe Mathieu-Daudé             }
142480e64a38SPhilippe Mathieu-Daudé             break;
142580e64a38SPhilippe Mathieu-Daudé         case OPC_DPADD_S_df:
142680e64a38SPhilippe Mathieu-Daudé             switch (df) {
142780e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
142880e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_s_h(cpu_env, twd, tws, twt);
142980e64a38SPhilippe Mathieu-Daudé                 break;
143080e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
143180e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_s_w(cpu_env, twd, tws, twt);
143280e64a38SPhilippe Mathieu-Daudé                 break;
143380e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
143480e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_s_d(cpu_env, twd, tws, twt);
143580e64a38SPhilippe Mathieu-Daudé                 break;
143680e64a38SPhilippe Mathieu-Daudé             }
143780e64a38SPhilippe Mathieu-Daudé             break;
143880e64a38SPhilippe Mathieu-Daudé         case OPC_DPADD_U_df:
143980e64a38SPhilippe Mathieu-Daudé             switch (df) {
144080e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
144180e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_u_h(cpu_env, twd, tws, twt);
144280e64a38SPhilippe Mathieu-Daudé                 break;
144380e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
144480e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_u_w(cpu_env, twd, tws, twt);
144580e64a38SPhilippe Mathieu-Daudé                 break;
144680e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
144780e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpadd_u_d(cpu_env, twd, tws, twt);
144880e64a38SPhilippe Mathieu-Daudé                 break;
144980e64a38SPhilippe Mathieu-Daudé             }
145080e64a38SPhilippe Mathieu-Daudé             break;
145180e64a38SPhilippe Mathieu-Daudé         case OPC_DPSUB_S_df:
145280e64a38SPhilippe Mathieu-Daudé             switch (df) {
145380e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
145480e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_s_h(cpu_env, twd, tws, twt);
145580e64a38SPhilippe Mathieu-Daudé                 break;
145680e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
145780e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_s_w(cpu_env, twd, tws, twt);
145880e64a38SPhilippe Mathieu-Daudé                 break;
145980e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
146080e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_s_d(cpu_env, twd, tws, twt);
146180e64a38SPhilippe Mathieu-Daudé                 break;
146280e64a38SPhilippe Mathieu-Daudé             }
146380e64a38SPhilippe Mathieu-Daudé             break;
146480e64a38SPhilippe Mathieu-Daudé         case OPC_DPSUB_U_df:
146580e64a38SPhilippe Mathieu-Daudé             switch (df) {
146680e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
146780e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_u_h(cpu_env, twd, tws, twt);
146880e64a38SPhilippe Mathieu-Daudé                 break;
146980e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
147080e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_u_w(cpu_env, twd, tws, twt);
147180e64a38SPhilippe Mathieu-Daudé                 break;
147280e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
147380e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_dpsub_u_d(cpu_env, twd, tws, twt);
147480e64a38SPhilippe Mathieu-Daudé                 break;
147580e64a38SPhilippe Mathieu-Daudé             }
147680e64a38SPhilippe Mathieu-Daudé             break;
147780e64a38SPhilippe Mathieu-Daudé         }
147880e64a38SPhilippe Mathieu-Daudé         break;
147980e64a38SPhilippe Mathieu-Daudé     default:
148080e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
148180e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
148280e64a38SPhilippe Mathieu-Daudé         break;
148380e64a38SPhilippe Mathieu-Daudé     }
148480e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
148580e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
148680e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twt);
148780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdf);
148880e64a38SPhilippe Mathieu-Daudé }
148980e64a38SPhilippe Mathieu-Daudé 
149080e64a38SPhilippe Mathieu-Daudé static void gen_msa_elm_3e(DisasContext *ctx)
149180e64a38SPhilippe Mathieu-Daudé {
149280e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_ELM_DF3E(op)   (MASK_MSA_MINOR(op) | (op & (0x3FF << 16)))
149380e64a38SPhilippe Mathieu-Daudé     uint8_t source = (ctx->opcode >> 11) & 0x1f;
149480e64a38SPhilippe Mathieu-Daudé     uint8_t dest = (ctx->opcode >> 6) & 0x1f;
149580e64a38SPhilippe Mathieu-Daudé     TCGv telm = tcg_temp_new();
149680e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tsr = tcg_const_i32(source);
149780e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tdt = tcg_const_i32(dest);
149880e64a38SPhilippe Mathieu-Daudé 
149980e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_ELM_DF3E(ctx->opcode)) {
150080e64a38SPhilippe Mathieu-Daudé     case OPC_CTCMSA:
150180e64a38SPhilippe Mathieu-Daudé         gen_load_gpr(telm, source);
150280e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_ctcmsa(cpu_env, telm, tdt);
150380e64a38SPhilippe Mathieu-Daudé         break;
150480e64a38SPhilippe Mathieu-Daudé     case OPC_CFCMSA:
150580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_cfcmsa(telm, cpu_env, tsr);
150680e64a38SPhilippe Mathieu-Daudé         gen_store_gpr(telm, dest);
150780e64a38SPhilippe Mathieu-Daudé         break;
150880e64a38SPhilippe Mathieu-Daudé     case OPC_MOVE_V:
150980e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_move_v(cpu_env, tdt, tsr);
151080e64a38SPhilippe Mathieu-Daudé         break;
151180e64a38SPhilippe Mathieu-Daudé     default:
151280e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
151380e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
151480e64a38SPhilippe Mathieu-Daudé         break;
151580e64a38SPhilippe Mathieu-Daudé     }
151680e64a38SPhilippe Mathieu-Daudé 
151780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free(telm);
151880e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tdt);
151980e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tsr);
152080e64a38SPhilippe Mathieu-Daudé }
152180e64a38SPhilippe Mathieu-Daudé 
152280e64a38SPhilippe Mathieu-Daudé static void gen_msa_elm_df(DisasContext *ctx, uint32_t df, uint32_t n)
152380e64a38SPhilippe Mathieu-Daudé {
152480e64a38SPhilippe Mathieu-Daudé #define MASK_MSA_ELM(op)    (MASK_MSA_MINOR(op) | (op & (0xf << 22)))
152580e64a38SPhilippe Mathieu-Daudé     uint8_t ws = (ctx->opcode >> 11) & 0x1f;
152680e64a38SPhilippe Mathieu-Daudé     uint8_t wd = (ctx->opcode >> 6) & 0x1f;
152780e64a38SPhilippe Mathieu-Daudé 
152880e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tws = tcg_const_i32(ws);
152980e64a38SPhilippe Mathieu-Daudé     TCGv_i32 twd = tcg_const_i32(wd);
153080e64a38SPhilippe Mathieu-Daudé     TCGv_i32 tn  = tcg_const_i32(n);
15312b537a3dSPhilippe Mathieu-Daudé     TCGv_i32 tdf = tcg_constant_i32(df);
153280e64a38SPhilippe Mathieu-Daudé 
153380e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_ELM(ctx->opcode)) {
153480e64a38SPhilippe Mathieu-Daudé     case OPC_SLDI_df:
153580e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_sldi_df(cpu_env, tdf, twd, tws, tn);
153680e64a38SPhilippe Mathieu-Daudé         break;
153780e64a38SPhilippe Mathieu-Daudé     case OPC_SPLATI_df:
153880e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_splati_df(cpu_env, tdf, twd, tws, tn);
153980e64a38SPhilippe Mathieu-Daudé         break;
154080e64a38SPhilippe Mathieu-Daudé     case OPC_INSVE_df:
154180e64a38SPhilippe Mathieu-Daudé         gen_helper_msa_insve_df(cpu_env, tdf, twd, tws, tn);
154280e64a38SPhilippe Mathieu-Daudé         break;
154380e64a38SPhilippe Mathieu-Daudé     case OPC_COPY_S_df:
154480e64a38SPhilippe Mathieu-Daudé     case OPC_COPY_U_df:
154580e64a38SPhilippe Mathieu-Daudé     case OPC_INSERT_df:
154680e64a38SPhilippe Mathieu-Daudé #if !defined(TARGET_MIPS64)
154780e64a38SPhilippe Mathieu-Daudé         /* Double format valid only for MIPS64 */
154880e64a38SPhilippe Mathieu-Daudé         if (df == DF_DOUBLE) {
154980e64a38SPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
155080e64a38SPhilippe Mathieu-Daudé             break;
155180e64a38SPhilippe Mathieu-Daudé         }
155280e64a38SPhilippe Mathieu-Daudé         if ((MASK_MSA_ELM(ctx->opcode) == OPC_COPY_U_df) &&
155380e64a38SPhilippe Mathieu-Daudé               (df == DF_WORD)) {
155480e64a38SPhilippe Mathieu-Daudé             gen_reserved_instruction(ctx);
155580e64a38SPhilippe Mathieu-Daudé             break;
155680e64a38SPhilippe Mathieu-Daudé         }
155780e64a38SPhilippe Mathieu-Daudé #endif
155880e64a38SPhilippe Mathieu-Daudé         switch (MASK_MSA_ELM(ctx->opcode)) {
155980e64a38SPhilippe Mathieu-Daudé         case OPC_COPY_S_df:
156080e64a38SPhilippe Mathieu-Daudé             if (likely(wd != 0)) {
156180e64a38SPhilippe Mathieu-Daudé                 switch (df) {
156280e64a38SPhilippe Mathieu-Daudé                 case DF_BYTE:
156380e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_b(cpu_env, twd, tws, tn);
156480e64a38SPhilippe Mathieu-Daudé                     break;
156580e64a38SPhilippe Mathieu-Daudé                 case DF_HALF:
156680e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_h(cpu_env, twd, tws, tn);
156780e64a38SPhilippe Mathieu-Daudé                     break;
156880e64a38SPhilippe Mathieu-Daudé                 case DF_WORD:
156980e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_w(cpu_env, twd, tws, tn);
157080e64a38SPhilippe Mathieu-Daudé                     break;
157180e64a38SPhilippe Mathieu-Daudé #if defined(TARGET_MIPS64)
157280e64a38SPhilippe Mathieu-Daudé                 case DF_DOUBLE:
157380e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_s_d(cpu_env, twd, tws, tn);
157480e64a38SPhilippe Mathieu-Daudé                     break;
157580e64a38SPhilippe Mathieu-Daudé #endif
157680e64a38SPhilippe Mathieu-Daudé                 default:
157780e64a38SPhilippe Mathieu-Daudé                     assert(0);
157880e64a38SPhilippe Mathieu-Daudé                 }
157980e64a38SPhilippe Mathieu-Daudé             }
158080e64a38SPhilippe Mathieu-Daudé             break;
158180e64a38SPhilippe Mathieu-Daudé         case OPC_COPY_U_df:
158280e64a38SPhilippe Mathieu-Daudé             if (likely(wd != 0)) {
158380e64a38SPhilippe Mathieu-Daudé                 switch (df) {
158480e64a38SPhilippe Mathieu-Daudé                 case DF_BYTE:
158580e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_u_b(cpu_env, twd, tws, tn);
158680e64a38SPhilippe Mathieu-Daudé                     break;
158780e64a38SPhilippe Mathieu-Daudé                 case DF_HALF:
158880e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_u_h(cpu_env, twd, tws, tn);
158980e64a38SPhilippe Mathieu-Daudé                     break;
159080e64a38SPhilippe Mathieu-Daudé #if defined(TARGET_MIPS64)
159180e64a38SPhilippe Mathieu-Daudé                 case DF_WORD:
159280e64a38SPhilippe Mathieu-Daudé                     gen_helper_msa_copy_u_w(cpu_env, twd, tws, tn);
159380e64a38SPhilippe Mathieu-Daudé                     break;
159480e64a38SPhilippe Mathieu-Daudé #endif
159580e64a38SPhilippe Mathieu-Daudé                 default:
159680e64a38SPhilippe Mathieu-Daudé                     assert(0);
159780e64a38SPhilippe Mathieu-Daudé                 }
159880e64a38SPhilippe Mathieu-Daudé             }
159980e64a38SPhilippe Mathieu-Daudé             break;
160080e64a38SPhilippe Mathieu-Daudé         case OPC_INSERT_df:
160180e64a38SPhilippe Mathieu-Daudé             switch (df) {
160280e64a38SPhilippe Mathieu-Daudé             case DF_BYTE:
160380e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_insert_b(cpu_env, twd, tws, tn);
160480e64a38SPhilippe Mathieu-Daudé                 break;
160580e64a38SPhilippe Mathieu-Daudé             case DF_HALF:
160680e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_insert_h(cpu_env, twd, tws, tn);
160780e64a38SPhilippe Mathieu-Daudé                 break;
160880e64a38SPhilippe Mathieu-Daudé             case DF_WORD:
160980e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_insert_w(cpu_env, twd, tws, tn);
161080e64a38SPhilippe Mathieu-Daudé                 break;
161180e64a38SPhilippe Mathieu-Daudé #if defined(TARGET_MIPS64)
161280e64a38SPhilippe Mathieu-Daudé             case DF_DOUBLE:
161380e64a38SPhilippe Mathieu-Daudé                 gen_helper_msa_insert_d(cpu_env, twd, tws, tn);
161480e64a38SPhilippe Mathieu-Daudé                 break;
161580e64a38SPhilippe Mathieu-Daudé #endif
161680e64a38SPhilippe Mathieu-Daudé             default:
161780e64a38SPhilippe Mathieu-Daudé                 assert(0);
161880e64a38SPhilippe Mathieu-Daudé             }
161980e64a38SPhilippe Mathieu-Daudé             break;
162080e64a38SPhilippe Mathieu-Daudé         }
162180e64a38SPhilippe Mathieu-Daudé         break;
162280e64a38SPhilippe Mathieu-Daudé     default:
162380e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
162480e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
162580e64a38SPhilippe Mathieu-Daudé     }
162680e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(twd);
162780e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tws);
162880e64a38SPhilippe Mathieu-Daudé     tcg_temp_free_i32(tn);
162980e64a38SPhilippe Mathieu-Daudé }
163080e64a38SPhilippe Mathieu-Daudé 
163180e64a38SPhilippe Mathieu-Daudé static void gen_msa_elm(DisasContext *ctx)
163280e64a38SPhilippe Mathieu-Daudé {
163380e64a38SPhilippe Mathieu-Daudé     uint8_t dfn = (ctx->opcode >> 16) & 0x3f;
163480e64a38SPhilippe Mathieu-Daudé     uint32_t df = 0, n = 0;
163580e64a38SPhilippe Mathieu-Daudé 
163680e64a38SPhilippe Mathieu-Daudé     if ((dfn & 0x30) == 0x00) {
163780e64a38SPhilippe Mathieu-Daudé         n = dfn & 0x0f;
163880e64a38SPhilippe Mathieu-Daudé         df = DF_BYTE;
163980e64a38SPhilippe Mathieu-Daudé     } else if ((dfn & 0x38) == 0x20) {
164080e64a38SPhilippe Mathieu-Daudé         n = dfn & 0x07;
164180e64a38SPhilippe Mathieu-Daudé         df = DF_HALF;
164280e64a38SPhilippe Mathieu-Daudé     } else if ((dfn & 0x3c) == 0x30) {
164380e64a38SPhilippe Mathieu-Daudé         n = dfn & 0x03;
164480e64a38SPhilippe Mathieu-Daudé         df = DF_WORD;
164580e64a38SPhilippe Mathieu-Daudé     } else if ((dfn & 0x3e) == 0x38) {
164680e64a38SPhilippe Mathieu-Daudé         n = dfn & 0x01;
164780e64a38SPhilippe Mathieu-Daudé         df = DF_DOUBLE;
164880e64a38SPhilippe Mathieu-Daudé     } else if (dfn == 0x3E) {
164980e64a38SPhilippe Mathieu-Daudé         /* CTCMSA, CFCMSA, MOVE.V */
165080e64a38SPhilippe Mathieu-Daudé         gen_msa_elm_3e(ctx);
165180e64a38SPhilippe Mathieu-Daudé         return;
165280e64a38SPhilippe Mathieu-Daudé     } else {
165380e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
165480e64a38SPhilippe Mathieu-Daudé         return;
165580e64a38SPhilippe Mathieu-Daudé     }
165680e64a38SPhilippe Mathieu-Daudé 
165780e64a38SPhilippe Mathieu-Daudé     gen_msa_elm_df(ctx, df, n);
165880e64a38SPhilippe Mathieu-Daudé }
165980e64a38SPhilippe Mathieu-Daudé 
1660*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCAF,     trans_msa_3rf, gen_helper_msa_fcaf_df);
1661*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCUN,     trans_msa_3rf, gen_helper_msa_fcun_df);
1662*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCEQ,     trans_msa_3rf, gen_helper_msa_fceq_df);
1663*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCUEQ,    trans_msa_3rf, gen_helper_msa_fcueq_df);
1664*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCLT,     trans_msa_3rf, gen_helper_msa_fclt_df);
1665*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCULT,    trans_msa_3rf, gen_helper_msa_fcult_df);
1666*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCLE,     trans_msa_3rf, gen_helper_msa_fcle_df);
1667*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCULE,    trans_msa_3rf, gen_helper_msa_fcule_df);
1668*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSAF,     trans_msa_3rf, gen_helper_msa_fsaf_df);
1669*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSUN,     trans_msa_3rf, gen_helper_msa_fsun_df);
1670*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSEQ,     trans_msa_3rf, gen_helper_msa_fseq_df);
1671*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSUEQ,    trans_msa_3rf, gen_helper_msa_fsueq_df);
1672*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSLT,     trans_msa_3rf, gen_helper_msa_fslt_df);
1673*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSULT,    trans_msa_3rf, gen_helper_msa_fsult_df);
1674*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSLE,     trans_msa_3rf, gen_helper_msa_fsle_df);
1675*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSULE,    trans_msa_3rf, gen_helper_msa_fsule_df);
1676*2d5246f3SPhilippe Mathieu-Daudé 
1677*2d5246f3SPhilippe Mathieu-Daudé TRANS(FADD,     trans_msa_3rf, gen_helper_msa_fadd_df);
1678*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSUB,     trans_msa_3rf, gen_helper_msa_fsub_df);
1679*2d5246f3SPhilippe Mathieu-Daudé TRANS(FMUL,     trans_msa_3rf, gen_helper_msa_fmul_df);
1680*2d5246f3SPhilippe Mathieu-Daudé TRANS(FDIV,     trans_msa_3rf, gen_helper_msa_fdiv_df);
1681*2d5246f3SPhilippe Mathieu-Daudé TRANS(FMADD,    trans_msa_3rf, gen_helper_msa_fmadd_df);
1682*2d5246f3SPhilippe Mathieu-Daudé TRANS(FMSUB,    trans_msa_3rf, gen_helper_msa_fmsub_df);
1683*2d5246f3SPhilippe Mathieu-Daudé TRANS(FEXP2,    trans_msa_3rf, gen_helper_msa_fexp2_df);
1684*2d5246f3SPhilippe Mathieu-Daudé TRANS(FEXDO,    trans_msa_3rf, gen_helper_msa_fexdo_df);
1685*2d5246f3SPhilippe Mathieu-Daudé TRANS(FTQ,      trans_msa_3rf, gen_helper_msa_ftq_df);
1686*2d5246f3SPhilippe Mathieu-Daudé TRANS(FMIN,     trans_msa_3rf, gen_helper_msa_fmin_df);
1687*2d5246f3SPhilippe Mathieu-Daudé TRANS(FMIN_A,   trans_msa_3rf, gen_helper_msa_fmin_a_df);
1688*2d5246f3SPhilippe Mathieu-Daudé TRANS(FMAX,     trans_msa_3rf, gen_helper_msa_fmax_df);
1689*2d5246f3SPhilippe Mathieu-Daudé TRANS(FMAX_A,   trans_msa_3rf, gen_helper_msa_fmax_a_df);
1690*2d5246f3SPhilippe Mathieu-Daudé 
1691*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCOR,     trans_msa_3rf, gen_helper_msa_fcor_df);
1692*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCUNE,    trans_msa_3rf, gen_helper_msa_fcune_df);
1693*2d5246f3SPhilippe Mathieu-Daudé TRANS(FCNE,     trans_msa_3rf, gen_helper_msa_fcne_df);
1694ff29e5d3SPhilippe Mathieu-Daudé TRANS(MUL_Q,    trans_msa_3rf, gen_helper_msa_mul_q_df);
1695ff29e5d3SPhilippe Mathieu-Daudé TRANS(MADD_Q,   trans_msa_3rf, gen_helper_msa_madd_q_df);
1696ff29e5d3SPhilippe Mathieu-Daudé TRANS(MSUB_Q,   trans_msa_3rf, gen_helper_msa_msub_q_df);
1697*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSOR,     trans_msa_3rf, gen_helper_msa_fsor_df);
1698*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSUNE,    trans_msa_3rf, gen_helper_msa_fsune_df);
1699*2d5246f3SPhilippe Mathieu-Daudé TRANS(FSNE,     trans_msa_3rf, gen_helper_msa_fsne_df);
1700ff29e5d3SPhilippe Mathieu-Daudé TRANS(MULR_Q,   trans_msa_3rf, gen_helper_msa_mulr_q_df);
1701ff29e5d3SPhilippe Mathieu-Daudé TRANS(MADDR_Q,  trans_msa_3rf, gen_helper_msa_maddr_q_df);
1702ff29e5d3SPhilippe Mathieu-Daudé TRANS(MSUBR_Q,  trans_msa_3rf, gen_helper_msa_msubr_q_df);
1703ff29e5d3SPhilippe Mathieu-Daudé 
1704adcff99aSPhilippe Mathieu-Daudé static bool trans_msa_2r(DisasContext *ctx, arg_msa_r *a,
1705adcff99aSPhilippe Mathieu-Daudé                          gen_helper_pii *gen_msa_2r)
170680e64a38SPhilippe Mathieu-Daudé {
1707adcff99aSPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
1708adcff99aSPhilippe Mathieu-Daudé         return true;
170980e64a38SPhilippe Mathieu-Daudé     }
171080e64a38SPhilippe Mathieu-Daudé 
1711adcff99aSPhilippe Mathieu-Daudé     gen_msa_2r(cpu_env, tcg_constant_i32(a->wd), tcg_constant_i32(a->ws));
1712adcff99aSPhilippe Mathieu-Daudé 
1713adcff99aSPhilippe Mathieu-Daudé     return true;
171480e64a38SPhilippe Mathieu-Daudé }
171580e64a38SPhilippe Mathieu-Daudé 
1716adcff99aSPhilippe Mathieu-Daudé TRANS_DF_ii(PCNT, trans_msa_2r, gen_helper_msa_pcnt);
1717adcff99aSPhilippe Mathieu-Daudé TRANS_DF_ii(NLOC, trans_msa_2r, gen_helper_msa_nloc);
1718adcff99aSPhilippe Mathieu-Daudé TRANS_DF_ii(NLZC, trans_msa_2r, gen_helper_msa_nlzc);
1719adcff99aSPhilippe Mathieu-Daudé 
1720675bf34aSPhilippe Mathieu-Daudé static bool trans_FILL(DisasContext *ctx, arg_msa_r *a)
1721675bf34aSPhilippe Mathieu-Daudé {
1722675bf34aSPhilippe Mathieu-Daudé     if (TARGET_LONG_BITS != 64 && a->df == DF_DOUBLE) {
1723675bf34aSPhilippe Mathieu-Daudé         /* Double format valid only for MIPS64 */
1724675bf34aSPhilippe Mathieu-Daudé         return false;
1725675bf34aSPhilippe Mathieu-Daudé     }
1726675bf34aSPhilippe Mathieu-Daudé 
1727675bf34aSPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
1728675bf34aSPhilippe Mathieu-Daudé         return true;
1729675bf34aSPhilippe Mathieu-Daudé     }
1730675bf34aSPhilippe Mathieu-Daudé 
1731675bf34aSPhilippe Mathieu-Daudé     gen_helper_msa_fill_df(cpu_env,
1732675bf34aSPhilippe Mathieu-Daudé                            tcg_constant_i32(a->df),
1733675bf34aSPhilippe Mathieu-Daudé                            tcg_constant_i32(a->wd),
1734675bf34aSPhilippe Mathieu-Daudé                            tcg_constant_i32(a->ws));
1735675bf34aSPhilippe Mathieu-Daudé 
1736675bf34aSPhilippe Mathieu-Daudé     return true;
1737675bf34aSPhilippe Mathieu-Daudé }
1738675bf34aSPhilippe Mathieu-Daudé 
17395c5b6400SPhilippe Mathieu-Daudé static bool trans_msa_2rf(DisasContext *ctx, arg_msa_r *a,
17405c5b6400SPhilippe Mathieu-Daudé                           gen_helper_piii *gen_msa_2rf)
174180e64a38SPhilippe Mathieu-Daudé {
17425c5b6400SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
17435c5b6400SPhilippe Mathieu-Daudé         return true;
174480e64a38SPhilippe Mathieu-Daudé     }
174580e64a38SPhilippe Mathieu-Daudé 
17465c5b6400SPhilippe Mathieu-Daudé     gen_msa_2rf(cpu_env,
17475c5b6400SPhilippe Mathieu-Daudé                 tcg_constant_i32(a->df),
17485c5b6400SPhilippe Mathieu-Daudé                 tcg_constant_i32(a->wd),
17495c5b6400SPhilippe Mathieu-Daudé                 tcg_constant_i32(a->ws));
17505c5b6400SPhilippe Mathieu-Daudé 
17515c5b6400SPhilippe Mathieu-Daudé     return true;
175280e64a38SPhilippe Mathieu-Daudé }
175380e64a38SPhilippe Mathieu-Daudé 
17545c5b6400SPhilippe Mathieu-Daudé TRANS(FCLASS,   trans_msa_2rf, gen_helper_msa_fclass_df);
17555c5b6400SPhilippe Mathieu-Daudé TRANS(FTRUNC_S, trans_msa_2rf, gen_helper_msa_fclass_df);
17565c5b6400SPhilippe Mathieu-Daudé TRANS(FTRUNC_U, trans_msa_2rf, gen_helper_msa_ftrunc_s_df);
17575c5b6400SPhilippe Mathieu-Daudé TRANS(FSQRT,    trans_msa_2rf, gen_helper_msa_fsqrt_df);
17585c5b6400SPhilippe Mathieu-Daudé TRANS(FRSQRT,   trans_msa_2rf, gen_helper_msa_frsqrt_df);
17595c5b6400SPhilippe Mathieu-Daudé TRANS(FRCP,     trans_msa_2rf, gen_helper_msa_frcp_df);
17605c5b6400SPhilippe Mathieu-Daudé TRANS(FRINT,    trans_msa_2rf, gen_helper_msa_frint_df);
17615c5b6400SPhilippe Mathieu-Daudé TRANS(FLOG2,    trans_msa_2rf, gen_helper_msa_flog2_df);
17625c5b6400SPhilippe Mathieu-Daudé TRANS(FEXUPL,   trans_msa_2rf, gen_helper_msa_fexupl_df);
17635c5b6400SPhilippe Mathieu-Daudé TRANS(FEXUPR,   trans_msa_2rf, gen_helper_msa_fexupr_df);
17645c5b6400SPhilippe Mathieu-Daudé TRANS(FFQL,     trans_msa_2rf, gen_helper_msa_ffql_df);
17655c5b6400SPhilippe Mathieu-Daudé TRANS(FFQR,     trans_msa_2rf, gen_helper_msa_ffqr_df);
17665c5b6400SPhilippe Mathieu-Daudé TRANS(FTINT_S,  trans_msa_2rf, gen_helper_msa_ftint_s_df);
17675c5b6400SPhilippe Mathieu-Daudé TRANS(FTINT_U,  trans_msa_2rf, gen_helper_msa_ftint_u_df);
17685c5b6400SPhilippe Mathieu-Daudé TRANS(FFINT_S,  trans_msa_2rf, gen_helper_msa_ffint_s_df);
17695c5b6400SPhilippe Mathieu-Daudé TRANS(FFINT_U,  trans_msa_2rf, gen_helper_msa_ffint_u_df);
17705c5b6400SPhilippe Mathieu-Daudé 
1771525ea877SPhilippe Mathieu-Daudé static bool trans_MSA(DisasContext *ctx, arg_MSA *a)
177280e64a38SPhilippe Mathieu-Daudé {
177380e64a38SPhilippe Mathieu-Daudé     uint32_t opcode = ctx->opcode;
177480e64a38SPhilippe Mathieu-Daudé 
1775340ee8b3SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
1776340ee8b3SPhilippe Mathieu-Daudé         return true;
1777340ee8b3SPhilippe Mathieu-Daudé     }
177880e64a38SPhilippe Mathieu-Daudé 
177980e64a38SPhilippe Mathieu-Daudé     switch (MASK_MSA_MINOR(opcode)) {
178080e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_0D:
178180e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_0E:
178280e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_0F:
178380e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_10:
178480e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_11:
178580e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_12:
178680e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_13:
178780e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_14:
178880e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_3R_15:
178980e64a38SPhilippe Mathieu-Daudé         gen_msa_3r(ctx);
179080e64a38SPhilippe Mathieu-Daudé         break;
179180e64a38SPhilippe Mathieu-Daudé     case OPC_MSA_ELM:
179280e64a38SPhilippe Mathieu-Daudé         gen_msa_elm(ctx);
179380e64a38SPhilippe Mathieu-Daudé         break;
179480e64a38SPhilippe Mathieu-Daudé     default:
179580e64a38SPhilippe Mathieu-Daudé         MIPS_INVAL("MSA instruction");
179680e64a38SPhilippe Mathieu-Daudé         gen_reserved_instruction(ctx);
179780e64a38SPhilippe Mathieu-Daudé         break;
179880e64a38SPhilippe Mathieu-Daudé     }
1799c7a9ef75SPhilippe Mathieu-Daudé 
1800c7a9ef75SPhilippe Mathieu-Daudé     return true;
1801c7a9ef75SPhilippe Mathieu-Daudé }
1802c7a9ef75SPhilippe Mathieu-Daudé 
1803ce121fe2SPhilippe Mathieu-Daudé static bool trans_msa_ldst(DisasContext *ctx, arg_msa_i *a,
1804ce121fe2SPhilippe Mathieu-Daudé                            gen_helper_piv *gen_msa_ldst)
1805ce121fe2SPhilippe Mathieu-Daudé {
1806ce121fe2SPhilippe Mathieu-Daudé     TCGv taddr;
1807ce121fe2SPhilippe Mathieu-Daudé 
1808ce121fe2SPhilippe Mathieu-Daudé     if (!check_msa_enabled(ctx)) {
1809ce121fe2SPhilippe Mathieu-Daudé         return true;
1810ce121fe2SPhilippe Mathieu-Daudé     }
1811ce121fe2SPhilippe Mathieu-Daudé 
1812ce121fe2SPhilippe Mathieu-Daudé     taddr = tcg_temp_new();
1813ce121fe2SPhilippe Mathieu-Daudé 
1814ce121fe2SPhilippe Mathieu-Daudé     gen_base_offset_addr(ctx, taddr, a->ws, a->sa << a->df);
1815ce121fe2SPhilippe Mathieu-Daudé     gen_msa_ldst(cpu_env, tcg_constant_i32(a->wd), taddr);
1816ce121fe2SPhilippe Mathieu-Daudé 
1817ce121fe2SPhilippe Mathieu-Daudé     tcg_temp_free(taddr);
1818ce121fe2SPhilippe Mathieu-Daudé 
1819ce121fe2SPhilippe Mathieu-Daudé     return true;
1820ce121fe2SPhilippe Mathieu-Daudé }
1821ce121fe2SPhilippe Mathieu-Daudé 
1822ce121fe2SPhilippe Mathieu-Daudé TRANS_DF_iv(LD, trans_msa_ldst, gen_helper_msa_ld);
1823ce121fe2SPhilippe Mathieu-Daudé TRANS_DF_iv(ST, trans_msa_ldst, gen_helper_msa_st);
1824ce121fe2SPhilippe Mathieu-Daudé 
182534fe9fa3SPhilippe Mathieu-Daudé static bool trans_LSA(DisasContext *ctx, arg_r *a)
18265f21f30dSPhilippe Mathieu-Daudé {
18275f21f30dSPhilippe Mathieu-Daudé     return gen_lsa(ctx, a->rd, a->rt, a->rs, a->sa);
18285f21f30dSPhilippe Mathieu-Daudé }
18295f21f30dSPhilippe Mathieu-Daudé 
183034fe9fa3SPhilippe Mathieu-Daudé static bool trans_DLSA(DisasContext *ctx, arg_r *a)
18315f21f30dSPhilippe Mathieu-Daudé {
1832f5c6ee0cSPhilippe Mathieu-Daudé     if (TARGET_LONG_BITS != 64) {
1833f5c6ee0cSPhilippe Mathieu-Daudé         return false;
1834f5c6ee0cSPhilippe Mathieu-Daudé     }
18355f21f30dSPhilippe Mathieu-Daudé     return gen_dlsa(ctx, a->rd, a->rt, a->rs, a->sa);
18365f21f30dSPhilippe Mathieu-Daudé }
1837