root / target-mips / translate.c @ aa343735
History | View | Annotate | Download (185.5 kB)
1 | 6af0bf9c | bellard | /*
|
---|---|---|---|
2 | 6af0bf9c | bellard | * MIPS32 emulation for qemu: main translation routines.
|
3 | 5fafdf24 | ths | *
|
4 | 6af0bf9c | bellard | * Copyright (c) 2004-2005 Jocelyn Mayer
|
5 | 6ea83fed | bellard | * Copyright (c) 2006 Marius Groeger (FPU operations)
|
6 | bb8a53ad | ths | * Copyright (c) 2006 Thiemo Seufer (MIPS32R2 support)
|
7 | 6af0bf9c | bellard | *
|
8 | 6af0bf9c | bellard | * This library is free software; you can redistribute it and/or
|
9 | 6af0bf9c | bellard | * modify it under the terms of the GNU Lesser General Public
|
10 | 6af0bf9c | bellard | * License as published by the Free Software Foundation; either
|
11 | 6af0bf9c | bellard | * version 2 of the License, or (at your option) any later version.
|
12 | 6af0bf9c | bellard | *
|
13 | 6af0bf9c | bellard | * This library is distributed in the hope that it will be useful,
|
14 | 6af0bf9c | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 | 6af0bf9c | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16 | 6af0bf9c | bellard | * Lesser General Public License for more details.
|
17 | 6af0bf9c | bellard | *
|
18 | 6af0bf9c | bellard | * You should have received a copy of the GNU Lesser General Public
|
19 | 6af0bf9c | bellard | * License along with this library; if not, write to the Free Software
|
20 | 6af0bf9c | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
21 | 6af0bf9c | bellard | */
|
22 | 6af0bf9c | bellard | |
23 | 6af0bf9c | bellard | #include <stdarg.h> |
24 | 6af0bf9c | bellard | #include <stdlib.h> |
25 | 6af0bf9c | bellard | #include <stdio.h> |
26 | 6af0bf9c | bellard | #include <string.h> |
27 | 6af0bf9c | bellard | #include <inttypes.h> |
28 | 6af0bf9c | bellard | |
29 | 6af0bf9c | bellard | #include "cpu.h" |
30 | 6af0bf9c | bellard | #include "exec-all.h" |
31 | 6af0bf9c | bellard | #include "disas.h" |
32 | 6af0bf9c | bellard | |
33 | eeef26cd | bellard | //#define MIPS_DEBUG_DISAS
|
34 | c570fd16 | ths | //#define MIPS_DEBUG_SIGN_EXTENSIONS
|
35 | 6af0bf9c | bellard | //#define MIPS_SINGLE_STEP
|
36 | 6af0bf9c | bellard | |
37 | c53be334 | bellard | #ifdef USE_DIRECT_JUMP
|
38 | c53be334 | bellard | #define TBPARAM(x)
|
39 | c53be334 | bellard | #else
|
40 | c53be334 | bellard | #define TBPARAM(x) (long)(x) |
41 | c53be334 | bellard | #endif
|
42 | c53be334 | bellard | |
43 | 6af0bf9c | bellard | enum {
|
44 | 6af0bf9c | bellard | #define DEF(s, n, copy_size) INDEX_op_ ## s, |
45 | 6af0bf9c | bellard | #include "opc.h" |
46 | 6af0bf9c | bellard | #undef DEF
|
47 | 6af0bf9c | bellard | NB_OPS, |
48 | 6af0bf9c | bellard | }; |
49 | 6af0bf9c | bellard | |
50 | 6af0bf9c | bellard | static uint16_t *gen_opc_ptr;
|
51 | 6af0bf9c | bellard | static uint32_t *gen_opparam_ptr;
|
52 | 6af0bf9c | bellard | |
53 | 6af0bf9c | bellard | #include "gen-op.h" |
54 | 6af0bf9c | bellard | |
55 | 7a387fff | ths | /* MIPS major opcodes */
|
56 | 7a387fff | ths | #define MASK_OP_MAJOR(op) (op & (0x3F << 26)) |
57 | e37e863f | bellard | |
58 | e37e863f | bellard | enum {
|
59 | e37e863f | bellard | /* indirect opcode tables */
|
60 | 7a387fff | ths | OPC_SPECIAL = (0x00 << 26), |
61 | 7a387fff | ths | OPC_REGIMM = (0x01 << 26), |
62 | 7a387fff | ths | OPC_CP0 = (0x10 << 26), |
63 | 7a387fff | ths | OPC_CP1 = (0x11 << 26), |
64 | 7a387fff | ths | OPC_CP2 = (0x12 << 26), |
65 | 7a387fff | ths | OPC_CP3 = (0x13 << 26), |
66 | 7a387fff | ths | OPC_SPECIAL2 = (0x1C << 26), |
67 | 7a387fff | ths | OPC_SPECIAL3 = (0x1F << 26), |
68 | e37e863f | bellard | /* arithmetic with immediate */
|
69 | 7a387fff | ths | OPC_ADDI = (0x08 << 26), |
70 | 7a387fff | ths | OPC_ADDIU = (0x09 << 26), |
71 | 7a387fff | ths | OPC_SLTI = (0x0A << 26), |
72 | 7a387fff | ths | OPC_SLTIU = (0x0B << 26), |
73 | 7a387fff | ths | OPC_ANDI = (0x0C << 26), |
74 | 7a387fff | ths | OPC_ORI = (0x0D << 26), |
75 | 7a387fff | ths | OPC_XORI = (0x0E << 26), |
76 | 7a387fff | ths | OPC_LUI = (0x0F << 26), |
77 | 7a387fff | ths | OPC_DADDI = (0x18 << 26), |
78 | 7a387fff | ths | OPC_DADDIU = (0x19 << 26), |
79 | e37e863f | bellard | /* Jump and branches */
|
80 | 7a387fff | ths | OPC_J = (0x02 << 26), |
81 | 7a387fff | ths | OPC_JAL = (0x03 << 26), |
82 | 7a387fff | ths | OPC_BEQ = (0x04 << 26), /* Unconditional if rs = rt = 0 (B) */ |
83 | 7a387fff | ths | OPC_BEQL = (0x14 << 26), |
84 | 7a387fff | ths | OPC_BNE = (0x05 << 26), |
85 | 7a387fff | ths | OPC_BNEL = (0x15 << 26), |
86 | 7a387fff | ths | OPC_BLEZ = (0x06 << 26), |
87 | 7a387fff | ths | OPC_BLEZL = (0x16 << 26), |
88 | 7a387fff | ths | OPC_BGTZ = (0x07 << 26), |
89 | 7a387fff | ths | OPC_BGTZL = (0x17 << 26), |
90 | 7a387fff | ths | OPC_JALX = (0x1D << 26), /* MIPS 16 only */ |
91 | e37e863f | bellard | /* Load and stores */
|
92 | 7a387fff | ths | OPC_LDL = (0x1A << 26), |
93 | 7a387fff | ths | OPC_LDR = (0x1B << 26), |
94 | 7a387fff | ths | OPC_LB = (0x20 << 26), |
95 | 7a387fff | ths | OPC_LH = (0x21 << 26), |
96 | 7a387fff | ths | OPC_LWL = (0x22 << 26), |
97 | 7a387fff | ths | OPC_LW = (0x23 << 26), |
98 | 7a387fff | ths | OPC_LBU = (0x24 << 26), |
99 | 7a387fff | ths | OPC_LHU = (0x25 << 26), |
100 | 7a387fff | ths | OPC_LWR = (0x26 << 26), |
101 | 7a387fff | ths | OPC_LWU = (0x27 << 26), |
102 | 7a387fff | ths | OPC_SB = (0x28 << 26), |
103 | 7a387fff | ths | OPC_SH = (0x29 << 26), |
104 | 7a387fff | ths | OPC_SWL = (0x2A << 26), |
105 | 7a387fff | ths | OPC_SW = (0x2B << 26), |
106 | 7a387fff | ths | OPC_SDL = (0x2C << 26), |
107 | 7a387fff | ths | OPC_SDR = (0x2D << 26), |
108 | 7a387fff | ths | OPC_SWR = (0x2E << 26), |
109 | 7a387fff | ths | OPC_LL = (0x30 << 26), |
110 | 7a387fff | ths | OPC_LLD = (0x34 << 26), |
111 | 7a387fff | ths | OPC_LD = (0x37 << 26), |
112 | 7a387fff | ths | OPC_SC = (0x38 << 26), |
113 | 7a387fff | ths | OPC_SCD = (0x3C << 26), |
114 | 7a387fff | ths | OPC_SD = (0x3F << 26), |
115 | e37e863f | bellard | /* Floating point load/store */
|
116 | 7a387fff | ths | OPC_LWC1 = (0x31 << 26), |
117 | 7a387fff | ths | OPC_LWC2 = (0x32 << 26), |
118 | 7a387fff | ths | OPC_LDC1 = (0x35 << 26), |
119 | 7a387fff | ths | OPC_LDC2 = (0x36 << 26), |
120 | 7a387fff | ths | OPC_SWC1 = (0x39 << 26), |
121 | 7a387fff | ths | OPC_SWC2 = (0x3A << 26), |
122 | 7a387fff | ths | OPC_SDC1 = (0x3D << 26), |
123 | 7a387fff | ths | OPC_SDC2 = (0x3E << 26), |
124 | 7a387fff | ths | /* MDMX ASE specific */
|
125 | 7a387fff | ths | OPC_MDMX = (0x1E << 26), |
126 | e37e863f | bellard | /* Cache and prefetch */
|
127 | 7a387fff | ths | OPC_CACHE = (0x2F << 26), |
128 | 7a387fff | ths | OPC_PREF = (0x33 << 26), |
129 | 7a387fff | ths | /* Reserved major opcode */
|
130 | 7a387fff | ths | OPC_MAJOR3B_RESERVED = (0x3B << 26), |
131 | e37e863f | bellard | }; |
132 | e37e863f | bellard | |
133 | e37e863f | bellard | /* MIPS special opcodes */
|
134 | 7a387fff | ths | #define MASK_SPECIAL(op) MASK_OP_MAJOR(op) | (op & 0x3F) |
135 | 7a387fff | ths | |
136 | e37e863f | bellard | enum {
|
137 | e37e863f | bellard | /* Shifts */
|
138 | 7a387fff | ths | OPC_SLL = 0x00 | OPC_SPECIAL,
|
139 | e37e863f | bellard | /* NOP is SLL r0, r0, 0 */
|
140 | e37e863f | bellard | /* SSNOP is SLL r0, r0, 1 */
|
141 | 7a387fff | ths | /* EHB is SLL r0, r0, 3 */
|
142 | 7a387fff | ths | OPC_SRL = 0x02 | OPC_SPECIAL, /* also ROTR */ |
143 | 7a387fff | ths | OPC_SRA = 0x03 | OPC_SPECIAL,
|
144 | 7a387fff | ths | OPC_SLLV = 0x04 | OPC_SPECIAL,
|
145 | e189e748 | ths | OPC_SRLV = 0x06 | OPC_SPECIAL, /* also ROTRV */ |
146 | 7a387fff | ths | OPC_SRAV = 0x07 | OPC_SPECIAL,
|
147 | 7a387fff | ths | OPC_DSLLV = 0x14 | OPC_SPECIAL,
|
148 | 7a387fff | ths | OPC_DSRLV = 0x16 | OPC_SPECIAL, /* also DROTRV */ |
149 | 7a387fff | ths | OPC_DSRAV = 0x17 | OPC_SPECIAL,
|
150 | 7a387fff | ths | OPC_DSLL = 0x38 | OPC_SPECIAL,
|
151 | 7a387fff | ths | OPC_DSRL = 0x3A | OPC_SPECIAL, /* also DROTR */ |
152 | 7a387fff | ths | OPC_DSRA = 0x3B | OPC_SPECIAL,
|
153 | 7a387fff | ths | OPC_DSLL32 = 0x3C | OPC_SPECIAL,
|
154 | 7a387fff | ths | OPC_DSRL32 = 0x3E | OPC_SPECIAL, /* also DROTR32 */ |
155 | 7a387fff | ths | OPC_DSRA32 = 0x3F | OPC_SPECIAL,
|
156 | e37e863f | bellard | /* Multiplication / division */
|
157 | 7a387fff | ths | OPC_MULT = 0x18 | OPC_SPECIAL,
|
158 | 7a387fff | ths | OPC_MULTU = 0x19 | OPC_SPECIAL,
|
159 | 7a387fff | ths | OPC_DIV = 0x1A | OPC_SPECIAL,
|
160 | 7a387fff | ths | OPC_DIVU = 0x1B | OPC_SPECIAL,
|
161 | 7a387fff | ths | OPC_DMULT = 0x1C | OPC_SPECIAL,
|
162 | 7a387fff | ths | OPC_DMULTU = 0x1D | OPC_SPECIAL,
|
163 | 7a387fff | ths | OPC_DDIV = 0x1E | OPC_SPECIAL,
|
164 | 7a387fff | ths | OPC_DDIVU = 0x1F | OPC_SPECIAL,
|
165 | e37e863f | bellard | /* 2 registers arithmetic / logic */
|
166 | 7a387fff | ths | OPC_ADD = 0x20 | OPC_SPECIAL,
|
167 | 7a387fff | ths | OPC_ADDU = 0x21 | OPC_SPECIAL,
|
168 | 7a387fff | ths | OPC_SUB = 0x22 | OPC_SPECIAL,
|
169 | 7a387fff | ths | OPC_SUBU = 0x23 | OPC_SPECIAL,
|
170 | 7a387fff | ths | OPC_AND = 0x24 | OPC_SPECIAL,
|
171 | 7a387fff | ths | OPC_OR = 0x25 | OPC_SPECIAL,
|
172 | 7a387fff | ths | OPC_XOR = 0x26 | OPC_SPECIAL,
|
173 | 7a387fff | ths | OPC_NOR = 0x27 | OPC_SPECIAL,
|
174 | 7a387fff | ths | OPC_SLT = 0x2A | OPC_SPECIAL,
|
175 | 7a387fff | ths | OPC_SLTU = 0x2B | OPC_SPECIAL,
|
176 | 7a387fff | ths | OPC_DADD = 0x2C | OPC_SPECIAL,
|
177 | 7a387fff | ths | OPC_DADDU = 0x2D | OPC_SPECIAL,
|
178 | 7a387fff | ths | OPC_DSUB = 0x2E | OPC_SPECIAL,
|
179 | 7a387fff | ths | OPC_DSUBU = 0x2F | OPC_SPECIAL,
|
180 | e37e863f | bellard | /* Jumps */
|
181 | 7a387fff | ths | OPC_JR = 0x08 | OPC_SPECIAL, /* Also JR.HB */ |
182 | 7a387fff | ths | OPC_JALR = 0x09 | OPC_SPECIAL, /* Also JALR.HB */ |
183 | e37e863f | bellard | /* Traps */
|
184 | 7a387fff | ths | OPC_TGE = 0x30 | OPC_SPECIAL,
|
185 | 7a387fff | ths | OPC_TGEU = 0x31 | OPC_SPECIAL,
|
186 | 7a387fff | ths | OPC_TLT = 0x32 | OPC_SPECIAL,
|
187 | 7a387fff | ths | OPC_TLTU = 0x33 | OPC_SPECIAL,
|
188 | 7a387fff | ths | OPC_TEQ = 0x34 | OPC_SPECIAL,
|
189 | 7a387fff | ths | OPC_TNE = 0x36 | OPC_SPECIAL,
|
190 | e37e863f | bellard | /* HI / LO registers load & stores */
|
191 | 7a387fff | ths | OPC_MFHI = 0x10 | OPC_SPECIAL,
|
192 | 7a387fff | ths | OPC_MTHI = 0x11 | OPC_SPECIAL,
|
193 | 7a387fff | ths | OPC_MFLO = 0x12 | OPC_SPECIAL,
|
194 | 7a387fff | ths | OPC_MTLO = 0x13 | OPC_SPECIAL,
|
195 | e37e863f | bellard | /* Conditional moves */
|
196 | 7a387fff | ths | OPC_MOVZ = 0x0A | OPC_SPECIAL,
|
197 | 7a387fff | ths | OPC_MOVN = 0x0B | OPC_SPECIAL,
|
198 | e37e863f | bellard | |
199 | 7a387fff | ths | OPC_MOVCI = 0x01 | OPC_SPECIAL,
|
200 | e37e863f | bellard | |
201 | e37e863f | bellard | /* Special */
|
202 | 7a387fff | ths | OPC_PMON = 0x05 | OPC_SPECIAL, /* inofficial */ |
203 | 7a387fff | ths | OPC_SYSCALL = 0x0C | OPC_SPECIAL,
|
204 | 7a387fff | ths | OPC_BREAK = 0x0D | OPC_SPECIAL,
|
205 | 7a387fff | ths | OPC_SPIM = 0x0E | OPC_SPECIAL, /* inofficial */ |
206 | 7a387fff | ths | OPC_SYNC = 0x0F | OPC_SPECIAL,
|
207 | 7a387fff | ths | |
208 | 7a387fff | ths | OPC_SPECIAL15_RESERVED = 0x15 | OPC_SPECIAL,
|
209 | 7a387fff | ths | OPC_SPECIAL28_RESERVED = 0x28 | OPC_SPECIAL,
|
210 | 7a387fff | ths | OPC_SPECIAL29_RESERVED = 0x29 | OPC_SPECIAL,
|
211 | 7a387fff | ths | OPC_SPECIAL35_RESERVED = 0x35 | OPC_SPECIAL,
|
212 | 7a387fff | ths | OPC_SPECIAL37_RESERVED = 0x37 | OPC_SPECIAL,
|
213 | 7a387fff | ths | OPC_SPECIAL39_RESERVED = 0x39 | OPC_SPECIAL,
|
214 | 7a387fff | ths | OPC_SPECIAL3D_RESERVED = 0x3D | OPC_SPECIAL,
|
215 | 7a387fff | ths | }; |
216 | 7a387fff | ths | |
217 | 7a387fff | ths | /* REGIMM (rt field) opcodes */
|
218 | 7a387fff | ths | #define MASK_REGIMM(op) MASK_OP_MAJOR(op) | (op & (0x1F << 16)) |
219 | 7a387fff | ths | |
220 | 7a387fff | ths | enum {
|
221 | 7a387fff | ths | OPC_BLTZ = (0x00 << 16) | OPC_REGIMM, |
222 | 7a387fff | ths | OPC_BLTZL = (0x02 << 16) | OPC_REGIMM, |
223 | 7a387fff | ths | OPC_BGEZ = (0x01 << 16) | OPC_REGIMM, |
224 | 7a387fff | ths | OPC_BGEZL = (0x03 << 16) | OPC_REGIMM, |
225 | 7a387fff | ths | OPC_BLTZAL = (0x10 << 16) | OPC_REGIMM, |
226 | 7a387fff | ths | OPC_BLTZALL = (0x12 << 16) | OPC_REGIMM, |
227 | 7a387fff | ths | OPC_BGEZAL = (0x11 << 16) | OPC_REGIMM, |
228 | 7a387fff | ths | OPC_BGEZALL = (0x13 << 16) | OPC_REGIMM, |
229 | 7a387fff | ths | OPC_TGEI = (0x08 << 16) | OPC_REGIMM, |
230 | 7a387fff | ths | OPC_TGEIU = (0x09 << 16) | OPC_REGIMM, |
231 | 7a387fff | ths | OPC_TLTI = (0x0A << 16) | OPC_REGIMM, |
232 | 7a387fff | ths | OPC_TLTIU = (0x0B << 16) | OPC_REGIMM, |
233 | 7a387fff | ths | OPC_TEQI = (0x0C << 16) | OPC_REGIMM, |
234 | 7a387fff | ths | OPC_TNEI = (0x0E << 16) | OPC_REGIMM, |
235 | 7a387fff | ths | OPC_SYNCI = (0x1F << 16) | OPC_REGIMM, |
236 | e37e863f | bellard | }; |
237 | e37e863f | bellard | |
238 | 7a387fff | ths | /* Special2 opcodes */
|
239 | 7a387fff | ths | #define MASK_SPECIAL2(op) MASK_OP_MAJOR(op) | (op & 0x3F) |
240 | 7a387fff | ths | |
241 | e37e863f | bellard | enum {
|
242 | 7a387fff | ths | /* Multiply & xxx operations */
|
243 | 7a387fff | ths | OPC_MADD = 0x00 | OPC_SPECIAL2,
|
244 | 7a387fff | ths | OPC_MADDU = 0x01 | OPC_SPECIAL2,
|
245 | 7a387fff | ths | OPC_MUL = 0x02 | OPC_SPECIAL2,
|
246 | 7a387fff | ths | OPC_MSUB = 0x04 | OPC_SPECIAL2,
|
247 | 7a387fff | ths | OPC_MSUBU = 0x05 | OPC_SPECIAL2,
|
248 | e37e863f | bellard | /* Misc */
|
249 | 7a387fff | ths | OPC_CLZ = 0x20 | OPC_SPECIAL2,
|
250 | 7a387fff | ths | OPC_CLO = 0x21 | OPC_SPECIAL2,
|
251 | 7a387fff | ths | OPC_DCLZ = 0x24 | OPC_SPECIAL2,
|
252 | 7a387fff | ths | OPC_DCLO = 0x25 | OPC_SPECIAL2,
|
253 | e37e863f | bellard | /* Special */
|
254 | 7a387fff | ths | OPC_SDBBP = 0x3F | OPC_SPECIAL2,
|
255 | 7a387fff | ths | }; |
256 | 7a387fff | ths | |
257 | 7a387fff | ths | /* Special3 opcodes */
|
258 | 7a387fff | ths | #define MASK_SPECIAL3(op) MASK_OP_MAJOR(op) | (op & 0x3F) |
259 | 7a387fff | ths | |
260 | 7a387fff | ths | enum {
|
261 | 7a387fff | ths | OPC_EXT = 0x00 | OPC_SPECIAL3,
|
262 | 7a387fff | ths | OPC_DEXTM = 0x01 | OPC_SPECIAL3,
|
263 | 7a387fff | ths | OPC_DEXTU = 0x02 | OPC_SPECIAL3,
|
264 | 7a387fff | ths | OPC_DEXT = 0x03 | OPC_SPECIAL3,
|
265 | 7a387fff | ths | OPC_INS = 0x04 | OPC_SPECIAL3,
|
266 | 7a387fff | ths | OPC_DINSM = 0x05 | OPC_SPECIAL3,
|
267 | 7a387fff | ths | OPC_DINSU = 0x06 | OPC_SPECIAL3,
|
268 | 7a387fff | ths | OPC_DINS = 0x07 | OPC_SPECIAL3,
|
269 | ead9360e | ths | OPC_FORK = 0x08 | OPC_SPECIAL3,
|
270 | ead9360e | ths | OPC_YIELD = 0x09 | OPC_SPECIAL3,
|
271 | 7a387fff | ths | OPC_BSHFL = 0x20 | OPC_SPECIAL3,
|
272 | 7a387fff | ths | OPC_DBSHFL = 0x24 | OPC_SPECIAL3,
|
273 | 7a387fff | ths | OPC_RDHWR = 0x3B | OPC_SPECIAL3,
|
274 | e37e863f | bellard | }; |
275 | e37e863f | bellard | |
276 | 7a387fff | ths | /* BSHFL opcodes */
|
277 | 7a387fff | ths | #define MASK_BSHFL(op) MASK_SPECIAL3(op) | (op & (0x1F << 6)) |
278 | 7a387fff | ths | |
279 | e37e863f | bellard | enum {
|
280 | 7a387fff | ths | OPC_WSBH = (0x02 << 6) | OPC_BSHFL, |
281 | 7a387fff | ths | OPC_SEB = (0x10 << 6) | OPC_BSHFL, |
282 | 7a387fff | ths | OPC_SEH = (0x18 << 6) | OPC_BSHFL, |
283 | e37e863f | bellard | }; |
284 | e37e863f | bellard | |
285 | 7a387fff | ths | /* DBSHFL opcodes */
|
286 | 7a387fff | ths | #define MASK_DBSHFL(op) MASK_SPECIAL3(op) | (op & (0x1F << 6)) |
287 | 7a387fff | ths | |
288 | e37e863f | bellard | enum {
|
289 | 7a387fff | ths | OPC_DSBH = (0x02 << 6) | OPC_DBSHFL, |
290 | 7a387fff | ths | OPC_DSHD = (0x05 << 6) | OPC_DBSHFL, |
291 | e37e863f | bellard | }; |
292 | e37e863f | bellard | |
293 | 7a387fff | ths | /* Coprocessor 0 (rs field) */
|
294 | 7a387fff | ths | #define MASK_CP0(op) MASK_OP_MAJOR(op) | (op & (0x1F << 21)) |
295 | 7a387fff | ths | |
296 | 6ea83fed | bellard | enum {
|
297 | 7a387fff | ths | OPC_MFC0 = (0x00 << 21) | OPC_CP0, |
298 | 7a387fff | ths | OPC_DMFC0 = (0x01 << 21) | OPC_CP0, |
299 | 7a387fff | ths | OPC_MTC0 = (0x04 << 21) | OPC_CP0, |
300 | 7a387fff | ths | OPC_DMTC0 = (0x05 << 21) | OPC_CP0, |
301 | ead9360e | ths | OPC_MFTR = (0x08 << 21) | OPC_CP0, |
302 | 7a387fff | ths | OPC_RDPGPR = (0x0A << 21) | OPC_CP0, |
303 | 7a387fff | ths | OPC_MFMC0 = (0x0B << 21) | OPC_CP0, |
304 | ead9360e | ths | OPC_MTTR = (0x0C << 21) | OPC_CP0, |
305 | 7a387fff | ths | OPC_WRPGPR = (0x0E << 21) | OPC_CP0, |
306 | 7a387fff | ths | OPC_C0 = (0x10 << 21) | OPC_CP0, |
307 | 7a387fff | ths | OPC_C0_FIRST = (0x10 << 21) | OPC_CP0, |
308 | 7a387fff | ths | OPC_C0_LAST = (0x1F << 21) | OPC_CP0, |
309 | 6ea83fed | bellard | }; |
310 | 7a387fff | ths | |
311 | 7a387fff | ths | /* MFMC0 opcodes */
|
312 | b48cfdff | ths | #define MASK_MFMC0(op) MASK_CP0(op) | (op & 0xFFFF) |
313 | 7a387fff | ths | |
314 | 7a387fff | ths | enum {
|
315 | ead9360e | ths | OPC_DMT = 0x01 | (0 << 5) | (0x0F << 6) | (0x01 << 11) | OPC_MFMC0, |
316 | ead9360e | ths | OPC_EMT = 0x01 | (1 << 5) | (0x0F << 6) | (0x01 << 11) | OPC_MFMC0, |
317 | ead9360e | ths | OPC_DVPE = 0x01 | (0 << 5) | OPC_MFMC0, |
318 | ead9360e | ths | OPC_EVPE = 0x01 | (1 << 5) | OPC_MFMC0, |
319 | 7a387fff | ths | OPC_DI = (0 << 5) | (0x0C << 11) | OPC_MFMC0, |
320 | 7a387fff | ths | OPC_EI = (1 << 5) | (0x0C << 11) | OPC_MFMC0, |
321 | 7a387fff | ths | }; |
322 | 7a387fff | ths | |
323 | 7a387fff | ths | /* Coprocessor 0 (with rs == C0) */
|
324 | 7a387fff | ths | #define MASK_C0(op) MASK_CP0(op) | (op & 0x3F) |
325 | 7a387fff | ths | |
326 | 7a387fff | ths | enum {
|
327 | 7a387fff | ths | OPC_TLBR = 0x01 | OPC_C0,
|
328 | 7a387fff | ths | OPC_TLBWI = 0x02 | OPC_C0,
|
329 | 7a387fff | ths | OPC_TLBWR = 0x06 | OPC_C0,
|
330 | 7a387fff | ths | OPC_TLBP = 0x08 | OPC_C0,
|
331 | 7a387fff | ths | OPC_RFE = 0x10 | OPC_C0,
|
332 | 7a387fff | ths | OPC_ERET = 0x18 | OPC_C0,
|
333 | 7a387fff | ths | OPC_DERET = 0x1F | OPC_C0,
|
334 | 7a387fff | ths | OPC_WAIT = 0x20 | OPC_C0,
|
335 | 7a387fff | ths | }; |
336 | 7a387fff | ths | |
337 | 7a387fff | ths | /* Coprocessor 1 (rs field) */
|
338 | 7a387fff | ths | #define MASK_CP1(op) MASK_OP_MAJOR(op) | (op & (0x1F << 21)) |
339 | 7a387fff | ths | |
340 | 7a387fff | ths | enum {
|
341 | 7a387fff | ths | OPC_MFC1 = (0x00 << 21) | OPC_CP1, |
342 | 7a387fff | ths | OPC_DMFC1 = (0x01 << 21) | OPC_CP1, |
343 | 7a387fff | ths | OPC_CFC1 = (0x02 << 21) | OPC_CP1, |
344 | 5a5012ec | ths | OPC_MFHC1 = (0x03 << 21) | OPC_CP1, |
345 | 7a387fff | ths | OPC_MTC1 = (0x04 << 21) | OPC_CP1, |
346 | 7a387fff | ths | OPC_DMTC1 = (0x05 << 21) | OPC_CP1, |
347 | 7a387fff | ths | OPC_CTC1 = (0x06 << 21) | OPC_CP1, |
348 | 5a5012ec | ths | OPC_MTHC1 = (0x07 << 21) | OPC_CP1, |
349 | 7a387fff | ths | OPC_BC1 = (0x08 << 21) | OPC_CP1, /* bc */ |
350 | 5a5012ec | ths | OPC_BC1ANY2 = (0x09 << 21) | OPC_CP1, |
351 | 5a5012ec | ths | OPC_BC1ANY4 = (0x0A << 21) | OPC_CP1, |
352 | 7a387fff | ths | OPC_S_FMT = (0x10 << 21) | OPC_CP1, /* 16: fmt=single fp */ |
353 | 7a387fff | ths | OPC_D_FMT = (0x11 << 21) | OPC_CP1, /* 17: fmt=double fp */ |
354 | 7a387fff | ths | OPC_E_FMT = (0x12 << 21) | OPC_CP1, /* 18: fmt=extended fp */ |
355 | 7a387fff | ths | OPC_Q_FMT = (0x13 << 21) | OPC_CP1, /* 19: fmt=quad fp */ |
356 | 7a387fff | ths | OPC_W_FMT = (0x14 << 21) | OPC_CP1, /* 20: fmt=32bit fixed */ |
357 | 7a387fff | ths | OPC_L_FMT = (0x15 << 21) | OPC_CP1, /* 21: fmt=64bit fixed */ |
358 | 5a5012ec | ths | OPC_PS_FMT = (0x16 << 21) | OPC_CP1, /* 22: fmt=paired single fp */ |
359 | 7a387fff | ths | }; |
360 | 7a387fff | ths | |
361 | 5a5012ec | ths | #define MASK_CP1_FUNC(op) MASK_CP1(op) | (op & 0x3F) |
362 | 5a5012ec | ths | #define MASK_BC1(op) MASK_CP1(op) | (op & (0x3 << 16)) |
363 | 5a5012ec | ths | |
364 | 7a387fff | ths | enum {
|
365 | 7a387fff | ths | OPC_BC1F = (0x00 << 16) | OPC_BC1, |
366 | 7a387fff | ths | OPC_BC1T = (0x01 << 16) | OPC_BC1, |
367 | 7a387fff | ths | OPC_BC1FL = (0x02 << 16) | OPC_BC1, |
368 | 7a387fff | ths | OPC_BC1TL = (0x03 << 16) | OPC_BC1, |
369 | 7a387fff | ths | }; |
370 | 7a387fff | ths | |
371 | 5a5012ec | ths | enum {
|
372 | 5a5012ec | ths | OPC_BC1FANY2 = (0x00 << 16) | OPC_BC1ANY2, |
373 | 5a5012ec | ths | OPC_BC1TANY2 = (0x01 << 16) | OPC_BC1ANY2, |
374 | 5a5012ec | ths | }; |
375 | 5a5012ec | ths | |
376 | 5a5012ec | ths | enum {
|
377 | 5a5012ec | ths | OPC_BC1FANY4 = (0x00 << 16) | OPC_BC1ANY4, |
378 | 5a5012ec | ths | OPC_BC1TANY4 = (0x01 << 16) | OPC_BC1ANY4, |
379 | 5a5012ec | ths | }; |
380 | 7a387fff | ths | |
381 | 7a387fff | ths | #define MASK_CP2(op) MASK_OP_MAJOR(op) | (op & (0x1F << 21)) |
382 | e0c84da7 | ths | |
383 | e0c84da7 | ths | enum {
|
384 | e0c84da7 | ths | OPC_MFC2 = (0x00 << 21) | OPC_CP2, |
385 | e0c84da7 | ths | OPC_DMFC2 = (0x01 << 21) | OPC_CP2, |
386 | e0c84da7 | ths | OPC_CFC2 = (0x02 << 21) | OPC_CP2, |
387 | e0c84da7 | ths | OPC_MFHC2 = (0x03 << 21) | OPC_CP2, |
388 | e0c84da7 | ths | OPC_MTC2 = (0x04 << 21) | OPC_CP2, |
389 | e0c84da7 | ths | OPC_DMTC2 = (0x05 << 21) | OPC_CP2, |
390 | e0c84da7 | ths | OPC_CTC2 = (0x06 << 21) | OPC_CP2, |
391 | e0c84da7 | ths | OPC_MTHC2 = (0x07 << 21) | OPC_CP2, |
392 | e0c84da7 | ths | OPC_BC2 = (0x08 << 21) | OPC_CP2, |
393 | e0c84da7 | ths | }; |
394 | e0c84da7 | ths | |
395 | e0c84da7 | ths | #define MASK_CP3(op) MASK_OP_MAJOR(op) | (op & 0x3F) |
396 | e0c84da7 | ths | |
397 | e0c84da7 | ths | enum {
|
398 | e0c84da7 | ths | OPC_LWXC1 = 0x00 | OPC_CP3,
|
399 | e0c84da7 | ths | OPC_LDXC1 = 0x01 | OPC_CP3,
|
400 | e0c84da7 | ths | OPC_LUXC1 = 0x05 | OPC_CP3,
|
401 | e0c84da7 | ths | OPC_SWXC1 = 0x08 | OPC_CP3,
|
402 | e0c84da7 | ths | OPC_SDXC1 = 0x09 | OPC_CP3,
|
403 | e0c84da7 | ths | OPC_SUXC1 = 0x0D | OPC_CP3,
|
404 | e0c84da7 | ths | OPC_PREFX = 0x0F | OPC_CP3,
|
405 | e0c84da7 | ths | OPC_ALNV_PS = 0x1E | OPC_CP3,
|
406 | e0c84da7 | ths | OPC_MADD_S = 0x20 | OPC_CP3,
|
407 | e0c84da7 | ths | OPC_MADD_D = 0x21 | OPC_CP3,
|
408 | e0c84da7 | ths | OPC_MADD_PS = 0x26 | OPC_CP3,
|
409 | e0c84da7 | ths | OPC_MSUB_S = 0x28 | OPC_CP3,
|
410 | e0c84da7 | ths | OPC_MSUB_D = 0x29 | OPC_CP3,
|
411 | e0c84da7 | ths | OPC_MSUB_PS = 0x2E | OPC_CP3,
|
412 | e0c84da7 | ths | OPC_NMADD_S = 0x30 | OPC_CP3,
|
413 | fbcc6828 | ths | OPC_NMADD_D = 0x31 | OPC_CP3,
|
414 | e0c84da7 | ths | OPC_NMADD_PS= 0x36 | OPC_CP3,
|
415 | e0c84da7 | ths | OPC_NMSUB_S = 0x38 | OPC_CP3,
|
416 | e0c84da7 | ths | OPC_NMSUB_D = 0x39 | OPC_CP3,
|
417 | e0c84da7 | ths | OPC_NMSUB_PS= 0x3E | OPC_CP3,
|
418 | e0c84da7 | ths | }; |
419 | e0c84da7 | ths | |
420 | 6ea83fed | bellard | |
421 | 6af0bf9c | bellard | const unsigned char *regnames[] = |
422 | 6af0bf9c | bellard | { "r0", "at", "v0", "v1", "a0", "a1", "a2", "a3", |
423 | 6af0bf9c | bellard | "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", |
424 | 6af0bf9c | bellard | "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", |
425 | 6af0bf9c | bellard | "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra", }; |
426 | 6af0bf9c | bellard | |
427 | 6af0bf9c | bellard | /* Warning: no function for r0 register (hard wired to zero) */
|
428 | 5a5012ec | ths | #define GEN32(func, NAME) \
|
429 | 5a5012ec | ths | static GenOpFunc *NAME ## _table [32] = { \ |
430 | 5a5012ec | ths | NULL, NAME ## 1, NAME ## 2, NAME ## 3, \ |
431 | 5a5012ec | ths | NAME ## 4, NAME ## 5, NAME ## 6, NAME ## 7, \ |
432 | 5a5012ec | ths | NAME ## 8, NAME ## 9, NAME ## 10, NAME ## 11, \ |
433 | 5a5012ec | ths | NAME ## 12, NAME ## 13, NAME ## 14, NAME ## 15, \ |
434 | 5a5012ec | ths | NAME ## 16, NAME ## 17, NAME ## 18, NAME ## 19, \ |
435 | 5a5012ec | ths | NAME ## 20, NAME ## 21, NAME ## 22, NAME ## 23, \ |
436 | 5a5012ec | ths | NAME ## 24, NAME ## 25, NAME ## 26, NAME ## 27, \ |
437 | 5a5012ec | ths | NAME ## 28, NAME ## 29, NAME ## 30, NAME ## 31, \ |
438 | 5a5012ec | ths | }; \ |
439 | aa343735 | ths | static always_inline void func(int n) \ |
440 | 5a5012ec | ths | { \ |
441 | 5a5012ec | ths | NAME ## _table[n](); \ |
442 | 6af0bf9c | bellard | } |
443 | 6af0bf9c | bellard | |
444 | 6af0bf9c | bellard | /* General purpose registers moves */
|
445 | 6af0bf9c | bellard | GEN32(gen_op_load_gpr_T0, gen_op_load_gpr_T0_gpr); |
446 | 6af0bf9c | bellard | GEN32(gen_op_load_gpr_T1, gen_op_load_gpr_T1_gpr); |
447 | 6af0bf9c | bellard | GEN32(gen_op_load_gpr_T2, gen_op_load_gpr_T2_gpr); |
448 | 6af0bf9c | bellard | |
449 | 6af0bf9c | bellard | GEN32(gen_op_store_T0_gpr, gen_op_store_T0_gpr_gpr); |
450 | 6af0bf9c | bellard | GEN32(gen_op_store_T1_gpr, gen_op_store_T1_gpr_gpr); |
451 | 6af0bf9c | bellard | |
452 | ead9360e | ths | /* Moves to/from shadow registers */
|
453 | ead9360e | ths | GEN32(gen_op_load_srsgpr_T0, gen_op_load_srsgpr_T0_gpr); |
454 | ead9360e | ths | GEN32(gen_op_store_T0_srsgpr, gen_op_store_T0_srsgpr_gpr); |
455 | ead9360e | ths | |
456 | 7a387fff | ths | static const char *fregnames[] = |
457 | 6ea83fed | bellard | { "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", |
458 | 6ea83fed | bellard | "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", |
459 | 6ea83fed | bellard | "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", |
460 | 6ea83fed | bellard | "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", }; |
461 | 6ea83fed | bellard | |
462 | 5a5012ec | ths | #define FGEN32(func, NAME) \
|
463 | 5a5012ec | ths | static GenOpFunc *NAME ## _table [32] = { \ |
464 | 5a5012ec | ths | NAME ## 0, NAME ## 1, NAME ## 2, NAME ## 3, \ |
465 | 5a5012ec | ths | NAME ## 4, NAME ## 5, NAME ## 6, NAME ## 7, \ |
466 | 5a5012ec | ths | NAME ## 8, NAME ## 9, NAME ## 10, NAME ## 11, \ |
467 | 5a5012ec | ths | NAME ## 12, NAME ## 13, NAME ## 14, NAME ## 15, \ |
468 | 5a5012ec | ths | NAME ## 16, NAME ## 17, NAME ## 18, NAME ## 19, \ |
469 | 5a5012ec | ths | NAME ## 20, NAME ## 21, NAME ## 22, NAME ## 23, \ |
470 | 5a5012ec | ths | NAME ## 24, NAME ## 25, NAME ## 26, NAME ## 27, \ |
471 | 5a5012ec | ths | NAME ## 28, NAME ## 29, NAME ## 30, NAME ## 31, \ |
472 | 5a5012ec | ths | }; \ |
473 | aa343735 | ths | static always_inline void func(int n) \ |
474 | 5a5012ec | ths | { \ |
475 | 5a5012ec | ths | NAME ## _table[n](); \ |
476 | 6ea83fed | bellard | } |
477 | 6ea83fed | bellard | |
478 | 5a5012ec | ths | FGEN32(gen_op_load_fpr_WT0, gen_op_load_fpr_WT0_fpr); |
479 | 5a5012ec | ths | FGEN32(gen_op_store_fpr_WT0, gen_op_store_fpr_WT0_fpr); |
480 | 5a5012ec | ths | |
481 | 5a5012ec | ths | FGEN32(gen_op_load_fpr_WT1, gen_op_load_fpr_WT1_fpr); |
482 | 5a5012ec | ths | FGEN32(gen_op_store_fpr_WT1, gen_op_store_fpr_WT1_fpr); |
483 | 6ea83fed | bellard | |
484 | 5a5012ec | ths | FGEN32(gen_op_load_fpr_WT2, gen_op_load_fpr_WT2_fpr); |
485 | 5a5012ec | ths | FGEN32(gen_op_store_fpr_WT2, gen_op_store_fpr_WT2_fpr); |
486 | 6ea83fed | bellard | |
487 | 5a5012ec | ths | FGEN32(gen_op_load_fpr_DT0, gen_op_load_fpr_DT0_fpr); |
488 | 5a5012ec | ths | FGEN32(gen_op_store_fpr_DT0, gen_op_store_fpr_DT0_fpr); |
489 | 6ea83fed | bellard | |
490 | 5a5012ec | ths | FGEN32(gen_op_load_fpr_DT1, gen_op_load_fpr_DT1_fpr); |
491 | 5a5012ec | ths | FGEN32(gen_op_store_fpr_DT1, gen_op_store_fpr_DT1_fpr); |
492 | 6ea83fed | bellard | |
493 | 5a5012ec | ths | FGEN32(gen_op_load_fpr_DT2, gen_op_load_fpr_DT2_fpr); |
494 | 5a5012ec | ths | FGEN32(gen_op_store_fpr_DT2, gen_op_store_fpr_DT2_fpr); |
495 | 6ea83fed | bellard | |
496 | 5a5012ec | ths | FGEN32(gen_op_load_fpr_WTH0, gen_op_load_fpr_WTH0_fpr); |
497 | 5a5012ec | ths | FGEN32(gen_op_store_fpr_WTH0, gen_op_store_fpr_WTH0_fpr); |
498 | 6ea83fed | bellard | |
499 | 5a5012ec | ths | FGEN32(gen_op_load_fpr_WTH1, gen_op_load_fpr_WTH1_fpr); |
500 | 5a5012ec | ths | FGEN32(gen_op_store_fpr_WTH1, gen_op_store_fpr_WTH1_fpr); |
501 | 5a5012ec | ths | |
502 | 5a5012ec | ths | FGEN32(gen_op_load_fpr_WTH2, gen_op_load_fpr_WTH2_fpr); |
503 | 5a5012ec | ths | FGEN32(gen_op_store_fpr_WTH2, gen_op_store_fpr_WTH2_fpr); |
504 | 6ea83fed | bellard | |
505 | 5a1e8ffb | ths | #define FOP_CONDS(type, fmt) \
|
506 | fd4a04eb | ths | static GenOpFunc1 * gen_op_cmp ## type ## _ ## fmt ## _table[16] = { \ |
507 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _f, \ |
508 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _un, \ |
509 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _eq, \ |
510 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _ueq, \ |
511 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _olt, \ |
512 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _ult, \ |
513 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _ole, \ |
514 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _ule, \ |
515 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _sf, \ |
516 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _ngle, \ |
517 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _seq, \ |
518 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _ngl, \ |
519 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _lt, \ |
520 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _nge, \ |
521 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _le, \ |
522 | 5a1e8ffb | ths | gen_op_cmp ## type ## _ ## fmt ## _ngt, \ |
523 | 6ea83fed | bellard | }; \ |
524 | aa343735 | ths | static always_inline void gen_cmp ## type ## _ ## fmt(int n, long cc) \ |
525 | 6ea83fed | bellard | { \ |
526 | fd4a04eb | ths | gen_op_cmp ## type ## _ ## fmt ## _table[n](cc); \ |
527 | 6ea83fed | bellard | } |
528 | 6ea83fed | bellard | |
529 | 5a1e8ffb | ths | FOP_CONDS(, d) |
530 | 5a1e8ffb | ths | FOP_CONDS(abs, d) |
531 | 5a1e8ffb | ths | FOP_CONDS(, s) |
532 | 5a1e8ffb | ths | FOP_CONDS(abs, s) |
533 | 5a1e8ffb | ths | FOP_CONDS(, ps) |
534 | 5a1e8ffb | ths | FOP_CONDS(abs, ps) |
535 | 6ea83fed | bellard | |
536 | 6af0bf9c | bellard | typedef struct DisasContext { |
537 | 6af0bf9c | bellard | struct TranslationBlock *tb;
|
538 | 6af0bf9c | bellard | target_ulong pc, saved_pc; |
539 | 6af0bf9c | bellard | uint32_t opcode; |
540 | fd4a04eb | ths | uint32_t fp_status; |
541 | 6af0bf9c | bellard | /* Routine used to access memory */
|
542 | 6af0bf9c | bellard | int mem_idx;
|
543 | 6af0bf9c | bellard | uint32_t hflags, saved_hflags; |
544 | 6af0bf9c | bellard | int bstate;
|
545 | 6af0bf9c | bellard | target_ulong btarget; |
546 | 6af0bf9c | bellard | } DisasContext; |
547 | 6af0bf9c | bellard | |
548 | 6af0bf9c | bellard | enum {
|
549 | 6af0bf9c | bellard | BS_NONE = 0, /* We go out of the TB without reaching a branch or an |
550 | 6af0bf9c | bellard | * exception condition
|
551 | 6af0bf9c | bellard | */
|
552 | 6af0bf9c | bellard | BS_STOP = 1, /* We want to stop translation for any reason */ |
553 | 6af0bf9c | bellard | BS_BRANCH = 2, /* We reached a branch condition */ |
554 | 6af0bf9c | bellard | BS_EXCP = 3, /* We reached an exception condition */ |
555 | 6af0bf9c | bellard | }; |
556 | 6af0bf9c | bellard | |
557 | 923617a3 | ths | #ifdef MIPS_DEBUG_DISAS
|
558 | 6af0bf9c | bellard | #define MIPS_DEBUG(fmt, args...) \
|
559 | 6af0bf9c | bellard | do { \
|
560 | 6af0bf9c | bellard | if (loglevel & CPU_LOG_TB_IN_ASM) { \
|
561 | 3594c774 | ths | fprintf(logfile, TARGET_FMT_lx ": %08x " fmt "\n", \ |
562 | 6af0bf9c | bellard | ctx->pc, ctx->opcode , ##args); \ |
563 | 6af0bf9c | bellard | } \ |
564 | 6af0bf9c | bellard | } while (0) |
565 | 6af0bf9c | bellard | #else
|
566 | 6af0bf9c | bellard | #define MIPS_DEBUG(fmt, args...) do { } while(0) |
567 | 6af0bf9c | bellard | #endif
|
568 | 6af0bf9c | bellard | |
569 | 6af0bf9c | bellard | #define MIPS_INVAL(op) \
|
570 | 6af0bf9c | bellard | do { \
|
571 | 6af0bf9c | bellard | MIPS_DEBUG("Invalid %s %03x %03x %03x", op, ctx->opcode >> 26, \ |
572 | 6af0bf9c | bellard | ctx->opcode & 0x3F, ((ctx->opcode >> 16) & 0x1F)); \ |
573 | 6af0bf9c | bellard | } while (0) |
574 | 6af0bf9c | bellard | |
575 | 6af0bf9c | bellard | #define GEN_LOAD_REG_TN(Tn, Rn) \
|
576 | 6af0bf9c | bellard | do { \
|
577 | 6af0bf9c | bellard | if (Rn == 0) { \ |
578 | 6af0bf9c | bellard | glue(gen_op_reset_, Tn)(); \ |
579 | 6af0bf9c | bellard | } else { \
|
580 | 6af0bf9c | bellard | glue(gen_op_load_gpr_, Tn)(Rn); \ |
581 | 6af0bf9c | bellard | } \ |
582 | 6af0bf9c | bellard | } while (0) |
583 | 6af0bf9c | bellard | |
584 | ead9360e | ths | #define GEN_LOAD_SRSREG_TN(Tn, Rn) \
|
585 | ead9360e | ths | do { \
|
586 | ead9360e | ths | if (Rn == 0) { \ |
587 | ead9360e | ths | glue(gen_op_reset_, Tn)(); \ |
588 | ead9360e | ths | } else { \
|
589 | ead9360e | ths | glue(gen_op_load_srsgpr_, Tn)(Rn); \ |
590 | ead9360e | ths | } \ |
591 | ead9360e | ths | } while (0) |
592 | ead9360e | ths | |
593 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
594 | 9b9e4393 | ths | #define GEN_LOAD_IMM_TN(Tn, Imm) \
|
595 | 9b9e4393 | ths | do { \
|
596 | 9b9e4393 | ths | if (Imm == 0) { \ |
597 | 9b9e4393 | ths | glue(gen_op_reset_, Tn)(); \ |
598 | 9b9e4393 | ths | } else if ((int32_t)Imm == Imm) { \ |
599 | 9b9e4393 | ths | glue(gen_op_set_, Tn)(Imm); \ |
600 | 9b9e4393 | ths | } else { \
|
601 | 9b9e4393 | ths | glue(gen_op_set64_, Tn)(((uint64_t)Imm) >> 32, (uint32_t)Imm); \
|
602 | 9b9e4393 | ths | } \ |
603 | 9b9e4393 | ths | } while (0) |
604 | 9b9e4393 | ths | #else
|
605 | 6af0bf9c | bellard | #define GEN_LOAD_IMM_TN(Tn, Imm) \
|
606 | 6af0bf9c | bellard | do { \
|
607 | 6af0bf9c | bellard | if (Imm == 0) { \ |
608 | 6af0bf9c | bellard | glue(gen_op_reset_, Tn)(); \ |
609 | 6af0bf9c | bellard | } else { \
|
610 | 6af0bf9c | bellard | glue(gen_op_set_, Tn)(Imm); \ |
611 | 6af0bf9c | bellard | } \ |
612 | 6af0bf9c | bellard | } while (0) |
613 | 9b9e4393 | ths | #endif
|
614 | 6af0bf9c | bellard | |
615 | 6af0bf9c | bellard | #define GEN_STORE_TN_REG(Rn, Tn) \
|
616 | 6af0bf9c | bellard | do { \
|
617 | 6af0bf9c | bellard | if (Rn != 0) { \ |
618 | 6af0bf9c | bellard | glue(glue(gen_op_store_, Tn),_gpr)(Rn); \ |
619 | 6af0bf9c | bellard | } \ |
620 | 6af0bf9c | bellard | } while (0) |
621 | 6af0bf9c | bellard | |
622 | ead9360e | ths | #define GEN_STORE_TN_SRSREG(Rn, Tn) \
|
623 | ead9360e | ths | do { \
|
624 | ead9360e | ths | if (Rn != 0) { \ |
625 | ead9360e | ths | glue(glue(gen_op_store_, Tn),_srsgpr)(Rn); \ |
626 | ead9360e | ths | } \ |
627 | ead9360e | ths | } while (0) |
628 | ead9360e | ths | |
629 | 7a387fff | ths | #define GEN_LOAD_FREG_FTN(FTn, Fn) \
|
630 | 6ea83fed | bellard | do { \
|
631 | 6ea83fed | bellard | glue(gen_op_load_fpr_, FTn)(Fn); \ |
632 | 6ea83fed | bellard | } while (0) |
633 | 6ea83fed | bellard | |
634 | 6ea83fed | bellard | #define GEN_STORE_FTN_FREG(Fn, FTn) \
|
635 | 6ea83fed | bellard | do { \
|
636 | 6ea83fed | bellard | glue(gen_op_store_fpr_, FTn)(Fn); \ |
637 | 6ea83fed | bellard | } while (0) |
638 | 6ea83fed | bellard | |
639 | aa343735 | ths | static always_inline void gen_save_pc(target_ulong pc) |
640 | 9b9e4393 | ths | { |
641 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
642 | 9b9e4393 | ths | if (pc == (int32_t)pc) {
|
643 | 9b9e4393 | ths | gen_op_save_pc(pc); |
644 | 9b9e4393 | ths | } else {
|
645 | 9b9e4393 | ths | gen_op_save_pc64(pc >> 32, (uint32_t)pc);
|
646 | 9b9e4393 | ths | } |
647 | 9b9e4393 | ths | #else
|
648 | 9b9e4393 | ths | gen_op_save_pc(pc); |
649 | 9b9e4393 | ths | #endif
|
650 | 9b9e4393 | ths | } |
651 | 9b9e4393 | ths | |
652 | aa343735 | ths | static always_inline void gen_save_btarget(target_ulong btarget) |
653 | 9b9e4393 | ths | { |
654 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
655 | 9b9e4393 | ths | if (btarget == (int32_t)btarget) {
|
656 | 9b9e4393 | ths | gen_op_save_btarget(btarget); |
657 | 9b9e4393 | ths | } else {
|
658 | 9b9e4393 | ths | gen_op_save_btarget64(btarget >> 32, (uint32_t)btarget);
|
659 | 9b9e4393 | ths | } |
660 | 9b9e4393 | ths | #else
|
661 | 9b9e4393 | ths | gen_op_save_btarget(btarget); |
662 | 9b9e4393 | ths | #endif
|
663 | 9b9e4393 | ths | } |
664 | 9b9e4393 | ths | |
665 | aa343735 | ths | static always_inline void save_cpu_state (DisasContext *ctx, int do_save_pc) |
666 | 6af0bf9c | bellard | { |
667 | 6af0bf9c | bellard | #if defined MIPS_DEBUG_DISAS
|
668 | 6af0bf9c | bellard | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
669 | 6af0bf9c | bellard | fprintf(logfile, "hflags %08x saved %08x\n",
|
670 | 6af0bf9c | bellard | ctx->hflags, ctx->saved_hflags); |
671 | 6af0bf9c | bellard | } |
672 | 6af0bf9c | bellard | #endif
|
673 | 6af0bf9c | bellard | if (do_save_pc && ctx->pc != ctx->saved_pc) {
|
674 | 9b9e4393 | ths | gen_save_pc(ctx->pc); |
675 | 6af0bf9c | bellard | ctx->saved_pc = ctx->pc; |
676 | 6af0bf9c | bellard | } |
677 | 6af0bf9c | bellard | if (ctx->hflags != ctx->saved_hflags) {
|
678 | 6af0bf9c | bellard | gen_op_save_state(ctx->hflags); |
679 | 6af0bf9c | bellard | ctx->saved_hflags = ctx->hflags; |
680 | 5a5012ec | ths | switch (ctx->hflags & MIPS_HFLAG_BMASK) {
|
681 | 5a5012ec | ths | case MIPS_HFLAG_BR:
|
682 | 6af0bf9c | bellard | gen_op_save_breg_target(); |
683 | 5a5012ec | ths | break;
|
684 | 5a5012ec | ths | case MIPS_HFLAG_BC:
|
685 | 6af0bf9c | bellard | gen_op_save_bcond(); |
686 | 5a5012ec | ths | /* fall through */
|
687 | 5a5012ec | ths | case MIPS_HFLAG_BL:
|
688 | 5a5012ec | ths | /* bcond was already saved by the BL insn */
|
689 | 5a5012ec | ths | /* fall through */
|
690 | 5a5012ec | ths | case MIPS_HFLAG_B:
|
691 | 9b9e4393 | ths | gen_save_btarget(ctx->btarget); |
692 | 5a5012ec | ths | break;
|
693 | 6af0bf9c | bellard | } |
694 | 6af0bf9c | bellard | } |
695 | 6af0bf9c | bellard | } |
696 | 6af0bf9c | bellard | |
697 | aa343735 | ths | static always_inline void restore_cpu_state (CPUState *env, DisasContext *ctx) |
698 | 5a5012ec | ths | { |
699 | fd4a04eb | ths | ctx->saved_hflags = ctx->hflags; |
700 | fd4a04eb | ths | switch (ctx->hflags & MIPS_HFLAG_BMASK) {
|
701 | fd4a04eb | ths | case MIPS_HFLAG_BR:
|
702 | fd4a04eb | ths | gen_op_restore_breg_target(); |
703 | fd4a04eb | ths | break;
|
704 | fd4a04eb | ths | case MIPS_HFLAG_B:
|
705 | fd4a04eb | ths | ctx->btarget = env->btarget; |
706 | fd4a04eb | ths | break;
|
707 | fd4a04eb | ths | case MIPS_HFLAG_BC:
|
708 | fd4a04eb | ths | case MIPS_HFLAG_BL:
|
709 | fd4a04eb | ths | ctx->btarget = env->btarget; |
710 | fd4a04eb | ths | gen_op_restore_bcond(); |
711 | fd4a04eb | ths | break;
|
712 | 5a5012ec | ths | } |
713 | 5a5012ec | ths | } |
714 | 5a5012ec | ths | |
715 | aa343735 | ths | static always_inline void generate_exception_err (DisasContext *ctx, int excp, int err) |
716 | 6af0bf9c | bellard | { |
717 | 6af0bf9c | bellard | #if defined MIPS_DEBUG_DISAS
|
718 | 6af0bf9c | bellard | if (loglevel & CPU_LOG_TB_IN_ASM)
|
719 | 6af0bf9c | bellard | fprintf(logfile, "%s: raise exception %d\n", __func__, excp);
|
720 | 6af0bf9c | bellard | #endif
|
721 | 6af0bf9c | bellard | save_cpu_state(ctx, 1);
|
722 | 4ad40f36 | bellard | if (err == 0) |
723 | 4ad40f36 | bellard | gen_op_raise_exception(excp); |
724 | 4ad40f36 | bellard | else
|
725 | 4ad40f36 | bellard | gen_op_raise_exception_err(excp, err); |
726 | 6af0bf9c | bellard | ctx->bstate = BS_EXCP; |
727 | 6af0bf9c | bellard | } |
728 | 6af0bf9c | bellard | |
729 | aa343735 | ths | static always_inline void generate_exception (DisasContext *ctx, int excp) |
730 | 4ad40f36 | bellard | { |
731 | 4ad40f36 | bellard | generate_exception_err (ctx, excp, 0);
|
732 | 4ad40f36 | bellard | } |
733 | 4ad40f36 | bellard | |
734 | aa343735 | ths | static always_inline void check_cp0_enabled(DisasContext *ctx) |
735 | 387a8fe5 | ths | { |
736 | fe253235 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_CP0)))
|
737 | 387a8fe5 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
738 | 387a8fe5 | ths | } |
739 | 387a8fe5 | ths | |
740 | aa343735 | ths | static always_inline void check_cp1_enabled(DisasContext *ctx) |
741 | 5e755519 | ths | { |
742 | fe253235 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_FPU)))
|
743 | 5e755519 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
744 | 5e755519 | ths | } |
745 | 5e755519 | ths | |
746 | aa343735 | ths | static always_inline void check_cp1_64bitmode(DisasContext *ctx) |
747 | 5e755519 | ths | { |
748 | fe253235 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_F64)))
|
749 | 5e755519 | ths | generate_exception(ctx, EXCP_RI); |
750 | 5e755519 | ths | } |
751 | 5e755519 | ths | |
752 | 5e755519 | ths | /*
|
753 | 5e755519 | ths | * Verify if floating point register is valid; an operation is not defined
|
754 | 5e755519 | ths | * if bit 0 of any register specification is set and the FR bit in the
|
755 | 5e755519 | ths | * Status register equals zero, since the register numbers specify an
|
756 | 5e755519 | ths | * even-odd pair of adjacent coprocessor general registers. When the FR bit
|
757 | 5e755519 | ths | * in the Status register equals one, both even and odd register numbers
|
758 | 5e755519 | ths | * are valid. This limitation exists only for 64 bit wide (d,l,ps) registers.
|
759 | 5e755519 | ths | *
|
760 | 5e755519 | ths | * Multiple 64 bit wide registers can be checked by calling
|
761 | 5e755519 | ths | * gen_op_cp1_registers(freg1 | freg2 | ... | fregN);
|
762 | 5e755519 | ths | */
|
763 | 5e755519 | ths | void check_cp1_registers(DisasContext *ctx, int regs) |
764 | 5e755519 | ths | { |
765 | fe253235 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_F64) && (regs & 1))) |
766 | 5e755519 | ths | generate_exception(ctx, EXCP_RI); |
767 | 5e755519 | ths | } |
768 | 5e755519 | ths | |
769 | 3a95e3a7 | ths | /* This code generates a "reserved instruction" exception if the
|
770 | e189e748 | ths | CPU does not support the instruction set corresponding to flags. */
|
771 | aa343735 | ths | static always_inline void check_insn(CPUState *env, DisasContext *ctx, int flags) |
772 | 3a95e3a7 | ths | { |
773 | e189e748 | ths | if (unlikely(!(env->insn_flags & flags)))
|
774 | 3a95e3a7 | ths | generate_exception(ctx, EXCP_RI); |
775 | 3a95e3a7 | ths | } |
776 | 3a95e3a7 | ths | |
777 | ead9360e | ths | /* This code generates a "reserved instruction" exception if the
|
778 | ead9360e | ths | CPU is not MIPS MT capable. */
|
779 | aa343735 | ths | static always_inline void check_mips_mt(CPUState *env, DisasContext *ctx) |
780 | ead9360e | ths | { |
781 | fe253235 | ths | if (unlikely(!(env->CP0_Config3 & (1 << CP0C3_MT)))) |
782 | ead9360e | ths | generate_exception(ctx, EXCP_RI); |
783 | ead9360e | ths | } |
784 | ead9360e | ths | |
785 | e189e748 | ths | /* This code generates a "reserved instruction" exception if 64-bit
|
786 | e189e748 | ths | instructions are not enabled. */
|
787 | aa343735 | ths | static always_inline void check_mips_64(DisasContext *ctx) |
788 | e189e748 | ths | { |
789 | fe253235 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_64)))
|
790 | e189e748 | ths | generate_exception(ctx, EXCP_RI); |
791 | e189e748 | ths | } |
792 | e189e748 | ths | |
793 | 6af0bf9c | bellard | #if defined(CONFIG_USER_ONLY)
|
794 | 6af0bf9c | bellard | #define op_ldst(name) gen_op_##name##_raw() |
795 | 6af0bf9c | bellard | #define OP_LD_TABLE(width)
|
796 | 6af0bf9c | bellard | #define OP_ST_TABLE(width)
|
797 | 6af0bf9c | bellard | #else
|
798 | 6af0bf9c | bellard | #define op_ldst(name) (*gen_op_##name[ctx->mem_idx])() |
799 | 6af0bf9c | bellard | #define OP_LD_TABLE(width) \
|
800 | 6af0bf9c | bellard | static GenOpFunc *gen_op_l##width[] = { \ |
801 | 6af0bf9c | bellard | &gen_op_l##width##_user, \ |
802 | 6af0bf9c | bellard | &gen_op_l##width##_kernel, \ |
803 | 6af0bf9c | bellard | } |
804 | 6af0bf9c | bellard | #define OP_ST_TABLE(width) \
|
805 | 6af0bf9c | bellard | static GenOpFunc *gen_op_s##width[] = { \ |
806 | 6af0bf9c | bellard | &gen_op_s##width##_user, \ |
807 | 6af0bf9c | bellard | &gen_op_s##width##_kernel, \ |
808 | 6af0bf9c | bellard | } |
809 | 6af0bf9c | bellard | #endif
|
810 | 6af0bf9c | bellard | |
811 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
812 | 6af0bf9c | bellard | OP_LD_TABLE(d); |
813 | 6af0bf9c | bellard | OP_LD_TABLE(dl); |
814 | 6af0bf9c | bellard | OP_LD_TABLE(dr); |
815 | 6af0bf9c | bellard | OP_ST_TABLE(d); |
816 | 6af0bf9c | bellard | OP_ST_TABLE(dl); |
817 | 6af0bf9c | bellard | OP_ST_TABLE(dr); |
818 | c570fd16 | ths | OP_LD_TABLE(ld); |
819 | c570fd16 | ths | OP_ST_TABLE(cd); |
820 | 6e473128 | ths | OP_LD_TABLE(wu); |
821 | 6af0bf9c | bellard | #endif
|
822 | 6af0bf9c | bellard | OP_LD_TABLE(w); |
823 | 6af0bf9c | bellard | OP_LD_TABLE(wl); |
824 | 6af0bf9c | bellard | OP_LD_TABLE(wr); |
825 | 6af0bf9c | bellard | OP_ST_TABLE(w); |
826 | 6af0bf9c | bellard | OP_ST_TABLE(wl); |
827 | 6af0bf9c | bellard | OP_ST_TABLE(wr); |
828 | 6af0bf9c | bellard | OP_LD_TABLE(h); |
829 | 6af0bf9c | bellard | OP_LD_TABLE(hu); |
830 | 6af0bf9c | bellard | OP_ST_TABLE(h); |
831 | 6af0bf9c | bellard | OP_LD_TABLE(b); |
832 | 6af0bf9c | bellard | OP_LD_TABLE(bu); |
833 | 6af0bf9c | bellard | OP_ST_TABLE(b); |
834 | 6af0bf9c | bellard | OP_LD_TABLE(l); |
835 | 6af0bf9c | bellard | OP_ST_TABLE(c); |
836 | 6ea83fed | bellard | OP_LD_TABLE(wc1); |
837 | 6ea83fed | bellard | OP_ST_TABLE(wc1); |
838 | 6ea83fed | bellard | OP_LD_TABLE(dc1); |
839 | 6ea83fed | bellard | OP_ST_TABLE(dc1); |
840 | 5a5012ec | ths | OP_LD_TABLE(uxc1); |
841 | 5a5012ec | ths | OP_ST_TABLE(uxc1); |
842 | 6af0bf9c | bellard | |
843 | 6af0bf9c | bellard | /* Load and store */
|
844 | 7a387fff | ths | static void gen_ldst (DisasContext *ctx, uint32_t opc, int rt, |
845 | 6af0bf9c | bellard | int base, int16_t offset)
|
846 | 6af0bf9c | bellard | { |
847 | 923617a3 | ths | const char *opn = "ldst"; |
848 | 6af0bf9c | bellard | |
849 | 6af0bf9c | bellard | if (base == 0) { |
850 | 6af0bf9c | bellard | GEN_LOAD_IMM_TN(T0, offset); |
851 | 6af0bf9c | bellard | } else if (offset == 0) { |
852 | 6af0bf9c | bellard | gen_op_load_gpr_T0(base); |
853 | 6af0bf9c | bellard | } else {
|
854 | 6af0bf9c | bellard | gen_op_load_gpr_T0(base); |
855 | 6af0bf9c | bellard | gen_op_set_T1(offset); |
856 | a6763a58 | ths | gen_op_addr_add(); |
857 | 6af0bf9c | bellard | } |
858 | 6af0bf9c | bellard | /* Don't do NOP if destination is zero: we must perform the actual
|
859 | ead9360e | ths | memory access. */
|
860 | 6af0bf9c | bellard | switch (opc) {
|
861 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
862 | 6e473128 | ths | case OPC_LWU:
|
863 | 6e473128 | ths | op_ldst(lwu); |
864 | 6e473128 | ths | GEN_STORE_TN_REG(rt, T0); |
865 | 6e473128 | ths | opn = "lwu";
|
866 | 6e473128 | ths | break;
|
867 | 6af0bf9c | bellard | case OPC_LD:
|
868 | 6af0bf9c | bellard | op_ldst(ld); |
869 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rt, T0); |
870 | 6af0bf9c | bellard | opn = "ld";
|
871 | 6af0bf9c | bellard | break;
|
872 | 7a387fff | ths | case OPC_LLD:
|
873 | 7a387fff | ths | op_ldst(lld); |
874 | 7a387fff | ths | GEN_STORE_TN_REG(rt, T0); |
875 | 7a387fff | ths | opn = "lld";
|
876 | 7a387fff | ths | break;
|
877 | 6af0bf9c | bellard | case OPC_SD:
|
878 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
879 | 6af0bf9c | bellard | op_ldst(sd); |
880 | 6af0bf9c | bellard | opn = "sd";
|
881 | 6af0bf9c | bellard | break;
|
882 | 7a387fff | ths | case OPC_SCD:
|
883 | 62c5609a | ths | save_cpu_state(ctx, 1);
|
884 | 7a387fff | ths | GEN_LOAD_REG_TN(T1, rt); |
885 | 7a387fff | ths | op_ldst(scd); |
886 | beebb570 | ths | GEN_STORE_TN_REG(rt, T0); |
887 | 7a387fff | ths | opn = "scd";
|
888 | 7a387fff | ths | break;
|
889 | 6af0bf9c | bellard | case OPC_LDL:
|
890 | 5d46d55d | ths | GEN_LOAD_REG_TN(T1, rt); |
891 | 6af0bf9c | bellard | op_ldst(ldl); |
892 | 4e9f8537 | ths | GEN_STORE_TN_REG(rt, T1); |
893 | 6af0bf9c | bellard | opn = "ldl";
|
894 | 6af0bf9c | bellard | break;
|
895 | 6af0bf9c | bellard | case OPC_SDL:
|
896 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
897 | 6af0bf9c | bellard | op_ldst(sdl); |
898 | 6af0bf9c | bellard | opn = "sdl";
|
899 | 6af0bf9c | bellard | break;
|
900 | 6af0bf9c | bellard | case OPC_LDR:
|
901 | 5d46d55d | ths | GEN_LOAD_REG_TN(T1, rt); |
902 | 6af0bf9c | bellard | op_ldst(ldr); |
903 | 4e9f8537 | ths | GEN_STORE_TN_REG(rt, T1); |
904 | 6af0bf9c | bellard | opn = "ldr";
|
905 | 6af0bf9c | bellard | break;
|
906 | 6af0bf9c | bellard | case OPC_SDR:
|
907 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
908 | 6af0bf9c | bellard | op_ldst(sdr); |
909 | 6af0bf9c | bellard | opn = "sdr";
|
910 | 6af0bf9c | bellard | break;
|
911 | 6af0bf9c | bellard | #endif
|
912 | 6af0bf9c | bellard | case OPC_LW:
|
913 | 6af0bf9c | bellard | op_ldst(lw); |
914 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rt, T0); |
915 | 6af0bf9c | bellard | opn = "lw";
|
916 | 6af0bf9c | bellard | break;
|
917 | 6af0bf9c | bellard | case OPC_SW:
|
918 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
919 | 6af0bf9c | bellard | op_ldst(sw); |
920 | 6af0bf9c | bellard | opn = "sw";
|
921 | 6af0bf9c | bellard | break;
|
922 | 6af0bf9c | bellard | case OPC_LH:
|
923 | 6af0bf9c | bellard | op_ldst(lh); |
924 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rt, T0); |
925 | 6af0bf9c | bellard | opn = "lh";
|
926 | 6af0bf9c | bellard | break;
|
927 | 6af0bf9c | bellard | case OPC_SH:
|
928 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
929 | 6af0bf9c | bellard | op_ldst(sh); |
930 | 6af0bf9c | bellard | opn = "sh";
|
931 | 6af0bf9c | bellard | break;
|
932 | 6af0bf9c | bellard | case OPC_LHU:
|
933 | 6af0bf9c | bellard | op_ldst(lhu); |
934 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rt, T0); |
935 | 6af0bf9c | bellard | opn = "lhu";
|
936 | 6af0bf9c | bellard | break;
|
937 | 6af0bf9c | bellard | case OPC_LB:
|
938 | 6af0bf9c | bellard | op_ldst(lb); |
939 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rt, T0); |
940 | 6af0bf9c | bellard | opn = "lb";
|
941 | 6af0bf9c | bellard | break;
|
942 | 6af0bf9c | bellard | case OPC_SB:
|
943 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
944 | 6af0bf9c | bellard | op_ldst(sb); |
945 | 6af0bf9c | bellard | opn = "sb";
|
946 | 6af0bf9c | bellard | break;
|
947 | 6af0bf9c | bellard | case OPC_LBU:
|
948 | 6af0bf9c | bellard | op_ldst(lbu); |
949 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rt, T0); |
950 | 6af0bf9c | bellard | opn = "lbu";
|
951 | 6af0bf9c | bellard | break;
|
952 | 6af0bf9c | bellard | case OPC_LWL:
|
953 | 9d1d106a | bellard | GEN_LOAD_REG_TN(T1, rt); |
954 | 6af0bf9c | bellard | op_ldst(lwl); |
955 | 4e9f8537 | ths | GEN_STORE_TN_REG(rt, T1); |
956 | 6af0bf9c | bellard | opn = "lwl";
|
957 | 6af0bf9c | bellard | break;
|
958 | 6af0bf9c | bellard | case OPC_SWL:
|
959 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
960 | 6af0bf9c | bellard | op_ldst(swl); |
961 | 6af0bf9c | bellard | opn = "swr";
|
962 | 6af0bf9c | bellard | break;
|
963 | 6af0bf9c | bellard | case OPC_LWR:
|
964 | 9d1d106a | bellard | GEN_LOAD_REG_TN(T1, rt); |
965 | 6af0bf9c | bellard | op_ldst(lwr); |
966 | 4e9f8537 | ths | GEN_STORE_TN_REG(rt, T1); |
967 | 6af0bf9c | bellard | opn = "lwr";
|
968 | 6af0bf9c | bellard | break;
|
969 | 6af0bf9c | bellard | case OPC_SWR:
|
970 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
971 | 6af0bf9c | bellard | op_ldst(swr); |
972 | 6af0bf9c | bellard | opn = "swr";
|
973 | 6af0bf9c | bellard | break;
|
974 | 6af0bf9c | bellard | case OPC_LL:
|
975 | 6af0bf9c | bellard | op_ldst(ll); |
976 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rt, T0); |
977 | 6af0bf9c | bellard | opn = "ll";
|
978 | 6af0bf9c | bellard | break;
|
979 | 6af0bf9c | bellard | case OPC_SC:
|
980 | 62c5609a | ths | save_cpu_state(ctx, 1);
|
981 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
982 | 6af0bf9c | bellard | op_ldst(sc); |
983 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rt, T0); |
984 | 6af0bf9c | bellard | opn = "sc";
|
985 | 6af0bf9c | bellard | break;
|
986 | 6af0bf9c | bellard | default:
|
987 | 923617a3 | ths | MIPS_INVAL(opn); |
988 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
989 | 6af0bf9c | bellard | return;
|
990 | 6af0bf9c | bellard | } |
991 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s, %d(%s)", opn, regnames[rt], offset, regnames[base]);
|
992 | 6af0bf9c | bellard | } |
993 | 6af0bf9c | bellard | |
994 | 6ea83fed | bellard | /* Load and store */
|
995 | 7a387fff | ths | static void gen_flt_ldst (DisasContext *ctx, uint32_t opc, int ft, |
996 | 6ea83fed | bellard | int base, int16_t offset)
|
997 | 6ea83fed | bellard | { |
998 | 923617a3 | ths | const char *opn = "flt_ldst"; |
999 | 6ea83fed | bellard | |
1000 | 6ea83fed | bellard | if (base == 0) { |
1001 | 6ea83fed | bellard | GEN_LOAD_IMM_TN(T0, offset); |
1002 | 6ea83fed | bellard | } else if (offset == 0) { |
1003 | 6ea83fed | bellard | gen_op_load_gpr_T0(base); |
1004 | 6ea83fed | bellard | } else {
|
1005 | 6ea83fed | bellard | gen_op_load_gpr_T0(base); |
1006 | 6ea83fed | bellard | gen_op_set_T1(offset); |
1007 | a6763a58 | ths | gen_op_addr_add(); |
1008 | 6ea83fed | bellard | } |
1009 | 6ea83fed | bellard | /* Don't do NOP if destination is zero: we must perform the actual
|
1010 | ead9360e | ths | memory access. */
|
1011 | 6ea83fed | bellard | switch (opc) {
|
1012 | 6ea83fed | bellard | case OPC_LWC1:
|
1013 | 6ea83fed | bellard | op_ldst(lwc1); |
1014 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(ft, WT0); |
1015 | 6ea83fed | bellard | opn = "lwc1";
|
1016 | 6ea83fed | bellard | break;
|
1017 | 6ea83fed | bellard | case OPC_SWC1:
|
1018 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, ft); |
1019 | 6ea83fed | bellard | op_ldst(swc1); |
1020 | 6ea83fed | bellard | opn = "swc1";
|
1021 | 6ea83fed | bellard | break;
|
1022 | 6ea83fed | bellard | case OPC_LDC1:
|
1023 | 6ea83fed | bellard | op_ldst(ldc1); |
1024 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(ft, DT0); |
1025 | 6ea83fed | bellard | opn = "ldc1";
|
1026 | 6ea83fed | bellard | break;
|
1027 | 6ea83fed | bellard | case OPC_SDC1:
|
1028 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, ft); |
1029 | 6ea83fed | bellard | op_ldst(sdc1); |
1030 | 6ea83fed | bellard | opn = "sdc1";
|
1031 | 6ea83fed | bellard | break;
|
1032 | 6ea83fed | bellard | default:
|
1033 | 923617a3 | ths | MIPS_INVAL(opn); |
1034 | e397ee33 | ths | generate_exception(ctx, EXCP_RI); |
1035 | 6ea83fed | bellard | return;
|
1036 | 6ea83fed | bellard | } |
1037 | 6ea83fed | bellard | MIPS_DEBUG("%s %s, %d(%s)", opn, fregnames[ft], offset, regnames[base]);
|
1038 | 6ea83fed | bellard | } |
1039 | 6ea83fed | bellard | |
1040 | 6af0bf9c | bellard | /* Arithmetic with immediate operand */
|
1041 | e189e748 | ths | static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc, |
1042 | e189e748 | ths | int rt, int rs, int16_t imm) |
1043 | 6af0bf9c | bellard | { |
1044 | f469b9db | ths | target_ulong uimm; |
1045 | 923617a3 | ths | const char *opn = "imm arith"; |
1046 | 6af0bf9c | bellard | |
1047 | 7a387fff | ths | if (rt == 0 && opc != OPC_ADDI && opc != OPC_DADDI) { |
1048 | ead9360e | ths | /* If no destination, treat it as a NOP.
|
1049 | ead9360e | ths | For addi, we must generate the overflow exception when needed. */
|
1050 | 6af0bf9c | bellard | MIPS_DEBUG("NOP");
|
1051 | 6af0bf9c | bellard | return;
|
1052 | 6af0bf9c | bellard | } |
1053 | 5a63bcb2 | ths | uimm = (uint16_t)imm; |
1054 | 5a63bcb2 | ths | switch (opc) {
|
1055 | 5a63bcb2 | ths | case OPC_ADDI:
|
1056 | 5a63bcb2 | ths | case OPC_ADDIU:
|
1057 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
1058 | 5a63bcb2 | ths | case OPC_DADDI:
|
1059 | 5a63bcb2 | ths | case OPC_DADDIU:
|
1060 | 5a63bcb2 | ths | #endif
|
1061 | 5a63bcb2 | ths | case OPC_SLTI:
|
1062 | 5a63bcb2 | ths | case OPC_SLTIU:
|
1063 | f469b9db | ths | uimm = (target_long)imm; /* Sign extend to 32/64 bits */
|
1064 | 5a63bcb2 | ths | /* Fall through. */
|
1065 | 5a63bcb2 | ths | case OPC_ANDI:
|
1066 | 5a63bcb2 | ths | case OPC_ORI:
|
1067 | 5a63bcb2 | ths | case OPC_XORI:
|
1068 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, rs); |
1069 | 6af0bf9c | bellard | GEN_LOAD_IMM_TN(T1, uimm); |
1070 | 5a63bcb2 | ths | break;
|
1071 | 5a63bcb2 | ths | case OPC_LUI:
|
1072 | 9b9e4393 | ths | GEN_LOAD_IMM_TN(T0, imm << 16);
|
1073 | 5a63bcb2 | ths | break;
|
1074 | 5a63bcb2 | ths | case OPC_SLL:
|
1075 | 5a63bcb2 | ths | case OPC_SRA:
|
1076 | 5a63bcb2 | ths | case OPC_SRL:
|
1077 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
1078 | 5a63bcb2 | ths | case OPC_DSLL:
|
1079 | 5a63bcb2 | ths | case OPC_DSRA:
|
1080 | 5a63bcb2 | ths | case OPC_DSRL:
|
1081 | 5a63bcb2 | ths | case OPC_DSLL32:
|
1082 | 5a63bcb2 | ths | case OPC_DSRA32:
|
1083 | 5a63bcb2 | ths | case OPC_DSRL32:
|
1084 | 5a63bcb2 | ths | #endif
|
1085 | 5a63bcb2 | ths | uimm &= 0x1f;
|
1086 | 5a63bcb2 | ths | GEN_LOAD_REG_TN(T0, rs); |
1087 | 5a63bcb2 | ths | GEN_LOAD_IMM_TN(T1, uimm); |
1088 | 5a63bcb2 | ths | break;
|
1089 | 6af0bf9c | bellard | } |
1090 | 6af0bf9c | bellard | switch (opc) {
|
1091 | 6af0bf9c | bellard | case OPC_ADDI:
|
1092 | 6af0bf9c | bellard | save_cpu_state(ctx, 1);
|
1093 | 6af0bf9c | bellard | gen_op_addo(); |
1094 | 6af0bf9c | bellard | opn = "addi";
|
1095 | 6af0bf9c | bellard | break;
|
1096 | 6af0bf9c | bellard | case OPC_ADDIU:
|
1097 | 6af0bf9c | bellard | gen_op_add(); |
1098 | 6af0bf9c | bellard | opn = "addiu";
|
1099 | 6af0bf9c | bellard | break;
|
1100 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
1101 | 7a387fff | ths | case OPC_DADDI:
|
1102 | 7a387fff | ths | save_cpu_state(ctx, 1);
|
1103 | 7a387fff | ths | gen_op_daddo(); |
1104 | 7a387fff | ths | opn = "daddi";
|
1105 | 7a387fff | ths | break;
|
1106 | 7a387fff | ths | case OPC_DADDIU:
|
1107 | 7a387fff | ths | gen_op_dadd(); |
1108 | 7a387fff | ths | opn = "daddiu";
|
1109 | 7a387fff | ths | break;
|
1110 | 7a387fff | ths | #endif
|
1111 | 6af0bf9c | bellard | case OPC_SLTI:
|
1112 | 6af0bf9c | bellard | gen_op_lt(); |
1113 | 6af0bf9c | bellard | opn = "slti";
|
1114 | 6af0bf9c | bellard | break;
|
1115 | 6af0bf9c | bellard | case OPC_SLTIU:
|
1116 | 6af0bf9c | bellard | gen_op_ltu(); |
1117 | 6af0bf9c | bellard | opn = "sltiu";
|
1118 | 6af0bf9c | bellard | break;
|
1119 | 6af0bf9c | bellard | case OPC_ANDI:
|
1120 | 6af0bf9c | bellard | gen_op_and(); |
1121 | 6af0bf9c | bellard | opn = "andi";
|
1122 | 6af0bf9c | bellard | break;
|
1123 | 6af0bf9c | bellard | case OPC_ORI:
|
1124 | 6af0bf9c | bellard | gen_op_or(); |
1125 | 6af0bf9c | bellard | opn = "ori";
|
1126 | 6af0bf9c | bellard | break;
|
1127 | 6af0bf9c | bellard | case OPC_XORI:
|
1128 | 6af0bf9c | bellard | gen_op_xor(); |
1129 | 6af0bf9c | bellard | opn = "xori";
|
1130 | 6af0bf9c | bellard | break;
|
1131 | 6af0bf9c | bellard | case OPC_LUI:
|
1132 | 6af0bf9c | bellard | opn = "lui";
|
1133 | 6af0bf9c | bellard | break;
|
1134 | 6af0bf9c | bellard | case OPC_SLL:
|
1135 | 6af0bf9c | bellard | gen_op_sll(); |
1136 | 6af0bf9c | bellard | opn = "sll";
|
1137 | 6af0bf9c | bellard | break;
|
1138 | 6af0bf9c | bellard | case OPC_SRA:
|
1139 | 6af0bf9c | bellard | gen_op_sra(); |
1140 | 6af0bf9c | bellard | opn = "sra";
|
1141 | 6af0bf9c | bellard | break;
|
1142 | 6af0bf9c | bellard | case OPC_SRL:
|
1143 | 5a63bcb2 | ths | switch ((ctx->opcode >> 21) & 0x1f) { |
1144 | 5a63bcb2 | ths | case 0: |
1145 | 7a387fff | ths | gen_op_srl(); |
1146 | 7a387fff | ths | opn = "srl";
|
1147 | 5a63bcb2 | ths | break;
|
1148 | 5a63bcb2 | ths | case 1: |
1149 | e189e748 | ths | /* rotr is decoded as srl on non-R2 CPUs */
|
1150 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1151 | e189e748 | ths | gen_op_rotr(); |
1152 | e189e748 | ths | opn = "rotr";
|
1153 | e189e748 | ths | } else {
|
1154 | e189e748 | ths | gen_op_srl(); |
1155 | e189e748 | ths | opn = "srl";
|
1156 | e189e748 | ths | } |
1157 | 5a63bcb2 | ths | break;
|
1158 | 5a63bcb2 | ths | default:
|
1159 | 5a63bcb2 | ths | MIPS_INVAL("invalid srl flag");
|
1160 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1161 | 5a63bcb2 | ths | break;
|
1162 | 5a63bcb2 | ths | } |
1163 | 7a387fff | ths | break;
|
1164 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
1165 | 7a387fff | ths | case OPC_DSLL:
|
1166 | 7a387fff | ths | gen_op_dsll(); |
1167 | 7a387fff | ths | opn = "dsll";
|
1168 | 7a387fff | ths | break;
|
1169 | 7a387fff | ths | case OPC_DSRA:
|
1170 | 7a387fff | ths | gen_op_dsra(); |
1171 | 7a387fff | ths | opn = "dsra";
|
1172 | 7a387fff | ths | break;
|
1173 | 7a387fff | ths | case OPC_DSRL:
|
1174 | 5a63bcb2 | ths | switch ((ctx->opcode >> 21) & 0x1f) { |
1175 | 5a63bcb2 | ths | case 0: |
1176 | 7a387fff | ths | gen_op_dsrl(); |
1177 | 7a387fff | ths | opn = "dsrl";
|
1178 | 5a63bcb2 | ths | break;
|
1179 | 5a63bcb2 | ths | case 1: |
1180 | e189e748 | ths | /* drotr is decoded as dsrl on non-R2 CPUs */
|
1181 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1182 | e189e748 | ths | gen_op_drotr(); |
1183 | e189e748 | ths | opn = "drotr";
|
1184 | e189e748 | ths | } else {
|
1185 | e189e748 | ths | gen_op_dsrl(); |
1186 | e189e748 | ths | opn = "dsrl";
|
1187 | e189e748 | ths | } |
1188 | 5a63bcb2 | ths | break;
|
1189 | 5a63bcb2 | ths | default:
|
1190 | 5a63bcb2 | ths | MIPS_INVAL("invalid dsrl flag");
|
1191 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1192 | 5a63bcb2 | ths | break;
|
1193 | 5a63bcb2 | ths | } |
1194 | 7a387fff | ths | break;
|
1195 | 7a387fff | ths | case OPC_DSLL32:
|
1196 | 7a387fff | ths | gen_op_dsll32(); |
1197 | 7a387fff | ths | opn = "dsll32";
|
1198 | 7a387fff | ths | break;
|
1199 | 7a387fff | ths | case OPC_DSRA32:
|
1200 | 7a387fff | ths | gen_op_dsra32(); |
1201 | 7a387fff | ths | opn = "dsra32";
|
1202 | 7a387fff | ths | break;
|
1203 | 7a387fff | ths | case OPC_DSRL32:
|
1204 | 5a63bcb2 | ths | switch ((ctx->opcode >> 21) & 0x1f) { |
1205 | 5a63bcb2 | ths | case 0: |
1206 | 7a387fff | ths | gen_op_dsrl32(); |
1207 | 7a387fff | ths | opn = "dsrl32";
|
1208 | 5a63bcb2 | ths | break;
|
1209 | 5a63bcb2 | ths | case 1: |
1210 | e189e748 | ths | /* drotr32 is decoded as dsrl32 on non-R2 CPUs */
|
1211 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1212 | e189e748 | ths | gen_op_drotr32(); |
1213 | e189e748 | ths | opn = "drotr32";
|
1214 | e189e748 | ths | } else {
|
1215 | e189e748 | ths | gen_op_dsrl32(); |
1216 | e189e748 | ths | opn = "dsrl32";
|
1217 | e189e748 | ths | } |
1218 | 5a63bcb2 | ths | break;
|
1219 | 5a63bcb2 | ths | default:
|
1220 | 5a63bcb2 | ths | MIPS_INVAL("invalid dsrl32 flag");
|
1221 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1222 | 5a63bcb2 | ths | break;
|
1223 | 5a63bcb2 | ths | } |
1224 | 6af0bf9c | bellard | break;
|
1225 | 7a387fff | ths | #endif
|
1226 | 6af0bf9c | bellard | default:
|
1227 | 923617a3 | ths | MIPS_INVAL(opn); |
1228 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1229 | 6af0bf9c | bellard | return;
|
1230 | 6af0bf9c | bellard | } |
1231 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rt, T0); |
1232 | 93b12ccc | ths | MIPS_DEBUG("%s %s, %s, " TARGET_FMT_lx, opn, regnames[rt], regnames[rs], uimm);
|
1233 | 6af0bf9c | bellard | } |
1234 | 6af0bf9c | bellard | |
1235 | 6af0bf9c | bellard | /* Arithmetic */
|
1236 | e189e748 | ths | static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc, |
1237 | 6af0bf9c | bellard | int rd, int rs, int rt) |
1238 | 6af0bf9c | bellard | { |
1239 | 923617a3 | ths | const char *opn = "arith"; |
1240 | 6af0bf9c | bellard | |
1241 | 7a387fff | ths | if (rd == 0 && opc != OPC_ADD && opc != OPC_SUB |
1242 | 7a387fff | ths | && opc != OPC_DADD && opc != OPC_DSUB) { |
1243 | ead9360e | ths | /* If no destination, treat it as a NOP.
|
1244 | ead9360e | ths | For add & sub, we must generate the overflow exception when needed. */
|
1245 | 6af0bf9c | bellard | MIPS_DEBUG("NOP");
|
1246 | 6af0bf9c | bellard | return;
|
1247 | 6af0bf9c | bellard | } |
1248 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, rs); |
1249 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
1250 | 6af0bf9c | bellard | switch (opc) {
|
1251 | 6af0bf9c | bellard | case OPC_ADD:
|
1252 | 6af0bf9c | bellard | save_cpu_state(ctx, 1);
|
1253 | 6af0bf9c | bellard | gen_op_addo(); |
1254 | 6af0bf9c | bellard | opn = "add";
|
1255 | 6af0bf9c | bellard | break;
|
1256 | 6af0bf9c | bellard | case OPC_ADDU:
|
1257 | 6af0bf9c | bellard | gen_op_add(); |
1258 | 6af0bf9c | bellard | opn = "addu";
|
1259 | 6af0bf9c | bellard | break;
|
1260 | 6af0bf9c | bellard | case OPC_SUB:
|
1261 | 6af0bf9c | bellard | save_cpu_state(ctx, 1);
|
1262 | 6af0bf9c | bellard | gen_op_subo(); |
1263 | 6af0bf9c | bellard | opn = "sub";
|
1264 | 6af0bf9c | bellard | break;
|
1265 | 6af0bf9c | bellard | case OPC_SUBU:
|
1266 | 6af0bf9c | bellard | gen_op_sub(); |
1267 | 6af0bf9c | bellard | opn = "subu";
|
1268 | 6af0bf9c | bellard | break;
|
1269 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
1270 | 7a387fff | ths | case OPC_DADD:
|
1271 | 7a387fff | ths | save_cpu_state(ctx, 1);
|
1272 | 7a387fff | ths | gen_op_daddo(); |
1273 | 7a387fff | ths | opn = "dadd";
|
1274 | 7a387fff | ths | break;
|
1275 | 7a387fff | ths | case OPC_DADDU:
|
1276 | 7a387fff | ths | gen_op_dadd(); |
1277 | 7a387fff | ths | opn = "daddu";
|
1278 | 7a387fff | ths | break;
|
1279 | 7a387fff | ths | case OPC_DSUB:
|
1280 | 7a387fff | ths | save_cpu_state(ctx, 1);
|
1281 | 7a387fff | ths | gen_op_dsubo(); |
1282 | 7a387fff | ths | opn = "dsub";
|
1283 | 7a387fff | ths | break;
|
1284 | 7a387fff | ths | case OPC_DSUBU:
|
1285 | 7a387fff | ths | gen_op_dsub(); |
1286 | 7a387fff | ths | opn = "dsubu";
|
1287 | 7a387fff | ths | break;
|
1288 | 7a387fff | ths | #endif
|
1289 | 6af0bf9c | bellard | case OPC_SLT:
|
1290 | 6af0bf9c | bellard | gen_op_lt(); |
1291 | 6af0bf9c | bellard | opn = "slt";
|
1292 | 6af0bf9c | bellard | break;
|
1293 | 6af0bf9c | bellard | case OPC_SLTU:
|
1294 | 6af0bf9c | bellard | gen_op_ltu(); |
1295 | 6af0bf9c | bellard | opn = "sltu";
|
1296 | 6af0bf9c | bellard | break;
|
1297 | 6af0bf9c | bellard | case OPC_AND:
|
1298 | 6af0bf9c | bellard | gen_op_and(); |
1299 | 6af0bf9c | bellard | opn = "and";
|
1300 | 6af0bf9c | bellard | break;
|
1301 | 6af0bf9c | bellard | case OPC_NOR:
|
1302 | 6af0bf9c | bellard | gen_op_nor(); |
1303 | 6af0bf9c | bellard | opn = "nor";
|
1304 | 6af0bf9c | bellard | break;
|
1305 | 6af0bf9c | bellard | case OPC_OR:
|
1306 | 6af0bf9c | bellard | gen_op_or(); |
1307 | 6af0bf9c | bellard | opn = "or";
|
1308 | 6af0bf9c | bellard | break;
|
1309 | 6af0bf9c | bellard | case OPC_XOR:
|
1310 | 6af0bf9c | bellard | gen_op_xor(); |
1311 | 6af0bf9c | bellard | opn = "xor";
|
1312 | 6af0bf9c | bellard | break;
|
1313 | 6af0bf9c | bellard | case OPC_MUL:
|
1314 | 6af0bf9c | bellard | gen_op_mul(); |
1315 | 6af0bf9c | bellard | opn = "mul";
|
1316 | 6af0bf9c | bellard | break;
|
1317 | 6af0bf9c | bellard | case OPC_MOVN:
|
1318 | 6af0bf9c | bellard | gen_op_movn(rd); |
1319 | 6af0bf9c | bellard | opn = "movn";
|
1320 | 6af0bf9c | bellard | goto print;
|
1321 | 6af0bf9c | bellard | case OPC_MOVZ:
|
1322 | 6af0bf9c | bellard | gen_op_movz(rd); |
1323 | 6af0bf9c | bellard | opn = "movz";
|
1324 | 6af0bf9c | bellard | goto print;
|
1325 | 6af0bf9c | bellard | case OPC_SLLV:
|
1326 | 6af0bf9c | bellard | gen_op_sllv(); |
1327 | 6af0bf9c | bellard | opn = "sllv";
|
1328 | 6af0bf9c | bellard | break;
|
1329 | 6af0bf9c | bellard | case OPC_SRAV:
|
1330 | 6af0bf9c | bellard | gen_op_srav(); |
1331 | 6af0bf9c | bellard | opn = "srav";
|
1332 | 6af0bf9c | bellard | break;
|
1333 | 6af0bf9c | bellard | case OPC_SRLV:
|
1334 | 5a63bcb2 | ths | switch ((ctx->opcode >> 6) & 0x1f) { |
1335 | 5a63bcb2 | ths | case 0: |
1336 | 7a387fff | ths | gen_op_srlv(); |
1337 | 7a387fff | ths | opn = "srlv";
|
1338 | 5a63bcb2 | ths | break;
|
1339 | 5a63bcb2 | ths | case 1: |
1340 | e189e748 | ths | /* rotrv is decoded as srlv on non-R2 CPUs */
|
1341 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1342 | e189e748 | ths | gen_op_rotrv(); |
1343 | e189e748 | ths | opn = "rotrv";
|
1344 | e189e748 | ths | } else {
|
1345 | e189e748 | ths | gen_op_srlv(); |
1346 | e189e748 | ths | opn = "srlv";
|
1347 | e189e748 | ths | } |
1348 | 5a63bcb2 | ths | break;
|
1349 | 5a63bcb2 | ths | default:
|
1350 | 5a63bcb2 | ths | MIPS_INVAL("invalid srlv flag");
|
1351 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1352 | 5a63bcb2 | ths | break;
|
1353 | 5a63bcb2 | ths | } |
1354 | 7a387fff | ths | break;
|
1355 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
1356 | 7a387fff | ths | case OPC_DSLLV:
|
1357 | 7a387fff | ths | gen_op_dsllv(); |
1358 | 7a387fff | ths | opn = "dsllv";
|
1359 | 7a387fff | ths | break;
|
1360 | 7a387fff | ths | case OPC_DSRAV:
|
1361 | 7a387fff | ths | gen_op_dsrav(); |
1362 | 7a387fff | ths | opn = "dsrav";
|
1363 | 7a387fff | ths | break;
|
1364 | 7a387fff | ths | case OPC_DSRLV:
|
1365 | 5a63bcb2 | ths | switch ((ctx->opcode >> 6) & 0x1f) { |
1366 | 5a63bcb2 | ths | case 0: |
1367 | 7a387fff | ths | gen_op_dsrlv(); |
1368 | 7a387fff | ths | opn = "dsrlv";
|
1369 | 5a63bcb2 | ths | break;
|
1370 | 5a63bcb2 | ths | case 1: |
1371 | e189e748 | ths | /* drotrv is decoded as dsrlv on non-R2 CPUs */
|
1372 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1373 | e189e748 | ths | gen_op_drotrv(); |
1374 | e189e748 | ths | opn = "drotrv";
|
1375 | e189e748 | ths | } else {
|
1376 | e189e748 | ths | gen_op_dsrlv(); |
1377 | e189e748 | ths | opn = "dsrlv";
|
1378 | e189e748 | ths | } |
1379 | 5a63bcb2 | ths | break;
|
1380 | 5a63bcb2 | ths | default:
|
1381 | 5a63bcb2 | ths | MIPS_INVAL("invalid dsrlv flag");
|
1382 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1383 | 5a63bcb2 | ths | break;
|
1384 | 5a63bcb2 | ths | } |
1385 | 6af0bf9c | bellard | break;
|
1386 | 7a387fff | ths | #endif
|
1387 | 6af0bf9c | bellard | default:
|
1388 | 923617a3 | ths | MIPS_INVAL(opn); |
1389 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1390 | 6af0bf9c | bellard | return;
|
1391 | 6af0bf9c | bellard | } |
1392 | 6af0bf9c | bellard | GEN_STORE_TN_REG(rd, T0); |
1393 | 6af0bf9c | bellard | print:
|
1394 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s, %s, %s", opn, regnames[rd], regnames[rs], regnames[rt]);
|
1395 | 6af0bf9c | bellard | } |
1396 | 6af0bf9c | bellard | |
1397 | 6af0bf9c | bellard | /* Arithmetic on HI/LO registers */
|
1398 | 7a387fff | ths | static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg) |
1399 | 6af0bf9c | bellard | { |
1400 | 923617a3 | ths | const char *opn = "hilo"; |
1401 | 6af0bf9c | bellard | |
1402 | 6af0bf9c | bellard | if (reg == 0 && (opc == OPC_MFHI || opc == OPC_MFLO)) { |
1403 | ead9360e | ths | /* Treat as NOP. */
|
1404 | 6af0bf9c | bellard | MIPS_DEBUG("NOP");
|
1405 | 6af0bf9c | bellard | return;
|
1406 | 6af0bf9c | bellard | } |
1407 | 6af0bf9c | bellard | switch (opc) {
|
1408 | 6af0bf9c | bellard | case OPC_MFHI:
|
1409 | ead9360e | ths | gen_op_load_HI(0);
|
1410 | 6af0bf9c | bellard | GEN_STORE_TN_REG(reg, T0); |
1411 | 6af0bf9c | bellard | opn = "mfhi";
|
1412 | 6af0bf9c | bellard | break;
|
1413 | 6af0bf9c | bellard | case OPC_MFLO:
|
1414 | ead9360e | ths | gen_op_load_LO(0);
|
1415 | 6af0bf9c | bellard | GEN_STORE_TN_REG(reg, T0); |
1416 | 6af0bf9c | bellard | opn = "mflo";
|
1417 | 6af0bf9c | bellard | break;
|
1418 | 6af0bf9c | bellard | case OPC_MTHI:
|
1419 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, reg); |
1420 | ead9360e | ths | gen_op_store_HI(0);
|
1421 | 6af0bf9c | bellard | opn = "mthi";
|
1422 | 6af0bf9c | bellard | break;
|
1423 | 6af0bf9c | bellard | case OPC_MTLO:
|
1424 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, reg); |
1425 | ead9360e | ths | gen_op_store_LO(0);
|
1426 | 6af0bf9c | bellard | opn = "mtlo";
|
1427 | 6af0bf9c | bellard | break;
|
1428 | 6af0bf9c | bellard | default:
|
1429 | 923617a3 | ths | MIPS_INVAL(opn); |
1430 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1431 | 6af0bf9c | bellard | return;
|
1432 | 6af0bf9c | bellard | } |
1433 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s", opn, regnames[reg]);
|
1434 | 6af0bf9c | bellard | } |
1435 | 6af0bf9c | bellard | |
1436 | 7a387fff | ths | static void gen_muldiv (DisasContext *ctx, uint32_t opc, |
1437 | 6af0bf9c | bellard | int rs, int rt) |
1438 | 6af0bf9c | bellard | { |
1439 | 923617a3 | ths | const char *opn = "mul/div"; |
1440 | 6af0bf9c | bellard | |
1441 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, rs); |
1442 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
1443 | 6af0bf9c | bellard | switch (opc) {
|
1444 | 6af0bf9c | bellard | case OPC_DIV:
|
1445 | 6af0bf9c | bellard | gen_op_div(); |
1446 | 6af0bf9c | bellard | opn = "div";
|
1447 | 6af0bf9c | bellard | break;
|
1448 | 6af0bf9c | bellard | case OPC_DIVU:
|
1449 | 6af0bf9c | bellard | gen_op_divu(); |
1450 | 6af0bf9c | bellard | opn = "divu";
|
1451 | 6af0bf9c | bellard | break;
|
1452 | 6af0bf9c | bellard | case OPC_MULT:
|
1453 | 6af0bf9c | bellard | gen_op_mult(); |
1454 | 6af0bf9c | bellard | opn = "mult";
|
1455 | 6af0bf9c | bellard | break;
|
1456 | 6af0bf9c | bellard | case OPC_MULTU:
|
1457 | 6af0bf9c | bellard | gen_op_multu(); |
1458 | 6af0bf9c | bellard | opn = "multu";
|
1459 | 6af0bf9c | bellard | break;
|
1460 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
1461 | 7a387fff | ths | case OPC_DDIV:
|
1462 | 7a387fff | ths | gen_op_ddiv(); |
1463 | 7a387fff | ths | opn = "ddiv";
|
1464 | 7a387fff | ths | break;
|
1465 | 7a387fff | ths | case OPC_DDIVU:
|
1466 | 7a387fff | ths | gen_op_ddivu(); |
1467 | 7a387fff | ths | opn = "ddivu";
|
1468 | 7a387fff | ths | break;
|
1469 | 7a387fff | ths | case OPC_DMULT:
|
1470 | 7a387fff | ths | gen_op_dmult(); |
1471 | 7a387fff | ths | opn = "dmult";
|
1472 | 7a387fff | ths | break;
|
1473 | 7a387fff | ths | case OPC_DMULTU:
|
1474 | 7a387fff | ths | gen_op_dmultu(); |
1475 | 7a387fff | ths | opn = "dmultu";
|
1476 | 7a387fff | ths | break;
|
1477 | 7a387fff | ths | #endif
|
1478 | 6af0bf9c | bellard | case OPC_MADD:
|
1479 | 6af0bf9c | bellard | gen_op_madd(); |
1480 | 6af0bf9c | bellard | opn = "madd";
|
1481 | 6af0bf9c | bellard | break;
|
1482 | 6af0bf9c | bellard | case OPC_MADDU:
|
1483 | 6af0bf9c | bellard | gen_op_maddu(); |
1484 | 6af0bf9c | bellard | opn = "maddu";
|
1485 | 6af0bf9c | bellard | break;
|
1486 | 6af0bf9c | bellard | case OPC_MSUB:
|
1487 | 6af0bf9c | bellard | gen_op_msub(); |
1488 | 6af0bf9c | bellard | opn = "msub";
|
1489 | 6af0bf9c | bellard | break;
|
1490 | 6af0bf9c | bellard | case OPC_MSUBU:
|
1491 | 6af0bf9c | bellard | gen_op_msubu(); |
1492 | 6af0bf9c | bellard | opn = "msubu";
|
1493 | 6af0bf9c | bellard | break;
|
1494 | 6af0bf9c | bellard | default:
|
1495 | 923617a3 | ths | MIPS_INVAL(opn); |
1496 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1497 | 6af0bf9c | bellard | return;
|
1498 | 6af0bf9c | bellard | } |
1499 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s %s", opn, regnames[rs], regnames[rt]);
|
1500 | 6af0bf9c | bellard | } |
1501 | 6af0bf9c | bellard | |
1502 | 7a387fff | ths | static void gen_cl (DisasContext *ctx, uint32_t opc, |
1503 | 6af0bf9c | bellard | int rd, int rs) |
1504 | 6af0bf9c | bellard | { |
1505 | 923617a3 | ths | const char *opn = "CLx"; |
1506 | 6af0bf9c | bellard | if (rd == 0) { |
1507 | ead9360e | ths | /* Treat as NOP. */
|
1508 | 6af0bf9c | bellard | MIPS_DEBUG("NOP");
|
1509 | 6af0bf9c | bellard | return;
|
1510 | 6af0bf9c | bellard | } |
1511 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, rs); |
1512 | 6af0bf9c | bellard | switch (opc) {
|
1513 | 6af0bf9c | bellard | case OPC_CLO:
|
1514 | 6af0bf9c | bellard | gen_op_clo(); |
1515 | 6af0bf9c | bellard | opn = "clo";
|
1516 | 6af0bf9c | bellard | break;
|
1517 | 6af0bf9c | bellard | case OPC_CLZ:
|
1518 | 6af0bf9c | bellard | gen_op_clz(); |
1519 | 6af0bf9c | bellard | opn = "clz";
|
1520 | 6af0bf9c | bellard | break;
|
1521 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
1522 | 7a387fff | ths | case OPC_DCLO:
|
1523 | 7a387fff | ths | gen_op_dclo(); |
1524 | 7a387fff | ths | opn = "dclo";
|
1525 | 7a387fff | ths | break;
|
1526 | 7a387fff | ths | case OPC_DCLZ:
|
1527 | 7a387fff | ths | gen_op_dclz(); |
1528 | 7a387fff | ths | opn = "dclz";
|
1529 | 7a387fff | ths | break;
|
1530 | 7a387fff | ths | #endif
|
1531 | 6af0bf9c | bellard | default:
|
1532 | 923617a3 | ths | MIPS_INVAL(opn); |
1533 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1534 | 6af0bf9c | bellard | return;
|
1535 | 6af0bf9c | bellard | } |
1536 | 6af0bf9c | bellard | gen_op_store_T0_gpr(rd); |
1537 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s, %s", opn, regnames[rd], regnames[rs]);
|
1538 | 6af0bf9c | bellard | } |
1539 | 6af0bf9c | bellard | |
1540 | 6af0bf9c | bellard | /* Traps */
|
1541 | 7a387fff | ths | static void gen_trap (DisasContext *ctx, uint32_t opc, |
1542 | 6af0bf9c | bellard | int rs, int rt, int16_t imm) |
1543 | 6af0bf9c | bellard | { |
1544 | 6af0bf9c | bellard | int cond;
|
1545 | 6af0bf9c | bellard | |
1546 | 6af0bf9c | bellard | cond = 0;
|
1547 | 6af0bf9c | bellard | /* Load needed operands */
|
1548 | 6af0bf9c | bellard | switch (opc) {
|
1549 | 6af0bf9c | bellard | case OPC_TEQ:
|
1550 | 6af0bf9c | bellard | case OPC_TGE:
|
1551 | 6af0bf9c | bellard | case OPC_TGEU:
|
1552 | 6af0bf9c | bellard | case OPC_TLT:
|
1553 | 6af0bf9c | bellard | case OPC_TLTU:
|
1554 | 6af0bf9c | bellard | case OPC_TNE:
|
1555 | 6af0bf9c | bellard | /* Compare two registers */
|
1556 | 6af0bf9c | bellard | if (rs != rt) {
|
1557 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, rs); |
1558 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
1559 | 6af0bf9c | bellard | cond = 1;
|
1560 | 6af0bf9c | bellard | } |
1561 | 179e32bb | ths | break;
|
1562 | 6af0bf9c | bellard | case OPC_TEQI:
|
1563 | 6af0bf9c | bellard | case OPC_TGEI:
|
1564 | 6af0bf9c | bellard | case OPC_TGEIU:
|
1565 | 6af0bf9c | bellard | case OPC_TLTI:
|
1566 | 6af0bf9c | bellard | case OPC_TLTIU:
|
1567 | 6af0bf9c | bellard | case OPC_TNEI:
|
1568 | 6af0bf9c | bellard | /* Compare register to immediate */
|
1569 | 6af0bf9c | bellard | if (rs != 0 || imm != 0) { |
1570 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, rs); |
1571 | 6af0bf9c | bellard | GEN_LOAD_IMM_TN(T1, (int32_t)imm); |
1572 | 6af0bf9c | bellard | cond = 1;
|
1573 | 6af0bf9c | bellard | } |
1574 | 6af0bf9c | bellard | break;
|
1575 | 6af0bf9c | bellard | } |
1576 | 6af0bf9c | bellard | if (cond == 0) { |
1577 | 6af0bf9c | bellard | switch (opc) {
|
1578 | 6af0bf9c | bellard | case OPC_TEQ: /* rs == rs */ |
1579 | 6af0bf9c | bellard | case OPC_TEQI: /* r0 == 0 */ |
1580 | 6af0bf9c | bellard | case OPC_TGE: /* rs >= rs */ |
1581 | 6af0bf9c | bellard | case OPC_TGEI: /* r0 >= 0 */ |
1582 | 6af0bf9c | bellard | case OPC_TGEU: /* rs >= rs unsigned */ |
1583 | 6af0bf9c | bellard | case OPC_TGEIU: /* r0 >= 0 unsigned */ |
1584 | 6af0bf9c | bellard | /* Always trap */
|
1585 | 6af0bf9c | bellard | gen_op_set_T0(1);
|
1586 | 6af0bf9c | bellard | break;
|
1587 | 6af0bf9c | bellard | case OPC_TLT: /* rs < rs */ |
1588 | 6af0bf9c | bellard | case OPC_TLTI: /* r0 < 0 */ |
1589 | 6af0bf9c | bellard | case OPC_TLTU: /* rs < rs unsigned */ |
1590 | 6af0bf9c | bellard | case OPC_TLTIU: /* r0 < 0 unsigned */ |
1591 | 6af0bf9c | bellard | case OPC_TNE: /* rs != rs */ |
1592 | 6af0bf9c | bellard | case OPC_TNEI: /* r0 != 0 */ |
1593 | ead9360e | ths | /* Never trap: treat as NOP. */
|
1594 | 6af0bf9c | bellard | return;
|
1595 | 6af0bf9c | bellard | default:
|
1596 | 923617a3 | ths | MIPS_INVAL("trap");
|
1597 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1598 | 6af0bf9c | bellard | return;
|
1599 | 6af0bf9c | bellard | } |
1600 | 6af0bf9c | bellard | } else {
|
1601 | 6af0bf9c | bellard | switch (opc) {
|
1602 | 6af0bf9c | bellard | case OPC_TEQ:
|
1603 | 6af0bf9c | bellard | case OPC_TEQI:
|
1604 | 6af0bf9c | bellard | gen_op_eq(); |
1605 | 6af0bf9c | bellard | break;
|
1606 | 6af0bf9c | bellard | case OPC_TGE:
|
1607 | 6af0bf9c | bellard | case OPC_TGEI:
|
1608 | 6af0bf9c | bellard | gen_op_ge(); |
1609 | 6af0bf9c | bellard | break;
|
1610 | 6af0bf9c | bellard | case OPC_TGEU:
|
1611 | 6af0bf9c | bellard | case OPC_TGEIU:
|
1612 | 6af0bf9c | bellard | gen_op_geu(); |
1613 | 6af0bf9c | bellard | break;
|
1614 | 6af0bf9c | bellard | case OPC_TLT:
|
1615 | 6af0bf9c | bellard | case OPC_TLTI:
|
1616 | 6af0bf9c | bellard | gen_op_lt(); |
1617 | 6af0bf9c | bellard | break;
|
1618 | 6af0bf9c | bellard | case OPC_TLTU:
|
1619 | 6af0bf9c | bellard | case OPC_TLTIU:
|
1620 | 6af0bf9c | bellard | gen_op_ltu(); |
1621 | 6af0bf9c | bellard | break;
|
1622 | 6af0bf9c | bellard | case OPC_TNE:
|
1623 | 6af0bf9c | bellard | case OPC_TNEI:
|
1624 | 6af0bf9c | bellard | gen_op_ne(); |
1625 | 6af0bf9c | bellard | break;
|
1626 | 6af0bf9c | bellard | default:
|
1627 | 923617a3 | ths | MIPS_INVAL("trap");
|
1628 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1629 | 6af0bf9c | bellard | return;
|
1630 | 6af0bf9c | bellard | } |
1631 | 6af0bf9c | bellard | } |
1632 | 6af0bf9c | bellard | save_cpu_state(ctx, 1);
|
1633 | 6af0bf9c | bellard | gen_op_trap(); |
1634 | 6af0bf9c | bellard | ctx->bstate = BS_STOP; |
1635 | 6af0bf9c | bellard | } |
1636 | 6af0bf9c | bellard | |
1637 | aa343735 | ths | static always_inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest) |
1638 | c53be334 | bellard | { |
1639 | 6e256c93 | bellard | TranslationBlock *tb; |
1640 | 6e256c93 | bellard | tb = ctx->tb; |
1641 | 6e256c93 | bellard | if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
|
1642 | 6e256c93 | bellard | if (n == 0) |
1643 | 6e256c93 | bellard | gen_op_goto_tb0(TBPARAM(tb)); |
1644 | 6e256c93 | bellard | else
|
1645 | 6e256c93 | bellard | gen_op_goto_tb1(TBPARAM(tb)); |
1646 | 9b9e4393 | ths | gen_save_pc(dest); |
1647 | 6e256c93 | bellard | gen_op_set_T0((long)tb + n);
|
1648 | 6e256c93 | bellard | } else {
|
1649 | 9b9e4393 | ths | gen_save_pc(dest); |
1650 | 9898128f | ths | gen_op_reset_T0(); |
1651 | 6e256c93 | bellard | } |
1652 | 9898128f | ths | gen_op_exit_tb(); |
1653 | c53be334 | bellard | } |
1654 | c53be334 | bellard | |
1655 | 6af0bf9c | bellard | /* Branches (before delay slot) */
|
1656 | 7a387fff | ths | static void gen_compute_branch (DisasContext *ctx, uint32_t opc, |
1657 | 6af0bf9c | bellard | int rs, int rt, int32_t offset) |
1658 | 6af0bf9c | bellard | { |
1659 | 3ad4bb2d | ths | target_ulong btarget = -1;
|
1660 | 3ad4bb2d | ths | int blink = 0; |
1661 | 3ad4bb2d | ths | int bcond = 0; |
1662 | 3ad4bb2d | ths | |
1663 | 3ad4bb2d | ths | if (ctx->hflags & MIPS_HFLAG_BMASK) {
|
1664 | 923617a3 | ths | #ifdef MIPS_DEBUG_DISAS
|
1665 | 3ad4bb2d | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
1666 | 3ad4bb2d | ths | fprintf(logfile, |
1667 | 5a5012ec | ths | "Branch in delay slot at PC 0x" TARGET_FMT_lx "\n", |
1668 | 38121543 | ths | ctx->pc); |
1669 | 3ad4bb2d | ths | } |
1670 | 923617a3 | ths | #endif
|
1671 | 3ad4bb2d | ths | generate_exception(ctx, EXCP_RI); |
1672 | 3ad4bb2d | ths | return;
|
1673 | 3ad4bb2d | ths | } |
1674 | 6af0bf9c | bellard | |
1675 | 6af0bf9c | bellard | /* Load needed operands */
|
1676 | 6af0bf9c | bellard | switch (opc) {
|
1677 | 6af0bf9c | bellard | case OPC_BEQ:
|
1678 | 6af0bf9c | bellard | case OPC_BEQL:
|
1679 | 6af0bf9c | bellard | case OPC_BNE:
|
1680 | 6af0bf9c | bellard | case OPC_BNEL:
|
1681 | 6af0bf9c | bellard | /* Compare two registers */
|
1682 | 6af0bf9c | bellard | if (rs != rt) {
|
1683 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, rs); |
1684 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T1, rt); |
1685 | 6af0bf9c | bellard | bcond = 1;
|
1686 | 6af0bf9c | bellard | } |
1687 | 6af0bf9c | bellard | btarget = ctx->pc + 4 + offset;
|
1688 | 6af0bf9c | bellard | break;
|
1689 | 6af0bf9c | bellard | case OPC_BGEZ:
|
1690 | 6af0bf9c | bellard | case OPC_BGEZAL:
|
1691 | 6af0bf9c | bellard | case OPC_BGEZALL:
|
1692 | 6af0bf9c | bellard | case OPC_BGEZL:
|
1693 | 6af0bf9c | bellard | case OPC_BGTZ:
|
1694 | 6af0bf9c | bellard | case OPC_BGTZL:
|
1695 | 6af0bf9c | bellard | case OPC_BLEZ:
|
1696 | 6af0bf9c | bellard | case OPC_BLEZL:
|
1697 | 6af0bf9c | bellard | case OPC_BLTZ:
|
1698 | 6af0bf9c | bellard | case OPC_BLTZAL:
|
1699 | 6af0bf9c | bellard | case OPC_BLTZALL:
|
1700 | 6af0bf9c | bellard | case OPC_BLTZL:
|
1701 | 6af0bf9c | bellard | /* Compare to zero */
|
1702 | 6af0bf9c | bellard | if (rs != 0) { |
1703 | 6af0bf9c | bellard | gen_op_load_gpr_T0(rs); |
1704 | 6af0bf9c | bellard | bcond = 1;
|
1705 | 6af0bf9c | bellard | } |
1706 | 6af0bf9c | bellard | btarget = ctx->pc + 4 + offset;
|
1707 | 6af0bf9c | bellard | break;
|
1708 | 6af0bf9c | bellard | case OPC_J:
|
1709 | 6af0bf9c | bellard | case OPC_JAL:
|
1710 | 6af0bf9c | bellard | /* Jump to immediate */
|
1711 | 9b9e4393 | ths | btarget = ((ctx->pc + 4) & (int32_t)0xF0000000) | (uint32_t)offset; |
1712 | 6af0bf9c | bellard | break;
|
1713 | 6af0bf9c | bellard | case OPC_JR:
|
1714 | 6af0bf9c | bellard | case OPC_JALR:
|
1715 | 6af0bf9c | bellard | /* Jump to register */
|
1716 | 7a387fff | ths | if (offset != 0 && offset != 16) { |
1717 | 7a387fff | ths | /* Hint = 0 is JR/JALR, hint 16 is JR.HB/JALR.HB, the
|
1718 | cbeb0857 | ths | others are reserved. */
|
1719 | 923617a3 | ths | MIPS_INVAL("jump hint");
|
1720 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1721 | 6af0bf9c | bellard | return;
|
1722 | 6af0bf9c | bellard | } |
1723 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T2, rs); |
1724 | 6af0bf9c | bellard | break;
|
1725 | 6af0bf9c | bellard | default:
|
1726 | 6af0bf9c | bellard | MIPS_INVAL("branch/jump");
|
1727 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1728 | 6af0bf9c | bellard | return;
|
1729 | 6af0bf9c | bellard | } |
1730 | 6af0bf9c | bellard | if (bcond == 0) { |
1731 | 6af0bf9c | bellard | /* No condition to be computed */
|
1732 | 6af0bf9c | bellard | switch (opc) {
|
1733 | 6af0bf9c | bellard | case OPC_BEQ: /* rx == rx */ |
1734 | 6af0bf9c | bellard | case OPC_BEQL: /* rx == rx likely */ |
1735 | 6af0bf9c | bellard | case OPC_BGEZ: /* 0 >= 0 */ |
1736 | 6af0bf9c | bellard | case OPC_BGEZL: /* 0 >= 0 likely */ |
1737 | 6af0bf9c | bellard | case OPC_BLEZ: /* 0 <= 0 */ |
1738 | 6af0bf9c | bellard | case OPC_BLEZL: /* 0 <= 0 likely */ |
1739 | 6af0bf9c | bellard | /* Always take */
|
1740 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_B; |
1741 | 6af0bf9c | bellard | MIPS_DEBUG("balways");
|
1742 | 6af0bf9c | bellard | break;
|
1743 | 6af0bf9c | bellard | case OPC_BGEZAL: /* 0 >= 0 */ |
1744 | 6af0bf9c | bellard | case OPC_BGEZALL: /* 0 >= 0 likely */ |
1745 | 6af0bf9c | bellard | /* Always take and link */
|
1746 | 6af0bf9c | bellard | blink = 31;
|
1747 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_B; |
1748 | 6af0bf9c | bellard | MIPS_DEBUG("balways and link");
|
1749 | 6af0bf9c | bellard | break;
|
1750 | 6af0bf9c | bellard | case OPC_BNE: /* rx != rx */ |
1751 | 6af0bf9c | bellard | case OPC_BGTZ: /* 0 > 0 */ |
1752 | 6af0bf9c | bellard | case OPC_BLTZ: /* 0 < 0 */ |
1753 | ead9360e | ths | /* Treat as NOP. */
|
1754 | 6af0bf9c | bellard | MIPS_DEBUG("bnever (NOP)");
|
1755 | 6af0bf9c | bellard | return;
|
1756 | eeef26cd | bellard | case OPC_BLTZAL: /* 0 < 0 */ |
1757 | 9b9e4393 | ths | GEN_LOAD_IMM_TN(T0, ctx->pc + 8);
|
1758 | eeef26cd | bellard | gen_op_store_T0_gpr(31);
|
1759 | 9898128f | ths | MIPS_DEBUG("bnever and link");
|
1760 | eeef26cd | bellard | return;
|
1761 | eeef26cd | bellard | case OPC_BLTZALL: /* 0 < 0 likely */ |
1762 | 9b9e4393 | ths | GEN_LOAD_IMM_TN(T0, ctx->pc + 8);
|
1763 | eeef26cd | bellard | gen_op_store_T0_gpr(31);
|
1764 | 9898128f | ths | /* Skip the instruction in the delay slot */
|
1765 | 9898128f | ths | MIPS_DEBUG("bnever, link and skip");
|
1766 | 9898128f | ths | ctx->pc += 4;
|
1767 | eeef26cd | bellard | return;
|
1768 | 6af0bf9c | bellard | case OPC_BNEL: /* rx != rx likely */ |
1769 | 6af0bf9c | bellard | case OPC_BGTZL: /* 0 > 0 likely */ |
1770 | 6af0bf9c | bellard | case OPC_BLTZL: /* 0 < 0 likely */ |
1771 | 6af0bf9c | bellard | /* Skip the instruction in the delay slot */
|
1772 | 6af0bf9c | bellard | MIPS_DEBUG("bnever and skip");
|
1773 | 9898128f | ths | ctx->pc += 4;
|
1774 | 6af0bf9c | bellard | return;
|
1775 | 6af0bf9c | bellard | case OPC_J:
|
1776 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_B; |
1777 | 923617a3 | ths | MIPS_DEBUG("j " TARGET_FMT_lx, btarget);
|
1778 | 6af0bf9c | bellard | break;
|
1779 | 6af0bf9c | bellard | case OPC_JAL:
|
1780 | 6af0bf9c | bellard | blink = 31;
|
1781 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_B; |
1782 | 923617a3 | ths | MIPS_DEBUG("jal " TARGET_FMT_lx, btarget);
|
1783 | 6af0bf9c | bellard | break;
|
1784 | 6af0bf9c | bellard | case OPC_JR:
|
1785 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_BR; |
1786 | 6af0bf9c | bellard | MIPS_DEBUG("jr %s", regnames[rs]);
|
1787 | 6af0bf9c | bellard | break;
|
1788 | 6af0bf9c | bellard | case OPC_JALR:
|
1789 | 6af0bf9c | bellard | blink = rt; |
1790 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_BR; |
1791 | 6af0bf9c | bellard | MIPS_DEBUG("jalr %s, %s", regnames[rt], regnames[rs]);
|
1792 | 6af0bf9c | bellard | break;
|
1793 | 6af0bf9c | bellard | default:
|
1794 | 6af0bf9c | bellard | MIPS_INVAL("branch/jump");
|
1795 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1796 | 6af0bf9c | bellard | return;
|
1797 | 6af0bf9c | bellard | } |
1798 | 6af0bf9c | bellard | } else {
|
1799 | 6af0bf9c | bellard | switch (opc) {
|
1800 | 6af0bf9c | bellard | case OPC_BEQ:
|
1801 | 6af0bf9c | bellard | gen_op_eq(); |
1802 | 923617a3 | ths | MIPS_DEBUG("beq %s, %s, " TARGET_FMT_lx,
|
1803 | 6af0bf9c | bellard | regnames[rs], regnames[rt], btarget); |
1804 | 6af0bf9c | bellard | goto not_likely;
|
1805 | 6af0bf9c | bellard | case OPC_BEQL:
|
1806 | 6af0bf9c | bellard | gen_op_eq(); |
1807 | 923617a3 | ths | MIPS_DEBUG("beql %s, %s, " TARGET_FMT_lx,
|
1808 | 6af0bf9c | bellard | regnames[rs], regnames[rt], btarget); |
1809 | 6af0bf9c | bellard | goto likely;
|
1810 | 6af0bf9c | bellard | case OPC_BNE:
|
1811 | 6af0bf9c | bellard | gen_op_ne(); |
1812 | 923617a3 | ths | MIPS_DEBUG("bne %s, %s, " TARGET_FMT_lx,
|
1813 | 6af0bf9c | bellard | regnames[rs], regnames[rt], btarget); |
1814 | 6af0bf9c | bellard | goto not_likely;
|
1815 | 6af0bf9c | bellard | case OPC_BNEL:
|
1816 | 6af0bf9c | bellard | gen_op_ne(); |
1817 | 923617a3 | ths | MIPS_DEBUG("bnel %s, %s, " TARGET_FMT_lx,
|
1818 | 6af0bf9c | bellard | regnames[rs], regnames[rt], btarget); |
1819 | 6af0bf9c | bellard | goto likely;
|
1820 | 6af0bf9c | bellard | case OPC_BGEZ:
|
1821 | 6af0bf9c | bellard | gen_op_gez(); |
1822 | 923617a3 | ths | MIPS_DEBUG("bgez %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1823 | 6af0bf9c | bellard | goto not_likely;
|
1824 | 6af0bf9c | bellard | case OPC_BGEZL:
|
1825 | 6af0bf9c | bellard | gen_op_gez(); |
1826 | 923617a3 | ths | MIPS_DEBUG("bgezl %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1827 | 6af0bf9c | bellard | goto likely;
|
1828 | 6af0bf9c | bellard | case OPC_BGEZAL:
|
1829 | 6af0bf9c | bellard | gen_op_gez(); |
1830 | 923617a3 | ths | MIPS_DEBUG("bgezal %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1831 | 6af0bf9c | bellard | blink = 31;
|
1832 | 6af0bf9c | bellard | goto not_likely;
|
1833 | 6af0bf9c | bellard | case OPC_BGEZALL:
|
1834 | 6af0bf9c | bellard | gen_op_gez(); |
1835 | 6af0bf9c | bellard | blink = 31;
|
1836 | 923617a3 | ths | MIPS_DEBUG("bgezall %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1837 | 6af0bf9c | bellard | goto likely;
|
1838 | 6af0bf9c | bellard | case OPC_BGTZ:
|
1839 | 6af0bf9c | bellard | gen_op_gtz(); |
1840 | 923617a3 | ths | MIPS_DEBUG("bgtz %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1841 | 6af0bf9c | bellard | goto not_likely;
|
1842 | 6af0bf9c | bellard | case OPC_BGTZL:
|
1843 | 6af0bf9c | bellard | gen_op_gtz(); |
1844 | 923617a3 | ths | MIPS_DEBUG("bgtzl %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1845 | 6af0bf9c | bellard | goto likely;
|
1846 | 6af0bf9c | bellard | case OPC_BLEZ:
|
1847 | 6af0bf9c | bellard | gen_op_lez(); |
1848 | 923617a3 | ths | MIPS_DEBUG("blez %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1849 | 6af0bf9c | bellard | goto not_likely;
|
1850 | 6af0bf9c | bellard | case OPC_BLEZL:
|
1851 | 6af0bf9c | bellard | gen_op_lez(); |
1852 | 923617a3 | ths | MIPS_DEBUG("blezl %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1853 | 6af0bf9c | bellard | goto likely;
|
1854 | 6af0bf9c | bellard | case OPC_BLTZ:
|
1855 | 6af0bf9c | bellard | gen_op_ltz(); |
1856 | 923617a3 | ths | MIPS_DEBUG("bltz %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1857 | 6af0bf9c | bellard | goto not_likely;
|
1858 | 6af0bf9c | bellard | case OPC_BLTZL:
|
1859 | 6af0bf9c | bellard | gen_op_ltz(); |
1860 | 923617a3 | ths | MIPS_DEBUG("bltzl %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1861 | 6af0bf9c | bellard | goto likely;
|
1862 | 6af0bf9c | bellard | case OPC_BLTZAL:
|
1863 | 6af0bf9c | bellard | gen_op_ltz(); |
1864 | 6af0bf9c | bellard | blink = 31;
|
1865 | 923617a3 | ths | MIPS_DEBUG("bltzal %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1866 | 6af0bf9c | bellard | not_likely:
|
1867 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_BC; |
1868 | 5a5012ec | ths | gen_op_set_bcond(); |
1869 | 6af0bf9c | bellard | break;
|
1870 | 6af0bf9c | bellard | case OPC_BLTZALL:
|
1871 | 6af0bf9c | bellard | gen_op_ltz(); |
1872 | 6af0bf9c | bellard | blink = 31;
|
1873 | 923617a3 | ths | MIPS_DEBUG("bltzall %s, " TARGET_FMT_lx, regnames[rs], btarget);
|
1874 | 6af0bf9c | bellard | likely:
|
1875 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_BL; |
1876 | 5a5012ec | ths | gen_op_set_bcond(); |
1877 | 5a5012ec | ths | gen_op_save_bcond(); |
1878 | 6af0bf9c | bellard | break;
|
1879 | c53f4a62 | ths | default:
|
1880 | c53f4a62 | ths | MIPS_INVAL("conditional branch/jump");
|
1881 | c53f4a62 | ths | generate_exception(ctx, EXCP_RI); |
1882 | c53f4a62 | ths | return;
|
1883 | 6af0bf9c | bellard | } |
1884 | 6af0bf9c | bellard | } |
1885 | 923617a3 | ths | MIPS_DEBUG("enter ds: link %d cond %02x target " TARGET_FMT_lx,
|
1886 | 6af0bf9c | bellard | blink, ctx->hflags, btarget); |
1887 | 9b9e4393 | ths | |
1888 | 6af0bf9c | bellard | ctx->btarget = btarget; |
1889 | 6af0bf9c | bellard | if (blink > 0) { |
1890 | 9b9e4393 | ths | GEN_LOAD_IMM_TN(T0, ctx->pc + 8);
|
1891 | 6af0bf9c | bellard | gen_op_store_T0_gpr(blink); |
1892 | 6af0bf9c | bellard | } |
1893 | 6af0bf9c | bellard | } |
1894 | 6af0bf9c | bellard | |
1895 | 7a387fff | ths | /* special3 bitfield operations */
|
1896 | 7a387fff | ths | static void gen_bitops (DisasContext *ctx, uint32_t opc, int rt, |
1897 | 7a387fff | ths | int rs, int lsb, int msb) |
1898 | 7a387fff | ths | { |
1899 | 7a387fff | ths | GEN_LOAD_REG_TN(T1, rs); |
1900 | 7a387fff | ths | switch (opc) {
|
1901 | 7a387fff | ths | case OPC_EXT:
|
1902 | 7a387fff | ths | if (lsb + msb > 31) |
1903 | 7a387fff | ths | goto fail;
|
1904 | 7a387fff | ths | gen_op_ext(lsb, msb + 1);
|
1905 | 7a387fff | ths | break;
|
1906 | 7a387fff | ths | case OPC_DEXTM:
|
1907 | 7a387fff | ths | if (lsb + msb > 63) |
1908 | 7a387fff | ths | goto fail;
|
1909 | 7a387fff | ths | gen_op_ext(lsb, msb + 1 + 32); |
1910 | 7a387fff | ths | break;
|
1911 | 7a387fff | ths | case OPC_DEXTU:
|
1912 | 7a387fff | ths | if (lsb + msb > 63) |
1913 | 7a387fff | ths | goto fail;
|
1914 | 7a387fff | ths | gen_op_ext(lsb + 32, msb + 1); |
1915 | 7a387fff | ths | break;
|
1916 | 7a387fff | ths | case OPC_DEXT:
|
1917 | 7a387fff | ths | gen_op_ext(lsb, msb + 1);
|
1918 | 7a387fff | ths | break;
|
1919 | 7a387fff | ths | case OPC_INS:
|
1920 | 7a387fff | ths | if (lsb > msb)
|
1921 | 7a387fff | ths | goto fail;
|
1922 | 171b31e7 | ths | GEN_LOAD_REG_TN(T0, rt); |
1923 | 7a387fff | ths | gen_op_ins(lsb, msb - lsb + 1);
|
1924 | 7a387fff | ths | break;
|
1925 | 7a387fff | ths | case OPC_DINSM:
|
1926 | 7a387fff | ths | if (lsb > msb)
|
1927 | 7a387fff | ths | goto fail;
|
1928 | 171b31e7 | ths | GEN_LOAD_REG_TN(T0, rt); |
1929 | 7a387fff | ths | gen_op_ins(lsb, msb - lsb + 1 + 32); |
1930 | 7a387fff | ths | break;
|
1931 | 7a387fff | ths | case OPC_DINSU:
|
1932 | 7a387fff | ths | if (lsb > msb)
|
1933 | 7a387fff | ths | goto fail;
|
1934 | 171b31e7 | ths | GEN_LOAD_REG_TN(T0, rt); |
1935 | 7a387fff | ths | gen_op_ins(lsb + 32, msb - lsb + 1); |
1936 | 7a387fff | ths | break;
|
1937 | 7a387fff | ths | case OPC_DINS:
|
1938 | 7a387fff | ths | if (lsb > msb)
|
1939 | 7a387fff | ths | goto fail;
|
1940 | 171b31e7 | ths | GEN_LOAD_REG_TN(T0, rt); |
1941 | 7a387fff | ths | gen_op_ins(lsb, msb - lsb + 1);
|
1942 | 7a387fff | ths | break;
|
1943 | 7a387fff | ths | default:
|
1944 | 7a387fff | ths | fail:
|
1945 | 7a387fff | ths | MIPS_INVAL("bitops");
|
1946 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
1947 | 7a387fff | ths | return;
|
1948 | 7a387fff | ths | } |
1949 | 7a387fff | ths | GEN_STORE_TN_REG(rt, T0); |
1950 | 7a387fff | ths | } |
1951 | 7a387fff | ths | |
1952 | 6af0bf9c | bellard | /* CP0 (MMU and control) */
|
1953 | 3a95e3a7 | ths | static void gen_mfc0 (CPUState *env, DisasContext *ctx, int reg, int sel) |
1954 | 873eb012 | ths | { |
1955 | 7a387fff | ths | const char *rn = "invalid"; |
1956 | 873eb012 | ths | |
1957 | e189e748 | ths | if (sel != 0) |
1958 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
1959 | e189e748 | ths | |
1960 | 873eb012 | ths | switch (reg) {
|
1961 | 873eb012 | ths | case 0: |
1962 | 7a387fff | ths | switch (sel) {
|
1963 | 7a387fff | ths | case 0: |
1964 | 2423f660 | ths | gen_op_mfc0_index(); |
1965 | 7a387fff | ths | rn = "Index";
|
1966 | 7a387fff | ths | break;
|
1967 | 7a387fff | ths | case 1: |
1968 | ead9360e | ths | check_mips_mt(env, ctx); |
1969 | ead9360e | ths | gen_op_mfc0_mvpcontrol(); |
1970 | 7a387fff | ths | rn = "MVPControl";
|
1971 | ead9360e | ths | break;
|
1972 | 7a387fff | ths | case 2: |
1973 | ead9360e | ths | check_mips_mt(env, ctx); |
1974 | ead9360e | ths | gen_op_mfc0_mvpconf0(); |
1975 | 7a387fff | ths | rn = "MVPConf0";
|
1976 | ead9360e | ths | break;
|
1977 | 7a387fff | ths | case 3: |
1978 | ead9360e | ths | check_mips_mt(env, ctx); |
1979 | ead9360e | ths | gen_op_mfc0_mvpconf1(); |
1980 | 7a387fff | ths | rn = "MVPConf1";
|
1981 | ead9360e | ths | break;
|
1982 | 7a387fff | ths | default:
|
1983 | 7a387fff | ths | goto die;
|
1984 | 7a387fff | ths | } |
1985 | 873eb012 | ths | break;
|
1986 | 873eb012 | ths | case 1: |
1987 | 7a387fff | ths | switch (sel) {
|
1988 | 7a387fff | ths | case 0: |
1989 | 7a387fff | ths | gen_op_mfc0_random(); |
1990 | 7a387fff | ths | rn = "Random";
|
1991 | 2423f660 | ths | break;
|
1992 | 7a387fff | ths | case 1: |
1993 | ead9360e | ths | check_mips_mt(env, ctx); |
1994 | ead9360e | ths | gen_op_mfc0_vpecontrol(); |
1995 | 7a387fff | ths | rn = "VPEControl";
|
1996 | ead9360e | ths | break;
|
1997 | 7a387fff | ths | case 2: |
1998 | ead9360e | ths | check_mips_mt(env, ctx); |
1999 | ead9360e | ths | gen_op_mfc0_vpeconf0(); |
2000 | 7a387fff | ths | rn = "VPEConf0";
|
2001 | ead9360e | ths | break;
|
2002 | 7a387fff | ths | case 3: |
2003 | ead9360e | ths | check_mips_mt(env, ctx); |
2004 | ead9360e | ths | gen_op_mfc0_vpeconf1(); |
2005 | 7a387fff | ths | rn = "VPEConf1";
|
2006 | ead9360e | ths | break;
|
2007 | 7a387fff | ths | case 4: |
2008 | ead9360e | ths | check_mips_mt(env, ctx); |
2009 | ead9360e | ths | gen_op_mfc0_yqmask(); |
2010 | 7a387fff | ths | rn = "YQMask";
|
2011 | ead9360e | ths | break;
|
2012 | 7a387fff | ths | case 5: |
2013 | ead9360e | ths | check_mips_mt(env, ctx); |
2014 | ead9360e | ths | gen_op_mfc0_vpeschedule(); |
2015 | 7a387fff | ths | rn = "VPESchedule";
|
2016 | ead9360e | ths | break;
|
2017 | 7a387fff | ths | case 6: |
2018 | ead9360e | ths | check_mips_mt(env, ctx); |
2019 | ead9360e | ths | gen_op_mfc0_vpeschefback(); |
2020 | 7a387fff | ths | rn = "VPEScheFBack";
|
2021 | ead9360e | ths | break;
|
2022 | 7a387fff | ths | case 7: |
2023 | ead9360e | ths | check_mips_mt(env, ctx); |
2024 | ead9360e | ths | gen_op_mfc0_vpeopt(); |
2025 | 7a387fff | ths | rn = "VPEOpt";
|
2026 | ead9360e | ths | break;
|
2027 | 7a387fff | ths | default:
|
2028 | 7a387fff | ths | goto die;
|
2029 | 7a387fff | ths | } |
2030 | 873eb012 | ths | break;
|
2031 | 873eb012 | ths | case 2: |
2032 | 7a387fff | ths | switch (sel) {
|
2033 | 7a387fff | ths | case 0: |
2034 | 2423f660 | ths | gen_op_mfc0_entrylo0(); |
2035 | 2423f660 | ths | rn = "EntryLo0";
|
2036 | 2423f660 | ths | break;
|
2037 | 7a387fff | ths | case 1: |
2038 | ead9360e | ths | check_mips_mt(env, ctx); |
2039 | ead9360e | ths | gen_op_mfc0_tcstatus(); |
2040 | 2423f660 | ths | rn = "TCStatus";
|
2041 | ead9360e | ths | break;
|
2042 | 7a387fff | ths | case 2: |
2043 | ead9360e | ths | check_mips_mt(env, ctx); |
2044 | ead9360e | ths | gen_op_mfc0_tcbind(); |
2045 | 2423f660 | ths | rn = "TCBind";
|
2046 | ead9360e | ths | break;
|
2047 | 7a387fff | ths | case 3: |
2048 | ead9360e | ths | check_mips_mt(env, ctx); |
2049 | ead9360e | ths | gen_op_mfc0_tcrestart(); |
2050 | 2423f660 | ths | rn = "TCRestart";
|
2051 | ead9360e | ths | break;
|
2052 | 7a387fff | ths | case 4: |
2053 | ead9360e | ths | check_mips_mt(env, ctx); |
2054 | ead9360e | ths | gen_op_mfc0_tchalt(); |
2055 | 2423f660 | ths | rn = "TCHalt";
|
2056 | ead9360e | ths | break;
|
2057 | 7a387fff | ths | case 5: |
2058 | ead9360e | ths | check_mips_mt(env, ctx); |
2059 | ead9360e | ths | gen_op_mfc0_tccontext(); |
2060 | 2423f660 | ths | rn = "TCContext";
|
2061 | ead9360e | ths | break;
|
2062 | 7a387fff | ths | case 6: |
2063 | ead9360e | ths | check_mips_mt(env, ctx); |
2064 | ead9360e | ths | gen_op_mfc0_tcschedule(); |
2065 | 2423f660 | ths | rn = "TCSchedule";
|
2066 | ead9360e | ths | break;
|
2067 | 7a387fff | ths | case 7: |
2068 | ead9360e | ths | check_mips_mt(env, ctx); |
2069 | ead9360e | ths | gen_op_mfc0_tcschefback(); |
2070 | 2423f660 | ths | rn = "TCScheFBack";
|
2071 | ead9360e | ths | break;
|
2072 | 7a387fff | ths | default:
|
2073 | 7a387fff | ths | goto die;
|
2074 | 7a387fff | ths | } |
2075 | 873eb012 | ths | break;
|
2076 | 873eb012 | ths | case 3: |
2077 | 7a387fff | ths | switch (sel) {
|
2078 | 7a387fff | ths | case 0: |
2079 | 2423f660 | ths | gen_op_mfc0_entrylo1(); |
2080 | 2423f660 | ths | rn = "EntryLo1";
|
2081 | 2423f660 | ths | break;
|
2082 | 7a387fff | ths | default:
|
2083 | 7a387fff | ths | goto die;
|
2084 | 1579a72e | ths | } |
2085 | 873eb012 | ths | break;
|
2086 | 873eb012 | ths | case 4: |
2087 | 7a387fff | ths | switch (sel) {
|
2088 | 7a387fff | ths | case 0: |
2089 | 2423f660 | ths | gen_op_mfc0_context(); |
2090 | 2423f660 | ths | rn = "Context";
|
2091 | 2423f660 | ths | break;
|
2092 | 7a387fff | ths | case 1: |
2093 | 2423f660 | ths | // gen_op_mfc0_contextconfig(); /* SmartMIPS ASE */
|
2094 | 2423f660 | ths | rn = "ContextConfig";
|
2095 | 2423f660 | ths | // break;
|
2096 | 7a387fff | ths | default:
|
2097 | 7a387fff | ths | goto die;
|
2098 | 1579a72e | ths | } |
2099 | 873eb012 | ths | break;
|
2100 | 873eb012 | ths | case 5: |
2101 | 7a387fff | ths | switch (sel) {
|
2102 | 7a387fff | ths | case 0: |
2103 | 2423f660 | ths | gen_op_mfc0_pagemask(); |
2104 | 2423f660 | ths | rn = "PageMask";
|
2105 | 2423f660 | ths | break;
|
2106 | 7a387fff | ths | case 1: |
2107 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2108 | 2423f660 | ths | gen_op_mfc0_pagegrain(); |
2109 | 2423f660 | ths | rn = "PageGrain";
|
2110 | 2423f660 | ths | break;
|
2111 | 7a387fff | ths | default:
|
2112 | 7a387fff | ths | goto die;
|
2113 | 1579a72e | ths | } |
2114 | 873eb012 | ths | break;
|
2115 | 873eb012 | ths | case 6: |
2116 | 7a387fff | ths | switch (sel) {
|
2117 | 7a387fff | ths | case 0: |
2118 | 2423f660 | ths | gen_op_mfc0_wired(); |
2119 | 2423f660 | ths | rn = "Wired";
|
2120 | 2423f660 | ths | break;
|
2121 | 7a387fff | ths | case 1: |
2122 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2123 | ead9360e | ths | gen_op_mfc0_srsconf0(); |
2124 | 2423f660 | ths | rn = "SRSConf0";
|
2125 | ead9360e | ths | break;
|
2126 | 7a387fff | ths | case 2: |
2127 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2128 | ead9360e | ths | gen_op_mfc0_srsconf1(); |
2129 | 2423f660 | ths | rn = "SRSConf1";
|
2130 | ead9360e | ths | break;
|
2131 | 7a387fff | ths | case 3: |
2132 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2133 | ead9360e | ths | gen_op_mfc0_srsconf2(); |
2134 | 2423f660 | ths | rn = "SRSConf2";
|
2135 | ead9360e | ths | break;
|
2136 | 7a387fff | ths | case 4: |
2137 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2138 | ead9360e | ths | gen_op_mfc0_srsconf3(); |
2139 | 2423f660 | ths | rn = "SRSConf3";
|
2140 | ead9360e | ths | break;
|
2141 | 7a387fff | ths | case 5: |
2142 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2143 | ead9360e | ths | gen_op_mfc0_srsconf4(); |
2144 | 2423f660 | ths | rn = "SRSConf4";
|
2145 | ead9360e | ths | break;
|
2146 | 7a387fff | ths | default:
|
2147 | 7a387fff | ths | goto die;
|
2148 | 1579a72e | ths | } |
2149 | 873eb012 | ths | break;
|
2150 | 8c0fdd85 | ths | case 7: |
2151 | 7a387fff | ths | switch (sel) {
|
2152 | 7a387fff | ths | case 0: |
2153 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2154 | 2423f660 | ths | gen_op_mfc0_hwrena(); |
2155 | 2423f660 | ths | rn = "HWREna";
|
2156 | 2423f660 | ths | break;
|
2157 | 7a387fff | ths | default:
|
2158 | 7a387fff | ths | goto die;
|
2159 | 1579a72e | ths | } |
2160 | 8c0fdd85 | ths | break;
|
2161 | 873eb012 | ths | case 8: |
2162 | 7a387fff | ths | switch (sel) {
|
2163 | 7a387fff | ths | case 0: |
2164 | 2423f660 | ths | gen_op_mfc0_badvaddr(); |
2165 | 2423f660 | ths | rn = "BadVaddr";
|
2166 | 2423f660 | ths | break;
|
2167 | 7a387fff | ths | default:
|
2168 | 7a387fff | ths | goto die;
|
2169 | 7a387fff | ths | } |
2170 | 873eb012 | ths | break;
|
2171 | 873eb012 | ths | case 9: |
2172 | 7a387fff | ths | switch (sel) {
|
2173 | 7a387fff | ths | case 0: |
2174 | 2423f660 | ths | gen_op_mfc0_count(); |
2175 | 2423f660 | ths | rn = "Count";
|
2176 | 2423f660 | ths | break;
|
2177 | 2423f660 | ths | /* 6,7 are implementation dependent */
|
2178 | 7a387fff | ths | default:
|
2179 | 7a387fff | ths | goto die;
|
2180 | 2423f660 | ths | } |
2181 | 873eb012 | ths | break;
|
2182 | 873eb012 | ths | case 10: |
2183 | 7a387fff | ths | switch (sel) {
|
2184 | 7a387fff | ths | case 0: |
2185 | 2423f660 | ths | gen_op_mfc0_entryhi(); |
2186 | 2423f660 | ths | rn = "EntryHi";
|
2187 | 2423f660 | ths | break;
|
2188 | 7a387fff | ths | default:
|
2189 | 7a387fff | ths | goto die;
|
2190 | 1579a72e | ths | } |
2191 | 873eb012 | ths | break;
|
2192 | 873eb012 | ths | case 11: |
2193 | 7a387fff | ths | switch (sel) {
|
2194 | 7a387fff | ths | case 0: |
2195 | 2423f660 | ths | gen_op_mfc0_compare(); |
2196 | 2423f660 | ths | rn = "Compare";
|
2197 | 2423f660 | ths | break;
|
2198 | 2423f660 | ths | /* 6,7 are implementation dependent */
|
2199 | 7a387fff | ths | default:
|
2200 | 7a387fff | ths | goto die;
|
2201 | 2423f660 | ths | } |
2202 | 873eb012 | ths | break;
|
2203 | 873eb012 | ths | case 12: |
2204 | 7a387fff | ths | switch (sel) {
|
2205 | 7a387fff | ths | case 0: |
2206 | 2423f660 | ths | gen_op_mfc0_status(); |
2207 | 2423f660 | ths | rn = "Status";
|
2208 | 2423f660 | ths | break;
|
2209 | 7a387fff | ths | case 1: |
2210 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2211 | 2423f660 | ths | gen_op_mfc0_intctl(); |
2212 | 2423f660 | ths | rn = "IntCtl";
|
2213 | 2423f660 | ths | break;
|
2214 | 7a387fff | ths | case 2: |
2215 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2216 | 2423f660 | ths | gen_op_mfc0_srsctl(); |
2217 | 2423f660 | ths | rn = "SRSCtl";
|
2218 | 2423f660 | ths | break;
|
2219 | 7a387fff | ths | case 3: |
2220 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2221 | fd88b6ab | ths | gen_op_mfc0_srsmap(); |
2222 | 2423f660 | ths | rn = "SRSMap";
|
2223 | fd88b6ab | ths | break;
|
2224 | 7a387fff | ths | default:
|
2225 | 7a387fff | ths | goto die;
|
2226 | 7a387fff | ths | } |
2227 | 873eb012 | ths | break;
|
2228 | 873eb012 | ths | case 13: |
2229 | 7a387fff | ths | switch (sel) {
|
2230 | 7a387fff | ths | case 0: |
2231 | 2423f660 | ths | gen_op_mfc0_cause(); |
2232 | 2423f660 | ths | rn = "Cause";
|
2233 | 2423f660 | ths | break;
|
2234 | 7a387fff | ths | default:
|
2235 | 7a387fff | ths | goto die;
|
2236 | 7a387fff | ths | } |
2237 | 873eb012 | ths | break;
|
2238 | 873eb012 | ths | case 14: |
2239 | 7a387fff | ths | switch (sel) {
|
2240 | 7a387fff | ths | case 0: |
2241 | 2423f660 | ths | gen_op_mfc0_epc(); |
2242 | 2423f660 | ths | rn = "EPC";
|
2243 | 2423f660 | ths | break;
|
2244 | 7a387fff | ths | default:
|
2245 | 7a387fff | ths | goto die;
|
2246 | 1579a72e | ths | } |
2247 | 873eb012 | ths | break;
|
2248 | 873eb012 | ths | case 15: |
2249 | 7a387fff | ths | switch (sel) {
|
2250 | 7a387fff | ths | case 0: |
2251 | 2423f660 | ths | gen_op_mfc0_prid(); |
2252 | 2423f660 | ths | rn = "PRid";
|
2253 | 2423f660 | ths | break;
|
2254 | 7a387fff | ths | case 1: |
2255 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2256 | 2423f660 | ths | gen_op_mfc0_ebase(); |
2257 | 2423f660 | ths | rn = "EBase";
|
2258 | 2423f660 | ths | break;
|
2259 | 7a387fff | ths | default:
|
2260 | 7a387fff | ths | goto die;
|
2261 | 7a387fff | ths | } |
2262 | 873eb012 | ths | break;
|
2263 | 873eb012 | ths | case 16: |
2264 | 873eb012 | ths | switch (sel) {
|
2265 | 873eb012 | ths | case 0: |
2266 | e397ee33 | ths | gen_op_mfc0_config0(); |
2267 | 873eb012 | ths | rn = "Config";
|
2268 | 873eb012 | ths | break;
|
2269 | 873eb012 | ths | case 1: |
2270 | e397ee33 | ths | gen_op_mfc0_config1(); |
2271 | 873eb012 | ths | rn = "Config1";
|
2272 | 873eb012 | ths | break;
|
2273 | 7a387fff | ths | case 2: |
2274 | e397ee33 | ths | gen_op_mfc0_config2(); |
2275 | 7a387fff | ths | rn = "Config2";
|
2276 | 7a387fff | ths | break;
|
2277 | 7a387fff | ths | case 3: |
2278 | e397ee33 | ths | gen_op_mfc0_config3(); |
2279 | 7a387fff | ths | rn = "Config3";
|
2280 | 7a387fff | ths | break;
|
2281 | e397ee33 | ths | /* 4,5 are reserved */
|
2282 | e397ee33 | ths | /* 6,7 are implementation dependent */
|
2283 | e397ee33 | ths | case 6: |
2284 | e397ee33 | ths | gen_op_mfc0_config6(); |
2285 | e397ee33 | ths | rn = "Config6";
|
2286 | e397ee33 | ths | break;
|
2287 | e397ee33 | ths | case 7: |
2288 | e397ee33 | ths | gen_op_mfc0_config7(); |
2289 | e397ee33 | ths | rn = "Config7";
|
2290 | e397ee33 | ths | break;
|
2291 | 873eb012 | ths | default:
|
2292 | 873eb012 | ths | goto die;
|
2293 | 873eb012 | ths | } |
2294 | 873eb012 | ths | break;
|
2295 | 873eb012 | ths | case 17: |
2296 | 7a387fff | ths | switch (sel) {
|
2297 | 7a387fff | ths | case 0: |
2298 | 2423f660 | ths | gen_op_mfc0_lladdr(); |
2299 | 2423f660 | ths | rn = "LLAddr";
|
2300 | 2423f660 | ths | break;
|
2301 | 7a387fff | ths | default:
|
2302 | 7a387fff | ths | goto die;
|
2303 | 7a387fff | ths | } |
2304 | 873eb012 | ths | break;
|
2305 | 873eb012 | ths | case 18: |
2306 | 7a387fff | ths | switch (sel) {
|
2307 | fd88b6ab | ths | case 0 ... 7: |
2308 | fd88b6ab | ths | gen_op_mfc0_watchlo(sel); |
2309 | 2423f660 | ths | rn = "WatchLo";
|
2310 | 2423f660 | ths | break;
|
2311 | 7a387fff | ths | default:
|
2312 | 7a387fff | ths | goto die;
|
2313 | 7a387fff | ths | } |
2314 | 873eb012 | ths | break;
|
2315 | 873eb012 | ths | case 19: |
2316 | 7a387fff | ths | switch (sel) {
|
2317 | fd88b6ab | ths | case 0 ...7: |
2318 | fd88b6ab | ths | gen_op_mfc0_watchhi(sel); |
2319 | 2423f660 | ths | rn = "WatchHi";
|
2320 | 2423f660 | ths | break;
|
2321 | 7a387fff | ths | default:
|
2322 | 7a387fff | ths | goto die;
|
2323 | 7a387fff | ths | } |
2324 | 873eb012 | ths | break;
|
2325 | 8c0fdd85 | ths | case 20: |
2326 | 7a387fff | ths | switch (sel) {
|
2327 | 7a387fff | ths | case 0: |
2328 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
2329 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
2330 | 2423f660 | ths | gen_op_mfc0_xcontext(); |
2331 | 2423f660 | ths | rn = "XContext";
|
2332 | 2423f660 | ths | break;
|
2333 | 703eaf37 | ths | #endif
|
2334 | 7a387fff | ths | default:
|
2335 | 7a387fff | ths | goto die;
|
2336 | 7a387fff | ths | } |
2337 | 8c0fdd85 | ths | break;
|
2338 | 8c0fdd85 | ths | case 21: |
2339 | 7a387fff | ths | /* Officially reserved, but sel 0 is used for R1x000 framemask */
|
2340 | 7a387fff | ths | switch (sel) {
|
2341 | 7a387fff | ths | case 0: |
2342 | 2423f660 | ths | gen_op_mfc0_framemask(); |
2343 | 2423f660 | ths | rn = "Framemask";
|
2344 | 2423f660 | ths | break;
|
2345 | 7a387fff | ths | default:
|
2346 | 7a387fff | ths | goto die;
|
2347 | 7a387fff | ths | } |
2348 | 8c0fdd85 | ths | break;
|
2349 | 8c0fdd85 | ths | case 22: |
2350 | 2423f660 | ths | /* ignored */
|
2351 | 2423f660 | ths | rn = "'Diagnostic"; /* implementation dependent */ |
2352 | 2423f660 | ths | break;
|
2353 | 873eb012 | ths | case 23: |
2354 | 7a387fff | ths | switch (sel) {
|
2355 | 7a387fff | ths | case 0: |
2356 | 2423f660 | ths | gen_op_mfc0_debug(); /* EJTAG support */
|
2357 | 2423f660 | ths | rn = "Debug";
|
2358 | 2423f660 | ths | break;
|
2359 | 7a387fff | ths | case 1: |
2360 | 2423f660 | ths | // gen_op_mfc0_tracecontrol(); /* PDtrace support */
|
2361 | 2423f660 | ths | rn = "TraceControl";
|
2362 | 2423f660 | ths | // break;
|
2363 | 7a387fff | ths | case 2: |
2364 | 2423f660 | ths | // gen_op_mfc0_tracecontrol2(); /* PDtrace support */
|
2365 | 2423f660 | ths | rn = "TraceControl2";
|
2366 | 2423f660 | ths | // break;
|
2367 | 7a387fff | ths | case 3: |
2368 | 2423f660 | ths | // gen_op_mfc0_usertracedata(); /* PDtrace support */
|
2369 | 2423f660 | ths | rn = "UserTraceData";
|
2370 | 2423f660 | ths | // break;
|
2371 | 7a387fff | ths | case 4: |
2372 | 2423f660 | ths | // gen_op_mfc0_debug(); /* PDtrace support */
|
2373 | 2423f660 | ths | rn = "TraceBPC";
|
2374 | 2423f660 | ths | // break;
|
2375 | 7a387fff | ths | default:
|
2376 | 7a387fff | ths | goto die;
|
2377 | 7a387fff | ths | } |
2378 | 873eb012 | ths | break;
|
2379 | 873eb012 | ths | case 24: |
2380 | 7a387fff | ths | switch (sel) {
|
2381 | 7a387fff | ths | case 0: |
2382 | 2423f660 | ths | gen_op_mfc0_depc(); /* EJTAG support */
|
2383 | 2423f660 | ths | rn = "DEPC";
|
2384 | 2423f660 | ths | break;
|
2385 | 7a387fff | ths | default:
|
2386 | 7a387fff | ths | goto die;
|
2387 | 7a387fff | ths | } |
2388 | 873eb012 | ths | break;
|
2389 | 8c0fdd85 | ths | case 25: |
2390 | 7a387fff | ths | switch (sel) {
|
2391 | 7a387fff | ths | case 0: |
2392 | 2423f660 | ths | gen_op_mfc0_performance0(); |
2393 | 2423f660 | ths | rn = "Performance0";
|
2394 | 7a387fff | ths | break;
|
2395 | 7a387fff | ths | case 1: |
2396 | 2423f660 | ths | // gen_op_mfc0_performance1();
|
2397 | 2423f660 | ths | rn = "Performance1";
|
2398 | 2423f660 | ths | // break;
|
2399 | 7a387fff | ths | case 2: |
2400 | 2423f660 | ths | // gen_op_mfc0_performance2();
|
2401 | 2423f660 | ths | rn = "Performance2";
|
2402 | 2423f660 | ths | // break;
|
2403 | 7a387fff | ths | case 3: |
2404 | 2423f660 | ths | // gen_op_mfc0_performance3();
|
2405 | 2423f660 | ths | rn = "Performance3";
|
2406 | 2423f660 | ths | // break;
|
2407 | 7a387fff | ths | case 4: |
2408 | 2423f660 | ths | // gen_op_mfc0_performance4();
|
2409 | 2423f660 | ths | rn = "Performance4";
|
2410 | 2423f660 | ths | // break;
|
2411 | 7a387fff | ths | case 5: |
2412 | 2423f660 | ths | // gen_op_mfc0_performance5();
|
2413 | 2423f660 | ths | rn = "Performance5";
|
2414 | 2423f660 | ths | // break;
|
2415 | 7a387fff | ths | case 6: |
2416 | 2423f660 | ths | // gen_op_mfc0_performance6();
|
2417 | 2423f660 | ths | rn = "Performance6";
|
2418 | 2423f660 | ths | // break;
|
2419 | 7a387fff | ths | case 7: |
2420 | 2423f660 | ths | // gen_op_mfc0_performance7();
|
2421 | 2423f660 | ths | rn = "Performance7";
|
2422 | 2423f660 | ths | // break;
|
2423 | 7a387fff | ths | default:
|
2424 | 7a387fff | ths | goto die;
|
2425 | 7a387fff | ths | } |
2426 | 8c0fdd85 | ths | break;
|
2427 | 8c0fdd85 | ths | case 26: |
2428 | 7a387fff | ths | rn = "ECC";
|
2429 | 7a387fff | ths | break;
|
2430 | 8c0fdd85 | ths | case 27: |
2431 | 7a387fff | ths | switch (sel) {
|
2432 | 7a387fff | ths | /* ignored */
|
2433 | 7a387fff | ths | case 0 ... 3: |
2434 | 2423f660 | ths | rn = "CacheErr";
|
2435 | 2423f660 | ths | break;
|
2436 | 7a387fff | ths | default:
|
2437 | 7a387fff | ths | goto die;
|
2438 | 7a387fff | ths | } |
2439 | 8c0fdd85 | ths | break;
|
2440 | 873eb012 | ths | case 28: |
2441 | 873eb012 | ths | switch (sel) {
|
2442 | 873eb012 | ths | case 0: |
2443 | 7a387fff | ths | case 2: |
2444 | 7a387fff | ths | case 4: |
2445 | 7a387fff | ths | case 6: |
2446 | 873eb012 | ths | gen_op_mfc0_taglo(); |
2447 | 873eb012 | ths | rn = "TagLo";
|
2448 | 873eb012 | ths | break;
|
2449 | 873eb012 | ths | case 1: |
2450 | 7a387fff | ths | case 3: |
2451 | 7a387fff | ths | case 5: |
2452 | 7a387fff | ths | case 7: |
2453 | 873eb012 | ths | gen_op_mfc0_datalo(); |
2454 | 873eb012 | ths | rn = "DataLo";
|
2455 | 873eb012 | ths | break;
|
2456 | 873eb012 | ths | default:
|
2457 | 873eb012 | ths | goto die;
|
2458 | 873eb012 | ths | } |
2459 | 873eb012 | ths | break;
|
2460 | 8c0fdd85 | ths | case 29: |
2461 | 7a387fff | ths | switch (sel) {
|
2462 | 7a387fff | ths | case 0: |
2463 | 7a387fff | ths | case 2: |
2464 | 7a387fff | ths | case 4: |
2465 | 7a387fff | ths | case 6: |
2466 | 7a387fff | ths | gen_op_mfc0_taghi(); |
2467 | 7a387fff | ths | rn = "TagHi";
|
2468 | 7a387fff | ths | break;
|
2469 | 7a387fff | ths | case 1: |
2470 | 7a387fff | ths | case 3: |
2471 | 7a387fff | ths | case 5: |
2472 | 7a387fff | ths | case 7: |
2473 | 7a387fff | ths | gen_op_mfc0_datahi(); |
2474 | 7a387fff | ths | rn = "DataHi";
|
2475 | 7a387fff | ths | break;
|
2476 | 7a387fff | ths | default:
|
2477 | 7a387fff | ths | goto die;
|
2478 | 7a387fff | ths | } |
2479 | 8c0fdd85 | ths | break;
|
2480 | 873eb012 | ths | case 30: |
2481 | 7a387fff | ths | switch (sel) {
|
2482 | 7a387fff | ths | case 0: |
2483 | 2423f660 | ths | gen_op_mfc0_errorepc(); |
2484 | 2423f660 | ths | rn = "ErrorEPC";
|
2485 | 2423f660 | ths | break;
|
2486 | 7a387fff | ths | default:
|
2487 | 7a387fff | ths | goto die;
|
2488 | 7a387fff | ths | } |
2489 | 873eb012 | ths | break;
|
2490 | 873eb012 | ths | case 31: |
2491 | 7a387fff | ths | switch (sel) {
|
2492 | 7a387fff | ths | case 0: |
2493 | 2423f660 | ths | gen_op_mfc0_desave(); /* EJTAG support */
|
2494 | 2423f660 | ths | rn = "DESAVE";
|
2495 | 2423f660 | ths | break;
|
2496 | 7a387fff | ths | default:
|
2497 | 7a387fff | ths | goto die;
|
2498 | 7a387fff | ths | } |
2499 | 873eb012 | ths | break;
|
2500 | 873eb012 | ths | default:
|
2501 | 873eb012 | ths | goto die;
|
2502 | 873eb012 | ths | } |
2503 | 873eb012 | ths | #if defined MIPS_DEBUG_DISAS
|
2504 | 873eb012 | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
2505 | 7a387fff | ths | fprintf(logfile, "mfc0 %s (reg %d sel %d)\n",
|
2506 | 7a387fff | ths | rn, reg, sel); |
2507 | 873eb012 | ths | } |
2508 | 873eb012 | ths | #endif
|
2509 | 873eb012 | ths | return;
|
2510 | 873eb012 | ths | |
2511 | 873eb012 | ths | die:
|
2512 | 873eb012 | ths | #if defined MIPS_DEBUG_DISAS
|
2513 | 873eb012 | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
2514 | 7a387fff | ths | fprintf(logfile, "mfc0 %s (reg %d sel %d)\n",
|
2515 | 7a387fff | ths | rn, reg, sel); |
2516 | 873eb012 | ths | } |
2517 | 873eb012 | ths | #endif
|
2518 | 873eb012 | ths | generate_exception(ctx, EXCP_RI); |
2519 | 873eb012 | ths | } |
2520 | 873eb012 | ths | |
2521 | 3a95e3a7 | ths | static void gen_mtc0 (CPUState *env, DisasContext *ctx, int reg, int sel) |
2522 | 8c0fdd85 | ths | { |
2523 | 7a387fff | ths | const char *rn = "invalid"; |
2524 | 7a387fff | ths | |
2525 | e189e748 | ths | if (sel != 0) |
2526 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
2527 | e189e748 | ths | |
2528 | 8c0fdd85 | ths | switch (reg) {
|
2529 | 8c0fdd85 | ths | case 0: |
2530 | 7a387fff | ths | switch (sel) {
|
2531 | 7a387fff | ths | case 0: |
2532 | 7a387fff | ths | gen_op_mtc0_index(); |
2533 | 7a387fff | ths | rn = "Index";
|
2534 | 7a387fff | ths | break;
|
2535 | 7a387fff | ths | case 1: |
2536 | ead9360e | ths | check_mips_mt(env, ctx); |
2537 | ead9360e | ths | gen_op_mtc0_mvpcontrol(); |
2538 | 7a387fff | ths | rn = "MVPControl";
|
2539 | ead9360e | ths | break;
|
2540 | 7a387fff | ths | case 2: |
2541 | ead9360e | ths | check_mips_mt(env, ctx); |
2542 | ead9360e | ths | /* ignored */
|
2543 | 7a387fff | ths | rn = "MVPConf0";
|
2544 | ead9360e | ths | break;
|
2545 | 7a387fff | ths | case 3: |
2546 | ead9360e | ths | check_mips_mt(env, ctx); |
2547 | ead9360e | ths | /* ignored */
|
2548 | 7a387fff | ths | rn = "MVPConf1";
|
2549 | ead9360e | ths | break;
|
2550 | 7a387fff | ths | default:
|
2551 | 7a387fff | ths | goto die;
|
2552 | 7a387fff | ths | } |
2553 | 8c0fdd85 | ths | break;
|
2554 | 8c0fdd85 | ths | case 1: |
2555 | 7a387fff | ths | switch (sel) {
|
2556 | 7a387fff | ths | case 0: |
2557 | 2423f660 | ths | /* ignored */
|
2558 | 7a387fff | ths | rn = "Random";
|
2559 | 2423f660 | ths | break;
|
2560 | 7a387fff | ths | case 1: |
2561 | ead9360e | ths | check_mips_mt(env, ctx); |
2562 | ead9360e | ths | gen_op_mtc0_vpecontrol(); |
2563 | 7a387fff | ths | rn = "VPEControl";
|
2564 | ead9360e | ths | break;
|
2565 | 7a387fff | ths | case 2: |
2566 | ead9360e | ths | check_mips_mt(env, ctx); |
2567 | ead9360e | ths | gen_op_mtc0_vpeconf0(); |
2568 | 7a387fff | ths | rn = "VPEConf0";
|
2569 | ead9360e | ths | break;
|
2570 | 7a387fff | ths | case 3: |
2571 | ead9360e | ths | check_mips_mt(env, ctx); |
2572 | ead9360e | ths | gen_op_mtc0_vpeconf1(); |
2573 | 7a387fff | ths | rn = "VPEConf1";
|
2574 | ead9360e | ths | break;
|
2575 | 7a387fff | ths | case 4: |
2576 | ead9360e | ths | check_mips_mt(env, ctx); |
2577 | ead9360e | ths | gen_op_mtc0_yqmask(); |
2578 | 7a387fff | ths | rn = "YQMask";
|
2579 | ead9360e | ths | break;
|
2580 | 7a387fff | ths | case 5: |
2581 | ead9360e | ths | check_mips_mt(env, ctx); |
2582 | ead9360e | ths | gen_op_mtc0_vpeschedule(); |
2583 | 7a387fff | ths | rn = "VPESchedule";
|
2584 | ead9360e | ths | break;
|
2585 | 7a387fff | ths | case 6: |
2586 | ead9360e | ths | check_mips_mt(env, ctx); |
2587 | ead9360e | ths | gen_op_mtc0_vpeschefback(); |
2588 | 7a387fff | ths | rn = "VPEScheFBack";
|
2589 | ead9360e | ths | break;
|
2590 | 7a387fff | ths | case 7: |
2591 | ead9360e | ths | check_mips_mt(env, ctx); |
2592 | ead9360e | ths | gen_op_mtc0_vpeopt(); |
2593 | 7a387fff | ths | rn = "VPEOpt";
|
2594 | ead9360e | ths | break;
|
2595 | 7a387fff | ths | default:
|
2596 | 7a387fff | ths | goto die;
|
2597 | 7a387fff | ths | } |
2598 | 8c0fdd85 | ths | break;
|
2599 | 8c0fdd85 | ths | case 2: |
2600 | 7a387fff | ths | switch (sel) {
|
2601 | 7a387fff | ths | case 0: |
2602 | 2423f660 | ths | gen_op_mtc0_entrylo0(); |
2603 | 2423f660 | ths | rn = "EntryLo0";
|
2604 | 2423f660 | ths | break;
|
2605 | 7a387fff | ths | case 1: |
2606 | ead9360e | ths | check_mips_mt(env, ctx); |
2607 | ead9360e | ths | gen_op_mtc0_tcstatus(); |
2608 | 2423f660 | ths | rn = "TCStatus";
|
2609 | ead9360e | ths | break;
|
2610 | 7a387fff | ths | case 2: |
2611 | ead9360e | ths | check_mips_mt(env, ctx); |
2612 | ead9360e | ths | gen_op_mtc0_tcbind(); |
2613 | 2423f660 | ths | rn = "TCBind";
|
2614 | ead9360e | ths | break;
|
2615 | 7a387fff | ths | case 3: |
2616 | ead9360e | ths | check_mips_mt(env, ctx); |
2617 | ead9360e | ths | gen_op_mtc0_tcrestart(); |
2618 | 2423f660 | ths | rn = "TCRestart";
|
2619 | ead9360e | ths | break;
|
2620 | 7a387fff | ths | case 4: |
2621 | ead9360e | ths | check_mips_mt(env, ctx); |
2622 | ead9360e | ths | gen_op_mtc0_tchalt(); |
2623 | 2423f660 | ths | rn = "TCHalt";
|
2624 | ead9360e | ths | break;
|
2625 | 7a387fff | ths | case 5: |
2626 | ead9360e | ths | check_mips_mt(env, ctx); |
2627 | ead9360e | ths | gen_op_mtc0_tccontext(); |
2628 | 2423f660 | ths | rn = "TCContext";
|
2629 | ead9360e | ths | break;
|
2630 | 7a387fff | ths | case 6: |
2631 | ead9360e | ths | check_mips_mt(env, ctx); |
2632 | ead9360e | ths | gen_op_mtc0_tcschedule(); |
2633 | 2423f660 | ths | rn = "TCSchedule";
|
2634 | ead9360e | ths | break;
|
2635 | 7a387fff | ths | case 7: |
2636 | ead9360e | ths | check_mips_mt(env, ctx); |
2637 | ead9360e | ths | gen_op_mtc0_tcschefback(); |
2638 | 2423f660 | ths | rn = "TCScheFBack";
|
2639 | ead9360e | ths | break;
|
2640 | 7a387fff | ths | default:
|
2641 | 7a387fff | ths | goto die;
|
2642 | 7a387fff | ths | } |
2643 | 8c0fdd85 | ths | break;
|
2644 | 8c0fdd85 | ths | case 3: |
2645 | 7a387fff | ths | switch (sel) {
|
2646 | 7a387fff | ths | case 0: |
2647 | 2423f660 | ths | gen_op_mtc0_entrylo1(); |
2648 | 2423f660 | ths | rn = "EntryLo1";
|
2649 | 2423f660 | ths | break;
|
2650 | 7a387fff | ths | default:
|
2651 | 7a387fff | ths | goto die;
|
2652 | 876d4b07 | ths | } |
2653 | 8c0fdd85 | ths | break;
|
2654 | 8c0fdd85 | ths | case 4: |
2655 | 7a387fff | ths | switch (sel) {
|
2656 | 7a387fff | ths | case 0: |
2657 | 2423f660 | ths | gen_op_mtc0_context(); |
2658 | 2423f660 | ths | rn = "Context";
|
2659 | 2423f660 | ths | break;
|
2660 | 7a387fff | ths | case 1: |
2661 | 2423f660 | ths | // gen_op_mtc0_contextconfig(); /* SmartMIPS ASE */
|
2662 | 2423f660 | ths | rn = "ContextConfig";
|
2663 | 2423f660 | ths | // break;
|
2664 | 7a387fff | ths | default:
|
2665 | 7a387fff | ths | goto die;
|
2666 | 876d4b07 | ths | } |
2667 | 8c0fdd85 | ths | break;
|
2668 | 8c0fdd85 | ths | case 5: |
2669 | 7a387fff | ths | switch (sel) {
|
2670 | 7a387fff | ths | case 0: |
2671 | 2423f660 | ths | gen_op_mtc0_pagemask(); |
2672 | 2423f660 | ths | rn = "PageMask";
|
2673 | 2423f660 | ths | break;
|
2674 | 7a387fff | ths | case 1: |
2675 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2676 | 2423f660 | ths | gen_op_mtc0_pagegrain(); |
2677 | 2423f660 | ths | rn = "PageGrain";
|
2678 | 2423f660 | ths | break;
|
2679 | 7a387fff | ths | default:
|
2680 | 7a387fff | ths | goto die;
|
2681 | 876d4b07 | ths | } |
2682 | 8c0fdd85 | ths | break;
|
2683 | 8c0fdd85 | ths | case 6: |
2684 | 7a387fff | ths | switch (sel) {
|
2685 | 7a387fff | ths | case 0: |
2686 | 2423f660 | ths | gen_op_mtc0_wired(); |
2687 | 2423f660 | ths | rn = "Wired";
|
2688 | 2423f660 | ths | break;
|
2689 | 7a387fff | ths | case 1: |
2690 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2691 | ead9360e | ths | gen_op_mtc0_srsconf0(); |
2692 | 2423f660 | ths | rn = "SRSConf0";
|
2693 | ead9360e | ths | break;
|
2694 | 7a387fff | ths | case 2: |
2695 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2696 | ead9360e | ths | gen_op_mtc0_srsconf1(); |
2697 | 2423f660 | ths | rn = "SRSConf1";
|
2698 | ead9360e | ths | break;
|
2699 | 7a387fff | ths | case 3: |
2700 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2701 | ead9360e | ths | gen_op_mtc0_srsconf2(); |
2702 | 2423f660 | ths | rn = "SRSConf2";
|
2703 | ead9360e | ths | break;
|
2704 | 7a387fff | ths | case 4: |
2705 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2706 | ead9360e | ths | gen_op_mtc0_srsconf3(); |
2707 | 2423f660 | ths | rn = "SRSConf3";
|
2708 | ead9360e | ths | break;
|
2709 | 7a387fff | ths | case 5: |
2710 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2711 | ead9360e | ths | gen_op_mtc0_srsconf4(); |
2712 | 2423f660 | ths | rn = "SRSConf4";
|
2713 | ead9360e | ths | break;
|
2714 | 7a387fff | ths | default:
|
2715 | 7a387fff | ths | goto die;
|
2716 | 876d4b07 | ths | } |
2717 | 8c0fdd85 | ths | break;
|
2718 | 8c0fdd85 | ths | case 7: |
2719 | 7a387fff | ths | switch (sel) {
|
2720 | 7a387fff | ths | case 0: |
2721 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2722 | 2423f660 | ths | gen_op_mtc0_hwrena(); |
2723 | 2423f660 | ths | rn = "HWREna";
|
2724 | 2423f660 | ths | break;
|
2725 | 7a387fff | ths | default:
|
2726 | 7a387fff | ths | goto die;
|
2727 | 876d4b07 | ths | } |
2728 | 8c0fdd85 | ths | break;
|
2729 | 8c0fdd85 | ths | case 8: |
2730 | 7a387fff | ths | /* ignored */
|
2731 | 8c0fdd85 | ths | rn = "BadVaddr";
|
2732 | 8c0fdd85 | ths | break;
|
2733 | 8c0fdd85 | ths | case 9: |
2734 | 7a387fff | ths | switch (sel) {
|
2735 | 7a387fff | ths | case 0: |
2736 | 2423f660 | ths | gen_op_mtc0_count(); |
2737 | 2423f660 | ths | rn = "Count";
|
2738 | 2423f660 | ths | break;
|
2739 | 876d4b07 | ths | /* 6,7 are implementation dependent */
|
2740 | 7a387fff | ths | default:
|
2741 | 7a387fff | ths | goto die;
|
2742 | 876d4b07 | ths | } |
2743 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
2744 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
2745 | 8c0fdd85 | ths | break;
|
2746 | 8c0fdd85 | ths | case 10: |
2747 | 7a387fff | ths | switch (sel) {
|
2748 | 7a387fff | ths | case 0: |
2749 | 2423f660 | ths | gen_op_mtc0_entryhi(); |
2750 | 2423f660 | ths | rn = "EntryHi";
|
2751 | 2423f660 | ths | break;
|
2752 | 7a387fff | ths | default:
|
2753 | 7a387fff | ths | goto die;
|
2754 | 876d4b07 | ths | } |
2755 | 8c0fdd85 | ths | break;
|
2756 | 8c0fdd85 | ths | case 11: |
2757 | 7a387fff | ths | switch (sel) {
|
2758 | 7a387fff | ths | case 0: |
2759 | 2423f660 | ths | gen_op_mtc0_compare(); |
2760 | 2423f660 | ths | rn = "Compare";
|
2761 | 2423f660 | ths | break;
|
2762 | 2423f660 | ths | /* 6,7 are implementation dependent */
|
2763 | 7a387fff | ths | default:
|
2764 | 7a387fff | ths | goto die;
|
2765 | 876d4b07 | ths | } |
2766 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
2767 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
2768 | 8c0fdd85 | ths | break;
|
2769 | 8c0fdd85 | ths | case 12: |
2770 | 7a387fff | ths | switch (sel) {
|
2771 | 7a387fff | ths | case 0: |
2772 | 2423f660 | ths | gen_op_mtc0_status(); |
2773 | 8487327a | ths | /* BS_STOP isn't good enough here, hflags may have changed. */
|
2774 | 8487327a | ths | gen_save_pc(ctx->pc + 4);
|
2775 | 8487327a | ths | ctx->bstate = BS_EXCP; |
2776 | 2423f660 | ths | rn = "Status";
|
2777 | 2423f660 | ths | break;
|
2778 | 7a387fff | ths | case 1: |
2779 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2780 | 2423f660 | ths | gen_op_mtc0_intctl(); |
2781 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
2782 | 8487327a | ths | ctx->bstate = BS_STOP; |
2783 | 2423f660 | ths | rn = "IntCtl";
|
2784 | 2423f660 | ths | break;
|
2785 | 7a387fff | ths | case 2: |
2786 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2787 | 2423f660 | ths | gen_op_mtc0_srsctl(); |
2788 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
2789 | 8487327a | ths | ctx->bstate = BS_STOP; |
2790 | 2423f660 | ths | rn = "SRSCtl";
|
2791 | 2423f660 | ths | break;
|
2792 | 7a387fff | ths | case 3: |
2793 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2794 | fd88b6ab | ths | gen_op_mtc0_srsmap(); |
2795 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
2796 | 8487327a | ths | ctx->bstate = BS_STOP; |
2797 | 2423f660 | ths | rn = "SRSMap";
|
2798 | fd88b6ab | ths | break;
|
2799 | 7a387fff | ths | default:
|
2800 | 7a387fff | ths | goto die;
|
2801 | 876d4b07 | ths | } |
2802 | 8c0fdd85 | ths | break;
|
2803 | 8c0fdd85 | ths | case 13: |
2804 | 7a387fff | ths | switch (sel) {
|
2805 | 7a387fff | ths | case 0: |
2806 | 2423f660 | ths | gen_op_mtc0_cause(); |
2807 | 2423f660 | ths | rn = "Cause";
|
2808 | 2423f660 | ths | break;
|
2809 | 7a387fff | ths | default:
|
2810 | 7a387fff | ths | goto die;
|
2811 | 876d4b07 | ths | } |
2812 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
2813 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
2814 | 8c0fdd85 | ths | break;
|
2815 | 8c0fdd85 | ths | case 14: |
2816 | 7a387fff | ths | switch (sel) {
|
2817 | 7a387fff | ths | case 0: |
2818 | 2423f660 | ths | gen_op_mtc0_epc(); |
2819 | 2423f660 | ths | rn = "EPC";
|
2820 | 2423f660 | ths | break;
|
2821 | 7a387fff | ths | default:
|
2822 | 7a387fff | ths | goto die;
|
2823 | 876d4b07 | ths | } |
2824 | 8c0fdd85 | ths | break;
|
2825 | 8c0fdd85 | ths | case 15: |
2826 | 7a387fff | ths | switch (sel) {
|
2827 | 7a387fff | ths | case 0: |
2828 | 2423f660 | ths | /* ignored */
|
2829 | 2423f660 | ths | rn = "PRid";
|
2830 | 2423f660 | ths | break;
|
2831 | 7a387fff | ths | case 1: |
2832 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2833 | 2423f660 | ths | gen_op_mtc0_ebase(); |
2834 | 2423f660 | ths | rn = "EBase";
|
2835 | 2423f660 | ths | break;
|
2836 | 7a387fff | ths | default:
|
2837 | 7a387fff | ths | goto die;
|
2838 | 1579a72e | ths | } |
2839 | 8c0fdd85 | ths | break;
|
2840 | 8c0fdd85 | ths | case 16: |
2841 | 8c0fdd85 | ths | switch (sel) {
|
2842 | 8c0fdd85 | ths | case 0: |
2843 | e397ee33 | ths | gen_op_mtc0_config0(); |
2844 | 7a387fff | ths | rn = "Config";
|
2845 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
2846 | 2423f660 | ths | ctx->bstate = BS_STOP; |
2847 | 7a387fff | ths | break;
|
2848 | 7a387fff | ths | case 1: |
2849 | e397ee33 | ths | /* ignored, read only */
|
2850 | 7a387fff | ths | rn = "Config1";
|
2851 | 7a387fff | ths | break;
|
2852 | 7a387fff | ths | case 2: |
2853 | e397ee33 | ths | gen_op_mtc0_config2(); |
2854 | 7a387fff | ths | rn = "Config2";
|
2855 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
2856 | 2423f660 | ths | ctx->bstate = BS_STOP; |
2857 | 8c0fdd85 | ths | break;
|
2858 | 7a387fff | ths | case 3: |
2859 | e397ee33 | ths | /* ignored, read only */
|
2860 | 7a387fff | ths | rn = "Config3";
|
2861 | 7a387fff | ths | break;
|
2862 | e397ee33 | ths | /* 4,5 are reserved */
|
2863 | e397ee33 | ths | /* 6,7 are implementation dependent */
|
2864 | e397ee33 | ths | case 6: |
2865 | e397ee33 | ths | /* ignored */
|
2866 | e397ee33 | ths | rn = "Config6";
|
2867 | e397ee33 | ths | break;
|
2868 | e397ee33 | ths | case 7: |
2869 | e397ee33 | ths | /* ignored */
|
2870 | e397ee33 | ths | rn = "Config7";
|
2871 | e397ee33 | ths | break;
|
2872 | 8c0fdd85 | ths | default:
|
2873 | 8c0fdd85 | ths | rn = "Invalid config selector";
|
2874 | 8c0fdd85 | ths | goto die;
|
2875 | 8c0fdd85 | ths | } |
2876 | 8c0fdd85 | ths | break;
|
2877 | 8c0fdd85 | ths | case 17: |
2878 | 7a387fff | ths | switch (sel) {
|
2879 | 7a387fff | ths | case 0: |
2880 | 2423f660 | ths | /* ignored */
|
2881 | 2423f660 | ths | rn = "LLAddr";
|
2882 | 2423f660 | ths | break;
|
2883 | 7a387fff | ths | default:
|
2884 | 7a387fff | ths | goto die;
|
2885 | 7a387fff | ths | } |
2886 | 8c0fdd85 | ths | break;
|
2887 | 8c0fdd85 | ths | case 18: |
2888 | 7a387fff | ths | switch (sel) {
|
2889 | fd88b6ab | ths | case 0 ... 7: |
2890 | fd88b6ab | ths | gen_op_mtc0_watchlo(sel); |
2891 | 2423f660 | ths | rn = "WatchLo";
|
2892 | 2423f660 | ths | break;
|
2893 | 7a387fff | ths | default:
|
2894 | 7a387fff | ths | goto die;
|
2895 | 7a387fff | ths | } |
2896 | 8c0fdd85 | ths | break;
|
2897 | 8c0fdd85 | ths | case 19: |
2898 | 7a387fff | ths | switch (sel) {
|
2899 | fd88b6ab | ths | case 0 ... 7: |
2900 | fd88b6ab | ths | gen_op_mtc0_watchhi(sel); |
2901 | 2423f660 | ths | rn = "WatchHi";
|
2902 | 2423f660 | ths | break;
|
2903 | 7a387fff | ths | default:
|
2904 | 7a387fff | ths | goto die;
|
2905 | 7a387fff | ths | } |
2906 | 8c0fdd85 | ths | break;
|
2907 | 8c0fdd85 | ths | case 20: |
2908 | 7a387fff | ths | switch (sel) {
|
2909 | 7a387fff | ths | case 0: |
2910 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
2911 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
2912 | f1b0aa5d | ths | gen_op_mtc0_xcontext(); |
2913 | 2423f660 | ths | rn = "XContext";
|
2914 | 2423f660 | ths | break;
|
2915 | 703eaf37 | ths | #endif
|
2916 | 7a387fff | ths | default:
|
2917 | 7a387fff | ths | goto die;
|
2918 | 7a387fff | ths | } |
2919 | 8c0fdd85 | ths | break;
|
2920 | 8c0fdd85 | ths | case 21: |
2921 | 7a387fff | ths | /* Officially reserved, but sel 0 is used for R1x000 framemask */
|
2922 | 7a387fff | ths | switch (sel) {
|
2923 | 7a387fff | ths | case 0: |
2924 | 2423f660 | ths | gen_op_mtc0_framemask(); |
2925 | 2423f660 | ths | rn = "Framemask";
|
2926 | 2423f660 | ths | break;
|
2927 | 7a387fff | ths | default:
|
2928 | 7a387fff | ths | goto die;
|
2929 | 7a387fff | ths | } |
2930 | 7a387fff | ths | break;
|
2931 | 8c0fdd85 | ths | case 22: |
2932 | 7a387fff | ths | /* ignored */
|
2933 | 7a387fff | ths | rn = "Diagnostic"; /* implementation dependent */ |
2934 | 2423f660 | ths | break;
|
2935 | 8c0fdd85 | ths | case 23: |
2936 | 7a387fff | ths | switch (sel) {
|
2937 | 7a387fff | ths | case 0: |
2938 | 2423f660 | ths | gen_op_mtc0_debug(); /* EJTAG support */
|
2939 | 8487327a | ths | /* BS_STOP isn't good enough here, hflags may have changed. */
|
2940 | 8487327a | ths | gen_save_pc(ctx->pc + 4);
|
2941 | 8487327a | ths | ctx->bstate = BS_EXCP; |
2942 | 2423f660 | ths | rn = "Debug";
|
2943 | 2423f660 | ths | break;
|
2944 | 7a387fff | ths | case 1: |
2945 | 2423f660 | ths | // gen_op_mtc0_tracecontrol(); /* PDtrace support */
|
2946 | 2423f660 | ths | rn = "TraceControl";
|
2947 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
2948 | 8487327a | ths | ctx->bstate = BS_STOP; |
2949 | 2423f660 | ths | // break;
|
2950 | 7a387fff | ths | case 2: |
2951 | 2423f660 | ths | // gen_op_mtc0_tracecontrol2(); /* PDtrace support */
|
2952 | 2423f660 | ths | rn = "TraceControl2";
|
2953 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
2954 | 8487327a | ths | ctx->bstate = BS_STOP; |
2955 | 2423f660 | ths | // break;
|
2956 | 7a387fff | ths | case 3: |
2957 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
2958 | 8487327a | ths | ctx->bstate = BS_STOP; |
2959 | 2423f660 | ths | // gen_op_mtc0_usertracedata(); /* PDtrace support */
|
2960 | 2423f660 | ths | rn = "UserTraceData";
|
2961 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
2962 | 8487327a | ths | ctx->bstate = BS_STOP; |
2963 | 2423f660 | ths | // break;
|
2964 | 7a387fff | ths | case 4: |
2965 | 2423f660 | ths | // gen_op_mtc0_debug(); /* PDtrace support */
|
2966 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
2967 | 8487327a | ths | ctx->bstate = BS_STOP; |
2968 | 2423f660 | ths | rn = "TraceBPC";
|
2969 | 2423f660 | ths | // break;
|
2970 | 7a387fff | ths | default:
|
2971 | 7a387fff | ths | goto die;
|
2972 | 7a387fff | ths | } |
2973 | 8c0fdd85 | ths | break;
|
2974 | 8c0fdd85 | ths | case 24: |
2975 | 7a387fff | ths | switch (sel) {
|
2976 | 7a387fff | ths | case 0: |
2977 | 2423f660 | ths | gen_op_mtc0_depc(); /* EJTAG support */
|
2978 | 2423f660 | ths | rn = "DEPC";
|
2979 | 2423f660 | ths | break;
|
2980 | 7a387fff | ths | default:
|
2981 | 7a387fff | ths | goto die;
|
2982 | 7a387fff | ths | } |
2983 | 8c0fdd85 | ths | break;
|
2984 | 8c0fdd85 | ths | case 25: |
2985 | 7a387fff | ths | switch (sel) {
|
2986 | 7a387fff | ths | case 0: |
2987 | 2423f660 | ths | gen_op_mtc0_performance0(); |
2988 | 2423f660 | ths | rn = "Performance0";
|
2989 | 2423f660 | ths | break;
|
2990 | 7a387fff | ths | case 1: |
2991 | 2423f660 | ths | // gen_op_mtc0_performance1();
|
2992 | 2423f660 | ths | rn = "Performance1";
|
2993 | 2423f660 | ths | // break;
|
2994 | 7a387fff | ths | case 2: |
2995 | 2423f660 | ths | // gen_op_mtc0_performance2();
|
2996 | 2423f660 | ths | rn = "Performance2";
|
2997 | 2423f660 | ths | // break;
|
2998 | 7a387fff | ths | case 3: |
2999 | 2423f660 | ths | // gen_op_mtc0_performance3();
|
3000 | 2423f660 | ths | rn = "Performance3";
|
3001 | 2423f660 | ths | // break;
|
3002 | 7a387fff | ths | case 4: |
3003 | 2423f660 | ths | // gen_op_mtc0_performance4();
|
3004 | 2423f660 | ths | rn = "Performance4";
|
3005 | 2423f660 | ths | // break;
|
3006 | 7a387fff | ths | case 5: |
3007 | 2423f660 | ths | // gen_op_mtc0_performance5();
|
3008 | 2423f660 | ths | rn = "Performance5";
|
3009 | 2423f660 | ths | // break;
|
3010 | 7a387fff | ths | case 6: |
3011 | 2423f660 | ths | // gen_op_mtc0_performance6();
|
3012 | 2423f660 | ths | rn = "Performance6";
|
3013 | 2423f660 | ths | // break;
|
3014 | 7a387fff | ths | case 7: |
3015 | 2423f660 | ths | // gen_op_mtc0_performance7();
|
3016 | 2423f660 | ths | rn = "Performance7";
|
3017 | 2423f660 | ths | // break;
|
3018 | 7a387fff | ths | default:
|
3019 | 7a387fff | ths | goto die;
|
3020 | 7a387fff | ths | } |
3021 | 8c0fdd85 | ths | break;
|
3022 | 8c0fdd85 | ths | case 26: |
3023 | 2423f660 | ths | /* ignored */
|
3024 | 8c0fdd85 | ths | rn = "ECC";
|
3025 | 2423f660 | ths | break;
|
3026 | 8c0fdd85 | ths | case 27: |
3027 | 7a387fff | ths | switch (sel) {
|
3028 | 7a387fff | ths | case 0 ... 3: |
3029 | 2423f660 | ths | /* ignored */
|
3030 | 2423f660 | ths | rn = "CacheErr";
|
3031 | 2423f660 | ths | break;
|
3032 | 7a387fff | ths | default:
|
3033 | 7a387fff | ths | goto die;
|
3034 | 7a387fff | ths | } |
3035 | 8c0fdd85 | ths | break;
|
3036 | 8c0fdd85 | ths | case 28: |
3037 | 8c0fdd85 | ths | switch (sel) {
|
3038 | 8c0fdd85 | ths | case 0: |
3039 | 7a387fff | ths | case 2: |
3040 | 7a387fff | ths | case 4: |
3041 | 7a387fff | ths | case 6: |
3042 | 8c0fdd85 | ths | gen_op_mtc0_taglo(); |
3043 | 8c0fdd85 | ths | rn = "TagLo";
|
3044 | 8c0fdd85 | ths | break;
|
3045 | 7a387fff | ths | case 1: |
3046 | 7a387fff | ths | case 3: |
3047 | 7a387fff | ths | case 5: |
3048 | 7a387fff | ths | case 7: |
3049 | 2423f660 | ths | gen_op_mtc0_datalo(); |
3050 | 7a387fff | ths | rn = "DataLo";
|
3051 | 7a387fff | ths | break;
|
3052 | 8c0fdd85 | ths | default:
|
3053 | 8c0fdd85 | ths | goto die;
|
3054 | 8c0fdd85 | ths | } |
3055 | 8c0fdd85 | ths | break;
|
3056 | 8c0fdd85 | ths | case 29: |
3057 | 7a387fff | ths | switch (sel) {
|
3058 | 7a387fff | ths | case 0: |
3059 | 7a387fff | ths | case 2: |
3060 | 7a387fff | ths | case 4: |
3061 | 7a387fff | ths | case 6: |
3062 | 7a387fff | ths | gen_op_mtc0_taghi(); |
3063 | 7a387fff | ths | rn = "TagHi";
|
3064 | 7a387fff | ths | break;
|
3065 | 7a387fff | ths | case 1: |
3066 | 7a387fff | ths | case 3: |
3067 | 7a387fff | ths | case 5: |
3068 | 7a387fff | ths | case 7: |
3069 | 2423f660 | ths | gen_op_mtc0_datahi(); |
3070 | 7a387fff | ths | rn = "DataHi";
|
3071 | 7a387fff | ths | break;
|
3072 | 7a387fff | ths | default:
|
3073 | 7a387fff | ths | rn = "invalid sel";
|
3074 | 7a387fff | ths | goto die;
|
3075 | 7a387fff | ths | } |
3076 | 8c0fdd85 | ths | break;
|
3077 | 8c0fdd85 | ths | case 30: |
3078 | 7a387fff | ths | switch (sel) {
|
3079 | 7a387fff | ths | case 0: |
3080 | 2423f660 | ths | gen_op_mtc0_errorepc(); |
3081 | 2423f660 | ths | rn = "ErrorEPC";
|
3082 | 2423f660 | ths | break;
|
3083 | 7a387fff | ths | default:
|
3084 | 7a387fff | ths | goto die;
|
3085 | 7a387fff | ths | } |
3086 | 8c0fdd85 | ths | break;
|
3087 | 8c0fdd85 | ths | case 31: |
3088 | 7a387fff | ths | switch (sel) {
|
3089 | 7a387fff | ths | case 0: |
3090 | 2423f660 | ths | gen_op_mtc0_desave(); /* EJTAG support */
|
3091 | 2423f660 | ths | rn = "DESAVE";
|
3092 | 2423f660 | ths | break;
|
3093 | 7a387fff | ths | default:
|
3094 | 7a387fff | ths | goto die;
|
3095 | 7a387fff | ths | } |
3096 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
3097 | 2423f660 | ths | ctx->bstate = BS_STOP; |
3098 | 8c0fdd85 | ths | break;
|
3099 | 8c0fdd85 | ths | default:
|
3100 | 8c0fdd85 | ths | goto die;
|
3101 | 8c0fdd85 | ths | } |
3102 | 8c0fdd85 | ths | #if defined MIPS_DEBUG_DISAS
|
3103 | 8c0fdd85 | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
3104 | 7a387fff | ths | fprintf(logfile, "mtc0 %s (reg %d sel %d)\n",
|
3105 | 7a387fff | ths | rn, reg, sel); |
3106 | 8c0fdd85 | ths | } |
3107 | 8c0fdd85 | ths | #endif
|
3108 | 8c0fdd85 | ths | return;
|
3109 | 8c0fdd85 | ths | |
3110 | 8c0fdd85 | ths | die:
|
3111 | 8c0fdd85 | ths | #if defined MIPS_DEBUG_DISAS
|
3112 | 8c0fdd85 | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
3113 | 7a387fff | ths | fprintf(logfile, "mtc0 %s (reg %d sel %d)\n",
|
3114 | 7a387fff | ths | rn, reg, sel); |
3115 | 8c0fdd85 | ths | } |
3116 | 8c0fdd85 | ths | #endif
|
3117 | 8c0fdd85 | ths | generate_exception(ctx, EXCP_RI); |
3118 | 8c0fdd85 | ths | } |
3119 | 8c0fdd85 | ths | |
3120 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
3121 | 3a95e3a7 | ths | static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel) |
3122 | 9c2149c8 | ths | { |
3123 | 9c2149c8 | ths | const char *rn = "invalid"; |
3124 | 9c2149c8 | ths | |
3125 | e189e748 | ths | if (sel != 0) |
3126 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64); |
3127 | e189e748 | ths | |
3128 | 9c2149c8 | ths | switch (reg) {
|
3129 | 9c2149c8 | ths | case 0: |
3130 | 9c2149c8 | ths | switch (sel) {
|
3131 | 9c2149c8 | ths | case 0: |
3132 | 2423f660 | ths | gen_op_mfc0_index(); |
3133 | 9c2149c8 | ths | rn = "Index";
|
3134 | 9c2149c8 | ths | break;
|
3135 | 9c2149c8 | ths | case 1: |
3136 | ead9360e | ths | check_mips_mt(env, ctx); |
3137 | ead9360e | ths | gen_op_mfc0_mvpcontrol(); |
3138 | 9c2149c8 | ths | rn = "MVPControl";
|
3139 | ead9360e | ths | break;
|
3140 | 9c2149c8 | ths | case 2: |
3141 | ead9360e | ths | check_mips_mt(env, ctx); |
3142 | ead9360e | ths | gen_op_mfc0_mvpconf0(); |
3143 | 9c2149c8 | ths | rn = "MVPConf0";
|
3144 | ead9360e | ths | break;
|
3145 | 9c2149c8 | ths | case 3: |
3146 | ead9360e | ths | check_mips_mt(env, ctx); |
3147 | ead9360e | ths | gen_op_mfc0_mvpconf1(); |
3148 | 9c2149c8 | ths | rn = "MVPConf1";
|
3149 | ead9360e | ths | break;
|
3150 | 9c2149c8 | ths | default:
|
3151 | 9c2149c8 | ths | goto die;
|
3152 | 9c2149c8 | ths | } |
3153 | 9c2149c8 | ths | break;
|
3154 | 9c2149c8 | ths | case 1: |
3155 | 9c2149c8 | ths | switch (sel) {
|
3156 | 9c2149c8 | ths | case 0: |
3157 | 9c2149c8 | ths | gen_op_mfc0_random(); |
3158 | 9c2149c8 | ths | rn = "Random";
|
3159 | 2423f660 | ths | break;
|
3160 | 9c2149c8 | ths | case 1: |
3161 | ead9360e | ths | check_mips_mt(env, ctx); |
3162 | ead9360e | ths | gen_op_mfc0_vpecontrol(); |
3163 | 9c2149c8 | ths | rn = "VPEControl";
|
3164 | ead9360e | ths | break;
|
3165 | 9c2149c8 | ths | case 2: |
3166 | ead9360e | ths | check_mips_mt(env, ctx); |
3167 | ead9360e | ths | gen_op_mfc0_vpeconf0(); |
3168 | 9c2149c8 | ths | rn = "VPEConf0";
|
3169 | ead9360e | ths | break;
|
3170 | 9c2149c8 | ths | case 3: |
3171 | ead9360e | ths | check_mips_mt(env, ctx); |
3172 | ead9360e | ths | gen_op_mfc0_vpeconf1(); |
3173 | 9c2149c8 | ths | rn = "VPEConf1";
|
3174 | ead9360e | ths | break;
|
3175 | 9c2149c8 | ths | case 4: |
3176 | ead9360e | ths | check_mips_mt(env, ctx); |
3177 | ead9360e | ths | gen_op_dmfc0_yqmask(); |
3178 | 9c2149c8 | ths | rn = "YQMask";
|
3179 | ead9360e | ths | break;
|
3180 | 9c2149c8 | ths | case 5: |
3181 | ead9360e | ths | check_mips_mt(env, ctx); |
3182 | ead9360e | ths | gen_op_dmfc0_vpeschedule(); |
3183 | 9c2149c8 | ths | rn = "VPESchedule";
|
3184 | ead9360e | ths | break;
|
3185 | 9c2149c8 | ths | case 6: |
3186 | ead9360e | ths | check_mips_mt(env, ctx); |
3187 | ead9360e | ths | gen_op_dmfc0_vpeschefback(); |
3188 | 9c2149c8 | ths | rn = "VPEScheFBack";
|
3189 | ead9360e | ths | break;
|
3190 | 9c2149c8 | ths | case 7: |
3191 | ead9360e | ths | check_mips_mt(env, ctx); |
3192 | ead9360e | ths | gen_op_mfc0_vpeopt(); |
3193 | 9c2149c8 | ths | rn = "VPEOpt";
|
3194 | ead9360e | ths | break;
|
3195 | 9c2149c8 | ths | default:
|
3196 | 9c2149c8 | ths | goto die;
|
3197 | 9c2149c8 | ths | } |
3198 | 9c2149c8 | ths | break;
|
3199 | 9c2149c8 | ths | case 2: |
3200 | 9c2149c8 | ths | switch (sel) {
|
3201 | 9c2149c8 | ths | case 0: |
3202 | 2423f660 | ths | gen_op_dmfc0_entrylo0(); |
3203 | 2423f660 | ths | rn = "EntryLo0";
|
3204 | 2423f660 | ths | break;
|
3205 | 9c2149c8 | ths | case 1: |
3206 | ead9360e | ths | check_mips_mt(env, ctx); |
3207 | ead9360e | ths | gen_op_mfc0_tcstatus(); |
3208 | 2423f660 | ths | rn = "TCStatus";
|
3209 | ead9360e | ths | break;
|
3210 | 9c2149c8 | ths | case 2: |
3211 | ead9360e | ths | check_mips_mt(env, ctx); |
3212 | ead9360e | ths | gen_op_mfc0_tcbind(); |
3213 | 2423f660 | ths | rn = "TCBind";
|
3214 | ead9360e | ths | break;
|
3215 | 9c2149c8 | ths | case 3: |
3216 | ead9360e | ths | check_mips_mt(env, ctx); |
3217 | ead9360e | ths | gen_op_dmfc0_tcrestart(); |
3218 | 2423f660 | ths | rn = "TCRestart";
|
3219 | ead9360e | ths | break;
|
3220 | 9c2149c8 | ths | case 4: |
3221 | ead9360e | ths | check_mips_mt(env, ctx); |
3222 | ead9360e | ths | gen_op_dmfc0_tchalt(); |
3223 | 2423f660 | ths | rn = "TCHalt";
|
3224 | ead9360e | ths | break;
|
3225 | 9c2149c8 | ths | case 5: |
3226 | ead9360e | ths | check_mips_mt(env, ctx); |
3227 | ead9360e | ths | gen_op_dmfc0_tccontext(); |
3228 | 2423f660 | ths | rn = "TCContext";
|
3229 | ead9360e | ths | break;
|
3230 | 9c2149c8 | ths | case 6: |
3231 | ead9360e | ths | check_mips_mt(env, ctx); |
3232 | ead9360e | ths | gen_op_dmfc0_tcschedule(); |
3233 | 2423f660 | ths | rn = "TCSchedule";
|
3234 | ead9360e | ths | break;
|
3235 | 9c2149c8 | ths | case 7: |
3236 | ead9360e | ths | check_mips_mt(env, ctx); |
3237 | ead9360e | ths | gen_op_dmfc0_tcschefback(); |
3238 | 2423f660 | ths | rn = "TCScheFBack";
|
3239 | ead9360e | ths | break;
|
3240 | 9c2149c8 | ths | default:
|
3241 | 9c2149c8 | ths | goto die;
|
3242 | 9c2149c8 | ths | } |
3243 | 9c2149c8 | ths | break;
|
3244 | 9c2149c8 | ths | case 3: |
3245 | 9c2149c8 | ths | switch (sel) {
|
3246 | 9c2149c8 | ths | case 0: |
3247 | 2423f660 | ths | gen_op_dmfc0_entrylo1(); |
3248 | 2423f660 | ths | rn = "EntryLo1";
|
3249 | 2423f660 | ths | break;
|
3250 | 9c2149c8 | ths | default:
|
3251 | 9c2149c8 | ths | goto die;
|
3252 | 1579a72e | ths | } |
3253 | 9c2149c8 | ths | break;
|
3254 | 9c2149c8 | ths | case 4: |
3255 | 9c2149c8 | ths | switch (sel) {
|
3256 | 9c2149c8 | ths | case 0: |
3257 | 2423f660 | ths | gen_op_dmfc0_context(); |
3258 | 2423f660 | ths | rn = "Context";
|
3259 | 2423f660 | ths | break;
|
3260 | 9c2149c8 | ths | case 1: |
3261 | 2423f660 | ths | // gen_op_dmfc0_contextconfig(); /* SmartMIPS ASE */
|
3262 | 2423f660 | ths | rn = "ContextConfig";
|
3263 | 2423f660 | ths | // break;
|
3264 | 9c2149c8 | ths | default:
|
3265 | 9c2149c8 | ths | goto die;
|
3266 | 876d4b07 | ths | } |
3267 | 9c2149c8 | ths | break;
|
3268 | 9c2149c8 | ths | case 5: |
3269 | 9c2149c8 | ths | switch (sel) {
|
3270 | 9c2149c8 | ths | case 0: |
3271 | 2423f660 | ths | gen_op_mfc0_pagemask(); |
3272 | 2423f660 | ths | rn = "PageMask";
|
3273 | 2423f660 | ths | break;
|
3274 | 9c2149c8 | ths | case 1: |
3275 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3276 | 2423f660 | ths | gen_op_mfc0_pagegrain(); |
3277 | 2423f660 | ths | rn = "PageGrain";
|
3278 | 2423f660 | ths | break;
|
3279 | 9c2149c8 | ths | default:
|
3280 | 9c2149c8 | ths | goto die;
|
3281 | 876d4b07 | ths | } |
3282 | 9c2149c8 | ths | break;
|
3283 | 9c2149c8 | ths | case 6: |
3284 | 9c2149c8 | ths | switch (sel) {
|
3285 | 9c2149c8 | ths | case 0: |
3286 | 2423f660 | ths | gen_op_mfc0_wired(); |
3287 | 2423f660 | ths | rn = "Wired";
|
3288 | 2423f660 | ths | break;
|
3289 | 9c2149c8 | ths | case 1: |
3290 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3291 | ead9360e | ths | gen_op_mfc0_srsconf0(); |
3292 | 2423f660 | ths | rn = "SRSConf0";
|
3293 | ead9360e | ths | break;
|
3294 | 9c2149c8 | ths | case 2: |
3295 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3296 | ead9360e | ths | gen_op_mfc0_srsconf1(); |
3297 | 2423f660 | ths | rn = "SRSConf1";
|
3298 | ead9360e | ths | break;
|
3299 | 9c2149c8 | ths | case 3: |
3300 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3301 | ead9360e | ths | gen_op_mfc0_srsconf2(); |
3302 | 2423f660 | ths | rn = "SRSConf2";
|
3303 | ead9360e | ths | break;
|
3304 | 9c2149c8 | ths | case 4: |
3305 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3306 | ead9360e | ths | gen_op_mfc0_srsconf3(); |
3307 | 2423f660 | ths | rn = "SRSConf3";
|
3308 | ead9360e | ths | break;
|
3309 | 9c2149c8 | ths | case 5: |
3310 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3311 | ead9360e | ths | gen_op_mfc0_srsconf4(); |
3312 | 2423f660 | ths | rn = "SRSConf4";
|
3313 | ead9360e | ths | break;
|
3314 | 9c2149c8 | ths | default:
|
3315 | 9c2149c8 | ths | goto die;
|
3316 | 876d4b07 | ths | } |
3317 | 9c2149c8 | ths | break;
|
3318 | 9c2149c8 | ths | case 7: |
3319 | 9c2149c8 | ths | switch (sel) {
|
3320 | 9c2149c8 | ths | case 0: |
3321 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3322 | 2423f660 | ths | gen_op_mfc0_hwrena(); |
3323 | 2423f660 | ths | rn = "HWREna";
|
3324 | 2423f660 | ths | break;
|
3325 | 9c2149c8 | ths | default:
|
3326 | 9c2149c8 | ths | goto die;
|
3327 | 876d4b07 | ths | } |
3328 | 9c2149c8 | ths | break;
|
3329 | 9c2149c8 | ths | case 8: |
3330 | 9c2149c8 | ths | switch (sel) {
|
3331 | 9c2149c8 | ths | case 0: |
3332 | 2423f660 | ths | gen_op_dmfc0_badvaddr(); |
3333 | 2423f660 | ths | rn = "BadVaddr";
|
3334 | 2423f660 | ths | break;
|
3335 | 9c2149c8 | ths | default:
|
3336 | 9c2149c8 | ths | goto die;
|
3337 | 876d4b07 | ths | } |
3338 | 9c2149c8 | ths | break;
|
3339 | 9c2149c8 | ths | case 9: |
3340 | 9c2149c8 | ths | switch (sel) {
|
3341 | 9c2149c8 | ths | case 0: |
3342 | 2423f660 | ths | gen_op_mfc0_count(); |
3343 | 2423f660 | ths | rn = "Count";
|
3344 | 2423f660 | ths | break;
|
3345 | 2423f660 | ths | /* 6,7 are implementation dependent */
|
3346 | 9c2149c8 | ths | default:
|
3347 | 9c2149c8 | ths | goto die;
|
3348 | 876d4b07 | ths | } |
3349 | 9c2149c8 | ths | break;
|
3350 | 9c2149c8 | ths | case 10: |
3351 | 9c2149c8 | ths | switch (sel) {
|
3352 | 9c2149c8 | ths | case 0: |
3353 | 2423f660 | ths | gen_op_dmfc0_entryhi(); |
3354 | 2423f660 | ths | rn = "EntryHi";
|
3355 | 2423f660 | ths | break;
|
3356 | 9c2149c8 | ths | default:
|
3357 | 9c2149c8 | ths | goto die;
|
3358 | 876d4b07 | ths | } |
3359 | 9c2149c8 | ths | break;
|
3360 | 9c2149c8 | ths | case 11: |
3361 | 9c2149c8 | ths | switch (sel) {
|
3362 | 9c2149c8 | ths | case 0: |
3363 | 2423f660 | ths | gen_op_mfc0_compare(); |
3364 | 2423f660 | ths | rn = "Compare";
|
3365 | 2423f660 | ths | break;
|
3366 | 876d4b07 | ths | /* 6,7 are implementation dependent */
|
3367 | 9c2149c8 | ths | default:
|
3368 | 9c2149c8 | ths | goto die;
|
3369 | 876d4b07 | ths | } |
3370 | 9c2149c8 | ths | break;
|
3371 | 9c2149c8 | ths | case 12: |
3372 | 9c2149c8 | ths | switch (sel) {
|
3373 | 9c2149c8 | ths | case 0: |
3374 | 2423f660 | ths | gen_op_mfc0_status(); |
3375 | 2423f660 | ths | rn = "Status";
|
3376 | 2423f660 | ths | break;
|
3377 | 9c2149c8 | ths | case 1: |
3378 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3379 | 2423f660 | ths | gen_op_mfc0_intctl(); |
3380 | 2423f660 | ths | rn = "IntCtl";
|
3381 | 2423f660 | ths | break;
|
3382 | 9c2149c8 | ths | case 2: |
3383 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3384 | 2423f660 | ths | gen_op_mfc0_srsctl(); |
3385 | 2423f660 | ths | rn = "SRSCtl";
|
3386 | 2423f660 | ths | break;
|
3387 | 9c2149c8 | ths | case 3: |
3388 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3389 | ead9360e | ths | gen_op_mfc0_srsmap(); |
3390 | 2423f660 | ths | rn = "SRSMap";
|
3391 | 2423f660 | ths | break;
|
3392 | 9c2149c8 | ths | default:
|
3393 | 9c2149c8 | ths | goto die;
|
3394 | 876d4b07 | ths | } |
3395 | 9c2149c8 | ths | break;
|
3396 | 9c2149c8 | ths | case 13: |
3397 | 9c2149c8 | ths | switch (sel) {
|
3398 | 9c2149c8 | ths | case 0: |
3399 | 2423f660 | ths | gen_op_mfc0_cause(); |
3400 | 2423f660 | ths | rn = "Cause";
|
3401 | 2423f660 | ths | break;
|
3402 | 9c2149c8 | ths | default:
|
3403 | 9c2149c8 | ths | goto die;
|
3404 | 876d4b07 | ths | } |
3405 | 9c2149c8 | ths | break;
|
3406 | 9c2149c8 | ths | case 14: |
3407 | 9c2149c8 | ths | switch (sel) {
|
3408 | 9c2149c8 | ths | case 0: |
3409 | 2423f660 | ths | gen_op_dmfc0_epc(); |
3410 | 2423f660 | ths | rn = "EPC";
|
3411 | 2423f660 | ths | break;
|
3412 | 9c2149c8 | ths | default:
|
3413 | 9c2149c8 | ths | goto die;
|
3414 | 876d4b07 | ths | } |
3415 | 9c2149c8 | ths | break;
|
3416 | 9c2149c8 | ths | case 15: |
3417 | 9c2149c8 | ths | switch (sel) {
|
3418 | 9c2149c8 | ths | case 0: |
3419 | 2423f660 | ths | gen_op_mfc0_prid(); |
3420 | 2423f660 | ths | rn = "PRid";
|
3421 | 2423f660 | ths | break;
|
3422 | 9c2149c8 | ths | case 1: |
3423 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3424 | 2423f660 | ths | gen_op_mfc0_ebase(); |
3425 | 2423f660 | ths | rn = "EBase";
|
3426 | 2423f660 | ths | break;
|
3427 | 9c2149c8 | ths | default:
|
3428 | 9c2149c8 | ths | goto die;
|
3429 | 876d4b07 | ths | } |
3430 | 9c2149c8 | ths | break;
|
3431 | 9c2149c8 | ths | case 16: |
3432 | 9c2149c8 | ths | switch (sel) {
|
3433 | 9c2149c8 | ths | case 0: |
3434 | 2423f660 | ths | gen_op_mfc0_config0(); |
3435 | 9c2149c8 | ths | rn = "Config";
|
3436 | 9c2149c8 | ths | break;
|
3437 | 9c2149c8 | ths | case 1: |
3438 | 2423f660 | ths | gen_op_mfc0_config1(); |
3439 | 9c2149c8 | ths | rn = "Config1";
|
3440 | 9c2149c8 | ths | break;
|
3441 | 9c2149c8 | ths | case 2: |
3442 | 2423f660 | ths | gen_op_mfc0_config2(); |
3443 | 9c2149c8 | ths | rn = "Config2";
|
3444 | 9c2149c8 | ths | break;
|
3445 | 9c2149c8 | ths | case 3: |
3446 | 2423f660 | ths | gen_op_mfc0_config3(); |
3447 | 9c2149c8 | ths | rn = "Config3";
|
3448 | 9c2149c8 | ths | break;
|
3449 | 9c2149c8 | ths | /* 6,7 are implementation dependent */
|
3450 | 9c2149c8 | ths | default:
|
3451 | 9c2149c8 | ths | goto die;
|
3452 | 9c2149c8 | ths | } |
3453 | 9c2149c8 | ths | break;
|
3454 | 9c2149c8 | ths | case 17: |
3455 | 9c2149c8 | ths | switch (sel) {
|
3456 | 9c2149c8 | ths | case 0: |
3457 | 2423f660 | ths | gen_op_dmfc0_lladdr(); |
3458 | 2423f660 | ths | rn = "LLAddr";
|
3459 | 2423f660 | ths | break;
|
3460 | 9c2149c8 | ths | default:
|
3461 | 9c2149c8 | ths | goto die;
|
3462 | 9c2149c8 | ths | } |
3463 | 9c2149c8 | ths | break;
|
3464 | 9c2149c8 | ths | case 18: |
3465 | 9c2149c8 | ths | switch (sel) {
|
3466 | fd88b6ab | ths | case 0 ... 7: |
3467 | fd88b6ab | ths | gen_op_dmfc0_watchlo(sel); |
3468 | 2423f660 | ths | rn = "WatchLo";
|
3469 | 2423f660 | ths | break;
|
3470 | 9c2149c8 | ths | default:
|
3471 | 9c2149c8 | ths | goto die;
|
3472 | 9c2149c8 | ths | } |
3473 | 9c2149c8 | ths | break;
|
3474 | 9c2149c8 | ths | case 19: |
3475 | 9c2149c8 | ths | switch (sel) {
|
3476 | fd88b6ab | ths | case 0 ... 7: |
3477 | fd88b6ab | ths | gen_op_mfc0_watchhi(sel); |
3478 | 2423f660 | ths | rn = "WatchHi";
|
3479 | 2423f660 | ths | break;
|
3480 | 9c2149c8 | ths | default:
|
3481 | 9c2149c8 | ths | goto die;
|
3482 | 9c2149c8 | ths | } |
3483 | 9c2149c8 | ths | break;
|
3484 | 9c2149c8 | ths | case 20: |
3485 | 9c2149c8 | ths | switch (sel) {
|
3486 | 9c2149c8 | ths | case 0: |
3487 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
3488 | 2423f660 | ths | gen_op_dmfc0_xcontext(); |
3489 | 2423f660 | ths | rn = "XContext";
|
3490 | 2423f660 | ths | break;
|
3491 | 9c2149c8 | ths | default:
|
3492 | 9c2149c8 | ths | goto die;
|
3493 | 9c2149c8 | ths | } |
3494 | 9c2149c8 | ths | break;
|
3495 | 9c2149c8 | ths | case 21: |
3496 | 9c2149c8 | ths | /* Officially reserved, but sel 0 is used for R1x000 framemask */
|
3497 | 9c2149c8 | ths | switch (sel) {
|
3498 | 9c2149c8 | ths | case 0: |
3499 | 2423f660 | ths | gen_op_mfc0_framemask(); |
3500 | 2423f660 | ths | rn = "Framemask";
|
3501 | 2423f660 | ths | break;
|
3502 | 9c2149c8 | ths | default:
|
3503 | 9c2149c8 | ths | goto die;
|
3504 | 9c2149c8 | ths | } |
3505 | 9c2149c8 | ths | break;
|
3506 | 9c2149c8 | ths | case 22: |
3507 | 2423f660 | ths | /* ignored */
|
3508 | 2423f660 | ths | rn = "'Diagnostic"; /* implementation dependent */ |
3509 | 2423f660 | ths | break;
|
3510 | 9c2149c8 | ths | case 23: |
3511 | 9c2149c8 | ths | switch (sel) {
|
3512 | 9c2149c8 | ths | case 0: |
3513 | 2423f660 | ths | gen_op_mfc0_debug(); /* EJTAG support */
|
3514 | 2423f660 | ths | rn = "Debug";
|
3515 | 2423f660 | ths | break;
|
3516 | 9c2149c8 | ths | case 1: |
3517 | 2423f660 | ths | // gen_op_dmfc0_tracecontrol(); /* PDtrace support */
|
3518 | 2423f660 | ths | rn = "TraceControl";
|
3519 | 2423f660 | ths | // break;
|
3520 | 9c2149c8 | ths | case 2: |
3521 | 2423f660 | ths | // gen_op_dmfc0_tracecontrol2(); /* PDtrace support */
|
3522 | 2423f660 | ths | rn = "TraceControl2";
|
3523 | 2423f660 | ths | // break;
|
3524 | 9c2149c8 | ths | case 3: |
3525 | 2423f660 | ths | // gen_op_dmfc0_usertracedata(); /* PDtrace support */
|
3526 | 2423f660 | ths | rn = "UserTraceData";
|
3527 | 2423f660 | ths | // break;
|
3528 | 9c2149c8 | ths | case 4: |
3529 | 2423f660 | ths | // gen_op_dmfc0_debug(); /* PDtrace support */
|
3530 | 2423f660 | ths | rn = "TraceBPC";
|
3531 | 2423f660 | ths | // break;
|
3532 | 9c2149c8 | ths | default:
|
3533 | 9c2149c8 | ths | goto die;
|
3534 | 9c2149c8 | ths | } |
3535 | 9c2149c8 | ths | break;
|
3536 | 9c2149c8 | ths | case 24: |
3537 | 9c2149c8 | ths | switch (sel) {
|
3538 | 9c2149c8 | ths | case 0: |
3539 | 2423f660 | ths | gen_op_dmfc0_depc(); /* EJTAG support */
|
3540 | 2423f660 | ths | rn = "DEPC";
|
3541 | 2423f660 | ths | break;
|
3542 | 9c2149c8 | ths | default:
|
3543 | 9c2149c8 | ths | goto die;
|
3544 | 9c2149c8 | ths | } |
3545 | 9c2149c8 | ths | break;
|
3546 | 9c2149c8 | ths | case 25: |
3547 | 9c2149c8 | ths | switch (sel) {
|
3548 | 9c2149c8 | ths | case 0: |
3549 | 2423f660 | ths | gen_op_mfc0_performance0(); |
3550 | 2423f660 | ths | rn = "Performance0";
|
3551 | 9c2149c8 | ths | break;
|
3552 | 9c2149c8 | ths | case 1: |
3553 | 2423f660 | ths | // gen_op_dmfc0_performance1();
|
3554 | 2423f660 | ths | rn = "Performance1";
|
3555 | 2423f660 | ths | // break;
|
3556 | 9c2149c8 | ths | case 2: |
3557 | 2423f660 | ths | // gen_op_dmfc0_performance2();
|
3558 | 2423f660 | ths | rn = "Performance2";
|
3559 | 2423f660 | ths | // break;
|
3560 | 9c2149c8 | ths | case 3: |
3561 | 2423f660 | ths | // gen_op_dmfc0_performance3();
|
3562 | 2423f660 | ths | rn = "Performance3";
|
3563 | 2423f660 | ths | // break;
|
3564 | 9c2149c8 | ths | case 4: |
3565 | 2423f660 | ths | // gen_op_dmfc0_performance4();
|
3566 | 2423f660 | ths | rn = "Performance4";
|
3567 | 2423f660 | ths | // break;
|
3568 | 9c2149c8 | ths | case 5: |
3569 | 2423f660 | ths | // gen_op_dmfc0_performance5();
|
3570 | 2423f660 | ths | rn = "Performance5";
|
3571 | 2423f660 | ths | // break;
|
3572 | 9c2149c8 | ths | case 6: |
3573 | 2423f660 | ths | // gen_op_dmfc0_performance6();
|
3574 | 2423f660 | ths | rn = "Performance6";
|
3575 | 2423f660 | ths | // break;
|
3576 | 9c2149c8 | ths | case 7: |
3577 | 2423f660 | ths | // gen_op_dmfc0_performance7();
|
3578 | 2423f660 | ths | rn = "Performance7";
|
3579 | 2423f660 | ths | // break;
|
3580 | 9c2149c8 | ths | default:
|
3581 | 9c2149c8 | ths | goto die;
|
3582 | 9c2149c8 | ths | } |
3583 | 9c2149c8 | ths | break;
|
3584 | 9c2149c8 | ths | case 26: |
3585 | 9c2149c8 | ths | rn = "ECC";
|
3586 | 9c2149c8 | ths | break;
|
3587 | 9c2149c8 | ths | case 27: |
3588 | 9c2149c8 | ths | switch (sel) {
|
3589 | 9c2149c8 | ths | /* ignored */
|
3590 | 9c2149c8 | ths | case 0 ... 3: |
3591 | 2423f660 | ths | rn = "CacheErr";
|
3592 | 2423f660 | ths | break;
|
3593 | 9c2149c8 | ths | default:
|
3594 | 9c2149c8 | ths | goto die;
|
3595 | 9c2149c8 | ths | } |
3596 | 9c2149c8 | ths | break;
|
3597 | 9c2149c8 | ths | case 28: |
3598 | 9c2149c8 | ths | switch (sel) {
|
3599 | 9c2149c8 | ths | case 0: |
3600 | 9c2149c8 | ths | case 2: |
3601 | 9c2149c8 | ths | case 4: |
3602 | 9c2149c8 | ths | case 6: |
3603 | 9c2149c8 | ths | gen_op_mfc0_taglo(); |
3604 | 9c2149c8 | ths | rn = "TagLo";
|
3605 | 9c2149c8 | ths | break;
|
3606 | 9c2149c8 | ths | case 1: |
3607 | 9c2149c8 | ths | case 3: |
3608 | 9c2149c8 | ths | case 5: |
3609 | 9c2149c8 | ths | case 7: |
3610 | 9c2149c8 | ths | gen_op_mfc0_datalo(); |
3611 | 9c2149c8 | ths | rn = "DataLo";
|
3612 | 9c2149c8 | ths | break;
|
3613 | 9c2149c8 | ths | default:
|
3614 | 9c2149c8 | ths | goto die;
|
3615 | 9c2149c8 | ths | } |
3616 | 9c2149c8 | ths | break;
|
3617 | 9c2149c8 | ths | case 29: |
3618 | 9c2149c8 | ths | switch (sel) {
|
3619 | 9c2149c8 | ths | case 0: |
3620 | 9c2149c8 | ths | case 2: |
3621 | 9c2149c8 | ths | case 4: |
3622 | 9c2149c8 | ths | case 6: |
3623 | 9c2149c8 | ths | gen_op_mfc0_taghi(); |
3624 | 9c2149c8 | ths | rn = "TagHi";
|
3625 | 9c2149c8 | ths | break;
|
3626 | 9c2149c8 | ths | case 1: |
3627 | 9c2149c8 | ths | case 3: |
3628 | 9c2149c8 | ths | case 5: |
3629 | 9c2149c8 | ths | case 7: |
3630 | 9c2149c8 | ths | gen_op_mfc0_datahi(); |
3631 | 9c2149c8 | ths | rn = "DataHi";
|
3632 | 9c2149c8 | ths | break;
|
3633 | 9c2149c8 | ths | default:
|
3634 | 9c2149c8 | ths | goto die;
|
3635 | 9c2149c8 | ths | } |
3636 | 9c2149c8 | ths | break;
|
3637 | 9c2149c8 | ths | case 30: |
3638 | 9c2149c8 | ths | switch (sel) {
|
3639 | 9c2149c8 | ths | case 0: |
3640 | 2423f660 | ths | gen_op_dmfc0_errorepc(); |
3641 | 2423f660 | ths | rn = "ErrorEPC";
|
3642 | 2423f660 | ths | break;
|
3643 | 9c2149c8 | ths | default:
|
3644 | 9c2149c8 | ths | goto die;
|
3645 | 9c2149c8 | ths | } |
3646 | 9c2149c8 | ths | break;
|
3647 | 9c2149c8 | ths | case 31: |
3648 | 9c2149c8 | ths | switch (sel) {
|
3649 | 9c2149c8 | ths | case 0: |
3650 | 2423f660 | ths | gen_op_mfc0_desave(); /* EJTAG support */
|
3651 | 2423f660 | ths | rn = "DESAVE";
|
3652 | 2423f660 | ths | break;
|
3653 | 9c2149c8 | ths | default:
|
3654 | 9c2149c8 | ths | goto die;
|
3655 | 9c2149c8 | ths | } |
3656 | 9c2149c8 | ths | break;
|
3657 | 9c2149c8 | ths | default:
|
3658 | 876d4b07 | ths | goto die;
|
3659 | 9c2149c8 | ths | } |
3660 | 9c2149c8 | ths | #if defined MIPS_DEBUG_DISAS
|
3661 | 9c2149c8 | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
3662 | 9c2149c8 | ths | fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
|
3663 | 9c2149c8 | ths | rn, reg, sel); |
3664 | 9c2149c8 | ths | } |
3665 | 9c2149c8 | ths | #endif
|
3666 | 9c2149c8 | ths | return;
|
3667 | 9c2149c8 | ths | |
3668 | 9c2149c8 | ths | die:
|
3669 | 9c2149c8 | ths | #if defined MIPS_DEBUG_DISAS
|
3670 | 9c2149c8 | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
3671 | 9c2149c8 | ths | fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
|
3672 | 9c2149c8 | ths | rn, reg, sel); |
3673 | 9c2149c8 | ths | } |
3674 | 9c2149c8 | ths | #endif
|
3675 | 9c2149c8 | ths | generate_exception(ctx, EXCP_RI); |
3676 | 9c2149c8 | ths | } |
3677 | 9c2149c8 | ths | |
3678 | 3a95e3a7 | ths | static void gen_dmtc0 (CPUState *env, DisasContext *ctx, int reg, int sel) |
3679 | 9c2149c8 | ths | { |
3680 | 9c2149c8 | ths | const char *rn = "invalid"; |
3681 | 9c2149c8 | ths | |
3682 | e189e748 | ths | if (sel != 0) |
3683 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64); |
3684 | e189e748 | ths | |
3685 | 9c2149c8 | ths | switch (reg) {
|
3686 | 9c2149c8 | ths | case 0: |
3687 | 9c2149c8 | ths | switch (sel) {
|
3688 | 9c2149c8 | ths | case 0: |
3689 | 9c2149c8 | ths | gen_op_mtc0_index(); |
3690 | 9c2149c8 | ths | rn = "Index";
|
3691 | 9c2149c8 | ths | break;
|
3692 | 9c2149c8 | ths | case 1: |
3693 | ead9360e | ths | check_mips_mt(env, ctx); |
3694 | ead9360e | ths | gen_op_mtc0_mvpcontrol(); |
3695 | 9c2149c8 | ths | rn = "MVPControl";
|
3696 | ead9360e | ths | break;
|
3697 | 9c2149c8 | ths | case 2: |
3698 | ead9360e | ths | check_mips_mt(env, ctx); |
3699 | ead9360e | ths | /* ignored */
|
3700 | 9c2149c8 | ths | rn = "MVPConf0";
|
3701 | ead9360e | ths | break;
|
3702 | 9c2149c8 | ths | case 3: |
3703 | ead9360e | ths | check_mips_mt(env, ctx); |
3704 | ead9360e | ths | /* ignored */
|
3705 | 9c2149c8 | ths | rn = "MVPConf1";
|
3706 | ead9360e | ths | break;
|
3707 | 9c2149c8 | ths | default:
|
3708 | 9c2149c8 | ths | goto die;
|
3709 | 9c2149c8 | ths | } |
3710 | 9c2149c8 | ths | break;
|
3711 | 9c2149c8 | ths | case 1: |
3712 | 9c2149c8 | ths | switch (sel) {
|
3713 | 9c2149c8 | ths | case 0: |
3714 | 2423f660 | ths | /* ignored */
|
3715 | 9c2149c8 | ths | rn = "Random";
|
3716 | 2423f660 | ths | break;
|
3717 | 9c2149c8 | ths | case 1: |
3718 | ead9360e | ths | check_mips_mt(env, ctx); |
3719 | ead9360e | ths | gen_op_mtc0_vpecontrol(); |
3720 | 9c2149c8 | ths | rn = "VPEControl";
|
3721 | ead9360e | ths | break;
|
3722 | 9c2149c8 | ths | case 2: |
3723 | ead9360e | ths | check_mips_mt(env, ctx); |
3724 | ead9360e | ths | gen_op_mtc0_vpeconf0(); |
3725 | 9c2149c8 | ths | rn = "VPEConf0";
|
3726 | ead9360e | ths | break;
|
3727 | 9c2149c8 | ths | case 3: |
3728 | ead9360e | ths | check_mips_mt(env, ctx); |
3729 | ead9360e | ths | gen_op_mtc0_vpeconf1(); |
3730 | 9c2149c8 | ths | rn = "VPEConf1";
|
3731 | ead9360e | ths | break;
|
3732 | 9c2149c8 | ths | case 4: |
3733 | ead9360e | ths | check_mips_mt(env, ctx); |
3734 | ead9360e | ths | gen_op_mtc0_yqmask(); |
3735 | 9c2149c8 | ths | rn = "YQMask";
|
3736 | ead9360e | ths | break;
|
3737 | 9c2149c8 | ths | case 5: |
3738 | ead9360e | ths | check_mips_mt(env, ctx); |
3739 | ead9360e | ths | gen_op_mtc0_vpeschedule(); |
3740 | 9c2149c8 | ths | rn = "VPESchedule";
|
3741 | ead9360e | ths | break;
|
3742 | 9c2149c8 | ths | case 6: |
3743 | ead9360e | ths | check_mips_mt(env, ctx); |
3744 | ead9360e | ths | gen_op_mtc0_vpeschefback(); |
3745 | 9c2149c8 | ths | rn = "VPEScheFBack";
|
3746 | ead9360e | ths | break;
|
3747 | 9c2149c8 | ths | case 7: |
3748 | ead9360e | ths | check_mips_mt(env, ctx); |
3749 | ead9360e | ths | gen_op_mtc0_vpeopt(); |
3750 | 9c2149c8 | ths | rn = "VPEOpt";
|
3751 | ead9360e | ths | break;
|
3752 | 9c2149c8 | ths | default:
|
3753 | 9c2149c8 | ths | goto die;
|
3754 | 9c2149c8 | ths | } |
3755 | 9c2149c8 | ths | break;
|
3756 | 9c2149c8 | ths | case 2: |
3757 | 9c2149c8 | ths | switch (sel) {
|
3758 | 9c2149c8 | ths | case 0: |
3759 | f1b0aa5d | ths | gen_op_mtc0_entrylo0(); |
3760 | 2423f660 | ths | rn = "EntryLo0";
|
3761 | 2423f660 | ths | break;
|
3762 | 9c2149c8 | ths | case 1: |
3763 | ead9360e | ths | check_mips_mt(env, ctx); |
3764 | ead9360e | ths | gen_op_mtc0_tcstatus(); |
3765 | 2423f660 | ths | rn = "TCStatus";
|
3766 | ead9360e | ths | break;
|
3767 | 9c2149c8 | ths | case 2: |
3768 | ead9360e | ths | check_mips_mt(env, ctx); |
3769 | ead9360e | ths | gen_op_mtc0_tcbind(); |
3770 | 2423f660 | ths | rn = "TCBind";
|
3771 | ead9360e | ths | break;
|
3772 | 9c2149c8 | ths | case 3: |
3773 | ead9360e | ths | check_mips_mt(env, ctx); |
3774 | ead9360e | ths | gen_op_mtc0_tcrestart(); |
3775 | 2423f660 | ths | rn = "TCRestart";
|
3776 | ead9360e | ths | break;
|
3777 | 9c2149c8 | ths | case 4: |
3778 | ead9360e | ths | check_mips_mt(env, ctx); |
3779 | ead9360e | ths | gen_op_mtc0_tchalt(); |
3780 | 2423f660 | ths | rn = "TCHalt";
|
3781 | ead9360e | ths | break;
|
3782 | 9c2149c8 | ths | case 5: |
3783 | ead9360e | ths | check_mips_mt(env, ctx); |
3784 | ead9360e | ths | gen_op_mtc0_tccontext(); |
3785 | 2423f660 | ths | rn = "TCContext";
|
3786 | ead9360e | ths | break;
|
3787 | 9c2149c8 | ths | case 6: |
3788 | ead9360e | ths | check_mips_mt(env, ctx); |
3789 | ead9360e | ths | gen_op_mtc0_tcschedule(); |
3790 | 2423f660 | ths | rn = "TCSchedule";
|
3791 | ead9360e | ths | break;
|
3792 | 9c2149c8 | ths | case 7: |
3793 | ead9360e | ths | check_mips_mt(env, ctx); |
3794 | ead9360e | ths | gen_op_mtc0_tcschefback(); |
3795 | 2423f660 | ths | rn = "TCScheFBack";
|
3796 | ead9360e | ths | break;
|
3797 | 9c2149c8 | ths | default:
|
3798 | 9c2149c8 | ths | goto die;
|
3799 | 9c2149c8 | ths | } |
3800 | 9c2149c8 | ths | break;
|
3801 | 9c2149c8 | ths | case 3: |
3802 | 9c2149c8 | ths | switch (sel) {
|
3803 | 9c2149c8 | ths | case 0: |
3804 | f1b0aa5d | ths | gen_op_mtc0_entrylo1(); |
3805 | 2423f660 | ths | rn = "EntryLo1";
|
3806 | 2423f660 | ths | break;
|
3807 | 9c2149c8 | ths | default:
|
3808 | 9c2149c8 | ths | goto die;
|
3809 | 876d4b07 | ths | } |
3810 | 9c2149c8 | ths | break;
|
3811 | 9c2149c8 | ths | case 4: |
3812 | 9c2149c8 | ths | switch (sel) {
|
3813 | 9c2149c8 | ths | case 0: |
3814 | f1b0aa5d | ths | gen_op_mtc0_context(); |
3815 | 2423f660 | ths | rn = "Context";
|
3816 | 2423f660 | ths | break;
|
3817 | 9c2149c8 | ths | case 1: |
3818 | f1b0aa5d | ths | // gen_op_mtc0_contextconfig(); /* SmartMIPS ASE */
|
3819 | 2423f660 | ths | rn = "ContextConfig";
|
3820 | 2423f660 | ths | // break;
|
3821 | 9c2149c8 | ths | default:
|
3822 | 9c2149c8 | ths | goto die;
|
3823 | 876d4b07 | ths | } |
3824 | 9c2149c8 | ths | break;
|
3825 | 9c2149c8 | ths | case 5: |
3826 | 9c2149c8 | ths | switch (sel) {
|
3827 | 9c2149c8 | ths | case 0: |
3828 | 2423f660 | ths | gen_op_mtc0_pagemask(); |
3829 | 2423f660 | ths | rn = "PageMask";
|
3830 | 2423f660 | ths | break;
|
3831 | 9c2149c8 | ths | case 1: |
3832 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3833 | 2423f660 | ths | gen_op_mtc0_pagegrain(); |
3834 | 2423f660 | ths | rn = "PageGrain";
|
3835 | 2423f660 | ths | break;
|
3836 | 9c2149c8 | ths | default:
|
3837 | 9c2149c8 | ths | goto die;
|
3838 | 876d4b07 | ths | } |
3839 | 9c2149c8 | ths | break;
|
3840 | 9c2149c8 | ths | case 6: |
3841 | 9c2149c8 | ths | switch (sel) {
|
3842 | 9c2149c8 | ths | case 0: |
3843 | 2423f660 | ths | gen_op_mtc0_wired(); |
3844 | 2423f660 | ths | rn = "Wired";
|
3845 | 2423f660 | ths | break;
|
3846 | 9c2149c8 | ths | case 1: |
3847 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3848 | ead9360e | ths | gen_op_mtc0_srsconf0(); |
3849 | 2423f660 | ths | rn = "SRSConf0";
|
3850 | ead9360e | ths | break;
|
3851 | 9c2149c8 | ths | case 2: |
3852 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3853 | ead9360e | ths | gen_op_mtc0_srsconf1(); |
3854 | 2423f660 | ths | rn = "SRSConf1";
|
3855 | ead9360e | ths | break;
|
3856 | 9c2149c8 | ths | case 3: |
3857 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3858 | ead9360e | ths | gen_op_mtc0_srsconf2(); |
3859 | 2423f660 | ths | rn = "SRSConf2";
|
3860 | ead9360e | ths | break;
|
3861 | 9c2149c8 | ths | case 4: |
3862 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3863 | ead9360e | ths | gen_op_mtc0_srsconf3(); |
3864 | 2423f660 | ths | rn = "SRSConf3";
|
3865 | ead9360e | ths | break;
|
3866 | 9c2149c8 | ths | case 5: |
3867 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3868 | ead9360e | ths | gen_op_mtc0_srsconf4(); |
3869 | 2423f660 | ths | rn = "SRSConf4";
|
3870 | ead9360e | ths | break;
|
3871 | 9c2149c8 | ths | default:
|
3872 | 9c2149c8 | ths | goto die;
|
3873 | 876d4b07 | ths | } |
3874 | 9c2149c8 | ths | break;
|
3875 | 9c2149c8 | ths | case 7: |
3876 | 9c2149c8 | ths | switch (sel) {
|
3877 | 9c2149c8 | ths | case 0: |
3878 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3879 | 2423f660 | ths | gen_op_mtc0_hwrena(); |
3880 | 2423f660 | ths | rn = "HWREna";
|
3881 | 2423f660 | ths | break;
|
3882 | 9c2149c8 | ths | default:
|
3883 | 9c2149c8 | ths | goto die;
|
3884 | 876d4b07 | ths | } |
3885 | 9c2149c8 | ths | break;
|
3886 | 9c2149c8 | ths | case 8: |
3887 | 9c2149c8 | ths | /* ignored */
|
3888 | 9c2149c8 | ths | rn = "BadVaddr";
|
3889 | 9c2149c8 | ths | break;
|
3890 | 9c2149c8 | ths | case 9: |
3891 | 9c2149c8 | ths | switch (sel) {
|
3892 | 9c2149c8 | ths | case 0: |
3893 | 2423f660 | ths | gen_op_mtc0_count(); |
3894 | 2423f660 | ths | rn = "Count";
|
3895 | 2423f660 | ths | break;
|
3896 | 876d4b07 | ths | /* 6,7 are implementation dependent */
|
3897 | 9c2149c8 | ths | default:
|
3898 | 9c2149c8 | ths | goto die;
|
3899 | 876d4b07 | ths | } |
3900 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
3901 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
3902 | 9c2149c8 | ths | break;
|
3903 | 9c2149c8 | ths | case 10: |
3904 | 9c2149c8 | ths | switch (sel) {
|
3905 | 9c2149c8 | ths | case 0: |
3906 | 2423f660 | ths | gen_op_mtc0_entryhi(); |
3907 | 2423f660 | ths | rn = "EntryHi";
|
3908 | 2423f660 | ths | break;
|
3909 | 9c2149c8 | ths | default:
|
3910 | 9c2149c8 | ths | goto die;
|
3911 | 876d4b07 | ths | } |
3912 | 9c2149c8 | ths | break;
|
3913 | 9c2149c8 | ths | case 11: |
3914 | 9c2149c8 | ths | switch (sel) {
|
3915 | 9c2149c8 | ths | case 0: |
3916 | 2423f660 | ths | gen_op_mtc0_compare(); |
3917 | 2423f660 | ths | rn = "Compare";
|
3918 | 2423f660 | ths | break;
|
3919 | 876d4b07 | ths | /* 6,7 are implementation dependent */
|
3920 | 9c2149c8 | ths | default:
|
3921 | 9c2149c8 | ths | goto die;
|
3922 | 876d4b07 | ths | } |
3923 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
3924 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
3925 | 9c2149c8 | ths | break;
|
3926 | 9c2149c8 | ths | case 12: |
3927 | 9c2149c8 | ths | switch (sel) {
|
3928 | 9c2149c8 | ths | case 0: |
3929 | 2423f660 | ths | gen_op_mtc0_status(); |
3930 | 8487327a | ths | /* BS_STOP isn't good enough here, hflags may have changed. */
|
3931 | 8487327a | ths | gen_save_pc(ctx->pc + 4);
|
3932 | 8487327a | ths | ctx->bstate = BS_EXCP; |
3933 | 2423f660 | ths | rn = "Status";
|
3934 | 2423f660 | ths | break;
|
3935 | 9c2149c8 | ths | case 1: |
3936 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3937 | 2423f660 | ths | gen_op_mtc0_intctl(); |
3938 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3939 | 8487327a | ths | ctx->bstate = BS_STOP; |
3940 | 2423f660 | ths | rn = "IntCtl";
|
3941 | 2423f660 | ths | break;
|
3942 | 9c2149c8 | ths | case 2: |
3943 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3944 | 2423f660 | ths | gen_op_mtc0_srsctl(); |
3945 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3946 | 8487327a | ths | ctx->bstate = BS_STOP; |
3947 | 2423f660 | ths | rn = "SRSCtl";
|
3948 | 2423f660 | ths | break;
|
3949 | 9c2149c8 | ths | case 3: |
3950 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3951 | fd88b6ab | ths | gen_op_mtc0_srsmap(); |
3952 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3953 | 8487327a | ths | ctx->bstate = BS_STOP; |
3954 | 2423f660 | ths | rn = "SRSMap";
|
3955 | 2423f660 | ths | break;
|
3956 | 2423f660 | ths | default:
|
3957 | 9c2149c8 | ths | goto die;
|
3958 | 876d4b07 | ths | } |
3959 | 9c2149c8 | ths | break;
|
3960 | 9c2149c8 | ths | case 13: |
3961 | 9c2149c8 | ths | switch (sel) {
|
3962 | 9c2149c8 | ths | case 0: |
3963 | 2423f660 | ths | gen_op_mtc0_cause(); |
3964 | 2423f660 | ths | rn = "Cause";
|
3965 | 2423f660 | ths | break;
|
3966 | 9c2149c8 | ths | default:
|
3967 | 9c2149c8 | ths | goto die;
|
3968 | 876d4b07 | ths | } |
3969 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
3970 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
3971 | 9c2149c8 | ths | break;
|
3972 | 9c2149c8 | ths | case 14: |
3973 | 9c2149c8 | ths | switch (sel) {
|
3974 | 9c2149c8 | ths | case 0: |
3975 | f1b0aa5d | ths | gen_op_mtc0_epc(); |
3976 | 2423f660 | ths | rn = "EPC";
|
3977 | 2423f660 | ths | break;
|
3978 | 9c2149c8 | ths | default:
|
3979 | 9c2149c8 | ths | goto die;
|
3980 | 876d4b07 | ths | } |
3981 | 9c2149c8 | ths | break;
|
3982 | 9c2149c8 | ths | case 15: |
3983 | 9c2149c8 | ths | switch (sel) {
|
3984 | 9c2149c8 | ths | case 0: |
3985 | 2423f660 | ths | /* ignored */
|
3986 | 2423f660 | ths | rn = "PRid";
|
3987 | 2423f660 | ths | break;
|
3988 | 9c2149c8 | ths | case 1: |
3989 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3990 | 2423f660 | ths | gen_op_mtc0_ebase(); |
3991 | 2423f660 | ths | rn = "EBase";
|
3992 | 2423f660 | ths | break;
|
3993 | 9c2149c8 | ths | default:
|
3994 | 9c2149c8 | ths | goto die;
|
3995 | 876d4b07 | ths | } |
3996 | 9c2149c8 | ths | break;
|
3997 | 9c2149c8 | ths | case 16: |
3998 | 9c2149c8 | ths | switch (sel) {
|
3999 | 9c2149c8 | ths | case 0: |
4000 | 9c2149c8 | ths | gen_op_mtc0_config0(); |
4001 | 9c2149c8 | ths | rn = "Config";
|
4002 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
4003 | 2423f660 | ths | ctx->bstate = BS_STOP; |
4004 | 9c2149c8 | ths | break;
|
4005 | 9c2149c8 | ths | case 1: |
4006 | 2423f660 | ths | /* ignored */
|
4007 | 9c2149c8 | ths | rn = "Config1";
|
4008 | 9c2149c8 | ths | break;
|
4009 | 9c2149c8 | ths | case 2: |
4010 | 9c2149c8 | ths | gen_op_mtc0_config2(); |
4011 | 9c2149c8 | ths | rn = "Config2";
|
4012 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
4013 | 2423f660 | ths | ctx->bstate = BS_STOP; |
4014 | 9c2149c8 | ths | break;
|
4015 | 9c2149c8 | ths | case 3: |
4016 | 2423f660 | ths | /* ignored */
|
4017 | 9c2149c8 | ths | rn = "Config3";
|
4018 | 9c2149c8 | ths | break;
|
4019 | 9c2149c8 | ths | /* 6,7 are implementation dependent */
|
4020 | 9c2149c8 | ths | default:
|
4021 | 9c2149c8 | ths | rn = "Invalid config selector";
|
4022 | 9c2149c8 | ths | goto die;
|
4023 | 9c2149c8 | ths | } |
4024 | 9c2149c8 | ths | break;
|
4025 | 9c2149c8 | ths | case 17: |
4026 | 9c2149c8 | ths | switch (sel) {
|
4027 | 9c2149c8 | ths | case 0: |
4028 | 2423f660 | ths | /* ignored */
|
4029 | 2423f660 | ths | rn = "LLAddr";
|
4030 | 2423f660 | ths | break;
|
4031 | 9c2149c8 | ths | default:
|
4032 | 9c2149c8 | ths | goto die;
|
4033 | 9c2149c8 | ths | } |
4034 | 9c2149c8 | ths | break;
|
4035 | 9c2149c8 | ths | case 18: |
4036 | 9c2149c8 | ths | switch (sel) {
|
4037 | fd88b6ab | ths | case 0 ... 7: |
4038 | fd88b6ab | ths | gen_op_mtc0_watchlo(sel); |
4039 | 2423f660 | ths | rn = "WatchLo";
|
4040 | 2423f660 | ths | break;
|
4041 | 9c2149c8 | ths | default:
|
4042 | 9c2149c8 | ths | goto die;
|
4043 | 9c2149c8 | ths | } |
4044 | 9c2149c8 | ths | break;
|
4045 | 9c2149c8 | ths | case 19: |
4046 | 9c2149c8 | ths | switch (sel) {
|
4047 | fd88b6ab | ths | case 0 ... 7: |
4048 | fd88b6ab | ths | gen_op_mtc0_watchhi(sel); |
4049 | 2423f660 | ths | rn = "WatchHi";
|
4050 | 2423f660 | ths | break;
|
4051 | 9c2149c8 | ths | default:
|
4052 | 9c2149c8 | ths | goto die;
|
4053 | 9c2149c8 | ths | } |
4054 | 9c2149c8 | ths | break;
|
4055 | 9c2149c8 | ths | case 20: |
4056 | 9c2149c8 | ths | switch (sel) {
|
4057 | 9c2149c8 | ths | case 0: |
4058 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
4059 | f1b0aa5d | ths | gen_op_mtc0_xcontext(); |
4060 | 2423f660 | ths | rn = "XContext";
|
4061 | 2423f660 | ths | break;
|
4062 | 9c2149c8 | ths | default:
|
4063 | 9c2149c8 | ths | goto die;
|
4064 | 9c2149c8 | ths | } |
4065 | 9c2149c8 | ths | break;
|
4066 | 9c2149c8 | ths | case 21: |
4067 | 9c2149c8 | ths | /* Officially reserved, but sel 0 is used for R1x000 framemask */
|
4068 | 9c2149c8 | ths | switch (sel) {
|
4069 | 9c2149c8 | ths | case 0: |
4070 | 2423f660 | ths | gen_op_mtc0_framemask(); |
4071 | 2423f660 | ths | rn = "Framemask";
|
4072 | 2423f660 | ths | break;
|
4073 | 9c2149c8 | ths | default:
|
4074 | 9c2149c8 | ths | goto die;
|
4075 | 9c2149c8 | ths | } |
4076 | 9c2149c8 | ths | break;
|
4077 | 9c2149c8 | ths | case 22: |
4078 | 9c2149c8 | ths | /* ignored */
|
4079 | 9c2149c8 | ths | rn = "Diagnostic"; /* implementation dependent */ |
4080 | 876d4b07 | ths | break;
|
4081 | 9c2149c8 | ths | case 23: |
4082 | 9c2149c8 | ths | switch (sel) {
|
4083 | 9c2149c8 | ths | case 0: |
4084 | 2423f660 | ths | gen_op_mtc0_debug(); /* EJTAG support */
|
4085 | 8487327a | ths | /* BS_STOP isn't good enough here, hflags may have changed. */
|
4086 | 8487327a | ths | gen_save_pc(ctx->pc + 4);
|
4087 | 8487327a | ths | ctx->bstate = BS_EXCP; |
4088 | 2423f660 | ths | rn = "Debug";
|
4089 | 2423f660 | ths | break;
|
4090 | 9c2149c8 | ths | case 1: |
4091 | f1b0aa5d | ths | // gen_op_mtc0_tracecontrol(); /* PDtrace support */
|
4092 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4093 | 8487327a | ths | ctx->bstate = BS_STOP; |
4094 | 2423f660 | ths | rn = "TraceControl";
|
4095 | 2423f660 | ths | // break;
|
4096 | 9c2149c8 | ths | case 2: |
4097 | f1b0aa5d | ths | // gen_op_mtc0_tracecontrol2(); /* PDtrace support */
|
4098 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4099 | 8487327a | ths | ctx->bstate = BS_STOP; |
4100 | 2423f660 | ths | rn = "TraceControl2";
|
4101 | 2423f660 | ths | // break;
|
4102 | 9c2149c8 | ths | case 3: |
4103 | f1b0aa5d | ths | // gen_op_mtc0_usertracedata(); /* PDtrace support */
|
4104 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4105 | 8487327a | ths | ctx->bstate = BS_STOP; |
4106 | 2423f660 | ths | rn = "UserTraceData";
|
4107 | 2423f660 | ths | // break;
|
4108 | 9c2149c8 | ths | case 4: |
4109 | f1b0aa5d | ths | // gen_op_mtc0_debug(); /* PDtrace support */
|
4110 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4111 | 8487327a | ths | ctx->bstate = BS_STOP; |
4112 | 2423f660 | ths | rn = "TraceBPC";
|
4113 | 2423f660 | ths | // break;
|
4114 | 9c2149c8 | ths | default:
|
4115 | 9c2149c8 | ths | goto die;
|
4116 | 9c2149c8 | ths | } |
4117 | 9c2149c8 | ths | break;
|
4118 | 9c2149c8 | ths | case 24: |
4119 | 9c2149c8 | ths | switch (sel) {
|
4120 | 9c2149c8 | ths | case 0: |
4121 | f1b0aa5d | ths | gen_op_mtc0_depc(); /* EJTAG support */
|
4122 | 2423f660 | ths | rn = "DEPC";
|
4123 | 2423f660 | ths | break;
|
4124 | 9c2149c8 | ths | default:
|
4125 | 9c2149c8 | ths | goto die;
|
4126 | 9c2149c8 | ths | } |
4127 | 9c2149c8 | ths | break;
|
4128 | 9c2149c8 | ths | case 25: |
4129 | 9c2149c8 | ths | switch (sel) {
|
4130 | 9c2149c8 | ths | case 0: |
4131 | 2423f660 | ths | gen_op_mtc0_performance0(); |
4132 | 2423f660 | ths | rn = "Performance0";
|
4133 | 2423f660 | ths | break;
|
4134 | 9c2149c8 | ths | case 1: |
4135 | f1b0aa5d | ths | // gen_op_mtc0_performance1();
|
4136 | 2423f660 | ths | rn = "Performance1";
|
4137 | 2423f660 | ths | // break;
|
4138 | 9c2149c8 | ths | case 2: |
4139 | f1b0aa5d | ths | // gen_op_mtc0_performance2();
|
4140 | 2423f660 | ths | rn = "Performance2";
|
4141 | 2423f660 | ths | // break;
|
4142 | 9c2149c8 | ths | case 3: |
4143 | f1b0aa5d | ths | // gen_op_mtc0_performance3();
|
4144 | 2423f660 | ths | rn = "Performance3";
|
4145 | 2423f660 | ths | // break;
|
4146 | 9c2149c8 | ths | case 4: |
4147 | f1b0aa5d | ths | // gen_op_mtc0_performance4();
|
4148 | 2423f660 | ths | rn = "Performance4";
|
4149 | 2423f660 | ths | // break;
|
4150 | 9c2149c8 | ths | case 5: |
4151 | f1b0aa5d | ths | // gen_op_mtc0_performance5();
|
4152 | 2423f660 | ths | rn = "Performance5";
|
4153 | 2423f660 | ths | // break;
|
4154 | 9c2149c8 | ths | case 6: |
4155 | f1b0aa5d | ths | // gen_op_mtc0_performance6();
|
4156 | 2423f660 | ths | rn = "Performance6";
|
4157 | 2423f660 | ths | // break;
|
4158 | 9c2149c8 | ths | case 7: |
4159 | f1b0aa5d | ths | // gen_op_mtc0_performance7();
|
4160 | 2423f660 | ths | rn = "Performance7";
|
4161 | 2423f660 | ths | // break;
|
4162 | 9c2149c8 | ths | default:
|
4163 | 9c2149c8 | ths | goto die;
|
4164 | 9c2149c8 | ths | } |
4165 | 876d4b07 | ths | break;
|
4166 | 9c2149c8 | ths | case 26: |
4167 | 876d4b07 | ths | /* ignored */
|
4168 | 9c2149c8 | ths | rn = "ECC";
|
4169 | 876d4b07 | ths | break;
|
4170 | 9c2149c8 | ths | case 27: |
4171 | 9c2149c8 | ths | switch (sel) {
|
4172 | 9c2149c8 | ths | case 0 ... 3: |
4173 | 2423f660 | ths | /* ignored */
|
4174 | 2423f660 | ths | rn = "CacheErr";
|
4175 | 2423f660 | ths | break;
|
4176 | 9c2149c8 | ths | default:
|
4177 | 9c2149c8 | ths | goto die;
|
4178 | 9c2149c8 | ths | } |
4179 | 876d4b07 | ths | break;
|
4180 | 9c2149c8 | ths | case 28: |
4181 | 9c2149c8 | ths | switch (sel) {
|
4182 | 9c2149c8 | ths | case 0: |
4183 | 9c2149c8 | ths | case 2: |
4184 | 9c2149c8 | ths | case 4: |
4185 | 9c2149c8 | ths | case 6: |
4186 | 9c2149c8 | ths | gen_op_mtc0_taglo(); |
4187 | 9c2149c8 | ths | rn = "TagLo";
|
4188 | 9c2149c8 | ths | break;
|
4189 | 9c2149c8 | ths | case 1: |
4190 | 9c2149c8 | ths | case 3: |
4191 | 9c2149c8 | ths | case 5: |
4192 | 9c2149c8 | ths | case 7: |
4193 | 2423f660 | ths | gen_op_mtc0_datalo(); |
4194 | 9c2149c8 | ths | rn = "DataLo";
|
4195 | 9c2149c8 | ths | break;
|
4196 | 9c2149c8 | ths | default:
|
4197 | 9c2149c8 | ths | goto die;
|
4198 | 9c2149c8 | ths | } |
4199 | 9c2149c8 | ths | break;
|
4200 | 9c2149c8 | ths | case 29: |
4201 | 9c2149c8 | ths | switch (sel) {
|
4202 | 9c2149c8 | ths | case 0: |
4203 | 9c2149c8 | ths | case 2: |
4204 | 9c2149c8 | ths | case 4: |
4205 | 9c2149c8 | ths | case 6: |
4206 | 9c2149c8 | ths | gen_op_mtc0_taghi(); |
4207 | 9c2149c8 | ths | rn = "TagHi";
|
4208 | 9c2149c8 | ths | break;
|
4209 | 9c2149c8 | ths | case 1: |
4210 | 9c2149c8 | ths | case 3: |
4211 | 9c2149c8 | ths | case 5: |
4212 | 9c2149c8 | ths | case 7: |
4213 | 2423f660 | ths | gen_op_mtc0_datahi(); |
4214 | 9c2149c8 | ths | rn = "DataHi";
|
4215 | 9c2149c8 | ths | break;
|
4216 | 9c2149c8 | ths | default:
|
4217 | 9c2149c8 | ths | rn = "invalid sel";
|
4218 | 9c2149c8 | ths | goto die;
|
4219 | 9c2149c8 | ths | } |
4220 | 876d4b07 | ths | break;
|
4221 | 9c2149c8 | ths | case 30: |
4222 | 9c2149c8 | ths | switch (sel) {
|
4223 | 9c2149c8 | ths | case 0: |
4224 | f1b0aa5d | ths | gen_op_mtc0_errorepc(); |
4225 | 2423f660 | ths | rn = "ErrorEPC";
|
4226 | 2423f660 | ths | break;
|
4227 | 9c2149c8 | ths | default:
|
4228 | 9c2149c8 | ths | goto die;
|
4229 | 9c2149c8 | ths | } |
4230 | 9c2149c8 | ths | break;
|
4231 | 9c2149c8 | ths | case 31: |
4232 | 9c2149c8 | ths | switch (sel) {
|
4233 | 9c2149c8 | ths | case 0: |
4234 | 2423f660 | ths | gen_op_mtc0_desave(); /* EJTAG support */
|
4235 | 2423f660 | ths | rn = "DESAVE";
|
4236 | 2423f660 | ths | break;
|
4237 | 9c2149c8 | ths | default:
|
4238 | 9c2149c8 | ths | goto die;
|
4239 | 9c2149c8 | ths | } |
4240 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
4241 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
4242 | 9c2149c8 | ths | break;
|
4243 | 9c2149c8 | ths | default:
|
4244 | 876d4b07 | ths | goto die;
|
4245 | 9c2149c8 | ths | } |
4246 | 9c2149c8 | ths | #if defined MIPS_DEBUG_DISAS
|
4247 | 9c2149c8 | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
4248 | 9c2149c8 | ths | fprintf(logfile, "dmtc0 %s (reg %d sel %d)\n",
|
4249 | 9c2149c8 | ths | rn, reg, sel); |
4250 | 9c2149c8 | ths | } |
4251 | 9c2149c8 | ths | #endif
|
4252 | 9c2149c8 | ths | return;
|
4253 | 9c2149c8 | ths | |
4254 | 9c2149c8 | ths | die:
|
4255 | 9c2149c8 | ths | #if defined MIPS_DEBUG_DISAS
|
4256 | 9c2149c8 | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
4257 | 9c2149c8 | ths | fprintf(logfile, "dmtc0 %s (reg %d sel %d)\n",
|
4258 | 9c2149c8 | ths | rn, reg, sel); |
4259 | 9c2149c8 | ths | } |
4260 | 9c2149c8 | ths | #endif
|
4261 | 9c2149c8 | ths | generate_exception(ctx, EXCP_RI); |
4262 | 9c2149c8 | ths | } |
4263 | 540635ba | ths | #endif /* TARGET_MIPSN32 || TARGET_MIPS64 */ |
4264 | 9c2149c8 | ths | |
4265 | ead9360e | ths | static void gen_mftr(CPUState *env, DisasContext *ctx, int rt, |
4266 | ead9360e | ths | int u, int sel, int h) |
4267 | ead9360e | ths | { |
4268 | ead9360e | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
4269 | ead9360e | ths | |
4270 | ead9360e | ths | if ((env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) == 0 && |
4271 | ead9360e | ths | ((env->CP0_TCBind[other_tc] & (0xf << CP0TCBd_CurVPE)) !=
|
4272 | ead9360e | ths | (env->CP0_TCBind[env->current_tc] & (0xf << CP0TCBd_CurVPE))))
|
4273 | ead9360e | ths | gen_op_set_T0(-1);
|
4274 | ead9360e | ths | else if ((env->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) > |
4275 | ead9360e | ths | (env->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
|
4276 | ead9360e | ths | gen_op_set_T0(-1);
|
4277 | ead9360e | ths | else if (u == 0) { |
4278 | ead9360e | ths | switch (rt) {
|
4279 | ead9360e | ths | case 2: |
4280 | ead9360e | ths | switch (sel) {
|
4281 | ead9360e | ths | case 1: |
4282 | ead9360e | ths | gen_op_mftc0_tcstatus(); |
4283 | ead9360e | ths | break;
|
4284 | ead9360e | ths | case 2: |
4285 | ead9360e | ths | gen_op_mftc0_tcbind(); |
4286 | ead9360e | ths | break;
|
4287 | ead9360e | ths | case 3: |
4288 | ead9360e | ths | gen_op_mftc0_tcrestart(); |
4289 | ead9360e | ths | break;
|
4290 | ead9360e | ths | case 4: |
4291 | ead9360e | ths | gen_op_mftc0_tchalt(); |
4292 | ead9360e | ths | break;
|
4293 | ead9360e | ths | case 5: |
4294 | ead9360e | ths | gen_op_mftc0_tccontext(); |
4295 | ead9360e | ths | break;
|
4296 | ead9360e | ths | case 6: |
4297 | ead9360e | ths | gen_op_mftc0_tcschedule(); |
4298 | ead9360e | ths | break;
|
4299 | ead9360e | ths | case 7: |
4300 | ead9360e | ths | gen_op_mftc0_tcschefback(); |
4301 | ead9360e | ths | break;
|
4302 | ead9360e | ths | default:
|
4303 | ead9360e | ths | gen_mfc0(env, ctx, rt, sel); |
4304 | ead9360e | ths | break;
|
4305 | ead9360e | ths | } |
4306 | ead9360e | ths | break;
|
4307 | ead9360e | ths | case 10: |
4308 | ead9360e | ths | switch (sel) {
|
4309 | ead9360e | ths | case 0: |
4310 | ead9360e | ths | gen_op_mftc0_entryhi(); |
4311 | ead9360e | ths | break;
|
4312 | ead9360e | ths | default:
|
4313 | ead9360e | ths | gen_mfc0(env, ctx, rt, sel); |
4314 | ead9360e | ths | break;
|
4315 | ead9360e | ths | } |
4316 | ead9360e | ths | case 12: |
4317 | ead9360e | ths | switch (sel) {
|
4318 | ead9360e | ths | case 0: |
4319 | ead9360e | ths | gen_op_mftc0_status(); |
4320 | ead9360e | ths | break;
|
4321 | ead9360e | ths | default:
|
4322 | ead9360e | ths | gen_mfc0(env, ctx, rt, sel); |
4323 | ead9360e | ths | break;
|
4324 | ead9360e | ths | } |
4325 | ead9360e | ths | case 23: |
4326 | ead9360e | ths | switch (sel) {
|
4327 | ead9360e | ths | case 0: |
4328 | ead9360e | ths | gen_op_mftc0_debug(); |
4329 | ead9360e | ths | break;
|
4330 | ead9360e | ths | default:
|
4331 | ead9360e | ths | gen_mfc0(env, ctx, rt, sel); |
4332 | ead9360e | ths | break;
|
4333 | ead9360e | ths | } |
4334 | ead9360e | ths | break;
|
4335 | ead9360e | ths | default:
|
4336 | ead9360e | ths | gen_mfc0(env, ctx, rt, sel); |
4337 | ead9360e | ths | } |
4338 | ead9360e | ths | } else switch (sel) { |
4339 | ead9360e | ths | /* GPR registers. */
|
4340 | ead9360e | ths | case 0: |
4341 | ead9360e | ths | gen_op_mftgpr(rt); |
4342 | ead9360e | ths | break;
|
4343 | ead9360e | ths | /* Auxiliary CPU registers */
|
4344 | ead9360e | ths | case 1: |
4345 | ead9360e | ths | switch (rt) {
|
4346 | ead9360e | ths | case 0: |
4347 | ead9360e | ths | gen_op_mftlo(0);
|
4348 | ead9360e | ths | break;
|
4349 | ead9360e | ths | case 1: |
4350 | ead9360e | ths | gen_op_mfthi(0);
|
4351 | ead9360e | ths | break;
|
4352 | ead9360e | ths | case 2: |
4353 | ead9360e | ths | gen_op_mftacx(0);
|
4354 | ead9360e | ths | break;
|
4355 | ead9360e | ths | case 4: |
4356 | ead9360e | ths | gen_op_mftlo(1);
|
4357 | ead9360e | ths | break;
|
4358 | ead9360e | ths | case 5: |
4359 | ead9360e | ths | gen_op_mfthi(1);
|
4360 | ead9360e | ths | break;
|
4361 | ead9360e | ths | case 6: |
4362 | ead9360e | ths | gen_op_mftacx(1);
|
4363 | ead9360e | ths | break;
|
4364 | ead9360e | ths | case 8: |
4365 | ead9360e | ths | gen_op_mftlo(2);
|
4366 | ead9360e | ths | break;
|
4367 | ead9360e | ths | case 9: |
4368 | ead9360e | ths | gen_op_mfthi(2);
|
4369 | ead9360e | ths | break;
|
4370 | ead9360e | ths | case 10: |
4371 | ead9360e | ths | gen_op_mftacx(2);
|
4372 | ead9360e | ths | break;
|
4373 | ead9360e | ths | case 12: |
4374 | ead9360e | ths | gen_op_mftlo(3);
|
4375 | ead9360e | ths | break;
|
4376 | ead9360e | ths | case 13: |
4377 | ead9360e | ths | gen_op_mfthi(3);
|
4378 | ead9360e | ths | break;
|
4379 | ead9360e | ths | case 14: |
4380 | ead9360e | ths | gen_op_mftacx(3);
|
4381 | ead9360e | ths | break;
|
4382 | ead9360e | ths | case 16: |
4383 | ead9360e | ths | gen_op_mftdsp(); |
4384 | ead9360e | ths | break;
|
4385 | ead9360e | ths | default:
|
4386 | ead9360e | ths | goto die;
|
4387 | ead9360e | ths | } |
4388 | ead9360e | ths | break;
|
4389 | ead9360e | ths | /* Floating point (COP1). */
|
4390 | ead9360e | ths | case 2: |
4391 | ead9360e | ths | /* XXX: For now we support only a single FPU context. */
|
4392 | ead9360e | ths | if (h == 0) { |
4393 | ead9360e | ths | GEN_LOAD_FREG_FTN(WT0, rt); |
4394 | ead9360e | ths | gen_op_mfc1(); |
4395 | ead9360e | ths | } else {
|
4396 | ead9360e | ths | GEN_LOAD_FREG_FTN(WTH0, rt); |
4397 | ead9360e | ths | gen_op_mfhc1(); |
4398 | ead9360e | ths | } |
4399 | ead9360e | ths | break;
|
4400 | ead9360e | ths | case 3: |
4401 | ead9360e | ths | /* XXX: For now we support only a single FPU context. */
|
4402 | ead9360e | ths | gen_op_cfc1(rt); |
4403 | ead9360e | ths | break;
|
4404 | ead9360e | ths | /* COP2: Not implemented. */
|
4405 | ead9360e | ths | case 4: |
4406 | ead9360e | ths | case 5: |
4407 | ead9360e | ths | /* fall through */
|
4408 | ead9360e | ths | default:
|
4409 | ead9360e | ths | goto die;
|
4410 | ead9360e | ths | } |
4411 | ead9360e | ths | #if defined MIPS_DEBUG_DISAS
|
4412 | ead9360e | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
4413 | ead9360e | ths | fprintf(logfile, "mftr (reg %d u %d sel %d h %d)\n",
|
4414 | ead9360e | ths | rt, u, sel, h); |
4415 | ead9360e | ths | } |
4416 | ead9360e | ths | #endif
|
4417 | ead9360e | ths | return;
|
4418 | ead9360e | ths | |
4419 | ead9360e | ths | die:
|
4420 | ead9360e | ths | #if defined MIPS_DEBUG_DISAS
|
4421 | ead9360e | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
4422 | ead9360e | ths | fprintf(logfile, "mftr (reg %d u %d sel %d h %d)\n",
|
4423 | ead9360e | ths | rt, u, sel, h); |
4424 | ead9360e | ths | } |
4425 | ead9360e | ths | #endif
|
4426 | ead9360e | ths | generate_exception(ctx, EXCP_RI); |
4427 | ead9360e | ths | } |
4428 | ead9360e | ths | |
4429 | ead9360e | ths | static void gen_mttr(CPUState *env, DisasContext *ctx, int rd, |
4430 | ead9360e | ths | int u, int sel, int h) |
4431 | ead9360e | ths | { |
4432 | ead9360e | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
4433 | ead9360e | ths | |
4434 | ead9360e | ths | if ((env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) == 0 && |
4435 | ead9360e | ths | ((env->CP0_TCBind[other_tc] & (0xf << CP0TCBd_CurVPE)) !=
|
4436 | ead9360e | ths | (env->CP0_TCBind[env->current_tc] & (0xf << CP0TCBd_CurVPE))))
|
4437 | ead9360e | ths | /* NOP */ ;
|
4438 | ead9360e | ths | else if ((env->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) > |
4439 | ead9360e | ths | (env->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
|
4440 | ead9360e | ths | /* NOP */ ;
|
4441 | ead9360e | ths | else if (u == 0) { |
4442 | ead9360e | ths | switch (rd) {
|
4443 | ead9360e | ths | case 2: |
4444 | ead9360e | ths | switch (sel) {
|
4445 | ead9360e | ths | case 1: |
4446 | ead9360e | ths | gen_op_mttc0_tcstatus(); |
4447 | ead9360e | ths | break;
|
4448 | ead9360e | ths | case 2: |
4449 | ead9360e | ths | gen_op_mttc0_tcbind(); |
4450 | ead9360e | ths | break;
|
4451 | ead9360e | ths | case 3: |
4452 | ead9360e | ths | gen_op_mttc0_tcrestart(); |
4453 | ead9360e | ths | break;
|
4454 | ead9360e | ths | case 4: |
4455 | ead9360e | ths | gen_op_mttc0_tchalt(); |
4456 | ead9360e | ths | break;
|
4457 | ead9360e | ths | case 5: |
4458 | ead9360e | ths | gen_op_mttc0_tccontext(); |
4459 | ead9360e | ths | break;
|
4460 | ead9360e | ths | case 6: |
4461 | ead9360e | ths | gen_op_mttc0_tcschedule(); |
4462 | ead9360e | ths | break;
|
4463 | ead9360e | ths | case 7: |
4464 | ead9360e | ths | gen_op_mttc0_tcschefback(); |
4465 | ead9360e | ths | break;
|
4466 | ead9360e | ths | default:
|
4467 | ead9360e | ths | gen_mtc0(env, ctx, rd, sel); |
4468 | ead9360e | ths | break;
|
4469 | ead9360e | ths | } |
4470 | ead9360e | ths | break;
|
4471 | ead9360e | ths | case 10: |
4472 | ead9360e | ths | switch (sel) {
|
4473 | ead9360e | ths | case 0: |
4474 | ead9360e | ths | gen_op_mttc0_entryhi(); |
4475 | ead9360e | ths | break;
|
4476 | ead9360e | ths | default:
|
4477 | ead9360e | ths | gen_mtc0(env, ctx, rd, sel); |
4478 | ead9360e | ths | break;
|
4479 | ead9360e | ths | } |
4480 | ead9360e | ths | case 12: |
4481 | ead9360e | ths | switch (sel) {
|
4482 | ead9360e | ths | case 0: |
4483 | ead9360e | ths | gen_op_mttc0_status(); |
4484 | ead9360e | ths | break;
|
4485 | ead9360e | ths | default:
|
4486 | ead9360e | ths | gen_mtc0(env, ctx, rd, sel); |
4487 | ead9360e | ths | break;
|
4488 | ead9360e | ths | } |
4489 | ead9360e | ths | case 23: |
4490 | ead9360e | ths | switch (sel) {
|
4491 | ead9360e | ths | case 0: |
4492 | ead9360e | ths | gen_op_mttc0_debug(); |
4493 | ead9360e | ths | break;
|
4494 | ead9360e | ths | default:
|
4495 | ead9360e | ths | gen_mtc0(env, ctx, rd, sel); |
4496 | ead9360e | ths | break;
|
4497 | ead9360e | ths | } |
4498 | ead9360e | ths | break;
|
4499 | ead9360e | ths | default:
|
4500 | ead9360e | ths | gen_mtc0(env, ctx, rd, sel); |
4501 | ead9360e | ths | } |
4502 | ead9360e | ths | } else switch (sel) { |
4503 | ead9360e | ths | /* GPR registers. */
|
4504 | ead9360e | ths | case 0: |
4505 | ead9360e | ths | gen_op_mttgpr(rd); |
4506 | ead9360e | ths | break;
|
4507 | ead9360e | ths | /* Auxiliary CPU registers */
|
4508 | ead9360e | ths | case 1: |
4509 | ead9360e | ths | switch (rd) {
|
4510 | ead9360e | ths | case 0: |
4511 | ead9360e | ths | gen_op_mttlo(0);
|
4512 | ead9360e | ths | break;
|
4513 | ead9360e | ths | case 1: |
4514 | ead9360e | ths | gen_op_mtthi(0);
|
4515 | ead9360e | ths | break;
|
4516 | ead9360e | ths | case 2: |
4517 | ead9360e | ths | gen_op_mttacx(0);
|
4518 | ead9360e | ths | break;
|
4519 | ead9360e | ths | case 4: |
4520 | ead9360e | ths | gen_op_mttlo(1);
|
4521 | ead9360e | ths | break;
|
4522 | ead9360e | ths | case 5: |
4523 | ead9360e | ths | gen_op_mtthi(1);
|
4524 | ead9360e | ths | break;
|
4525 | ead9360e | ths | case 6: |
4526 | ead9360e | ths | gen_op_mttacx(1);
|
4527 | ead9360e | ths | break;
|
4528 | ead9360e | ths | case 8: |
4529 | ead9360e | ths | gen_op_mttlo(2);
|
4530 | ead9360e | ths | break;
|
4531 | ead9360e | ths | case 9: |
4532 | ead9360e | ths | gen_op_mtthi(2);
|
4533 | ead9360e | ths | break;
|
4534 | ead9360e | ths | case 10: |
4535 | ead9360e | ths | gen_op_mttacx(2);
|
4536 | ead9360e | ths | break;
|
4537 | ead9360e | ths | case 12: |
4538 | ead9360e | ths | gen_op_mttlo(3);
|
4539 | ead9360e | ths | break;
|
4540 | ead9360e | ths | case 13: |
4541 | ead9360e | ths | gen_op_mtthi(3);
|
4542 | ead9360e | ths | break;
|
4543 | ead9360e | ths | case 14: |
4544 | ead9360e | ths | gen_op_mttacx(3);
|
4545 | ead9360e | ths | break;
|
4546 | ead9360e | ths | case 16: |
4547 | ead9360e | ths | gen_op_mttdsp(); |
4548 | ead9360e | ths | break;
|
4549 | ead9360e | ths | default:
|
4550 | ead9360e | ths | goto die;
|
4551 | ead9360e | ths | } |
4552 | ead9360e | ths | break;
|
4553 | ead9360e | ths | /* Floating point (COP1). */
|
4554 | ead9360e | ths | case 2: |
4555 | ead9360e | ths | /* XXX: For now we support only a single FPU context. */
|
4556 | ead9360e | ths | if (h == 0) { |
4557 | ead9360e | ths | gen_op_mtc1(); |
4558 | ead9360e | ths | GEN_STORE_FTN_FREG(rd, WT0); |
4559 | ead9360e | ths | } else {
|
4560 | ead9360e | ths | gen_op_mthc1(); |
4561 | ead9360e | ths | GEN_STORE_FTN_FREG(rd, WTH0); |
4562 | ead9360e | ths | } |
4563 | ead9360e | ths | break;
|
4564 | ead9360e | ths | case 3: |
4565 | ead9360e | ths | /* XXX: For now we support only a single FPU context. */
|
4566 | ead9360e | ths | gen_op_ctc1(rd); |
4567 | ead9360e | ths | break;
|
4568 | ead9360e | ths | /* COP2: Not implemented. */
|
4569 | ead9360e | ths | case 4: |
4570 | ead9360e | ths | case 5: |
4571 | ead9360e | ths | /* fall through */
|
4572 | ead9360e | ths | default:
|
4573 | ead9360e | ths | goto die;
|
4574 | ead9360e | ths | } |
4575 | ead9360e | ths | #if defined MIPS_DEBUG_DISAS
|
4576 | ead9360e | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
4577 | ead9360e | ths | fprintf(logfile, "mttr (reg %d u %d sel %d h %d)\n",
|
4578 | ead9360e | ths | rd, u, sel, h); |
4579 | ead9360e | ths | } |
4580 | ead9360e | ths | #endif
|
4581 | ead9360e | ths | return;
|
4582 | ead9360e | ths | |
4583 | ead9360e | ths | die:
|
4584 | ead9360e | ths | #if defined MIPS_DEBUG_DISAS
|
4585 | ead9360e | ths | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
4586 | ead9360e | ths | fprintf(logfile, "mttr (reg %d u %d sel %d h %d)\n",
|
4587 | ead9360e | ths | rd, u, sel, h); |
4588 | ead9360e | ths | } |
4589 | ead9360e | ths | #endif
|
4590 | ead9360e | ths | generate_exception(ctx, EXCP_RI); |
4591 | ead9360e | ths | } |
4592 | ead9360e | ths | |
4593 | 29929e34 | ths | static void gen_cp0 (CPUState *env, DisasContext *ctx, uint32_t opc, int rt, int rd) |
4594 | 6af0bf9c | bellard | { |
4595 | 287c4b84 | ths | const char *opn = "ldst"; |
4596 | 6af0bf9c | bellard | |
4597 | 6af0bf9c | bellard | switch (opc) {
|
4598 | 6af0bf9c | bellard | case OPC_MFC0:
|
4599 | 6af0bf9c | bellard | if (rt == 0) { |
4600 | ead9360e | ths | /* Treat as NOP. */
|
4601 | 6af0bf9c | bellard | return;
|
4602 | 6af0bf9c | bellard | } |
4603 | 3a95e3a7 | ths | gen_mfc0(env, ctx, rd, ctx->opcode & 0x7);
|
4604 | 6af0bf9c | bellard | gen_op_store_T0_gpr(rt); |
4605 | 6af0bf9c | bellard | opn = "mfc0";
|
4606 | 6af0bf9c | bellard | break;
|
4607 | 6af0bf9c | bellard | case OPC_MTC0:
|
4608 | 6af0bf9c | bellard | GEN_LOAD_REG_TN(T0, rt); |
4609 | 387a8fe5 | ths | save_cpu_state(ctx, 1);
|
4610 | 3a95e3a7 | ths | gen_mtc0(env, ctx, rd, ctx->opcode & 0x7);
|
4611 | 6af0bf9c | bellard | opn = "mtc0";
|
4612 | 6af0bf9c | bellard | break;
|
4613 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
4614 | 9c2149c8 | ths | case OPC_DMFC0:
|
4615 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
4616 | 9c2149c8 | ths | if (rt == 0) { |
4617 | ead9360e | ths | /* Treat as NOP. */
|
4618 | 9c2149c8 | ths | return;
|
4619 | 9c2149c8 | ths | } |
4620 | 3a95e3a7 | ths | gen_dmfc0(env, ctx, rd, ctx->opcode & 0x7);
|
4621 | 9c2149c8 | ths | gen_op_store_T0_gpr(rt); |
4622 | 9c2149c8 | ths | opn = "dmfc0";
|
4623 | 9c2149c8 | ths | break;
|
4624 | 9c2149c8 | ths | case OPC_DMTC0:
|
4625 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
4626 | 9c2149c8 | ths | GEN_LOAD_REG_TN(T0, rt); |
4627 | 387a8fe5 | ths | save_cpu_state(ctx, 1);
|
4628 | ead9360e | ths | gen_dmtc0(env, ctx, rd, ctx->opcode & 0x7);
|
4629 | 9c2149c8 | ths | opn = "dmtc0";
|
4630 | 9c2149c8 | ths | break;
|
4631 | 534ce69f | ths | #endif
|
4632 | ead9360e | ths | case OPC_MFTR:
|
4633 | ead9360e | ths | check_mips_mt(env, ctx); |
4634 | ead9360e | ths | if (rd == 0) { |
4635 | ead9360e | ths | /* Treat as NOP. */
|
4636 | ead9360e | ths | return;
|
4637 | ead9360e | ths | } |
4638 | ead9360e | ths | gen_mftr(env, ctx, rt, (ctx->opcode >> 5) & 1, |
4639 | ead9360e | ths | ctx->opcode & 0x7, (ctx->opcode >> 4) & 1); |
4640 | ead9360e | ths | gen_op_store_T0_gpr(rd); |
4641 | ead9360e | ths | opn = "mftr";
|
4642 | ead9360e | ths | break;
|
4643 | ead9360e | ths | case OPC_MTTR:
|
4644 | ead9360e | ths | check_mips_mt(env, ctx); |
4645 | ead9360e | ths | GEN_LOAD_REG_TN(T0, rt); |
4646 | ead9360e | ths | gen_mttr(env, ctx, rd, (ctx->opcode >> 5) & 1, |
4647 | ead9360e | ths | ctx->opcode & 0x7, (ctx->opcode >> 4) & 1); |
4648 | ead9360e | ths | opn = "mttr";
|
4649 | ead9360e | ths | break;
|
4650 | 6af0bf9c | bellard | case OPC_TLBWI:
|
4651 | 6af0bf9c | bellard | opn = "tlbwi";
|
4652 | ead9360e | ths | if (!env->tlb->do_tlbwi)
|
4653 | 29929e34 | ths | goto die;
|
4654 | 29929e34 | ths | gen_op_tlbwi(); |
4655 | 6af0bf9c | bellard | break;
|
4656 | 6af0bf9c | bellard | case OPC_TLBWR:
|
4657 | 6af0bf9c | bellard | opn = "tlbwr";
|
4658 | ead9360e | ths | if (!env->tlb->do_tlbwr)
|
4659 | 29929e34 | ths | goto die;
|
4660 | 29929e34 | ths | gen_op_tlbwr(); |
4661 | 6af0bf9c | bellard | break;
|
4662 | 6af0bf9c | bellard | case OPC_TLBP:
|
4663 | 6af0bf9c | bellard | opn = "tlbp";
|
4664 | ead9360e | ths | if (!env->tlb->do_tlbp)
|
4665 | 29929e34 | ths | goto die;
|
4666 | 29929e34 | ths | gen_op_tlbp(); |
4667 | 6af0bf9c | bellard | break;
|
4668 | 6af0bf9c | bellard | case OPC_TLBR:
|
4669 | 6af0bf9c | bellard | opn = "tlbr";
|
4670 | ead9360e | ths | if (!env->tlb->do_tlbr)
|
4671 | 29929e34 | ths | goto die;
|
4672 | 29929e34 | ths | gen_op_tlbr(); |
4673 | 6af0bf9c | bellard | break;
|
4674 | 6af0bf9c | bellard | case OPC_ERET:
|
4675 | 6af0bf9c | bellard | opn = "eret";
|
4676 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS2); |
4677 | 387a8fe5 | ths | save_cpu_state(ctx, 1);
|
4678 | 6af0bf9c | bellard | gen_op_eret(); |
4679 | 6af0bf9c | bellard | ctx->bstate = BS_EXCP; |
4680 | 6af0bf9c | bellard | break;
|
4681 | 6af0bf9c | bellard | case OPC_DERET:
|
4682 | 6af0bf9c | bellard | opn = "deret";
|
4683 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
4684 | 6af0bf9c | bellard | if (!(ctx->hflags & MIPS_HFLAG_DM)) {
|
4685 | 923617a3 | ths | MIPS_INVAL(opn); |
4686 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
4687 | 6af0bf9c | bellard | } else {
|
4688 | 387a8fe5 | ths | save_cpu_state(ctx, 1);
|
4689 | 6af0bf9c | bellard | gen_op_deret(); |
4690 | 6af0bf9c | bellard | ctx->bstate = BS_EXCP; |
4691 | 6af0bf9c | bellard | } |
4692 | 6af0bf9c | bellard | break;
|
4693 | 4ad40f36 | bellard | case OPC_WAIT:
|
4694 | 4ad40f36 | bellard | opn = "wait";
|
4695 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32); |
4696 | 4ad40f36 | bellard | /* If we get an exception, we want to restart at next instruction */
|
4697 | 4ad40f36 | bellard | ctx->pc += 4;
|
4698 | 4ad40f36 | bellard | save_cpu_state(ctx, 1);
|
4699 | 4ad40f36 | bellard | ctx->pc -= 4;
|
4700 | 4ad40f36 | bellard | gen_op_wait(); |
4701 | 4ad40f36 | bellard | ctx->bstate = BS_EXCP; |
4702 | 4ad40f36 | bellard | break;
|
4703 | 6af0bf9c | bellard | default:
|
4704 | 29929e34 | ths | die:
|
4705 | 923617a3 | ths | MIPS_INVAL(opn); |
4706 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
4707 | 6af0bf9c | bellard | return;
|
4708 | 6af0bf9c | bellard | } |
4709 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s %d", opn, regnames[rt], rd);
|
4710 | 6af0bf9c | bellard | } |
4711 | 6af0bf9c | bellard | |
4712 | 6ea83fed | bellard | /* CP1 Branches (before delay slot) */
|
4713 | e189e748 | ths | static void gen_compute_branch1 (CPUState *env, DisasContext *ctx, uint32_t op, |
4714 | 5a5012ec | ths | int32_t cc, int32_t offset) |
4715 | 6ea83fed | bellard | { |
4716 | 6ea83fed | bellard | target_ulong btarget; |
4717 | 923617a3 | ths | const char *opn = "cp1 cond branch"; |
4718 | 6ea83fed | bellard | |
4719 | e189e748 | ths | if (cc != 0) |
4720 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); |
4721 | e189e748 | ths | |
4722 | 6ea83fed | bellard | btarget = ctx->pc + 4 + offset;
|
4723 | 6ea83fed | bellard | |
4724 | 7a387fff | ths | switch (op) {
|
4725 | 7a387fff | ths | case OPC_BC1F:
|
4726 | 5a5012ec | ths | gen_op_bc1f(cc); |
4727 | 923617a3 | ths | opn = "bc1f";
|
4728 | 6ea83fed | bellard | goto not_likely;
|
4729 | 7a387fff | ths | case OPC_BC1FL:
|
4730 | 5a5012ec | ths | gen_op_bc1f(cc); |
4731 | 923617a3 | ths | opn = "bc1fl";
|
4732 | 6ea83fed | bellard | goto likely;
|
4733 | 7a387fff | ths | case OPC_BC1T:
|
4734 | 5a5012ec | ths | gen_op_bc1t(cc); |
4735 | 923617a3 | ths | opn = "bc1t";
|
4736 | 5a5012ec | ths | goto not_likely;
|
4737 | 7a387fff | ths | case OPC_BC1TL:
|
4738 | 5a5012ec | ths | gen_op_bc1t(cc); |
4739 | 923617a3 | ths | opn = "bc1tl";
|
4740 | 6ea83fed | bellard | likely:
|
4741 | 6ea83fed | bellard | ctx->hflags |= MIPS_HFLAG_BL; |
4742 | 5a5012ec | ths | gen_op_set_bcond(); |
4743 | 5a5012ec | ths | gen_op_save_bcond(); |
4744 | 6ea83fed | bellard | break;
|
4745 | 5a5012ec | ths | case OPC_BC1FANY2:
|
4746 | fd4a04eb | ths | gen_op_bc1any2f(cc); |
4747 | fd4a04eb | ths | opn = "bc1any2f";
|
4748 | 5a5012ec | ths | goto not_likely;
|
4749 | 5a5012ec | ths | case OPC_BC1TANY2:
|
4750 | fd4a04eb | ths | gen_op_bc1any2t(cc); |
4751 | fd4a04eb | ths | opn = "bc1any2t";
|
4752 | 5a5012ec | ths | goto not_likely;
|
4753 | 5a5012ec | ths | case OPC_BC1FANY4:
|
4754 | fd4a04eb | ths | gen_op_bc1any4f(cc); |
4755 | fd4a04eb | ths | opn = "bc1any4f";
|
4756 | 5a5012ec | ths | goto not_likely;
|
4757 | 5a5012ec | ths | case OPC_BC1TANY4:
|
4758 | fd4a04eb | ths | gen_op_bc1any4t(cc); |
4759 | fd4a04eb | ths | opn = "bc1any4t";
|
4760 | 5a5012ec | ths | not_likely:
|
4761 | 5a5012ec | ths | ctx->hflags |= MIPS_HFLAG_BC; |
4762 | 5a5012ec | ths | gen_op_set_bcond(); |
4763 | 5a5012ec | ths | break;
|
4764 | 5a5012ec | ths | default:
|
4765 | 923617a3 | ths | MIPS_INVAL(opn); |
4766 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
4767 | 6ea83fed | bellard | return;
|
4768 | 6ea83fed | bellard | } |
4769 | 923617a3 | ths | MIPS_DEBUG("%s: cond %02x target " TARGET_FMT_lx, opn,
|
4770 | 6ea83fed | bellard | ctx->hflags, btarget); |
4771 | 6ea83fed | bellard | ctx->btarget = btarget; |
4772 | 6ea83fed | bellard | } |
4773 | 6ea83fed | bellard | |
4774 | 6af0bf9c | bellard | /* Coprocessor 1 (FPU) */
|
4775 | 5a5012ec | ths | |
4776 | 5a5012ec | ths | #define FOP(func, fmt) (((fmt) << 21) | (func)) |
4777 | 5a5012ec | ths | |
4778 | 7a387fff | ths | static void gen_cp1 (DisasContext *ctx, uint32_t opc, int rt, int fs) |
4779 | 6ea83fed | bellard | { |
4780 | 923617a3 | ths | const char *opn = "cp1 move"; |
4781 | 6ea83fed | bellard | |
4782 | 6ea83fed | bellard | switch (opc) {
|
4783 | 6ea83fed | bellard | case OPC_MFC1:
|
4784 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
4785 | 6ea83fed | bellard | gen_op_mfc1(); |
4786 | 6ea83fed | bellard | GEN_STORE_TN_REG(rt, T0); |
4787 | 6ea83fed | bellard | opn = "mfc1";
|
4788 | 6ea83fed | bellard | break;
|
4789 | 6ea83fed | bellard | case OPC_MTC1:
|
4790 | 6ea83fed | bellard | GEN_LOAD_REG_TN(T0, rt); |
4791 | 6ea83fed | bellard | gen_op_mtc1(); |
4792 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fs, WT0); |
4793 | 6ea83fed | bellard | opn = "mtc1";
|
4794 | 6ea83fed | bellard | break;
|
4795 | 6ea83fed | bellard | case OPC_CFC1:
|
4796 | ead9360e | ths | gen_op_cfc1(fs); |
4797 | 6ea83fed | bellard | GEN_STORE_TN_REG(rt, T0); |
4798 | 6ea83fed | bellard | opn = "cfc1";
|
4799 | 6ea83fed | bellard | break;
|
4800 | 6ea83fed | bellard | case OPC_CTC1:
|
4801 | 6ea83fed | bellard | GEN_LOAD_REG_TN(T0, rt); |
4802 | ead9360e | ths | gen_op_ctc1(fs); |
4803 | 6ea83fed | bellard | opn = "ctc1";
|
4804 | 6ea83fed | bellard | break;
|
4805 | 9c2149c8 | ths | case OPC_DMFC1:
|
4806 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
4807 | 5a5012ec | ths | gen_op_dmfc1(); |
4808 | 5a5012ec | ths | GEN_STORE_TN_REG(rt, T0); |
4809 | 5a5012ec | ths | opn = "dmfc1";
|
4810 | 5a5012ec | ths | break;
|
4811 | 9c2149c8 | ths | case OPC_DMTC1:
|
4812 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, rt); |
4813 | 5a5012ec | ths | gen_op_dmtc1(); |
4814 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fs, DT0); |
4815 | 5a5012ec | ths | opn = "dmtc1";
|
4816 | 5a5012ec | ths | break;
|
4817 | 5a5012ec | ths | case OPC_MFHC1:
|
4818 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
4819 | 5a5012ec | ths | gen_op_mfhc1(); |
4820 | 5a5012ec | ths | GEN_STORE_TN_REG(rt, T0); |
4821 | 5a5012ec | ths | opn = "mfhc1";
|
4822 | 5a5012ec | ths | break;
|
4823 | 5a5012ec | ths | case OPC_MTHC1:
|
4824 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, rt); |
4825 | 5a5012ec | ths | gen_op_mthc1(); |
4826 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fs, WTH0); |
4827 | 5a5012ec | ths | opn = "mthc1";
|
4828 | 5a5012ec | ths | break;
|
4829 | 6ea83fed | bellard | default:
|
4830 | 923617a3 | ths | MIPS_INVAL(opn); |
4831 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
4832 | 6ea83fed | bellard | return;
|
4833 | 6ea83fed | bellard | } |
4834 | 6ea83fed | bellard | MIPS_DEBUG("%s %s %s", opn, regnames[rt], fregnames[fs]);
|
4835 | 6ea83fed | bellard | } |
4836 | 6ea83fed | bellard | |
4837 | 5a5012ec | ths | static void gen_movci (DisasContext *ctx, int rd, int rs, int cc, int tf) |
4838 | 5a5012ec | ths | { |
4839 | 5a5012ec | ths | uint32_t ccbit; |
4840 | 6ea83fed | bellard | |
4841 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, rd); |
4842 | 5a5012ec | ths | GEN_LOAD_REG_TN(T1, rs); |
4843 | 57fa1fb3 | ths | if (cc) {
|
4844 | 5a5012ec | ths | ccbit = 1 << (24 + cc); |
4845 | 57fa1fb3 | ths | } else
|
4846 | 5a5012ec | ths | ccbit = 1 << 23; |
4847 | 5a5012ec | ths | if (!tf)
|
4848 | 5a5012ec | ths | gen_op_movf(ccbit); |
4849 | 5a5012ec | ths | else
|
4850 | 5a5012ec | ths | gen_op_movt(ccbit); |
4851 | 5a5012ec | ths | GEN_STORE_TN_REG(rd, T0); |
4852 | 5a5012ec | ths | } |
4853 | 5a5012ec | ths | |
4854 | 5a5012ec | ths | #define GEN_MOVCF(fmt) \
|
4855 | 5a5012ec | ths | static void glue(gen_movcf_, fmt) (DisasContext *ctx, int cc, int tf) \ |
4856 | 5a5012ec | ths | { \ |
4857 | 5a5012ec | ths | uint32_t ccbit; \ |
4858 | 5a5012ec | ths | \ |
4859 | 57fa1fb3 | ths | if (cc) { \
|
4860 | 5a5012ec | ths | ccbit = 1 << (24 + cc); \ |
4861 | 57fa1fb3 | ths | } else \
|
4862 | 5a5012ec | ths | ccbit = 1 << 23; \ |
4863 | 5a5012ec | ths | if (!tf) \
|
4864 | 5a5012ec | ths | glue(gen_op_float_movf_, fmt)(ccbit); \ |
4865 | 5a5012ec | ths | else \
|
4866 | 5a5012ec | ths | glue(gen_op_float_movt_, fmt)(ccbit); \ |
4867 | 5a5012ec | ths | } |
4868 | 5a5012ec | ths | GEN_MOVCF(d); |
4869 | 5a5012ec | ths | GEN_MOVCF(s); |
4870 | 5a5012ec | ths | GEN_MOVCF(ps); |
4871 | 5a5012ec | ths | #undef GEN_MOVCF
|
4872 | 6ea83fed | bellard | |
4873 | 5e755519 | ths | static void gen_farith (DisasContext *ctx, uint32_t op1, |
4874 | 5e755519 | ths | int ft, int fs, int fd, int cc) |
4875 | 6ea83fed | bellard | { |
4876 | 923617a3 | ths | const char *opn = "farith"; |
4877 | 6ea83fed | bellard | const char *condnames[] = { |
4878 | 6ea83fed | bellard | "c.f",
|
4879 | 6ea83fed | bellard | "c.un",
|
4880 | 6ea83fed | bellard | "c.eq",
|
4881 | 6ea83fed | bellard | "c.ueq",
|
4882 | 6ea83fed | bellard | "c.olt",
|
4883 | 6ea83fed | bellard | "c.ult",
|
4884 | 6ea83fed | bellard | "c.ole",
|
4885 | 6ea83fed | bellard | "c.ule",
|
4886 | 6ea83fed | bellard | "c.sf",
|
4887 | 6ea83fed | bellard | "c.ngle",
|
4888 | 6ea83fed | bellard | "c.seq",
|
4889 | 6ea83fed | bellard | "c.ngl",
|
4890 | 6ea83fed | bellard | "c.lt",
|
4891 | 6ea83fed | bellard | "c.nge",
|
4892 | 6ea83fed | bellard | "c.le",
|
4893 | 6ea83fed | bellard | "c.ngt",
|
4894 | 6ea83fed | bellard | }; |
4895 | 5a1e8ffb | ths | const char *condnames_abs[] = { |
4896 | 5a1e8ffb | ths | "cabs.f",
|
4897 | 5a1e8ffb | ths | "cabs.un",
|
4898 | 5a1e8ffb | ths | "cabs.eq",
|
4899 | 5a1e8ffb | ths | "cabs.ueq",
|
4900 | 5a1e8ffb | ths | "cabs.olt",
|
4901 | 5a1e8ffb | ths | "cabs.ult",
|
4902 | 5a1e8ffb | ths | "cabs.ole",
|
4903 | 5a1e8ffb | ths | "cabs.ule",
|
4904 | 5a1e8ffb | ths | "cabs.sf",
|
4905 | 5a1e8ffb | ths | "cabs.ngle",
|
4906 | 5a1e8ffb | ths | "cabs.seq",
|
4907 | 5a1e8ffb | ths | "cabs.ngl",
|
4908 | 5a1e8ffb | ths | "cabs.lt",
|
4909 | 5a1e8ffb | ths | "cabs.nge",
|
4910 | 5a1e8ffb | ths | "cabs.le",
|
4911 | 5a1e8ffb | ths | "cabs.ngt",
|
4912 | 5a1e8ffb | ths | }; |
4913 | 5a1e8ffb | ths | enum { BINOP, CMPOP, OTHEROP } optype = OTHEROP;
|
4914 | 7a387fff | ths | uint32_t func = ctx->opcode & 0x3f;
|
4915 | 7a387fff | ths | |
4916 | 6ea83fed | bellard | switch (ctx->opcode & FOP(0x3f, 0x1f)) { |
4917 | 5a5012ec | ths | case FOP(0, 16): |
4918 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4919 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
4920 | 5a5012ec | ths | gen_op_float_add_s(); |
4921 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
4922 | 5a5012ec | ths | opn = "add.s";
|
4923 | 5a1e8ffb | ths | optype = BINOP; |
4924 | 5a5012ec | ths | break;
|
4925 | 5a5012ec | ths | case FOP(1, 16): |
4926 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4927 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
4928 | 5a5012ec | ths | gen_op_float_sub_s(); |
4929 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
4930 | 5a5012ec | ths | opn = "sub.s";
|
4931 | 5a1e8ffb | ths | optype = BINOP; |
4932 | 5a5012ec | ths | break;
|
4933 | 5a5012ec | ths | case FOP(2, 16): |
4934 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4935 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
4936 | 5a5012ec | ths | gen_op_float_mul_s(); |
4937 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
4938 | 5a5012ec | ths | opn = "mul.s";
|
4939 | 5a1e8ffb | ths | optype = BINOP; |
4940 | 5a5012ec | ths | break;
|
4941 | 5a5012ec | ths | case FOP(3, 16): |
4942 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4943 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
4944 | 5a5012ec | ths | gen_op_float_div_s(); |
4945 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
4946 | 5a5012ec | ths | opn = "div.s";
|
4947 | 5a1e8ffb | ths | optype = BINOP; |
4948 | 5a5012ec | ths | break;
|
4949 | 5a5012ec | ths | case FOP(4, 16): |
4950 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4951 | 5a5012ec | ths | gen_op_float_sqrt_s(); |
4952 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
4953 | 5a5012ec | ths | opn = "sqrt.s";
|
4954 | 5a5012ec | ths | break;
|
4955 | 5a5012ec | ths | case FOP(5, 16): |
4956 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4957 | 5a5012ec | ths | gen_op_float_abs_s(); |
4958 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
4959 | 5a5012ec | ths | opn = "abs.s";
|
4960 | 5a5012ec | ths | break;
|
4961 | 5a5012ec | ths | case FOP(6, 16): |
4962 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4963 | 5a5012ec | ths | gen_op_float_mov_s(); |
4964 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
4965 | 5a5012ec | ths | opn = "mov.s";
|
4966 | 5a5012ec | ths | break;
|
4967 | 5a5012ec | ths | case FOP(7, 16): |
4968 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4969 | 5a5012ec | ths | gen_op_float_chs_s(); |
4970 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
4971 | 5a5012ec | ths | opn = "neg.s";
|
4972 | 5a5012ec | ths | break;
|
4973 | 5a5012ec | ths | case FOP(8, 16): |
4974 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
4975 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4976 | 5a5012ec | ths | gen_op_float_roundl_s(); |
4977 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
4978 | 5a5012ec | ths | opn = "round.l.s";
|
4979 | 5a5012ec | ths | break;
|
4980 | 5a5012ec | ths | case FOP(9, 16): |
4981 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
4982 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4983 | 5a5012ec | ths | gen_op_float_truncl_s(); |
4984 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
4985 | 5a5012ec | ths | opn = "trunc.l.s";
|
4986 | 5a5012ec | ths | break;
|
4987 | 5a5012ec | ths | case FOP(10, 16): |
4988 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
4989 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4990 | 5a5012ec | ths | gen_op_float_ceill_s(); |
4991 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
4992 | 5a5012ec | ths | opn = "ceil.l.s";
|
4993 | 5a5012ec | ths | break;
|
4994 | 5a5012ec | ths | case FOP(11, 16): |
4995 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
4996 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
4997 | 5a5012ec | ths | gen_op_float_floorl_s(); |
4998 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
4999 | 5a5012ec | ths | opn = "floor.l.s";
|
5000 | 5a5012ec | ths | break;
|
5001 | 5a5012ec | ths | case FOP(12, 16): |
5002 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5003 | 5a5012ec | ths | gen_op_float_roundw_s(); |
5004 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5005 | 5a5012ec | ths | opn = "round.w.s";
|
5006 | 5a5012ec | ths | break;
|
5007 | 5a5012ec | ths | case FOP(13, 16): |
5008 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5009 | 5a5012ec | ths | gen_op_float_truncw_s(); |
5010 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5011 | 5a5012ec | ths | opn = "trunc.w.s";
|
5012 | 5a5012ec | ths | break;
|
5013 | 5a5012ec | ths | case FOP(14, 16): |
5014 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5015 | 5a5012ec | ths | gen_op_float_ceilw_s(); |
5016 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5017 | 5a5012ec | ths | opn = "ceil.w.s";
|
5018 | 5a5012ec | ths | break;
|
5019 | 5a5012ec | ths | case FOP(15, 16): |
5020 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5021 | 5a5012ec | ths | gen_op_float_floorw_s(); |
5022 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5023 | 5a5012ec | ths | opn = "floor.w.s";
|
5024 | 5a5012ec | ths | break;
|
5025 | 5a5012ec | ths | case FOP(17, 16): |
5026 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, ft); |
5027 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5028 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT2, fd); |
5029 | 5a5012ec | ths | gen_movcf_s(ctx, (ft >> 2) & 0x7, ft & 0x1); |
5030 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5031 | 5a5012ec | ths | opn = "movcf.s";
|
5032 | 5a5012ec | ths | break;
|
5033 | 5a5012ec | ths | case FOP(18, 16): |
5034 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, ft); |
5035 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5036 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT2, fd); |
5037 | 5a5012ec | ths | gen_op_float_movz_s(); |
5038 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5039 | 5a5012ec | ths | opn = "movz.s";
|
5040 | 5a5012ec | ths | break;
|
5041 | 5a5012ec | ths | case FOP(19, 16): |
5042 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, ft); |
5043 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5044 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT2, fd); |
5045 | 5a5012ec | ths | gen_op_float_movn_s(); |
5046 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5047 | 5a5012ec | ths | opn = "movn.s";
|
5048 | 5a5012ec | ths | break;
|
5049 | 57fa1fb3 | ths | case FOP(21, 16): |
5050 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5051 | 57fa1fb3 | ths | gen_op_float_recip_s(); |
5052 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5053 | 57fa1fb3 | ths | opn = "recip.s";
|
5054 | 57fa1fb3 | ths | break;
|
5055 | 57fa1fb3 | ths | case FOP(22, 16): |
5056 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5057 | 57fa1fb3 | ths | gen_op_float_rsqrt_s(); |
5058 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5059 | 57fa1fb3 | ths | opn = "rsqrt.s";
|
5060 | 57fa1fb3 | ths | break;
|
5061 | 57fa1fb3 | ths | case FOP(28, 16): |
5062 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5063 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5064 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT2, fd); |
5065 | 57fa1fb3 | ths | gen_op_float_recip2_s(); |
5066 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5067 | 57fa1fb3 | ths | opn = "recip2.s";
|
5068 | 57fa1fb3 | ths | break;
|
5069 | 57fa1fb3 | ths | case FOP(29, 16): |
5070 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5071 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5072 | 57fa1fb3 | ths | gen_op_float_recip1_s(); |
5073 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5074 | 57fa1fb3 | ths | opn = "recip1.s";
|
5075 | 57fa1fb3 | ths | break;
|
5076 | 57fa1fb3 | ths | case FOP(30, 16): |
5077 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5078 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5079 | 57fa1fb3 | ths | gen_op_float_rsqrt1_s(); |
5080 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5081 | 57fa1fb3 | ths | opn = "rsqrt1.s";
|
5082 | 57fa1fb3 | ths | break;
|
5083 | 57fa1fb3 | ths | case FOP(31, 16): |
5084 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5085 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5086 | 8dfdb87c | ths | GEN_LOAD_FREG_FTN(WT2, ft); |
5087 | 57fa1fb3 | ths | gen_op_float_rsqrt2_s(); |
5088 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5089 | 57fa1fb3 | ths | opn = "rsqrt2.s";
|
5090 | 57fa1fb3 | ths | break;
|
5091 | 5a5012ec | ths | case FOP(33, 16): |
5092 | 5e755519 | ths | check_cp1_registers(ctx, fd); |
5093 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5094 | 5a5012ec | ths | gen_op_float_cvtd_s(); |
5095 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5096 | 5a5012ec | ths | opn = "cvt.d.s";
|
5097 | 5a5012ec | ths | break;
|
5098 | 5a5012ec | ths | case FOP(36, 16): |
5099 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5100 | 5a5012ec | ths | gen_op_float_cvtw_s(); |
5101 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5102 | 5a5012ec | ths | opn = "cvt.w.s";
|
5103 | 5a5012ec | ths | break;
|
5104 | 5a5012ec | ths | case FOP(37, 16): |
5105 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5106 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5107 | 5a5012ec | ths | gen_op_float_cvtl_s(); |
5108 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5109 | 5a5012ec | ths | opn = "cvt.l.s";
|
5110 | 5a5012ec | ths | break;
|
5111 | 5a5012ec | ths | case FOP(38, 16): |
5112 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5113 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT1, fs); |
5114 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, ft); |
5115 | 5a5012ec | ths | gen_op_float_cvtps_s(); |
5116 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5117 | 5a5012ec | ths | opn = "cvt.ps.s";
|
5118 | 5a5012ec | ths | break;
|
5119 | 5a5012ec | ths | case FOP(48, 16): |
5120 | 5a5012ec | ths | case FOP(49, 16): |
5121 | 5a5012ec | ths | case FOP(50, 16): |
5122 | 5a5012ec | ths | case FOP(51, 16): |
5123 | 5a5012ec | ths | case FOP(52, 16): |
5124 | 5a5012ec | ths | case FOP(53, 16): |
5125 | 5a5012ec | ths | case FOP(54, 16): |
5126 | 5a5012ec | ths | case FOP(55, 16): |
5127 | 5a5012ec | ths | case FOP(56, 16): |
5128 | 5a5012ec | ths | case FOP(57, 16): |
5129 | 5a5012ec | ths | case FOP(58, 16): |
5130 | 5a5012ec | ths | case FOP(59, 16): |
5131 | 5a5012ec | ths | case FOP(60, 16): |
5132 | 5a5012ec | ths | case FOP(61, 16): |
5133 | 5a5012ec | ths | case FOP(62, 16): |
5134 | 5a5012ec | ths | case FOP(63, 16): |
5135 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5136 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5137 | 5a1e8ffb | ths | if (ctx->opcode & (1 << 6)) { |
5138 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5139 | 5a1e8ffb | ths | gen_cmpabs_s(func-48, cc);
|
5140 | 5a1e8ffb | ths | opn = condnames_abs[func-48];
|
5141 | 5a1e8ffb | ths | } else {
|
5142 | 5a1e8ffb | ths | gen_cmp_s(func-48, cc);
|
5143 | 5a1e8ffb | ths | opn = condnames[func-48];
|
5144 | 5a1e8ffb | ths | } |
5145 | 5a5012ec | ths | break;
|
5146 | 6ea83fed | bellard | case FOP(0, 17): |
5147 | 5e755519 | ths | check_cp1_registers(ctx, fs | ft | fd); |
5148 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5149 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT1, ft); |
5150 | 6ea83fed | bellard | gen_op_float_add_d(); |
5151 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5152 | 6ea83fed | bellard | opn = "add.d";
|
5153 | 5a1e8ffb | ths | optype = BINOP; |
5154 | 6ea83fed | bellard | break;
|
5155 | 6ea83fed | bellard | case FOP(1, 17): |
5156 | 5e755519 | ths | check_cp1_registers(ctx, fs | ft | fd); |
5157 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5158 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT1, ft); |
5159 | 6ea83fed | bellard | gen_op_float_sub_d(); |
5160 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5161 | 6ea83fed | bellard | opn = "sub.d";
|
5162 | 5a1e8ffb | ths | optype = BINOP; |
5163 | 6ea83fed | bellard | break;
|
5164 | 6ea83fed | bellard | case FOP(2, 17): |
5165 | 5e755519 | ths | check_cp1_registers(ctx, fs | ft | fd); |
5166 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5167 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT1, ft); |
5168 | 6ea83fed | bellard | gen_op_float_mul_d(); |
5169 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5170 | 6ea83fed | bellard | opn = "mul.d";
|
5171 | 5a1e8ffb | ths | optype = BINOP; |
5172 | 6ea83fed | bellard | break;
|
5173 | 6ea83fed | bellard | case FOP(3, 17): |
5174 | 5e755519 | ths | check_cp1_registers(ctx, fs | ft | fd); |
5175 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5176 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT1, ft); |
5177 | 6ea83fed | bellard | gen_op_float_div_d(); |
5178 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5179 | 6ea83fed | bellard | opn = "div.d";
|
5180 | 5a1e8ffb | ths | optype = BINOP; |
5181 | 6ea83fed | bellard | break;
|
5182 | 6ea83fed | bellard | case FOP(4, 17): |
5183 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
5184 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5185 | 6ea83fed | bellard | gen_op_float_sqrt_d(); |
5186 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5187 | 6ea83fed | bellard | opn = "sqrt.d";
|
5188 | 6ea83fed | bellard | break;
|
5189 | 6ea83fed | bellard | case FOP(5, 17): |
5190 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
5191 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5192 | 6ea83fed | bellard | gen_op_float_abs_d(); |
5193 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5194 | 6ea83fed | bellard | opn = "abs.d";
|
5195 | 6ea83fed | bellard | break;
|
5196 | 6ea83fed | bellard | case FOP(6, 17): |
5197 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
5198 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5199 | 6ea83fed | bellard | gen_op_float_mov_d(); |
5200 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5201 | 6ea83fed | bellard | opn = "mov.d";
|
5202 | 6ea83fed | bellard | break;
|
5203 | 6ea83fed | bellard | case FOP(7, 17): |
5204 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
5205 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5206 | 6ea83fed | bellard | gen_op_float_chs_d(); |
5207 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5208 | 6ea83fed | bellard | opn = "neg.d";
|
5209 | 6ea83fed | bellard | break;
|
5210 | 5a5012ec | ths | case FOP(8, 17): |
5211 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5212 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5213 | 5a5012ec | ths | gen_op_float_roundl_d(); |
5214 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5215 | 5a5012ec | ths | opn = "round.l.d";
|
5216 | 5a5012ec | ths | break;
|
5217 | 5a5012ec | ths | case FOP(9, 17): |
5218 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5219 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5220 | 5a5012ec | ths | gen_op_float_truncl_d(); |
5221 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5222 | 5a5012ec | ths | opn = "trunc.l.d";
|
5223 | 5a5012ec | ths | break;
|
5224 | 5a5012ec | ths | case FOP(10, 17): |
5225 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5226 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5227 | 5a5012ec | ths | gen_op_float_ceill_d(); |
5228 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5229 | 5a5012ec | ths | opn = "ceil.l.d";
|
5230 | 5a5012ec | ths | break;
|
5231 | 5a5012ec | ths | case FOP(11, 17): |
5232 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5233 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5234 | 5a5012ec | ths | gen_op_float_floorl_d(); |
5235 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5236 | 5a5012ec | ths | opn = "floor.l.d";
|
5237 | 5a5012ec | ths | break;
|
5238 | 6ea83fed | bellard | case FOP(12, 17): |
5239 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
5240 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5241 | 6ea83fed | bellard | gen_op_float_roundw_d(); |
5242 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5243 | 6ea83fed | bellard | opn = "round.w.d";
|
5244 | 6ea83fed | bellard | break;
|
5245 | 6ea83fed | bellard | case FOP(13, 17): |
5246 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
5247 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5248 | 6ea83fed | bellard | gen_op_float_truncw_d(); |
5249 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5250 | 6ea83fed | bellard | opn = "trunc.w.d";
|
5251 | 6ea83fed | bellard | break;
|
5252 | 6ea83fed | bellard | case FOP(14, 17): |
5253 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
5254 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5255 | 6ea83fed | bellard | gen_op_float_ceilw_d(); |
5256 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5257 | 6ea83fed | bellard | opn = "ceil.w.d";
|
5258 | 6ea83fed | bellard | break;
|
5259 | 6ea83fed | bellard | case FOP(15, 17): |
5260 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
5261 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5262 | 6ea83fed | bellard | gen_op_float_floorw_d(); |
5263 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5264 | 7a387fff | ths | opn = "floor.w.d";
|
5265 | 6ea83fed | bellard | break;
|
5266 | 5a5012ec | ths | case FOP(17, 17): |
5267 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, ft); |
5268 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5269 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT2, fd); |
5270 | 5a5012ec | ths | gen_movcf_d(ctx, (ft >> 2) & 0x7, ft & 0x1); |
5271 | dd016883 | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5272 | 5a5012ec | ths | opn = "movcf.d";
|
5273 | dd016883 | bellard | break;
|
5274 | 5a5012ec | ths | case FOP(18, 17): |
5275 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, ft); |
5276 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5277 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT2, fd); |
5278 | 5a5012ec | ths | gen_op_float_movz_d(); |
5279 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, DT2); |
5280 | 5a5012ec | ths | opn = "movz.d";
|
5281 | 5a5012ec | ths | break;
|
5282 | 5a5012ec | ths | case FOP(19, 17): |
5283 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, ft); |
5284 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5285 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT2, fd); |
5286 | 5a5012ec | ths | gen_op_float_movn_d(); |
5287 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5288 | 5a5012ec | ths | opn = "movn.d";
|
5289 | 6ea83fed | bellard | break;
|
5290 | 57fa1fb3 | ths | case FOP(21, 17): |
5291 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
5292 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5293 | 57fa1fb3 | ths | gen_op_float_recip_d(); |
5294 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5295 | 57fa1fb3 | ths | opn = "recip.d";
|
5296 | 57fa1fb3 | ths | break;
|
5297 | 57fa1fb3 | ths | case FOP(22, 17): |
5298 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
5299 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5300 | 57fa1fb3 | ths | gen_op_float_rsqrt_d(); |
5301 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5302 | 57fa1fb3 | ths | opn = "rsqrt.d";
|
5303 | 57fa1fb3 | ths | break;
|
5304 | 57fa1fb3 | ths | case FOP(28, 17): |
5305 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5306 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5307 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(DT2, ft); |
5308 | 57fa1fb3 | ths | gen_op_float_recip2_d(); |
5309 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5310 | 57fa1fb3 | ths | opn = "recip2.d";
|
5311 | 57fa1fb3 | ths | break;
|
5312 | 57fa1fb3 | ths | case FOP(29, 17): |
5313 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5314 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5315 | 57fa1fb3 | ths | gen_op_float_recip1_d(); |
5316 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5317 | 57fa1fb3 | ths | opn = "recip1.d";
|
5318 | 57fa1fb3 | ths | break;
|
5319 | 57fa1fb3 | ths | case FOP(30, 17): |
5320 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5321 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5322 | 57fa1fb3 | ths | gen_op_float_rsqrt1_d(); |
5323 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5324 | 57fa1fb3 | ths | opn = "rsqrt1.d";
|
5325 | 57fa1fb3 | ths | break;
|
5326 | 57fa1fb3 | ths | case FOP(31, 17): |
5327 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5328 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5329 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(DT2, ft); |
5330 | 57fa1fb3 | ths | gen_op_float_rsqrt2_d(); |
5331 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5332 | 57fa1fb3 | ths | opn = "rsqrt2.d";
|
5333 | 57fa1fb3 | ths | break;
|
5334 | 6ea83fed | bellard | case FOP(48, 17): |
5335 | 6ea83fed | bellard | case FOP(49, 17): |
5336 | 6ea83fed | bellard | case FOP(50, 17): |
5337 | 6ea83fed | bellard | case FOP(51, 17): |
5338 | 6ea83fed | bellard | case FOP(52, 17): |
5339 | 6ea83fed | bellard | case FOP(53, 17): |
5340 | 6ea83fed | bellard | case FOP(54, 17): |
5341 | 6ea83fed | bellard | case FOP(55, 17): |
5342 | 6ea83fed | bellard | case FOP(56, 17): |
5343 | 6ea83fed | bellard | case FOP(57, 17): |
5344 | 6ea83fed | bellard | case FOP(58, 17): |
5345 | 6ea83fed | bellard | case FOP(59, 17): |
5346 | 6ea83fed | bellard | case FOP(60, 17): |
5347 | 6ea83fed | bellard | case FOP(61, 17): |
5348 | 6ea83fed | bellard | case FOP(62, 17): |
5349 | 6ea83fed | bellard | case FOP(63, 17): |
5350 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT0, fs); |
5351 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(DT1, ft); |
5352 | 5a1e8ffb | ths | if (ctx->opcode & (1 << 6)) { |
5353 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5354 | 5a1e8ffb | ths | gen_cmpabs_d(func-48, cc);
|
5355 | 5a1e8ffb | ths | opn = condnames_abs[func-48];
|
5356 | 5a1e8ffb | ths | } else {
|
5357 | 5e755519 | ths | check_cp1_registers(ctx, fs | ft); |
5358 | 5a1e8ffb | ths | gen_cmp_d(func-48, cc);
|
5359 | 5a1e8ffb | ths | opn = condnames[func-48];
|
5360 | 5a1e8ffb | ths | } |
5361 | 6ea83fed | bellard | break;
|
5362 | 5a5012ec | ths | case FOP(32, 17): |
5363 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
5364 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5365 | 5a5012ec | ths | gen_op_float_cvts_d(); |
5366 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5367 | 5a5012ec | ths | opn = "cvt.s.d";
|
5368 | 5a5012ec | ths | break;
|
5369 | 5a5012ec | ths | case FOP(36, 17): |
5370 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
5371 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5372 | 5a5012ec | ths | gen_op_float_cvtw_d(); |
5373 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5374 | 5a5012ec | ths | opn = "cvt.w.d";
|
5375 | 5a5012ec | ths | break;
|
5376 | 5a5012ec | ths | case FOP(37, 17): |
5377 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5378 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5379 | 5a5012ec | ths | gen_op_float_cvtl_d(); |
5380 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5381 | 5a5012ec | ths | opn = "cvt.l.d";
|
5382 | 5a5012ec | ths | break;
|
5383 | 5a5012ec | ths | case FOP(32, 20): |
5384 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5385 | 5a5012ec | ths | gen_op_float_cvts_w(); |
5386 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5387 | 5a5012ec | ths | opn = "cvt.s.w";
|
5388 | 6ea83fed | bellard | break;
|
5389 | 5a5012ec | ths | case FOP(33, 20): |
5390 | 5e755519 | ths | check_cp1_registers(ctx, fd); |
5391 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5392 | 5a5012ec | ths | gen_op_float_cvtd_w(); |
5393 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5394 | 5a5012ec | ths | opn = "cvt.d.w";
|
5395 | 5a5012ec | ths | break;
|
5396 | 5a5012ec | ths | case FOP(32, 21): |
5397 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5398 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5399 | 5a5012ec | ths | gen_op_float_cvts_l(); |
5400 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5401 | 5a5012ec | ths | opn = "cvt.s.l";
|
5402 | 5a5012ec | ths | break;
|
5403 | 5a5012ec | ths | case FOP(33, 21): |
5404 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5405 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5406 | 5a5012ec | ths | gen_op_float_cvtd_l(); |
5407 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5408 | 5a5012ec | ths | opn = "cvt.d.l";
|
5409 | 5a5012ec | ths | break;
|
5410 | 5a5012ec | ths | case FOP(38, 20): |
5411 | 5a5012ec | ths | case FOP(38, 21): |
5412 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5413 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5414 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5415 | 5a5012ec | ths | gen_op_float_cvtps_pw(); |
5416 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5417 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5418 | 5a5012ec | ths | opn = "cvt.ps.pw";
|
5419 | 5a5012ec | ths | break;
|
5420 | 5a5012ec | ths | case FOP(0, 22): |
5421 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5422 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5423 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5424 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT1, ft); |
5425 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5426 | 5a5012ec | ths | gen_op_float_add_ps(); |
5427 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5428 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5429 | 5a5012ec | ths | opn = "add.ps";
|
5430 | 6ea83fed | bellard | break;
|
5431 | 5a5012ec | ths | case FOP(1, 22): |
5432 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5433 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5434 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5435 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT1, ft); |
5436 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5437 | 5a5012ec | ths | gen_op_float_sub_ps(); |
5438 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5439 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5440 | 5a5012ec | ths | opn = "sub.ps";
|
5441 | 6ea83fed | bellard | break;
|
5442 | 5a5012ec | ths | case FOP(2, 22): |
5443 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5444 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5445 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5446 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT1, ft); |
5447 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5448 | 5a5012ec | ths | gen_op_float_mul_ps(); |
5449 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5450 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5451 | 5a5012ec | ths | opn = "mul.ps";
|
5452 | 6ea83fed | bellard | break;
|
5453 | 5a5012ec | ths | case FOP(5, 22): |
5454 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5455 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5456 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5457 | 5a5012ec | ths | gen_op_float_abs_ps(); |
5458 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5459 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5460 | 5a5012ec | ths | opn = "abs.ps";
|
5461 | 6ea83fed | bellard | break;
|
5462 | 5a5012ec | ths | case FOP(6, 22): |
5463 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5464 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5465 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5466 | 5a5012ec | ths | gen_op_float_mov_ps(); |
5467 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5468 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5469 | 5a5012ec | ths | opn = "mov.ps";
|
5470 | 6ea83fed | bellard | break;
|
5471 | 5a5012ec | ths | case FOP(7, 22): |
5472 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5473 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5474 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5475 | 5a5012ec | ths | gen_op_float_chs_ps(); |
5476 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5477 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5478 | 5a5012ec | ths | opn = "neg.ps";
|
5479 | 6ea83fed | bellard | break;
|
5480 | 5a5012ec | ths | case FOP(17, 22): |
5481 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5482 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, ft); |
5483 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5484 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5485 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT2, fd); |
5486 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH2, fd); |
5487 | 5a5012ec | ths | gen_movcf_ps(ctx, (ft >> 2) & 0x7, ft & 0x1); |
5488 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5489 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5490 | 5a5012ec | ths | opn = "movcf.ps";
|
5491 | 6ea83fed | bellard | break;
|
5492 | 5a5012ec | ths | case FOP(18, 22): |
5493 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5494 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, ft); |
5495 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5496 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5497 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT2, fd); |
5498 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH2, fd); |
5499 | 5a5012ec | ths | gen_op_float_movz_ps(); |
5500 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5501 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5502 | 5a5012ec | ths | opn = "movz.ps";
|
5503 | 6ea83fed | bellard | break;
|
5504 | 5a5012ec | ths | case FOP(19, 22): |
5505 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5506 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, ft); |
5507 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5508 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5509 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT2, fd); |
5510 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH2, fd); |
5511 | 5a5012ec | ths | gen_op_float_movn_ps(); |
5512 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5513 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5514 | 5a5012ec | ths | opn = "movn.ps";
|
5515 | 6ea83fed | bellard | break;
|
5516 | fbcc6828 | ths | case FOP(24, 22): |
5517 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5518 | 3a5b360d | ths | GEN_LOAD_FREG_FTN(WT0, ft); |
5519 | 3a5b360d | ths | GEN_LOAD_FREG_FTN(WTH0, ft); |
5520 | 3a5b360d | ths | GEN_LOAD_FREG_FTN(WT1, fs); |
5521 | 3a5b360d | ths | GEN_LOAD_FREG_FTN(WTH1, fs); |
5522 | fbcc6828 | ths | gen_op_float_addr_ps(); |
5523 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5524 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5525 | fbcc6828 | ths | opn = "addr.ps";
|
5526 | fbcc6828 | ths | break;
|
5527 | 57fa1fb3 | ths | case FOP(26, 22): |
5528 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5529 | 3a5b360d | ths | GEN_LOAD_FREG_FTN(WT0, ft); |
5530 | 3a5b360d | ths | GEN_LOAD_FREG_FTN(WTH0, ft); |
5531 | 3a5b360d | ths | GEN_LOAD_FREG_FTN(WT1, fs); |
5532 | 3a5b360d | ths | GEN_LOAD_FREG_FTN(WTH1, fs); |
5533 | 57fa1fb3 | ths | gen_op_float_mulr_ps(); |
5534 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5535 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5536 | 57fa1fb3 | ths | opn = "mulr.ps";
|
5537 | 57fa1fb3 | ths | break;
|
5538 | 57fa1fb3 | ths | case FOP(28, 22): |
5539 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5540 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5541 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5542 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT2, fd); |
5543 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WTH2, fd); |
5544 | 57fa1fb3 | ths | gen_op_float_recip2_ps(); |
5545 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5546 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5547 | 57fa1fb3 | ths | opn = "recip2.ps";
|
5548 | 57fa1fb3 | ths | break;
|
5549 | 57fa1fb3 | ths | case FOP(29, 22): |
5550 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5551 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5552 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5553 | 57fa1fb3 | ths | gen_op_float_recip1_ps(); |
5554 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5555 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5556 | 57fa1fb3 | ths | opn = "recip1.ps";
|
5557 | 57fa1fb3 | ths | break;
|
5558 | 57fa1fb3 | ths | case FOP(30, 22): |
5559 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5560 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5561 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5562 | 57fa1fb3 | ths | gen_op_float_rsqrt1_ps(); |
5563 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5564 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5565 | 57fa1fb3 | ths | opn = "rsqrt1.ps";
|
5566 | 57fa1fb3 | ths | break;
|
5567 | 57fa1fb3 | ths | case FOP(31, 22): |
5568 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5569 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5570 | 57fa1fb3 | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5571 | 8dfdb87c | ths | GEN_LOAD_FREG_FTN(WT2, ft); |
5572 | 8dfdb87c | ths | GEN_LOAD_FREG_FTN(WTH2, ft); |
5573 | 57fa1fb3 | ths | gen_op_float_rsqrt2_ps(); |
5574 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5575 | 57fa1fb3 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5576 | 57fa1fb3 | ths | opn = "rsqrt2.ps";
|
5577 | 57fa1fb3 | ths | break;
|
5578 | 5a5012ec | ths | case FOP(32, 22): |
5579 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5580 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5581 | 5a5012ec | ths | gen_op_float_cvts_pu(); |
5582 | dd016883 | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5583 | 5a5012ec | ths | opn = "cvt.s.pu";
|
5584 | dd016883 | bellard | break;
|
5585 | 5a5012ec | ths | case FOP(36, 22): |
5586 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5587 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5588 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5589 | 5a5012ec | ths | gen_op_float_cvtpw_ps(); |
5590 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5591 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5592 | 5a5012ec | ths | opn = "cvt.pw.ps";
|
5593 | 6ea83fed | bellard | break;
|
5594 | 5a5012ec | ths | case FOP(40, 22): |
5595 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5596 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5597 | 5a5012ec | ths | gen_op_float_cvts_pl(); |
5598 | 6ea83fed | bellard | GEN_STORE_FTN_FREG(fd, WT2); |
5599 | 5a5012ec | ths | opn = "cvt.s.pl";
|
5600 | 6ea83fed | bellard | break;
|
5601 | 5a5012ec | ths | case FOP(44, 22): |
5602 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5603 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5604 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5605 | 5a5012ec | ths | gen_op_float_pll_ps(); |
5606 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5607 | 5a5012ec | ths | opn = "pll.ps";
|
5608 | 6ea83fed | bellard | break;
|
5609 | 5a5012ec | ths | case FOP(45, 22): |
5610 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5611 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT0, fs); |
5612 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5613 | 5a5012ec | ths | gen_op_float_plu_ps(); |
5614 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5615 | 5a5012ec | ths | opn = "plu.ps";
|
5616 | 5a5012ec | ths | break;
|
5617 | 5a5012ec | ths | case FOP(46, 22): |
5618 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5619 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5620 | 6ea83fed | bellard | GEN_LOAD_FREG_FTN(WT1, ft); |
5621 | 5a5012ec | ths | gen_op_float_pul_ps(); |
5622 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5623 | 5a5012ec | ths | opn = "pul.ps";
|
5624 | 5a5012ec | ths | break;
|
5625 | 5a5012ec | ths | case FOP(47, 22): |
5626 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5627 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5628 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5629 | 5a5012ec | ths | gen_op_float_puu_ps(); |
5630 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5631 | 5a5012ec | ths | opn = "puu.ps";
|
5632 | 5a5012ec | ths | break;
|
5633 | 5a5012ec | ths | case FOP(48, 22): |
5634 | 5a5012ec | ths | case FOP(49, 22): |
5635 | 5a5012ec | ths | case FOP(50, 22): |
5636 | 5a5012ec | ths | case FOP(51, 22): |
5637 | 5a5012ec | ths | case FOP(52, 22): |
5638 | 5a5012ec | ths | case FOP(53, 22): |
5639 | 5a5012ec | ths | case FOP(54, 22): |
5640 | 5a5012ec | ths | case FOP(55, 22): |
5641 | 5a5012ec | ths | case FOP(56, 22): |
5642 | 5a5012ec | ths | case FOP(57, 22): |
5643 | 5a5012ec | ths | case FOP(58, 22): |
5644 | 5a5012ec | ths | case FOP(59, 22): |
5645 | 5a5012ec | ths | case FOP(60, 22): |
5646 | 5a5012ec | ths | case FOP(61, 22): |
5647 | 5a5012ec | ths | case FOP(62, 22): |
5648 | 5a5012ec | ths | case FOP(63, 22): |
5649 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5650 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5651 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5652 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5653 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5654 | 5a1e8ffb | ths | if (ctx->opcode & (1 << 6)) { |
5655 | 5a1e8ffb | ths | gen_cmpabs_ps(func-48, cc);
|
5656 | 5a1e8ffb | ths | opn = condnames_abs[func-48];
|
5657 | 5a1e8ffb | ths | } else {
|
5658 | 5a1e8ffb | ths | gen_cmp_ps(func-48, cc);
|
5659 | 5a1e8ffb | ths | opn = condnames[func-48];
|
5660 | 5a1e8ffb | ths | } |
5661 | 6ea83fed | bellard | break;
|
5662 | 5a5012ec | ths | default:
|
5663 | 923617a3 | ths | MIPS_INVAL(opn); |
5664 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
5665 | 6ea83fed | bellard | return;
|
5666 | 6ea83fed | bellard | } |
5667 | 5a1e8ffb | ths | switch (optype) {
|
5668 | 5a1e8ffb | ths | case BINOP:
|
5669 | 6ea83fed | bellard | MIPS_DEBUG("%s %s, %s, %s", opn, fregnames[fd], fregnames[fs], fregnames[ft]);
|
5670 | 5a1e8ffb | ths | break;
|
5671 | 5a1e8ffb | ths | case CMPOP:
|
5672 | 5a1e8ffb | ths | MIPS_DEBUG("%s %s,%s", opn, fregnames[fs], fregnames[ft]);
|
5673 | 5a1e8ffb | ths | break;
|
5674 | 5a1e8ffb | ths | default:
|
5675 | 6ea83fed | bellard | MIPS_DEBUG("%s %s,%s", opn, fregnames[fd], fregnames[fs]);
|
5676 | 5a1e8ffb | ths | break;
|
5677 | 5a1e8ffb | ths | } |
5678 | 6ea83fed | bellard | } |
5679 | 6af0bf9c | bellard | |
5680 | 5a5012ec | ths | /* Coprocessor 3 (FPU) */
|
5681 | 5e755519 | ths | static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, |
5682 | 5e755519 | ths | int fd, int fs, int base, int index) |
5683 | 7a387fff | ths | { |
5684 | 923617a3 | ths | const char *opn = "extended float load/store"; |
5685 | 93b12ccc | ths | int store = 0; |
5686 | 7a387fff | ths | |
5687 | 57fa1fb3 | ths | /* All of those work only on 64bit FPUs. */
|
5688 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5689 | 93b12ccc | ths | if (base == 0) { |
5690 | 93b12ccc | ths | if (index == 0) |
5691 | 93b12ccc | ths | gen_op_reset_T0(); |
5692 | 93b12ccc | ths | else
|
5693 | 93b12ccc | ths | GEN_LOAD_REG_TN(T0, index); |
5694 | 93b12ccc | ths | } else if (index == 0) { |
5695 | 93b12ccc | ths | GEN_LOAD_REG_TN(T0, base); |
5696 | 93b12ccc | ths | } else {
|
5697 | 93b12ccc | ths | GEN_LOAD_REG_TN(T0, base); |
5698 | 93b12ccc | ths | GEN_LOAD_REG_TN(T1, index); |
5699 | 93b12ccc | ths | gen_op_addr_add(); |
5700 | 93b12ccc | ths | } |
5701 | 5a5012ec | ths | /* Don't do NOP if destination is zero: we must perform the actual
|
5702 | ead9360e | ths | memory access. */
|
5703 | 5a5012ec | ths | switch (opc) {
|
5704 | 5a5012ec | ths | case OPC_LWXC1:
|
5705 | 93b12ccc | ths | op_ldst(lwc1); |
5706 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT0); |
5707 | 5a5012ec | ths | opn = "lwxc1";
|
5708 | 5a5012ec | ths | break;
|
5709 | 5a5012ec | ths | case OPC_LDXC1:
|
5710 | 93b12ccc | ths | op_ldst(ldc1); |
5711 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT0); |
5712 | 5a5012ec | ths | opn = "ldxc1";
|
5713 | 5a5012ec | ths | break;
|
5714 | 5a5012ec | ths | case OPC_LUXC1:
|
5715 | 5a5012ec | ths | op_ldst(luxc1); |
5716 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT0); |
5717 | 5a5012ec | ths | opn = "luxc1";
|
5718 | 5a5012ec | ths | break;
|
5719 | 5a5012ec | ths | case OPC_SWXC1:
|
5720 | 93b12ccc | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5721 | 93b12ccc | ths | op_ldst(swc1); |
5722 | 5a5012ec | ths | opn = "swxc1";
|
5723 | 93b12ccc | ths | store = 1;
|
5724 | 5a5012ec | ths | break;
|
5725 | 5a5012ec | ths | case OPC_SDXC1:
|
5726 | 93b12ccc | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5727 | 93b12ccc | ths | op_ldst(sdc1); |
5728 | 5a5012ec | ths | opn = "sdxc1";
|
5729 | 93b12ccc | ths | store = 1;
|
5730 | 5a5012ec | ths | break;
|
5731 | 5a5012ec | ths | case OPC_SUXC1:
|
5732 | 93b12ccc | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5733 | 5a5012ec | ths | op_ldst(suxc1); |
5734 | 5a5012ec | ths | opn = "suxc1";
|
5735 | 93b12ccc | ths | store = 1;
|
5736 | 5a5012ec | ths | break;
|
5737 | 5a5012ec | ths | default:
|
5738 | 923617a3 | ths | MIPS_INVAL(opn); |
5739 | 5a5012ec | ths | generate_exception(ctx, EXCP_RI); |
5740 | 5a5012ec | ths | return;
|
5741 | 5a5012ec | ths | } |
5742 | 93b12ccc | ths | MIPS_DEBUG("%s %s, %s(%s)", opn, fregnames[store ? fs : fd],
|
5743 | 93b12ccc | ths | regnames[index], regnames[base]); |
5744 | 5a5012ec | ths | } |
5745 | 5a5012ec | ths | |
5746 | 5e755519 | ths | static void gen_flt3_arith (DisasContext *ctx, uint32_t opc, |
5747 | 5e755519 | ths | int fd, int fr, int fs, int ft) |
5748 | 5a5012ec | ths | { |
5749 | 923617a3 | ths | const char *opn = "flt3_arith"; |
5750 | 5a5012ec | ths | |
5751 | 5a5012ec | ths | /* All of those work only on 64bit FPUs. */
|
5752 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
5753 | 5a5012ec | ths | switch (opc) {
|
5754 | 5a5012ec | ths | case OPC_ALNV_PS:
|
5755 | 5a5012ec | ths | GEN_LOAD_REG_TN(T0, fr); |
5756 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5757 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(DT1, ft); |
5758 | 5a5012ec | ths | gen_op_float_alnv_ps(); |
5759 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5760 | 5a5012ec | ths | opn = "alnv.ps";
|
5761 | 5a5012ec | ths | break;
|
5762 | 5a5012ec | ths | case OPC_MADD_S:
|
5763 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5764 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5765 | 5a5012ec | ths | GEN_LOAD_FREG_FTN(WT2, fr); |
5766 | 5a5012ec | ths | gen_op_float_muladd_s(); |
5767 | 5a5012ec | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5768 | 5a5012ec | ths | opn = "madd.s";
|
5769 | 5a5012ec | ths | break;
|
5770 | 5a5012ec | ths | case OPC_MADD_D:
|
5771 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5772 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT1, ft); |
5773 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT2, fr); |
5774 | fbcc6828 | ths | gen_op_float_muladd_d(); |
5775 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5776 | 5a5012ec | ths | opn = "madd.d";
|
5777 | 5a5012ec | ths | break;
|
5778 | 5a5012ec | ths | case OPC_MADD_PS:
|
5779 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5780 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5781 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5782 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5783 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT2, fr); |
5784 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH2, fr); |
5785 | fbcc6828 | ths | gen_op_float_muladd_ps(); |
5786 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5787 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5788 | 5a5012ec | ths | opn = "madd.ps";
|
5789 | 5a5012ec | ths | break;
|
5790 | 5a5012ec | ths | case OPC_MSUB_S:
|
5791 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5792 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5793 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT2, fr); |
5794 | fbcc6828 | ths | gen_op_float_mulsub_s(); |
5795 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5796 | 5a5012ec | ths | opn = "msub.s";
|
5797 | 5a5012ec | ths | break;
|
5798 | 5a5012ec | ths | case OPC_MSUB_D:
|
5799 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5800 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT1, ft); |
5801 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT2, fr); |
5802 | fbcc6828 | ths | gen_op_float_mulsub_d(); |
5803 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5804 | 5a5012ec | ths | opn = "msub.d";
|
5805 | 5a5012ec | ths | break;
|
5806 | 5a5012ec | ths | case OPC_MSUB_PS:
|
5807 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5808 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5809 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5810 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5811 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT2, fr); |
5812 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH2, fr); |
5813 | fbcc6828 | ths | gen_op_float_mulsub_ps(); |
5814 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5815 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5816 | 5a5012ec | ths | opn = "msub.ps";
|
5817 | 5a5012ec | ths | break;
|
5818 | 5a5012ec | ths | case OPC_NMADD_S:
|
5819 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5820 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5821 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT2, fr); |
5822 | fbcc6828 | ths | gen_op_float_nmuladd_s(); |
5823 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5824 | 5a5012ec | ths | opn = "nmadd.s";
|
5825 | 5a5012ec | ths | break;
|
5826 | 5a5012ec | ths | case OPC_NMADD_D:
|
5827 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5828 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT1, ft); |
5829 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT2, fr); |
5830 | fbcc6828 | ths | gen_op_float_nmuladd_d(); |
5831 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5832 | 5a5012ec | ths | opn = "nmadd.d";
|
5833 | 5a5012ec | ths | break;
|
5834 | 5a5012ec | ths | case OPC_NMADD_PS:
|
5835 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5836 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5837 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5838 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5839 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT2, fr); |
5840 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH2, fr); |
5841 | fbcc6828 | ths | gen_op_float_nmuladd_ps(); |
5842 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5843 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5844 | 5a5012ec | ths | opn = "nmadd.ps";
|
5845 | 5a5012ec | ths | break;
|
5846 | 5a5012ec | ths | case OPC_NMSUB_S:
|
5847 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5848 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5849 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT2, fr); |
5850 | fbcc6828 | ths | gen_op_float_nmulsub_s(); |
5851 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5852 | 5a5012ec | ths | opn = "nmsub.s";
|
5853 | 5a5012ec | ths | break;
|
5854 | 5a5012ec | ths | case OPC_NMSUB_D:
|
5855 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT0, fs); |
5856 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT1, ft); |
5857 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(DT2, fr); |
5858 | fbcc6828 | ths | gen_op_float_nmulsub_d(); |
5859 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, DT2); |
5860 | 5a5012ec | ths | opn = "nmsub.d";
|
5861 | 5a5012ec | ths | break;
|
5862 | 5a5012ec | ths | case OPC_NMSUB_PS:
|
5863 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT0, fs); |
5864 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH0, fs); |
5865 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT1, ft); |
5866 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH1, ft); |
5867 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WT2, fr); |
5868 | fbcc6828 | ths | GEN_LOAD_FREG_FTN(WTH2, fr); |
5869 | fbcc6828 | ths | gen_op_float_nmulsub_ps(); |
5870 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WT2); |
5871 | fbcc6828 | ths | GEN_STORE_FTN_FREG(fd, WTH2); |
5872 | 5a5012ec | ths | opn = "nmsub.ps";
|
5873 | 5a5012ec | ths | break;
|
5874 | 923617a3 | ths | default:
|
5875 | 923617a3 | ths | MIPS_INVAL(opn); |
5876 | 5a5012ec | ths | generate_exception (ctx, EXCP_RI); |
5877 | 5a5012ec | ths | return;
|
5878 | 5a5012ec | ths | } |
5879 | 5a5012ec | ths | MIPS_DEBUG("%s %s, %s, %s, %s", opn, fregnames[fd], fregnames[fr],
|
5880 | 5a5012ec | ths | fregnames[fs], fregnames[ft]); |
5881 | 7a387fff | ths | } |
5882 | 7a387fff | ths | |
5883 | 7a387fff | ths | /* ISA extensions (ASEs) */
|
5884 | 6af0bf9c | bellard | /* MIPS16 extension to MIPS32 */
|
5885 | 6af0bf9c | bellard | /* SmartMIPS extension to MIPS32 */
|
5886 | 6af0bf9c | bellard | |
5887 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
5888 | 6af0bf9c | bellard | |
5889 | 6af0bf9c | bellard | /* MDMX extension to MIPS64 */
|
5890 | 6af0bf9c | bellard | /* MIPS-3D extension to MIPS64 */
|
5891 | 6af0bf9c | bellard | |
5892 | 6af0bf9c | bellard | #endif
|
5893 | 6af0bf9c | bellard | |
5894 | 36d23958 | ths | static void decode_opc (CPUState *env, DisasContext *ctx) |
5895 | 6af0bf9c | bellard | { |
5896 | 6af0bf9c | bellard | int32_t offset; |
5897 | 6af0bf9c | bellard | int rs, rt, rd, sa;
|
5898 | 7a387fff | ths | uint32_t op, op1, op2; |
5899 | 6af0bf9c | bellard | int16_t imm; |
5900 | 6af0bf9c | bellard | |
5901 | d796321b | bellard | /* make sure instructions are on a word boundary */
|
5902 | d796321b | bellard | if (ctx->pc & 0x3) { |
5903 | cbeb0857 | ths | env->CP0_BadVAddr = ctx->pc; |
5904 | d796321b | bellard | generate_exception(ctx, EXCP_AdEL); |
5905 | d796321b | bellard | return;
|
5906 | d796321b | bellard | } |
5907 | d796321b | bellard | |
5908 | 4ad40f36 | bellard | if ((ctx->hflags & MIPS_HFLAG_BMASK) == MIPS_HFLAG_BL) {
|
5909 | 5a5012ec | ths | int l1;
|
5910 | 6af0bf9c | bellard | /* Handle blikely not taken case */
|
5911 | 3594c774 | ths | MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4); |
5912 | 5a5012ec | ths | l1 = gen_new_label(); |
5913 | 5a5012ec | ths | gen_op_jnz_T2(l1); |
5914 | 5a5012ec | ths | gen_op_save_state(ctx->hflags & ~MIPS_HFLAG_BMASK); |
5915 | 5a5012ec | ths | gen_goto_tb(ctx, 1, ctx->pc + 4); |
5916 | 5a5012ec | ths | gen_set_label(l1); |
5917 | 6af0bf9c | bellard | } |
5918 | 7a387fff | ths | op = MASK_OP_MAJOR(ctx->opcode); |
5919 | 7a387fff | ths | rs = (ctx->opcode >> 21) & 0x1f; |
5920 | 7a387fff | ths | rt = (ctx->opcode >> 16) & 0x1f; |
5921 | 7a387fff | ths | rd = (ctx->opcode >> 11) & 0x1f; |
5922 | 7a387fff | ths | sa = (ctx->opcode >> 6) & 0x1f; |
5923 | 6af0bf9c | bellard | imm = (int16_t)ctx->opcode; |
5924 | 6af0bf9c | bellard | switch (op) {
|
5925 | 7a387fff | ths | case OPC_SPECIAL:
|
5926 | 7a387fff | ths | op1 = MASK_SPECIAL(ctx->opcode); |
5927 | 6af0bf9c | bellard | switch (op1) {
|
5928 | 7a387fff | ths | case OPC_SLL: /* Arithmetic with immediate */ |
5929 | 7a387fff | ths | case OPC_SRL ... OPC_SRA:
|
5930 | e189e748 | ths | gen_arith_imm(env, ctx, op1, rd, rt, sa); |
5931 | 7a387fff | ths | break;
|
5932 | e189e748 | ths | case OPC_MOVZ ... OPC_MOVN:
|
5933 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); |
5934 | 7a387fff | ths | case OPC_SLLV: /* Arithmetic */ |
5935 | 7a387fff | ths | case OPC_SRLV ... OPC_SRAV:
|
5936 | 7a387fff | ths | case OPC_ADD ... OPC_NOR:
|
5937 | 7a387fff | ths | case OPC_SLT ... OPC_SLTU:
|
5938 | e189e748 | ths | gen_arith(env, ctx, op1, rd, rs, rt); |
5939 | 7a387fff | ths | break;
|
5940 | 7a387fff | ths | case OPC_MULT ... OPC_DIVU:
|
5941 | 7a387fff | ths | gen_muldiv(ctx, op1, rs, rt); |
5942 | 7a387fff | ths | break;
|
5943 | 7a387fff | ths | case OPC_JR ... OPC_JALR:
|
5944 | 7a387fff | ths | gen_compute_branch(ctx, op1, rs, rd, sa); |
5945 | 6af0bf9c | bellard | return;
|
5946 | 7a387fff | ths | case OPC_TGE ... OPC_TEQ: /* Traps */ |
5947 | 7a387fff | ths | case OPC_TNE:
|
5948 | 7a387fff | ths | gen_trap(ctx, op1, rs, rt, -1);
|
5949 | 6af0bf9c | bellard | break;
|
5950 | 7a387fff | ths | case OPC_MFHI: /* Move from HI/LO */ |
5951 | 7a387fff | ths | case OPC_MFLO:
|
5952 | 7a387fff | ths | gen_HILO(ctx, op1, rd); |
5953 | 6af0bf9c | bellard | break;
|
5954 | 7a387fff | ths | case OPC_MTHI:
|
5955 | 7a387fff | ths | case OPC_MTLO: /* Move to HI/LO */ |
5956 | 7a387fff | ths | gen_HILO(ctx, op1, rs); |
5957 | 6af0bf9c | bellard | break;
|
5958 | b48cfdff | ths | case OPC_PMON: /* Pmon entry point, also R4010 selsl */ |
5959 | b48cfdff | ths | #ifdef MIPS_STRICT_STANDARD
|
5960 | b48cfdff | ths | MIPS_INVAL("PMON / selsl");
|
5961 | b48cfdff | ths | generate_exception(ctx, EXCP_RI); |
5962 | b48cfdff | ths | #else
|
5963 | 7a387fff | ths | gen_op_pmon(sa); |
5964 | b48cfdff | ths | #endif
|
5965 | 7a387fff | ths | break;
|
5966 | 7a387fff | ths | case OPC_SYSCALL:
|
5967 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_SYSCALL); |
5968 | 6af0bf9c | bellard | break;
|
5969 | 7a387fff | ths | case OPC_BREAK:
|
5970 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_BREAK); |
5971 | 6af0bf9c | bellard | break;
|
5972 | b48cfdff | ths | case OPC_SPIM:
|
5973 | b48cfdff | ths | #ifdef MIPS_STRICT_STANDARD
|
5974 | b48cfdff | ths | MIPS_INVAL("SPIM");
|
5975 | b48cfdff | ths | generate_exception(ctx, EXCP_RI); |
5976 | b48cfdff | ths | #else
|
5977 | 7a387fff | ths | /* Implemented as RI exception for now. */
|
5978 | 7a387fff | ths | MIPS_INVAL("spim (unofficial)");
|
5979 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
5980 | b48cfdff | ths | #endif
|
5981 | 6af0bf9c | bellard | break;
|
5982 | 7a387fff | ths | case OPC_SYNC:
|
5983 | ead9360e | ths | /* Treat as NOP. */
|
5984 | 6af0bf9c | bellard | break;
|
5985 | 4ad40f36 | bellard | |
5986 | 7a387fff | ths | case OPC_MOVCI:
|
5987 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); |
5988 | 36d23958 | ths | if (env->CP0_Config1 & (1 << CP0C1_FP)) { |
5989 | e397ee33 | ths | save_cpu_state(ctx, 1);
|
5990 | 5e755519 | ths | check_cp1_enabled(ctx); |
5991 | 36d23958 | ths | gen_movci(ctx, rd, rs, (ctx->opcode >> 18) & 0x7, |
5992 | 36d23958 | ths | (ctx->opcode >> 16) & 1); |
5993 | 36d23958 | ths | } else {
|
5994 | e397ee33 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
5995 | 36d23958 | ths | } |
5996 | 4ad40f36 | bellard | break;
|
5997 | 4ad40f36 | bellard | |
5998 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
5999 | 7a387fff | ths | /* MIPS64 specific opcodes */
|
6000 | 7a387fff | ths | case OPC_DSLL:
|
6001 | 7a387fff | ths | case OPC_DSRL ... OPC_DSRA:
|
6002 | 7a387fff | ths | case OPC_DSLL32:
|
6003 | 7a387fff | ths | case OPC_DSRL32 ... OPC_DSRA32:
|
6004 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
6005 | e189e748 | ths | check_mips_64(ctx); |
6006 | e189e748 | ths | gen_arith_imm(env, ctx, op1, rd, rt, sa); |
6007 | 7a387fff | ths | break;
|
6008 | 7a387fff | ths | case OPC_DSLLV:
|
6009 | 7a387fff | ths | case OPC_DSRLV ... OPC_DSRAV:
|
6010 | 7a387fff | ths | case OPC_DADD ... OPC_DSUBU:
|
6011 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
6012 | e189e748 | ths | check_mips_64(ctx); |
6013 | e189e748 | ths | gen_arith(env, ctx, op1, rd, rs, rt); |
6014 | 7a387fff | ths | break;
|
6015 | 7a387fff | ths | case OPC_DMULT ... OPC_DDIVU:
|
6016 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
6017 | e189e748 | ths | check_mips_64(ctx); |
6018 | 7a387fff | ths | gen_muldiv(ctx, op1, rs, rt); |
6019 | 7a387fff | ths | break;
|
6020 | 6af0bf9c | bellard | #endif
|
6021 | 6af0bf9c | bellard | default: /* Invalid */ |
6022 | 6af0bf9c | bellard | MIPS_INVAL("special");
|
6023 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
6024 | 6af0bf9c | bellard | break;
|
6025 | 6af0bf9c | bellard | } |
6026 | 6af0bf9c | bellard | break;
|
6027 | 7a387fff | ths | case OPC_SPECIAL2:
|
6028 | 7a387fff | ths | op1 = MASK_SPECIAL2(ctx->opcode); |
6029 | 6af0bf9c | bellard | switch (op1) {
|
6030 | 7a387fff | ths | case OPC_MADD ... OPC_MADDU: /* Multiply and add/sub */ |
6031 | 7a387fff | ths | case OPC_MSUB ... OPC_MSUBU:
|
6032 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
6033 | 7a387fff | ths | gen_muldiv(ctx, op1, rs, rt); |
6034 | 6af0bf9c | bellard | break;
|
6035 | 7a387fff | ths | case OPC_MUL:
|
6036 | e189e748 | ths | gen_arith(env, ctx, op1, rd, rs, rt); |
6037 | 6af0bf9c | bellard | break;
|
6038 | 7a387fff | ths | case OPC_CLZ ... OPC_CLO:
|
6039 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
6040 | 7a387fff | ths | gen_cl(ctx, op1, rd, rs); |
6041 | 6af0bf9c | bellard | break;
|
6042 | 7a387fff | ths | case OPC_SDBBP:
|
6043 | 6af0bf9c | bellard | /* XXX: not clear which exception should be raised
|
6044 | 6af0bf9c | bellard | * when in debug mode...
|
6045 | 6af0bf9c | bellard | */
|
6046 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
6047 | 6af0bf9c | bellard | if (!(ctx->hflags & MIPS_HFLAG_DM)) {
|
6048 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_DBp); |
6049 | 6af0bf9c | bellard | } else {
|
6050 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_DBp); |
6051 | 6af0bf9c | bellard | } |
6052 | ead9360e | ths | /* Treat as NOP. */
|
6053 | 6af0bf9c | bellard | break;
|
6054 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
6055 | 7a387fff | ths | case OPC_DCLZ ... OPC_DCLO:
|
6056 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64); |
6057 | e189e748 | ths | check_mips_64(ctx); |
6058 | 7a387fff | ths | gen_cl(ctx, op1, rd, rs); |
6059 | 7a387fff | ths | break;
|
6060 | 7a387fff | ths | #endif
|
6061 | 6af0bf9c | bellard | default: /* Invalid */ |
6062 | 6af0bf9c | bellard | MIPS_INVAL("special2");
|
6063 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
6064 | 6af0bf9c | bellard | break;
|
6065 | 6af0bf9c | bellard | } |
6066 | 6af0bf9c | bellard | break;
|
6067 | 7a387fff | ths | case OPC_SPECIAL3:
|
6068 | 1579a72e | ths | op1 = MASK_SPECIAL3(ctx->opcode); |
6069 | 1579a72e | ths | switch (op1) {
|
6070 | 1579a72e | ths | case OPC_EXT:
|
6071 | 1579a72e | ths | case OPC_INS:
|
6072 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
6073 | 1579a72e | ths | gen_bitops(ctx, op1, rt, rs, sa, rd); |
6074 | 1579a72e | ths | break;
|
6075 | 1579a72e | ths | case OPC_BSHFL:
|
6076 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
6077 | 1579a72e | ths | op2 = MASK_BSHFL(ctx->opcode); |
6078 | 1579a72e | ths | switch (op2) {
|
6079 | 1579a72e | ths | case OPC_WSBH:
|
6080 | 1579a72e | ths | GEN_LOAD_REG_TN(T1, rt); |
6081 | 1579a72e | ths | gen_op_wsbh(); |
6082 | 1579a72e | ths | break;
|
6083 | 1579a72e | ths | case OPC_SEB:
|
6084 | 1579a72e | ths | GEN_LOAD_REG_TN(T1, rt); |
6085 | 1579a72e | ths | gen_op_seb(); |
6086 | 1579a72e | ths | break;
|
6087 | 1579a72e | ths | case OPC_SEH:
|
6088 | 1579a72e | ths | GEN_LOAD_REG_TN(T1, rt); |
6089 | 1579a72e | ths | gen_op_seh(); |
6090 | 1579a72e | ths | break;
|
6091 | 1579a72e | ths | default: /* Invalid */ |
6092 | 1579a72e | ths | MIPS_INVAL("bshfl");
|
6093 | 1579a72e | ths | generate_exception(ctx, EXCP_RI); |
6094 | 1579a72e | ths | break;
|
6095 | 1579a72e | ths | } |
6096 | 1579a72e | ths | GEN_STORE_TN_REG(rd, T0); |
6097 | 7a387fff | ths | break;
|
6098 | 1579a72e | ths | case OPC_RDHWR:
|
6099 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
6100 | 1579a72e | ths | switch (rd) {
|
6101 | 1579a72e | ths | case 0: |
6102 | 97428a4d | ths | save_cpu_state(ctx, 1);
|
6103 | 1579a72e | ths | gen_op_rdhwr_cpunum(); |
6104 | 7a387fff | ths | break;
|
6105 | 1579a72e | ths | case 1: |
6106 | 97428a4d | ths | save_cpu_state(ctx, 1);
|
6107 | 1579a72e | ths | gen_op_rdhwr_synci_step(); |
6108 | 7a387fff | ths | break;
|
6109 | 1579a72e | ths | case 2: |
6110 | 97428a4d | ths | save_cpu_state(ctx, 1);
|
6111 | 1579a72e | ths | gen_op_rdhwr_cc(); |
6112 | 7a387fff | ths | break;
|
6113 | 1579a72e | ths | case 3: |
6114 | 97428a4d | ths | save_cpu_state(ctx, 1);
|
6115 | 1579a72e | ths | gen_op_rdhwr_ccres(); |
6116 | 7a387fff | ths | break;
|
6117 | 1579a72e | ths | case 29: |
6118 | 6f5b89a0 | ths | #if defined (CONFIG_USER_ONLY)
|
6119 | ead9360e | ths | gen_op_tls_value(); |
6120 | 1579a72e | ths | break;
|
6121 | 97428a4d | ths | #endif
|
6122 | 1579a72e | ths | default: /* Invalid */ |
6123 | 1579a72e | ths | MIPS_INVAL("rdhwr");
|
6124 | 1579a72e | ths | generate_exception(ctx, EXCP_RI); |
6125 | 1579a72e | ths | break;
|
6126 | 1579a72e | ths | } |
6127 | 1579a72e | ths | GEN_STORE_TN_REG(rt, T0); |
6128 | 1579a72e | ths | break;
|
6129 | ead9360e | ths | case OPC_FORK:
|
6130 | ead9360e | ths | check_mips_mt(env, ctx); |
6131 | ead9360e | ths | GEN_LOAD_REG_TN(T0, rt); |
6132 | ead9360e | ths | GEN_LOAD_REG_TN(T1, rs); |
6133 | ead9360e | ths | gen_op_fork(); |
6134 | ead9360e | ths | break;
|
6135 | ead9360e | ths | case OPC_YIELD:
|
6136 | ead9360e | ths | check_mips_mt(env, ctx); |
6137 | ead9360e | ths | GEN_LOAD_REG_TN(T0, rs); |
6138 | ead9360e | ths | gen_op_yield(); |
6139 | ead9360e | ths | GEN_STORE_TN_REG(rd, T0); |
6140 | ead9360e | ths | break;
|
6141 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
6142 | 1579a72e | ths | case OPC_DEXTM ... OPC_DEXT:
|
6143 | 1579a72e | ths | case OPC_DINSM ... OPC_DINS:
|
6144 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64R2); |
6145 | e189e748 | ths | check_mips_64(ctx); |
6146 | 1579a72e | ths | gen_bitops(ctx, op1, rt, rs, sa, rd); |
6147 | 7a387fff | ths | break;
|
6148 | 1579a72e | ths | case OPC_DBSHFL:
|
6149 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64R2); |
6150 | e189e748 | ths | check_mips_64(ctx); |
6151 | 1579a72e | ths | op2 = MASK_DBSHFL(ctx->opcode); |
6152 | 1579a72e | ths | switch (op2) {
|
6153 | 1579a72e | ths | case OPC_DSBH:
|
6154 | 1579a72e | ths | GEN_LOAD_REG_TN(T1, rt); |
6155 | 1579a72e | ths | gen_op_dsbh(); |
6156 | 1579a72e | ths | break;
|
6157 | 1579a72e | ths | case OPC_DSHD:
|
6158 | 1579a72e | ths | GEN_LOAD_REG_TN(T1, rt); |
6159 | 1579a72e | ths | gen_op_dshd(); |
6160 | 1579a72e | ths | break;
|
6161 | 7a387fff | ths | default: /* Invalid */ |
6162 | 7a387fff | ths | MIPS_INVAL("dbshfl");
|
6163 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
6164 | 7a387fff | ths | break;
|
6165 | 1579a72e | ths | } |
6166 | 1579a72e | ths | GEN_STORE_TN_REG(rd, T0); |
6167 | 7a387fff | ths | #endif
|
6168 | 7a387fff | ths | default: /* Invalid */ |
6169 | 7a387fff | ths | MIPS_INVAL("special3");
|
6170 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
6171 | 7a387fff | ths | break;
|
6172 | 7a387fff | ths | } |
6173 | 7a387fff | ths | break;
|
6174 | 7a387fff | ths | case OPC_REGIMM:
|
6175 | 7a387fff | ths | op1 = MASK_REGIMM(ctx->opcode); |
6176 | 7a387fff | ths | switch (op1) {
|
6177 | 7a387fff | ths | case OPC_BLTZ ... OPC_BGEZL: /* REGIMM branches */ |
6178 | 7a387fff | ths | case OPC_BLTZAL ... OPC_BGEZALL:
|
6179 | 7a387fff | ths | gen_compute_branch(ctx, op1, rs, -1, imm << 2); |
6180 | 6af0bf9c | bellard | return;
|
6181 | 7a387fff | ths | case OPC_TGEI ... OPC_TEQI: /* REGIMM traps */ |
6182 | 7a387fff | ths | case OPC_TNEI:
|
6183 | 7a387fff | ths | gen_trap(ctx, op1, rs, -1, imm);
|
6184 | 7a387fff | ths | break;
|
6185 | 7a387fff | ths | case OPC_SYNCI:
|
6186 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
6187 | ead9360e | ths | /* Treat as NOP. */
|
6188 | 6af0bf9c | bellard | break;
|
6189 | 6af0bf9c | bellard | default: /* Invalid */ |
6190 | 923617a3 | ths | MIPS_INVAL("regimm");
|
6191 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
6192 | 6af0bf9c | bellard | break;
|
6193 | 6af0bf9c | bellard | } |
6194 | 6af0bf9c | bellard | break;
|
6195 | 7a387fff | ths | case OPC_CP0:
|
6196 | 387a8fe5 | ths | check_cp0_enabled(ctx); |
6197 | 7a387fff | ths | op1 = MASK_CP0(ctx->opcode); |
6198 | 6af0bf9c | bellard | switch (op1) {
|
6199 | 7a387fff | ths | case OPC_MFC0:
|
6200 | 7a387fff | ths | case OPC_MTC0:
|
6201 | ead9360e | ths | case OPC_MFTR:
|
6202 | ead9360e | ths | case OPC_MTTR:
|
6203 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
6204 | 7a387fff | ths | case OPC_DMFC0:
|
6205 | 7a387fff | ths | case OPC_DMTC0:
|
6206 | 7a387fff | ths | #endif
|
6207 | 29929e34 | ths | gen_cp0(env, ctx, op1, rt, rd); |
6208 | 7a387fff | ths | break;
|
6209 | 7a387fff | ths | case OPC_C0_FIRST ... OPC_C0_LAST:
|
6210 | 29929e34 | ths | gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd); |
6211 | 7a387fff | ths | break;
|
6212 | 7a387fff | ths | case OPC_MFMC0:
|
6213 | 7a387fff | ths | op2 = MASK_MFMC0(ctx->opcode); |
6214 | 7a387fff | ths | switch (op2) {
|
6215 | ead9360e | ths | case OPC_DMT:
|
6216 | ead9360e | ths | check_mips_mt(env, ctx); |
6217 | ead9360e | ths | gen_op_dmt(); |
6218 | ead9360e | ths | break;
|
6219 | ead9360e | ths | case OPC_EMT:
|
6220 | ead9360e | ths | check_mips_mt(env, ctx); |
6221 | ead9360e | ths | gen_op_emt(); |
6222 | ead9360e | ths | break;
|
6223 | ead9360e | ths | case OPC_DVPE:
|
6224 | ead9360e | ths | check_mips_mt(env, ctx); |
6225 | ead9360e | ths | gen_op_dvpe(); |
6226 | ead9360e | ths | break;
|
6227 | ead9360e | ths | case OPC_EVPE:
|
6228 | ead9360e | ths | check_mips_mt(env, ctx); |
6229 | ead9360e | ths | gen_op_evpe(); |
6230 | ead9360e | ths | break;
|
6231 | 7a387fff | ths | case OPC_DI:
|
6232 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
6233 | 387a8fe5 | ths | save_cpu_state(ctx, 1);
|
6234 | 7a387fff | ths | gen_op_di(); |
6235 | 7a387fff | ths | /* Stop translation as we may have switched the execution mode */
|
6236 | 7a387fff | ths | ctx->bstate = BS_STOP; |
6237 | 7a387fff | ths | break;
|
6238 | 7a387fff | ths | case OPC_EI:
|
6239 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
6240 | 387a8fe5 | ths | save_cpu_state(ctx, 1);
|
6241 | 7a387fff | ths | gen_op_ei(); |
6242 | 7a387fff | ths | /* Stop translation as we may have switched the execution mode */
|
6243 | 7a387fff | ths | ctx->bstate = BS_STOP; |
6244 | 7a387fff | ths | break;
|
6245 | 7a387fff | ths | default: /* Invalid */ |
6246 | 923617a3 | ths | MIPS_INVAL("mfmc0");
|
6247 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
6248 | 7a387fff | ths | break;
|
6249 | 7a387fff | ths | } |
6250 | 7a387fff | ths | GEN_STORE_TN_REG(rt, T0); |
6251 | 6af0bf9c | bellard | break;
|
6252 | 7a387fff | ths | case OPC_RDPGPR:
|
6253 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
6254 | ead9360e | ths | GEN_LOAD_SRSREG_TN(T0, rt); |
6255 | ead9360e | ths | GEN_STORE_TN_REG(rd, T0); |
6256 | ead9360e | ths | break;
|
6257 | 7a387fff | ths | case OPC_WRPGPR:
|
6258 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
6259 | 3a95e3a7 | ths | GEN_LOAD_REG_TN(T0, rt); |
6260 | ead9360e | ths | GEN_STORE_TN_SRSREG(rd, T0); |
6261 | 38121543 | ths | break;
|
6262 | 6af0bf9c | bellard | default:
|
6263 | 923617a3 | ths | MIPS_INVAL("cp0");
|
6264 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
6265 | 6af0bf9c | bellard | break;
|
6266 | 6af0bf9c | bellard | } |
6267 | 6af0bf9c | bellard | break;
|
6268 | 7a387fff | ths | case OPC_ADDI ... OPC_LUI: /* Arithmetic with immediate opcode */ |
6269 | e189e748 | ths | gen_arith_imm(env, ctx, op, rt, rs, imm); |
6270 | 7a387fff | ths | break;
|
6271 | 7a387fff | ths | case OPC_J ... OPC_JAL: /* Jump */ |
6272 | 7a387fff | ths | offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2; |
6273 | 7a387fff | ths | gen_compute_branch(ctx, op, rs, rt, offset); |
6274 | 7a387fff | ths | return;
|
6275 | 7a387fff | ths | case OPC_BEQ ... OPC_BGTZ: /* Branch */ |
6276 | 7a387fff | ths | case OPC_BEQL ... OPC_BGTZL:
|
6277 | 7a387fff | ths | gen_compute_branch(ctx, op, rs, rt, imm << 2);
|
6278 | 7a387fff | ths | return;
|
6279 | 7a387fff | ths | case OPC_LB ... OPC_LWR: /* Load and stores */ |
6280 | 7a387fff | ths | case OPC_SB ... OPC_SW:
|
6281 | 7a387fff | ths | case OPC_SWR:
|
6282 | 7a387fff | ths | case OPC_LL:
|
6283 | 7a387fff | ths | case OPC_SC:
|
6284 | 7a387fff | ths | gen_ldst(ctx, op, rt, rs, imm); |
6285 | 7a387fff | ths | break;
|
6286 | 7a387fff | ths | case OPC_CACHE:
|
6287 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32); |
6288 | ead9360e | ths | /* Treat as NOP. */
|
6289 | 34ae7b51 | ths | break;
|
6290 | 7a387fff | ths | case OPC_PREF:
|
6291 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); |
6292 | ead9360e | ths | /* Treat as NOP. */
|
6293 | 6af0bf9c | bellard | break;
|
6294 | 4ad40f36 | bellard | |
6295 | 923617a3 | ths | /* Floating point (COP1). */
|
6296 | 7a387fff | ths | case OPC_LWC1:
|
6297 | 7a387fff | ths | case OPC_LDC1:
|
6298 | 7a387fff | ths | case OPC_SWC1:
|
6299 | 7a387fff | ths | case OPC_SDC1:
|
6300 | 36d23958 | ths | if (env->CP0_Config1 & (1 << CP0C1_FP)) { |
6301 | 36d23958 | ths | save_cpu_state(ctx, 1);
|
6302 | 5e755519 | ths | check_cp1_enabled(ctx); |
6303 | 36d23958 | ths | gen_flt_ldst(ctx, op, rt, rs, imm); |
6304 | 36d23958 | ths | } else {
|
6305 | 36d23958 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
6306 | 36d23958 | ths | } |
6307 | 6ea83fed | bellard | break;
|
6308 | 6ea83fed | bellard | |
6309 | 7a387fff | ths | case OPC_CP1:
|
6310 | 36d23958 | ths | if (env->CP0_Config1 & (1 << CP0C1_FP)) { |
6311 | 36d23958 | ths | save_cpu_state(ctx, 1);
|
6312 | 5e755519 | ths | check_cp1_enabled(ctx); |
6313 | 36d23958 | ths | op1 = MASK_CP1(ctx->opcode); |
6314 | 36d23958 | ths | switch (op1) {
|
6315 | 3a95e3a7 | ths | case OPC_MFHC1:
|
6316 | 3a95e3a7 | ths | case OPC_MTHC1:
|
6317 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
6318 | 36d23958 | ths | case OPC_MFC1:
|
6319 | 36d23958 | ths | case OPC_CFC1:
|
6320 | 36d23958 | ths | case OPC_MTC1:
|
6321 | 36d23958 | ths | case OPC_CTC1:
|
6322 | e189e748 | ths | gen_cp1(ctx, op1, rt, rd); |
6323 | e189e748 | ths | break;
|
6324 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
6325 | 36d23958 | ths | case OPC_DMFC1:
|
6326 | 36d23958 | ths | case OPC_DMTC1:
|
6327 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
6328 | 36d23958 | ths | gen_cp1(ctx, op1, rt, rd); |
6329 | 36d23958 | ths | break;
|
6330 | e189e748 | ths | #endif
|
6331 | 36d23958 | ths | case OPC_BC1:
|
6332 | fbcc6828 | ths | case OPC_BC1ANY2:
|
6333 | fbcc6828 | ths | case OPC_BC1ANY4:
|
6334 | e189e748 | ths | gen_compute_branch1(env, ctx, MASK_BC1(ctx->opcode), |
6335 | 5a5012ec | ths | (rt >> 2) & 0x7, imm << 2); |
6336 | 36d23958 | ths | return;
|
6337 | 36d23958 | ths | case OPC_S_FMT:
|
6338 | 36d23958 | ths | case OPC_D_FMT:
|
6339 | 36d23958 | ths | case OPC_W_FMT:
|
6340 | 36d23958 | ths | case OPC_L_FMT:
|
6341 | 5a5012ec | ths | case OPC_PS_FMT:
|
6342 | 5a5012ec | ths | gen_farith(ctx, MASK_CP1_FUNC(ctx->opcode), rt, rd, sa, |
6343 | 5a5012ec | ths | (imm >> 8) & 0x7); |
6344 | 36d23958 | ths | break;
|
6345 | 36d23958 | ths | default:
|
6346 | 923617a3 | ths | MIPS_INVAL("cp1");
|
6347 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
6348 | 36d23958 | ths | break;
|
6349 | 36d23958 | ths | } |
6350 | 36d23958 | ths | } else {
|
6351 | 36d23958 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
6352 | 6ea83fed | bellard | } |
6353 | 4ad40f36 | bellard | break;
|
6354 | 4ad40f36 | bellard | |
6355 | 4ad40f36 | bellard | /* COP2. */
|
6356 | 7a387fff | ths | case OPC_LWC2:
|
6357 | 7a387fff | ths | case OPC_LDC2:
|
6358 | 7a387fff | ths | case OPC_SWC2:
|
6359 | 7a387fff | ths | case OPC_SDC2:
|
6360 | 7a387fff | ths | case OPC_CP2:
|
6361 | 7a387fff | ths | /* COP2: Not implemented. */
|
6362 | 4ad40f36 | bellard | generate_exception_err(ctx, EXCP_CpU, 2);
|
6363 | 4ad40f36 | bellard | break;
|
6364 | 4ad40f36 | bellard | |
6365 | 7a387fff | ths | case OPC_CP3:
|
6366 | 36d23958 | ths | if (env->CP0_Config1 & (1 << CP0C1_FP)) { |
6367 | e397ee33 | ths | save_cpu_state(ctx, 1);
|
6368 | 5e755519 | ths | check_cp1_enabled(ctx); |
6369 | 36d23958 | ths | op1 = MASK_CP3(ctx->opcode); |
6370 | 36d23958 | ths | switch (op1) {
|
6371 | 5a5012ec | ths | case OPC_LWXC1:
|
6372 | 5a5012ec | ths | case OPC_LDXC1:
|
6373 | 5a5012ec | ths | case OPC_LUXC1:
|
6374 | 5a5012ec | ths | case OPC_SWXC1:
|
6375 | 5a5012ec | ths | case OPC_SDXC1:
|
6376 | 5a5012ec | ths | case OPC_SUXC1:
|
6377 | 93b12ccc | ths | gen_flt3_ldst(ctx, op1, sa, rd, rs, rt); |
6378 | 5a5012ec | ths | break;
|
6379 | e0c84da7 | ths | case OPC_PREFX:
|
6380 | ead9360e | ths | /* Treat as NOP. */
|
6381 | e0c84da7 | ths | break;
|
6382 | 5a5012ec | ths | case OPC_ALNV_PS:
|
6383 | 5a5012ec | ths | case OPC_MADD_S:
|
6384 | 5a5012ec | ths | case OPC_MADD_D:
|
6385 | 5a5012ec | ths | case OPC_MADD_PS:
|
6386 | 5a5012ec | ths | case OPC_MSUB_S:
|
6387 | 5a5012ec | ths | case OPC_MSUB_D:
|
6388 | 5a5012ec | ths | case OPC_MSUB_PS:
|
6389 | 5a5012ec | ths | case OPC_NMADD_S:
|
6390 | 5a5012ec | ths | case OPC_NMADD_D:
|
6391 | 5a5012ec | ths | case OPC_NMADD_PS:
|
6392 | 5a5012ec | ths | case OPC_NMSUB_S:
|
6393 | 5a5012ec | ths | case OPC_NMSUB_D:
|
6394 | 5a5012ec | ths | case OPC_NMSUB_PS:
|
6395 | 5a5012ec | ths | gen_flt3_arith(ctx, op1, sa, rs, rd, rt); |
6396 | 5a5012ec | ths | break;
|
6397 | 36d23958 | ths | default:
|
6398 | 923617a3 | ths | MIPS_INVAL("cp3");
|
6399 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
6400 | 36d23958 | ths | break;
|
6401 | 36d23958 | ths | } |
6402 | 36d23958 | ths | } else {
|
6403 | e397ee33 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
6404 | 7a387fff | ths | } |
6405 | 4ad40f36 | bellard | break;
|
6406 | 4ad40f36 | bellard | |
6407 | 540635ba | ths | #if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
|
6408 | 7a387fff | ths | /* MIPS64 opcodes */
|
6409 | 7a387fff | ths | case OPC_LWU:
|
6410 | 7a387fff | ths | case OPC_LDL ... OPC_LDR:
|
6411 | 7a387fff | ths | case OPC_SDL ... OPC_SDR:
|
6412 | 7a387fff | ths | case OPC_LLD:
|
6413 | 7a387fff | ths | case OPC_LD:
|
6414 | 7a387fff | ths | case OPC_SCD:
|
6415 | 7a387fff | ths | case OPC_SD:
|
6416 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
6417 | e189e748 | ths | check_mips_64(ctx); |
6418 | 7a387fff | ths | gen_ldst(ctx, op, rt, rs, imm); |
6419 | 7a387fff | ths | break;
|
6420 | 7a387fff | ths | case OPC_DADDI ... OPC_DADDIU:
|
6421 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
6422 | e189e748 | ths | check_mips_64(ctx); |
6423 | e189e748 | ths | gen_arith_imm(env, ctx, op, rt, rs, imm); |
6424 | 7a387fff | ths | break;
|
6425 | 6af0bf9c | bellard | #endif
|
6426 | 7a387fff | ths | case OPC_JALX:
|
6427 | e189e748 | ths | check_insn(env, ctx, ASE_MIPS16); |
6428 | 7a387fff | ths | /* MIPS16: Not implemented. */
|
6429 | 7a387fff | ths | case OPC_MDMX:
|
6430 | e189e748 | ths | check_insn(env, ctx, ASE_MDMX); |
6431 | 7a387fff | ths | /* MDMX: Not implemented. */
|
6432 | 6af0bf9c | bellard | default: /* Invalid */ |
6433 | 923617a3 | ths | MIPS_INVAL("major opcode");
|
6434 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
6435 | 6af0bf9c | bellard | break;
|
6436 | 6af0bf9c | bellard | } |
6437 | 4ad40f36 | bellard | if (ctx->hflags & MIPS_HFLAG_BMASK) {
|
6438 | c53f4a62 | ths | int hflags = ctx->hflags & MIPS_HFLAG_BMASK;
|
6439 | 6af0bf9c | bellard | /* Branches completion */
|
6440 | 4ad40f36 | bellard | ctx->hflags &= ~MIPS_HFLAG_BMASK; |
6441 | 6af0bf9c | bellard | ctx->bstate = BS_BRANCH; |
6442 | 6af0bf9c | bellard | save_cpu_state(ctx, 0);
|
6443 | 5a5012ec | ths | switch (hflags) {
|
6444 | 6af0bf9c | bellard | case MIPS_HFLAG_B:
|
6445 | 6af0bf9c | bellard | /* unconditional branch */
|
6446 | 6af0bf9c | bellard | MIPS_DEBUG("unconditional branch");
|
6447 | 6e256c93 | bellard | gen_goto_tb(ctx, 0, ctx->btarget);
|
6448 | 6af0bf9c | bellard | break;
|
6449 | 6af0bf9c | bellard | case MIPS_HFLAG_BL:
|
6450 | 6af0bf9c | bellard | /* blikely taken case */
|
6451 | 6af0bf9c | bellard | MIPS_DEBUG("blikely branch taken");
|
6452 | 6e256c93 | bellard | gen_goto_tb(ctx, 0, ctx->btarget);
|
6453 | 6af0bf9c | bellard | break;
|
6454 | 6af0bf9c | bellard | case MIPS_HFLAG_BC:
|
6455 | 6af0bf9c | bellard | /* Conditional branch */
|
6456 | 6af0bf9c | bellard | MIPS_DEBUG("conditional branch");
|
6457 | c53be334 | bellard | { |
6458 | c53be334 | bellard | int l1;
|
6459 | c53be334 | bellard | l1 = gen_new_label(); |
6460 | c53be334 | bellard | gen_op_jnz_T2(l1); |
6461 | 6e256c93 | bellard | gen_goto_tb(ctx, 1, ctx->pc + 4); |
6462 | eeef26cd | bellard | gen_set_label(l1); |
6463 | eeef26cd | bellard | gen_goto_tb(ctx, 0, ctx->btarget);
|
6464 | c53be334 | bellard | } |
6465 | 6af0bf9c | bellard | break;
|
6466 | 6af0bf9c | bellard | case MIPS_HFLAG_BR:
|
6467 | 6af0bf9c | bellard | /* unconditional branch to register */
|
6468 | 6af0bf9c | bellard | MIPS_DEBUG("branch to register");
|
6469 | 6af0bf9c | bellard | gen_op_breg(); |
6470 | 5a5012ec | ths | gen_op_reset_T0(); |
6471 | 5a5012ec | ths | gen_op_exit_tb(); |
6472 | 6af0bf9c | bellard | break;
|
6473 | 6af0bf9c | bellard | default:
|
6474 | 6af0bf9c | bellard | MIPS_DEBUG("unknown branch");
|
6475 | 6af0bf9c | bellard | break;
|
6476 | 6af0bf9c | bellard | } |
6477 | 6af0bf9c | bellard | } |
6478 | 6af0bf9c | bellard | } |
6479 | 6af0bf9c | bellard | |
6480 | aa343735 | ths | static always_inline int |
6481 | 820e00f2 | ths | gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, |
6482 | 820e00f2 | ths | int search_pc)
|
6483 | 6af0bf9c | bellard | { |
6484 | 278d0702 | ths | DisasContext ctx; |
6485 | 6af0bf9c | bellard | target_ulong pc_start; |
6486 | 6af0bf9c | bellard | uint16_t *gen_opc_end; |
6487 | 6af0bf9c | bellard | int j, lj = -1; |
6488 | 6af0bf9c | bellard | |
6489 | 4ad40f36 | bellard | if (search_pc && loglevel)
|
6490 | 6ea83fed | bellard | fprintf (logfile, "search pc %d\n", search_pc);
|
6491 | 4ad40f36 | bellard | |
6492 | 6af0bf9c | bellard | pc_start = tb->pc; |
6493 | 6af0bf9c | bellard | gen_opc_ptr = gen_opc_buf; |
6494 | 6af0bf9c | bellard | gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; |
6495 | 6af0bf9c | bellard | gen_opparam_ptr = gen_opparam_buf; |
6496 | c53be334 | bellard | nb_gen_labels = 0;
|
6497 | 6af0bf9c | bellard | ctx.pc = pc_start; |
6498 | 4ad40f36 | bellard | ctx.saved_pc = -1;
|
6499 | 6af0bf9c | bellard | ctx.tb = tb; |
6500 | 6af0bf9c | bellard | ctx.bstate = BS_NONE; |
6501 | 4ad40f36 | bellard | /* Restore delay slot state from the tb context. */
|
6502 | c068688b | j_mayer | ctx.hflags = (uint32_t)tb->flags; /* FIXME: maybe use 64 bits here? */
|
6503 | fd4a04eb | ths | restore_cpu_state(env, &ctx); |
6504 | 6af0bf9c | bellard | #if defined(CONFIG_USER_ONLY)
|
6505 | 6af0bf9c | bellard | ctx.mem_idx = 0;
|
6506 | 6af0bf9c | bellard | #else
|
6507 | 3d9fb9fe | bellard | ctx.mem_idx = !((ctx.hflags & MIPS_HFLAG_MODE) == MIPS_HFLAG_UM); |
6508 | 6af0bf9c | bellard | #endif
|
6509 | 6af0bf9c | bellard | #ifdef DEBUG_DISAS
|
6510 | 6af0bf9c | bellard | if (loglevel & CPU_LOG_TB_CPU) {
|
6511 | 6af0bf9c | bellard | fprintf(logfile, "------------------------------------------------\n");
|
6512 | 4ad40f36 | bellard | /* FIXME: This may print out stale hflags from env... */
|
6513 | 6af0bf9c | bellard | cpu_dump_state(env, logfile, fprintf, 0);
|
6514 | 6af0bf9c | bellard | } |
6515 | 6af0bf9c | bellard | #endif
|
6516 | 923617a3 | ths | #ifdef MIPS_DEBUG_DISAS
|
6517 | 6af0bf9c | bellard | if (loglevel & CPU_LOG_TB_IN_ASM)
|
6518 | 4ad40f36 | bellard | fprintf(logfile, "\ntb %p super %d cond %04x\n",
|
6519 | 4ad40f36 | bellard | tb, ctx.mem_idx, ctx.hflags); |
6520 | 6af0bf9c | bellard | #endif
|
6521 | 6af0bf9c | bellard | while (ctx.bstate == BS_NONE && gen_opc_ptr < gen_opc_end) {
|
6522 | 4ad40f36 | bellard | if (env->nb_breakpoints > 0) { |
6523 | 4ad40f36 | bellard | for(j = 0; j < env->nb_breakpoints; j++) { |
6524 | 4ad40f36 | bellard | if (env->breakpoints[j] == ctx.pc) {
|
6525 | 278d0702 | ths | save_cpu_state(&ctx, 1);
|
6526 | 4ad40f36 | bellard | ctx.bstate = BS_BRANCH; |
6527 | 4ad40f36 | bellard | gen_op_debug(); |
6528 | ce62e5ba | ths | /* Include the breakpoint location or the tb won't
|
6529 | ce62e5ba | ths | * be flushed when it must be. */
|
6530 | ce62e5ba | ths | ctx.pc += 4;
|
6531 | 4ad40f36 | bellard | goto done_generating;
|
6532 | 4ad40f36 | bellard | } |
6533 | 4ad40f36 | bellard | } |
6534 | 4ad40f36 | bellard | } |
6535 | 4ad40f36 | bellard | |
6536 | 6af0bf9c | bellard | if (search_pc) {
|
6537 | 6af0bf9c | bellard | j = gen_opc_ptr - gen_opc_buf; |
6538 | 6af0bf9c | bellard | if (lj < j) {
|
6539 | 6af0bf9c | bellard | lj++; |
6540 | 6af0bf9c | bellard | while (lj < j)
|
6541 | 6af0bf9c | bellard | gen_opc_instr_start[lj++] = 0;
|
6542 | 6af0bf9c | bellard | } |
6543 | 4ad40f36 | bellard | gen_opc_pc[lj] = ctx.pc; |
6544 | 4ad40f36 | bellard | gen_opc_hflags[lj] = ctx.hflags & MIPS_HFLAG_BMASK; |
6545 | 4ad40f36 | bellard | gen_opc_instr_start[lj] = 1;
|
6546 | 6af0bf9c | bellard | } |
6547 | 6af0bf9c | bellard | ctx.opcode = ldl_code(ctx.pc); |
6548 | 36d23958 | ths | decode_opc(env, &ctx); |
6549 | 6af0bf9c | bellard | ctx.pc += 4;
|
6550 | 4ad40f36 | bellard | |
6551 | 4ad40f36 | bellard | if (env->singlestep_enabled)
|
6552 | 4ad40f36 | bellard | break;
|
6553 | 4ad40f36 | bellard | |
6554 | 6af0bf9c | bellard | if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) |
6555 | 6af0bf9c | bellard | break;
|
6556 | 4ad40f36 | bellard | |
6557 | 6af0bf9c | bellard | #if defined (MIPS_SINGLE_STEP)
|
6558 | 6af0bf9c | bellard | break;
|
6559 | 6af0bf9c | bellard | #endif
|
6560 | 6af0bf9c | bellard | } |
6561 | 4ad40f36 | bellard | if (env->singlestep_enabled) {
|
6562 | 278d0702 | ths | save_cpu_state(&ctx, ctx.bstate == BS_NONE); |
6563 | 4ad40f36 | bellard | gen_op_debug(); |
6564 | 16c00cb2 | ths | } else {
|
6565 | 16c00cb2 | ths | switch (ctx.bstate) {
|
6566 | 16c00cb2 | ths | case BS_STOP:
|
6567 | 16c00cb2 | ths | gen_op_interrupt_restart(); |
6568 | df1561e2 | ths | gen_goto_tb(&ctx, 0, ctx.pc);
|
6569 | df1561e2 | ths | break;
|
6570 | 16c00cb2 | ths | case BS_NONE:
|
6571 | 278d0702 | ths | save_cpu_state(&ctx, 0);
|
6572 | 16c00cb2 | ths | gen_goto_tb(&ctx, 0, ctx.pc);
|
6573 | 16c00cb2 | ths | break;
|
6574 | 5a5012ec | ths | case BS_EXCP:
|
6575 | 5a5012ec | ths | gen_op_interrupt_restart(); |
6576 | a85427b1 | ths | gen_op_reset_T0(); |
6577 | a85427b1 | ths | gen_op_exit_tb(); |
6578 | 16c00cb2 | ths | break;
|
6579 | 5a5012ec | ths | case BS_BRANCH:
|
6580 | 5a5012ec | ths | default:
|
6581 | 5a5012ec | ths | break;
|
6582 | 16c00cb2 | ths | } |
6583 | 6af0bf9c | bellard | } |
6584 | 4ad40f36 | bellard | done_generating:
|
6585 | 6af0bf9c | bellard | *gen_opc_ptr = INDEX_op_end; |
6586 | 6af0bf9c | bellard | if (search_pc) {
|
6587 | 6af0bf9c | bellard | j = gen_opc_ptr - gen_opc_buf; |
6588 | 6af0bf9c | bellard | lj++; |
6589 | 6af0bf9c | bellard | while (lj <= j)
|
6590 | 6af0bf9c | bellard | gen_opc_instr_start[lj++] = 0;
|
6591 | 6af0bf9c | bellard | } else {
|
6592 | 6af0bf9c | bellard | tb->size = ctx.pc - pc_start; |
6593 | 6af0bf9c | bellard | } |
6594 | 6af0bf9c | bellard | #ifdef DEBUG_DISAS
|
6595 | 6af0bf9c | bellard | #if defined MIPS_DEBUG_DISAS
|
6596 | 6af0bf9c | bellard | if (loglevel & CPU_LOG_TB_IN_ASM)
|
6597 | 6af0bf9c | bellard | fprintf(logfile, "\n");
|
6598 | 6af0bf9c | bellard | #endif
|
6599 | 6af0bf9c | bellard | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
6600 | 6af0bf9c | bellard | fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
|
6601 | 9898128f | ths | target_disas(logfile, pc_start, ctx.pc - pc_start, 0);
|
6602 | 6af0bf9c | bellard | fprintf(logfile, "\n");
|
6603 | 6af0bf9c | bellard | } |
6604 | 6af0bf9c | bellard | if (loglevel & CPU_LOG_TB_OP) {
|
6605 | 6af0bf9c | bellard | fprintf(logfile, "OP:\n");
|
6606 | 6af0bf9c | bellard | dump_ops(gen_opc_buf, gen_opparam_buf); |
6607 | 6af0bf9c | bellard | fprintf(logfile, "\n");
|
6608 | 6af0bf9c | bellard | } |
6609 | 6af0bf9c | bellard | if (loglevel & CPU_LOG_TB_CPU) {
|
6610 | 6af0bf9c | bellard | fprintf(logfile, "---------------- %d %08x\n", ctx.bstate, ctx.hflags);
|
6611 | 6af0bf9c | bellard | } |
6612 | 6af0bf9c | bellard | #endif
|
6613 | 3b46e624 | ths | |
6614 | 6af0bf9c | bellard | return 0; |
6615 | 6af0bf9c | bellard | } |
6616 | 6af0bf9c | bellard | |
6617 | 6af0bf9c | bellard | int gen_intermediate_code (CPUState *env, struct TranslationBlock *tb) |
6618 | 6af0bf9c | bellard | { |
6619 | 6af0bf9c | bellard | return gen_intermediate_code_internal(env, tb, 0); |
6620 | 6af0bf9c | bellard | } |
6621 | 6af0bf9c | bellard | |
6622 | 6af0bf9c | bellard | int gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb) |
6623 | 6af0bf9c | bellard | { |
6624 | 6af0bf9c | bellard | return gen_intermediate_code_internal(env, tb, 1); |
6625 | 6af0bf9c | bellard | } |
6626 | 6af0bf9c | bellard | |
6627 | 5fafdf24 | ths | void fpu_dump_state(CPUState *env, FILE *f,
|
6628 | 6ea83fed | bellard | int (*fpu_fprintf)(FILE *f, const char *fmt, ...), |
6629 | 6ea83fed | bellard | int flags)
|
6630 | 6ea83fed | bellard | { |
6631 | 6ea83fed | bellard | int i;
|
6632 | 5e755519 | ths | int is_fpu64 = !!(env->hflags & MIPS_HFLAG_F64);
|
6633 | 5a5012ec | ths | |
6634 | 5a5012ec | ths | #define printfpr(fp) \
|
6635 | 5a5012ec | ths | do { \
|
6636 | 5a5012ec | ths | if (is_fpu64) \
|
6637 | 5a5012ec | ths | fpu_fprintf(f, "w:%08x d:%016lx fd:%13g fs:%13g psu: %13g\n", \
|
6638 | 5a5012ec | ths | (fp)->w[FP_ENDIAN_IDX], (fp)->d, (fp)->fd, \ |
6639 | 5a5012ec | ths | (fp)->fs[FP_ENDIAN_IDX], (fp)->fs[!FP_ENDIAN_IDX]); \ |
6640 | 5a5012ec | ths | else { \
|
6641 | 5a5012ec | ths | fpr_t tmp; \ |
6642 | 5a5012ec | ths | tmp.w[FP_ENDIAN_IDX] = (fp)->w[FP_ENDIAN_IDX]; \ |
6643 | 5a5012ec | ths | tmp.w[!FP_ENDIAN_IDX] = ((fp) + 1)->w[FP_ENDIAN_IDX]; \
|
6644 | 5a5012ec | ths | fpu_fprintf(f, "w:%08x d:%016lx fd:%13g fs:%13g psu:%13g\n", \
|
6645 | 5a5012ec | ths | tmp.w[FP_ENDIAN_IDX], tmp.d, tmp.fd, \ |
6646 | 5a5012ec | ths | tmp.fs[FP_ENDIAN_IDX], tmp.fs[!FP_ENDIAN_IDX]); \ |
6647 | 5a5012ec | ths | } \ |
6648 | 6ea83fed | bellard | } while(0) |
6649 | 6ea83fed | bellard | |
6650 | 5a5012ec | ths | |
6651 | 5a5012ec | ths | fpu_fprintf(f, "CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d fp_status 0x%08x(0x%02x)\n",
|
6652 | ead9360e | ths | env->fpu->fcr0, env->fpu->fcr31, is_fpu64, env->fpu->fp_status, |
6653 | ead9360e | ths | get_float_exception_flags(&env->fpu->fp_status)); |
6654 | ead9360e | ths | fpu_fprintf(f, "FT0: "); printfpr(&env->fpu->ft0);
|
6655 | ead9360e | ths | fpu_fprintf(f, "FT1: "); printfpr(&env->fpu->ft1);
|
6656 | ead9360e | ths | fpu_fprintf(f, "FT2: "); printfpr(&env->fpu->ft2);
|
6657 | 5a5012ec | ths | for (i = 0; i < 32; (is_fpu64) ? i++ : (i += 2)) { |
6658 | 5a5012ec | ths | fpu_fprintf(f, "%3s: ", fregnames[i]);
|
6659 | ead9360e | ths | printfpr(&env->fpu->fpr[i]); |
6660 | 6ea83fed | bellard | } |
6661 | 6ea83fed | bellard | |
6662 | 6ea83fed | bellard | #undef printfpr
|
6663 | 6ea83fed | bellard | } |
6664 | 6ea83fed | bellard | |
6665 | 7a387fff | ths | void dump_fpu (CPUState *env)
|
6666 | 6ea83fed | bellard | { |
6667 | 5fafdf24 | ths | if (loglevel) {
|
6668 | 3594c774 | ths | fprintf(logfile, "pc=0x" TARGET_FMT_lx " HI=0x" TARGET_FMT_lx " LO=0x" TARGET_FMT_lx " ds %04x " TARGET_FMT_lx " %d\n", |
6669 | ead9360e | ths | env->PC[env->current_tc], env->HI[0][env->current_tc], env->LO[0][env->current_tc], env->hflags, env->btarget, env->bcond); |
6670 | 6ea83fed | bellard | fpu_dump_state(env, logfile, fprintf, 0);
|
6671 | 6ea83fed | bellard | } |
6672 | 6ea83fed | bellard | } |
6673 | 6ea83fed | bellard | |
6674 | 540635ba | ths | #if (defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)) && defined(MIPS_DEBUG_SIGN_EXTENSIONS)
|
6675 | c570fd16 | ths | /* Debug help: The architecture requires 32bit code to maintain proper
|
6676 | c570fd16 | ths | sign-extened values on 64bit machines. */
|
6677 | c570fd16 | ths | |
6678 | c570fd16 | ths | #define SIGN_EXT_P(val) ((((val) & ~0x7fffffff) == 0) || (((val) & ~0x7fffffff) == ~0x7fffffff)) |
6679 | c570fd16 | ths | |
6680 | c570fd16 | ths | void cpu_mips_check_sign_extensions (CPUState *env, FILE *f,
|
6681 | c570fd16 | ths | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
6682 | c570fd16 | ths | int flags)
|
6683 | c570fd16 | ths | { |
6684 | c570fd16 | ths | int i;
|
6685 | c570fd16 | ths | |
6686 | ead9360e | ths | if (!SIGN_EXT_P(env->PC[env->current_tc]))
|
6687 | ead9360e | ths | cpu_fprintf(f, "BROKEN: pc=0x" TARGET_FMT_lx "\n", env->PC[env->current_tc]); |
6688 | ead9360e | ths | if (!SIGN_EXT_P(env->HI[env->current_tc]))
|
6689 | ead9360e | ths | cpu_fprintf(f, "BROKEN: HI=0x" TARGET_FMT_lx "\n", env->HI[env->current_tc]); |
6690 | ead9360e | ths | if (!SIGN_EXT_P(env->LO[env->current_tc]))
|
6691 | ead9360e | ths | cpu_fprintf(f, "BROKEN: LO=0x" TARGET_FMT_lx "\n", env->LO[env->current_tc]); |
6692 | c570fd16 | ths | if (!SIGN_EXT_P(env->btarget))
|
6693 | 3594c774 | ths | cpu_fprintf(f, "BROKEN: btarget=0x" TARGET_FMT_lx "\n", env->btarget); |
6694 | c570fd16 | ths | |
6695 | c570fd16 | ths | for (i = 0; i < 32; i++) { |
6696 | ead9360e | ths | if (!SIGN_EXT_P(env->gpr[i][env->current_tc]))
|
6697 | ead9360e | ths | cpu_fprintf(f, "BROKEN: %s=0x" TARGET_FMT_lx "\n", regnames[i], env->gpr[i][env->current_tc]); |
6698 | c570fd16 | ths | } |
6699 | c570fd16 | ths | |
6700 | c570fd16 | ths | if (!SIGN_EXT_P(env->CP0_EPC))
|
6701 | 3594c774 | ths | cpu_fprintf(f, "BROKEN: EPC=0x" TARGET_FMT_lx "\n", env->CP0_EPC); |
6702 | c570fd16 | ths | if (!SIGN_EXT_P(env->CP0_LLAddr))
|
6703 | 3594c774 | ths | cpu_fprintf(f, "BROKEN: LLAddr=0x" TARGET_FMT_lx "\n", env->CP0_LLAddr); |
6704 | c570fd16 | ths | } |
6705 | c570fd16 | ths | #endif
|
6706 | c570fd16 | ths | |
6707 | 5fafdf24 | ths | void cpu_dump_state (CPUState *env, FILE *f,
|
6708 | 6af0bf9c | bellard | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
6709 | 6af0bf9c | bellard | int flags)
|
6710 | 6af0bf9c | bellard | { |
6711 | 6af0bf9c | bellard | int i;
|
6712 | 3b46e624 | ths | |
6713 | 3594c774 | ths | 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", |
6714 | ead9360e | ths | env->PC[env->current_tc], env->HI[env->current_tc], env->LO[env->current_tc], env->hflags, env->btarget, env->bcond); |
6715 | 6af0bf9c | bellard | for (i = 0; i < 32; i++) { |
6716 | 6af0bf9c | bellard | if ((i & 3) == 0) |
6717 | 6af0bf9c | bellard | cpu_fprintf(f, "GPR%02d:", i);
|
6718 | ead9360e | ths | cpu_fprintf(f, " %s " TARGET_FMT_lx, regnames[i], env->gpr[i][env->current_tc]);
|
6719 | 6af0bf9c | bellard | if ((i & 3) == 3) |
6720 | 6af0bf9c | bellard | cpu_fprintf(f, "\n");
|
6721 | 6af0bf9c | bellard | } |
6722 | 568b600d | bellard | |
6723 | 3594c774 | ths | cpu_fprintf(f, "CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_FMT_lx "\n", |
6724 | 5e755519 | ths | env->CP0_Status, env->CP0_Cause, env->CP0_EPC); |
6725 | 3594c774 | ths | cpu_fprintf(f, " Config0 0x%08x Config1 0x%08x LLAddr 0x" TARGET_FMT_lx "\n", |
6726 | 6af0bf9c | bellard | env->CP0_Config0, env->CP0_Config1, env->CP0_LLAddr); |
6727 | 5e755519 | ths | if (env->hflags & MIPS_HFLAG_FPU)
|
6728 | 7a387fff | ths | fpu_dump_state(env, f, cpu_fprintf, flags); |
6729 | 540635ba | ths | #if (defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)) && defined(MIPS_DEBUG_SIGN_EXTENSIONS)
|
6730 | c570fd16 | ths | cpu_mips_check_sign_extensions(env, f, cpu_fprintf, flags); |
6731 | c570fd16 | ths | #endif
|
6732 | 6af0bf9c | bellard | } |
6733 | 6af0bf9c | bellard | |
6734 | 6af0bf9c | bellard | CPUMIPSState *cpu_mips_init (void)
|
6735 | 6af0bf9c | bellard | { |
6736 | 6af0bf9c | bellard | CPUMIPSState *env; |
6737 | 6af0bf9c | bellard | |
6738 | 6af0bf9c | bellard | env = qemu_mallocz(sizeof(CPUMIPSState));
|
6739 | 6af0bf9c | bellard | if (!env)
|
6740 | 6af0bf9c | bellard | return NULL; |
6741 | 173d6cfe | bellard | cpu_exec_init(env); |
6742 | 6ae81775 | ths | cpu_reset(env); |
6743 | 6ae81775 | ths | return env;
|
6744 | 6ae81775 | ths | } |
6745 | 6ae81775 | ths | |
6746 | 6ae81775 | ths | void cpu_reset (CPUMIPSState *env)
|
6747 | 6ae81775 | ths | { |
6748 | 6ae81775 | ths | memset(env, 0, offsetof(CPUMIPSState, breakpoints));
|
6749 | 6ae81775 | ths | |
6750 | 6af0bf9c | bellard | tlb_flush(env, 1);
|
6751 | 6ae81775 | ths | |
6752 | 6af0bf9c | bellard | /* Minimal init */
|
6753 | ca7c2b1b | ths | #if !defined(CONFIG_USER_ONLY)
|
6754 | aa328add | ths | if (env->hflags & MIPS_HFLAG_BMASK) {
|
6755 | aa328add | ths | /* If the exception was raised from a delay slot,
|
6756 | aa328add | ths | * come back to the jump. */
|
6757 | ead9360e | ths | env->CP0_ErrorEPC = env->PC[env->current_tc] - 4;
|
6758 | aa328add | ths | } else {
|
6759 | ead9360e | ths | env->CP0_ErrorEPC = env->PC[env->current_tc]; |
6760 | aa328add | ths | } |
6761 | ead9360e | ths | env->PC[env->current_tc] = (int32_t)0xBFC00000;
|
6762 | 6af0bf9c | bellard | env->CP0_Wired = 0;
|
6763 | 7a387fff | ths | /* SMP not implemented */
|
6764 | b29a0341 | ths | env->CP0_EBase = 0x80000000;
|
6765 | aa328add | ths | env->CP0_Status = (1 << CP0St_BEV) | (1 << CP0St_ERL); |
6766 | c090a8f4 | ths | /* vectored interrupts not implemented, timer on int 7,
|
6767 | c090a8f4 | ths | no performance counters. */
|
6768 | c090a8f4 | ths | env->CP0_IntCtl = 0xe0000000;
|
6769 | fd88b6ab | ths | { |
6770 | fd88b6ab | ths | int i;
|
6771 | fd88b6ab | ths | |
6772 | fd88b6ab | ths | for (i = 0; i < 7; i++) { |
6773 | fd88b6ab | ths | env->CP0_WatchLo[i] = 0;
|
6774 | fd88b6ab | ths | env->CP0_WatchHi[i] = 0x80000000;
|
6775 | fd88b6ab | ths | } |
6776 | fd88b6ab | ths | env->CP0_WatchLo[7] = 0; |
6777 | fd88b6ab | ths | env->CP0_WatchHi[7] = 0; |
6778 | fd88b6ab | ths | } |
6779 | 6af0bf9c | bellard | /* Count register increments in debug mode, EJTAG version 1 */
|
6780 | 6af0bf9c | bellard | env->CP0_Debug = (1 << CP0DB_CNT) | (0x1 << CP0DB_VER); |
6781 | ca7c2b1b | ths | #endif
|
6782 | 6af0bf9c | bellard | env->exception_index = EXCP_NONE; |
6783 | eeef26cd | bellard | #if defined(CONFIG_USER_ONLY)
|
6784 | 387a8fe5 | ths | env->hflags = MIPS_HFLAG_UM; |
6785 | ca7c2b1b | ths | env->user_mode_only = 1;
|
6786 | 387a8fe5 | ths | #else
|
6787 | 387a8fe5 | ths | env->hflags = MIPS_HFLAG_CP0; |
6788 | eeef26cd | bellard | #endif
|
6789 | 6af0bf9c | bellard | } |
6790 | 33d68b5f | ths | |
6791 | 33d68b5f | ths | #include "translate_init.c" |