2 * MIPS emulation for QEMU - main translation routines
4 * Copyright (c) 2004-2005 Jocelyn Mayer
5 * Copyright (c) 2006 Marius Groeger (FPU operations)
6 * Copyright (c) 2006 Thiemo Seufer (MIPS32R2 support)
7 * Copyright (c) 2009 CodeSourcery (MIPS16 and microMIPS support)
8 * Copyright (c) 2012 Jia Liu & Dongxue Zhang (MIPS ASE DSP support)
9 * Copyright (c) 2020 Philippe Mathieu-Daudé
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
25 #include "qemu/osdep.h"
28 #include "tcg/tcg-op.h"
29 #include "exec/translator.h"
30 #include "exec/helper-proto.h"
31 #include "exec/helper-gen.h"
32 #include "semihosting/semihost.h"
35 #include "exec/translator.h"
37 #include "qemu/qemu-print.h"
38 #include "fpu_helper.h"
39 #include "translate.h"
42 * Many sysemu-only helpers are not reachable for user-only.
43 * Define stub generators here, so that we need not either sprinkle
44 * ifdefs through the translator, nor provide the helper function.
46 #define STUB_HELPER(NAME, ...) \
47 static inline void gen_helper_##NAME(__VA_ARGS__) \
48 { g_assert_not_reached(); }
50 #ifdef CONFIG_USER_ONLY
51 STUB_HELPER(cache
, TCGv_env env
, TCGv val
, TCGv_i32 reg
)
55 /* indirect opcode tables */
56 OPC_SPECIAL
= (0x00 << 26),
57 OPC_REGIMM
= (0x01 << 26),
58 OPC_CP0
= (0x10 << 26),
59 OPC_CP2
= (0x12 << 26),
60 OPC_CP3
= (0x13 << 26),
61 OPC_SPECIAL2
= (0x1C << 26),
62 OPC_SPECIAL3
= (0x1F << 26),
63 /* arithmetic with immediate */
64 OPC_ADDI
= (0x08 << 26),
65 OPC_ADDIU
= (0x09 << 26),
66 OPC_SLTI
= (0x0A << 26),
67 OPC_SLTIU
= (0x0B << 26),
68 /* logic with immediate */
69 OPC_ANDI
= (0x0C << 26),
70 OPC_ORI
= (0x0D << 26),
71 OPC_XORI
= (0x0E << 26),
72 OPC_LUI
= (0x0F << 26),
73 /* arithmetic with immediate */
74 OPC_DADDI
= (0x18 << 26),
75 OPC_DADDIU
= (0x19 << 26),
76 /* Jump and branches */
78 OPC_JAL
= (0x03 << 26),
79 OPC_BEQ
= (0x04 << 26), /* Unconditional if rs = rt = 0 (B) */
80 OPC_BEQL
= (0x14 << 26),
81 OPC_BNE
= (0x05 << 26),
82 OPC_BNEL
= (0x15 << 26),
83 OPC_BLEZ
= (0x06 << 26),
84 OPC_BLEZL
= (0x16 << 26),
85 OPC_BGTZ
= (0x07 << 26),
86 OPC_BGTZL
= (0x17 << 26),
87 OPC_JALX
= (0x1D << 26),
88 OPC_DAUI
= (0x1D << 26),
90 OPC_LDL
= (0x1A << 26),
91 OPC_LDR
= (0x1B << 26),
92 OPC_LB
= (0x20 << 26),
93 OPC_LH
= (0x21 << 26),
94 OPC_LWL
= (0x22 << 26),
95 OPC_LW
= (0x23 << 26),
96 OPC_LWPC
= OPC_LW
| 0x5,
97 OPC_LBU
= (0x24 << 26),
98 OPC_LHU
= (0x25 << 26),
99 OPC_LWR
= (0x26 << 26),
100 OPC_LWU
= (0x27 << 26),
101 OPC_SB
= (0x28 << 26),
102 OPC_SH
= (0x29 << 26),
103 OPC_SWL
= (0x2A << 26),
104 OPC_SW
= (0x2B << 26),
105 OPC_SDL
= (0x2C << 26),
106 OPC_SDR
= (0x2D << 26),
107 OPC_SWR
= (0x2E << 26),
108 OPC_LL
= (0x30 << 26),
109 OPC_LLD
= (0x34 << 26),
110 OPC_LD
= (0x37 << 26),
111 OPC_LDPC
= OPC_LD
| 0x5,
112 OPC_SC
= (0x38 << 26),
113 OPC_SCD
= (0x3C << 26),
114 OPC_SD
= (0x3F << 26),
115 /* Floating point load/store */
116 OPC_LWC1
= (0x31 << 26),
117 OPC_LWC2
= (0x32 << 26),
118 OPC_LDC1
= (0x35 << 26),
119 OPC_LDC2
= (0x36 << 26),
120 OPC_SWC1
= (0x39 << 26),
121 OPC_SWC2
= (0x3A << 26),
122 OPC_SDC1
= (0x3D << 26),
123 OPC_SDC2
= (0x3E << 26),
124 /* Compact Branches */
125 OPC_BLEZALC
= (0x06 << 26),
126 OPC_BGEZALC
= (0x06 << 26),
127 OPC_BGEUC
= (0x06 << 26),
128 OPC_BGTZALC
= (0x07 << 26),
129 OPC_BLTZALC
= (0x07 << 26),
130 OPC_BLTUC
= (0x07 << 26),
131 OPC_BOVC
= (0x08 << 26),
132 OPC_BEQZALC
= (0x08 << 26),
133 OPC_BEQC
= (0x08 << 26),
134 OPC_BLEZC
= (0x16 << 26),
135 OPC_BGEZC
= (0x16 << 26),
136 OPC_BGEC
= (0x16 << 26),
137 OPC_BGTZC
= (0x17 << 26),
138 OPC_BLTZC
= (0x17 << 26),
139 OPC_BLTC
= (0x17 << 26),
140 OPC_BNVC
= (0x18 << 26),
141 OPC_BNEZALC
= (0x18 << 26),
142 OPC_BNEC
= (0x18 << 26),
143 OPC_BC
= (0x32 << 26),
144 OPC_BEQZC
= (0x36 << 26),
145 OPC_JIC
= (0x36 << 26),
146 OPC_BALC
= (0x3A << 26),
147 OPC_BNEZC
= (0x3E << 26),
148 OPC_JIALC
= (0x3E << 26),
149 /* MDMX ASE specific */
150 OPC_MDMX
= (0x1E << 26),
151 /* Cache and prefetch */
152 OPC_CACHE
= (0x2F << 26),
153 OPC_PREF
= (0x33 << 26),
154 /* PC-relative address computation / loads */
155 OPC_PCREL
= (0x3B << 26),
158 /* PC-relative address computation / loads */
159 #define MASK_OPC_PCREL_TOP2BITS(op) (MASK_OP_MAJOR(op) | (op & (3 << 19)))
160 #define MASK_OPC_PCREL_TOP5BITS(op) (MASK_OP_MAJOR(op) | (op & (0x1f << 16)))
162 /* Instructions determined by bits 19 and 20 */
163 OPC_ADDIUPC
= OPC_PCREL
| (0 << 19),
164 R6_OPC_LWPC
= OPC_PCREL
| (1 << 19),
165 OPC_LWUPC
= OPC_PCREL
| (2 << 19),
167 /* Instructions determined by bits 16 ... 20 */
168 OPC_AUIPC
= OPC_PCREL
| (0x1e << 16),
169 OPC_ALUIPC
= OPC_PCREL
| (0x1f << 16),
172 R6_OPC_LDPC
= OPC_PCREL
| (6 << 18),
175 /* MIPS special opcodes */
176 #define MASK_SPECIAL(op) (MASK_OP_MAJOR(op) | (op & 0x3F))
180 OPC_SLL
= 0x00 | OPC_SPECIAL
,
181 /* NOP is SLL r0, r0, 0 */
182 /* SSNOP is SLL r0, r0, 1 */
183 /* EHB is SLL r0, r0, 3 */
184 OPC_SRL
= 0x02 | OPC_SPECIAL
, /* also ROTR */
185 OPC_ROTR
= OPC_SRL
| (1 << 21),
186 OPC_SRA
= 0x03 | OPC_SPECIAL
,
187 OPC_SLLV
= 0x04 | OPC_SPECIAL
,
188 OPC_SRLV
= 0x06 | OPC_SPECIAL
, /* also ROTRV */
189 OPC_ROTRV
= OPC_SRLV
| (1 << 6),
190 OPC_SRAV
= 0x07 | OPC_SPECIAL
,
191 OPC_DSLLV
= 0x14 | OPC_SPECIAL
,
192 OPC_DSRLV
= 0x16 | OPC_SPECIAL
, /* also DROTRV */
193 OPC_DROTRV
= OPC_DSRLV
| (1 << 6),
194 OPC_DSRAV
= 0x17 | OPC_SPECIAL
,
195 OPC_DSLL
= 0x38 | OPC_SPECIAL
,
196 OPC_DSRL
= 0x3A | OPC_SPECIAL
, /* also DROTR */
197 OPC_DROTR
= OPC_DSRL
| (1 << 21),
198 OPC_DSRA
= 0x3B | OPC_SPECIAL
,
199 OPC_DSLL32
= 0x3C | OPC_SPECIAL
,
200 OPC_DSRL32
= 0x3E | OPC_SPECIAL
, /* also DROTR32 */
201 OPC_DROTR32
= OPC_DSRL32
| (1 << 21),
202 OPC_DSRA32
= 0x3F | OPC_SPECIAL
,
203 /* Multiplication / division */
204 OPC_MULT
= 0x18 | OPC_SPECIAL
,
205 OPC_MULTU
= 0x19 | OPC_SPECIAL
,
206 OPC_DIV
= 0x1A | OPC_SPECIAL
,
207 OPC_DIVU
= 0x1B | OPC_SPECIAL
,
208 OPC_DMULT
= 0x1C | OPC_SPECIAL
,
209 OPC_DMULTU
= 0x1D | OPC_SPECIAL
,
210 OPC_DDIV
= 0x1E | OPC_SPECIAL
,
211 OPC_DDIVU
= 0x1F | OPC_SPECIAL
,
213 /* 2 registers arithmetic / logic */
214 OPC_ADD
= 0x20 | OPC_SPECIAL
,
215 OPC_ADDU
= 0x21 | OPC_SPECIAL
,
216 OPC_SUB
= 0x22 | OPC_SPECIAL
,
217 OPC_SUBU
= 0x23 | OPC_SPECIAL
,
218 OPC_AND
= 0x24 | OPC_SPECIAL
,
219 OPC_OR
= 0x25 | OPC_SPECIAL
,
220 OPC_XOR
= 0x26 | OPC_SPECIAL
,
221 OPC_NOR
= 0x27 | OPC_SPECIAL
,
222 OPC_SLT
= 0x2A | OPC_SPECIAL
,
223 OPC_SLTU
= 0x2B | OPC_SPECIAL
,
224 OPC_DADD
= 0x2C | OPC_SPECIAL
,
225 OPC_DADDU
= 0x2D | OPC_SPECIAL
,
226 OPC_DSUB
= 0x2E | OPC_SPECIAL
,
227 OPC_DSUBU
= 0x2F | OPC_SPECIAL
,
229 OPC_JR
= 0x08 | OPC_SPECIAL
, /* Also JR.HB */
230 OPC_JALR
= 0x09 | OPC_SPECIAL
, /* Also JALR.HB */
232 OPC_TGE
= 0x30 | OPC_SPECIAL
,
233 OPC_TGEU
= 0x31 | OPC_SPECIAL
,
234 OPC_TLT
= 0x32 | OPC_SPECIAL
,
235 OPC_TLTU
= 0x33 | OPC_SPECIAL
,
236 OPC_TEQ
= 0x34 | OPC_SPECIAL
,
237 OPC_TNE
= 0x36 | OPC_SPECIAL
,
238 /* HI / LO registers load & stores */
239 OPC_MFHI
= 0x10 | OPC_SPECIAL
,
240 OPC_MTHI
= 0x11 | OPC_SPECIAL
,
241 OPC_MFLO
= 0x12 | OPC_SPECIAL
,
242 OPC_MTLO
= 0x13 | OPC_SPECIAL
,
243 /* Conditional moves */
244 OPC_MOVZ
= 0x0A | OPC_SPECIAL
,
245 OPC_MOVN
= 0x0B | OPC_SPECIAL
,
247 OPC_SELEQZ
= 0x35 | OPC_SPECIAL
,
248 OPC_SELNEZ
= 0x37 | OPC_SPECIAL
,
250 OPC_MOVCI
= 0x01 | OPC_SPECIAL
,
253 OPC_PMON
= 0x05 | OPC_SPECIAL
, /* unofficial */
254 OPC_SYSCALL
= 0x0C | OPC_SPECIAL
,
255 OPC_BREAK
= 0x0D | OPC_SPECIAL
,
256 OPC_SPIM
= 0x0E | OPC_SPECIAL
, /* unofficial */
257 OPC_SYNC
= 0x0F | OPC_SPECIAL
,
259 OPC_SPECIAL28_RESERVED
= 0x28 | OPC_SPECIAL
,
260 OPC_SPECIAL29_RESERVED
= 0x29 | OPC_SPECIAL
,
261 OPC_SPECIAL39_RESERVED
= 0x39 | OPC_SPECIAL
,
262 OPC_SPECIAL3D_RESERVED
= 0x3D | OPC_SPECIAL
,
266 * R6 Multiply and Divide instructions have the same opcode
267 * and function field as legacy OPC_MULT[U]/OPC_DIV[U]
269 #define MASK_R6_MULDIV(op) (MASK_SPECIAL(op) | (op & (0x7ff)))
272 R6_OPC_MUL
= OPC_MULT
| (2 << 6),
273 R6_OPC_MUH
= OPC_MULT
| (3 << 6),
274 R6_OPC_MULU
= OPC_MULTU
| (2 << 6),
275 R6_OPC_MUHU
= OPC_MULTU
| (3 << 6),
276 R6_OPC_DIV
= OPC_DIV
| (2 << 6),
277 R6_OPC_MOD
= OPC_DIV
| (3 << 6),
278 R6_OPC_DIVU
= OPC_DIVU
| (2 << 6),
279 R6_OPC_MODU
= OPC_DIVU
| (3 << 6),
281 R6_OPC_DMUL
= OPC_DMULT
| (2 << 6),
282 R6_OPC_DMUH
= OPC_DMULT
| (3 << 6),
283 R6_OPC_DMULU
= OPC_DMULTU
| (2 << 6),
284 R6_OPC_DMUHU
= OPC_DMULTU
| (3 << 6),
285 R6_OPC_DDIV
= OPC_DDIV
| (2 << 6),
286 R6_OPC_DMOD
= OPC_DDIV
| (3 << 6),
287 R6_OPC_DDIVU
= OPC_DDIVU
| (2 << 6),
288 R6_OPC_DMODU
= OPC_DDIVU
| (3 << 6),
290 R6_OPC_CLZ
= 0x10 | OPC_SPECIAL
,
291 R6_OPC_CLO
= 0x11 | OPC_SPECIAL
,
292 R6_OPC_DCLZ
= 0x12 | OPC_SPECIAL
,
293 R6_OPC_DCLO
= 0x13 | OPC_SPECIAL
,
294 R6_OPC_SDBBP
= 0x0e | OPC_SPECIAL
,
297 /* REGIMM (rt field) opcodes */
298 #define MASK_REGIMM(op) (MASK_OP_MAJOR(op) | (op & (0x1F << 16)))
301 OPC_BLTZ
= (0x00 << 16) | OPC_REGIMM
,
302 OPC_BLTZL
= (0x02 << 16) | OPC_REGIMM
,
303 OPC_BGEZ
= (0x01 << 16) | OPC_REGIMM
,
304 OPC_BGEZL
= (0x03 << 16) | OPC_REGIMM
,
305 OPC_BLTZAL
= (0x10 << 16) | OPC_REGIMM
,
306 OPC_BLTZALL
= (0x12 << 16) | OPC_REGIMM
,
307 OPC_BGEZAL
= (0x11 << 16) | OPC_REGIMM
,
308 OPC_BGEZALL
= (0x13 << 16) | OPC_REGIMM
,
309 OPC_TGEI
= (0x08 << 16) | OPC_REGIMM
,
310 OPC_TGEIU
= (0x09 << 16) | OPC_REGIMM
,
311 OPC_TLTI
= (0x0A << 16) | OPC_REGIMM
,
312 OPC_TLTIU
= (0x0B << 16) | OPC_REGIMM
,
313 OPC_TEQI
= (0x0C << 16) | OPC_REGIMM
,
314 OPC_TNEI
= (0x0E << 16) | OPC_REGIMM
,
315 OPC_SIGRIE
= (0x17 << 16) | OPC_REGIMM
,
316 OPC_SYNCI
= (0x1F << 16) | OPC_REGIMM
,
318 OPC_DAHI
= (0x06 << 16) | OPC_REGIMM
,
319 OPC_DATI
= (0x1e << 16) | OPC_REGIMM
,
322 /* Special2 opcodes */
323 #define MASK_SPECIAL2(op) (MASK_OP_MAJOR(op) | (op & 0x3F))
326 /* Multiply & xxx operations */
327 OPC_MADD
= 0x00 | OPC_SPECIAL2
,
328 OPC_MADDU
= 0x01 | OPC_SPECIAL2
,
329 OPC_MUL
= 0x02 | OPC_SPECIAL2
,
330 OPC_MSUB
= 0x04 | OPC_SPECIAL2
,
331 OPC_MSUBU
= 0x05 | OPC_SPECIAL2
,
333 OPC_MULT_G_2F
= 0x10 | OPC_SPECIAL2
,
334 OPC_DMULT_G_2F
= 0x11 | OPC_SPECIAL2
,
335 OPC_MULTU_G_2F
= 0x12 | OPC_SPECIAL2
,
336 OPC_DMULTU_G_2F
= 0x13 | OPC_SPECIAL2
,
337 OPC_DIV_G_2F
= 0x14 | OPC_SPECIAL2
,
338 OPC_DDIV_G_2F
= 0x15 | OPC_SPECIAL2
,
339 OPC_DIVU_G_2F
= 0x16 | OPC_SPECIAL2
,
340 OPC_DDIVU_G_2F
= 0x17 | OPC_SPECIAL2
,
341 OPC_MOD_G_2F
= 0x1c | OPC_SPECIAL2
,
342 OPC_DMOD_G_2F
= 0x1d | OPC_SPECIAL2
,
343 OPC_MODU_G_2F
= 0x1e | OPC_SPECIAL2
,
344 OPC_DMODU_G_2F
= 0x1f | OPC_SPECIAL2
,
346 OPC_CLZ
= 0x20 | OPC_SPECIAL2
,
347 OPC_CLO
= 0x21 | OPC_SPECIAL2
,
348 OPC_DCLZ
= 0x24 | OPC_SPECIAL2
,
349 OPC_DCLO
= 0x25 | OPC_SPECIAL2
,
351 OPC_SDBBP
= 0x3F | OPC_SPECIAL2
,
354 /* Special3 opcodes */
355 #define MASK_SPECIAL3(op) (MASK_OP_MAJOR(op) | (op & 0x3F))
358 OPC_EXT
= 0x00 | OPC_SPECIAL3
,
359 OPC_DEXTM
= 0x01 | OPC_SPECIAL3
,
360 OPC_DEXTU
= 0x02 | OPC_SPECIAL3
,
361 OPC_DEXT
= 0x03 | OPC_SPECIAL3
,
362 OPC_INS
= 0x04 | OPC_SPECIAL3
,
363 OPC_DINSM
= 0x05 | OPC_SPECIAL3
,
364 OPC_DINSU
= 0x06 | OPC_SPECIAL3
,
365 OPC_DINS
= 0x07 | OPC_SPECIAL3
,
366 OPC_FORK
= 0x08 | OPC_SPECIAL3
,
367 OPC_YIELD
= 0x09 | OPC_SPECIAL3
,
368 OPC_BSHFL
= 0x20 | OPC_SPECIAL3
,
369 OPC_DBSHFL
= 0x24 | OPC_SPECIAL3
,
370 OPC_RDHWR
= 0x3B | OPC_SPECIAL3
,
371 OPC_GINV
= 0x3D | OPC_SPECIAL3
,
374 OPC_MULT_G_2E
= 0x18 | OPC_SPECIAL3
,
375 OPC_MULTU_G_2E
= 0x19 | OPC_SPECIAL3
,
376 OPC_DIV_G_2E
= 0x1A | OPC_SPECIAL3
,
377 OPC_DIVU_G_2E
= 0x1B | OPC_SPECIAL3
,
378 OPC_DMULT_G_2E
= 0x1C | OPC_SPECIAL3
,
379 OPC_DMULTU_G_2E
= 0x1D | OPC_SPECIAL3
,
380 OPC_DDIV_G_2E
= 0x1E | OPC_SPECIAL3
,
381 OPC_DDIVU_G_2E
= 0x1F | OPC_SPECIAL3
,
382 OPC_MOD_G_2E
= 0x22 | OPC_SPECIAL3
,
383 OPC_MODU_G_2E
= 0x23 | OPC_SPECIAL3
,
384 OPC_DMOD_G_2E
= 0x26 | OPC_SPECIAL3
,
385 OPC_DMODU_G_2E
= 0x27 | OPC_SPECIAL3
,
388 OPC_LX_DSP
= 0x0A | OPC_SPECIAL3
,
389 /* MIPS DSP Arithmetic */
390 OPC_ADDU_QB_DSP
= 0x10 | OPC_SPECIAL3
,
391 OPC_ADDU_OB_DSP
= 0x14 | OPC_SPECIAL3
,
392 OPC_ABSQ_S_PH_DSP
= 0x12 | OPC_SPECIAL3
,
393 OPC_ABSQ_S_QH_DSP
= 0x16 | OPC_SPECIAL3
,
394 /* OPC_ADDUH_QB_DSP is same as OPC_MULT_G_2E. */
395 /* OPC_ADDUH_QB_DSP = 0x18 | OPC_SPECIAL3, */
396 OPC_CMPU_EQ_QB_DSP
= 0x11 | OPC_SPECIAL3
,
397 OPC_CMPU_EQ_OB_DSP
= 0x15 | OPC_SPECIAL3
,
398 /* MIPS DSP GPR-Based Shift Sub-class */
399 OPC_SHLL_QB_DSP
= 0x13 | OPC_SPECIAL3
,
400 OPC_SHLL_OB_DSP
= 0x17 | OPC_SPECIAL3
,
401 /* MIPS DSP Multiply Sub-class insns */
402 /* OPC_MUL_PH_DSP is same as OPC_ADDUH_QB_DSP. */
403 /* OPC_MUL_PH_DSP = 0x18 | OPC_SPECIAL3, */
404 OPC_DPA_W_PH_DSP
= 0x30 | OPC_SPECIAL3
,
405 OPC_DPAQ_W_QH_DSP
= 0x34 | OPC_SPECIAL3
,
406 /* DSP Bit/Manipulation Sub-class */
407 OPC_INSV_DSP
= 0x0C | OPC_SPECIAL3
,
408 OPC_DINSV_DSP
= 0x0D | OPC_SPECIAL3
,
409 /* MIPS DSP Append Sub-class */
410 OPC_APPEND_DSP
= 0x31 | OPC_SPECIAL3
,
411 OPC_DAPPEND_DSP
= 0x35 | OPC_SPECIAL3
,
412 /* MIPS DSP Accumulator and DSPControl Access Sub-class */
413 OPC_EXTR_W_DSP
= 0x38 | OPC_SPECIAL3
,
414 OPC_DEXTR_W_DSP
= 0x3C | OPC_SPECIAL3
,
417 OPC_LWLE
= 0x19 | OPC_SPECIAL3
,
418 OPC_LWRE
= 0x1A | OPC_SPECIAL3
,
419 OPC_CACHEE
= 0x1B | OPC_SPECIAL3
,
420 OPC_SBE
= 0x1C | OPC_SPECIAL3
,
421 OPC_SHE
= 0x1D | OPC_SPECIAL3
,
422 OPC_SCE
= 0x1E | OPC_SPECIAL3
,
423 OPC_SWE
= 0x1F | OPC_SPECIAL3
,
424 OPC_SWLE
= 0x21 | OPC_SPECIAL3
,
425 OPC_SWRE
= 0x22 | OPC_SPECIAL3
,
426 OPC_PREFE
= 0x23 | OPC_SPECIAL3
,
427 OPC_LBUE
= 0x28 | OPC_SPECIAL3
,
428 OPC_LHUE
= 0x29 | OPC_SPECIAL3
,
429 OPC_LBE
= 0x2C | OPC_SPECIAL3
,
430 OPC_LHE
= 0x2D | OPC_SPECIAL3
,
431 OPC_LLE
= 0x2E | OPC_SPECIAL3
,
432 OPC_LWE
= 0x2F | OPC_SPECIAL3
,
435 R6_OPC_PREF
= 0x35 | OPC_SPECIAL3
,
436 R6_OPC_CACHE
= 0x25 | OPC_SPECIAL3
,
437 R6_OPC_LL
= 0x36 | OPC_SPECIAL3
,
438 R6_OPC_SC
= 0x26 | OPC_SPECIAL3
,
439 R6_OPC_LLD
= 0x37 | OPC_SPECIAL3
,
440 R6_OPC_SCD
= 0x27 | OPC_SPECIAL3
,
443 /* Loongson EXT load/store quad word opcodes */
444 #define MASK_LOONGSON_GSLSQ(op) (MASK_OP_MAJOR(op) | (op & 0x8020))
446 OPC_GSLQ
= 0x0020 | OPC_LWC2
,
447 OPC_GSLQC1
= 0x8020 | OPC_LWC2
,
448 OPC_GSSHFL
= OPC_LWC2
,
449 OPC_GSSQ
= 0x0020 | OPC_SWC2
,
450 OPC_GSSQC1
= 0x8020 | OPC_SWC2
,
451 OPC_GSSHFS
= OPC_SWC2
,
454 /* Loongson EXT shifted load/store opcodes */
455 #define MASK_LOONGSON_GSSHFLS(op) (MASK_OP_MAJOR(op) | (op & 0xc03f))
457 OPC_GSLWLC1
= 0x4 | OPC_GSSHFL
,
458 OPC_GSLWRC1
= 0x5 | OPC_GSSHFL
,
459 OPC_GSLDLC1
= 0x6 | OPC_GSSHFL
,
460 OPC_GSLDRC1
= 0x7 | OPC_GSSHFL
,
461 OPC_GSSWLC1
= 0x4 | OPC_GSSHFS
,
462 OPC_GSSWRC1
= 0x5 | OPC_GSSHFS
,
463 OPC_GSSDLC1
= 0x6 | OPC_GSSHFS
,
464 OPC_GSSDRC1
= 0x7 | OPC_GSSHFS
,
467 /* Loongson EXT LDC2/SDC2 opcodes */
468 #define MASK_LOONGSON_LSDC2(op) (MASK_OP_MAJOR(op) | (op & 0x7))
471 OPC_GSLBX
= 0x0 | OPC_LDC2
,
472 OPC_GSLHX
= 0x1 | OPC_LDC2
,
473 OPC_GSLWX
= 0x2 | OPC_LDC2
,
474 OPC_GSLDX
= 0x3 | OPC_LDC2
,
475 OPC_GSLWXC1
= 0x6 | OPC_LDC2
,
476 OPC_GSLDXC1
= 0x7 | OPC_LDC2
,
477 OPC_GSSBX
= 0x0 | OPC_SDC2
,
478 OPC_GSSHX
= 0x1 | OPC_SDC2
,
479 OPC_GSSWX
= 0x2 | OPC_SDC2
,
480 OPC_GSSDX
= 0x3 | OPC_SDC2
,
481 OPC_GSSWXC1
= 0x6 | OPC_SDC2
,
482 OPC_GSSDXC1
= 0x7 | OPC_SDC2
,
486 #define MASK_BSHFL(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
489 OPC_WSBH
= (0x02 << 6) | OPC_BSHFL
,
490 OPC_SEB
= (0x10 << 6) | OPC_BSHFL
,
491 OPC_SEH
= (0x18 << 6) | OPC_BSHFL
,
492 OPC_ALIGN
= (0x08 << 6) | OPC_BSHFL
, /* 010.bp (010.00 to 010.11) */
493 OPC_ALIGN_1
= (0x09 << 6) | OPC_BSHFL
,
494 OPC_ALIGN_2
= (0x0A << 6) | OPC_BSHFL
,
495 OPC_ALIGN_3
= (0x0B << 6) | OPC_BSHFL
,
496 OPC_BITSWAP
= (0x00 << 6) | OPC_BSHFL
/* 00000 */
500 #define MASK_DBSHFL(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
503 OPC_DSBH
= (0x02 << 6) | OPC_DBSHFL
,
504 OPC_DSHD
= (0x05 << 6) | OPC_DBSHFL
,
505 OPC_DALIGN
= (0x08 << 6) | OPC_DBSHFL
, /* 01.bp (01.000 to 01.111) */
506 OPC_DALIGN_1
= (0x09 << 6) | OPC_DBSHFL
,
507 OPC_DALIGN_2
= (0x0A << 6) | OPC_DBSHFL
,
508 OPC_DALIGN_3
= (0x0B << 6) | OPC_DBSHFL
,
509 OPC_DALIGN_4
= (0x0C << 6) | OPC_DBSHFL
,
510 OPC_DALIGN_5
= (0x0D << 6) | OPC_DBSHFL
,
511 OPC_DALIGN_6
= (0x0E << 6) | OPC_DBSHFL
,
512 OPC_DALIGN_7
= (0x0F << 6) | OPC_DBSHFL
,
513 OPC_DBITSWAP
= (0x00 << 6) | OPC_DBSHFL
, /* 00000 */
516 /* MIPS DSP REGIMM opcodes */
518 OPC_BPOSGE32
= (0x1C << 16) | OPC_REGIMM
,
519 OPC_BPOSGE64
= (0x1D << 16) | OPC_REGIMM
,
522 #define MASK_LX(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
525 OPC_LBUX
= (0x06 << 6) | OPC_LX_DSP
,
526 OPC_LHX
= (0x04 << 6) | OPC_LX_DSP
,
527 OPC_LWX
= (0x00 << 6) | OPC_LX_DSP
,
528 OPC_LDX
= (0x08 << 6) | OPC_LX_DSP
,
531 #define MASK_ADDU_QB(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
533 /* MIPS DSP Arithmetic Sub-class */
534 OPC_ADDQ_PH
= (0x0A << 6) | OPC_ADDU_QB_DSP
,
535 OPC_ADDQ_S_PH
= (0x0E << 6) | OPC_ADDU_QB_DSP
,
536 OPC_ADDQ_S_W
= (0x16 << 6) | OPC_ADDU_QB_DSP
,
537 OPC_ADDU_QB
= (0x00 << 6) | OPC_ADDU_QB_DSP
,
538 OPC_ADDU_S_QB
= (0x04 << 6) | OPC_ADDU_QB_DSP
,
539 OPC_ADDU_PH
= (0x08 << 6) | OPC_ADDU_QB_DSP
,
540 OPC_ADDU_S_PH
= (0x0C << 6) | OPC_ADDU_QB_DSP
,
541 OPC_SUBQ_PH
= (0x0B << 6) | OPC_ADDU_QB_DSP
,
542 OPC_SUBQ_S_PH
= (0x0F << 6) | OPC_ADDU_QB_DSP
,
543 OPC_SUBQ_S_W
= (0x17 << 6) | OPC_ADDU_QB_DSP
,
544 OPC_SUBU_QB
= (0x01 << 6) | OPC_ADDU_QB_DSP
,
545 OPC_SUBU_S_QB
= (0x05 << 6) | OPC_ADDU_QB_DSP
,
546 OPC_SUBU_PH
= (0x09 << 6) | OPC_ADDU_QB_DSP
,
547 OPC_SUBU_S_PH
= (0x0D << 6) | OPC_ADDU_QB_DSP
,
548 OPC_ADDSC
= (0x10 << 6) | OPC_ADDU_QB_DSP
,
549 OPC_ADDWC
= (0x11 << 6) | OPC_ADDU_QB_DSP
,
550 OPC_MODSUB
= (0x12 << 6) | OPC_ADDU_QB_DSP
,
551 OPC_RADDU_W_QB
= (0x14 << 6) | OPC_ADDU_QB_DSP
,
552 /* MIPS DSP Multiply Sub-class insns */
553 OPC_MULEU_S_PH_QBL
= (0x06 << 6) | OPC_ADDU_QB_DSP
,
554 OPC_MULEU_S_PH_QBR
= (0x07 << 6) | OPC_ADDU_QB_DSP
,
555 OPC_MULQ_RS_PH
= (0x1F << 6) | OPC_ADDU_QB_DSP
,
556 OPC_MULEQ_S_W_PHL
= (0x1C << 6) | OPC_ADDU_QB_DSP
,
557 OPC_MULEQ_S_W_PHR
= (0x1D << 6) | OPC_ADDU_QB_DSP
,
558 OPC_MULQ_S_PH
= (0x1E << 6) | OPC_ADDU_QB_DSP
,
561 #define OPC_ADDUH_QB_DSP OPC_MULT_G_2E
562 #define MASK_ADDUH_QB(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
564 /* MIPS DSP Arithmetic Sub-class */
565 OPC_ADDUH_QB
= (0x00 << 6) | OPC_ADDUH_QB_DSP
,
566 OPC_ADDUH_R_QB
= (0x02 << 6) | OPC_ADDUH_QB_DSP
,
567 OPC_ADDQH_PH
= (0x08 << 6) | OPC_ADDUH_QB_DSP
,
568 OPC_ADDQH_R_PH
= (0x0A << 6) | OPC_ADDUH_QB_DSP
,
569 OPC_ADDQH_W
= (0x10 << 6) | OPC_ADDUH_QB_DSP
,
570 OPC_ADDQH_R_W
= (0x12 << 6) | OPC_ADDUH_QB_DSP
,
571 OPC_SUBUH_QB
= (0x01 << 6) | OPC_ADDUH_QB_DSP
,
572 OPC_SUBUH_R_QB
= (0x03 << 6) | OPC_ADDUH_QB_DSP
,
573 OPC_SUBQH_PH
= (0x09 << 6) | OPC_ADDUH_QB_DSP
,
574 OPC_SUBQH_R_PH
= (0x0B << 6) | OPC_ADDUH_QB_DSP
,
575 OPC_SUBQH_W
= (0x11 << 6) | OPC_ADDUH_QB_DSP
,
576 OPC_SUBQH_R_W
= (0x13 << 6) | OPC_ADDUH_QB_DSP
,
577 /* MIPS DSP Multiply Sub-class insns */
578 OPC_MUL_PH
= (0x0C << 6) | OPC_ADDUH_QB_DSP
,
579 OPC_MUL_S_PH
= (0x0E << 6) | OPC_ADDUH_QB_DSP
,
580 OPC_MULQ_S_W
= (0x16 << 6) | OPC_ADDUH_QB_DSP
,
581 OPC_MULQ_RS_W
= (0x17 << 6) | OPC_ADDUH_QB_DSP
,
584 #define MASK_ABSQ_S_PH(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
586 /* MIPS DSP Arithmetic Sub-class */
587 OPC_ABSQ_S_QB
= (0x01 << 6) | OPC_ABSQ_S_PH_DSP
,
588 OPC_ABSQ_S_PH
= (0x09 << 6) | OPC_ABSQ_S_PH_DSP
,
589 OPC_ABSQ_S_W
= (0x11 << 6) | OPC_ABSQ_S_PH_DSP
,
590 OPC_PRECEQ_W_PHL
= (0x0C << 6) | OPC_ABSQ_S_PH_DSP
,
591 OPC_PRECEQ_W_PHR
= (0x0D << 6) | OPC_ABSQ_S_PH_DSP
,
592 OPC_PRECEQU_PH_QBL
= (0x04 << 6) | OPC_ABSQ_S_PH_DSP
,
593 OPC_PRECEQU_PH_QBR
= (0x05 << 6) | OPC_ABSQ_S_PH_DSP
,
594 OPC_PRECEQU_PH_QBLA
= (0x06 << 6) | OPC_ABSQ_S_PH_DSP
,
595 OPC_PRECEQU_PH_QBRA
= (0x07 << 6) | OPC_ABSQ_S_PH_DSP
,
596 OPC_PRECEU_PH_QBL
= (0x1C << 6) | OPC_ABSQ_S_PH_DSP
,
597 OPC_PRECEU_PH_QBR
= (0x1D << 6) | OPC_ABSQ_S_PH_DSP
,
598 OPC_PRECEU_PH_QBLA
= (0x1E << 6) | OPC_ABSQ_S_PH_DSP
,
599 OPC_PRECEU_PH_QBRA
= (0x1F << 6) | OPC_ABSQ_S_PH_DSP
,
600 /* DSP Bit/Manipulation Sub-class */
601 OPC_BITREV
= (0x1B << 6) | OPC_ABSQ_S_PH_DSP
,
602 OPC_REPL_QB
= (0x02 << 6) | OPC_ABSQ_S_PH_DSP
,
603 OPC_REPLV_QB
= (0x03 << 6) | OPC_ABSQ_S_PH_DSP
,
604 OPC_REPL_PH
= (0x0A << 6) | OPC_ABSQ_S_PH_DSP
,
605 OPC_REPLV_PH
= (0x0B << 6) | OPC_ABSQ_S_PH_DSP
,
608 #define MASK_CMPU_EQ_QB(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
610 /* MIPS DSP Arithmetic Sub-class */
611 OPC_PRECR_QB_PH
= (0x0D << 6) | OPC_CMPU_EQ_QB_DSP
,
612 OPC_PRECRQ_QB_PH
= (0x0C << 6) | OPC_CMPU_EQ_QB_DSP
,
613 OPC_PRECR_SRA_PH_W
= (0x1E << 6) | OPC_CMPU_EQ_QB_DSP
,
614 OPC_PRECR_SRA_R_PH_W
= (0x1F << 6) | OPC_CMPU_EQ_QB_DSP
,
615 OPC_PRECRQ_PH_W
= (0x14 << 6) | OPC_CMPU_EQ_QB_DSP
,
616 OPC_PRECRQ_RS_PH_W
= (0x15 << 6) | OPC_CMPU_EQ_QB_DSP
,
617 OPC_PRECRQU_S_QB_PH
= (0x0F << 6) | OPC_CMPU_EQ_QB_DSP
,
618 /* DSP Compare-Pick Sub-class */
619 OPC_CMPU_EQ_QB
= (0x00 << 6) | OPC_CMPU_EQ_QB_DSP
,
620 OPC_CMPU_LT_QB
= (0x01 << 6) | OPC_CMPU_EQ_QB_DSP
,
621 OPC_CMPU_LE_QB
= (0x02 << 6) | OPC_CMPU_EQ_QB_DSP
,
622 OPC_CMPGU_EQ_QB
= (0x04 << 6) | OPC_CMPU_EQ_QB_DSP
,
623 OPC_CMPGU_LT_QB
= (0x05 << 6) | OPC_CMPU_EQ_QB_DSP
,
624 OPC_CMPGU_LE_QB
= (0x06 << 6) | OPC_CMPU_EQ_QB_DSP
,
625 OPC_CMPGDU_EQ_QB
= (0x18 << 6) | OPC_CMPU_EQ_QB_DSP
,
626 OPC_CMPGDU_LT_QB
= (0x19 << 6) | OPC_CMPU_EQ_QB_DSP
,
627 OPC_CMPGDU_LE_QB
= (0x1A << 6) | OPC_CMPU_EQ_QB_DSP
,
628 OPC_CMP_EQ_PH
= (0x08 << 6) | OPC_CMPU_EQ_QB_DSP
,
629 OPC_CMP_LT_PH
= (0x09 << 6) | OPC_CMPU_EQ_QB_DSP
,
630 OPC_CMP_LE_PH
= (0x0A << 6) | OPC_CMPU_EQ_QB_DSP
,
631 OPC_PICK_QB
= (0x03 << 6) | OPC_CMPU_EQ_QB_DSP
,
632 OPC_PICK_PH
= (0x0B << 6) | OPC_CMPU_EQ_QB_DSP
,
633 OPC_PACKRL_PH
= (0x0E << 6) | OPC_CMPU_EQ_QB_DSP
,
636 #define MASK_SHLL_QB(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
638 /* MIPS DSP GPR-Based Shift Sub-class */
639 OPC_SHLL_QB
= (0x00 << 6) | OPC_SHLL_QB_DSP
,
640 OPC_SHLLV_QB
= (0x02 << 6) | OPC_SHLL_QB_DSP
,
641 OPC_SHLL_PH
= (0x08 << 6) | OPC_SHLL_QB_DSP
,
642 OPC_SHLLV_PH
= (0x0A << 6) | OPC_SHLL_QB_DSP
,
643 OPC_SHLL_S_PH
= (0x0C << 6) | OPC_SHLL_QB_DSP
,
644 OPC_SHLLV_S_PH
= (0x0E << 6) | OPC_SHLL_QB_DSP
,
645 OPC_SHLL_S_W
= (0x14 << 6) | OPC_SHLL_QB_DSP
,
646 OPC_SHLLV_S_W
= (0x16 << 6) | OPC_SHLL_QB_DSP
,
647 OPC_SHRL_QB
= (0x01 << 6) | OPC_SHLL_QB_DSP
,
648 OPC_SHRLV_QB
= (0x03 << 6) | OPC_SHLL_QB_DSP
,
649 OPC_SHRL_PH
= (0x19 << 6) | OPC_SHLL_QB_DSP
,
650 OPC_SHRLV_PH
= (0x1B << 6) | OPC_SHLL_QB_DSP
,
651 OPC_SHRA_QB
= (0x04 << 6) | OPC_SHLL_QB_DSP
,
652 OPC_SHRA_R_QB
= (0x05 << 6) | OPC_SHLL_QB_DSP
,
653 OPC_SHRAV_QB
= (0x06 << 6) | OPC_SHLL_QB_DSP
,
654 OPC_SHRAV_R_QB
= (0x07 << 6) | OPC_SHLL_QB_DSP
,
655 OPC_SHRA_PH
= (0x09 << 6) | OPC_SHLL_QB_DSP
,
656 OPC_SHRAV_PH
= (0x0B << 6) | OPC_SHLL_QB_DSP
,
657 OPC_SHRA_R_PH
= (0x0D << 6) | OPC_SHLL_QB_DSP
,
658 OPC_SHRAV_R_PH
= (0x0F << 6) | OPC_SHLL_QB_DSP
,
659 OPC_SHRA_R_W
= (0x15 << 6) | OPC_SHLL_QB_DSP
,
660 OPC_SHRAV_R_W
= (0x17 << 6) | OPC_SHLL_QB_DSP
,
663 #define MASK_DPA_W_PH(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
665 /* MIPS DSP Multiply Sub-class insns */
666 OPC_DPAU_H_QBL
= (0x03 << 6) | OPC_DPA_W_PH_DSP
,
667 OPC_DPAU_H_QBR
= (0x07 << 6) | OPC_DPA_W_PH_DSP
,
668 OPC_DPSU_H_QBL
= (0x0B << 6) | OPC_DPA_W_PH_DSP
,
669 OPC_DPSU_H_QBR
= (0x0F << 6) | OPC_DPA_W_PH_DSP
,
670 OPC_DPA_W_PH
= (0x00 << 6) | OPC_DPA_W_PH_DSP
,
671 OPC_DPAX_W_PH
= (0x08 << 6) | OPC_DPA_W_PH_DSP
,
672 OPC_DPAQ_S_W_PH
= (0x04 << 6) | OPC_DPA_W_PH_DSP
,
673 OPC_DPAQX_S_W_PH
= (0x18 << 6) | OPC_DPA_W_PH_DSP
,
674 OPC_DPAQX_SA_W_PH
= (0x1A << 6) | OPC_DPA_W_PH_DSP
,
675 OPC_DPS_W_PH
= (0x01 << 6) | OPC_DPA_W_PH_DSP
,
676 OPC_DPSX_W_PH
= (0x09 << 6) | OPC_DPA_W_PH_DSP
,
677 OPC_DPSQ_S_W_PH
= (0x05 << 6) | OPC_DPA_W_PH_DSP
,
678 OPC_DPSQX_S_W_PH
= (0x19 << 6) | OPC_DPA_W_PH_DSP
,
679 OPC_DPSQX_SA_W_PH
= (0x1B << 6) | OPC_DPA_W_PH_DSP
,
680 OPC_MULSAQ_S_W_PH
= (0x06 << 6) | OPC_DPA_W_PH_DSP
,
681 OPC_DPAQ_SA_L_W
= (0x0C << 6) | OPC_DPA_W_PH_DSP
,
682 OPC_DPSQ_SA_L_W
= (0x0D << 6) | OPC_DPA_W_PH_DSP
,
683 OPC_MAQ_S_W_PHL
= (0x14 << 6) | OPC_DPA_W_PH_DSP
,
684 OPC_MAQ_S_W_PHR
= (0x16 << 6) | OPC_DPA_W_PH_DSP
,
685 OPC_MAQ_SA_W_PHL
= (0x10 << 6) | OPC_DPA_W_PH_DSP
,
686 OPC_MAQ_SA_W_PHR
= (0x12 << 6) | OPC_DPA_W_PH_DSP
,
687 OPC_MULSA_W_PH
= (0x02 << 6) | OPC_DPA_W_PH_DSP
,
690 #define MASK_INSV(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
692 /* DSP Bit/Manipulation Sub-class */
693 OPC_INSV
= (0x00 << 6) | OPC_INSV_DSP
,
696 #define MASK_APPEND(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
698 /* MIPS DSP Append Sub-class */
699 OPC_APPEND
= (0x00 << 6) | OPC_APPEND_DSP
,
700 OPC_PREPEND
= (0x01 << 6) | OPC_APPEND_DSP
,
701 OPC_BALIGN
= (0x10 << 6) | OPC_APPEND_DSP
,
704 #define MASK_EXTR_W(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
706 /* MIPS DSP Accumulator and DSPControl Access Sub-class */
707 OPC_EXTR_W
= (0x00 << 6) | OPC_EXTR_W_DSP
,
708 OPC_EXTR_R_W
= (0x04 << 6) | OPC_EXTR_W_DSP
,
709 OPC_EXTR_RS_W
= (0x06 << 6) | OPC_EXTR_W_DSP
,
710 OPC_EXTR_S_H
= (0x0E << 6) | OPC_EXTR_W_DSP
,
711 OPC_EXTRV_S_H
= (0x0F << 6) | OPC_EXTR_W_DSP
,
712 OPC_EXTRV_W
= (0x01 << 6) | OPC_EXTR_W_DSP
,
713 OPC_EXTRV_R_W
= (0x05 << 6) | OPC_EXTR_W_DSP
,
714 OPC_EXTRV_RS_W
= (0x07 << 6) | OPC_EXTR_W_DSP
,
715 OPC_EXTP
= (0x02 << 6) | OPC_EXTR_W_DSP
,
716 OPC_EXTPV
= (0x03 << 6) | OPC_EXTR_W_DSP
,
717 OPC_EXTPDP
= (0x0A << 6) | OPC_EXTR_W_DSP
,
718 OPC_EXTPDPV
= (0x0B << 6) | OPC_EXTR_W_DSP
,
719 OPC_SHILO
= (0x1A << 6) | OPC_EXTR_W_DSP
,
720 OPC_SHILOV
= (0x1B << 6) | OPC_EXTR_W_DSP
,
721 OPC_MTHLIP
= (0x1F << 6) | OPC_EXTR_W_DSP
,
722 OPC_WRDSP
= (0x13 << 6) | OPC_EXTR_W_DSP
,
723 OPC_RDDSP
= (0x12 << 6) | OPC_EXTR_W_DSP
,
726 #define MASK_ABSQ_S_QH(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
728 /* MIPS DSP Arithmetic Sub-class */
729 OPC_PRECEQ_L_PWL
= (0x14 << 6) | OPC_ABSQ_S_QH_DSP
,
730 OPC_PRECEQ_L_PWR
= (0x15 << 6) | OPC_ABSQ_S_QH_DSP
,
731 OPC_PRECEQ_PW_QHL
= (0x0C << 6) | OPC_ABSQ_S_QH_DSP
,
732 OPC_PRECEQ_PW_QHR
= (0x0D << 6) | OPC_ABSQ_S_QH_DSP
,
733 OPC_PRECEQ_PW_QHLA
= (0x0E << 6) | OPC_ABSQ_S_QH_DSP
,
734 OPC_PRECEQ_PW_QHRA
= (0x0F << 6) | OPC_ABSQ_S_QH_DSP
,
735 OPC_PRECEQU_QH_OBL
= (0x04 << 6) | OPC_ABSQ_S_QH_DSP
,
736 OPC_PRECEQU_QH_OBR
= (0x05 << 6) | OPC_ABSQ_S_QH_DSP
,
737 OPC_PRECEQU_QH_OBLA
= (0x06 << 6) | OPC_ABSQ_S_QH_DSP
,
738 OPC_PRECEQU_QH_OBRA
= (0x07 << 6) | OPC_ABSQ_S_QH_DSP
,
739 OPC_PRECEU_QH_OBL
= (0x1C << 6) | OPC_ABSQ_S_QH_DSP
,
740 OPC_PRECEU_QH_OBR
= (0x1D << 6) | OPC_ABSQ_S_QH_DSP
,
741 OPC_PRECEU_QH_OBLA
= (0x1E << 6) | OPC_ABSQ_S_QH_DSP
,
742 OPC_PRECEU_QH_OBRA
= (0x1F << 6) | OPC_ABSQ_S_QH_DSP
,
743 OPC_ABSQ_S_OB
= (0x01 << 6) | OPC_ABSQ_S_QH_DSP
,
744 OPC_ABSQ_S_PW
= (0x11 << 6) | OPC_ABSQ_S_QH_DSP
,
745 OPC_ABSQ_S_QH
= (0x09 << 6) | OPC_ABSQ_S_QH_DSP
,
746 /* DSP Bit/Manipulation Sub-class */
747 OPC_REPL_OB
= (0x02 << 6) | OPC_ABSQ_S_QH_DSP
,
748 OPC_REPL_PW
= (0x12 << 6) | OPC_ABSQ_S_QH_DSP
,
749 OPC_REPL_QH
= (0x0A << 6) | OPC_ABSQ_S_QH_DSP
,
750 OPC_REPLV_OB
= (0x03 << 6) | OPC_ABSQ_S_QH_DSP
,
751 OPC_REPLV_PW
= (0x13 << 6) | OPC_ABSQ_S_QH_DSP
,
752 OPC_REPLV_QH
= (0x0B << 6) | OPC_ABSQ_S_QH_DSP
,
755 #define MASK_ADDU_OB(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
757 /* MIPS DSP Multiply Sub-class insns */
758 OPC_MULEQ_S_PW_QHL
= (0x1C << 6) | OPC_ADDU_OB_DSP
,
759 OPC_MULEQ_S_PW_QHR
= (0x1D << 6) | OPC_ADDU_OB_DSP
,
760 OPC_MULEU_S_QH_OBL
= (0x06 << 6) | OPC_ADDU_OB_DSP
,
761 OPC_MULEU_S_QH_OBR
= (0x07 << 6) | OPC_ADDU_OB_DSP
,
762 OPC_MULQ_RS_QH
= (0x1F << 6) | OPC_ADDU_OB_DSP
,
763 /* MIPS DSP Arithmetic Sub-class */
764 OPC_RADDU_L_OB
= (0x14 << 6) | OPC_ADDU_OB_DSP
,
765 OPC_SUBQ_PW
= (0x13 << 6) | OPC_ADDU_OB_DSP
,
766 OPC_SUBQ_S_PW
= (0x17 << 6) | OPC_ADDU_OB_DSP
,
767 OPC_SUBQ_QH
= (0x0B << 6) | OPC_ADDU_OB_DSP
,
768 OPC_SUBQ_S_QH
= (0x0F << 6) | OPC_ADDU_OB_DSP
,
769 OPC_SUBU_OB
= (0x01 << 6) | OPC_ADDU_OB_DSP
,
770 OPC_SUBU_S_OB
= (0x05 << 6) | OPC_ADDU_OB_DSP
,
771 OPC_SUBU_QH
= (0x09 << 6) | OPC_ADDU_OB_DSP
,
772 OPC_SUBU_S_QH
= (0x0D << 6) | OPC_ADDU_OB_DSP
,
773 OPC_SUBUH_OB
= (0x19 << 6) | OPC_ADDU_OB_DSP
,
774 OPC_SUBUH_R_OB
= (0x1B << 6) | OPC_ADDU_OB_DSP
,
775 OPC_ADDQ_PW
= (0x12 << 6) | OPC_ADDU_OB_DSP
,
776 OPC_ADDQ_S_PW
= (0x16 << 6) | OPC_ADDU_OB_DSP
,
777 OPC_ADDQ_QH
= (0x0A << 6) | OPC_ADDU_OB_DSP
,
778 OPC_ADDQ_S_QH
= (0x0E << 6) | OPC_ADDU_OB_DSP
,
779 OPC_ADDU_OB
= (0x00 << 6) | OPC_ADDU_OB_DSP
,
780 OPC_ADDU_S_OB
= (0x04 << 6) | OPC_ADDU_OB_DSP
,
781 OPC_ADDU_QH
= (0x08 << 6) | OPC_ADDU_OB_DSP
,
782 OPC_ADDU_S_QH
= (0x0C << 6) | OPC_ADDU_OB_DSP
,
783 OPC_ADDUH_OB
= (0x18 << 6) | OPC_ADDU_OB_DSP
,
784 OPC_ADDUH_R_OB
= (0x1A << 6) | OPC_ADDU_OB_DSP
,
787 #define MASK_CMPU_EQ_OB(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
789 /* DSP Compare-Pick Sub-class */
790 OPC_CMP_EQ_PW
= (0x10 << 6) | OPC_CMPU_EQ_OB_DSP
,
791 OPC_CMP_LT_PW
= (0x11 << 6) | OPC_CMPU_EQ_OB_DSP
,
792 OPC_CMP_LE_PW
= (0x12 << 6) | OPC_CMPU_EQ_OB_DSP
,
793 OPC_CMP_EQ_QH
= (0x08 << 6) | OPC_CMPU_EQ_OB_DSP
,
794 OPC_CMP_LT_QH
= (0x09 << 6) | OPC_CMPU_EQ_OB_DSP
,
795 OPC_CMP_LE_QH
= (0x0A << 6) | OPC_CMPU_EQ_OB_DSP
,
796 OPC_CMPGDU_EQ_OB
= (0x18 << 6) | OPC_CMPU_EQ_OB_DSP
,
797 OPC_CMPGDU_LT_OB
= (0x19 << 6) | OPC_CMPU_EQ_OB_DSP
,
798 OPC_CMPGDU_LE_OB
= (0x1A << 6) | OPC_CMPU_EQ_OB_DSP
,
799 OPC_CMPGU_EQ_OB
= (0x04 << 6) | OPC_CMPU_EQ_OB_DSP
,
800 OPC_CMPGU_LT_OB
= (0x05 << 6) | OPC_CMPU_EQ_OB_DSP
,
801 OPC_CMPGU_LE_OB
= (0x06 << 6) | OPC_CMPU_EQ_OB_DSP
,
802 OPC_CMPU_EQ_OB
= (0x00 << 6) | OPC_CMPU_EQ_OB_DSP
,
803 OPC_CMPU_LT_OB
= (0x01 << 6) | OPC_CMPU_EQ_OB_DSP
,
804 OPC_CMPU_LE_OB
= (0x02 << 6) | OPC_CMPU_EQ_OB_DSP
,
805 OPC_PACKRL_PW
= (0x0E << 6) | OPC_CMPU_EQ_OB_DSP
,
806 OPC_PICK_OB
= (0x03 << 6) | OPC_CMPU_EQ_OB_DSP
,
807 OPC_PICK_PW
= (0x13 << 6) | OPC_CMPU_EQ_OB_DSP
,
808 OPC_PICK_QH
= (0x0B << 6) | OPC_CMPU_EQ_OB_DSP
,
809 /* MIPS DSP Arithmetic Sub-class */
810 OPC_PRECR_OB_QH
= (0x0D << 6) | OPC_CMPU_EQ_OB_DSP
,
811 OPC_PRECR_SRA_QH_PW
= (0x1E << 6) | OPC_CMPU_EQ_OB_DSP
,
812 OPC_PRECR_SRA_R_QH_PW
= (0x1F << 6) | OPC_CMPU_EQ_OB_DSP
,
813 OPC_PRECRQ_OB_QH
= (0x0C << 6) | OPC_CMPU_EQ_OB_DSP
,
814 OPC_PRECRQ_PW_L
= (0x1C << 6) | OPC_CMPU_EQ_OB_DSP
,
815 OPC_PRECRQ_QH_PW
= (0x14 << 6) | OPC_CMPU_EQ_OB_DSP
,
816 OPC_PRECRQ_RS_QH_PW
= (0x15 << 6) | OPC_CMPU_EQ_OB_DSP
,
817 OPC_PRECRQU_S_OB_QH
= (0x0F << 6) | OPC_CMPU_EQ_OB_DSP
,
820 #define MASK_DAPPEND(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
822 /* DSP Append Sub-class */
823 OPC_DAPPEND
= (0x00 << 6) | OPC_DAPPEND_DSP
,
824 OPC_PREPENDD
= (0x03 << 6) | OPC_DAPPEND_DSP
,
825 OPC_PREPENDW
= (0x01 << 6) | OPC_DAPPEND_DSP
,
826 OPC_DBALIGN
= (0x10 << 6) | OPC_DAPPEND_DSP
,
829 #define MASK_DEXTR_W(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
831 /* MIPS DSP Accumulator and DSPControl Access Sub-class */
832 OPC_DMTHLIP
= (0x1F << 6) | OPC_DEXTR_W_DSP
,
833 OPC_DSHILO
= (0x1A << 6) | OPC_DEXTR_W_DSP
,
834 OPC_DEXTP
= (0x02 << 6) | OPC_DEXTR_W_DSP
,
835 OPC_DEXTPDP
= (0x0A << 6) | OPC_DEXTR_W_DSP
,
836 OPC_DEXTPDPV
= (0x0B << 6) | OPC_DEXTR_W_DSP
,
837 OPC_DEXTPV
= (0x03 << 6) | OPC_DEXTR_W_DSP
,
838 OPC_DEXTR_L
= (0x10 << 6) | OPC_DEXTR_W_DSP
,
839 OPC_DEXTR_R_L
= (0x14 << 6) | OPC_DEXTR_W_DSP
,
840 OPC_DEXTR_RS_L
= (0x16 << 6) | OPC_DEXTR_W_DSP
,
841 OPC_DEXTR_W
= (0x00 << 6) | OPC_DEXTR_W_DSP
,
842 OPC_DEXTR_R_W
= (0x04 << 6) | OPC_DEXTR_W_DSP
,
843 OPC_DEXTR_RS_W
= (0x06 << 6) | OPC_DEXTR_W_DSP
,
844 OPC_DEXTR_S_H
= (0x0E << 6) | OPC_DEXTR_W_DSP
,
845 OPC_DEXTRV_L
= (0x11 << 6) | OPC_DEXTR_W_DSP
,
846 OPC_DEXTRV_R_L
= (0x15 << 6) | OPC_DEXTR_W_DSP
,
847 OPC_DEXTRV_RS_L
= (0x17 << 6) | OPC_DEXTR_W_DSP
,
848 OPC_DEXTRV_S_H
= (0x0F << 6) | OPC_DEXTR_W_DSP
,
849 OPC_DEXTRV_W
= (0x01 << 6) | OPC_DEXTR_W_DSP
,
850 OPC_DEXTRV_R_W
= (0x05 << 6) | OPC_DEXTR_W_DSP
,
851 OPC_DEXTRV_RS_W
= (0x07 << 6) | OPC_DEXTR_W_DSP
,
852 OPC_DSHILOV
= (0x1B << 6) | OPC_DEXTR_W_DSP
,
855 #define MASK_DINSV(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
857 /* DSP Bit/Manipulation Sub-class */
858 OPC_DINSV
= (0x00 << 6) | OPC_DINSV_DSP
,
861 #define MASK_DPAQ_W_QH(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
863 /* MIPS DSP Multiply Sub-class insns */
864 OPC_DMADD
= (0x19 << 6) | OPC_DPAQ_W_QH_DSP
,
865 OPC_DMADDU
= (0x1D << 6) | OPC_DPAQ_W_QH_DSP
,
866 OPC_DMSUB
= (0x1B << 6) | OPC_DPAQ_W_QH_DSP
,
867 OPC_DMSUBU
= (0x1F << 6) | OPC_DPAQ_W_QH_DSP
,
868 OPC_DPA_W_QH
= (0x00 << 6) | OPC_DPAQ_W_QH_DSP
,
869 OPC_DPAQ_S_W_QH
= (0x04 << 6) | OPC_DPAQ_W_QH_DSP
,
870 OPC_DPAQ_SA_L_PW
= (0x0C << 6) | OPC_DPAQ_W_QH_DSP
,
871 OPC_DPAU_H_OBL
= (0x03 << 6) | OPC_DPAQ_W_QH_DSP
,
872 OPC_DPAU_H_OBR
= (0x07 << 6) | OPC_DPAQ_W_QH_DSP
,
873 OPC_DPS_W_QH
= (0x01 << 6) | OPC_DPAQ_W_QH_DSP
,
874 OPC_DPSQ_S_W_QH
= (0x05 << 6) | OPC_DPAQ_W_QH_DSP
,
875 OPC_DPSQ_SA_L_PW
= (0x0D << 6) | OPC_DPAQ_W_QH_DSP
,
876 OPC_DPSU_H_OBL
= (0x0B << 6) | OPC_DPAQ_W_QH_DSP
,
877 OPC_DPSU_H_OBR
= (0x0F << 6) | OPC_DPAQ_W_QH_DSP
,
878 OPC_MAQ_S_L_PWL
= (0x1C << 6) | OPC_DPAQ_W_QH_DSP
,
879 OPC_MAQ_S_L_PWR
= (0x1E << 6) | OPC_DPAQ_W_QH_DSP
,
880 OPC_MAQ_S_W_QHLL
= (0x14 << 6) | OPC_DPAQ_W_QH_DSP
,
881 OPC_MAQ_SA_W_QHLL
= (0x10 << 6) | OPC_DPAQ_W_QH_DSP
,
882 OPC_MAQ_S_W_QHLR
= (0x15 << 6) | OPC_DPAQ_W_QH_DSP
,
883 OPC_MAQ_SA_W_QHLR
= (0x11 << 6) | OPC_DPAQ_W_QH_DSP
,
884 OPC_MAQ_S_W_QHRL
= (0x16 << 6) | OPC_DPAQ_W_QH_DSP
,
885 OPC_MAQ_SA_W_QHRL
= (0x12 << 6) | OPC_DPAQ_W_QH_DSP
,
886 OPC_MAQ_S_W_QHRR
= (0x17 << 6) | OPC_DPAQ_W_QH_DSP
,
887 OPC_MAQ_SA_W_QHRR
= (0x13 << 6) | OPC_DPAQ_W_QH_DSP
,
888 OPC_MULSAQ_S_L_PW
= (0x0E << 6) | OPC_DPAQ_W_QH_DSP
,
889 OPC_MULSAQ_S_W_QH
= (0x06 << 6) | OPC_DPAQ_W_QH_DSP
,
892 #define MASK_SHLL_OB(op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))
894 /* MIPS DSP GPR-Based Shift Sub-class */
895 OPC_SHLL_PW
= (0x10 << 6) | OPC_SHLL_OB_DSP
,
896 OPC_SHLL_S_PW
= (0x14 << 6) | OPC_SHLL_OB_DSP
,
897 OPC_SHLLV_OB
= (0x02 << 6) | OPC_SHLL_OB_DSP
,
898 OPC_SHLLV_PW
= (0x12 << 6) | OPC_SHLL_OB_DSP
,
899 OPC_SHLLV_S_PW
= (0x16 << 6) | OPC_SHLL_OB_DSP
,
900 OPC_SHLLV_QH
= (0x0A << 6) | OPC_SHLL_OB_DSP
,
901 OPC_SHLLV_S_QH
= (0x0E << 6) | OPC_SHLL_OB_DSP
,
902 OPC_SHRA_PW
= (0x11 << 6) | OPC_SHLL_OB_DSP
,
903 OPC_SHRA_R_PW
= (0x15 << 6) | OPC_SHLL_OB_DSP
,
904 OPC_SHRAV_OB
= (0x06 << 6) | OPC_SHLL_OB_DSP
,
905 OPC_SHRAV_R_OB
= (0x07 << 6) | OPC_SHLL_OB_DSP
,
906 OPC_SHRAV_PW
= (0x13 << 6) | OPC_SHLL_OB_DSP
,
907 OPC_SHRAV_R_PW
= (0x17 << 6) | OPC_SHLL_OB_DSP
,
908 OPC_SHRAV_QH
= (0x0B << 6) | OPC_SHLL_OB_DSP
,
909 OPC_SHRAV_R_QH
= (0x0F << 6) | OPC_SHLL_OB_DSP
,
910 OPC_SHRLV_OB
= (0x03 << 6) | OPC_SHLL_OB_DSP
,
911 OPC_SHRLV_QH
= (0x1B << 6) | OPC_SHLL_OB_DSP
,
912 OPC_SHLL_OB
= (0x00 << 6) | OPC_SHLL_OB_DSP
,
913 OPC_SHLL_QH
= (0x08 << 6) | OPC_SHLL_OB_DSP
,
914 OPC_SHLL_S_QH
= (0x0C << 6) | OPC_SHLL_OB_DSP
,
915 OPC_SHRA_OB
= (0x04 << 6) | OPC_SHLL_OB_DSP
,
916 OPC_SHRA_R_OB
= (0x05 << 6) | OPC_SHLL_OB_DSP
,
917 OPC_SHRA_QH
= (0x09 << 6) | OPC_SHLL_OB_DSP
,
918 OPC_SHRA_R_QH
= (0x0D << 6) | OPC_SHLL_OB_DSP
,
919 OPC_SHRL_OB
= (0x01 << 6) | OPC_SHLL_OB_DSP
,
920 OPC_SHRL_QH
= (0x19 << 6) | OPC_SHLL_OB_DSP
,
923 /* Coprocessor 0 (rs field) */
924 #define MASK_CP0(op) (MASK_OP_MAJOR(op) | (op & (0x1F << 21)))
927 OPC_MFC0
= (0x00 << 21) | OPC_CP0
,
928 OPC_DMFC0
= (0x01 << 21) | OPC_CP0
,
929 OPC_MFHC0
= (0x02 << 21) | OPC_CP0
,
930 OPC_MTC0
= (0x04 << 21) | OPC_CP0
,
931 OPC_DMTC0
= (0x05 << 21) | OPC_CP0
,
932 OPC_MTHC0
= (0x06 << 21) | OPC_CP0
,
933 OPC_MFTR
= (0x08 << 21) | OPC_CP0
,
934 OPC_RDPGPR
= (0x0A << 21) | OPC_CP0
,
935 OPC_MFMC0
= (0x0B << 21) | OPC_CP0
,
936 OPC_MTTR
= (0x0C << 21) | OPC_CP0
,
937 OPC_WRPGPR
= (0x0E << 21) | OPC_CP0
,
938 OPC_C0
= (0x10 << 21) | OPC_CP0
,
939 OPC_C0_1
= (0x11 << 21) | OPC_CP0
,
940 OPC_C0_2
= (0x12 << 21) | OPC_CP0
,
941 OPC_C0_3
= (0x13 << 21) | OPC_CP0
,
942 OPC_C0_4
= (0x14 << 21) | OPC_CP0
,
943 OPC_C0_5
= (0x15 << 21) | OPC_CP0
,
944 OPC_C0_6
= (0x16 << 21) | OPC_CP0
,
945 OPC_C0_7
= (0x17 << 21) | OPC_CP0
,
946 OPC_C0_8
= (0x18 << 21) | OPC_CP0
,
947 OPC_C0_9
= (0x19 << 21) | OPC_CP0
,
948 OPC_C0_A
= (0x1A << 21) | OPC_CP0
,
949 OPC_C0_B
= (0x1B << 21) | OPC_CP0
,
950 OPC_C0_C
= (0x1C << 21) | OPC_CP0
,
951 OPC_C0_D
= (0x1D << 21) | OPC_CP0
,
952 OPC_C0_E
= (0x1E << 21) | OPC_CP0
,
953 OPC_C0_F
= (0x1F << 21) | OPC_CP0
,
957 #define MASK_MFMC0(op) (MASK_CP0(op) | (op & 0xFFFF))
960 OPC_DMT
= 0x01 | (0 << 5) | (0x0F << 6) | (0x01 << 11) | OPC_MFMC0
,
961 OPC_EMT
= 0x01 | (1 << 5) | (0x0F << 6) | (0x01 << 11) | OPC_MFMC0
,
962 OPC_DVPE
= 0x01 | (0 << 5) | OPC_MFMC0
,
963 OPC_EVPE
= 0x01 | (1 << 5) | OPC_MFMC0
,
964 OPC_DI
= (0 << 5) | (0x0C << 11) | OPC_MFMC0
,
965 OPC_EI
= (1 << 5) | (0x0C << 11) | OPC_MFMC0
,
966 OPC_DVP
= 0x04 | (0 << 3) | (1 << 5) | (0 << 11) | OPC_MFMC0
,
967 OPC_EVP
= 0x04 | (0 << 3) | (0 << 5) | (0 << 11) | OPC_MFMC0
,
970 /* Coprocessor 0 (with rs == C0) */
971 #define MASK_C0(op) (MASK_CP0(op) | (op & 0x3F))
974 OPC_TLBR
= 0x01 | OPC_C0
,
975 OPC_TLBWI
= 0x02 | OPC_C0
,
976 OPC_TLBINV
= 0x03 | OPC_C0
,
977 OPC_TLBINVF
= 0x04 | OPC_C0
,
978 OPC_TLBWR
= 0x06 | OPC_C0
,
979 OPC_TLBP
= 0x08 | OPC_C0
,
980 OPC_RFE
= 0x10 | OPC_C0
,
981 OPC_ERET
= 0x18 | OPC_C0
,
982 OPC_DERET
= 0x1F | OPC_C0
,
983 OPC_WAIT
= 0x20 | OPC_C0
,
986 #define MASK_CP2(op) (MASK_OP_MAJOR(op) | (op & (0x1F << 21)))
989 OPC_MFC2
= (0x00 << 21) | OPC_CP2
,
990 OPC_DMFC2
= (0x01 << 21) | OPC_CP2
,
991 OPC_CFC2
= (0x02 << 21) | OPC_CP2
,
992 OPC_MFHC2
= (0x03 << 21) | OPC_CP2
,
993 OPC_MTC2
= (0x04 << 21) | OPC_CP2
,
994 OPC_DMTC2
= (0x05 << 21) | OPC_CP2
,
995 OPC_CTC2
= (0x06 << 21) | OPC_CP2
,
996 OPC_MTHC2
= (0x07 << 21) | OPC_CP2
,
997 OPC_BC2
= (0x08 << 21) | OPC_CP2
,
998 OPC_BC2EQZ
= (0x09 << 21) | OPC_CP2
,
999 OPC_BC2NEZ
= (0x0D << 21) | OPC_CP2
,
1002 #define MASK_LMMI(op) (MASK_OP_MAJOR(op) | (op & (0x1F << 21)) | (op & 0x1F))
1005 OPC_PADDSH
= (24 << 21) | (0x00) | OPC_CP2
,
1006 OPC_PADDUSH
= (25 << 21) | (0x00) | OPC_CP2
,
1007 OPC_PADDH
= (26 << 21) | (0x00) | OPC_CP2
,
1008 OPC_PADDW
= (27 << 21) | (0x00) | OPC_CP2
,
1009 OPC_PADDSB
= (28 << 21) | (0x00) | OPC_CP2
,
1010 OPC_PADDUSB
= (29 << 21) | (0x00) | OPC_CP2
,
1011 OPC_PADDB
= (30 << 21) | (0x00) | OPC_CP2
,
1012 OPC_PADDD
= (31 << 21) | (0x00) | OPC_CP2
,
1014 OPC_PSUBSH
= (24 << 21) | (0x01) | OPC_CP2
,
1015 OPC_PSUBUSH
= (25 << 21) | (0x01) | OPC_CP2
,
1016 OPC_PSUBH
= (26 << 21) | (0x01) | OPC_CP2
,
1017 OPC_PSUBW
= (27 << 21) | (0x01) | OPC_CP2
,
1018 OPC_PSUBSB
= (28 << 21) | (0x01) | OPC_CP2
,
1019 OPC_PSUBUSB
= (29 << 21) | (0x01) | OPC_CP2
,
1020 OPC_PSUBB
= (30 << 21) | (0x01) | OPC_CP2
,
1021 OPC_PSUBD
= (31 << 21) | (0x01) | OPC_CP2
,
1023 OPC_PSHUFH
= (24 << 21) | (0x02) | OPC_CP2
,
1024 OPC_PACKSSWH
= (25 << 21) | (0x02) | OPC_CP2
,
1025 OPC_PACKSSHB
= (26 << 21) | (0x02) | OPC_CP2
,
1026 OPC_PACKUSHB
= (27 << 21) | (0x02) | OPC_CP2
,
1027 OPC_XOR_CP2
= (28 << 21) | (0x02) | OPC_CP2
,
1028 OPC_NOR_CP2
= (29 << 21) | (0x02) | OPC_CP2
,
1029 OPC_AND_CP2
= (30 << 21) | (0x02) | OPC_CP2
,
1030 OPC_PANDN
= (31 << 21) | (0x02) | OPC_CP2
,
1032 OPC_PUNPCKLHW
= (24 << 21) | (0x03) | OPC_CP2
,
1033 OPC_PUNPCKHHW
= (25 << 21) | (0x03) | OPC_CP2
,
1034 OPC_PUNPCKLBH
= (26 << 21) | (0x03) | OPC_CP2
,
1035 OPC_PUNPCKHBH
= (27 << 21) | (0x03) | OPC_CP2
,
1036 OPC_PINSRH_0
= (28 << 21) | (0x03) | OPC_CP2
,
1037 OPC_PINSRH_1
= (29 << 21) | (0x03) | OPC_CP2
,
1038 OPC_PINSRH_2
= (30 << 21) | (0x03) | OPC_CP2
,
1039 OPC_PINSRH_3
= (31 << 21) | (0x03) | OPC_CP2
,
1041 OPC_PAVGH
= (24 << 21) | (0x08) | OPC_CP2
,
1042 OPC_PAVGB
= (25 << 21) | (0x08) | OPC_CP2
,
1043 OPC_PMAXSH
= (26 << 21) | (0x08) | OPC_CP2
,
1044 OPC_PMINSH
= (27 << 21) | (0x08) | OPC_CP2
,
1045 OPC_PMAXUB
= (28 << 21) | (0x08) | OPC_CP2
,
1046 OPC_PMINUB
= (29 << 21) | (0x08) | OPC_CP2
,
1048 OPC_PCMPEQW
= (24 << 21) | (0x09) | OPC_CP2
,
1049 OPC_PCMPGTW
= (25 << 21) | (0x09) | OPC_CP2
,
1050 OPC_PCMPEQH
= (26 << 21) | (0x09) | OPC_CP2
,
1051 OPC_PCMPGTH
= (27 << 21) | (0x09) | OPC_CP2
,
1052 OPC_PCMPEQB
= (28 << 21) | (0x09) | OPC_CP2
,
1053 OPC_PCMPGTB
= (29 << 21) | (0x09) | OPC_CP2
,
1055 OPC_PSLLW
= (24 << 21) | (0x0A) | OPC_CP2
,
1056 OPC_PSLLH
= (25 << 21) | (0x0A) | OPC_CP2
,
1057 OPC_PMULLH
= (26 << 21) | (0x0A) | OPC_CP2
,
1058 OPC_PMULHH
= (27 << 21) | (0x0A) | OPC_CP2
,
1059 OPC_PMULUW
= (28 << 21) | (0x0A) | OPC_CP2
,
1060 OPC_PMULHUH
= (29 << 21) | (0x0A) | OPC_CP2
,
1062 OPC_PSRLW
= (24 << 21) | (0x0B) | OPC_CP2
,
1063 OPC_PSRLH
= (25 << 21) | (0x0B) | OPC_CP2
,
1064 OPC_PSRAW
= (26 << 21) | (0x0B) | OPC_CP2
,
1065 OPC_PSRAH
= (27 << 21) | (0x0B) | OPC_CP2
,
1066 OPC_PUNPCKLWD
= (28 << 21) | (0x0B) | OPC_CP2
,
1067 OPC_PUNPCKHWD
= (29 << 21) | (0x0B) | OPC_CP2
,
1069 OPC_ADDU_CP2
= (24 << 21) | (0x0C) | OPC_CP2
,
1070 OPC_OR_CP2
= (25 << 21) | (0x0C) | OPC_CP2
,
1071 OPC_ADD_CP2
= (26 << 21) | (0x0C) | OPC_CP2
,
1072 OPC_DADD_CP2
= (27 << 21) | (0x0C) | OPC_CP2
,
1073 OPC_SEQU_CP2
= (28 << 21) | (0x0C) | OPC_CP2
,
1074 OPC_SEQ_CP2
= (29 << 21) | (0x0C) | OPC_CP2
,
1076 OPC_SUBU_CP2
= (24 << 21) | (0x0D) | OPC_CP2
,
1077 OPC_PASUBUB
= (25 << 21) | (0x0D) | OPC_CP2
,
1078 OPC_SUB_CP2
= (26 << 21) | (0x0D) | OPC_CP2
,
1079 OPC_DSUB_CP2
= (27 << 21) | (0x0D) | OPC_CP2
,
1080 OPC_SLTU_CP2
= (28 << 21) | (0x0D) | OPC_CP2
,
1081 OPC_SLT_CP2
= (29 << 21) | (0x0D) | OPC_CP2
,
1083 OPC_SLL_CP2
= (24 << 21) | (0x0E) | OPC_CP2
,
1084 OPC_DSLL_CP2
= (25 << 21) | (0x0E) | OPC_CP2
,
1085 OPC_PEXTRH
= (26 << 21) | (0x0E) | OPC_CP2
,
1086 OPC_PMADDHW
= (27 << 21) | (0x0E) | OPC_CP2
,
1087 OPC_SLEU_CP2
= (28 << 21) | (0x0E) | OPC_CP2
,
1088 OPC_SLE_CP2
= (29 << 21) | (0x0E) | OPC_CP2
,
1090 OPC_SRL_CP2
= (24 << 21) | (0x0F) | OPC_CP2
,
1091 OPC_DSRL_CP2
= (25 << 21) | (0x0F) | OPC_CP2
,
1092 OPC_SRA_CP2
= (26 << 21) | (0x0F) | OPC_CP2
,
1093 OPC_DSRA_CP2
= (27 << 21) | (0x0F) | OPC_CP2
,
1094 OPC_BIADD
= (28 << 21) | (0x0F) | OPC_CP2
,
1095 OPC_PMOVMSKB
= (29 << 21) | (0x0F) | OPC_CP2
,
1099 #define MASK_CP3(op) (MASK_OP_MAJOR(op) | (op & 0x3F))
1102 OPC_LWXC1
= 0x00 | OPC_CP3
,
1103 OPC_LDXC1
= 0x01 | OPC_CP3
,
1104 OPC_LUXC1
= 0x05 | OPC_CP3
,
1105 OPC_SWXC1
= 0x08 | OPC_CP3
,
1106 OPC_SDXC1
= 0x09 | OPC_CP3
,
1107 OPC_SUXC1
= 0x0D | OPC_CP3
,
1108 OPC_PREFX
= 0x0F | OPC_CP3
,
1109 OPC_ALNV_PS
= 0x1E | OPC_CP3
,
1110 OPC_MADD_S
= 0x20 | OPC_CP3
,
1111 OPC_MADD_D
= 0x21 | OPC_CP3
,
1112 OPC_MADD_PS
= 0x26 | OPC_CP3
,
1113 OPC_MSUB_S
= 0x28 | OPC_CP3
,
1114 OPC_MSUB_D
= 0x29 | OPC_CP3
,
1115 OPC_MSUB_PS
= 0x2E | OPC_CP3
,
1116 OPC_NMADD_S
= 0x30 | OPC_CP3
,
1117 OPC_NMADD_D
= 0x31 | OPC_CP3
,
1118 OPC_NMADD_PS
= 0x36 | OPC_CP3
,
1119 OPC_NMSUB_S
= 0x38 | OPC_CP3
,
1120 OPC_NMSUB_D
= 0x39 | OPC_CP3
,
1121 OPC_NMSUB_PS
= 0x3E | OPC_CP3
,
1125 * MMI (MultiMedia Instruction) encodings
1126 * ======================================
1128 * MMI instructions encoding table keys:
1130 * * This code is reserved for future use. An attempt to execute it
1131 * causes a Reserved Instruction exception.
1132 * % This code indicates an instruction class. The instruction word
1133 * must be further decoded by examining additional tables that show
1134 * the values for other instruction fields.
1135 * # This code is reserved for the unsupported instructions DMULT,
1136 * DMULTU, DDIV, DDIVU, LL, LLD, SC, SCD, LWC2 and SWC2. An attempt
1137 * to execute it causes a Reserved Instruction exception.
1139 * MMI instructions encoded by opcode field (MMI, LQ, SQ):
1142 * +--------+----------------------------------------+
1144 * +--------+----------------------------------------+
1146 * opcode bits 28..26
1147 * bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
1148 * 31..29 | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111
1149 * -------+-------+-------+-------+-------+-------+-------+-------+-------
1150 * 0 000 |SPECIAL| REGIMM| J | JAL | BEQ | BNE | BLEZ | BGTZ
1151 * 1 001 | ADDI | ADDIU | SLTI | SLTIU | ANDI | ORI | XORI | LUI
1152 * 2 010 | COP0 | COP1 | * | * | BEQL | BNEL | BLEZL | BGTZL
1153 * 3 011 | DADDI | DADDIU| LDL | LDR | MMI% | * | LQ | SQ
1154 * 4 100 | LB | LH | LWL | LW | LBU | LHU | LWR | LWU
1155 * 5 101 | SB | SH | SWL | SW | SDL | SDR | SWR | CACHE
1156 * 6 110 | # | LWC1 | # | PREF | # | LDC1 | # | LD
1157 * 7 111 | # | SWC1 | # | * | # | SDC1 | # | SD
1161 MMI_OPC_CLASS_MMI
= 0x1C << 26, /* Same as OPC_SPECIAL2 */
1162 MMI_OPC_SQ
= 0x1F << 26, /* Same as OPC_SPECIAL3 */
1166 * MMI instructions with opcode field = MMI:
1169 * +--------+-------------------------------+--------+
1170 * | MMI | |function|
1171 * +--------+-------------------------------+--------+
1173 * function bits 2..0
1174 * bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
1175 * 5..3 | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111
1176 * -------+-------+-------+-------+-------+-------+-------+-------+-------
1177 * 0 000 | MADD | MADDU | * | * | PLZCW | * | * | *
1178 * 1 001 | MMI0% | MMI2% | * | * | * | * | * | *
1179 * 2 010 | MFHI1 | MTHI1 | MFLO1 | MTLO1 | * | * | * | *
1180 * 3 011 | MULT1 | MULTU1| DIV1 | DIVU1 | * | * | * | *
1181 * 4 100 | MADD1 | MADDU1| * | * | * | * | * | *
1182 * 5 101 | MMI1% | MMI3% | * | * | * | * | * | *
1183 * 6 110 | PMFHL | PMTHL | * | * | PSLLH | * | PSRLH | PSRAH
1184 * 7 111 | * | * | * | * | PSLLW | * | PSRLW | PSRAW
1187 #define MASK_MMI(op) (MASK_OP_MAJOR(op) | ((op) & 0x3F))
1189 MMI_OPC_MADD
= 0x00 | MMI_OPC_CLASS_MMI
, /* Same as OPC_MADD */
1190 MMI_OPC_MADDU
= 0x01 | MMI_OPC_CLASS_MMI
, /* Same as OPC_MADDU */
1191 MMI_OPC_MULT1
= 0x18 | MMI_OPC_CLASS_MMI
, /* Same minor as OPC_MULT */
1192 MMI_OPC_MULTU1
= 0x19 | MMI_OPC_CLASS_MMI
, /* Same min. as OPC_MULTU */
1193 MMI_OPC_DIV1
= 0x1A | MMI_OPC_CLASS_MMI
, /* Same minor as OPC_DIV */
1194 MMI_OPC_DIVU1
= 0x1B | MMI_OPC_CLASS_MMI
, /* Same minor as OPC_DIVU */
1195 MMI_OPC_MADD1
= 0x20 | MMI_OPC_CLASS_MMI
,
1196 MMI_OPC_MADDU1
= 0x21 | MMI_OPC_CLASS_MMI
,
1199 /* global register indices */
1200 TCGv cpu_gpr
[32], cpu_PC
;
1202 * For CPUs using 128-bit GPR registers, we put the lower halves in cpu_gpr[])
1203 * and the upper halves in cpu_gpr_hi[].
1205 TCGv_i64 cpu_gpr_hi
[32];
1206 TCGv cpu_HI
[MIPS_DSP_ACC
], cpu_LO
[MIPS_DSP_ACC
];
1207 static TCGv cpu_dspctrl
, btarget
;
1209 static TCGv cpu_lladdr
, cpu_llval
;
1210 static TCGv_i32 hflags
;
1211 TCGv_i32 fpu_fcr0
, fpu_fcr31
;
1212 TCGv_i64 fpu_f64
[32];
1214 #include "exec/gen-icount.h"
1216 #define gen_helper_0e1i(name, arg1, arg2) do { \
1217 gen_helper_##name(cpu_env, arg1, tcg_constant_i32(arg2)); \
1220 #define gen_helper_1e0i(name, ret, arg1) do { \
1221 gen_helper_##name(ret, cpu_env, tcg_constant_i32(arg1)); \
1224 #define gen_helper_0e2i(name, arg1, arg2, arg3) do { \
1225 gen_helper_##name(cpu_env, arg1, arg2, tcg_constant_i32(arg3));\
1228 #define DISAS_STOP DISAS_TARGET_0
1229 #define DISAS_EXIT DISAS_TARGET_1
1231 static const char regnames_HI
[][4] = {
1232 "HI0", "HI1", "HI2", "HI3",
1235 static const char regnames_LO
[][4] = {
1236 "LO0", "LO1", "LO2", "LO3",
1239 /* General purpose registers moves. */
1240 void gen_load_gpr(TCGv t
, int reg
)
1243 tcg_gen_movi_tl(t
, 0);
1245 tcg_gen_mov_tl(t
, cpu_gpr
[reg
]);
1249 void gen_store_gpr(TCGv t
, int reg
)
1252 tcg_gen_mov_tl(cpu_gpr
[reg
], t
);
1256 #if defined(TARGET_MIPS64)
1257 void gen_load_gpr_hi(TCGv_i64 t
, int reg
)
1260 tcg_gen_movi_i64(t
, 0);
1262 tcg_gen_mov_i64(t
, cpu_gpr_hi
[reg
]);
1266 void gen_store_gpr_hi(TCGv_i64 t
, int reg
)
1269 tcg_gen_mov_i64(cpu_gpr_hi
[reg
], t
);
1272 #endif /* TARGET_MIPS64 */
1274 /* Moves to/from shadow registers. */
1275 static inline void gen_load_srsgpr(int from
, int to
)
1277 TCGv t0
= tcg_temp_new();
1280 tcg_gen_movi_tl(t0
, 0);
1282 TCGv_i32 t2
= tcg_temp_new_i32();
1283 TCGv_ptr addr
= tcg_temp_new_ptr();
1285 tcg_gen_ld_i32(t2
, cpu_env
, offsetof(CPUMIPSState
, CP0_SRSCtl
));
1286 tcg_gen_shri_i32(t2
, t2
, CP0SRSCtl_PSS
);
1287 tcg_gen_andi_i32(t2
, t2
, 0xf);
1288 tcg_gen_muli_i32(t2
, t2
, sizeof(target_ulong
) * 32);
1289 tcg_gen_ext_i32_ptr(addr
, t2
);
1290 tcg_gen_add_ptr(addr
, cpu_env
, addr
);
1292 tcg_gen_ld_tl(t0
, addr
, sizeof(target_ulong
) * from
);
1293 tcg_temp_free_ptr(addr
);
1294 tcg_temp_free_i32(t2
);
1296 gen_store_gpr(t0
, to
);
1300 static inline void gen_store_srsgpr(int from
, int to
)
1303 TCGv t0
= tcg_temp_new();
1304 TCGv_i32 t2
= tcg_temp_new_i32();
1305 TCGv_ptr addr
= tcg_temp_new_ptr();
1307 gen_load_gpr(t0
, from
);
1308 tcg_gen_ld_i32(t2
, cpu_env
, offsetof(CPUMIPSState
, CP0_SRSCtl
));
1309 tcg_gen_shri_i32(t2
, t2
, CP0SRSCtl_PSS
);
1310 tcg_gen_andi_i32(t2
, t2
, 0xf);
1311 tcg_gen_muli_i32(t2
, t2
, sizeof(target_ulong
) * 32);
1312 tcg_gen_ext_i32_ptr(addr
, t2
);
1313 tcg_gen_add_ptr(addr
, cpu_env
, addr
);
1315 tcg_gen_st_tl(t0
, addr
, sizeof(target_ulong
) * to
);
1316 tcg_temp_free_ptr(addr
);
1317 tcg_temp_free_i32(t2
);
1323 static inline void gen_save_pc(target_ulong pc
)
1325 tcg_gen_movi_tl(cpu_PC
, pc
);
1328 static inline void save_cpu_state(DisasContext
*ctx
, int do_save_pc
)
1330 LOG_DISAS("hflags %08x saved %08x\n", ctx
->hflags
, ctx
->saved_hflags
);
1331 if (do_save_pc
&& ctx
->base
.pc_next
!= ctx
->saved_pc
) {
1332 gen_save_pc(ctx
->base
.pc_next
);
1333 ctx
->saved_pc
= ctx
->base
.pc_next
;
1335 if (ctx
->hflags
!= ctx
->saved_hflags
) {
1336 tcg_gen_movi_i32(hflags
, ctx
->hflags
);
1337 ctx
->saved_hflags
= ctx
->hflags
;
1338 switch (ctx
->hflags
& MIPS_HFLAG_BMASK_BASE
) {
1344 tcg_gen_movi_tl(btarget
, ctx
->btarget
);
1350 static inline void restore_cpu_state(CPUMIPSState
*env
, DisasContext
*ctx
)
1352 ctx
->saved_hflags
= ctx
->hflags
;
1353 switch (ctx
->hflags
& MIPS_HFLAG_BMASK_BASE
) {
1359 ctx
->btarget
= env
->btarget
;
1364 void generate_exception_err(DisasContext
*ctx
, int excp
, int err
)
1366 TCGv_i32 texcp
= tcg_const_i32(excp
);
1367 TCGv_i32 terr
= tcg_const_i32(err
);
1368 save_cpu_state(ctx
, 1);
1369 gen_helper_raise_exception_err(cpu_env
, texcp
, terr
);
1370 tcg_temp_free_i32(terr
);
1371 tcg_temp_free_i32(texcp
);
1372 ctx
->base
.is_jmp
= DISAS_NORETURN
;
1375 void generate_exception(DisasContext
*ctx
, int excp
)
1377 gen_helper_raise_exception(cpu_env
, tcg_constant_i32(excp
));
1380 void generate_exception_end(DisasContext
*ctx
, int excp
)
1382 generate_exception_err(ctx
, excp
, 0);
1385 void gen_reserved_instruction(DisasContext
*ctx
)
1387 generate_exception_end(ctx
, EXCP_RI
);
1390 /* Floating point register moves. */
1391 void gen_load_fpr32(DisasContext
*ctx
, TCGv_i32 t
, int reg
)
1393 if (ctx
->hflags
& MIPS_HFLAG_FRE
) {
1394 generate_exception(ctx
, EXCP_RI
);
1396 tcg_gen_extrl_i64_i32(t
, fpu_f64
[reg
]);
1399 void gen_store_fpr32(DisasContext
*ctx
, TCGv_i32 t
, int reg
)
1402 if (ctx
->hflags
& MIPS_HFLAG_FRE
) {
1403 generate_exception(ctx
, EXCP_RI
);
1405 t64
= tcg_temp_new_i64();
1406 tcg_gen_extu_i32_i64(t64
, t
);
1407 tcg_gen_deposit_i64(fpu_f64
[reg
], fpu_f64
[reg
], t64
, 0, 32);
1408 tcg_temp_free_i64(t64
);
1411 static void gen_load_fpr32h(DisasContext
*ctx
, TCGv_i32 t
, int reg
)
1413 if (ctx
->hflags
& MIPS_HFLAG_F64
) {
1414 tcg_gen_extrh_i64_i32(t
, fpu_f64
[reg
]);
1416 gen_load_fpr32(ctx
, t
, reg
| 1);
1420 static void gen_store_fpr32h(DisasContext
*ctx
, TCGv_i32 t
, int reg
)
1422 if (ctx
->hflags
& MIPS_HFLAG_F64
) {
1423 TCGv_i64 t64
= tcg_temp_new_i64();
1424 tcg_gen_extu_i32_i64(t64
, t
);
1425 tcg_gen_deposit_i64(fpu_f64
[reg
], fpu_f64
[reg
], t64
, 32, 32);
1426 tcg_temp_free_i64(t64
);
1428 gen_store_fpr32(ctx
, t
, reg
| 1);
1432 void gen_load_fpr64(DisasContext
*ctx
, TCGv_i64 t
, int reg
)
1434 if (ctx
->hflags
& MIPS_HFLAG_F64
) {
1435 tcg_gen_mov_i64(t
, fpu_f64
[reg
]);
1437 tcg_gen_concat32_i64(t
, fpu_f64
[reg
& ~1], fpu_f64
[reg
| 1]);
1441 void gen_store_fpr64(DisasContext
*ctx
, TCGv_i64 t
, int reg
)
1443 if (ctx
->hflags
& MIPS_HFLAG_F64
) {
1444 tcg_gen_mov_i64(fpu_f64
[reg
], t
);
1447 tcg_gen_deposit_i64(fpu_f64
[reg
& ~1], fpu_f64
[reg
& ~1], t
, 0, 32);
1448 t0
= tcg_temp_new_i64();
1449 tcg_gen_shri_i64(t0
, t
, 32);
1450 tcg_gen_deposit_i64(fpu_f64
[reg
| 1], fpu_f64
[reg
| 1], t0
, 0, 32);
1451 tcg_temp_free_i64(t0
);
1455 int get_fp_bit(int cc
)
1464 /* Addresses computation */
1465 void gen_op_addr_add(DisasContext
*ctx
, TCGv ret
, TCGv arg0
, TCGv arg1
)
1467 tcg_gen_add_tl(ret
, arg0
, arg1
);
1469 #if defined(TARGET_MIPS64)
1470 if (ctx
->hflags
& MIPS_HFLAG_AWRAP
) {
1471 tcg_gen_ext32s_i64(ret
, ret
);
1476 static inline void gen_op_addr_addi(DisasContext
*ctx
, TCGv ret
, TCGv base
,
1479 tcg_gen_addi_tl(ret
, base
, ofs
);
1481 #if defined(TARGET_MIPS64)
1482 if (ctx
->hflags
& MIPS_HFLAG_AWRAP
) {
1483 tcg_gen_ext32s_i64(ret
, ret
);
1488 /* Addresses computation (translation time) */
1489 static target_long
addr_add(DisasContext
*ctx
, target_long base
,
1492 target_long sum
= base
+ offset
;
1494 #if defined(TARGET_MIPS64)
1495 if (ctx
->hflags
& MIPS_HFLAG_AWRAP
) {
1502 /* Sign-extract the low 32-bits to a target_long. */
1503 void gen_move_low32(TCGv ret
, TCGv_i64 arg
)
1505 #if defined(TARGET_MIPS64)
1506 tcg_gen_ext32s_i64(ret
, arg
);
1508 tcg_gen_extrl_i64_i32(ret
, arg
);
1512 /* Sign-extract the high 32-bits to a target_long. */
1513 void gen_move_high32(TCGv ret
, TCGv_i64 arg
)
1515 #if defined(TARGET_MIPS64)
1516 tcg_gen_sari_i64(ret
, arg
, 32);
1518 tcg_gen_extrh_i64_i32(ret
, arg
);
1522 bool check_cp0_enabled(DisasContext
*ctx
)
1524 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_CP0
))) {
1525 generate_exception_end(ctx
, EXCP_CpU
);
1531 void check_cp1_enabled(DisasContext
*ctx
)
1533 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_FPU
))) {
1534 generate_exception_err(ctx
, EXCP_CpU
, 1);
1539 * Verify that the processor is running with COP1X instructions enabled.
1540 * This is associated with the nabla symbol in the MIPS32 and MIPS64
1543 void check_cop1x(DisasContext
*ctx
)
1545 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_COP1X
))) {
1546 gen_reserved_instruction(ctx
);
1551 * Verify that the processor is running with 64-bit floating-point
1552 * operations enabled.
1554 void check_cp1_64bitmode(DisasContext
*ctx
)
1556 if (unlikely(~ctx
->hflags
& (MIPS_HFLAG_F64
| MIPS_HFLAG_COP1X
))) {
1557 gen_reserved_instruction(ctx
);
1562 * Verify if floating point register is valid; an operation is not defined
1563 * if bit 0 of any register specification is set and the FR bit in the
1564 * Status register equals zero, since the register numbers specify an
1565 * even-odd pair of adjacent coprocessor general registers. When the FR bit
1566 * in the Status register equals one, both even and odd register numbers
1567 * are valid. This limitation exists only for 64 bit wide (d,l,ps) registers.
1569 * Multiple 64 bit wide registers can be checked by calling
1570 * gen_op_cp1_registers(freg1 | freg2 | ... | fregN);
1572 void check_cp1_registers(DisasContext
*ctx
, int regs
)
1574 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_F64
) && (regs
& 1))) {
1575 gen_reserved_instruction(ctx
);
1580 * Verify that the processor is running with DSP instructions enabled.
1581 * This is enabled by CP0 Status register MX(24) bit.
1583 static inline void check_dsp(DisasContext
*ctx
)
1585 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_DSP
))) {
1586 if (ctx
->insn_flags
& ASE_DSP
) {
1587 generate_exception_end(ctx
, EXCP_DSPDIS
);
1589 gen_reserved_instruction(ctx
);
1594 static inline void check_dsp_r2(DisasContext
*ctx
)
1596 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_DSP_R2
))) {
1597 if (ctx
->insn_flags
& ASE_DSP
) {
1598 generate_exception_end(ctx
, EXCP_DSPDIS
);
1600 gen_reserved_instruction(ctx
);
1605 static inline void check_dsp_r3(DisasContext
*ctx
)
1607 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_DSP_R3
))) {
1608 if (ctx
->insn_flags
& ASE_DSP
) {
1609 generate_exception_end(ctx
, EXCP_DSPDIS
);
1611 gen_reserved_instruction(ctx
);
1617 * This code generates a "reserved instruction" exception if the
1618 * CPU does not support the instruction set corresponding to flags.
1620 void check_insn(DisasContext
*ctx
, uint64_t flags
)
1622 if (unlikely(!(ctx
->insn_flags
& flags
))) {
1623 gen_reserved_instruction(ctx
);
1628 * This code generates a "reserved instruction" exception if the
1629 * CPU has corresponding flag set which indicates that the instruction
1632 static inline void check_insn_opc_removed(DisasContext
*ctx
, uint64_t flags
)
1634 if (unlikely(ctx
->insn_flags
& flags
)) {
1635 gen_reserved_instruction(ctx
);
1640 * The Linux kernel traps certain reserved instruction exceptions to
1641 * emulate the corresponding instructions. QEMU is the kernel in user
1642 * mode, so those traps are emulated by accepting the instructions.
1644 * A reserved instruction exception is generated for flagged CPUs if
1645 * QEMU runs in system mode.
1647 static inline void check_insn_opc_user_only(DisasContext
*ctx
, uint64_t flags
)
1649 #ifndef CONFIG_USER_ONLY
1650 check_insn_opc_removed(ctx
, flags
);
1655 * This code generates a "reserved instruction" exception if the
1656 * CPU does not support 64-bit paired-single (PS) floating point data type.
1658 static inline void check_ps(DisasContext
*ctx
)
1660 if (unlikely(!ctx
->ps
)) {
1661 generate_exception(ctx
, EXCP_RI
);
1663 check_cp1_64bitmode(ctx
);
1667 * This code generates a "reserved instruction" exception if cpu is not
1668 * 64-bit or 64-bit instructions are not enabled.
1670 void check_mips_64(DisasContext
*ctx
)
1672 if (unlikely((TARGET_LONG_BITS
!= 64) || !(ctx
->hflags
& MIPS_HFLAG_64
))) {
1673 gen_reserved_instruction(ctx
);
1677 #ifndef CONFIG_USER_ONLY
1678 static inline void check_mvh(DisasContext
*ctx
)
1680 if (unlikely(!ctx
->mvh
)) {
1681 generate_exception(ctx
, EXCP_RI
);
1687 * This code generates a "reserved instruction" exception if the
1688 * Config5 XNP bit is set.
1690 static inline void check_xnp(DisasContext
*ctx
)
1692 if (unlikely(ctx
->CP0_Config5
& (1 << CP0C5_XNP
))) {
1693 gen_reserved_instruction(ctx
);
1697 #ifndef CONFIG_USER_ONLY
1699 * This code generates a "reserved instruction" exception if the
1700 * Config3 PW bit is NOT set.
1702 static inline void check_pw(DisasContext
*ctx
)
1704 if (unlikely(!(ctx
->CP0_Config3
& (1 << CP0C3_PW
)))) {
1705 gen_reserved_instruction(ctx
);
1711 * This code generates a "reserved instruction" exception if the
1712 * Config3 MT bit is NOT set.
1714 static inline void check_mt(DisasContext
*ctx
)
1716 if (unlikely(!(ctx
->CP0_Config3
& (1 << CP0C3_MT
)))) {
1717 gen_reserved_instruction(ctx
);
1721 #ifndef CONFIG_USER_ONLY
1723 * This code generates a "coprocessor unusable" exception if CP0 is not
1724 * available, and, if that is not the case, generates a "reserved instruction"
1725 * exception if the Config5 MT bit is NOT set. This is needed for availability
1726 * control of some of MT ASE instructions.
1728 static inline void check_cp0_mt(DisasContext
*ctx
)
1730 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_CP0
))) {
1731 generate_exception_end(ctx
, EXCP_CpU
);
1733 if (unlikely(!(ctx
->CP0_Config3
& (1 << CP0C3_MT
)))) {
1734 gen_reserved_instruction(ctx
);
1741 * This code generates a "reserved instruction" exception if the
1742 * Config5 NMS bit is set.
1744 static inline void check_nms(DisasContext
*ctx
)
1746 if (unlikely(ctx
->CP0_Config5
& (1 << CP0C5_NMS
))) {
1747 gen_reserved_instruction(ctx
);
1752 * This code generates a "reserved instruction" exception if the
1753 * Config5 NMS bit is set, and Config1 DL, Config1 IL, Config2 SL,
1754 * Config2 TL, and Config5 L2C are unset.
1756 static inline void check_nms_dl_il_sl_tl_l2c(DisasContext
*ctx
)
1758 if (unlikely((ctx
->CP0_Config5
& (1 << CP0C5_NMS
)) &&
1759 !(ctx
->CP0_Config1
& (1 << CP0C1_DL
)) &&
1760 !(ctx
->CP0_Config1
& (1 << CP0C1_IL
)) &&
1761 !(ctx
->CP0_Config2
& (1 << CP0C2_SL
)) &&
1762 !(ctx
->CP0_Config2
& (1 << CP0C2_TL
)) &&
1763 !(ctx
->CP0_Config5
& (1 << CP0C5_L2C
)))) {
1764 gen_reserved_instruction(ctx
);
1769 * This code generates a "reserved instruction" exception if the
1770 * Config5 EVA bit is NOT set.
1772 static inline void check_eva(DisasContext
*ctx
)
1774 if (unlikely(!(ctx
->CP0_Config5
& (1 << CP0C5_EVA
)))) {
1775 gen_reserved_instruction(ctx
);
1781 * Define small wrappers for gen_load_fpr* so that we have a uniform
1782 * calling interface for 32 and 64-bit FPRs. No sense in changing
1783 * all callers for gen_load_fpr32 when we need the CTX parameter for
1786 #define gen_ldcmp_fpr32(ctx, x, y) gen_load_fpr32(ctx, x, y)
1787 #define gen_ldcmp_fpr64(ctx, x, y) gen_load_fpr64(ctx, x, y)
1788 #define FOP_CONDS(type, abs, fmt, ifmt, bits) \
1789 static inline void gen_cmp ## type ## _ ## fmt(DisasContext *ctx, int n, \
1790 int ft, int fs, int cc) \
1792 TCGv_i##bits fp0 = tcg_temp_new_i##bits(); \
1793 TCGv_i##bits fp1 = tcg_temp_new_i##bits(); \
1802 check_cp1_registers(ctx, fs | ft); \
1810 gen_ldcmp_fpr##bits(ctx, fp0, fs); \
1811 gen_ldcmp_fpr##bits(ctx, fp1, ft); \
1814 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _f, fp0, fp1, cc); \
1817 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _un, fp0, fp1, cc); \
1820 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _eq, fp0, fp1, cc); \
1823 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _ueq, fp0, fp1, cc); \
1826 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _olt, fp0, fp1, cc); \
1829 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _ult, fp0, fp1, cc); \
1832 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _ole, fp0, fp1, cc); \
1835 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _ule, fp0, fp1, cc); \
1838 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _sf, fp0, fp1, cc); \
1841 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _ngle, fp0, fp1, cc); \
1844 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _seq, fp0, fp1, cc); \
1847 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _ngl, fp0, fp1, cc); \
1850 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _lt, fp0, fp1, cc); \
1853 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _nge, fp0, fp1, cc); \
1856 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _le, fp0, fp1, cc); \
1859 gen_helper_0e2i(cmp ## type ## _ ## fmt ## _ngt, fp0, fp1, cc); \
1864 tcg_temp_free_i##bits(fp0); \
1865 tcg_temp_free_i##bits(fp1); \
1868 FOP_CONDS(, 0, d
, FMT_D
, 64)
1869 FOP_CONDS(abs
, 1, d
, FMT_D
, 64)
1870 FOP_CONDS(, 0, s
, FMT_S
, 32)
1871 FOP_CONDS(abs
, 1, s
, FMT_S
, 32)
1872 FOP_CONDS(, 0, ps
, FMT_PS
, 64)
1873 FOP_CONDS(abs
, 1, ps
, FMT_PS
, 64)
1876 #define FOP_CONDNS(fmt, ifmt, bits, STORE) \
1877 static inline void gen_r6_cmp_ ## fmt(DisasContext *ctx, int n, \
1878 int ft, int fs, int fd) \
1880 TCGv_i ## bits fp0 = tcg_temp_new_i ## bits(); \
1881 TCGv_i ## bits fp1 = tcg_temp_new_i ## bits(); \
1882 if (ifmt == FMT_D) { \
1883 check_cp1_registers(ctx, fs | ft | fd); \
1885 gen_ldcmp_fpr ## bits(ctx, fp0, fs); \
1886 gen_ldcmp_fpr ## bits(ctx, fp1, ft); \
1889 gen_helper_r6_cmp_ ## fmt ## _af(fp0, cpu_env, fp0, fp1); \
1892 gen_helper_r6_cmp_ ## fmt ## _un(fp0, cpu_env, fp0, fp1); \
1895 gen_helper_r6_cmp_ ## fmt ## _eq(fp0, cpu_env, fp0, fp1); \
1898 gen_helper_r6_cmp_ ## fmt ## _ueq(fp0, cpu_env, fp0, fp1); \
1901 gen_helper_r6_cmp_ ## fmt ## _lt(fp0, cpu_env, fp0, fp1); \
1904 gen_helper_r6_cmp_ ## fmt ## _ult(fp0, cpu_env, fp0, fp1); \
1907 gen_helper_r6_cmp_ ## fmt ## _le(fp0, cpu_env, fp0, fp1); \
1910 gen_helper_r6_cmp_ ## fmt ## _ule(fp0, cpu_env, fp0, fp1); \
1913 gen_helper_r6_cmp_ ## fmt ## _saf(fp0, cpu_env, fp0, fp1); \
1916 gen_helper_r6_cmp_ ## fmt ## _sun(fp0, cpu_env, fp0, fp1); \
1919 gen_helper_r6_cmp_ ## fmt ## _seq(fp0, cpu_env, fp0, fp1); \
1922 gen_helper_r6_cmp_ ## fmt ## _sueq(fp0, cpu_env, fp0, fp1); \
1925 gen_helper_r6_cmp_ ## fmt ## _slt(fp0, cpu_env, fp0, fp1); \
1928 gen_helper_r6_cmp_ ## fmt ## _sult(fp0, cpu_env, fp0, fp1); \
1931 gen_helper_r6_cmp_ ## fmt ## _sle(fp0, cpu_env, fp0, fp1); \
1934 gen_helper_r6_cmp_ ## fmt ## _sule(fp0, cpu_env, fp0, fp1); \
1937 gen_helper_r6_cmp_ ## fmt ## _or(fp0, cpu_env, fp0, fp1); \
1940 gen_helper_r6_cmp_ ## fmt ## _une(fp0, cpu_env, fp0, fp1); \
1943 gen_helper_r6_cmp_ ## fmt ## _ne(fp0, cpu_env, fp0, fp1); \
1946 gen_helper_r6_cmp_ ## fmt ## _sor(fp0, cpu_env, fp0, fp1); \
1949 gen_helper_r6_cmp_ ## fmt ## _sune(fp0, cpu_env, fp0, fp1); \
1952 gen_helper_r6_cmp_ ## fmt ## _sne(fp0, cpu_env, fp0, fp1); \
1958 tcg_temp_free_i ## bits(fp0); \
1959 tcg_temp_free_i ## bits(fp1); \
1962 FOP_CONDNS(d
, FMT_D
, 64, gen_store_fpr64(ctx
, fp0
, fd
))
1963 FOP_CONDNS(s
, FMT_S
, 32, gen_store_fpr32(ctx
, fp0
, fd
))
1965 #undef gen_ldcmp_fpr32
1966 #undef gen_ldcmp_fpr64
1968 /* load/store instructions. */
1969 #ifdef CONFIG_USER_ONLY
1970 #define OP_LD_ATOMIC(insn, fname) \
1971 static inline void op_ld_##insn(TCGv ret, TCGv arg1, int mem_idx, \
1972 DisasContext *ctx) \
1974 TCGv t0 = tcg_temp_new(); \
1975 tcg_gen_mov_tl(t0, arg1); \
1976 tcg_gen_qemu_##fname(ret, arg1, ctx->mem_idx); \
1977 tcg_gen_st_tl(t0, cpu_env, offsetof(CPUMIPSState, lladdr)); \
1978 tcg_gen_st_tl(ret, cpu_env, offsetof(CPUMIPSState, llval)); \
1979 tcg_temp_free(t0); \
1982 #define OP_LD_ATOMIC(insn, fname) \
1983 static inline void op_ld_##insn(TCGv ret, TCGv arg1, int mem_idx, \
1984 DisasContext *ctx) \
1986 gen_helper_##insn(ret, cpu_env, arg1, tcg_constant_i32(mem_idx)); \
1989 OP_LD_ATOMIC(ll
, ld32s
);
1990 #if defined(TARGET_MIPS64)
1991 OP_LD_ATOMIC(lld
, ld64
);
1995 void gen_base_offset_addr(DisasContext
*ctx
, TCGv addr
, int base
, int offset
)
1998 tcg_gen_movi_tl(addr
, offset
);
1999 } else if (offset
== 0) {
2000 gen_load_gpr(addr
, base
);
2002 tcg_gen_movi_tl(addr
, offset
);
2003 gen_op_addr_add(ctx
, addr
, cpu_gpr
[base
], addr
);
2007 static target_ulong
pc_relative_pc(DisasContext
*ctx
)
2009 target_ulong pc
= ctx
->base
.pc_next
;
2011 if (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
2012 int branch_bytes
= ctx
->hflags
& MIPS_HFLAG_BDS16
? 2 : 4;
2017 pc
&= ~(target_ulong
)3;
2022 static void gen_ld(DisasContext
*ctx
, uint32_t opc
,
2023 int rt
, int base
, int offset
)
2026 int mem_idx
= ctx
->mem_idx
;
2028 if (rt
== 0 && ctx
->insn_flags
& (INSN_LOONGSON2E
| INSN_LOONGSON2F
|
2031 * Loongson CPU uses a load to zero register for prefetch.
2032 * We emulate it as a NOP. On other CPU we must perform the
2033 * actual memory access.
2038 t0
= tcg_temp_new();
2039 gen_base_offset_addr(ctx
, t0
, base
, offset
);
2042 #if defined(TARGET_MIPS64)
2044 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TEUL
|
2045 ctx
->default_tcg_memop_mask
);
2046 gen_store_gpr(t0
, rt
);
2049 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TEQ
|
2050 ctx
->default_tcg_memop_mask
);
2051 gen_store_gpr(t0
, rt
);
2055 op_ld_lld(t0
, t0
, mem_idx
, ctx
);
2056 gen_store_gpr(t0
, rt
);
2059 t1
= tcg_temp_new();
2061 * Do a byte access to possibly trigger a page
2062 * fault with the unaligned address.
2064 tcg_gen_qemu_ld_tl(t1
, t0
, mem_idx
, MO_UB
);
2065 tcg_gen_andi_tl(t1
, t0
, 7);
2066 #ifndef TARGET_WORDS_BIGENDIAN
2067 tcg_gen_xori_tl(t1
, t1
, 7);
2069 tcg_gen_shli_tl(t1
, t1
, 3);
2070 tcg_gen_andi_tl(t0
, t0
, ~7);
2071 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TEQ
);
2072 tcg_gen_shl_tl(t0
, t0
, t1
);
2073 t2
= tcg_const_tl(-1);
2074 tcg_gen_shl_tl(t2
, t2
, t1
);
2075 gen_load_gpr(t1
, rt
);
2076 tcg_gen_andc_tl(t1
, t1
, t2
);
2078 tcg_gen_or_tl(t0
, t0
, t1
);
2080 gen_store_gpr(t0
, rt
);
2083 t1
= tcg_temp_new();
2085 * Do a byte access to possibly trigger a page
2086 * fault with the unaligned address.
2088 tcg_gen_qemu_ld_tl(t1
, t0
, mem_idx
, MO_UB
);
2089 tcg_gen_andi_tl(t1
, t0
, 7);
2090 #ifdef TARGET_WORDS_BIGENDIAN
2091 tcg_gen_xori_tl(t1
, t1
, 7);
2093 tcg_gen_shli_tl(t1
, t1
, 3);
2094 tcg_gen_andi_tl(t0
, t0
, ~7);
2095 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TEQ
);
2096 tcg_gen_shr_tl(t0
, t0
, t1
);
2097 tcg_gen_xori_tl(t1
, t1
, 63);
2098 t2
= tcg_const_tl(0xfffffffffffffffeull
);
2099 tcg_gen_shl_tl(t2
, t2
, t1
);
2100 gen_load_gpr(t1
, rt
);
2101 tcg_gen_and_tl(t1
, t1
, t2
);
2103 tcg_gen_or_tl(t0
, t0
, t1
);
2105 gen_store_gpr(t0
, rt
);
2108 t1
= tcg_const_tl(pc_relative_pc(ctx
));
2109 gen_op_addr_add(ctx
, t0
, t0
, t1
);
2111 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TEQ
);
2112 gen_store_gpr(t0
, rt
);
2116 t1
= tcg_const_tl(pc_relative_pc(ctx
));
2117 gen_op_addr_add(ctx
, t0
, t0
, t1
);
2119 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TESL
);
2120 gen_store_gpr(t0
, rt
);
2123 mem_idx
= MIPS_HFLAG_UM
;
2126 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TESL
|
2127 ctx
->default_tcg_memop_mask
);
2128 gen_store_gpr(t0
, rt
);
2131 mem_idx
= MIPS_HFLAG_UM
;
2134 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TESW
|
2135 ctx
->default_tcg_memop_mask
);
2136 gen_store_gpr(t0
, rt
);
2139 mem_idx
= MIPS_HFLAG_UM
;
2142 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TEUW
|
2143 ctx
->default_tcg_memop_mask
);
2144 gen_store_gpr(t0
, rt
);
2147 mem_idx
= MIPS_HFLAG_UM
;
2150 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_SB
);
2151 gen_store_gpr(t0
, rt
);
2154 mem_idx
= MIPS_HFLAG_UM
;
2157 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_UB
);
2158 gen_store_gpr(t0
, rt
);
2161 mem_idx
= MIPS_HFLAG_UM
;
2164 t1
= tcg_temp_new();
2166 * Do a byte access to possibly trigger a page
2167 * fault with the unaligned address.
2169 tcg_gen_qemu_ld_tl(t1
, t0
, mem_idx
, MO_UB
);
2170 tcg_gen_andi_tl(t1
, t0
, 3);
2171 #ifndef TARGET_WORDS_BIGENDIAN
2172 tcg_gen_xori_tl(t1
, t1
, 3);
2174 tcg_gen_shli_tl(t1
, t1
, 3);
2175 tcg_gen_andi_tl(t0
, t0
, ~3);
2176 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TEUL
);
2177 tcg_gen_shl_tl(t0
, t0
, t1
);
2178 t2
= tcg_const_tl(-1);
2179 tcg_gen_shl_tl(t2
, t2
, t1
);
2180 gen_load_gpr(t1
, rt
);
2181 tcg_gen_andc_tl(t1
, t1
, t2
);
2183 tcg_gen_or_tl(t0
, t0
, t1
);
2185 tcg_gen_ext32s_tl(t0
, t0
);
2186 gen_store_gpr(t0
, rt
);
2189 mem_idx
= MIPS_HFLAG_UM
;
2192 t1
= tcg_temp_new();
2194 * Do a byte access to possibly trigger a page
2195 * fault with the unaligned address.
2197 tcg_gen_qemu_ld_tl(t1
, t0
, mem_idx
, MO_UB
);
2198 tcg_gen_andi_tl(t1
, t0
, 3);
2199 #ifdef TARGET_WORDS_BIGENDIAN
2200 tcg_gen_xori_tl(t1
, t1
, 3);
2202 tcg_gen_shli_tl(t1
, t1
, 3);
2203 tcg_gen_andi_tl(t0
, t0
, ~3);
2204 tcg_gen_qemu_ld_tl(t0
, t0
, mem_idx
, MO_TEUL
);
2205 tcg_gen_shr_tl(t0
, t0
, t1
);
2206 tcg_gen_xori_tl(t1
, t1
, 31);
2207 t2
= tcg_const_tl(0xfffffffeull
);
2208 tcg_gen_shl_tl(t2
, t2
, t1
);
2209 gen_load_gpr(t1
, rt
);
2210 tcg_gen_and_tl(t1
, t1
, t2
);
2212 tcg_gen_or_tl(t0
, t0
, t1
);
2214 tcg_gen_ext32s_tl(t0
, t0
);
2215 gen_store_gpr(t0
, rt
);
2218 mem_idx
= MIPS_HFLAG_UM
;
2222 op_ld_ll(t0
, t0
, mem_idx
, ctx
);
2223 gen_store_gpr(t0
, rt
);
2230 static void gen_st(DisasContext
*ctx
, uint32_t opc
, int rt
,
2231 int base
, int offset
)
2233 TCGv t0
= tcg_temp_new();
2234 TCGv t1
= tcg_temp_new();
2235 int mem_idx
= ctx
->mem_idx
;
2237 gen_base_offset_addr(ctx
, t0
, base
, offset
);
2238 gen_load_gpr(t1
, rt
);
2240 #if defined(TARGET_MIPS64)
2242 tcg_gen_qemu_st_tl(t1
, t0
, mem_idx
, MO_TEQ
|
2243 ctx
->default_tcg_memop_mask
);
2246 gen_helper_0e2i(sdl
, t1
, t0
, mem_idx
);
2249 gen_helper_0e2i(sdr
, t1
, t0
, mem_idx
);
2253 mem_idx
= MIPS_HFLAG_UM
;
2256 tcg_gen_qemu_st_tl(t1
, t0
, mem_idx
, MO_TEUL
|
2257 ctx
->default_tcg_memop_mask
);
2260 mem_idx
= MIPS_HFLAG_UM
;
2263 tcg_gen_qemu_st_tl(t1
, t0
, mem_idx
, MO_TEUW
|
2264 ctx
->default_tcg_memop_mask
);
2267 mem_idx
= MIPS_HFLAG_UM
;
2270 tcg_gen_qemu_st_tl(t1
, t0
, mem_idx
, MO_8
);
2273 mem_idx
= MIPS_HFLAG_UM
;
2276 gen_helper_0e2i(swl
, t1
, t0
, mem_idx
);
2279 mem_idx
= MIPS_HFLAG_UM
;
2282 gen_helper_0e2i(swr
, t1
, t0
, mem_idx
);
2290 /* Store conditional */
2291 static void gen_st_cond(DisasContext
*ctx
, int rt
, int base
, int offset
,
2292 MemOp tcg_mo
, bool eva
)
2295 TCGLabel
*l1
= gen_new_label();
2296 TCGLabel
*done
= gen_new_label();
2298 t0
= tcg_temp_new();
2299 addr
= tcg_temp_new();
2300 /* compare the address against that of the preceding LL */
2301 gen_base_offset_addr(ctx
, addr
, base
, offset
);
2302 tcg_gen_brcond_tl(TCG_COND_EQ
, addr
, cpu_lladdr
, l1
);
2303 tcg_temp_free(addr
);
2304 tcg_gen_movi_tl(t0
, 0);
2305 gen_store_gpr(t0
, rt
);
2309 /* generate cmpxchg */
2310 val
= tcg_temp_new();
2311 gen_load_gpr(val
, rt
);
2312 tcg_gen_atomic_cmpxchg_tl(t0
, cpu_lladdr
, cpu_llval
, val
,
2313 eva
? MIPS_HFLAG_UM
: ctx
->mem_idx
, tcg_mo
);
2314 tcg_gen_setcond_tl(TCG_COND_EQ
, t0
, t0
, cpu_llval
);
2315 gen_store_gpr(t0
, rt
);
2318 gen_set_label(done
);
2322 /* Load and store */
2323 static void gen_flt_ldst(DisasContext
*ctx
, uint32_t opc
, int ft
,
2327 * Don't do NOP if destination is zero: we must perform the actual
2333 TCGv_i32 fp0
= tcg_temp_new_i32();
2334 tcg_gen_qemu_ld_i32(fp0
, t0
, ctx
->mem_idx
, MO_TESL
|
2335 ctx
->default_tcg_memop_mask
);
2336 gen_store_fpr32(ctx
, fp0
, ft
);
2337 tcg_temp_free_i32(fp0
);
2342 TCGv_i32 fp0
= tcg_temp_new_i32();
2343 gen_load_fpr32(ctx
, fp0
, ft
);
2344 tcg_gen_qemu_st_i32(fp0
, t0
, ctx
->mem_idx
, MO_TEUL
|
2345 ctx
->default_tcg_memop_mask
);
2346 tcg_temp_free_i32(fp0
);
2351 TCGv_i64 fp0
= tcg_temp_new_i64();
2352 tcg_gen_qemu_ld_i64(fp0
, t0
, ctx
->mem_idx
, MO_TEQ
|
2353 ctx
->default_tcg_memop_mask
);
2354 gen_store_fpr64(ctx
, fp0
, ft
);
2355 tcg_temp_free_i64(fp0
);
2360 TCGv_i64 fp0
= tcg_temp_new_i64();
2361 gen_load_fpr64(ctx
, fp0
, ft
);
2362 tcg_gen_qemu_st_i64(fp0
, t0
, ctx
->mem_idx
, MO_TEQ
|
2363 ctx
->default_tcg_memop_mask
);
2364 tcg_temp_free_i64(fp0
);
2368 MIPS_INVAL("flt_ldst");
2369 gen_reserved_instruction(ctx
);
2374 static void gen_cop1_ldst(DisasContext
*ctx
, uint32_t op
, int rt
,
2375 int rs
, int16_t imm
)
2377 TCGv t0
= tcg_temp_new();
2379 if (ctx
->CP0_Config1
& (1 << CP0C1_FP
)) {
2380 check_cp1_enabled(ctx
);
2384 check_insn(ctx
, ISA_MIPS2
);
2387 gen_base_offset_addr(ctx
, t0
, rs
, imm
);
2388 gen_flt_ldst(ctx
, op
, rt
, t0
);
2391 generate_exception_err(ctx
, EXCP_CpU
, 1);
2396 /* Arithmetic with immediate operand */
2397 static void gen_arith_imm(DisasContext
*ctx
, uint32_t opc
,
2398 int rt
, int rs
, int imm
)
2400 target_ulong uimm
= (target_long
)imm
; /* Sign extend to 32/64 bits */
2402 if (rt
== 0 && opc
!= OPC_ADDI
&& opc
!= OPC_DADDI
) {
2404 * If no destination, treat it as a NOP.
2405 * For addi, we must generate the overflow exception when needed.
2412 TCGv t0
= tcg_temp_local_new();
2413 TCGv t1
= tcg_temp_new();
2414 TCGv t2
= tcg_temp_new();
2415 TCGLabel
*l1
= gen_new_label();
2417 gen_load_gpr(t1
, rs
);
2418 tcg_gen_addi_tl(t0
, t1
, uimm
);
2419 tcg_gen_ext32s_tl(t0
, t0
);
2421 tcg_gen_xori_tl(t1
, t1
, ~uimm
);
2422 tcg_gen_xori_tl(t2
, t0
, uimm
);
2423 tcg_gen_and_tl(t1
, t1
, t2
);
2425 tcg_gen_brcondi_tl(TCG_COND_GE
, t1
, 0, l1
);
2427 /* operands of same sign, result different sign */
2428 generate_exception(ctx
, EXCP_OVERFLOW
);
2430 tcg_gen_ext32s_tl(t0
, t0
);
2431 gen_store_gpr(t0
, rt
);
2437 tcg_gen_addi_tl(cpu_gpr
[rt
], cpu_gpr
[rs
], uimm
);
2438 tcg_gen_ext32s_tl(cpu_gpr
[rt
], cpu_gpr
[rt
]);
2440 tcg_gen_movi_tl(cpu_gpr
[rt
], uimm
);
2443 #if defined(TARGET_MIPS64)
2446 TCGv t0
= tcg_temp_local_new();
2447 TCGv t1
= tcg_temp_new();
2448 TCGv t2
= tcg_temp_new();
2449 TCGLabel
*l1
= gen_new_label();
2451 gen_load_gpr(t1
, rs
);
2452 tcg_gen_addi_tl(t0
, t1
, uimm
);
2454 tcg_gen_xori_tl(t1
, t1
, ~uimm
);
2455 tcg_gen_xori_tl(t2
, t0
, uimm
);
2456 tcg_gen_and_tl(t1
, t1
, t2
);
2458 tcg_gen_brcondi_tl(TCG_COND_GE
, t1
, 0, l1
);
2460 /* operands of same sign, result different sign */
2461 generate_exception(ctx
, EXCP_OVERFLOW
);
2463 gen_store_gpr(t0
, rt
);
2469 tcg_gen_addi_tl(cpu_gpr
[rt
], cpu_gpr
[rs
], uimm
);
2471 tcg_gen_movi_tl(cpu_gpr
[rt
], uimm
);
2478 /* Logic with immediate operand */
2479 static void gen_logic_imm(DisasContext
*ctx
, uint32_t opc
,
2480 int rt
, int rs
, int16_t imm
)
2485 /* If no destination, treat it as a NOP. */
2488 uimm
= (uint16_t)imm
;
2491 if (likely(rs
!= 0)) {
2492 tcg_gen_andi_tl(cpu_gpr
[rt
], cpu_gpr
[rs
], uimm
);
2494 tcg_gen_movi_tl(cpu_gpr
[rt
], 0);
2499 tcg_gen_ori_tl(cpu_gpr
[rt
], cpu_gpr
[rs
], uimm
);
2501 tcg_gen_movi_tl(cpu_gpr
[rt
], uimm
);
2505 if (likely(rs
!= 0)) {
2506 tcg_gen_xori_tl(cpu_gpr
[rt
], cpu_gpr
[rs
], uimm
);
2508 tcg_gen_movi_tl(cpu_gpr
[rt
], uimm
);
2512 if (rs
!= 0 && (ctx
->insn_flags
& ISA_MIPS_R6
)) {
2514 tcg_gen_addi_tl(cpu_gpr
[rt
], cpu_gpr
[rs
], imm
<< 16);
2515 tcg_gen_ext32s_tl(cpu_gpr
[rt
], cpu_gpr
[rt
]);
2517 tcg_gen_movi_tl(cpu_gpr
[rt
], imm
<< 16);
2526 /* Set on less than with immediate operand */
2527 static void gen_slt_imm(DisasContext
*ctx
, uint32_t opc
,
2528 int rt
, int rs
, int16_t imm
)
2530 target_ulong uimm
= (target_long
)imm
; /* Sign extend to 32/64 bits */
2534 /* If no destination, treat it as a NOP. */
2537 t0
= tcg_temp_new();
2538 gen_load_gpr(t0
, rs
);
2541 tcg_gen_setcondi_tl(TCG_COND_LT
, cpu_gpr
[rt
], t0
, uimm
);
2544 tcg_gen_setcondi_tl(TCG_COND_LTU
, cpu_gpr
[rt
], t0
, uimm
);
2550 /* Shifts with immediate operand */
2551 static void gen_shift_imm(DisasContext
*ctx
, uint32_t opc
,
2552 int rt
, int rs
, int16_t imm
)
2554 target_ulong uimm
= ((uint16_t)imm
) & 0x1f;
2558 /* If no destination, treat it as a NOP. */
2562 t0
= tcg_temp_new();
2563 gen_load_gpr(t0
, rs
);
2566 tcg_gen_shli_tl(t0
, t0
, uimm
);
2567 tcg_gen_ext32s_tl(cpu_gpr
[rt
], t0
);
2570 tcg_gen_sari_tl(cpu_gpr
[rt
], t0
, uimm
);
2574 tcg_gen_ext32u_tl(t0
, t0
);
2575 tcg_gen_shri_tl(cpu_gpr
[rt
], t0
, uimm
);
2577 tcg_gen_ext32s_tl(cpu_gpr
[rt
], t0
);
2582 TCGv_i32 t1
= tcg_temp_new_i32();
2584 tcg_gen_trunc_tl_i32(t1
, t0
);
2585 tcg_gen_rotri_i32(t1
, t1
, uimm
);
2586 tcg_gen_ext_i32_tl(cpu_gpr
[rt
], t1
);
2587 tcg_temp_free_i32(t1
);
2589 tcg_gen_ext32s_tl(cpu_gpr
[rt
], t0
);
2592 #if defined(TARGET_MIPS64)
2594 tcg_gen_shli_tl(cpu_gpr
[rt
], t0
, uimm
);
2597 tcg_gen_sari_tl(cpu_gpr
[rt
], t0
, uimm
);
2600 tcg_gen_shri_tl(cpu_gpr
[rt
], t0
, uimm
);
2604 tcg_gen_rotri_tl(cpu_gpr
[rt
], t0
, uimm
);
2606 tcg_gen_mov_tl(cpu_gpr
[rt
], t0
);
2610 tcg_gen_shli_tl(cpu_gpr
[rt
], t0
, uimm
+ 32);
2613 tcg_gen_sari_tl(cpu_gpr
[rt
], t0
, uimm
+ 32);
2616 tcg_gen_shri_tl(cpu_gpr
[rt
], t0
, uimm
+ 32);
2619 tcg_gen_rotri_tl(cpu_gpr
[rt
], t0
, uimm
+ 32);
2627 static void gen_arith(DisasContext
*ctx
, uint32_t opc
,
2628 int rd
, int rs
, int rt
)
2630 if (rd
== 0 && opc
!= OPC_ADD
&& opc
!= OPC_SUB
2631 && opc
!= OPC_DADD
&& opc
!= OPC_DSUB
) {
2633 * If no destination, treat it as a NOP.
2634 * For add & sub, we must generate the overflow exception when needed.
2642 TCGv t0
= tcg_temp_local_new();
2643 TCGv t1
= tcg_temp_new();
2644 TCGv t2
= tcg_temp_new();
2645 TCGLabel
*l1
= gen_new_label();
2647 gen_load_gpr(t1
, rs
);
2648 gen_load_gpr(t2
, rt
);
2649 tcg_gen_add_tl(t0
, t1
, t2
);
2650 tcg_gen_ext32s_tl(t0
, t0
);
2651 tcg_gen_xor_tl(t1
, t1
, t2
);
2652 tcg_gen_xor_tl(t2
, t0
, t2
);
2653 tcg_gen_andc_tl(t1
, t2
, t1
);
2655 tcg_gen_brcondi_tl(TCG_COND_GE
, t1
, 0, l1
);
2657 /* operands of same sign, result different sign */
2658 generate_exception(ctx
, EXCP_OVERFLOW
);
2660 gen_store_gpr(t0
, rd
);
2665 if (rs
!= 0 && rt
!= 0) {
2666 tcg_gen_add_tl(cpu_gpr
[rd
], cpu_gpr
[rs
], cpu_gpr
[rt
]);
2667 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
2668 } else if (rs
== 0 && rt
!= 0) {
2669 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rt
]);
2670 } else if (rs
!= 0 && rt
== 0) {
2671 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rs
]);
2673 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
2678 TCGv t0
= tcg_temp_local_new();
2679 TCGv t1
= tcg_temp_new();
2680 TCGv t2
= tcg_temp_new();
2681 TCGLabel
*l1
= gen_new_label();
2683 gen_load_gpr(t1
, rs
);
2684 gen_load_gpr(t2
, rt
);
2685 tcg_gen_sub_tl(t0
, t1
, t2
);
2686 tcg_gen_ext32s_tl(t0
, t0
);
2687 tcg_gen_xor_tl(t2
, t1
, t2
);
2688 tcg_gen_xor_tl(t1
, t0
, t1
);
2689 tcg_gen_and_tl(t1
, t1
, t2
);
2691 tcg_gen_brcondi_tl(TCG_COND_GE
, t1
, 0, l1
);
2694 * operands of different sign, first operand and the result
2697 generate_exception(ctx
, EXCP_OVERFLOW
);
2699 gen_store_gpr(t0
, rd
);
2704 if (rs
!= 0 && rt
!= 0) {
2705 tcg_gen_sub_tl(cpu_gpr
[rd
], cpu_gpr
[rs
], cpu_gpr
[rt
]);
2706 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
2707 } else if (rs
== 0 && rt
!= 0) {
2708 tcg_gen_neg_tl(cpu_gpr
[rd
], cpu_gpr
[rt
]);
2709 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
2710 } else if (rs
!= 0 && rt
== 0) {
2711 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rs
]);
2713 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
2716 #if defined(TARGET_MIPS64)
2719 TCGv t0
= tcg_temp_local_new();
2720 TCGv t1
= tcg_temp_new();
2721 TCGv t2
= tcg_temp_new();
2722 TCGLabel
*l1
= gen_new_label();
2724 gen_load_gpr(t1
, rs
);
2725 gen_load_gpr(t2
, rt
);
2726 tcg_gen_add_tl(t0
, t1
, t2
);
2727 tcg_gen_xor_tl(t1
, t1
, t2
);
2728 tcg_gen_xor_tl(t2
, t0
, t2
);
2729 tcg_gen_andc_tl(t1
, t2
, t1
);
2731 tcg_gen_brcondi_tl(TCG_COND_GE
, t1
, 0, l1
);
2733 /* operands of same sign, result different sign */
2734 generate_exception(ctx
, EXCP_OVERFLOW
);
2736 gen_store_gpr(t0
, rd
);
2741 if (rs
!= 0 && rt
!= 0) {
2742 tcg_gen_add_tl(cpu_gpr
[rd
], cpu_gpr
[rs
], cpu_gpr
[rt
]);
2743 } else if (rs
== 0 && rt
!= 0) {
2744 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rt
]);
2745 } else if (rs
!= 0 && rt
== 0) {
2746 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rs
]);
2748 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
2753 TCGv t0
= tcg_temp_local_new();
2754 TCGv t1
= tcg_temp_new();
2755 TCGv t2
= tcg_temp_new();
2756 TCGLabel
*l1
= gen_new_label();
2758 gen_load_gpr(t1
, rs
);
2759 gen_load_gpr(t2
, rt
);
2760 tcg_gen_sub_tl(t0
, t1
, t2
);
2761 tcg_gen_xor_tl(t2
, t1
, t2
);
2762 tcg_gen_xor_tl(t1
, t0
, t1
);
2763 tcg_gen_and_tl(t1
, t1
, t2
);
2765 tcg_gen_brcondi_tl(TCG_COND_GE
, t1
, 0, l1
);
2768 * Operands of different sign, first operand and result different
2771 generate_exception(ctx
, EXCP_OVERFLOW
);
2773 gen_store_gpr(t0
, rd
);
2778 if (rs
!= 0 && rt
!= 0) {
2779 tcg_gen_sub_tl(cpu_gpr
[rd
], cpu_gpr
[rs
], cpu_gpr
[rt
]);
2780 } else if (rs
== 0 && rt
!= 0) {
2781 tcg_gen_neg_tl(cpu_gpr
[rd
], cpu_gpr
[rt
]);
2782 } else if (rs
!= 0 && rt
== 0) {
2783 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rs
]);
2785 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
2790 if (likely(rs
!= 0 && rt
!= 0)) {
2791 tcg_gen_mul_tl(cpu_gpr
[rd
], cpu_gpr
[rs
], cpu_gpr
[rt
]);
2792 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
2794 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
2800 /* Conditional move */
2801 static void gen_cond_move(DisasContext
*ctx
, uint32_t opc
,
2802 int rd
, int rs
, int rt
)
2807 /* If no destination, treat it as a NOP. */
2811 t0
= tcg_temp_new();
2812 gen_load_gpr(t0
, rt
);
2813 t1
= tcg_const_tl(0);
2814 t2
= tcg_temp_new();
2815 gen_load_gpr(t2
, rs
);
2818 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr
[rd
], t0
, t1
, t2
, cpu_gpr
[rd
]);
2821 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr
[rd
], t0
, t1
, t2
, cpu_gpr
[rd
]);
2824 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr
[rd
], t0
, t1
, t2
, t1
);
2827 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr
[rd
], t0
, t1
, t2
, t1
);
2836 static void gen_logic(DisasContext
*ctx
, uint32_t opc
,
2837 int rd
, int rs
, int rt
)
2840 /* If no destination, treat it as a NOP. */
2846 if (likely(rs
!= 0 && rt
!= 0)) {
2847 tcg_gen_and_tl(cpu_gpr
[rd
], cpu_gpr
[rs
], cpu_gpr
[rt
]);
2849 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
2853 if (rs
!= 0 && rt
!= 0) {
2854 tcg_gen_nor_tl(cpu_gpr
[rd
], cpu_gpr
[rs
], cpu_gpr
[rt
]);
2855 } else if (rs
== 0 && rt
!= 0) {
2856 tcg_gen_not_tl(cpu_gpr
[rd
], cpu_gpr
[rt
]);
2857 } else if (rs
!= 0 && rt
== 0) {
2858 tcg_gen_not_tl(cpu_gpr
[rd
], cpu_gpr
[rs
]);
2860 tcg_gen_movi_tl(cpu_gpr
[rd
], ~((target_ulong
)0));
2864 if (likely(rs
!= 0 && rt
!= 0)) {
2865 tcg_gen_or_tl(cpu_gpr
[rd
], cpu_gpr
[rs
], cpu_gpr
[rt
]);
2866 } else if (rs
== 0 && rt
!= 0) {
2867 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rt
]);
2868 } else if (rs
!= 0 && rt
== 0) {
2869 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rs
]);
2871 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
2875 if (likely(rs
!= 0 && rt
!= 0)) {
2876 tcg_gen_xor_tl(cpu_gpr
[rd
], cpu_gpr
[rs
], cpu_gpr
[rt
]);
2877 } else if (rs
== 0 && rt
!= 0) {
2878 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rt
]);
2879 } else if (rs
!= 0 && rt
== 0) {
2880 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rs
]);
2882 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
2888 /* Set on lower than */
2889 static void gen_slt(DisasContext
*ctx
, uint32_t opc
,
2890 int rd
, int rs
, int rt
)
2895 /* If no destination, treat it as a NOP. */
2899 t0
= tcg_temp_new();
2900 t1
= tcg_temp_new();
2901 gen_load_gpr(t0
, rs
);
2902 gen_load_gpr(t1
, rt
);
2905 tcg_gen_setcond_tl(TCG_COND_LT
, cpu_gpr
[rd
], t0
, t1
);
2908 tcg_gen_setcond_tl(TCG_COND_LTU
, cpu_gpr
[rd
], t0
, t1
);
2916 static void gen_shift(DisasContext
*ctx
, uint32_t opc
,
2917 int rd
, int rs
, int rt
)
2923 * If no destination, treat it as a NOP.
2924 * For add & sub, we must generate the overflow exception when needed.
2929 t0
= tcg_temp_new();
2930 t1
= tcg_temp_new();
2931 gen_load_gpr(t0
, rs
);
2932 gen_load_gpr(t1
, rt
);
2935 tcg_gen_andi_tl(t0
, t0
, 0x1f);
2936 tcg_gen_shl_tl(t0
, t1
, t0
);
2937 tcg_gen_ext32s_tl(cpu_gpr
[rd
], t0
);
2940 tcg_gen_andi_tl(t0
, t0
, 0x1f);
2941 tcg_gen_sar_tl(cpu_gpr
[rd
], t1
, t0
);
2944 tcg_gen_ext32u_tl(t1
, t1
);
2945 tcg_gen_andi_tl(t0
, t0
, 0x1f);
2946 tcg_gen_shr_tl(t0
, t1
, t0
);
2947 tcg_gen_ext32s_tl(cpu_gpr
[rd
], t0
);
2951 TCGv_i32 t2
= tcg_temp_new_i32();
2952 TCGv_i32 t3
= tcg_temp_new_i32();
2954 tcg_gen_trunc_tl_i32(t2
, t0
);
2955 tcg_gen_trunc_tl_i32(t3
, t1
);
2956 tcg_gen_andi_i32(t2
, t2
, 0x1f);
2957 tcg_gen_rotr_i32(t2
, t3
, t2
);
2958 tcg_gen_ext_i32_tl(cpu_gpr
[rd
], t2
);
2959 tcg_temp_free_i32(t2
);
2960 tcg_temp_free_i32(t3
);
2963 #if defined(TARGET_MIPS64)
2965 tcg_gen_andi_tl(t0
, t0
, 0x3f);
2966 tcg_gen_shl_tl(cpu_gpr
[rd
], t1
, t0
);
2969 tcg_gen_andi_tl(t0
, t0
, 0x3f);
2970 tcg_gen_sar_tl(cpu_gpr
[rd
], t1
, t0
);
2973 tcg_gen_andi_tl(t0
, t0
, 0x3f);
2974 tcg_gen_shr_tl(cpu_gpr
[rd
], t1
, t0
);
2977 tcg_gen_andi_tl(t0
, t0
, 0x3f);
2978 tcg_gen_rotr_tl(cpu_gpr
[rd
], t1
, t0
);
2986 /* Arithmetic on HI/LO registers */
2987 static void gen_HILO(DisasContext
*ctx
, uint32_t opc
, int acc
, int reg
)
2989 if (reg
== 0 && (opc
== OPC_MFHI
|| opc
== OPC_MFLO
)) {
3000 #if defined(TARGET_MIPS64)
3002 tcg_gen_ext32s_tl(cpu_gpr
[reg
], cpu_HI
[acc
]);
3006 tcg_gen_mov_tl(cpu_gpr
[reg
], cpu_HI
[acc
]);
3010 #if defined(TARGET_MIPS64)
3012 tcg_gen_ext32s_tl(cpu_gpr
[reg
], cpu_LO
[acc
]);
3016 tcg_gen_mov_tl(cpu_gpr
[reg
], cpu_LO
[acc
]);
3021 #if defined(TARGET_MIPS64)
3023 tcg_gen_ext32s_tl(cpu_HI
[acc
], cpu_gpr
[reg
]);
3027 tcg_gen_mov_tl(cpu_HI
[acc
], cpu_gpr
[reg
]);
3030 tcg_gen_movi_tl(cpu_HI
[acc
], 0);
3035 #if defined(TARGET_MIPS64)
3037 tcg_gen_ext32s_tl(cpu_LO
[acc
], cpu_gpr
[reg
]);
3041 tcg_gen_mov_tl(cpu_LO
[acc
], cpu_gpr
[reg
]);
3044 tcg_gen_movi_tl(cpu_LO
[acc
], 0);
3050 static inline void gen_r6_ld(target_long addr
, int reg
, int memidx
,
3053 TCGv t0
= tcg_const_tl(addr
);
3054 tcg_gen_qemu_ld_tl(t0
, t0
, memidx
, memop
);
3055 gen_store_gpr(t0
, reg
);
3059 static inline void gen_pcrel(DisasContext
*ctx
, int opc
, target_ulong pc
,
3065 switch (MASK_OPC_PCREL_TOP2BITS(opc
)) {
3068 offset
= sextract32(ctx
->opcode
<< 2, 0, 21);
3069 addr
= addr_add(ctx
, pc
, offset
);
3070 tcg_gen_movi_tl(cpu_gpr
[rs
], addr
);
3074 offset
= sextract32(ctx
->opcode
<< 2, 0, 21);
3075 addr
= addr_add(ctx
, pc
, offset
);
3076 gen_r6_ld(addr
, rs
, ctx
->mem_idx
, MO_TESL
);
3078 #if defined(TARGET_MIPS64)
3081 offset
= sextract32(ctx
->opcode
<< 2, 0, 21);
3082 addr
= addr_add(ctx
, pc
, offset
);
3083 gen_r6_ld(addr
, rs
, ctx
->mem_idx
, MO_TEUL
);
3087 switch (MASK_OPC_PCREL_TOP5BITS(opc
)) {
3090 offset
= sextract32(ctx
->opcode
, 0, 16) << 16;
3091 addr
= addr_add(ctx
, pc
, offset
);
3092 tcg_gen_movi_tl(cpu_gpr
[rs
], addr
);
3097 offset
= sextract32(ctx
->opcode
, 0, 16) << 16;
3098 addr
= ~0xFFFF & addr_add(ctx
, pc
, offset
);
3099 tcg_gen_movi_tl(cpu_gpr
[rs
], addr
);
3102 #if defined(TARGET_MIPS64)
3103 case R6_OPC_LDPC
: /* bits 16 and 17 are part of immediate */
3104 case R6_OPC_LDPC
+ (1 << 16):
3105 case R6_OPC_LDPC
+ (2 << 16):
3106 case R6_OPC_LDPC
+ (3 << 16):
3108 offset
= sextract32(ctx
->opcode
<< 3, 0, 21);
3109 addr
= addr_add(ctx
, (pc
& ~0x7), offset
);
3110 gen_r6_ld(addr
, rs
, ctx
->mem_idx
, MO_TEQ
);
3114 MIPS_INVAL("OPC_PCREL");
3115 gen_reserved_instruction(ctx
);
3122 static void gen_r6_muldiv(DisasContext
*ctx
, int opc
, int rd
, int rs
, int rt
)
3131 t0
= tcg_temp_new();
3132 t1
= tcg_temp_new();
3134 gen_load_gpr(t0
, rs
);
3135 gen_load_gpr(t1
, rt
);
3140 TCGv t2
= tcg_temp_new();
3141 TCGv t3
= tcg_temp_new();
3142 tcg_gen_ext32s_tl(t0
, t0
);
3143 tcg_gen_ext32s_tl(t1
, t1
);
3144 tcg_gen_setcondi_tl(TCG_COND_EQ
, t2
, t0
, INT_MIN
);
3145 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, -1);
3146 tcg_gen_and_tl(t2
, t2
, t3
);
3147 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, 0);
3148 tcg_gen_or_tl(t2
, t2
, t3
);
3149 tcg_gen_movi_tl(t3
, 0);
3150 tcg_gen_movcond_tl(TCG_COND_NE
, t1
, t2
, t3
, t2
, t1
);
3151 tcg_gen_div_tl(cpu_gpr
[rd
], t0
, t1
);
3152 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3159 TCGv t2
= tcg_temp_new();
3160 TCGv t3
= tcg_temp_new();
3161 tcg_gen_ext32s_tl(t0
, t0
);
3162 tcg_gen_ext32s_tl(t1
, t1
);
3163 tcg_gen_setcondi_tl(TCG_COND_EQ
, t2
, t0
, INT_MIN
);
3164 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, -1);
3165 tcg_gen_and_tl(t2
, t2
, t3
);
3166 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, 0);
3167 tcg_gen_or_tl(t2
, t2
, t3
);
3168 tcg_gen_movi_tl(t3
, 0);
3169 tcg_gen_movcond_tl(TCG_COND_NE
, t1
, t2
, t3
, t2
, t1
);
3170 tcg_gen_rem_tl(cpu_gpr
[rd
], t0
, t1
);
3171 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3178 TCGv t2
= tcg_const_tl(0);
3179 TCGv t3
= tcg_const_tl(1);
3180 tcg_gen_ext32u_tl(t0
, t0
);
3181 tcg_gen_ext32u_tl(t1
, t1
);
3182 tcg_gen_movcond_tl(TCG_COND_EQ
, t1
, t1
, t2
, t3
, t1
);
3183 tcg_gen_divu_tl(cpu_gpr
[rd
], t0
, t1
);
3184 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3191 TCGv t2
= tcg_const_tl(0);
3192 TCGv t3
= tcg_const_tl(1);
3193 tcg_gen_ext32u_tl(t0
, t0
);
3194 tcg_gen_ext32u_tl(t1
, t1
);
3195 tcg_gen_movcond_tl(TCG_COND_EQ
, t1
, t1
, t2
, t3
, t1
);
3196 tcg_gen_remu_tl(cpu_gpr
[rd
], t0
, t1
);
3197 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3204 TCGv_i32 t2
= tcg_temp_new_i32();
3205 TCGv_i32 t3
= tcg_temp_new_i32();
3206 tcg_gen_trunc_tl_i32(t2
, t0
);
3207 tcg_gen_trunc_tl_i32(t3
, t1
);
3208 tcg_gen_mul_i32(t2
, t2
, t3
);
3209 tcg_gen_ext_i32_tl(cpu_gpr
[rd
], t2
);
3210 tcg_temp_free_i32(t2
);
3211 tcg_temp_free_i32(t3
);
3216 TCGv_i32 t2
= tcg_temp_new_i32();
3217 TCGv_i32 t3
= tcg_temp_new_i32();
3218 tcg_gen_trunc_tl_i32(t2
, t0
);
3219 tcg_gen_trunc_tl_i32(t3
, t1
);
3220 tcg_gen_muls2_i32(t2
, t3
, t2
, t3
);
3221 tcg_gen_ext_i32_tl(cpu_gpr
[rd
], t3
);
3222 tcg_temp_free_i32(t2
);
3223 tcg_temp_free_i32(t3
);
3228 TCGv_i32 t2
= tcg_temp_new_i32();
3229 TCGv_i32 t3
= tcg_temp_new_i32();
3230 tcg_gen_trunc_tl_i32(t2
, t0
);
3231 tcg_gen_trunc_tl_i32(t3
, t1
);
3232 tcg_gen_mul_i32(t2
, t2
, t3
);
3233 tcg_gen_ext_i32_tl(cpu_gpr
[rd
], t2
);
3234 tcg_temp_free_i32(t2
);
3235 tcg_temp_free_i32(t3
);
3240 TCGv_i32 t2
= tcg_temp_new_i32();
3241 TCGv_i32 t3
= tcg_temp_new_i32();
3242 tcg_gen_trunc_tl_i32(t2
, t0
);
3243 tcg_gen_trunc_tl_i32(t3
, t1
);
3244 tcg_gen_mulu2_i32(t2
, t3
, t2
, t3
);
3245 tcg_gen_ext_i32_tl(cpu_gpr
[rd
], t3
);
3246 tcg_temp_free_i32(t2
);
3247 tcg_temp_free_i32(t3
);
3250 #if defined(TARGET_MIPS64)
3253 TCGv t2
= tcg_temp_new();
3254 TCGv t3
= tcg_temp_new();
3255 tcg_gen_setcondi_tl(TCG_COND_EQ
, t2
, t0
, -1LL << 63);
3256 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, -1LL);
3257 tcg_gen_and_tl(t2
, t2
, t3
);
3258 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, 0);
3259 tcg_gen_or_tl(t2
, t2
, t3
);
3260 tcg_gen_movi_tl(t3
, 0);
3261 tcg_gen_movcond_tl(TCG_COND_NE
, t1
, t2
, t3
, t2
, t1
);
3262 tcg_gen_div_tl(cpu_gpr
[rd
], t0
, t1
);
3269 TCGv t2
= tcg_temp_new();
3270 TCGv t3
= tcg_temp_new();
3271 tcg_gen_setcondi_tl(TCG_COND_EQ
, t2
, t0
, -1LL << 63);
3272 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, -1LL);
3273 tcg_gen_and_tl(t2
, t2
, t3
);
3274 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, 0);
3275 tcg_gen_or_tl(t2
, t2
, t3
);
3276 tcg_gen_movi_tl(t3
, 0);
3277 tcg_gen_movcond_tl(TCG_COND_NE
, t1
, t2
, t3
, t2
, t1
);
3278 tcg_gen_rem_tl(cpu_gpr
[rd
], t0
, t1
);
3285 TCGv t2
= tcg_const_tl(0);
3286 TCGv t3
= tcg_const_tl(1);
3287 tcg_gen_movcond_tl(TCG_COND_EQ
, t1
, t1
, t2
, t3
, t1
);
3288 tcg_gen_divu_i64(cpu_gpr
[rd
], t0
, t1
);
3295 TCGv t2
= tcg_const_tl(0);
3296 TCGv t3
= tcg_const_tl(1);
3297 tcg_gen_movcond_tl(TCG_COND_EQ
, t1
, t1
, t2
, t3
, t1
);
3298 tcg_gen_remu_i64(cpu_gpr
[rd
], t0
, t1
);
3304 tcg_gen_mul_i64(cpu_gpr
[rd
], t0
, t1
);
3308 TCGv t2
= tcg_temp_new();
3309 tcg_gen_muls2_i64(t2
, cpu_gpr
[rd
], t0
, t1
);
3314 tcg_gen_mul_i64(cpu_gpr
[rd
], t0
, t1
);
3318 TCGv t2
= tcg_temp_new();
3319 tcg_gen_mulu2_i64(t2
, cpu_gpr
[rd
], t0
, t1
);
3325 MIPS_INVAL("r6 mul/div");
3326 gen_reserved_instruction(ctx
);
3334 #if defined(TARGET_MIPS64)
3335 static void gen_div1_tx79(DisasContext
*ctx
, uint32_t opc
, int rs
, int rt
)
3339 t0
= tcg_temp_new();
3340 t1
= tcg_temp_new();
3342 gen_load_gpr(t0
, rs
);
3343 gen_load_gpr(t1
, rt
);
3348 TCGv t2
= tcg_temp_new();
3349 TCGv t3
= tcg_temp_new();
3350 tcg_gen_ext32s_tl(t0
, t0
);
3351 tcg_gen_ext32s_tl(t1
, t1
);
3352 tcg_gen_setcondi_tl(TCG_COND_EQ
, t2
, t0
, INT_MIN
);
3353 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, -1);
3354 tcg_gen_and_tl(t2
, t2
, t3
);
3355 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, 0);
3356 tcg_gen_or_tl(t2
, t2
, t3
);
3357 tcg_gen_movi_tl(t3
, 0);
3358 tcg_gen_movcond_tl(TCG_COND_NE
, t1
, t2
, t3
, t2
, t1
);
3359 tcg_gen_div_tl(cpu_LO
[1], t0
, t1
);
3360 tcg_gen_rem_tl(cpu_HI
[1], t0
, t1
);
3361 tcg_gen_ext32s_tl(cpu_LO
[1], cpu_LO
[1]);
3362 tcg_gen_ext32s_tl(cpu_HI
[1], cpu_HI
[1]);
3369 TCGv t2
= tcg_const_tl(0);
3370 TCGv t3
= tcg_const_tl(1);
3371 tcg_gen_ext32u_tl(t0
, t0
);
3372 tcg_gen_ext32u_tl(t1
, t1
);
3373 tcg_gen_movcond_tl(TCG_COND_EQ
, t1
, t1
, t2
, t3
, t1
);
3374 tcg_gen_divu_tl(cpu_LO
[1], t0
, t1
);
3375 tcg_gen_remu_tl(cpu_HI
[1], t0
, t1
);
3376 tcg_gen_ext32s_tl(cpu_LO
[1], cpu_LO
[1]);
3377 tcg_gen_ext32s_tl(cpu_HI
[1], cpu_HI
[1]);
3383 MIPS_INVAL("div1 TX79");
3384 gen_reserved_instruction(ctx
);
3393 static void gen_muldiv(DisasContext
*ctx
, uint32_t opc
,
3394 int acc
, int rs
, int rt
)
3398 t0
= tcg_temp_new();
3399 t1
= tcg_temp_new();
3401 gen_load_gpr(t0
, rs
);
3402 gen_load_gpr(t1
, rt
);
3411 TCGv t2
= tcg_temp_new();
3412 TCGv t3
= tcg_temp_new();
3413 tcg_gen_ext32s_tl(t0
, t0
);
3414 tcg_gen_ext32s_tl(t1
, t1
);
3415 tcg_gen_setcondi_tl(TCG_COND_EQ
, t2
, t0
, INT_MIN
);
3416 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, -1);
3417 tcg_gen_and_tl(t2
, t2
, t3
);
3418 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, 0);
3419 tcg_gen_or_tl(t2
, t2
, t3
);
3420 tcg_gen_movi_tl(t3
, 0);
3421 tcg_gen_movcond_tl(TCG_COND_NE
, t1
, t2
, t3
, t2
, t1
);
3422 tcg_gen_div_tl(cpu_LO
[acc
], t0
, t1
);
3423 tcg_gen_rem_tl(cpu_HI
[acc
], t0
, t1
);
3424 tcg_gen_ext32s_tl(cpu_LO
[acc
], cpu_LO
[acc
]);
3425 tcg_gen_ext32s_tl(cpu_HI
[acc
], cpu_HI
[acc
]);
3432 TCGv t2
= tcg_const_tl(0);
3433 TCGv t3
= tcg_const_tl(1);
3434 tcg_gen_ext32u_tl(t0
, t0
);
3435 tcg_gen_ext32u_tl(t1
, t1
);
3436 tcg_gen_movcond_tl(TCG_COND_EQ
, t1
, t1
, t2
, t3
, t1
);
3437 tcg_gen_divu_tl(cpu_LO
[acc
], t0
, t1
);
3438 tcg_gen_remu_tl(cpu_HI
[acc
], t0
, t1
);
3439 tcg_gen_ext32s_tl(cpu_LO
[acc
], cpu_LO
[acc
]);
3440 tcg_gen_ext32s_tl(cpu_HI
[acc
], cpu_HI
[acc
]);
3447 TCGv_i32 t2
= tcg_temp_new_i32();
3448 TCGv_i32 t3
= tcg_temp_new_i32();
3449 tcg_gen_trunc_tl_i32(t2
, t0
);
3450 tcg_gen_trunc_tl_i32(t3
, t1
);
3451 tcg_gen_muls2_i32(t2
, t3
, t2
, t3
);
3452 tcg_gen_ext_i32_tl(cpu_LO
[acc
], t2
);
3453 tcg_gen_ext_i32_tl(cpu_HI
[acc
], t3
);
3454 tcg_temp_free_i32(t2
);
3455 tcg_temp_free_i32(t3
);
3460 TCGv_i32 t2
= tcg_temp_new_i32();
3461 TCGv_i32 t3
= tcg_temp_new_i32();
3462 tcg_gen_trunc_tl_i32(t2
, t0
);
3463 tcg_gen_trunc_tl_i32(t3
, t1
);
3464 tcg_gen_mulu2_i32(t2
, t3
, t2
, t3
);
3465 tcg_gen_ext_i32_tl(cpu_LO
[acc
], t2
);
3466 tcg_gen_ext_i32_tl(cpu_HI
[acc
], t3
);
3467 tcg_temp_free_i32(t2
);
3468 tcg_temp_free_i32(t3
);
3471 #if defined(TARGET_MIPS64)
3474 TCGv t2
= tcg_temp_new();
3475 TCGv t3
= tcg_temp_new();
3476 tcg_gen_setcondi_tl(TCG_COND_EQ
, t2
, t0
, -1LL << 63);
3477 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, -1LL);
3478 tcg_gen_and_tl(t2
, t2
, t3
);
3479 tcg_gen_setcondi_tl(TCG_COND_EQ
, t3
, t1
, 0);
3480 tcg_gen_or_tl(t2
, t2
, t3
);
3481 tcg_gen_movi_tl(t3
, 0);
3482 tcg_gen_movcond_tl(TCG_COND_NE
, t1
, t2
, t3
, t2
, t1
);
3483 tcg_gen_div_tl(cpu_LO
[acc
], t0
, t1
);
3484 tcg_gen_rem_tl(cpu_HI
[acc
], t0
, t1
);
3491 TCGv t2
= tcg_const_tl(0);
3492 TCGv t3
= tcg_const_tl(1);
3493 tcg_gen_movcond_tl(TCG_COND_EQ
, t1
, t1
, t2
, t3
, t1
);
3494 tcg_gen_divu_i64(cpu_LO
[acc
], t0
, t1
);
3495 tcg_gen_remu_i64(cpu_HI
[acc
], t0
, t1
);
3501 tcg_gen_muls2_i64(cpu_LO
[acc
], cpu_HI
[acc
], t0
, t1
);
3504 tcg_gen_mulu2_i64(cpu_LO
[acc
], cpu_HI
[acc
], t0
, t1
);
3509 TCGv_i64 t2
= tcg_temp_new_i64();
3510 TCGv_i64 t3
= tcg_temp_new_i64();
3512 tcg_gen_ext_tl_i64(t2
, t0
);
3513 tcg_gen_ext_tl_i64(t3
, t1
);
3514 tcg_gen_mul_i64(t2
, t2
, t3
);
3515 tcg_gen_concat_tl_i64(t3
, cpu_LO
[acc
], cpu_HI
[acc
]);
3516 tcg_gen_add_i64(t2
, t2
, t3
);
3517 tcg_temp_free_i64(t3
);
3518 gen_move_low32(cpu_LO
[acc
], t2
);
3519 gen_move_high32(cpu_HI
[acc
], t2
);
3520 tcg_temp_free_i64(t2
);
3525 TCGv_i64 t2
= tcg_temp_new_i64();
3526 TCGv_i64 t3
= tcg_temp_new_i64();
3528 tcg_gen_ext32u_tl(t0
, t0
);
3529 tcg_gen_ext32u_tl(t1
, t1
);
3530 tcg_gen_extu_tl_i64(t2
, t0
);
3531 tcg_gen_extu_tl_i64(t3
, t1
);
3532 tcg_gen_mul_i64(t2
, t2
, t3
);
3533 tcg_gen_concat_tl_i64(t3
, cpu_LO
[acc
], cpu_HI
[acc
]);
3534 tcg_gen_add_i64(t2
, t2
, t3
);
3535 tcg_temp_free_i64(t3
);
3536 gen_move_low32(cpu_LO
[acc
], t2
);
3537 gen_move_high32(cpu_HI
[acc
], t2
);
3538 tcg_temp_free_i64(t2
);
3543 TCGv_i64 t2
= tcg_temp_new_i64();
3544 TCGv_i64 t3
= tcg_temp_new_i64();
3546 tcg_gen_ext_tl_i64(t2
, t0
);
3547 tcg_gen_ext_tl_i64(t3
, t1
);
3548 tcg_gen_mul_i64(t2
, t2
, t3
);
3549 tcg_gen_concat_tl_i64(t3
, cpu_LO
[acc
], cpu_HI
[acc
]);
3550 tcg_gen_sub_i64(t2
, t3
, t2
);
3551 tcg_temp_free_i64(t3
);
3552 gen_move_low32(cpu_LO
[acc
], t2
);
3553 gen_move_high32(cpu_HI
[acc
], t2
);
3554 tcg_temp_free_i64(t2
);
3559 TCGv_i64 t2
= tcg_temp_new_i64();
3560 TCGv_i64 t3
= tcg_temp_new_i64();
3562 tcg_gen_ext32u_tl(t0
, t0
);
3563 tcg_gen_ext32u_tl(t1
, t1
);
3564 tcg_gen_extu_tl_i64(t2
, t0
);
3565 tcg_gen_extu_tl_i64(t3
, t1
);
3566 tcg_gen_mul_i64(t2
, t2
, t3
);
3567 tcg_gen_concat_tl_i64(t3
, cpu_LO
[acc
], cpu_HI
[acc
]);
3568 tcg_gen_sub_i64(t2
, t3
, t2
);
3569 tcg_temp_free_i64(t3
);
3570 gen_move_low32(cpu_LO
[acc
], t2
);
3571 gen_move_high32(cpu_HI
[acc
], t2
);
3572 tcg_temp_free_i64(t2
);
3576 MIPS_INVAL("mul/div");
3577 gen_reserved_instruction(ctx
);
3586 * These MULT[U] and MADD[U] instructions implemented in for example
3587 * the Toshiba/Sony R5900 and the Toshiba TX19, TX39 and TX79 core
3588 * architectures are special three-operand variants with the syntax
3590 * MULT[U][1] rd, rs, rt
3594 * (rd, LO, HI) <- rs * rt
3598 * MADD[U][1] rd, rs, rt
3602 * (rd, LO, HI) <- (LO, HI) + rs * rt
3604 * where the low-order 32-bits of the result is placed into both the
3605 * GPR rd and the special register LO. The high-order 32-bits of the
3606 * result is placed into the special register HI.
3608 * If the GPR rd is omitted in assembly language, it is taken to be 0,
3609 * which is the zero register that always reads as 0.
3611 static void gen_mul_txx9(DisasContext
*ctx
, uint32_t opc
,
3612 int rd
, int rs
, int rt
)
3614 TCGv t0
= tcg_temp_new();
3615 TCGv t1
= tcg_temp_new();
3618 gen_load_gpr(t0
, rs
);
3619 gen_load_gpr(t1
, rt
);
3627 TCGv_i32 t2
= tcg_temp_new_i32();
3628 TCGv_i32 t3
= tcg_temp_new_i32();
3629 tcg_gen_trunc_tl_i32(t2
, t0
);
3630 tcg_gen_trunc_tl_i32(t3
, t1
);
3631 tcg_gen_muls2_i32(t2
, t3
, t2
, t3
);
3633 tcg_gen_ext_i32_tl(cpu_gpr
[rd
], t2
);
3635 tcg_gen_ext_i32_tl(cpu_LO
[acc
], t2
);
3636 tcg_gen_ext_i32_tl(cpu_HI
[acc
], t3
);
3637 tcg_temp_free_i32(t2
);
3638 tcg_temp_free_i32(t3
);
3641 case MMI_OPC_MULTU1
:
3646 TCGv_i32 t2
= tcg_temp_new_i32();
3647 TCGv_i32 t3
= tcg_temp_new_i32();
3648 tcg_gen_trunc_tl_i32(t2
, t0
);
3649 tcg_gen_trunc_tl_i32(t3
, t1
);
3650 tcg_gen_mulu2_i32(t2
, t3
, t2
, t3
);
3652 tcg_gen_ext_i32_tl(cpu_gpr
[rd
], t2
);
3654 tcg_gen_ext_i32_tl(cpu_LO
[acc
], t2
);
3655 tcg_gen_ext_i32_tl(cpu_HI
[acc
], t3
);
3656 tcg_temp_free_i32(t2
);
3657 tcg_temp_free_i32(t3
);
3665 TCGv_i64 t2
= tcg_temp_new_i64();
3666 TCGv_i64 t3
= tcg_temp_new_i64();
3668 tcg_gen_ext_tl_i64(t2
, t0
);
3669 tcg_gen_ext_tl_i64(t3
, t1
);
3670 tcg_gen_mul_i64(t2
, t2
, t3
);
3671 tcg_gen_concat_tl_i64(t3
, cpu_LO
[acc
], cpu_HI
[acc
]);
3672 tcg_gen_add_i64(t2
, t2
, t3
);
3673 tcg_temp_free_i64(t3
);
3674 gen_move_low32(cpu_LO
[acc
], t2
);
3675 gen_move_high32(cpu_HI
[acc
], t2
);
3677 gen_move_low32(cpu_gpr
[rd
], t2
);
3679 tcg_temp_free_i64(t2
);
3682 case MMI_OPC_MADDU1
:
3687 TCGv_i64 t2
= tcg_temp_new_i64();
3688 TCGv_i64 t3
= tcg_temp_new_i64();
3690 tcg_gen_ext32u_tl(t0
, t0
);
3691 tcg_gen_ext32u_tl(t1
, t1
);
3692 tcg_gen_extu_tl_i64(t2
, t0
);
3693 tcg_gen_extu_tl_i64(t3
, t1
);
3694 tcg_gen_mul_i64(t2
, t2
, t3
);
3695 tcg_gen_concat_tl_i64(t3
, cpu_LO
[acc
], cpu_HI
[acc
]);
3696 tcg_gen_add_i64(t2
, t2
, t3
);
3697 tcg_temp_free_i64(t3
);
3698 gen_move_low32(cpu_LO
[acc
], t2
);
3699 gen_move_high32(cpu_HI
[acc
], t2
);
3701 gen_move_low32(cpu_gpr
[rd
], t2
);
3703 tcg_temp_free_i64(t2
);
3707 MIPS_INVAL("mul/madd TXx9");
3708 gen_reserved_instruction(ctx
);
3717 static void gen_cl(DisasContext
*ctx
, uint32_t opc
,
3727 gen_load_gpr(t0
, rs
);
3732 #if defined(TARGET_MIPS64)
3736 tcg_gen_not_tl(t0
, t0
);
3745 tcg_gen_ext32u_tl(t0
, t0
);
3746 tcg_gen_clzi_tl(t0
, t0
, TARGET_LONG_BITS
);
3747 tcg_gen_subi_tl(t0
, t0
, TARGET_LONG_BITS
- 32);
3749 #if defined(TARGET_MIPS64)
3754 tcg_gen_clzi_i64(t0
, t0
, 64);
3760 /* Godson integer instructions */
3761 static void gen_loongson_integer(DisasContext
*ctx
, uint32_t opc
,
3762 int rd
, int rs
, int rt
)
3774 case OPC_MULTU_G_2E
:
3775 case OPC_MULTU_G_2F
:
3776 #if defined(TARGET_MIPS64)
3777 case OPC_DMULT_G_2E
:
3778 case OPC_DMULT_G_2F
:
3779 case OPC_DMULTU_G_2E
:
3780 case OPC_DMULTU_G_2F
:
3782 t0
= tcg_temp_new();
3783 t1
= tcg_temp_new();
3786 t0
= tcg_temp_local_new();
3787 t1
= tcg_temp_local_new();
3791 gen_load_gpr(t0
, rs
);
3792 gen_load_gpr(t1
, rt
);
3797 tcg_gen_mul_tl(cpu_gpr
[rd
], t0
, t1
);
3798 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3800 case OPC_MULTU_G_2E
:
3801 case OPC_MULTU_G_2F
:
3802 tcg_gen_ext32u_tl(t0
, t0
);
3803 tcg_gen_ext32u_tl(t1
, t1
);
3804 tcg_gen_mul_tl(cpu_gpr
[rd
], t0
, t1
);
3805 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3810 TCGLabel
*l1
= gen_new_label();
3811 TCGLabel
*l2
= gen_new_label();
3812 TCGLabel
*l3
= gen_new_label();
3813 tcg_gen_ext32s_tl(t0
, t0
);
3814 tcg_gen_ext32s_tl(t1
, t1
);
3815 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, 0, l1
);
3816 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
3819 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, INT_MIN
, l2
);
3820 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, -1, l2
);
3821 tcg_gen_mov_tl(cpu_gpr
[rd
], t0
);
3824 tcg_gen_div_tl(cpu_gpr
[rd
], t0
, t1
);
3825 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3832 TCGLabel
*l1
= gen_new_label();
3833 TCGLabel
*l2
= gen_new_label();
3834 tcg_gen_ext32u_tl(t0
, t0
);
3835 tcg_gen_ext32u_tl(t1
, t1
);
3836 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, 0, l1
);
3837 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
3840 tcg_gen_divu_tl(cpu_gpr
[rd
], t0
, t1
);
3841 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3848 TCGLabel
*l1
= gen_new_label();
3849 TCGLabel
*l2
= gen_new_label();
3850 TCGLabel
*l3
= gen_new_label();
3851 tcg_gen_ext32u_tl(t0
, t0
);
3852 tcg_gen_ext32u_tl(t1
, t1
);
3853 tcg_gen_brcondi_tl(TCG_COND_EQ
, t1
, 0, l1
);
3854 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, INT_MIN
, l2
);
3855 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, -1, l2
);
3857 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
3860 tcg_gen_rem_tl(cpu_gpr
[rd
], t0
, t1
);
3861 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3868 TCGLabel
*l1
= gen_new_label();
3869 TCGLabel
*l2
= gen_new_label();
3870 tcg_gen_ext32u_tl(t0
, t0
);
3871 tcg_gen_ext32u_tl(t1
, t1
);
3872 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, 0, l1
);
3873 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
3876 tcg_gen_remu_tl(cpu_gpr
[rd
], t0
, t1
);
3877 tcg_gen_ext32s_tl(cpu_gpr
[rd
], cpu_gpr
[rd
]);
3881 #if defined(TARGET_MIPS64)
3882 case OPC_DMULT_G_2E
:
3883 case OPC_DMULT_G_2F
:
3884 tcg_gen_mul_tl(cpu_gpr
[rd
], t0
, t1
);
3886 case OPC_DMULTU_G_2E
:
3887 case OPC_DMULTU_G_2F
:
3888 tcg_gen_mul_tl(cpu_gpr
[rd
], t0
, t1
);
3893 TCGLabel
*l1
= gen_new_label();
3894 TCGLabel
*l2
= gen_new_label();
3895 TCGLabel
*l3
= gen_new_label();
3896 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, 0, l1
);
3897 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
3900 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, -1LL << 63, l2
);
3901 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, -1LL, l2
);
3902 tcg_gen_mov_tl(cpu_gpr
[rd
], t0
);
3905 tcg_gen_div_tl(cpu_gpr
[rd
], t0
, t1
);
3909 case OPC_DDIVU_G_2E
:
3910 case OPC_DDIVU_G_2F
:
3912 TCGLabel
*l1
= gen_new_label();
3913 TCGLabel
*l2
= gen_new_label();
3914 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, 0, l1
);
3915 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
3918 tcg_gen_divu_tl(cpu_gpr
[rd
], t0
, t1
);
3925 TCGLabel
*l1
= gen_new_label();
3926 TCGLabel
*l2
= gen_new_label();
3927 TCGLabel
*l3
= gen_new_label();
3928 tcg_gen_brcondi_tl(TCG_COND_EQ
, t1
, 0, l1
);
3929 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, -1LL << 63, l2
);
3930 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, -1LL, l2
);
3932 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
3935 tcg_gen_rem_tl(cpu_gpr
[rd
], t0
, t1
);
3939 case OPC_DMODU_G_2E
:
3940 case OPC_DMODU_G_2F
:
3942 TCGLabel
*l1
= gen_new_label();
3943 TCGLabel
*l2
= gen_new_label();
3944 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, 0, l1
);
3945 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
3948 tcg_gen_remu_tl(cpu_gpr
[rd
], t0
, t1
);
3959 /* Loongson multimedia instructions */
3960 static void gen_loongson_multimedia(DisasContext
*ctx
, int rd
, int rs
, int rt
)
3962 uint32_t opc
, shift_max
;
3966 opc
= MASK_LMMI(ctx
->opcode
);
3972 t0
= tcg_temp_local_new_i64();
3973 t1
= tcg_temp_local_new_i64();
3976 t0
= tcg_temp_new_i64();
3977 t1
= tcg_temp_new_i64();
3981 check_cp1_enabled(ctx
);
3982 gen_load_fpr64(ctx
, t0
, rs
);
3983 gen_load_fpr64(ctx
, t1
, rt
);
3987 gen_helper_paddsh(t0
, t0
, t1
);
3990 gen_helper_paddush(t0
, t0
, t1
);
3993 gen_helper_paddh(t0
, t0
, t1
);
3996 gen_helper_paddw(t0
, t0
, t1
);
3999 gen_helper_paddsb(t0
, t0
, t1
);
4002 gen_helper_paddusb(t0
, t0
, t1
);
4005 gen_helper_paddb(t0
, t0
, t1
);
4009 gen_helper_psubsh(t0
, t0
, t1
);
4012 gen_helper_psubush(t0
, t0
, t1
);
4015 gen_helper_psubh(t0
, t0
, t1
);
4018 gen_helper_psubw(t0
, t0
, t1
);
4021 gen_helper_psubsb(t0
, t0
, t1
);
4024 gen_helper_psubusb(t0
, t0
, t1
);
4027 gen_helper_psubb(t0
, t0
, t1
);
4031 gen_helper_pshufh(t0
, t0
, t1
);
4034 gen_helper_packsswh(t0
, t0
, t1
);
4037 gen_helper_packsshb(t0
, t0
, t1
);
4040 gen_helper_packushb(t0
, t0
, t1
);
4044 gen_helper_punpcklhw(t0
, t0
, t1
);
4047 gen_helper_punpckhhw(t0
, t0
, t1
);
4050 gen_helper_punpcklbh(t0
, t0
, t1
);
4053 gen_helper_punpckhbh(t0
, t0
, t1
);
4056 gen_helper_punpcklwd(t0
, t0
, t1
);
4059 gen_helper_punpckhwd(t0
, t0
, t1
);
4063 gen_helper_pavgh(t0
, t0
, t1
);
4066 gen_helper_pavgb(t0
, t0
, t1
);
4069 gen_helper_pmaxsh(t0
, t0
, t1
);
4072 gen_helper_pminsh(t0
, t0
, t1
);
4075 gen_helper_pmaxub(t0
, t0
, t1
);
4078 gen_helper_pminub(t0
, t0
, t1
);
4082 gen_helper_pcmpeqw(t0
, t0
, t1
);
4085 gen_helper_pcmpgtw(t0
, t0
, t1
);
4088 gen_helper_pcmpeqh(t0
, t0
, t1
);
4091 gen_helper_pcmpgth(t0
, t0
, t1
);
4094 gen_helper_pcmpeqb(t0
, t0
, t1
);
4097 gen_helper_pcmpgtb(t0
, t0
, t1
);
4101 gen_helper_psllw(t0
, t0
, t1
);
4104 gen_helper_psllh(t0
, t0
, t1
);
4107 gen_helper_psrlw(t0
, t0
, t1
);
4110 gen_helper_psrlh(t0
, t0
, t1
);
4113 gen_helper_psraw(t0
, t0
, t1
);
4116 gen_helper_psrah(t0
, t0
, t1
);
4120 gen_helper_pmullh(t0
, t0
, t1
);
4123 gen_helper_pmulhh(t0
, t0
, t1
);
4126 gen_helper_pmulhuh(t0
, t0
, t1
);
4129 gen_helper_pmaddhw(t0
, t0
, t1
);
4133 gen_helper_pasubub(t0
, t0
, t1
);
4136 gen_helper_biadd(t0
, t0
);
4139 gen_helper_pmovmskb(t0
, t0
);
4143 tcg_gen_add_i64(t0
, t0
, t1
);
4146 tcg_gen_sub_i64(t0
, t0
, t1
);
4149 tcg_gen_xor_i64(t0
, t0
, t1
);
4152 tcg_gen_nor_i64(t0
, t0
, t1
);
4155 tcg_gen_and_i64(t0
, t0
, t1
);
4158 tcg_gen_or_i64(t0
, t0
, t1
);
4162 tcg_gen_andc_i64(t0
, t1
, t0
);
4166 tcg_gen_deposit_i64(t0
, t0
, t1
, 0, 16);
4169 tcg_gen_deposit_i64(t0
, t0
, t1
, 16, 16);
4172 tcg_gen_deposit_i64(t0
, t0
, t1
, 32, 16);
4175 tcg_gen_deposit_i64(t0
, t0
, t1
, 48, 16);
4179 tcg_gen_andi_i64(t1
, t1
, 3);
4180 tcg_gen_shli_i64(t1
, t1
, 4);
4181 tcg_gen_shr_i64(t0
, t0
, t1
);
4182 tcg_gen_ext16u_i64(t0
, t0
);
4186 tcg_gen_add_i64(t0
, t0
, t1
);
4187 tcg_gen_ext32s_i64(t0
, t0
);
4190 tcg_gen_sub_i64(t0
, t0
, t1
);
4191 tcg_gen_ext32s_i64(t0
, t0
);
4213 /* Make sure shift count isn't TCG undefined behaviour. */
4214 tcg_gen_andi_i64(t1
, t1
, shift_max
- 1);
4219 tcg_gen_shl_i64(t0
, t0
, t1
);
4224 * Since SRA is UndefinedResult without sign-extended inputs,
4225 * we can treat SRA and DSRA the same.
4227 tcg_gen_sar_i64(t0
, t0
, t1
);
4230 /* We want to shift in zeros for SRL; zero-extend first. */
4231 tcg_gen_ext32u_i64(t0
, t0
);
4234 tcg_gen_shr_i64(t0
, t0
, t1
);
4238 if (shift_max
== 32) {
4239 tcg_gen_ext32s_i64(t0
, t0
);
4242 /* Shifts larger than MAX produce zero. */
4243 tcg_gen_setcondi_i64(TCG_COND_LTU
, t1
, t1
, shift_max
);
4244 tcg_gen_neg_i64(t1
, t1
);
4245 tcg_gen_and_i64(t0
, t0
, t1
);
4251 TCGv_i64 t2
= tcg_temp_new_i64();
4252 TCGLabel
*lab
= gen_new_label();
4254 tcg_gen_mov_i64(t2
, t0
);
4255 tcg_gen_add_i64(t0
, t1
, t2
);
4256 if (opc
== OPC_ADD_CP2
) {
4257 tcg_gen_ext32s_i64(t0
, t0
);
4259 tcg_gen_xor_i64(t1
, t1
, t2
);
4260 tcg_gen_xor_i64(t2
, t2
, t0
);
4261 tcg_gen_andc_i64(t1
, t2
, t1
);
4262 tcg_temp_free_i64(t2
);
4263 tcg_gen_brcondi_i64(TCG_COND_GE
, t1
, 0, lab
);
4264 generate_exception(ctx
, EXCP_OVERFLOW
);
4272 TCGv_i64 t2
= tcg_temp_new_i64();
4273 TCGLabel
*lab
= gen_new_label();
4275 tcg_gen_mov_i64(t2
, t0
);
4276 tcg_gen_sub_i64(t0
, t1
, t2
);
4277 if (opc
== OPC_SUB_CP2
) {
4278 tcg_gen_ext32s_i64(t0
, t0
);
4280 tcg_gen_xor_i64(t1
, t1
, t2
);
4281 tcg_gen_xor_i64(t2
, t2
, t0
);
4282 tcg_gen_and_i64(t1
, t1
, t2
);
4283 tcg_temp_free_i64(t2
);
4284 tcg_gen_brcondi_i64(TCG_COND_GE
, t1
, 0, lab
);
4285 generate_exception(ctx
, EXCP_OVERFLOW
);
4291 tcg_gen_ext32u_i64(t0
, t0
);
4292 tcg_gen_ext32u_i64(t1
, t1
);
4293 tcg_gen_mul_i64(t0
, t0
, t1
);
4302 cond
= TCG_COND_LTU
;
4310 cond
= TCG_COND_LEU
;
4317 int cc
= (ctx
->opcode
>> 8) & 0x7;
4318 TCGv_i64 t64
= tcg_temp_new_i64();
4319 TCGv_i32 t32
= tcg_temp_new_i32();
4321 tcg_gen_setcond_i64(cond
, t64
, t0
, t1
);
4322 tcg_gen_extrl_i64_i32(t32
, t64
);
4323 tcg_gen_deposit_i32(fpu_fcr31
, fpu_fcr31
, t32
,
4326 tcg_temp_free_i32(t32
);
4327 tcg_temp_free_i64(t64
);
4332 MIPS_INVAL("loongson_cp2");
4333 gen_reserved_instruction(ctx
);
4337 gen_store_fpr64(ctx
, t0
, rd
);
4340 tcg_temp_free_i64(t0
);
4341 tcg_temp_free_i64(t1
);
4344 static void gen_loongson_lswc2(DisasContext
*ctx
, int rt
,
4349 #if defined(TARGET_MIPS64)
4350 int lsq_rt1
= ctx
->opcode
& 0x1f;
4351 int lsq_offset
= sextract32(ctx
->opcode
, 6, 9) << 4;
4353 int shf_offset
= sextract32(ctx
->opcode
, 6, 8);
4355 t0
= tcg_temp_new();
4357 switch (MASK_LOONGSON_GSLSQ(ctx
->opcode
)) {
4358 #if defined(TARGET_MIPS64)
4360 t1
= tcg_temp_new();
4361 gen_base_offset_addr(ctx
, t0
, rs
, lsq_offset
);
4362 tcg_gen_qemu_ld_tl(t1
, t0
, ctx
->mem_idx
, MO_TEQ
|
4363 ctx
->default_tcg_memop_mask
);
4364 gen_base_offset_addr(ctx
, t0
, rs
, lsq_offset
+ 8);
4365 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TEQ
|
4366 ctx
->default_tcg_memop_mask
);
4367 gen_store_gpr(t1
, rt
);
4368 gen_store_gpr(t0
, lsq_rt1
);
4372 check_cp1_enabled(ctx
);
4373 t1
= tcg_temp_new();
4374 gen_base_offset_addr(ctx
, t0
, rs
, lsq_offset
);
4375 tcg_gen_qemu_ld_tl(t1
, t0
, ctx
->mem_idx
, MO_TEQ
|
4376 ctx
->default_tcg_memop_mask
);
4377 gen_base_offset_addr(ctx
, t0
, rs
, lsq_offset
+ 8);
4378 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TEQ
|
4379 ctx
->default_tcg_memop_mask
);
4380 gen_store_fpr64(ctx
, t1
, rt
);
4381 gen_store_fpr64(ctx
, t0
, lsq_rt1
);
4385 t1
= tcg_temp_new();
4386 gen_base_offset_addr(ctx
, t0
, rs
, lsq_offset
);
4387 gen_load_gpr(t1
, rt
);
4388 tcg_gen_qemu_st_tl(t1
, t0
, ctx
->mem_idx
, MO_TEQ
|
4389 ctx
->default_tcg_memop_mask
);
4390 gen_base_offset_addr(ctx
, t0
, rs
, lsq_offset
+ 8);
4391 gen_load_gpr(t1
, lsq_rt1
);
4392 tcg_gen_qemu_st_tl(t1
, t0
, ctx
->mem_idx
, MO_TEQ
|
4393 ctx
->default_tcg_memop_mask
);
4397 check_cp1_enabled(ctx
);
4398 t1
= tcg_temp_new();
4399 gen_base_offset_addr(ctx
, t0
, rs
, lsq_offset
);
4400 gen_load_fpr64(ctx
, t1
, rt
);
4401 tcg_gen_qemu_st_tl(t1
, t0
, ctx
->mem_idx
, MO_TEQ
|
4402 ctx
->default_tcg_memop_mask
);
4403 gen_base_offset_addr(ctx
, t0
, rs
, lsq_offset
+ 8);
4404 gen_load_fpr64(ctx
, t1
, lsq_rt1
);
4405 tcg_gen_qemu_st_tl(t1
, t0
, ctx
->mem_idx
, MO_TEQ
|
4406 ctx
->default_tcg_memop_mask
);
4411 switch (MASK_LOONGSON_GSSHFLS(ctx
->opcode
)) {
4413 check_cp1_enabled(ctx
);
4414 gen_base_offset_addr(ctx
, t0
, rs
, shf_offset
);
4415 t1
= tcg_temp_new();
4416 tcg_gen_qemu_ld_tl(t1
, t0
, ctx
->mem_idx
, MO_UB
);
4417 tcg_gen_andi_tl(t1
, t0
, 3);
4418 #ifndef TARGET_WORDS_BIGENDIAN
4419 tcg_gen_xori_tl(t1
, t1
, 3);
4421 tcg_gen_shli_tl(t1
, t1
, 3);
4422 tcg_gen_andi_tl(t0
, t0
, ~3);
4423 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TEUL
);
4424 tcg_gen_shl_tl(t0
, t0
, t1
);
4425 t2
= tcg_const_tl(-1);
4426 tcg_gen_shl_tl(t2
, t2
, t1
);
4427 fp0
= tcg_temp_new_i32();
4428 gen_load_fpr32(ctx
, fp0
, rt
);
4429 tcg_gen_ext_i32_tl(t1
, fp0
);
4430 tcg_gen_andc_tl(t1
, t1
, t2
);
4432 tcg_gen_or_tl(t0
, t0
, t1
);
4434 #if defined(TARGET_MIPS64)
4435 tcg_gen_extrl_i64_i32(fp0
, t0
);
4437 tcg_gen_ext32s_tl(fp0
, t0
);
4439 gen_store_fpr32(ctx
, fp0
, rt
);
4440 tcg_temp_free_i32(fp0
);
4443 check_cp1_enabled(ctx
);
4444 gen_base_offset_addr(ctx
, t0
, rs
, shf_offset
);
4445 t1
= tcg_temp_new();
4446 tcg_gen_qemu_ld_tl(t1
, t0
, ctx
->mem_idx
, MO_UB
);
4447 tcg_gen_andi_tl(t1
, t0
, 3);
4448 #ifdef TARGET_WORDS_BIGENDIAN
4449 tcg_gen_xori_tl(t1
, t1
, 3);
4451 tcg_gen_shli_tl(t1
, t1
, 3);
4452 tcg_gen_andi_tl(t0
, t0
, ~3);
4453 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TEUL
);
4454 tcg_gen_shr_tl(t0
, t0
, t1
);
4455 tcg_gen_xori_tl(t1
, t1
, 31);
4456 t2
= tcg_const_tl(0xfffffffeull
);
4457 tcg_gen_shl_tl(t2
, t2
, t1
);
4458 fp0
= tcg_temp_new_i32();
4459 gen_load_fpr32(ctx
, fp0
, rt
);
4460 tcg_gen_ext_i32_tl(t1
, fp0
);
4461 tcg_gen_and_tl(t1
, t1
, t2
);
4463 tcg_gen_or_tl(t0
, t0
, t1
);
4465 #if defined(TARGET_MIPS64)
4466 tcg_gen_extrl_i64_i32(fp0
, t0
);
4468 tcg_gen_ext32s_tl(fp0
, t0
);
4470 gen_store_fpr32(ctx
, fp0
, rt
);
4471 tcg_temp_free_i32(fp0
);
4473 #if defined(TARGET_MIPS64)
4475 check_cp1_enabled(ctx
);
4476 gen_base_offset_addr(ctx
, t0
, rs
, shf_offset
);
4477 t1
= tcg_temp_new();
4478 tcg_gen_qemu_ld_tl(t1
, t0
, ctx
->mem_idx
, MO_UB
);
4479 tcg_gen_andi_tl(t1
, t0
, 7);
4480 #ifndef TARGET_WORDS_BIGENDIAN
4481 tcg_gen_xori_tl(t1
, t1
, 7);
4483 tcg_gen_shli_tl(t1
, t1
, 3);
4484 tcg_gen_andi_tl(t0
, t0
, ~7);
4485 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TEQ
);
4486 tcg_gen_shl_tl(t0
, t0
, t1
);
4487 t2
= tcg_const_tl(-1);
4488 tcg_gen_shl_tl(t2
, t2
, t1
);
4489 gen_load_fpr64(ctx
, t1
, rt
);
4490 tcg_gen_andc_tl(t1
, t1
, t2
);
4492 tcg_gen_or_tl(t0
, t0
, t1
);
4494 gen_store_fpr64(ctx
, t0
, rt
);
4497 check_cp1_enabled(ctx
);
4498 gen_base_offset_addr(ctx
, t0
, rs
, shf_offset
);
4499 t1
= tcg_temp_new();
4500 tcg_gen_qemu_ld_tl(t1
, t0
, ctx
->mem_idx
, MO_UB
);
4501 tcg_gen_andi_tl(t1
, t0
, 7);
4502 #ifdef TARGET_WORDS_BIGENDIAN
4503 tcg_gen_xori_tl(t1
, t1
, 7);
4505 tcg_gen_shli_tl(t1
, t1
, 3);
4506 tcg_gen_andi_tl(t0
, t0
, ~7);
4507 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TEQ
);
4508 tcg_gen_shr_tl(t0
, t0
, t1
);
4509 tcg_gen_xori_tl(t1
, t1
, 63);
4510 t2
= tcg_const_tl(0xfffffffffffffffeull
);
4511 tcg_gen_shl_tl(t2
, t2
, t1
);
4512 gen_load_fpr64(ctx
, t1
, rt
);
4513 tcg_gen_and_tl(t1
, t1
, t2
);
4515 tcg_gen_or_tl(t0
, t0
, t1
);
4517 gen_store_fpr64(ctx
, t0
, rt
);
4521 MIPS_INVAL("loongson_gsshfl");
4522 gen_reserved_instruction(ctx
);
4527 switch (MASK_LOONGSON_GSSHFLS(ctx
->opcode
)) {
4529 check_cp1_enabled(ctx
);
4530 t1
= tcg_temp_new();
4531 gen_base_offset_addr(ctx
, t0
, rs
, shf_offset
);
4532 fp0
= tcg_temp_new_i32();
4533 gen_load_fpr32(ctx
, fp0
, rt
);
4534 tcg_gen_ext_i32_tl(t1
, fp0
);
4535 gen_helper_0e2i(swl
, t1
, t0
, ctx
->mem_idx
);
4536 tcg_temp_free_i32(fp0
);
4540 check_cp1_enabled(ctx
);
4541 t1
= tcg_temp_new();
4542 gen_base_offset_addr(ctx
, t0
, rs
, shf_offset
);
4543 fp0
= tcg_temp_new_i32();
4544 gen_load_fpr32(ctx
, fp0
, rt
);
4545 tcg_gen_ext_i32_tl(t1
, fp0
);
4546 gen_helper_0e2i(swr
, t1
, t0
, ctx
->mem_idx
);
4547 tcg_temp_free_i32(fp0
);
4550 #if defined(TARGET_MIPS64)
4552 check_cp1_enabled(ctx
);
4553 t1
= tcg_temp_new();
4554 gen_base_offset_addr(ctx
, t0
, rs
, shf_offset
);
4555 gen_load_fpr64(ctx
, t1
, rt
);
4556 gen_helper_0e2i(sdl
, t1
, t0
, ctx
->mem_idx
);
4560 check_cp1_enabled(ctx
);
4561 t1
= tcg_temp_new();
4562 gen_base_offset_addr(ctx
, t0
, rs
, shf_offset
);
4563 gen_load_fpr64(ctx
, t1
, rt
);
4564 gen_helper_0e2i(sdr
, t1
, t0
, ctx
->mem_idx
);
4569 MIPS_INVAL("loongson_gsshfs");
4570 gen_reserved_instruction(ctx
);
4575 MIPS_INVAL("loongson_gslsq");
4576 gen_reserved_instruction(ctx
);
4582 /* Loongson EXT LDC2/SDC2 */
4583 static void gen_loongson_lsdc2(DisasContext
*ctx
, int rt
,
4586 int offset
= sextract32(ctx
->opcode
, 3, 8);
4587 uint32_t opc
= MASK_LOONGSON_LSDC2(ctx
->opcode
);
4591 /* Pre-conditions */
4597 /* prefetch, implement as NOP */
4608 #if defined(TARGET_MIPS64)
4611 check_cp1_enabled(ctx
);
4612 /* prefetch, implement as NOP */
4618 #if defined(TARGET_MIPS64)
4621 check_cp1_enabled(ctx
);
4624 MIPS_INVAL("loongson_lsdc2");
4625 gen_reserved_instruction(ctx
);
4630 t0
= tcg_temp_new();
4632 gen_base_offset_addr(ctx
, t0
, rs
, offset
);
4633 gen_op_addr_add(ctx
, t0
, cpu_gpr
[rd
], t0
);
4637 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_SB
);
4638 gen_store_gpr(t0
, rt
);
4641 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TESW
|
4642 ctx
->default_tcg_memop_mask
);
4643 gen_store_gpr(t0
, rt
);
4646 gen_base_offset_addr(ctx
, t0
, rs
, offset
);
4648 gen_op_addr_add(ctx
, t0
, cpu_gpr
[rd
], t0
);
4650 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TESL
|
4651 ctx
->default_tcg_memop_mask
);
4652 gen_store_gpr(t0
, rt
);
4654 #if defined(TARGET_MIPS64)
4656 gen_base_offset_addr(ctx
, t0
, rs
, offset
);
4658 gen_op_addr_add(ctx
, t0
, cpu_gpr
[rd
], t0
);
4660 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TEQ
|
4661 ctx
->default_tcg_memop_mask
);
4662 gen_store_gpr(t0
, rt
);
4666 gen_base_offset_addr(ctx
, t0
, rs
, offset
);
4668 gen_op_addr_add(ctx
, t0
, cpu_gpr
[rd
], t0
);
4670 fp0
= tcg_temp_new_i32();
4671 tcg_gen_qemu_ld_i32(fp0
, t0
, ctx
->mem_idx
, MO_TESL
|
4672 ctx
->default_tcg_memop_mask
);
4673 gen_store_fpr32(ctx
, fp0
, rt
);
4674 tcg_temp_free_i32(fp0
);
4676 #if defined(TARGET_MIPS64)
4678 gen_base_offset_addr(ctx
, t0
, rs
, offset
);
4680 gen_op_addr_add(ctx
, t0
, cpu_gpr
[rd
], t0
);
4682 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TEQ
|
4683 ctx
->default_tcg_memop_mask
);
4684 gen_store_fpr64(ctx
, t0
, rt
);
4688 t1
= tcg_temp_new();
4689 gen_load_gpr(t1
, rt
);
4690 tcg_gen_qemu_st_tl(t1
, t0
, ctx
->mem_idx
, MO_SB
);
4694 t1
= tcg_temp_new();
4695 gen_load_gpr(t1
, rt
);
4696 tcg_gen_qemu_st_tl(t1
, t0
, ctx
->mem_idx
, MO_TEUW
|
4697 ctx
->default_tcg_memop_mask
);
4701 t1
= tcg_temp_new();
4702 gen_load_gpr(t1
, rt
);
4703 tcg_gen_qemu_st_tl(t1
, t0
, ctx
->mem_idx
, MO_TEUL
|
4704 ctx
->default_tcg_memop_mask
);
4707 #if defined(TARGET_MIPS64)
4709 t1
= tcg_temp_new();
4710 gen_load_gpr(t1
, rt
);
4711 tcg_gen_qemu_st_tl(t1
, t0
, ctx
->mem_idx
, MO_TEQ
|
4712 ctx
->default_tcg_memop_mask
);
4717 fp0
= tcg_temp_new_i32();
4718 gen_load_fpr32(ctx
, fp0
, rt
);
4719 tcg_gen_qemu_st_i32(fp0
, t0
, ctx
->mem_idx
, MO_TEUL
|
4720 ctx
->default_tcg_memop_mask
);
4721 tcg_temp_free_i32(fp0
);
4723 #if defined(TARGET_MIPS64)
4725 t1
= tcg_temp_new();
4726 gen_load_fpr64(ctx
, t1
, rt
);
4727 tcg_gen_qemu_st_i64(t1
, t0
, ctx
->mem_idx
, MO_TEQ
|
4728 ctx
->default_tcg_memop_mask
);
4740 static void gen_trap(DisasContext
*ctx
, uint32_t opc
,
4741 int rs
, int rt
, int16_t imm
)
4744 TCGv t0
= tcg_temp_new();
4745 TCGv t1
= tcg_temp_new();
4748 /* Load needed operands */
4756 /* Compare two registers */
4758 gen_load_gpr(t0
, rs
);
4759 gen_load_gpr(t1
, rt
);
4769 /* Compare register to immediate */
4770 if (rs
!= 0 || imm
!= 0) {
4771 gen_load_gpr(t0
, rs
);
4772 tcg_gen_movi_tl(t1
, (int32_t)imm
);
4779 case OPC_TEQ
: /* rs == rs */
4780 case OPC_TEQI
: /* r0 == 0 */
4781 case OPC_TGE
: /* rs >= rs */
4782 case OPC_TGEI
: /* r0 >= 0 */
4783 case OPC_TGEU
: /* rs >= rs unsigned */
4784 case OPC_TGEIU
: /* r0 >= 0 unsigned */
4786 generate_exception_end(ctx
, EXCP_TRAP
);
4788 case OPC_TLT
: /* rs < rs */
4789 case OPC_TLTI
: /* r0 < 0 */
4790 case OPC_TLTU
: /* rs < rs unsigned */
4791 case OPC_TLTIU
: /* r0 < 0 unsigned */
4792 case OPC_TNE
: /* rs != rs */
4793 case OPC_TNEI
: /* r0 != 0 */
4794 /* Never trap: treat as NOP. */
4798 TCGLabel
*l1
= gen_new_label();
4803 tcg_gen_brcond_tl(TCG_COND_NE
, t0
, t1
, l1
);
4807 tcg_gen_brcond_tl(TCG_COND_LT
, t0
, t1
, l1
);
4811 tcg_gen_brcond_tl(TCG_COND_LTU
, t0
, t1
, l1
);
4815 tcg_gen_brcond_tl(TCG_COND_GE
, t0
, t1
, l1
);
4819 tcg_gen_brcond_tl(TCG_COND_GEU
, t0
, t1
, l1
);
4823 tcg_gen_brcond_tl(TCG_COND_EQ
, t0
, t1
, l1
);
4826 generate_exception(ctx
, EXCP_TRAP
);
4833 static void gen_goto_tb(DisasContext
*ctx
, int n
, target_ulong dest
)
4835 if (translator_use_goto_tb(&ctx
->base
, dest
)) {
4838 tcg_gen_exit_tb(ctx
->base
.tb
, n
);
4841 if (ctx
->base
.singlestep_enabled
) {
4842 save_cpu_state(ctx
, 0);
4843 gen_helper_raise_exception_debug(cpu_env
);
4845 tcg_gen_lookup_and_goto_ptr();
4850 /* Branches (before delay slot) */
4851 static void gen_compute_branch(DisasContext
*ctx
, uint32_t opc
,
4853 int rs
, int rt
, int32_t offset
,
4856 target_ulong btgt
= -1;
4858 int bcond_compute
= 0;
4859 TCGv t0
= tcg_temp_new();
4860 TCGv t1
= tcg_temp_new();
4862 if (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
4863 #ifdef MIPS_DEBUG_DISAS
4864 LOG_DISAS("Branch in delay / forbidden slot at PC 0x"
4865 TARGET_FMT_lx
"\n", ctx
->base
.pc_next
);
4867 gen_reserved_instruction(ctx
);
4871 /* Load needed operands */
4877 /* Compare two registers */
4879 gen_load_gpr(t0
, rs
);
4880 gen_load_gpr(t1
, rt
);
4883 btgt
= ctx
->base
.pc_next
+ insn_bytes
+ offset
;
4897 /* Compare to zero */
4899 gen_load_gpr(t0
, rs
);
4902 btgt
= ctx
->base
.pc_next
+ insn_bytes
+ offset
;
4905 #if defined(TARGET_MIPS64)
4907 tcg_gen_andi_tl(t0
, cpu_dspctrl
, 0x7F);
4909 tcg_gen_andi_tl(t0
, cpu_dspctrl
, 0x3F);
4912 btgt
= ctx
->base
.pc_next
+ insn_bytes
+ offset
;
4917 /* Jump to immediate */
4918 btgt
= ((ctx
->base
.pc_next
+ insn_bytes
) & (int32_t)0xF0000000) |
4923 /* Jump to register */
4924 if (offset
!= 0 && offset
!= 16) {
4926 * Hint = 0 is JR/JALR, hint 16 is JR.HB/JALR.HB, the
4927 * others are reserved.
4929 MIPS_INVAL("jump hint");
4930 gen_reserved_instruction(ctx
);
4933 gen_load_gpr(btarget
, rs
);
4936 MIPS_INVAL("branch/jump");
4937 gen_reserved_instruction(ctx
);
4940 if (bcond_compute
== 0) {
4941 /* No condition to be computed */
4943 case OPC_BEQ
: /* rx == rx */
4944 case OPC_BEQL
: /* rx == rx likely */
4945 case OPC_BGEZ
: /* 0 >= 0 */
4946 case OPC_BGEZL
: /* 0 >= 0 likely */
4947 case OPC_BLEZ
: /* 0 <= 0 */
4948 case OPC_BLEZL
: /* 0 <= 0 likely */
4950 ctx
->hflags
|= MIPS_HFLAG_B
;
4952 case OPC_BGEZAL
: /* 0 >= 0 */
4953 case OPC_BGEZALL
: /* 0 >= 0 likely */
4954 /* Always take and link */
4956 ctx
->hflags
|= MIPS_HFLAG_B
;
4958 case OPC_BNE
: /* rx != rx */
4959 case OPC_BGTZ
: /* 0 > 0 */
4960 case OPC_BLTZ
: /* 0 < 0 */
4963 case OPC_BLTZAL
: /* 0 < 0 */
4965 * Handle as an unconditional branch to get correct delay
4969 btgt
= ctx
->base
.pc_next
+ insn_bytes
+ delayslot_size
;
4970 ctx
->hflags
|= MIPS_HFLAG_B
;
4972 case OPC_BLTZALL
: /* 0 < 0 likely */
4973 tcg_gen_movi_tl(cpu_gpr
[31], ctx
->base
.pc_next
+ 8);
4974 /* Skip the instruction in the delay slot */
4975 ctx
->base
.pc_next
+= 4;
4977 case OPC_BNEL
: /* rx != rx likely */
4978 case OPC_BGTZL
: /* 0 > 0 likely */
4979 case OPC_BLTZL
: /* 0 < 0 likely */
4980 /* Skip the instruction in the delay slot */
4981 ctx
->base
.pc_next
+= 4;
4984 ctx
->hflags
|= MIPS_HFLAG_B
;
4987 ctx
->hflags
|= MIPS_HFLAG_BX
;
4991 ctx
->hflags
|= MIPS_HFLAG_B
;
4994 ctx
->hflags
|= MIPS_HFLAG_BR
;
4998 ctx
->hflags
|= MIPS_HFLAG_BR
;
5001 MIPS_INVAL("branch/jump");
5002 gen_reserved_instruction(ctx
);
5008 tcg_gen_setcond_tl(TCG_COND_EQ
, bcond
, t0
, t1
);
5011 tcg_gen_setcond_tl(TCG_COND_EQ
, bcond
, t0
, t1
);
5014 tcg_gen_setcond_tl(TCG_COND_NE
, bcond
, t0
, t1
);
5017 tcg_gen_setcond_tl(TCG_COND_NE
, bcond
, t0
, t1
);
5020 tcg_gen_setcondi_tl(TCG_COND_GE
, bcond
, t0
, 0);
5023 tcg_gen_setcondi_tl(TCG_COND_GE
, bcond
, t0
, 0);
5026 tcg_gen_setcondi_tl(TCG_COND_GE
, bcond
, t0
, 0);
5030 tcg_gen_setcondi_tl(TCG_COND_GE
, bcond
, t0
, 0);
5034 tcg_gen_setcondi_tl(TCG_COND_GT
, bcond
, t0
, 0);
5037 tcg_gen_setcondi_tl(TCG_COND_GT
, bcond
, t0
, 0);
5040 tcg_gen_setcondi_tl(TCG_COND_LE
, bcond
, t0
, 0);
5043 tcg_gen_setcondi_tl(TCG_COND_LE
, bcond
, t0
, 0);
5046 tcg_gen_setcondi_tl(TCG_COND_LT
, bcond
, t0
, 0);
5049 tcg_gen_setcondi_tl(TCG_COND_LT
, bcond
, t0
, 0);
5052 tcg_gen_setcondi_tl(TCG_COND_GE
, bcond
, t0
, 32);
5054 #if defined(TARGET_MIPS64)
5056 tcg_gen_setcondi_tl(TCG_COND_GE
, bcond
, t0
, 64);
5060 tcg_gen_setcondi_tl(TCG_COND_LT
, bcond
, t0
, 0);
5063 ctx
->hflags
|= MIPS_HFLAG_BC
;
5066 tcg_gen_setcondi_tl(TCG_COND_LT
, bcond
, t0
, 0);
5069 ctx
->hflags
|= MIPS_HFLAG_BL
;
5072 MIPS_INVAL("conditional branch/jump");
5073 gen_reserved_instruction(ctx
);
5078 ctx
->btarget
= btgt
;
5080 switch (delayslot_size
) {
5082 ctx
->hflags
|= MIPS_HFLAG_BDS16
;
5085 ctx
->hflags
|= MIPS_HFLAG_BDS32
;
5090 int post_delay
= insn_bytes
+ delayslot_size
;
5091 int lowbit
= !!(ctx
->hflags
& MIPS_HFLAG_M16
);
5093 tcg_gen_movi_tl(cpu_gpr
[blink
],
5094 ctx
->base
.pc_next
+ post_delay
+ lowbit
);
5098 if (insn_bytes
== 2) {
5099 ctx
->hflags
|= MIPS_HFLAG_B16
;
5106 /* special3 bitfield operations */
5107 static void gen_bitops(DisasContext
*ctx
, uint32_t opc
, int rt
,
5108 int rs
, int lsb
, int msb
)
5110 TCGv t0
= tcg_temp_new();
5111 TCGv t1
= tcg_temp_new();
5113 gen_load_gpr(t1
, rs
);
5116 if (lsb
+ msb
> 31) {
5120 tcg_gen_extract_tl(t0
, t1
, lsb
, msb
+ 1);
5123 * The two checks together imply that lsb == 0,
5124 * so this is a simple sign-extension.
5126 tcg_gen_ext32s_tl(t0
, t1
);
5129 #if defined(TARGET_MIPS64)
5138 if (lsb
+ msb
> 63) {
5141 tcg_gen_extract_tl(t0
, t1
, lsb
, msb
+ 1);
5148 gen_load_gpr(t0
, rt
);
5149 tcg_gen_deposit_tl(t0
, t0
, t1
, lsb
, msb
- lsb
+ 1);
5150 tcg_gen_ext32s_tl(t0
, t0
);
5152 #if defined(TARGET_MIPS64)
5163 gen_load_gpr(t0
, rt
);
5164 tcg_gen_deposit_tl(t0
, t0
, t1
, lsb
, msb
- lsb
+ 1);
5169 MIPS_INVAL("bitops");
5170 gen_reserved_instruction(ctx
);
5175 gen_store_gpr(t0
, rt
);
5180 static void gen_bshfl(DisasContext
*ctx
, uint32_t op2
, int rt
, int rd
)
5185 /* If no destination, treat it as a NOP. */
5189 t0
= tcg_temp_new();
5190 gen_load_gpr(t0
, rt
);
5194 TCGv t1
= tcg_temp_new();
5195 TCGv t2
= tcg_const_tl(0x00FF00FF);
5197 tcg_gen_shri_tl(t1
, t0
, 8);
5198 tcg_gen_and_tl(t1
, t1
, t2
);
5199 tcg_gen_and_tl(t0
, t0
, t2
);
5200 tcg_gen_shli_tl(t0
, t0
, 8);
5201 tcg_gen_or_tl(t0
, t0
, t1
);
5204 tcg_gen_ext32s_tl(cpu_gpr
[rd
], t0
);
5208 tcg_gen_ext8s_tl(cpu_gpr
[rd
], t0
);
5211 tcg_gen_ext16s_tl(cpu_gpr
[rd
], t0
);
5213 #if defined(TARGET_MIPS64)
5216 TCGv t1
= tcg_temp_new();
5217 TCGv t2
= tcg_const_tl(0x00FF00FF00FF00FFULL
);
5219 tcg_gen_shri_tl(t1
, t0
, 8);
5220 tcg_gen_and_tl(t1
, t1
, t2
);
5221 tcg_gen_and_tl(t0
, t0
, t2
);
5222 tcg_gen_shli_tl(t0
, t0
, 8);
5223 tcg_gen_or_tl(cpu_gpr
[rd
], t0
, t1
);
5230 TCGv t1
= tcg_temp_new();
5231 TCGv t2
= tcg_const_tl(0x0000FFFF0000FFFFULL
);
5233 tcg_gen_shri_tl(t1
, t0
, 16);
5234 tcg_gen_and_tl(t1
, t1
, t2
);
5235 tcg_gen_and_tl(t0
, t0
, t2
);
5236 tcg_gen_shli_tl(t0
, t0
, 16);
5237 tcg_gen_or_tl(t0
, t0
, t1
);
5238 tcg_gen_shri_tl(t1
, t0
, 32);
5239 tcg_gen_shli_tl(t0
, t0
, 32);
5240 tcg_gen_or_tl(cpu_gpr
[rd
], t0
, t1
);
5247 MIPS_INVAL("bsfhl");
5248 gen_reserved_instruction(ctx
);
5255 static void gen_align_bits(DisasContext
*ctx
, int wordsz
, int rd
, int rs
,
5263 t0
= tcg_temp_new();
5264 if (bits
== 0 || bits
== wordsz
) {
5266 gen_load_gpr(t0
, rt
);
5268 gen_load_gpr(t0
, rs
);
5272 tcg_gen_ext32s_tl(cpu_gpr
[rd
], t0
);
5274 #if defined(TARGET_MIPS64)
5276 tcg_gen_mov_tl(cpu_gpr
[rd
], t0
);
5281 TCGv t1
= tcg_temp_new();
5282 gen_load_gpr(t0
, rt
);
5283 gen_load_gpr(t1
, rs
);
5287 TCGv_i64 t2
= tcg_temp_new_i64();
5288 tcg_gen_concat_tl_i64(t2
, t1
, t0
);
5289 tcg_gen_shri_i64(t2
, t2
, 32 - bits
);
5290 gen_move_low32(cpu_gpr
[rd
], t2
);
5291 tcg_temp_free_i64(t2
);
5294 #if defined(TARGET_MIPS64)
5296 tcg_gen_shli_tl(t0
, t0
, bits
);
5297 tcg_gen_shri_tl(t1
, t1
, 64 - bits
);
5298 tcg_gen_or_tl(cpu_gpr
[rd
], t1
, t0
);
5308 void gen_align(DisasContext
*ctx
, int wordsz
, int rd
, int rs
, int rt
, int bp
)
5310 gen_align_bits(ctx
, wordsz
, rd
, rs
, rt
, bp
* 8);
5313 static void gen_bitswap(DisasContext
*ctx
, int opc
, int rd
, int rt
)
5320 t0
= tcg_temp_new();
5321 gen_load_gpr(t0
, rt
);
5324 gen_helper_bitswap(cpu_gpr
[rd
], t0
);
5326 #if defined(TARGET_MIPS64)
5328 gen_helper_dbitswap(cpu_gpr
[rd
], t0
);
5335 #ifndef CONFIG_USER_ONLY
5336 /* CP0 (MMU and control) */
5337 static inline void gen_mthc0_entrylo(TCGv arg
, target_ulong off
)
5339 TCGv_i64 t0
= tcg_temp_new_i64();
5340 TCGv_i64 t1
= tcg_temp_new_i64();
5342 tcg_gen_ext_tl_i64(t0
, arg
);
5343 tcg_gen_ld_i64(t1
, cpu_env
, off
);
5344 #if defined(TARGET_MIPS64)
5345 tcg_gen_deposit_i64(t1
, t1
, t0
, 30, 32);
5347 tcg_gen_concat32_i64(t1
, t1
, t0
);
5349 tcg_gen_st_i64(t1
, cpu_env
, off
);
5350 tcg_temp_free_i64(t1
);
5351 tcg_temp_free_i64(t0
);
5354 static inline void gen_mthc0_store64(TCGv arg
, target_ulong off
)
5356 TCGv_i64 t0
= tcg_temp_new_i64();
5357 TCGv_i64 t1
= tcg_temp_new_i64();
5359 tcg_gen_ext_tl_i64(t0
, arg
);
5360 tcg_gen_ld_i64(t1
, cpu_env
, off
);
5361 tcg_gen_concat32_i64(t1
, t1
, t0
);
5362 tcg_gen_st_i64(t1
, cpu_env
, off
);
5363 tcg_temp_free_i64(t1
);
5364 tcg_temp_free_i64(t0
);
5367 static inline void gen_mfhc0_entrylo(TCGv arg
, target_ulong off
)
5369 TCGv_i64 t0
= tcg_temp_new_i64();
5371 tcg_gen_ld_i64(t0
, cpu_env
, off
);
5372 #if defined(TARGET_MIPS64)
5373 tcg_gen_shri_i64(t0
, t0
, 30);
5375 tcg_gen_shri_i64(t0
, t0
, 32);
5377 gen_move_low32(arg
, t0
);
5378 tcg_temp_free_i64(t0
);
5381 static inline void gen_mfhc0_load64(TCGv arg
, target_ulong off
, int shift
)
5383 TCGv_i64 t0
= tcg_temp_new_i64();
5385 tcg_gen_ld_i64(t0
, cpu_env
, off
);
5386 tcg_gen_shri_i64(t0
, t0
, 32 + shift
);
5387 gen_move_low32(arg
, t0
);
5388 tcg_temp_free_i64(t0
);
5391 static inline void gen_mfc0_load32(TCGv arg
, target_ulong off
)
5393 TCGv_i32 t0
= tcg_temp_new_i32();
5395 tcg_gen_ld_i32(t0
, cpu_env
, off
);
5396 tcg_gen_ext_i32_tl(arg
, t0
);
5397 tcg_temp_free_i32(t0
);
5400 static inline void gen_mfc0_load64(TCGv arg
, target_ulong off
)
5402 tcg_gen_ld_tl(arg
, cpu_env
, off
);
5403 tcg_gen_ext32s_tl(arg
, arg
);
5406 static inline void gen_mtc0_store32(TCGv arg
, target_ulong off
)
5408 TCGv_i32 t0
= tcg_temp_new_i32();
5410 tcg_gen_trunc_tl_i32(t0
, arg
);
5411 tcg_gen_st_i32(t0
, cpu_env
, off
);
5412 tcg_temp_free_i32(t0
);
5415 #define CP0_CHECK(c) \
5418 goto cp0_unimplemented; \
5422 static void gen_mfhc0(DisasContext
*ctx
, TCGv arg
, int reg
, int sel
)
5424 const char *register_name
= "invalid";
5427 case CP0_REGISTER_02
:
5430 CP0_CHECK(ctx
->hflags
& MIPS_HFLAG_ELPA
);
5431 gen_mfhc0_entrylo(arg
, offsetof(CPUMIPSState
, CP0_EntryLo0
));
5432 register_name
= "EntryLo0";
5435 goto cp0_unimplemented
;
5438 case CP0_REGISTER_03
:
5440 case CP0_REG03__ENTRYLO1
:
5441 CP0_CHECK(ctx
->hflags
& MIPS_HFLAG_ELPA
);
5442 gen_mfhc0_entrylo(arg
, offsetof(CPUMIPSState
, CP0_EntryLo1
));
5443 register_name
= "EntryLo1";
5446 goto cp0_unimplemented
;
5449 case CP0_REGISTER_09
:
5451 case CP0_REG09__SAAR
:
5452 CP0_CHECK(ctx
->saar
);
5453 gen_helper_mfhc0_saar(arg
, cpu_env
);
5454 register_name
= "SAAR";
5457 goto cp0_unimplemented
;
5460 case CP0_REGISTER_17
:
5462 case CP0_REG17__LLADDR
:
5463 gen_mfhc0_load64(arg
, offsetof(CPUMIPSState
, CP0_LLAddr
),
5464 ctx
->CP0_LLAddr_shift
);
5465 register_name
= "LLAddr";
5467 case CP0_REG17__MAAR
:
5468 CP0_CHECK(ctx
->mrp
);
5469 gen_helper_mfhc0_maar(arg
, cpu_env
);
5470 register_name
= "MAAR";
5473 goto cp0_unimplemented
;
5476 case CP0_REGISTER_19
:
5478 case CP0_REG19__WATCHHI0
:
5479 case CP0_REG19__WATCHHI1
:
5480 case CP0_REG19__WATCHHI2
:
5481 case CP0_REG19__WATCHHI3
:
5482 case CP0_REG19__WATCHHI4
:
5483 case CP0_REG19__WATCHHI5
:
5484 case CP0_REG19__WATCHHI6
:
5485 case CP0_REG19__WATCHHI7
:
5486 /* upper 32 bits are only available when Config5MI != 0 */
5488 gen_mfhc0_load64(arg
, offsetof(CPUMIPSState
, CP0_WatchHi
[sel
]), 0);
5489 register_name
= "WatchHi";
5492 goto cp0_unimplemented
;
5495 case CP0_REGISTER_28
:
5501 gen_mfhc0_load64(arg
, offsetof(CPUMIPSState
, CP0_TagLo
), 0);
5502 register_name
= "TagLo";
5505 goto cp0_unimplemented
;
5509 goto cp0_unimplemented
;
5511 trace_mips_translate_c0("mfhc0", register_name
, reg
, sel
);
5515 qemu_log_mask(LOG_UNIMP
, "mfhc0 %s (reg %d sel %d)\n",
5516 register_name
, reg
, sel
);
5517 tcg_gen_movi_tl(arg
, 0);
5520 static void gen_mthc0(DisasContext
*ctx
, TCGv arg
, int reg
, int sel
)
5522 const char *register_name
= "invalid";
5523 uint64_t mask
= ctx
->PAMask
>> 36;
5526 case CP0_REGISTER_02
:
5529 CP0_CHECK(ctx
->hflags
& MIPS_HFLAG_ELPA
);
5530 tcg_gen_andi_tl(arg
, arg
, mask
);
5531 gen_mthc0_entrylo(arg
, offsetof(CPUMIPSState
, CP0_EntryLo0
));
5532 register_name
= "EntryLo0";
5535 goto cp0_unimplemented
;
5538 case CP0_REGISTER_03
:
5540 case CP0_REG03__ENTRYLO1
:
5541 CP0_CHECK(ctx
->hflags
& MIPS_HFLAG_ELPA
);
5542 tcg_gen_andi_tl(arg
, arg
, mask
);
5543 gen_mthc0_entrylo(arg
, offsetof(CPUMIPSState
, CP0_EntryLo1
));
5544 register_name
= "EntryLo1";
5547 goto cp0_unimplemented
;
5550 case CP0_REGISTER_09
:
5552 case CP0_REG09__SAAR
:
5553 CP0_CHECK(ctx
->saar
);
5554 gen_helper_mthc0_saar(cpu_env
, arg
);
5555 register_name
= "SAAR";
5558 goto cp0_unimplemented
;
5561 case CP0_REGISTER_17
:
5563 case CP0_REG17__LLADDR
:
5565 * LLAddr is read-only (the only exception is bit 0 if LLB is
5566 * supported); the CP0_LLAddr_rw_bitmask does not seem to be
5567 * relevant for modern MIPS cores supporting MTHC0, therefore
5568 * treating MTHC0 to LLAddr as NOP.
5570 register_name
= "LLAddr";
5572 case CP0_REG17__MAAR
:
5573 CP0_CHECK(ctx
->mrp
);
5574 gen_helper_mthc0_maar(cpu_env
, arg
);
5575 register_name
= "MAAR";
5578 goto cp0_unimplemented
;
5581 case CP0_REGISTER_19
:
5583 case CP0_REG19__WATCHHI0
:
5584 case CP0_REG19__WATCHHI1
:
5585 case CP0_REG19__WATCHHI2
:
5586 case CP0_REG19__WATCHHI3
:
5587 case CP0_REG19__WATCHHI4
:
5588 case CP0_REG19__WATCHHI5
:
5589 case CP0_REG19__WATCHHI6
:
5590 case CP0_REG19__WATCHHI7
:
5591 /* upper 32 bits are only available when Config5MI != 0 */
5593 gen_helper_0e1i(mthc0_watchhi
, arg
, sel
);
5594 register_name
= "WatchHi";
5597 goto cp0_unimplemented
;
5600 case CP0_REGISTER_28
:
5606 tcg_gen_andi_tl(arg
, arg
, mask
);
5607 gen_mthc0_store64(arg
, offsetof(CPUMIPSState
, CP0_TagLo
));
5608 register_name
= "TagLo";
5611 goto cp0_unimplemented
;
5615 goto cp0_unimplemented
;
5617 trace_mips_translate_c0("mthc0", register_name
, reg
, sel
);
5621 qemu_log_mask(LOG_UNIMP
, "mthc0 %s (reg %d sel %d)\n",
5622 register_name
, reg
, sel
);
5625 static inline void gen_mfc0_unimplemented(DisasContext
*ctx
, TCGv arg
)
5627 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
5628 tcg_gen_movi_tl(arg
, 0);
5630 tcg_gen_movi_tl(arg
, ~0);
5634 static void gen_mfc0(DisasContext
*ctx
, TCGv arg
, int reg
, int sel
)
5636 const char *register_name
= "invalid";
5639 check_insn(ctx
, ISA_MIPS_R1
);
5643 case CP0_REGISTER_00
:
5645 case CP0_REG00__INDEX
:
5646 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Index
));
5647 register_name
= "Index";
5649 case CP0_REG00__MVPCONTROL
:
5650 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5651 gen_helper_mfc0_mvpcontrol(arg
, cpu_env
);
5652 register_name
= "MVPControl";
5654 case CP0_REG00__MVPCONF0
:
5655 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5656 gen_helper_mfc0_mvpconf0(arg
, cpu_env
);
5657 register_name
= "MVPConf0";
5659 case CP0_REG00__MVPCONF1
:
5660 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5661 gen_helper_mfc0_mvpconf1(arg
, cpu_env
);
5662 register_name
= "MVPConf1";
5664 case CP0_REG00__VPCONTROL
:
5666 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPControl
));
5667 register_name
= "VPControl";
5670 goto cp0_unimplemented
;
5673 case CP0_REGISTER_01
:
5675 case CP0_REG01__RANDOM
:
5676 CP0_CHECK(!(ctx
->insn_flags
& ISA_MIPS_R6
));
5677 gen_helper_mfc0_random(arg
, cpu_env
);
5678 register_name
= "Random";
5680 case CP0_REG01__VPECONTROL
:
5681 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5682 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPEControl
));
5683 register_name
= "VPEControl";
5685 case CP0_REG01__VPECONF0
:
5686 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5687 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPEConf0
));
5688 register_name
= "VPEConf0";
5690 case CP0_REG01__VPECONF1
:
5691 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5692 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPEConf1
));
5693 register_name
= "VPEConf1";
5695 case CP0_REG01__YQMASK
:
5696 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5697 gen_mfc0_load64(arg
, offsetof(CPUMIPSState
, CP0_YQMask
));
5698 register_name
= "YQMask";
5700 case CP0_REG01__VPESCHEDULE
:
5701 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5702 gen_mfc0_load64(arg
, offsetof(CPUMIPSState
, CP0_VPESchedule
));
5703 register_name
= "VPESchedule";
5705 case CP0_REG01__VPESCHEFBACK
:
5706 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5707 gen_mfc0_load64(arg
, offsetof(CPUMIPSState
, CP0_VPEScheFBack
));
5708 register_name
= "VPEScheFBack";
5710 case CP0_REG01__VPEOPT
:
5711 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5712 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPEOpt
));
5713 register_name
= "VPEOpt";
5716 goto cp0_unimplemented
;
5719 case CP0_REGISTER_02
:
5721 case CP0_REG02__ENTRYLO0
:
5723 TCGv_i64 tmp
= tcg_temp_new_i64();
5724 tcg_gen_ld_i64(tmp
, cpu_env
,
5725 offsetof(CPUMIPSState
, CP0_EntryLo0
));
5726 #if defined(TARGET_MIPS64)
5728 /* Move RI/XI fields to bits 31:30 */
5729 tcg_gen_shri_tl(arg
, tmp
, CP0EnLo_XI
);
5730 tcg_gen_deposit_tl(tmp
, tmp
, arg
, 30, 2);
5733 gen_move_low32(arg
, tmp
);
5734 tcg_temp_free_i64(tmp
);
5736 register_name
= "EntryLo0";
5738 case CP0_REG02__TCSTATUS
:
5739 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5740 gen_helper_mfc0_tcstatus(arg
, cpu_env
);
5741 register_name
= "TCStatus";
5743 case CP0_REG02__TCBIND
:
5744 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5745 gen_helper_mfc0_tcbind(arg
, cpu_env
);
5746 register_name
= "TCBind";
5748 case CP0_REG02__TCRESTART
:
5749 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5750 gen_helper_mfc0_tcrestart(arg
, cpu_env
);
5751 register_name
= "TCRestart";
5753 case CP0_REG02__TCHALT
:
5754 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5755 gen_helper_mfc0_tchalt(arg
, cpu_env
);
5756 register_name
= "TCHalt";
5758 case CP0_REG02__TCCONTEXT
:
5759 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5760 gen_helper_mfc0_tccontext(arg
, cpu_env
);
5761 register_name
= "TCContext";
5763 case CP0_REG02__TCSCHEDULE
:
5764 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5765 gen_helper_mfc0_tcschedule(arg
, cpu_env
);
5766 register_name
= "TCSchedule";
5768 case CP0_REG02__TCSCHEFBACK
:
5769 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
5770 gen_helper_mfc0_tcschefback(arg
, cpu_env
);
5771 register_name
= "TCScheFBack";
5774 goto cp0_unimplemented
;
5777 case CP0_REGISTER_03
:
5779 case CP0_REG03__ENTRYLO1
:
5781 TCGv_i64 tmp
= tcg_temp_new_i64();
5782 tcg_gen_ld_i64(tmp
, cpu_env
,
5783 offsetof(CPUMIPSState
, CP0_EntryLo1
));
5784 #if defined(TARGET_MIPS64)
5786 /* Move RI/XI fields to bits 31:30 */
5787 tcg_gen_shri_tl(arg
, tmp
, CP0EnLo_XI
);
5788 tcg_gen_deposit_tl(tmp
, tmp
, arg
, 30, 2);
5791 gen_move_low32(arg
, tmp
);
5792 tcg_temp_free_i64(tmp
);
5794 register_name
= "EntryLo1";
5796 case CP0_REG03__GLOBALNUM
:
5798 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_GlobalNumber
));
5799 register_name
= "GlobalNumber";
5802 goto cp0_unimplemented
;
5805 case CP0_REGISTER_04
:
5807 case CP0_REG04__CONTEXT
:
5808 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_Context
));
5809 tcg_gen_ext32s_tl(arg
, arg
);
5810 register_name
= "Context";
5812 case CP0_REG04__CONTEXTCONFIG
:
5814 /* gen_helper_mfc0_contextconfig(arg); */
5815 register_name
= "ContextConfig";
5816 goto cp0_unimplemented
;
5817 case CP0_REG04__USERLOCAL
:
5818 CP0_CHECK(ctx
->ulri
);
5819 tcg_gen_ld_tl(arg
, cpu_env
,
5820 offsetof(CPUMIPSState
, active_tc
.CP0_UserLocal
));
5821 tcg_gen_ext32s_tl(arg
, arg
);
5822 register_name
= "UserLocal";
5824 case CP0_REG04__MMID
:
5826 gen_helper_mtc0_memorymapid(cpu_env
, arg
);
5827 register_name
= "MMID";
5830 goto cp0_unimplemented
;
5833 case CP0_REGISTER_05
:
5835 case CP0_REG05__PAGEMASK
:
5836 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PageMask
));
5837 register_name
= "PageMask";
5839 case CP0_REG05__PAGEGRAIN
:
5840 check_insn(ctx
, ISA_MIPS_R2
);
5841 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PageGrain
));
5842 register_name
= "PageGrain";
5844 case CP0_REG05__SEGCTL0
:
5846 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_SegCtl0
));
5847 tcg_gen_ext32s_tl(arg
, arg
);
5848 register_name
= "SegCtl0";
5850 case CP0_REG05__SEGCTL1
:
5852 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_SegCtl1
));
5853 tcg_gen_ext32s_tl(arg
, arg
);
5854 register_name
= "SegCtl1";
5856 case CP0_REG05__SEGCTL2
:
5858 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_SegCtl2
));
5859 tcg_gen_ext32s_tl(arg
, arg
);
5860 register_name
= "SegCtl2";
5862 case CP0_REG05__PWBASE
:
5864 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PWBase
));
5865 register_name
= "PWBase";
5867 case CP0_REG05__PWFIELD
:
5869 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PWField
));
5870 register_name
= "PWField";
5872 case CP0_REG05__PWSIZE
:
5874 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PWSize
));
5875 register_name
= "PWSize";
5878 goto cp0_unimplemented
;
5881 case CP0_REGISTER_06
:
5883 case CP0_REG06__WIRED
:
5884 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Wired
));
5885 register_name
= "Wired";
5887 case CP0_REG06__SRSCONF0
:
5888 check_insn(ctx
, ISA_MIPS_R2
);
5889 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf0
));
5890 register_name
= "SRSConf0";
5892 case CP0_REG06__SRSCONF1
:
5893 check_insn(ctx
, ISA_MIPS_R2
);
5894 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf1
));
5895 register_name
= "SRSConf1";
5897 case CP0_REG06__SRSCONF2
:
5898 check_insn(ctx
, ISA_MIPS_R2
);
5899 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf2
));
5900 register_name
= "SRSConf2";
5902 case CP0_REG06__SRSCONF3
:
5903 check_insn(ctx
, ISA_MIPS_R2
);
5904 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf3
));
5905 register_name
= "SRSConf3";
5907 case CP0_REG06__SRSCONF4
:
5908 check_insn(ctx
, ISA_MIPS_R2
);
5909 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf4
));
5910 register_name
= "SRSConf4";
5912 case CP0_REG06__PWCTL
:
5914 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PWCtl
));
5915 register_name
= "PWCtl";
5918 goto cp0_unimplemented
;
5921 case CP0_REGISTER_07
:
5923 case CP0_REG07__HWRENA
:
5924 check_insn(ctx
, ISA_MIPS_R2
);
5925 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_HWREna
));
5926 register_name
= "HWREna";
5929 goto cp0_unimplemented
;
5932 case CP0_REGISTER_08
:
5934 case CP0_REG08__BADVADDR
:
5935 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_BadVAddr
));
5936 tcg_gen_ext32s_tl(arg
, arg
);
5937 register_name
= "BadVAddr";
5939 case CP0_REG08__BADINSTR
:
5941 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_BadInstr
));
5942 register_name
= "BadInstr";
5944 case CP0_REG08__BADINSTRP
:
5946 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_BadInstrP
));
5947 register_name
= "BadInstrP";
5949 case CP0_REG08__BADINSTRX
:
5951 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_BadInstrX
));
5952 tcg_gen_andi_tl(arg
, arg
, ~0xffff);
5953 register_name
= "BadInstrX";
5956 goto cp0_unimplemented
;
5959 case CP0_REGISTER_09
:
5961 case CP0_REG09__COUNT
:
5962 /* Mark as an IO operation because we read the time. */
5963 if (tb_cflags(ctx
->base
.tb
) & CF_USE_ICOUNT
) {
5966 gen_helper_mfc0_count(arg
, cpu_env
);
5968 * Break the TB to be able to take timer interrupts immediately
5969 * after reading count. DISAS_STOP isn't sufficient, we need to
5970 * ensure we break completely out of translated code.
5972 gen_save_pc(ctx
->base
.pc_next
+ 4);
5973 ctx
->base
.is_jmp
= DISAS_EXIT
;
5974 register_name
= "Count";
5976 case CP0_REG09__SAARI
:
5977 CP0_CHECK(ctx
->saar
);
5978 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SAARI
));
5979 register_name
= "SAARI";
5981 case CP0_REG09__SAAR
:
5982 CP0_CHECK(ctx
->saar
);
5983 gen_helper_mfc0_saar(arg
, cpu_env
);
5984 register_name
= "SAAR";
5987 goto cp0_unimplemented
;
5990 case CP0_REGISTER_10
:
5992 case CP0_REG10__ENTRYHI
:
5993 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_EntryHi
));
5994 tcg_gen_ext32s_tl(arg
, arg
);
5995 register_name
= "EntryHi";
5998 goto cp0_unimplemented
;
6001 case CP0_REGISTER_11
:
6003 case CP0_REG11__COMPARE
:
6004 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Compare
));
6005 register_name
= "Compare";
6007 /* 6,7 are implementation dependent */
6009 goto cp0_unimplemented
;
6012 case CP0_REGISTER_12
:
6014 case CP0_REG12__STATUS
:
6015 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Status
));
6016 register_name
= "Status";
6018 case CP0_REG12__INTCTL
:
6019 check_insn(ctx
, ISA_MIPS_R2
);
6020 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_IntCtl
));
6021 register_name
= "IntCtl";
6023 case CP0_REG12__SRSCTL
:
6024 check_insn(ctx
, ISA_MIPS_R2
);
6025 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSCtl
));
6026 register_name
= "SRSCtl";
6028 case CP0_REG12__SRSMAP
:
6029 check_insn(ctx
, ISA_MIPS_R2
);
6030 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSMap
));
6031 register_name
= "SRSMap";
6034 goto cp0_unimplemented
;
6037 case CP0_REGISTER_13
:
6039 case CP0_REG13__CAUSE
:
6040 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Cause
));
6041 register_name
= "Cause";
6044 goto cp0_unimplemented
;
6047 case CP0_REGISTER_14
:
6049 case CP0_REG14__EPC
:
6050 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_EPC
));
6051 tcg_gen_ext32s_tl(arg
, arg
);
6052 register_name
= "EPC";
6055 goto cp0_unimplemented
;
6058 case CP0_REGISTER_15
:
6060 case CP0_REG15__PRID
:
6061 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PRid
));
6062 register_name
= "PRid";
6064 case CP0_REG15__EBASE
:
6065 check_insn(ctx
, ISA_MIPS_R2
);
6066 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_EBase
));
6067 tcg_gen_ext32s_tl(arg
, arg
);
6068 register_name
= "EBase";
6070 case CP0_REG15__CMGCRBASE
:
6071 check_insn(ctx
, ISA_MIPS_R2
);
6072 CP0_CHECK(ctx
->cmgcr
);
6073 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_CMGCRBase
));
6074 tcg_gen_ext32s_tl(arg
, arg
);
6075 register_name
= "CMGCRBase";
6078 goto cp0_unimplemented
;
6081 case CP0_REGISTER_16
:
6083 case CP0_REG16__CONFIG
:
6084 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config0
));
6085 register_name
= "Config";
6087 case CP0_REG16__CONFIG1
:
6088 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config1
));
6089 register_name
= "Config1";
6091 case CP0_REG16__CONFIG2
:
6092 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config2
));
6093 register_name
= "Config2";
6095 case CP0_REG16__CONFIG3
:
6096 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config3
));
6097 register_name
= "Config3";
6099 case CP0_REG16__CONFIG4
:
6100 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config4
));
6101 register_name
= "Config4";
6103 case CP0_REG16__CONFIG5
:
6104 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config5
));
6105 register_name
= "Config5";
6107 /* 6,7 are implementation dependent */
6108 case CP0_REG16__CONFIG6
:
6109 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config6
));
6110 register_name
= "Config6";
6112 case CP0_REG16__CONFIG7
:
6113 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config7
));
6114 register_name
= "Config7";
6117 goto cp0_unimplemented
;
6120 case CP0_REGISTER_17
:
6122 case CP0_REG17__LLADDR
:
6123 gen_helper_mfc0_lladdr(arg
, cpu_env
);
6124 register_name
= "LLAddr";
6126 case CP0_REG17__MAAR
:
6127 CP0_CHECK(ctx
->mrp
);
6128 gen_helper_mfc0_maar(arg
, cpu_env
);
6129 register_name
= "MAAR";
6131 case CP0_REG17__MAARI
:
6132 CP0_CHECK(ctx
->mrp
);
6133 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_MAARI
));
6134 register_name
= "MAARI";
6137 goto cp0_unimplemented
;
6140 case CP0_REGISTER_18
:
6142 case CP0_REG18__WATCHLO0
:
6143 case CP0_REG18__WATCHLO1
:
6144 case CP0_REG18__WATCHLO2
:
6145 case CP0_REG18__WATCHLO3
:
6146 case CP0_REG18__WATCHLO4
:
6147 case CP0_REG18__WATCHLO5
:
6148 case CP0_REG18__WATCHLO6
:
6149 case CP0_REG18__WATCHLO7
:
6150 CP0_CHECK(ctx
->CP0_Config1
& (1 << CP0C1_WR
));
6151 gen_helper_1e0i(mfc0_watchlo
, arg
, sel
);
6152 register_name
= "WatchLo";
6155 goto cp0_unimplemented
;
6158 case CP0_REGISTER_19
:
6160 case CP0_REG19__WATCHHI0
:
6161 case CP0_REG19__WATCHHI1
:
6162 case CP0_REG19__WATCHHI2
:
6163 case CP0_REG19__WATCHHI3
:
6164 case CP0_REG19__WATCHHI4
:
6165 case CP0_REG19__WATCHHI5
:
6166 case CP0_REG19__WATCHHI6
:
6167 case CP0_REG19__WATCHHI7
:
6168 CP0_CHECK(ctx
->CP0_Config1
& (1 << CP0C1_WR
));
6169 gen_helper_1e0i(mfc0_watchhi
, arg
, sel
);
6170 register_name
= "WatchHi";
6173 goto cp0_unimplemented
;
6176 case CP0_REGISTER_20
:
6178 case CP0_REG20__XCONTEXT
:
6179 #if defined(TARGET_MIPS64)
6180 check_insn(ctx
, ISA_MIPS3
);
6181 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_XContext
));
6182 tcg_gen_ext32s_tl(arg
, arg
);
6183 register_name
= "XContext";
6187 goto cp0_unimplemented
;
6190 case CP0_REGISTER_21
:
6191 /* Officially reserved, but sel 0 is used for R1x000 framemask */
6192 CP0_CHECK(!(ctx
->insn_flags
& ISA_MIPS_R6
));
6195 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Framemask
));
6196 register_name
= "Framemask";
6199 goto cp0_unimplemented
;
6202 case CP0_REGISTER_22
:
6203 tcg_gen_movi_tl(arg
, 0); /* unimplemented */
6204 register_name
= "'Diagnostic"; /* implementation dependent */
6206 case CP0_REGISTER_23
:
6208 case CP0_REG23__DEBUG
:
6209 gen_helper_mfc0_debug(arg
, cpu_env
); /* EJTAG support */
6210 register_name
= "Debug";
6212 case CP0_REG23__TRACECONTROL
:
6213 /* PDtrace support */
6214 /* gen_helper_mfc0_tracecontrol(arg); */
6215 register_name
= "TraceControl";
6216 goto cp0_unimplemented
;
6217 case CP0_REG23__TRACECONTROL2
:
6218 /* PDtrace support */
6219 /* gen_helper_mfc0_tracecontrol2(arg); */
6220 register_name
= "TraceControl2";
6221 goto cp0_unimplemented
;
6222 case CP0_REG23__USERTRACEDATA1
:
6223 /* PDtrace support */
6224 /* gen_helper_mfc0_usertracedata1(arg);*/
6225 register_name
= "UserTraceData1";
6226 goto cp0_unimplemented
;
6227 case CP0_REG23__TRACEIBPC
:
6228 /* PDtrace support */
6229 /* gen_helper_mfc0_traceibpc(arg); */
6230 register_name
= "TraceIBPC";
6231 goto cp0_unimplemented
;
6232 case CP0_REG23__TRACEDBPC
:
6233 /* PDtrace support */
6234 /* gen_helper_mfc0_tracedbpc(arg); */
6235 register_name
= "TraceDBPC";
6236 goto cp0_unimplemented
;
6238 goto cp0_unimplemented
;
6241 case CP0_REGISTER_24
:
6243 case CP0_REG24__DEPC
:
6245 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_DEPC
));
6246 tcg_gen_ext32s_tl(arg
, arg
);
6247 register_name
= "DEPC";
6250 goto cp0_unimplemented
;
6253 case CP0_REGISTER_25
:
6255 case CP0_REG25__PERFCTL0
:
6256 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Performance0
));
6257 register_name
= "Performance0";
6259 case CP0_REG25__PERFCNT0
:
6260 /* gen_helper_mfc0_performance1(arg); */
6261 register_name
= "Performance1";
6262 goto cp0_unimplemented
;
6263 case CP0_REG25__PERFCTL1
:
6264 /* gen_helper_mfc0_performance2(arg); */
6265 register_name
= "Performance2";
6266 goto cp0_unimplemented
;
6267 case CP0_REG25__PERFCNT1
:
6268 /* gen_helper_mfc0_performance3(arg); */
6269 register_name
= "Performance3";
6270 goto cp0_unimplemented
;
6271 case CP0_REG25__PERFCTL2
:
6272 /* gen_helper_mfc0_performance4(arg); */
6273 register_name
= "Performance4";
6274 goto cp0_unimplemented
;
6275 case CP0_REG25__PERFCNT2
:
6276 /* gen_helper_mfc0_performance5(arg); */
6277 register_name
= "Performance5";
6278 goto cp0_unimplemented
;
6279 case CP0_REG25__PERFCTL3
:
6280 /* gen_helper_mfc0_performance6(arg); */
6281 register_name
= "Performance6";
6282 goto cp0_unimplemented
;
6283 case CP0_REG25__PERFCNT3
:
6284 /* gen_helper_mfc0_performance7(arg); */
6285 register_name
= "Performance7";
6286 goto cp0_unimplemented
;
6288 goto cp0_unimplemented
;
6291 case CP0_REGISTER_26
:
6293 case CP0_REG26__ERRCTL
:
6294 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_ErrCtl
));
6295 register_name
= "ErrCtl";
6298 goto cp0_unimplemented
;
6301 case CP0_REGISTER_27
:
6303 case CP0_REG27__CACHERR
:
6304 tcg_gen_movi_tl(arg
, 0); /* unimplemented */
6305 register_name
= "CacheErr";
6308 goto cp0_unimplemented
;
6311 case CP0_REGISTER_28
:
6313 case CP0_REG28__TAGLO
:
6314 case CP0_REG28__TAGLO1
:
6315 case CP0_REG28__TAGLO2
:
6316 case CP0_REG28__TAGLO3
:
6318 TCGv_i64 tmp
= tcg_temp_new_i64();
6319 tcg_gen_ld_i64(tmp
, cpu_env
, offsetof(CPUMIPSState
, CP0_TagLo
));
6320 gen_move_low32(arg
, tmp
);
6321 tcg_temp_free_i64(tmp
);
6323 register_name
= "TagLo";
6325 case CP0_REG28__DATALO
:
6326 case CP0_REG28__DATALO1
:
6327 case CP0_REG28__DATALO2
:
6328 case CP0_REG28__DATALO3
:
6329 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_DataLo
));
6330 register_name
= "DataLo";
6333 goto cp0_unimplemented
;
6336 case CP0_REGISTER_29
:
6338 case CP0_REG29__TAGHI
:
6339 case CP0_REG29__TAGHI1
:
6340 case CP0_REG29__TAGHI2
:
6341 case CP0_REG29__TAGHI3
:
6342 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_TagHi
));
6343 register_name
= "TagHi";
6345 case CP0_REG29__DATAHI
:
6346 case CP0_REG29__DATAHI1
:
6347 case CP0_REG29__DATAHI2
:
6348 case CP0_REG29__DATAHI3
:
6349 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_DataHi
));
6350 register_name
= "DataHi";
6353 goto cp0_unimplemented
;
6356 case CP0_REGISTER_30
:
6358 case CP0_REG30__ERROREPC
:
6359 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_ErrorEPC
));
6360 tcg_gen_ext32s_tl(arg
, arg
);
6361 register_name
= "ErrorEPC";
6364 goto cp0_unimplemented
;
6367 case CP0_REGISTER_31
:
6369 case CP0_REG31__DESAVE
:
6371 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_DESAVE
));
6372 register_name
= "DESAVE";
6374 case CP0_REG31__KSCRATCH1
:
6375 case CP0_REG31__KSCRATCH2
:
6376 case CP0_REG31__KSCRATCH3
:
6377 case CP0_REG31__KSCRATCH4
:
6378 case CP0_REG31__KSCRATCH5
:
6379 case CP0_REG31__KSCRATCH6
:
6380 CP0_CHECK(ctx
->kscrexist
& (1 << sel
));
6381 tcg_gen_ld_tl(arg
, cpu_env
,
6382 offsetof(CPUMIPSState
, CP0_KScratch
[sel
- 2]));
6383 tcg_gen_ext32s_tl(arg
, arg
);
6384 register_name
= "KScratch";
6387 goto cp0_unimplemented
;
6391 goto cp0_unimplemented
;
6393 trace_mips_translate_c0("mfc0", register_name
, reg
, sel
);
6397 qemu_log_mask(LOG_UNIMP
, "mfc0 %s (reg %d sel %d)\n",
6398 register_name
, reg
, sel
);
6399 gen_mfc0_unimplemented(ctx
, arg
);
6402 static void gen_mtc0(DisasContext
*ctx
, TCGv arg
, int reg
, int sel
)
6404 const char *register_name
= "invalid";
6407 check_insn(ctx
, ISA_MIPS_R1
);
6410 if (tb_cflags(ctx
->base
.tb
) & CF_USE_ICOUNT
) {
6415 case CP0_REGISTER_00
:
6417 case CP0_REG00__INDEX
:
6418 gen_helper_mtc0_index(cpu_env
, arg
);
6419 register_name
= "Index";
6421 case CP0_REG00__MVPCONTROL
:
6422 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6423 gen_helper_mtc0_mvpcontrol(cpu_env
, arg
);
6424 register_name
= "MVPControl";
6426 case CP0_REG00__MVPCONF0
:
6427 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6429 register_name
= "MVPConf0";
6431 case CP0_REG00__MVPCONF1
:
6432 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6434 register_name
= "MVPConf1";
6436 case CP0_REG00__VPCONTROL
:
6439 register_name
= "VPControl";
6442 goto cp0_unimplemented
;
6445 case CP0_REGISTER_01
:
6447 case CP0_REG01__RANDOM
:
6449 register_name
= "Random";
6451 case CP0_REG01__VPECONTROL
:
6452 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6453 gen_helper_mtc0_vpecontrol(cpu_env
, arg
);
6454 register_name
= "VPEControl";
6456 case CP0_REG01__VPECONF0
:
6457 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6458 gen_helper_mtc0_vpeconf0(cpu_env
, arg
);
6459 register_name
= "VPEConf0";
6461 case CP0_REG01__VPECONF1
:
6462 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6463 gen_helper_mtc0_vpeconf1(cpu_env
, arg
);
6464 register_name
= "VPEConf1";
6466 case CP0_REG01__YQMASK
:
6467 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6468 gen_helper_mtc0_yqmask(cpu_env
, arg
);
6469 register_name
= "YQMask";
6471 case CP0_REG01__VPESCHEDULE
:
6472 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6473 tcg_gen_st_tl(arg
, cpu_env
,
6474 offsetof(CPUMIPSState
, CP0_VPESchedule
));
6475 register_name
= "VPESchedule";
6477 case CP0_REG01__VPESCHEFBACK
:
6478 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6479 tcg_gen_st_tl(arg
, cpu_env
,
6480 offsetof(CPUMIPSState
, CP0_VPEScheFBack
));
6481 register_name
= "VPEScheFBack";
6483 case CP0_REG01__VPEOPT
:
6484 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6485 gen_helper_mtc0_vpeopt(cpu_env
, arg
);
6486 register_name
= "VPEOpt";
6489 goto cp0_unimplemented
;
6492 case CP0_REGISTER_02
:
6494 case CP0_REG02__ENTRYLO0
:
6495 gen_helper_mtc0_entrylo0(cpu_env
, arg
);
6496 register_name
= "EntryLo0";
6498 case CP0_REG02__TCSTATUS
:
6499 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6500 gen_helper_mtc0_tcstatus(cpu_env
, arg
);
6501 register_name
= "TCStatus";
6503 case CP0_REG02__TCBIND
:
6504 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6505 gen_helper_mtc0_tcbind(cpu_env
, arg
);
6506 register_name
= "TCBind";
6508 case CP0_REG02__TCRESTART
:
6509 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6510 gen_helper_mtc0_tcrestart(cpu_env
, arg
);
6511 register_name
= "TCRestart";
6513 case CP0_REG02__TCHALT
:
6514 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6515 gen_helper_mtc0_tchalt(cpu_env
, arg
);
6516 register_name
= "TCHalt";
6518 case CP0_REG02__TCCONTEXT
:
6519 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6520 gen_helper_mtc0_tccontext(cpu_env
, arg
);
6521 register_name
= "TCContext";
6523 case CP0_REG02__TCSCHEDULE
:
6524 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6525 gen_helper_mtc0_tcschedule(cpu_env
, arg
);
6526 register_name
= "TCSchedule";
6528 case CP0_REG02__TCSCHEFBACK
:
6529 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
6530 gen_helper_mtc0_tcschefback(cpu_env
, arg
);
6531 register_name
= "TCScheFBack";
6534 goto cp0_unimplemented
;
6537 case CP0_REGISTER_03
:
6539 case CP0_REG03__ENTRYLO1
:
6540 gen_helper_mtc0_entrylo1(cpu_env
, arg
);
6541 register_name
= "EntryLo1";
6543 case CP0_REG03__GLOBALNUM
:
6546 register_name
= "GlobalNumber";
6549 goto cp0_unimplemented
;
6552 case CP0_REGISTER_04
:
6554 case CP0_REG04__CONTEXT
:
6555 gen_helper_mtc0_context(cpu_env
, arg
);
6556 register_name
= "Context";
6558 case CP0_REG04__CONTEXTCONFIG
:
6560 /* gen_helper_mtc0_contextconfig(arg); */
6561 register_name
= "ContextConfig";
6562 goto cp0_unimplemented
;
6563 case CP0_REG04__USERLOCAL
:
6564 CP0_CHECK(ctx
->ulri
);
6565 tcg_gen_st_tl(arg
, cpu_env
,
6566 offsetof(CPUMIPSState
, active_tc
.CP0_UserLocal
));
6567 register_name
= "UserLocal";
6569 case CP0_REG04__MMID
:
6571 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_MemoryMapID
));
6572 register_name
= "MMID";
6575 goto cp0_unimplemented
;
6578 case CP0_REGISTER_05
:
6580 case CP0_REG05__PAGEMASK
:
6581 gen_helper_mtc0_pagemask(cpu_env
, arg
);
6582 register_name
= "PageMask";
6584 case CP0_REG05__PAGEGRAIN
:
6585 check_insn(ctx
, ISA_MIPS_R2
);
6586 gen_helper_mtc0_pagegrain(cpu_env
, arg
);
6587 register_name
= "PageGrain";
6588 ctx
->base
.is_jmp
= DISAS_STOP
;
6590 case CP0_REG05__SEGCTL0
:
6592 gen_helper_mtc0_segctl0(cpu_env
, arg
);
6593 register_name
= "SegCtl0";
6595 case CP0_REG05__SEGCTL1
:
6597 gen_helper_mtc0_segctl1(cpu_env
, arg
);
6598 register_name
= "SegCtl1";
6600 case CP0_REG05__SEGCTL2
:
6602 gen_helper_mtc0_segctl2(cpu_env
, arg
);
6603 register_name
= "SegCtl2";
6605 case CP0_REG05__PWBASE
:
6607 gen_mtc0_store32(arg
, offsetof(CPUMIPSState
, CP0_PWBase
));
6608 register_name
= "PWBase";
6610 case CP0_REG05__PWFIELD
:
6612 gen_helper_mtc0_pwfield(cpu_env
, arg
);
6613 register_name
= "PWField";
6615 case CP0_REG05__PWSIZE
:
6617 gen_helper_mtc0_pwsize(cpu_env
, arg
);
6618 register_name
= "PWSize";
6621 goto cp0_unimplemented
;
6624 case CP0_REGISTER_06
:
6626 case CP0_REG06__WIRED
:
6627 gen_helper_mtc0_wired(cpu_env
, arg
);
6628 register_name
= "Wired";
6630 case CP0_REG06__SRSCONF0
:
6631 check_insn(ctx
, ISA_MIPS_R2
);
6632 gen_helper_mtc0_srsconf0(cpu_env
, arg
);
6633 register_name
= "SRSConf0";
6635 case CP0_REG06__SRSCONF1
:
6636 check_insn(ctx
, ISA_MIPS_R2
);
6637 gen_helper_mtc0_srsconf1(cpu_env
, arg
);
6638 register_name
= "SRSConf1";
6640 case CP0_REG06__SRSCONF2
:
6641 check_insn(ctx
, ISA_MIPS_R2
);
6642 gen_helper_mtc0_srsconf2(cpu_env
, arg
);
6643 register_name
= "SRSConf2";
6645 case CP0_REG06__SRSCONF3
:
6646 check_insn(ctx
, ISA_MIPS_R2
);
6647 gen_helper_mtc0_srsconf3(cpu_env
, arg
);
6648 register_name
= "SRSConf3";
6650 case CP0_REG06__SRSCONF4
:
6651 check_insn(ctx
, ISA_MIPS_R2
);
6652 gen_helper_mtc0_srsconf4(cpu_env
, arg
);
6653 register_name
= "SRSConf4";
6655 case CP0_REG06__PWCTL
:
6657 gen_helper_mtc0_pwctl(cpu_env
, arg
);
6658 register_name
= "PWCtl";
6661 goto cp0_unimplemented
;
6664 case CP0_REGISTER_07
:
6666 case CP0_REG07__HWRENA
:
6667 check_insn(ctx
, ISA_MIPS_R2
);
6668 gen_helper_mtc0_hwrena(cpu_env
, arg
);
6669 ctx
->base
.is_jmp
= DISAS_STOP
;
6670 register_name
= "HWREna";
6673 goto cp0_unimplemented
;
6676 case CP0_REGISTER_08
:
6678 case CP0_REG08__BADVADDR
:
6680 register_name
= "BadVAddr";
6682 case CP0_REG08__BADINSTR
:
6684 register_name
= "BadInstr";
6686 case CP0_REG08__BADINSTRP
:
6688 register_name
= "BadInstrP";
6690 case CP0_REG08__BADINSTRX
:
6692 register_name
= "BadInstrX";
6695 goto cp0_unimplemented
;
6698 case CP0_REGISTER_09
:
6700 case CP0_REG09__COUNT
:
6701 gen_helper_mtc0_count(cpu_env
, arg
);
6702 register_name
= "Count";
6704 case CP0_REG09__SAARI
:
6705 CP0_CHECK(ctx
->saar
);
6706 gen_helper_mtc0_saari(cpu_env
, arg
);
6707 register_name
= "SAARI";
6709 case CP0_REG09__SAAR
:
6710 CP0_CHECK(ctx
->saar
);
6711 gen_helper_mtc0_saar(cpu_env
, arg
);
6712 register_name
= "SAAR";
6715 goto cp0_unimplemented
;
6718 case CP0_REGISTER_10
:
6720 case CP0_REG10__ENTRYHI
:
6721 gen_helper_mtc0_entryhi(cpu_env
, arg
);
6722 register_name
= "EntryHi";
6725 goto cp0_unimplemented
;
6728 case CP0_REGISTER_11
:
6730 case CP0_REG11__COMPARE
:
6731 gen_helper_mtc0_compare(cpu_env
, arg
);
6732 register_name
= "Compare";
6734 /* 6,7 are implementation dependent */
6736 goto cp0_unimplemented
;
6739 case CP0_REGISTER_12
:
6741 case CP0_REG12__STATUS
:
6742 save_cpu_state(ctx
, 1);
6743 gen_helper_mtc0_status(cpu_env
, arg
);
6744 /* DISAS_STOP isn't good enough here, hflags may have changed. */
6745 gen_save_pc(ctx
->base
.pc_next
+ 4);
6746 ctx
->base
.is_jmp
= DISAS_EXIT
;
6747 register_name
= "Status";
6749 case CP0_REG12__INTCTL
:
6750 check_insn(ctx
, ISA_MIPS_R2
);
6751 gen_helper_mtc0_intctl(cpu_env
, arg
);
6752 /* Stop translation as we may have switched the execution mode */
6753 ctx
->base
.is_jmp
= DISAS_STOP
;
6754 register_name
= "IntCtl";
6756 case CP0_REG12__SRSCTL
:
6757 check_insn(ctx
, ISA_MIPS_R2
);
6758 gen_helper_mtc0_srsctl(cpu_env
, arg
);
6759 /* Stop translation as we may have switched the execution mode */
6760 ctx
->base
.is_jmp
= DISAS_STOP
;
6761 register_name
= "SRSCtl";
6763 case CP0_REG12__SRSMAP
:
6764 check_insn(ctx
, ISA_MIPS_R2
);
6765 gen_mtc0_store32(arg
, offsetof(CPUMIPSState
, CP0_SRSMap
));
6766 /* Stop translation as we may have switched the execution mode */
6767 ctx
->base
.is_jmp
= DISAS_STOP
;
6768 register_name
= "SRSMap";
6771 goto cp0_unimplemented
;
6774 case CP0_REGISTER_13
:
6776 case CP0_REG13__CAUSE
:
6777 save_cpu_state(ctx
, 1);
6778 gen_helper_mtc0_cause(cpu_env
, arg
);
6780 * Stop translation as we may have triggered an interrupt.
6781 * DISAS_STOP isn't sufficient, we need to ensure we break out of
6782 * translated code to check for pending interrupts.
6784 gen_save_pc(ctx
->base
.pc_next
+ 4);
6785 ctx
->base
.is_jmp
= DISAS_EXIT
;
6786 register_name
= "Cause";
6789 goto cp0_unimplemented
;
6792 case CP0_REGISTER_14
:
6794 case CP0_REG14__EPC
:
6795 tcg_gen_st_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_EPC
));
6796 register_name
= "EPC";
6799 goto cp0_unimplemented
;
6802 case CP0_REGISTER_15
:
6804 case CP0_REG15__PRID
:
6806 register_name
= "PRid";
6808 case CP0_REG15__EBASE
:
6809 check_insn(ctx
, ISA_MIPS_R2
);
6810 gen_helper_mtc0_ebase(cpu_env
, arg
);
6811 register_name
= "EBase";
6814 goto cp0_unimplemented
;
6817 case CP0_REGISTER_16
:
6819 case CP0_REG16__CONFIG
:
6820 gen_helper_mtc0_config0(cpu_env
, arg
);
6821 register_name
= "Config";
6822 /* Stop translation as we may have switched the execution mode */
6823 ctx
->base
.is_jmp
= DISAS_STOP
;
6825 case CP0_REG16__CONFIG1
:
6826 /* ignored, read only */
6827 register_name
= "Config1";
6829 case CP0_REG16__CONFIG2
:
6830 gen_helper_mtc0_config2(cpu_env
, arg
);
6831 register_name
= "Config2";
6832 /* Stop translation as we may have switched the execution mode */
6833 ctx
->base
.is_jmp
= DISAS_STOP
;
6835 case CP0_REG16__CONFIG3
:
6836 gen_helper_mtc0_config3(cpu_env
, arg
);
6837 register_name
= "Config3";
6838 /* Stop translation as we may have switched the execution mode */
6839 ctx
->base
.is_jmp
= DISAS_STOP
;
6841 case CP0_REG16__CONFIG4
:
6842 gen_helper_mtc0_config4(cpu_env
, arg
);
6843 register_name
= "Config4";
6844 ctx
->base
.is_jmp
= DISAS_STOP
;
6846 case CP0_REG16__CONFIG5
:
6847 gen_helper_mtc0_config5(cpu_env
, arg
);
6848 register_name
= "Config5";
6849 /* Stop translation as we may have switched the execution mode */
6850 ctx
->base
.is_jmp
= DISAS_STOP
;
6852 /* 6,7 are implementation dependent */
6853 case CP0_REG16__CONFIG6
:
6855 register_name
= "Config6";
6857 case CP0_REG16__CONFIG7
:
6859 register_name
= "Config7";
6862 register_name
= "Invalid config selector";
6863 goto cp0_unimplemented
;
6866 case CP0_REGISTER_17
:
6868 case CP0_REG17__LLADDR
:
6869 gen_helper_mtc0_lladdr(cpu_env
, arg
);
6870 register_name
= "LLAddr";
6872 case CP0_REG17__MAAR
:
6873 CP0_CHECK(ctx
->mrp
);
6874 gen_helper_mtc0_maar(cpu_env
, arg
);
6875 register_name
= "MAAR";
6877 case CP0_REG17__MAARI
:
6878 CP0_CHECK(ctx
->mrp
);
6879 gen_helper_mtc0_maari(cpu_env
, arg
);
6880 register_name
= "MAARI";
6883 goto cp0_unimplemented
;
6886 case CP0_REGISTER_18
:
6888 case CP0_REG18__WATCHLO0
:
6889 case CP0_REG18__WATCHLO1
:
6890 case CP0_REG18__WATCHLO2
:
6891 case CP0_REG18__WATCHLO3
:
6892 case CP0_REG18__WATCHLO4
:
6893 case CP0_REG18__WATCHLO5
:
6894 case CP0_REG18__WATCHLO6
:
6895 case CP0_REG18__WATCHLO7
:
6896 CP0_CHECK(ctx
->CP0_Config1
& (1 << CP0C1_WR
));
6897 gen_helper_0e1i(mtc0_watchlo
, arg
, sel
);
6898 register_name
= "WatchLo";
6901 goto cp0_unimplemented
;
6904 case CP0_REGISTER_19
:
6906 case CP0_REG19__WATCHHI0
:
6907 case CP0_REG19__WATCHHI1
:
6908 case CP0_REG19__WATCHHI2
:
6909 case CP0_REG19__WATCHHI3
:
6910 case CP0_REG19__WATCHHI4
:
6911 case CP0_REG19__WATCHHI5
:
6912 case CP0_REG19__WATCHHI6
:
6913 case CP0_REG19__WATCHHI7
:
6914 CP0_CHECK(ctx
->CP0_Config1
& (1 << CP0C1_WR
));
6915 gen_helper_0e1i(mtc0_watchhi
, arg
, sel
);
6916 register_name
= "WatchHi";
6919 goto cp0_unimplemented
;
6922 case CP0_REGISTER_20
:
6924 case CP0_REG20__XCONTEXT
:
6925 #if defined(TARGET_MIPS64)
6926 check_insn(ctx
, ISA_MIPS3
);
6927 gen_helper_mtc0_xcontext(cpu_env
, arg
);
6928 register_name
= "XContext";
6932 goto cp0_unimplemented
;
6935 case CP0_REGISTER_21
:
6936 /* Officially reserved, but sel 0 is used for R1x000 framemask */
6937 CP0_CHECK(!(ctx
->insn_flags
& ISA_MIPS_R6
));
6940 gen_helper_mtc0_framemask(cpu_env
, arg
);
6941 register_name
= "Framemask";
6944 goto cp0_unimplemented
;
6947 case CP0_REGISTER_22
:
6949 register_name
= "Diagnostic"; /* implementation dependent */
6951 case CP0_REGISTER_23
:
6953 case CP0_REG23__DEBUG
:
6954 gen_helper_mtc0_debug(cpu_env
, arg
); /* EJTAG support */
6955 /* DISAS_STOP isn't good enough here, hflags may have changed. */
6956 gen_save_pc(ctx
->base
.pc_next
+ 4);
6957 ctx
->base
.is_jmp
= DISAS_EXIT
;
6958 register_name
= "Debug";
6960 case CP0_REG23__TRACECONTROL
:
6961 /* PDtrace support */
6962 /* gen_helper_mtc0_tracecontrol(cpu_env, arg); */
6963 register_name
= "TraceControl";
6964 /* Stop translation as we may have switched the execution mode */
6965 ctx
->base
.is_jmp
= DISAS_STOP
;
6966 goto cp0_unimplemented
;
6967 case CP0_REG23__TRACECONTROL2
:
6968 /* PDtrace support */
6969 /* gen_helper_mtc0_tracecontrol2(cpu_env, arg); */
6970 register_name
= "TraceControl2";
6971 /* Stop translation as we may have switched the execution mode */
6972 ctx
->base
.is_jmp
= DISAS_STOP
;
6973 goto cp0_unimplemented
;
6974 case CP0_REG23__USERTRACEDATA1
:
6975 /* Stop translation as we may have switched the execution mode */
6976 ctx
->base
.is_jmp
= DISAS_STOP
;
6977 /* PDtrace support */
6978 /* gen_helper_mtc0_usertracedata1(cpu_env, arg);*/
6979 register_name
= "UserTraceData";
6980 /* Stop translation as we may have switched the execution mode */
6981 ctx
->base
.is_jmp
= DISAS_STOP
;
6982 goto cp0_unimplemented
;
6983 case CP0_REG23__TRACEIBPC
:
6984 /* PDtrace support */
6985 /* gen_helper_mtc0_traceibpc(cpu_env, arg); */
6986 /* Stop translation as we may have switched the execution mode */
6987 ctx
->base
.is_jmp
= DISAS_STOP
;
6988 register_name
= "TraceIBPC";
6989 goto cp0_unimplemented
;
6990 case CP0_REG23__TRACEDBPC
:
6991 /* PDtrace support */
6992 /* gen_helper_mtc0_tracedbpc(cpu_env, arg); */
6993 /* Stop translation as we may have switched the execution mode */
6994 ctx
->base
.is_jmp
= DISAS_STOP
;
6995 register_name
= "TraceDBPC";
6996 goto cp0_unimplemented
;
6998 goto cp0_unimplemented
;
7001 case CP0_REGISTER_24
:
7003 case CP0_REG24__DEPC
:
7005 tcg_gen_st_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_DEPC
));
7006 register_name
= "DEPC";
7009 goto cp0_unimplemented
;
7012 case CP0_REGISTER_25
:
7014 case CP0_REG25__PERFCTL0
:
7015 gen_helper_mtc0_performance0(cpu_env
, arg
);
7016 register_name
= "Performance0";
7018 case CP0_REG25__PERFCNT0
:
7019 /* gen_helper_mtc0_performance1(arg); */
7020 register_name
= "Performance1";
7021 goto cp0_unimplemented
;
7022 case CP0_REG25__PERFCTL1
:
7023 /* gen_helper_mtc0_performance2(arg); */
7024 register_name
= "Performance2";
7025 goto cp0_unimplemented
;
7026 case CP0_REG25__PERFCNT1
:
7027 /* gen_helper_mtc0_performance3(arg); */
7028 register_name
= "Performance3";
7029 goto cp0_unimplemented
;
7030 case CP0_REG25__PERFCTL2
:
7031 /* gen_helper_mtc0_performance4(arg); */
7032 register_name
= "Performance4";
7033 goto cp0_unimplemented
;
7034 case CP0_REG25__PERFCNT2
:
7035 /* gen_helper_mtc0_performance5(arg); */
7036 register_name
= "Performance5";
7037 goto cp0_unimplemented
;
7038 case CP0_REG25__PERFCTL3
:
7039 /* gen_helper_mtc0_performance6(arg); */
7040 register_name
= "Performance6";
7041 goto cp0_unimplemented
;
7042 case CP0_REG25__PERFCNT3
:
7043 /* gen_helper_mtc0_performance7(arg); */
7044 register_name
= "Performance7";
7045 goto cp0_unimplemented
;
7047 goto cp0_unimplemented
;
7050 case CP0_REGISTER_26
:
7052 case CP0_REG26__ERRCTL
:
7053 gen_helper_mtc0_errctl(cpu_env
, arg
);
7054 ctx
->base
.is_jmp
= DISAS_STOP
;
7055 register_name
= "ErrCtl";
7058 goto cp0_unimplemented
;
7061 case CP0_REGISTER_27
:
7063 case CP0_REG27__CACHERR
:
7065 register_name
= "CacheErr";
7068 goto cp0_unimplemented
;
7071 case CP0_REGISTER_28
:
7073 case CP0_REG28__TAGLO
:
7074 case CP0_REG28__TAGLO1
:
7075 case CP0_REG28__TAGLO2
:
7076 case CP0_REG28__TAGLO3
:
7077 gen_helper_mtc0_taglo(cpu_env
, arg
);
7078 register_name
= "TagLo";
7080 case CP0_REG28__DATALO
:
7081 case CP0_REG28__DATALO1
:
7082 case CP0_REG28__DATALO2
:
7083 case CP0_REG28__DATALO3
:
7084 gen_helper_mtc0_datalo(cpu_env
, arg
);
7085 register_name
= "DataLo";
7088 goto cp0_unimplemented
;
7091 case CP0_REGISTER_29
:
7093 case CP0_REG29__TAGHI
:
7094 case CP0_REG29__TAGHI1
:
7095 case CP0_REG29__TAGHI2
:
7096 case CP0_REG29__TAGHI3
:
7097 gen_helper_mtc0_taghi(cpu_env
, arg
);
7098 register_name
= "TagHi";
7100 case CP0_REG29__DATAHI
:
7101 case CP0_REG29__DATAHI1
:
7102 case CP0_REG29__DATAHI2
:
7103 case CP0_REG29__DATAHI3
:
7104 gen_helper_mtc0_datahi(cpu_env
, arg
);
7105 register_name
= "DataHi";
7108 register_name
= "invalid sel";
7109 goto cp0_unimplemented
;
7112 case CP0_REGISTER_30
:
7114 case CP0_REG30__ERROREPC
:
7115 tcg_gen_st_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_ErrorEPC
));
7116 register_name
= "ErrorEPC";
7119 goto cp0_unimplemented
;
7122 case CP0_REGISTER_31
:
7124 case CP0_REG31__DESAVE
:
7126 gen_mtc0_store32(arg
, offsetof(CPUMIPSState
, CP0_DESAVE
));
7127 register_name
= "DESAVE";
7129 case CP0_REG31__KSCRATCH1
:
7130 case CP0_REG31__KSCRATCH2
:
7131 case CP0_REG31__KSCRATCH3
:
7132 case CP0_REG31__KSCRATCH4
:
7133 case CP0_REG31__KSCRATCH5
:
7134 case CP0_REG31__KSCRATCH6
:
7135 CP0_CHECK(ctx
->kscrexist
& (1 << sel
));
7136 tcg_gen_st_tl(arg
, cpu_env
,
7137 offsetof(CPUMIPSState
, CP0_KScratch
[sel
- 2]));
7138 register_name
= "KScratch";
7141 goto cp0_unimplemented
;
7145 goto cp0_unimplemented
;
7147 trace_mips_translate_c0("mtc0", register_name
, reg
, sel
);
7149 /* For simplicity assume that all writes can cause interrupts. */
7150 if (tb_cflags(ctx
->base
.tb
) & CF_USE_ICOUNT
) {
7152 * DISAS_STOP isn't sufficient, we need to ensure we break out of
7153 * translated code to check for pending interrupts.
7155 gen_save_pc(ctx
->base
.pc_next
+ 4);
7156 ctx
->base
.is_jmp
= DISAS_EXIT
;
7161 qemu_log_mask(LOG_UNIMP
, "mtc0 %s (reg %d sel %d)\n",
7162 register_name
, reg
, sel
);
7165 #if defined(TARGET_MIPS64)
7166 static void gen_dmfc0(DisasContext
*ctx
, TCGv arg
, int reg
, int sel
)
7168 const char *register_name
= "invalid";
7171 check_insn(ctx
, ISA_MIPS_R1
);
7175 case CP0_REGISTER_00
:
7177 case CP0_REG00__INDEX
:
7178 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Index
));
7179 register_name
= "Index";
7181 case CP0_REG00__MVPCONTROL
:
7182 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7183 gen_helper_mfc0_mvpcontrol(arg
, cpu_env
);
7184 register_name
= "MVPControl";
7186 case CP0_REG00__MVPCONF0
:
7187 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7188 gen_helper_mfc0_mvpconf0(arg
, cpu_env
);
7189 register_name
= "MVPConf0";
7191 case CP0_REG00__MVPCONF1
:
7192 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7193 gen_helper_mfc0_mvpconf1(arg
, cpu_env
);
7194 register_name
= "MVPConf1";
7196 case CP0_REG00__VPCONTROL
:
7198 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPControl
));
7199 register_name
= "VPControl";
7202 goto cp0_unimplemented
;
7205 case CP0_REGISTER_01
:
7207 case CP0_REG01__RANDOM
:
7208 CP0_CHECK(!(ctx
->insn_flags
& ISA_MIPS_R6
));
7209 gen_helper_mfc0_random(arg
, cpu_env
);
7210 register_name
= "Random";
7212 case CP0_REG01__VPECONTROL
:
7213 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7214 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPEControl
));
7215 register_name
= "VPEControl";
7217 case CP0_REG01__VPECONF0
:
7218 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7219 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPEConf0
));
7220 register_name
= "VPEConf0";
7222 case CP0_REG01__VPECONF1
:
7223 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7224 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPEConf1
));
7225 register_name
= "VPEConf1";
7227 case CP0_REG01__YQMASK
:
7228 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7229 tcg_gen_ld_tl(arg
, cpu_env
,
7230 offsetof(CPUMIPSState
, CP0_YQMask
));
7231 register_name
= "YQMask";
7233 case CP0_REG01__VPESCHEDULE
:
7234 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7235 tcg_gen_ld_tl(arg
, cpu_env
,
7236 offsetof(CPUMIPSState
, CP0_VPESchedule
));
7237 register_name
= "VPESchedule";
7239 case CP0_REG01__VPESCHEFBACK
:
7240 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7241 tcg_gen_ld_tl(arg
, cpu_env
,
7242 offsetof(CPUMIPSState
, CP0_VPEScheFBack
));
7243 register_name
= "VPEScheFBack";
7245 case CP0_REG01__VPEOPT
:
7246 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7247 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_VPEOpt
));
7248 register_name
= "VPEOpt";
7251 goto cp0_unimplemented
;
7254 case CP0_REGISTER_02
:
7256 case CP0_REG02__ENTRYLO0
:
7257 tcg_gen_ld_tl(arg
, cpu_env
,
7258 offsetof(CPUMIPSState
, CP0_EntryLo0
));
7259 register_name
= "EntryLo0";
7261 case CP0_REG02__TCSTATUS
:
7262 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7263 gen_helper_mfc0_tcstatus(arg
, cpu_env
);
7264 register_name
= "TCStatus";
7266 case CP0_REG02__TCBIND
:
7267 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7268 gen_helper_mfc0_tcbind(arg
, cpu_env
);
7269 register_name
= "TCBind";
7271 case CP0_REG02__TCRESTART
:
7272 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7273 gen_helper_dmfc0_tcrestart(arg
, cpu_env
);
7274 register_name
= "TCRestart";
7276 case CP0_REG02__TCHALT
:
7277 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7278 gen_helper_dmfc0_tchalt(arg
, cpu_env
);
7279 register_name
= "TCHalt";
7281 case CP0_REG02__TCCONTEXT
:
7282 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7283 gen_helper_dmfc0_tccontext(arg
, cpu_env
);
7284 register_name
= "TCContext";
7286 case CP0_REG02__TCSCHEDULE
:
7287 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7288 gen_helper_dmfc0_tcschedule(arg
, cpu_env
);
7289 register_name
= "TCSchedule";
7291 case CP0_REG02__TCSCHEFBACK
:
7292 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7293 gen_helper_dmfc0_tcschefback(arg
, cpu_env
);
7294 register_name
= "TCScheFBack";
7297 goto cp0_unimplemented
;
7300 case CP0_REGISTER_03
:
7302 case CP0_REG03__ENTRYLO1
:
7303 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_EntryLo1
));
7304 register_name
= "EntryLo1";
7306 case CP0_REG03__GLOBALNUM
:
7308 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_GlobalNumber
));
7309 register_name
= "GlobalNumber";
7312 goto cp0_unimplemented
;
7315 case CP0_REGISTER_04
:
7317 case CP0_REG04__CONTEXT
:
7318 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_Context
));
7319 register_name
= "Context";
7321 case CP0_REG04__CONTEXTCONFIG
:
7323 /* gen_helper_dmfc0_contextconfig(arg); */
7324 register_name
= "ContextConfig";
7325 goto cp0_unimplemented
;
7326 case CP0_REG04__USERLOCAL
:
7327 CP0_CHECK(ctx
->ulri
);
7328 tcg_gen_ld_tl(arg
, cpu_env
,
7329 offsetof(CPUMIPSState
, active_tc
.CP0_UserLocal
));
7330 register_name
= "UserLocal";
7332 case CP0_REG04__MMID
:
7334 gen_helper_mtc0_memorymapid(cpu_env
, arg
);
7335 register_name
= "MMID";
7338 goto cp0_unimplemented
;
7341 case CP0_REGISTER_05
:
7343 case CP0_REG05__PAGEMASK
:
7344 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PageMask
));
7345 register_name
= "PageMask";
7347 case CP0_REG05__PAGEGRAIN
:
7348 check_insn(ctx
, ISA_MIPS_R2
);
7349 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PageGrain
));
7350 register_name
= "PageGrain";
7352 case CP0_REG05__SEGCTL0
:
7354 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_SegCtl0
));
7355 register_name
= "SegCtl0";
7357 case CP0_REG05__SEGCTL1
:
7359 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_SegCtl1
));
7360 register_name
= "SegCtl1";
7362 case CP0_REG05__SEGCTL2
:
7364 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_SegCtl2
));
7365 register_name
= "SegCtl2";
7367 case CP0_REG05__PWBASE
:
7369 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_PWBase
));
7370 register_name
= "PWBase";
7372 case CP0_REG05__PWFIELD
:
7374 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_PWField
));
7375 register_name
= "PWField";
7377 case CP0_REG05__PWSIZE
:
7379 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_PWSize
));
7380 register_name
= "PWSize";
7383 goto cp0_unimplemented
;
7386 case CP0_REGISTER_06
:
7388 case CP0_REG06__WIRED
:
7389 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Wired
));
7390 register_name
= "Wired";
7392 case CP0_REG06__SRSCONF0
:
7393 check_insn(ctx
, ISA_MIPS_R2
);
7394 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf0
));
7395 register_name
= "SRSConf0";
7397 case CP0_REG06__SRSCONF1
:
7398 check_insn(ctx
, ISA_MIPS_R2
);
7399 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf1
));
7400 register_name
= "SRSConf1";
7402 case CP0_REG06__SRSCONF2
:
7403 check_insn(ctx
, ISA_MIPS_R2
);
7404 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf2
));
7405 register_name
= "SRSConf2";
7407 case CP0_REG06__SRSCONF3
:
7408 check_insn(ctx
, ISA_MIPS_R2
);
7409 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf3
));
7410 register_name
= "SRSConf3";
7412 case CP0_REG06__SRSCONF4
:
7413 check_insn(ctx
, ISA_MIPS_R2
);
7414 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSConf4
));
7415 register_name
= "SRSConf4";
7417 case CP0_REG06__PWCTL
:
7419 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PWCtl
));
7420 register_name
= "PWCtl";
7423 goto cp0_unimplemented
;
7426 case CP0_REGISTER_07
:
7428 case CP0_REG07__HWRENA
:
7429 check_insn(ctx
, ISA_MIPS_R2
);
7430 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_HWREna
));
7431 register_name
= "HWREna";
7434 goto cp0_unimplemented
;
7437 case CP0_REGISTER_08
:
7439 case CP0_REG08__BADVADDR
:
7440 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_BadVAddr
));
7441 register_name
= "BadVAddr";
7443 case CP0_REG08__BADINSTR
:
7445 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_BadInstr
));
7446 register_name
= "BadInstr";
7448 case CP0_REG08__BADINSTRP
:
7450 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_BadInstrP
));
7451 register_name
= "BadInstrP";
7453 case CP0_REG08__BADINSTRX
:
7455 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_BadInstrX
));
7456 tcg_gen_andi_tl(arg
, arg
, ~0xffff);
7457 register_name
= "BadInstrX";
7460 goto cp0_unimplemented
;
7463 case CP0_REGISTER_09
:
7465 case CP0_REG09__COUNT
:
7466 /* Mark as an IO operation because we read the time. */
7467 if (tb_cflags(ctx
->base
.tb
) & CF_USE_ICOUNT
) {
7470 gen_helper_mfc0_count(arg
, cpu_env
);
7472 * Break the TB to be able to take timer interrupts immediately
7473 * after reading count. DISAS_STOP isn't sufficient, we need to
7474 * ensure we break completely out of translated code.
7476 gen_save_pc(ctx
->base
.pc_next
+ 4);
7477 ctx
->base
.is_jmp
= DISAS_EXIT
;
7478 register_name
= "Count";
7480 case CP0_REG09__SAARI
:
7481 CP0_CHECK(ctx
->saar
);
7482 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SAARI
));
7483 register_name
= "SAARI";
7485 case CP0_REG09__SAAR
:
7486 CP0_CHECK(ctx
->saar
);
7487 gen_helper_dmfc0_saar(arg
, cpu_env
);
7488 register_name
= "SAAR";
7491 goto cp0_unimplemented
;
7494 case CP0_REGISTER_10
:
7496 case CP0_REG10__ENTRYHI
:
7497 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_EntryHi
));
7498 register_name
= "EntryHi";
7501 goto cp0_unimplemented
;
7504 case CP0_REGISTER_11
:
7506 case CP0_REG11__COMPARE
:
7507 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Compare
));
7508 register_name
= "Compare";
7510 /* 6,7 are implementation dependent */
7512 goto cp0_unimplemented
;
7515 case CP0_REGISTER_12
:
7517 case CP0_REG12__STATUS
:
7518 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Status
));
7519 register_name
= "Status";
7521 case CP0_REG12__INTCTL
:
7522 check_insn(ctx
, ISA_MIPS_R2
);
7523 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_IntCtl
));
7524 register_name
= "IntCtl";
7526 case CP0_REG12__SRSCTL
:
7527 check_insn(ctx
, ISA_MIPS_R2
);
7528 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSCtl
));
7529 register_name
= "SRSCtl";
7531 case CP0_REG12__SRSMAP
:
7532 check_insn(ctx
, ISA_MIPS_R2
);
7533 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_SRSMap
));
7534 register_name
= "SRSMap";
7537 goto cp0_unimplemented
;
7540 case CP0_REGISTER_13
:
7542 case CP0_REG13__CAUSE
:
7543 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Cause
));
7544 register_name
= "Cause";
7547 goto cp0_unimplemented
;
7550 case CP0_REGISTER_14
:
7552 case CP0_REG14__EPC
:
7553 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_EPC
));
7554 register_name
= "EPC";
7557 goto cp0_unimplemented
;
7560 case CP0_REGISTER_15
:
7562 case CP0_REG15__PRID
:
7563 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_PRid
));
7564 register_name
= "PRid";
7566 case CP0_REG15__EBASE
:
7567 check_insn(ctx
, ISA_MIPS_R2
);
7568 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_EBase
));
7569 register_name
= "EBase";
7571 case CP0_REG15__CMGCRBASE
:
7572 check_insn(ctx
, ISA_MIPS_R2
);
7573 CP0_CHECK(ctx
->cmgcr
);
7574 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_CMGCRBase
));
7575 register_name
= "CMGCRBase";
7578 goto cp0_unimplemented
;
7581 case CP0_REGISTER_16
:
7583 case CP0_REG16__CONFIG
:
7584 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config0
));
7585 register_name
= "Config";
7587 case CP0_REG16__CONFIG1
:
7588 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config1
));
7589 register_name
= "Config1";
7591 case CP0_REG16__CONFIG2
:
7592 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config2
));
7593 register_name
= "Config2";
7595 case CP0_REG16__CONFIG3
:
7596 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config3
));
7597 register_name
= "Config3";
7599 case CP0_REG16__CONFIG4
:
7600 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config4
));
7601 register_name
= "Config4";
7603 case CP0_REG16__CONFIG5
:
7604 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config5
));
7605 register_name
= "Config5";
7607 /* 6,7 are implementation dependent */
7608 case CP0_REG16__CONFIG6
:
7609 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config6
));
7610 register_name
= "Config6";
7612 case CP0_REG16__CONFIG7
:
7613 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Config7
));
7614 register_name
= "Config7";
7617 goto cp0_unimplemented
;
7620 case CP0_REGISTER_17
:
7622 case CP0_REG17__LLADDR
:
7623 gen_helper_dmfc0_lladdr(arg
, cpu_env
);
7624 register_name
= "LLAddr";
7626 case CP0_REG17__MAAR
:
7627 CP0_CHECK(ctx
->mrp
);
7628 gen_helper_dmfc0_maar(arg
, cpu_env
);
7629 register_name
= "MAAR";
7631 case CP0_REG17__MAARI
:
7632 CP0_CHECK(ctx
->mrp
);
7633 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_MAARI
));
7634 register_name
= "MAARI";
7637 goto cp0_unimplemented
;
7640 case CP0_REGISTER_18
:
7642 case CP0_REG18__WATCHLO0
:
7643 case CP0_REG18__WATCHLO1
:
7644 case CP0_REG18__WATCHLO2
:
7645 case CP0_REG18__WATCHLO3
:
7646 case CP0_REG18__WATCHLO4
:
7647 case CP0_REG18__WATCHLO5
:
7648 case CP0_REG18__WATCHLO6
:
7649 case CP0_REG18__WATCHLO7
:
7650 CP0_CHECK(ctx
->CP0_Config1
& (1 << CP0C1_WR
));
7651 gen_helper_1e0i(dmfc0_watchlo
, arg
, sel
);
7652 register_name
= "WatchLo";
7655 goto cp0_unimplemented
;
7658 case CP0_REGISTER_19
:
7660 case CP0_REG19__WATCHHI0
:
7661 case CP0_REG19__WATCHHI1
:
7662 case CP0_REG19__WATCHHI2
:
7663 case CP0_REG19__WATCHHI3
:
7664 case CP0_REG19__WATCHHI4
:
7665 case CP0_REG19__WATCHHI5
:
7666 case CP0_REG19__WATCHHI6
:
7667 case CP0_REG19__WATCHHI7
:
7668 CP0_CHECK(ctx
->CP0_Config1
& (1 << CP0C1_WR
));
7669 gen_helper_1e0i(dmfc0_watchhi
, arg
, sel
);
7670 register_name
= "WatchHi";
7673 goto cp0_unimplemented
;
7676 case CP0_REGISTER_20
:
7678 case CP0_REG20__XCONTEXT
:
7679 check_insn(ctx
, ISA_MIPS3
);
7680 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_XContext
));
7681 register_name
= "XContext";
7684 goto cp0_unimplemented
;
7687 case CP0_REGISTER_21
:
7688 /* Officially reserved, but sel 0 is used for R1x000 framemask */
7689 CP0_CHECK(!(ctx
->insn_flags
& ISA_MIPS_R6
));
7692 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Framemask
));
7693 register_name
= "Framemask";
7696 goto cp0_unimplemented
;
7699 case CP0_REGISTER_22
:
7700 tcg_gen_movi_tl(arg
, 0); /* unimplemented */
7701 register_name
= "'Diagnostic"; /* implementation dependent */
7703 case CP0_REGISTER_23
:
7705 case CP0_REG23__DEBUG
:
7706 gen_helper_mfc0_debug(arg
, cpu_env
); /* EJTAG support */
7707 register_name
= "Debug";
7709 case CP0_REG23__TRACECONTROL
:
7710 /* PDtrace support */
7711 /* gen_helper_dmfc0_tracecontrol(arg, cpu_env); */
7712 register_name
= "TraceControl";
7713 goto cp0_unimplemented
;
7714 case CP0_REG23__TRACECONTROL2
:
7715 /* PDtrace support */
7716 /* gen_helper_dmfc0_tracecontrol2(arg, cpu_env); */
7717 register_name
= "TraceControl2";
7718 goto cp0_unimplemented
;
7719 case CP0_REG23__USERTRACEDATA1
:
7720 /* PDtrace support */
7721 /* gen_helper_dmfc0_usertracedata1(arg, cpu_env);*/
7722 register_name
= "UserTraceData1";
7723 goto cp0_unimplemented
;
7724 case CP0_REG23__TRACEIBPC
:
7725 /* PDtrace support */
7726 /* gen_helper_dmfc0_traceibpc(arg, cpu_env); */
7727 register_name
= "TraceIBPC";
7728 goto cp0_unimplemented
;
7729 case CP0_REG23__TRACEDBPC
:
7730 /* PDtrace support */
7731 /* gen_helper_dmfc0_tracedbpc(arg, cpu_env); */
7732 register_name
= "TraceDBPC";
7733 goto cp0_unimplemented
;
7735 goto cp0_unimplemented
;
7738 case CP0_REGISTER_24
:
7740 case CP0_REG24__DEPC
:
7742 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_DEPC
));
7743 register_name
= "DEPC";
7746 goto cp0_unimplemented
;
7749 case CP0_REGISTER_25
:
7751 case CP0_REG25__PERFCTL0
:
7752 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_Performance0
));
7753 register_name
= "Performance0";
7755 case CP0_REG25__PERFCNT0
:
7756 /* gen_helper_dmfc0_performance1(arg); */
7757 register_name
= "Performance1";
7758 goto cp0_unimplemented
;
7759 case CP0_REG25__PERFCTL1
:
7760 /* gen_helper_dmfc0_performance2(arg); */
7761 register_name
= "Performance2";
7762 goto cp0_unimplemented
;
7763 case CP0_REG25__PERFCNT1
:
7764 /* gen_helper_dmfc0_performance3(arg); */
7765 register_name
= "Performance3";
7766 goto cp0_unimplemented
;
7767 case CP0_REG25__PERFCTL2
:
7768 /* gen_helper_dmfc0_performance4(arg); */
7769 register_name
= "Performance4";
7770 goto cp0_unimplemented
;
7771 case CP0_REG25__PERFCNT2
:
7772 /* gen_helper_dmfc0_performance5(arg); */
7773 register_name
= "Performance5";
7774 goto cp0_unimplemented
;
7775 case CP0_REG25__PERFCTL3
:
7776 /* gen_helper_dmfc0_performance6(arg); */
7777 register_name
= "Performance6";
7778 goto cp0_unimplemented
;
7779 case CP0_REG25__PERFCNT3
:
7780 /* gen_helper_dmfc0_performance7(arg); */
7781 register_name
= "Performance7";
7782 goto cp0_unimplemented
;
7784 goto cp0_unimplemented
;
7787 case CP0_REGISTER_26
:
7789 case CP0_REG26__ERRCTL
:
7790 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_ErrCtl
));
7791 register_name
= "ErrCtl";
7794 goto cp0_unimplemented
;
7797 case CP0_REGISTER_27
:
7800 case CP0_REG27__CACHERR
:
7801 tcg_gen_movi_tl(arg
, 0); /* unimplemented */
7802 register_name
= "CacheErr";
7805 goto cp0_unimplemented
;
7808 case CP0_REGISTER_28
:
7810 case CP0_REG28__TAGLO
:
7811 case CP0_REG28__TAGLO1
:
7812 case CP0_REG28__TAGLO2
:
7813 case CP0_REG28__TAGLO3
:
7814 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_TagLo
));
7815 register_name
= "TagLo";
7817 case CP0_REG28__DATALO
:
7818 case CP0_REG28__DATALO1
:
7819 case CP0_REG28__DATALO2
:
7820 case CP0_REG28__DATALO3
:
7821 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_DataLo
));
7822 register_name
= "DataLo";
7825 goto cp0_unimplemented
;
7828 case CP0_REGISTER_29
:
7830 case CP0_REG29__TAGHI
:
7831 case CP0_REG29__TAGHI1
:
7832 case CP0_REG29__TAGHI2
:
7833 case CP0_REG29__TAGHI3
:
7834 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_TagHi
));
7835 register_name
= "TagHi";
7837 case CP0_REG29__DATAHI
:
7838 case CP0_REG29__DATAHI1
:
7839 case CP0_REG29__DATAHI2
:
7840 case CP0_REG29__DATAHI3
:
7841 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_DataHi
));
7842 register_name
= "DataHi";
7845 goto cp0_unimplemented
;
7848 case CP0_REGISTER_30
:
7850 case CP0_REG30__ERROREPC
:
7851 tcg_gen_ld_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_ErrorEPC
));
7852 register_name
= "ErrorEPC";
7855 goto cp0_unimplemented
;
7858 case CP0_REGISTER_31
:
7860 case CP0_REG31__DESAVE
:
7862 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_DESAVE
));
7863 register_name
= "DESAVE";
7865 case CP0_REG31__KSCRATCH1
:
7866 case CP0_REG31__KSCRATCH2
:
7867 case CP0_REG31__KSCRATCH3
:
7868 case CP0_REG31__KSCRATCH4
:
7869 case CP0_REG31__KSCRATCH5
:
7870 case CP0_REG31__KSCRATCH6
:
7871 CP0_CHECK(ctx
->kscrexist
& (1 << sel
));
7872 tcg_gen_ld_tl(arg
, cpu_env
,
7873 offsetof(CPUMIPSState
, CP0_KScratch
[sel
- 2]));
7874 register_name
= "KScratch";
7877 goto cp0_unimplemented
;
7881 goto cp0_unimplemented
;
7883 trace_mips_translate_c0("dmfc0", register_name
, reg
, sel
);
7887 qemu_log_mask(LOG_UNIMP
, "dmfc0 %s (reg %d sel %d)\n",
7888 register_name
, reg
, sel
);
7889 gen_mfc0_unimplemented(ctx
, arg
);
7892 static void gen_dmtc0(DisasContext
*ctx
, TCGv arg
, int reg
, int sel
)
7894 const char *register_name
= "invalid";
7897 check_insn(ctx
, ISA_MIPS_R1
);
7900 if (tb_cflags(ctx
->base
.tb
) & CF_USE_ICOUNT
) {
7905 case CP0_REGISTER_00
:
7907 case CP0_REG00__INDEX
:
7908 gen_helper_mtc0_index(cpu_env
, arg
);
7909 register_name
= "Index";
7911 case CP0_REG00__MVPCONTROL
:
7912 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7913 gen_helper_mtc0_mvpcontrol(cpu_env
, arg
);
7914 register_name
= "MVPControl";
7916 case CP0_REG00__MVPCONF0
:
7917 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7919 register_name
= "MVPConf0";
7921 case CP0_REG00__MVPCONF1
:
7922 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7924 register_name
= "MVPConf1";
7926 case CP0_REG00__VPCONTROL
:
7929 register_name
= "VPControl";
7932 goto cp0_unimplemented
;
7935 case CP0_REGISTER_01
:
7937 case CP0_REG01__RANDOM
:
7939 register_name
= "Random";
7941 case CP0_REG01__VPECONTROL
:
7942 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7943 gen_helper_mtc0_vpecontrol(cpu_env
, arg
);
7944 register_name
= "VPEControl";
7946 case CP0_REG01__VPECONF0
:
7947 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7948 gen_helper_mtc0_vpeconf0(cpu_env
, arg
);
7949 register_name
= "VPEConf0";
7951 case CP0_REG01__VPECONF1
:
7952 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7953 gen_helper_mtc0_vpeconf1(cpu_env
, arg
);
7954 register_name
= "VPEConf1";
7956 case CP0_REG01__YQMASK
:
7957 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7958 gen_helper_mtc0_yqmask(cpu_env
, arg
);
7959 register_name
= "YQMask";
7961 case CP0_REG01__VPESCHEDULE
:
7962 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7963 tcg_gen_st_tl(arg
, cpu_env
,
7964 offsetof(CPUMIPSState
, CP0_VPESchedule
));
7965 register_name
= "VPESchedule";
7967 case CP0_REG01__VPESCHEFBACK
:
7968 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7969 tcg_gen_st_tl(arg
, cpu_env
,
7970 offsetof(CPUMIPSState
, CP0_VPEScheFBack
));
7971 register_name
= "VPEScheFBack";
7973 case CP0_REG01__VPEOPT
:
7974 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7975 gen_helper_mtc0_vpeopt(cpu_env
, arg
);
7976 register_name
= "VPEOpt";
7979 goto cp0_unimplemented
;
7982 case CP0_REGISTER_02
:
7984 case CP0_REG02__ENTRYLO0
:
7985 gen_helper_dmtc0_entrylo0(cpu_env
, arg
);
7986 register_name
= "EntryLo0";
7988 case CP0_REG02__TCSTATUS
:
7989 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7990 gen_helper_mtc0_tcstatus(cpu_env
, arg
);
7991 register_name
= "TCStatus";
7993 case CP0_REG02__TCBIND
:
7994 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
7995 gen_helper_mtc0_tcbind(cpu_env
, arg
);
7996 register_name
= "TCBind";
7998 case CP0_REG02__TCRESTART
:
7999 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
8000 gen_helper_mtc0_tcrestart(cpu_env
, arg
);
8001 register_name
= "TCRestart";
8003 case CP0_REG02__TCHALT
:
8004 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
8005 gen_helper_mtc0_tchalt(cpu_env
, arg
);
8006 register_name
= "TCHalt";
8008 case CP0_REG02__TCCONTEXT
:
8009 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
8010 gen_helper_mtc0_tccontext(cpu_env
, arg
);
8011 register_name
= "TCContext";
8013 case CP0_REG02__TCSCHEDULE
:
8014 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
8015 gen_helper_mtc0_tcschedule(cpu_env
, arg
);
8016 register_name
= "TCSchedule";
8018 case CP0_REG02__TCSCHEFBACK
:
8019 CP0_CHECK(ctx
->insn_flags
& ASE_MT
);
8020 gen_helper_mtc0_tcschefback(cpu_env
, arg
);
8021 register_name
= "TCScheFBack";
8024 goto cp0_unimplemented
;
8027 case CP0_REGISTER_03
:
8029 case CP0_REG03__ENTRYLO1
:
8030 gen_helper_dmtc0_entrylo1(cpu_env
, arg
);
8031 register_name
= "EntryLo1";
8033 case CP0_REG03__GLOBALNUM
:
8036 register_name
= "GlobalNumber";
8039 goto cp0_unimplemented
;
8042 case CP0_REGISTER_04
:
8044 case CP0_REG04__CONTEXT
:
8045 gen_helper_mtc0_context(cpu_env
, arg
);
8046 register_name
= "Context";
8048 case CP0_REG04__CONTEXTCONFIG
:
8050 /* gen_helper_dmtc0_contextconfig(arg); */
8051 register_name
= "ContextConfig";
8052 goto cp0_unimplemented
;
8053 case CP0_REG04__USERLOCAL
:
8054 CP0_CHECK(ctx
->ulri
);
8055 tcg_gen_st_tl(arg
, cpu_env
,
8056 offsetof(CPUMIPSState
, active_tc
.CP0_UserLocal
));
8057 register_name
= "UserLocal";
8059 case CP0_REG04__MMID
:
8061 gen_mfc0_load32(arg
, offsetof(CPUMIPSState
, CP0_MemoryMapID
));
8062 register_name
= "MMID";
8065 goto cp0_unimplemented
;
8068 case CP0_REGISTER_05
:
8070 case CP0_REG05__PAGEMASK
:
8071 gen_helper_mtc0_pagemask(cpu_env
, arg
);
8072 register_name
= "PageMask";
8074 case CP0_REG05__PAGEGRAIN
:
8075 check_insn(ctx
, ISA_MIPS_R2
);
8076 gen_helper_mtc0_pagegrain(cpu_env
, arg
);
8077 register_name
= "PageGrain";
8079 case CP0_REG05__SEGCTL0
:
8081 gen_helper_mtc0_segctl0(cpu_env
, arg
);
8082 register_name
= "SegCtl0";
8084 case CP0_REG05__SEGCTL1
:
8086 gen_helper_mtc0_segctl1(cpu_env
, arg
);
8087 register_name
= "SegCtl1";
8089 case CP0_REG05__SEGCTL2
:
8091 gen_helper_mtc0_segctl2(cpu_env
, arg
);
8092 register_name
= "SegCtl2";
8094 case CP0_REG05__PWBASE
:
8096 tcg_gen_st_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_PWBase
));
8097 register_name
= "PWBase";
8099 case CP0_REG05__PWFIELD
:
8101 gen_helper_mtc0_pwfield(cpu_env
, arg
);
8102 register_name
= "PWField";
8104 case CP0_REG05__PWSIZE
:
8106 gen_helper_mtc0_pwsize(cpu_env
, arg
);
8107 register_name
= "PWSize";
8110 goto cp0_unimplemented
;
8113 case CP0_REGISTER_06
:
8115 case CP0_REG06__WIRED
:
8116 gen_helper_mtc0_wired(cpu_env
, arg
);
8117 register_name
= "Wired";
8119 case CP0_REG06__SRSCONF0
:
8120 check_insn(ctx
, ISA_MIPS_R2
);
8121 gen_helper_mtc0_srsconf0(cpu_env
, arg
);
8122 register_name
= "SRSConf0";
8124 case CP0_REG06__SRSCONF1
:
8125 check_insn(ctx
, ISA_MIPS_R2
);
8126 gen_helper_mtc0_srsconf1(cpu_env
, arg
);
8127 register_name
= "SRSConf1";
8129 case CP0_REG06__SRSCONF2
:
8130 check_insn(ctx
, ISA_MIPS_R2
);
8131 gen_helper_mtc0_srsconf2(cpu_env
, arg
);
8132 register_name
= "SRSConf2";
8134 case CP0_REG06__SRSCONF3
:
8135 check_insn(ctx
, ISA_MIPS_R2
);
8136 gen_helper_mtc0_srsconf3(cpu_env
, arg
);
8137 register_name
= "SRSConf3";
8139 case CP0_REG06__SRSCONF4
:
8140 check_insn(ctx
, ISA_MIPS_R2
);
8141 gen_helper_mtc0_srsconf4(cpu_env
, arg
);
8142 register_name
= "SRSConf4";
8144 case CP0_REG06__PWCTL
:
8146 gen_helper_mtc0_pwctl(cpu_env
, arg
);
8147 register_name
= "PWCtl";
8150 goto cp0_unimplemented
;
8153 case CP0_REGISTER_07
:
8155 case CP0_REG07__HWRENA
:
8156 check_insn(ctx
, ISA_MIPS_R2
);
8157 gen_helper_mtc0_hwrena(cpu_env
, arg
);
8158 ctx
->base
.is_jmp
= DISAS_STOP
;
8159 register_name
= "HWREna";
8162 goto cp0_unimplemented
;
8165 case CP0_REGISTER_08
:
8167 case CP0_REG08__BADVADDR
:
8169 register_name
= "BadVAddr";
8171 case CP0_REG08__BADINSTR
:
8173 register_name
= "BadInstr";
8175 case CP0_REG08__BADINSTRP
:
8177 register_name
= "BadInstrP";
8179 case CP0_REG08__BADINSTRX
:
8181 register_name
= "BadInstrX";
8184 goto cp0_unimplemented
;
8187 case CP0_REGISTER_09
:
8189 case CP0_REG09__COUNT
:
8190 gen_helper_mtc0_count(cpu_env
, arg
);
8191 register_name
= "Count";
8193 case CP0_REG09__SAARI
:
8194 CP0_CHECK(ctx
->saar
);
8195 gen_helper_mtc0_saari(cpu_env
, arg
);
8196 register_name
= "SAARI";
8198 case CP0_REG09__SAAR
:
8199 CP0_CHECK(ctx
->saar
);
8200 gen_helper_mtc0_saar(cpu_env
, arg
);
8201 register_name
= "SAAR";
8204 goto cp0_unimplemented
;
8206 /* Stop translation as we may have switched the execution mode */
8207 ctx
->base
.is_jmp
= DISAS_STOP
;
8209 case CP0_REGISTER_10
:
8211 case CP0_REG10__ENTRYHI
:
8212 gen_helper_mtc0_entryhi(cpu_env
, arg
);
8213 register_name
= "EntryHi";
8216 goto cp0_unimplemented
;
8219 case CP0_REGISTER_11
:
8221 case CP0_REG11__COMPARE
:
8222 gen_helper_mtc0_compare(cpu_env
, arg
);
8223 register_name
= "Compare";
8225 /* 6,7 are implementation dependent */
8227 goto cp0_unimplemented
;
8229 /* Stop translation as we may have switched the execution mode */
8230 ctx
->base
.is_jmp
= DISAS_STOP
;
8232 case CP0_REGISTER_12
:
8234 case CP0_REG12__STATUS
:
8235 save_cpu_state(ctx
, 1);
8236 gen_helper_mtc0_status(cpu_env
, arg
);
8237 /* DISAS_STOP isn't good enough here, hflags may have changed. */
8238 gen_save_pc(ctx
->base
.pc_next
+ 4);
8239 ctx
->base
.is_jmp
= DISAS_EXIT
;
8240 register_name
= "Status";
8242 case CP0_REG12__INTCTL
:
8243 check_insn(ctx
, ISA_MIPS_R2
);
8244 gen_helper_mtc0_intctl(cpu_env
, arg
);
8245 /* Stop translation as we may have switched the execution mode */
8246 ctx
->base
.is_jmp
= DISAS_STOP
;
8247 register_name
= "IntCtl";
8249 case CP0_REG12__SRSCTL
:
8250 check_insn(ctx
, ISA_MIPS_R2
);
8251 gen_helper_mtc0_srsctl(cpu_env
, arg
);
8252 /* Stop translation as we may have switched the execution mode */
8253 ctx
->base
.is_jmp
= DISAS_STOP
;
8254 register_name
= "SRSCtl";
8256 case CP0_REG12__SRSMAP
:
8257 check_insn(ctx
, ISA_MIPS_R2
);
8258 gen_mtc0_store32(arg
, offsetof(CPUMIPSState
, CP0_SRSMap
));
8259 /* Stop translation as we may have switched the execution mode */
8260 ctx
->base
.is_jmp
= DISAS_STOP
;
8261 register_name
= "SRSMap";
8264 goto cp0_unimplemented
;
8267 case CP0_REGISTER_13
:
8269 case CP0_REG13__CAUSE
:
8270 save_cpu_state(ctx
, 1);
8271 gen_helper_mtc0_cause(cpu_env
, arg
);
8273 * Stop translation as we may have triggered an interrupt.
8274 * DISAS_STOP isn't sufficient, we need to ensure we break out of
8275 * translated code to check for pending interrupts.
8277 gen_save_pc(ctx
->base
.pc_next
+ 4);
8278 ctx
->base
.is_jmp
= DISAS_EXIT
;
8279 register_name
= "Cause";
8282 goto cp0_unimplemented
;
8285 case CP0_REGISTER_14
:
8287 case CP0_REG14__EPC
:
8288 tcg_gen_st_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_EPC
));
8289 register_name
= "EPC";
8292 goto cp0_unimplemented
;
8295 case CP0_REGISTER_15
:
8297 case CP0_REG15__PRID
:
8299 register_name
= "PRid";
8301 case CP0_REG15__EBASE
:
8302 check_insn(ctx
, ISA_MIPS_R2
);
8303 gen_helper_mtc0_ebase(cpu_env
, arg
);
8304 register_name
= "EBase";
8307 goto cp0_unimplemented
;
8310 case CP0_REGISTER_16
:
8312 case CP0_REG16__CONFIG
:
8313 gen_helper_mtc0_config0(cpu_env
, arg
);
8314 register_name
= "Config";
8315 /* Stop translation as we may have switched the execution mode */
8316 ctx
->base
.is_jmp
= DISAS_STOP
;
8318 case CP0_REG16__CONFIG1
:
8319 /* ignored, read only */
8320 register_name
= "Config1";
8322 case CP0_REG16__CONFIG2
:
8323 gen_helper_mtc0_config2(cpu_env
, arg
);
8324 register_name
= "Config2";
8325 /* Stop translation as we may have switched the execution mode */
8326 ctx
->base
.is_jmp
= DISAS_STOP
;
8328 case CP0_REG16__CONFIG3
:
8329 gen_helper_mtc0_config3(cpu_env
, arg
);
8330 register_name
= "Config3";
8331 /* Stop translation as we may have switched the execution mode */
8332 ctx
->base
.is_jmp
= DISAS_STOP
;
8334 case CP0_REG16__CONFIG4
:
8335 /* currently ignored */
8336 register_name
= "Config4";
8338 case CP0_REG16__CONFIG5
:
8339 gen_helper_mtc0_config5(cpu_env
, arg
);
8340 register_name
= "Config5";
8341 /* Stop translation as we may have switched the execution mode */
8342 ctx
->base
.is_jmp
= DISAS_STOP
;
8344 /* 6,7 are implementation dependent */
8346 register_name
= "Invalid config selector";
8347 goto cp0_unimplemented
;
8350 case CP0_REGISTER_17
:
8352 case CP0_REG17__LLADDR
:
8353 gen_helper_mtc0_lladdr(cpu_env
, arg
);
8354 register_name
= "LLAddr";
8356 case CP0_REG17__MAAR
:
8357 CP0_CHECK(ctx
->mrp
);
8358 gen_helper_mtc0_maar(cpu_env
, arg
);
8359 register_name
= "MAAR";
8361 case CP0_REG17__MAARI
:
8362 CP0_CHECK(ctx
->mrp
);
8363 gen_helper_mtc0_maari(cpu_env
, arg
);
8364 register_name
= "MAARI";
8367 goto cp0_unimplemented
;
8370 case CP0_REGISTER_18
:
8372 case CP0_REG18__WATCHLO0
:
8373 case CP0_REG18__WATCHLO1
:
8374 case CP0_REG18__WATCHLO2
:
8375 case CP0_REG18__WATCHLO3
:
8376 case CP0_REG18__WATCHLO4
:
8377 case CP0_REG18__WATCHLO5
:
8378 case CP0_REG18__WATCHLO6
:
8379 case CP0_REG18__WATCHLO7
:
8380 CP0_CHECK(ctx
->CP0_Config1
& (1 << CP0C1_WR
));
8381 gen_helper_0e1i(mtc0_watchlo
, arg
, sel
);
8382 register_name
= "WatchLo";
8385 goto cp0_unimplemented
;
8388 case CP0_REGISTER_19
:
8390 case CP0_REG19__WATCHHI0
:
8391 case CP0_REG19__WATCHHI1
:
8392 case CP0_REG19__WATCHHI2
:
8393 case CP0_REG19__WATCHHI3
:
8394 case CP0_REG19__WATCHHI4
:
8395 case CP0_REG19__WATCHHI5
:
8396 case CP0_REG19__WATCHHI6
:
8397 case CP0_REG19__WATCHHI7
:
8398 CP0_CHECK(ctx
->CP0_Config1
& (1 << CP0C1_WR
));
8399 gen_helper_0e1i(mtc0_watchhi
, arg
, sel
);
8400 register_name
= "WatchHi";
8403 goto cp0_unimplemented
;
8406 case CP0_REGISTER_20
:
8408 case CP0_REG20__XCONTEXT
:
8409 check_insn(ctx
, ISA_MIPS3
);
8410 gen_helper_mtc0_xcontext(cpu_env
, arg
);
8411 register_name
= "XContext";
8414 goto cp0_unimplemented
;
8417 case CP0_REGISTER_21
:
8418 /* Officially reserved, but sel 0 is used for R1x000 framemask */
8419 CP0_CHECK(!(ctx
->insn_flags
& ISA_MIPS_R6
));
8422 gen_helper_mtc0_framemask(cpu_env
, arg
);
8423 register_name
= "Framemask";
8426 goto cp0_unimplemented
;
8429 case CP0_REGISTER_22
:
8431 register_name
= "Diagnostic"; /* implementation dependent */
8433 case CP0_REGISTER_23
:
8435 case CP0_REG23__DEBUG
:
8436 gen_helper_mtc0_debug(cpu_env
, arg
); /* EJTAG support */
8437 /* DISAS_STOP isn't good enough here, hflags may have changed. */
8438 gen_save_pc(ctx
->base
.pc_next
+ 4);
8439 ctx
->base
.is_jmp
= DISAS_EXIT
;
8440 register_name
= "Debug";
8442 case CP0_REG23__TRACECONTROL
:
8443 /* PDtrace support */
8444 /* gen_helper_mtc0_tracecontrol(cpu_env, arg); */
8445 /* Stop translation as we may have switched the execution mode */
8446 ctx
->base
.is_jmp
= DISAS_STOP
;
8447 register_name
= "TraceControl";
8448 goto cp0_unimplemented
;
8449 case CP0_REG23__TRACECONTROL2
:
8450 /* PDtrace support */
8451 /* gen_helper_mtc0_tracecontrol2(cpu_env, arg); */
8452 /* Stop translation as we may have switched the execution mode */
8453 ctx
->base
.is_jmp
= DISAS_STOP
;
8454 register_name
= "TraceControl2";
8455 goto cp0_unimplemented
;
8456 case CP0_REG23__USERTRACEDATA1
:
8457 /* PDtrace support */
8458 /* gen_helper_mtc0_usertracedata1(cpu_env, arg);*/
8459 /* Stop translation as we may have switched the execution mode */
8460 ctx
->base
.is_jmp
= DISAS_STOP
;
8461 register_name
= "UserTraceData1";
8462 goto cp0_unimplemented
;
8463 case CP0_REG23__TRACEIBPC
:
8464 /* PDtrace support */
8465 /* gen_helper_mtc0_traceibpc(cpu_env, arg); */
8466 /* Stop translation as we may have switched the execution mode */
8467 ctx
->base
.is_jmp
= DISAS_STOP
;
8468 register_name
= "TraceIBPC";
8469 goto cp0_unimplemented
;
8470 case CP0_REG23__TRACEDBPC
:
8471 /* PDtrace support */
8472 /* gen_helper_mtc0_tracedbpc(cpu_env, arg); */
8473 /* Stop translation as we may have switched the execution mode */
8474 ctx
->base
.is_jmp
= DISAS_STOP
;
8475 register_name
= "TraceDBPC";
8476 goto cp0_unimplemented
;
8478 goto cp0_unimplemented
;
8481 case CP0_REGISTER_24
:
8483 case CP0_REG24__DEPC
:
8485 tcg_gen_st_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_DEPC
));
8486 register_name
= "DEPC";
8489 goto cp0_unimplemented
;
8492 case CP0_REGISTER_25
:
8494 case CP0_REG25__PERFCTL0
:
8495 gen_helper_mtc0_performance0(cpu_env
, arg
);
8496 register_name
= "Performance0";
8498 case CP0_REG25__PERFCNT0
:
8499 /* gen_helper_mtc0_performance1(cpu_env, arg); */
8500 register_name
= "Performance1";
8501 goto cp0_unimplemented
;
8502 case CP0_REG25__PERFCTL1
:
8503 /* gen_helper_mtc0_performance2(cpu_env, arg); */
8504 register_name
= "Performance2";
8505 goto cp0_unimplemented
;
8506 case CP0_REG25__PERFCNT1
:
8507 /* gen_helper_mtc0_performance3(cpu_env, arg); */
8508 register_name
= "Performance3";
8509 goto cp0_unimplemented
;
8510 case CP0_REG25__PERFCTL2
:
8511 /* gen_helper_mtc0_performance4(cpu_env, arg); */
8512 register_name
= "Performance4";
8513 goto cp0_unimplemented
;
8514 case CP0_REG25__PERFCNT2
:
8515 /* gen_helper_mtc0_performance5(cpu_env, arg); */
8516 register_name
= "Performance5";
8517 goto cp0_unimplemented
;
8518 case CP0_REG25__PERFCTL3
:
8519 /* gen_helper_mtc0_performance6(cpu_env, arg); */
8520 register_name
= "Performance6";
8521 goto cp0_unimplemented
;
8522 case CP0_REG25__PERFCNT3
:
8523 /* gen_helper_mtc0_performance7(cpu_env, arg); */
8524 register_name
= "Performance7";
8525 goto cp0_unimplemented
;
8527 goto cp0_unimplemented
;
8530 case CP0_REGISTER_26
:
8532 case CP0_REG26__ERRCTL
:
8533 gen_helper_mtc0_errctl(cpu_env
, arg
);
8534 ctx
->base
.is_jmp
= DISAS_STOP
;
8535 register_name
= "ErrCtl";
8538 goto cp0_unimplemented
;
8541 case CP0_REGISTER_27
:
8543 case CP0_REG27__CACHERR
:
8545 register_name
= "CacheErr";
8548 goto cp0_unimplemented
;
8551 case CP0_REGISTER_28
:
8553 case CP0_REG28__TAGLO
:
8554 case CP0_REG28__TAGLO1
:
8555 case CP0_REG28__TAGLO2
:
8556 case CP0_REG28__TAGLO3
:
8557 gen_helper_mtc0_taglo(cpu_env
, arg
);
8558 register_name
= "TagLo";
8560 case CP0_REG28__DATALO
:
8561 case CP0_REG28__DATALO1
:
8562 case CP0_REG28__DATALO2
:
8563 case CP0_REG28__DATALO3
:
8564 gen_helper_mtc0_datalo(cpu_env
, arg
);
8565 register_name
= "DataLo";
8568 goto cp0_unimplemented
;
8571 case CP0_REGISTER_29
:
8573 case CP0_REG29__TAGHI
:
8574 case CP0_REG29__TAGHI1
:
8575 case CP0_REG29__TAGHI2
:
8576 case CP0_REG29__TAGHI3
:
8577 gen_helper_mtc0_taghi(cpu_env
, arg
);
8578 register_name
= "TagHi";
8580 case CP0_REG29__DATAHI
:
8581 case CP0_REG29__DATAHI1
:
8582 case CP0_REG29__DATAHI2
:
8583 case CP0_REG29__DATAHI3
:
8584 gen_helper_mtc0_datahi(cpu_env
, arg
);
8585 register_name
= "DataHi";
8588 register_name
= "invalid sel";
8589 goto cp0_unimplemented
;
8592 case CP0_REGISTER_30
:
8594 case CP0_REG30__ERROREPC
:
8595 tcg_gen_st_tl(arg
, cpu_env
, offsetof(CPUMIPSState
, CP0_ErrorEPC
));
8596 register_name
= "ErrorEPC";
8599 goto cp0_unimplemented
;
8602 case CP0_REGISTER_31
:
8604 case CP0_REG31__DESAVE
:
8606 gen_mtc0_store32(arg
, offsetof(CPUMIPSState
, CP0_DESAVE
));
8607 register_name
= "DESAVE";
8609 case CP0_REG31__KSCRATCH1
:
8610 case CP0_REG31__KSCRATCH2
:
8611 case CP0_REG31__KSCRATCH3
:
8612 case CP0_REG31__KSCRATCH4
:
8613 case CP0_REG31__KSCRATCH5
:
8614 case CP0_REG31__KSCRATCH6
:
8615 CP0_CHECK(ctx
->kscrexist
& (1 << sel
));
8616 tcg_gen_st_tl(arg
, cpu_env
,
8617 offsetof(CPUMIPSState
, CP0_KScratch
[sel
- 2]));
8618 register_name
= "KScratch";
8621 goto cp0_unimplemented
;
8625 goto cp0_unimplemented
;
8627 trace_mips_translate_c0("dmtc0", register_name
, reg
, sel
);
8629 /* For simplicity assume that all writes can cause interrupts. */
8630 if (tb_cflags(ctx
->base
.tb
) & CF_USE_ICOUNT
) {
8632 * DISAS_STOP isn't sufficient, we need to ensure we break out of
8633 * translated code to check for pending interrupts.
8635 gen_save_pc(ctx
->base
.pc_next
+ 4);
8636 ctx
->base
.is_jmp
= DISAS_EXIT
;
8641 qemu_log_mask(LOG_UNIMP
, "dmtc0 %s (reg %d sel %d)\n",
8642 register_name
, reg
, sel
);
8644 #endif /* TARGET_MIPS64 */
8646 static void gen_mftr(CPUMIPSState
*env
, DisasContext
*ctx
, int rt
, int rd
,
8647 int u
, int sel
, int h
)
8649 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
8650 TCGv t0
= tcg_temp_local_new();
8652 if ((env
->CP0_VPEConf0
& (1 << CP0VPEC0_MVP
)) == 0 &&
8653 ((env
->tcs
[other_tc
].CP0_TCBind
& (0xf << CP0TCBd_CurVPE
)) !=
8654 (env
->active_tc
.CP0_TCBind
& (0xf << CP0TCBd_CurVPE
)))) {
8655 tcg_gen_movi_tl(t0
, -1);
8656 } else if ((env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
)) >
8657 (env
->mvp
->CP0_MVPConf0
& (0xff << CP0MVPC0_PTC
))) {
8658 tcg_gen_movi_tl(t0
, -1);
8659 } else if (u
== 0) {
8664 gen_helper_mftc0_vpecontrol(t0
, cpu_env
);
8667 gen_helper_mftc0_vpeconf0(t0
, cpu_env
);
8677 gen_helper_mftc0_tcstatus(t0
, cpu_env
);
8680 gen_helper_mftc0_tcbind(t0
, cpu_env
);
8683 gen_helper_mftc0_tcrestart(t0
, cpu_env
);
8686 gen_helper_mftc0_tchalt(t0
, cpu_env
);
8689 gen_helper_mftc0_tccontext(t0
, cpu_env
);
8692 gen_helper_mftc0_tcschedule(t0
, cpu_env
);
8695 gen_helper_mftc0_tcschefback(t0
, cpu_env
);
8698 gen_mfc0(ctx
, t0
, rt
, sel
);
8705 gen_helper_mftc0_entryhi(t0
, cpu_env
);
8708 gen_mfc0(ctx
, t0
, rt
, sel
);
8715 gen_helper_mftc0_status(t0
, cpu_env
);
8718 gen_mfc0(ctx
, t0
, rt
, sel
);
8725 gen_helper_mftc0_cause(t0
, cpu_env
);
8735 gen_helper_mftc0_epc(t0
, cpu_env
);
8745 gen_helper_mftc0_ebase(t0
, cpu_env
);
8762 gen_helper_mftc0_configx(t0
, cpu_env
, tcg_const_tl(sel
));
8772 gen_helper_mftc0_debug(t0
, cpu_env
);
8775 gen_mfc0(ctx
, t0
, rt
, sel
);
8780 gen_mfc0(ctx
, t0
, rt
, sel
);
8784 /* GPR registers. */
8786 gen_helper_1e0i(mftgpr
, t0
, rt
);
8788 /* Auxiliary CPU registers */
8792 gen_helper_1e0i(mftlo
, t0
, 0);
8795 gen_helper_1e0i(mfthi
, t0
, 0);
8798 gen_helper_1e0i(mftacx
, t0
, 0);
8801 gen_helper_1e0i(mftlo
, t0
, 1);
8804 gen_helper_1e0i(mfthi
, t0
, 1);
8807 gen_helper_1e0i(mftacx
, t0
, 1);
8810 gen_helper_1e0i(mftlo
, t0
, 2);
8813 gen_helper_1e0i(mfthi
, t0
, 2);
8816 gen_helper_1e0i(mftacx
, t0
, 2);
8819 gen_helper_1e0i(mftlo
, t0
, 3);
8822 gen_helper_1e0i(mfthi
, t0
, 3);
8825 gen_helper_1e0i(mftacx
, t0
, 3);
8828 gen_helper_mftdsp(t0
, cpu_env
);
8834 /* Floating point (COP1). */
8836 /* XXX: For now we support only a single FPU context. */
8838 TCGv_i32 fp0
= tcg_temp_new_i32();
8840 gen_load_fpr32(ctx
, fp0
, rt
);
8841 tcg_gen_ext_i32_tl(t0
, fp0
);
8842 tcg_temp_free_i32(fp0
);
8844 TCGv_i32 fp0
= tcg_temp_new_i32();
8846 gen_load_fpr32h(ctx
, fp0
, rt
);
8847 tcg_gen_ext_i32_tl(t0
, fp0
);
8848 tcg_temp_free_i32(fp0
);
8852 /* XXX: For now we support only a single FPU context. */
8853 gen_helper_1e0i(cfc1
, t0
, rt
);
8855 /* COP2: Not implemented. */
8863 trace_mips_translate_tr("mftr", rt
, u
, sel
, h
);
8864 gen_store_gpr(t0
, rd
);
8870 LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt
, u
, sel
, h
);
8871 gen_reserved_instruction(ctx
);
8874 static void gen_mttr(CPUMIPSState
*env
, DisasContext
*ctx
, int rd
, int rt
,
8875 int u
, int sel
, int h
)
8877 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
8878 TCGv t0
= tcg_temp_local_new();
8880 gen_load_gpr(t0
, rt
);
8881 if ((env
->CP0_VPEConf0
& (1 << CP0VPEC0_MVP
)) == 0 &&
8882 ((env
->tcs
[other_tc
].CP0_TCBind
& (0xf << CP0TCBd_CurVPE
)) !=
8883 (env
->active_tc
.CP0_TCBind
& (0xf << CP0TCBd_CurVPE
)))) {
8886 } else if ((env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
)) >
8887 (env
->mvp
->CP0_MVPConf0
& (0xff << CP0MVPC0_PTC
))) {
8890 } else if (u
== 0) {
8895 gen_helper_mttc0_vpecontrol(cpu_env
, t0
);
8898 gen_helper_mttc0_vpeconf0(cpu_env
, t0
);
8908 gen_helper_mttc0_tcstatus(cpu_env
, t0
);
8911 gen_helper_mttc0_tcbind(cpu_env
, t0
);
8914 gen_helper_mttc0_tcrestart(cpu_env
, t0
);
8917 gen_helper_mttc0_tchalt(cpu_env
, t0
);
8920 gen_helper_mttc0_tccontext(cpu_env
, t0
);
8923 gen_helper_mttc0_tcschedule(cpu_env
, t0
);
8926 gen_helper_mttc0_tcschefback(cpu_env
, t0
);
8929 gen_mtc0(ctx
, t0
, rd
, sel
);
8936 gen_helper_mttc0_entryhi(cpu_env
, t0
);
8939 gen_mtc0(ctx
, t0
, rd
, sel
);
8946 gen_helper_mttc0_status(cpu_env
, t0
);
8949 gen_mtc0(ctx
, t0
, rd
, sel
);
8956 gen_helper_mttc0_cause(cpu_env
, t0
);
8966 gen_helper_mttc0_ebase(cpu_env
, t0
);
8976 gen_helper_mttc0_debug(cpu_env
, t0
);
8979 gen_mtc0(ctx
, t0
, rd
, sel
);
8984 gen_mtc0(ctx
, t0
, rd
, sel
);
8988 /* GPR registers. */
8990 gen_helper_0e1i(mttgpr
, t0
, rd
);
8992 /* Auxiliary CPU registers */
8996 gen_helper_0e1i(mttlo
, t0
, 0);
8999 gen_helper_0e1i(mtthi
, t0
, 0);
9002 gen_helper_0e1i(mttacx
, t0
, 0);
9005 gen_helper_0e1i(mttlo
, t0
, 1);
9008 gen_helper_0e1i(mtthi
, t0
, 1);
9011 gen_helper_0e1i(mttacx
, t0
, 1);
9014 gen_helper_0e1i(mttlo
, t0
, 2);
9017 gen_helper_0e1i(mtthi
, t0
, 2);
9020 gen_helper_0e1i(mttacx
, t0
, 2);
9023 gen_helper_0e1i(mttlo
, t0
, 3);
9026 gen_helper_0e1i(mtthi
, t0
, 3);
9029 gen_helper_0e1i(mttacx
, t0
, 3);
9032 gen_helper_mttdsp(cpu_env
, t0
);
9038 /* Floating point (COP1). */
9040 /* XXX: For now we support only a single FPU context. */
9042 TCGv_i32 fp0
= tcg_temp_new_i32();
9044 tcg_gen_trunc_tl_i32(fp0
, t0
);
9045 gen_store_fpr32(ctx
, fp0
, rd
);
9046 tcg_temp_free_i32(fp0
);
9048 TCGv_i32 fp0
= tcg_temp_new_i32();
9050 tcg_gen_trunc_tl_i32(fp0
, t0
);
9051 gen_store_fpr32h(ctx
, fp0
, rd
);
9052 tcg_temp_free_i32(fp0
);
9056 /* XXX: For now we support only a single FPU context. */
9057 gen_helper_0e2i(ctc1
, t0
, tcg_constant_i32(rd
), rt
);
9058 /* Stop translation as we may have changed hflags */
9059 ctx
->base
.is_jmp
= DISAS_STOP
;
9061 /* COP2: Not implemented. */
9069 trace_mips_translate_tr("mttr", rd
, u
, sel
, h
);
9075 LOG_DISAS("mttr (reg %d u %d sel %d h %d)\n", rd
, u
, sel
, h
);
9076 gen_reserved_instruction(ctx
);
9079 static void gen_cp0(CPUMIPSState
*env
, DisasContext
*ctx
, uint32_t opc
,
9082 const char *opn
= "ldst";
9084 check_cp0_enabled(ctx
);
9091 gen_mfc0(ctx
, cpu_gpr
[rt
], rd
, ctx
->opcode
& 0x7);
9096 TCGv t0
= tcg_temp_new();
9098 gen_load_gpr(t0
, rt
);
9099 gen_mtc0(ctx
, t0
, rd
, ctx
->opcode
& 0x7);
9104 #if defined(TARGET_MIPS64)
9106 check_insn(ctx
, ISA_MIPS3
);
9111 gen_dmfc0(ctx
, cpu_gpr
[rt
], rd
, ctx
->opcode
& 0x7);
9115 check_insn(ctx
, ISA_MIPS3
);
9117 TCGv t0
= tcg_temp_new();
9119 gen_load_gpr(t0
, rt
);
9120 gen_dmtc0(ctx
, t0
, rd
, ctx
->opcode
& 0x7);
9132 gen_mfhc0(ctx
, cpu_gpr
[rt
], rd
, ctx
->opcode
& 0x7);
9138 TCGv t0
= tcg_temp_new();
9139 gen_load_gpr(t0
, rt
);
9140 gen_mthc0(ctx
, t0
, rd
, ctx
->opcode
& 0x7);
9146 check_cp0_enabled(ctx
);
9151 gen_mftr(env
, ctx
, rt
, rd
, (ctx
->opcode
>> 5) & 1,
9152 ctx
->opcode
& 0x7, (ctx
->opcode
>> 4) & 1);
9156 check_cp0_enabled(ctx
);
9157 gen_mttr(env
, ctx
, rd
, rt
, (ctx
->opcode
>> 5) & 1,
9158 ctx
->opcode
& 0x7, (ctx
->opcode
>> 4) & 1);
9163 if (!env
->tlb
->helper_tlbwi
) {
9166 gen_helper_tlbwi(cpu_env
);
9171 if (!env
->tlb
->helper_tlbinv
) {
9174 gen_helper_tlbinv(cpu_env
);
9175 } /* treat as nop if TLBINV not supported */
9180 if (!env
->tlb
->helper_tlbinvf
) {
9183 gen_helper_tlbinvf(cpu_env
);
9184 } /* treat as nop if TLBINV not supported */
9188 if (!env
->tlb
->helper_tlbwr
) {
9191 gen_helper_tlbwr(cpu_env
);
9195 if (!env
->tlb
->helper_tlbp
) {
9198 gen_helper_tlbp(cpu_env
);
9202 if (!env
->tlb
->helper_tlbr
) {
9205 gen_helper_tlbr(cpu_env
);
9207 case OPC_ERET
: /* OPC_ERETNC */
9208 if ((ctx
->insn_flags
& ISA_MIPS_R6
) &&
9209 (ctx
->hflags
& MIPS_HFLAG_BMASK
)) {
9212 int bit_shift
= (ctx
->hflags
& MIPS_HFLAG_M16
) ? 16 : 6;
9213 if (ctx
->opcode
& (1 << bit_shift
)) {
9216 check_insn(ctx
, ISA_MIPS_R5
);
9217 gen_helper_eretnc(cpu_env
);
9221 check_insn(ctx
, ISA_MIPS2
);
9222 gen_helper_eret(cpu_env
);
9224 ctx
->base
.is_jmp
= DISAS_EXIT
;
9229 check_insn(ctx
, ISA_MIPS_R1
);
9230 if ((ctx
->insn_flags
& ISA_MIPS_R6
) &&
9231 (ctx
->hflags
& MIPS_HFLAG_BMASK
)) {
9234 if (!(ctx
->hflags
& MIPS_HFLAG_DM
)) {
9236 gen_reserved_instruction(ctx
);
9238 gen_helper_deret(cpu_env
);
9239 ctx
->base
.is_jmp
= DISAS_EXIT
;
9244 check_insn(ctx
, ISA_MIPS3
| ISA_MIPS_R1
);
9245 if ((ctx
->insn_flags
& ISA_MIPS_R6
) &&
9246 (ctx
->hflags
& MIPS_HFLAG_BMASK
)) {
9249 /* If we get an exception, we want to restart at next instruction */
9250 ctx
->base
.pc_next
+= 4;
9251 save_cpu_state(ctx
, 1);
9252 ctx
->base
.pc_next
-= 4;
9253 gen_helper_wait(cpu_env
);
9254 ctx
->base
.is_jmp
= DISAS_NORETURN
;
9259 gen_reserved_instruction(ctx
);
9262 (void)opn
; /* avoid a compiler warning */
9264 #endif /* !CONFIG_USER_ONLY */
9266 /* CP1 Branches (before delay slot) */
9267 static void gen_compute_branch1(DisasContext
*ctx
, uint32_t op
,
9268 int32_t cc
, int32_t offset
)
9270 target_ulong btarget
;
9271 TCGv_i32 t0
= tcg_temp_new_i32();
9273 if ((ctx
->insn_flags
& ISA_MIPS_R6
) && (ctx
->hflags
& MIPS_HFLAG_BMASK
)) {
9274 gen_reserved_instruction(ctx
);
9279 check_insn(ctx
, ISA_MIPS4
| ISA_MIPS_R1
);
9282 btarget
= ctx
->base
.pc_next
+ 4 + offset
;
9286 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
9287 tcg_gen_not_i32(t0
, t0
);
9288 tcg_gen_andi_i32(t0
, t0
, 1);
9289 tcg_gen_extu_i32_tl(bcond
, t0
);
9292 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
9293 tcg_gen_not_i32(t0
, t0
);
9294 tcg_gen_andi_i32(t0
, t0
, 1);
9295 tcg_gen_extu_i32_tl(bcond
, t0
);
9298 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
9299 tcg_gen_andi_i32(t0
, t0
, 1);
9300 tcg_gen_extu_i32_tl(bcond
, t0
);
9303 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
9304 tcg_gen_andi_i32(t0
, t0
, 1);
9305 tcg_gen_extu_i32_tl(bcond
, t0
);
9307 ctx
->hflags
|= MIPS_HFLAG_BL
;
9311 TCGv_i32 t1
= tcg_temp_new_i32();
9312 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
9313 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+ 1));
9314 tcg_gen_nand_i32(t0
, t0
, t1
);
9315 tcg_temp_free_i32(t1
);
9316 tcg_gen_andi_i32(t0
, t0
, 1);
9317 tcg_gen_extu_i32_tl(bcond
, t0
);
9322 TCGv_i32 t1
= tcg_temp_new_i32();
9323 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
9324 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+ 1));
9325 tcg_gen_or_i32(t0
, t0
, t1
);
9326 tcg_temp_free_i32(t1
);
9327 tcg_gen_andi_i32(t0
, t0
, 1);
9328 tcg_gen_extu_i32_tl(bcond
, t0
);
9333 TCGv_i32 t1
= tcg_temp_new_i32();
9334 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
9335 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+ 1));
9336 tcg_gen_and_i32(t0
, t0
, t1
);
9337 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+ 2));
9338 tcg_gen_and_i32(t0
, t0
, t1
);
9339 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+ 3));
9340 tcg_gen_nand_i32(t0
, t0
, t1
);
9341 tcg_temp_free_i32(t1
);
9342 tcg_gen_andi_i32(t0
, t0
, 1);
9343 tcg_gen_extu_i32_tl(bcond
, t0
);
9348 TCGv_i32 t1
= tcg_temp_new_i32();
9349 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
9350 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+ 1));
9351 tcg_gen_or_i32(t0
, t0
, t1
);
9352 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+ 2));
9353 tcg_gen_or_i32(t0
, t0
, t1
);
9354 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+ 3));
9355 tcg_gen_or_i32(t0
, t0
, t1
);
9356 tcg_temp_free_i32(t1
);
9357 tcg_gen_andi_i32(t0
, t0
, 1);
9358 tcg_gen_extu_i32_tl(bcond
, t0
);
9361 ctx
->hflags
|= MIPS_HFLAG_BC
;
9364 MIPS_INVAL("cp1 cond branch");
9365 gen_reserved_instruction(ctx
);
9368 ctx
->btarget
= btarget
;
9369 ctx
->hflags
|= MIPS_HFLAG_BDS32
;
9371 tcg_temp_free_i32(t0
);
9374 /* R6 CP1 Branches */
9375 static void gen_compute_branch1_r6(DisasContext
*ctx
, uint32_t op
,
9376 int32_t ft
, int32_t offset
,
9379 target_ulong btarget
;
9380 TCGv_i64 t0
= tcg_temp_new_i64();
9382 if (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
9383 #ifdef MIPS_DEBUG_DISAS
9384 LOG_DISAS("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx
9385 "\n", ctx
->base
.pc_next
);
9387 gen_reserved_instruction(ctx
);
9391 gen_load_fpr64(ctx
, t0
, ft
);
9392 tcg_gen_andi_i64(t0
, t0
, 1);
9394 btarget
= addr_add(ctx
, ctx
->base
.pc_next
+ 4, offset
);
9398 tcg_gen_xori_i64(t0
, t0
, 1);
9399 ctx
->hflags
|= MIPS_HFLAG_BC
;
9402 /* t0 already set */
9403 ctx
->hflags
|= MIPS_HFLAG_BC
;
9406 MIPS_INVAL("cp1 cond branch");
9407 gen_reserved_instruction(ctx
);
9411 tcg_gen_trunc_i64_tl(bcond
, t0
);
9413 ctx
->btarget
= btarget
;
9415 switch (delayslot_size
) {
9417 ctx
->hflags
|= MIPS_HFLAG_BDS16
;
9420 ctx
->hflags
|= MIPS_HFLAG_BDS32
;
9425 tcg_temp_free_i64(t0
);
9428 /* Coprocessor 1 (FPU) */
9430 #define FOP(func, fmt) (((fmt) << 21) | (func))
9433 OPC_ADD_S
= FOP(0, FMT_S
),
9434 OPC_SUB_S
= FOP(1, FMT_S
),
9435 OPC_MUL_S
= FOP(2, FMT_S
),
9436 OPC_DIV_S
= FOP(3, FMT_S
),
9437 OPC_SQRT_S
= FOP(4, FMT_S
),
9438 OPC_ABS_S
= FOP(5, FMT_S
),
9439 OPC_MOV_S
= FOP(6, FMT_S
),
9440 OPC_NEG_S
= FOP(7, FMT_S
),
9441 OPC_ROUND_L_S
= FOP(8, FMT_S
),
9442 OPC_TRUNC_L_S
= FOP(9, FMT_S
),
9443 OPC_CEIL_L_S
= FOP(10, FMT_S
),
9444 OPC_FLOOR_L_S
= FOP(11, FMT_S
),
9445 OPC_ROUND_W_S
= FOP(12, FMT_S
),
9446 OPC_TRUNC_W_S
= FOP(13, FMT_S
),
9447 OPC_CEIL_W_S
= FOP(14, FMT_S
),
9448 OPC_FLOOR_W_S
= FOP(15, FMT_S
),
9449 OPC_SEL_S
= FOP(16, FMT_S
),
9450 OPC_MOVCF_S
= FOP(17, FMT_S
),
9451 OPC_MOVZ_S
= FOP(18, FMT_S
),
9452 OPC_MOVN_S
= FOP(19, FMT_S
),
9453 OPC_SELEQZ_S
= FOP(20, FMT_S
),
9454 OPC_RECIP_S
= FOP(21, FMT_S
),
9455 OPC_RSQRT_S
= FOP(22, FMT_S
),
9456 OPC_SELNEZ_S
= FOP(23, FMT_S
),
9457 OPC_MADDF_S
= FOP(24, FMT_S
),
9458 OPC_MSUBF_S
= FOP(25, FMT_S
),
9459 OPC_RINT_S
= FOP(26, FMT_S
),
9460 OPC_CLASS_S
= FOP(27, FMT_S
),
9461 OPC_MIN_S
= FOP(28, FMT_S
),
9462 OPC_RECIP2_S
= FOP(28, FMT_S
),
9463 OPC_MINA_S
= FOP(29, FMT_S
),
9464 OPC_RECIP1_S
= FOP(29, FMT_S
),
9465 OPC_MAX_S
= FOP(30, FMT_S
),
9466 OPC_RSQRT1_S
= FOP(30, FMT_S
),
9467 OPC_MAXA_S
= FOP(31, FMT_S
),
9468 OPC_RSQRT2_S
= FOP(31, FMT_S
),
9469 OPC_CVT_D_S
= FOP(33, FMT_S
),
9470 OPC_CVT_W_S
= FOP(36, FMT_S
),
9471 OPC_CVT_L_S
= FOP(37, FMT_S
),
9472 OPC_CVT_PS_S
= FOP(38, FMT_S
),
9473 OPC_CMP_F_S
= FOP(48, FMT_S
),
9474 OPC_CMP_UN_S
= FOP(49, FMT_S
),
9475 OPC_CMP_EQ_S
= FOP(50, FMT_S
),
9476 OPC_CMP_UEQ_S
= FOP(51, FMT_S
),
9477 OPC_CMP_OLT_S
= FOP(52, FMT_S
),
9478 OPC_CMP_ULT_S
= FOP(53, FMT_S
),
9479 OPC_CMP_OLE_S
= FOP(54, FMT_S
),
9480 OPC_CMP_ULE_S
= FOP(55, FMT_S
),
9481 OPC_CMP_SF_S
= FOP(56, FMT_S
),
9482 OPC_CMP_NGLE_S
= FOP(57, FMT_S
),
9483 OPC_CMP_SEQ_S
= FOP(58, FMT_S
),
9484 OPC_CMP_NGL_S
= FOP(59, FMT_S
),
9485 OPC_CMP_LT_S
= FOP(60, FMT_S
),
9486 OPC_CMP_NGE_S
= FOP(61, FMT_S
),
9487 OPC_CMP_LE_S
= FOP(62, FMT_S
),
9488 OPC_CMP_NGT_S
= FOP(63, FMT_S
),
9490 OPC_ADD_D
= FOP(0, FMT_D
),
9491 OPC_SUB_D
= FOP(1, FMT_D
),
9492 OPC_MUL_D
= FOP(2, FMT_D
),
9493 OPC_DIV_D
= FOP(3, FMT_D
),
9494 OPC_SQRT_D
= FOP(4, FMT_D
),
9495 OPC_ABS_D
= FOP(5, FMT_D
),
9496 OPC_MOV_D
= FOP(6, FMT_D
),
9497 OPC_NEG_D
= FOP(7, FMT_D
),
9498 OPC_ROUND_L_D
= FOP(8, FMT_D
),
9499 OPC_TRUNC_L_D
= FOP(9, FMT_D
),
9500 OPC_CEIL_L_D
= FOP(10, FMT_D
),
9501 OPC_FLOOR_L_D
= FOP(11, FMT_D
),
9502 OPC_ROUND_W_D
= FOP(12, FMT_D
),
9503 OPC_TRUNC_W_D
= FOP(13, FMT_D
),
9504 OPC_CEIL_W_D
= FOP(14, FMT_D
),
9505 OPC_FLOOR_W_D
= FOP(15, FMT_D
),
9506 OPC_SEL_D
= FOP(16, FMT_D
),
9507 OPC_MOVCF_D
= FOP(17, FMT_D
),
9508 OPC_MOVZ_D
= FOP(18, FMT_D
),
9509 OPC_MOVN_D
= FOP(19, FMT_D
),
9510 OPC_SELEQZ_D
= FOP(20, FMT_D
),
9511 OPC_RECIP_D
= FOP(21, FMT_D
),
9512 OPC_RSQRT_D
= FOP(22, FMT_D
),
9513 OPC_SELNEZ_D
= FOP(23, FMT_D
),
9514 OPC_MADDF_D
= FOP(24, FMT_D
),
9515 OPC_MSUBF_D
= FOP(25, FMT_D
),
9516 OPC_RINT_D
= FOP(26, FMT_D
),
9517 OPC_CLASS_D
= FOP(27, FMT_D
),
9518 OPC_MIN_D
= FOP(28, FMT_D
),
9519 OPC_RECIP2_D
= FOP(28, FMT_D
),
9520 OPC_MINA_D
= FOP(29, FMT_D
),
9521 OPC_RECIP1_D
= FOP(29, FMT_D
),
9522 OPC_MAX_D
= FOP(30, FMT_D
),
9523 OPC_RSQRT1_D
= FOP(30, FMT_D
),
9524 OPC_MAXA_D
= FOP(31, FMT_D
),
9525 OPC_RSQRT2_D
= FOP(31, FMT_D
),
9526 OPC_CVT_S_D
= FOP(32, FMT_D
),
9527 OPC_CVT_W_D
= FOP(36, FMT_D
),
9528 OPC_CVT_L_D
= FOP(37, FMT_D
),
9529 OPC_CMP_F_D
= FOP(48, FMT_D
),
9530 OPC_CMP_UN_D
= FOP(49, FMT_D
),
9531 OPC_CMP_EQ_D
= FOP(50, FMT_D
),
9532 OPC_CMP_UEQ_D
= FOP(51, FMT_D
),
9533 OPC_CMP_OLT_D
= FOP(52, FMT_D
),
9534 OPC_CMP_ULT_D
= FOP(53, FMT_D
),
9535 OPC_CMP_OLE_D
= FOP(54, FMT_D
),
9536 OPC_CMP_ULE_D
= FOP(55, FMT_D
),
9537 OPC_CMP_SF_D
= FOP(56, FMT_D
),
9538 OPC_CMP_NGLE_D
= FOP(57, FMT_D
),
9539 OPC_CMP_SEQ_D
= FOP(58, FMT_D
),
9540 OPC_CMP_NGL_D
= FOP(59, FMT_D
),
9541 OPC_CMP_LT_D
= FOP(60, FMT_D
),
9542 OPC_CMP_NGE_D
= FOP(61, FMT_D
),
9543 OPC_CMP_LE_D
= FOP(62, FMT_D
),
9544 OPC_CMP_NGT_D
= FOP(63, FMT_D
),
9546 OPC_CVT_S_W
= FOP(32, FMT_W
),
9547 OPC_CVT_D_W
= FOP(33, FMT_W
),
9548 OPC_CVT_S_L
= FOP(32, FMT_L
),
9549 OPC_CVT_D_L
= FOP(33, FMT_L
),
9550 OPC_CVT_PS_PW
= FOP(38, FMT_W
),
9552 OPC_ADD_PS
= FOP(0, FMT_PS
),
9553 OPC_SUB_PS
= FOP(1, FMT_PS
),
9554 OPC_MUL_PS
= FOP(2, FMT_PS
),
9555 OPC_DIV_PS
= FOP(3, FMT_PS
),
9556 OPC_ABS_PS
= FOP(5, FMT_PS
),
9557 OPC_MOV_PS
= FOP(6, FMT_PS
),
9558 OPC_NEG_PS
= FOP(7, FMT_PS
),
9559 OPC_MOVCF_PS
= FOP(17, FMT_PS
),
9560 OPC_MOVZ_PS
= FOP(18, FMT_PS
),
9561 OPC_MOVN_PS
= FOP(19, FMT_PS
),
9562 OPC_ADDR_PS
= FOP(24, FMT_PS
),
9563 OPC_MULR_PS
= FOP(26, FMT_PS
),
9564 OPC_RECIP2_PS
= FOP(28, FMT_PS
),
9565 OPC_RECIP1_PS
= FOP(29, FMT_PS
),
9566 OPC_RSQRT1_PS
= FOP(30, FMT_PS
),
9567 OPC_RSQRT2_PS
= FOP(31, FMT_PS
),
9569 OPC_CVT_S_PU
= FOP(32, FMT_PS
),
9570 OPC_CVT_PW_PS
= FOP(36, FMT_PS
),
9571 OPC_CVT_S_PL
= FOP(40, FMT_PS
),
9572 OPC_PLL_PS
= FOP(44, FMT_PS
),
9573 OPC_PLU_PS
= FOP(45, FMT_PS
),
9574 OPC_PUL_PS
= FOP(46, FMT_PS
),
9575 OPC_PUU_PS
= FOP(47, FMT_PS
),
9576 OPC_CMP_F_PS
= FOP(48, FMT_PS
),
9577 OPC_CMP_UN_PS
= FOP(49, FMT_PS
),
9578 OPC_CMP_EQ_PS
= FOP(50, FMT_PS
),
9579 OPC_CMP_UEQ_PS
= FOP(51, FMT_PS
),
9580 OPC_CMP_OLT_PS
= FOP(52, FMT_PS
),
9581 OPC_CMP_ULT_PS
= FOP(53, FMT_PS
),
9582 OPC_CMP_OLE_PS
= FOP(54, FMT_PS
),
9583 OPC_CMP_ULE_PS
= FOP(55, FMT_PS
),
9584 OPC_CMP_SF_PS
= FOP(56, FMT_PS
),
9585 OPC_CMP_NGLE_PS
= FOP(57, FMT_PS
),
9586 OPC_CMP_SEQ_PS
= FOP(58, FMT_PS
),
9587 OPC_CMP_NGL_PS
= FOP(59, FMT_PS
),
9588 OPC_CMP_LT_PS
= FOP(60, FMT_PS
),
9589 OPC_CMP_NGE_PS
= FOP(61, FMT_PS
),
9590 OPC_CMP_LE_PS
= FOP(62, FMT_PS
),
9591 OPC_CMP_NGT_PS
= FOP(63, FMT_PS
),
9595 R6_OPC_CMP_AF_S
= FOP(0, FMT_W
),
9596 R6_OPC_CMP_UN_S
= FOP(1, FMT_W
),
9597 R6_OPC_CMP_EQ_S
= FOP(2, FMT_W
),
9598 R6_OPC_CMP_UEQ_S
= FOP(3, FMT_W
),
9599 R6_OPC_CMP_LT_S
= FOP(4, FMT_W
),
9600 R6_OPC_CMP_ULT_S
= FOP(5, FMT_W
),
9601 R6_OPC_CMP_LE_S
= FOP(6, FMT_W
),
9602 R6_OPC_CMP_ULE_S
= FOP(7, FMT_W
),
9603 R6_OPC_CMP_SAF_S
= FOP(8, FMT_W
),
9604 R6_OPC_CMP_SUN_S
= FOP(9, FMT_W
),
9605 R6_OPC_CMP_SEQ_S
= FOP(10, FMT_W
),
9606 R6_OPC_CMP_SEUQ_S
= FOP(11, FMT_W
),
9607 R6_OPC_CMP_SLT_S
= FOP(12, FMT_W
),
9608 R6_OPC_CMP_SULT_S
= FOP(13, FMT_W
),
9609 R6_OPC_CMP_SLE_S
= FOP(14, FMT_W
),
9610 R6_OPC_CMP_SULE_S
= FOP(15, FMT_W
),
9611 R6_OPC_CMP_OR_S
= FOP(17, FMT_W
),
9612 R6_OPC_CMP_UNE_S
= FOP(18, FMT_W
),
9613 R6_OPC_CMP_NE_S
= FOP(19, FMT_W
),
9614 R6_OPC_CMP_SOR_S
= FOP(25, FMT_W
),
9615 R6_OPC_CMP_SUNE_S
= FOP(26, FMT_W
),
9616 R6_OPC_CMP_SNE_S
= FOP(27, FMT_W
),
9618 R6_OPC_CMP_AF_D
= FOP(0, FMT_L
),
9619 R6_OPC_CMP_UN_D
= FOP(1, FMT_L
),
9620 R6_OPC_CMP_EQ_D
= FOP(2, FMT_L
),
9621 R6_OPC_CMP_UEQ_D
= FOP(3, FMT_L
),
9622 R6_OPC_CMP_LT_D
= FOP(4, FMT_L
),
9623 R6_OPC_CMP_ULT_D
= FOP(5, FMT_L
),
9624 R6_OPC_CMP_LE_D
= FOP(6, FMT_L
),
9625 R6_OPC_CMP_ULE_D
= FOP(7, FMT_L
),
9626 R6_OPC_CMP_SAF_D
= FOP(8, FMT_L
),
9627 R6_OPC_CMP_SUN_D
= FOP(9, FMT_L
),
9628 R6_OPC_CMP_SEQ_D
= FOP(10, FMT_L
),
9629 R6_OPC_CMP_SEUQ_D
= FOP(11, FMT_L
),
9630 R6_OPC_CMP_SLT_D
= FOP(12, FMT_L
),
9631 R6_OPC_CMP_SULT_D
= FOP(13, FMT_L
),
9632 R6_OPC_CMP_SLE_D
= FOP(14, FMT_L
),
9633 R6_OPC_CMP_SULE_D
= FOP(15, FMT_L
),
9634 R6_OPC_CMP_OR_D
= FOP(17, FMT_L
),
9635 R6_OPC_CMP_UNE_D
= FOP(18, FMT_L
),
9636 R6_OPC_CMP_NE_D
= FOP(19, FMT_L
),
9637 R6_OPC_CMP_SOR_D
= FOP(25, FMT_L
),
9638 R6_OPC_CMP_SUNE_D
= FOP(26, FMT_L
),
9639 R6_OPC_CMP_SNE_D
= FOP(27, FMT_L
),
9642 static void gen_cp1(DisasContext
*ctx
, uint32_t opc
, int rt
, int fs
)
9644 TCGv t0
= tcg_temp_new();
9649 TCGv_i32 fp0
= tcg_temp_new_i32();
9651 gen_load_fpr32(ctx
, fp0
, fs
);
9652 tcg_gen_ext_i32_tl(t0
, fp0
);
9653 tcg_temp_free_i32(fp0
);
9655 gen_store_gpr(t0
, rt
);
9658 gen_load_gpr(t0
, rt
);
9660 TCGv_i32 fp0
= tcg_temp_new_i32();
9662 tcg_gen_trunc_tl_i32(fp0
, t0
);
9663 gen_store_fpr32(ctx
, fp0
, fs
);
9664 tcg_temp_free_i32(fp0
);
9668 gen_helper_1e0i(cfc1
, t0
, fs
);
9669 gen_store_gpr(t0
, rt
);
9672 gen_load_gpr(t0
, rt
);
9673 save_cpu_state(ctx
, 0);
9674 gen_helper_0e2i(ctc1
, t0
, tcg_constant_i32(fs
), rt
);
9675 /* Stop translation as we may have changed hflags */
9676 ctx
->base
.is_jmp
= DISAS_STOP
;
9678 #if defined(TARGET_MIPS64)
9680 gen_load_fpr64(ctx
, t0
, fs
);
9681 gen_store_gpr(t0
, rt
);
9684 gen_load_gpr(t0
, rt
);
9685 gen_store_fpr64(ctx
, t0
, fs
);
9690 TCGv_i32 fp0
= tcg_temp_new_i32();
9692 gen_load_fpr32h(ctx
, fp0
, fs
);
9693 tcg_gen_ext_i32_tl(t0
, fp0
);
9694 tcg_temp_free_i32(fp0
);
9696 gen_store_gpr(t0
, rt
);
9699 gen_load_gpr(t0
, rt
);
9701 TCGv_i32 fp0
= tcg_temp_new_i32();
9703 tcg_gen_trunc_tl_i32(fp0
, t0
);
9704 gen_store_fpr32h(ctx
, fp0
, fs
);
9705 tcg_temp_free_i32(fp0
);
9709 MIPS_INVAL("cp1 move");
9710 gen_reserved_instruction(ctx
);
9718 static void gen_movci(DisasContext
*ctx
, int rd
, int rs
, int cc
, int tf
)
9735 l1
= gen_new_label();
9736 t0
= tcg_temp_new_i32();
9737 tcg_gen_andi_i32(t0
, fpu_fcr31
, 1 << get_fp_bit(cc
));
9738 tcg_gen_brcondi_i32(cond
, t0
, 0, l1
);
9739 tcg_temp_free_i32(t0
);
9740 gen_load_gpr(cpu_gpr
[rd
], rs
);
9744 static inline void gen_movcf_s(DisasContext
*ctx
, int fs
, int fd
, int cc
,
9748 TCGv_i32 t0
= tcg_temp_new_i32();
9749 TCGLabel
*l1
= gen_new_label();
9757 tcg_gen_andi_i32(t0
, fpu_fcr31
, 1 << get_fp_bit(cc
));
9758 tcg_gen_brcondi_i32(cond
, t0
, 0, l1
);
9759 gen_load_fpr32(ctx
, t0
, fs
);
9760 gen_store_fpr32(ctx
, t0
, fd
);
9762 tcg_temp_free_i32(t0
);
9765 static inline void gen_movcf_d(DisasContext
*ctx
, int fs
, int fd
, int cc
,
9769 TCGv_i32 t0
= tcg_temp_new_i32();
9771 TCGLabel
*l1
= gen_new_label();
9779 tcg_gen_andi_i32(t0
, fpu_fcr31
, 1 << get_fp_bit(cc
));
9780 tcg_gen_brcondi_i32(cond
, t0
, 0, l1
);
9781 tcg_temp_free_i32(t0
);
9782 fp0
= tcg_temp_new_i64();
9783 gen_load_fpr64(ctx
, fp0
, fs
);
9784 gen_store_fpr64(ctx
, fp0
, fd
);
9785 tcg_temp_free_i64(fp0
);
9789 static inline void gen_movcf_ps(DisasContext
*ctx
, int fs
, int fd
,
9793 TCGv_i32 t0
= tcg_temp_new_i32();
9794 TCGLabel
*l1
= gen_new_label();
9795 TCGLabel
*l2
= gen_new_label();
9803 tcg_gen_andi_i32(t0
, fpu_fcr31
, 1 << get_fp_bit(cc
));
9804 tcg_gen_brcondi_i32(cond
, t0
, 0, l1
);
9805 gen_load_fpr32(ctx
, t0
, fs
);
9806 gen_store_fpr32(ctx
, t0
, fd
);
9809 tcg_gen_andi_i32(t0
, fpu_fcr31
, 1 << get_fp_bit(cc
+ 1));
9810 tcg_gen_brcondi_i32(cond
, t0
, 0, l2
);
9811 gen_load_fpr32h(ctx
, t0
, fs
);
9812 gen_store_fpr32h(ctx
, t0
, fd
);
9813 tcg_temp_free_i32(t0
);
9817 static void gen_sel_s(DisasContext
*ctx
, enum fopcode op1
, int fd
, int ft
,
9820 TCGv_i32 t1
= tcg_const_i32(0);
9821 TCGv_i32 fp0
= tcg_temp_new_i32();
9822 TCGv_i32 fp1
= tcg_temp_new_i32();
9823 TCGv_i32 fp2
= tcg_temp_new_i32();
9824 gen_load_fpr32(ctx
, fp0
, fd
);
9825 gen_load_fpr32(ctx
, fp1
, ft
);
9826 gen_load_fpr32(ctx
, fp2
, fs
);
9830 tcg_gen_andi_i32(fp0
, fp0
, 1);
9831 tcg_gen_movcond_i32(TCG_COND_NE
, fp0
, fp0
, t1
, fp1
, fp2
);
9834 tcg_gen_andi_i32(fp1
, fp1
, 1);
9835 tcg_gen_movcond_i32(TCG_COND_EQ
, fp0
, fp1
, t1
, fp2
, t1
);
9838 tcg_gen_andi_i32(fp1
, fp1
, 1);
9839 tcg_gen_movcond_i32(TCG_COND_NE
, fp0
, fp1
, t1
, fp2
, t1
);
9842 MIPS_INVAL("gen_sel_s");
9843 gen_reserved_instruction(ctx
);
9847 gen_store_fpr32(ctx
, fp0
, fd
);
9848 tcg_temp_free_i32(fp2
);
9849 tcg_temp_free_i32(fp1
);
9850 tcg_temp_free_i32(fp0
);
9851 tcg_temp_free_i32(t1
);
9854 static void gen_sel_d(DisasContext
*ctx
, enum fopcode op1
, int fd
, int ft
,
9857 TCGv_i64 t1
= tcg_const_i64(0);
9858 TCGv_i64 fp0
= tcg_temp_new_i64();
9859 TCGv_i64 fp1
= tcg_temp_new_i64();
9860 TCGv_i64 fp2
= tcg_temp_new_i64();
9861 gen_load_fpr64(ctx
, fp0
, fd
);
9862 gen_load_fpr64(ctx
, fp1
, ft
);
9863 gen_load_fpr64(ctx
, fp2
, fs
);
9867 tcg_gen_andi_i64(fp0
, fp0
, 1);
9868 tcg_gen_movcond_i64(TCG_COND_NE
, fp0
, fp0
, t1
, fp1
, fp2
);
9871 tcg_gen_andi_i64(fp1
, fp1
, 1);
9872 tcg_gen_movcond_i64(TCG_COND_EQ
, fp0
, fp1
, t1
, fp2
, t1
);
9875 tcg_gen_andi_i64(fp1
, fp1
, 1);
9876 tcg_gen_movcond_i64(TCG_COND_NE
, fp0
, fp1
, t1
, fp2
, t1
);
9879 MIPS_INVAL("gen_sel_d");
9880 gen_reserved_instruction(ctx
);
9884 gen_store_fpr64(ctx
, fp0
, fd
);
9885 tcg_temp_free_i64(fp2
);
9886 tcg_temp_free_i64(fp1
);
9887 tcg_temp_free_i64(fp0
);
9888 tcg_temp_free_i64(t1
);
9891 static void gen_farith(DisasContext
*ctx
, enum fopcode op1
,
9892 int ft
, int fs
, int fd
, int cc
)
9894 uint32_t func
= ctx
->opcode
& 0x3f;
9898 TCGv_i32 fp0
= tcg_temp_new_i32();
9899 TCGv_i32 fp1
= tcg_temp_new_i32();
9901 gen_load_fpr32(ctx
, fp0
, fs
);
9902 gen_load_fpr32(ctx
, fp1
, ft
);
9903 gen_helper_float_add_s(fp0
, cpu_env
, fp0
, fp1
);
9904 tcg_temp_free_i32(fp1
);
9905 gen_store_fpr32(ctx
, fp0
, fd
);
9906 tcg_temp_free_i32(fp0
);
9911 TCGv_i32 fp0
= tcg_temp_new_i32();
9912 TCGv_i32 fp1
= tcg_temp_new_i32();
9914 gen_load_fpr32(ctx
, fp0
, fs
);
9915 gen_load_fpr32(ctx
, fp1
, ft
);
9916 gen_helper_float_sub_s(fp0
, cpu_env
, fp0
, fp1
);
9917 tcg_temp_free_i32(fp1
);
9918 gen_store_fpr32(ctx
, fp0
, fd
);
9919 tcg_temp_free_i32(fp0
);
9924 TCGv_i32 fp0
= tcg_temp_new_i32();
9925 TCGv_i32 fp1
= tcg_temp_new_i32();
9927 gen_load_fpr32(ctx
, fp0
, fs
);
9928 gen_load_fpr32(ctx
, fp1
, ft
);
9929 gen_helper_float_mul_s(fp0
, cpu_env
, fp0
, fp1
);
9930 tcg_temp_free_i32(fp1
);
9931 gen_store_fpr32(ctx
, fp0
, fd
);
9932 tcg_temp_free_i32(fp0
);
9937 TCGv_i32 fp0
= tcg_temp_new_i32();
9938 TCGv_i32 fp1
= tcg_temp_new_i32();
9940 gen_load_fpr32(ctx
, fp0
, fs
);
9941 gen_load_fpr32(ctx
, fp1
, ft
);
9942 gen_helper_float_div_s(fp0
, cpu_env
, fp0
, fp1
);
9943 tcg_temp_free_i32(fp1
);
9944 gen_store_fpr32(ctx
, fp0
, fd
);
9945 tcg_temp_free_i32(fp0
);
9950 TCGv_i32 fp0
= tcg_temp_new_i32();
9952 gen_load_fpr32(ctx
, fp0
, fs
);
9953 gen_helper_float_sqrt_s(fp0
, cpu_env
, fp0
);
9954 gen_store_fpr32(ctx
, fp0
, fd
);
9955 tcg_temp_free_i32(fp0
);
9960 TCGv_i32 fp0
= tcg_temp_new_i32();
9962 gen_load_fpr32(ctx
, fp0
, fs
);
9964 tcg_gen_andi_i32(fp0
, fp0
, 0x7fffffffUL
);
9966 gen_helper_float_abs_s(fp0
, fp0
);
9968 gen_store_fpr32(ctx
, fp0
, fd
);
9969 tcg_temp_free_i32(fp0
);
9974 TCGv_i32 fp0
= tcg_temp_new_i32();
9976 gen_load_fpr32(ctx
, fp0
, fs
);
9977 gen_store_fpr32(ctx
, fp0
, fd
);
9978 tcg_temp_free_i32(fp0
);
9983 TCGv_i32 fp0
= tcg_temp_new_i32();
9985 gen_load_fpr32(ctx
, fp0
, fs
);
9987 tcg_gen_xori_i32(fp0
, fp0
, 1UL << 31);
9989 gen_helper_float_chs_s(fp0
, fp0
);
9991 gen_store_fpr32(ctx
, fp0
, fd
);
9992 tcg_temp_free_i32(fp0
);
9996 check_cp1_64bitmode(ctx
);
9998 TCGv_i32 fp32
= tcg_temp_new_i32();
9999 TCGv_i64 fp64
= tcg_temp_new_i64();
10001 gen_load_fpr32(ctx
, fp32
, fs
);
10002 if (ctx
->nan2008
) {
10003 gen_helper_float_round_2008_l_s(fp64
, cpu_env
, fp32
);
10005 gen_helper_float_round_l_s(fp64
, cpu_env
, fp32
);
10007 tcg_temp_free_i32(fp32
);
10008 gen_store_fpr64(ctx
, fp64
, fd
);
10009 tcg_temp_free_i64(fp64
);
10012 case OPC_TRUNC_L_S
:
10013 check_cp1_64bitmode(ctx
);
10015 TCGv_i32 fp32
= tcg_temp_new_i32();
10016 TCGv_i64 fp64
= tcg_temp_new_i64();
10018 gen_load_fpr32(ctx
, fp32
, fs
);
10019 if (ctx
->nan2008
) {
10020 gen_helper_float_trunc_2008_l_s(fp64
, cpu_env
, fp32
);
10022 gen_helper_float_trunc_l_s(fp64
, cpu_env
, fp32
);
10024 tcg_temp_free_i32(fp32
);
10025 gen_store_fpr64(ctx
, fp64
, fd
);
10026 tcg_temp_free_i64(fp64
);
10030 check_cp1_64bitmode(ctx
);
10032 TCGv_i32 fp32
= tcg_temp_new_i32();
10033 TCGv_i64 fp64
= tcg_temp_new_i64();
10035 gen_load_fpr32(ctx
, fp32
, fs
);
10036 if (ctx
->nan2008
) {
10037 gen_helper_float_ceil_2008_l_s(fp64
, cpu_env
, fp32
);
10039 gen_helper_float_ceil_l_s(fp64
, cpu_env
, fp32
);
10041 tcg_temp_free_i32(fp32
);
10042 gen_store_fpr64(ctx
, fp64
, fd
);
10043 tcg_temp_free_i64(fp64
);
10046 case OPC_FLOOR_L_S
:
10047 check_cp1_64bitmode(ctx
);
10049 TCGv_i32 fp32
= tcg_temp_new_i32();
10050 TCGv_i64 fp64
= tcg_temp_new_i64();
10052 gen_load_fpr32(ctx
, fp32
, fs
);
10053 if (ctx
->nan2008
) {
10054 gen_helper_float_floor_2008_l_s(fp64
, cpu_env
, fp32
);
10056 gen_helper_float_floor_l_s(fp64
, cpu_env
, fp32
);
10058 tcg_temp_free_i32(fp32
);
10059 gen_store_fpr64(ctx
, fp64
, fd
);
10060 tcg_temp_free_i64(fp64
);
10063 case OPC_ROUND_W_S
:
10065 TCGv_i32 fp0
= tcg_temp_new_i32();
10067 gen_load_fpr32(ctx
, fp0
, fs
);
10068 if (ctx
->nan2008
) {
10069 gen_helper_float_round_2008_w_s(fp0
, cpu_env
, fp0
);
10071 gen_helper_float_round_w_s(fp0
, cpu_env
, fp0
);
10073 gen_store_fpr32(ctx
, fp0
, fd
);
10074 tcg_temp_free_i32(fp0
);
10077 case OPC_TRUNC_W_S
:
10079 TCGv_i32 fp0
= tcg_temp_new_i32();
10081 gen_load_fpr32(ctx
, fp0
, fs
);
10082 if (ctx
->nan2008
) {
10083 gen_helper_float_trunc_2008_w_s(fp0
, cpu_env
, fp0
);
10085 gen_helper_float_trunc_w_s(fp0
, cpu_env
, fp0
);
10087 gen_store_fpr32(ctx
, fp0
, fd
);
10088 tcg_temp_free_i32(fp0
);
10093 TCGv_i32 fp0
= tcg_temp_new_i32();
10095 gen_load_fpr32(ctx
, fp0
, fs
);
10096 if (ctx
->nan2008
) {
10097 gen_helper_float_ceil_2008_w_s(fp0
, cpu_env
, fp0
);
10099 gen_helper_float_ceil_w_s(fp0
, cpu_env
, fp0
);
10101 gen_store_fpr32(ctx
, fp0
, fd
);
10102 tcg_temp_free_i32(fp0
);
10105 case OPC_FLOOR_W_S
:
10107 TCGv_i32 fp0
= tcg_temp_new_i32();
10109 gen_load_fpr32(ctx
, fp0
, fs
);
10110 if (ctx
->nan2008
) {
10111 gen_helper_float_floor_2008_w_s(fp0
, cpu_env
, fp0
);
10113 gen_helper_float_floor_w_s(fp0
, cpu_env
, fp0
);
10115 gen_store_fpr32(ctx
, fp0
, fd
);
10116 tcg_temp_free_i32(fp0
);
10120 check_insn(ctx
, ISA_MIPS_R6
);
10121 gen_sel_s(ctx
, op1
, fd
, ft
, fs
);
10124 check_insn(ctx
, ISA_MIPS_R6
);
10125 gen_sel_s(ctx
, op1
, fd
, ft
, fs
);
10128 check_insn(ctx
, ISA_MIPS_R6
);
10129 gen_sel_s(ctx
, op1
, fd
, ft
, fs
);
10132 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
10133 gen_movcf_s(ctx
, fs
, fd
, (ft
>> 2) & 0x7, ft
& 0x1);
10136 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
10138 TCGLabel
*l1
= gen_new_label();
10142 tcg_gen_brcondi_tl(TCG_COND_NE
, cpu_gpr
[ft
], 0, l1
);
10144 fp0
= tcg_temp_new_i32();
10145 gen_load_fpr32(ctx
, fp0
, fs
);
10146 gen_store_fpr32(ctx
, fp0
, fd
);
10147 tcg_temp_free_i32(fp0
);
10152 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
10154 TCGLabel
*l1
= gen_new_label();
10158 tcg_gen_brcondi_tl(TCG_COND_EQ
, cpu_gpr
[ft
], 0, l1
);
10159 fp0
= tcg_temp_new_i32();
10160 gen_load_fpr32(ctx
, fp0
, fs
);
10161 gen_store_fpr32(ctx
, fp0
, fd
);
10162 tcg_temp_free_i32(fp0
);
10169 TCGv_i32 fp0
= tcg_temp_new_i32();
10171 gen_load_fpr32(ctx
, fp0
, fs
);
10172 gen_helper_float_recip_s(fp0
, cpu_env
, fp0
);
10173 gen_store_fpr32(ctx
, fp0
, fd
);
10174 tcg_temp_free_i32(fp0
);
10179 TCGv_i32 fp0
= tcg_temp_new_i32();
10181 gen_load_fpr32(ctx
, fp0
, fs
);
10182 gen_helper_float_rsqrt_s(fp0
, cpu_env
, fp0
);
10183 gen_store_fpr32(ctx
, fp0
, fd
);
10184 tcg_temp_free_i32(fp0
);
10188 check_insn(ctx
, ISA_MIPS_R6
);
10190 TCGv_i32 fp0
= tcg_temp_new_i32();
10191 TCGv_i32 fp1
= tcg_temp_new_i32();
10192 TCGv_i32 fp2
= tcg_temp_new_i32();
10193 gen_load_fpr32(ctx
, fp0
, fs
);
10194 gen_load_fpr32(ctx
, fp1
, ft
);
10195 gen_load_fpr32(ctx
, fp2
, fd
);
10196 gen_helper_float_maddf_s(fp2
, cpu_env
, fp0
, fp1
, fp2
);
10197 gen_store_fpr32(ctx
, fp2
, fd
);
10198 tcg_temp_free_i32(fp2
);
10199 tcg_temp_free_i32(fp1
);
10200 tcg_temp_free_i32(fp0
);
10204 check_insn(ctx
, ISA_MIPS_R6
);
10206 TCGv_i32 fp0
= tcg_temp_new_i32();
10207 TCGv_i32 fp1
= tcg_temp_new_i32();
10208 TCGv_i32 fp2
= tcg_temp_new_i32();
10209 gen_load_fpr32(ctx
, fp0
, fs
);
10210 gen_load_fpr32(ctx
, fp1
, ft
);
10211 gen_load_fpr32(ctx
, fp2
, fd
);
10212 gen_helper_float_msubf_s(fp2
, cpu_env
, fp0
, fp1
, fp2
);
10213 gen_store_fpr32(ctx
, fp2
, fd
);
10214 tcg_temp_free_i32(fp2
);
10215 tcg_temp_free_i32(fp1
);
10216 tcg_temp_free_i32(fp0
);
10220 check_insn(ctx
, ISA_MIPS_R6
);
10222 TCGv_i32 fp0
= tcg_temp_new_i32();
10223 gen_load_fpr32(ctx
, fp0
, fs
);
10224 gen_helper_float_rint_s(fp0
, cpu_env
, fp0
);
10225 gen_store_fpr32(ctx
, fp0
, fd
);
10226 tcg_temp_free_i32(fp0
);
10230 check_insn(ctx
, ISA_MIPS_R6
);
10232 TCGv_i32 fp0
= tcg_temp_new_i32();
10233 gen_load_fpr32(ctx
, fp0
, fs
);
10234 gen_helper_float_class_s(fp0
, cpu_env
, fp0
);
10235 gen_store_fpr32(ctx
, fp0
, fd
);
10236 tcg_temp_free_i32(fp0
);
10239 case OPC_MIN_S
: /* OPC_RECIP2_S */
10240 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
10242 TCGv_i32 fp0
= tcg_temp_new_i32();
10243 TCGv_i32 fp1
= tcg_temp_new_i32();
10244 TCGv_i32 fp2
= tcg_temp_new_i32();
10245 gen_load_fpr32(ctx
, fp0
, fs
);
10246 gen_load_fpr32(ctx
, fp1
, ft
);
10247 gen_helper_float_min_s(fp2
, cpu_env
, fp0
, fp1
);
10248 gen_store_fpr32(ctx
, fp2
, fd
);
10249 tcg_temp_free_i32(fp2
);
10250 tcg_temp_free_i32(fp1
);
10251 tcg_temp_free_i32(fp0
);
10254 check_cp1_64bitmode(ctx
);
10256 TCGv_i32 fp0
= tcg_temp_new_i32();
10257 TCGv_i32 fp1
= tcg_temp_new_i32();
10259 gen_load_fpr32(ctx
, fp0
, fs
);
10260 gen_load_fpr32(ctx
, fp1
, ft
);
10261 gen_helper_float_recip2_s(fp0
, cpu_env
, fp0
, fp1
);
10262 tcg_temp_free_i32(fp1
);
10263 gen_store_fpr32(ctx
, fp0
, fd
);
10264 tcg_temp_free_i32(fp0
);
10268 case OPC_MINA_S
: /* OPC_RECIP1_S */
10269 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
10271 TCGv_i32 fp0
= tcg_temp_new_i32();
10272 TCGv_i32 fp1
= tcg_temp_new_i32();
10273 TCGv_i32 fp2
= tcg_temp_new_i32();
10274 gen_load_fpr32(ctx
, fp0
, fs
);
10275 gen_load_fpr32(ctx
, fp1
, ft
);
10276 gen_helper_float_mina_s(fp2
, cpu_env
, fp0
, fp1
);
10277 gen_store_fpr32(ctx
, fp2
, fd
);
10278 tcg_temp_free_i32(fp2
);
10279 tcg_temp_free_i32(fp1
);
10280 tcg_temp_free_i32(fp0
);
10283 check_cp1_64bitmode(ctx
);
10285 TCGv_i32 fp0
= tcg_temp_new_i32();
10287 gen_load_fpr32(ctx
, fp0
, fs
);
10288 gen_helper_float_recip1_s(fp0
, cpu_env
, fp0
);
10289 gen_store_fpr32(ctx
, fp0
, fd
);
10290 tcg_temp_free_i32(fp0
);
10294 case OPC_MAX_S
: /* OPC_RSQRT1_S */
10295 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
10297 TCGv_i32 fp0
= tcg_temp_new_i32();
10298 TCGv_i32 fp1
= tcg_temp_new_i32();
10299 gen_load_fpr32(ctx
, fp0
, fs
);
10300 gen_load_fpr32(ctx
, fp1
, ft
);
10301 gen_helper_float_max_s(fp1
, cpu_env
, fp0
, fp1
);
10302 gen_store_fpr32(ctx
, fp1
, fd
);
10303 tcg_temp_free_i32(fp1
);
10304 tcg_temp_free_i32(fp0
);
10307 check_cp1_64bitmode(ctx
);
10309 TCGv_i32 fp0
= tcg_temp_new_i32();
10311 gen_load_fpr32(ctx
, fp0
, fs
);
10312 gen_helper_float_rsqrt1_s(fp0
, cpu_env
, fp0
);
10313 gen_store_fpr32(ctx
, fp0
, fd
);
10314 tcg_temp_free_i32(fp0
);
10318 case OPC_MAXA_S
: /* OPC_RSQRT2_S */
10319 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
10321 TCGv_i32 fp0
= tcg_temp_new_i32();
10322 TCGv_i32 fp1
= tcg_temp_new_i32();
10323 gen_load_fpr32(ctx
, fp0
, fs
);
10324 gen_load_fpr32(ctx
, fp1
, ft
);
10325 gen_helper_float_maxa_s(fp1
, cpu_env
, fp0
, fp1
);
10326 gen_store_fpr32(ctx
, fp1
, fd
);
10327 tcg_temp_free_i32(fp1
);
10328 tcg_temp_free_i32(fp0
);
10331 check_cp1_64bitmode(ctx
);
10333 TCGv_i32 fp0
= tcg_temp_new_i32();
10334 TCGv_i32 fp1
= tcg_temp_new_i32();
10336 gen_load_fpr32(ctx
, fp0
, fs
);
10337 gen_load_fpr32(ctx
, fp1
, ft
);
10338 gen_helper_float_rsqrt2_s(fp0
, cpu_env
, fp0
, fp1
);
10339 tcg_temp_free_i32(fp1
);
10340 gen_store_fpr32(ctx
, fp0
, fd
);
10341 tcg_temp_free_i32(fp0
);
10346 check_cp1_registers(ctx
, fd
);
10348 TCGv_i32 fp32
= tcg_temp_new_i32();
10349 TCGv_i64 fp64
= tcg_temp_new_i64();
10351 gen_load_fpr32(ctx
, fp32
, fs
);
10352 gen_helper_float_cvtd_s(fp64
, cpu_env
, fp32
);
10353 tcg_temp_free_i32(fp32
);
10354 gen_store_fpr64(ctx
, fp64
, fd
);
10355 tcg_temp_free_i64(fp64
);
10360 TCGv_i32 fp0
= tcg_temp_new_i32();
10362 gen_load_fpr32(ctx
, fp0
, fs
);
10363 if (ctx
->nan2008
) {
10364 gen_helper_float_cvt_2008_w_s(fp0
, cpu_env
, fp0
);
10366 gen_helper_float_cvt_w_s(fp0
, cpu_env
, fp0
);
10368 gen_store_fpr32(ctx
, fp0
, fd
);
10369 tcg_temp_free_i32(fp0
);
10373 check_cp1_64bitmode(ctx
);
10375 TCGv_i32 fp32
= tcg_temp_new_i32();
10376 TCGv_i64 fp64
= tcg_temp_new_i64();
10378 gen_load_fpr32(ctx
, fp32
, fs
);
10379 if (ctx
->nan2008
) {
10380 gen_helper_float_cvt_2008_l_s(fp64
, cpu_env
, fp32
);
10382 gen_helper_float_cvt_l_s(fp64
, cpu_env
, fp32
);
10384 tcg_temp_free_i32(fp32
);
10385 gen_store_fpr64(ctx
, fp64
, fd
);
10386 tcg_temp_free_i64(fp64
);
10392 TCGv_i64 fp64
= tcg_temp_new_i64();
10393 TCGv_i32 fp32_0
= tcg_temp_new_i32();
10394 TCGv_i32 fp32_1
= tcg_temp_new_i32();
10396 gen_load_fpr32(ctx
, fp32_0
, fs
);
10397 gen_load_fpr32(ctx
, fp32_1
, ft
);
10398 tcg_gen_concat_i32_i64(fp64
, fp32_1
, fp32_0
);
10399 tcg_temp_free_i32(fp32_1
);
10400 tcg_temp_free_i32(fp32_0
);
10401 gen_store_fpr64(ctx
, fp64
, fd
);
10402 tcg_temp_free_i64(fp64
);
10408 case OPC_CMP_UEQ_S
:
10409 case OPC_CMP_OLT_S
:
10410 case OPC_CMP_ULT_S
:
10411 case OPC_CMP_OLE_S
:
10412 case OPC_CMP_ULE_S
:
10414 case OPC_CMP_NGLE_S
:
10415 case OPC_CMP_SEQ_S
:
10416 case OPC_CMP_NGL_S
:
10418 case OPC_CMP_NGE_S
:
10420 case OPC_CMP_NGT_S
:
10421 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
10422 if (ctx
->opcode
& (1 << 6)) {
10423 gen_cmpabs_s(ctx
, func
- 48, ft
, fs
, cc
);
10425 gen_cmp_s(ctx
, func
- 48, ft
, fs
, cc
);
10429 check_cp1_registers(ctx
, fs
| ft
| fd
);
10431 TCGv_i64 fp0
= tcg_temp_new_i64();
10432 TCGv_i64 fp1
= tcg_temp_new_i64();
10434 gen_load_fpr64(ctx
, fp0
, fs
);
10435 gen_load_fpr64(ctx
, fp1
, ft
);
10436 gen_helper_float_add_d(fp0
, cpu_env
, fp0
, fp1
);
10437 tcg_temp_free_i64(fp1
);
10438 gen_store_fpr64(ctx
, fp0
, fd
);
10439 tcg_temp_free_i64(fp0
);
10443 check_cp1_registers(ctx
, fs
| ft
| fd
);
10445 TCGv_i64 fp0
= tcg_temp_new_i64();
10446 TCGv_i64 fp1
= tcg_temp_new_i64();
10448 gen_load_fpr64(ctx
, fp0
, fs
);
10449 gen_load_fpr64(ctx
, fp1
, ft
);
10450 gen_helper_float_sub_d(fp0
, cpu_env
, fp0
, fp1
);
10451 tcg_temp_free_i64(fp1
);
10452 gen_store_fpr64(ctx
, fp0
, fd
);
10453 tcg_temp_free_i64(fp0
);
10457 check_cp1_registers(ctx
, fs
| ft
| fd
);
10459 TCGv_i64 fp0
= tcg_temp_new_i64();
10460 TCGv_i64 fp1
= tcg_temp_new_i64();
10462 gen_load_fpr64(ctx
, fp0
, fs
);
10463 gen_load_fpr64(ctx
, fp1
, ft
);
10464 gen_helper_float_mul_d(fp0
, cpu_env
, fp0
, fp1
);
10465 tcg_temp_free_i64(fp1
);
10466 gen_store_fpr64(ctx
, fp0
, fd
);
10467 tcg_temp_free_i64(fp0
);
10471 check_cp1_registers(ctx
, fs
| ft
| fd
);
10473 TCGv_i64 fp0
= tcg_temp_new_i64();
10474 TCGv_i64 fp1
= tcg_temp_new_i64();
10476 gen_load_fpr64(ctx
, fp0
, fs
);
10477 gen_load_fpr64(ctx
, fp1
, ft
);
10478 gen_helper_float_div_d(fp0
, cpu_env
, fp0
, fp1
);
10479 tcg_temp_free_i64(fp1
);
10480 gen_store_fpr64(ctx
, fp0
, fd
);
10481 tcg_temp_free_i64(fp0
);
10485 check_cp1_registers(ctx
, fs
| fd
);
10487 TCGv_i64 fp0
= tcg_temp_new_i64();
10489 gen_load_fpr64(ctx
, fp0
, fs
);
10490 gen_helper_float_sqrt_d(fp0
, cpu_env
, fp0
);
10491 gen_store_fpr64(ctx
, fp0
, fd
);
10492 tcg_temp_free_i64(fp0
);
10496 check_cp1_registers(ctx
, fs
| fd
);
10498 TCGv_i64 fp0
= tcg_temp_new_i64();
10500 gen_load_fpr64(ctx
, fp0
, fs
);
10501 if (ctx
->abs2008
) {
10502 tcg_gen_andi_i64(fp0
, fp0
, 0x7fffffffffffffffULL
);
10504 gen_helper_float_abs_d(fp0
, fp0
);
10506 gen_store_fpr64(ctx
, fp0
, fd
);
10507 tcg_temp_free_i64(fp0
);
10511 check_cp1_registers(ctx
, fs
| fd
);
10513 TCGv_i64 fp0
= tcg_temp_new_i64();
10515 gen_load_fpr64(ctx
, fp0
, fs
);
10516 gen_store_fpr64(ctx
, fp0
, fd
);
10517 tcg_temp_free_i64(fp0
);
10521 check_cp1_registers(ctx
, fs
| fd
);
10523 TCGv_i64 fp0
= tcg_temp_new_i64();
10525 gen_load_fpr64(ctx
, fp0
, fs
);
10526 if (ctx
->abs2008
) {
10527 tcg_gen_xori_i64(fp0
, fp0
, 1ULL << 63);
10529 gen_helper_float_chs_d(fp0
, fp0
);
10531 gen_store_fpr64(ctx
, fp0
, fd
);
10532 tcg_temp_free_i64(fp0
);
10535 case OPC_ROUND_L_D
:
10536 check_cp1_64bitmode(ctx
);
10538 TCGv_i64 fp0
= tcg_temp_new_i64();
10540 gen_load_fpr64(ctx
, fp0
, fs
);
10541 if (ctx
->nan2008
) {
10542 gen_helper_float_round_2008_l_d(fp0
, cpu_env
, fp0
);
10544 gen_helper_float_round_l_d(fp0
, cpu_env
, fp0
);
10546 gen_store_fpr64(ctx
, fp0
, fd
);
10547 tcg_temp_free_i64(fp0
);
10550 case OPC_TRUNC_L_D
:
10551 check_cp1_64bitmode(ctx
);
10553 TCGv_i64 fp0
= tcg_temp_new_i64();
10555 gen_load_fpr64(ctx
, fp0
, fs
);
10556 if (ctx
->nan2008
) {
10557 gen_helper_float_trunc_2008_l_d(fp0
, cpu_env
, fp0
);
10559 gen_helper_float_trunc_l_d(fp0
, cpu_env
, fp0
);
10561 gen_store_fpr64(ctx
, fp0
, fd
);
10562 tcg_temp_free_i64(fp0
);
10566 check_cp1_64bitmode(ctx
);
10568 TCGv_i64 fp0
= tcg_temp_new_i64();
10570 gen_load_fpr64(ctx
, fp0
, fs
);
10571 if (ctx
->nan2008
) {
10572 gen_helper_float_ceil_2008_l_d(fp0
, cpu_env
, fp0
);
10574 gen_helper_float_ceil_l_d(fp0
, cpu_env
, fp0
);
10576 gen_store_fpr64(ctx
, fp0
, fd
);
10577 tcg_temp_free_i64(fp0
);
10580 case OPC_FLOOR_L_D
:
10581 check_cp1_64bitmode(ctx
);
10583 TCGv_i64 fp0
= tcg_temp_new_i64();
10585 gen_load_fpr64(ctx
, fp0
, fs
);
10586 if (ctx
->nan2008
) {
10587 gen_helper_float_floor_2008_l_d(fp0
, cpu_env
, fp0
);
10589 gen_helper_float_floor_l_d(fp0
, cpu_env
, fp0
);
10591 gen_store_fpr64(ctx
, fp0
, fd
);
10592 tcg_temp_free_i64(fp0
);
10595 case OPC_ROUND_W_D
:
10596 check_cp1_registers(ctx
, fs
);
10598 TCGv_i32 fp32
= tcg_temp_new_i32();
10599 TCGv_i64 fp64
= tcg_temp_new_i64();
10601 gen_load_fpr64(ctx
, fp64
, fs
);
10602 if (ctx
->nan2008
) {
10603 gen_helper_float_round_2008_w_d(fp32
, cpu_env
, fp64
);
10605 gen_helper_float_round_w_d(fp32
, cpu_env
, fp64
);
10607 tcg_temp_free_i64(fp64
);
10608 gen_store_fpr32(ctx
, fp32
, fd
);
10609 tcg_temp_free_i32(fp32
);
10612 case OPC_TRUNC_W_D
:
10613 check_cp1_registers(ctx
, fs
);
10615 TCGv_i32 fp32
= tcg_temp_new_i32();
10616 TCGv_i64 fp64
= tcg_temp_new_i64();
10618 gen_load_fpr64(ctx
, fp64
, fs
);
10619 if (ctx
->nan2008
) {
10620 gen_helper_float_trunc_2008_w_d(fp32
, cpu_env
, fp64
);
10622 gen_helper_float_trunc_w_d(fp32
, cpu_env
, fp64
);
10624 tcg_temp_free_i64(fp64
);
10625 gen_store_fpr32(ctx
, fp32
, fd
);
10626 tcg_temp_free_i32(fp32
);
10630 check_cp1_registers(ctx
, fs
);
10632 TCGv_i32 fp32
= tcg_temp_new_i32();
10633 TCGv_i64 fp64
= tcg_temp_new_i64();
10635 gen_load_fpr64(ctx
, fp64
, fs
);
10636 if (ctx
->nan2008
) {
10637 gen_helper_float_ceil_2008_w_d(fp32
, cpu_env
, fp64
);
10639 gen_helper_float_ceil_w_d(fp32
, cpu_env
, fp64
);
10641 tcg_temp_free_i64(fp64
);
10642 gen_store_fpr32(ctx
, fp32
, fd
);
10643 tcg_temp_free_i32(fp32
);
10646 case OPC_FLOOR_W_D
:
10647 check_cp1_registers(ctx
, fs
);
10649 TCGv_i32 fp32
= tcg_temp_new_i32();
10650 TCGv_i64 fp64
= tcg_temp_new_i64();
10652 gen_load_fpr64(ctx
, fp64
, fs
);
10653 if (ctx
->nan2008
) {
10654 gen_helper_float_floor_2008_w_d(fp32
, cpu_env
, fp64
);
10656 gen_helper_float_floor_w_d(fp32
, cpu_env
, fp64
);
10658 tcg_temp_free_i64(fp64
);
10659 gen_store_fpr32(ctx
, fp32
, fd
);
10660 tcg_temp_free_i32(fp32
);
10664 check_insn(ctx
, ISA_MIPS_R6
);
10665 gen_sel_d(ctx
, op1
, fd
, ft
, fs
);
10668 check_insn(ctx
, ISA_MIPS_R6
);
10669 gen_sel_d(ctx
, op1
, fd
, ft
, fs
);
10672 check_insn(ctx
, ISA_MIPS_R6
);
10673 gen_sel_d(ctx
, op1
, fd
, ft
, fs
);
10676 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
10677 gen_movcf_d(ctx
, fs
, fd
, (ft
>> 2) & 0x7, ft
& 0x1);
10680 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
10682 TCGLabel
*l1
= gen_new_label();
10686 tcg_gen_brcondi_tl(TCG_COND_NE
, cpu_gpr
[ft
], 0, l1
);
10688 fp0
= tcg_temp_new_i64();
10689 gen_load_fpr64(ctx
, fp0
, fs
);
10690 gen_store_fpr64(ctx
, fp0
, fd
);
10691 tcg_temp_free_i64(fp0
);
10696 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
10698 TCGLabel
*l1
= gen_new_label();
10702 tcg_gen_brcondi_tl(TCG_COND_EQ
, cpu_gpr
[ft
], 0, l1
);
10703 fp0
= tcg_temp_new_i64();
10704 gen_load_fpr64(ctx
, fp0
, fs
);
10705 gen_store_fpr64(ctx
, fp0
, fd
);
10706 tcg_temp_free_i64(fp0
);
10712 check_cp1_registers(ctx
, fs
| fd
);
10714 TCGv_i64 fp0
= tcg_temp_new_i64();
10716 gen_load_fpr64(ctx
, fp0
, fs
);
10717 gen_helper_float_recip_d(fp0
, cpu_env
, fp0
);
10718 gen_store_fpr64(ctx
, fp0
, fd
);
10719 tcg_temp_free_i64(fp0
);
10723 check_cp1_registers(ctx
, fs
| fd
);
10725 TCGv_i64 fp0
= tcg_temp_new_i64();
10727 gen_load_fpr64(ctx
, fp0
, fs
);
10728 gen_helper_float_rsqrt_d(fp0
, cpu_env
, fp0
);
10729 gen_store_fpr64(ctx
, fp0
, fd
);
10730 tcg_temp_free_i64(fp0
);
10734 check_insn(ctx
, ISA_MIPS_R6
);
10736 TCGv_i64 fp0
= tcg_temp_new_i64();
10737 TCGv_i64 fp1
= tcg_temp_new_i64();
10738 TCGv_i64 fp2
= tcg_temp_new_i64();
10739 gen_load_fpr64(ctx
, fp0
, fs
);
10740 gen_load_fpr64(ctx
, fp1
, ft
);
10741 gen_load_fpr64(ctx
, fp2
, fd
);
10742 gen_helper_float_maddf_d(fp2
, cpu_env
, fp0
, fp1
, fp2
);
10743 gen_store_fpr64(ctx
, fp2
, fd
);
10744 tcg_temp_free_i64(fp2
);
10745 tcg_temp_free_i64(fp1
);
10746 tcg_temp_free_i64(fp0
);
10750 check_insn(ctx
, ISA_MIPS_R6
);
10752 TCGv_i64 fp0
= tcg_temp_new_i64();
10753 TCGv_i64 fp1
= tcg_temp_new_i64();
10754 TCGv_i64 fp2
= tcg_temp_new_i64();
10755 gen_load_fpr64(ctx
, fp0
, fs
);
10756 gen_load_fpr64(ctx
, fp1
, ft
);
10757 gen_load_fpr64(ctx
, fp2
, fd
);
10758 gen_helper_float_msubf_d(fp2
, cpu_env
, fp0
, fp1
, fp2
);
10759 gen_store_fpr64(ctx
, fp2
, fd
);
10760 tcg_temp_free_i64(fp2
);
10761 tcg_temp_free_i64(fp1
);
10762 tcg_temp_free_i64(fp0
);
10766 check_insn(ctx
, ISA_MIPS_R6
);
10768 TCGv_i64 fp0
= tcg_temp_new_i64();
10769 gen_load_fpr64(ctx
, fp0
, fs
);
10770 gen_helper_float_rint_d(fp0
, cpu_env
, fp0
);
10771 gen_store_fpr64(ctx
, fp0
, fd
);
10772 tcg_temp_free_i64(fp0
);
10776 check_insn(ctx
, ISA_MIPS_R6
);
10778 TCGv_i64 fp0
= tcg_temp_new_i64();
10779 gen_load_fpr64(ctx
, fp0
, fs
);
10780 gen_helper_float_class_d(fp0
, cpu_env
, fp0
);
10781 gen_store_fpr64(ctx
, fp0
, fd
);
10782 tcg_temp_free_i64(fp0
);
10785 case OPC_MIN_D
: /* OPC_RECIP2_D */
10786 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
10788 TCGv_i64 fp0
= tcg_temp_new_i64();
10789 TCGv_i64 fp1
= tcg_temp_new_i64();
10790 gen_load_fpr64(ctx
, fp0
, fs
);
10791 gen_load_fpr64(ctx
, fp1
, ft
);
10792 gen_helper_float_min_d(fp1
, cpu_env
, fp0
, fp1
);
10793 gen_store_fpr64(ctx
, fp1
, fd
);
10794 tcg_temp_free_i64(fp1
);
10795 tcg_temp_free_i64(fp0
);
10798 check_cp1_64bitmode(ctx
);
10800 TCGv_i64 fp0
= tcg_temp_new_i64();
10801 TCGv_i64 fp1
= tcg_temp_new_i64();
10803 gen_load_fpr64(ctx
, fp0
, fs
);
10804 gen_load_fpr64(ctx
, fp1
, ft
);
10805 gen_helper_float_recip2_d(fp0
, cpu_env
, fp0
, fp1
);
10806 tcg_temp_free_i64(fp1
);
10807 gen_store_fpr64(ctx
, fp0
, fd
);
10808 tcg_temp_free_i64(fp0
);
10812 case OPC_MINA_D
: /* OPC_RECIP1_D */
10813 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
10815 TCGv_i64 fp0
= tcg_temp_new_i64();
10816 TCGv_i64 fp1
= tcg_temp_new_i64();
10817 gen_load_fpr64(ctx
, fp0
, fs
);
10818 gen_load_fpr64(ctx
, fp1
, ft
);
10819 gen_helper_float_mina_d(fp1
, cpu_env
, fp0
, fp1
);
10820 gen_store_fpr64(ctx
, fp1
, fd
);
10821 tcg_temp_free_i64(fp1
);
10822 tcg_temp_free_i64(fp0
);
10825 check_cp1_64bitmode(ctx
);
10827 TCGv_i64 fp0
= tcg_temp_new_i64();
10829 gen_load_fpr64(ctx
, fp0
, fs
);
10830 gen_helper_float_recip1_d(fp0
, cpu_env
, fp0
);
10831 gen_store_fpr64(ctx
, fp0
, fd
);
10832 tcg_temp_free_i64(fp0
);
10836 case OPC_MAX_D
: /* OPC_RSQRT1_D */
10837 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
10839 TCGv_i64 fp0
= tcg_temp_new_i64();
10840 TCGv_i64 fp1
= tcg_temp_new_i64();
10841 gen_load_fpr64(ctx
, fp0
, fs
);
10842 gen_load_fpr64(ctx
, fp1
, ft
);
10843 gen_helper_float_max_d(fp1
, cpu_env
, fp0
, fp1
);
10844 gen_store_fpr64(ctx
, fp1
, fd
);
10845 tcg_temp_free_i64(fp1
);
10846 tcg_temp_free_i64(fp0
);
10849 check_cp1_64bitmode(ctx
);
10851 TCGv_i64 fp0
= tcg_temp_new_i64();
10853 gen_load_fpr64(ctx
, fp0
, fs
);
10854 gen_helper_float_rsqrt1_d(fp0
, cpu_env
, fp0
);
10855 gen_store_fpr64(ctx
, fp0
, fd
);
10856 tcg_temp_free_i64(fp0
);
10860 case OPC_MAXA_D
: /* OPC_RSQRT2_D */
10861 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
10863 TCGv_i64 fp0
= tcg_temp_new_i64();
10864 TCGv_i64 fp1
= tcg_temp_new_i64();
10865 gen_load_fpr64(ctx
, fp0
, fs
);
10866 gen_load_fpr64(ctx
, fp1
, ft
);
10867 gen_helper_float_maxa_d(fp1
, cpu_env
, fp0
, fp1
);
10868 gen_store_fpr64(ctx
, fp1
, fd
);
10869 tcg_temp_free_i64(fp1
);
10870 tcg_temp_free_i64(fp0
);
10873 check_cp1_64bitmode(ctx
);
10875 TCGv_i64 fp0
= tcg_temp_new_i64();
10876 TCGv_i64 fp1
= tcg_temp_new_i64();
10878 gen_load_fpr64(ctx
, fp0
, fs
);
10879 gen_load_fpr64(ctx
, fp1
, ft
);
10880 gen_helper_float_rsqrt2_d(fp0
, cpu_env
, fp0
, fp1
);
10881 tcg_temp_free_i64(fp1
);
10882 gen_store_fpr64(ctx
, fp0
, fd
);
10883 tcg_temp_free_i64(fp0
);
10890 case OPC_CMP_UEQ_D
:
10891 case OPC_CMP_OLT_D
:
10892 case OPC_CMP_ULT_D
:
10893 case OPC_CMP_OLE_D
:
10894 case OPC_CMP_ULE_D
:
10896 case OPC_CMP_NGLE_D
:
10897 case OPC_CMP_SEQ_D
:
10898 case OPC_CMP_NGL_D
:
10900 case OPC_CMP_NGE_D
:
10902 case OPC_CMP_NGT_D
:
10903 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
10904 if (ctx
->opcode
& (1 << 6)) {
10905 gen_cmpabs_d(ctx
, func
- 48, ft
, fs
, cc
);
10907 gen_cmp_d(ctx
, func
- 48, ft
, fs
, cc
);
10911 check_cp1_registers(ctx
, fs
);
10913 TCGv_i32 fp32
= tcg_temp_new_i32();
10914 TCGv_i64 fp64
= tcg_temp_new_i64();
10916 gen_load_fpr64(ctx
, fp64
, fs
);
10917 gen_helper_float_cvts_d(fp32
, cpu_env
, fp64
);
10918 tcg_temp_free_i64(fp64
);
10919 gen_store_fpr32(ctx
, fp32
, fd
);
10920 tcg_temp_free_i32(fp32
);
10924 check_cp1_registers(ctx
, fs
);
10926 TCGv_i32 fp32
= tcg_temp_new_i32();
10927 TCGv_i64 fp64
= tcg_temp_new_i64();
10929 gen_load_fpr64(ctx
, fp64
, fs
);
10930 if (ctx
->nan2008
) {
10931 gen_helper_float_cvt_2008_w_d(fp32
, cpu_env
, fp64
);
10933 gen_helper_float_cvt_w_d(fp32
, cpu_env
, fp64
);
10935 tcg_temp_free_i64(fp64
);
10936 gen_store_fpr32(ctx
, fp32
, fd
);
10937 tcg_temp_free_i32(fp32
);
10941 check_cp1_64bitmode(ctx
);
10943 TCGv_i64 fp0
= tcg_temp_new_i64();
10945 gen_load_fpr64(ctx
, fp0
, fs
);
10946 if (ctx
->nan2008
) {
10947 gen_helper_float_cvt_2008_l_d(fp0
, cpu_env
, fp0
);
10949 gen_helper_float_cvt_l_d(fp0
, cpu_env
, fp0
);
10951 gen_store_fpr64(ctx
, fp0
, fd
);
10952 tcg_temp_free_i64(fp0
);
10957 TCGv_i32 fp0
= tcg_temp_new_i32();
10959 gen_load_fpr32(ctx
, fp0
, fs
);
10960 gen_helper_float_cvts_w(fp0
, cpu_env
, fp0
);
10961 gen_store_fpr32(ctx
, fp0
, fd
);
10962 tcg_temp_free_i32(fp0
);
10966 check_cp1_registers(ctx
, fd
);
10968 TCGv_i32 fp32
= tcg_temp_new_i32();
10969 TCGv_i64 fp64
= tcg_temp_new_i64();
10971 gen_load_fpr32(ctx
, fp32
, fs
);
10972 gen_helper_float_cvtd_w(fp64
, cpu_env
, fp32
);
10973 tcg_temp_free_i32(fp32
);
10974 gen_store_fpr64(ctx
, fp64
, fd
);
10975 tcg_temp_free_i64(fp64
);
10979 check_cp1_64bitmode(ctx
);
10981 TCGv_i32 fp32
= tcg_temp_new_i32();
10982 TCGv_i64 fp64
= tcg_temp_new_i64();
10984 gen_load_fpr64(ctx
, fp64
, fs
);
10985 gen_helper_float_cvts_l(fp32
, cpu_env
, fp64
);
10986 tcg_temp_free_i64(fp64
);
10987 gen_store_fpr32(ctx
, fp32
, fd
);
10988 tcg_temp_free_i32(fp32
);
10992 check_cp1_64bitmode(ctx
);
10994 TCGv_i64 fp0
= tcg_temp_new_i64();
10996 gen_load_fpr64(ctx
, fp0
, fs
);
10997 gen_helper_float_cvtd_l(fp0
, cpu_env
, fp0
);
10998 gen_store_fpr64(ctx
, fp0
, fd
);
10999 tcg_temp_free_i64(fp0
);
11002 case OPC_CVT_PS_PW
:
11005 TCGv_i64 fp0
= tcg_temp_new_i64();
11007 gen_load_fpr64(ctx
, fp0
, fs
);
11008 gen_helper_float_cvtps_pw(fp0
, cpu_env
, fp0
);
11009 gen_store_fpr64(ctx
, fp0
, fd
);
11010 tcg_temp_free_i64(fp0
);
11016 TCGv_i64 fp0
= tcg_temp_new_i64();
11017 TCGv_i64 fp1
= tcg_temp_new_i64();
11019 gen_load_fpr64(ctx
, fp0
, fs
);
11020 gen_load_fpr64(ctx
, fp1
, ft
);
11021 gen_helper_float_add_ps(fp0
, cpu_env
, fp0
, fp1
);
11022 tcg_temp_free_i64(fp1
);
11023 gen_store_fpr64(ctx
, fp0
, fd
);
11024 tcg_temp_free_i64(fp0
);
11030 TCGv_i64 fp0
= tcg_temp_new_i64();
11031 TCGv_i64 fp1
= tcg_temp_new_i64();
11033 gen_load_fpr64(ctx
, fp0
, fs
);
11034 gen_load_fpr64(ctx
, fp1
, ft
);
11035 gen_helper_float_sub_ps(fp0
, cpu_env
, fp0
, fp1
);
11036 tcg_temp_free_i64(fp1
);
11037 gen_store_fpr64(ctx
, fp0
, fd
);
11038 tcg_temp_free_i64(fp0
);
11044 TCGv_i64 fp0
= tcg_temp_new_i64();
11045 TCGv_i64 fp1
= tcg_temp_new_i64();
11047 gen_load_fpr64(ctx
, fp0
, fs
);
11048 gen_load_fpr64(ctx
, fp1
, ft
);
11049 gen_helper_float_mul_ps(fp0
, cpu_env
, fp0
, fp1
);
11050 tcg_temp_free_i64(fp1
);
11051 gen_store_fpr64(ctx
, fp0
, fd
);
11052 tcg_temp_free_i64(fp0
);
11058 TCGv_i64 fp0
= tcg_temp_new_i64();
11060 gen_load_fpr64(ctx
, fp0
, fs
);
11061 gen_helper_float_abs_ps(fp0
, fp0
);
11062 gen_store_fpr64(ctx
, fp0
, fd
);
11063 tcg_temp_free_i64(fp0
);
11069 TCGv_i64 fp0
= tcg_temp_new_i64();
11071 gen_load_fpr64(ctx
, fp0
, fs
);
11072 gen_store_fpr64(ctx
, fp0
, fd
);
11073 tcg_temp_free_i64(fp0
);
11079 TCGv_i64 fp0
= tcg_temp_new_i64();
11081 gen_load_fpr64(ctx
, fp0
, fs
);
11082 gen_helper_float_chs_ps(fp0
, fp0
);
11083 gen_store_fpr64(ctx
, fp0
, fd
);
11084 tcg_temp_free_i64(fp0
);
11089 gen_movcf_ps(ctx
, fs
, fd
, (ft
>> 2) & 0x7, ft
& 0x1);
11094 TCGLabel
*l1
= gen_new_label();
11098 tcg_gen_brcondi_tl(TCG_COND_NE
, cpu_gpr
[ft
], 0, l1
);
11100 fp0
= tcg_temp_new_i64();
11101 gen_load_fpr64(ctx
, fp0
, fs
);
11102 gen_store_fpr64(ctx
, fp0
, fd
);
11103 tcg_temp_free_i64(fp0
);
11110 TCGLabel
*l1
= gen_new_label();
11114 tcg_gen_brcondi_tl(TCG_COND_EQ
, cpu_gpr
[ft
], 0, l1
);
11115 fp0
= tcg_temp_new_i64();
11116 gen_load_fpr64(ctx
, fp0
, fs
);
11117 gen_store_fpr64(ctx
, fp0
, fd
);
11118 tcg_temp_free_i64(fp0
);
11126 TCGv_i64 fp0
= tcg_temp_new_i64();
11127 TCGv_i64 fp1
= tcg_temp_new_i64();
11129 gen_load_fpr64(ctx
, fp0
, ft
);
11130 gen_load_fpr64(ctx
, fp1
, fs
);
11131 gen_helper_float_addr_ps(fp0
, cpu_env
, fp0
, fp1
);
11132 tcg_temp_free_i64(fp1
);
11133 gen_store_fpr64(ctx
, fp0
, fd
);
11134 tcg_temp_free_i64(fp0
);
11140 TCGv_i64 fp0
= tcg_temp_new_i64();
11141 TCGv_i64 fp1
= tcg_temp_new_i64();
11143 gen_load_fpr64(ctx
, fp0
, ft
);
11144 gen_load_fpr64(ctx
, fp1
, fs
);
11145 gen_helper_float_mulr_ps(fp0
, cpu_env
, fp0
, fp1
);
11146 tcg_temp_free_i64(fp1
);
11147 gen_store_fpr64(ctx
, fp0
, fd
);
11148 tcg_temp_free_i64(fp0
);
11151 case OPC_RECIP2_PS
:
11154 TCGv_i64 fp0
= tcg_temp_new_i64();
11155 TCGv_i64 fp1
= tcg_temp_new_i64();
11157 gen_load_fpr64(ctx
, fp0
, fs
);
11158 gen_load_fpr64(ctx
, fp1
, ft
);
11159 gen_helper_float_recip2_ps(fp0
, cpu_env
, fp0
, fp1
);
11160 tcg_temp_free_i64(fp1
);
11161 gen_store_fpr64(ctx
, fp0
, fd
);
11162 tcg_temp_free_i64(fp0
);
11165 case OPC_RECIP1_PS
:
11168 TCGv_i64 fp0
= tcg_temp_new_i64();
11170 gen_load_fpr64(ctx
, fp0
, fs
);
11171 gen_helper_float_recip1_ps(fp0
, cpu_env
, fp0
);
11172 gen_store_fpr64(ctx
, fp0
, fd
);
11173 tcg_temp_free_i64(fp0
);
11176 case OPC_RSQRT1_PS
:
11179 TCGv_i64 fp0
= tcg_temp_new_i64();
11181 gen_load_fpr64(ctx
, fp0
, fs
);
11182 gen_helper_float_rsqrt1_ps(fp0
, cpu_env
, fp0
);
11183 gen_store_fpr64(ctx
, fp0
, fd
);
11184 tcg_temp_free_i64(fp0
);
11187 case OPC_RSQRT2_PS
:
11190 TCGv_i64 fp0
= tcg_temp_new_i64();
11191 TCGv_i64 fp1
= tcg_temp_new_i64();
11193 gen_load_fpr64(ctx
, fp0
, fs
);
11194 gen_load_fpr64(ctx
, fp1
, ft
);
11195 gen_helper_float_rsqrt2_ps(fp0
, cpu_env
, fp0
, fp1
);
11196 tcg_temp_free_i64(fp1
);
11197 gen_store_fpr64(ctx
, fp0
, fd
);
11198 tcg_temp_free_i64(fp0
);
11202 check_cp1_64bitmode(ctx
);
11204 TCGv_i32 fp0
= tcg_temp_new_i32();
11206 gen_load_fpr32h(ctx
, fp0
, fs
);
11207 gen_helper_float_cvts_pu(fp0
, cpu_env
, fp0
);
11208 gen_store_fpr32(ctx
, fp0
, fd
);
11209 tcg_temp_free_i32(fp0
);
11212 case OPC_CVT_PW_PS
:
11215 TCGv_i64 fp0
= tcg_temp_new_i64();
11217 gen_load_fpr64(ctx
, fp0
, fs
);
11218 gen_helper_float_cvtpw_ps(fp0
, cpu_env
, fp0
);
11219 gen_store_fpr64(ctx
, fp0
, fd
);
11220 tcg_temp_free_i64(fp0
);
11224 check_cp1_64bitmode(ctx
);
11226 TCGv_i32 fp0
= tcg_temp_new_i32();
11228 gen_load_fpr32(ctx
, fp0
, fs
);
11229 gen_helper_float_cvts_pl(fp0
, cpu_env
, fp0
);
11230 gen_store_fpr32(ctx
, fp0
, fd
);
11231 tcg_temp_free_i32(fp0
);
11237 TCGv_i32 fp0
= tcg_temp_new_i32();
11238 TCGv_i32 fp1
= tcg_temp_new_i32();
11240 gen_load_fpr32(ctx
, fp0
, fs
);
11241 gen_load_fpr32(ctx
, fp1
, ft
);
11242 gen_store_fpr32h(ctx
, fp0
, fd
);
11243 gen_store_fpr32(ctx
, fp1
, fd
);
11244 tcg_temp_free_i32(fp0
);
11245 tcg_temp_free_i32(fp1
);
11251 TCGv_i32 fp0
= tcg_temp_new_i32();
11252 TCGv_i32 fp1
= tcg_temp_new_i32();
11254 gen_load_fpr32(ctx
, fp0
, fs
);
11255 gen_load_fpr32h(ctx
, fp1
, ft
);
11256 gen_store_fpr32(ctx
, fp1
, fd
);
11257 gen_store_fpr32h(ctx
, fp0
, fd
);
11258 tcg_temp_free_i32(fp0
);
11259 tcg_temp_free_i32(fp1
);
11265 TCGv_i32 fp0
= tcg_temp_new_i32();
11266 TCGv_i32 fp1
= tcg_temp_new_i32();
11268 gen_load_fpr32h(ctx
, fp0
, fs
);
11269 gen_load_fpr32(ctx
, fp1
, ft
);
11270 gen_store_fpr32(ctx
, fp1
, fd
);
11271 gen_store_fpr32h(ctx
, fp0
, fd
);
11272 tcg_temp_free_i32(fp0
);
11273 tcg_temp_free_i32(fp1
);
11279 TCGv_i32 fp0
= tcg_temp_new_i32();
11280 TCGv_i32 fp1
= tcg_temp_new_i32();
11282 gen_load_fpr32h(ctx
, fp0
, fs
);
11283 gen_load_fpr32h(ctx
, fp1
, ft
);
11284 gen_store_fpr32(ctx
, fp1
, fd
);
11285 gen_store_fpr32h(ctx
, fp0
, fd
);
11286 tcg_temp_free_i32(fp0
);
11287 tcg_temp_free_i32(fp1
);
11291 case OPC_CMP_UN_PS
:
11292 case OPC_CMP_EQ_PS
:
11293 case OPC_CMP_UEQ_PS
:
11294 case OPC_CMP_OLT_PS
:
11295 case OPC_CMP_ULT_PS
:
11296 case OPC_CMP_OLE_PS
:
11297 case OPC_CMP_ULE_PS
:
11298 case OPC_CMP_SF_PS
:
11299 case OPC_CMP_NGLE_PS
:
11300 case OPC_CMP_SEQ_PS
:
11301 case OPC_CMP_NGL_PS
:
11302 case OPC_CMP_LT_PS
:
11303 case OPC_CMP_NGE_PS
:
11304 case OPC_CMP_LE_PS
:
11305 case OPC_CMP_NGT_PS
:
11306 if (ctx
->opcode
& (1 << 6)) {
11307 gen_cmpabs_ps(ctx
, func
- 48, ft
, fs
, cc
);
11309 gen_cmp_ps(ctx
, func
- 48, ft
, fs
, cc
);
11313 MIPS_INVAL("farith");
11314 gen_reserved_instruction(ctx
);
11319 /* Coprocessor 3 (FPU) */
11320 static void gen_flt3_ldst(DisasContext
*ctx
, uint32_t opc
,
11321 int fd
, int fs
, int base
, int index
)
11323 TCGv t0
= tcg_temp_new();
11326 gen_load_gpr(t0
, index
);
11327 } else if (index
== 0) {
11328 gen_load_gpr(t0
, base
);
11330 gen_op_addr_add(ctx
, t0
, cpu_gpr
[base
], cpu_gpr
[index
]);
11333 * Don't do NOP if destination is zero: we must perform the actual
11340 TCGv_i32 fp0
= tcg_temp_new_i32();
11342 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TESL
);
11343 tcg_gen_trunc_tl_i32(fp0
, t0
);
11344 gen_store_fpr32(ctx
, fp0
, fd
);
11345 tcg_temp_free_i32(fp0
);
11350 check_cp1_registers(ctx
, fd
);
11352 TCGv_i64 fp0
= tcg_temp_new_i64();
11353 tcg_gen_qemu_ld_i64(fp0
, t0
, ctx
->mem_idx
, MO_TEQ
);
11354 gen_store_fpr64(ctx
, fp0
, fd
);
11355 tcg_temp_free_i64(fp0
);
11359 check_cp1_64bitmode(ctx
);
11360 tcg_gen_andi_tl(t0
, t0
, ~0x7);
11362 TCGv_i64 fp0
= tcg_temp_new_i64();
11364 tcg_gen_qemu_ld_i64(fp0
, t0
, ctx
->mem_idx
, MO_TEQ
);
11365 gen_store_fpr64(ctx
, fp0
, fd
);
11366 tcg_temp_free_i64(fp0
);
11372 TCGv_i32 fp0
= tcg_temp_new_i32();
11373 gen_load_fpr32(ctx
, fp0
, fs
);
11374 tcg_gen_qemu_st_i32(fp0
, t0
, ctx
->mem_idx
, MO_TEUL
);
11375 tcg_temp_free_i32(fp0
);
11380 check_cp1_registers(ctx
, fs
);
11382 TCGv_i64 fp0
= tcg_temp_new_i64();
11383 gen_load_fpr64(ctx
, fp0
, fs
);
11384 tcg_gen_qemu_st_i64(fp0
, t0
, ctx
->mem_idx
, MO_TEQ
);
11385 tcg_temp_free_i64(fp0
);
11389 check_cp1_64bitmode(ctx
);
11390 tcg_gen_andi_tl(t0
, t0
, ~0x7);
11392 TCGv_i64 fp0
= tcg_temp_new_i64();
11393 gen_load_fpr64(ctx
, fp0
, fs
);
11394 tcg_gen_qemu_st_i64(fp0
, t0
, ctx
->mem_idx
, MO_TEQ
);
11395 tcg_temp_free_i64(fp0
);
11402 static void gen_flt3_arith(DisasContext
*ctx
, uint32_t opc
,
11403 int fd
, int fr
, int fs
, int ft
)
11409 TCGv t0
= tcg_temp_local_new();
11410 TCGv_i32 fp
= tcg_temp_new_i32();
11411 TCGv_i32 fph
= tcg_temp_new_i32();
11412 TCGLabel
*l1
= gen_new_label();
11413 TCGLabel
*l2
= gen_new_label();
11415 gen_load_gpr(t0
, fr
);
11416 tcg_gen_andi_tl(t0
, t0
, 0x7);
11418 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, 0, l1
);
11419 gen_load_fpr32(ctx
, fp
, fs
);
11420 gen_load_fpr32h(ctx
, fph
, fs
);
11421 gen_store_fpr32(ctx
, fp
, fd
);
11422 gen_store_fpr32h(ctx
, fph
, fd
);
11425 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, 4, l2
);
11427 #ifdef TARGET_WORDS_BIGENDIAN
11428 gen_load_fpr32(ctx
, fp
, fs
);
11429 gen_load_fpr32h(ctx
, fph
, ft
);
11430 gen_store_fpr32h(ctx
, fp
, fd
);
11431 gen_store_fpr32(ctx
, fph
, fd
);
11433 gen_load_fpr32h(ctx
, fph
, fs
);
11434 gen_load_fpr32(ctx
, fp
, ft
);
11435 gen_store_fpr32(ctx
, fph
, fd
);
11436 gen_store_fpr32h(ctx
, fp
, fd
);
11439 tcg_temp_free_i32(fp
);
11440 tcg_temp_free_i32(fph
);
11446 TCGv_i32 fp0
= tcg_temp_new_i32();
11447 TCGv_i32 fp1
= tcg_temp_new_i32();
11448 TCGv_i32 fp2
= tcg_temp_new_i32();
11450 gen_load_fpr32(ctx
, fp0
, fs
);
11451 gen_load_fpr32(ctx
, fp1
, ft
);
11452 gen_load_fpr32(ctx
, fp2
, fr
);
11453 gen_helper_float_madd_s(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11454 tcg_temp_free_i32(fp0
);
11455 tcg_temp_free_i32(fp1
);
11456 gen_store_fpr32(ctx
, fp2
, fd
);
11457 tcg_temp_free_i32(fp2
);
11462 check_cp1_registers(ctx
, fd
| fs
| ft
| fr
);
11464 TCGv_i64 fp0
= tcg_temp_new_i64();
11465 TCGv_i64 fp1
= tcg_temp_new_i64();
11466 TCGv_i64 fp2
= tcg_temp_new_i64();
11468 gen_load_fpr64(ctx
, fp0
, fs
);
11469 gen_load_fpr64(ctx
, fp1
, ft
);
11470 gen_load_fpr64(ctx
, fp2
, fr
);
11471 gen_helper_float_madd_d(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11472 tcg_temp_free_i64(fp0
);
11473 tcg_temp_free_i64(fp1
);
11474 gen_store_fpr64(ctx
, fp2
, fd
);
11475 tcg_temp_free_i64(fp2
);
11481 TCGv_i64 fp0
= tcg_temp_new_i64();
11482 TCGv_i64 fp1
= tcg_temp_new_i64();
11483 TCGv_i64 fp2
= tcg_temp_new_i64();
11485 gen_load_fpr64(ctx
, fp0
, fs
);
11486 gen_load_fpr64(ctx
, fp1
, ft
);
11487 gen_load_fpr64(ctx
, fp2
, fr
);
11488 gen_helper_float_madd_ps(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11489 tcg_temp_free_i64(fp0
);
11490 tcg_temp_free_i64(fp1
);
11491 gen_store_fpr64(ctx
, fp2
, fd
);
11492 tcg_temp_free_i64(fp2
);
11498 TCGv_i32 fp0
= tcg_temp_new_i32();
11499 TCGv_i32 fp1
= tcg_temp_new_i32();
11500 TCGv_i32 fp2
= tcg_temp_new_i32();
11502 gen_load_fpr32(ctx
, fp0
, fs
);
11503 gen_load_fpr32(ctx
, fp1
, ft
);
11504 gen_load_fpr32(ctx
, fp2
, fr
);
11505 gen_helper_float_msub_s(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11506 tcg_temp_free_i32(fp0
);
11507 tcg_temp_free_i32(fp1
);
11508 gen_store_fpr32(ctx
, fp2
, fd
);
11509 tcg_temp_free_i32(fp2
);
11514 check_cp1_registers(ctx
, fd
| fs
| ft
| fr
);
11516 TCGv_i64 fp0
= tcg_temp_new_i64();
11517 TCGv_i64 fp1
= tcg_temp_new_i64();
11518 TCGv_i64 fp2
= tcg_temp_new_i64();
11520 gen_load_fpr64(ctx
, fp0
, fs
);
11521 gen_load_fpr64(ctx
, fp1
, ft
);
11522 gen_load_fpr64(ctx
, fp2
, fr
);
11523 gen_helper_float_msub_d(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11524 tcg_temp_free_i64(fp0
);
11525 tcg_temp_free_i64(fp1
);
11526 gen_store_fpr64(ctx
, fp2
, fd
);
11527 tcg_temp_free_i64(fp2
);
11533 TCGv_i64 fp0
= tcg_temp_new_i64();
11534 TCGv_i64 fp1
= tcg_temp_new_i64();
11535 TCGv_i64 fp2
= tcg_temp_new_i64();
11537 gen_load_fpr64(ctx
, fp0
, fs
);
11538 gen_load_fpr64(ctx
, fp1
, ft
);
11539 gen_load_fpr64(ctx
, fp2
, fr
);
11540 gen_helper_float_msub_ps(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11541 tcg_temp_free_i64(fp0
);
11542 tcg_temp_free_i64(fp1
);
11543 gen_store_fpr64(ctx
, fp2
, fd
);
11544 tcg_temp_free_i64(fp2
);
11550 TCGv_i32 fp0
= tcg_temp_new_i32();
11551 TCGv_i32 fp1
= tcg_temp_new_i32();
11552 TCGv_i32 fp2
= tcg_temp_new_i32();
11554 gen_load_fpr32(ctx
, fp0
, fs
);
11555 gen_load_fpr32(ctx
, fp1
, ft
);
11556 gen_load_fpr32(ctx
, fp2
, fr
);
11557 gen_helper_float_nmadd_s(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11558 tcg_temp_free_i32(fp0
);
11559 tcg_temp_free_i32(fp1
);
11560 gen_store_fpr32(ctx
, fp2
, fd
);
11561 tcg_temp_free_i32(fp2
);
11566 check_cp1_registers(ctx
, fd
| fs
| ft
| fr
);
11568 TCGv_i64 fp0
= tcg_temp_new_i64();
11569 TCGv_i64 fp1
= tcg_temp_new_i64();
11570 TCGv_i64 fp2
= tcg_temp_new_i64();
11572 gen_load_fpr64(ctx
, fp0
, fs
);
11573 gen_load_fpr64(ctx
, fp1
, ft
);
11574 gen_load_fpr64(ctx
, fp2
, fr
);
11575 gen_helper_float_nmadd_d(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11576 tcg_temp_free_i64(fp0
);
11577 tcg_temp_free_i64(fp1
);
11578 gen_store_fpr64(ctx
, fp2
, fd
);
11579 tcg_temp_free_i64(fp2
);
11585 TCGv_i64 fp0
= tcg_temp_new_i64();
11586 TCGv_i64 fp1
= tcg_temp_new_i64();
11587 TCGv_i64 fp2
= tcg_temp_new_i64();
11589 gen_load_fpr64(ctx
, fp0
, fs
);
11590 gen_load_fpr64(ctx
, fp1
, ft
);
11591 gen_load_fpr64(ctx
, fp2
, fr
);
11592 gen_helper_float_nmadd_ps(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11593 tcg_temp_free_i64(fp0
);
11594 tcg_temp_free_i64(fp1
);
11595 gen_store_fpr64(ctx
, fp2
, fd
);
11596 tcg_temp_free_i64(fp2
);
11602 TCGv_i32 fp0
= tcg_temp_new_i32();
11603 TCGv_i32 fp1
= tcg_temp_new_i32();
11604 TCGv_i32 fp2
= tcg_temp_new_i32();
11606 gen_load_fpr32(ctx
, fp0
, fs
);
11607 gen_load_fpr32(ctx
, fp1
, ft
);
11608 gen_load_fpr32(ctx
, fp2
, fr
);
11609 gen_helper_float_nmsub_s(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11610 tcg_temp_free_i32(fp0
);
11611 tcg_temp_free_i32(fp1
);
11612 gen_store_fpr32(ctx
, fp2
, fd
);
11613 tcg_temp_free_i32(fp2
);
11618 check_cp1_registers(ctx
, fd
| fs
| ft
| fr
);
11620 TCGv_i64 fp0
= tcg_temp_new_i64();
11621 TCGv_i64 fp1
= tcg_temp_new_i64();
11622 TCGv_i64 fp2
= tcg_temp_new_i64();
11624 gen_load_fpr64(ctx
, fp0
, fs
);
11625 gen_load_fpr64(ctx
, fp1
, ft
);
11626 gen_load_fpr64(ctx
, fp2
, fr
);
11627 gen_helper_float_nmsub_d(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11628 tcg_temp_free_i64(fp0
);
11629 tcg_temp_free_i64(fp1
);
11630 gen_store_fpr64(ctx
, fp2
, fd
);
11631 tcg_temp_free_i64(fp2
);
11637 TCGv_i64 fp0
= tcg_temp_new_i64();
11638 TCGv_i64 fp1
= tcg_temp_new_i64();
11639 TCGv_i64 fp2
= tcg_temp_new_i64();
11641 gen_load_fpr64(ctx
, fp0
, fs
);
11642 gen_load_fpr64(ctx
, fp1
, ft
);
11643 gen_load_fpr64(ctx
, fp2
, fr
);
11644 gen_helper_float_nmsub_ps(fp2
, cpu_env
, fp0
, fp1
, fp2
);
11645 tcg_temp_free_i64(fp0
);
11646 tcg_temp_free_i64(fp1
);
11647 gen_store_fpr64(ctx
, fp2
, fd
);
11648 tcg_temp_free_i64(fp2
);
11652 MIPS_INVAL("flt3_arith");
11653 gen_reserved_instruction(ctx
);
11658 void gen_rdhwr(DisasContext
*ctx
, int rt
, int rd
, int sel
)
11662 #if !defined(CONFIG_USER_ONLY)
11664 * The Linux kernel will emulate rdhwr if it's not supported natively.
11665 * Therefore only check the ISA in system mode.
11667 check_insn(ctx
, ISA_MIPS_R2
);
11669 t0
= tcg_temp_new();
11673 gen_helper_rdhwr_cpunum(t0
, cpu_env
);
11674 gen_store_gpr(t0
, rt
);
11677 gen_helper_rdhwr_synci_step(t0
, cpu_env
);
11678 gen_store_gpr(t0
, rt
);
11681 if (tb_cflags(ctx
->base
.tb
) & CF_USE_ICOUNT
) {
11684 gen_helper_rdhwr_cc(t0
, cpu_env
);
11685 gen_store_gpr(t0
, rt
);
11687 * Break the TB to be able to take timer interrupts immediately
11688 * after reading count. DISAS_STOP isn't sufficient, we need to ensure
11689 * we break completely out of translated code.
11691 gen_save_pc(ctx
->base
.pc_next
+ 4);
11692 ctx
->base
.is_jmp
= DISAS_EXIT
;
11695 gen_helper_rdhwr_ccres(t0
, cpu_env
);
11696 gen_store_gpr(t0
, rt
);
11699 check_insn(ctx
, ISA_MIPS_R6
);
11702 * Performance counter registers are not implemented other than
11703 * control register 0.
11705 generate_exception(ctx
, EXCP_RI
);
11707 gen_helper_rdhwr_performance(t0
, cpu_env
);
11708 gen_store_gpr(t0
, rt
);
11711 check_insn(ctx
, ISA_MIPS_R6
);
11712 gen_helper_rdhwr_xnp(t0
, cpu_env
);
11713 gen_store_gpr(t0
, rt
);
11716 #if defined(CONFIG_USER_ONLY)
11717 tcg_gen_ld_tl(t0
, cpu_env
,
11718 offsetof(CPUMIPSState
, active_tc
.CP0_UserLocal
));
11719 gen_store_gpr(t0
, rt
);
11722 if ((ctx
->hflags
& MIPS_HFLAG_CP0
) ||
11723 (ctx
->hflags
& MIPS_HFLAG_HWRENA_ULR
)) {
11724 tcg_gen_ld_tl(t0
, cpu_env
,
11725 offsetof(CPUMIPSState
, active_tc
.CP0_UserLocal
));
11726 gen_store_gpr(t0
, rt
);
11728 gen_reserved_instruction(ctx
);
11732 default: /* Invalid */
11733 MIPS_INVAL("rdhwr");
11734 gen_reserved_instruction(ctx
);
11740 static inline void clear_branch_hflags(DisasContext
*ctx
)
11742 ctx
->hflags
&= ~MIPS_HFLAG_BMASK
;
11743 if (ctx
->base
.is_jmp
== DISAS_NEXT
) {
11744 save_cpu_state(ctx
, 0);
11747 * It is not safe to save ctx->hflags as hflags may be changed
11748 * in execution time by the instruction in delay / forbidden slot.
11750 tcg_gen_andi_i32(hflags
, hflags
, ~MIPS_HFLAG_BMASK
);
11754 static void gen_branch(DisasContext
*ctx
, int insn_bytes
)
11756 if (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
11757 int proc_hflags
= ctx
->hflags
& MIPS_HFLAG_BMASK
;
11758 /* Branches completion */
11759 clear_branch_hflags(ctx
);
11760 ctx
->base
.is_jmp
= DISAS_NORETURN
;
11761 /* FIXME: Need to clear can_do_io. */
11762 switch (proc_hflags
& MIPS_HFLAG_BMASK_BASE
) {
11763 case MIPS_HFLAG_FBNSLOT
:
11764 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ insn_bytes
);
11767 /* unconditional branch */
11768 if (proc_hflags
& MIPS_HFLAG_BX
) {
11769 tcg_gen_xori_i32(hflags
, hflags
, MIPS_HFLAG_M16
);
11771 gen_goto_tb(ctx
, 0, ctx
->btarget
);
11773 case MIPS_HFLAG_BL
:
11774 /* blikely taken case */
11775 gen_goto_tb(ctx
, 0, ctx
->btarget
);
11777 case MIPS_HFLAG_BC
:
11778 /* Conditional branch */
11780 TCGLabel
*l1
= gen_new_label();
11782 tcg_gen_brcondi_tl(TCG_COND_NE
, bcond
, 0, l1
);
11783 gen_goto_tb(ctx
, 1, ctx
->base
.pc_next
+ insn_bytes
);
11785 gen_goto_tb(ctx
, 0, ctx
->btarget
);
11788 case MIPS_HFLAG_BR
:
11789 /* unconditional branch to register */
11790 if (ctx
->insn_flags
& (ASE_MIPS16
| ASE_MICROMIPS
)) {
11791 TCGv t0
= tcg_temp_new();
11792 TCGv_i32 t1
= tcg_temp_new_i32();
11794 tcg_gen_andi_tl(t0
, btarget
, 0x1);
11795 tcg_gen_trunc_tl_i32(t1
, t0
);
11797 tcg_gen_andi_i32(hflags
, hflags
, ~(uint32_t)MIPS_HFLAG_M16
);
11798 tcg_gen_shli_i32(t1
, t1
, MIPS_HFLAG_M16_SHIFT
);
11799 tcg_gen_or_i32(hflags
, hflags
, t1
);
11800 tcg_temp_free_i32(t1
);
11802 tcg_gen_andi_tl(cpu_PC
, btarget
, ~(target_ulong
)0x1);
11804 tcg_gen_mov_tl(cpu_PC
, btarget
);
11806 if (ctx
->base
.singlestep_enabled
) {
11807 save_cpu_state(ctx
, 0);
11808 gen_helper_raise_exception_debug(cpu_env
);
11810 tcg_gen_lookup_and_goto_ptr();
11813 LOG_DISAS("unknown branch 0x%x\n", proc_hflags
);
11814 gen_reserved_instruction(ctx
);
11819 /* Compact Branches */
11820 static void gen_compute_compact_branch(DisasContext
*ctx
, uint32_t opc
,
11821 int rs
, int rt
, int32_t offset
)
11823 int bcond_compute
= 0;
11824 TCGv t0
= tcg_temp_new();
11825 TCGv t1
= tcg_temp_new();
11826 int m16_lowbit
= (ctx
->hflags
& MIPS_HFLAG_M16
) != 0;
11828 if (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
11829 #ifdef MIPS_DEBUG_DISAS
11830 LOG_DISAS("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx
11831 "\n", ctx
->base
.pc_next
);
11833 gen_reserved_instruction(ctx
);
11837 /* Load needed operands and calculate btarget */
11839 /* compact branch */
11840 case OPC_BOVC
: /* OPC_BEQZALC, OPC_BEQC */
11841 case OPC_BNVC
: /* OPC_BNEZALC, OPC_BNEC */
11842 gen_load_gpr(t0
, rs
);
11843 gen_load_gpr(t1
, rt
);
11845 ctx
->btarget
= addr_add(ctx
, ctx
->base
.pc_next
+ 4, offset
);
11846 if (rs
<= rt
&& rs
== 0) {
11847 /* OPC_BEQZALC, OPC_BNEZALC */
11848 tcg_gen_movi_tl(cpu_gpr
[31], ctx
->base
.pc_next
+ 4 + m16_lowbit
);
11851 case OPC_BLEZC
: /* OPC_BGEZC, OPC_BGEC */
11852 case OPC_BGTZC
: /* OPC_BLTZC, OPC_BLTC */
11853 gen_load_gpr(t0
, rs
);
11854 gen_load_gpr(t1
, rt
);
11856 ctx
->btarget
= addr_add(ctx
, ctx
->base
.pc_next
+ 4, offset
);
11858 case OPC_BLEZALC
: /* OPC_BGEZALC, OPC_BGEUC */
11859 case OPC_BGTZALC
: /* OPC_BLTZALC, OPC_BLTUC */
11860 if (rs
== 0 || rs
== rt
) {
11861 /* OPC_BLEZALC, OPC_BGEZALC */
11862 /* OPC_BGTZALC, OPC_BLTZALC */
11863 tcg_gen_movi_tl(cpu_gpr
[31], ctx
->base
.pc_next
+ 4 + m16_lowbit
);
11865 gen_load_gpr(t0
, rs
);
11866 gen_load_gpr(t1
, rt
);
11868 ctx
->btarget
= addr_add(ctx
, ctx
->base
.pc_next
+ 4, offset
);
11872 ctx
->btarget
= addr_add(ctx
, ctx
->base
.pc_next
+ 4, offset
);
11877 /* OPC_BEQZC, OPC_BNEZC */
11878 gen_load_gpr(t0
, rs
);
11880 ctx
->btarget
= addr_add(ctx
, ctx
->base
.pc_next
+ 4, offset
);
11882 /* OPC_JIC, OPC_JIALC */
11883 TCGv tbase
= tcg_temp_new();
11884 TCGv toffset
= tcg_temp_new();
11886 gen_load_gpr(tbase
, rt
);
11887 tcg_gen_movi_tl(toffset
, offset
);
11888 gen_op_addr_add(ctx
, btarget
, tbase
, toffset
);
11889 tcg_temp_free(tbase
);
11890 tcg_temp_free(toffset
);
11894 MIPS_INVAL("Compact branch/jump");
11895 gen_reserved_instruction(ctx
);
11899 if (bcond_compute
== 0) {
11900 /* Unconditional compact branch */
11903 tcg_gen_movi_tl(cpu_gpr
[31], ctx
->base
.pc_next
+ 4 + m16_lowbit
);
11906 ctx
->hflags
|= MIPS_HFLAG_BR
;
11909 tcg_gen_movi_tl(cpu_gpr
[31], ctx
->base
.pc_next
+ 4 + m16_lowbit
);
11912 ctx
->hflags
|= MIPS_HFLAG_B
;
11915 MIPS_INVAL("Compact branch/jump");
11916 gen_reserved_instruction(ctx
);
11920 /* Generating branch here as compact branches don't have delay slot */
11921 gen_branch(ctx
, 4);
11923 /* Conditional compact branch */
11924 TCGLabel
*fs
= gen_new_label();
11925 save_cpu_state(ctx
, 0);
11928 case OPC_BLEZALC
: /* OPC_BGEZALC, OPC_BGEUC */
11929 if (rs
== 0 && rt
!= 0) {
11931 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE
), t1
, 0, fs
);
11932 } else if (rs
!= 0 && rt
!= 0 && rs
== rt
) {
11934 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE
), t1
, 0, fs
);
11937 tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GEU
), t0
, t1
, fs
);
11940 case OPC_BGTZALC
: /* OPC_BLTZALC, OPC_BLTUC */
11941 if (rs
== 0 && rt
!= 0) {
11943 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT
), t1
, 0, fs
);
11944 } else if (rs
!= 0 && rt
!= 0 && rs
== rt
) {
11946 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT
), t1
, 0, fs
);
11949 tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LTU
), t0
, t1
, fs
);
11952 case OPC_BLEZC
: /* OPC_BGEZC, OPC_BGEC */
11953 if (rs
== 0 && rt
!= 0) {
11955 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE
), t1
, 0, fs
);
11956 } else if (rs
!= 0 && rt
!= 0 && rs
== rt
) {
11958 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE
), t1
, 0, fs
);
11961 tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GE
), t0
, t1
, fs
);
11964 case OPC_BGTZC
: /* OPC_BLTZC, OPC_BLTC */
11965 if (rs
== 0 && rt
!= 0) {
11967 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT
), t1
, 0, fs
);
11968 } else if (rs
!= 0 && rt
!= 0 && rs
== rt
) {
11970 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT
), t1
, 0, fs
);
11973 tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LT
), t0
, t1
, fs
);
11976 case OPC_BOVC
: /* OPC_BEQZALC, OPC_BEQC */
11977 case OPC_BNVC
: /* OPC_BNEZALC, OPC_BNEC */
11979 /* OPC_BOVC, OPC_BNVC */
11980 TCGv t2
= tcg_temp_new();
11981 TCGv t3
= tcg_temp_new();
11982 TCGv t4
= tcg_temp_new();
11983 TCGv input_overflow
= tcg_temp_new();
11985 gen_load_gpr(t0
, rs
);
11986 gen_load_gpr(t1
, rt
);
11987 tcg_gen_ext32s_tl(t2
, t0
);
11988 tcg_gen_setcond_tl(TCG_COND_NE
, input_overflow
, t2
, t0
);
11989 tcg_gen_ext32s_tl(t3
, t1
);
11990 tcg_gen_setcond_tl(TCG_COND_NE
, t4
, t3
, t1
);
11991 tcg_gen_or_tl(input_overflow
, input_overflow
, t4
);
11993 tcg_gen_add_tl(t4
, t2
, t3
);
11994 tcg_gen_ext32s_tl(t4
, t4
);
11995 tcg_gen_xor_tl(t2
, t2
, t3
);
11996 tcg_gen_xor_tl(t3
, t4
, t3
);
11997 tcg_gen_andc_tl(t2
, t3
, t2
);
11998 tcg_gen_setcondi_tl(TCG_COND_LT
, t4
, t2
, 0);
11999 tcg_gen_or_tl(t4
, t4
, input_overflow
);
12000 if (opc
== OPC_BOVC
) {
12002 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE
), t4
, 0, fs
);
12005 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ
), t4
, 0, fs
);
12007 tcg_temp_free(input_overflow
);
12011 } else if (rs
< rt
&& rs
== 0) {
12012 /* OPC_BEQZALC, OPC_BNEZALC */
12013 if (opc
== OPC_BEQZALC
) {
12015 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ
), t1
, 0, fs
);
12018 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE
), t1
, 0, fs
);
12021 /* OPC_BEQC, OPC_BNEC */
12022 if (opc
== OPC_BEQC
) {
12024 tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_EQ
), t0
, t1
, fs
);
12027 tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_NE
), t0
, t1
, fs
);
12032 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ
), t0
, 0, fs
);
12035 tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE
), t0
, 0, fs
);
12038 MIPS_INVAL("Compact conditional branch/jump");
12039 gen_reserved_instruction(ctx
);
12043 /* Generating branch here as compact branches don't have delay slot */
12044 gen_goto_tb(ctx
, 1, ctx
->btarget
);
12047 ctx
->hflags
|= MIPS_HFLAG_FBNSLOT
;
12055 void gen_addiupc(DisasContext
*ctx
, int rx
, int imm
,
12056 int is_64_bit
, int extended
)
12060 if (extended
&& (ctx
->hflags
& MIPS_HFLAG_BMASK
)) {
12061 gen_reserved_instruction(ctx
);
12065 t0
= tcg_temp_new();
12067 tcg_gen_movi_tl(t0
, pc_relative_pc(ctx
));
12068 tcg_gen_addi_tl(cpu_gpr
[rx
], t0
, imm
);
12070 tcg_gen_ext32s_tl(cpu_gpr
[rx
], cpu_gpr
[rx
]);
12076 static void gen_cache_operation(DisasContext
*ctx
, uint32_t op
, int base
,
12079 TCGv_i32 t0
= tcg_const_i32(op
);
12080 TCGv t1
= tcg_temp_new();
12081 gen_base_offset_addr(ctx
, t1
, base
, offset
);
12082 gen_helper_cache(cpu_env
, t1
, t0
);
12084 tcg_temp_free_i32(t0
);
12087 static inline bool is_uhi(int sdbbp_code
)
12089 #ifdef CONFIG_USER_ONLY
12092 return semihosting_enabled() && sdbbp_code
== 1;
12096 #ifdef CONFIG_USER_ONLY
12097 /* The above should dead-code away any calls to this..*/
12098 static inline void gen_helper_do_semihosting(void *env
)
12100 g_assert_not_reached();
12104 void gen_ldxs(DisasContext
*ctx
, int base
, int index
, int rd
)
12106 TCGv t0
= tcg_temp_new();
12107 TCGv t1
= tcg_temp_new();
12109 gen_load_gpr(t0
, base
);
12112 gen_load_gpr(t1
, index
);
12113 tcg_gen_shli_tl(t1
, t1
, 2);
12114 gen_op_addr_add(ctx
, t0
, t1
, t0
);
12117 tcg_gen_qemu_ld_tl(t1
, t0
, ctx
->mem_idx
, MO_TESL
);
12118 gen_store_gpr(t1
, rd
);
12124 static void gen_sync(int stype
)
12126 TCGBar tcg_mo
= TCG_BAR_SC
;
12129 case 0x4: /* SYNC_WMB */
12130 tcg_mo
|= TCG_MO_ST_ST
;
12132 case 0x10: /* SYNC_MB */
12133 tcg_mo
|= TCG_MO_ALL
;
12135 case 0x11: /* SYNC_ACQUIRE */
12136 tcg_mo
|= TCG_MO_LD_LD
| TCG_MO_LD_ST
;
12138 case 0x12: /* SYNC_RELEASE */
12139 tcg_mo
|= TCG_MO_ST_ST
| TCG_MO_LD_ST
;
12141 case 0x13: /* SYNC_RMB */
12142 tcg_mo
|= TCG_MO_LD_LD
;
12145 tcg_mo
|= TCG_MO_ALL
;
12149 tcg_gen_mb(tcg_mo
);
12152 /* ISA extensions (ASEs) */
12154 /* MIPS16 extension to MIPS32 */
12155 #include "mips16e_translate.c.inc"
12157 /* microMIPS extension to MIPS32/MIPS64 */
12160 * Values for microMIPS fmt field. Variable-width, depending on which
12161 * formats the instruction supports.
12180 #include "micromips_translate.c.inc"
12182 #include "nanomips_translate.c.inc"
12184 /* MIPSDSP functions. */
12185 static void gen_mipsdsp_ld(DisasContext
*ctx
, uint32_t opc
,
12186 int rd
, int base
, int offset
)
12191 t0
= tcg_temp_new();
12194 gen_load_gpr(t0
, offset
);
12195 } else if (offset
== 0) {
12196 gen_load_gpr(t0
, base
);
12198 gen_op_addr_add(ctx
, t0
, cpu_gpr
[base
], cpu_gpr
[offset
]);
12203 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_UB
);
12204 gen_store_gpr(t0
, rd
);
12207 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TESW
);
12208 gen_store_gpr(t0
, rd
);
12211 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TESL
);
12212 gen_store_gpr(t0
, rd
);
12214 #if defined(TARGET_MIPS64)
12216 tcg_gen_qemu_ld_tl(t0
, t0
, ctx
->mem_idx
, MO_TEQ
);
12217 gen_store_gpr(t0
, rd
);
12224 static void gen_mipsdsp_arith(DisasContext
*ctx
, uint32_t op1
, uint32_t op2
,
12225 int ret
, int v1
, int v2
)
12231 /* Treat as NOP. */
12235 v1_t
= tcg_temp_new();
12236 v2_t
= tcg_temp_new();
12238 gen_load_gpr(v1_t
, v1
);
12239 gen_load_gpr(v2_t
, v2
);
12242 /* OPC_MULT_G_2E is equal OPC_ADDUH_QB_DSP */
12243 case OPC_MULT_G_2E
:
12247 gen_helper_adduh_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
12249 case OPC_ADDUH_R_QB
:
12250 gen_helper_adduh_r_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
12253 gen_helper_addqh_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
12255 case OPC_ADDQH_R_PH
:
12256 gen_helper_addqh_r_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
12259 gen_helper_addqh_w(cpu_gpr
[ret
], v1_t
, v2_t
);
12261 case OPC_ADDQH_R_W
:
12262 gen_helper_addqh_r_w(cpu_gpr
[ret
], v1_t
, v2_t
);
12265 gen_helper_subuh_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
12267 case OPC_SUBUH_R_QB
:
12268 gen_helper_subuh_r_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
12271 gen_helper_subqh_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
12273 case OPC_SUBQH_R_PH
:
12274 gen_helper_subqh_r_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
12277 gen_helper_subqh_w(cpu_gpr
[ret
], v1_t
, v2_t
);
12279 case OPC_SUBQH_R_W
:
12280 gen_helper_subqh_r_w(cpu_gpr
[ret
], v1_t
, v2_t
);
12284 case OPC_ABSQ_S_PH_DSP
:
12286 case OPC_ABSQ_S_QB
:
12288 gen_helper_absq_s_qb(cpu_gpr
[ret
], v2_t
, cpu_env
);
12290 case OPC_ABSQ_S_PH
:
12292 gen_helper_absq_s_ph(cpu_gpr
[ret
], v2_t
, cpu_env
);
12296 gen_helper_absq_s_w(cpu_gpr
[ret
], v2_t
, cpu_env
);
12298 case OPC_PRECEQ_W_PHL
:
12300 tcg_gen_andi_tl(cpu_gpr
[ret
], v2_t
, 0xFFFF0000);
12301 tcg_gen_ext32s_tl(cpu_gpr
[ret
], cpu_gpr
[ret
]);
12303 case OPC_PRECEQ_W_PHR
:
12305 tcg_gen_andi_tl(cpu_gpr
[ret
], v2_t
, 0x0000FFFF);
12306 tcg_gen_shli_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], 16);
12307 tcg_gen_ext32s_tl(cpu_gpr
[ret
], cpu_gpr
[ret
]);
12309 case OPC_PRECEQU_PH_QBL
:
12311 gen_helper_precequ_ph_qbl(cpu_gpr
[ret
], v2_t
);
12313 case OPC_PRECEQU_PH_QBR
:
12315 gen_helper_precequ_ph_qbr(cpu_gpr
[ret
], v2_t
);
12317 case OPC_PRECEQU_PH_QBLA
:
12319 gen_helper_precequ_ph_qbla(cpu_gpr
[ret
], v2_t
);
12321 case OPC_PRECEQU_PH_QBRA
:
12323 gen_helper_precequ_ph_qbra(cpu_gpr
[ret
], v2_t
);
12325 case OPC_PRECEU_PH_QBL
:
12327 gen_helper_preceu_ph_qbl(cpu_gpr
[ret
], v2_t
);
12329 case OPC_PRECEU_PH_QBR
:
12331 gen_helper_preceu_ph_qbr(cpu_gpr
[ret
], v2_t
);
12333 case OPC_PRECEU_PH_QBLA
:
12335 gen_helper_preceu_ph_qbla(cpu_gpr
[ret
], v2_t
);
12337 case OPC_PRECEU_PH_QBRA
:
12339 gen_helper_preceu_ph_qbra(cpu_gpr
[ret
], v2_t
);
12343 case OPC_ADDU_QB_DSP
:
12347 gen_helper_addq_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12349 case OPC_ADDQ_S_PH
:
12351 gen_helper_addq_s_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12355 gen_helper_addq_s_w(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12359 gen_helper_addu_qb(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12361 case OPC_ADDU_S_QB
:
12363 gen_helper_addu_s_qb(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12367 gen_helper_addu_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12369 case OPC_ADDU_S_PH
:
12371 gen_helper_addu_s_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12375 gen_helper_subq_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12377 case OPC_SUBQ_S_PH
:
12379 gen_helper_subq_s_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12383 gen_helper_subq_s_w(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12387 gen_helper_subu_qb(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12389 case OPC_SUBU_S_QB
:
12391 gen_helper_subu_s_qb(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12395 gen_helper_subu_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12397 case OPC_SUBU_S_PH
:
12399 gen_helper_subu_s_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12403 gen_helper_addsc(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12407 gen_helper_addwc(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12411 gen_helper_modsub(cpu_gpr
[ret
], v1_t
, v2_t
);
12413 case OPC_RADDU_W_QB
:
12415 gen_helper_raddu_w_qb(cpu_gpr
[ret
], v1_t
);
12419 case OPC_CMPU_EQ_QB_DSP
:
12421 case OPC_PRECR_QB_PH
:
12423 gen_helper_precr_qb_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
12425 case OPC_PRECRQ_QB_PH
:
12427 gen_helper_precrq_qb_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
12429 case OPC_PRECR_SRA_PH_W
:
12432 TCGv_i32 sa_t
= tcg_const_i32(v2
);
12433 gen_helper_precr_sra_ph_w(cpu_gpr
[ret
], sa_t
, v1_t
,
12435 tcg_temp_free_i32(sa_t
);
12438 case OPC_PRECR_SRA_R_PH_W
:
12441 TCGv_i32 sa_t
= tcg_const_i32(v2
);
12442 gen_helper_precr_sra_r_ph_w(cpu_gpr
[ret
], sa_t
, v1_t
,
12444 tcg_temp_free_i32(sa_t
);
12447 case OPC_PRECRQ_PH_W
:
12449 gen_helper_precrq_ph_w(cpu_gpr
[ret
], v1_t
, v2_t
);
12451 case OPC_PRECRQ_RS_PH_W
:
12453 gen_helper_precrq_rs_ph_w(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12455 case OPC_PRECRQU_S_QB_PH
:
12457 gen_helper_precrqu_s_qb_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12461 #ifdef TARGET_MIPS64
12462 case OPC_ABSQ_S_QH_DSP
:
12464 case OPC_PRECEQ_L_PWL
:
12466 tcg_gen_andi_tl(cpu_gpr
[ret
], v2_t
, 0xFFFFFFFF00000000ull
);
12468 case OPC_PRECEQ_L_PWR
:
12470 tcg_gen_shli_tl(cpu_gpr
[ret
], v2_t
, 32);
12472 case OPC_PRECEQ_PW_QHL
:
12474 gen_helper_preceq_pw_qhl(cpu_gpr
[ret
], v2_t
);
12476 case OPC_PRECEQ_PW_QHR
:
12478 gen_helper_preceq_pw_qhr(cpu_gpr
[ret
], v2_t
);
12480 case OPC_PRECEQ_PW_QHLA
:
12482 gen_helper_preceq_pw_qhla(cpu_gpr
[ret
], v2_t
);
12484 case OPC_PRECEQ_PW_QHRA
:
12486 gen_helper_preceq_pw_qhra(cpu_gpr
[ret
], v2_t
);
12488 case OPC_PRECEQU_QH_OBL
:
12490 gen_helper_precequ_qh_obl(cpu_gpr
[ret
], v2_t
);
12492 case OPC_PRECEQU_QH_OBR
:
12494 gen_helper_precequ_qh_obr(cpu_gpr
[ret
], v2_t
);
12496 case OPC_PRECEQU_QH_OBLA
:
12498 gen_helper_precequ_qh_obla(cpu_gpr
[ret
], v2_t
);
12500 case OPC_PRECEQU_QH_OBRA
:
12502 gen_helper_precequ_qh_obra(cpu_gpr
[ret
], v2_t
);
12504 case OPC_PRECEU_QH_OBL
:
12506 gen_helper_preceu_qh_obl(cpu_gpr
[ret
], v2_t
);
12508 case OPC_PRECEU_QH_OBR
:
12510 gen_helper_preceu_qh_obr(cpu_gpr
[ret
], v2_t
);
12512 case OPC_PRECEU_QH_OBLA
:
12514 gen_helper_preceu_qh_obla(cpu_gpr
[ret
], v2_t
);
12516 case OPC_PRECEU_QH_OBRA
:
12518 gen_helper_preceu_qh_obra(cpu_gpr
[ret
], v2_t
);
12520 case OPC_ABSQ_S_OB
:
12522 gen_helper_absq_s_ob(cpu_gpr
[ret
], v2_t
, cpu_env
);
12524 case OPC_ABSQ_S_PW
:
12526 gen_helper_absq_s_pw(cpu_gpr
[ret
], v2_t
, cpu_env
);
12528 case OPC_ABSQ_S_QH
:
12530 gen_helper_absq_s_qh(cpu_gpr
[ret
], v2_t
, cpu_env
);
12534 case OPC_ADDU_OB_DSP
:
12536 case OPC_RADDU_L_OB
:
12538 gen_helper_raddu_l_ob(cpu_gpr
[ret
], v1_t
);
12542 gen_helper_subq_pw(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12544 case OPC_SUBQ_S_PW
:
12546 gen_helper_subq_s_pw(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12550 gen_helper_subq_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12552 case OPC_SUBQ_S_QH
:
12554 gen_helper_subq_s_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12558 gen_helper_subu_ob(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12560 case OPC_SUBU_S_OB
:
12562 gen_helper_subu_s_ob(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12566 gen_helper_subu_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12568 case OPC_SUBU_S_QH
:
12570 gen_helper_subu_s_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12574 gen_helper_subuh_ob(cpu_gpr
[ret
], v1_t
, v2_t
);
12576 case OPC_SUBUH_R_OB
:
12578 gen_helper_subuh_r_ob(cpu_gpr
[ret
], v1_t
, v2_t
);
12582 gen_helper_addq_pw(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12584 case OPC_ADDQ_S_PW
:
12586 gen_helper_addq_s_pw(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12590 gen_helper_addq_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12592 case OPC_ADDQ_S_QH
:
12594 gen_helper_addq_s_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12598 gen_helper_addu_ob(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12600 case OPC_ADDU_S_OB
:
12602 gen_helper_addu_s_ob(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12606 gen_helper_addu_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12608 case OPC_ADDU_S_QH
:
12610 gen_helper_addu_s_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12614 gen_helper_adduh_ob(cpu_gpr
[ret
], v1_t
, v2_t
);
12616 case OPC_ADDUH_R_OB
:
12618 gen_helper_adduh_r_ob(cpu_gpr
[ret
], v1_t
, v2_t
);
12622 case OPC_CMPU_EQ_OB_DSP
:
12624 case OPC_PRECR_OB_QH
:
12626 gen_helper_precr_ob_qh(cpu_gpr
[ret
], v1_t
, v2_t
);
12628 case OPC_PRECR_SRA_QH_PW
:
12631 TCGv_i32 ret_t
= tcg_const_i32(ret
);
12632 gen_helper_precr_sra_qh_pw(v2_t
, v1_t
, v2_t
, ret_t
);
12633 tcg_temp_free_i32(ret_t
);
12636 case OPC_PRECR_SRA_R_QH_PW
:
12639 TCGv_i32 sa_v
= tcg_const_i32(ret
);
12640 gen_helper_precr_sra_r_qh_pw(v2_t
, v1_t
, v2_t
, sa_v
);
12641 tcg_temp_free_i32(sa_v
);
12644 case OPC_PRECRQ_OB_QH
:
12646 gen_helper_precrq_ob_qh(cpu_gpr
[ret
], v1_t
, v2_t
);
12648 case OPC_PRECRQ_PW_L
:
12650 gen_helper_precrq_pw_l(cpu_gpr
[ret
], v1_t
, v2_t
);
12652 case OPC_PRECRQ_QH_PW
:
12654 gen_helper_precrq_qh_pw(cpu_gpr
[ret
], v1_t
, v2_t
);
12656 case OPC_PRECRQ_RS_QH_PW
:
12658 gen_helper_precrq_rs_qh_pw(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12660 case OPC_PRECRQU_S_OB_QH
:
12662 gen_helper_precrqu_s_ob_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12669 tcg_temp_free(v1_t
);
12670 tcg_temp_free(v2_t
);
12673 static void gen_mipsdsp_shift(DisasContext
*ctx
, uint32_t opc
,
12674 int ret
, int v1
, int v2
)
12682 /* Treat as NOP. */
12686 t0
= tcg_temp_new();
12687 v1_t
= tcg_temp_new();
12688 v2_t
= tcg_temp_new();
12690 tcg_gen_movi_tl(t0
, v1
);
12691 gen_load_gpr(v1_t
, v1
);
12692 gen_load_gpr(v2_t
, v2
);
12695 case OPC_SHLL_QB_DSP
:
12697 op2
= MASK_SHLL_QB(ctx
->opcode
);
12701 gen_helper_shll_qb(cpu_gpr
[ret
], t0
, v2_t
, cpu_env
);
12705 gen_helper_shll_qb(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12709 gen_helper_shll_ph(cpu_gpr
[ret
], t0
, v2_t
, cpu_env
);
12713 gen_helper_shll_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12715 case OPC_SHLL_S_PH
:
12717 gen_helper_shll_s_ph(cpu_gpr
[ret
], t0
, v2_t
, cpu_env
);
12719 case OPC_SHLLV_S_PH
:
12721 gen_helper_shll_s_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12725 gen_helper_shll_s_w(cpu_gpr
[ret
], t0
, v2_t
, cpu_env
);
12727 case OPC_SHLLV_S_W
:
12729 gen_helper_shll_s_w(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12733 gen_helper_shrl_qb(cpu_gpr
[ret
], t0
, v2_t
);
12737 gen_helper_shrl_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
12741 gen_helper_shrl_ph(cpu_gpr
[ret
], t0
, v2_t
);
12745 gen_helper_shrl_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
12749 gen_helper_shra_qb(cpu_gpr
[ret
], t0
, v2_t
);
12751 case OPC_SHRA_R_QB
:
12753 gen_helper_shra_r_qb(cpu_gpr
[ret
], t0
, v2_t
);
12757 gen_helper_shra_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
12759 case OPC_SHRAV_R_QB
:
12761 gen_helper_shra_r_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
12765 gen_helper_shra_ph(cpu_gpr
[ret
], t0
, v2_t
);
12767 case OPC_SHRA_R_PH
:
12769 gen_helper_shra_r_ph(cpu_gpr
[ret
], t0
, v2_t
);
12773 gen_helper_shra_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
12775 case OPC_SHRAV_R_PH
:
12777 gen_helper_shra_r_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
12781 gen_helper_shra_r_w(cpu_gpr
[ret
], t0
, v2_t
);
12783 case OPC_SHRAV_R_W
:
12785 gen_helper_shra_r_w(cpu_gpr
[ret
], v1_t
, v2_t
);
12787 default: /* Invalid */
12788 MIPS_INVAL("MASK SHLL.QB");
12789 gen_reserved_instruction(ctx
);
12794 #ifdef TARGET_MIPS64
12795 case OPC_SHLL_OB_DSP
:
12796 op2
= MASK_SHLL_OB(ctx
->opcode
);
12800 gen_helper_shll_pw(cpu_gpr
[ret
], v2_t
, t0
, cpu_env
);
12804 gen_helper_shll_pw(cpu_gpr
[ret
], v2_t
, v1_t
, cpu_env
);
12806 case OPC_SHLL_S_PW
:
12808 gen_helper_shll_s_pw(cpu_gpr
[ret
], v2_t
, t0
, cpu_env
);
12810 case OPC_SHLLV_S_PW
:
12812 gen_helper_shll_s_pw(cpu_gpr
[ret
], v2_t
, v1_t
, cpu_env
);
12816 gen_helper_shll_ob(cpu_gpr
[ret
], v2_t
, t0
, cpu_env
);
12820 gen_helper_shll_ob(cpu_gpr
[ret
], v2_t
, v1_t
, cpu_env
);
12824 gen_helper_shll_qh(cpu_gpr
[ret
], v2_t
, t0
, cpu_env
);
12828 gen_helper_shll_qh(cpu_gpr
[ret
], v2_t
, v1_t
, cpu_env
);
12830 case OPC_SHLL_S_QH
:
12832 gen_helper_shll_s_qh(cpu_gpr
[ret
], v2_t
, t0
, cpu_env
);
12834 case OPC_SHLLV_S_QH
:
12836 gen_helper_shll_s_qh(cpu_gpr
[ret
], v2_t
, v1_t
, cpu_env
);
12840 gen_helper_shra_ob(cpu_gpr
[ret
], v2_t
, t0
);
12844 gen_helper_shra_ob(cpu_gpr
[ret
], v2_t
, v1_t
);
12846 case OPC_SHRA_R_OB
:
12848 gen_helper_shra_r_ob(cpu_gpr
[ret
], v2_t
, t0
);
12850 case OPC_SHRAV_R_OB
:
12852 gen_helper_shra_r_ob(cpu_gpr
[ret
], v2_t
, v1_t
);
12856 gen_helper_shra_pw(cpu_gpr
[ret
], v2_t
, t0
);
12860 gen_helper_shra_pw(cpu_gpr
[ret
], v2_t
, v1_t
);
12862 case OPC_SHRA_R_PW
:
12864 gen_helper_shra_r_pw(cpu_gpr
[ret
], v2_t
, t0
);
12866 case OPC_SHRAV_R_PW
:
12868 gen_helper_shra_r_pw(cpu_gpr
[ret
], v2_t
, v1_t
);
12872 gen_helper_shra_qh(cpu_gpr
[ret
], v2_t
, t0
);
12876 gen_helper_shra_qh(cpu_gpr
[ret
], v2_t
, v1_t
);
12878 case OPC_SHRA_R_QH
:
12880 gen_helper_shra_r_qh(cpu_gpr
[ret
], v2_t
, t0
);
12882 case OPC_SHRAV_R_QH
:
12884 gen_helper_shra_r_qh(cpu_gpr
[ret
], v2_t
, v1_t
);
12888 gen_helper_shrl_ob(cpu_gpr
[ret
], v2_t
, t0
);
12892 gen_helper_shrl_ob(cpu_gpr
[ret
], v2_t
, v1_t
);
12896 gen_helper_shrl_qh(cpu_gpr
[ret
], v2_t
, t0
);
12900 gen_helper_shrl_qh(cpu_gpr
[ret
], v2_t
, v1_t
);
12902 default: /* Invalid */
12903 MIPS_INVAL("MASK SHLL.OB");
12904 gen_reserved_instruction(ctx
);
12912 tcg_temp_free(v1_t
);
12913 tcg_temp_free(v2_t
);
12916 static void gen_mipsdsp_multiply(DisasContext
*ctx
, uint32_t op1
, uint32_t op2
,
12917 int ret
, int v1
, int v2
, int check_ret
)
12923 if ((ret
== 0) && (check_ret
== 1)) {
12924 /* Treat as NOP. */
12928 t0
= tcg_temp_new_i32();
12929 v1_t
= tcg_temp_new();
12930 v2_t
= tcg_temp_new();
12932 tcg_gen_movi_i32(t0
, ret
);
12933 gen_load_gpr(v1_t
, v1
);
12934 gen_load_gpr(v2_t
, v2
);
12938 * OPC_MULT_G_2E, OPC_ADDUH_QB_DSP, OPC_MUL_PH_DSP have
12939 * the same mask and op1.
12941 case OPC_MULT_G_2E
:
12945 gen_helper_mul_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12948 gen_helper_mul_s_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12951 gen_helper_mulq_s_w(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12953 case OPC_MULQ_RS_W
:
12954 gen_helper_mulq_rs_w(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
12958 case OPC_DPA_W_PH_DSP
:
12960 case OPC_DPAU_H_QBL
:
12962 gen_helper_dpau_h_qbl(t0
, v1_t
, v2_t
, cpu_env
);
12964 case OPC_DPAU_H_QBR
:
12966 gen_helper_dpau_h_qbr(t0
, v1_t
, v2_t
, cpu_env
);
12968 case OPC_DPSU_H_QBL
:
12970 gen_helper_dpsu_h_qbl(t0
, v1_t
, v2_t
, cpu_env
);
12972 case OPC_DPSU_H_QBR
:
12974 gen_helper_dpsu_h_qbr(t0
, v1_t
, v2_t
, cpu_env
);
12978 gen_helper_dpa_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
12980 case OPC_DPAX_W_PH
:
12982 gen_helper_dpax_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
12984 case OPC_DPAQ_S_W_PH
:
12986 gen_helper_dpaq_s_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
12988 case OPC_DPAQX_S_W_PH
:
12990 gen_helper_dpaqx_s_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
12992 case OPC_DPAQX_SA_W_PH
:
12994 gen_helper_dpaqx_sa_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
12998 gen_helper_dps_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
13000 case OPC_DPSX_W_PH
:
13002 gen_helper_dpsx_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
13004 case OPC_DPSQ_S_W_PH
:
13006 gen_helper_dpsq_s_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
13008 case OPC_DPSQX_S_W_PH
:
13010 gen_helper_dpsqx_s_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
13012 case OPC_DPSQX_SA_W_PH
:
13014 gen_helper_dpsqx_sa_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
13016 case OPC_MULSAQ_S_W_PH
:
13018 gen_helper_mulsaq_s_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
13020 case OPC_DPAQ_SA_L_W
:
13022 gen_helper_dpaq_sa_l_w(t0
, v1_t
, v2_t
, cpu_env
);
13024 case OPC_DPSQ_SA_L_W
:
13026 gen_helper_dpsq_sa_l_w(t0
, v1_t
, v2_t
, cpu_env
);
13028 case OPC_MAQ_S_W_PHL
:
13030 gen_helper_maq_s_w_phl(t0
, v1_t
, v2_t
, cpu_env
);
13032 case OPC_MAQ_S_W_PHR
:
13034 gen_helper_maq_s_w_phr(t0
, v1_t
, v2_t
, cpu_env
);
13036 case OPC_MAQ_SA_W_PHL
:
13038 gen_helper_maq_sa_w_phl(t0
, v1_t
, v2_t
, cpu_env
);
13040 case OPC_MAQ_SA_W_PHR
:
13042 gen_helper_maq_sa_w_phr(t0
, v1_t
, v2_t
, cpu_env
);
13044 case OPC_MULSA_W_PH
:
13046 gen_helper_mulsa_w_ph(t0
, v1_t
, v2_t
, cpu_env
);
13050 #ifdef TARGET_MIPS64
13051 case OPC_DPAQ_W_QH_DSP
:
13053 int ac
= ret
& 0x03;
13054 tcg_gen_movi_i32(t0
, ac
);
13059 gen_helper_dmadd(v1_t
, v2_t
, t0
, cpu_env
);
13063 gen_helper_dmaddu(v1_t
, v2_t
, t0
, cpu_env
);
13067 gen_helper_dmsub(v1_t
, v2_t
, t0
, cpu_env
);
13071 gen_helper_dmsubu(v1_t
, v2_t
, t0
, cpu_env
);
13075 gen_helper_dpa_w_qh(v1_t
, v2_t
, t0
, cpu_env
);
13077 case OPC_DPAQ_S_W_QH
:
13079 gen_helper_dpaq_s_w_qh(v1_t
, v2_t
, t0
, cpu_env
);
13081 case OPC_DPAQ_SA_L_PW
:
13083 gen_helper_dpaq_sa_l_pw(v1_t
, v2_t
, t0
, cpu_env
);
13085 case OPC_DPAU_H_OBL
:
13087 gen_helper_dpau_h_obl(v1_t
, v2_t
, t0
, cpu_env
);
13089 case OPC_DPAU_H_OBR
:
13091 gen_helper_dpau_h_obr(v1_t
, v2_t
, t0
, cpu_env
);
13095 gen_helper_dps_w_qh(v1_t
, v2_t
, t0
, cpu_env
);
13097 case OPC_DPSQ_S_W_QH
:
13099 gen_helper_dpsq_s_w_qh(v1_t
, v2_t
, t0
, cpu_env
);
13101 case OPC_DPSQ_SA_L_PW
:
13103 gen_helper_dpsq_sa_l_pw(v1_t
, v2_t
, t0
, cpu_env
);
13105 case OPC_DPSU_H_OBL
:
13107 gen_helper_dpsu_h_obl(v1_t
, v2_t
, t0
, cpu_env
);
13109 case OPC_DPSU_H_OBR
:
13111 gen_helper_dpsu_h_obr(v1_t
, v2_t
, t0
, cpu_env
);
13113 case OPC_MAQ_S_L_PWL
:
13115 gen_helper_maq_s_l_pwl(v1_t
, v2_t
, t0
, cpu_env
);
13117 case OPC_MAQ_S_L_PWR
:
13119 gen_helper_maq_s_l_pwr(v1_t
, v2_t
, t0
, cpu_env
);
13121 case OPC_MAQ_S_W_QHLL
:
13123 gen_helper_maq_s_w_qhll(v1_t
, v2_t
, t0
, cpu_env
);
13125 case OPC_MAQ_SA_W_QHLL
:
13127 gen_helper_maq_sa_w_qhll(v1_t
, v2_t
, t0
, cpu_env
);
13129 case OPC_MAQ_S_W_QHLR
:
13131 gen_helper_maq_s_w_qhlr(v1_t
, v2_t
, t0
, cpu_env
);
13133 case OPC_MAQ_SA_W_QHLR
:
13135 gen_helper_maq_sa_w_qhlr(v1_t
, v2_t
, t0
, cpu_env
);
13137 case OPC_MAQ_S_W_QHRL
:
13139 gen_helper_maq_s_w_qhrl(v1_t
, v2_t
, t0
, cpu_env
);
13141 case OPC_MAQ_SA_W_QHRL
:
13143 gen_helper_maq_sa_w_qhrl(v1_t
, v2_t
, t0
, cpu_env
);
13145 case OPC_MAQ_S_W_QHRR
:
13147 gen_helper_maq_s_w_qhrr(v1_t
, v2_t
, t0
, cpu_env
);
13149 case OPC_MAQ_SA_W_QHRR
:
13151 gen_helper_maq_sa_w_qhrr(v1_t
, v2_t
, t0
, cpu_env
);
13153 case OPC_MULSAQ_S_L_PW
:
13155 gen_helper_mulsaq_s_l_pw(v1_t
, v2_t
, t0
, cpu_env
);
13157 case OPC_MULSAQ_S_W_QH
:
13159 gen_helper_mulsaq_s_w_qh(v1_t
, v2_t
, t0
, cpu_env
);
13165 case OPC_ADDU_QB_DSP
:
13167 case OPC_MULEU_S_PH_QBL
:
13169 gen_helper_muleu_s_ph_qbl(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13171 case OPC_MULEU_S_PH_QBR
:
13173 gen_helper_muleu_s_ph_qbr(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13175 case OPC_MULQ_RS_PH
:
13177 gen_helper_mulq_rs_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13179 case OPC_MULEQ_S_W_PHL
:
13181 gen_helper_muleq_s_w_phl(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13183 case OPC_MULEQ_S_W_PHR
:
13185 gen_helper_muleq_s_w_phr(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13187 case OPC_MULQ_S_PH
:
13189 gen_helper_mulq_s_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13193 #ifdef TARGET_MIPS64
13194 case OPC_ADDU_OB_DSP
:
13196 case OPC_MULEQ_S_PW_QHL
:
13198 gen_helper_muleq_s_pw_qhl(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13200 case OPC_MULEQ_S_PW_QHR
:
13202 gen_helper_muleq_s_pw_qhr(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13204 case OPC_MULEU_S_QH_OBL
:
13206 gen_helper_muleu_s_qh_obl(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13208 case OPC_MULEU_S_QH_OBR
:
13210 gen_helper_muleu_s_qh_obr(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13212 case OPC_MULQ_RS_QH
:
13214 gen_helper_mulq_rs_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13221 tcg_temp_free_i32(t0
);
13222 tcg_temp_free(v1_t
);
13223 tcg_temp_free(v2_t
);
13226 static void gen_mipsdsp_bitinsn(DisasContext
*ctx
, uint32_t op1
, uint32_t op2
,
13234 /* Treat as NOP. */
13238 t0
= tcg_temp_new();
13239 val_t
= tcg_temp_new();
13240 gen_load_gpr(val_t
, val
);
13243 case OPC_ABSQ_S_PH_DSP
:
13247 gen_helper_bitrev(cpu_gpr
[ret
], val_t
);
13252 target_long result
;
13253 imm
= (ctx
->opcode
>> 16) & 0xFF;
13254 result
= (uint32_t)imm
<< 24 |
13255 (uint32_t)imm
<< 16 |
13256 (uint32_t)imm
<< 8 |
13258 result
= (int32_t)result
;
13259 tcg_gen_movi_tl(cpu_gpr
[ret
], result
);
13264 tcg_gen_ext8u_tl(cpu_gpr
[ret
], val_t
);
13265 tcg_gen_shli_tl(t0
, cpu_gpr
[ret
], 8);
13266 tcg_gen_or_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], t0
);
13267 tcg_gen_shli_tl(t0
, cpu_gpr
[ret
], 16);
13268 tcg_gen_or_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], t0
);
13269 tcg_gen_ext32s_tl(cpu_gpr
[ret
], cpu_gpr
[ret
]);
13274 imm
= (ctx
->opcode
>> 16) & 0x03FF;
13275 imm
= (int16_t)(imm
<< 6) >> 6;
13276 tcg_gen_movi_tl(cpu_gpr
[ret
], \
13277 (target_long
)((int32_t)imm
<< 16 | \
13283 tcg_gen_ext16u_tl(cpu_gpr
[ret
], val_t
);
13284 tcg_gen_shli_tl(t0
, cpu_gpr
[ret
], 16);
13285 tcg_gen_or_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], t0
);
13286 tcg_gen_ext32s_tl(cpu_gpr
[ret
], cpu_gpr
[ret
]);
13290 #ifdef TARGET_MIPS64
13291 case OPC_ABSQ_S_QH_DSP
:
13298 imm
= (ctx
->opcode
>> 16) & 0xFF;
13299 temp
= ((uint64_t)imm
<< 8) | (uint64_t)imm
;
13300 temp
= (temp
<< 16) | temp
;
13301 temp
= (temp
<< 32) | temp
;
13302 tcg_gen_movi_tl(cpu_gpr
[ret
], temp
);
13310 imm
= (ctx
->opcode
>> 16) & 0x03FF;
13311 imm
= (int16_t)(imm
<< 6) >> 6;
13312 temp
= ((target_long
)imm
<< 32) \
13313 | ((target_long
)imm
& 0xFFFFFFFF);
13314 tcg_gen_movi_tl(cpu_gpr
[ret
], temp
);
13322 imm
= (ctx
->opcode
>> 16) & 0x03FF;
13323 imm
= (int16_t)(imm
<< 6) >> 6;
13325 temp
= ((uint64_t)(uint16_t)imm
<< 48) |
13326 ((uint64_t)(uint16_t)imm
<< 32) |
13327 ((uint64_t)(uint16_t)imm
<< 16) |
13328 (uint64_t)(uint16_t)imm
;
13329 tcg_gen_movi_tl(cpu_gpr
[ret
], temp
);
13334 tcg_gen_ext8u_tl(cpu_gpr
[ret
], val_t
);
13335 tcg_gen_shli_tl(t0
, cpu_gpr
[ret
], 8);
13336 tcg_gen_or_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], t0
);
13337 tcg_gen_shli_tl(t0
, cpu_gpr
[ret
], 16);
13338 tcg_gen_or_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], t0
);
13339 tcg_gen_shli_tl(t0
, cpu_gpr
[ret
], 32);
13340 tcg_gen_or_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], t0
);
13344 tcg_gen_ext32u_i64(cpu_gpr
[ret
], val_t
);
13345 tcg_gen_shli_tl(t0
, cpu_gpr
[ret
], 32);
13346 tcg_gen_or_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], t0
);
13350 tcg_gen_ext16u_tl(cpu_gpr
[ret
], val_t
);
13351 tcg_gen_shli_tl(t0
, cpu_gpr
[ret
], 16);
13352 tcg_gen_or_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], t0
);
13353 tcg_gen_shli_tl(t0
, cpu_gpr
[ret
], 32);
13354 tcg_gen_or_tl(cpu_gpr
[ret
], cpu_gpr
[ret
], t0
);
13361 tcg_temp_free(val_t
);
13364 static void gen_mipsdsp_add_cmp_pick(DisasContext
*ctx
,
13365 uint32_t op1
, uint32_t op2
,
13366 int ret
, int v1
, int v2
, int check_ret
)
13372 if ((ret
== 0) && (check_ret
== 1)) {
13373 /* Treat as NOP. */
13377 t1
= tcg_temp_new();
13378 v1_t
= tcg_temp_new();
13379 v2_t
= tcg_temp_new();
13381 gen_load_gpr(v1_t
, v1
);
13382 gen_load_gpr(v2_t
, v2
);
13385 case OPC_CMPU_EQ_QB_DSP
:
13387 case OPC_CMPU_EQ_QB
:
13389 gen_helper_cmpu_eq_qb(v1_t
, v2_t
, cpu_env
);
13391 case OPC_CMPU_LT_QB
:
13393 gen_helper_cmpu_lt_qb(v1_t
, v2_t
, cpu_env
);
13395 case OPC_CMPU_LE_QB
:
13397 gen_helper_cmpu_le_qb(v1_t
, v2_t
, cpu_env
);
13399 case OPC_CMPGU_EQ_QB
:
13401 gen_helper_cmpgu_eq_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
13403 case OPC_CMPGU_LT_QB
:
13405 gen_helper_cmpgu_lt_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
13407 case OPC_CMPGU_LE_QB
:
13409 gen_helper_cmpgu_le_qb(cpu_gpr
[ret
], v1_t
, v2_t
);
13411 case OPC_CMPGDU_EQ_QB
:
13413 gen_helper_cmpgu_eq_qb(t1
, v1_t
, v2_t
);
13414 tcg_gen_mov_tl(cpu_gpr
[ret
], t1
);
13415 tcg_gen_andi_tl(cpu_dspctrl
, cpu_dspctrl
, 0xF0FFFFFF);
13416 tcg_gen_shli_tl(t1
, t1
, 24);
13417 tcg_gen_or_tl(cpu_dspctrl
, cpu_dspctrl
, t1
);
13419 case OPC_CMPGDU_LT_QB
:
13421 gen_helper_cmpgu_lt_qb(t1
, v1_t
, v2_t
);
13422 tcg_gen_mov_tl(cpu_gpr
[ret
], t1
);
13423 tcg_gen_andi_tl(cpu_dspctrl
, cpu_dspctrl
, 0xF0FFFFFF);
13424 tcg_gen_shli_tl(t1
, t1
, 24);
13425 tcg_gen_or_tl(cpu_dspctrl
, cpu_dspctrl
, t1
);
13427 case OPC_CMPGDU_LE_QB
:
13429 gen_helper_cmpgu_le_qb(t1
, v1_t
, v2_t
);
13430 tcg_gen_mov_tl(cpu_gpr
[ret
], t1
);
13431 tcg_gen_andi_tl(cpu_dspctrl
, cpu_dspctrl
, 0xF0FFFFFF);
13432 tcg_gen_shli_tl(t1
, t1
, 24);
13433 tcg_gen_or_tl(cpu_dspctrl
, cpu_dspctrl
, t1
);
13435 case OPC_CMP_EQ_PH
:
13437 gen_helper_cmp_eq_ph(v1_t
, v2_t
, cpu_env
);
13439 case OPC_CMP_LT_PH
:
13441 gen_helper_cmp_lt_ph(v1_t
, v2_t
, cpu_env
);
13443 case OPC_CMP_LE_PH
:
13445 gen_helper_cmp_le_ph(v1_t
, v2_t
, cpu_env
);
13449 gen_helper_pick_qb(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13453 gen_helper_pick_ph(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13455 case OPC_PACKRL_PH
:
13457 gen_helper_packrl_ph(cpu_gpr
[ret
], v1_t
, v2_t
);
13461 #ifdef TARGET_MIPS64
13462 case OPC_CMPU_EQ_OB_DSP
:
13464 case OPC_CMP_EQ_PW
:
13466 gen_helper_cmp_eq_pw(v1_t
, v2_t
, cpu_env
);
13468 case OPC_CMP_LT_PW
:
13470 gen_helper_cmp_lt_pw(v1_t
, v2_t
, cpu_env
);
13472 case OPC_CMP_LE_PW
:
13474 gen_helper_cmp_le_pw(v1_t
, v2_t
, cpu_env
);
13476 case OPC_CMP_EQ_QH
:
13478 gen_helper_cmp_eq_qh(v1_t
, v2_t
, cpu_env
);
13480 case OPC_CMP_LT_QH
:
13482 gen_helper_cmp_lt_qh(v1_t
, v2_t
, cpu_env
);
13484 case OPC_CMP_LE_QH
:
13486 gen_helper_cmp_le_qh(v1_t
, v2_t
, cpu_env
);
13488 case OPC_CMPGDU_EQ_OB
:
13490 gen_helper_cmpgdu_eq_ob(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13492 case OPC_CMPGDU_LT_OB
:
13494 gen_helper_cmpgdu_lt_ob(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13496 case OPC_CMPGDU_LE_OB
:
13498 gen_helper_cmpgdu_le_ob(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13500 case OPC_CMPGU_EQ_OB
:
13502 gen_helper_cmpgu_eq_ob(cpu_gpr
[ret
], v1_t
, v2_t
);
13504 case OPC_CMPGU_LT_OB
:
13506 gen_helper_cmpgu_lt_ob(cpu_gpr
[ret
], v1_t
, v2_t
);
13508 case OPC_CMPGU_LE_OB
:
13510 gen_helper_cmpgu_le_ob(cpu_gpr
[ret
], v1_t
, v2_t
);
13512 case OPC_CMPU_EQ_OB
:
13514 gen_helper_cmpu_eq_ob(v1_t
, v2_t
, cpu_env
);
13516 case OPC_CMPU_LT_OB
:
13518 gen_helper_cmpu_lt_ob(v1_t
, v2_t
, cpu_env
);
13520 case OPC_CMPU_LE_OB
:
13522 gen_helper_cmpu_le_ob(v1_t
, v2_t
, cpu_env
);
13524 case OPC_PACKRL_PW
:
13526 gen_helper_packrl_pw(cpu_gpr
[ret
], v1_t
, v2_t
);
13530 gen_helper_pick_ob(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13534 gen_helper_pick_pw(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13538 gen_helper_pick_qh(cpu_gpr
[ret
], v1_t
, v2_t
, cpu_env
);
13546 tcg_temp_free(v1_t
);
13547 tcg_temp_free(v2_t
);
13550 static void gen_mipsdsp_append(CPUMIPSState
*env
, DisasContext
*ctx
,
13551 uint32_t op1
, int rt
, int rs
, int sa
)
13558 /* Treat as NOP. */
13562 t0
= tcg_temp_new();
13563 gen_load_gpr(t0
, rs
);
13566 case OPC_APPEND_DSP
:
13567 switch (MASK_APPEND(ctx
->opcode
)) {
13570 tcg_gen_deposit_tl(cpu_gpr
[rt
], t0
, cpu_gpr
[rt
], sa
, 32 - sa
);
13572 tcg_gen_ext32s_tl(cpu_gpr
[rt
], cpu_gpr
[rt
]);
13576 tcg_gen_ext32u_tl(cpu_gpr
[rt
], cpu_gpr
[rt
]);
13577 tcg_gen_shri_tl(cpu_gpr
[rt
], cpu_gpr
[rt
], sa
);
13578 tcg_gen_shli_tl(t0
, t0
, 32 - sa
);
13579 tcg_gen_or_tl(cpu_gpr
[rt
], cpu_gpr
[rt
], t0
);
13581 tcg_gen_ext32s_tl(cpu_gpr
[rt
], cpu_gpr
[rt
]);
13585 if (sa
!= 0 && sa
!= 2) {
13586 tcg_gen_shli_tl(cpu_gpr
[rt
], cpu_gpr
[rt
], 8 * sa
);
13587 tcg_gen_ext32u_tl(t0
, t0
);
13588 tcg_gen_shri_tl(t0
, t0
, 8 * (4 - sa
));
13589 tcg_gen_or_tl(cpu_gpr
[rt
], cpu_gpr
[rt
], t0
);
13591 tcg_gen_ext32s_tl(cpu_gpr
[rt
], cpu_gpr
[rt
]);
13593 default: /* Invalid */
13594 MIPS_INVAL("MASK APPEND");
13595 gen_reserved_instruction(ctx
);
13599 #ifdef TARGET_MIPS64
13600 case OPC_DAPPEND_DSP
:
13601 switch (MASK_DAPPEND(ctx
->opcode
)) {
13604 tcg_gen_deposit_tl(cpu_gpr
[rt
], t0
, cpu_gpr
[rt
], sa
, 64 - sa
);
13608 tcg_gen_shri_tl(cpu_gpr
[rt
], cpu_gpr
[rt
], 0x20 | sa
);
13609 tcg_gen_shli_tl(t0
, t0
, 64 - (0x20 | sa
));
13610 tcg_gen_or_tl(cpu_gpr
[rt
], t0
, t0
);
13614 tcg_gen_shri_tl(cpu_gpr
[rt
], cpu_gpr
[rt
], sa
);
13615 tcg_gen_shli_tl(t0
, t0
, 64 - sa
);
13616 tcg_gen_or_tl(cpu_gpr
[rt
], cpu_gpr
[rt
], t0
);
13621 if (sa
!= 0 && sa
!= 2 && sa
!= 4) {
13622 tcg_gen_shli_tl(cpu_gpr
[rt
], cpu_gpr
[rt
], 8 * sa
);
13623 tcg_gen_shri_tl(t0
, t0
, 8 * (8 - sa
));
13624 tcg_gen_or_tl(cpu_gpr
[rt
], cpu_gpr
[rt
], t0
);
13627 default: /* Invalid */
13628 MIPS_INVAL("MASK DAPPEND");
13629 gen_reserved_instruction(ctx
);
13638 static void gen_mipsdsp_accinsn(DisasContext
*ctx
, uint32_t op1
, uint32_t op2
,
13639 int ret
, int v1
, int v2
, int check_ret
)
13648 if ((ret
== 0) && (check_ret
== 1)) {
13649 /* Treat as NOP. */
13653 t0
= tcg_temp_new();
13654 t1
= tcg_temp_new();
13655 v1_t
= tcg_temp_new();
13656 v2_t
= tcg_temp_new();
13658 gen_load_gpr(v1_t
, v1
);
13659 gen_load_gpr(v2_t
, v2
);
13662 case OPC_EXTR_W_DSP
:
13666 tcg_gen_movi_tl(t0
, v2
);
13667 tcg_gen_movi_tl(t1
, v1
);
13668 gen_helper_extr_w(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13671 tcg_gen_movi_tl(t0
, v2
);
13672 tcg_gen_movi_tl(t1
, v1
);
13673 gen_helper_extr_r_w(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13675 case OPC_EXTR_RS_W
:
13676 tcg_gen_movi_tl(t0
, v2
);
13677 tcg_gen_movi_tl(t1
, v1
);
13678 gen_helper_extr_rs_w(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13681 tcg_gen_movi_tl(t0
, v2
);
13682 tcg_gen_movi_tl(t1
, v1
);
13683 gen_helper_extr_s_h(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13685 case OPC_EXTRV_S_H
:
13686 tcg_gen_movi_tl(t0
, v2
);
13687 gen_helper_extr_s_h(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13690 tcg_gen_movi_tl(t0
, v2
);
13691 gen_helper_extr_w(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13693 case OPC_EXTRV_R_W
:
13694 tcg_gen_movi_tl(t0
, v2
);
13695 gen_helper_extr_r_w(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13697 case OPC_EXTRV_RS_W
:
13698 tcg_gen_movi_tl(t0
, v2
);
13699 gen_helper_extr_rs_w(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13702 tcg_gen_movi_tl(t0
, v2
);
13703 tcg_gen_movi_tl(t1
, v1
);
13704 gen_helper_extp(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13707 tcg_gen_movi_tl(t0
, v2
);
13708 gen_helper_extp(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13711 tcg_gen_movi_tl(t0
, v2
);
13712 tcg_gen_movi_tl(t1
, v1
);
13713 gen_helper_extpdp(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13716 tcg_gen_movi_tl(t0
, v2
);
13717 gen_helper_extpdp(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13720 imm
= (ctx
->opcode
>> 20) & 0x3F;
13721 tcg_gen_movi_tl(t0
, ret
);
13722 tcg_gen_movi_tl(t1
, imm
);
13723 gen_helper_shilo(t0
, t1
, cpu_env
);
13726 tcg_gen_movi_tl(t0
, ret
);
13727 gen_helper_shilo(t0
, v1_t
, cpu_env
);
13730 tcg_gen_movi_tl(t0
, ret
);
13731 gen_helper_mthlip(t0
, v1_t
, cpu_env
);
13734 imm
= (ctx
->opcode
>> 11) & 0x3FF;
13735 tcg_gen_movi_tl(t0
, imm
);
13736 gen_helper_wrdsp(v1_t
, t0
, cpu_env
);
13739 imm
= (ctx
->opcode
>> 16) & 0x03FF;
13740 tcg_gen_movi_tl(t0
, imm
);
13741 gen_helper_rddsp(cpu_gpr
[ret
], t0
, cpu_env
);
13745 #ifdef TARGET_MIPS64
13746 case OPC_DEXTR_W_DSP
:
13750 tcg_gen_movi_tl(t0
, ret
);
13751 gen_helper_dmthlip(v1_t
, t0
, cpu_env
);
13755 int shift
= (ctx
->opcode
>> 19) & 0x7F;
13756 int ac
= (ctx
->opcode
>> 11) & 0x03;
13757 tcg_gen_movi_tl(t0
, shift
);
13758 tcg_gen_movi_tl(t1
, ac
);
13759 gen_helper_dshilo(t0
, t1
, cpu_env
);
13764 int ac
= (ctx
->opcode
>> 11) & 0x03;
13765 tcg_gen_movi_tl(t0
, ac
);
13766 gen_helper_dshilo(v1_t
, t0
, cpu_env
);
13770 tcg_gen_movi_tl(t0
, v2
);
13771 tcg_gen_movi_tl(t1
, v1
);
13773 gen_helper_dextp(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13776 tcg_gen_movi_tl(t0
, v2
);
13777 gen_helper_dextp(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13780 tcg_gen_movi_tl(t0
, v2
);
13781 tcg_gen_movi_tl(t1
, v1
);
13782 gen_helper_dextpdp(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13785 tcg_gen_movi_tl(t0
, v2
);
13786 gen_helper_dextpdp(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13789 tcg_gen_movi_tl(t0
, v2
);
13790 tcg_gen_movi_tl(t1
, v1
);
13791 gen_helper_dextr_l(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13793 case OPC_DEXTR_R_L
:
13794 tcg_gen_movi_tl(t0
, v2
);
13795 tcg_gen_movi_tl(t1
, v1
);
13796 gen_helper_dextr_r_l(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13798 case OPC_DEXTR_RS_L
:
13799 tcg_gen_movi_tl(t0
, v2
);
13800 tcg_gen_movi_tl(t1
, v1
);
13801 gen_helper_dextr_rs_l(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13804 tcg_gen_movi_tl(t0
, v2
);
13805 tcg_gen_movi_tl(t1
, v1
);
13806 gen_helper_dextr_w(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13808 case OPC_DEXTR_R_W
:
13809 tcg_gen_movi_tl(t0
, v2
);
13810 tcg_gen_movi_tl(t1
, v1
);
13811 gen_helper_dextr_r_w(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13813 case OPC_DEXTR_RS_W
:
13814 tcg_gen_movi_tl(t0
, v2
);
13815 tcg_gen_movi_tl(t1
, v1
);
13816 gen_helper_dextr_rs_w(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13818 case OPC_DEXTR_S_H
:
13819 tcg_gen_movi_tl(t0
, v2
);
13820 tcg_gen_movi_tl(t1
, v1
);
13821 gen_helper_dextr_s_h(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13823 case OPC_DEXTRV_S_H
:
13824 tcg_gen_movi_tl(t0
, v2
);
13825 tcg_gen_movi_tl(t1
, v1
);
13826 gen_helper_dextr_s_h(cpu_gpr
[ret
], t0
, t1
, cpu_env
);
13829 tcg_gen_movi_tl(t0
, v2
);
13830 gen_helper_dextr_l(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13832 case OPC_DEXTRV_R_L
:
13833 tcg_gen_movi_tl(t0
, v2
);
13834 gen_helper_dextr_r_l(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13836 case OPC_DEXTRV_RS_L
:
13837 tcg_gen_movi_tl(t0
, v2
);
13838 gen_helper_dextr_rs_l(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13841 tcg_gen_movi_tl(t0
, v2
);
13842 gen_helper_dextr_w(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13844 case OPC_DEXTRV_R_W
:
13845 tcg_gen_movi_tl(t0
, v2
);
13846 gen_helper_dextr_r_w(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13848 case OPC_DEXTRV_RS_W
:
13849 tcg_gen_movi_tl(t0
, v2
);
13850 gen_helper_dextr_rs_w(cpu_gpr
[ret
], t0
, v1_t
, cpu_env
);
13859 tcg_temp_free(v1_t
);
13860 tcg_temp_free(v2_t
);
13863 /* End MIPSDSP functions. */
13865 static void decode_opc_special_r6(CPUMIPSState
*env
, DisasContext
*ctx
)
13867 int rs
, rt
, rd
, sa
;
13870 rs
= (ctx
->opcode
>> 21) & 0x1f;
13871 rt
= (ctx
->opcode
>> 16) & 0x1f;
13872 rd
= (ctx
->opcode
>> 11) & 0x1f;
13873 sa
= (ctx
->opcode
>> 6) & 0x1f;
13875 op1
= MASK_SPECIAL(ctx
->opcode
);
13881 op2
= MASK_R6_MULDIV(ctx
->opcode
);
13891 gen_r6_muldiv(ctx
, op2
, rd
, rs
, rt
);
13894 MIPS_INVAL("special_r6 muldiv");
13895 gen_reserved_instruction(ctx
);
13901 gen_cond_move(ctx
, op1
, rd
, rs
, rt
);
13905 if (rt
== 0 && sa
== 1) {
13907 * Major opcode and function field is shared with preR6 MFHI/MTHI.
13908 * We need additionally to check other fields.
13910 gen_cl(ctx
, op1
, rd
, rs
);
13912 gen_reserved_instruction(ctx
);
13916 if (is_uhi(extract32(ctx
->opcode
, 6, 20))) {
13917 gen_helper_do_semihosting(cpu_env
);
13919 if (ctx
->hflags
& MIPS_HFLAG_SBRI
) {
13920 gen_reserved_instruction(ctx
);
13922 generate_exception_end(ctx
, EXCP_DBp
);
13926 #if defined(TARGET_MIPS64)
13929 if (rt
== 0 && sa
== 1) {
13931 * Major opcode and function field is shared with preR6 MFHI/MTHI.
13932 * We need additionally to check other fields.
13934 check_mips_64(ctx
);
13935 gen_cl(ctx
, op1
, rd
, rs
);
13937 gen_reserved_instruction(ctx
);
13945 op2
= MASK_R6_MULDIV(ctx
->opcode
);
13955 check_mips_64(ctx
);
13956 gen_r6_muldiv(ctx
, op2
, rd
, rs
, rt
);
13959 MIPS_INVAL("special_r6 muldiv");
13960 gen_reserved_instruction(ctx
);
13965 default: /* Invalid */
13966 MIPS_INVAL("special_r6");
13967 gen_reserved_instruction(ctx
);
13972 static void decode_opc_special_tx79(CPUMIPSState
*env
, DisasContext
*ctx
)
13974 int rs
= extract32(ctx
->opcode
, 21, 5);
13975 int rt
= extract32(ctx
->opcode
, 16, 5);
13976 int rd
= extract32(ctx
->opcode
, 11, 5);
13977 uint32_t op1
= MASK_SPECIAL(ctx
->opcode
);
13980 case OPC_MOVN
: /* Conditional move */
13982 gen_cond_move(ctx
, op1
, rd
, rs
, rt
);
13984 case OPC_MFHI
: /* Move from HI/LO */
13986 gen_HILO(ctx
, op1
, 0, rd
);
13989 case OPC_MTLO
: /* Move to HI/LO */
13990 gen_HILO(ctx
, op1
, 0, rs
);
13994 gen_mul_txx9(ctx
, op1
, rd
, rs
, rt
);
13998 gen_muldiv(ctx
, op1
, 0, rs
, rt
);
14000 #if defined(TARGET_MIPS64)
14005 check_insn_opc_user_only(ctx
, INSN_R5900
);
14006 gen_muldiv(ctx
, op1
, 0, rs
, rt
);
14010 gen_compute_branch(ctx
, op1
, 4, rs
, 0, 0, 4);
14012 default: /* Invalid */
14013 MIPS_INVAL("special_tx79");
14014 gen_reserved_instruction(ctx
);
14019 static void decode_opc_special_legacy(CPUMIPSState
*env
, DisasContext
*ctx
)
14024 rs
= (ctx
->opcode
>> 21) & 0x1f;
14025 rt
= (ctx
->opcode
>> 16) & 0x1f;
14026 rd
= (ctx
->opcode
>> 11) & 0x1f;
14028 op1
= MASK_SPECIAL(ctx
->opcode
);
14030 case OPC_MOVN
: /* Conditional move */
14032 check_insn(ctx
, ISA_MIPS4
| ISA_MIPS_R1
|
14033 INSN_LOONGSON2E
| INSN_LOONGSON2F
);
14034 gen_cond_move(ctx
, op1
, rd
, rs
, rt
);
14036 case OPC_MFHI
: /* Move from HI/LO */
14038 gen_HILO(ctx
, op1
, rs
& 3, rd
);
14041 case OPC_MTLO
: /* Move to HI/LO */
14042 gen_HILO(ctx
, op1
, rd
& 3, rs
);
14045 check_insn(ctx
, ISA_MIPS4
| ISA_MIPS_R1
);
14046 if (env
->CP0_Config1
& (1 << CP0C1_FP
)) {
14047 check_cp1_enabled(ctx
);
14048 gen_movci(ctx
, rd
, rs
, (ctx
->opcode
>> 18) & 0x7,
14049 (ctx
->opcode
>> 16) & 1);
14051 generate_exception_err(ctx
, EXCP_CpU
, 1);
14056 gen_muldiv(ctx
, op1
, rd
& 3, rs
, rt
);
14060 gen_muldiv(ctx
, op1
, 0, rs
, rt
);
14062 #if defined(TARGET_MIPS64)
14067 check_insn(ctx
, ISA_MIPS3
);
14068 check_mips_64(ctx
);
14069 gen_muldiv(ctx
, op1
, 0, rs
, rt
);
14073 gen_compute_branch(ctx
, op1
, 4, rs
, 0, 0, 4);
14076 #ifdef MIPS_STRICT_STANDARD
14077 MIPS_INVAL("SPIM");
14078 gen_reserved_instruction(ctx
);
14080 /* Implemented as RI exception for now. */
14081 MIPS_INVAL("spim (unofficial)");
14082 gen_reserved_instruction(ctx
);
14085 default: /* Invalid */
14086 MIPS_INVAL("special_legacy");
14087 gen_reserved_instruction(ctx
);
14092 static void decode_opc_special(CPUMIPSState
*env
, DisasContext
*ctx
)
14094 int rs
, rt
, rd
, sa
;
14097 rs
= (ctx
->opcode
>> 21) & 0x1f;
14098 rt
= (ctx
->opcode
>> 16) & 0x1f;
14099 rd
= (ctx
->opcode
>> 11) & 0x1f;
14100 sa
= (ctx
->opcode
>> 6) & 0x1f;
14102 op1
= MASK_SPECIAL(ctx
->opcode
);
14104 case OPC_SLL
: /* Shift with immediate */
14105 if (sa
== 5 && rd
== 0 &&
14106 rs
== 0 && rt
== 0) { /* PAUSE */
14107 if ((ctx
->insn_flags
& ISA_MIPS_R6
) &&
14108 (ctx
->hflags
& MIPS_HFLAG_BMASK
)) {
14109 gen_reserved_instruction(ctx
);
14115 gen_shift_imm(ctx
, op1
, rd
, rt
, sa
);
14118 switch ((ctx
->opcode
>> 21) & 0x1f) {
14120 /* rotr is decoded as srl on non-R2 CPUs */
14121 if (ctx
->insn_flags
& ISA_MIPS_R2
) {
14126 gen_shift_imm(ctx
, op1
, rd
, rt
, sa
);
14129 gen_reserved_instruction(ctx
);
14137 gen_arith(ctx
, op1
, rd
, rs
, rt
);
14139 case OPC_SLLV
: /* Shifts */
14141 gen_shift(ctx
, op1
, rd
, rs
, rt
);
14144 switch ((ctx
->opcode
>> 6) & 0x1f) {
14146 /* rotrv is decoded as srlv on non-R2 CPUs */
14147 if (ctx
->insn_flags
& ISA_MIPS_R2
) {
14152 gen_shift(ctx
, op1
, rd
, rs
, rt
);
14155 gen_reserved_instruction(ctx
);
14159 case OPC_SLT
: /* Set on less than */
14161 gen_slt(ctx
, op1
, rd
, rs
, rt
);
14163 case OPC_AND
: /* Logic*/
14167 gen_logic(ctx
, op1
, rd
, rs
, rt
);
14170 gen_compute_branch(ctx
, op1
, 4, rs
, rd
, sa
, 4);
14172 case OPC_TGE
: /* Traps */
14178 check_insn(ctx
, ISA_MIPS2
);
14179 gen_trap(ctx
, op1
, rs
, rt
, -1);
14182 /* Pmon entry point, also R4010 selsl */
14183 #ifdef MIPS_STRICT_STANDARD
14184 MIPS_INVAL("PMON / selsl");
14185 gen_reserved_instruction(ctx
);
14187 gen_helper_pmon(cpu_env
, tcg_constant_i32(sa
));
14191 generate_exception_end(ctx
, EXCP_SYSCALL
);
14194 generate_exception_end(ctx
, EXCP_BREAK
);
14197 check_insn(ctx
, ISA_MIPS2
);
14198 gen_sync(extract32(ctx
->opcode
, 6, 5));
14201 #if defined(TARGET_MIPS64)
14202 /* MIPS64 specific opcodes */
14207 check_insn(ctx
, ISA_MIPS3
);
14208 check_mips_64(ctx
);
14209 gen_shift_imm(ctx
, op1
, rd
, rt
, sa
);
14212 switch ((ctx
->opcode
>> 21) & 0x1f) {
14214 /* drotr is decoded as dsrl on non-R2 CPUs */
14215 if (ctx
->insn_flags
& ISA_MIPS_R2
) {
14220 check_insn(ctx
, ISA_MIPS3
);
14221 check_mips_64(ctx
);
14222 gen_shift_imm(ctx
, op1
, rd
, rt
, sa
);
14225 gen_reserved_instruction(ctx
);
14230 switch ((ctx
->opcode
>> 21) & 0x1f) {
14232 /* drotr32 is decoded as dsrl32 on non-R2 CPUs */
14233 if (ctx
->insn_flags
& ISA_MIPS_R2
) {
14238 check_insn(ctx
, ISA_MIPS3
);
14239 check_mips_64(ctx
);
14240 gen_shift_imm(ctx
, op1
, rd
, rt
, sa
);
14243 gen_reserved_instruction(ctx
);
14251 check_insn(ctx
, ISA_MIPS3
);
14252 check_mips_64(ctx
);
14253 gen_arith(ctx
, op1
, rd
, rs
, rt
);
14257 check_insn(ctx
, ISA_MIPS3
);
14258 check_mips_64(ctx
);
14259 gen_shift(ctx
, op1
, rd
, rs
, rt
);
14262 switch ((ctx
->opcode
>> 6) & 0x1f) {
14264 /* drotrv is decoded as dsrlv on non-R2 CPUs */
14265 if (ctx
->insn_flags
& ISA_MIPS_R2
) {
14270 check_insn(ctx
, ISA_MIPS3
);
14271 check_mips_64(ctx
);
14272 gen_shift(ctx
, op1
, rd
, rs
, rt
);
14275 gen_reserved_instruction(ctx
);
14281 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
14282 decode_opc_special_r6(env
, ctx
);
14283 } else if (ctx
->insn_flags
& INSN_R5900
) {
14284 decode_opc_special_tx79(env
, ctx
);
14286 decode_opc_special_legacy(env
, ctx
);
14292 static void decode_opc_special2_legacy(CPUMIPSState
*env
, DisasContext
*ctx
)
14297 rs
= (ctx
->opcode
>> 21) & 0x1f;
14298 rt
= (ctx
->opcode
>> 16) & 0x1f;
14299 rd
= (ctx
->opcode
>> 11) & 0x1f;
14301 op1
= MASK_SPECIAL2(ctx
->opcode
);
14303 case OPC_MADD
: /* Multiply and add/sub */
14307 check_insn(ctx
, ISA_MIPS_R1
);
14308 gen_muldiv(ctx
, op1
, rd
& 3, rs
, rt
);
14311 gen_arith(ctx
, op1
, rd
, rs
, rt
);
14314 case OPC_DIVU_G_2F
:
14315 case OPC_MULT_G_2F
:
14316 case OPC_MULTU_G_2F
:
14318 case OPC_MODU_G_2F
:
14319 check_insn(ctx
, INSN_LOONGSON2F
| ASE_LEXT
);
14320 gen_loongson_integer(ctx
, op1
, rd
, rs
, rt
);
14324 check_insn(ctx
, ISA_MIPS_R1
);
14325 gen_cl(ctx
, op1
, rd
, rs
);
14328 if (is_uhi(extract32(ctx
->opcode
, 6, 20))) {
14329 gen_helper_do_semihosting(cpu_env
);
14332 * XXX: not clear which exception should be raised
14333 * when in debug mode...
14335 check_insn(ctx
, ISA_MIPS_R1
);
14336 generate_exception_end(ctx
, EXCP_DBp
);
14339 #if defined(TARGET_MIPS64)
14342 check_insn(ctx
, ISA_MIPS_R1
);
14343 check_mips_64(ctx
);
14344 gen_cl(ctx
, op1
, rd
, rs
);
14346 case OPC_DMULT_G_2F
:
14347 case OPC_DMULTU_G_2F
:
14348 case OPC_DDIV_G_2F
:
14349 case OPC_DDIVU_G_2F
:
14350 case OPC_DMOD_G_2F
:
14351 case OPC_DMODU_G_2F
:
14352 check_insn(ctx
, INSN_LOONGSON2F
| ASE_LEXT
);
14353 gen_loongson_integer(ctx
, op1
, rd
, rs
, rt
);
14356 default: /* Invalid */
14357 MIPS_INVAL("special2_legacy");
14358 gen_reserved_instruction(ctx
);
14363 static void decode_opc_special3_r6(CPUMIPSState
*env
, DisasContext
*ctx
)
14365 int rs
, rt
, rd
, sa
;
14369 rs
= (ctx
->opcode
>> 21) & 0x1f;
14370 rt
= (ctx
->opcode
>> 16) & 0x1f;
14371 rd
= (ctx
->opcode
>> 11) & 0x1f;
14372 sa
= (ctx
->opcode
>> 6) & 0x1f;
14373 imm
= (int16_t)ctx
->opcode
>> 7;
14375 op1
= MASK_SPECIAL3(ctx
->opcode
);
14379 /* hint codes 24-31 are reserved and signal RI */
14380 gen_reserved_instruction(ctx
);
14382 /* Treat as NOP. */
14385 check_cp0_enabled(ctx
);
14386 if (ctx
->hflags
& MIPS_HFLAG_ITC_CACHE
) {
14387 gen_cache_operation(ctx
, rt
, rs
, imm
);
14391 gen_st_cond(ctx
, rt
, rs
, imm
, MO_TESL
, false);
14394 gen_ld(ctx
, op1
, rt
, rs
, imm
);
14399 /* Treat as NOP. */
14402 op2
= MASK_BSHFL(ctx
->opcode
);
14408 gen_align(ctx
, 32, rd
, rs
, rt
, sa
& 3);
14411 gen_bitswap(ctx
, op2
, rd
, rt
);
14416 #ifndef CONFIG_USER_ONLY
14418 if (unlikely(ctx
->gi
<= 1)) {
14419 gen_reserved_instruction(ctx
);
14421 check_cp0_enabled(ctx
);
14422 switch ((ctx
->opcode
>> 6) & 3) {
14423 case 0: /* GINVI */
14424 /* Treat as NOP. */
14426 case 2: /* GINVT */
14427 gen_helper_0e1i(ginvt
, cpu_gpr
[rs
], extract32(ctx
->opcode
, 8, 2));
14430 gen_reserved_instruction(ctx
);
14435 #if defined(TARGET_MIPS64)
14437 gen_st_cond(ctx
, rt
, rs
, imm
, MO_TEQ
, false);
14440 gen_ld(ctx
, op1
, rt
, rs
, imm
);
14443 check_mips_64(ctx
);
14446 /* Treat as NOP. */
14449 op2
= MASK_DBSHFL(ctx
->opcode
);
14459 gen_align(ctx
, 64, rd
, rs
, rt
, sa
& 7);
14462 gen_bitswap(ctx
, op2
, rd
, rt
);
14469 default: /* Invalid */
14470 MIPS_INVAL("special3_r6");
14471 gen_reserved_instruction(ctx
);
14476 static void decode_opc_special3_legacy(CPUMIPSState
*env
, DisasContext
*ctx
)
14481 rs
= (ctx
->opcode
>> 21) & 0x1f;
14482 rt
= (ctx
->opcode
>> 16) & 0x1f;
14483 rd
= (ctx
->opcode
>> 11) & 0x1f;
14485 op1
= MASK_SPECIAL3(ctx
->opcode
);
14488 case OPC_DIVU_G_2E
:
14490 case OPC_MODU_G_2E
:
14491 case OPC_MULT_G_2E
:
14492 case OPC_MULTU_G_2E
:
14494 * OPC_MULT_G_2E, OPC_ADDUH_QB_DSP, OPC_MUL_PH_DSP have
14495 * the same mask and op1.
14497 if ((ctx
->insn_flags
& ASE_DSP_R2
) && (op1
== OPC_MULT_G_2E
)) {
14498 op2
= MASK_ADDUH_QB(ctx
->opcode
);
14501 case OPC_ADDUH_R_QB
:
14503 case OPC_ADDQH_R_PH
:
14505 case OPC_ADDQH_R_W
:
14507 case OPC_SUBUH_R_QB
:
14509 case OPC_SUBQH_R_PH
:
14511 case OPC_SUBQH_R_W
:
14512 gen_mipsdsp_arith(ctx
, op1
, op2
, rd
, rs
, rt
);
14517 case OPC_MULQ_RS_W
:
14518 gen_mipsdsp_multiply(ctx
, op1
, op2
, rd
, rs
, rt
, 1);
14521 MIPS_INVAL("MASK ADDUH.QB");
14522 gen_reserved_instruction(ctx
);
14525 } else if (ctx
->insn_flags
& INSN_LOONGSON2E
) {
14526 gen_loongson_integer(ctx
, op1
, rd
, rs
, rt
);
14528 gen_reserved_instruction(ctx
);
14532 op2
= MASK_LX(ctx
->opcode
);
14534 #if defined(TARGET_MIPS64)
14540 gen_mipsdsp_ld(ctx
, op2
, rd
, rs
, rt
);
14542 default: /* Invalid */
14543 MIPS_INVAL("MASK LX");
14544 gen_reserved_instruction(ctx
);
14548 case OPC_ABSQ_S_PH_DSP
:
14549 op2
= MASK_ABSQ_S_PH(ctx
->opcode
);
14551 case OPC_ABSQ_S_QB
:
14552 case OPC_ABSQ_S_PH
:
14554 case OPC_PRECEQ_W_PHL
:
14555 case OPC_PRECEQ_W_PHR
:
14556 case OPC_PRECEQU_PH_QBL
:
14557 case OPC_PRECEQU_PH_QBR
:
14558 case OPC_PRECEQU_PH_QBLA
:
14559 case OPC_PRECEQU_PH_QBRA
:
14560 case OPC_PRECEU_PH_QBL
:
14561 case OPC_PRECEU_PH_QBR
:
14562 case OPC_PRECEU_PH_QBLA
:
14563 case OPC_PRECEU_PH_QBRA
:
14564 gen_mipsdsp_arith(ctx
, op1
, op2
, rd
, rs
, rt
);
14571 gen_mipsdsp_bitinsn(ctx
, op1
, op2
, rd
, rt
);
14574 MIPS_INVAL("MASK ABSQ_S.PH");
14575 gen_reserved_instruction(ctx
);
14579 case OPC_ADDU_QB_DSP
:
14580 op2
= MASK_ADDU_QB(ctx
->opcode
);
14583 case OPC_ADDQ_S_PH
:
14586 case OPC_ADDU_S_QB
:
14588 case OPC_ADDU_S_PH
:
14590 case OPC_SUBQ_S_PH
:
14593 case OPC_SUBU_S_QB
:
14595 case OPC_SUBU_S_PH
:
14599 case OPC_RADDU_W_QB
:
14600 gen_mipsdsp_arith(ctx
, op1
, op2
, rd
, rs
, rt
);
14602 case OPC_MULEU_S_PH_QBL
:
14603 case OPC_MULEU_S_PH_QBR
:
14604 case OPC_MULQ_RS_PH
:
14605 case OPC_MULEQ_S_W_PHL
:
14606 case OPC_MULEQ_S_W_PHR
:
14607 case OPC_MULQ_S_PH
:
14608 gen_mipsdsp_multiply(ctx
, op1
, op2
, rd
, rs
, rt
, 1);
14610 default: /* Invalid */
14611 MIPS_INVAL("MASK ADDU.QB");
14612 gen_reserved_instruction(ctx
);
14617 case OPC_CMPU_EQ_QB_DSP
:
14618 op2
= MASK_CMPU_EQ_QB(ctx
->opcode
);
14620 case OPC_PRECR_SRA_PH_W
:
14621 case OPC_PRECR_SRA_R_PH_W
:
14622 gen_mipsdsp_arith(ctx
, op1
, op2
, rt
, rs
, rd
);
14624 case OPC_PRECR_QB_PH
:
14625 case OPC_PRECRQ_QB_PH
:
14626 case OPC_PRECRQ_PH_W
:
14627 case OPC_PRECRQ_RS_PH_W
:
14628 case OPC_PRECRQU_S_QB_PH
:
14629 gen_mipsdsp_arith(ctx
, op1
, op2
, rd
, rs
, rt
);
14631 case OPC_CMPU_EQ_QB
:
14632 case OPC_CMPU_LT_QB
:
14633 case OPC_CMPU_LE_QB
:
14634 case OPC_CMP_EQ_PH
:
14635 case OPC_CMP_LT_PH
:
14636 case OPC_CMP_LE_PH
:
14637 gen_mipsdsp_add_cmp_pick(ctx
, op1
, op2
, rd
, rs
, rt
, 0);
14639 case OPC_CMPGU_EQ_QB
:
14640 case OPC_CMPGU_LT_QB
:
14641 case OPC_CMPGU_LE_QB
:
14642 case OPC_CMPGDU_EQ_QB
:
14643 case OPC_CMPGDU_LT_QB
:
14644 case OPC_CMPGDU_LE_QB
:
14647 case OPC_PACKRL_PH
:
14648 gen_mipsdsp_add_cmp_pick(ctx
, op1
, op2
, rd
, rs
, rt
, 1);
14650 default: /* Invalid */
14651 MIPS_INVAL("MASK CMPU.EQ.QB");
14652 gen_reserved_instruction(ctx
);
14656 case OPC_SHLL_QB_DSP
:
14657 gen_mipsdsp_shift(ctx
, op1
, rd
, rs
, rt
);
14659 case OPC_DPA_W_PH_DSP
:
14660 op2
= MASK_DPA_W_PH(ctx
->opcode
);
14662 case OPC_DPAU_H_QBL
:
14663 case OPC_DPAU_H_QBR
:
14664 case OPC_DPSU_H_QBL
:
14665 case OPC_DPSU_H_QBR
:
14667 case OPC_DPAX_W_PH
:
14668 case OPC_DPAQ_S_W_PH
:
14669 case OPC_DPAQX_S_W_PH
:
14670 case OPC_DPAQX_SA_W_PH
:
14672 case OPC_DPSX_W_PH
:
14673 case OPC_DPSQ_S_W_PH
:
14674 case OPC_DPSQX_S_W_PH
:
14675 case OPC_DPSQX_SA_W_PH
:
14676 case OPC_MULSAQ_S_W_PH
:
14677 case OPC_DPAQ_SA_L_W
:
14678 case OPC_DPSQ_SA_L_W
:
14679 case OPC_MAQ_S_W_PHL
:
14680 case OPC_MAQ_S_W_PHR
:
14681 case OPC_MAQ_SA_W_PHL
:
14682 case OPC_MAQ_SA_W_PHR
:
14683 case OPC_MULSA_W_PH
:
14684 gen_mipsdsp_multiply(ctx
, op1
, op2
, rd
, rs
, rt
, 0);
14686 default: /* Invalid */
14687 MIPS_INVAL("MASK DPAW.PH");
14688 gen_reserved_instruction(ctx
);
14693 op2
= MASK_INSV(ctx
->opcode
);
14704 t0
= tcg_temp_new();
14705 t1
= tcg_temp_new();
14707 gen_load_gpr(t0
, rt
);
14708 gen_load_gpr(t1
, rs
);
14710 gen_helper_insv(cpu_gpr
[rt
], cpu_env
, t1
, t0
);
14716 default: /* Invalid */
14717 MIPS_INVAL("MASK INSV");
14718 gen_reserved_instruction(ctx
);
14722 case OPC_APPEND_DSP
:
14723 gen_mipsdsp_append(env
, ctx
, op1
, rt
, rs
, rd
);
14725 case OPC_EXTR_W_DSP
:
14726 op2
= MASK_EXTR_W(ctx
->opcode
);
14730 case OPC_EXTR_RS_W
:
14732 case OPC_EXTRV_S_H
:
14734 case OPC_EXTRV_R_W
:
14735 case OPC_EXTRV_RS_W
:
14740 gen_mipsdsp_accinsn(ctx
, op1
, op2
, rt
, rs
, rd
, 1);
14743 gen_mipsdsp_accinsn(ctx
, op1
, op2
, rd
, rs
, rt
, 1);
14749 gen_mipsdsp_accinsn(ctx
, op1
, op2
, rd
, rs
, rt
, 0);
14751 default: /* Invalid */
14752 MIPS_INVAL("MASK EXTR.W");
14753 gen_reserved_instruction(ctx
);
14757 #if defined(TARGET_MIPS64)
14758 case OPC_DDIV_G_2E
:
14759 case OPC_DDIVU_G_2E
:
14760 case OPC_DMULT_G_2E
:
14761 case OPC_DMULTU_G_2E
:
14762 case OPC_DMOD_G_2E
:
14763 case OPC_DMODU_G_2E
:
14764 check_insn(ctx
, INSN_LOONGSON2E
);
14765 gen_loongson_integer(ctx
, op1
, rd
, rs
, rt
);
14767 case OPC_ABSQ_S_QH_DSP
:
14768 op2
= MASK_ABSQ_S_QH(ctx
->opcode
);
14770 case OPC_PRECEQ_L_PWL
:
14771 case OPC_PRECEQ_L_PWR
:
14772 case OPC_PRECEQ_PW_QHL
:
14773 case OPC_PRECEQ_PW_QHR
:
14774 case OPC_PRECEQ_PW_QHLA
:
14775 case OPC_PRECEQ_PW_QHRA
:
14776 case OPC_PRECEQU_QH_OBL
:
14777 case OPC_PRECEQU_QH_OBR
:
14778 case OPC_PRECEQU_QH_OBLA
:
14779 case OPC_PRECEQU_QH_OBRA
:
14780 case OPC_PRECEU_QH_OBL
:
14781 case OPC_PRECEU_QH_OBR
:
14782 case OPC_PRECEU_QH_OBLA
:
14783 case OPC_PRECEU_QH_OBRA
:
14784 case OPC_ABSQ_S_OB
:
14785 case OPC_ABSQ_S_PW
:
14786 case OPC_ABSQ_S_QH
:
14787 gen_mipsdsp_arith(ctx
, op1
, op2
, rd
, rs
, rt
);
14795 gen_mipsdsp_bitinsn(ctx
, op1
, op2
, rd
, rt
);
14797 default: /* Invalid */
14798 MIPS_INVAL("MASK ABSQ_S.QH");
14799 gen_reserved_instruction(ctx
);
14803 case OPC_ADDU_OB_DSP
:
14804 op2
= MASK_ADDU_OB(ctx
->opcode
);
14806 case OPC_RADDU_L_OB
:
14808 case OPC_SUBQ_S_PW
:
14810 case OPC_SUBQ_S_QH
:
14812 case OPC_SUBU_S_OB
:
14814 case OPC_SUBU_S_QH
:
14816 case OPC_SUBUH_R_OB
:
14818 case OPC_ADDQ_S_PW
:
14820 case OPC_ADDQ_S_QH
:
14822 case OPC_ADDU_S_OB
:
14824 case OPC_ADDU_S_QH
:
14826 case OPC_ADDUH_R_OB
:
14827 gen_mipsdsp_arith(ctx
, op1
, op2
, rd
, rs
, rt
);
14829 case OPC_MULEQ_S_PW_QHL
:
14830 case OPC_MULEQ_S_PW_QHR
:
14831 case OPC_MULEU_S_QH_OBL
:
14832 case OPC_MULEU_S_QH_OBR
:
14833 case OPC_MULQ_RS_QH
:
14834 gen_mipsdsp_multiply(ctx
, op1
, op2
, rd
, rs
, rt
, 1);
14836 default: /* Invalid */
14837 MIPS_INVAL("MASK ADDU.OB");
14838 gen_reserved_instruction(ctx
);
14842 case OPC_CMPU_EQ_OB_DSP
:
14843 op2
= MASK_CMPU_EQ_OB(ctx
->opcode
);
14845 case OPC_PRECR_SRA_QH_PW
:
14846 case OPC_PRECR_SRA_R_QH_PW
:
14847 /* Return value is rt. */
14848 gen_mipsdsp_arith(ctx
, op1
, op2
, rt
, rs
, rd
);
14850 case OPC_PRECR_OB_QH
:
14851 case OPC_PRECRQ_OB_QH
:
14852 case OPC_PRECRQ_PW_L
:
14853 case OPC_PRECRQ_QH_PW
:
14854 case OPC_PRECRQ_RS_QH_PW
:
14855 case OPC_PRECRQU_S_OB_QH
:
14856 gen_mipsdsp_arith(ctx
, op1
, op2
, rd
, rs
, rt
);
14858 case OPC_CMPU_EQ_OB
:
14859 case OPC_CMPU_LT_OB
:
14860 case OPC_CMPU_LE_OB
:
14861 case OPC_CMP_EQ_QH
:
14862 case OPC_CMP_LT_QH
:
14863 case OPC_CMP_LE_QH
:
14864 case OPC_CMP_EQ_PW
:
14865 case OPC_CMP_LT_PW
:
14866 case OPC_CMP_LE_PW
:
14867 gen_mipsdsp_add_cmp_pick(ctx
, op1
, op2
, rd
, rs
, rt
, 0);
14869 case OPC_CMPGDU_EQ_OB
:
14870 case OPC_CMPGDU_LT_OB
:
14871 case OPC_CMPGDU_LE_OB
:
14872 case OPC_CMPGU_EQ_OB
:
14873 case OPC_CMPGU_LT_OB
:
14874 case OPC_CMPGU_LE_OB
:
14875 case OPC_PACKRL_PW
:
14879 gen_mipsdsp_add_cmp_pick(ctx
, op1
, op2
, rd
, rs
, rt
, 1);
14881 default: /* Invalid */
14882 MIPS_INVAL("MASK CMPU_EQ.OB");
14883 gen_reserved_instruction(ctx
);
14887 case OPC_DAPPEND_DSP
:
14888 gen_mipsdsp_append(env
, ctx
, op1
, rt
, rs
, rd
);
14890 case OPC_DEXTR_W_DSP
:
14891 op2
= MASK_DEXTR_W(ctx
->opcode
);
14898 case OPC_DEXTR_R_L
:
14899 case OPC_DEXTR_RS_L
:
14901 case OPC_DEXTR_R_W
:
14902 case OPC_DEXTR_RS_W
:
14903 case OPC_DEXTR_S_H
:
14905 case OPC_DEXTRV_R_L
:
14906 case OPC_DEXTRV_RS_L
:
14907 case OPC_DEXTRV_S_H
:
14909 case OPC_DEXTRV_R_W
:
14910 case OPC_DEXTRV_RS_W
:
14911 gen_mipsdsp_accinsn(ctx
, op1
, op2
, rt
, rs
, rd
, 1);
14916 gen_mipsdsp_accinsn(ctx
, op1
, op2
, rd
, rs
, rt
, 0);
14918 default: /* Invalid */
14919 MIPS_INVAL("MASK EXTR.W");
14920 gen_reserved_instruction(ctx
);
14924 case OPC_DPAQ_W_QH_DSP
:
14925 op2
= MASK_DPAQ_W_QH(ctx
->opcode
);
14927 case OPC_DPAU_H_OBL
:
14928 case OPC_DPAU_H_OBR
:
14929 case OPC_DPSU_H_OBL
:
14930 case OPC_DPSU_H_OBR
:
14932 case OPC_DPAQ_S_W_QH
:
14934 case OPC_DPSQ_S_W_QH
:
14935 case OPC_MULSAQ_S_W_QH
:
14936 case OPC_DPAQ_SA_L_PW
:
14937 case OPC_DPSQ_SA_L_PW
:
14938 case OPC_MULSAQ_S_L_PW
:
14939 gen_mipsdsp_multiply(ctx
, op1
, op2
, rd
, rs
, rt
, 0);
14941 case OPC_MAQ_S_W_QHLL
:
14942 case OPC_MAQ_S_W_QHLR
:
14943 case OPC_MAQ_S_W_QHRL
:
14944 case OPC_MAQ_S_W_QHRR
:
14945 case OPC_MAQ_SA_W_QHLL
:
14946 case OPC_MAQ_SA_W_QHLR
:
14947 case OPC_MAQ_SA_W_QHRL
:
14948 case OPC_MAQ_SA_W_QHRR
:
14949 case OPC_MAQ_S_L_PWL
:
14950 case OPC_MAQ_S_L_PWR
:
14955 gen_mipsdsp_multiply(ctx
, op1
, op2
, rd
, rs
, rt
, 0);
14957 default: /* Invalid */
14958 MIPS_INVAL("MASK DPAQ.W.QH");
14959 gen_reserved_instruction(ctx
);
14963 case OPC_DINSV_DSP
:
14964 op2
= MASK_INSV(ctx
->opcode
);
14976 t0
= tcg_temp_new();
14977 t1
= tcg_temp_new();
14979 gen_load_gpr(t0
, rt
);
14980 gen_load_gpr(t1
, rs
);
14982 gen_helper_dinsv(cpu_gpr
[rt
], cpu_env
, t1
, t0
);
14988 default: /* Invalid */
14989 MIPS_INVAL("MASK DINSV");
14990 gen_reserved_instruction(ctx
);
14994 case OPC_SHLL_OB_DSP
:
14995 gen_mipsdsp_shift(ctx
, op1
, rd
, rs
, rt
);
14998 default: /* Invalid */
14999 MIPS_INVAL("special3_legacy");
15000 gen_reserved_instruction(ctx
);
15006 #if defined(TARGET_MIPS64)
15008 static void decode_mmi(CPUMIPSState
*env
, DisasContext
*ctx
)
15010 uint32_t opc
= MASK_MMI(ctx
->opcode
);
15011 int rs
= extract32(ctx
->opcode
, 21, 5);
15012 int rt
= extract32(ctx
->opcode
, 16, 5);
15013 int rd
= extract32(ctx
->opcode
, 11, 5);
15016 case MMI_OPC_MULT1
:
15017 case MMI_OPC_MULTU1
:
15019 case MMI_OPC_MADDU
:
15020 case MMI_OPC_MADD1
:
15021 case MMI_OPC_MADDU1
:
15022 gen_mul_txx9(ctx
, opc
, rd
, rs
, rt
);
15025 case MMI_OPC_DIVU1
:
15026 gen_div1_tx79(ctx
, opc
, rs
, rt
);
15029 MIPS_INVAL("TX79 MMI class");
15030 gen_reserved_instruction(ctx
);
15035 static void gen_mmi_sq(DisasContext
*ctx
, int base
, int rt
, int offset
)
15037 gen_reserved_instruction(ctx
); /* TODO: MMI_OPC_SQ */
15041 * The TX79-specific instruction Store Quadword
15043 * +--------+-------+-------+------------------------+
15044 * | 011111 | base | rt | offset | SQ
15045 * +--------+-------+-------+------------------------+
15048 * has the same opcode as the Read Hardware Register instruction
15050 * +--------+-------+-------+-------+-------+--------+
15051 * | 011111 | 00000 | rt | rd | 00000 | 111011 | RDHWR
15052 * +--------+-------+-------+-------+-------+--------+
15055 * that is required, trapped and emulated by the Linux kernel. However, all
15056 * RDHWR encodings yield address error exceptions on the TX79 since the SQ
15057 * offset is odd. Therefore all valid SQ instructions can execute normally.
15058 * In user mode, QEMU must verify the upper and lower 11 bits to distinguish
15059 * between SQ and RDHWR, as the Linux kernel does.
15061 static void decode_mmi_sq(CPUMIPSState
*env
, DisasContext
*ctx
)
15063 int base
= extract32(ctx
->opcode
, 21, 5);
15064 int rt
= extract32(ctx
->opcode
, 16, 5);
15065 int offset
= extract32(ctx
->opcode
, 0, 16);
15067 #ifdef CONFIG_USER_ONLY
15068 uint32_t op1
= MASK_SPECIAL3(ctx
->opcode
);
15069 uint32_t op2
= extract32(ctx
->opcode
, 6, 5);
15071 if (base
== 0 && op2
== 0 && op1
== OPC_RDHWR
) {
15072 int rd
= extract32(ctx
->opcode
, 11, 5);
15074 gen_rdhwr(ctx
, rt
, rd
, 0);
15079 gen_mmi_sq(ctx
, base
, rt
, offset
);
15084 static void decode_opc_special3(CPUMIPSState
*env
, DisasContext
*ctx
)
15086 int rs
, rt
, rd
, sa
;
15090 rs
= (ctx
->opcode
>> 21) & 0x1f;
15091 rt
= (ctx
->opcode
>> 16) & 0x1f;
15092 rd
= (ctx
->opcode
>> 11) & 0x1f;
15093 sa
= (ctx
->opcode
>> 6) & 0x1f;
15094 imm
= sextract32(ctx
->opcode
, 7, 9);
15096 op1
= MASK_SPECIAL3(ctx
->opcode
);
15099 * EVA loads and stores overlap Loongson 2E instructions decoded by
15100 * decode_opc_special3_legacy(), so be careful to allow their decoding when
15113 check_cp0_enabled(ctx
);
15114 gen_ld(ctx
, op1
, rt
, rs
, imm
);
15121 check_cp0_enabled(ctx
);
15122 gen_st(ctx
, op1
, rt
, rs
, imm
);
15125 check_cp0_enabled(ctx
);
15126 gen_st_cond(ctx
, rt
, rs
, imm
, MO_TESL
, true);
15130 check_cp0_enabled(ctx
);
15131 if (ctx
->hflags
& MIPS_HFLAG_ITC_CACHE
) {
15132 gen_cache_operation(ctx
, rt
, rs
, imm
);
15136 check_cp0_enabled(ctx
);
15137 /* Treat as NOP. */
15145 check_insn(ctx
, ISA_MIPS_R2
);
15146 gen_bitops(ctx
, op1
, rt
, rs
, sa
, rd
);
15149 op2
= MASK_BSHFL(ctx
->opcode
);
15156 check_insn(ctx
, ISA_MIPS_R6
);
15157 decode_opc_special3_r6(env
, ctx
);
15160 check_insn(ctx
, ISA_MIPS_R2
);
15161 gen_bshfl(ctx
, op2
, rt
, rd
);
15165 #if defined(TARGET_MIPS64)
15172 check_insn(ctx
, ISA_MIPS_R2
);
15173 check_mips_64(ctx
);
15174 gen_bitops(ctx
, op1
, rt
, rs
, sa
, rd
);
15177 op2
= MASK_DBSHFL(ctx
->opcode
);
15188 check_insn(ctx
, ISA_MIPS_R6
);
15189 decode_opc_special3_r6(env
, ctx
);
15192 check_insn(ctx
, ISA_MIPS_R2
);
15193 check_mips_64(ctx
);
15194 op2
= MASK_DBSHFL(ctx
->opcode
);
15195 gen_bshfl(ctx
, op2
, rt
, rd
);
15201 gen_rdhwr(ctx
, rt
, rd
, extract32(ctx
->opcode
, 6, 3));
15206 TCGv t0
= tcg_temp_new();
15207 TCGv t1
= tcg_temp_new();
15209 gen_load_gpr(t0
, rt
);
15210 gen_load_gpr(t1
, rs
);
15211 gen_helper_fork(t0
, t1
);
15219 TCGv t0
= tcg_temp_new();
15221 gen_load_gpr(t0
, rs
);
15222 gen_helper_yield(t0
, cpu_env
, t0
);
15223 gen_store_gpr(t0
, rd
);
15228 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15229 decode_opc_special3_r6(env
, ctx
);
15231 decode_opc_special3_legacy(env
, ctx
);
15236 static bool decode_opc_legacy(CPUMIPSState
*env
, DisasContext
*ctx
)
15239 int rs
, rt
, rd
, sa
;
15243 op
= MASK_OP_MAJOR(ctx
->opcode
);
15244 rs
= (ctx
->opcode
>> 21) & 0x1f;
15245 rt
= (ctx
->opcode
>> 16) & 0x1f;
15246 rd
= (ctx
->opcode
>> 11) & 0x1f;
15247 sa
= (ctx
->opcode
>> 6) & 0x1f;
15248 imm
= (int16_t)ctx
->opcode
;
15251 decode_opc_special(env
, ctx
);
15254 #if defined(TARGET_MIPS64)
15255 if ((ctx
->insn_flags
& INSN_R5900
) && (ctx
->insn_flags
& ASE_MMI
)) {
15256 decode_mmi(env
, ctx
);
15260 if (TARGET_LONG_BITS
== 32 && (ctx
->insn_flags
& ASE_MXU
)) {
15261 if (MASK_SPECIAL2(ctx
->opcode
) == OPC_MUL
) {
15262 gen_arith(ctx
, OPC_MUL
, rd
, rs
, rt
);
15264 decode_ase_mxu(ctx
, ctx
->opcode
);
15268 decode_opc_special2_legacy(env
, ctx
);
15271 #if defined(TARGET_MIPS64)
15272 if (ctx
->insn_flags
& INSN_R5900
) {
15273 decode_mmi_sq(env
, ctx
); /* MMI_OPC_SQ */
15275 decode_opc_special3(env
, ctx
);
15278 decode_opc_special3(env
, ctx
);
15282 op1
= MASK_REGIMM(ctx
->opcode
);
15284 case OPC_BLTZL
: /* REGIMM branches */
15288 check_insn(ctx
, ISA_MIPS2
);
15289 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
15293 gen_compute_branch(ctx
, op1
, 4, rs
, -1, imm
<< 2, 4);
15297 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15299 /* OPC_NAL, OPC_BAL */
15300 gen_compute_branch(ctx
, op1
, 4, 0, -1, imm
<< 2, 4);
15302 gen_reserved_instruction(ctx
);
15305 gen_compute_branch(ctx
, op1
, 4, rs
, -1, imm
<< 2, 4);
15308 case OPC_TGEI
: /* REGIMM traps */
15315 check_insn(ctx
, ISA_MIPS2
);
15316 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
15317 gen_trap(ctx
, op1
, rs
, -1, imm
);
15320 check_insn(ctx
, ISA_MIPS_R6
);
15321 gen_reserved_instruction(ctx
);
15324 check_insn(ctx
, ISA_MIPS_R2
);
15326 * Break the TB to be able to sync copied instructions
15329 ctx
->base
.is_jmp
= DISAS_STOP
;
15331 case OPC_BPOSGE32
: /* MIPS DSP branch */
15332 #if defined(TARGET_MIPS64)
15336 gen_compute_branch(ctx
, op1
, 4, -1, -2, (int32_t)imm
<< 2, 4);
15338 #if defined(TARGET_MIPS64)
15340 check_insn(ctx
, ISA_MIPS_R6
);
15341 check_mips_64(ctx
);
15343 tcg_gen_addi_tl(cpu_gpr
[rs
], cpu_gpr
[rs
], (int64_t)imm
<< 32);
15347 check_insn(ctx
, ISA_MIPS_R6
);
15348 check_mips_64(ctx
);
15350 tcg_gen_addi_tl(cpu_gpr
[rs
], cpu_gpr
[rs
], (int64_t)imm
<< 48);
15354 default: /* Invalid */
15355 MIPS_INVAL("regimm");
15356 gen_reserved_instruction(ctx
);
15361 check_cp0_enabled(ctx
);
15362 op1
= MASK_CP0(ctx
->opcode
);
15370 #if defined(TARGET_MIPS64)
15374 #ifndef CONFIG_USER_ONLY
15375 gen_cp0(env
, ctx
, op1
, rt
, rd
);
15376 #endif /* !CONFIG_USER_ONLY */
15394 #ifndef CONFIG_USER_ONLY
15395 gen_cp0(env
, ctx
, MASK_C0(ctx
->opcode
), rt
, rd
);
15396 #endif /* !CONFIG_USER_ONLY */
15399 #ifndef CONFIG_USER_ONLY
15402 TCGv t0
= tcg_temp_new();
15404 op2
= MASK_MFMC0(ctx
->opcode
);
15408 gen_helper_dmt(t0
);
15409 gen_store_gpr(t0
, rt
);
15413 gen_helper_emt(t0
);
15414 gen_store_gpr(t0
, rt
);
15418 gen_helper_dvpe(t0
, cpu_env
);
15419 gen_store_gpr(t0
, rt
);
15423 gen_helper_evpe(t0
, cpu_env
);
15424 gen_store_gpr(t0
, rt
);
15427 check_insn(ctx
, ISA_MIPS_R6
);
15429 gen_helper_dvp(t0
, cpu_env
);
15430 gen_store_gpr(t0
, rt
);
15434 check_insn(ctx
, ISA_MIPS_R6
);
15436 gen_helper_evp(t0
, cpu_env
);
15437 gen_store_gpr(t0
, rt
);
15441 check_insn(ctx
, ISA_MIPS_R2
);
15442 save_cpu_state(ctx
, 1);
15443 gen_helper_di(t0
, cpu_env
);
15444 gen_store_gpr(t0
, rt
);
15446 * Stop translation as we may have switched
15447 * the execution mode.
15449 ctx
->base
.is_jmp
= DISAS_STOP
;
15452 check_insn(ctx
, ISA_MIPS_R2
);
15453 save_cpu_state(ctx
, 1);
15454 gen_helper_ei(t0
, cpu_env
);
15455 gen_store_gpr(t0
, rt
);
15457 * DISAS_STOP isn't sufficient, we need to ensure we break
15458 * out of translated code to check for pending interrupts.
15460 gen_save_pc(ctx
->base
.pc_next
+ 4);
15461 ctx
->base
.is_jmp
= DISAS_EXIT
;
15463 default: /* Invalid */
15464 MIPS_INVAL("mfmc0");
15465 gen_reserved_instruction(ctx
);
15470 #endif /* !CONFIG_USER_ONLY */
15473 check_insn(ctx
, ISA_MIPS_R2
);
15474 gen_load_srsgpr(rt
, rd
);
15477 check_insn(ctx
, ISA_MIPS_R2
);
15478 gen_store_srsgpr(rt
, rd
);
15482 gen_reserved_instruction(ctx
);
15486 case OPC_BOVC
: /* OPC_BEQZALC, OPC_BEQC, OPC_ADDI */
15487 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15488 /* OPC_BOVC, OPC_BEQZALC, OPC_BEQC */
15489 gen_compute_compact_branch(ctx
, op
, rs
, rt
, imm
<< 2);
15492 /* Arithmetic with immediate opcode */
15493 gen_arith_imm(ctx
, op
, rt
, rs
, imm
);
15497 gen_arith_imm(ctx
, op
, rt
, rs
, imm
);
15499 case OPC_SLTI
: /* Set on less than with immediate opcode */
15501 gen_slt_imm(ctx
, op
, rt
, rs
, imm
);
15503 case OPC_ANDI
: /* Arithmetic with immediate opcode */
15504 case OPC_LUI
: /* OPC_AUI */
15507 gen_logic_imm(ctx
, op
, rt
, rs
, imm
);
15509 case OPC_J
: /* Jump */
15511 offset
= (int32_t)(ctx
->opcode
& 0x3FFFFFF) << 2;
15512 gen_compute_branch(ctx
, op
, 4, rs
, rt
, offset
, 4);
15515 case OPC_BLEZC
: /* OPC_BGEZC, OPC_BGEC, OPC_BLEZL */
15516 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15518 gen_reserved_instruction(ctx
);
15521 /* OPC_BLEZC, OPC_BGEZC, OPC_BGEC */
15522 gen_compute_compact_branch(ctx
, op
, rs
, rt
, imm
<< 2);
15525 gen_compute_branch(ctx
, op
, 4, rs
, rt
, imm
<< 2, 4);
15528 case OPC_BGTZC
: /* OPC_BLTZC, OPC_BLTC, OPC_BGTZL */
15529 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15531 gen_reserved_instruction(ctx
);
15534 /* OPC_BGTZC, OPC_BLTZC, OPC_BLTC */
15535 gen_compute_compact_branch(ctx
, op
, rs
, rt
, imm
<< 2);
15538 gen_compute_branch(ctx
, op
, 4, rs
, rt
, imm
<< 2, 4);
15541 case OPC_BLEZALC
: /* OPC_BGEZALC, OPC_BGEUC, OPC_BLEZ */
15544 gen_compute_branch(ctx
, op
, 4, rs
, rt
, imm
<< 2, 4);
15546 check_insn(ctx
, ISA_MIPS_R6
);
15547 /* OPC_BLEZALC, OPC_BGEZALC, OPC_BGEUC */
15548 gen_compute_compact_branch(ctx
, op
, rs
, rt
, imm
<< 2);
15551 case OPC_BGTZALC
: /* OPC_BLTZALC, OPC_BLTUC, OPC_BGTZ */
15554 gen_compute_branch(ctx
, op
, 4, rs
, rt
, imm
<< 2, 4);
15556 check_insn(ctx
, ISA_MIPS_R6
);
15557 /* OPC_BGTZALC, OPC_BLTZALC, OPC_BLTUC */
15558 gen_compute_compact_branch(ctx
, op
, rs
, rt
, imm
<< 2);
15563 check_insn(ctx
, ISA_MIPS2
);
15564 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
15568 gen_compute_branch(ctx
, op
, 4, rs
, rt
, imm
<< 2, 4);
15570 case OPC_LL
: /* Load and stores */
15571 check_insn(ctx
, ISA_MIPS2
);
15572 if (ctx
->insn_flags
& INSN_R5900
) {
15573 check_insn_opc_user_only(ctx
, INSN_R5900
);
15584 gen_ld(ctx
, op
, rt
, rs
, imm
);
15591 gen_st(ctx
, op
, rt
, rs
, imm
);
15594 check_insn(ctx
, ISA_MIPS2
);
15595 if (ctx
->insn_flags
& INSN_R5900
) {
15596 check_insn_opc_user_only(ctx
, INSN_R5900
);
15598 gen_st_cond(ctx
, rt
, rs
, imm
, MO_TESL
, false);
15601 check_cp0_enabled(ctx
);
15602 check_insn(ctx
, ISA_MIPS3
| ISA_MIPS_R1
);
15603 if (ctx
->hflags
& MIPS_HFLAG_ITC_CACHE
) {
15604 gen_cache_operation(ctx
, rt
, rs
, imm
);
15606 /* Treat as NOP. */
15609 check_insn(ctx
, ISA_MIPS4
| ISA_MIPS_R1
| INSN_R5900
);
15610 /* Treat as NOP. */
15613 /* Floating point (COP1). */
15618 gen_cop1_ldst(ctx
, op
, rt
, rs
, imm
);
15622 op1
= MASK_CP1(ctx
->opcode
);
15627 check_cp1_enabled(ctx
);
15628 check_insn(ctx
, ISA_MIPS_R2
);
15634 check_cp1_enabled(ctx
);
15635 gen_cp1(ctx
, op1
, rt
, rd
);
15637 #if defined(TARGET_MIPS64)
15640 check_cp1_enabled(ctx
);
15641 check_insn(ctx
, ISA_MIPS3
);
15642 check_mips_64(ctx
);
15643 gen_cp1(ctx
, op1
, rt
, rd
);
15646 case OPC_BC1EQZ
: /* OPC_BC1ANY2 */
15647 check_cp1_enabled(ctx
);
15648 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15650 gen_compute_branch1_r6(ctx
, MASK_CP1(ctx
->opcode
),
15655 check_insn(ctx
, ASE_MIPS3D
);
15656 gen_compute_branch1(ctx
, MASK_BC1(ctx
->opcode
),
15657 (rt
>> 2) & 0x7, imm
<< 2);
15661 check_cp1_enabled(ctx
);
15662 check_insn(ctx
, ISA_MIPS_R6
);
15663 gen_compute_branch1_r6(ctx
, MASK_CP1(ctx
->opcode
),
15667 check_cp1_enabled(ctx
);
15668 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
15670 check_insn(ctx
, ASE_MIPS3D
);
15673 check_cp1_enabled(ctx
);
15674 check_insn_opc_removed(ctx
, ISA_MIPS_R6
);
15675 gen_compute_branch1(ctx
, MASK_BC1(ctx
->opcode
),
15676 (rt
>> 2) & 0x7, imm
<< 2);
15683 check_cp1_enabled(ctx
);
15684 gen_farith(ctx
, ctx
->opcode
& FOP(0x3f, 0x1f), rt
, rd
, sa
,
15690 int r6_op
= ctx
->opcode
& FOP(0x3f, 0x1f);
15691 check_cp1_enabled(ctx
);
15692 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15694 case R6_OPC_CMP_AF_S
:
15695 case R6_OPC_CMP_UN_S
:
15696 case R6_OPC_CMP_EQ_S
:
15697 case R6_OPC_CMP_UEQ_S
:
15698 case R6_OPC_CMP_LT_S
:
15699 case R6_OPC_CMP_ULT_S
:
15700 case R6_OPC_CMP_LE_S
:
15701 case R6_OPC_CMP_ULE_S
:
15702 case R6_OPC_CMP_SAF_S
:
15703 case R6_OPC_CMP_SUN_S
:
15704 case R6_OPC_CMP_SEQ_S
:
15705 case R6_OPC_CMP_SEUQ_S
:
15706 case R6_OPC_CMP_SLT_S
:
15707 case R6_OPC_CMP_SULT_S
:
15708 case R6_OPC_CMP_SLE_S
:
15709 case R6_OPC_CMP_SULE_S
:
15710 case R6_OPC_CMP_OR_S
:
15711 case R6_OPC_CMP_UNE_S
:
15712 case R6_OPC_CMP_NE_S
:
15713 case R6_OPC_CMP_SOR_S
:
15714 case R6_OPC_CMP_SUNE_S
:
15715 case R6_OPC_CMP_SNE_S
:
15716 gen_r6_cmp_s(ctx
, ctx
->opcode
& 0x1f, rt
, rd
, sa
);
15718 case R6_OPC_CMP_AF_D
:
15719 case R6_OPC_CMP_UN_D
:
15720 case R6_OPC_CMP_EQ_D
:
15721 case R6_OPC_CMP_UEQ_D
:
15722 case R6_OPC_CMP_LT_D
:
15723 case R6_OPC_CMP_ULT_D
:
15724 case R6_OPC_CMP_LE_D
:
15725 case R6_OPC_CMP_ULE_D
:
15726 case R6_OPC_CMP_SAF_D
:
15727 case R6_OPC_CMP_SUN_D
:
15728 case R6_OPC_CMP_SEQ_D
:
15729 case R6_OPC_CMP_SEUQ_D
:
15730 case R6_OPC_CMP_SLT_D
:
15731 case R6_OPC_CMP_SULT_D
:
15732 case R6_OPC_CMP_SLE_D
:
15733 case R6_OPC_CMP_SULE_D
:
15734 case R6_OPC_CMP_OR_D
:
15735 case R6_OPC_CMP_UNE_D
:
15736 case R6_OPC_CMP_NE_D
:
15737 case R6_OPC_CMP_SOR_D
:
15738 case R6_OPC_CMP_SUNE_D
:
15739 case R6_OPC_CMP_SNE_D
:
15740 gen_r6_cmp_d(ctx
, ctx
->opcode
& 0x1f, rt
, rd
, sa
);
15743 gen_farith(ctx
, ctx
->opcode
& FOP(0x3f, 0x1f),
15744 rt
, rd
, sa
, (imm
>> 8) & 0x7);
15749 gen_farith(ctx
, ctx
->opcode
& FOP(0x3f, 0x1f), rt
, rd
, sa
,
15756 gen_reserved_instruction(ctx
);
15761 /* Compact branches [R6] and COP2 [non-R6] */
15762 case OPC_BC
: /* OPC_LWC2 */
15763 case OPC_BALC
: /* OPC_SWC2 */
15764 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15765 /* OPC_BC, OPC_BALC */
15766 gen_compute_compact_branch(ctx
, op
, 0, 0,
15767 sextract32(ctx
->opcode
<< 2, 0, 28));
15768 } else if (ctx
->insn_flags
& ASE_LEXT
) {
15769 gen_loongson_lswc2(ctx
, rt
, rs
, rd
);
15771 /* OPC_LWC2, OPC_SWC2 */
15772 /* COP2: Not implemented. */
15773 generate_exception_err(ctx
, EXCP_CpU
, 2);
15776 case OPC_BEQZC
: /* OPC_JIC, OPC_LDC2 */
15777 case OPC_BNEZC
: /* OPC_JIALC, OPC_SDC2 */
15778 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15780 /* OPC_BEQZC, OPC_BNEZC */
15781 gen_compute_compact_branch(ctx
, op
, rs
, 0,
15782 sextract32(ctx
->opcode
<< 2, 0, 23));
15784 /* OPC_JIC, OPC_JIALC */
15785 gen_compute_compact_branch(ctx
, op
, 0, rt
, imm
);
15787 } else if (ctx
->insn_flags
& ASE_LEXT
) {
15788 gen_loongson_lsdc2(ctx
, rt
, rs
, rd
);
15790 /* OPC_LWC2, OPC_SWC2 */
15791 /* COP2: Not implemented. */
15792 generate_exception_err(ctx
, EXCP_CpU
, 2);
15796 check_insn(ctx
, ASE_LMMI
);
15797 /* Note that these instructions use different fields. */
15798 gen_loongson_multimedia(ctx
, sa
, rd
, rt
);
15802 if (ctx
->CP0_Config1
& (1 << CP0C1_FP
)) {
15803 check_cp1_enabled(ctx
);
15804 op1
= MASK_CP3(ctx
->opcode
);
15808 check_insn(ctx
, ISA_MIPS5
| ISA_MIPS_R2
);
15814 check_insn(ctx
, ISA_MIPS4
| ISA_MIPS_R2
);
15815 gen_flt3_ldst(ctx
, op1
, sa
, rd
, rs
, rt
);
15818 check_insn(ctx
, ISA_MIPS4
| ISA_MIPS_R2
);
15819 /* Treat as NOP. */
15822 check_insn(ctx
, ISA_MIPS5
| ISA_MIPS_R2
);
15836 check_insn(ctx
, ISA_MIPS4
| ISA_MIPS_R2
);
15837 gen_flt3_arith(ctx
, op1
, sa
, rs
, rd
, rt
);
15841 gen_reserved_instruction(ctx
);
15845 generate_exception_err(ctx
, EXCP_CpU
, 1);
15849 #if defined(TARGET_MIPS64)
15850 /* MIPS64 opcodes */
15852 if (ctx
->insn_flags
& INSN_R5900
) {
15853 check_insn_opc_user_only(ctx
, INSN_R5900
);
15860 check_insn(ctx
, ISA_MIPS3
);
15861 check_mips_64(ctx
);
15862 gen_ld(ctx
, op
, rt
, rs
, imm
);
15867 check_insn(ctx
, ISA_MIPS3
);
15868 check_mips_64(ctx
);
15869 gen_st(ctx
, op
, rt
, rs
, imm
);
15872 check_insn(ctx
, ISA_MIPS3
);
15873 if (ctx
->insn_flags
& INSN_R5900
) {
15874 check_insn_opc_user_only(ctx
, INSN_R5900
);
15876 check_mips_64(ctx
);
15877 gen_st_cond(ctx
, rt
, rs
, imm
, MO_TEQ
, false);
15879 case OPC_BNVC
: /* OPC_BNEZALC, OPC_BNEC, OPC_DADDI */
15880 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15881 /* OPC_BNVC, OPC_BNEZALC, OPC_BNEC */
15882 gen_compute_compact_branch(ctx
, op
, rs
, rt
, imm
<< 2);
15885 check_insn(ctx
, ISA_MIPS3
);
15886 check_mips_64(ctx
);
15887 gen_arith_imm(ctx
, op
, rt
, rs
, imm
);
15891 check_insn(ctx
, ISA_MIPS3
);
15892 check_mips_64(ctx
);
15893 gen_arith_imm(ctx
, op
, rt
, rs
, imm
);
15896 case OPC_BNVC
: /* OPC_BNEZALC, OPC_BNEC */
15897 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15898 gen_compute_compact_branch(ctx
, op
, rs
, rt
, imm
<< 2);
15900 MIPS_INVAL("major opcode");
15901 gen_reserved_instruction(ctx
);
15905 case OPC_DAUI
: /* OPC_JALX */
15906 if (ctx
->insn_flags
& ISA_MIPS_R6
) {
15907 #if defined(TARGET_MIPS64)
15909 check_mips_64(ctx
);
15911 generate_exception(ctx
, EXCP_RI
);
15912 } else if (rt
!= 0) {
15913 TCGv t0
= tcg_temp_new();
15914 gen_load_gpr(t0
, rs
);
15915 tcg_gen_addi_tl(cpu_gpr
[rt
], t0
, imm
<< 16);
15919 gen_reserved_instruction(ctx
);
15920 MIPS_INVAL("major opcode");
15924 check_insn(ctx
, ASE_MIPS16
| ASE_MICROMIPS
);
15925 offset
= (int32_t)(ctx
->opcode
& 0x3FFFFFF) << 2;
15926 gen_compute_branch(ctx
, op
, 4, rs
, rt
, offset
, 4);
15930 /* MDMX: Not implemented. */
15933 check_insn(ctx
, ISA_MIPS_R6
);
15934 gen_pcrel(ctx
, ctx
->opcode
, ctx
->base
.pc_next
, rs
);
15936 default: /* Invalid */
15937 MIPS_INVAL("major opcode");
15943 static void decode_opc(CPUMIPSState
*env
, DisasContext
*ctx
)
15945 /* make sure instructions are on a word boundary */
15946 if (ctx
->base
.pc_next
& 0x3) {
15947 env
->CP0_BadVAddr
= ctx
->base
.pc_next
;
15948 generate_exception_err(ctx
, EXCP_AdEL
, EXCP_INST_NOTAVAIL
);
15952 /* Handle blikely not taken case */
15953 if ((ctx
->hflags
& MIPS_HFLAG_BMASK_BASE
) == MIPS_HFLAG_BL
) {
15954 TCGLabel
*l1
= gen_new_label();
15956 tcg_gen_brcondi_tl(TCG_COND_NE
, bcond
, 0, l1
);
15957 tcg_gen_movi_i32(hflags
, ctx
->hflags
& ~MIPS_HFLAG_BMASK
);
15958 gen_goto_tb(ctx
, 1, ctx
->base
.pc_next
+ 4);
15962 /* Transition to the auto-generated decoder. */
15964 /* Vendor specific extensions */
15965 if (cpu_supports_isa(env
, INSN_R5900
) && decode_ext_txx9(ctx
, ctx
->opcode
)) {
15968 if (cpu_supports_isa(env
, INSN_VR54XX
) && decode_ext_vr54xx(ctx
, ctx
->opcode
)) {
15972 /* ISA extensions */
15973 if (ase_msa_available(env
) && decode_ase_msa(ctx
, ctx
->opcode
)) {
15977 /* ISA (from latest to oldest) */
15978 if (cpu_supports_isa(env
, ISA_MIPS_R6
) && decode_isa_rel6(ctx
, ctx
->opcode
)) {
15982 if (decode_opc_legacy(env
, ctx
)) {
15986 gen_reserved_instruction(ctx
);
15989 static void mips_tr_init_disas_context(DisasContextBase
*dcbase
, CPUState
*cs
)
15991 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
15992 CPUMIPSState
*env
= cs
->env_ptr
;
15994 ctx
->page_start
= ctx
->base
.pc_first
& TARGET_PAGE_MASK
;
15995 ctx
->saved_pc
= -1;
15996 ctx
->insn_flags
= env
->insn_flags
;
15997 ctx
->CP0_Config1
= env
->CP0_Config1
;
15998 ctx
->CP0_Config2
= env
->CP0_Config2
;
15999 ctx
->CP0_Config3
= env
->CP0_Config3
;
16000 ctx
->CP0_Config5
= env
->CP0_Config5
;
16002 ctx
->kscrexist
= (env
->CP0_Config4
>> CP0C4_KScrExist
) & 0xff;
16003 ctx
->rxi
= (env
->CP0_Config3
>> CP0C3_RXI
) & 1;
16004 ctx
->ie
= (env
->CP0_Config4
>> CP0C4_IE
) & 3;
16005 ctx
->bi
= (env
->CP0_Config3
>> CP0C3_BI
) & 1;
16006 ctx
->bp
= (env
->CP0_Config3
>> CP0C3_BP
) & 1;
16007 ctx
->PAMask
= env
->PAMask
;
16008 ctx
->mvh
= (env
->CP0_Config5
>> CP0C5_MVH
) & 1;
16009 ctx
->eva
= (env
->CP0_Config5
>> CP0C5_EVA
) & 1;
16010 ctx
->sc
= (env
->CP0_Config3
>> CP0C3_SC
) & 1;
16011 ctx
->CP0_LLAddr_shift
= env
->CP0_LLAddr_shift
;
16012 ctx
->cmgcr
= (env
->CP0_Config3
>> CP0C3_CMGCR
) & 1;
16013 /* Restore delay slot state from the tb context. */
16014 ctx
->hflags
= (uint32_t)ctx
->base
.tb
->flags
; /* FIXME: maybe use 64 bits? */
16015 ctx
->ulri
= (env
->CP0_Config3
>> CP0C3_ULRI
) & 1;
16016 ctx
->ps
= ((env
->active_fpu
.fcr0
>> FCR0_PS
) & 1) ||
16017 (env
->insn_flags
& (INSN_LOONGSON2E
| INSN_LOONGSON2F
));
16018 ctx
->vp
= (env
->CP0_Config5
>> CP0C5_VP
) & 1;
16019 ctx
->mrp
= (env
->CP0_Config5
>> CP0C5_MRP
) & 1;
16020 ctx
->nan2008
= (env
->active_fpu
.fcr31
>> FCR31_NAN2008
) & 1;
16021 ctx
->abs2008
= (env
->active_fpu
.fcr31
>> FCR31_ABS2008
) & 1;
16022 ctx
->mi
= (env
->CP0_Config5
>> CP0C5_MI
) & 1;
16023 ctx
->gi
= (env
->CP0_Config5
>> CP0C5_GI
) & 3;
16024 restore_cpu_state(env
, ctx
);
16025 #ifdef CONFIG_USER_ONLY
16026 ctx
->mem_idx
= MIPS_HFLAG_UM
;
16028 ctx
->mem_idx
= hflags_mmu_index(ctx
->hflags
);
16030 ctx
->default_tcg_memop_mask
= (ctx
->insn_flags
& (ISA_MIPS_R6
|
16031 INSN_LOONGSON3A
)) ? MO_UNALN
: MO_ALIGN
;
16033 LOG_DISAS("\ntb %p idx %d hflags %04x\n", ctx
->base
.tb
, ctx
->mem_idx
,
16037 static void mips_tr_tb_start(DisasContextBase
*dcbase
, CPUState
*cs
)
16041 static void mips_tr_insn_start(DisasContextBase
*dcbase
, CPUState
*cs
)
16043 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
16045 tcg_gen_insn_start(ctx
->base
.pc_next
, ctx
->hflags
& MIPS_HFLAG_BMASK
,
16049 static void mips_tr_translate_insn(DisasContextBase
*dcbase
, CPUState
*cs
)
16051 CPUMIPSState
*env
= cs
->env_ptr
;
16052 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
16056 is_slot
= ctx
->hflags
& MIPS_HFLAG_BMASK
;
16057 if (ctx
->insn_flags
& ISA_NANOMIPS32
) {
16058 ctx
->opcode
= translator_lduw(env
, ctx
->base
.pc_next
);
16059 insn_bytes
= decode_isa_nanomips(env
, ctx
);
16060 } else if (!(ctx
->hflags
& MIPS_HFLAG_M16
)) {
16061 ctx
->opcode
= translator_ldl(env
, ctx
->base
.pc_next
);
16063 decode_opc(env
, ctx
);
16064 } else if (ctx
->insn_flags
& ASE_MICROMIPS
) {
16065 ctx
->opcode
= translator_lduw(env
, ctx
->base
.pc_next
);
16066 insn_bytes
= decode_isa_micromips(env
, ctx
);
16067 } else if (ctx
->insn_flags
& ASE_MIPS16
) {
16068 ctx
->opcode
= translator_lduw(env
, ctx
->base
.pc_next
);
16069 insn_bytes
= decode_ase_mips16e(env
, ctx
);
16071 gen_reserved_instruction(ctx
);
16072 g_assert(ctx
->base
.is_jmp
== DISAS_NORETURN
);
16076 if (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
16077 if (!(ctx
->hflags
& (MIPS_HFLAG_BDS16
| MIPS_HFLAG_BDS32
|
16078 MIPS_HFLAG_FBNSLOT
))) {
16080 * Force to generate branch as there is neither delay nor
16085 if ((ctx
->hflags
& MIPS_HFLAG_M16
) &&
16086 (ctx
->hflags
& MIPS_HFLAG_FBNSLOT
)) {
16088 * Force to generate branch as microMIPS R6 doesn't restrict
16089 * branches in the forbidden slot.
16095 gen_branch(ctx
, insn_bytes
);
16097 ctx
->base
.pc_next
+= insn_bytes
;
16099 if (ctx
->base
.is_jmp
!= DISAS_NEXT
) {
16103 * Execute a branch and its delay slot as a single instruction.
16104 * This is what GDB expects and is consistent with what the
16105 * hardware does (e.g. if a delay slot instruction faults, the
16106 * reported PC is the PC of the branch).
16108 if (ctx
->base
.singlestep_enabled
&&
16109 (ctx
->hflags
& MIPS_HFLAG_BMASK
) == 0) {
16110 ctx
->base
.is_jmp
= DISAS_TOO_MANY
;
16112 if (ctx
->base
.pc_next
- ctx
->page_start
>= TARGET_PAGE_SIZE
) {
16113 ctx
->base
.is_jmp
= DISAS_TOO_MANY
;
16117 static void mips_tr_tb_stop(DisasContextBase
*dcbase
, CPUState
*cs
)
16119 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
16121 if (ctx
->base
.singlestep_enabled
&& ctx
->base
.is_jmp
!= DISAS_NORETURN
) {
16122 save_cpu_state(ctx
, ctx
->base
.is_jmp
!= DISAS_EXIT
);
16123 gen_helper_raise_exception_debug(cpu_env
);
16125 switch (ctx
->base
.is_jmp
) {
16127 gen_save_pc(ctx
->base
.pc_next
);
16128 tcg_gen_lookup_and_goto_ptr();
16131 case DISAS_TOO_MANY
:
16132 save_cpu_state(ctx
, 0);
16133 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
);
16136 tcg_gen_exit_tb(NULL
, 0);
16138 case DISAS_NORETURN
:
16141 g_assert_not_reached();
16146 static void mips_tr_disas_log(const DisasContextBase
*dcbase
, CPUState
*cs
)
16148 qemu_log("IN: %s\n", lookup_symbol(dcbase
->pc_first
));
16149 log_target_disas(cs
, dcbase
->pc_first
, dcbase
->tb
->size
);
16152 static const TranslatorOps mips_tr_ops
= {
16153 .init_disas_context
= mips_tr_init_disas_context
,
16154 .tb_start
= mips_tr_tb_start
,
16155 .insn_start
= mips_tr_insn_start
,
16156 .translate_insn
= mips_tr_translate_insn
,
16157 .tb_stop
= mips_tr_tb_stop
,
16158 .disas_log
= mips_tr_disas_log
,
16161 void gen_intermediate_code(CPUState
*cs
, TranslationBlock
*tb
, int max_insns
)
16165 translator_loop(&mips_tr_ops
, &ctx
.base
, cs
, tb
, max_insns
);
16168 void mips_tcg_init(void)
16173 for (i
= 1; i
< 32; i
++)
16174 cpu_gpr
[i
] = tcg_global_mem_new(cpu_env
,
16175 offsetof(CPUMIPSState
,
16178 #if defined(TARGET_MIPS64)
16179 cpu_gpr_hi
[0] = NULL
;
16181 for (unsigned i
= 1; i
< 32; i
++) {
16182 g_autofree
char *rname
= g_strdup_printf("%s[hi]", regnames
[i
]);
16184 cpu_gpr_hi
[i
] = tcg_global_mem_new_i64(cpu_env
,
16185 offsetof(CPUMIPSState
,
16186 active_tc
.gpr_hi
[i
]),
16189 #endif /* !TARGET_MIPS64 */
16190 for (i
= 0; i
< 32; i
++) {
16191 int off
= offsetof(CPUMIPSState
, active_fpu
.fpr
[i
].wr
.d
[0]);
16193 fpu_f64
[i
] = tcg_global_mem_new_i64(cpu_env
, off
, fregnames
[i
]);
16195 msa_translate_init();
16196 cpu_PC
= tcg_global_mem_new(cpu_env
,
16197 offsetof(CPUMIPSState
, active_tc
.PC
), "PC");
16198 for (i
= 0; i
< MIPS_DSP_ACC
; i
++) {
16199 cpu_HI
[i
] = tcg_global_mem_new(cpu_env
,
16200 offsetof(CPUMIPSState
, active_tc
.HI
[i
]),
16202 cpu_LO
[i
] = tcg_global_mem_new(cpu_env
,
16203 offsetof(CPUMIPSState
, active_tc
.LO
[i
]),
16206 cpu_dspctrl
= tcg_global_mem_new(cpu_env
,
16207 offsetof(CPUMIPSState
,
16208 active_tc
.DSPControl
),
16210 bcond
= tcg_global_mem_new(cpu_env
,
16211 offsetof(CPUMIPSState
, bcond
), "bcond");
16212 btarget
= tcg_global_mem_new(cpu_env
,
16213 offsetof(CPUMIPSState
, btarget
), "btarget");
16214 hflags
= tcg_global_mem_new_i32(cpu_env
,
16215 offsetof(CPUMIPSState
, hflags
), "hflags");
16217 fpu_fcr0
= tcg_global_mem_new_i32(cpu_env
,
16218 offsetof(CPUMIPSState
, active_fpu
.fcr0
),
16220 fpu_fcr31
= tcg_global_mem_new_i32(cpu_env
,
16221 offsetof(CPUMIPSState
, active_fpu
.fcr31
),
16223 cpu_lladdr
= tcg_global_mem_new(cpu_env
, offsetof(CPUMIPSState
, lladdr
),
16225 cpu_llval
= tcg_global_mem_new(cpu_env
, offsetof(CPUMIPSState
, llval
),
16228 if (TARGET_LONG_BITS
== 32) {
16229 mxu_translate_init();
16233 void restore_state_to_opc(CPUMIPSState
*env
, TranslationBlock
*tb
,
16234 target_ulong
*data
)
16236 env
->active_tc
.PC
= data
[0];
16237 env
->hflags
&= ~MIPS_HFLAG_BMASK
;
16238 env
->hflags
|= data
[1];
16239 switch (env
->hflags
& MIPS_HFLAG_BMASK_BASE
) {
16240 case MIPS_HFLAG_BR
:
16242 case MIPS_HFLAG_BC
:
16243 case MIPS_HFLAG_BL
:
16245 env
->btarget
= data
[2];