2 * MIPS32 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)
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
33 #include "qemu-common.h"
39 //#define MIPS_DEBUG_DISAS
40 //#define MIPS_DEBUG_SIGN_EXTENSIONS
41 //#define MIPS_SINGLE_STEP
43 /* MIPS major opcodes */
44 #define MASK_OP_MAJOR(op) (op & (0x3F << 26))
47 /* indirect opcode tables */
48 OPC_SPECIAL
= (0x00 << 26),
49 OPC_REGIMM
= (0x01 << 26),
50 OPC_CP0
= (0x10 << 26),
51 OPC_CP1
= (0x11 << 26),
52 OPC_CP2
= (0x12 << 26),
53 OPC_CP3
= (0x13 << 26),
54 OPC_SPECIAL2
= (0x1C << 26),
55 OPC_SPECIAL3
= (0x1F << 26),
56 /* arithmetic with immediate */
57 OPC_ADDI
= (0x08 << 26),
58 OPC_ADDIU
= (0x09 << 26),
59 OPC_SLTI
= (0x0A << 26),
60 OPC_SLTIU
= (0x0B << 26),
61 OPC_ANDI
= (0x0C << 26),
62 OPC_ORI
= (0x0D << 26),
63 OPC_XORI
= (0x0E << 26),
64 OPC_LUI
= (0x0F << 26),
65 OPC_DADDI
= (0x18 << 26),
66 OPC_DADDIU
= (0x19 << 26),
67 /* Jump and branches */
69 OPC_JAL
= (0x03 << 26),
70 OPC_BEQ
= (0x04 << 26), /* Unconditional if rs = rt = 0 (B) */
71 OPC_BEQL
= (0x14 << 26),
72 OPC_BNE
= (0x05 << 26),
73 OPC_BNEL
= (0x15 << 26),
74 OPC_BLEZ
= (0x06 << 26),
75 OPC_BLEZL
= (0x16 << 26),
76 OPC_BGTZ
= (0x07 << 26),
77 OPC_BGTZL
= (0x17 << 26),
78 OPC_JALX
= (0x1D << 26), /* MIPS 16 only */
80 OPC_LDL
= (0x1A << 26),
81 OPC_LDR
= (0x1B << 26),
82 OPC_LB
= (0x20 << 26),
83 OPC_LH
= (0x21 << 26),
84 OPC_LWL
= (0x22 << 26),
85 OPC_LW
= (0x23 << 26),
86 OPC_LBU
= (0x24 << 26),
87 OPC_LHU
= (0x25 << 26),
88 OPC_LWR
= (0x26 << 26),
89 OPC_LWU
= (0x27 << 26),
90 OPC_SB
= (0x28 << 26),
91 OPC_SH
= (0x29 << 26),
92 OPC_SWL
= (0x2A << 26),
93 OPC_SW
= (0x2B << 26),
94 OPC_SDL
= (0x2C << 26),
95 OPC_SDR
= (0x2D << 26),
96 OPC_SWR
= (0x2E << 26),
97 OPC_LL
= (0x30 << 26),
98 OPC_LLD
= (0x34 << 26),
99 OPC_LD
= (0x37 << 26),
100 OPC_SC
= (0x38 << 26),
101 OPC_SCD
= (0x3C << 26),
102 OPC_SD
= (0x3F << 26),
103 /* Floating point load/store */
104 OPC_LWC1
= (0x31 << 26),
105 OPC_LWC2
= (0x32 << 26),
106 OPC_LDC1
= (0x35 << 26),
107 OPC_LDC2
= (0x36 << 26),
108 OPC_SWC1
= (0x39 << 26),
109 OPC_SWC2
= (0x3A << 26),
110 OPC_SDC1
= (0x3D << 26),
111 OPC_SDC2
= (0x3E << 26),
112 /* MDMX ASE specific */
113 OPC_MDMX
= (0x1E << 26),
114 /* Cache and prefetch */
115 OPC_CACHE
= (0x2F << 26),
116 OPC_PREF
= (0x33 << 26),
117 /* Reserved major opcode */
118 OPC_MAJOR3B_RESERVED
= (0x3B << 26),
121 /* MIPS special opcodes */
122 #define MASK_SPECIAL(op) MASK_OP_MAJOR(op) | (op & 0x3F)
126 OPC_SLL
= 0x00 | OPC_SPECIAL
,
127 /* NOP is SLL r0, r0, 0 */
128 /* SSNOP is SLL r0, r0, 1 */
129 /* EHB is SLL r0, r0, 3 */
130 OPC_SRL
= 0x02 | OPC_SPECIAL
, /* also ROTR */
131 OPC_SRA
= 0x03 | OPC_SPECIAL
,
132 OPC_SLLV
= 0x04 | OPC_SPECIAL
,
133 OPC_SRLV
= 0x06 | OPC_SPECIAL
, /* also ROTRV */
134 OPC_SRAV
= 0x07 | OPC_SPECIAL
,
135 OPC_DSLLV
= 0x14 | OPC_SPECIAL
,
136 OPC_DSRLV
= 0x16 | OPC_SPECIAL
, /* also DROTRV */
137 OPC_DSRAV
= 0x17 | OPC_SPECIAL
,
138 OPC_DSLL
= 0x38 | OPC_SPECIAL
,
139 OPC_DSRL
= 0x3A | OPC_SPECIAL
, /* also DROTR */
140 OPC_DSRA
= 0x3B | OPC_SPECIAL
,
141 OPC_DSLL32
= 0x3C | OPC_SPECIAL
,
142 OPC_DSRL32
= 0x3E | OPC_SPECIAL
, /* also DROTR32 */
143 OPC_DSRA32
= 0x3F | OPC_SPECIAL
,
144 /* Multiplication / division */
145 OPC_MULT
= 0x18 | OPC_SPECIAL
,
146 OPC_MULTU
= 0x19 | OPC_SPECIAL
,
147 OPC_DIV
= 0x1A | OPC_SPECIAL
,
148 OPC_DIVU
= 0x1B | OPC_SPECIAL
,
149 OPC_DMULT
= 0x1C | OPC_SPECIAL
,
150 OPC_DMULTU
= 0x1D | OPC_SPECIAL
,
151 OPC_DDIV
= 0x1E | OPC_SPECIAL
,
152 OPC_DDIVU
= 0x1F | OPC_SPECIAL
,
153 /* 2 registers arithmetic / logic */
154 OPC_ADD
= 0x20 | OPC_SPECIAL
,
155 OPC_ADDU
= 0x21 | OPC_SPECIAL
,
156 OPC_SUB
= 0x22 | OPC_SPECIAL
,
157 OPC_SUBU
= 0x23 | OPC_SPECIAL
,
158 OPC_AND
= 0x24 | OPC_SPECIAL
,
159 OPC_OR
= 0x25 | OPC_SPECIAL
,
160 OPC_XOR
= 0x26 | OPC_SPECIAL
,
161 OPC_NOR
= 0x27 | OPC_SPECIAL
,
162 OPC_SLT
= 0x2A | OPC_SPECIAL
,
163 OPC_SLTU
= 0x2B | OPC_SPECIAL
,
164 OPC_DADD
= 0x2C | OPC_SPECIAL
,
165 OPC_DADDU
= 0x2D | OPC_SPECIAL
,
166 OPC_DSUB
= 0x2E | OPC_SPECIAL
,
167 OPC_DSUBU
= 0x2F | OPC_SPECIAL
,
169 OPC_JR
= 0x08 | OPC_SPECIAL
, /* Also JR.HB */
170 OPC_JALR
= 0x09 | OPC_SPECIAL
, /* Also JALR.HB */
172 OPC_TGE
= 0x30 | OPC_SPECIAL
,
173 OPC_TGEU
= 0x31 | OPC_SPECIAL
,
174 OPC_TLT
= 0x32 | OPC_SPECIAL
,
175 OPC_TLTU
= 0x33 | OPC_SPECIAL
,
176 OPC_TEQ
= 0x34 | OPC_SPECIAL
,
177 OPC_TNE
= 0x36 | OPC_SPECIAL
,
178 /* HI / LO registers load & stores */
179 OPC_MFHI
= 0x10 | OPC_SPECIAL
,
180 OPC_MTHI
= 0x11 | OPC_SPECIAL
,
181 OPC_MFLO
= 0x12 | OPC_SPECIAL
,
182 OPC_MTLO
= 0x13 | OPC_SPECIAL
,
183 /* Conditional moves */
184 OPC_MOVZ
= 0x0A | OPC_SPECIAL
,
185 OPC_MOVN
= 0x0B | OPC_SPECIAL
,
187 OPC_MOVCI
= 0x01 | OPC_SPECIAL
,
190 OPC_PMON
= 0x05 | OPC_SPECIAL
, /* inofficial */
191 OPC_SYSCALL
= 0x0C | OPC_SPECIAL
,
192 OPC_BREAK
= 0x0D | OPC_SPECIAL
,
193 OPC_SPIM
= 0x0E | OPC_SPECIAL
, /* inofficial */
194 OPC_SYNC
= 0x0F | OPC_SPECIAL
,
196 OPC_SPECIAL15_RESERVED
= 0x15 | OPC_SPECIAL
,
197 OPC_SPECIAL28_RESERVED
= 0x28 | OPC_SPECIAL
,
198 OPC_SPECIAL29_RESERVED
= 0x29 | OPC_SPECIAL
,
199 OPC_SPECIAL35_RESERVED
= 0x35 | OPC_SPECIAL
,
200 OPC_SPECIAL37_RESERVED
= 0x37 | OPC_SPECIAL
,
201 OPC_SPECIAL39_RESERVED
= 0x39 | OPC_SPECIAL
,
202 OPC_SPECIAL3D_RESERVED
= 0x3D | OPC_SPECIAL
,
205 /* Multiplication variants of the vr54xx. */
206 #define MASK_MUL_VR54XX(op) MASK_SPECIAL(op) | (op & (0x1F << 6))
209 OPC_VR54XX_MULS
= (0x03 << 6) | OPC_MULT
,
210 OPC_VR54XX_MULSU
= (0x03 << 6) | OPC_MULTU
,
211 OPC_VR54XX_MACC
= (0x05 << 6) | OPC_MULT
,
212 OPC_VR54XX_MACCU
= (0x05 << 6) | OPC_MULTU
,
213 OPC_VR54XX_MSAC
= (0x07 << 6) | OPC_MULT
,
214 OPC_VR54XX_MSACU
= (0x07 << 6) | OPC_MULTU
,
215 OPC_VR54XX_MULHI
= (0x09 << 6) | OPC_MULT
,
216 OPC_VR54XX_MULHIU
= (0x09 << 6) | OPC_MULTU
,
217 OPC_VR54XX_MULSHI
= (0x0B << 6) | OPC_MULT
,
218 OPC_VR54XX_MULSHIU
= (0x0B << 6) | OPC_MULTU
,
219 OPC_VR54XX_MACCHI
= (0x0D << 6) | OPC_MULT
,
220 OPC_VR54XX_MACCHIU
= (0x0D << 6) | OPC_MULTU
,
221 OPC_VR54XX_MSACHI
= (0x0F << 6) | OPC_MULT
,
222 OPC_VR54XX_MSACHIU
= (0x0F << 6) | OPC_MULTU
,
225 /* REGIMM (rt field) opcodes */
226 #define MASK_REGIMM(op) MASK_OP_MAJOR(op) | (op & (0x1F << 16))
229 OPC_BLTZ
= (0x00 << 16) | OPC_REGIMM
,
230 OPC_BLTZL
= (0x02 << 16) | OPC_REGIMM
,
231 OPC_BGEZ
= (0x01 << 16) | OPC_REGIMM
,
232 OPC_BGEZL
= (0x03 << 16) | OPC_REGIMM
,
233 OPC_BLTZAL
= (0x10 << 16) | OPC_REGIMM
,
234 OPC_BLTZALL
= (0x12 << 16) | OPC_REGIMM
,
235 OPC_BGEZAL
= (0x11 << 16) | OPC_REGIMM
,
236 OPC_BGEZALL
= (0x13 << 16) | OPC_REGIMM
,
237 OPC_TGEI
= (0x08 << 16) | OPC_REGIMM
,
238 OPC_TGEIU
= (0x09 << 16) | OPC_REGIMM
,
239 OPC_TLTI
= (0x0A << 16) | OPC_REGIMM
,
240 OPC_TLTIU
= (0x0B << 16) | OPC_REGIMM
,
241 OPC_TEQI
= (0x0C << 16) | OPC_REGIMM
,
242 OPC_TNEI
= (0x0E << 16) | OPC_REGIMM
,
243 OPC_SYNCI
= (0x1F << 16) | OPC_REGIMM
,
246 /* Special2 opcodes */
247 #define MASK_SPECIAL2(op) MASK_OP_MAJOR(op) | (op & 0x3F)
250 /* Multiply & xxx operations */
251 OPC_MADD
= 0x00 | OPC_SPECIAL2
,
252 OPC_MADDU
= 0x01 | OPC_SPECIAL2
,
253 OPC_MUL
= 0x02 | OPC_SPECIAL2
,
254 OPC_MSUB
= 0x04 | OPC_SPECIAL2
,
255 OPC_MSUBU
= 0x05 | OPC_SPECIAL2
,
257 OPC_CLZ
= 0x20 | OPC_SPECIAL2
,
258 OPC_CLO
= 0x21 | OPC_SPECIAL2
,
259 OPC_DCLZ
= 0x24 | OPC_SPECIAL2
,
260 OPC_DCLO
= 0x25 | OPC_SPECIAL2
,
262 OPC_SDBBP
= 0x3F | OPC_SPECIAL2
,
265 /* Special3 opcodes */
266 #define MASK_SPECIAL3(op) MASK_OP_MAJOR(op) | (op & 0x3F)
269 OPC_EXT
= 0x00 | OPC_SPECIAL3
,
270 OPC_DEXTM
= 0x01 | OPC_SPECIAL3
,
271 OPC_DEXTU
= 0x02 | OPC_SPECIAL3
,
272 OPC_DEXT
= 0x03 | OPC_SPECIAL3
,
273 OPC_INS
= 0x04 | OPC_SPECIAL3
,
274 OPC_DINSM
= 0x05 | OPC_SPECIAL3
,
275 OPC_DINSU
= 0x06 | OPC_SPECIAL3
,
276 OPC_DINS
= 0x07 | OPC_SPECIAL3
,
277 OPC_FORK
= 0x08 | OPC_SPECIAL3
,
278 OPC_YIELD
= 0x09 | OPC_SPECIAL3
,
279 OPC_BSHFL
= 0x20 | OPC_SPECIAL3
,
280 OPC_DBSHFL
= 0x24 | OPC_SPECIAL3
,
281 OPC_RDHWR
= 0x3B | OPC_SPECIAL3
,
285 #define MASK_BSHFL(op) MASK_SPECIAL3(op) | (op & (0x1F << 6))
288 OPC_WSBH
= (0x02 << 6) | OPC_BSHFL
,
289 OPC_SEB
= (0x10 << 6) | OPC_BSHFL
,
290 OPC_SEH
= (0x18 << 6) | OPC_BSHFL
,
294 #define MASK_DBSHFL(op) MASK_SPECIAL3(op) | (op & (0x1F << 6))
297 OPC_DSBH
= (0x02 << 6) | OPC_DBSHFL
,
298 OPC_DSHD
= (0x05 << 6) | OPC_DBSHFL
,
301 /* Coprocessor 0 (rs field) */
302 #define MASK_CP0(op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))
305 OPC_MFC0
= (0x00 << 21) | OPC_CP0
,
306 OPC_DMFC0
= (0x01 << 21) | OPC_CP0
,
307 OPC_MTC0
= (0x04 << 21) | OPC_CP0
,
308 OPC_DMTC0
= (0x05 << 21) | OPC_CP0
,
309 OPC_MFTR
= (0x08 << 21) | OPC_CP0
,
310 OPC_RDPGPR
= (0x0A << 21) | OPC_CP0
,
311 OPC_MFMC0
= (0x0B << 21) | OPC_CP0
,
312 OPC_MTTR
= (0x0C << 21) | OPC_CP0
,
313 OPC_WRPGPR
= (0x0E << 21) | OPC_CP0
,
314 OPC_C0
= (0x10 << 21) | OPC_CP0
,
315 OPC_C0_FIRST
= (0x10 << 21) | OPC_CP0
,
316 OPC_C0_LAST
= (0x1F << 21) | OPC_CP0
,
320 #define MASK_MFMC0(op) MASK_CP0(op) | (op & 0xFFFF)
323 OPC_DMT
= 0x01 | (0 << 5) | (0x0F << 6) | (0x01 << 11) | OPC_MFMC0
,
324 OPC_EMT
= 0x01 | (1 << 5) | (0x0F << 6) | (0x01 << 11) | OPC_MFMC0
,
325 OPC_DVPE
= 0x01 | (0 << 5) | OPC_MFMC0
,
326 OPC_EVPE
= 0x01 | (1 << 5) | OPC_MFMC0
,
327 OPC_DI
= (0 << 5) | (0x0C << 11) | OPC_MFMC0
,
328 OPC_EI
= (1 << 5) | (0x0C << 11) | OPC_MFMC0
,
331 /* Coprocessor 0 (with rs == C0) */
332 #define MASK_C0(op) MASK_CP0(op) | (op & 0x3F)
335 OPC_TLBR
= 0x01 | OPC_C0
,
336 OPC_TLBWI
= 0x02 | OPC_C0
,
337 OPC_TLBWR
= 0x06 | OPC_C0
,
338 OPC_TLBP
= 0x08 | OPC_C0
,
339 OPC_RFE
= 0x10 | OPC_C0
,
340 OPC_ERET
= 0x18 | OPC_C0
,
341 OPC_DERET
= 0x1F | OPC_C0
,
342 OPC_WAIT
= 0x20 | OPC_C0
,
345 /* Coprocessor 1 (rs field) */
346 #define MASK_CP1(op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))
349 OPC_MFC1
= (0x00 << 21) | OPC_CP1
,
350 OPC_DMFC1
= (0x01 << 21) | OPC_CP1
,
351 OPC_CFC1
= (0x02 << 21) | OPC_CP1
,
352 OPC_MFHC1
= (0x03 << 21) | OPC_CP1
,
353 OPC_MTC1
= (0x04 << 21) | OPC_CP1
,
354 OPC_DMTC1
= (0x05 << 21) | OPC_CP1
,
355 OPC_CTC1
= (0x06 << 21) | OPC_CP1
,
356 OPC_MTHC1
= (0x07 << 21) | OPC_CP1
,
357 OPC_BC1
= (0x08 << 21) | OPC_CP1
, /* bc */
358 OPC_BC1ANY2
= (0x09 << 21) | OPC_CP1
,
359 OPC_BC1ANY4
= (0x0A << 21) | OPC_CP1
,
360 OPC_S_FMT
= (0x10 << 21) | OPC_CP1
, /* 16: fmt=single fp */
361 OPC_D_FMT
= (0x11 << 21) | OPC_CP1
, /* 17: fmt=double fp */
362 OPC_E_FMT
= (0x12 << 21) | OPC_CP1
, /* 18: fmt=extended fp */
363 OPC_Q_FMT
= (0x13 << 21) | OPC_CP1
, /* 19: fmt=quad fp */
364 OPC_W_FMT
= (0x14 << 21) | OPC_CP1
, /* 20: fmt=32bit fixed */
365 OPC_L_FMT
= (0x15 << 21) | OPC_CP1
, /* 21: fmt=64bit fixed */
366 OPC_PS_FMT
= (0x16 << 21) | OPC_CP1
, /* 22: fmt=paired single fp */
369 #define MASK_CP1_FUNC(op) MASK_CP1(op) | (op & 0x3F)
370 #define MASK_BC1(op) MASK_CP1(op) | (op & (0x3 << 16))
373 OPC_BC1F
= (0x00 << 16) | OPC_BC1
,
374 OPC_BC1T
= (0x01 << 16) | OPC_BC1
,
375 OPC_BC1FL
= (0x02 << 16) | OPC_BC1
,
376 OPC_BC1TL
= (0x03 << 16) | OPC_BC1
,
380 OPC_BC1FANY2
= (0x00 << 16) | OPC_BC1ANY2
,
381 OPC_BC1TANY2
= (0x01 << 16) | OPC_BC1ANY2
,
385 OPC_BC1FANY4
= (0x00 << 16) | OPC_BC1ANY4
,
386 OPC_BC1TANY4
= (0x01 << 16) | OPC_BC1ANY4
,
389 #define MASK_CP2(op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))
392 OPC_MFC2
= (0x00 << 21) | OPC_CP2
,
393 OPC_DMFC2
= (0x01 << 21) | OPC_CP2
,
394 OPC_CFC2
= (0x02 << 21) | OPC_CP2
,
395 OPC_MFHC2
= (0x03 << 21) | OPC_CP2
,
396 OPC_MTC2
= (0x04 << 21) | OPC_CP2
,
397 OPC_DMTC2
= (0x05 << 21) | OPC_CP2
,
398 OPC_CTC2
= (0x06 << 21) | OPC_CP2
,
399 OPC_MTHC2
= (0x07 << 21) | OPC_CP2
,
400 OPC_BC2
= (0x08 << 21) | OPC_CP2
,
403 #define MASK_CP3(op) MASK_OP_MAJOR(op) | (op & 0x3F)
406 OPC_LWXC1
= 0x00 | OPC_CP3
,
407 OPC_LDXC1
= 0x01 | OPC_CP3
,
408 OPC_LUXC1
= 0x05 | OPC_CP3
,
409 OPC_SWXC1
= 0x08 | OPC_CP3
,
410 OPC_SDXC1
= 0x09 | OPC_CP3
,
411 OPC_SUXC1
= 0x0D | OPC_CP3
,
412 OPC_PREFX
= 0x0F | OPC_CP3
,
413 OPC_ALNV_PS
= 0x1E | OPC_CP3
,
414 OPC_MADD_S
= 0x20 | OPC_CP3
,
415 OPC_MADD_D
= 0x21 | OPC_CP3
,
416 OPC_MADD_PS
= 0x26 | OPC_CP3
,
417 OPC_MSUB_S
= 0x28 | OPC_CP3
,
418 OPC_MSUB_D
= 0x29 | OPC_CP3
,
419 OPC_MSUB_PS
= 0x2E | OPC_CP3
,
420 OPC_NMADD_S
= 0x30 | OPC_CP3
,
421 OPC_NMADD_D
= 0x31 | OPC_CP3
,
422 OPC_NMADD_PS
= 0x36 | OPC_CP3
,
423 OPC_NMSUB_S
= 0x38 | OPC_CP3
,
424 OPC_NMSUB_D
= 0x39 | OPC_CP3
,
425 OPC_NMSUB_PS
= 0x3E | OPC_CP3
,
428 /* global register indices */
429 static TCGv_ptr cpu_env
;
430 static TCGv cpu_gpr
[32], cpu_PC
;
431 static TCGv cpu_HI
[MIPS_DSP_ACC
], cpu_LO
[MIPS_DSP_ACC
], cpu_ACX
[MIPS_DSP_ACC
];
432 static TCGv cpu_dspctrl
, btarget
, bcond
;
433 static TCGv_i32 hflags
;
434 static TCGv_i32 fpu_fcr0
, fpu_fcr31
;
436 #include "gen-icount.h"
438 #define gen_helper_0i(name, arg) do { \
439 TCGv_i32 helper_tmp = tcg_const_i32(arg); \
440 gen_helper_##name(helper_tmp); \
441 tcg_temp_free_i32(helper_tmp); \
444 #define gen_helper_1i(name, arg1, arg2) do { \
445 TCGv_i32 helper_tmp = tcg_const_i32(arg2); \
446 gen_helper_##name(arg1, helper_tmp); \
447 tcg_temp_free_i32(helper_tmp); \
450 #define gen_helper_2i(name, arg1, arg2, arg3) do { \
451 TCGv_i32 helper_tmp = tcg_const_i32(arg3); \
452 gen_helper_##name(arg1, arg2, helper_tmp); \
453 tcg_temp_free_i32(helper_tmp); \
456 #define gen_helper_3i(name, arg1, arg2, arg3, arg4) do { \
457 TCGv_i32 helper_tmp = tcg_const_i32(arg4); \
458 gen_helper_##name(arg1, arg2, arg3, helper_tmp); \
459 tcg_temp_free_i32(helper_tmp); \
462 typedef struct DisasContext
{
463 struct TranslationBlock
*tb
;
464 target_ulong pc
, saved_pc
;
466 /* Routine used to access memory */
468 uint32_t hflags
, saved_hflags
;
470 target_ulong btarget
;
474 BS_NONE
= 0, /* We go out of the TB without reaching a branch or an
475 * exception condition */
476 BS_STOP
= 1, /* We want to stop translation for any reason */
477 BS_BRANCH
= 2, /* We reached a branch condition */
478 BS_EXCP
= 3, /* We reached an exception condition */
481 static const char *regnames
[] =
482 { "r0", "at", "v0", "v1", "a0", "a1", "a2", "a3",
483 "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
484 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
485 "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra", };
487 static const char *regnames_HI
[] =
488 { "HI0", "HI1", "HI2", "HI3", };
490 static const char *regnames_LO
[] =
491 { "LO0", "LO1", "LO2", "LO3", };
493 static const char *regnames_ACX
[] =
494 { "ACX0", "ACX1", "ACX2", "ACX3", };
496 static const char *fregnames
[] =
497 { "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
498 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
499 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
500 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", };
502 #ifdef MIPS_DEBUG_DISAS
503 #define MIPS_DEBUG(fmt, args...) \
504 qemu_log_mask(CPU_LOG_TB_IN_ASM, \
505 TARGET_FMT_lx ": %08x " fmt "\n", \
506 ctx->pc, ctx->opcode , ##args)
507 #define LOG_DISAS(...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)
509 #define MIPS_DEBUG(fmt, args...) do { } while(0)
510 #define LOG_DISAS(...) do { } while (0)
513 #define MIPS_INVAL(op) \
515 MIPS_DEBUG("Invalid %s %03x %03x %03x", op, ctx->opcode >> 26, \
516 ctx->opcode & 0x3F, ((ctx->opcode >> 16) & 0x1F)); \
519 /* General purpose registers moves. */
520 static inline void gen_load_gpr (TCGv t
, int reg
)
523 tcg_gen_movi_tl(t
, 0);
525 tcg_gen_mov_tl(t
, cpu_gpr
[reg
]);
528 static inline void gen_store_gpr (TCGv t
, int reg
)
531 tcg_gen_mov_tl(cpu_gpr
[reg
], t
);
534 /* Moves to/from ACX register. */
535 static inline void gen_load_ACX (TCGv t
, int reg
)
537 tcg_gen_mov_tl(t
, cpu_ACX
[reg
]);
540 static inline void gen_store_ACX (TCGv t
, int reg
)
542 tcg_gen_mov_tl(cpu_ACX
[reg
], t
);
545 /* Moves to/from shadow registers. */
546 static inline void gen_load_srsgpr (int from
, int to
)
548 TCGv r_tmp1
= tcg_temp_new();
551 tcg_gen_movi_tl(r_tmp1
, 0);
553 TCGv_i32 r_tmp2
= tcg_temp_new_i32();
554 TCGv_ptr addr
= tcg_temp_new_ptr();
556 tcg_gen_ld_i32(r_tmp2
, cpu_env
, offsetof(CPUState
, CP0_SRSCtl
));
557 tcg_gen_shri_i32(r_tmp2
, r_tmp2
, CP0SRSCtl_PSS
);
558 tcg_gen_andi_i32(r_tmp2
, r_tmp2
, 0xf);
559 tcg_gen_muli_i32(r_tmp2
, r_tmp2
, sizeof(target_ulong
) * 32);
560 tcg_gen_ext_i32_ptr(addr
, r_tmp2
);
561 tcg_gen_add_ptr(addr
, cpu_env
, addr
);
563 tcg_gen_ld_tl(r_tmp1
, addr
, sizeof(target_ulong
) * from
);
564 tcg_temp_free_ptr(addr
);
565 tcg_temp_free_i32(r_tmp2
);
567 gen_store_gpr(r_tmp1
, to
);
568 tcg_temp_free(r_tmp1
);
571 static inline void gen_store_srsgpr (int from
, int to
)
574 TCGv r_tmp1
= tcg_temp_new();
575 TCGv_i32 r_tmp2
= tcg_temp_new_i32();
576 TCGv_ptr addr
= tcg_temp_new_ptr();
578 gen_load_gpr(r_tmp1
, from
);
579 tcg_gen_ld_i32(r_tmp2
, cpu_env
, offsetof(CPUState
, CP0_SRSCtl
));
580 tcg_gen_shri_i32(r_tmp2
, r_tmp2
, CP0SRSCtl_PSS
);
581 tcg_gen_andi_i32(r_tmp2
, r_tmp2
, 0xf);
582 tcg_gen_muli_i32(r_tmp2
, r_tmp2
, sizeof(target_ulong
) * 32);
583 tcg_gen_ext_i32_ptr(addr
, r_tmp2
);
584 tcg_gen_add_ptr(addr
, cpu_env
, addr
);
586 tcg_gen_st_tl(r_tmp1
, addr
, sizeof(target_ulong
) * to
);
587 tcg_temp_free_ptr(addr
);
588 tcg_temp_free_i32(r_tmp2
);
589 tcg_temp_free(r_tmp1
);
593 /* Floating point register moves. */
594 static inline void gen_load_fpr32 (TCGv_i32 t
, int reg
)
596 tcg_gen_ld_i32(t
, cpu_env
, offsetof(CPUState
, active_fpu
.fpr
[reg
].w
[FP_ENDIAN_IDX
]));
599 static inline void gen_store_fpr32 (TCGv_i32 t
, int reg
)
601 tcg_gen_st_i32(t
, cpu_env
, offsetof(CPUState
, active_fpu
.fpr
[reg
].w
[FP_ENDIAN_IDX
]));
604 static inline void gen_load_fpr32h (TCGv_i32 t
, int reg
)
606 tcg_gen_ld_i32(t
, cpu_env
, offsetof(CPUState
, active_fpu
.fpr
[reg
].w
[!FP_ENDIAN_IDX
]));
609 static inline void gen_store_fpr32h (TCGv_i32 t
, int reg
)
611 tcg_gen_st_i32(t
, cpu_env
, offsetof(CPUState
, active_fpu
.fpr
[reg
].w
[!FP_ENDIAN_IDX
]));
614 static inline void gen_load_fpr64 (DisasContext
*ctx
, TCGv_i64 t
, int reg
)
616 if (ctx
->hflags
& MIPS_HFLAG_F64
) {
617 tcg_gen_ld_i64(t
, cpu_env
, offsetof(CPUState
, active_fpu
.fpr
[reg
].d
));
619 TCGv_i32 t0
= tcg_temp_new_i32();
620 TCGv_i32 t1
= tcg_temp_new_i32();
621 gen_load_fpr32(t0
, reg
& ~1);
622 gen_load_fpr32(t1
, reg
| 1);
623 tcg_gen_concat_i32_i64(t
, t0
, t1
);
624 tcg_temp_free_i32(t0
);
625 tcg_temp_free_i32(t1
);
629 static inline void gen_store_fpr64 (DisasContext
*ctx
, TCGv_i64 t
, int reg
)
631 if (ctx
->hflags
& MIPS_HFLAG_F64
) {
632 tcg_gen_st_i64(t
, cpu_env
, offsetof(CPUState
, active_fpu
.fpr
[reg
].d
));
634 TCGv_i64 t0
= tcg_temp_new_i64();
635 TCGv_i32 t1
= tcg_temp_new_i32();
636 tcg_gen_trunc_i64_i32(t1
, t
);
637 gen_store_fpr32(t1
, reg
& ~1);
638 tcg_gen_shri_i64(t0
, t
, 32);
639 tcg_gen_trunc_i64_i32(t1
, t0
);
640 gen_store_fpr32(t1
, reg
| 1);
641 tcg_temp_free_i32(t1
);
642 tcg_temp_free_i64(t0
);
646 static inline int get_fp_bit (int cc
)
654 #define FOP_CONDS(type, fmt, bits) \
655 static inline void gen_cmp ## type ## _ ## fmt(int n, TCGv_i##bits a, \
656 TCGv_i##bits b, int cc) \
659 case 0: gen_helper_2i(cmp ## type ## _ ## fmt ## _f, a, b, cc); break;\
660 case 1: gen_helper_2i(cmp ## type ## _ ## fmt ## _un, a, b, cc); break;\
661 case 2: gen_helper_2i(cmp ## type ## _ ## fmt ## _eq, a, b, cc); break;\
662 case 3: gen_helper_2i(cmp ## type ## _ ## fmt ## _ueq, a, b, cc); break;\
663 case 4: gen_helper_2i(cmp ## type ## _ ## fmt ## _olt, a, b, cc); break;\
664 case 5: gen_helper_2i(cmp ## type ## _ ## fmt ## _ult, a, b, cc); break;\
665 case 6: gen_helper_2i(cmp ## type ## _ ## fmt ## _ole, a, b, cc); break;\
666 case 7: gen_helper_2i(cmp ## type ## _ ## fmt ## _ule, a, b, cc); break;\
667 case 8: gen_helper_2i(cmp ## type ## _ ## fmt ## _sf, a, b, cc); break;\
668 case 9: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngle, a, b, cc); break;\
669 case 10: gen_helper_2i(cmp ## type ## _ ## fmt ## _seq, a, b, cc); break;\
670 case 11: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngl, a, b, cc); break;\
671 case 12: gen_helper_2i(cmp ## type ## _ ## fmt ## _lt, a, b, cc); break;\
672 case 13: gen_helper_2i(cmp ## type ## _ ## fmt ## _nge, a, b, cc); break;\
673 case 14: gen_helper_2i(cmp ## type ## _ ## fmt ## _le, a, b, cc); break;\
674 case 15: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngt, a, b, cc); break;\
680 FOP_CONDS(abs
, d
, 64)
682 FOP_CONDS(abs
, s
, 32)
684 FOP_CONDS(abs
, ps
, 64)
688 #define OP_COND(name, cond) \
689 static inline void glue(gen_op_, name) (TCGv ret, TCGv t0, TCGv t1) \
691 int l1 = gen_new_label(); \
692 int l2 = gen_new_label(); \
694 tcg_gen_brcond_tl(cond, t0, t1, l1); \
695 tcg_gen_movi_tl(ret, 0); \
698 tcg_gen_movi_tl(ret, 1); \
701 OP_COND(eq
, TCG_COND_EQ
);
702 OP_COND(ne
, TCG_COND_NE
);
703 OP_COND(ge
, TCG_COND_GE
);
704 OP_COND(geu
, TCG_COND_GEU
);
705 OP_COND(lt
, TCG_COND_LT
);
706 OP_COND(ltu
, TCG_COND_LTU
);
709 #define OP_CONDI(name, cond) \
710 static inline void glue(gen_op_, name) (TCGv ret, TCGv t0, target_ulong val) \
712 int l1 = gen_new_label(); \
713 int l2 = gen_new_label(); \
715 tcg_gen_brcondi_tl(cond, t0, val, l1); \
716 tcg_gen_movi_tl(ret, 0); \
719 tcg_gen_movi_tl(ret, 1); \
722 OP_CONDI(lti
, TCG_COND_LT
);
723 OP_CONDI(ltiu
, TCG_COND_LTU
);
726 #define OP_CONDZ(name, cond) \
727 static inline void glue(gen_op_, name) (TCGv ret, TCGv t0) \
729 int l1 = gen_new_label(); \
730 int l2 = gen_new_label(); \
732 tcg_gen_brcondi_tl(cond, t0, 0, l1); \
733 tcg_gen_movi_tl(ret, 0); \
736 tcg_gen_movi_tl(ret, 1); \
739 OP_CONDZ(gez
, TCG_COND_GE
);
740 OP_CONDZ(gtz
, TCG_COND_GT
);
741 OP_CONDZ(lez
, TCG_COND_LE
);
742 OP_CONDZ(ltz
, TCG_COND_LT
);
745 static inline void gen_save_pc(target_ulong pc
)
747 tcg_gen_movi_tl(cpu_PC
, pc
);
750 static inline void save_cpu_state (DisasContext
*ctx
, int do_save_pc
)
752 LOG_DISAS("hflags %08x saved %08x\n", ctx
->hflags
, ctx
->saved_hflags
);
753 if (do_save_pc
&& ctx
->pc
!= ctx
->saved_pc
) {
754 gen_save_pc(ctx
->pc
);
755 ctx
->saved_pc
= ctx
->pc
;
757 if (ctx
->hflags
!= ctx
->saved_hflags
) {
758 tcg_gen_movi_i32(hflags
, ctx
->hflags
);
759 ctx
->saved_hflags
= ctx
->hflags
;
760 switch (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
766 tcg_gen_movi_tl(btarget
, ctx
->btarget
);
772 static inline void restore_cpu_state (CPUState
*env
, DisasContext
*ctx
)
774 ctx
->saved_hflags
= ctx
->hflags
;
775 switch (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
781 ctx
->btarget
= env
->btarget
;
787 generate_exception_err (DisasContext
*ctx
, int excp
, int err
)
789 TCGv_i32 texcp
= tcg_const_i32(excp
);
790 TCGv_i32 terr
= tcg_const_i32(err
);
791 save_cpu_state(ctx
, 1);
792 gen_helper_raise_exception_err(texcp
, terr
);
793 tcg_temp_free_i32(terr
);
794 tcg_temp_free_i32(texcp
);
795 gen_helper_interrupt_restart();
800 generate_exception (DisasContext
*ctx
, int excp
)
802 save_cpu_state(ctx
, 1);
803 gen_helper_0i(raise_exception
, excp
);
804 gen_helper_interrupt_restart();
808 /* Addresses computation */
809 static inline void gen_op_addr_add (DisasContext
*ctx
, TCGv t0
, TCGv t1
)
811 tcg_gen_add_tl(t0
, t0
, t1
);
813 #if defined(TARGET_MIPS64)
814 /* For compatibility with 32-bit code, data reference in user mode
815 with Status_UX = 0 should be casted to 32-bit and sign extended.
816 See the MIPS64 PRA manual, section 4.10. */
817 if (((ctx
->hflags
& MIPS_HFLAG_KSU
) == MIPS_HFLAG_UM
) &&
818 !(ctx
->hflags
& MIPS_HFLAG_UX
)) {
819 tcg_gen_ext32s_i64(t0
, t0
);
824 static inline void check_cp0_enabled(DisasContext
*ctx
)
826 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_CP0
)))
827 generate_exception_err(ctx
, EXCP_CpU
, 1);
830 static inline void check_cp1_enabled(DisasContext
*ctx
)
832 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_FPU
)))
833 generate_exception_err(ctx
, EXCP_CpU
, 1);
836 /* Verify that the processor is running with COP1X instructions enabled.
837 This is associated with the nabla symbol in the MIPS32 and MIPS64
840 static inline void check_cop1x(DisasContext
*ctx
)
842 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_COP1X
)))
843 generate_exception(ctx
, EXCP_RI
);
846 /* Verify that the processor is running with 64-bit floating-point
847 operations enabled. */
849 static inline void check_cp1_64bitmode(DisasContext
*ctx
)
851 if (unlikely(~ctx
->hflags
& (MIPS_HFLAG_F64
| MIPS_HFLAG_COP1X
)))
852 generate_exception(ctx
, EXCP_RI
);
856 * Verify if floating point register is valid; an operation is not defined
857 * if bit 0 of any register specification is set and the FR bit in the
858 * Status register equals zero, since the register numbers specify an
859 * even-odd pair of adjacent coprocessor general registers. When the FR bit
860 * in the Status register equals one, both even and odd register numbers
861 * are valid. This limitation exists only for 64 bit wide (d,l,ps) registers.
863 * Multiple 64 bit wide registers can be checked by calling
864 * gen_op_cp1_registers(freg1 | freg2 | ... | fregN);
866 static inline void check_cp1_registers(DisasContext
*ctx
, int regs
)
868 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_F64
) && (regs
& 1)))
869 generate_exception(ctx
, EXCP_RI
);
872 /* This code generates a "reserved instruction" exception if the
873 CPU does not support the instruction set corresponding to flags. */
874 static inline void check_insn(CPUState
*env
, DisasContext
*ctx
, int flags
)
876 if (unlikely(!(env
->insn_flags
& flags
)))
877 generate_exception(ctx
, EXCP_RI
);
880 /* This code generates a "reserved instruction" exception if 64-bit
881 instructions are not enabled. */
882 static inline void check_mips_64(DisasContext
*ctx
)
884 if (unlikely(!(ctx
->hflags
& MIPS_HFLAG_64
)))
885 generate_exception(ctx
, EXCP_RI
);
888 /* load/store instructions. */
889 #define OP_LD(insn,fname) \
890 static inline void op_ldst_##insn(TCGv t0, DisasContext *ctx) \
892 tcg_gen_qemu_##fname(t0, t0, ctx->mem_idx); \
899 #if defined(TARGET_MIPS64)
905 #define OP_ST(insn,fname) \
906 static inline void op_ldst_##insn(TCGv t0, TCGv t1, DisasContext *ctx) \
908 tcg_gen_qemu_##fname(t1, t0, ctx->mem_idx); \
913 #if defined(TARGET_MIPS64)
918 #define OP_LD_ATOMIC(insn,fname) \
919 static inline void op_ldst_##insn(TCGv t0, TCGv t1, DisasContext *ctx) \
921 tcg_gen_mov_tl(t1, t0); \
922 tcg_gen_qemu_##fname(t0, t0, ctx->mem_idx); \
923 tcg_gen_st_tl(t1, cpu_env, offsetof(CPUState, CP0_LLAddr)); \
925 OP_LD_ATOMIC(ll
,ld32s
);
926 #if defined(TARGET_MIPS64)
927 OP_LD_ATOMIC(lld
,ld64
);
931 #define OP_ST_ATOMIC(insn,fname,almask) \
932 static inline void op_ldst_##insn(TCGv t0, TCGv t1, DisasContext *ctx) \
934 TCGv r_tmp = tcg_temp_local_new(); \
935 int l1 = gen_new_label(); \
936 int l2 = gen_new_label(); \
937 int l3 = gen_new_label(); \
939 tcg_gen_andi_tl(r_tmp, t0, almask); \
940 tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp, 0, l1); \
941 tcg_gen_st_tl(t0, cpu_env, offsetof(CPUState, CP0_BadVAddr)); \
942 generate_exception(ctx, EXCP_AdES); \
944 tcg_gen_ld_tl(r_tmp, cpu_env, offsetof(CPUState, CP0_LLAddr)); \
945 tcg_gen_brcond_tl(TCG_COND_NE, t0, r_tmp, l2); \
946 tcg_gen_qemu_##fname(t1, t0, ctx->mem_idx); \
947 tcg_gen_movi_tl(t0, 1); \
950 tcg_gen_movi_tl(t0, 0); \
952 tcg_temp_free(r_tmp); \
954 OP_ST_ATOMIC(sc
,st32
,0x3);
955 #if defined(TARGET_MIPS64)
956 OP_ST_ATOMIC(scd
,st64
,0x7);
961 static void gen_ldst (DisasContext
*ctx
, uint32_t opc
, int rt
,
962 int base
, int16_t offset
)
964 const char *opn
= "ldst";
965 TCGv t0
= tcg_temp_local_new();
966 TCGv t1
= tcg_temp_local_new();
969 tcg_gen_movi_tl(t0
, offset
);
970 } else if (offset
== 0) {
971 gen_load_gpr(t0
, base
);
973 tcg_gen_movi_tl(t0
, offset
);
974 gen_op_addr_add(ctx
, t0
, cpu_gpr
[base
]);
976 /* Don't do NOP if destination is zero: we must perform the actual
979 #if defined(TARGET_MIPS64)
981 op_ldst_lwu(t0
, ctx
);
982 gen_store_gpr(t0
, rt
);
987 gen_store_gpr(t0
, rt
);
991 op_ldst_lld(t0
, t1
, ctx
);
992 gen_store_gpr(t0
, rt
);
996 gen_load_gpr(t1
, rt
);
997 op_ldst_sd(t0
, t1
, ctx
);
1001 save_cpu_state(ctx
, 1);
1002 gen_load_gpr(t1
, rt
);
1003 op_ldst_scd(t0
, t1
, ctx
);
1004 gen_store_gpr(t0
, rt
);
1008 save_cpu_state(ctx
, 1);
1009 gen_load_gpr(t1
, rt
);
1010 gen_helper_3i(ldl
, t1
, t0
, t1
, ctx
->mem_idx
);
1011 gen_store_gpr(t1
, rt
);
1015 save_cpu_state(ctx
, 1);
1016 gen_load_gpr(t1
, rt
);
1017 gen_helper_2i(sdl
, t0
, t1
, ctx
->mem_idx
);
1021 save_cpu_state(ctx
, 1);
1022 gen_load_gpr(t1
, rt
);
1023 gen_helper_3i(ldr
, t1
, t0
, t1
, ctx
->mem_idx
);
1024 gen_store_gpr(t1
, rt
);
1028 save_cpu_state(ctx
, 1);
1029 gen_load_gpr(t1
, rt
);
1030 gen_helper_2i(sdr
, t0
, t1
, ctx
->mem_idx
);
1035 op_ldst_lw(t0
, ctx
);
1036 gen_store_gpr(t0
, rt
);
1040 gen_load_gpr(t1
, rt
);
1041 op_ldst_sw(t0
, t1
, ctx
);
1045 op_ldst_lh(t0
, ctx
);
1046 gen_store_gpr(t0
, rt
);
1050 gen_load_gpr(t1
, rt
);
1051 op_ldst_sh(t0
, t1
, ctx
);
1055 op_ldst_lhu(t0
, ctx
);
1056 gen_store_gpr(t0
, rt
);
1060 op_ldst_lb(t0
, ctx
);
1061 gen_store_gpr(t0
, rt
);
1065 gen_load_gpr(t1
, rt
);
1066 op_ldst_sb(t0
, t1
, ctx
);
1070 op_ldst_lbu(t0
, ctx
);
1071 gen_store_gpr(t0
, rt
);
1075 save_cpu_state(ctx
, 1);
1076 gen_load_gpr(t1
, rt
);
1077 gen_helper_3i(lwl
, t1
, t0
, t1
, ctx
->mem_idx
);
1078 gen_store_gpr(t1
, rt
);
1082 save_cpu_state(ctx
, 1);
1083 gen_load_gpr(t1
, rt
);
1084 gen_helper_2i(swl
, t0
, t1
, ctx
->mem_idx
);
1088 save_cpu_state(ctx
, 1);
1089 gen_load_gpr(t1
, rt
);
1090 gen_helper_3i(lwr
, t1
, t0
, t1
, ctx
->mem_idx
);
1091 gen_store_gpr(t1
, rt
);
1095 save_cpu_state(ctx
, 1);
1096 gen_load_gpr(t1
, rt
);
1097 gen_helper_2i(swr
, t0
, t1
, ctx
->mem_idx
);
1101 op_ldst_ll(t0
, t1
, ctx
);
1102 gen_store_gpr(t0
, rt
);
1106 save_cpu_state(ctx
, 1);
1107 gen_load_gpr(t1
, rt
);
1108 op_ldst_sc(t0
, t1
, ctx
);
1109 gen_store_gpr(t0
, rt
);
1114 generate_exception(ctx
, EXCP_RI
);
1117 MIPS_DEBUG("%s %s, %d(%s)", opn
, regnames
[rt
], offset
, regnames
[base
]);
1123 /* Load and store */
1124 static void gen_flt_ldst (DisasContext
*ctx
, uint32_t opc
, int ft
,
1125 int base
, int16_t offset
)
1127 const char *opn
= "flt_ldst";
1128 TCGv t0
= tcg_temp_local_new();
1131 tcg_gen_movi_tl(t0
, offset
);
1132 } else if (offset
== 0) {
1133 gen_load_gpr(t0
, base
);
1135 tcg_gen_movi_tl(t0
, offset
);
1136 gen_op_addr_add(ctx
, t0
, cpu_gpr
[base
]);
1138 /* Don't do NOP if destination is zero: we must perform the actual
1143 TCGv_i32 fp0
= tcg_temp_new_i32();
1144 TCGv t1
= tcg_temp_new();
1146 tcg_gen_qemu_ld32s(t1
, t0
, ctx
->mem_idx
);
1147 tcg_gen_trunc_tl_i32(fp0
, t1
);
1148 gen_store_fpr32(fp0
, ft
);
1150 tcg_temp_free_i32(fp0
);
1156 TCGv_i32 fp0
= tcg_temp_new_i32();
1157 TCGv t1
= tcg_temp_new();
1159 gen_load_fpr32(fp0
, ft
);
1160 tcg_gen_extu_i32_tl(t1
, fp0
);
1161 tcg_gen_qemu_st32(t1
, t0
, ctx
->mem_idx
);
1163 tcg_temp_free_i32(fp0
);
1169 TCGv_i64 fp0
= tcg_temp_new_i64();
1171 tcg_gen_qemu_ld64(fp0
, t0
, ctx
->mem_idx
);
1172 gen_store_fpr64(ctx
, fp0
, ft
);
1173 tcg_temp_free_i64(fp0
);
1179 TCGv_i64 fp0
= tcg_temp_new_i64();
1181 gen_load_fpr64(ctx
, fp0
, ft
);
1182 tcg_gen_qemu_st64(fp0
, t0
, ctx
->mem_idx
);
1183 tcg_temp_free_i64(fp0
);
1189 generate_exception(ctx
, EXCP_RI
);
1192 MIPS_DEBUG("%s %s, %d(%s)", opn
, fregnames
[ft
], offset
, regnames
[base
]);
1197 /* Arithmetic with immediate operand */
1198 static void gen_arith_imm (CPUState
*env
, DisasContext
*ctx
, uint32_t opc
,
1199 int rt
, int rs
, int16_t imm
)
1202 const char *opn
= "imm arith";
1203 TCGv t0
= tcg_temp_local_new();
1205 if (rt
== 0 && opc
!= OPC_ADDI
&& opc
!= OPC_DADDI
) {
1206 /* If no destination, treat it as a NOP.
1207 For addi, we must generate the overflow exception when needed. */
1211 uimm
= (uint16_t)imm
;
1215 #if defined(TARGET_MIPS64)
1221 uimm
= (target_long
)imm
; /* Sign extend to 32/64 bits */
1226 gen_load_gpr(t0
, rs
);
1229 tcg_gen_movi_tl(t0
, imm
<< 16);
1234 #if defined(TARGET_MIPS64)
1243 gen_load_gpr(t0
, rs
);
1249 TCGv r_tmp1
= tcg_temp_new();
1250 TCGv r_tmp2
= tcg_temp_new();
1251 int l1
= gen_new_label();
1253 save_cpu_state(ctx
, 1);
1254 tcg_gen_ext32s_tl(r_tmp1
, t0
);
1255 tcg_gen_addi_tl(t0
, r_tmp1
, uimm
);
1257 tcg_gen_xori_tl(r_tmp1
, r_tmp1
, ~uimm
);
1258 tcg_gen_xori_tl(r_tmp2
, t0
, uimm
);
1259 tcg_gen_and_tl(r_tmp1
, r_tmp1
, r_tmp2
);
1260 tcg_temp_free(r_tmp2
);
1261 tcg_gen_brcondi_tl(TCG_COND_GE
, r_tmp1
, 0, l1
);
1262 /* operands of same sign, result different sign */
1263 generate_exception(ctx
, EXCP_OVERFLOW
);
1265 tcg_temp_free(r_tmp1
);
1267 tcg_gen_ext32s_tl(t0
, t0
);
1272 tcg_gen_addi_tl(t0
, t0
, uimm
);
1273 tcg_gen_ext32s_tl(t0
, t0
);
1276 #if defined(TARGET_MIPS64)
1279 TCGv r_tmp1
= tcg_temp_new();
1280 TCGv r_tmp2
= tcg_temp_new();
1281 int l1
= gen_new_label();
1283 save_cpu_state(ctx
, 1);
1284 tcg_gen_mov_tl(r_tmp1
, t0
);
1285 tcg_gen_addi_tl(t0
, t0
, uimm
);
1287 tcg_gen_xori_tl(r_tmp1
, r_tmp1
, ~uimm
);
1288 tcg_gen_xori_tl(r_tmp2
, t0
, uimm
);
1289 tcg_gen_and_tl(r_tmp1
, r_tmp1
, r_tmp2
);
1290 tcg_temp_free(r_tmp2
);
1291 tcg_gen_brcondi_tl(TCG_COND_GE
, r_tmp1
, 0, l1
);
1292 /* operands of same sign, result different sign */
1293 generate_exception(ctx
, EXCP_OVERFLOW
);
1295 tcg_temp_free(r_tmp1
);
1300 tcg_gen_addi_tl(t0
, t0
, uimm
);
1305 gen_op_lti(t0
, t0
, uimm
);
1309 gen_op_ltiu(t0
, t0
, uimm
);
1313 tcg_gen_andi_tl(t0
, t0
, uimm
);
1317 tcg_gen_ori_tl(t0
, t0
, uimm
);
1321 tcg_gen_xori_tl(t0
, t0
, uimm
);
1328 tcg_gen_shli_tl(t0
, t0
, uimm
);
1329 tcg_gen_ext32s_tl(t0
, t0
);
1333 tcg_gen_ext32s_tl(t0
, t0
);
1334 tcg_gen_sari_tl(t0
, t0
, uimm
);
1338 switch ((ctx
->opcode
>> 21) & 0x1f) {
1341 tcg_gen_ext32u_tl(t0
, t0
);
1342 tcg_gen_shri_tl(t0
, t0
, uimm
);
1344 tcg_gen_ext32s_tl(t0
, t0
);
1349 /* rotr is decoded as srl on non-R2 CPUs */
1350 if (env
->insn_flags
& ISA_MIPS32R2
) {
1352 TCGv_i32 r_tmp1
= tcg_temp_new_i32();
1354 tcg_gen_trunc_tl_i32(r_tmp1
, t0
);
1355 tcg_gen_rotri_i32(r_tmp1
, r_tmp1
, uimm
);
1356 tcg_gen_ext_i32_tl(t0
, r_tmp1
);
1357 tcg_temp_free_i32(r_tmp1
);
1362 tcg_gen_ext32u_tl(t0
, t0
);
1363 tcg_gen_shri_tl(t0
, t0
, uimm
);
1365 tcg_gen_ext32s_tl(t0
, t0
);
1371 MIPS_INVAL("invalid srl flag");
1372 generate_exception(ctx
, EXCP_RI
);
1376 #if defined(TARGET_MIPS64)
1378 tcg_gen_shli_tl(t0
, t0
, uimm
);
1382 tcg_gen_sari_tl(t0
, t0
, uimm
);
1386 switch ((ctx
->opcode
>> 21) & 0x1f) {
1388 tcg_gen_shri_tl(t0
, t0
, uimm
);
1392 /* drotr is decoded as dsrl on non-R2 CPUs */
1393 if (env
->insn_flags
& ISA_MIPS32R2
) {
1395 tcg_gen_rotri_tl(t0
, t0
, uimm
);
1399 tcg_gen_shri_tl(t0
, t0
, uimm
);
1404 MIPS_INVAL("invalid dsrl flag");
1405 generate_exception(ctx
, EXCP_RI
);
1410 tcg_gen_shli_tl(t0
, t0
, uimm
+ 32);
1414 tcg_gen_sari_tl(t0
, t0
, uimm
+ 32);
1418 switch ((ctx
->opcode
>> 21) & 0x1f) {
1420 tcg_gen_shri_tl(t0
, t0
, uimm
+ 32);
1424 /* drotr32 is decoded as dsrl32 on non-R2 CPUs */
1425 if (env
->insn_flags
& ISA_MIPS32R2
) {
1426 tcg_gen_rotri_tl(t0
, t0
, uimm
+ 32);
1429 tcg_gen_shri_tl(t0
, t0
, uimm
+ 32);
1434 MIPS_INVAL("invalid dsrl32 flag");
1435 generate_exception(ctx
, EXCP_RI
);
1442 generate_exception(ctx
, EXCP_RI
);
1445 gen_store_gpr(t0
, rt
);
1446 MIPS_DEBUG("%s %s, %s, " TARGET_FMT_lx
, opn
, regnames
[rt
], regnames
[rs
], uimm
);
1452 static void gen_arith (CPUState
*env
, DisasContext
*ctx
, uint32_t opc
,
1453 int rd
, int rs
, int rt
)
1455 const char *opn
= "arith";
1456 TCGv t0
= tcg_temp_local_new();
1457 TCGv t1
= tcg_temp_local_new();
1459 if (rd
== 0 && opc
!= OPC_ADD
&& opc
!= OPC_SUB
1460 && opc
!= OPC_DADD
&& opc
!= OPC_DSUB
) {
1461 /* If no destination, treat it as a NOP.
1462 For add & sub, we must generate the overflow exception when needed. */
1466 gen_load_gpr(t0
, rs
);
1467 /* Specialcase the conventional move operation. */
1468 if (rt
== 0 && (opc
== OPC_ADDU
|| opc
== OPC_DADDU
1469 || opc
== OPC_SUBU
|| opc
== OPC_DSUBU
)) {
1470 gen_store_gpr(t0
, rd
);
1473 gen_load_gpr(t1
, rt
);
1477 TCGv r_tmp1
= tcg_temp_new();
1478 TCGv r_tmp2
= tcg_temp_new();
1479 int l1
= gen_new_label();
1481 save_cpu_state(ctx
, 1);
1482 tcg_gen_ext32s_tl(r_tmp1
, t0
);
1483 tcg_gen_ext32s_tl(r_tmp2
, t1
);
1484 tcg_gen_add_tl(t0
, r_tmp1
, r_tmp2
);
1486 tcg_gen_xor_tl(r_tmp1
, r_tmp1
, t1
);
1487 tcg_gen_xori_tl(r_tmp1
, r_tmp1
, -1);
1488 tcg_gen_xor_tl(r_tmp2
, t0
, t1
);
1489 tcg_gen_and_tl(r_tmp1
, r_tmp1
, r_tmp2
);
1490 tcg_temp_free(r_tmp2
);
1491 tcg_gen_brcondi_tl(TCG_COND_GE
, r_tmp1
, 0, l1
);
1492 /* operands of same sign, result different sign */
1493 generate_exception(ctx
, EXCP_OVERFLOW
);
1495 tcg_temp_free(r_tmp1
);
1497 tcg_gen_ext32s_tl(t0
, t0
);
1502 tcg_gen_add_tl(t0
, t0
, t1
);
1503 tcg_gen_ext32s_tl(t0
, t0
);
1508 TCGv r_tmp1
= tcg_temp_new();
1509 TCGv r_tmp2
= tcg_temp_new();
1510 int l1
= gen_new_label();
1512 save_cpu_state(ctx
, 1);
1513 tcg_gen_ext32s_tl(r_tmp1
, t0
);
1514 tcg_gen_ext32s_tl(r_tmp2
, t1
);
1515 tcg_gen_sub_tl(t0
, r_tmp1
, r_tmp2
);
1517 tcg_gen_xor_tl(r_tmp2
, r_tmp1
, t1
);
1518 tcg_gen_xor_tl(r_tmp1
, r_tmp1
, t0
);
1519 tcg_gen_and_tl(r_tmp1
, r_tmp1
, r_tmp2
);
1520 tcg_temp_free(r_tmp2
);
1521 tcg_gen_brcondi_tl(TCG_COND_GE
, r_tmp1
, 0, l1
);
1522 /* operands of different sign, first operand and result different sign */
1523 generate_exception(ctx
, EXCP_OVERFLOW
);
1525 tcg_temp_free(r_tmp1
);
1527 tcg_gen_ext32s_tl(t0
, t0
);
1532 tcg_gen_sub_tl(t0
, t0
, t1
);
1533 tcg_gen_ext32s_tl(t0
, t0
);
1536 #if defined(TARGET_MIPS64)
1539 TCGv r_tmp1
= tcg_temp_new();
1540 TCGv r_tmp2
= tcg_temp_new();
1541 int l1
= gen_new_label();
1543 save_cpu_state(ctx
, 1);
1544 tcg_gen_mov_tl(r_tmp1
, t0
);
1545 tcg_gen_add_tl(t0
, t0
, t1
);
1547 tcg_gen_xor_tl(r_tmp1
, r_tmp1
, t1
);
1548 tcg_gen_xori_tl(r_tmp1
, r_tmp1
, -1);
1549 tcg_gen_xor_tl(r_tmp2
, t0
, t1
);
1550 tcg_gen_and_tl(r_tmp1
, r_tmp1
, r_tmp2
);
1551 tcg_temp_free(r_tmp2
);
1552 tcg_gen_brcondi_tl(TCG_COND_GE
, r_tmp1
, 0, l1
);
1553 /* operands of same sign, result different sign */
1554 generate_exception(ctx
, EXCP_OVERFLOW
);
1556 tcg_temp_free(r_tmp1
);
1561 tcg_gen_add_tl(t0
, t0
, t1
);
1566 TCGv r_tmp1
= tcg_temp_new();
1567 TCGv r_tmp2
= tcg_temp_new();
1568 int l1
= gen_new_label();
1570 save_cpu_state(ctx
, 1);
1571 tcg_gen_mov_tl(r_tmp1
, t0
);
1572 tcg_gen_sub_tl(t0
, t0
, t1
);
1574 tcg_gen_xor_tl(r_tmp2
, r_tmp1
, t1
);
1575 tcg_gen_xor_tl(r_tmp1
, r_tmp1
, t0
);
1576 tcg_gen_and_tl(r_tmp1
, r_tmp1
, r_tmp2
);
1577 tcg_temp_free(r_tmp2
);
1578 tcg_gen_brcondi_tl(TCG_COND_GE
, r_tmp1
, 0, l1
);
1579 /* operands of different sign, first operand and result different sign */
1580 generate_exception(ctx
, EXCP_OVERFLOW
);
1582 tcg_temp_free(r_tmp1
);
1587 tcg_gen_sub_tl(t0
, t0
, t1
);
1592 gen_op_lt(t0
, t0
, t1
);
1596 gen_op_ltu(t0
, t0
, t1
);
1600 tcg_gen_and_tl(t0
, t0
, t1
);
1604 tcg_gen_nor_tl(t0
, t0
, t1
);
1608 tcg_gen_or_tl(t0
, t0
, t1
);
1612 tcg_gen_xor_tl(t0
, t0
, t1
);
1616 tcg_gen_mul_tl(t0
, t0
, t1
);
1617 tcg_gen_ext32s_tl(t0
, t0
);
1622 int l1
= gen_new_label();
1624 tcg_gen_brcondi_tl(TCG_COND_EQ
, t1
, 0, l1
);
1625 gen_store_gpr(t0
, rd
);
1632 int l1
= gen_new_label();
1634 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, 0, l1
);
1635 gen_store_gpr(t0
, rd
);
1641 tcg_gen_andi_tl(t0
, t0
, 0x1f);
1642 tcg_gen_shl_tl(t0
, t1
, t0
);
1643 tcg_gen_ext32s_tl(t0
, t0
);
1647 tcg_gen_ext32s_tl(t1
, t1
);
1648 tcg_gen_andi_tl(t0
, t0
, 0x1f);
1649 tcg_gen_sar_tl(t0
, t1
, t0
);
1653 switch ((ctx
->opcode
>> 6) & 0x1f) {
1655 tcg_gen_ext32u_tl(t1
, t1
);
1656 tcg_gen_andi_tl(t0
, t0
, 0x1f);
1657 tcg_gen_shr_tl(t0
, t1
, t0
);
1658 tcg_gen_ext32s_tl(t0
, t0
);
1662 /* rotrv is decoded as srlv on non-R2 CPUs */
1663 if (env
->insn_flags
& ISA_MIPS32R2
) {
1664 int l1
= gen_new_label();
1665 int l2
= gen_new_label();
1667 tcg_gen_andi_tl(t0
, t0
, 0x1f);
1668 tcg_gen_brcondi_tl(TCG_COND_EQ
, t0
, 0, l1
);
1670 TCGv_i32 r_tmp1
= tcg_temp_new_i32();
1671 TCGv_i32 r_tmp2
= tcg_temp_new_i32();
1673 tcg_gen_trunc_tl_i32(r_tmp1
, t0
);
1674 tcg_gen_trunc_tl_i32(r_tmp2
, t1
);
1675 tcg_gen_rotr_i32(r_tmp1
, r_tmp1
, r_tmp2
);
1676 tcg_temp_free_i32(r_tmp1
);
1677 tcg_temp_free_i32(r_tmp2
);
1681 tcg_gen_mov_tl(t0
, t1
);
1685 tcg_gen_ext32u_tl(t1
, t1
);
1686 tcg_gen_andi_tl(t0
, t0
, 0x1f);
1687 tcg_gen_shr_tl(t0
, t1
, t0
);
1688 tcg_gen_ext32s_tl(t0
, t0
);
1693 MIPS_INVAL("invalid srlv flag");
1694 generate_exception(ctx
, EXCP_RI
);
1698 #if defined(TARGET_MIPS64)
1700 tcg_gen_andi_tl(t0
, t0
, 0x3f);
1701 tcg_gen_shl_tl(t0
, t1
, t0
);
1705 tcg_gen_andi_tl(t0
, t0
, 0x3f);
1706 tcg_gen_sar_tl(t0
, t1
, t0
);
1710 switch ((ctx
->opcode
>> 6) & 0x1f) {
1712 tcg_gen_andi_tl(t0
, t0
, 0x3f);
1713 tcg_gen_shr_tl(t0
, t1
, t0
);
1717 /* drotrv is decoded as dsrlv on non-R2 CPUs */
1718 if (env
->insn_flags
& ISA_MIPS32R2
) {
1719 int l1
= gen_new_label();
1720 int l2
= gen_new_label();
1722 tcg_gen_andi_tl(t0
, t0
, 0x3f);
1723 tcg_gen_brcondi_tl(TCG_COND_EQ
, t0
, 0, l1
);
1725 tcg_gen_rotr_tl(t0
, t1
, t0
);
1729 tcg_gen_mov_tl(t0
, t1
);
1733 tcg_gen_andi_tl(t0
, t0
, 0x3f);
1734 tcg_gen_shr_tl(t0
, t1
, t0
);
1739 MIPS_INVAL("invalid dsrlv flag");
1740 generate_exception(ctx
, EXCP_RI
);
1747 generate_exception(ctx
, EXCP_RI
);
1750 gen_store_gpr(t0
, rd
);
1752 MIPS_DEBUG("%s %s, %s, %s", opn
, regnames
[rd
], regnames
[rs
], regnames
[rt
]);
1758 /* Arithmetic on HI/LO registers */
1759 static void gen_HILO (DisasContext
*ctx
, uint32_t opc
, int reg
)
1761 const char *opn
= "hilo";
1763 if (reg
== 0 && (opc
== OPC_MFHI
|| opc
== OPC_MFLO
)) {
1770 tcg_gen_mov_tl(cpu_gpr
[reg
], cpu_HI
[0]);
1774 tcg_gen_mov_tl(cpu_gpr
[reg
], cpu_LO
[0]);
1779 tcg_gen_mov_tl(cpu_HI
[0], cpu_gpr
[reg
]);
1781 tcg_gen_movi_tl(cpu_HI
[0], 0);
1786 tcg_gen_mov_tl(cpu_LO
[0], cpu_gpr
[reg
]);
1788 tcg_gen_movi_tl(cpu_LO
[0], 0);
1792 MIPS_DEBUG("%s %s", opn
, regnames
[reg
]);
1795 static void gen_muldiv (DisasContext
*ctx
, uint32_t opc
,
1798 const char *opn
= "mul/div";
1804 #if defined(TARGET_MIPS64)
1808 t0
= tcg_temp_local_new();
1809 t1
= tcg_temp_local_new();
1812 t0
= tcg_temp_new();
1813 t1
= tcg_temp_new();
1817 gen_load_gpr(t0
, rs
);
1818 gen_load_gpr(t1
, rt
);
1822 int l1
= gen_new_label();
1823 int l2
= gen_new_label();
1825 tcg_gen_ext32s_tl(t0
, t0
);
1826 tcg_gen_ext32s_tl(t1
, t1
);
1827 tcg_gen_brcondi_tl(TCG_COND_EQ
, t1
, 0, l1
);
1828 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, INT_MIN
, l2
);
1829 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, -1, l2
);
1831 tcg_gen_mov_tl(cpu_LO
[0], t0
);
1832 tcg_gen_movi_tl(cpu_HI
[0], 0);
1835 tcg_gen_div_tl(cpu_LO
[0], t0
, t1
);
1836 tcg_gen_rem_tl(cpu_HI
[0], t0
, t1
);
1837 tcg_gen_ext32s_tl(cpu_LO
[0], cpu_LO
[0]);
1838 tcg_gen_ext32s_tl(cpu_HI
[0], cpu_HI
[0]);
1845 int l1
= gen_new_label();
1847 tcg_gen_ext32u_tl(t0
, t0
);
1848 tcg_gen_ext32u_tl(t1
, t1
);
1849 tcg_gen_brcondi_tl(TCG_COND_EQ
, t1
, 0, l1
);
1850 tcg_gen_divu_tl(cpu_LO
[0], t0
, t1
);
1851 tcg_gen_remu_tl(cpu_HI
[0], t0
, t1
);
1852 tcg_gen_ext32s_tl(cpu_LO
[0], cpu_LO
[0]);
1853 tcg_gen_ext32s_tl(cpu_HI
[0], cpu_HI
[0]);
1860 TCGv_i64 t2
= tcg_temp_new_i64();
1861 TCGv_i64 t3
= tcg_temp_new_i64();
1863 tcg_gen_ext_tl_i64(t2
, t0
);
1864 tcg_gen_ext_tl_i64(t3
, t1
);
1865 tcg_gen_mul_i64(t2
, t2
, t3
);
1866 tcg_temp_free_i64(t3
);
1867 tcg_gen_trunc_i64_tl(t0
, t2
);
1868 tcg_gen_shri_i64(t2
, t2
, 32);
1869 tcg_gen_trunc_i64_tl(t1
, t2
);
1870 tcg_temp_free_i64(t2
);
1871 tcg_gen_ext32s_tl(cpu_LO
[0], t0
);
1872 tcg_gen_ext32s_tl(cpu_HI
[0], t1
);
1878 TCGv_i64 t2
= tcg_temp_new_i64();
1879 TCGv_i64 t3
= tcg_temp_new_i64();
1881 tcg_gen_ext32u_tl(t0
, t0
);
1882 tcg_gen_ext32u_tl(t1
, t1
);
1883 tcg_gen_extu_tl_i64(t2
, t0
);
1884 tcg_gen_extu_tl_i64(t3
, t1
);
1885 tcg_gen_mul_i64(t2
, t2
, t3
);
1886 tcg_temp_free_i64(t3
);
1887 tcg_gen_trunc_i64_tl(t0
, t2
);
1888 tcg_gen_shri_i64(t2
, t2
, 32);
1889 tcg_gen_trunc_i64_tl(t1
, t2
);
1890 tcg_temp_free_i64(t2
);
1891 tcg_gen_ext32s_tl(cpu_LO
[0], t0
);
1892 tcg_gen_ext32s_tl(cpu_HI
[0], t1
);
1896 #if defined(TARGET_MIPS64)
1899 int l1
= gen_new_label();
1900 int l2
= gen_new_label();
1902 tcg_gen_brcondi_tl(TCG_COND_EQ
, t1
, 0, l1
);
1903 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, -1LL << 63, l2
);
1904 tcg_gen_brcondi_tl(TCG_COND_NE
, t1
, -1LL, l2
);
1905 tcg_gen_mov_tl(cpu_LO
[0], t0
);
1906 tcg_gen_movi_tl(cpu_HI
[0], 0);
1909 tcg_gen_div_i64(cpu_LO
[0], t0
, t1
);
1910 tcg_gen_rem_i64(cpu_HI
[0], t0
, t1
);
1917 int l1
= gen_new_label();
1919 tcg_gen_brcondi_tl(TCG_COND_EQ
, t1
, 0, l1
);
1920 tcg_gen_divu_i64(cpu_LO
[0], t0
, t1
);
1921 tcg_gen_remu_i64(cpu_HI
[0], t0
, t1
);
1927 gen_helper_dmult(t0
, t1
);
1931 gen_helper_dmultu(t0
, t1
);
1937 TCGv_i64 t2
= tcg_temp_new_i64();
1938 TCGv_i64 t3
= tcg_temp_new_i64();
1940 tcg_gen_ext_tl_i64(t2
, t0
);
1941 tcg_gen_ext_tl_i64(t3
, t1
);
1942 tcg_gen_mul_i64(t2
, t2
, t3
);
1943 tcg_gen_concat_tl_i64(t3
, cpu_LO
[0], cpu_HI
[0]);
1944 tcg_gen_add_i64(t2
, t2
, t3
);
1945 tcg_temp_free_i64(t3
);
1946 tcg_gen_trunc_i64_tl(t0
, t2
);
1947 tcg_gen_shri_i64(t2
, t2
, 32);
1948 tcg_gen_trunc_i64_tl(t1
, t2
);
1949 tcg_temp_free_i64(t2
);
1950 tcg_gen_ext32s_tl(cpu_LO
[0], t0
);
1951 tcg_gen_ext32s_tl(cpu_LO
[1], t1
);
1957 TCGv_i64 t2
= tcg_temp_new_i64();
1958 TCGv_i64 t3
= tcg_temp_new_i64();
1960 tcg_gen_ext32u_tl(t0
, t0
);
1961 tcg_gen_ext32u_tl(t1
, t1
);
1962 tcg_gen_extu_tl_i64(t2
, t0
);
1963 tcg_gen_extu_tl_i64(t3
, t1
);
1964 tcg_gen_mul_i64(t2
, t2
, t3
);
1965 tcg_gen_concat_tl_i64(t3
, cpu_LO
[0], cpu_HI
[0]);
1966 tcg_gen_add_i64(t2
, t2
, t3
);
1967 tcg_temp_free_i64(t3
);
1968 tcg_gen_trunc_i64_tl(t0
, t2
);
1969 tcg_gen_shri_i64(t2
, t2
, 32);
1970 tcg_gen_trunc_i64_tl(t1
, t2
);
1971 tcg_temp_free_i64(t2
);
1972 tcg_gen_ext32s_tl(cpu_LO
[0], t0
);
1973 tcg_gen_ext32s_tl(cpu_HI
[0], t1
);
1979 TCGv_i64 t2
= tcg_temp_new_i64();
1980 TCGv_i64 t3
= tcg_temp_new_i64();
1982 tcg_gen_ext_tl_i64(t2
, t0
);
1983 tcg_gen_ext_tl_i64(t3
, t1
);
1984 tcg_gen_mul_i64(t2
, t2
, t3
);
1985 tcg_gen_concat_tl_i64(t3
, cpu_LO
[0], cpu_HI
[0]);
1986 tcg_gen_sub_i64(t2
, t2
, t3
);
1987 tcg_temp_free_i64(t3
);
1988 tcg_gen_trunc_i64_tl(t0
, t2
);
1989 tcg_gen_shri_i64(t2
, t2
, 32);
1990 tcg_gen_trunc_i64_tl(t1
, t2
);
1991 tcg_temp_free_i64(t2
);
1992 tcg_gen_ext32s_tl(cpu_LO
[0], t0
);
1993 tcg_gen_ext32s_tl(cpu_HI
[0], t1
);
1999 TCGv_i64 t2
= tcg_temp_new_i64();
2000 TCGv_i64 t3
= tcg_temp_new_i64();
2002 tcg_gen_ext32u_tl(t0
, t0
);
2003 tcg_gen_ext32u_tl(t1
, t1
);
2004 tcg_gen_extu_tl_i64(t2
, t0
);
2005 tcg_gen_extu_tl_i64(t3
, t1
);
2006 tcg_gen_mul_i64(t2
, t2
, t3
);
2007 tcg_gen_concat_tl_i64(t3
, cpu_LO
[0], cpu_HI
[0]);
2008 tcg_gen_sub_i64(t2
, t2
, t3
);
2009 tcg_temp_free_i64(t3
);
2010 tcg_gen_trunc_i64_tl(t0
, t2
);
2011 tcg_gen_shri_i64(t2
, t2
, 32);
2012 tcg_gen_trunc_i64_tl(t1
, t2
);
2013 tcg_temp_free_i64(t2
);
2014 tcg_gen_ext32s_tl(cpu_LO
[0], t0
);
2015 tcg_gen_ext32s_tl(cpu_HI
[0], t1
);
2021 generate_exception(ctx
, EXCP_RI
);
2024 MIPS_DEBUG("%s %s %s", opn
, regnames
[rs
], regnames
[rt
]);
2030 static void gen_mul_vr54xx (DisasContext
*ctx
, uint32_t opc
,
2031 int rd
, int rs
, int rt
)
2033 const char *opn
= "mul vr54xx";
2034 TCGv t0
= tcg_temp_new();
2035 TCGv t1
= tcg_temp_new();
2037 gen_load_gpr(t0
, rs
);
2038 gen_load_gpr(t1
, rt
);
2041 case OPC_VR54XX_MULS
:
2042 gen_helper_muls(t0
, t0
, t1
);
2045 case OPC_VR54XX_MULSU
:
2046 gen_helper_mulsu(t0
, t0
, t1
);
2049 case OPC_VR54XX_MACC
:
2050 gen_helper_macc(t0
, t0
, t1
);
2053 case OPC_VR54XX_MACCU
:
2054 gen_helper_maccu(t0
, t0
, t1
);
2057 case OPC_VR54XX_MSAC
:
2058 gen_helper_msac(t0
, t0
, t1
);
2061 case OPC_VR54XX_MSACU
:
2062 gen_helper_msacu(t0
, t0
, t1
);
2065 case OPC_VR54XX_MULHI
:
2066 gen_helper_mulhi(t0
, t0
, t1
);
2069 case OPC_VR54XX_MULHIU
:
2070 gen_helper_mulhiu(t0
, t0
, t1
);
2073 case OPC_VR54XX_MULSHI
:
2074 gen_helper_mulshi(t0
, t0
, t1
);
2077 case OPC_VR54XX_MULSHIU
:
2078 gen_helper_mulshiu(t0
, t0
, t1
);
2081 case OPC_VR54XX_MACCHI
:
2082 gen_helper_macchi(t0
, t0
, t1
);
2085 case OPC_VR54XX_MACCHIU
:
2086 gen_helper_macchiu(t0
, t0
, t1
);
2089 case OPC_VR54XX_MSACHI
:
2090 gen_helper_msachi(t0
, t0
, t1
);
2093 case OPC_VR54XX_MSACHIU
:
2094 gen_helper_msachiu(t0
, t0
, t1
);
2098 MIPS_INVAL("mul vr54xx");
2099 generate_exception(ctx
, EXCP_RI
);
2102 gen_store_gpr(t0
, rd
);
2103 MIPS_DEBUG("%s %s, %s, %s", opn
, regnames
[rd
], regnames
[rs
], regnames
[rt
]);
2110 static void gen_cl (DisasContext
*ctx
, uint32_t opc
,
2113 const char *opn
= "CLx";
2121 t0
= tcg_temp_new();
2122 gen_load_gpr(t0
, rs
);
2125 gen_helper_clo(cpu_gpr
[rd
], t0
);
2129 gen_helper_clz(cpu_gpr
[rd
], t0
);
2132 #if defined(TARGET_MIPS64)
2134 gen_helper_dclo(cpu_gpr
[rd
], t0
);
2138 gen_helper_dclz(cpu_gpr
[rd
], t0
);
2143 MIPS_DEBUG("%s %s, %s", opn
, regnames
[rd
], regnames
[rs
]);
2148 static void gen_trap (DisasContext
*ctx
, uint32_t opc
,
2149 int rs
, int rt
, int16_t imm
)
2152 TCGv t0
= tcg_temp_new();
2153 TCGv t1
= tcg_temp_new();
2156 /* Load needed operands */
2164 /* Compare two registers */
2166 gen_load_gpr(t0
, rs
);
2167 gen_load_gpr(t1
, rt
);
2177 /* Compare register to immediate */
2178 if (rs
!= 0 || imm
!= 0) {
2179 gen_load_gpr(t0
, rs
);
2180 tcg_gen_movi_tl(t1
, (int32_t)imm
);
2187 case OPC_TEQ
: /* rs == rs */
2188 case OPC_TEQI
: /* r0 == 0 */
2189 case OPC_TGE
: /* rs >= rs */
2190 case OPC_TGEI
: /* r0 >= 0 */
2191 case OPC_TGEU
: /* rs >= rs unsigned */
2192 case OPC_TGEIU
: /* r0 >= 0 unsigned */
2194 generate_exception(ctx
, EXCP_TRAP
);
2196 case OPC_TLT
: /* rs < rs */
2197 case OPC_TLTI
: /* r0 < 0 */
2198 case OPC_TLTU
: /* rs < rs unsigned */
2199 case OPC_TLTIU
: /* r0 < 0 unsigned */
2200 case OPC_TNE
: /* rs != rs */
2201 case OPC_TNEI
: /* r0 != 0 */
2202 /* Never trap: treat as NOP. */
2206 int l1
= gen_new_label();
2211 tcg_gen_brcond_tl(TCG_COND_NE
, t0
, t1
, l1
);
2215 tcg_gen_brcond_tl(TCG_COND_LT
, t0
, t1
, l1
);
2219 tcg_gen_brcond_tl(TCG_COND_LTU
, t0
, t1
, l1
);
2223 tcg_gen_brcond_tl(TCG_COND_GE
, t0
, t1
, l1
);
2227 tcg_gen_brcond_tl(TCG_COND_GEU
, t0
, t1
, l1
);
2231 tcg_gen_brcond_tl(TCG_COND_EQ
, t0
, t1
, l1
);
2234 generate_exception(ctx
, EXCP_TRAP
);
2241 static inline void gen_goto_tb(DisasContext
*ctx
, int n
, target_ulong dest
)
2243 TranslationBlock
*tb
;
2245 if ((tb
->pc
& TARGET_PAGE_MASK
) == (dest
& TARGET_PAGE_MASK
)) {
2248 tcg_gen_exit_tb((long)tb
+ n
);
2255 /* Branches (before delay slot) */
2256 static void gen_compute_branch (DisasContext
*ctx
, uint32_t opc
,
2257 int rs
, int rt
, int32_t offset
)
2259 target_ulong btgt
= -1;
2261 int bcond_compute
= 0;
2262 TCGv t0
= tcg_temp_new();
2263 TCGv t1
= tcg_temp_new();
2265 if (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
2266 #ifdef MIPS_DEBUG_DISAS
2267 LOG_DISAS("Branch in delay slot at PC 0x" TARGET_FMT_lx
"\n", ctx
->pc
);
2269 generate_exception(ctx
, EXCP_RI
);
2273 /* Load needed operands */
2279 /* Compare two registers */
2281 gen_load_gpr(t0
, rs
);
2282 gen_load_gpr(t1
, rt
);
2285 btgt
= ctx
->pc
+ 4 + offset
;
2299 /* Compare to zero */
2301 gen_load_gpr(t0
, rs
);
2304 btgt
= ctx
->pc
+ 4 + offset
;
2308 /* Jump to immediate */
2309 btgt
= ((ctx
->pc
+ 4) & (int32_t)0xF0000000) | (uint32_t)offset
;
2313 /* Jump to register */
2314 if (offset
!= 0 && offset
!= 16) {
2315 /* Hint = 0 is JR/JALR, hint 16 is JR.HB/JALR.HB, the
2316 others are reserved. */
2317 MIPS_INVAL("jump hint");
2318 generate_exception(ctx
, EXCP_RI
);
2321 gen_load_gpr(btarget
, rs
);
2324 MIPS_INVAL("branch/jump");
2325 generate_exception(ctx
, EXCP_RI
);
2328 if (bcond_compute
== 0) {
2329 /* No condition to be computed */
2331 case OPC_BEQ
: /* rx == rx */
2332 case OPC_BEQL
: /* rx == rx likely */
2333 case OPC_BGEZ
: /* 0 >= 0 */
2334 case OPC_BGEZL
: /* 0 >= 0 likely */
2335 case OPC_BLEZ
: /* 0 <= 0 */
2336 case OPC_BLEZL
: /* 0 <= 0 likely */
2338 ctx
->hflags
|= MIPS_HFLAG_B
;
2339 MIPS_DEBUG("balways");
2341 case OPC_BGEZAL
: /* 0 >= 0 */
2342 case OPC_BGEZALL
: /* 0 >= 0 likely */
2343 /* Always take and link */
2345 ctx
->hflags
|= MIPS_HFLAG_B
;
2346 MIPS_DEBUG("balways and link");
2348 case OPC_BNE
: /* rx != rx */
2349 case OPC_BGTZ
: /* 0 > 0 */
2350 case OPC_BLTZ
: /* 0 < 0 */
2352 MIPS_DEBUG("bnever (NOP)");
2354 case OPC_BLTZAL
: /* 0 < 0 */
2355 tcg_gen_movi_tl(cpu_gpr
[31], ctx
->pc
+ 8);
2356 MIPS_DEBUG("bnever and link");
2358 case OPC_BLTZALL
: /* 0 < 0 likely */
2359 tcg_gen_movi_tl(cpu_gpr
[31], ctx
->pc
+ 8);
2360 /* Skip the instruction in the delay slot */
2361 MIPS_DEBUG("bnever, link and skip");
2364 case OPC_BNEL
: /* rx != rx likely */
2365 case OPC_BGTZL
: /* 0 > 0 likely */
2366 case OPC_BLTZL
: /* 0 < 0 likely */
2367 /* Skip the instruction in the delay slot */
2368 MIPS_DEBUG("bnever and skip");
2372 ctx
->hflags
|= MIPS_HFLAG_B
;
2373 MIPS_DEBUG("j " TARGET_FMT_lx
, btgt
);
2377 ctx
->hflags
|= MIPS_HFLAG_B
;
2378 MIPS_DEBUG("jal " TARGET_FMT_lx
, btgt
);
2381 ctx
->hflags
|= MIPS_HFLAG_BR
;
2382 MIPS_DEBUG("jr %s", regnames
[rs
]);
2386 ctx
->hflags
|= MIPS_HFLAG_BR
;
2387 MIPS_DEBUG("jalr %s, %s", regnames
[rt
], regnames
[rs
]);
2390 MIPS_INVAL("branch/jump");
2391 generate_exception(ctx
, EXCP_RI
);
2397 gen_op_eq(bcond
, t0
, t1
);
2398 MIPS_DEBUG("beq %s, %s, " TARGET_FMT_lx
,
2399 regnames
[rs
], regnames
[rt
], btgt
);
2402 gen_op_eq(bcond
, t0
, t1
);
2403 MIPS_DEBUG("beql %s, %s, " TARGET_FMT_lx
,
2404 regnames
[rs
], regnames
[rt
], btgt
);
2407 gen_op_ne(bcond
, t0
, t1
);
2408 MIPS_DEBUG("bne %s, %s, " TARGET_FMT_lx
,
2409 regnames
[rs
], regnames
[rt
], btgt
);
2412 gen_op_ne(bcond
, t0
, t1
);
2413 MIPS_DEBUG("bnel %s, %s, " TARGET_FMT_lx
,
2414 regnames
[rs
], regnames
[rt
], btgt
);
2417 gen_op_gez(bcond
, t0
);
2418 MIPS_DEBUG("bgez %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2421 gen_op_gez(bcond
, t0
);
2422 MIPS_DEBUG("bgezl %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2425 gen_op_gez(bcond
, t0
);
2426 MIPS_DEBUG("bgezal %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2430 gen_op_gez(bcond
, t0
);
2432 MIPS_DEBUG("bgezall %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2435 gen_op_gtz(bcond
, t0
);
2436 MIPS_DEBUG("bgtz %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2439 gen_op_gtz(bcond
, t0
);
2440 MIPS_DEBUG("bgtzl %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2443 gen_op_lez(bcond
, t0
);
2444 MIPS_DEBUG("blez %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2447 gen_op_lez(bcond
, t0
);
2448 MIPS_DEBUG("blezl %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2451 gen_op_ltz(bcond
, t0
);
2452 MIPS_DEBUG("bltz %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2455 gen_op_ltz(bcond
, t0
);
2456 MIPS_DEBUG("bltzl %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2459 gen_op_ltz(bcond
, t0
);
2461 MIPS_DEBUG("bltzal %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2463 ctx
->hflags
|= MIPS_HFLAG_BC
;
2466 gen_op_ltz(bcond
, t0
);
2468 MIPS_DEBUG("bltzall %s, " TARGET_FMT_lx
, regnames
[rs
], btgt
);
2470 ctx
->hflags
|= MIPS_HFLAG_BL
;
2473 MIPS_INVAL("conditional branch/jump");
2474 generate_exception(ctx
, EXCP_RI
);
2478 MIPS_DEBUG("enter ds: link %d cond %02x target " TARGET_FMT_lx
,
2479 blink
, ctx
->hflags
, btgt
);
2481 ctx
->btarget
= btgt
;
2483 tcg_gen_movi_tl(cpu_gpr
[blink
], ctx
->pc
+ 8);
2491 /* special3 bitfield operations */
2492 static void gen_bitops (DisasContext
*ctx
, uint32_t opc
, int rt
,
2493 int rs
, int lsb
, int msb
)
2495 TCGv t0
= tcg_temp_new();
2496 TCGv t1
= tcg_temp_new();
2499 gen_load_gpr(t1
, rs
);
2504 tcg_gen_shri_tl(t0
, t1
, lsb
);
2506 tcg_gen_andi_tl(t0
, t0
, (1 << (msb
+ 1)) - 1);
2508 tcg_gen_ext32s_tl(t0
, t0
);
2511 #if defined(TARGET_MIPS64)
2513 tcg_gen_shri_tl(t0
, t1
, lsb
);
2515 tcg_gen_andi_tl(t0
, t0
, (1ULL << (msb
+ 1 + 32)) - 1);
2519 tcg_gen_shri_tl(t0
, t1
, lsb
+ 32);
2520 tcg_gen_andi_tl(t0
, t0
, (1ULL << (msb
+ 1)) - 1);
2523 tcg_gen_shri_tl(t0
, t1
, lsb
);
2524 tcg_gen_andi_tl(t0
, t0
, (1ULL << (msb
+ 1)) - 1);
2530 mask
= ((msb
- lsb
+ 1 < 32) ? ((1 << (msb
- lsb
+ 1)) - 1) : ~0) << lsb
;
2531 gen_load_gpr(t0
, rt
);
2532 tcg_gen_andi_tl(t0
, t0
, ~mask
);
2533 tcg_gen_shli_tl(t1
, t1
, lsb
);
2534 tcg_gen_andi_tl(t1
, t1
, mask
);
2535 tcg_gen_or_tl(t0
, t0
, t1
);
2536 tcg_gen_ext32s_tl(t0
, t0
);
2538 #if defined(TARGET_MIPS64)
2542 mask
= ((msb
- lsb
+ 1 + 32 < 64) ? ((1ULL << (msb
- lsb
+ 1 + 32)) - 1) : ~0ULL) << lsb
;
2543 gen_load_gpr(t0
, rt
);
2544 tcg_gen_andi_tl(t0
, t0
, ~mask
);
2545 tcg_gen_shli_tl(t1
, t1
, lsb
);
2546 tcg_gen_andi_tl(t1
, t1
, mask
);
2547 tcg_gen_or_tl(t0
, t0
, t1
);
2552 mask
= ((1ULL << (msb
- lsb
+ 1)) - 1) << lsb
;
2553 gen_load_gpr(t0
, rt
);
2554 tcg_gen_andi_tl(t0
, t0
, ~mask
);
2555 tcg_gen_shli_tl(t1
, t1
, lsb
+ 32);
2556 tcg_gen_andi_tl(t1
, t1
, mask
);
2557 tcg_gen_or_tl(t0
, t0
, t1
);
2562 gen_load_gpr(t0
, rt
);
2563 mask
= ((1ULL << (msb
- lsb
+ 1)) - 1) << lsb
;
2564 gen_load_gpr(t0
, rt
);
2565 tcg_gen_andi_tl(t0
, t0
, ~mask
);
2566 tcg_gen_shli_tl(t1
, t1
, lsb
);
2567 tcg_gen_andi_tl(t1
, t1
, mask
);
2568 tcg_gen_or_tl(t0
, t0
, t1
);
2573 MIPS_INVAL("bitops");
2574 generate_exception(ctx
, EXCP_RI
);
2579 gen_store_gpr(t0
, rt
);
2584 static void gen_bshfl (DisasContext
*ctx
, uint32_t op2
, int rt
, int rd
)
2589 /* If no destination, treat it as a NOP. */
2594 t0
= tcg_temp_new();
2595 gen_load_gpr(t0
, rt
);
2599 TCGv t1
= tcg_temp_new();
2601 tcg_gen_shri_tl(t1
, t0
, 8);
2602 tcg_gen_andi_tl(t1
, t1
, 0x00FF00FF);
2603 tcg_gen_shli_tl(t0
, t0
, 8);
2604 tcg_gen_andi_tl(t0
, t0
, ~0x00FF00FF);
2605 tcg_gen_or_tl(t0
, t0
, t1
);
2607 tcg_gen_ext32s_tl(cpu_gpr
[rd
], t0
);
2611 tcg_gen_ext8s_tl(cpu_gpr
[rd
], t0
);
2614 tcg_gen_ext16s_tl(cpu_gpr
[rd
], t0
);
2616 #if defined(TARGET_MIPS64)
2619 TCGv t1
= tcg_temp_new();
2621 tcg_gen_shri_tl(t1
, t0
, 8);
2622 tcg_gen_andi_tl(t1
, t1
, 0x00FF00FF00FF00FFULL
);
2623 tcg_gen_shli_tl(t0
, t0
, 8);
2624 tcg_gen_andi_tl(t0
, t0
, ~0x00FF00FF00FF00FFULL
);
2625 tcg_gen_or_tl(cpu_gpr
[rd
], t0
, t1
);
2631 TCGv t1
= tcg_temp_new();
2633 tcg_gen_shri_tl(t1
, t0
, 16);
2634 tcg_gen_andi_tl(t1
, t1
, 0x0000FFFF0000FFFFULL
);
2635 tcg_gen_shli_tl(t0
, t0
, 16);
2636 tcg_gen_andi_tl(t0
, t0
, ~0x0000FFFF0000FFFFULL
);
2637 tcg_gen_or_tl(t0
, t0
, t1
);
2638 tcg_gen_shri_tl(t1
, t0
, 32);
2639 tcg_gen_shli_tl(t0
, t0
, 32);
2640 tcg_gen_or_tl(cpu_gpr
[rd
], t0
, t1
);
2646 MIPS_INVAL("bsfhl");
2647 generate_exception(ctx
, EXCP_RI
);
2654 #ifndef CONFIG_USER_ONLY
2655 /* CP0 (MMU and control) */
2656 static inline void gen_mfc0_load32 (TCGv t
, target_ulong off
)
2658 TCGv_i32 r_tmp
= tcg_temp_new_i32();
2660 tcg_gen_ld_i32(r_tmp
, cpu_env
, off
);
2661 tcg_gen_ext_i32_tl(t
, r_tmp
);
2662 tcg_temp_free_i32(r_tmp
);
2665 static inline void gen_mfc0_load64 (TCGv t
, target_ulong off
)
2667 tcg_gen_ld_tl(t
, cpu_env
, off
);
2668 tcg_gen_ext32s_tl(t
, t
);
2671 static inline void gen_mtc0_store32 (TCGv t
, target_ulong off
)
2673 TCGv_i32 r_tmp
= tcg_temp_new_i32();
2675 tcg_gen_trunc_tl_i32(r_tmp
, t
);
2676 tcg_gen_st_i32(r_tmp
, cpu_env
, off
);
2677 tcg_temp_free_i32(r_tmp
);
2680 static inline void gen_mtc0_store64 (TCGv t
, target_ulong off
)
2682 tcg_gen_ext32s_tl(t
, t
);
2683 tcg_gen_st_tl(t
, cpu_env
, off
);
2686 static void gen_mfc0 (CPUState
*env
, DisasContext
*ctx
, TCGv t0
, int reg
, int sel
)
2688 const char *rn
= "invalid";
2691 check_insn(env
, ctx
, ISA_MIPS32
);
2697 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Index
));
2701 check_insn(env
, ctx
, ASE_MT
);
2702 gen_helper_mfc0_mvpcontrol(t0
);
2706 check_insn(env
, ctx
, ASE_MT
);
2707 gen_helper_mfc0_mvpconf0(t0
);
2711 check_insn(env
, ctx
, ASE_MT
);
2712 gen_helper_mfc0_mvpconf1(t0
);
2722 gen_helper_mfc0_random(t0
);
2726 check_insn(env
, ctx
, ASE_MT
);
2727 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_VPEControl
));
2731 check_insn(env
, ctx
, ASE_MT
);
2732 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_VPEConf0
));
2736 check_insn(env
, ctx
, ASE_MT
);
2737 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_VPEConf1
));
2741 check_insn(env
, ctx
, ASE_MT
);
2742 gen_mfc0_load64(t0
, offsetof(CPUState
, CP0_YQMask
));
2746 check_insn(env
, ctx
, ASE_MT
);
2747 gen_mfc0_load64(t0
, offsetof(CPUState
, CP0_VPESchedule
));
2751 check_insn(env
, ctx
, ASE_MT
);
2752 gen_mfc0_load64(t0
, offsetof(CPUState
, CP0_VPEScheFBack
));
2753 rn
= "VPEScheFBack";
2756 check_insn(env
, ctx
, ASE_MT
);
2757 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_VPEOpt
));
2767 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_EntryLo0
));
2768 tcg_gen_ext32s_tl(t0
, t0
);
2772 check_insn(env
, ctx
, ASE_MT
);
2773 gen_helper_mfc0_tcstatus(t0
);
2777 check_insn(env
, ctx
, ASE_MT
);
2778 gen_helper_mfc0_tcbind(t0
);
2782 check_insn(env
, ctx
, ASE_MT
);
2783 gen_helper_mfc0_tcrestart(t0
);
2787 check_insn(env
, ctx
, ASE_MT
);
2788 gen_helper_mfc0_tchalt(t0
);
2792 check_insn(env
, ctx
, ASE_MT
);
2793 gen_helper_mfc0_tccontext(t0
);
2797 check_insn(env
, ctx
, ASE_MT
);
2798 gen_helper_mfc0_tcschedule(t0
);
2802 check_insn(env
, ctx
, ASE_MT
);
2803 gen_helper_mfc0_tcschefback(t0
);
2813 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_EntryLo1
));
2814 tcg_gen_ext32s_tl(t0
, t0
);
2824 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_Context
));
2825 tcg_gen_ext32s_tl(t0
, t0
);
2829 // gen_helper_mfc0_contextconfig(t0); /* SmartMIPS ASE */
2830 rn
= "ContextConfig";
2839 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_PageMask
));
2843 check_insn(env
, ctx
, ISA_MIPS32R2
);
2844 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_PageGrain
));
2854 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Wired
));
2858 check_insn(env
, ctx
, ISA_MIPS32R2
);
2859 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf0
));
2863 check_insn(env
, ctx
, ISA_MIPS32R2
);
2864 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf1
));
2868 check_insn(env
, ctx
, ISA_MIPS32R2
);
2869 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf2
));
2873 check_insn(env
, ctx
, ISA_MIPS32R2
);
2874 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf3
));
2878 check_insn(env
, ctx
, ISA_MIPS32R2
);
2879 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf4
));
2889 check_insn(env
, ctx
, ISA_MIPS32R2
);
2890 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_HWREna
));
2900 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_BadVAddr
));
2901 tcg_gen_ext32s_tl(t0
, t0
);
2911 /* Mark as an IO operation because we read the time. */
2914 gen_helper_mfc0_count(t0
);
2917 ctx
->bstate
= BS_STOP
;
2921 /* 6,7 are implementation dependent */
2929 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_EntryHi
));
2930 tcg_gen_ext32s_tl(t0
, t0
);
2940 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Compare
));
2943 /* 6,7 are implementation dependent */
2951 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Status
));
2955 check_insn(env
, ctx
, ISA_MIPS32R2
);
2956 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_IntCtl
));
2960 check_insn(env
, ctx
, ISA_MIPS32R2
);
2961 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSCtl
));
2965 check_insn(env
, ctx
, ISA_MIPS32R2
);
2966 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSMap
));
2976 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Cause
));
2986 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_EPC
));
2987 tcg_gen_ext32s_tl(t0
, t0
);
2997 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_PRid
));
3001 check_insn(env
, ctx
, ISA_MIPS32R2
);
3002 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_EBase
));
3012 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config0
));
3016 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config1
));
3020 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config2
));
3024 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config3
));
3027 /* 4,5 are reserved */
3028 /* 6,7 are implementation dependent */
3030 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config6
));
3034 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config7
));
3044 gen_helper_mfc0_lladdr(t0
);
3054 gen_helper_1i(mfc0_watchlo
, t0
, sel
);
3064 gen_helper_1i(mfc0_watchhi
, t0
, sel
);
3074 #if defined(TARGET_MIPS64)
3075 check_insn(env
, ctx
, ISA_MIPS3
);
3076 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_XContext
));
3077 tcg_gen_ext32s_tl(t0
, t0
);
3086 /* Officially reserved, but sel 0 is used for R1x000 framemask */
3089 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Framemask
));
3097 tcg_gen_movi_tl(t0
, 0); /* unimplemented */
3098 rn
= "'Diagnostic"; /* implementation dependent */
3103 gen_helper_mfc0_debug(t0
); /* EJTAG support */
3107 // gen_helper_mfc0_tracecontrol(t0); /* PDtrace support */
3108 rn
= "TraceControl";
3111 // gen_helper_mfc0_tracecontrol2(t0); /* PDtrace support */
3112 rn
= "TraceControl2";
3115 // gen_helper_mfc0_usertracedata(t0); /* PDtrace support */
3116 rn
= "UserTraceData";
3119 // gen_helper_mfc0_tracebpc(t0); /* PDtrace support */
3130 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_DEPC
));
3131 tcg_gen_ext32s_tl(t0
, t0
);
3141 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Performance0
));
3142 rn
= "Performance0";
3145 // gen_helper_mfc0_performance1(t0);
3146 rn
= "Performance1";
3149 // gen_helper_mfc0_performance2(t0);
3150 rn
= "Performance2";
3153 // gen_helper_mfc0_performance3(t0);
3154 rn
= "Performance3";
3157 // gen_helper_mfc0_performance4(t0);
3158 rn
= "Performance4";
3161 // gen_helper_mfc0_performance5(t0);
3162 rn
= "Performance5";
3165 // gen_helper_mfc0_performance6(t0);
3166 rn
= "Performance6";
3169 // gen_helper_mfc0_performance7(t0);
3170 rn
= "Performance7";
3177 tcg_gen_movi_tl(t0
, 0); /* unimplemented */
3183 tcg_gen_movi_tl(t0
, 0); /* unimplemented */
3196 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_TagLo
));
3203 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_DataLo
));
3216 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_TagHi
));
3223 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_DataHi
));
3233 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_ErrorEPC
));
3234 tcg_gen_ext32s_tl(t0
, t0
);
3245 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_DESAVE
));
3255 LOG_DISAS("mfc0 %s (reg %d sel %d)\n", rn
, reg
, sel
);
3259 LOG_DISAS("mfc0 %s (reg %d sel %d)\n", rn
, reg
, sel
);
3260 generate_exception(ctx
, EXCP_RI
);
3263 static void gen_mtc0 (CPUState
*env
, DisasContext
*ctx
, TCGv t0
, int reg
, int sel
)
3265 const char *rn
= "invalid";
3268 check_insn(env
, ctx
, ISA_MIPS32
);
3277 gen_helper_mtc0_index(t0
);
3281 check_insn(env
, ctx
, ASE_MT
);
3282 gen_helper_mtc0_mvpcontrol(t0
);
3286 check_insn(env
, ctx
, ASE_MT
);
3291 check_insn(env
, ctx
, ASE_MT
);
3306 check_insn(env
, ctx
, ASE_MT
);
3307 gen_helper_mtc0_vpecontrol(t0
);
3311 check_insn(env
, ctx
, ASE_MT
);
3312 gen_helper_mtc0_vpeconf0(t0
);
3316 check_insn(env
, ctx
, ASE_MT
);
3317 gen_helper_mtc0_vpeconf1(t0
);
3321 check_insn(env
, ctx
, ASE_MT
);
3322 gen_helper_mtc0_yqmask(t0
);
3326 check_insn(env
, ctx
, ASE_MT
);
3327 gen_mtc0_store64(t0
, offsetof(CPUState
, CP0_VPESchedule
));
3331 check_insn(env
, ctx
, ASE_MT
);
3332 gen_mtc0_store64(t0
, offsetof(CPUState
, CP0_VPEScheFBack
));
3333 rn
= "VPEScheFBack";
3336 check_insn(env
, ctx
, ASE_MT
);
3337 gen_helper_mtc0_vpeopt(t0
);
3347 gen_helper_mtc0_entrylo0(t0
);
3351 check_insn(env
, ctx
, ASE_MT
);
3352 gen_helper_mtc0_tcstatus(t0
);
3356 check_insn(env
, ctx
, ASE_MT
);
3357 gen_helper_mtc0_tcbind(t0
);
3361 check_insn(env
, ctx
, ASE_MT
);
3362 gen_helper_mtc0_tcrestart(t0
);
3366 check_insn(env
, ctx
, ASE_MT
);
3367 gen_helper_mtc0_tchalt(t0
);
3371 check_insn(env
, ctx
, ASE_MT
);
3372 gen_helper_mtc0_tccontext(t0
);
3376 check_insn(env
, ctx
, ASE_MT
);
3377 gen_helper_mtc0_tcschedule(t0
);
3381 check_insn(env
, ctx
, ASE_MT
);
3382 gen_helper_mtc0_tcschefback(t0
);
3392 gen_helper_mtc0_entrylo1(t0
);
3402 gen_helper_mtc0_context(t0
);
3406 // gen_helper_mtc0_contextconfig(t0); /* SmartMIPS ASE */
3407 rn
= "ContextConfig";
3416 gen_helper_mtc0_pagemask(t0
);
3420 check_insn(env
, ctx
, ISA_MIPS32R2
);
3421 gen_helper_mtc0_pagegrain(t0
);
3431 gen_helper_mtc0_wired(t0
);
3435 check_insn(env
, ctx
, ISA_MIPS32R2
);
3436 gen_helper_mtc0_srsconf0(t0
);
3440 check_insn(env
, ctx
, ISA_MIPS32R2
);
3441 gen_helper_mtc0_srsconf1(t0
);
3445 check_insn(env
, ctx
, ISA_MIPS32R2
);
3446 gen_helper_mtc0_srsconf2(t0
);
3450 check_insn(env
, ctx
, ISA_MIPS32R2
);
3451 gen_helper_mtc0_srsconf3(t0
);
3455 check_insn(env
, ctx
, ISA_MIPS32R2
);
3456 gen_helper_mtc0_srsconf4(t0
);
3466 check_insn(env
, ctx
, ISA_MIPS32R2
);
3467 gen_helper_mtc0_hwrena(t0
);
3481 gen_helper_mtc0_count(t0
);
3484 /* 6,7 are implementation dependent */
3488 /* Stop translation as we may have switched the execution mode */
3489 ctx
->bstate
= BS_STOP
;
3494 gen_helper_mtc0_entryhi(t0
);
3504 gen_helper_mtc0_compare(t0
);
3507 /* 6,7 are implementation dependent */
3511 /* Stop translation as we may have switched the execution mode */
3512 ctx
->bstate
= BS_STOP
;
3517 gen_helper_mtc0_status(t0
);
3518 /* BS_STOP isn't good enough here, hflags may have changed. */
3519 gen_save_pc(ctx
->pc
+ 4);
3520 ctx
->bstate
= BS_EXCP
;
3524 check_insn(env
, ctx
, ISA_MIPS32R2
);
3525 gen_helper_mtc0_intctl(t0
);
3526 /* Stop translation as we may have switched the execution mode */
3527 ctx
->bstate
= BS_STOP
;
3531 check_insn(env
, ctx
, ISA_MIPS32R2
);
3532 gen_helper_mtc0_srsctl(t0
);
3533 /* Stop translation as we may have switched the execution mode */
3534 ctx
->bstate
= BS_STOP
;
3538 check_insn(env
, ctx
, ISA_MIPS32R2
);
3539 gen_mtc0_store32(t0
, offsetof(CPUState
, CP0_SRSMap
));
3540 /* Stop translation as we may have switched the execution mode */
3541 ctx
->bstate
= BS_STOP
;
3551 gen_helper_mtc0_cause(t0
);
3557 /* Stop translation as we may have switched the execution mode */
3558 ctx
->bstate
= BS_STOP
;
3563 gen_mtc0_store64(t0
, offsetof(CPUState
, CP0_EPC
));
3577 check_insn(env
, ctx
, ISA_MIPS32R2
);
3578 gen_helper_mtc0_ebase(t0
);
3588 gen_helper_mtc0_config0(t0
);
3590 /* Stop translation as we may have switched the execution mode */
3591 ctx
->bstate
= BS_STOP
;
3594 /* ignored, read only */
3598 gen_helper_mtc0_config2(t0
);
3600 /* Stop translation as we may have switched the execution mode */
3601 ctx
->bstate
= BS_STOP
;
3604 /* ignored, read only */
3607 /* 4,5 are reserved */
3608 /* 6,7 are implementation dependent */
3618 rn
= "Invalid config selector";
3635 gen_helper_1i(mtc0_watchlo
, t0
, sel
);
3645 gen_helper_1i(mtc0_watchhi
, t0
, sel
);
3655 #if defined(TARGET_MIPS64)
3656 check_insn(env
, ctx
, ISA_MIPS3
);
3657 gen_helper_mtc0_xcontext(t0
);
3666 /* Officially reserved, but sel 0 is used for R1x000 framemask */
3669 gen_helper_mtc0_framemask(t0
);
3678 rn
= "Diagnostic"; /* implementation dependent */
3683 gen_helper_mtc0_debug(t0
); /* EJTAG support */
3684 /* BS_STOP isn't good enough here, hflags may have changed. */
3685 gen_save_pc(ctx
->pc
+ 4);
3686 ctx
->bstate
= BS_EXCP
;
3690 // gen_helper_mtc0_tracecontrol(t0); /* PDtrace support */
3691 rn
= "TraceControl";
3692 /* Stop translation as we may have switched the execution mode */
3693 ctx
->bstate
= BS_STOP
;
3696 // gen_helper_mtc0_tracecontrol2(t0); /* PDtrace support */
3697 rn
= "TraceControl2";
3698 /* Stop translation as we may have switched the execution mode */
3699 ctx
->bstate
= BS_STOP
;
3702 /* Stop translation as we may have switched the execution mode */
3703 ctx
->bstate
= BS_STOP
;
3704 // gen_helper_mtc0_usertracedata(t0); /* PDtrace support */
3705 rn
= "UserTraceData";
3706 /* Stop translation as we may have switched the execution mode */
3707 ctx
->bstate
= BS_STOP
;
3710 // gen_helper_mtc0_tracebpc(t0); /* PDtrace support */
3711 /* Stop translation as we may have switched the execution mode */
3712 ctx
->bstate
= BS_STOP
;
3723 gen_mtc0_store64(t0
, offsetof(CPUState
, CP0_DEPC
));
3733 gen_helper_mtc0_performance0(t0
);
3734 rn
= "Performance0";
3737 // gen_helper_mtc0_performance1(t0);
3738 rn
= "Performance1";
3741 // gen_helper_mtc0_performance2(t0);
3742 rn
= "Performance2";
3745 // gen_helper_mtc0_performance3(t0);
3746 rn
= "Performance3";
3749 // gen_helper_mtc0_performance4(t0);
3750 rn
= "Performance4";
3753 // gen_helper_mtc0_performance5(t0);
3754 rn
= "Performance5";
3757 // gen_helper_mtc0_performance6(t0);
3758 rn
= "Performance6";
3761 // gen_helper_mtc0_performance7(t0);
3762 rn
= "Performance7";
3788 gen_helper_mtc0_taglo(t0
);
3795 gen_helper_mtc0_datalo(t0
);
3808 gen_helper_mtc0_taghi(t0
);
3815 gen_helper_mtc0_datahi(t0
);
3826 gen_mtc0_store64(t0
, offsetof(CPUState
, CP0_ErrorEPC
));
3837 gen_mtc0_store32(t0
, offsetof(CPUState
, CP0_DESAVE
));
3843 /* Stop translation as we may have switched the execution mode */
3844 ctx
->bstate
= BS_STOP
;
3849 LOG_DISAS("mtc0 %s (reg %d sel %d)\n", rn
, reg
, sel
);
3850 /* For simplicity assume that all writes can cause interrupts. */
3853 ctx
->bstate
= BS_STOP
;
3858 LOG_DISAS("mtc0 %s (reg %d sel %d)\n", rn
, reg
, sel
);
3859 generate_exception(ctx
, EXCP_RI
);
3862 #if defined(TARGET_MIPS64)
3863 static void gen_dmfc0 (CPUState
*env
, DisasContext
*ctx
, TCGv t0
, int reg
, int sel
)
3865 const char *rn
= "invalid";
3868 check_insn(env
, ctx
, ISA_MIPS64
);
3874 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Index
));
3878 check_insn(env
, ctx
, ASE_MT
);
3879 gen_helper_mfc0_mvpcontrol(t0
);
3883 check_insn(env
, ctx
, ASE_MT
);
3884 gen_helper_mfc0_mvpconf0(t0
);
3888 check_insn(env
, ctx
, ASE_MT
);
3889 gen_helper_mfc0_mvpconf1(t0
);
3899 gen_helper_mfc0_random(t0
);
3903 check_insn(env
, ctx
, ASE_MT
);
3904 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_VPEControl
));
3908 check_insn(env
, ctx
, ASE_MT
);
3909 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_VPEConf0
));
3913 check_insn(env
, ctx
, ASE_MT
);
3914 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_VPEConf1
));
3918 check_insn(env
, ctx
, ASE_MT
);
3919 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_YQMask
));
3923 check_insn(env
, ctx
, ASE_MT
);
3924 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_VPESchedule
));
3928 check_insn(env
, ctx
, ASE_MT
);
3929 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_VPEScheFBack
));
3930 rn
= "VPEScheFBack";
3933 check_insn(env
, ctx
, ASE_MT
);
3934 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_VPEOpt
));
3944 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_EntryLo0
));
3948 check_insn(env
, ctx
, ASE_MT
);
3949 gen_helper_mfc0_tcstatus(t0
);
3953 check_insn(env
, ctx
, ASE_MT
);
3954 gen_helper_mfc0_tcbind(t0
);
3958 check_insn(env
, ctx
, ASE_MT
);
3959 gen_helper_dmfc0_tcrestart(t0
);
3963 check_insn(env
, ctx
, ASE_MT
);
3964 gen_helper_dmfc0_tchalt(t0
);
3968 check_insn(env
, ctx
, ASE_MT
);
3969 gen_helper_dmfc0_tccontext(t0
);
3973 check_insn(env
, ctx
, ASE_MT
);
3974 gen_helper_dmfc0_tcschedule(t0
);
3978 check_insn(env
, ctx
, ASE_MT
);
3979 gen_helper_dmfc0_tcschefback(t0
);
3989 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_EntryLo1
));
3999 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_Context
));
4003 // gen_helper_dmfc0_contextconfig(t0); /* SmartMIPS ASE */
4004 rn
= "ContextConfig";
4013 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_PageMask
));
4017 check_insn(env
, ctx
, ISA_MIPS32R2
);
4018 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_PageGrain
));
4028 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Wired
));
4032 check_insn(env
, ctx
, ISA_MIPS32R2
);
4033 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf0
));
4037 check_insn(env
, ctx
, ISA_MIPS32R2
);
4038 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf1
));
4042 check_insn(env
, ctx
, ISA_MIPS32R2
);
4043 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf2
));
4047 check_insn(env
, ctx
, ISA_MIPS32R2
);
4048 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf3
));
4052 check_insn(env
, ctx
, ISA_MIPS32R2
);
4053 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSConf4
));
4063 check_insn(env
, ctx
, ISA_MIPS32R2
);
4064 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_HWREna
));
4074 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_BadVAddr
));
4084 /* Mark as an IO operation because we read the time. */
4087 gen_helper_mfc0_count(t0
);
4090 ctx
->bstate
= BS_STOP
;
4094 /* 6,7 are implementation dependent */
4102 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_EntryHi
));
4112 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Compare
));
4115 /* 6,7 are implementation dependent */
4123 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Status
));
4127 check_insn(env
, ctx
, ISA_MIPS32R2
);
4128 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_IntCtl
));
4132 check_insn(env
, ctx
, ISA_MIPS32R2
);
4133 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSCtl
));
4137 check_insn(env
, ctx
, ISA_MIPS32R2
);
4138 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_SRSMap
));
4148 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Cause
));
4158 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_EPC
));
4168 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_PRid
));
4172 check_insn(env
, ctx
, ISA_MIPS32R2
);
4173 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_EBase
));
4183 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config0
));
4187 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config1
));
4191 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config2
));
4195 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config3
));
4198 /* 6,7 are implementation dependent */
4200 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config6
));
4204 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Config7
));
4214 gen_helper_dmfc0_lladdr(t0
);
4224 gen_helper_1i(dmfc0_watchlo
, t0
, sel
);
4234 gen_helper_1i(mfc0_watchhi
, t0
, sel
);
4244 check_insn(env
, ctx
, ISA_MIPS3
);
4245 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_XContext
));
4253 /* Officially reserved, but sel 0 is used for R1x000 framemask */
4256 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Framemask
));
4264 tcg_gen_movi_tl(t0
, 0); /* unimplemented */
4265 rn
= "'Diagnostic"; /* implementation dependent */
4270 gen_helper_mfc0_debug(t0
); /* EJTAG support */
4274 // gen_helper_dmfc0_tracecontrol(t0); /* PDtrace support */
4275 rn
= "TraceControl";
4278 // gen_helper_dmfc0_tracecontrol2(t0); /* PDtrace support */
4279 rn
= "TraceControl2";
4282 // gen_helper_dmfc0_usertracedata(t0); /* PDtrace support */
4283 rn
= "UserTraceData";
4286 // gen_helper_dmfc0_tracebpc(t0); /* PDtrace support */
4297 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_DEPC
));
4307 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_Performance0
));
4308 rn
= "Performance0";
4311 // gen_helper_dmfc0_performance1(t0);
4312 rn
= "Performance1";
4315 // gen_helper_dmfc0_performance2(t0);
4316 rn
= "Performance2";
4319 // gen_helper_dmfc0_performance3(t0);
4320 rn
= "Performance3";
4323 // gen_helper_dmfc0_performance4(t0);
4324 rn
= "Performance4";
4327 // gen_helper_dmfc0_performance5(t0);
4328 rn
= "Performance5";
4331 // gen_helper_dmfc0_performance6(t0);
4332 rn
= "Performance6";
4335 // gen_helper_dmfc0_performance7(t0);
4336 rn
= "Performance7";
4343 tcg_gen_movi_tl(t0
, 0); /* unimplemented */
4350 tcg_gen_movi_tl(t0
, 0); /* unimplemented */
4363 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_TagLo
));
4370 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_DataLo
));
4383 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_TagHi
));
4390 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_DataHi
));
4400 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_ErrorEPC
));
4411 gen_mfc0_load32(t0
, offsetof(CPUState
, CP0_DESAVE
));
4421 LOG_DISAS("dmfc0 %s (reg %d sel %d)\n", rn
, reg
, sel
);
4425 LOG_DISAS("dmfc0 %s (reg %d sel %d)\n", rn
, reg
, sel
);
4426 generate_exception(ctx
, EXCP_RI
);
4429 static void gen_dmtc0 (CPUState
*env
, DisasContext
*ctx
, TCGv t0
, int reg
, int sel
)
4431 const char *rn
= "invalid";
4434 check_insn(env
, ctx
, ISA_MIPS64
);
4443 gen_helper_mtc0_index(t0
);
4447 check_insn(env
, ctx
, ASE_MT
);
4448 gen_helper_mtc0_mvpcontrol(t0
);
4452 check_insn(env
, ctx
, ASE_MT
);
4457 check_insn(env
, ctx
, ASE_MT
);
4472 check_insn(env
, ctx
, ASE_MT
);
4473 gen_helper_mtc0_vpecontrol(t0
);
4477 check_insn(env
, ctx
, ASE_MT
);
4478 gen_helper_mtc0_vpeconf0(t0
);
4482 check_insn(env
, ctx
, ASE_MT
);
4483 gen_helper_mtc0_vpeconf1(t0
);
4487 check_insn(env
, ctx
, ASE_MT
);
4488 gen_helper_mtc0_yqmask(t0
);
4492 check_insn(env
, ctx
, ASE_MT
);
4493 tcg_gen_st_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_VPESchedule
));
4497 check_insn(env
, ctx
, ASE_MT
);
4498 tcg_gen_st_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_VPEScheFBack
));
4499 rn
= "VPEScheFBack";
4502 check_insn(env
, ctx
, ASE_MT
);
4503 gen_helper_mtc0_vpeopt(t0
);
4513 gen_helper_mtc0_entrylo0(t0
);
4517 check_insn(env
, ctx
, ASE_MT
);
4518 gen_helper_mtc0_tcstatus(t0
);
4522 check_insn(env
, ctx
, ASE_MT
);
4523 gen_helper_mtc0_tcbind(t0
);
4527 check_insn(env
, ctx
, ASE_MT
);
4528 gen_helper_mtc0_tcrestart(t0
);
4532 check_insn(env
, ctx
, ASE_MT
);
4533 gen_helper_mtc0_tchalt(t0
);
4537 check_insn(env
, ctx
, ASE_MT
);
4538 gen_helper_mtc0_tccontext(t0
);
4542 check_insn(env
, ctx
, ASE_MT
);
4543 gen_helper_mtc0_tcschedule(t0
);
4547 check_insn(env
, ctx
, ASE_MT
);
4548 gen_helper_mtc0_tcschefback(t0
);
4558 gen_helper_mtc0_entrylo1(t0
);
4568 gen_helper_mtc0_context(t0
);
4572 // gen_helper_mtc0_contextconfig(t0); /* SmartMIPS ASE */
4573 rn
= "ContextConfig";
4582 gen_helper_mtc0_pagemask(t0
);
4586 check_insn(env
, ctx
, ISA_MIPS32R2
);
4587 gen_helper_mtc0_pagegrain(t0
);
4597 gen_helper_mtc0_wired(t0
);
4601 check_insn(env
, ctx
, ISA_MIPS32R2
);
4602 gen_helper_mtc0_srsconf0(t0
);
4606 check_insn(env
, ctx
, ISA_MIPS32R2
);
4607 gen_helper_mtc0_srsconf1(t0
);
4611 check_insn(env
, ctx
, ISA_MIPS32R2
);
4612 gen_helper_mtc0_srsconf2(t0
);
4616 check_insn(env
, ctx
, ISA_MIPS32R2
);
4617 gen_helper_mtc0_srsconf3(t0
);
4621 check_insn(env
, ctx
, ISA_MIPS32R2
);
4622 gen_helper_mtc0_srsconf4(t0
);
4632 check_insn(env
, ctx
, ISA_MIPS32R2
);
4633 gen_helper_mtc0_hwrena(t0
);
4647 gen_helper_mtc0_count(t0
);
4650 /* 6,7 are implementation dependent */
4654 /* Stop translation as we may have switched the execution mode */
4655 ctx
->bstate
= BS_STOP
;
4660 gen_helper_mtc0_entryhi(t0
);
4670 gen_helper_mtc0_compare(t0
);
4673 /* 6,7 are implementation dependent */
4677 /* Stop translation as we may have switched the execution mode */
4678 ctx
->bstate
= BS_STOP
;
4683 gen_helper_mtc0_status(t0
);
4684 /* BS_STOP isn't good enough here, hflags may have changed. */
4685 gen_save_pc(ctx
->pc
+ 4);
4686 ctx
->bstate
= BS_EXCP
;
4690 check_insn(env
, ctx
, ISA_MIPS32R2
);
4691 gen_helper_mtc0_intctl(t0
);
4692 /* Stop translation as we may have switched the execution mode */
4693 ctx
->bstate
= BS_STOP
;
4697 check_insn(env
, ctx
, ISA_MIPS32R2
);
4698 gen_helper_mtc0_srsctl(t0
);
4699 /* Stop translation as we may have switched the execution mode */
4700 ctx
->bstate
= BS_STOP
;
4704 check_insn(env
, ctx
, ISA_MIPS32R2
);
4705 gen_mtc0_store32(t0
, offsetof(CPUState
, CP0_SRSMap
));
4706 /* Stop translation as we may have switched the execution mode */
4707 ctx
->bstate
= BS_STOP
;
4717 gen_helper_mtc0_cause(t0
);
4723 /* Stop translation as we may have switched the execution mode */
4724 ctx
->bstate
= BS_STOP
;
4729 tcg_gen_st_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_EPC
));
4743 check_insn(env
, ctx
, ISA_MIPS32R2
);
4744 gen_helper_mtc0_ebase(t0
);
4754 gen_helper_mtc0_config0(t0
);
4756 /* Stop translation as we may have switched the execution mode */
4757 ctx
->bstate
= BS_STOP
;
4764 gen_helper_mtc0_config2(t0
);
4766 /* Stop translation as we may have switched the execution mode */
4767 ctx
->bstate
= BS_STOP
;
4773 /* 6,7 are implementation dependent */
4775 rn
= "Invalid config selector";
4792 gen_helper_1i(mtc0_watchlo
, t0
, sel
);
4802 gen_helper_1i(mtc0_watchhi
, t0
, sel
);
4812 check_insn(env
, ctx
, ISA_MIPS3
);
4813 gen_helper_mtc0_xcontext(t0
);
4821 /* Officially reserved, but sel 0 is used for R1x000 framemask */
4824 gen_helper_mtc0_framemask(t0
);
4833 rn
= "Diagnostic"; /* implementation dependent */
4838 gen_helper_mtc0_debug(t0
); /* EJTAG support */
4839 /* BS_STOP isn't good enough here, hflags may have changed. */
4840 gen_save_pc(ctx
->pc
+ 4);
4841 ctx
->bstate
= BS_EXCP
;
4845 // gen_helper_mtc0_tracecontrol(t0); /* PDtrace support */
4846 /* Stop translation as we may have switched the execution mode */
4847 ctx
->bstate
= BS_STOP
;
4848 rn
= "TraceControl";
4851 // gen_helper_mtc0_tracecontrol2(t0); /* PDtrace support */
4852 /* Stop translation as we may have switched the execution mode */
4853 ctx
->bstate
= BS_STOP
;
4854 rn
= "TraceControl2";
4857 // gen_helper_mtc0_usertracedata(t0); /* PDtrace support */
4858 /* Stop translation as we may have switched the execution mode */
4859 ctx
->bstate
= BS_STOP
;
4860 rn
= "UserTraceData";
4863 // gen_helper_mtc0_tracebpc(t0); /* PDtrace support */
4864 /* Stop translation as we may have switched the execution mode */
4865 ctx
->bstate
= BS_STOP
;
4876 tcg_gen_st_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_DEPC
));
4886 gen_helper_mtc0_performance0(t0
);
4887 rn
= "Performance0";
4890 // gen_helper_mtc0_performance1(t0);
4891 rn
= "Performance1";
4894 // gen_helper_mtc0_performance2(t0);
4895 rn
= "Performance2";
4898 // gen_helper_mtc0_performance3(t0);
4899 rn
= "Performance3";
4902 // gen_helper_mtc0_performance4(t0);
4903 rn
= "Performance4";
4906 // gen_helper_mtc0_performance5(t0);
4907 rn
= "Performance5";
4910 // gen_helper_mtc0_performance6(t0);
4911 rn
= "Performance6";
4914 // gen_helper_mtc0_performance7(t0);
4915 rn
= "Performance7";
4941 gen_helper_mtc0_taglo(t0
);
4948 gen_helper_mtc0_datalo(t0
);
4961 gen_helper_mtc0_taghi(t0
);
4968 gen_helper_mtc0_datahi(t0
);
4979 tcg_gen_st_tl(t0
, cpu_env
, offsetof(CPUState
, CP0_ErrorEPC
));
4990 gen_mtc0_store32(t0
, offsetof(CPUState
, CP0_DESAVE
));
4996 /* Stop translation as we may have switched the execution mode */
4997 ctx
->bstate
= BS_STOP
;
5002 LOG_DISAS("dmtc0 %s (reg %d sel %d)\n", rn
, reg
, sel
);
5003 /* For simplicity assume that all writes can cause interrupts. */
5006 ctx
->bstate
= BS_STOP
;
5011 LOG_DISAS("dmtc0 %s (reg %d sel %d)\n", rn
, reg
, sel
);
5012 generate_exception(ctx
, EXCP_RI
);
5014 #endif /* TARGET_MIPS64 */
5016 static void gen_mftr(CPUState
*env
, DisasContext
*ctx
, int rt
, int rd
,
5017 int u
, int sel
, int h
)
5019 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
5020 TCGv t0
= tcg_temp_local_new();
5022 if ((env
->CP0_VPEConf0
& (1 << CP0VPEC0_MVP
)) == 0 &&
5023 ((env
->tcs
[other_tc
].CP0_TCBind
& (0xf << CP0TCBd_CurVPE
)) !=
5024 (env
->active_tc
.CP0_TCBind
& (0xf << CP0TCBd_CurVPE
))))
5025 tcg_gen_movi_tl(t0
, -1);
5026 else if ((env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
)) >
5027 (env
->mvp
->CP0_MVPConf0
& (0xff << CP0MVPC0_PTC
)))
5028 tcg_gen_movi_tl(t0
, -1);
5034 gen_helper_mftc0_tcstatus(t0
);
5037 gen_helper_mftc0_tcbind(t0
);
5040 gen_helper_mftc0_tcrestart(t0
);
5043 gen_helper_mftc0_tchalt(t0
);
5046 gen_helper_mftc0_tccontext(t0
);
5049 gen_helper_mftc0_tcschedule(t0
);
5052 gen_helper_mftc0_tcschefback(t0
);
5055 gen_mfc0(env
, ctx
, t0
, rt
, sel
);
5062 gen_helper_mftc0_entryhi(t0
);
5065 gen_mfc0(env
, ctx
, t0
, rt
, sel
);
5071 gen_helper_mftc0_status(t0
);
5074 gen_mfc0(env
, ctx
, t0
, rt
, sel
);
5080 gen_helper_mftc0_debug(t0
);
5083 gen_mfc0(env
, ctx
, t0
, rt
, sel
);
5088 gen_mfc0(env
, ctx
, t0
, rt
, sel
);
5090 } else switch (sel
) {
5091 /* GPR registers. */
5093 gen_helper_1i(mftgpr
, t0
, rt
);
5095 /* Auxiliary CPU registers */
5099 gen_helper_1i(mftlo
, t0
, 0);
5102 gen_helper_1i(mfthi
, t0
, 0);
5105 gen_helper_1i(mftacx
, t0
, 0);
5108 gen_helper_1i(mftlo
, t0
, 1);
5111 gen_helper_1i(mfthi
, t0
, 1);
5114 gen_helper_1i(mftacx
, t0
, 1);
5117 gen_helper_1i(mftlo
, t0
, 2);
5120 gen_helper_1i(mfthi
, t0
, 2);
5123 gen_helper_1i(mftacx
, t0
, 2);
5126 gen_helper_1i(mftlo
, t0
, 3);
5129 gen_helper_1i(mfthi
, t0
, 3);
5132 gen_helper_1i(mftacx
, t0
, 3);
5135 gen_helper_mftdsp(t0
);
5141 /* Floating point (COP1). */
5143 /* XXX: For now we support only a single FPU context. */
5145 TCGv_i32 fp0
= tcg_temp_new_i32();
5147 gen_load_fpr32(fp0
, rt
);
5148 tcg_gen_ext_i32_tl(t0
, fp0
);
5149 tcg_temp_free_i32(fp0
);
5151 TCGv_i32 fp0
= tcg_temp_new_i32();
5153 gen_load_fpr32h(fp0
, rt
);
5154 tcg_gen_ext_i32_tl(t0
, fp0
);
5155 tcg_temp_free_i32(fp0
);
5159 /* XXX: For now we support only a single FPU context. */
5160 gen_helper_1i(cfc1
, t0
, rt
);
5162 /* COP2: Not implemented. */
5169 LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt
, u
, sel
, h
);
5170 gen_store_gpr(t0
, rd
);
5176 LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt
, u
, sel
, h
);
5177 generate_exception(ctx
, EXCP_RI
);
5180 static void gen_mttr(CPUState
*env
, DisasContext
*ctx
, int rd
, int rt
,
5181 int u
, int sel
, int h
)
5183 int other_tc
= env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
);
5184 TCGv t0
= tcg_temp_local_new();
5186 gen_load_gpr(t0
, rt
);
5187 if ((env
->CP0_VPEConf0
& (1 << CP0VPEC0_MVP
)) == 0 &&
5188 ((env
->tcs
[other_tc
].CP0_TCBind
& (0xf << CP0TCBd_CurVPE
)) !=
5189 (env
->active_tc
.CP0_TCBind
& (0xf << CP0TCBd_CurVPE
))))
5191 else if ((env
->CP0_VPEControl
& (0xff << CP0VPECo_TargTC
)) >
5192 (env
->mvp
->CP0_MVPConf0
& (0xff << CP0MVPC0_PTC
)))
5199 gen_helper_mttc0_tcstatus(t0
);
5202 gen_helper_mttc0_tcbind(t0
);
5205 gen_helper_mttc0_tcrestart(t0
);
5208 gen_helper_mttc0_tchalt(t0
);
5211 gen_helper_mttc0_tccontext(t0
);
5214 gen_helper_mttc0_tcschedule(t0
);
5217 gen_helper_mttc0_tcschefback(t0
);
5220 gen_mtc0(env
, ctx
, t0
, rd
, sel
);
5227 gen_helper_mttc0_entryhi(t0
);
5230 gen_mtc0(env
, ctx
, t0
, rd
, sel
);
5236 gen_helper_mttc0_status(t0
);
5239 gen_mtc0(env
, ctx
, t0
, rd
, sel
);
5245 gen_helper_mttc0_debug(t0
);
5248 gen_mtc0(env
, ctx
, t0
, rd
, sel
);
5253 gen_mtc0(env
, ctx
, t0
, rd
, sel
);
5255 } else switch (sel
) {
5256 /* GPR registers. */
5258 gen_helper_1i(mttgpr
, t0
, rd
);
5260 /* Auxiliary CPU registers */
5264 gen_helper_1i(mttlo
, t0
, 0);
5267 gen_helper_1i(mtthi
, t0
, 0);
5270 gen_helper_1i(mttacx
, t0
, 0);
5273 gen_helper_1i(mttlo
, t0
, 1);
5276 gen_helper_1i(mtthi
, t0
, 1);
5279 gen_helper_1i(mttacx
, t0
, 1);
5282 gen_helper_1i(mttlo
, t0
, 2);
5285 gen_helper_1i(mtthi
, t0
, 2);
5288 gen_helper_1i(mttacx
, t0
, 2);
5291 gen_helper_1i(mttlo
, t0
, 3);
5294 gen_helper_1i(mtthi
, t0
, 3);
5297 gen_helper_1i(mttacx
, t0
, 3);
5300 gen_helper_mttdsp(t0
);
5306 /* Floating point (COP1). */
5308 /* XXX: For now we support only a single FPU context. */
5310 TCGv_i32 fp0
= tcg_temp_new_i32();
5312 tcg_gen_trunc_tl_i32(fp0
, t0
);
5313 gen_store_fpr32(fp0
, rd
);
5314 tcg_temp_free_i32(fp0
);
5316 TCGv_i32 fp0
= tcg_temp_new_i32();
5318 tcg_gen_trunc_tl_i32(fp0
, t0
);
5319 gen_store_fpr32h(fp0
, rd
);
5320 tcg_temp_free_i32(fp0
);
5324 /* XXX: For now we support only a single FPU context. */
5325 gen_helper_1i(ctc1
, t0
, rd
);
5327 /* COP2: Not implemented. */
5334 LOG_DISAS("mttr (reg %d u %d sel %d h %d)\n", rd
, u
, sel
, h
);
5340 LOG_DISAS("mttr (reg %d u %d sel %d h %d)\n", rd
, u
, sel
, h
);
5341 generate_exception(ctx
, EXCP_RI
);
5344 static void gen_cp0 (CPUState
*env
, DisasContext
*ctx
, uint32_t opc
, int rt
, int rd
)
5346 const char *opn
= "ldst";
5355 TCGv t0
= tcg_temp_local_new();
5357 gen_mfc0(env
, ctx
, t0
, rd
, ctx
->opcode
& 0x7);
5358 gen_store_gpr(t0
, rt
);
5365 TCGv t0
= tcg_temp_local_new();
5367 gen_load_gpr(t0
, rt
);
5368 save_cpu_state(ctx
, 1);
5369 gen_mtc0(env
, ctx
, t0
, rd
, ctx
->opcode
& 0x7);
5374 #if defined(TARGET_MIPS64)
5376 check_insn(env
, ctx
, ISA_MIPS3
);
5382 TCGv t0
= tcg_temp_local_new();
5384 gen_dmfc0(env
, ctx
, t0
, rd
, ctx
->opcode
& 0x7);
5385 gen_store_gpr(t0
, rt
);
5391 check_insn(env
, ctx
, ISA_MIPS3
);
5393 TCGv t0
= tcg_temp_local_new();
5395 gen_load_gpr(t0
, rt
);
5396 save_cpu_state(ctx
, 1);
5397 gen_dmtc0(env
, ctx
, t0
, rd
, ctx
->opcode
& 0x7);
5404 check_insn(env
, ctx
, ASE_MT
);
5409 gen_mftr(env
, ctx
, rt
, rd
, (ctx
->opcode
>> 5) & 1,
5410 ctx
->opcode
& 0x7, (ctx
->opcode
>> 4) & 1);
5414 check_insn(env
, ctx
, ASE_MT
);
5415 gen_mttr(env
, ctx
, rd
, rt
, (ctx
->opcode
>> 5) & 1,
5416 ctx
->opcode
& 0x7, (ctx
->opcode
>> 4) & 1);
5421 if (!env
->tlb
->helper_tlbwi
)
5427 if (!env
->tlb
->helper_tlbwr
)
5433 if (!env
->tlb
->helper_tlbp
)
5439 if (!env
->tlb
->helper_tlbr
)
5445 check_insn(env
, ctx
, ISA_MIPS2
);
5446 save_cpu_state(ctx
, 1);
5448 ctx
->bstate
= BS_EXCP
;
5452 check_insn(env
, ctx
, ISA_MIPS32
);
5453 if (!(ctx
->hflags
& MIPS_HFLAG_DM
)) {
5455 generate_exception(ctx
, EXCP_RI
);
5457 save_cpu_state(ctx
, 1);
5459 ctx
->bstate
= BS_EXCP
;
5464 check_insn(env
, ctx
, ISA_MIPS3
| ISA_MIPS32
);
5465 /* If we get an exception, we want to restart at next instruction */
5467 save_cpu_state(ctx
, 1);
5470 ctx
->bstate
= BS_EXCP
;
5475 generate_exception(ctx
, EXCP_RI
);
5478 MIPS_DEBUG("%s %s %d", opn
, regnames
[rt
], rd
);
5480 #endif /* !CONFIG_USER_ONLY */
5482 /* CP1 Branches (before delay slot) */
5483 static void gen_compute_branch1 (CPUState
*env
, DisasContext
*ctx
, uint32_t op
,
5484 int32_t cc
, int32_t offset
)
5486 target_ulong btarget
;
5487 const char *opn
= "cp1 cond branch";
5488 TCGv_i32 t0
= tcg_temp_new_i32();
5491 check_insn(env
, ctx
, ISA_MIPS4
| ISA_MIPS32
);
5493 btarget
= ctx
->pc
+ 4 + offset
;
5497 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5498 tcg_gen_not_i32(t0
, t0
);
5499 tcg_gen_andi_i32(t0
, t0
, 1);
5500 tcg_gen_extu_i32_tl(bcond
, t0
);
5504 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5505 tcg_gen_not_i32(t0
, t0
);
5506 tcg_gen_andi_i32(t0
, t0
, 1);
5507 tcg_gen_extu_i32_tl(bcond
, t0
);
5511 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5512 tcg_gen_andi_i32(t0
, t0
, 1);
5513 tcg_gen_extu_i32_tl(bcond
, t0
);
5517 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5518 tcg_gen_andi_i32(t0
, t0
, 1);
5519 tcg_gen_extu_i32_tl(bcond
, t0
);
5522 ctx
->hflags
|= MIPS_HFLAG_BL
;
5526 TCGv_i32 t1
= tcg_temp_new_i32();
5527 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5528 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+1));
5529 tcg_gen_or_i32(t0
, t0
, t1
);
5530 tcg_temp_free_i32(t1
);
5531 tcg_gen_not_i32(t0
, t0
);
5532 tcg_gen_andi_i32(t0
, t0
, 1);
5533 tcg_gen_extu_i32_tl(bcond
, t0
);
5539 TCGv_i32 t1
= tcg_temp_new_i32();
5540 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5541 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+1));
5542 tcg_gen_or_i32(t0
, t0
, t1
);
5543 tcg_temp_free_i32(t1
);
5544 tcg_gen_andi_i32(t0
, t0
, 1);
5545 tcg_gen_extu_i32_tl(bcond
, t0
);
5551 TCGv_i32 t1
= tcg_temp_new_i32();
5552 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5553 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+1));
5554 tcg_gen_or_i32(t0
, t0
, t1
);
5555 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+2));
5556 tcg_gen_or_i32(t0
, t0
, t1
);
5557 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+3));
5558 tcg_gen_or_i32(t0
, t0
, t1
);
5559 tcg_temp_free_i32(t1
);
5560 tcg_gen_not_i32(t0
, t0
);
5561 tcg_gen_andi_i32(t0
, t0
, 1);
5562 tcg_gen_extu_i32_tl(bcond
, t0
);
5568 TCGv_i32 t1
= tcg_temp_new_i32();
5569 tcg_gen_shri_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5570 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+1));
5571 tcg_gen_or_i32(t0
, t0
, t1
);
5572 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+2));
5573 tcg_gen_or_i32(t0
, t0
, t1
);
5574 tcg_gen_shri_i32(t1
, fpu_fcr31
, get_fp_bit(cc
+3));
5575 tcg_gen_or_i32(t0
, t0
, t1
);
5576 tcg_temp_free_i32(t1
);
5577 tcg_gen_andi_i32(t0
, t0
, 1);
5578 tcg_gen_extu_i32_tl(bcond
, t0
);
5582 ctx
->hflags
|= MIPS_HFLAG_BC
;
5586 generate_exception (ctx
, EXCP_RI
);
5589 MIPS_DEBUG("%s: cond %02x target " TARGET_FMT_lx
, opn
,
5590 ctx
->hflags
, btarget
);
5591 ctx
->btarget
= btarget
;
5594 tcg_temp_free_i32(t0
);
5597 /* Coprocessor 1 (FPU) */
5599 #define FOP(func, fmt) (((fmt) << 21) | (func))
5601 static void gen_cp1 (DisasContext
*ctx
, uint32_t opc
, int rt
, int fs
)
5603 const char *opn
= "cp1 move";
5604 TCGv t0
= tcg_temp_local_new();
5609 TCGv_i32 fp0
= tcg_temp_new_i32();
5611 gen_load_fpr32(fp0
, fs
);
5612 tcg_gen_ext_i32_tl(t0
, fp0
);
5613 tcg_temp_free_i32(fp0
);
5615 gen_store_gpr(t0
, rt
);
5619 gen_load_gpr(t0
, rt
);
5621 TCGv_i32 fp0
= tcg_temp_new_i32();
5623 tcg_gen_trunc_tl_i32(fp0
, t0
);
5624 gen_store_fpr32(fp0
, fs
);
5625 tcg_temp_free_i32(fp0
);
5630 gen_helper_1i(cfc1
, t0
, fs
);
5631 gen_store_gpr(t0
, rt
);
5635 gen_load_gpr(t0
, rt
);
5636 gen_helper_1i(ctc1
, t0
, fs
);
5641 TCGv_i64 fp0
= tcg_temp_new_i64();
5643 gen_load_fpr64(ctx
, fp0
, fs
);
5644 tcg_gen_trunc_i64_tl(t0
, fp0
);
5645 tcg_temp_free_i64(fp0
);
5647 gen_store_gpr(t0
, rt
);
5651 gen_load_gpr(t0
, rt
);
5653 TCGv_i64 fp0
= tcg_temp_new_i64();
5655 tcg_gen_extu_tl_i64(fp0
, t0
);
5656 gen_store_fpr64(ctx
, fp0
, fs
);
5657 tcg_temp_free_i64(fp0
);
5663 TCGv_i32 fp0
= tcg_temp_new_i32();
5665 gen_load_fpr32h(fp0
, fs
);
5666 tcg_gen_ext_i32_tl(t0
, fp0
);
5667 tcg_temp_free_i32(fp0
);
5669 gen_store_gpr(t0
, rt
);
5673 gen_load_gpr(t0
, rt
);
5675 TCGv_i32 fp0
= tcg_temp_new_i32();
5677 tcg_gen_trunc_tl_i32(fp0
, t0
);
5678 gen_store_fpr32h(fp0
, fs
);
5679 tcg_temp_free_i32(fp0
);
5685 generate_exception (ctx
, EXCP_RI
);
5688 MIPS_DEBUG("%s %s %s", opn
, regnames
[rt
], fregnames
[fs
]);
5694 static void gen_movci (DisasContext
*ctx
, int rd
, int rs
, int cc
, int tf
)
5710 l1
= gen_new_label();
5711 t0
= tcg_temp_new_i32();
5712 tcg_gen_andi_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5713 tcg_gen_brcondi_i32(cond
, t0
, 0, l1
);
5715 tcg_gen_movi_tl(cpu_gpr
[rd
], 0);
5717 tcg_gen_mov_tl(cpu_gpr
[rd
], cpu_gpr
[rs
]);
5720 tcg_temp_free_i32(t0
);
5723 static inline void gen_movcf_s (int fs
, int fd
, int cc
, int tf
)
5726 TCGv_i32 t0
= tcg_temp_new_i32();
5727 int l1
= gen_new_label();
5734 tcg_gen_andi_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5735 tcg_gen_brcondi_i32(cond
, t0
, 0, l1
);
5736 gen_load_fpr32(t0
, fs
);
5737 gen_store_fpr32(t0
, fd
);
5739 tcg_temp_free_i32(t0
);
5742 static inline void gen_movcf_d (DisasContext
*ctx
, int fs
, int fd
, int cc
, int tf
)
5745 TCGv_i32 t0
= tcg_temp_new_i32();
5747 int l1
= gen_new_label();
5754 tcg_gen_andi_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5755 tcg_gen_brcondi_i32(cond
, t0
, 0, l1
);
5756 fp0
= tcg_temp_local_new_i64();
5757 gen_load_fpr64(ctx
, fp0
, fs
);
5758 gen_store_fpr64(ctx
, fp0
, fd
);
5759 tcg_temp_free_i64(fp0
);
5761 tcg_temp_free_i32(t0
);
5764 static inline void gen_movcf_ps (int fs
, int fd
, int cc
, int tf
)
5767 TCGv_i32 t0
= tcg_temp_new_i32();
5768 int l1
= gen_new_label();
5769 int l2
= gen_new_label();
5776 tcg_gen_andi_i32(t0
, fpu_fcr31
, get_fp_bit(cc
));
5777 tcg_gen_brcondi_i32(cond
, t0
, 0, l1
);
5778 gen_load_fpr32(t0
, fs
);
5779 gen_store_fpr32(t0
, fd
);
5782 tcg_gen_andi_i32(t0
, fpu_fcr31
, get_fp_bit(cc
+1));
5783 tcg_gen_brcondi_i32(cond
, t0
, 0, l2
);
5784 gen_load_fpr32h(t0
, fs
);
5785 gen_store_fpr32h(t0
, fd
);
5788 tcg_temp_free_i32(t0
);
5792 static void gen_farith (DisasContext
*ctx
, uint32_t op1
,
5793 int ft
, int fs
, int fd
, int cc
)
5795 const char *opn
= "farith";
5796 const char *condnames
[] = {
5814 const char *condnames_abs
[] = {
5832 enum { BINOP
, CMPOP
, OTHEROP
} optype
= OTHEROP
;
5833 uint32_t func
= ctx
->opcode
& 0x3f;
5835 switch (ctx
->opcode
& FOP(0x3f, 0x1f)) {
5838 TCGv_i32 fp0
= tcg_temp_new_i32();
5839 TCGv_i32 fp1
= tcg_temp_new_i32();
5841 gen_load_fpr32(fp0
, fs
);
5842 gen_load_fpr32(fp1
, ft
);
5843 gen_helper_float_add_s(fp0
, fp0
, fp1
);
5844 tcg_temp_free_i32(fp1
);
5845 gen_store_fpr32(fp0
, fd
);
5846 tcg_temp_free_i32(fp0
);
5853 TCGv_i32 fp0
= tcg_temp_new_i32();
5854 TCGv_i32 fp1
= tcg_temp_new_i32();
5856 gen_load_fpr32(fp0
, fs
);
5857 gen_load_fpr32(fp1
, ft
);
5858 gen_helper_float_sub_s(fp0
, fp0
, fp1
);
5859 tcg_temp_free_i32(fp1
);
5860 gen_store_fpr32(fp0
, fd
);
5861 tcg_temp_free_i32(fp0
);
5868 TCGv_i32 fp0
= tcg_temp_new_i32();
5869 TCGv_i32 fp1
= tcg_temp_new_i32();
5871 gen_load_fpr32(fp0
, fs
);
5872 gen_load_fpr32(fp1
, ft
);
5873 gen_helper_float_mul_s(fp0
, fp0
, fp1
);
5874 tcg_temp_free_i32(fp1
);
5875 gen_store_fpr32(fp0
, fd
);
5876 tcg_temp_free_i32(fp0
);
5883 TCGv_i32 fp0
= tcg_temp_new_i32();
5884 TCGv_i32 fp1
= tcg_temp_new_i32();
5886 gen_load_fpr32(fp0
, fs
);
5887 gen_load_fpr32(fp1
, ft
);
5888 gen_helper_float_div_s(fp0
, fp0
, fp1
);
5889 tcg_temp_free_i32(fp1
);
5890 gen_store_fpr32(fp0
, fd
);
5891 tcg_temp_free_i32(fp0
);
5898 TCGv_i32 fp0
= tcg_temp_new_i32();
5900 gen_load_fpr32(fp0
, fs
);
5901 gen_helper_float_sqrt_s(fp0
, fp0
);
5902 gen_store_fpr32(fp0
, fd
);
5903 tcg_temp_free_i32(fp0
);
5909 TCGv_i32 fp0
= tcg_temp_new_i32();
5911 gen_load_fpr32(fp0
, fs
);
5912 gen_helper_float_abs_s(fp0
, fp0
);
5913 gen_store_fpr32(fp0
, fd
);
5914 tcg_temp_free_i32(fp0
);
5920 TCGv_i32 fp0
= tcg_temp_new_i32();
5922 gen_load_fpr32(fp0
, fs
);
5923 gen_store_fpr32(fp0
, fd
);
5924 tcg_temp_free_i32(fp0
);
5930 TCGv_i32 fp0
= tcg_temp_new_i32();
5932 gen_load_fpr32(fp0
, fs
);
5933 gen_helper_float_chs_s(fp0
, fp0
);
5934 gen_store_fpr32(fp0
, fd
);
5935 tcg_temp_free_i32(fp0
);
5940 check_cp1_64bitmode(ctx
);
5942 TCGv_i32 fp32
= tcg_temp_new_i32();
5943 TCGv_i64 fp64
= tcg_temp_new_i64();
5945 gen_load_fpr32(fp32
, fs
);
5946 gen_helper_float_roundl_s(fp64
, fp32
);
5947 tcg_temp_free_i32(fp32
);
5948 gen_store_fpr64(ctx
, fp64
, fd
);
5949 tcg_temp_free_i64(fp64
);
5954 check_cp1_64bitmode(ctx
);
5956 TCGv_i32 fp32
= tcg_temp_new_i32();
5957 TCGv_i64 fp64
= tcg_temp_new_i64();
5959 gen_load_fpr32(fp32
, fs
);
5960 gen_helper_float_truncl_s(fp64
, fp32
);
5961 tcg_temp_free_i32(fp32
);
5962 gen_store_fpr64(ctx
, fp64
, fd
);
5963 tcg_temp_free_i64(fp64
);
5968 check_cp1_64bitmode(ctx
);
5970 TCGv_i32 fp32
= tcg_temp_new_i32();
5971 TCGv_i64 fp64
= tcg_temp_new_i64();
5973 gen_load_fpr32(fp32
, fs
);
5974 gen_helper_float_ceill_s(fp64
, fp32
);
5975 tcg_temp_free_i32(fp32
);
5976 gen_store_fpr64(ctx
, fp64
, fd
);
5977 tcg_temp_free_i64(fp64
);
5982 check_cp1_64bitmode(ctx
);
5984 TCGv_i32 fp32
= tcg_temp_new_i32();
5985 TCGv_i64 fp64
= tcg_temp_new_i64();
5987 gen_load_fpr32(fp32
, fs
);
5988 gen_helper_float_floorl_s(fp64
, fp32
);
5989 tcg_temp_free_i32(fp32
);
5990 gen_store_fpr64(ctx
, fp64
, fd
);
5991 tcg_temp_free_i64(fp64
);
5997 TCGv_i32 fp0
= tcg_temp_new_i32();
5999 gen_load_fpr32(fp0
, fs
);
6000 gen_helper_float_roundw_s(fp0
, fp0
);
6001 gen_store_fpr32(fp0
, fd
);
6002 tcg_temp_free_i32(fp0
);
6008 TCGv_i32 fp0
= tcg_temp_new_i32();
6010 gen_load_fpr32(fp0
, fs
);
6011 gen_helper_float_truncw_s(fp0
, fp0
);
6012 gen_store_fpr32(fp0
, fd
);
6013 tcg_temp_free_i32(fp0
);
6019 TCGv_i32 fp0
= tcg_temp_new_i32();
6021 gen_load_fpr32(fp0
, fs
);
6022 gen_helper_float_ceilw_s(fp0
, fp0
);
6023 gen_store_fpr32(fp0
, fd
);
6024 tcg_temp_free_i32(fp0
);
6030 TCGv_i32 fp0
= tcg_temp_new_i32();
6032 gen_load_fpr32(fp0
, fs
);
6033 gen_helper_float_floorw_s(fp0
, fp0
);
6034 gen_store_fpr32(fp0
, fd
);
6035 tcg_temp_free_i32(fp0
);
6040 gen_movcf_s(fs
, fd
, (ft
>> 2) & 0x7, ft
& 0x1);
6045 int l1
= gen_new_label();
6046 TCGv t0
= tcg_temp_new();
6047 TCGv_i32 fp0
= tcg_temp_local_new_i32();
6049 gen_load_gpr(t0
, ft
);
6050 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, 0, l1
);
6051 gen_load_fpr32(fp0
, fs
);
6052 gen_store_fpr32(fp0
, fd
);
6053 tcg_temp_free_i32(fp0
);
6061 int l1
= gen_new_label();
6062 TCGv t0
= tcg_temp_new();
6063 TCGv_i32 fp0
= tcg_temp_local_new_i32();
6065 gen_load_gpr(t0
, ft
);
6066 tcg_gen_brcondi_tl(TCG_COND_EQ
, t0
, 0, l1
);
6067 gen_load_fpr32(fp0
, fs
);
6068 gen_store_fpr32(fp0
, fd
);
6069 tcg_temp_free_i32(fp0
);
6078 TCGv_i32 fp0
= tcg_temp_new_i32();
6080 gen_load_fpr32(fp0
, fs
);
6081 gen_helper_float_recip_s(fp0
, fp0
);
6082 gen_store_fpr32(fp0
, fd
);
6083 tcg_temp_free_i32(fp0
);
6090 TCGv_i32 fp0
= tcg_temp_new_i32();
6092 gen_load_fpr32(fp0
, fs
);
6093 gen_helper_float_rsqrt_s(fp0
, fp0
);
6094 gen_store_fpr32(fp0
, fd
);
6095 tcg_temp_free_i32(fp0
);
6100 check_cp1_64bitmode(ctx
);
6102 TCGv_i32 fp0
= tcg_temp_new_i32();
6103 TCGv_i32 fp1
= tcg_temp_new_i32();
6105 gen_load_fpr32(fp0
, fs
);
6106 gen_load_fpr32(fp1
, fd
);
6107 gen_helper_float_recip2_s(fp0
, fp0
, fp1
);
6108 tcg_temp_free_i32(fp1
);
6109 gen_store_fpr32(fp0
, fd
);
6110 tcg_temp_free_i32(fp0
);
6115 check_cp1_64bitmode(ctx
);
6117 TCGv_i32 fp0
= tcg_temp_new_i32();
6119 gen_load_fpr32(fp0
, fs
);
6120 gen_helper_float_recip1_s(fp0
, fp0
);
6121 gen_store_fpr32(fp0
, fd
);
6122 tcg_temp_free_i32(fp0
);
6127 check_cp1_64bitmode(ctx
);
6129 TCGv_i32 fp0
= tcg_temp_new_i32();
6131 gen_load_fpr32(fp0
, fs
);
6132 gen_helper_float_rsqrt1_s(fp0
, fp0
);
6133 gen_store_fpr32(fp0
, fd
);
6134 tcg_temp_free_i32(fp0
);
6139 check_cp1_64bitmode(ctx
);
6141 TCGv_i32 fp0
= tcg_temp_new_i32();
6142 TCGv_i32 fp1
= tcg_temp_new_i32();
6144 gen_load_fpr32(fp0
, fs
);
6145 gen_load_fpr32(fp1
, ft
);
6146 gen_helper_float_rsqrt2_s(fp0
, fp0
, fp1
);
6147 tcg_temp_free_i32(fp1
);
6148 gen_store_fpr32(fp0
, fd
);
6149 tcg_temp_free_i32(fp0
);
6154 check_cp1_registers(ctx
, fd
);
6156 TCGv_i32 fp32
= tcg_temp_new_i32();
6157 TCGv_i64 fp64
= tcg_temp_new_i64();
6159 gen_load_fpr32(fp32
, fs
);
6160 gen_helper_float_cvtd_s(fp64
, fp32
);
6161 tcg_temp_free_i32(fp32
);
6162 gen_store_fpr64(ctx
, fp64
, fd
);
6163 tcg_temp_free_i64(fp64
);
6169 TCGv_i32 fp0
= tcg_temp_new_i32();
6171 gen_load_fpr32(fp0
, fs
);
6172 gen_helper_float_cvtw_s(fp0
, fp0
);
6173 gen_store_fpr32(fp0
, fd
);
6174 tcg_temp_free_i32(fp0
);
6179 check_cp1_64bitmode(ctx
);
6181 TCGv_i32 fp32
= tcg_temp_new_i32();
6182 TCGv_i64 fp64
= tcg_temp_new_i64();
6184 gen_load_fpr32(fp32
, fs
);
6185 gen_helper_float_cvtl_s(fp64
, fp32
);
6186 tcg_temp_free_i32(fp32
);
6187 gen_store_fpr64(ctx
, fp64
, fd
);
6188 tcg_temp_free_i64(fp64
);
6193 check_cp1_64bitmode(ctx
);
6195 TCGv_i64 fp64
= tcg_temp_new_i64();
6196 TCGv_i32 fp32_0
= tcg_temp_new_i32();
6197 TCGv_i32 fp32_1
= tcg_temp_new_i32();
6199 gen_load_fpr32(fp32_0
, fs
);
6200 gen_load_fpr32(fp32_1
, ft
);
6201 tcg_gen_concat_i32_i64(fp64
, fp32_0
, fp32_1
);
6202 tcg_temp_free_i32(fp32_1
);
6203 tcg_temp_free_i32(fp32_0
);
6204 gen_store_fpr64(ctx
, fp64
, fd
);
6205 tcg_temp_free_i64(fp64
);
6226 TCGv_i32 fp0
= tcg_temp_new_i32();
6227 TCGv_i32 fp1
= tcg_temp_new_i32();
6229 gen_load_fpr32(fp0
, fs
);
6230 gen_load_fpr32(fp1
, ft
);
6231 if (ctx
->opcode
& (1 << 6)) {
6233 gen_cmpabs_s(func
-48, fp0
, fp1
, cc
);
6234 opn
= condnames_abs
[func
-48];
6236 gen_cmp_s(func
-48, fp0
, fp1
, cc
);
6237 opn
= condnames
[func
-48];
6239 tcg_temp_free_i32(fp0
);
6240 tcg_temp_free_i32(fp1
);
6244 check_cp1_registers(ctx
, fs
| ft
| fd
);
6246 TCGv_i64 fp0
= tcg_temp_new_i64();
6247 TCGv_i64 fp1
= tcg_temp_new_i64();
6249 gen_load_fpr64(ctx
, fp0
, fs
);
6250 gen_load_fpr64(ctx
, fp1
, ft
);
6251 gen_helper_float_add_d(fp0
, fp0
, fp1
);
6252 tcg_temp_free_i64(fp1
);
6253 gen_store_fpr64(ctx
, fp0
, fd
);
6254 tcg_temp_free_i64(fp0
);
6260 check_cp1_registers(ctx
, fs
| ft
| fd
);
6262 TCGv_i64 fp0
= tcg_temp_new_i64();
6263 TCGv_i64 fp1
= tcg_temp_new_i64();
6265 gen_load_fpr64(ctx
, fp0
, fs
);
6266 gen_load_fpr64(ctx
, fp1
, ft
);
6267 gen_helper_float_sub_d(fp0
, fp0
, fp1
);
6268 tcg_temp_free_i64(fp1
);
6269 gen_store_fpr64(ctx
, fp0
, fd
);
6270 tcg_temp_free_i64(fp0
);
6276 check_cp1_registers(ctx
, fs
| ft
| fd
);
6278 TCGv_i64 fp0
= tcg_temp_new_i64();
6279 TCGv_i64 fp1
= tcg_temp_new_i64();
6281 gen_load_fpr64(ctx
, fp0
, fs
);
6282 gen_load_fpr64(ctx
, fp1
, ft
);
6283 gen_helper_float_mul_d(fp0
, fp0
, fp1
);
6284 tcg_temp_free_i64(fp1
);
6285 gen_store_fpr64(ctx
, fp0
, fd
);
6286 tcg_temp_free_i64(fp0
);
6292 check_cp1_registers(ctx
, fs
| ft
| fd
);
6294 TCGv_i64 fp0
= tcg_temp_new_i64();
6295 TCGv_i64 fp1
= tcg_temp_new_i64();
6297 gen_load_fpr64(ctx
, fp0
, fs
);
6298 gen_load_fpr64(ctx
, fp1
, ft
);
6299 gen_helper_float_div_d(fp0
, fp0
, fp1
);
6300 tcg_temp_free_i64(fp1
);
6301 gen_store_fpr64(ctx
, fp0
, fd
);
6302 tcg_temp_free_i64(fp0
);
6308 check_cp1_registers(ctx
, fs
| fd
);
6310 TCGv_i64 fp0
= tcg_temp_new_i64();
6312 gen_load_fpr64(ctx
, fp0
, fs
);
6313 gen_helper_float_sqrt_d(fp0
, fp0
);
6314 gen_store_fpr64(ctx
, fp0
, fd
);
6315 tcg_temp_free_i64(fp0
);
6320 check_cp1_registers(ctx
, fs
| fd
);
6322 TCGv_i64 fp0
= tcg_temp_new_i64();
6324 gen_load_fpr64(ctx
, fp0
, fs
);
6325 gen_helper_float_abs_d(fp0
, fp0
);
6326 gen_store_fpr64(ctx
, fp0
, fd
);
6327 tcg_temp_free_i64(fp0
);
6332 check_cp1_registers(ctx
, fs
| fd
);
6334 TCGv_i64 fp0
= tcg_temp_new_i64();
6336 gen_load_fpr64(ctx
, fp0
, fs
);
6337 gen_store_fpr64(ctx
, fp0
, fd
);
6338 tcg_temp_free_i64(fp0
);
6343 check_cp1_registers(ctx
, fs
| fd
);
6345 TCGv_i64 fp0
= tcg_temp_new_i64();
6347 gen_load_fpr64(ctx
, fp0
, fs
);
6348 gen_helper_float_chs_d(fp0
, fp0
);
6349 gen_store_fpr64(ctx
, fp0
, fd
);
6350 tcg_temp_free_i64(fp0
);
6355 check_cp1_64bitmode(ctx
);
6357 TCGv_i64 fp0
= tcg_temp_new_i64();
6359 gen_load_fpr64(ctx
, fp0
, fs
);
6360 gen_helper_float_roundl_d(fp0
, fp0
);
6361 gen_store_fpr64(ctx
, fp0
, fd
);
6362 tcg_temp_free_i64(fp0
);
6367 check_cp1_64bitmode(ctx
);
6369 TCGv_i64 fp0
= tcg_temp_new_i64();
6371 gen_load_fpr64(ctx
, fp0
, fs
);
6372 gen_helper_float_truncl_d(fp0
, fp0
);
6373 gen_store_fpr64(ctx
, fp0
, fd
);
6374 tcg_temp_free_i64(fp0
);
6379 check_cp1_64bitmode(ctx
);
6381 TCGv_i64 fp0
= tcg_temp_new_i64();
6383 gen_load_fpr64(ctx
, fp0
, fs
);
6384 gen_helper_float_ceill_d(fp0
, fp0
);
6385 gen_store_fpr64(ctx
, fp0
, fd
);
6386 tcg_temp_free_i64(fp0
);
6391 check_cp1_64bitmode(ctx
);
6393 TCGv_i64 fp0
= tcg_temp_new_i64();
6395 gen_load_fpr64(ctx
, fp0
, fs
);
6396 gen_helper_float_floorl_d(fp0
, fp0
);
6397 gen_store_fpr64(ctx
, fp0
, fd
);
6398 tcg_temp_free_i64(fp0
);
6403 check_cp1_registers(ctx
, fs
);
6405 TCGv_i32 fp32
= tcg_temp_new_i32();
6406 TCGv_i64 fp64
= tcg_temp_new_i64();
6408 gen_load_fpr64(ctx
, fp64
, fs
);
6409 gen_helper_float_roundw_d(fp32
, fp64
);
6410 tcg_temp_free_i64(fp64
);
6411 gen_store_fpr32(fp32
, fd
);
6412 tcg_temp_free_i32(fp32
);
6417 check_cp1_registers(ctx
, fs
);
6419 TCGv_i32 fp32
= tcg_temp_new_i32();
6420 TCGv_i64 fp64
= tcg_temp_new_i64();
6422 gen_load_fpr64(ctx
, fp64
, fs
);
6423 gen_helper_float_truncw_d(fp32
, fp64
);
6424 tcg_temp_free_i64(fp64
);
6425 gen_store_fpr32(fp32
, fd
);
6426 tcg_temp_free_i32(fp32
);
6431 check_cp1_registers(ctx
, fs
);
6433 TCGv_i32 fp32
= tcg_temp_new_i32();
6434 TCGv_i64 fp64
= tcg_temp_new_i64();
6436 gen_load_fpr64(ctx
, fp64
, fs
);
6437 gen_helper_float_ceilw_d(fp32
, fp64
);
6438 tcg_temp_free_i64(fp64
);
6439 gen_store_fpr32(fp32
, fd
);
6440 tcg_temp_free_i32(fp32
);
6445 check_cp1_registers(ctx
, fs
);
6447 TCGv_i32 fp32
= tcg_temp_new_i32();
6448 TCGv_i64 fp64
= tcg_temp_new_i64();
6450 gen_load_fpr64(ctx
, fp64
, fs
);
6451 gen_helper_float_floorw_d(fp32
, fp64
);
6452 tcg_temp_free_i64(fp64
);
6453 gen_store_fpr32(fp32
, fd
);
6454 tcg_temp_free_i32(fp32
);
6459 gen_movcf_d(ctx
, fs
, fd
, (ft
>> 2) & 0x7, ft
& 0x1);
6464 int l1
= gen_new_label();
6465 TCGv t0
= tcg_temp_new();
6466 TCGv_i64 fp0
= tcg_temp_local_new_i64();
6468 gen_load_gpr(t0
, ft
);
6469 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, 0, l1
);
6470 gen_load_fpr64(ctx
, fp0
, fs
);
6471 gen_store_fpr64(ctx
, fp0
, fd
);
6472 tcg_temp_free_i64(fp0
);
6480 int l1
= gen_new_label();
6481 TCGv t0
= tcg_temp_new();
6482 TCGv_i64 fp0
= tcg_temp_local_new_i64();
6484 gen_load_gpr(t0
, ft
);
6485 tcg_gen_brcondi_tl(TCG_COND_EQ
, t0
, 0, l1
);
6486 gen_load_fpr64(ctx
, fp0
, fs
);
6487 gen_store_fpr64(ctx
, fp0
, fd
);
6488 tcg_temp_free_i64(fp0
);
6495 check_cp1_64bitmode(ctx
);
6497 TCGv_i64 fp0
= tcg_temp_new_i64();
6499 gen_load_fpr64(ctx
, fp0
, fs
);
6500 gen_helper_float_recip_d(fp0
, fp0
);
6501 gen_store_fpr64(ctx
, fp0
, fd
);
6502 tcg_temp_free_i64(fp0
);
6507 check_cp1_64bitmode(ctx
);
6509 TCGv_i64 fp0
= tcg_temp_new_i64();
6511 gen_load_fpr64(ctx
, fp0
, fs
);
6512 gen_helper_float_rsqrt_d(fp0
, fp0
);
6513 gen_store_fpr64(ctx
, fp0
, fd
);
6514 tcg_temp_free_i64(fp0
);
6519 check_cp1_64bitmode(ctx
);
6521 TCGv_i64 fp0
= tcg_temp_new_i64();
6522 TCGv_i64 fp1
= tcg_temp_new_i64();
6524 gen_load_fpr64(ctx
, fp0
, fs
);
6525 gen_load_fpr64(ctx
, fp1
, ft
);
6526 gen_helper_float_recip2_d(fp0
, fp0
, fp1
);
6527 tcg_temp_free_i64(fp1
);
6528 gen_store_fpr64(ctx
, fp0
, fd
);
6529 tcg_temp_free_i64(fp0
);
6534 check_cp1_64bitmode(ctx
);
6536 TCGv_i64 fp0
= tcg_temp_new_i64();
6538 gen_load_fpr64(ctx
, fp0
, fs
);
6539 gen_helper_float_recip1_d(fp0
, fp0
);
6540 gen_store_fpr64(ctx
, fp0
, fd
);
6541 tcg_temp_free_i64(fp0
);
6546 check_cp1_64bitmode(ctx
);
6548 TCGv_i64 fp0
= tcg_temp_new_i64();
6550 gen_load_fpr64(ctx
, fp0
, fs
);
6551 gen_helper_float_rsqrt1_d(fp0
, fp0
);
6552 gen_store_fpr64(ctx
, fp0
, fd
);
6553 tcg_temp_free_i64(fp0
);
6558 check_cp1_64bitmode(ctx
);
6560 TCGv_i64 fp0
= tcg_temp_new_i64();
6561 TCGv_i64 fp1
= tcg_temp_new_i64();
6563 gen_load_fpr64(ctx
, fp0
, fs
);
6564 gen_load_fpr64(ctx
, fp1
, ft
);
6565 gen_helper_float_rsqrt2_d(fp0
, fp0
, fp1
);
6566 tcg_temp_free_i64(fp1
);
6567 gen_store_fpr64(ctx
, fp0
, fd
);
6568 tcg_temp_free_i64(fp0
);
6589 TCGv_i64 fp0
= tcg_temp_new_i64();
6590 TCGv_i64 fp1
= tcg_temp_new_i64();
6592 gen_load_fpr64(ctx
, fp0
, fs
);
6593 gen_load_fpr64(ctx
, fp1
, ft
);
6594 if (ctx
->opcode
& (1 << 6)) {
6596 check_cp1_registers(ctx
, fs
| ft
);
6597 gen_cmpabs_d(func
-48, fp0
, fp1
, cc
);
6598 opn
= condnames_abs
[func
-48];
6600 check_cp1_registers(ctx
, fs
| ft
);
6601 gen_cmp_d(func
-48, fp0
, fp1
, cc
);
6602 opn
= condnames
[func
-48];
6604 tcg_temp_free_i64(fp0
);
6605 tcg_temp_free_i64(fp1
);
6609 check_cp1_registers(ctx
, fs
);
6611 TCGv_i32 fp32
= tcg_temp_new_i32();
6612 TCGv_i64 fp64
= tcg_temp_new_i64();
6614 gen_load_fpr64(ctx
, fp64
, fs
);
6615 gen_helper_float_cvts_d(fp32
, fp64
);
6616 tcg_temp_free_i64(fp64
);
6617 gen_store_fpr32(fp32
, fd
);
6618 tcg_temp_free_i32(fp32
);
6623 check_cp1_registers(ctx
, fs
);
6625 TCGv_i32 fp32
= tcg_temp_new_i32();
6626 TCGv_i64 fp64
= tcg_temp_new_i64();
6628 gen_load_fpr64(ctx
, fp64
, fs
);
6629 gen_helper_float_cvtw_d(fp32
, fp64
);
6630 tcg_temp_free_i64(fp64
);
6631 gen_store_fpr32(fp32
, fd
);
6632 tcg_temp_free_i32(fp32
);
6637 check_cp1_64bitmode(ctx
);
6639 TCGv_i64 fp0
= tcg_temp_new_i64();
6641 gen_load_fpr64(ctx
, fp0
, fs
);
6642 gen_helper_float_cvtl_d(fp0
, fp0
);
6643 gen_store_fpr64(ctx
, fp0
, fd
);
6644 tcg_temp_free_i64(fp0
);
6650 TCGv_i32 fp0
= tcg_temp_new_i32();
6652 gen_load_fpr32(fp0
, fs
);
6653 gen_helper_float_cvts_w(fp0
, fp0
);
6654 gen_store_fpr32(fp0
, fd
);
6655 tcg_temp_free_i32(fp0
);
6660 check_cp1_registers(ctx
, fd
);
6662 TCGv_i32 fp32
= tcg_temp_new_i32();
6663 TCGv_i64 fp64
= tcg_temp_new_i64();
6665 gen_load_fpr32(fp32
, fs
);
6666 gen_helper_float_cvtd_w(fp64
, fp32
);
6667 tcg_temp_free_i32(fp32
);
6668 gen_store_fpr64(ctx
, fp64
, fd
);
6669 tcg_temp_free_i64(fp64
);
6674 check_cp1_64bitmode(ctx
);
6676 TCGv_i32 fp32
= tcg_temp_new_i32();
6677 TCGv_i64 fp64
= tcg_temp_new_i64();
6679 gen_load_fpr64(ctx
, fp64
, fs
);
6680 gen_helper_float_cvts_l(fp32
, fp64
);
6681 tcg_temp_free_i64(fp64
);
6682 gen_store_fpr32(fp32
, fd
);
6683 tcg_temp_free_i32(fp32
);
6688 check_cp1_64bitmode(ctx
);
6690 TCGv_i64 fp0
= tcg_temp_new_i64();
6692 gen_load_fpr64(ctx
, fp0
, fs
);
6693 gen_helper_float_cvtd_l(fp0
, fp0
);
6694 gen_store_fpr64(ctx
, fp0
, fd
);
6695 tcg_temp_free_i64(fp0
);
6700 check_cp1_64bitmode(ctx
);
6702 TCGv_i64 fp0
= tcg_temp_new_i64();
6704 gen_load_fpr64(ctx
, fp0
, fs
);
6705 gen_helper_float_cvtps_pw(fp0
, fp0
);
6706 gen_store_fpr64(ctx
, fp0
, fd
);
6707 tcg_temp_free_i64(fp0
);
6712 check_cp1_64bitmode(ctx
);
6714 TCGv_i64 fp0
= tcg_temp_new_i64();
6715 TCGv_i64 fp1
= tcg_temp_new_i64();
6717 gen_load_fpr64(ctx
, fp0
, fs
);
6718 gen_load_fpr64(ctx
, fp1
, ft
);
6719 gen_helper_float_add_ps(fp0
, fp0
, fp1
);
6720 tcg_temp_free_i64(fp1
);
6721 gen_store_fpr64(ctx
, fp0
, fd
);
6722 tcg_temp_free_i64(fp0
);
6727 check_cp1_64bitmode(ctx
);
6729 TCGv_i64 fp0
= tcg_temp_new_i64();
6730 TCGv_i64 fp1
= tcg_temp_new_i64();
6732 gen_load_fpr64(ctx
, fp0
, fs
);
6733 gen_load_fpr64(ctx
, fp1
, ft
);
6734 gen_helper_float_sub_ps(fp0
, fp0
, fp1
);
6735 tcg_temp_free_i64(fp1
);
6736 gen_store_fpr64(ctx
, fp0
, fd
);
6737 tcg_temp_free_i64(fp0
);
6742 check_cp1_64bitmode(ctx
);
6744 TCGv_i64 fp0
= tcg_temp_new_i64();
6745 TCGv_i64 fp1
= tcg_temp_new_i64();
6747 gen_load_fpr64(ctx
, fp0
, fs
);
6748 gen_load_fpr64(ctx
, fp1
, ft
);
6749 gen_helper_float_mul_ps(fp0
, fp0
, fp1
);
6750 tcg_temp_free_i64(fp1
);
6751 gen_store_fpr64(ctx
, fp0
, fd
);
6752 tcg_temp_free_i64(fp0
);
6757 check_cp1_64bitmode(ctx
);
6759 TCGv_i64 fp0
= tcg_temp_new_i64();
6761 gen_load_fpr64(ctx
, fp0
, fs
);
6762 gen_helper_float_abs_ps(fp0
, fp0
);
6763 gen_store_fpr64(ctx
, fp0
, fd
);
6764 tcg_temp_free_i64(fp0
);
6769 check_cp1_64bitmode(ctx
);
6771 TCGv_i64 fp0
= tcg_temp_new_i64();
6773 gen_load_fpr64(ctx
, fp0
, fs
);
6774 gen_store_fpr64(ctx
, fp0
, fd
);
6775 tcg_temp_free_i64(fp0
);
6780 check_cp1_64bitmode(ctx
);
6782 TCGv_i64 fp0
= tcg_temp_new_i64();
6784 gen_load_fpr64(ctx
, fp0
, fs
);
6785 gen_helper_float_chs_ps(fp0
, fp0
);
6786 gen_store_fpr64(ctx
, fp0
, fd
);
6787 tcg_temp_free_i64(fp0
);
6792 check_cp1_64bitmode(ctx
);
6793 gen_movcf_ps(fs
, fd
, (ft
>> 2) & 0x7, ft
& 0x1);
6797 check_cp1_64bitmode(ctx
);
6799 int l1
= gen_new_label();
6800 TCGv t0
= tcg_temp_new();
6801 TCGv_i32 fp0
= tcg_temp_local_new_i32();
6802 TCGv_i32 fph0
= tcg_temp_local_new_i32();
6804 gen_load_gpr(t0
, ft
);
6805 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, 0, l1
);
6806 gen_load_fpr32(fp0
, fs
);
6807 gen_load_fpr32h(fph0
, fs
);
6808 gen_store_fpr32(fp0
, fd
);
6809 gen_store_fpr32h(fph0
, fd
);
6810 tcg_temp_free_i32(fp0
);
6811 tcg_temp_free_i32(fph0
);
6818 check_cp1_64bitmode(ctx
);
6820 int l1
= gen_new_label();
6821 TCGv t0
= tcg_temp_new();
6822 TCGv_i32 fp0
= tcg_temp_local_new_i32();
6823 TCGv_i32 fph0
= tcg_temp_local_new_i32();
6825 gen_load_gpr(t0
, ft
);
6826 tcg_gen_brcondi_tl(TCG_COND_EQ
, t0
, 0, l1
);
6827 gen_load_fpr32(fp0
, fs
);
6828 gen_load_fpr32h(fph0
, fs
);
6829 gen_store_fpr32(fp0
, fd
);
6830 gen_store_fpr32h(fph0
, fd
);
6831 tcg_temp_free_i32(fp0
);
6832 tcg_temp_free_i32(fph0
);
6839 check_cp1_64bitmode(ctx
);
6841 TCGv_i64 fp0
= tcg_temp_new_i64();
6842 TCGv_i64 fp1
= tcg_temp_new_i64();
6844 gen_load_fpr64(ctx
, fp0
, ft
);
6845 gen_load_fpr64(ctx
, fp1
, fs
);
6846 gen_helper_float_addr_ps(fp0
, fp0
, fp1
);
6847 tcg_temp_free_i64(fp1
);
6848 gen_store_fpr64(ctx
, fp0
, fd
);
6849 tcg_temp_free_i64(fp0
);
6854 check_cp1_64bitmode(ctx
);
6856 TCGv_i64 fp0
= tcg_temp_new_i64();
6857 TCGv_i64 fp1
= tcg_temp_new_i64();
6859 gen_load_fpr64(ctx
, fp0
, ft
);
6860 gen_load_fpr64(ctx
, fp1
, fs
);
6861 gen_helper_float_mulr_ps(fp0
, fp0
, fp1
);
6862 tcg_temp_free_i64(fp1
);
6863 gen_store_fpr64(ctx
, fp0
, fd
);
6864 tcg_temp_free_i64(fp0
);
6869 check_cp1_64bitmode(ctx
);
6871 TCGv_i64 fp0
= tcg_temp_new_i64();
6872 TCGv_i64 fp1
= tcg_temp_new_i64();
6874 gen_load_fpr64(ctx
, fp0
, fs
);
6875 gen_load_fpr64(ctx
, fp1
, fd
);
6876 gen_helper_float_recip2_ps(fp0
, fp0
, fp1
);
6877 tcg_temp_free_i64(fp1
);
6878 gen_store_fpr64(ctx
, fp0
, fd
);
6879 tcg_temp_free_i64(fp0
);
6884 check_cp1_64bitmode(ctx
);
6886 TCGv_i64 fp0
= tcg_temp_new_i64();
6888 gen_load_fpr64(ctx
, fp0
, fs
);
6889 gen_helper_float_recip1_ps(fp0
, fp0
);
6890 gen_store_fpr64(ctx
, fp0
, fd
);
6891 tcg_temp_free_i64(fp0
);
6896 check_cp1_64bitmode(ctx
);
6898 TCGv_i64 fp0
= tcg_temp_new_i64();
6900 gen_load_fpr64(ctx
, fp0
, fs
);
6901 gen_helper_float_rsqrt1_ps(fp0
, fp0
);
6902 gen_store_fpr64(ctx
, fp0
, fd
);
6903 tcg_temp_free_i64(fp0
);
6908 check_cp1_64bitmode(ctx
);
6910 TCGv_i64 fp0
= tcg_temp_new_i64();
6911 TCGv_i64 fp1
= tcg_temp_new_i64();
6913 gen_load_fpr64(ctx
, fp0
, fs
);
6914 gen_load_fpr64(ctx
, fp1
, ft
);
6915 gen_helper_float_rsqrt2_ps(fp0
, fp0
, fp1
);
6916 tcg_temp_free_i64(fp1
);
6917 gen_store_fpr64(ctx
, fp0
, fd
);
6918 tcg_temp_free_i64(fp0
);
6923 check_cp1_64bitmode(ctx
);
6925 TCGv_i32 fp0
= tcg_temp_new_i32();
6927 gen_load_fpr32h(fp0
, fs
);
6928 gen_helper_float_cvts_pu(fp0
, fp0
);
6929 gen_store_fpr32(fp0
, fd
);
6930 tcg_temp_free_i32(fp0
);
6935 check_cp1_64bitmode(ctx
);
6937 TCGv_i64 fp0
= tcg_temp_new_i64();
6939 gen_load_fpr64(ctx
, fp0
, fs
);
6940 gen_helper_float_cvtpw_ps(fp0
, fp0
);
6941 gen_store_fpr64(ctx
, fp0
, fd
);
6942 tcg_temp_free_i64(fp0
);
6947 check_cp1_64bitmode(ctx
);
6949 TCGv_i32 fp0
= tcg_temp_new_i32();
6951 gen_load_fpr32(fp0
, fs
);
6952 gen_helper_float_cvts_pl(fp0
, fp0
);
6953 gen_store_fpr32(fp0
, fd
);
6954 tcg_temp_free_i32(fp0
);
6959 check_cp1_64bitmode(ctx
);
6961 TCGv_i32 fp0
= tcg_temp_new_i32();
6962 TCGv_i32 fp1
= tcg_temp_new_i32();
6964 gen_load_fpr32(fp0
, fs
);
6965 gen_load_fpr32(fp1
, ft
);
6966 gen_store_fpr32h(fp0
, fd
);
6967 gen_store_fpr32(fp1
, fd
);
6968 tcg_temp_free_i32(fp0
);
6969 tcg_temp_free_i32(fp1
);
6974 check_cp1_64bitmode(ctx
);
6976 TCGv_i32 fp0
= tcg_temp_new_i32();
6977 TCGv_i32 fp1
= tcg_temp_new_i32();
6979 gen_load_fpr32(fp0
, fs
);
6980 gen_load_fpr32h(fp1
, ft
);
6981 gen_store_fpr32(fp1
, fd
);
6982 gen_store_fpr32h(fp0
, fd
);
6983 tcg_temp_free_i32(fp0
);
6984 tcg_temp_free_i32(fp1
);
6989 check_cp1_64bitmode(ctx
);
6991 TCGv_i32 fp0
= tcg_temp_new_i32();
6992 TCGv_i32 fp1
= tcg_temp_new_i32();
6994 gen_load_fpr32h(fp0
, fs
);
6995 gen_load_fpr32(fp1
, ft
);
6996 gen_store_fpr32(fp1
, fd
);
6997 gen_store_fpr32h(fp0
, fd
);
6998 tcg_temp_free_i32(fp0
);
6999 tcg_temp_free_i32(fp1
);
7004 check_cp1_64bitmode(ctx
);
7006 TCGv_i32 fp0
= tcg_temp_new_i32();
7007 TCGv_i32 fp1
= tcg_temp_new_i32();
7009 gen_load_fpr32h(fp0
, fs
);
7010 gen_load_fpr32h(fp1
, ft
);
7011 gen_store_fpr32(fp1
, fd
);
7012 gen_store_fpr32h(fp0
, fd
);
7013 tcg_temp_free_i32(fp0
);
7014 tcg_temp_free_i32(fp1
);
7034 check_cp1_64bitmode(ctx
);
7036 TCGv_i64 fp0
= tcg_temp_new_i64();
7037 TCGv_i64 fp1
= tcg_temp_new_i64();
7039 gen_load_fpr64(ctx
, fp0
, fs
);
7040 gen_load_fpr64(ctx
, fp1
, ft
);
7041 if (ctx
->opcode
& (1 << 6)) {
7042 gen_cmpabs_ps(func
-48, fp0
, fp1
, cc
);
7043 opn
= condnames_abs
[func
-48];
7045 gen_cmp_ps(func
-48, fp0
, fp1
, cc
);
7046 opn
= condnames
[func
-48];
7048 tcg_temp_free_i64(fp0
);
7049 tcg_temp_free_i64(fp1
);
7054 generate_exception (ctx
, EXCP_RI
);
7059 MIPS_DEBUG("%s %s, %s, %s", opn
, fregnames
[fd
], fregnames
[fs
], fregnames
[ft
]);
7062 MIPS_DEBUG("%s %s,%s", opn
, fregnames
[fs
], fregnames
[ft
]);
7065 MIPS_DEBUG("%s %s,%s", opn
, fregnames
[fd
], fregnames
[fs
]);
7070 /* Coprocessor 3 (FPU) */
7071 static void gen_flt3_ldst (DisasContext
*ctx
, uint32_t opc
,
7072 int fd
, int fs
, int base
, int index
)
7074 const char *opn
= "extended float load/store";
7076 TCGv t0
= tcg_temp_local_new();
7077 TCGv t1
= tcg_temp_local_new();
7080 gen_load_gpr(t0
, index
);
7081 } else if (index
== 0) {
7082 gen_load_gpr(t0
, base
);
7084 gen_load_gpr(t0
, index
);
7085 gen_op_addr_add(ctx
, t0
, cpu_gpr
[base
]);
7087 /* Don't do NOP if destination is zero: we must perform the actual
7093 TCGv_i32 fp0
= tcg_temp_new_i32();
7095 tcg_gen_qemu_ld32s(t1
, t0
, ctx
->mem_idx
);
7096 tcg_gen_trunc_tl_i32(fp0
, t1
);
7097 gen_store_fpr32(fp0
, fd
);
7098 tcg_temp_free_i32(fp0
);
7104 check_cp1_registers(ctx
, fd
);
7106 TCGv_i64 fp0
= tcg_temp_new_i64();
7108 tcg_gen_qemu_ld64(fp0
, t0
, ctx
->mem_idx
);
7109 gen_store_fpr64(ctx
, fp0
, fd
);
7110 tcg_temp_free_i64(fp0
);
7115 check_cp1_64bitmode(ctx
);
7116 tcg_gen_andi_tl(t0
, t0
, ~0x7);
7118 TCGv_i64 fp0
= tcg_temp_new_i64();
7120 tcg_gen_qemu_ld64(fp0
, t0
, ctx
->mem_idx
);
7121 gen_store_fpr64(ctx
, fp0
, fd
);
7122 tcg_temp_free_i64(fp0
);
7129 TCGv_i32 fp0
= tcg_temp_new_i32();
7131 gen_load_fpr32(fp0
, fs
);
7132 tcg_gen_extu_i32_tl(t1
, fp0
);
7133 tcg_gen_qemu_st32(t1
, t0
, ctx
->mem_idx
);
7134 tcg_temp_free_i32(fp0
);
7141 check_cp1_registers(ctx
, fs
);
7143 TCGv_i64 fp0
= tcg_temp_new_i64();
7145 gen_load_fpr64(ctx
, fp0
, fs
);
7146 tcg_gen_qemu_st64(fp0
, t0
, ctx
->mem_idx
);
7147 tcg_temp_free_i64(fp0
);
7153 check_cp1_64bitmode(ctx
);
7154 tcg_gen_andi_tl(t0
, t0
, ~0x7);
7156 TCGv_i64 fp0
= tcg_temp_new_i64();
7158 gen_load_fpr64(ctx
, fp0
, fs
);
7159 tcg_gen_qemu_st64(fp0
, t0
, ctx
->mem_idx
);
7160 tcg_temp_free_i64(fp0
);
7167 generate_exception(ctx
, EXCP_RI
);
7174 MIPS_DEBUG("%s %s, %s(%s)", opn
, fregnames
[store
? fs
: fd
],
7175 regnames
[index
], regnames
[base
]);
7178 static void gen_flt3_arith (DisasContext
*ctx
, uint32_t opc
,
7179 int fd
, int fr
, int fs
, int ft
)
7181 const char *opn
= "flt3_arith";
7185 check_cp1_64bitmode(ctx
);
7187 TCGv t0
= tcg_temp_local_new();
7188 TCGv_i32 fp0
= tcg_temp_local_new_i32();
7189 TCGv_i32 fph0
= tcg_temp_local_new_i32();
7190 TCGv_i32 fp1
= tcg_temp_local_new_i32();
7191 TCGv_i32 fph1
= tcg_temp_local_new_i32();
7192 int l1
= gen_new_label();
7193 int l2
= gen_new_label();
7195 gen_load_gpr(t0
, fr
);
7196 tcg_gen_andi_tl(t0
, t0
, 0x7);
7197 gen_load_fpr32(fp0
, fs
);
7198 gen_load_fpr32h(fph0
, fs
);
7199 gen_load_fpr32(fp1
, ft
);
7200 gen_load_fpr32h(fph1
, ft
);
7202 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, 0, l1
);
7203 gen_store_fpr32(fp0
, fd
);
7204 gen_store_fpr32h(fph0
, fd
);
7207 tcg_gen_brcondi_tl(TCG_COND_NE
, t0
, 4, l2
);
7209 #ifdef TARGET_WORDS_BIGENDIAN
7210 gen_store_fpr32(fph1
, fd
);
7211 gen_store_fpr32h(fp0
, fd
);
7213 gen_store_fpr32(fph0
, fd
);
7214 gen_store_fpr32h(fp1
, fd
);
7217 tcg_temp_free_i32(fp0
);
7218 tcg_temp_free_i32(fph0
);
7219 tcg_temp_free_i32(fp1
);
7220 tcg_temp_free_i32(fph1
);
7227 TCGv_i32 fp0
= tcg_temp_new_i32();
7228 TCGv_i32 fp1
= tcg_temp_new_i32();
7229 TCGv_i32 fp2
= tcg_temp_new_i32();
7231 gen_load_fpr32(fp0
, fs
);
7232 gen_load_fpr32(fp1
, ft
);
7233 gen_load_fpr32(fp2
, fr
);
7234 gen_helper_float_muladd_s(fp2
, fp0
, fp1
, fp2
);
7235 tcg_temp_free_i32(fp0
);
7236 tcg_temp_free_i32(fp1
);
7237 gen_store_fpr32(fp2
, fd
);
7238 tcg_temp_free_i32(fp2
);
7244 check_cp1_registers(ctx
, fd
| fs
| ft
| fr
);
7246 TCGv_i64 fp0
= tcg_temp_new_i64();
7247 TCGv_i64 fp1
= tcg_temp_new_i64();
7248 TCGv_i64 fp2
= tcg_temp_new_i64();
7250 gen_load_fpr64(ctx
, fp0
, fs
);
7251 gen_load_fpr64(ctx
, fp1
, ft
);
7252 gen_load_fpr64(ctx
, fp2
, fr
);
7253 gen_helper_float_muladd_d(fp2
, fp0
, fp1
, fp2
);
7254 tcg_temp_free_i64(fp0
);
7255 tcg_temp_free_i64(fp1
);
7256 gen_store_fpr64(ctx
, fp2
, fd
);
7257 tcg_temp_free_i64(fp2
);
7262 check_cp1_64bitmode(ctx
);
7264 TCGv_i64 fp0
= tcg_temp_new_i64();
7265 TCGv_i64 fp1
= tcg_temp_new_i64();
7266 TCGv_i64 fp2
= tcg_temp_new_i64();
7268 gen_load_fpr64(ctx
, fp0
, fs
);
7269 gen_load_fpr64(ctx
, fp1
, ft
);
7270 gen_load_fpr64(ctx
, fp2
, fr
);
7271 gen_helper_float_muladd_ps(fp2
, fp0
, fp1
, fp2
);
7272 tcg_temp_free_i64(fp0
);
7273 tcg_temp_free_i64(fp1
);
7274 gen_store_fpr64(ctx
, fp2
, fd
);
7275 tcg_temp_free_i64(fp2
);
7282 TCGv_i32 fp0
= tcg_temp_new_i32();
7283 TCGv_i32 fp1
= tcg_temp_new_i32();
7284 TCGv_i32 fp2
= tcg_temp_new_i32();
7286 gen_load_fpr32(fp0
, fs
);
7287 gen_load_fpr32(fp1
, ft
);
7288 gen_load_fpr32(fp2
, fr
);
7289 gen_helper_float_mulsub_s(fp2
, fp0
, fp1
, fp2
);
7290 tcg_temp_free_i32(fp0
);
7291 tcg_temp_free_i32(fp1
);
7292 gen_store_fpr32(fp2
, fd
);
7293 tcg_temp_free_i32(fp2
);
7299 check_cp1_registers(ctx
, fd
| fs
| ft
| fr
);
7301 TCGv_i64 fp0
= tcg_temp_new_i64();
7302 TCGv_i64 fp1
= tcg_temp_new_i64();
7303 TCGv_i64 fp2
= tcg_temp_new_i64();
7305 gen_load_fpr64(ctx
, fp0
, fs
);
7306 gen_load_fpr64(ctx
, fp1
, ft
);
7307 gen_load_fpr64(ctx
, fp2
, fr
);
7308 gen_helper_float_mulsub_d(fp2
, fp0
, fp1
, fp2
);
7309 tcg_temp_free_i64(fp0
);
7310 tcg_temp_free_i64(fp1
);
7311 gen_store_fpr64(ctx
, fp2
, fd
);
7312 tcg_temp_free_i64(fp2
);
7317 check_cp1_64bitmode(ctx
);
7319 TCGv_i64 fp0
= tcg_temp_new_i64();
7320 TCGv_i64 fp1
= tcg_temp_new_i64();
7321 TCGv_i64 fp2
= tcg_temp_new_i64();
7323 gen_load_fpr64(ctx
, fp0
, fs
);
7324 gen_load_fpr64(ctx
, fp1
, ft
);
7325 gen_load_fpr64(ctx
, fp2
, fr
);
7326 gen_helper_float_mulsub_ps(fp2
, fp0
, fp1
, fp2
);
7327 tcg_temp_free_i64(fp0
);
7328 tcg_temp_free_i64(fp1
);
7329 gen_store_fpr64(ctx
, fp2
, fd
);
7330 tcg_temp_free_i64(fp2
);
7337 TCGv_i32 fp0
= tcg_temp_new_i32();
7338 TCGv_i32 fp1
= tcg_temp_new_i32();
7339 TCGv_i32 fp2
= tcg_temp_new_i32();
7341 gen_load_fpr32(fp0
, fs
);
7342 gen_load_fpr32(fp1
, ft
);
7343 gen_load_fpr32(fp2
, fr
);
7344 gen_helper_float_nmuladd_s(fp2
, fp0
, fp1
, fp2
);
7345 tcg_temp_free_i32(fp0
);
7346 tcg_temp_free_i32(fp1
);
7347 gen_store_fpr32(fp2
, fd
);
7348 tcg_temp_free_i32(fp2
);
7354 check_cp1_registers(ctx
, fd
| fs
| ft
| fr
);
7356 TCGv_i64 fp0
= tcg_temp_new_i64();
7357 TCGv_i64 fp1
= tcg_temp_new_i64();
7358 TCGv_i64 fp2
= tcg_temp_new_i64();
7360 gen_load_fpr64(ctx
, fp0
, fs
);
7361 gen_load_fpr64(ctx
, fp1
, ft
);
7362 gen_load_fpr64(ctx
, fp2
, fr
);
7363 gen_helper_float_nmuladd_d(fp2
, fp0
, fp1
, fp2
);
7364 tcg_temp_free_i64(fp0
);
7365 tcg_temp_free_i64(fp1
);
7366 gen_store_fpr64(ctx
, fp2
, fd
);
7367 tcg_temp_free_i64(fp2
);
7372 check_cp1_64bitmode(ctx
);
7374 TCGv_i64 fp0
= tcg_temp_new_i64();
7375 TCGv_i64 fp1
= tcg_temp_new_i64();
7376 TCGv_i64 fp2
= tcg_temp_new_i64();
7378 gen_load_fpr64(ctx
, fp0
, fs
);
7379 gen_load_fpr64(ctx
, fp1
, ft
);
7380 gen_load_fpr64(ctx
, fp2
, fr
);
7381 gen_helper_float_nmuladd_ps(fp2
, fp0
, fp1
, fp2
);
7382 tcg_temp_free_i64(fp0
);
7383 tcg_temp_free_i64(fp1
);
7384 gen_store_fpr64(ctx
, fp2
, fd
);
7385 tcg_temp_free_i64(fp2
);
7392 TCGv_i32 fp0
= tcg_temp_new_i32();
7393 TCGv_i32 fp1
= tcg_temp_new_i32();
7394 TCGv_i32 fp2
= tcg_temp_new_i32();
7396 gen_load_fpr32(fp0
, fs
);
7397 gen_load_fpr32(fp1
, ft
);
7398 gen_load_fpr32(fp2
, fr
);
7399 gen_helper_float_nmulsub_s(fp2
, fp0
, fp1
, fp2
);
7400 tcg_temp_free_i32(fp0
);
7401 tcg_temp_free_i32(fp1
);
7402 gen_store_fpr32(fp2
, fd
);
7403 tcg_temp_free_i32(fp2
);
7409 check_cp1_registers(ctx
, fd
| fs
| ft
| fr
);
7411 TCGv_i64 fp0
= tcg_temp_new_i64();
7412 TCGv_i64 fp1
= tcg_temp_new_i64();
7413 TCGv_i64 fp2
= tcg_temp_new_i64();
7415 gen_load_fpr64(ctx
, fp0
, fs
);
7416 gen_load_fpr64(ctx
, fp1
, ft
);
7417 gen_load_fpr64(ctx
, fp2
, fr
);
7418 gen_helper_float_nmulsub_d(fp2
, fp0
, fp1
, fp2
);
7419 tcg_temp_free_i64(fp0
);
7420 tcg_temp_free_i64(fp1
);
7421 gen_store_fpr64(ctx
, fp2
, fd
);
7422 tcg_temp_free_i64(fp2
);
7427 check_cp1_64bitmode(ctx
);
7429 TCGv_i64 fp0
= tcg_temp_new_i64();
7430 TCGv_i64 fp1
= tcg_temp_new_i64();
7431 TCGv_i64 fp2
= tcg_temp_new_i64();
7433 gen_load_fpr64(ctx
, fp0
, fs
);
7434 gen_load_fpr64(ctx
, fp1
, ft
);
7435 gen_load_fpr64(ctx
, fp2
, fr
);
7436 gen_helper_float_nmulsub_ps(fp2
, fp0
, fp1
, fp2
);
7437 tcg_temp_free_i64(fp0
);
7438 tcg_temp_free_i64(fp1
);
7439 gen_store_fpr64(ctx
, fp2
, fd
);
7440 tcg_temp_free_i64(fp2
);
7446 generate_exception (ctx
, EXCP_RI
);
7449 MIPS_DEBUG("%s %s, %s, %s, %s", opn
, fregnames
[fd
], fregnames
[fr
],
7450 fregnames
[fs
], fregnames
[ft
]);
7453 /* ISA extensions (ASEs) */
7454 /* MIPS16 extension to MIPS32 */
7455 /* SmartMIPS extension to MIPS32 */
7457 #if defined(TARGET_MIPS64)
7459 /* MDMX extension to MIPS64 */
7463 static void decode_opc (CPUState
*env
, DisasContext
*ctx
)
7467 uint32_t op
, op1
, op2
;
7470 /* make sure instructions are on a word boundary */
7471 if (ctx
->pc
& 0x3) {
7472 env
->CP0_BadVAddr
= ctx
->pc
;
7473 generate_exception(ctx
, EXCP_AdEL
);
7477 /* Handle blikely not taken case */
7478 if ((ctx
->hflags
& MIPS_HFLAG_BMASK
) == MIPS_HFLAG_BL
) {
7479 int l1
= gen_new_label();
7481 MIPS_DEBUG("blikely condition (" TARGET_FMT_lx
")", ctx
->pc
+ 4);
7482 tcg_gen_brcondi_tl(TCG_COND_NE
, bcond
, 0, l1
);
7483 tcg_gen_movi_i32(hflags
, ctx
->hflags
& ~MIPS_HFLAG_BMASK
);
7484 gen_goto_tb(ctx
, 1, ctx
->pc
+ 4);
7487 op
= MASK_OP_MAJOR(ctx
->opcode
);
7488 rs
= (ctx
->opcode
>> 21) & 0x1f;
7489 rt
= (ctx
->opcode
>> 16) & 0x1f;
7490 rd
= (ctx
->opcode
>> 11) & 0x1f;
7491 sa
= (ctx
->opcode
>> 6) & 0x1f;
7492 imm
= (int16_t)ctx
->opcode
;
7495 op1
= MASK_SPECIAL(ctx
->opcode
);
7497 case OPC_SLL
: /* Arithmetic with immediate */
7498 case OPC_SRL
... OPC_SRA
:
7499 gen_arith_imm(env
, ctx
, op1
, rd
, rt
, sa
);
7501 case OPC_MOVZ
... OPC_MOVN
:
7502 check_insn(env
, ctx
, ISA_MIPS4
| ISA_MIPS32
);
7503 case OPC_SLLV
: /* Arithmetic */
7504 case OPC_SRLV
... OPC_SRAV
:
7505 case OPC_ADD
... OPC_NOR
:
7506 case OPC_SLT
... OPC_SLTU
:
7507 gen_arith(env
, ctx
, op1
, rd
, rs
, rt
);
7509 case OPC_MULT
... OPC_DIVU
:
7511 check_insn(env
, ctx
, INSN_VR54XX
);
7512 op1
= MASK_MUL_VR54XX(ctx
->opcode
);
7513 gen_mul_vr54xx(ctx
, op1
, rd
, rs
, rt
);
7515 gen_muldiv(ctx
, op1
, rs
, rt
);
7517 case OPC_JR
... OPC_JALR
:
7518 gen_compute_branch(ctx
, op1
, rs
, rd
, sa
);
7520 case OPC_TGE
... OPC_TEQ
: /* Traps */
7522 gen_trap(ctx
, op1
, rs
, rt
, -1);
7524 case OPC_MFHI
: /* Move from HI/LO */
7526 gen_HILO(ctx
, op1
, rd
);
7529 case OPC_MTLO
: /* Move to HI/LO */
7530 gen_HILO(ctx
, op1
, rs
);
7532 case OPC_PMON
: /* Pmon entry point, also R4010 selsl */
7533 #ifdef MIPS_STRICT_STANDARD
7534 MIPS_INVAL("PMON / selsl");
7535 generate_exception(ctx
, EXCP_RI
);
7537 gen_helper_0i(pmon
, sa
);
7541 generate_exception(ctx
, EXCP_SYSCALL
);
7544 generate_exception(ctx
, EXCP_BREAK
);
7547 #ifdef MIPS_STRICT_STANDARD
7549 generate_exception(ctx
, EXCP_RI
);
7551 /* Implemented as RI exception for now. */
7552 MIPS_INVAL("spim (unofficial)");
7553 generate_exception(ctx
, EXCP_RI
);
7561 check_insn(env
, ctx
, ISA_MIPS4
| ISA_MIPS32
);
7562 if (env
->CP0_Config1
& (1 << CP0C1_FP
)) {
7563 save_cpu_state(ctx
, 1);
7564 check_cp1_enabled(ctx
);
7565 gen_movci(ctx
, rd
, rs
, (ctx
->opcode
>> 18) & 0x7,
7566 (ctx
->opcode
>> 16) & 1);
7568 generate_exception_err(ctx
, EXCP_CpU
, 1);
7572 #if defined(TARGET_MIPS64)
7573 /* MIPS64 specific opcodes */
7575 case OPC_DSRL
... OPC_DSRA
:
7577 case OPC_DSRL32
... OPC_DSRA32
:
7578 check_insn(env
, ctx
, ISA_MIPS3
);
7580 gen_arith_imm(env
, ctx
, op1
, rd
, rt
, sa
);
7583 case OPC_DSRLV
... OPC_DSRAV
:
7584 case OPC_DADD
... OPC_DSUBU
:
7585 check_insn(env
, ctx
, ISA_MIPS3
);
7587 gen_arith(env
, ctx
, op1
, rd
, rs
, rt
);
7589 case OPC_DMULT
... OPC_DDIVU
:
7590 check_insn(env
, ctx
, ISA_MIPS3
);
7592 gen_muldiv(ctx
, op1
, rs
, rt
);
7595 default: /* Invalid */
7596 MIPS_INVAL("special");
7597 generate_exception(ctx
, EXCP_RI
);
7602 op1
= MASK_SPECIAL2(ctx
->opcode
);
7604 case OPC_MADD
... OPC_MADDU
: /* Multiply and add/sub */
7605 case OPC_MSUB
... OPC_MSUBU
:
7606 check_insn(env
, ctx
, ISA_MIPS32
);
7607 gen_muldiv(ctx
, op1
, rs
, rt
);
7610 gen_arith(env
, ctx
, op1
, rd
, rs
, rt
);
7614 check_insn(env
, ctx
, ISA_MIPS32
);
7615 gen_cl(ctx
, op1
, rd
, rs
);
7618 /* XXX: not clear which exception should be raised
7619 * when in debug mode...
7621 check_insn(env
, ctx
, ISA_MIPS32
);
7622 if (!(ctx
->hflags
& MIPS_HFLAG_DM
)) {
7623 generate_exception(ctx
, EXCP_DBp
);
7625 generate_exception(ctx
, EXCP_DBp
);
7629 #if defined(TARGET_MIPS64)
7632 check_insn(env
, ctx
, ISA_MIPS64
);
7634 gen_cl(ctx
, op1
, rd
, rs
);
7637 default: /* Invalid */
7638 MIPS_INVAL("special2");
7639 generate_exception(ctx
, EXCP_RI
);
7644 op1
= MASK_SPECIAL3(ctx
->opcode
);
7648 check_insn(env
, ctx
, ISA_MIPS32R2
);
7649 gen_bitops(ctx
, op1
, rt
, rs
, sa
, rd
);
7652 check_insn(env
, ctx
, ISA_MIPS32R2
);
7653 op2
= MASK_BSHFL(ctx
->opcode
);
7654 gen_bshfl(ctx
, op2
, rt
, rd
);
7657 check_insn(env
, ctx
, ISA_MIPS32R2
);
7659 TCGv t0
= tcg_temp_local_new();
7663 save_cpu_state(ctx
, 1);
7664 gen_helper_rdhwr_cpunum(t0
);
7667 save_cpu_state(ctx
, 1);
7668 gen_helper_rdhwr_synci_step(t0
);
7671 save_cpu_state(ctx
, 1);
7672 gen_helper_rdhwr_cc(t0
);
7675 save_cpu_state(ctx
, 1);
7676 gen_helper_rdhwr_ccres(t0
);
7679 #if defined(CONFIG_USER_ONLY)
7680 tcg_gen_ld_tl(t0
, cpu_env
, offsetof(CPUState
, tls_value
));
7683 /* XXX: Some CPUs implement this in hardware.
7684 Not supported yet. */
7686 default: /* Invalid */
7687 MIPS_INVAL("rdhwr");
7688 generate_exception(ctx
, EXCP_RI
);
7691 gen_store_gpr(t0
, rt
);
7696 check_insn(env
, ctx
, ASE_MT
);
7698 TCGv t0
= tcg_temp_local_new();
7699 TCGv t1
= tcg_temp_local_new();
7701 gen_load_gpr(t0
, rt
);
7702 gen_load_gpr(t1
, rs
);
7703 gen_helper_fork(t0
, t1
);
7709 check_insn(env
, ctx
, ASE_MT
);
7711 TCGv t0
= tcg_temp_local_new();
7713 gen_load_gpr(t0
, rs
);
7714 gen_helper_yield(t0
, t0
);
7715 gen_store_gpr(t0
, rd
);
7719 #if defined(TARGET_MIPS64)
7720 case OPC_DEXTM
... OPC_DEXT
:
7721 case OPC_DINSM
... OPC_DINS
:
7722 check_insn(env
, ctx
, ISA_MIPS64R2
);
7724 gen_bitops(ctx
, op1
, rt
, rs
, sa
, rd
);
7727 check_insn(env
, ctx
, ISA_MIPS64R2
);
7729 op2
= MASK_DBSHFL(ctx
->opcode
);
7730 gen_bshfl(ctx
, op2
, rt
, rd
);
7733 default: /* Invalid */
7734 MIPS_INVAL("special3");
7735 generate_exception(ctx
, EXCP_RI
);
7740 op1
= MASK_REGIMM(ctx
->opcode
);
7742 case OPC_BLTZ
... OPC_BGEZL
: /* REGIMM branches */
7743 case OPC_BLTZAL
... OPC_BGEZALL
:
7744 gen_compute_branch(ctx
, op1
, rs
, -1, imm
<< 2);
7746 case OPC_TGEI
... OPC_TEQI
: /* REGIMM traps */
7748 gen_trap(ctx
, op1
, rs
, -1, imm
);
7751 check_insn(env
, ctx
, ISA_MIPS32R2
);
7754 default: /* Invalid */
7755 MIPS_INVAL("regimm");
7756 generate_exception(ctx
, EXCP_RI
);
7761 check_cp0_enabled(ctx
);
7762 op1
= MASK_CP0(ctx
->opcode
);
7768 #if defined(TARGET_MIPS64)
7772 #ifndef CONFIG_USER_ONLY
7773 gen_cp0(env
, ctx
, op1
, rt
, rd
);
7774 #endif /* !CONFIG_USER_ONLY */
7776 case OPC_C0_FIRST
... OPC_C0_LAST
:
7777 #ifndef CONFIG_USER_ONLY
7778 gen_cp0(env
, ctx
, MASK_C0(ctx
->opcode
), rt
, rd
);
7779 #endif /* !CONFIG_USER_ONLY */
7782 #ifndef CONFIG_USER_ONLY
7784 TCGv t0
= tcg_temp_local_new();
7786 op2
= MASK_MFMC0(ctx
->opcode
);
7789 check_insn(env
, ctx
, ASE_MT
);
7790 gen_helper_dmt(t0
, t0
);
7793 check_insn(env
, ctx
, ASE_MT
);
7794 gen_helper_emt(t0
, t0
);
7797 check_insn(env
, ctx
, ASE_MT
);
7798 gen_helper_dvpe(t0
, t0
);
7801 check_insn(env
, ctx
, ASE_MT
);
7802 gen_helper_evpe(t0
, t0
);
7805 check_insn(env
, ctx
, ISA_MIPS32R2
);
7806 save_cpu_state(ctx
, 1);
7808 /* Stop translation as we may have switched the execution mode */
7809 ctx
->bstate
= BS_STOP
;
7812 check_insn(env
, ctx
, ISA_MIPS32R2
);
7813 save_cpu_state(ctx
, 1);
7815 /* Stop translation as we may have switched the execution mode */
7816 ctx
->bstate
= BS_STOP
;
7818 default: /* Invalid */
7819 MIPS_INVAL("mfmc0");
7820 generate_exception(ctx
, EXCP_RI
);
7823 gen_store_gpr(t0
, rt
);
7826 #endif /* !CONFIG_USER_ONLY */
7829 check_insn(env
, ctx
, ISA_MIPS32R2
);
7830 gen_load_srsgpr(rt
, rd
);
7833 check_insn(env
, ctx
, ISA_MIPS32R2
);
7834 gen_store_srsgpr(rt
, rd
);
7838 generate_exception(ctx
, EXCP_RI
);
7842 case OPC_ADDI
... OPC_LUI
: /* Arithmetic with immediate opcode */
7843 gen_arith_imm(env
, ctx
, op
, rt
, rs
, imm
);
7845 case OPC_J
... OPC_JAL
: /* Jump */
7846 offset
= (int32_t)(ctx
->opcode
& 0x3FFFFFF) << 2;
7847 gen_compute_branch(ctx
, op
, rs
, rt
, offset
);
7849 case OPC_BEQ
... OPC_BGTZ
: /* Branch */
7850 case OPC_BEQL
... OPC_BGTZL
:
7851 gen_compute_branch(ctx
, op
, rs
, rt
, imm
<< 2);
7853 case OPC_LB
... OPC_LWR
: /* Load and stores */
7854 case OPC_SB
... OPC_SW
:
7858 gen_ldst(ctx
, op
, rt
, rs
, imm
);
7861 check_insn(env
, ctx
, ISA_MIPS3
| ISA_MIPS32
);
7865 check_insn(env
, ctx
, ISA_MIPS4
| ISA_MIPS32
);
7869 /* Floating point (COP1). */
7874 if (env
->CP0_Config1
& (1 << CP0C1_FP
)) {
7875 save_cpu_state(ctx
, 1);
7876 check_cp1_enabled(ctx
);
7877 gen_flt_ldst(ctx
, op
, rt
, rs
, imm
);
7879 generate_exception_err(ctx
, EXCP_CpU
, 1);
7884 if (env
->CP0_Config1
& (1 << CP0C1_FP
)) {
7885 save_cpu_state(ctx
, 1);
7886 check_cp1_enabled(ctx
);
7887 op1
= MASK_CP1(ctx
->opcode
);
7891 check_insn(env
, ctx
, ISA_MIPS32R2
);
7896 gen_cp1(ctx
, op1
, rt
, rd
);
7898 #if defined(TARGET_MIPS64)
7901 check_insn(env
, ctx
, ISA_MIPS3
);
7902 gen_cp1(ctx
, op1
, rt
, rd
);
7908 check_insn(env
, ctx
, ASE_MIPS3D
);
7911 gen_compute_branch1(env
, ctx
, MASK_BC1(ctx
->opcode
),
7912 (rt
>> 2) & 0x7, imm
<< 2);
7919 gen_farith(ctx
, MASK_CP1_FUNC(ctx
->opcode
), rt
, rd
, sa
,
7924 generate_exception (ctx
, EXCP_RI
);
7928 generate_exception_err(ctx
, EXCP_CpU
, 1);
7938 /* COP2: Not implemented. */
7939 generate_exception_err(ctx
, EXCP_CpU
, 2);
7943 if (env
->CP0_Config1
& (1 << CP0C1_FP
)) {
7944 save_cpu_state(ctx
, 1);
7945 check_cp1_enabled(ctx
);
7946 op1
= MASK_CP3(ctx
->opcode
);
7954 gen_flt3_ldst(ctx
, op1
, sa
, rd
, rs
, rt
);
7972 gen_flt3_arith(ctx
, op1
, sa
, rs
, rd
, rt
);
7976 generate_exception (ctx
, EXCP_RI
);
7980 generate_exception_err(ctx
, EXCP_CpU
, 1);
7984 #if defined(TARGET_MIPS64)
7985 /* MIPS64 opcodes */
7987 case OPC_LDL
... OPC_LDR
:
7988 case OPC_SDL
... OPC_SDR
:
7993 check_insn(env
, ctx
, ISA_MIPS3
);
7995 gen_ldst(ctx
, op
, rt
, rs
, imm
);
7997 case OPC_DADDI
... OPC_DADDIU
:
7998 check_insn(env
, ctx
, ISA_MIPS3
);
8000 gen_arith_imm(env
, ctx
, op
, rt
, rs
, imm
);
8004 check_insn(env
, ctx
, ASE_MIPS16
);
8005 /* MIPS16: Not implemented. */
8007 check_insn(env
, ctx
, ASE_MDMX
);
8008 /* MDMX: Not implemented. */
8009 default: /* Invalid */
8010 MIPS_INVAL("major opcode");
8011 generate_exception(ctx
, EXCP_RI
);
8014 if (ctx
->hflags
& MIPS_HFLAG_BMASK
) {
8015 int hflags
= ctx
->hflags
& MIPS_HFLAG_BMASK
;
8016 /* Branches completion */
8017 ctx
->hflags
&= ~MIPS_HFLAG_BMASK
;
8018 ctx
->bstate
= BS_BRANCH
;
8019 save_cpu_state(ctx
, 0);
8020 /* FIXME: Need to clear can_do_io. */
8023 /* unconditional branch */
8024 MIPS_DEBUG("unconditional branch");
8025 gen_goto_tb(ctx
, 0, ctx
->btarget
);
8028 /* blikely taken case */
8029 MIPS_DEBUG("blikely branch taken");
8030 gen_goto_tb(ctx
, 0, ctx
->btarget
);
8033 /* Conditional branch */
8034 MIPS_DEBUG("conditional branch");
8036 int l1
= gen_new_label();
8038 tcg_gen_brcondi_tl(TCG_COND_NE
, bcond
, 0, l1
);
8039 gen_goto_tb(ctx
, 1, ctx
->pc
+ 4);
8041 gen_goto_tb(ctx
, 0, ctx
->btarget
);
8045 /* unconditional branch to register */
8046 MIPS_DEBUG("branch to register");
8047 tcg_gen_mov_tl(cpu_PC
, btarget
);
8051 MIPS_DEBUG("unknown branch");
8058 gen_intermediate_code_internal (CPUState
*env
, TranslationBlock
*tb
,
8062 target_ulong pc_start
;
8063 uint16_t *gen_opc_end
;
8070 qemu_log("search pc %d\n", search_pc
);
8073 /* Leave some spare opc slots for branch handling. */
8074 gen_opc_end
= gen_opc_buf
+ OPC_MAX_SIZE
- 16;
8078 ctx
.bstate
= BS_NONE
;
8079 /* Restore delay slot state from the tb context. */
8080 ctx
.hflags
= (uint32_t)tb
->flags
; /* FIXME: maybe use 64 bits here? */
8081 restore_cpu_state(env
, &ctx
);
8082 #ifdef CONFIG_USER_ONLY
8083 ctx
.mem_idx
= MIPS_HFLAG_UM
;
8085 ctx
.mem_idx
= ctx
.hflags
& MIPS_HFLAG_KSU
;
8088 max_insns
= tb
->cflags
& CF_COUNT_MASK
;
8090 max_insns
= CF_COUNT_MASK
;
8092 qemu_log_mask(CPU_LOG_TB_CPU
, "------------------------------------------------\n");
8093 /* FIXME: This may print out stale hflags from env... */
8094 log_cpu_state_mask(CPU_LOG_TB_CPU
, env
, 0);
8096 LOG_DISAS("\ntb %p idx %d hflags %04x\n", tb
, ctx
.mem_idx
, ctx
.hflags
);
8098 while (ctx
.bstate
== BS_NONE
) {
8099 if (unlikely(!TAILQ_EMPTY(&env
->breakpoints
))) {
8100 TAILQ_FOREACH(bp
, &env
->breakpoints
, entry
) {
8101 if (bp
->pc
== ctx
.pc
) {
8102 save_cpu_state(&ctx
, 1);
8103 ctx
.bstate
= BS_BRANCH
;
8104 gen_helper_0i(raise_exception
, EXCP_DEBUG
);
8105 /* Include the breakpoint location or the tb won't
8106 * be flushed when it must be. */
8108 goto done_generating
;
8114 j
= gen_opc_ptr
- gen_opc_buf
;
8118 gen_opc_instr_start
[lj
++] = 0;
8120 gen_opc_pc
[lj
] = ctx
.pc
;
8121 gen_opc_hflags
[lj
] = ctx
.hflags
& MIPS_HFLAG_BMASK
;
8122 gen_opc_instr_start
[lj
] = 1;
8123 gen_opc_icount
[lj
] = num_insns
;
8125 if (num_insns
+ 1 == max_insns
&& (tb
->cflags
& CF_LAST_IO
))
8127 ctx
.opcode
= ldl_code(ctx
.pc
);
8128 decode_opc(env
, &ctx
);
8132 if (env
->singlestep_enabled
)
8135 if ((ctx
.pc
& (TARGET_PAGE_SIZE
- 1)) == 0)
8138 if (gen_opc_ptr
>= gen_opc_end
)
8141 if (num_insns
>= max_insns
)
8143 #if defined (MIPS_SINGLE_STEP)
8147 if (tb
->cflags
& CF_LAST_IO
)
8149 if (env
->singlestep_enabled
) {
8150 save_cpu_state(&ctx
, ctx
.bstate
== BS_NONE
);
8151 gen_helper_0i(raise_exception
, EXCP_DEBUG
);
8153 switch (ctx
.bstate
) {
8155 gen_helper_interrupt_restart();
8156 gen_goto_tb(&ctx
, 0, ctx
.pc
);
8159 save_cpu_state(&ctx
, 0);
8160 gen_goto_tb(&ctx
, 0, ctx
.pc
);
8163 gen_helper_interrupt_restart();
8172 gen_icount_end(tb
, num_insns
);
8173 *gen_opc_ptr
= INDEX_op_end
;
8175 j
= gen_opc_ptr
- gen_opc_buf
;
8178 gen_opc_instr_start
[lj
++] = 0;
8180 tb
->size
= ctx
.pc
- pc_start
;
8181 tb
->icount
= num_insns
;
8185 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM
)) {
8186 qemu_log("IN: %s\n", lookup_symbol(pc_start
));
8187 log_target_disas(pc_start
, ctx
.pc
- pc_start
, 0);
8190 qemu_log_mask(CPU_LOG_TB_CPU
, "---------------- %d %08x\n", ctx
.bstate
, ctx
.hflags
);
8194 void gen_intermediate_code (CPUState
*env
, struct TranslationBlock
*tb
)
8196 gen_intermediate_code_internal(env
, tb
, 0);
8199 void gen_intermediate_code_pc (CPUState
*env
, struct TranslationBlock
*tb
)
8201 gen_intermediate_code_internal(env
, tb
, 1);
8204 static void fpu_dump_state(CPUState
*env
, FILE *f
,
8205 int (*fpu_fprintf
)(FILE *f
, const char *fmt
, ...),
8209 int is_fpu64
= !!(env
->hflags
& MIPS_HFLAG_F64
);
8211 #define printfpr(fp) \
8214 fpu_fprintf(f, "w:%08x d:%016lx fd:%13g fs:%13g psu: %13g\n", \
8215 (fp)->w[FP_ENDIAN_IDX], (fp)->d, (fp)->fd, \
8216 (fp)->fs[FP_ENDIAN_IDX], (fp)->fs[!FP_ENDIAN_IDX]); \
8219 tmp.w[FP_ENDIAN_IDX] = (fp)->w[FP_ENDIAN_IDX]; \
8220 tmp.w[!FP_ENDIAN_IDX] = ((fp) + 1)->w[FP_ENDIAN_IDX]; \
8221 fpu_fprintf(f, "w:%08x d:%016lx fd:%13g fs:%13g psu:%13g\n", \
8222 tmp.w[FP_ENDIAN_IDX], tmp.d, tmp.fd, \
8223 tmp.fs[FP_ENDIAN_IDX], tmp.fs[!FP_ENDIAN_IDX]); \
8228 fpu_fprintf(f
, "CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d fp_status 0x%08x(0x%02x)\n",
8229 env
->active_fpu
.fcr0
, env
->active_fpu
.fcr31
, is_fpu64
, env
->active_fpu
.fp_status
,
8230 get_float_exception_flags(&env
->active_fpu
.fp_status
));
8231 for (i
= 0; i
< 32; (is_fpu64
) ? i
++ : (i
+= 2)) {
8232 fpu_fprintf(f
, "%3s: ", fregnames
[i
]);
8233 printfpr(&env
->active_fpu
.fpr
[i
]);
8239 #if defined(TARGET_MIPS64) && defined(MIPS_DEBUG_SIGN_EXTENSIONS)
8240 /* Debug help: The architecture requires 32bit code to maintain proper
8241 sign-extended values on 64bit machines. */
8243 #define SIGN_EXT_P(val) ((((val) & ~0x7fffffff) == 0) || (((val) & ~0x7fffffff) == ~0x7fffffff))
8246 cpu_mips_check_sign_extensions (CPUState
*env
, FILE *f
,
8247 int (*cpu_fprintf
)(FILE *f
, const char *fmt
, ...),
8252 if (!SIGN_EXT_P(env
->active_tc
.PC
))
8253 cpu_fprintf(f
, "BROKEN: pc=0x" TARGET_FMT_lx
"\n", env
->active_tc
.PC
);
8254 if (!SIGN_EXT_P(env
->active_tc
.HI
[0]))
8255 cpu_fprintf(f
, "BROKEN: HI=0x" TARGET_FMT_lx
"\n", env
->active_tc
.HI
[0]);
8256 if (!SIGN_EXT_P(env
->active_tc
.LO
[0]))
8257 cpu_fprintf(f
, "BROKEN: LO=0x" TARGET_FMT_lx
"\n", env
->active_tc
.LO
[0]);
8258 if (!SIGN_EXT_P(env
->btarget
))
8259 cpu_fprintf(f
, "BROKEN: btarget=0x" TARGET_FMT_lx
"\n", env
->btarget
);
8261 for (i
= 0; i
< 32; i
++) {
8262 if (!SIGN_EXT_P(env
->active_tc
.gpr
[i
]))
8263 cpu_fprintf(f
, "BROKEN: %s=0x" TARGET_FMT_lx
"\n", regnames
[i
], env
->active_tc
.gpr
[i
]);
8266 if (!SIGN_EXT_P(env
->CP0_EPC
))
8267 cpu_fprintf(f
, "BROKEN: EPC=0x" TARGET_FMT_lx
"\n", env
->CP0_EPC
);
8268 if (!SIGN_EXT_P(env
->CP0_LLAddr
))
8269 cpu_fprintf(f
, "BROKEN: LLAddr=0x" TARGET_FMT_lx
"\n", env
->CP0_LLAddr
);
8273 void cpu_dump_state (CPUState
*env
, FILE *f
,
8274 int (*cpu_fprintf
)(FILE *f
, const char *fmt
, ...),
8279 cpu_fprintf(f
, "pc=0x" TARGET_FMT_lx
" HI=0x" TARGET_FMT_lx
" LO=0x" TARGET_FMT_lx
" ds %04x " TARGET_FMT_lx
" %d\n",
8280 env
->active_tc
.PC
, env
->active_tc
.HI
[0], env
->active_tc
.LO
[0],
8281 env
->hflags
, env
->btarget
, env
->bcond
);
8282 for (i
= 0; i
< 32; i
++) {
8284 cpu_fprintf(f
, "GPR%02d:", i
);
8285 cpu_fprintf(f
, " %s " TARGET_FMT_lx
, regnames
[i
], env
->active_tc
.gpr
[i
]);
8287 cpu_fprintf(f
, "\n");
8290 cpu_fprintf(f
, "CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_FMT_lx
"\n",
8291 env
->CP0_Status
, env
->CP0_Cause
, env
->CP0_EPC
);
8292 cpu_fprintf(f
, " Config0 0x%08x Config1 0x%08x LLAddr 0x" TARGET_FMT_lx
"\n",
8293 env
->CP0_Config0
, env
->CP0_Config1
, env
->CP0_LLAddr
);
8294 if (env
->hflags
& MIPS_HFLAG_FPU
)
8295 fpu_dump_state(env
, f
, cpu_fprintf
, flags
);
8296 #if defined(TARGET_MIPS64) && defined(MIPS_DEBUG_SIGN_EXTENSIONS)
8297 cpu_mips_check_sign_extensions(env
, f
, cpu_fprintf
, flags
);
8301 static void mips_tcg_init(void)
8306 /* Initialize various static tables. */
8310 cpu_env
= tcg_global_reg_new_ptr(TCG_AREG0
, "env");
8311 for (i
= 0; i
< 32; i
++)
8312 cpu_gpr
[i
] = tcg_global_mem_new(TCG_AREG0
,
8313 offsetof(CPUState
, active_tc
.gpr
[i
]),
8315 cpu_PC
= tcg_global_mem_new(TCG_AREG0
,
8316 offsetof(CPUState
, active_tc
.PC
), "PC");
8317 for (i
= 0; i
< MIPS_DSP_ACC
; i
++) {
8318 cpu_HI
[i
] = tcg_global_mem_new(TCG_AREG0
,
8319 offsetof(CPUState
, active_tc
.HI
[i
]),
8321 cpu_LO
[i
] = tcg_global_mem_new(TCG_AREG0
,
8322 offsetof(CPUState
, active_tc
.LO
[i
]),
8324 cpu_ACX
[i
] = tcg_global_mem_new(TCG_AREG0
,
8325 offsetof(CPUState
, active_tc
.ACX
[i
]),
8328 cpu_dspctrl
= tcg_global_mem_new(TCG_AREG0
,
8329 offsetof(CPUState
, active_tc
.DSPControl
),
8331 bcond
= tcg_global_mem_new(TCG_AREG0
,
8332 offsetof(CPUState
, bcond
), "bcond");
8333 btarget
= tcg_global_mem_new(TCG_AREG0
,
8334 offsetof(CPUState
, btarget
), "btarget");
8335 hflags
= tcg_global_mem_new_i32(TCG_AREG0
,
8336 offsetof(CPUState
, hflags
), "hflags");
8338 fpu_fcr0
= tcg_global_mem_new_i32(TCG_AREG0
,
8339 offsetof(CPUState
, active_fpu
.fcr0
),
8341 fpu_fcr31
= tcg_global_mem_new_i32(TCG_AREG0
,
8342 offsetof(CPUState
, active_fpu
.fcr31
),
8345 /* register helpers */
8346 #define GEN_HELPER 2
8352 #include "translate_init.c"
8354 CPUMIPSState
*cpu_mips_init (const char *cpu_model
)
8357 const mips_def_t
*def
;
8359 def
= cpu_mips_find_by_name(cpu_model
);
8362 env
= qemu_mallocz(sizeof(CPUMIPSState
));
8363 env
->cpu_model
= def
;
8366 env
->cpu_model_str
= cpu_model
;
8372 void cpu_reset (CPUMIPSState
*env
)
8374 if (qemu_loglevel_mask(CPU_LOG_RESET
)) {
8375 qemu_log("CPU Reset (CPU %d)\n", env
->cpu_index
);
8376 log_cpu_state(env
, 0);
8379 memset(env
, 0, offsetof(CPUMIPSState
, breakpoints
));
8384 #if defined(CONFIG_USER_ONLY)
8385 env
->hflags
= MIPS_HFLAG_UM
;
8387 if (env
->hflags
& MIPS_HFLAG_BMASK
) {
8388 /* If the exception was raised from a delay slot,
8389 come back to the jump. */
8390 env
->CP0_ErrorEPC
= env
->active_tc
.PC
- 4;
8392 env
->CP0_ErrorEPC
= env
->active_tc
.PC
;
8394 env
->active_tc
.PC
= (int32_t)0xBFC00000;
8396 /* SMP not implemented */
8397 env
->CP0_EBase
= 0x80000000;
8398 env
->CP0_Status
= (1 << CP0St_BEV
) | (1 << CP0St_ERL
);
8399 /* vectored interrupts not implemented, timer on int 7,
8400 no performance counters. */
8401 env
->CP0_IntCtl
= 0xe0000000;
8405 for (i
= 0; i
< 7; i
++) {
8406 env
->CP0_WatchLo
[i
] = 0;
8407 env
->CP0_WatchHi
[i
] = 0x80000000;
8409 env
->CP0_WatchLo
[7] = 0;
8410 env
->CP0_WatchHi
[7] = 0;
8412 /* Count register increments in debug mode, EJTAG version 1 */
8413 env
->CP0_Debug
= (1 << CP0DB_CNT
) | (0x1 << CP0DB_VER
);
8414 env
->hflags
= MIPS_HFLAG_CP0
;
8416 env
->exception_index
= EXCP_NONE
;
8417 cpu_mips_register(env
, env
->cpu_model
);
8420 void gen_pc_load(CPUState
*env
, TranslationBlock
*tb
,
8421 unsigned long searched_pc
, int pc_pos
, void *puc
)
8423 env
->active_tc
.PC
= gen_opc_pc
[pc_pos
];
8424 env
->hflags
&= ~MIPS_HFLAG_BMASK
;
8425 env
->hflags
|= gen_opc_hflags
[pc_pos
];