root / target-mips / translate.c @ cdc0faa6
History | View | Annotate | Download (245 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 | fad6cb1a | aurel32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 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 | 57fec1fe | bellard | #include "tcg-op.h" |
33 | ca10f867 | aurel32 | #include "qemu-common.h" |
34 | 6af0bf9c | bellard | |
35 | a7812ae4 | pbrook | #include "helper.h" |
36 | a7812ae4 | pbrook | #define GEN_HELPER 1 |
37 | a7812ae4 | pbrook | #include "helper.h" |
38 | a7812ae4 | pbrook | |
39 | eeef26cd | bellard | //#define MIPS_DEBUG_DISAS
|
40 | c570fd16 | ths | //#define MIPS_DEBUG_SIGN_EXTENSIONS
|
41 | 6af0bf9c | bellard | //#define MIPS_SINGLE_STEP
|
42 | 6af0bf9c | bellard | |
43 | 7a387fff | ths | /* MIPS major opcodes */
|
44 | 7a387fff | ths | #define MASK_OP_MAJOR(op) (op & (0x3F << 26)) |
45 | e37e863f | bellard | |
46 | e37e863f | bellard | enum {
|
47 | e37e863f | bellard | /* indirect opcode tables */
|
48 | 7a387fff | ths | OPC_SPECIAL = (0x00 << 26), |
49 | 7a387fff | ths | OPC_REGIMM = (0x01 << 26), |
50 | 7a387fff | ths | OPC_CP0 = (0x10 << 26), |
51 | 7a387fff | ths | OPC_CP1 = (0x11 << 26), |
52 | 7a387fff | ths | OPC_CP2 = (0x12 << 26), |
53 | 7a387fff | ths | OPC_CP3 = (0x13 << 26), |
54 | 7a387fff | ths | OPC_SPECIAL2 = (0x1C << 26), |
55 | 7a387fff | ths | OPC_SPECIAL3 = (0x1F << 26), |
56 | e37e863f | bellard | /* arithmetic with immediate */
|
57 | 7a387fff | ths | OPC_ADDI = (0x08 << 26), |
58 | 7a387fff | ths | OPC_ADDIU = (0x09 << 26), |
59 | 7a387fff | ths | OPC_SLTI = (0x0A << 26), |
60 | 7a387fff | ths | OPC_SLTIU = (0x0B << 26), |
61 | 7a387fff | ths | OPC_ANDI = (0x0C << 26), |
62 | 7a387fff | ths | OPC_ORI = (0x0D << 26), |
63 | 7a387fff | ths | OPC_XORI = (0x0E << 26), |
64 | 7a387fff | ths | OPC_LUI = (0x0F << 26), |
65 | 7a387fff | ths | OPC_DADDI = (0x18 << 26), |
66 | 7a387fff | ths | OPC_DADDIU = (0x19 << 26), |
67 | e37e863f | bellard | /* Jump and branches */
|
68 | 7a387fff | ths | OPC_J = (0x02 << 26), |
69 | 7a387fff | ths | OPC_JAL = (0x03 << 26), |
70 | 7a387fff | ths | OPC_BEQ = (0x04 << 26), /* Unconditional if rs = rt = 0 (B) */ |
71 | 7a387fff | ths | OPC_BEQL = (0x14 << 26), |
72 | 7a387fff | ths | OPC_BNE = (0x05 << 26), |
73 | 7a387fff | ths | OPC_BNEL = (0x15 << 26), |
74 | 7a387fff | ths | OPC_BLEZ = (0x06 << 26), |
75 | 7a387fff | ths | OPC_BLEZL = (0x16 << 26), |
76 | 7a387fff | ths | OPC_BGTZ = (0x07 << 26), |
77 | 7a387fff | ths | OPC_BGTZL = (0x17 << 26), |
78 | 7a387fff | ths | OPC_JALX = (0x1D << 26), /* MIPS 16 only */ |
79 | e37e863f | bellard | /* Load and stores */
|
80 | 7a387fff | ths | OPC_LDL = (0x1A << 26), |
81 | 7a387fff | ths | OPC_LDR = (0x1B << 26), |
82 | 7a387fff | ths | OPC_LB = (0x20 << 26), |
83 | 7a387fff | ths | OPC_LH = (0x21 << 26), |
84 | 7a387fff | ths | OPC_LWL = (0x22 << 26), |
85 | 7a387fff | ths | OPC_LW = (0x23 << 26), |
86 | 7a387fff | ths | OPC_LBU = (0x24 << 26), |
87 | 7a387fff | ths | OPC_LHU = (0x25 << 26), |
88 | 7a387fff | ths | OPC_LWR = (0x26 << 26), |
89 | 7a387fff | ths | OPC_LWU = (0x27 << 26), |
90 | 7a387fff | ths | OPC_SB = (0x28 << 26), |
91 | 7a387fff | ths | OPC_SH = (0x29 << 26), |
92 | 7a387fff | ths | OPC_SWL = (0x2A << 26), |
93 | 7a387fff | ths | OPC_SW = (0x2B << 26), |
94 | 7a387fff | ths | OPC_SDL = (0x2C << 26), |
95 | 7a387fff | ths | OPC_SDR = (0x2D << 26), |
96 | 7a387fff | ths | OPC_SWR = (0x2E << 26), |
97 | 7a387fff | ths | OPC_LL = (0x30 << 26), |
98 | 7a387fff | ths | OPC_LLD = (0x34 << 26), |
99 | 7a387fff | ths | OPC_LD = (0x37 << 26), |
100 | 7a387fff | ths | OPC_SC = (0x38 << 26), |
101 | 7a387fff | ths | OPC_SCD = (0x3C << 26), |
102 | 7a387fff | ths | OPC_SD = (0x3F << 26), |
103 | e37e863f | bellard | /* Floating point load/store */
|
104 | 7a387fff | ths | OPC_LWC1 = (0x31 << 26), |
105 | 7a387fff | ths | OPC_LWC2 = (0x32 << 26), |
106 | 7a387fff | ths | OPC_LDC1 = (0x35 << 26), |
107 | 7a387fff | ths | OPC_LDC2 = (0x36 << 26), |
108 | 7a387fff | ths | OPC_SWC1 = (0x39 << 26), |
109 | 7a387fff | ths | OPC_SWC2 = (0x3A << 26), |
110 | 7a387fff | ths | OPC_SDC1 = (0x3D << 26), |
111 | 7a387fff | ths | OPC_SDC2 = (0x3E << 26), |
112 | 7a387fff | ths | /* MDMX ASE specific */
|
113 | 7a387fff | ths | OPC_MDMX = (0x1E << 26), |
114 | e37e863f | bellard | /* Cache and prefetch */
|
115 | 7a387fff | ths | OPC_CACHE = (0x2F << 26), |
116 | 7a387fff | ths | OPC_PREF = (0x33 << 26), |
117 | 7a387fff | ths | /* Reserved major opcode */
|
118 | 7a387fff | ths | OPC_MAJOR3B_RESERVED = (0x3B << 26), |
119 | e37e863f | bellard | }; |
120 | e37e863f | bellard | |
121 | e37e863f | bellard | /* MIPS special opcodes */
|
122 | 7a387fff | ths | #define MASK_SPECIAL(op) MASK_OP_MAJOR(op) | (op & 0x3F) |
123 | 7a387fff | ths | |
124 | e37e863f | bellard | enum {
|
125 | e37e863f | bellard | /* Shifts */
|
126 | 7a387fff | ths | OPC_SLL = 0x00 | OPC_SPECIAL,
|
127 | e37e863f | bellard | /* NOP is SLL r0, r0, 0 */
|
128 | e37e863f | bellard | /* SSNOP is SLL r0, r0, 1 */
|
129 | 7a387fff | ths | /* EHB is SLL r0, r0, 3 */
|
130 | 7a387fff | ths | OPC_SRL = 0x02 | OPC_SPECIAL, /* also ROTR */ |
131 | 7a387fff | ths | OPC_SRA = 0x03 | OPC_SPECIAL,
|
132 | 7a387fff | ths | OPC_SLLV = 0x04 | OPC_SPECIAL,
|
133 | e189e748 | ths | OPC_SRLV = 0x06 | OPC_SPECIAL, /* also ROTRV */ |
134 | 7a387fff | ths | OPC_SRAV = 0x07 | OPC_SPECIAL,
|
135 | 7a387fff | ths | OPC_DSLLV = 0x14 | OPC_SPECIAL,
|
136 | 7a387fff | ths | OPC_DSRLV = 0x16 | OPC_SPECIAL, /* also DROTRV */ |
137 | 7a387fff | ths | OPC_DSRAV = 0x17 | OPC_SPECIAL,
|
138 | 7a387fff | ths | OPC_DSLL = 0x38 | OPC_SPECIAL,
|
139 | 7a387fff | ths | OPC_DSRL = 0x3A | OPC_SPECIAL, /* also DROTR */ |
140 | 7a387fff | ths | OPC_DSRA = 0x3B | OPC_SPECIAL,
|
141 | 7a387fff | ths | OPC_DSLL32 = 0x3C | OPC_SPECIAL,
|
142 | 7a387fff | ths | OPC_DSRL32 = 0x3E | OPC_SPECIAL, /* also DROTR32 */ |
143 | 7a387fff | ths | OPC_DSRA32 = 0x3F | OPC_SPECIAL,
|
144 | e37e863f | bellard | /* Multiplication / division */
|
145 | 7a387fff | ths | OPC_MULT = 0x18 | OPC_SPECIAL,
|
146 | 7a387fff | ths | OPC_MULTU = 0x19 | OPC_SPECIAL,
|
147 | 7a387fff | ths | OPC_DIV = 0x1A | OPC_SPECIAL,
|
148 | 7a387fff | ths | OPC_DIVU = 0x1B | OPC_SPECIAL,
|
149 | 7a387fff | ths | OPC_DMULT = 0x1C | OPC_SPECIAL,
|
150 | 7a387fff | ths | OPC_DMULTU = 0x1D | OPC_SPECIAL,
|
151 | 7a387fff | ths | OPC_DDIV = 0x1E | OPC_SPECIAL,
|
152 | 7a387fff | ths | OPC_DDIVU = 0x1F | OPC_SPECIAL,
|
153 | e37e863f | bellard | /* 2 registers arithmetic / logic */
|
154 | 7a387fff | ths | OPC_ADD = 0x20 | OPC_SPECIAL,
|
155 | 7a387fff | ths | OPC_ADDU = 0x21 | OPC_SPECIAL,
|
156 | 7a387fff | ths | OPC_SUB = 0x22 | OPC_SPECIAL,
|
157 | 7a387fff | ths | OPC_SUBU = 0x23 | OPC_SPECIAL,
|
158 | 7a387fff | ths | OPC_AND = 0x24 | OPC_SPECIAL,
|
159 | 7a387fff | ths | OPC_OR = 0x25 | OPC_SPECIAL,
|
160 | 7a387fff | ths | OPC_XOR = 0x26 | OPC_SPECIAL,
|
161 | 7a387fff | ths | OPC_NOR = 0x27 | OPC_SPECIAL,
|
162 | 7a387fff | ths | OPC_SLT = 0x2A | OPC_SPECIAL,
|
163 | 7a387fff | ths | OPC_SLTU = 0x2B | OPC_SPECIAL,
|
164 | 7a387fff | ths | OPC_DADD = 0x2C | OPC_SPECIAL,
|
165 | 7a387fff | ths | OPC_DADDU = 0x2D | OPC_SPECIAL,
|
166 | 7a387fff | ths | OPC_DSUB = 0x2E | OPC_SPECIAL,
|
167 | 7a387fff | ths | OPC_DSUBU = 0x2F | OPC_SPECIAL,
|
168 | e37e863f | bellard | /* Jumps */
|
169 | 7a387fff | ths | OPC_JR = 0x08 | OPC_SPECIAL, /* Also JR.HB */ |
170 | 7a387fff | ths | OPC_JALR = 0x09 | OPC_SPECIAL, /* Also JALR.HB */ |
171 | e37e863f | bellard | /* Traps */
|
172 | 7a387fff | ths | OPC_TGE = 0x30 | OPC_SPECIAL,
|
173 | 7a387fff | ths | OPC_TGEU = 0x31 | OPC_SPECIAL,
|
174 | 7a387fff | ths | OPC_TLT = 0x32 | OPC_SPECIAL,
|
175 | 7a387fff | ths | OPC_TLTU = 0x33 | OPC_SPECIAL,
|
176 | 7a387fff | ths | OPC_TEQ = 0x34 | OPC_SPECIAL,
|
177 | 7a387fff | ths | OPC_TNE = 0x36 | OPC_SPECIAL,
|
178 | e37e863f | bellard | /* HI / LO registers load & stores */
|
179 | 7a387fff | ths | OPC_MFHI = 0x10 | OPC_SPECIAL,
|
180 | 7a387fff | ths | OPC_MTHI = 0x11 | OPC_SPECIAL,
|
181 | 7a387fff | ths | OPC_MFLO = 0x12 | OPC_SPECIAL,
|
182 | 7a387fff | ths | OPC_MTLO = 0x13 | OPC_SPECIAL,
|
183 | e37e863f | bellard | /* Conditional moves */
|
184 | 7a387fff | ths | OPC_MOVZ = 0x0A | OPC_SPECIAL,
|
185 | 7a387fff | ths | OPC_MOVN = 0x0B | OPC_SPECIAL,
|
186 | e37e863f | bellard | |
187 | 7a387fff | ths | OPC_MOVCI = 0x01 | OPC_SPECIAL,
|
188 | e37e863f | bellard | |
189 | e37e863f | bellard | /* Special */
|
190 | 7a387fff | ths | OPC_PMON = 0x05 | OPC_SPECIAL, /* inofficial */ |
191 | 7a387fff | ths | OPC_SYSCALL = 0x0C | OPC_SPECIAL,
|
192 | 7a387fff | ths | OPC_BREAK = 0x0D | OPC_SPECIAL,
|
193 | 7a387fff | ths | OPC_SPIM = 0x0E | OPC_SPECIAL, /* inofficial */ |
194 | 7a387fff | ths | OPC_SYNC = 0x0F | OPC_SPECIAL,
|
195 | 7a387fff | ths | |
196 | 7a387fff | ths | OPC_SPECIAL15_RESERVED = 0x15 | OPC_SPECIAL,
|
197 | 7a387fff | ths | OPC_SPECIAL28_RESERVED = 0x28 | OPC_SPECIAL,
|
198 | 7a387fff | ths | OPC_SPECIAL29_RESERVED = 0x29 | OPC_SPECIAL,
|
199 | 7a387fff | ths | OPC_SPECIAL35_RESERVED = 0x35 | OPC_SPECIAL,
|
200 | 7a387fff | ths | OPC_SPECIAL37_RESERVED = 0x37 | OPC_SPECIAL,
|
201 | 7a387fff | ths | OPC_SPECIAL39_RESERVED = 0x39 | OPC_SPECIAL,
|
202 | 7a387fff | ths | OPC_SPECIAL3D_RESERVED = 0x3D | OPC_SPECIAL,
|
203 | 7a387fff | ths | }; |
204 | 7a387fff | ths | |
205 | e9c71dd1 | ths | /* Multiplication variants of the vr54xx. */
|
206 | e9c71dd1 | ths | #define MASK_MUL_VR54XX(op) MASK_SPECIAL(op) | (op & (0x1F << 6)) |
207 | e9c71dd1 | ths | |
208 | e9c71dd1 | ths | enum {
|
209 | e9c71dd1 | ths | OPC_VR54XX_MULS = (0x03 << 6) | OPC_MULT, |
210 | e9c71dd1 | ths | OPC_VR54XX_MULSU = (0x03 << 6) | OPC_MULTU, |
211 | e9c71dd1 | ths | OPC_VR54XX_MACC = (0x05 << 6) | OPC_MULT, |
212 | e9c71dd1 | ths | OPC_VR54XX_MACCU = (0x05 << 6) | OPC_MULTU, |
213 | e9c71dd1 | ths | OPC_VR54XX_MSAC = (0x07 << 6) | OPC_MULT, |
214 | e9c71dd1 | ths | OPC_VR54XX_MSACU = (0x07 << 6) | OPC_MULTU, |
215 | e9c71dd1 | ths | OPC_VR54XX_MULHI = (0x09 << 6) | OPC_MULT, |
216 | e9c71dd1 | ths | OPC_VR54XX_MULHIU = (0x09 << 6) | OPC_MULTU, |
217 | e9c71dd1 | ths | OPC_VR54XX_MULSHI = (0x0B << 6) | OPC_MULT, |
218 | e9c71dd1 | ths | OPC_VR54XX_MULSHIU = (0x0B << 6) | OPC_MULTU, |
219 | e9c71dd1 | ths | OPC_VR54XX_MACCHI = (0x0D << 6) | OPC_MULT, |
220 | e9c71dd1 | ths | OPC_VR54XX_MACCHIU = (0x0D << 6) | OPC_MULTU, |
221 | e9c71dd1 | ths | OPC_VR54XX_MSACHI = (0x0F << 6) | OPC_MULT, |
222 | e9c71dd1 | ths | OPC_VR54XX_MSACHIU = (0x0F << 6) | OPC_MULTU, |
223 | e9c71dd1 | ths | }; |
224 | e9c71dd1 | ths | |
225 | 7a387fff | ths | /* REGIMM (rt field) opcodes */
|
226 | 7a387fff | ths | #define MASK_REGIMM(op) MASK_OP_MAJOR(op) | (op & (0x1F << 16)) |
227 | 7a387fff | ths | |
228 | 7a387fff | ths | enum {
|
229 | 7a387fff | ths | OPC_BLTZ = (0x00 << 16) | OPC_REGIMM, |
230 | 7a387fff | ths | OPC_BLTZL = (0x02 << 16) | OPC_REGIMM, |
231 | 7a387fff | ths | OPC_BGEZ = (0x01 << 16) | OPC_REGIMM, |
232 | 7a387fff | ths | OPC_BGEZL = (0x03 << 16) | OPC_REGIMM, |
233 | 7a387fff | ths | OPC_BLTZAL = (0x10 << 16) | OPC_REGIMM, |
234 | 7a387fff | ths | OPC_BLTZALL = (0x12 << 16) | OPC_REGIMM, |
235 | 7a387fff | ths | OPC_BGEZAL = (0x11 << 16) | OPC_REGIMM, |
236 | 7a387fff | ths | OPC_BGEZALL = (0x13 << 16) | OPC_REGIMM, |
237 | 7a387fff | ths | OPC_TGEI = (0x08 << 16) | OPC_REGIMM, |
238 | 7a387fff | ths | OPC_TGEIU = (0x09 << 16) | OPC_REGIMM, |
239 | 7a387fff | ths | OPC_TLTI = (0x0A << 16) | OPC_REGIMM, |
240 | 7a387fff | ths | OPC_TLTIU = (0x0B << 16) | OPC_REGIMM, |
241 | 7a387fff | ths | OPC_TEQI = (0x0C << 16) | OPC_REGIMM, |
242 | 7a387fff | ths | OPC_TNEI = (0x0E << 16) | OPC_REGIMM, |
243 | 7a387fff | ths | OPC_SYNCI = (0x1F << 16) | OPC_REGIMM, |
244 | e37e863f | bellard | }; |
245 | e37e863f | bellard | |
246 | 7a387fff | ths | /* Special2 opcodes */
|
247 | 7a387fff | ths | #define MASK_SPECIAL2(op) MASK_OP_MAJOR(op) | (op & 0x3F) |
248 | 7a387fff | ths | |
249 | e37e863f | bellard | enum {
|
250 | 7a387fff | ths | /* Multiply & xxx operations */
|
251 | 7a387fff | ths | OPC_MADD = 0x00 | OPC_SPECIAL2,
|
252 | 7a387fff | ths | OPC_MADDU = 0x01 | OPC_SPECIAL2,
|
253 | 7a387fff | ths | OPC_MUL = 0x02 | OPC_SPECIAL2,
|
254 | 7a387fff | ths | OPC_MSUB = 0x04 | OPC_SPECIAL2,
|
255 | 7a387fff | ths | OPC_MSUBU = 0x05 | OPC_SPECIAL2,
|
256 | e37e863f | bellard | /* Misc */
|
257 | 7a387fff | ths | OPC_CLZ = 0x20 | OPC_SPECIAL2,
|
258 | 7a387fff | ths | OPC_CLO = 0x21 | OPC_SPECIAL2,
|
259 | 7a387fff | ths | OPC_DCLZ = 0x24 | OPC_SPECIAL2,
|
260 | 7a387fff | ths | OPC_DCLO = 0x25 | OPC_SPECIAL2,
|
261 | e37e863f | bellard | /* Special */
|
262 | 7a387fff | ths | OPC_SDBBP = 0x3F | OPC_SPECIAL2,
|
263 | 7a387fff | ths | }; |
264 | 7a387fff | ths | |
265 | 7a387fff | ths | /* Special3 opcodes */
|
266 | 7a387fff | ths | #define MASK_SPECIAL3(op) MASK_OP_MAJOR(op) | (op & 0x3F) |
267 | 7a387fff | ths | |
268 | 7a387fff | ths | enum {
|
269 | 7a387fff | ths | OPC_EXT = 0x00 | OPC_SPECIAL3,
|
270 | 7a387fff | ths | OPC_DEXTM = 0x01 | OPC_SPECIAL3,
|
271 | 7a387fff | ths | OPC_DEXTU = 0x02 | OPC_SPECIAL3,
|
272 | 7a387fff | ths | OPC_DEXT = 0x03 | OPC_SPECIAL3,
|
273 | 7a387fff | ths | OPC_INS = 0x04 | OPC_SPECIAL3,
|
274 | 7a387fff | ths | OPC_DINSM = 0x05 | OPC_SPECIAL3,
|
275 | 7a387fff | ths | OPC_DINSU = 0x06 | OPC_SPECIAL3,
|
276 | 7a387fff | ths | OPC_DINS = 0x07 | OPC_SPECIAL3,
|
277 | ead9360e | ths | OPC_FORK = 0x08 | OPC_SPECIAL3,
|
278 | ead9360e | ths | OPC_YIELD = 0x09 | OPC_SPECIAL3,
|
279 | 7a387fff | ths | OPC_BSHFL = 0x20 | OPC_SPECIAL3,
|
280 | 7a387fff | ths | OPC_DBSHFL = 0x24 | OPC_SPECIAL3,
|
281 | 7a387fff | ths | OPC_RDHWR = 0x3B | OPC_SPECIAL3,
|
282 | e37e863f | bellard | }; |
283 | e37e863f | bellard | |
284 | 7a387fff | ths | /* BSHFL opcodes */
|
285 | 7a387fff | ths | #define MASK_BSHFL(op) MASK_SPECIAL3(op) | (op & (0x1F << 6)) |
286 | 7a387fff | ths | |
287 | e37e863f | bellard | enum {
|
288 | 7a387fff | ths | OPC_WSBH = (0x02 << 6) | OPC_BSHFL, |
289 | 7a387fff | ths | OPC_SEB = (0x10 << 6) | OPC_BSHFL, |
290 | 7a387fff | ths | OPC_SEH = (0x18 << 6) | OPC_BSHFL, |
291 | e37e863f | bellard | }; |
292 | e37e863f | bellard | |
293 | 7a387fff | ths | /* DBSHFL opcodes */
|
294 | 7a387fff | ths | #define MASK_DBSHFL(op) MASK_SPECIAL3(op) | (op & (0x1F << 6)) |
295 | 7a387fff | ths | |
296 | e37e863f | bellard | enum {
|
297 | 7a387fff | ths | OPC_DSBH = (0x02 << 6) | OPC_DBSHFL, |
298 | 7a387fff | ths | OPC_DSHD = (0x05 << 6) | OPC_DBSHFL, |
299 | e37e863f | bellard | }; |
300 | e37e863f | bellard | |
301 | 7a387fff | ths | /* Coprocessor 0 (rs field) */
|
302 | 7a387fff | ths | #define MASK_CP0(op) MASK_OP_MAJOR(op) | (op & (0x1F << 21)) |
303 | 7a387fff | ths | |
304 | 6ea83fed | bellard | enum {
|
305 | 7a387fff | ths | OPC_MFC0 = (0x00 << 21) | OPC_CP0, |
306 | 7a387fff | ths | OPC_DMFC0 = (0x01 << 21) | OPC_CP0, |
307 | 7a387fff | ths | OPC_MTC0 = (0x04 << 21) | OPC_CP0, |
308 | 7a387fff | ths | OPC_DMTC0 = (0x05 << 21) | OPC_CP0, |
309 | ead9360e | ths | OPC_MFTR = (0x08 << 21) | OPC_CP0, |
310 | 7a387fff | ths | OPC_RDPGPR = (0x0A << 21) | OPC_CP0, |
311 | 7a387fff | ths | OPC_MFMC0 = (0x0B << 21) | OPC_CP0, |
312 | ead9360e | ths | OPC_MTTR = (0x0C << 21) | OPC_CP0, |
313 | 7a387fff | ths | OPC_WRPGPR = (0x0E << 21) | OPC_CP0, |
314 | 7a387fff | ths | OPC_C0 = (0x10 << 21) | OPC_CP0, |
315 | 7a387fff | ths | OPC_C0_FIRST = (0x10 << 21) | OPC_CP0, |
316 | 7a387fff | ths | OPC_C0_LAST = (0x1F << 21) | OPC_CP0, |
317 | 6ea83fed | bellard | }; |
318 | 7a387fff | ths | |
319 | 7a387fff | ths | /* MFMC0 opcodes */
|
320 | b48cfdff | ths | #define MASK_MFMC0(op) MASK_CP0(op) | (op & 0xFFFF) |
321 | 7a387fff | ths | |
322 | 7a387fff | ths | enum {
|
323 | ead9360e | ths | OPC_DMT = 0x01 | (0 << 5) | (0x0F << 6) | (0x01 << 11) | OPC_MFMC0, |
324 | ead9360e | ths | OPC_EMT = 0x01 | (1 << 5) | (0x0F << 6) | (0x01 << 11) | OPC_MFMC0, |
325 | ead9360e | ths | OPC_DVPE = 0x01 | (0 << 5) | OPC_MFMC0, |
326 | ead9360e | ths | OPC_EVPE = 0x01 | (1 << 5) | OPC_MFMC0, |
327 | 7a387fff | ths | OPC_DI = (0 << 5) | (0x0C << 11) | OPC_MFMC0, |
328 | 7a387fff | ths | OPC_EI = (1 << 5) | (0x0C << 11) | OPC_MFMC0, |
329 | 7a387fff | ths | }; |
330 | 7a387fff | ths | |
331 | 7a387fff | ths | /* Coprocessor 0 (with rs == C0) */
|
332 | 7a387fff | ths | #define MASK_C0(op) MASK_CP0(op) | (op & 0x3F) |
333 | 7a387fff | ths | |
334 | 7a387fff | ths | enum {
|
335 | 7a387fff | ths | OPC_TLBR = 0x01 | OPC_C0,
|
336 | 7a387fff | ths | OPC_TLBWI = 0x02 | OPC_C0,
|
337 | 7a387fff | ths | OPC_TLBWR = 0x06 | OPC_C0,
|
338 | 7a387fff | ths | OPC_TLBP = 0x08 | OPC_C0,
|
339 | 7a387fff | ths | OPC_RFE = 0x10 | OPC_C0,
|
340 | 7a387fff | ths | OPC_ERET = 0x18 | OPC_C0,
|
341 | 7a387fff | ths | OPC_DERET = 0x1F | OPC_C0,
|
342 | 7a387fff | ths | OPC_WAIT = 0x20 | OPC_C0,
|
343 | 7a387fff | ths | }; |
344 | 7a387fff | ths | |
345 | 7a387fff | ths | /* Coprocessor 1 (rs field) */
|
346 | 7a387fff | ths | #define MASK_CP1(op) MASK_OP_MAJOR(op) | (op & (0x1F << 21)) |
347 | 7a387fff | ths | |
348 | 7a387fff | ths | enum {
|
349 | 7a387fff | ths | OPC_MFC1 = (0x00 << 21) | OPC_CP1, |
350 | 7a387fff | ths | OPC_DMFC1 = (0x01 << 21) | OPC_CP1, |
351 | 7a387fff | ths | OPC_CFC1 = (0x02 << 21) | OPC_CP1, |
352 | 5a5012ec | ths | OPC_MFHC1 = (0x03 << 21) | OPC_CP1, |
353 | 7a387fff | ths | OPC_MTC1 = (0x04 << 21) | OPC_CP1, |
354 | 7a387fff | ths | OPC_DMTC1 = (0x05 << 21) | OPC_CP1, |
355 | 7a387fff | ths | OPC_CTC1 = (0x06 << 21) | OPC_CP1, |
356 | 5a5012ec | ths | OPC_MTHC1 = (0x07 << 21) | OPC_CP1, |
357 | 7a387fff | ths | OPC_BC1 = (0x08 << 21) | OPC_CP1, /* bc */ |
358 | 5a5012ec | ths | OPC_BC1ANY2 = (0x09 << 21) | OPC_CP1, |
359 | 5a5012ec | ths | OPC_BC1ANY4 = (0x0A << 21) | OPC_CP1, |
360 | 7a387fff | ths | OPC_S_FMT = (0x10 << 21) | OPC_CP1, /* 16: fmt=single fp */ |
361 | 7a387fff | ths | OPC_D_FMT = (0x11 << 21) | OPC_CP1, /* 17: fmt=double fp */ |
362 | 7a387fff | ths | OPC_E_FMT = (0x12 << 21) | OPC_CP1, /* 18: fmt=extended fp */ |
363 | 7a387fff | ths | OPC_Q_FMT = (0x13 << 21) | OPC_CP1, /* 19: fmt=quad fp */ |
364 | 7a387fff | ths | OPC_W_FMT = (0x14 << 21) | OPC_CP1, /* 20: fmt=32bit fixed */ |
365 | 7a387fff | ths | OPC_L_FMT = (0x15 << 21) | OPC_CP1, /* 21: fmt=64bit fixed */ |
366 | 5a5012ec | ths | OPC_PS_FMT = (0x16 << 21) | OPC_CP1, /* 22: fmt=paired single fp */ |
367 | 7a387fff | ths | }; |
368 | 7a387fff | ths | |
369 | 5a5012ec | ths | #define MASK_CP1_FUNC(op) MASK_CP1(op) | (op & 0x3F) |
370 | 5a5012ec | ths | #define MASK_BC1(op) MASK_CP1(op) | (op & (0x3 << 16)) |
371 | 5a5012ec | ths | |
372 | 7a387fff | ths | enum {
|
373 | 7a387fff | ths | OPC_BC1F = (0x00 << 16) | OPC_BC1, |
374 | 7a387fff | ths | OPC_BC1T = (0x01 << 16) | OPC_BC1, |
375 | 7a387fff | ths | OPC_BC1FL = (0x02 << 16) | OPC_BC1, |
376 | 7a387fff | ths | OPC_BC1TL = (0x03 << 16) | OPC_BC1, |
377 | 7a387fff | ths | }; |
378 | 7a387fff | ths | |
379 | 5a5012ec | ths | enum {
|
380 | 5a5012ec | ths | OPC_BC1FANY2 = (0x00 << 16) | OPC_BC1ANY2, |
381 | 5a5012ec | ths | OPC_BC1TANY2 = (0x01 << 16) | OPC_BC1ANY2, |
382 | 5a5012ec | ths | }; |
383 | 5a5012ec | ths | |
384 | 5a5012ec | ths | enum {
|
385 | 5a5012ec | ths | OPC_BC1FANY4 = (0x00 << 16) | OPC_BC1ANY4, |
386 | 5a5012ec | ths | OPC_BC1TANY4 = (0x01 << 16) | OPC_BC1ANY4, |
387 | 5a5012ec | ths | }; |
388 | 7a387fff | ths | |
389 | 7a387fff | ths | #define MASK_CP2(op) MASK_OP_MAJOR(op) | (op & (0x1F << 21)) |
390 | e0c84da7 | ths | |
391 | e0c84da7 | ths | enum {
|
392 | e0c84da7 | ths | OPC_MFC2 = (0x00 << 21) | OPC_CP2, |
393 | e0c84da7 | ths | OPC_DMFC2 = (0x01 << 21) | OPC_CP2, |
394 | e0c84da7 | ths | OPC_CFC2 = (0x02 << 21) | OPC_CP2, |
395 | e0c84da7 | ths | OPC_MFHC2 = (0x03 << 21) | OPC_CP2, |
396 | e0c84da7 | ths | OPC_MTC2 = (0x04 << 21) | OPC_CP2, |
397 | e0c84da7 | ths | OPC_DMTC2 = (0x05 << 21) | OPC_CP2, |
398 | e0c84da7 | ths | OPC_CTC2 = (0x06 << 21) | OPC_CP2, |
399 | e0c84da7 | ths | OPC_MTHC2 = (0x07 << 21) | OPC_CP2, |
400 | e0c84da7 | ths | OPC_BC2 = (0x08 << 21) | OPC_CP2, |
401 | e0c84da7 | ths | }; |
402 | e0c84da7 | ths | |
403 | e0c84da7 | ths | #define MASK_CP3(op) MASK_OP_MAJOR(op) | (op & 0x3F) |
404 | e0c84da7 | ths | |
405 | e0c84da7 | ths | enum {
|
406 | e0c84da7 | ths | OPC_LWXC1 = 0x00 | OPC_CP3,
|
407 | e0c84da7 | ths | OPC_LDXC1 = 0x01 | OPC_CP3,
|
408 | e0c84da7 | ths | OPC_LUXC1 = 0x05 | OPC_CP3,
|
409 | e0c84da7 | ths | OPC_SWXC1 = 0x08 | OPC_CP3,
|
410 | e0c84da7 | ths | OPC_SDXC1 = 0x09 | OPC_CP3,
|
411 | e0c84da7 | ths | OPC_SUXC1 = 0x0D | OPC_CP3,
|
412 | e0c84da7 | ths | OPC_PREFX = 0x0F | OPC_CP3,
|
413 | e0c84da7 | ths | OPC_ALNV_PS = 0x1E | OPC_CP3,
|
414 | e0c84da7 | ths | OPC_MADD_S = 0x20 | OPC_CP3,
|
415 | e0c84da7 | ths | OPC_MADD_D = 0x21 | OPC_CP3,
|
416 | e0c84da7 | ths | OPC_MADD_PS = 0x26 | OPC_CP3,
|
417 | e0c84da7 | ths | OPC_MSUB_S = 0x28 | OPC_CP3,
|
418 | e0c84da7 | ths | OPC_MSUB_D = 0x29 | OPC_CP3,
|
419 | e0c84da7 | ths | OPC_MSUB_PS = 0x2E | OPC_CP3,
|
420 | e0c84da7 | ths | OPC_NMADD_S = 0x30 | OPC_CP3,
|
421 | fbcc6828 | ths | OPC_NMADD_D = 0x31 | OPC_CP3,
|
422 | e0c84da7 | ths | OPC_NMADD_PS= 0x36 | OPC_CP3,
|
423 | e0c84da7 | ths | OPC_NMSUB_S = 0x38 | OPC_CP3,
|
424 | e0c84da7 | ths | OPC_NMSUB_D = 0x39 | OPC_CP3,
|
425 | e0c84da7 | ths | OPC_NMSUB_PS= 0x3E | OPC_CP3,
|
426 | e0c84da7 | ths | }; |
427 | e0c84da7 | ths | |
428 | 39454628 | ths | /* global register indices */
|
429 | a7812ae4 | pbrook | static TCGv_ptr cpu_env;
|
430 | a7812ae4 | pbrook | static TCGv cpu_gpr[32], cpu_PC; |
431 | 4b2eb8d2 | ths | static TCGv cpu_HI[MIPS_DSP_ACC], cpu_LO[MIPS_DSP_ACC], cpu_ACX[MIPS_DSP_ACC];
|
432 | a7812ae4 | pbrook | static TCGv cpu_dspctrl, btarget;
|
433 | 1ba74fb8 | aurel32 | static TCGv bcond;
|
434 | a7812ae4 | pbrook | static TCGv_i32 fpu_fpr32[32], fpu_fpr32h[32]; |
435 | a7812ae4 | pbrook | static TCGv_i32 fpu_fcr0, fpu_fcr31;
|
436 | aa0bf00b | ths | |
437 | 2e70f6ef | pbrook | #include "gen-icount.h" |
438 | 2e70f6ef | pbrook | |
439 | a7812ae4 | pbrook | #define gen_helper_0i(name, arg) do { \ |
440 | a7812ae4 | pbrook | TCGv_i32 helper_tmp = tcg_const_i32(arg); \ |
441 | a7812ae4 | pbrook | gen_helper_##name(helper_tmp); \ |
442 | a7812ae4 | pbrook | tcg_temp_free_i32(helper_tmp); \ |
443 | a7812ae4 | pbrook | } while(0) |
444 | be24bb4f | ths | |
445 | a7812ae4 | pbrook | #define gen_helper_1i(name, arg1, arg2) do { \ |
446 | a7812ae4 | pbrook | TCGv_i32 helper_tmp = tcg_const_i32(arg2); \ |
447 | a7812ae4 | pbrook | gen_helper_##name(arg1, helper_tmp); \ |
448 | a7812ae4 | pbrook | tcg_temp_free_i32(helper_tmp); \ |
449 | a7812ae4 | pbrook | } while(0) |
450 | be24bb4f | ths | |
451 | a7812ae4 | pbrook | #define gen_helper_2i(name, arg1, arg2, arg3) do { \ |
452 | a7812ae4 | pbrook | TCGv_i32 helper_tmp = tcg_const_i32(arg3); \ |
453 | a7812ae4 | pbrook | gen_helper_##name(arg1, arg2, helper_tmp); \ |
454 | a7812ae4 | pbrook | tcg_temp_free_i32(helper_tmp); \ |
455 | a7812ae4 | pbrook | } while(0) |
456 | be24bb4f | ths | |
457 | a7812ae4 | pbrook | #define gen_helper_3i(name, arg1, arg2, arg3, arg4) do { \ |
458 | a7812ae4 | pbrook | TCGv_i32 helper_tmp = tcg_const_i32(arg4); \ |
459 | a7812ae4 | pbrook | gen_helper_##name(arg1, arg2, arg3, helper_tmp); \ |
460 | a7812ae4 | pbrook | tcg_temp_free_i32(helper_tmp); \ |
461 | a7812ae4 | pbrook | } while(0) |
462 | c239529e | ths | |
463 | 8e9ade68 | ths | typedef struct DisasContext { |
464 | 8e9ade68 | ths | struct TranslationBlock *tb;
|
465 | 8e9ade68 | ths | target_ulong pc, saved_pc; |
466 | 8e9ade68 | ths | uint32_t opcode; |
467 | 8e9ade68 | ths | /* Routine used to access memory */
|
468 | 8e9ade68 | ths | int mem_idx;
|
469 | 8e9ade68 | ths | uint32_t hflags, saved_hflags; |
470 | 8e9ade68 | ths | int bstate;
|
471 | 8e9ade68 | ths | target_ulong btarget; |
472 | 8e9ade68 | ths | } DisasContext; |
473 | 8e9ade68 | ths | |
474 | 8e9ade68 | ths | enum {
|
475 | 8e9ade68 | ths | BS_NONE = 0, /* We go out of the TB without reaching a branch or an |
476 | d077b6f7 | ths | * exception condition */
|
477 | 8e9ade68 | ths | BS_STOP = 1, /* We want to stop translation for any reason */ |
478 | 8e9ade68 | ths | BS_BRANCH = 2, /* We reached a branch condition */ |
479 | 8e9ade68 | ths | BS_EXCP = 3, /* We reached an exception condition */ |
480 | 8e9ade68 | ths | }; |
481 | 8e9ade68 | ths | |
482 | 8e9ade68 | ths | static const char *regnames[] = |
483 | 6af0bf9c | bellard | { "r0", "at", "v0", "v1", "a0", "a1", "a2", "a3", |
484 | 6af0bf9c | bellard | "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", |
485 | 6af0bf9c | bellard | "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", |
486 | 6af0bf9c | bellard | "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra", }; |
487 | 6af0bf9c | bellard | |
488 | 4b2eb8d2 | ths | static const char *regnames_HI[] = |
489 | 4b2eb8d2 | ths | { "HI0", "HI1", "HI2", "HI3", }; |
490 | 4b2eb8d2 | ths | |
491 | 4b2eb8d2 | ths | static const char *regnames_LO[] = |
492 | 4b2eb8d2 | ths | { "LO0", "LO1", "LO2", "LO3", }; |
493 | 4b2eb8d2 | ths | |
494 | 4b2eb8d2 | ths | static const char *regnames_ACX[] = |
495 | 4b2eb8d2 | ths | { "ACX0", "ACX1", "ACX2", "ACX3", }; |
496 | 4b2eb8d2 | ths | |
497 | 8e9ade68 | ths | static const char *fregnames[] = |
498 | 8e9ade68 | ths | { "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", |
499 | 8e9ade68 | ths | "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", |
500 | 8e9ade68 | ths | "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", |
501 | 8e9ade68 | ths | "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", }; |
502 | 958fb4a9 | ths | |
503 | f01be154 | ths | static const char *fregnames_h[] = |
504 | f01be154 | ths | { "h0", "h1", "h2", "h3", "h4", "h5", "h6", "h7", |
505 | f01be154 | ths | "h8", "h9", "h10", "h11", "h12", "h13", "h14", "h15", |
506 | f01be154 | ths | "h16", "h17", "h18", "h19", "h20", "h21", "h22", "h23", |
507 | f01be154 | ths | "h24", "h25", "h26", "h27", "h28", "h29", "h30", "h31", }; |
508 | f01be154 | ths | |
509 | 8e9ade68 | ths | #ifdef MIPS_DEBUG_DISAS
|
510 | 93fcfe39 | aliguori | #define MIPS_DEBUG(fmt, args...) \
|
511 | 93fcfe39 | aliguori | qemu_log_mask(CPU_LOG_TB_IN_ASM, \ |
512 | 93fcfe39 | aliguori | TARGET_FMT_lx ": %08x " fmt "\n", \ |
513 | 93fcfe39 | aliguori | ctx->pc, ctx->opcode , ##args) |
514 | 93fcfe39 | aliguori | #define LOG_DISAS(...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__) |
515 | 8e9ade68 | ths | #else
|
516 | 8e9ade68 | ths | #define MIPS_DEBUG(fmt, args...) do { } while(0) |
517 | d12d51d5 | aliguori | #define LOG_DISAS(...) do { } while (0) |
518 | 8e9ade68 | ths | #endif
|
519 | 958fb4a9 | ths | |
520 | 8e9ade68 | ths | #define MIPS_INVAL(op) \
|
521 | 8e9ade68 | ths | do { \
|
522 | 8e9ade68 | ths | MIPS_DEBUG("Invalid %s %03x %03x %03x", op, ctx->opcode >> 26, \ |
523 | 8e9ade68 | ths | ctx->opcode & 0x3F, ((ctx->opcode >> 16) & 0x1F)); \ |
524 | 8e9ade68 | ths | } while (0) |
525 | ead9360e | ths | |
526 | 8e9ade68 | ths | /* General purpose registers moves. */
|
527 | 8e9ade68 | ths | static inline void gen_load_gpr (TCGv t, int reg) |
528 | aaa9128a | ths | { |
529 | 8e9ade68 | ths | if (reg == 0) |
530 | 8e9ade68 | ths | tcg_gen_movi_tl(t, 0);
|
531 | 8e9ade68 | ths | else
|
532 | 4b2eb8d2 | ths | tcg_gen_mov_tl(t, cpu_gpr[reg]); |
533 | aaa9128a | ths | } |
534 | aaa9128a | ths | |
535 | 8e9ade68 | ths | static inline void gen_store_gpr (TCGv t, int reg) |
536 | aaa9128a | ths | { |
537 | 8e9ade68 | ths | if (reg != 0) |
538 | 4b2eb8d2 | ths | tcg_gen_mov_tl(cpu_gpr[reg], t); |
539 | aaa9128a | ths | } |
540 | aaa9128a | ths | |
541 | b10fa3c9 | aurel32 | /* Moves to/from ACX register. */
|
542 | 4b2eb8d2 | ths | static inline void gen_load_ACX (TCGv t, int reg) |
543 | 893f9865 | ths | { |
544 | 4b2eb8d2 | ths | tcg_gen_mov_tl(t, cpu_ACX[reg]); |
545 | 893f9865 | ths | } |
546 | 893f9865 | ths | |
547 | 4b2eb8d2 | ths | static inline void gen_store_ACX (TCGv t, int reg) |
548 | 893f9865 | ths | { |
549 | 4b2eb8d2 | ths | tcg_gen_mov_tl(cpu_ACX[reg], t); |
550 | 893f9865 | ths | } |
551 | 893f9865 | ths | |
552 | 8e9ade68 | ths | /* Moves to/from shadow registers. */
|
553 | be24bb4f | ths | static inline void gen_load_srsgpr (int from, int to) |
554 | aaa9128a | ths | { |
555 | a7812ae4 | pbrook | TCGv r_tmp1 = tcg_temp_new(); |
556 | be24bb4f | ths | |
557 | be24bb4f | ths | if (from == 0) |
558 | be24bb4f | ths | tcg_gen_movi_tl(r_tmp1, 0);
|
559 | 8e9ade68 | ths | else {
|
560 | a7812ae4 | pbrook | TCGv_i32 r_tmp2 = tcg_temp_new_i32(); |
561 | a7812ae4 | pbrook | TCGv_ptr addr = tcg_temp_new_ptr(); |
562 | aaa9128a | ths | |
563 | be24bb4f | ths | tcg_gen_ld_i32(r_tmp2, cpu_env, offsetof(CPUState, CP0_SRSCtl)); |
564 | be24bb4f | ths | tcg_gen_shri_i32(r_tmp2, r_tmp2, CP0SRSCtl_PSS); |
565 | be24bb4f | ths | tcg_gen_andi_i32(r_tmp2, r_tmp2, 0xf);
|
566 | be24bb4f | ths | tcg_gen_muli_i32(r_tmp2, r_tmp2, sizeof(target_ulong) * 32); |
567 | a7812ae4 | pbrook | tcg_gen_ext_i32_ptr(addr, r_tmp2); |
568 | a7812ae4 | pbrook | tcg_gen_add_ptr(addr, cpu_env, addr); |
569 | aaa9128a | ths | |
570 | a7812ae4 | pbrook | tcg_gen_ld_tl(r_tmp1, addr, sizeof(target_ulong) * from);
|
571 | a7812ae4 | pbrook | tcg_temp_free_ptr(addr); |
572 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp2); |
573 | 8e9ade68 | ths | } |
574 | be24bb4f | ths | gen_store_gpr(r_tmp1, to); |
575 | be24bb4f | ths | tcg_temp_free(r_tmp1); |
576 | aaa9128a | ths | } |
577 | aaa9128a | ths | |
578 | be24bb4f | ths | static inline void gen_store_srsgpr (int from, int to) |
579 | aaa9128a | ths | { |
580 | be24bb4f | ths | if (to != 0) { |
581 | a7812ae4 | pbrook | TCGv r_tmp1 = tcg_temp_new(); |
582 | a7812ae4 | pbrook | TCGv_i32 r_tmp2 = tcg_temp_new_i32(); |
583 | a7812ae4 | pbrook | TCGv_ptr addr = tcg_temp_new_ptr(); |
584 | be24bb4f | ths | |
585 | be24bb4f | ths | gen_load_gpr(r_tmp1, from); |
586 | be24bb4f | ths | tcg_gen_ld_i32(r_tmp2, cpu_env, offsetof(CPUState, CP0_SRSCtl)); |
587 | be24bb4f | ths | tcg_gen_shri_i32(r_tmp2, r_tmp2, CP0SRSCtl_PSS); |
588 | be24bb4f | ths | tcg_gen_andi_i32(r_tmp2, r_tmp2, 0xf);
|
589 | be24bb4f | ths | tcg_gen_muli_i32(r_tmp2, r_tmp2, sizeof(target_ulong) * 32); |
590 | a7812ae4 | pbrook | tcg_gen_ext_i32_ptr(addr, r_tmp2); |
591 | a7812ae4 | pbrook | tcg_gen_add_ptr(addr, cpu_env, addr); |
592 | be24bb4f | ths | |
593 | a7812ae4 | pbrook | tcg_gen_st_tl(r_tmp1, addr, sizeof(target_ulong) * to);
|
594 | a7812ae4 | pbrook | tcg_temp_free_ptr(addr); |
595 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp2); |
596 | be24bb4f | ths | tcg_temp_free(r_tmp1); |
597 | 8e9ade68 | ths | } |
598 | aaa9128a | ths | } |
599 | aaa9128a | ths | |
600 | aaa9128a | ths | /* Floating point register moves. */
|
601 | a7812ae4 | pbrook | static inline void gen_load_fpr32 (TCGv_i32 t, int reg) |
602 | aa0bf00b | ths | { |
603 | f01be154 | ths | tcg_gen_mov_i32(t, fpu_fpr32[reg]); |
604 | 6ea83fed | bellard | } |
605 | 6ea83fed | bellard | |
606 | a7812ae4 | pbrook | static inline void gen_store_fpr32 (TCGv_i32 t, int reg) |
607 | aa0bf00b | ths | { |
608 | f01be154 | ths | tcg_gen_mov_i32(fpu_fpr32[reg], t); |
609 | aa0bf00b | ths | } |
610 | 6ea83fed | bellard | |
611 | a7812ae4 | pbrook | static inline void gen_load_fpr64 (DisasContext *ctx, TCGv_i64 t, int reg) |
612 | aa0bf00b | ths | { |
613 | f364515c | aurel32 | if (ctx->hflags & MIPS_HFLAG_F64) {
|
614 | f364515c | aurel32 | tcg_gen_concat_i32_i64(t, fpu_fpr32[reg], fpu_fpr32h[reg]); |
615 | f364515c | aurel32 | } else {
|
616 | 36aa55dc | pbrook | tcg_gen_concat_i32_i64(t, fpu_fpr32[reg & ~1], fpu_fpr32[reg | 1]); |
617 | aa0bf00b | ths | } |
618 | aa0bf00b | ths | } |
619 | 6ea83fed | bellard | |
620 | a7812ae4 | pbrook | static inline void gen_store_fpr64 (DisasContext *ctx, TCGv_i64 t, int reg) |
621 | aa0bf00b | ths | { |
622 | f364515c | aurel32 | if (ctx->hflags & MIPS_HFLAG_F64) {
|
623 | f364515c | aurel32 | tcg_gen_trunc_i64_i32(fpu_fpr32[reg], t); |
624 | f364515c | aurel32 | tcg_gen_shri_i64(t, t, 32);
|
625 | f364515c | aurel32 | tcg_gen_trunc_i64_i32(fpu_fpr32h[reg], t); |
626 | f364515c | aurel32 | } else {
|
627 | f01be154 | ths | tcg_gen_trunc_i64_i32(fpu_fpr32[reg & ~1], t);
|
628 | aa0bf00b | ths | tcg_gen_shri_i64(t, t, 32);
|
629 | f01be154 | ths | tcg_gen_trunc_i64_i32(fpu_fpr32[reg | 1], t);
|
630 | aa0bf00b | ths | } |
631 | aa0bf00b | ths | } |
632 | 6ea83fed | bellard | |
633 | a7812ae4 | pbrook | static inline void gen_load_fpr32h (TCGv_i32 t, int reg) |
634 | aa0bf00b | ths | { |
635 | f01be154 | ths | tcg_gen_mov_i32(t, fpu_fpr32h[reg]); |
636 | aa0bf00b | ths | } |
637 | 8e9ade68 | ths | |
638 | a7812ae4 | pbrook | static inline void gen_store_fpr32h (TCGv_i32 t, int reg) |
639 | aa0bf00b | ths | { |
640 | f01be154 | ths | tcg_gen_mov_i32(fpu_fpr32h[reg], t); |
641 | aa0bf00b | ths | } |
642 | 8e9ade68 | ths | |
643 | a7812ae4 | pbrook | static inline void get_fp_cond (TCGv_i32 t) |
644 | a16336e4 | ths | { |
645 | a7812ae4 | pbrook | TCGv_i32 r_tmp1 = tcg_temp_new_i32(); |
646 | a7812ae4 | pbrook | TCGv_i32 r_tmp2 = tcg_temp_new_i32(); |
647 | a16336e4 | ths | |
648 | f01be154 | ths | tcg_gen_shri_i32(r_tmp2, fpu_fcr31, 24);
|
649 | a16336e4 | ths | tcg_gen_andi_i32(r_tmp2, r_tmp2, 0xfe);
|
650 | f01be154 | ths | tcg_gen_shri_i32(r_tmp1, fpu_fcr31, 23);
|
651 | a16336e4 | ths | tcg_gen_andi_i32(r_tmp1, r_tmp1, 0x1);
|
652 | a16336e4 | ths | tcg_gen_or_i32(t, r_tmp1, r_tmp2); |
653 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp1); |
654 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp2); |
655 | a16336e4 | ths | } |
656 | a16336e4 | ths | |
657 | a7812ae4 | pbrook | #define FOP_CONDS(type, fmt, bits) \
|
658 | a7812ae4 | pbrook | static inline void gen_cmp ## type ## _ ## fmt(int n, TCGv_i##bits a, \ |
659 | a7812ae4 | pbrook | TCGv_i##bits b, int cc) \ |
660 | b6d96bed | ths | { \ |
661 | a7812ae4 | pbrook | switch (n) { \
|
662 | a7812ae4 | pbrook | case 0: gen_helper_2i(cmp ## type ## _ ## fmt ## _f, a, b, cc); break;\ |
663 | a7812ae4 | pbrook | case 1: gen_helper_2i(cmp ## type ## _ ## fmt ## _un, a, b, cc); break;\ |
664 | a7812ae4 | pbrook | case 2: gen_helper_2i(cmp ## type ## _ ## fmt ## _eq, a, b, cc); break;\ |
665 | a7812ae4 | pbrook | case 3: gen_helper_2i(cmp ## type ## _ ## fmt ## _ueq, a, b, cc); break;\ |
666 | a7812ae4 | pbrook | case 4: gen_helper_2i(cmp ## type ## _ ## fmt ## _olt, a, b, cc); break;\ |
667 | a7812ae4 | pbrook | case 5: gen_helper_2i(cmp ## type ## _ ## fmt ## _ult, a, b, cc); break;\ |
668 | a7812ae4 | pbrook | case 6: gen_helper_2i(cmp ## type ## _ ## fmt ## _ole, a, b, cc); break;\ |
669 | a7812ae4 | pbrook | case 7: gen_helper_2i(cmp ## type ## _ ## fmt ## _ule, a, b, cc); break;\ |
670 | a7812ae4 | pbrook | case 8: gen_helper_2i(cmp ## type ## _ ## fmt ## _sf, a, b, cc); break;\ |
671 | a7812ae4 | pbrook | case 9: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngle, a, b, cc); break;\ |
672 | a7812ae4 | pbrook | case 10: gen_helper_2i(cmp ## type ## _ ## fmt ## _seq, a, b, cc); break;\ |
673 | a7812ae4 | pbrook | case 11: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngl, a, b, cc); break;\ |
674 | a7812ae4 | pbrook | case 12: gen_helper_2i(cmp ## type ## _ ## fmt ## _lt, a, b, cc); break;\ |
675 | a7812ae4 | pbrook | case 13: gen_helper_2i(cmp ## type ## _ ## fmt ## _nge, a, b, cc); break;\ |
676 | a7812ae4 | pbrook | case 14: gen_helper_2i(cmp ## type ## _ ## fmt ## _le, a, b, cc); break;\ |
677 | a7812ae4 | pbrook | case 15: gen_helper_2i(cmp ## type ## _ ## fmt ## _ngt, a, b, cc); break;\ |
678 | a7812ae4 | pbrook | default: abort(); \
|
679 | a7812ae4 | pbrook | } \ |
680 | 6ea83fed | bellard | } |
681 | 6ea83fed | bellard | |
682 | a7812ae4 | pbrook | FOP_CONDS(, d, 64)
|
683 | a7812ae4 | pbrook | FOP_CONDS(abs, d, 64)
|
684 | a7812ae4 | pbrook | FOP_CONDS(, s, 32)
|
685 | a7812ae4 | pbrook | FOP_CONDS(abs, s, 32)
|
686 | a7812ae4 | pbrook | FOP_CONDS(, ps, 64)
|
687 | a7812ae4 | pbrook | FOP_CONDS(abs, ps, 64)
|
688 | 5d0fc900 | ths | #undef FOP_CONDS
|
689 | 6ea83fed | bellard | |
690 | 30898801 | ths | /* Tests */
|
691 | 92e90443 | aurel32 | #define OP_COND(name, cond) \
|
692 | 92e90443 | aurel32 | static inline void glue(gen_op_, name) (TCGv ret, TCGv t0, TCGv t1) \ |
693 | 92e90443 | aurel32 | { \ |
694 | 92e90443 | aurel32 | int l1 = gen_new_label(); \
|
695 | 92e90443 | aurel32 | int l2 = gen_new_label(); \
|
696 | 92e90443 | aurel32 | \ |
697 | 92e90443 | aurel32 | tcg_gen_brcond_tl(cond, t0, t1, l1); \ |
698 | 92e90443 | aurel32 | tcg_gen_movi_tl(ret, 0); \
|
699 | 92e90443 | aurel32 | tcg_gen_br(l2); \ |
700 | 92e90443 | aurel32 | gen_set_label(l1); \ |
701 | 92e90443 | aurel32 | tcg_gen_movi_tl(ret, 1); \
|
702 | 92e90443 | aurel32 | gen_set_label(l2); \ |
703 | 30898801 | ths | } |
704 | 30898801 | ths | OP_COND(eq, TCG_COND_EQ); |
705 | 30898801 | ths | OP_COND(ne, TCG_COND_NE); |
706 | 30898801 | ths | OP_COND(ge, TCG_COND_GE); |
707 | 30898801 | ths | OP_COND(geu, TCG_COND_GEU); |
708 | 30898801 | ths | OP_COND(lt, TCG_COND_LT); |
709 | 30898801 | ths | OP_COND(ltu, TCG_COND_LTU); |
710 | 30898801 | ths | #undef OP_COND
|
711 | 30898801 | ths | |
712 | 92e90443 | aurel32 | #define OP_CONDI(name, cond) \
|
713 | 92e90443 | aurel32 | static inline void glue(gen_op_, name) (TCGv ret, TCGv t0, target_ulong val) \ |
714 | 92e90443 | aurel32 | { \ |
715 | 92e90443 | aurel32 | int l1 = gen_new_label(); \
|
716 | 92e90443 | aurel32 | int l2 = gen_new_label(); \
|
717 | 92e90443 | aurel32 | \ |
718 | 92e90443 | aurel32 | tcg_gen_brcondi_tl(cond, t0, val, l1); \ |
719 | 92e90443 | aurel32 | tcg_gen_movi_tl(ret, 0); \
|
720 | 92e90443 | aurel32 | tcg_gen_br(l2); \ |
721 | 92e90443 | aurel32 | gen_set_label(l1); \ |
722 | 92e90443 | aurel32 | tcg_gen_movi_tl(ret, 1); \
|
723 | 92e90443 | aurel32 | gen_set_label(l2); \ |
724 | 30898801 | ths | } |
725 | 30898801 | ths | OP_CONDI(lti, TCG_COND_LT); |
726 | 30898801 | ths | OP_CONDI(ltiu, TCG_COND_LTU); |
727 | 30898801 | ths | #undef OP_CONDI
|
728 | 30898801 | ths | |
729 | 30898801 | ths | #define OP_CONDZ(name, cond) \
|
730 | 92e90443 | aurel32 | static inline void glue(gen_op_, name) (TCGv ret, TCGv t0) \ |
731 | 30898801 | ths | { \ |
732 | 30898801 | ths | int l1 = gen_new_label(); \
|
733 | 30898801 | ths | int l2 = gen_new_label(); \
|
734 | 30898801 | ths | \ |
735 | 92e90443 | aurel32 | tcg_gen_brcondi_tl(cond, t0, 0, l1); \
|
736 | 92e90443 | aurel32 | tcg_gen_movi_tl(ret, 0); \
|
737 | 30898801 | ths | tcg_gen_br(l2); \ |
738 | 30898801 | ths | gen_set_label(l1); \ |
739 | 92e90443 | aurel32 | tcg_gen_movi_tl(ret, 1); \
|
740 | 30898801 | ths | gen_set_label(l2); \ |
741 | 30898801 | ths | } |
742 | 30898801 | ths | OP_CONDZ(gez, TCG_COND_GE); |
743 | 30898801 | ths | OP_CONDZ(gtz, TCG_COND_GT); |
744 | 30898801 | ths | OP_CONDZ(lez, TCG_COND_LE); |
745 | 30898801 | ths | OP_CONDZ(ltz, TCG_COND_LT); |
746 | 30898801 | ths | #undef OP_CONDZ
|
747 | 30898801 | ths | |
748 | 8e9ade68 | ths | static inline void gen_save_pc(target_ulong pc) |
749 | 8e9ade68 | ths | { |
750 | 1eb75d4a | aurel32 | tcg_gen_movi_tl(cpu_PC, pc); |
751 | 8e9ade68 | ths | } |
752 | 30898801 | ths | |
753 | 356265ae | ths | static inline void save_cpu_state (DisasContext *ctx, int do_save_pc) |
754 | 6af0bf9c | bellard | { |
755 | d12d51d5 | aliguori | LOG_DISAS("hflags %08x saved %08x\n", ctx->hflags, ctx->saved_hflags);
|
756 | 6af0bf9c | bellard | if (do_save_pc && ctx->pc != ctx->saved_pc) {
|
757 | 9b9e4393 | ths | gen_save_pc(ctx->pc); |
758 | 6af0bf9c | bellard | ctx->saved_pc = ctx->pc; |
759 | 6af0bf9c | bellard | } |
760 | 6af0bf9c | bellard | if (ctx->hflags != ctx->saved_hflags) {
|
761 | a7812ae4 | pbrook | TCGv_i32 r_tmp = tcg_temp_new_i32(); |
762 | 08ba7963 | ths | |
763 | 08ba7963 | ths | tcg_gen_movi_i32(r_tmp, ctx->hflags); |
764 | 08ba7963 | ths | tcg_gen_st_i32(r_tmp, cpu_env, offsetof(CPUState, hflags)); |
765 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp); |
766 | 6af0bf9c | bellard | ctx->saved_hflags = ctx->hflags; |
767 | 5a5012ec | ths | switch (ctx->hflags & MIPS_HFLAG_BMASK) {
|
768 | 5a5012ec | ths | case MIPS_HFLAG_BR:
|
769 | 5a5012ec | ths | break;
|
770 | 5a5012ec | ths | case MIPS_HFLAG_BC:
|
771 | 5a5012ec | ths | case MIPS_HFLAG_BL:
|
772 | 5a5012ec | ths | case MIPS_HFLAG_B:
|
773 | d077b6f7 | ths | tcg_gen_movi_tl(btarget, ctx->btarget); |
774 | 5a5012ec | ths | break;
|
775 | 6af0bf9c | bellard | } |
776 | 6af0bf9c | bellard | } |
777 | 6af0bf9c | bellard | } |
778 | 6af0bf9c | bellard | |
779 | 356265ae | ths | static inline void restore_cpu_state (CPUState *env, DisasContext *ctx) |
780 | 5a5012ec | ths | { |
781 | fd4a04eb | ths | ctx->saved_hflags = ctx->hflags; |
782 | fd4a04eb | ths | switch (ctx->hflags & MIPS_HFLAG_BMASK) {
|
783 | fd4a04eb | ths | case MIPS_HFLAG_BR:
|
784 | fd4a04eb | ths | break;
|
785 | fd4a04eb | ths | case MIPS_HFLAG_BC:
|
786 | fd4a04eb | ths | case MIPS_HFLAG_BL:
|
787 | 39454628 | ths | case MIPS_HFLAG_B:
|
788 | fd4a04eb | ths | ctx->btarget = env->btarget; |
789 | fd4a04eb | ths | break;
|
790 | 5a5012ec | ths | } |
791 | 5a5012ec | ths | } |
792 | 5a5012ec | ths | |
793 | 356265ae | ths | static inline void |
794 | 48d38ca5 | ths | generate_exception_err (DisasContext *ctx, int excp, int err) |
795 | aaa9128a | ths | { |
796 | a7812ae4 | pbrook | TCGv_i32 texcp = tcg_const_i32(excp); |
797 | a7812ae4 | pbrook | TCGv_i32 terr = tcg_const_i32(err); |
798 | aaa9128a | ths | save_cpu_state(ctx, 1);
|
799 | a7812ae4 | pbrook | gen_helper_raise_exception_err(texcp, terr); |
800 | a7812ae4 | pbrook | tcg_temp_free_i32(terr); |
801 | a7812ae4 | pbrook | tcg_temp_free_i32(texcp); |
802 | a7812ae4 | pbrook | gen_helper_interrupt_restart(); |
803 | aaa9128a | ths | tcg_gen_exit_tb(0);
|
804 | aaa9128a | ths | } |
805 | aaa9128a | ths | |
806 | 356265ae | ths | static inline void |
807 | 48d38ca5 | ths | generate_exception (DisasContext *ctx, int excp)
|
808 | aaa9128a | ths | { |
809 | 6af0bf9c | bellard | save_cpu_state(ctx, 1);
|
810 | a7812ae4 | pbrook | gen_helper_0i(raise_exception, excp); |
811 | a7812ae4 | pbrook | gen_helper_interrupt_restart(); |
812 | 48d38ca5 | ths | tcg_gen_exit_tb(0);
|
813 | 6af0bf9c | bellard | } |
814 | 6af0bf9c | bellard | |
815 | 48d38ca5 | ths | /* Addresses computation */
|
816 | d144d1d9 | aurel32 | static inline void gen_op_addr_add (DisasContext *ctx, TCGv t0, TCGv t1) |
817 | 4ad40f36 | bellard | { |
818 | be24bb4f | ths | tcg_gen_add_tl(t0, t0, t1); |
819 | 48d38ca5 | ths | |
820 | 48d38ca5 | ths | #if defined(TARGET_MIPS64)
|
821 | 48d38ca5 | ths | /* For compatibility with 32-bit code, data reference in user mode
|
822 | 48d38ca5 | ths | with Status_UX = 0 should be casted to 32-bit and sign extended.
|
823 | 48d38ca5 | ths | See the MIPS64 PRA manual, section 4.10. */
|
824 | 2623c1ec | aurel32 | if (((ctx->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&
|
825 | 2623c1ec | aurel32 | !(ctx->hflags & MIPS_HFLAG_UX)) { |
826 | be24bb4f | ths | tcg_gen_ext32s_i64(t0, t0); |
827 | 48d38ca5 | ths | } |
828 | 48d38ca5 | ths | #endif
|
829 | 4ad40f36 | bellard | } |
830 | 4ad40f36 | bellard | |
831 | 356265ae | ths | static inline void check_cp0_enabled(DisasContext *ctx) |
832 | 387a8fe5 | ths | { |
833 | fe253235 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_CP0)))
|
834 | 387a8fe5 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
835 | 387a8fe5 | ths | } |
836 | 387a8fe5 | ths | |
837 | 356265ae | ths | static inline void check_cp1_enabled(DisasContext *ctx) |
838 | 5e755519 | ths | { |
839 | fe253235 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_FPU)))
|
840 | 5e755519 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
841 | 5e755519 | ths | } |
842 | 5e755519 | ths | |
843 | b8aa4598 | ths | /* Verify that the processor is running with COP1X instructions enabled.
|
844 | b8aa4598 | ths | This is associated with the nabla symbol in the MIPS32 and MIPS64
|
845 | b8aa4598 | ths | opcode tables. */
|
846 | b8aa4598 | ths | |
847 | 356265ae | ths | static inline void check_cop1x(DisasContext *ctx) |
848 | b8aa4598 | ths | { |
849 | b8aa4598 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_COP1X)))
|
850 | b8aa4598 | ths | generate_exception(ctx, EXCP_RI); |
851 | b8aa4598 | ths | } |
852 | b8aa4598 | ths | |
853 | b8aa4598 | ths | /* Verify that the processor is running with 64-bit floating-point
|
854 | b8aa4598 | ths | operations enabled. */
|
855 | b8aa4598 | ths | |
856 | 356265ae | ths | static inline void check_cp1_64bitmode(DisasContext *ctx) |
857 | 5e755519 | ths | { |
858 | b8aa4598 | ths | if (unlikely(~ctx->hflags & (MIPS_HFLAG_F64 | MIPS_HFLAG_COP1X)))
|
859 | 5e755519 | ths | generate_exception(ctx, EXCP_RI); |
860 | 5e755519 | ths | } |
861 | 5e755519 | ths | |
862 | 5e755519 | ths | /*
|
863 | 5e755519 | ths | * Verify if floating point register is valid; an operation is not defined
|
864 | 5e755519 | ths | * if bit 0 of any register specification is set and the FR bit in the
|
865 | 5e755519 | ths | * Status register equals zero, since the register numbers specify an
|
866 | 5e755519 | ths | * even-odd pair of adjacent coprocessor general registers. When the FR bit
|
867 | 5e755519 | ths | * in the Status register equals one, both even and odd register numbers
|
868 | 5e755519 | ths | * are valid. This limitation exists only for 64 bit wide (d,l,ps) registers.
|
869 | 5e755519 | ths | *
|
870 | 5e755519 | ths | * Multiple 64 bit wide registers can be checked by calling
|
871 | 5e755519 | ths | * gen_op_cp1_registers(freg1 | freg2 | ... | fregN);
|
872 | 5e755519 | ths | */
|
873 | 356265ae | ths | static inline void check_cp1_registers(DisasContext *ctx, int regs) |
874 | 5e755519 | ths | { |
875 | fe253235 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_F64) && (regs & 1))) |
876 | 5e755519 | ths | generate_exception(ctx, EXCP_RI); |
877 | 5e755519 | ths | } |
878 | 5e755519 | ths | |
879 | 3a95e3a7 | ths | /* This code generates a "reserved instruction" exception if the
|
880 | e189e748 | ths | CPU does not support the instruction set corresponding to flags. */
|
881 | 356265ae | ths | static inline void check_insn(CPUState *env, DisasContext *ctx, int flags) |
882 | 3a95e3a7 | ths | { |
883 | e189e748 | ths | if (unlikely(!(env->insn_flags & flags)))
|
884 | 3a95e3a7 | ths | generate_exception(ctx, EXCP_RI); |
885 | 3a95e3a7 | ths | } |
886 | 3a95e3a7 | ths | |
887 | e189e748 | ths | /* This code generates a "reserved instruction" exception if 64-bit
|
888 | e189e748 | ths | instructions are not enabled. */
|
889 | 356265ae | ths | static inline void check_mips_64(DisasContext *ctx) |
890 | e189e748 | ths | { |
891 | fe253235 | ths | if (unlikely(!(ctx->hflags & MIPS_HFLAG_64)))
|
892 | e189e748 | ths | generate_exception(ctx, EXCP_RI); |
893 | e189e748 | ths | } |
894 | e189e748 | ths | |
895 | 958fb4a9 | ths | /* load/store instructions. */
|
896 | aaa9128a | ths | #define OP_LD(insn,fname) \
|
897 | 356265ae | ths | static inline void op_ldst_##insn(TCGv t0, DisasContext *ctx) \ |
898 | aaa9128a | ths | { \ |
899 | be24bb4f | ths | tcg_gen_qemu_##fname(t0, t0, ctx->mem_idx); \ |
900 | aaa9128a | ths | } |
901 | aaa9128a | ths | OP_LD(lb,ld8s); |
902 | aaa9128a | ths | OP_LD(lbu,ld8u); |
903 | aaa9128a | ths | OP_LD(lh,ld16s); |
904 | aaa9128a | ths | OP_LD(lhu,ld16u); |
905 | aaa9128a | ths | OP_LD(lw,ld32s); |
906 | aaa9128a | ths | #if defined(TARGET_MIPS64)
|
907 | aaa9128a | ths | OP_LD(lwu,ld32u); |
908 | aaa9128a | ths | OP_LD(ld,ld64); |
909 | aaa9128a | ths | #endif
|
910 | aaa9128a | ths | #undef OP_LD
|
911 | aaa9128a | ths | |
912 | aaa9128a | ths | #define OP_ST(insn,fname) \
|
913 | 356265ae | ths | static inline void op_ldst_##insn(TCGv t0, TCGv t1, DisasContext *ctx) \ |
914 | aaa9128a | ths | { \ |
915 | be24bb4f | ths | tcg_gen_qemu_##fname(t1, t0, ctx->mem_idx); \ |
916 | aaa9128a | ths | } |
917 | aaa9128a | ths | OP_ST(sb,st8); |
918 | aaa9128a | ths | OP_ST(sh,st16); |
919 | aaa9128a | ths | OP_ST(sw,st32); |
920 | aaa9128a | ths | #if defined(TARGET_MIPS64)
|
921 | aaa9128a | ths | OP_ST(sd,st64); |
922 | aaa9128a | ths | #endif
|
923 | aaa9128a | ths | #undef OP_ST
|
924 | aaa9128a | ths | |
925 | aaa9128a | ths | #define OP_LD_ATOMIC(insn,fname) \
|
926 | 356265ae | ths | static inline void op_ldst_##insn(TCGv t0, TCGv t1, DisasContext *ctx) \ |
927 | aaa9128a | ths | { \ |
928 | be24bb4f | ths | tcg_gen_mov_tl(t1, t0); \ |
929 | be24bb4f | ths | tcg_gen_qemu_##fname(t0, t0, ctx->mem_idx); \ |
930 | be24bb4f | ths | tcg_gen_st_tl(t1, cpu_env, offsetof(CPUState, CP0_LLAddr)); \ |
931 | aaa9128a | ths | } |
932 | aaa9128a | ths | OP_LD_ATOMIC(ll,ld32s); |
933 | aaa9128a | ths | #if defined(TARGET_MIPS64)
|
934 | aaa9128a | ths | OP_LD_ATOMIC(lld,ld64); |
935 | aaa9128a | ths | #endif
|
936 | aaa9128a | ths | #undef OP_LD_ATOMIC
|
937 | aaa9128a | ths | |
938 | aaa9128a | ths | #define OP_ST_ATOMIC(insn,fname,almask) \
|
939 | 356265ae | ths | static inline void op_ldst_##insn(TCGv t0, TCGv t1, DisasContext *ctx) \ |
940 | aaa9128a | ths | { \ |
941 | a7812ae4 | pbrook | TCGv r_tmp = tcg_temp_local_new(); \ |
942 | aaa9128a | ths | int l1 = gen_new_label(); \
|
943 | aaa9128a | ths | int l2 = gen_new_label(); \
|
944 | aaa9128a | ths | int l3 = gen_new_label(); \
|
945 | aaa9128a | ths | \ |
946 | be24bb4f | ths | tcg_gen_andi_tl(r_tmp, t0, almask); \ |
947 | cb63669a | pbrook | tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp, 0, l1); \
|
948 | be24bb4f | ths | tcg_gen_st_tl(t0, cpu_env, offsetof(CPUState, CP0_BadVAddr)); \ |
949 | f0b3f3ae | ths | generate_exception(ctx, EXCP_AdES); \ |
950 | aaa9128a | ths | gen_set_label(l1); \ |
951 | aaa9128a | ths | tcg_gen_ld_tl(r_tmp, cpu_env, offsetof(CPUState, CP0_LLAddr)); \ |
952 | be24bb4f | ths | tcg_gen_brcond_tl(TCG_COND_NE, t0, r_tmp, l2); \ |
953 | be24bb4f | ths | tcg_gen_qemu_##fname(t1, t0, ctx->mem_idx); \ |
954 | be24bb4f | ths | tcg_gen_movi_tl(t0, 1); \
|
955 | aaa9128a | ths | tcg_gen_br(l3); \ |
956 | aaa9128a | ths | gen_set_label(l2); \ |
957 | be24bb4f | ths | tcg_gen_movi_tl(t0, 0); \
|
958 | aaa9128a | ths | gen_set_label(l3); \ |
959 | c24135ff | aurel32 | tcg_temp_free(r_tmp); \ |
960 | aaa9128a | ths | } |
961 | aaa9128a | ths | OP_ST_ATOMIC(sc,st32,0x3);
|
962 | aaa9128a | ths | #if defined(TARGET_MIPS64)
|
963 | aaa9128a | ths | OP_ST_ATOMIC(scd,st64,0x7);
|
964 | aaa9128a | ths | #endif
|
965 | aaa9128a | ths | #undef OP_ST_ATOMIC
|
966 | aaa9128a | ths | |
967 | 6af0bf9c | bellard | /* Load and store */
|
968 | 7a387fff | ths | static void gen_ldst (DisasContext *ctx, uint32_t opc, int rt, |
969 | 6af0bf9c | bellard | int base, int16_t offset)
|
970 | 6af0bf9c | bellard | { |
971 | 923617a3 | ths | const char *opn = "ldst"; |
972 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
973 | a7812ae4 | pbrook | TCGv t1 = tcg_temp_local_new(); |
974 | 6af0bf9c | bellard | |
975 | 6af0bf9c | bellard | if (base == 0) { |
976 | 78723684 | ths | tcg_gen_movi_tl(t0, offset); |
977 | 6af0bf9c | bellard | } else if (offset == 0) { |
978 | 78723684 | ths | gen_load_gpr(t0, base); |
979 | 6af0bf9c | bellard | } else {
|
980 | e9203484 | aurel32 | tcg_gen_movi_tl(t0, offset); |
981 | e9203484 | aurel32 | gen_op_addr_add(ctx, t0, cpu_gpr[base]); |
982 | 6af0bf9c | bellard | } |
983 | 6af0bf9c | bellard | /* Don't do NOP if destination is zero: we must perform the actual
|
984 | ead9360e | ths | memory access. */
|
985 | 6af0bf9c | bellard | switch (opc) {
|
986 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
987 | 6e473128 | ths | case OPC_LWU:
|
988 | 78723684 | ths | op_ldst_lwu(t0, ctx); |
989 | 78723684 | ths | gen_store_gpr(t0, rt); |
990 | 6e473128 | ths | opn = "lwu";
|
991 | 6e473128 | ths | break;
|
992 | 6af0bf9c | bellard | case OPC_LD:
|
993 | 78723684 | ths | op_ldst_ld(t0, ctx); |
994 | 78723684 | ths | gen_store_gpr(t0, rt); |
995 | 6af0bf9c | bellard | opn = "ld";
|
996 | 6af0bf9c | bellard | break;
|
997 | 7a387fff | ths | case OPC_LLD:
|
998 | 78723684 | ths | op_ldst_lld(t0, t1, ctx); |
999 | 78723684 | ths | gen_store_gpr(t0, rt); |
1000 | 7a387fff | ths | opn = "lld";
|
1001 | 7a387fff | ths | break;
|
1002 | 6af0bf9c | bellard | case OPC_SD:
|
1003 | 78723684 | ths | gen_load_gpr(t1, rt); |
1004 | 78723684 | ths | op_ldst_sd(t0, t1, ctx); |
1005 | 6af0bf9c | bellard | opn = "sd";
|
1006 | 6af0bf9c | bellard | break;
|
1007 | 7a387fff | ths | case OPC_SCD:
|
1008 | 62c5609a | ths | save_cpu_state(ctx, 1);
|
1009 | 78723684 | ths | gen_load_gpr(t1, rt); |
1010 | 78723684 | ths | op_ldst_scd(t0, t1, ctx); |
1011 | 78723684 | ths | gen_store_gpr(t0, rt); |
1012 | 7a387fff | ths | opn = "scd";
|
1013 | 7a387fff | ths | break;
|
1014 | 6af0bf9c | bellard | case OPC_LDL:
|
1015 | c8c2227e | ths | save_cpu_state(ctx, 1);
|
1016 | 78723684 | ths | gen_load_gpr(t1, rt); |
1017 | a7812ae4 | pbrook | gen_helper_3i(ldl, t1, t0, t1, ctx->mem_idx); |
1018 | 78723684 | ths | gen_store_gpr(t1, rt); |
1019 | 6af0bf9c | bellard | opn = "ldl";
|
1020 | 6af0bf9c | bellard | break;
|
1021 | 6af0bf9c | bellard | case OPC_SDL:
|
1022 | c8c2227e | ths | save_cpu_state(ctx, 1);
|
1023 | 78723684 | ths | gen_load_gpr(t1, rt); |
1024 | a7812ae4 | pbrook | gen_helper_2i(sdl, t0, t1, ctx->mem_idx); |
1025 | 6af0bf9c | bellard | opn = "sdl";
|
1026 | 6af0bf9c | bellard | break;
|
1027 | 6af0bf9c | bellard | case OPC_LDR:
|
1028 | c8c2227e | ths | save_cpu_state(ctx, 1);
|
1029 | 78723684 | ths | gen_load_gpr(t1, rt); |
1030 | a7812ae4 | pbrook | gen_helper_3i(ldr, t1, t0, t1, ctx->mem_idx); |
1031 | 78723684 | ths | gen_store_gpr(t1, rt); |
1032 | 6af0bf9c | bellard | opn = "ldr";
|
1033 | 6af0bf9c | bellard | break;
|
1034 | 6af0bf9c | bellard | case OPC_SDR:
|
1035 | c8c2227e | ths | save_cpu_state(ctx, 1);
|
1036 | 78723684 | ths | gen_load_gpr(t1, rt); |
1037 | a7812ae4 | pbrook | gen_helper_2i(sdr, t0, t1, ctx->mem_idx); |
1038 | 6af0bf9c | bellard | opn = "sdr";
|
1039 | 6af0bf9c | bellard | break;
|
1040 | 6af0bf9c | bellard | #endif
|
1041 | 6af0bf9c | bellard | case OPC_LW:
|
1042 | 78723684 | ths | op_ldst_lw(t0, ctx); |
1043 | 78723684 | ths | gen_store_gpr(t0, rt); |
1044 | 6af0bf9c | bellard | opn = "lw";
|
1045 | 6af0bf9c | bellard | break;
|
1046 | 6af0bf9c | bellard | case OPC_SW:
|
1047 | 78723684 | ths | gen_load_gpr(t1, rt); |
1048 | 78723684 | ths | op_ldst_sw(t0, t1, ctx); |
1049 | 6af0bf9c | bellard | opn = "sw";
|
1050 | 6af0bf9c | bellard | break;
|
1051 | 6af0bf9c | bellard | case OPC_LH:
|
1052 | 78723684 | ths | op_ldst_lh(t0, ctx); |
1053 | 78723684 | ths | gen_store_gpr(t0, rt); |
1054 | 6af0bf9c | bellard | opn = "lh";
|
1055 | 6af0bf9c | bellard | break;
|
1056 | 6af0bf9c | bellard | case OPC_SH:
|
1057 | 78723684 | ths | gen_load_gpr(t1, rt); |
1058 | 78723684 | ths | op_ldst_sh(t0, t1, ctx); |
1059 | 6af0bf9c | bellard | opn = "sh";
|
1060 | 6af0bf9c | bellard | break;
|
1061 | 6af0bf9c | bellard | case OPC_LHU:
|
1062 | 78723684 | ths | op_ldst_lhu(t0, ctx); |
1063 | 78723684 | ths | gen_store_gpr(t0, rt); |
1064 | 6af0bf9c | bellard | opn = "lhu";
|
1065 | 6af0bf9c | bellard | break;
|
1066 | 6af0bf9c | bellard | case OPC_LB:
|
1067 | 78723684 | ths | op_ldst_lb(t0, ctx); |
1068 | 78723684 | ths | gen_store_gpr(t0, rt); |
1069 | 6af0bf9c | bellard | opn = "lb";
|
1070 | 6af0bf9c | bellard | break;
|
1071 | 6af0bf9c | bellard | case OPC_SB:
|
1072 | 78723684 | ths | gen_load_gpr(t1, rt); |
1073 | 78723684 | ths | op_ldst_sb(t0, t1, ctx); |
1074 | 6af0bf9c | bellard | opn = "sb";
|
1075 | 6af0bf9c | bellard | break;
|
1076 | 6af0bf9c | bellard | case OPC_LBU:
|
1077 | 78723684 | ths | op_ldst_lbu(t0, ctx); |
1078 | 78723684 | ths | gen_store_gpr(t0, rt); |
1079 | 6af0bf9c | bellard | opn = "lbu";
|
1080 | 6af0bf9c | bellard | break;
|
1081 | 6af0bf9c | bellard | case OPC_LWL:
|
1082 | c8c2227e | ths | save_cpu_state(ctx, 1);
|
1083 | 6958549d | aurel32 | gen_load_gpr(t1, rt); |
1084 | a7812ae4 | pbrook | gen_helper_3i(lwl, t1, t0, t1, ctx->mem_idx); |
1085 | 78723684 | ths | gen_store_gpr(t1, rt); |
1086 | 6af0bf9c | bellard | opn = "lwl";
|
1087 | 6af0bf9c | bellard | break;
|
1088 | 6af0bf9c | bellard | case OPC_SWL:
|
1089 | c8c2227e | ths | save_cpu_state(ctx, 1);
|
1090 | 78723684 | ths | gen_load_gpr(t1, rt); |
1091 | a7812ae4 | pbrook | gen_helper_2i(swl, t0, t1, ctx->mem_idx); |
1092 | 6af0bf9c | bellard | opn = "swr";
|
1093 | 6af0bf9c | bellard | break;
|
1094 | 6af0bf9c | bellard | case OPC_LWR:
|
1095 | c8c2227e | ths | save_cpu_state(ctx, 1);
|
1096 | 6958549d | aurel32 | gen_load_gpr(t1, rt); |
1097 | a7812ae4 | pbrook | gen_helper_3i(lwr, t1, t0, t1, ctx->mem_idx); |
1098 | 78723684 | ths | gen_store_gpr(t1, rt); |
1099 | 6af0bf9c | bellard | opn = "lwr";
|
1100 | 6af0bf9c | bellard | break;
|
1101 | 6af0bf9c | bellard | case OPC_SWR:
|
1102 | c8c2227e | ths | save_cpu_state(ctx, 1);
|
1103 | 78723684 | ths | gen_load_gpr(t1, rt); |
1104 | a7812ae4 | pbrook | gen_helper_2i(swr, t0, t1, ctx->mem_idx); |
1105 | 6af0bf9c | bellard | opn = "swr";
|
1106 | 6af0bf9c | bellard | break;
|
1107 | 6af0bf9c | bellard | case OPC_LL:
|
1108 | 78723684 | ths | op_ldst_ll(t0, t1, ctx); |
1109 | 78723684 | ths | gen_store_gpr(t0, rt); |
1110 | 6af0bf9c | bellard | opn = "ll";
|
1111 | 6af0bf9c | bellard | break;
|
1112 | 6af0bf9c | bellard | case OPC_SC:
|
1113 | 62c5609a | ths | save_cpu_state(ctx, 1);
|
1114 | 78723684 | ths | gen_load_gpr(t1, rt); |
1115 | 78723684 | ths | op_ldst_sc(t0, t1, ctx); |
1116 | 78723684 | ths | gen_store_gpr(t0, rt); |
1117 | 6af0bf9c | bellard | opn = "sc";
|
1118 | 6af0bf9c | bellard | break;
|
1119 | 6af0bf9c | bellard | default:
|
1120 | 923617a3 | ths | MIPS_INVAL(opn); |
1121 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1122 | 78723684 | ths | goto out;
|
1123 | 6af0bf9c | bellard | } |
1124 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s, %d(%s)", opn, regnames[rt], offset, regnames[base]);
|
1125 | 78723684 | ths | out:
|
1126 | 78723684 | ths | tcg_temp_free(t0); |
1127 | 78723684 | ths | tcg_temp_free(t1); |
1128 | 6af0bf9c | bellard | } |
1129 | 6af0bf9c | bellard | |
1130 | 6ea83fed | bellard | /* Load and store */
|
1131 | 7a387fff | ths | static void gen_flt_ldst (DisasContext *ctx, uint32_t opc, int ft, |
1132 | 356265ae | ths | int base, int16_t offset)
|
1133 | 6ea83fed | bellard | { |
1134 | 923617a3 | ths | const char *opn = "flt_ldst"; |
1135 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
1136 | 6ea83fed | bellard | |
1137 | 6ea83fed | bellard | if (base == 0) { |
1138 | 78723684 | ths | tcg_gen_movi_tl(t0, offset); |
1139 | 6ea83fed | bellard | } else if (offset == 0) { |
1140 | 78723684 | ths | gen_load_gpr(t0, base); |
1141 | 6ea83fed | bellard | } else {
|
1142 | e9203484 | aurel32 | tcg_gen_movi_tl(t0, offset); |
1143 | e9203484 | aurel32 | gen_op_addr_add(ctx, t0, cpu_gpr[base]); |
1144 | 6ea83fed | bellard | } |
1145 | 6ea83fed | bellard | /* Don't do NOP if destination is zero: we must perform the actual
|
1146 | ead9360e | ths | memory access. */
|
1147 | 6ea83fed | bellard | switch (opc) {
|
1148 | 6ea83fed | bellard | case OPC_LWC1:
|
1149 | b6d96bed | ths | { |
1150 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
1151 | a7812ae4 | pbrook | TCGv t1 = tcg_temp_new(); |
1152 | b6d96bed | ths | |
1153 | a7812ae4 | pbrook | tcg_gen_qemu_ld32s(t1, t0, ctx->mem_idx); |
1154 | a7812ae4 | pbrook | tcg_gen_trunc_tl_i32(fp0, t1); |
1155 | b6d96bed | ths | gen_store_fpr32(fp0, ft); |
1156 | a7812ae4 | pbrook | tcg_temp_free(t1); |
1157 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
1158 | b6d96bed | ths | } |
1159 | 6ea83fed | bellard | opn = "lwc1";
|
1160 | 6ea83fed | bellard | break;
|
1161 | 6ea83fed | bellard | case OPC_SWC1:
|
1162 | b6d96bed | ths | { |
1163 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
1164 | a7812ae4 | pbrook | TCGv t1 = tcg_temp_new(); |
1165 | b6d96bed | ths | |
1166 | b6d96bed | ths | gen_load_fpr32(fp0, ft); |
1167 | a7812ae4 | pbrook | tcg_gen_extu_i32_tl(t1, fp0); |
1168 | a7812ae4 | pbrook | tcg_gen_qemu_st32(t1, t0, ctx->mem_idx); |
1169 | a7812ae4 | pbrook | tcg_temp_free(t1); |
1170 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
1171 | b6d96bed | ths | } |
1172 | 6ea83fed | bellard | opn = "swc1";
|
1173 | 6ea83fed | bellard | break;
|
1174 | 6ea83fed | bellard | case OPC_LDC1:
|
1175 | b6d96bed | ths | { |
1176 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
1177 | b6d96bed | ths | |
1178 | b6d96bed | ths | tcg_gen_qemu_ld64(fp0, t0, ctx->mem_idx); |
1179 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, ft); |
1180 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
1181 | b6d96bed | ths | } |
1182 | 6ea83fed | bellard | opn = "ldc1";
|
1183 | 6ea83fed | bellard | break;
|
1184 | 6ea83fed | bellard | case OPC_SDC1:
|
1185 | b6d96bed | ths | { |
1186 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
1187 | b6d96bed | ths | |
1188 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, ft); |
1189 | b6d96bed | ths | tcg_gen_qemu_st64(fp0, t0, ctx->mem_idx); |
1190 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
1191 | b6d96bed | ths | } |
1192 | 6ea83fed | bellard | opn = "sdc1";
|
1193 | 6ea83fed | bellard | break;
|
1194 | 6ea83fed | bellard | default:
|
1195 | 923617a3 | ths | MIPS_INVAL(opn); |
1196 | e397ee33 | ths | generate_exception(ctx, EXCP_RI); |
1197 | 78723684 | ths | goto out;
|
1198 | 6ea83fed | bellard | } |
1199 | 6ea83fed | bellard | MIPS_DEBUG("%s %s, %d(%s)", opn, fregnames[ft], offset, regnames[base]);
|
1200 | 78723684 | ths | out:
|
1201 | 78723684 | ths | tcg_temp_free(t0); |
1202 | 6ea83fed | bellard | } |
1203 | 6ea83fed | bellard | |
1204 | 6af0bf9c | bellard | /* Arithmetic with immediate operand */
|
1205 | e189e748 | ths | static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc, |
1206 | e189e748 | ths | int rt, int rs, int16_t imm) |
1207 | 6af0bf9c | bellard | { |
1208 | f469b9db | ths | target_ulong uimm; |
1209 | 923617a3 | ths | const char *opn = "imm arith"; |
1210 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
1211 | 6af0bf9c | bellard | |
1212 | 7a387fff | ths | if (rt == 0 && opc != OPC_ADDI && opc != OPC_DADDI) { |
1213 | ead9360e | ths | /* If no destination, treat it as a NOP.
|
1214 | ead9360e | ths | For addi, we must generate the overflow exception when needed. */
|
1215 | 6af0bf9c | bellard | MIPS_DEBUG("NOP");
|
1216 | 78723684 | ths | goto out;
|
1217 | 6af0bf9c | bellard | } |
1218 | 5a63bcb2 | ths | uimm = (uint16_t)imm; |
1219 | 5a63bcb2 | ths | switch (opc) {
|
1220 | 5a63bcb2 | ths | case OPC_ADDI:
|
1221 | 5a63bcb2 | ths | case OPC_ADDIU:
|
1222 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
1223 | 5a63bcb2 | ths | case OPC_DADDI:
|
1224 | 5a63bcb2 | ths | case OPC_DADDIU:
|
1225 | 5a63bcb2 | ths | #endif
|
1226 | 5a63bcb2 | ths | case OPC_SLTI:
|
1227 | 5a63bcb2 | ths | case OPC_SLTIU:
|
1228 | f469b9db | ths | uimm = (target_long)imm; /* Sign extend to 32/64 bits */
|
1229 | 5a63bcb2 | ths | /* Fall through. */
|
1230 | 5a63bcb2 | ths | case OPC_ANDI:
|
1231 | 5a63bcb2 | ths | case OPC_ORI:
|
1232 | 5a63bcb2 | ths | case OPC_XORI:
|
1233 | 78723684 | ths | gen_load_gpr(t0, rs); |
1234 | 5a63bcb2 | ths | break;
|
1235 | 5a63bcb2 | ths | case OPC_LUI:
|
1236 | 78723684 | ths | tcg_gen_movi_tl(t0, imm << 16);
|
1237 | 5a63bcb2 | ths | break;
|
1238 | 5a63bcb2 | ths | case OPC_SLL:
|
1239 | 5a63bcb2 | ths | case OPC_SRA:
|
1240 | 5a63bcb2 | ths | case OPC_SRL:
|
1241 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
1242 | 5a63bcb2 | ths | case OPC_DSLL:
|
1243 | 5a63bcb2 | ths | case OPC_DSRA:
|
1244 | 5a63bcb2 | ths | case OPC_DSRL:
|
1245 | 5a63bcb2 | ths | case OPC_DSLL32:
|
1246 | 5a63bcb2 | ths | case OPC_DSRA32:
|
1247 | 5a63bcb2 | ths | case OPC_DSRL32:
|
1248 | 5a63bcb2 | ths | #endif
|
1249 | 5a63bcb2 | ths | uimm &= 0x1f;
|
1250 | 78723684 | ths | gen_load_gpr(t0, rs); |
1251 | 5a63bcb2 | ths | break;
|
1252 | 6af0bf9c | bellard | } |
1253 | 6af0bf9c | bellard | switch (opc) {
|
1254 | 6af0bf9c | bellard | case OPC_ADDI:
|
1255 | 48d38ca5 | ths | { |
1256 | a7812ae4 | pbrook | TCGv r_tmp1 = tcg_temp_new(); |
1257 | a7812ae4 | pbrook | TCGv r_tmp2 = tcg_temp_new(); |
1258 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1259 | 48d38ca5 | ths | |
1260 | 48d38ca5 | ths | save_cpu_state(ctx, 1);
|
1261 | 78723684 | ths | tcg_gen_ext32s_tl(r_tmp1, t0); |
1262 | 78723684 | ths | tcg_gen_addi_tl(t0, r_tmp1, uimm); |
1263 | 48d38ca5 | ths | |
1264 | 507563e8 | aurel32 | tcg_gen_xori_tl(r_tmp1, r_tmp1, ~uimm); |
1265 | 78723684 | ths | tcg_gen_xori_tl(r_tmp2, t0, uimm); |
1266 | 48d38ca5 | ths | tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2); |
1267 | 4f57689a | ths | tcg_temp_free(r_tmp2); |
1268 | 507563e8 | aurel32 | tcg_gen_brcondi_tl(TCG_COND_GE, r_tmp1, 0, l1);
|
1269 | 48d38ca5 | ths | /* operands of same sign, result different sign */
|
1270 | 48d38ca5 | ths | generate_exception(ctx, EXCP_OVERFLOW); |
1271 | 48d38ca5 | ths | gen_set_label(l1); |
1272 | 507563e8 | aurel32 | tcg_temp_free(r_tmp1); |
1273 | 48d38ca5 | ths | |
1274 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1275 | 48d38ca5 | ths | } |
1276 | 6af0bf9c | bellard | opn = "addi";
|
1277 | 6af0bf9c | bellard | break;
|
1278 | 6af0bf9c | bellard | case OPC_ADDIU:
|
1279 | 78723684 | ths | tcg_gen_addi_tl(t0, t0, uimm); |
1280 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1281 | 6af0bf9c | bellard | opn = "addiu";
|
1282 | 6af0bf9c | bellard | break;
|
1283 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
1284 | 7a387fff | ths | case OPC_DADDI:
|
1285 | 48d38ca5 | ths | { |
1286 | a7812ae4 | pbrook | TCGv r_tmp1 = tcg_temp_new(); |
1287 | a7812ae4 | pbrook | TCGv r_tmp2 = tcg_temp_new(); |
1288 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1289 | 48d38ca5 | ths | |
1290 | 48d38ca5 | ths | save_cpu_state(ctx, 1);
|
1291 | 78723684 | ths | tcg_gen_mov_tl(r_tmp1, t0); |
1292 | 78723684 | ths | tcg_gen_addi_tl(t0, t0, uimm); |
1293 | 48d38ca5 | ths | |
1294 | 507563e8 | aurel32 | tcg_gen_xori_tl(r_tmp1, r_tmp1, ~uimm); |
1295 | 78723684 | ths | tcg_gen_xori_tl(r_tmp2, t0, uimm); |
1296 | 48d38ca5 | ths | tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2); |
1297 | 4f57689a | ths | tcg_temp_free(r_tmp2); |
1298 | 507563e8 | aurel32 | tcg_gen_brcondi_tl(TCG_COND_GE, r_tmp1, 0, l1);
|
1299 | 48d38ca5 | ths | /* operands of same sign, result different sign */
|
1300 | 48d38ca5 | ths | generate_exception(ctx, EXCP_OVERFLOW); |
1301 | 48d38ca5 | ths | gen_set_label(l1); |
1302 | 507563e8 | aurel32 | tcg_temp_free(r_tmp1); |
1303 | 48d38ca5 | ths | } |
1304 | 7a387fff | ths | opn = "daddi";
|
1305 | 7a387fff | ths | break;
|
1306 | 7a387fff | ths | case OPC_DADDIU:
|
1307 | 78723684 | ths | tcg_gen_addi_tl(t0, t0, uimm); |
1308 | 7a387fff | ths | opn = "daddiu";
|
1309 | 7a387fff | ths | break;
|
1310 | 7a387fff | ths | #endif
|
1311 | 6af0bf9c | bellard | case OPC_SLTI:
|
1312 | 92e90443 | aurel32 | gen_op_lti(t0, t0, uimm); |
1313 | 6af0bf9c | bellard | opn = "slti";
|
1314 | 6af0bf9c | bellard | break;
|
1315 | 6af0bf9c | bellard | case OPC_SLTIU:
|
1316 | 92e90443 | aurel32 | gen_op_ltiu(t0, t0, uimm); |
1317 | 6af0bf9c | bellard | opn = "sltiu";
|
1318 | 6af0bf9c | bellard | break;
|
1319 | 6af0bf9c | bellard | case OPC_ANDI:
|
1320 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, uimm); |
1321 | 6af0bf9c | bellard | opn = "andi";
|
1322 | 6af0bf9c | bellard | break;
|
1323 | 6af0bf9c | bellard | case OPC_ORI:
|
1324 | 78723684 | ths | tcg_gen_ori_tl(t0, t0, uimm); |
1325 | 6af0bf9c | bellard | opn = "ori";
|
1326 | 6af0bf9c | bellard | break;
|
1327 | 6af0bf9c | bellard | case OPC_XORI:
|
1328 | 78723684 | ths | tcg_gen_xori_tl(t0, t0, uimm); |
1329 | 6af0bf9c | bellard | opn = "xori";
|
1330 | 6af0bf9c | bellard | break;
|
1331 | 6af0bf9c | bellard | case OPC_LUI:
|
1332 | 6af0bf9c | bellard | opn = "lui";
|
1333 | 6af0bf9c | bellard | break;
|
1334 | 6af0bf9c | bellard | case OPC_SLL:
|
1335 | 78723684 | ths | tcg_gen_shli_tl(t0, t0, uimm); |
1336 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1337 | 6af0bf9c | bellard | opn = "sll";
|
1338 | 6af0bf9c | bellard | break;
|
1339 | 6af0bf9c | bellard | case OPC_SRA:
|
1340 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1341 | 78723684 | ths | tcg_gen_sari_tl(t0, t0, uimm); |
1342 | 6af0bf9c | bellard | opn = "sra";
|
1343 | 6af0bf9c | bellard | break;
|
1344 | 6af0bf9c | bellard | case OPC_SRL:
|
1345 | 5a63bcb2 | ths | switch ((ctx->opcode >> 21) & 0x1f) { |
1346 | 5a63bcb2 | ths | case 0: |
1347 | 507563e8 | aurel32 | if (uimm != 0) { |
1348 | 507563e8 | aurel32 | tcg_gen_ext32u_tl(t0, t0); |
1349 | 507563e8 | aurel32 | tcg_gen_shri_tl(t0, t0, uimm); |
1350 | 507563e8 | aurel32 | } else {
|
1351 | 507563e8 | aurel32 | tcg_gen_ext32s_tl(t0, t0); |
1352 | 507563e8 | aurel32 | } |
1353 | 7a387fff | ths | opn = "srl";
|
1354 | 5a63bcb2 | ths | break;
|
1355 | 5a63bcb2 | ths | case 1: |
1356 | e189e748 | ths | /* rotr is decoded as srl on non-R2 CPUs */
|
1357 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1358 | 48d38ca5 | ths | if (uimm != 0) { |
1359 | a7812ae4 | pbrook | TCGv_i32 r_tmp1 = tcg_temp_new_i32(); |
1360 | 48d38ca5 | ths | |
1361 | 78723684 | ths | tcg_gen_trunc_tl_i32(r_tmp1, t0); |
1362 | e00fcff7 | aurel32 | tcg_gen_rotri_i32(r_tmp1, r_tmp1, uimm); |
1363 | 78723684 | ths | tcg_gen_ext_i32_tl(t0, r_tmp1); |
1364 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp1); |
1365 | 48d38ca5 | ths | } |
1366 | e189e748 | ths | opn = "rotr";
|
1367 | e189e748 | ths | } else {
|
1368 | 507563e8 | aurel32 | if (uimm != 0) { |
1369 | 507563e8 | aurel32 | tcg_gen_ext32u_tl(t0, t0); |
1370 | 507563e8 | aurel32 | tcg_gen_shri_tl(t0, t0, uimm); |
1371 | 507563e8 | aurel32 | } else {
|
1372 | 507563e8 | aurel32 | tcg_gen_ext32s_tl(t0, t0); |
1373 | 507563e8 | aurel32 | } |
1374 | e189e748 | ths | opn = "srl";
|
1375 | e189e748 | ths | } |
1376 | 5a63bcb2 | ths | break;
|
1377 | 5a63bcb2 | ths | default:
|
1378 | 5a63bcb2 | ths | MIPS_INVAL("invalid srl flag");
|
1379 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1380 | 5a63bcb2 | ths | break;
|
1381 | 5a63bcb2 | ths | } |
1382 | 7a387fff | ths | break;
|
1383 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
1384 | 7a387fff | ths | case OPC_DSLL:
|
1385 | 78723684 | ths | tcg_gen_shli_tl(t0, t0, uimm); |
1386 | 7a387fff | ths | opn = "dsll";
|
1387 | 7a387fff | ths | break;
|
1388 | 7a387fff | ths | case OPC_DSRA:
|
1389 | 78723684 | ths | tcg_gen_sari_tl(t0, t0, uimm); |
1390 | 7a387fff | ths | opn = "dsra";
|
1391 | 7a387fff | ths | break;
|
1392 | 7a387fff | ths | case OPC_DSRL:
|
1393 | 5a63bcb2 | ths | switch ((ctx->opcode >> 21) & 0x1f) { |
1394 | 5a63bcb2 | ths | case 0: |
1395 | 78723684 | ths | tcg_gen_shri_tl(t0, t0, uimm); |
1396 | 7a387fff | ths | opn = "dsrl";
|
1397 | 5a63bcb2 | ths | break;
|
1398 | 5a63bcb2 | ths | case 1: |
1399 | e189e748 | ths | /* drotr is decoded as dsrl on non-R2 CPUs */
|
1400 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1401 | 48d38ca5 | ths | if (uimm != 0) { |
1402 | e00fcff7 | aurel32 | tcg_gen_rotri_tl(t0, t0, uimm); |
1403 | 48d38ca5 | ths | } |
1404 | e189e748 | ths | opn = "drotr";
|
1405 | e189e748 | ths | } else {
|
1406 | 78723684 | ths | tcg_gen_shri_tl(t0, t0, uimm); |
1407 | e189e748 | ths | opn = "dsrl";
|
1408 | e189e748 | ths | } |
1409 | 5a63bcb2 | ths | break;
|
1410 | 5a63bcb2 | ths | default:
|
1411 | 5a63bcb2 | ths | MIPS_INVAL("invalid dsrl flag");
|
1412 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1413 | 5a63bcb2 | ths | break;
|
1414 | 5a63bcb2 | ths | } |
1415 | 7a387fff | ths | break;
|
1416 | 7a387fff | ths | case OPC_DSLL32:
|
1417 | 78723684 | ths | tcg_gen_shli_tl(t0, t0, uimm + 32);
|
1418 | 7a387fff | ths | opn = "dsll32";
|
1419 | 7a387fff | ths | break;
|
1420 | 7a387fff | ths | case OPC_DSRA32:
|
1421 | 78723684 | ths | tcg_gen_sari_tl(t0, t0, uimm + 32);
|
1422 | 7a387fff | ths | opn = "dsra32";
|
1423 | 7a387fff | ths | break;
|
1424 | 7a387fff | ths | case OPC_DSRL32:
|
1425 | 5a63bcb2 | ths | switch ((ctx->opcode >> 21) & 0x1f) { |
1426 | 5a63bcb2 | ths | case 0: |
1427 | 78723684 | ths | tcg_gen_shri_tl(t0, t0, uimm + 32);
|
1428 | 7a387fff | ths | opn = "dsrl32";
|
1429 | 5a63bcb2 | ths | break;
|
1430 | 5a63bcb2 | ths | case 1: |
1431 | e189e748 | ths | /* drotr32 is decoded as dsrl32 on non-R2 CPUs */
|
1432 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1433 | e00fcff7 | aurel32 | tcg_gen_rotri_tl(t0, t0, uimm + 32);
|
1434 | e189e748 | ths | opn = "drotr32";
|
1435 | e189e748 | ths | } else {
|
1436 | 78723684 | ths | tcg_gen_shri_tl(t0, t0, uimm + 32);
|
1437 | e189e748 | ths | opn = "dsrl32";
|
1438 | e189e748 | ths | } |
1439 | 5a63bcb2 | ths | break;
|
1440 | 5a63bcb2 | ths | default:
|
1441 | 5a63bcb2 | ths | MIPS_INVAL("invalid dsrl32 flag");
|
1442 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1443 | 5a63bcb2 | ths | break;
|
1444 | 5a63bcb2 | ths | } |
1445 | 6af0bf9c | bellard | break;
|
1446 | 7a387fff | ths | #endif
|
1447 | 6af0bf9c | bellard | default:
|
1448 | 923617a3 | ths | MIPS_INVAL(opn); |
1449 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1450 | 78723684 | ths | goto out;
|
1451 | 6af0bf9c | bellard | } |
1452 | 78723684 | ths | gen_store_gpr(t0, rt); |
1453 | 93b12ccc | ths | MIPS_DEBUG("%s %s, %s, " TARGET_FMT_lx, opn, regnames[rt], regnames[rs], uimm);
|
1454 | 78723684 | ths | out:
|
1455 | 78723684 | ths | tcg_temp_free(t0); |
1456 | 6af0bf9c | bellard | } |
1457 | 6af0bf9c | bellard | |
1458 | 6af0bf9c | bellard | /* Arithmetic */
|
1459 | e189e748 | ths | static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc, |
1460 | 6af0bf9c | bellard | int rd, int rs, int rt) |
1461 | 6af0bf9c | bellard | { |
1462 | 923617a3 | ths | const char *opn = "arith"; |
1463 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
1464 | a7812ae4 | pbrook | TCGv t1 = tcg_temp_local_new(); |
1465 | 6af0bf9c | bellard | |
1466 | 7a387fff | ths | if (rd == 0 && opc != OPC_ADD && opc != OPC_SUB |
1467 | 7a387fff | ths | && opc != OPC_DADD && opc != OPC_DSUB) { |
1468 | ead9360e | ths | /* If no destination, treat it as a NOP.
|
1469 | ead9360e | ths | For add & sub, we must generate the overflow exception when needed. */
|
1470 | 6af0bf9c | bellard | MIPS_DEBUG("NOP");
|
1471 | 78723684 | ths | goto out;
|
1472 | 6af0bf9c | bellard | } |
1473 | 78723684 | ths | gen_load_gpr(t0, rs); |
1474 | 185f0762 | ths | /* Specialcase the conventional move operation. */
|
1475 | 185f0762 | ths | if (rt == 0 && (opc == OPC_ADDU || opc == OPC_DADDU |
1476 | 185f0762 | ths | || opc == OPC_SUBU || opc == OPC_DSUBU)) { |
1477 | 78723684 | ths | gen_store_gpr(t0, rd); |
1478 | 78723684 | ths | goto out;
|
1479 | 185f0762 | ths | } |
1480 | 78723684 | ths | gen_load_gpr(t1, rt); |
1481 | 6af0bf9c | bellard | switch (opc) {
|
1482 | 6af0bf9c | bellard | case OPC_ADD:
|
1483 | 48d38ca5 | ths | { |
1484 | a7812ae4 | pbrook | TCGv r_tmp1 = tcg_temp_new(); |
1485 | a7812ae4 | pbrook | TCGv r_tmp2 = tcg_temp_new(); |
1486 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1487 | 48d38ca5 | ths | |
1488 | 48d38ca5 | ths | save_cpu_state(ctx, 1);
|
1489 | 78723684 | ths | tcg_gen_ext32s_tl(r_tmp1, t0); |
1490 | 78723684 | ths | tcg_gen_ext32s_tl(r_tmp2, t1); |
1491 | 78723684 | ths | tcg_gen_add_tl(t0, r_tmp1, r_tmp2); |
1492 | 48d38ca5 | ths | |
1493 | 78723684 | ths | tcg_gen_xor_tl(r_tmp1, r_tmp1, t1); |
1494 | 48d38ca5 | ths | tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
|
1495 | 78723684 | ths | tcg_gen_xor_tl(r_tmp2, t0, t1); |
1496 | 48d38ca5 | ths | tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2); |
1497 | 4f57689a | ths | tcg_temp_free(r_tmp2); |
1498 | 507563e8 | aurel32 | tcg_gen_brcondi_tl(TCG_COND_GE, r_tmp1, 0, l1);
|
1499 | 48d38ca5 | ths | /* operands of same sign, result different sign */
|
1500 | 48d38ca5 | ths | generate_exception(ctx, EXCP_OVERFLOW); |
1501 | 48d38ca5 | ths | gen_set_label(l1); |
1502 | 507563e8 | aurel32 | tcg_temp_free(r_tmp1); |
1503 | 48d38ca5 | ths | |
1504 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1505 | 48d38ca5 | ths | } |
1506 | 6af0bf9c | bellard | opn = "add";
|
1507 | 6af0bf9c | bellard | break;
|
1508 | 6af0bf9c | bellard | case OPC_ADDU:
|
1509 | 78723684 | ths | tcg_gen_add_tl(t0, t0, t1); |
1510 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1511 | 6af0bf9c | bellard | opn = "addu";
|
1512 | 6af0bf9c | bellard | break;
|
1513 | 6af0bf9c | bellard | case OPC_SUB:
|
1514 | 48d38ca5 | ths | { |
1515 | a7812ae4 | pbrook | TCGv r_tmp1 = tcg_temp_new(); |
1516 | a7812ae4 | pbrook | TCGv r_tmp2 = tcg_temp_new(); |
1517 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1518 | 48d38ca5 | ths | |
1519 | 48d38ca5 | ths | save_cpu_state(ctx, 1);
|
1520 | 78723684 | ths | tcg_gen_ext32s_tl(r_tmp1, t0); |
1521 | 78723684 | ths | tcg_gen_ext32s_tl(r_tmp2, t1); |
1522 | 78723684 | ths | tcg_gen_sub_tl(t0, r_tmp1, r_tmp2); |
1523 | 48d38ca5 | ths | |
1524 | 78723684 | ths | tcg_gen_xor_tl(r_tmp2, r_tmp1, t1); |
1525 | 78723684 | ths | tcg_gen_xor_tl(r_tmp1, r_tmp1, t0); |
1526 | 48d38ca5 | ths | tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2); |
1527 | 4f57689a | ths | tcg_temp_free(r_tmp2); |
1528 | 507563e8 | aurel32 | tcg_gen_brcondi_tl(TCG_COND_GE, r_tmp1, 0, l1);
|
1529 | 48d38ca5 | ths | /* operands of different sign, first operand and result different sign */
|
1530 | 48d38ca5 | ths | generate_exception(ctx, EXCP_OVERFLOW); |
1531 | 48d38ca5 | ths | gen_set_label(l1); |
1532 | 507563e8 | aurel32 | tcg_temp_free(r_tmp1); |
1533 | 48d38ca5 | ths | |
1534 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1535 | 48d38ca5 | ths | } |
1536 | 6af0bf9c | bellard | opn = "sub";
|
1537 | 6af0bf9c | bellard | break;
|
1538 | 6af0bf9c | bellard | case OPC_SUBU:
|
1539 | 78723684 | ths | tcg_gen_sub_tl(t0, t0, t1); |
1540 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1541 | 6af0bf9c | bellard | opn = "subu";
|
1542 | 6af0bf9c | bellard | break;
|
1543 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
1544 | 7a387fff | ths | case OPC_DADD:
|
1545 | 48d38ca5 | ths | { |
1546 | a7812ae4 | pbrook | TCGv r_tmp1 = tcg_temp_new(); |
1547 | a7812ae4 | pbrook | TCGv r_tmp2 = tcg_temp_new(); |
1548 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1549 | 48d38ca5 | ths | |
1550 | 48d38ca5 | ths | save_cpu_state(ctx, 1);
|
1551 | 78723684 | ths | tcg_gen_mov_tl(r_tmp1, t0); |
1552 | 78723684 | ths | tcg_gen_add_tl(t0, t0, t1); |
1553 | 48d38ca5 | ths | |
1554 | 78723684 | ths | tcg_gen_xor_tl(r_tmp1, r_tmp1, t1); |
1555 | 48d38ca5 | ths | tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
|
1556 | 78723684 | ths | tcg_gen_xor_tl(r_tmp2, t0, t1); |
1557 | 48d38ca5 | ths | tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2); |
1558 | 4f57689a | ths | tcg_temp_free(r_tmp2); |
1559 | 507563e8 | aurel32 | tcg_gen_brcondi_tl(TCG_COND_GE, r_tmp1, 0, l1);
|
1560 | 48d38ca5 | ths | /* operands of same sign, result different sign */
|
1561 | 48d38ca5 | ths | generate_exception(ctx, EXCP_OVERFLOW); |
1562 | 48d38ca5 | ths | gen_set_label(l1); |
1563 | 507563e8 | aurel32 | tcg_temp_free(r_tmp1); |
1564 | 48d38ca5 | ths | } |
1565 | 7a387fff | ths | opn = "dadd";
|
1566 | 7a387fff | ths | break;
|
1567 | 7a387fff | ths | case OPC_DADDU:
|
1568 | 78723684 | ths | tcg_gen_add_tl(t0, t0, t1); |
1569 | 7a387fff | ths | opn = "daddu";
|
1570 | 7a387fff | ths | break;
|
1571 | 7a387fff | ths | case OPC_DSUB:
|
1572 | 48d38ca5 | ths | { |
1573 | a7812ae4 | pbrook | TCGv r_tmp1 = tcg_temp_new(); |
1574 | a7812ae4 | pbrook | TCGv r_tmp2 = tcg_temp_new(); |
1575 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1576 | 48d38ca5 | ths | |
1577 | 48d38ca5 | ths | save_cpu_state(ctx, 1);
|
1578 | 78723684 | ths | tcg_gen_mov_tl(r_tmp1, t0); |
1579 | 78723684 | ths | tcg_gen_sub_tl(t0, t0, t1); |
1580 | 48d38ca5 | ths | |
1581 | 78723684 | ths | tcg_gen_xor_tl(r_tmp2, r_tmp1, t1); |
1582 | 78723684 | ths | tcg_gen_xor_tl(r_tmp1, r_tmp1, t0); |
1583 | 48d38ca5 | ths | tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2); |
1584 | 4f57689a | ths | tcg_temp_free(r_tmp2); |
1585 | 507563e8 | aurel32 | tcg_gen_brcondi_tl(TCG_COND_GE, r_tmp1, 0, l1);
|
1586 | 48d38ca5 | ths | /* operands of different sign, first operand and result different sign */
|
1587 | 48d38ca5 | ths | generate_exception(ctx, EXCP_OVERFLOW); |
1588 | 48d38ca5 | ths | gen_set_label(l1); |
1589 | 507563e8 | aurel32 | tcg_temp_free(r_tmp1); |
1590 | 48d38ca5 | ths | } |
1591 | 7a387fff | ths | opn = "dsub";
|
1592 | 7a387fff | ths | break;
|
1593 | 7a387fff | ths | case OPC_DSUBU:
|
1594 | 78723684 | ths | tcg_gen_sub_tl(t0, t0, t1); |
1595 | 7a387fff | ths | opn = "dsubu";
|
1596 | 7a387fff | ths | break;
|
1597 | 7a387fff | ths | #endif
|
1598 | 6af0bf9c | bellard | case OPC_SLT:
|
1599 | 92e90443 | aurel32 | gen_op_lt(t0, t0, t1); |
1600 | 6af0bf9c | bellard | opn = "slt";
|
1601 | 6af0bf9c | bellard | break;
|
1602 | 6af0bf9c | bellard | case OPC_SLTU:
|
1603 | 92e90443 | aurel32 | gen_op_ltu(t0, t0, t1); |
1604 | 6af0bf9c | bellard | opn = "sltu";
|
1605 | 6af0bf9c | bellard | break;
|
1606 | 6af0bf9c | bellard | case OPC_AND:
|
1607 | 78723684 | ths | tcg_gen_and_tl(t0, t0, t1); |
1608 | 6af0bf9c | bellard | opn = "and";
|
1609 | 6af0bf9c | bellard | break;
|
1610 | 6af0bf9c | bellard | case OPC_NOR:
|
1611 | a3fe9013 | aurel32 | tcg_gen_nor_tl(t0, t0, t1); |
1612 | 6af0bf9c | bellard | opn = "nor";
|
1613 | 6af0bf9c | bellard | break;
|
1614 | 6af0bf9c | bellard | case OPC_OR:
|
1615 | 78723684 | ths | tcg_gen_or_tl(t0, t0, t1); |
1616 | 6af0bf9c | bellard | opn = "or";
|
1617 | 6af0bf9c | bellard | break;
|
1618 | 6af0bf9c | bellard | case OPC_XOR:
|
1619 | 78723684 | ths | tcg_gen_xor_tl(t0, t0, t1); |
1620 | 6af0bf9c | bellard | opn = "xor";
|
1621 | 6af0bf9c | bellard | break;
|
1622 | 6af0bf9c | bellard | case OPC_MUL:
|
1623 | 78723684 | ths | tcg_gen_mul_tl(t0, t0, t1); |
1624 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1625 | 6af0bf9c | bellard | opn = "mul";
|
1626 | 6af0bf9c | bellard | break;
|
1627 | 6af0bf9c | bellard | case OPC_MOVN:
|
1628 | 20c4c97c | ths | { |
1629 | 20c4c97c | ths | int l1 = gen_new_label();
|
1630 | 20c4c97c | ths | |
1631 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
|
1632 | 78723684 | ths | gen_store_gpr(t0, rd); |
1633 | 20c4c97c | ths | gen_set_label(l1); |
1634 | 20c4c97c | ths | } |
1635 | 6af0bf9c | bellard | opn = "movn";
|
1636 | 6af0bf9c | bellard | goto print;
|
1637 | 6af0bf9c | bellard | case OPC_MOVZ:
|
1638 | 20c4c97c | ths | { |
1639 | 20c4c97c | ths | int l1 = gen_new_label();
|
1640 | 20c4c97c | ths | |
1641 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_NE, t1, 0, l1);
|
1642 | 78723684 | ths | gen_store_gpr(t0, rd); |
1643 | 20c4c97c | ths | gen_set_label(l1); |
1644 | 20c4c97c | ths | } |
1645 | 6af0bf9c | bellard | opn = "movz";
|
1646 | 6af0bf9c | bellard | goto print;
|
1647 | 6af0bf9c | bellard | case OPC_SLLV:
|
1648 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x1f);
|
1649 | 78723684 | ths | tcg_gen_shl_tl(t0, t1, t0); |
1650 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1651 | 6af0bf9c | bellard | opn = "sllv";
|
1652 | 6af0bf9c | bellard | break;
|
1653 | 6af0bf9c | bellard | case OPC_SRAV:
|
1654 | 78723684 | ths | tcg_gen_ext32s_tl(t1, t1); |
1655 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x1f);
|
1656 | 78723684 | ths | tcg_gen_sar_tl(t0, t1, t0); |
1657 | 6af0bf9c | bellard | opn = "srav";
|
1658 | 6af0bf9c | bellard | break;
|
1659 | 6af0bf9c | bellard | case OPC_SRLV:
|
1660 | 5a63bcb2 | ths | switch ((ctx->opcode >> 6) & 0x1f) { |
1661 | 5a63bcb2 | ths | case 0: |
1662 | 78723684 | ths | tcg_gen_ext32u_tl(t1, t1); |
1663 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x1f);
|
1664 | 78723684 | ths | tcg_gen_shr_tl(t0, t1, t0); |
1665 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1666 | 7a387fff | ths | opn = "srlv";
|
1667 | 5a63bcb2 | ths | break;
|
1668 | 5a63bcb2 | ths | case 1: |
1669 | e189e748 | ths | /* rotrv is decoded as srlv on non-R2 CPUs */
|
1670 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1671 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1672 | 48d38ca5 | ths | int l2 = gen_new_label();
|
1673 | 48d38ca5 | ths | |
1674 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x1f);
|
1675 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
1676 | 48d38ca5 | ths | { |
1677 | a7812ae4 | pbrook | TCGv_i32 r_tmp1 = tcg_temp_new_i32(); |
1678 | a7812ae4 | pbrook | TCGv_i32 r_tmp2 = tcg_temp_new_i32(); |
1679 | 48d38ca5 | ths | |
1680 | 78723684 | ths | tcg_gen_trunc_tl_i32(r_tmp1, t0); |
1681 | 78723684 | ths | tcg_gen_trunc_tl_i32(r_tmp2, t1); |
1682 | e00fcff7 | aurel32 | tcg_gen_rotr_i32(r_tmp1, r_tmp1, r_tmp2); |
1683 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp1); |
1684 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp2); |
1685 | 48d38ca5 | ths | tcg_gen_br(l2); |
1686 | 48d38ca5 | ths | } |
1687 | 48d38ca5 | ths | gen_set_label(l1); |
1688 | 78723684 | ths | tcg_gen_mov_tl(t0, t1); |
1689 | 48d38ca5 | ths | gen_set_label(l2); |
1690 | e189e748 | ths | opn = "rotrv";
|
1691 | e189e748 | ths | } else {
|
1692 | 78723684 | ths | tcg_gen_ext32u_tl(t1, t1); |
1693 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x1f);
|
1694 | 78723684 | ths | tcg_gen_shr_tl(t0, t1, t0); |
1695 | 78723684 | ths | tcg_gen_ext32s_tl(t0, t0); |
1696 | e189e748 | ths | opn = "srlv";
|
1697 | e189e748 | ths | } |
1698 | 5a63bcb2 | ths | break;
|
1699 | 5a63bcb2 | ths | default:
|
1700 | 5a63bcb2 | ths | MIPS_INVAL("invalid srlv flag");
|
1701 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1702 | 5a63bcb2 | ths | break;
|
1703 | 5a63bcb2 | ths | } |
1704 | 7a387fff | ths | break;
|
1705 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
1706 | 7a387fff | ths | case OPC_DSLLV:
|
1707 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x3f);
|
1708 | 78723684 | ths | tcg_gen_shl_tl(t0, t1, t0); |
1709 | 7a387fff | ths | opn = "dsllv";
|
1710 | 7a387fff | ths | break;
|
1711 | 7a387fff | ths | case OPC_DSRAV:
|
1712 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x3f);
|
1713 | 78723684 | ths | tcg_gen_sar_tl(t0, t1, t0); |
1714 | 7a387fff | ths | opn = "dsrav";
|
1715 | 7a387fff | ths | break;
|
1716 | 7a387fff | ths | case OPC_DSRLV:
|
1717 | 5a63bcb2 | ths | switch ((ctx->opcode >> 6) & 0x1f) { |
1718 | 5a63bcb2 | ths | case 0: |
1719 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x3f);
|
1720 | 78723684 | ths | tcg_gen_shr_tl(t0, t1, t0); |
1721 | 7a387fff | ths | opn = "dsrlv";
|
1722 | 5a63bcb2 | ths | break;
|
1723 | 5a63bcb2 | ths | case 1: |
1724 | e189e748 | ths | /* drotrv is decoded as dsrlv on non-R2 CPUs */
|
1725 | e189e748 | ths | if (env->insn_flags & ISA_MIPS32R2) {
|
1726 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1727 | 48d38ca5 | ths | int l2 = gen_new_label();
|
1728 | 48d38ca5 | ths | |
1729 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x3f);
|
1730 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
1731 | 48d38ca5 | ths | { |
1732 | e00fcff7 | aurel32 | tcg_gen_rotr_tl(t0, t1, t0); |
1733 | 48d38ca5 | ths | tcg_gen_br(l2); |
1734 | 48d38ca5 | ths | } |
1735 | 48d38ca5 | ths | gen_set_label(l1); |
1736 | 78723684 | ths | tcg_gen_mov_tl(t0, t1); |
1737 | 48d38ca5 | ths | gen_set_label(l2); |
1738 | e189e748 | ths | opn = "drotrv";
|
1739 | e189e748 | ths | } else {
|
1740 | 78723684 | ths | tcg_gen_andi_tl(t0, t0, 0x3f);
|
1741 | 78723684 | ths | tcg_gen_shr_tl(t0, t1, t0); |
1742 | e189e748 | ths | opn = "dsrlv";
|
1743 | e189e748 | ths | } |
1744 | 5a63bcb2 | ths | break;
|
1745 | 5a63bcb2 | ths | default:
|
1746 | 5a63bcb2 | ths | MIPS_INVAL("invalid dsrlv flag");
|
1747 | 5a63bcb2 | ths | generate_exception(ctx, EXCP_RI); |
1748 | 5a63bcb2 | ths | break;
|
1749 | 5a63bcb2 | ths | } |
1750 | 6af0bf9c | bellard | break;
|
1751 | 7a387fff | ths | #endif
|
1752 | 6af0bf9c | bellard | default:
|
1753 | 923617a3 | ths | MIPS_INVAL(opn); |
1754 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1755 | 78723684 | ths | goto out;
|
1756 | 6af0bf9c | bellard | } |
1757 | 78723684 | ths | gen_store_gpr(t0, rd); |
1758 | 6af0bf9c | bellard | print:
|
1759 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s, %s, %s", opn, regnames[rd], regnames[rs], regnames[rt]);
|
1760 | 78723684 | ths | out:
|
1761 | 78723684 | ths | tcg_temp_free(t0); |
1762 | 78723684 | ths | tcg_temp_free(t1); |
1763 | 6af0bf9c | bellard | } |
1764 | 6af0bf9c | bellard | |
1765 | 6af0bf9c | bellard | /* Arithmetic on HI/LO registers */
|
1766 | 7a387fff | ths | static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg) |
1767 | 6af0bf9c | bellard | { |
1768 | 923617a3 | ths | const char *opn = "hilo"; |
1769 | 6af0bf9c | bellard | |
1770 | 6af0bf9c | bellard | if (reg == 0 && (opc == OPC_MFHI || opc == OPC_MFLO)) { |
1771 | ead9360e | ths | /* Treat as NOP. */
|
1772 | 6af0bf9c | bellard | MIPS_DEBUG("NOP");
|
1773 | a1f6684d | aurel32 | return;
|
1774 | 6af0bf9c | bellard | } |
1775 | 6af0bf9c | bellard | switch (opc) {
|
1776 | 6af0bf9c | bellard | case OPC_MFHI:
|
1777 | a1f6684d | aurel32 | tcg_gen_mov_tl(cpu_gpr[reg], cpu_HI[0]);
|
1778 | 6af0bf9c | bellard | opn = "mfhi";
|
1779 | 6af0bf9c | bellard | break;
|
1780 | 6af0bf9c | bellard | case OPC_MFLO:
|
1781 | a1f6684d | aurel32 | tcg_gen_mov_tl(cpu_gpr[reg], cpu_LO[0]);
|
1782 | 6af0bf9c | bellard | opn = "mflo";
|
1783 | 6af0bf9c | bellard | break;
|
1784 | 6af0bf9c | bellard | case OPC_MTHI:
|
1785 | a1f6684d | aurel32 | if (reg != 0) |
1786 | a1f6684d | aurel32 | tcg_gen_mov_tl(cpu_HI[0], cpu_gpr[reg]);
|
1787 | a1f6684d | aurel32 | else
|
1788 | a1f6684d | aurel32 | tcg_gen_movi_tl(cpu_HI[0], 0); |
1789 | 6af0bf9c | bellard | opn = "mthi";
|
1790 | 6af0bf9c | bellard | break;
|
1791 | 6af0bf9c | bellard | case OPC_MTLO:
|
1792 | a1f6684d | aurel32 | if (reg != 0) |
1793 | a1f6684d | aurel32 | tcg_gen_mov_tl(cpu_LO[0], cpu_gpr[reg]);
|
1794 | a1f6684d | aurel32 | else
|
1795 | a1f6684d | aurel32 | tcg_gen_movi_tl(cpu_LO[0], 0); |
1796 | 6af0bf9c | bellard | opn = "mtlo";
|
1797 | 6af0bf9c | bellard | break;
|
1798 | 6af0bf9c | bellard | default:
|
1799 | 923617a3 | ths | MIPS_INVAL(opn); |
1800 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
1801 | a1f6684d | aurel32 | return;
|
1802 | 6af0bf9c | bellard | } |
1803 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s", opn, regnames[reg]);
|
1804 | 6af0bf9c | bellard | } |
1805 | 6af0bf9c | bellard | |
1806 | 7a387fff | ths | static void gen_muldiv (DisasContext *ctx, uint32_t opc, |
1807 | 6af0bf9c | bellard | int rs, int rt) |
1808 | 6af0bf9c | bellard | { |
1809 | 923617a3 | ths | const char *opn = "mul/div"; |
1810 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
1811 | a7812ae4 | pbrook | TCGv t1 = tcg_temp_local_new(); |
1812 | 6af0bf9c | bellard | |
1813 | 78723684 | ths | gen_load_gpr(t0, rs); |
1814 | 78723684 | ths | gen_load_gpr(t1, rt); |
1815 | 6af0bf9c | bellard | switch (opc) {
|
1816 | 6af0bf9c | bellard | case OPC_DIV:
|
1817 | 48d38ca5 | ths | { |
1818 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1819 | 48d38ca5 | ths | |
1820 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
|
1821 | 48d38ca5 | ths | { |
1822 | b10fa3c9 | aurel32 | int l2 = gen_new_label();
|
1823 | a7812ae4 | pbrook | TCGv_i32 r_tmp1 = tcg_temp_local_new_i32(); |
1824 | a7812ae4 | pbrook | TCGv_i32 r_tmp2 = tcg_temp_local_new_i32(); |
1825 | a7812ae4 | pbrook | TCGv_i32 r_tmp3 = tcg_temp_local_new_i32(); |
1826 | b10fa3c9 | aurel32 | |
1827 | b10fa3c9 | aurel32 | tcg_gen_trunc_tl_i32(r_tmp1, t0); |
1828 | b10fa3c9 | aurel32 | tcg_gen_trunc_tl_i32(r_tmp2, t1); |
1829 | b10fa3c9 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_NE, r_tmp1, -1 << 31, l2); |
1830 | b10fa3c9 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_NE, r_tmp2, -1, l2);
|
1831 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_LO[0], t0);
|
1832 | b10fa3c9 | aurel32 | tcg_gen_movi_tl(cpu_HI[0], 0); |
1833 | b10fa3c9 | aurel32 | tcg_gen_br(l1); |
1834 | b10fa3c9 | aurel32 | gen_set_label(l2); |
1835 | b10fa3c9 | aurel32 | tcg_gen_div_i32(r_tmp3, r_tmp1, r_tmp2); |
1836 | b10fa3c9 | aurel32 | tcg_gen_rem_i32(r_tmp2, r_tmp1, r_tmp2); |
1837 | b10fa3c9 | aurel32 | tcg_gen_ext_i32_tl(cpu_LO[0], r_tmp3);
|
1838 | b10fa3c9 | aurel32 | tcg_gen_ext_i32_tl(cpu_HI[0], r_tmp2);
|
1839 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp1); |
1840 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp2); |
1841 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp3); |
1842 | 48d38ca5 | ths | } |
1843 | 48d38ca5 | ths | gen_set_label(l1); |
1844 | 48d38ca5 | ths | } |
1845 | 6af0bf9c | bellard | opn = "div";
|
1846 | 6af0bf9c | bellard | break;
|
1847 | 6af0bf9c | bellard | case OPC_DIVU:
|
1848 | 48d38ca5 | ths | { |
1849 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1850 | 48d38ca5 | ths | |
1851 | 78723684 | ths | tcg_gen_ext32s_tl(t1, t1); |
1852 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
|
1853 | 48d38ca5 | ths | { |
1854 | a7812ae4 | pbrook | TCGv_i32 r_tmp1 = tcg_temp_new_i32(); |
1855 | a7812ae4 | pbrook | TCGv_i32 r_tmp2 = tcg_temp_new_i32(); |
1856 | a7812ae4 | pbrook | TCGv_i32 r_tmp3 = tcg_temp_new_i32(); |
1857 | 48d38ca5 | ths | |
1858 | 78723684 | ths | tcg_gen_trunc_tl_i32(r_tmp1, t0); |
1859 | 78723684 | ths | tcg_gen_trunc_tl_i32(r_tmp2, t1); |
1860 | 48d38ca5 | ths | tcg_gen_divu_i32(r_tmp3, r_tmp1, r_tmp2); |
1861 | 48d38ca5 | ths | tcg_gen_remu_i32(r_tmp1, r_tmp1, r_tmp2); |
1862 | b10fa3c9 | aurel32 | tcg_gen_ext_i32_tl(cpu_LO[0], r_tmp3);
|
1863 | b10fa3c9 | aurel32 | tcg_gen_ext_i32_tl(cpu_HI[0], r_tmp1);
|
1864 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp1); |
1865 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp2); |
1866 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp3); |
1867 | 48d38ca5 | ths | } |
1868 | 48d38ca5 | ths | gen_set_label(l1); |
1869 | 48d38ca5 | ths | } |
1870 | 6af0bf9c | bellard | opn = "divu";
|
1871 | 6af0bf9c | bellard | break;
|
1872 | 6af0bf9c | bellard | case OPC_MULT:
|
1873 | 214c465f | ths | { |
1874 | a7812ae4 | pbrook | TCGv_i64 r_tmp1 = tcg_temp_new_i64(); |
1875 | a7812ae4 | pbrook | TCGv_i64 r_tmp2 = tcg_temp_new_i64(); |
1876 | 214c465f | ths | |
1877 | 78723684 | ths | tcg_gen_ext_tl_i64(r_tmp1, t0); |
1878 | 78723684 | ths | tcg_gen_ext_tl_i64(r_tmp2, t1); |
1879 | 214c465f | ths | tcg_gen_mul_i64(r_tmp1, r_tmp1, r_tmp2); |
1880 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp2); |
1881 | 78723684 | ths | tcg_gen_trunc_i64_tl(t0, r_tmp1); |
1882 | 214c465f | ths | tcg_gen_shri_i64(r_tmp1, r_tmp1, 32);
|
1883 | 78723684 | ths | tcg_gen_trunc_i64_tl(t1, r_tmp1); |
1884 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp1); |
1885 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_LO[0], t0);
|
1886 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_HI[0], t1);
|
1887 | 214c465f | ths | } |
1888 | 6af0bf9c | bellard | opn = "mult";
|
1889 | 6af0bf9c | bellard | break;
|
1890 | 6af0bf9c | bellard | case OPC_MULTU:
|
1891 | 214c465f | ths | { |
1892 | a7812ae4 | pbrook | TCGv_i64 r_tmp1 = tcg_temp_new_i64(); |
1893 | a7812ae4 | pbrook | TCGv_i64 r_tmp2 = tcg_temp_new_i64(); |
1894 | 214c465f | ths | |
1895 | 78723684 | ths | tcg_gen_ext32u_tl(t0, t0); |
1896 | 78723684 | ths | tcg_gen_ext32u_tl(t1, t1); |
1897 | 78723684 | ths | tcg_gen_extu_tl_i64(r_tmp1, t0); |
1898 | 78723684 | ths | tcg_gen_extu_tl_i64(r_tmp2, t1); |
1899 | 214c465f | ths | tcg_gen_mul_i64(r_tmp1, r_tmp1, r_tmp2); |
1900 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp2); |
1901 | 78723684 | ths | tcg_gen_trunc_i64_tl(t0, r_tmp1); |
1902 | 214c465f | ths | tcg_gen_shri_i64(r_tmp1, r_tmp1, 32);
|
1903 | 78723684 | ths | tcg_gen_trunc_i64_tl(t1, r_tmp1); |
1904 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp1); |
1905 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_LO[0], t0);
|
1906 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_HI[0], t1);
|
1907 | 214c465f | ths | } |
1908 | 6af0bf9c | bellard | opn = "multu";
|
1909 | 6af0bf9c | bellard | break;
|
1910 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
1911 | 7a387fff | ths | case OPC_DDIV:
|
1912 | 48d38ca5 | ths | { |
1913 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1914 | 48d38ca5 | ths | |
1915 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
|
1916 | 48d38ca5 | ths | { |
1917 | 48d38ca5 | ths | int l2 = gen_new_label();
|
1918 | 48d38ca5 | ths | |
1919 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_NE, t0, -1LL << 63, l2); |
1920 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_NE, t1, -1LL, l2);
|
1921 | b10fa3c9 | aurel32 | tcg_gen_mov_tl(cpu_LO[0], t0);
|
1922 | b10fa3c9 | aurel32 | tcg_gen_movi_tl(cpu_HI[0], 0); |
1923 | b10fa3c9 | aurel32 | tcg_gen_br(l1); |
1924 | 48d38ca5 | ths | gen_set_label(l2); |
1925 | b10fa3c9 | aurel32 | tcg_gen_div_i64(cpu_LO[0], t0, t1);
|
1926 | b10fa3c9 | aurel32 | tcg_gen_rem_i64(cpu_HI[0], t0, t1);
|
1927 | 48d38ca5 | ths | } |
1928 | 48d38ca5 | ths | gen_set_label(l1); |
1929 | 48d38ca5 | ths | } |
1930 | 7a387fff | ths | opn = "ddiv";
|
1931 | 7a387fff | ths | break;
|
1932 | 7a387fff | ths | case OPC_DDIVU:
|
1933 | 48d38ca5 | ths | { |
1934 | 48d38ca5 | ths | int l1 = gen_new_label();
|
1935 | 48d38ca5 | ths | |
1936 | 78723684 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
|
1937 | b10fa3c9 | aurel32 | tcg_gen_divu_i64(cpu_LO[0], t0, t1);
|
1938 | b10fa3c9 | aurel32 | tcg_gen_remu_i64(cpu_HI[0], t0, t1);
|
1939 | 48d38ca5 | ths | gen_set_label(l1); |
1940 | 48d38ca5 | ths | } |
1941 | 7a387fff | ths | opn = "ddivu";
|
1942 | 7a387fff | ths | break;
|
1943 | 7a387fff | ths | case OPC_DMULT:
|
1944 | a7812ae4 | pbrook | gen_helper_dmult(t0, t1); |
1945 | 7a387fff | ths | opn = "dmult";
|
1946 | 7a387fff | ths | break;
|
1947 | 7a387fff | ths | case OPC_DMULTU:
|
1948 | a7812ae4 | pbrook | gen_helper_dmultu(t0, t1); |
1949 | 7a387fff | ths | opn = "dmultu";
|
1950 | 7a387fff | ths | break;
|
1951 | 7a387fff | ths | #endif
|
1952 | 6af0bf9c | bellard | case OPC_MADD:
|
1953 | 214c465f | ths | { |
1954 | a7812ae4 | pbrook | TCGv_i64 r_tmp1 = tcg_temp_new_i64(); |
1955 | a7812ae4 | pbrook | TCGv_i64 r_tmp2 = tcg_temp_new_i64(); |
1956 | 214c465f | ths | |
1957 | 78723684 | ths | tcg_gen_ext_tl_i64(r_tmp1, t0); |
1958 | 78723684 | ths | tcg_gen_ext_tl_i64(r_tmp2, t1); |
1959 | 214c465f | ths | tcg_gen_mul_i64(r_tmp1, r_tmp1, r_tmp2); |
1960 | b10fa3c9 | aurel32 | tcg_gen_concat_tl_i64(r_tmp2, cpu_LO[0], cpu_HI[0]); |
1961 | 214c465f | ths | tcg_gen_add_i64(r_tmp1, r_tmp1, r_tmp2); |
1962 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp2); |
1963 | 78723684 | ths | tcg_gen_trunc_i64_tl(t0, r_tmp1); |
1964 | 214c465f | ths | tcg_gen_shri_i64(r_tmp1, r_tmp1, 32);
|
1965 | 78723684 | ths | tcg_gen_trunc_i64_tl(t1, r_tmp1); |
1966 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp1); |
1967 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_LO[0], t0);
|
1968 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_LO[1], t1);
|
1969 | 214c465f | ths | } |
1970 | 6af0bf9c | bellard | opn = "madd";
|
1971 | 6af0bf9c | bellard | break;
|
1972 | 6af0bf9c | bellard | case OPC_MADDU:
|
1973 | 214c465f | ths | { |
1974 | a7812ae4 | pbrook | TCGv_i64 r_tmp1 = tcg_temp_new_i64(); |
1975 | a7812ae4 | pbrook | TCGv_i64 r_tmp2 = tcg_temp_new_i64(); |
1976 | 214c465f | ths | |
1977 | 78723684 | ths | tcg_gen_ext32u_tl(t0, t0); |
1978 | 78723684 | ths | tcg_gen_ext32u_tl(t1, t1); |
1979 | 78723684 | ths | tcg_gen_extu_tl_i64(r_tmp1, t0); |
1980 | 78723684 | ths | tcg_gen_extu_tl_i64(r_tmp2, t1); |
1981 | 214c465f | ths | tcg_gen_mul_i64(r_tmp1, r_tmp1, r_tmp2); |
1982 | b10fa3c9 | aurel32 | tcg_gen_concat_tl_i64(r_tmp2, cpu_LO[0], cpu_HI[0]); |
1983 | 214c465f | ths | tcg_gen_add_i64(r_tmp1, r_tmp1, r_tmp2); |
1984 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp2); |
1985 | 78723684 | ths | tcg_gen_trunc_i64_tl(t0, r_tmp1); |
1986 | 214c465f | ths | tcg_gen_shri_i64(r_tmp1, r_tmp1, 32);
|
1987 | 78723684 | ths | tcg_gen_trunc_i64_tl(t1, r_tmp1); |
1988 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp1); |
1989 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_LO[0], t0);
|
1990 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_HI[0], t1);
|
1991 | 214c465f | ths | } |
1992 | 6af0bf9c | bellard | opn = "maddu";
|
1993 | 6af0bf9c | bellard | break;
|
1994 | 6af0bf9c | bellard | case OPC_MSUB:
|
1995 | 214c465f | ths | { |
1996 | a7812ae4 | pbrook | TCGv_i64 r_tmp1 = tcg_temp_new_i64(); |
1997 | a7812ae4 | pbrook | TCGv_i64 r_tmp2 = tcg_temp_new_i64(); |
1998 | 214c465f | ths | |
1999 | 78723684 | ths | tcg_gen_ext_tl_i64(r_tmp1, t0); |
2000 | 78723684 | ths | tcg_gen_ext_tl_i64(r_tmp2, t1); |
2001 | 214c465f | ths | tcg_gen_mul_i64(r_tmp1, r_tmp1, r_tmp2); |
2002 | b10fa3c9 | aurel32 | tcg_gen_concat_tl_i64(r_tmp2, cpu_LO[0], cpu_HI[0]); |
2003 | 214c465f | ths | tcg_gen_sub_i64(r_tmp1, r_tmp1, r_tmp2); |
2004 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp2); |
2005 | 78723684 | ths | tcg_gen_trunc_i64_tl(t0, r_tmp1); |
2006 | 214c465f | ths | tcg_gen_shri_i64(r_tmp1, r_tmp1, 32);
|
2007 | 78723684 | ths | tcg_gen_trunc_i64_tl(t1, r_tmp1); |
2008 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp1); |
2009 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_LO[0], t0);
|
2010 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_HI[0], t1);
|
2011 | 214c465f | ths | } |
2012 | 6af0bf9c | bellard | opn = "msub";
|
2013 | 6af0bf9c | bellard | break;
|
2014 | 6af0bf9c | bellard | case OPC_MSUBU:
|
2015 | 214c465f | ths | { |
2016 | a7812ae4 | pbrook | TCGv_i64 r_tmp1 = tcg_temp_new_i64(); |
2017 | a7812ae4 | pbrook | TCGv_i64 r_tmp2 = tcg_temp_new_i64(); |
2018 | 214c465f | ths | |
2019 | 78723684 | ths | tcg_gen_ext32u_tl(t0, t0); |
2020 | 78723684 | ths | tcg_gen_ext32u_tl(t1, t1); |
2021 | 78723684 | ths | tcg_gen_extu_tl_i64(r_tmp1, t0); |
2022 | 78723684 | ths | tcg_gen_extu_tl_i64(r_tmp2, t1); |
2023 | 214c465f | ths | tcg_gen_mul_i64(r_tmp1, r_tmp1, r_tmp2); |
2024 | b10fa3c9 | aurel32 | tcg_gen_concat_tl_i64(r_tmp2, cpu_LO[0], cpu_HI[0]); |
2025 | 214c465f | ths | tcg_gen_sub_i64(r_tmp1, r_tmp1, r_tmp2); |
2026 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp2); |
2027 | 78723684 | ths | tcg_gen_trunc_i64_tl(t0, r_tmp1); |
2028 | 214c465f | ths | tcg_gen_shri_i64(r_tmp1, r_tmp1, 32);
|
2029 | 78723684 | ths | tcg_gen_trunc_i64_tl(t1, r_tmp1); |
2030 | a7812ae4 | pbrook | tcg_temp_free_i64(r_tmp1); |
2031 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_LO[0], t0);
|
2032 | b10fa3c9 | aurel32 | tcg_gen_ext32s_tl(cpu_HI[0], t1);
|
2033 | 214c465f | ths | } |
2034 | 6af0bf9c | bellard | opn = "msubu";
|
2035 | 6af0bf9c | bellard | break;
|
2036 | 6af0bf9c | bellard | default:
|
2037 | 923617a3 | ths | MIPS_INVAL(opn); |
2038 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
2039 | 78723684 | ths | goto out;
|
2040 | 6af0bf9c | bellard | } |
2041 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s %s", opn, regnames[rs], regnames[rt]);
|
2042 | 78723684 | ths | out:
|
2043 | 78723684 | ths | tcg_temp_free(t0); |
2044 | 78723684 | ths | tcg_temp_free(t1); |
2045 | 6af0bf9c | bellard | } |
2046 | 6af0bf9c | bellard | |
2047 | e9c71dd1 | ths | static void gen_mul_vr54xx (DisasContext *ctx, uint32_t opc, |
2048 | e9c71dd1 | ths | int rd, int rs, int rt) |
2049 | e9c71dd1 | ths | { |
2050 | e9c71dd1 | ths | const char *opn = "mul vr54xx"; |
2051 | f157bfe1 | aurel32 | TCGv t0 = tcg_temp_new(); |
2052 | f157bfe1 | aurel32 | TCGv t1 = tcg_temp_new(); |
2053 | e9c71dd1 | ths | |
2054 | 6c5c1e20 | ths | gen_load_gpr(t0, rs); |
2055 | 6c5c1e20 | ths | gen_load_gpr(t1, rt); |
2056 | e9c71dd1 | ths | |
2057 | e9c71dd1 | ths | switch (opc) {
|
2058 | e9c71dd1 | ths | case OPC_VR54XX_MULS:
|
2059 | a7812ae4 | pbrook | gen_helper_muls(t0, t0, t1); |
2060 | e9c71dd1 | ths | opn = "muls";
|
2061 | 6958549d | aurel32 | break;
|
2062 | e9c71dd1 | ths | case OPC_VR54XX_MULSU:
|
2063 | a7812ae4 | pbrook | gen_helper_mulsu(t0, t0, t1); |
2064 | e9c71dd1 | ths | opn = "mulsu";
|
2065 | 6958549d | aurel32 | break;
|
2066 | e9c71dd1 | ths | case OPC_VR54XX_MACC:
|
2067 | a7812ae4 | pbrook | gen_helper_macc(t0, t0, t1); |
2068 | e9c71dd1 | ths | opn = "macc";
|
2069 | 6958549d | aurel32 | break;
|
2070 | e9c71dd1 | ths | case OPC_VR54XX_MACCU:
|
2071 | a7812ae4 | pbrook | gen_helper_maccu(t0, t0, t1); |
2072 | e9c71dd1 | ths | opn = "maccu";
|
2073 | 6958549d | aurel32 | break;
|
2074 | e9c71dd1 | ths | case OPC_VR54XX_MSAC:
|
2075 | a7812ae4 | pbrook | gen_helper_msac(t0, t0, t1); |
2076 | e9c71dd1 | ths | opn = "msac";
|
2077 | 6958549d | aurel32 | break;
|
2078 | e9c71dd1 | ths | case OPC_VR54XX_MSACU:
|
2079 | a7812ae4 | pbrook | gen_helper_msacu(t0, t0, t1); |
2080 | e9c71dd1 | ths | opn = "msacu";
|
2081 | 6958549d | aurel32 | break;
|
2082 | e9c71dd1 | ths | case OPC_VR54XX_MULHI:
|
2083 | a7812ae4 | pbrook | gen_helper_mulhi(t0, t0, t1); |
2084 | e9c71dd1 | ths | opn = "mulhi";
|
2085 | 6958549d | aurel32 | break;
|
2086 | e9c71dd1 | ths | case OPC_VR54XX_MULHIU:
|
2087 | a7812ae4 | pbrook | gen_helper_mulhiu(t0, t0, t1); |
2088 | e9c71dd1 | ths | opn = "mulhiu";
|
2089 | 6958549d | aurel32 | break;
|
2090 | e9c71dd1 | ths | case OPC_VR54XX_MULSHI:
|
2091 | a7812ae4 | pbrook | gen_helper_mulshi(t0, t0, t1); |
2092 | e9c71dd1 | ths | opn = "mulshi";
|
2093 | 6958549d | aurel32 | break;
|
2094 | e9c71dd1 | ths | case OPC_VR54XX_MULSHIU:
|
2095 | a7812ae4 | pbrook | gen_helper_mulshiu(t0, t0, t1); |
2096 | e9c71dd1 | ths | opn = "mulshiu";
|
2097 | 6958549d | aurel32 | break;
|
2098 | e9c71dd1 | ths | case OPC_VR54XX_MACCHI:
|
2099 | a7812ae4 | pbrook | gen_helper_macchi(t0, t0, t1); |
2100 | e9c71dd1 | ths | opn = "macchi";
|
2101 | 6958549d | aurel32 | break;
|
2102 | e9c71dd1 | ths | case OPC_VR54XX_MACCHIU:
|
2103 | a7812ae4 | pbrook | gen_helper_macchiu(t0, t0, t1); |
2104 | e9c71dd1 | ths | opn = "macchiu";
|
2105 | 6958549d | aurel32 | break;
|
2106 | e9c71dd1 | ths | case OPC_VR54XX_MSACHI:
|
2107 | a7812ae4 | pbrook | gen_helper_msachi(t0, t0, t1); |
2108 | e9c71dd1 | ths | opn = "msachi";
|
2109 | 6958549d | aurel32 | break;
|
2110 | e9c71dd1 | ths | case OPC_VR54XX_MSACHIU:
|
2111 | a7812ae4 | pbrook | gen_helper_msachiu(t0, t0, t1); |
2112 | e9c71dd1 | ths | opn = "msachiu";
|
2113 | 6958549d | aurel32 | break;
|
2114 | e9c71dd1 | ths | default:
|
2115 | e9c71dd1 | ths | MIPS_INVAL("mul vr54xx");
|
2116 | e9c71dd1 | ths | generate_exception(ctx, EXCP_RI); |
2117 | 6c5c1e20 | ths | goto out;
|
2118 | e9c71dd1 | ths | } |
2119 | 6c5c1e20 | ths | gen_store_gpr(t0, rd); |
2120 | e9c71dd1 | ths | MIPS_DEBUG("%s %s, %s, %s", opn, regnames[rd], regnames[rs], regnames[rt]);
|
2121 | 6c5c1e20 | ths | |
2122 | 6c5c1e20 | ths | out:
|
2123 | 6c5c1e20 | ths | tcg_temp_free(t0); |
2124 | 6c5c1e20 | ths | tcg_temp_free(t1); |
2125 | e9c71dd1 | ths | } |
2126 | e9c71dd1 | ths | |
2127 | 7a387fff | ths | static void gen_cl (DisasContext *ctx, uint32_t opc, |
2128 | 6af0bf9c | bellard | int rd, int rs) |
2129 | 6af0bf9c | bellard | { |
2130 | 923617a3 | ths | const char *opn = "CLx"; |
2131 | 20e1fb52 | aurel32 | TCGv t0; |
2132 | 6c5c1e20 | ths | |
2133 | 6af0bf9c | bellard | if (rd == 0) { |
2134 | ead9360e | ths | /* Treat as NOP. */
|
2135 | 6af0bf9c | bellard | MIPS_DEBUG("NOP");
|
2136 | 20e1fb52 | aurel32 | return;
|
2137 | 6af0bf9c | bellard | } |
2138 | 20e1fb52 | aurel32 | t0 = tcg_temp_new(); |
2139 | 6c5c1e20 | ths | gen_load_gpr(t0, rs); |
2140 | 6af0bf9c | bellard | switch (opc) {
|
2141 | 6af0bf9c | bellard | case OPC_CLO:
|
2142 | 20e1fb52 | aurel32 | gen_helper_clo(cpu_gpr[rd], t0); |
2143 | 6af0bf9c | bellard | opn = "clo";
|
2144 | 6af0bf9c | bellard | break;
|
2145 | 6af0bf9c | bellard | case OPC_CLZ:
|
2146 | 20e1fb52 | aurel32 | gen_helper_clz(cpu_gpr[rd], t0); |
2147 | 6af0bf9c | bellard | opn = "clz";
|
2148 | 6af0bf9c | bellard | break;
|
2149 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
2150 | 7a387fff | ths | case OPC_DCLO:
|
2151 | 20e1fb52 | aurel32 | gen_helper_dclo(cpu_gpr[rd], t0); |
2152 | 7a387fff | ths | opn = "dclo";
|
2153 | 7a387fff | ths | break;
|
2154 | 7a387fff | ths | case OPC_DCLZ:
|
2155 | 20e1fb52 | aurel32 | gen_helper_dclz(cpu_gpr[rd], t0); |
2156 | 7a387fff | ths | opn = "dclz";
|
2157 | 7a387fff | ths | break;
|
2158 | 7a387fff | ths | #endif
|
2159 | 6af0bf9c | bellard | } |
2160 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s, %s", opn, regnames[rd], regnames[rs]);
|
2161 | 6c5c1e20 | ths | tcg_temp_free(t0); |
2162 | 6af0bf9c | bellard | } |
2163 | 6af0bf9c | bellard | |
2164 | 6af0bf9c | bellard | /* Traps */
|
2165 | 7a387fff | ths | static void gen_trap (DisasContext *ctx, uint32_t opc, |
2166 | 6af0bf9c | bellard | int rs, int rt, int16_t imm) |
2167 | 6af0bf9c | bellard | { |
2168 | 6af0bf9c | bellard | int cond;
|
2169 | cdc0faa6 | aurel32 | TCGv t0 = tcg_temp_new(); |
2170 | 1ba74fb8 | aurel32 | TCGv t1 = tcg_temp_new(); |
2171 | 6af0bf9c | bellard | |
2172 | 6af0bf9c | bellard | cond = 0;
|
2173 | 6af0bf9c | bellard | /* Load needed operands */
|
2174 | 6af0bf9c | bellard | switch (opc) {
|
2175 | 6af0bf9c | bellard | case OPC_TEQ:
|
2176 | 6af0bf9c | bellard | case OPC_TGE:
|
2177 | 6af0bf9c | bellard | case OPC_TGEU:
|
2178 | 6af0bf9c | bellard | case OPC_TLT:
|
2179 | 6af0bf9c | bellard | case OPC_TLTU:
|
2180 | 6af0bf9c | bellard | case OPC_TNE:
|
2181 | 6af0bf9c | bellard | /* Compare two registers */
|
2182 | 6af0bf9c | bellard | if (rs != rt) {
|
2183 | be24bb4f | ths | gen_load_gpr(t0, rs); |
2184 | be24bb4f | ths | gen_load_gpr(t1, rt); |
2185 | 6af0bf9c | bellard | cond = 1;
|
2186 | 6af0bf9c | bellard | } |
2187 | 179e32bb | ths | break;
|
2188 | 6af0bf9c | bellard | case OPC_TEQI:
|
2189 | 6af0bf9c | bellard | case OPC_TGEI:
|
2190 | 6af0bf9c | bellard | case OPC_TGEIU:
|
2191 | 6af0bf9c | bellard | case OPC_TLTI:
|
2192 | 6af0bf9c | bellard | case OPC_TLTIU:
|
2193 | 6af0bf9c | bellard | case OPC_TNEI:
|
2194 | 6af0bf9c | bellard | /* Compare register to immediate */
|
2195 | 6af0bf9c | bellard | if (rs != 0 || imm != 0) { |
2196 | be24bb4f | ths | gen_load_gpr(t0, rs); |
2197 | be24bb4f | ths | tcg_gen_movi_tl(t1, (int32_t)imm); |
2198 | 6af0bf9c | bellard | cond = 1;
|
2199 | 6af0bf9c | bellard | } |
2200 | 6af0bf9c | bellard | break;
|
2201 | 6af0bf9c | bellard | } |
2202 | 6af0bf9c | bellard | if (cond == 0) { |
2203 | 6af0bf9c | bellard | switch (opc) {
|
2204 | 6af0bf9c | bellard | case OPC_TEQ: /* rs == rs */ |
2205 | 6af0bf9c | bellard | case OPC_TEQI: /* r0 == 0 */ |
2206 | 6af0bf9c | bellard | case OPC_TGE: /* rs >= rs */ |
2207 | 6af0bf9c | bellard | case OPC_TGEI: /* r0 >= 0 */ |
2208 | 6af0bf9c | bellard | case OPC_TGEU: /* rs >= rs unsigned */ |
2209 | 6af0bf9c | bellard | case OPC_TGEIU: /* r0 >= 0 unsigned */ |
2210 | 6af0bf9c | bellard | /* Always trap */
|
2211 | cdc0faa6 | aurel32 | generate_exception(ctx, EXCP_TRAP); |
2212 | 6af0bf9c | bellard | break;
|
2213 | 6af0bf9c | bellard | case OPC_TLT: /* rs < rs */ |
2214 | 6af0bf9c | bellard | case OPC_TLTI: /* r0 < 0 */ |
2215 | 6af0bf9c | bellard | case OPC_TLTU: /* rs < rs unsigned */ |
2216 | 6af0bf9c | bellard | case OPC_TLTIU: /* r0 < 0 unsigned */ |
2217 | 6af0bf9c | bellard | case OPC_TNE: /* rs != rs */ |
2218 | 6af0bf9c | bellard | case OPC_TNEI: /* r0 != 0 */ |
2219 | ead9360e | ths | /* Never trap: treat as NOP. */
|
2220 | cdc0faa6 | aurel32 | break;
|
2221 | 6af0bf9c | bellard | } |
2222 | 6af0bf9c | bellard | } else {
|
2223 | cdc0faa6 | aurel32 | int l1 = gen_new_label();
|
2224 | cdc0faa6 | aurel32 | |
2225 | 6af0bf9c | bellard | switch (opc) {
|
2226 | 6af0bf9c | bellard | case OPC_TEQ:
|
2227 | 6af0bf9c | bellard | case OPC_TEQI:
|
2228 | cdc0faa6 | aurel32 | tcg_gen_brcond_tl(TCG_COND_NE, t0, t1, l1); |
2229 | 6af0bf9c | bellard | break;
|
2230 | 6af0bf9c | bellard | case OPC_TGE:
|
2231 | 6af0bf9c | bellard | case OPC_TGEI:
|
2232 | cdc0faa6 | aurel32 | tcg_gen_brcond_tl(TCG_COND_LT, t0, t1, l1); |
2233 | 6af0bf9c | bellard | break;
|
2234 | 6af0bf9c | bellard | case OPC_TGEU:
|
2235 | 6af0bf9c | bellard | case OPC_TGEIU:
|
2236 | cdc0faa6 | aurel32 | tcg_gen_brcond_tl(TCG_COND_LTU, t0, t1, l1); |
2237 | 6af0bf9c | bellard | break;
|
2238 | 6af0bf9c | bellard | case OPC_TLT:
|
2239 | 6af0bf9c | bellard | case OPC_TLTI:
|
2240 | cdc0faa6 | aurel32 | tcg_gen_brcond_tl(TCG_COND_GE, t0, t1, l1); |
2241 | 6af0bf9c | bellard | break;
|
2242 | 6af0bf9c | bellard | case OPC_TLTU:
|
2243 | 6af0bf9c | bellard | case OPC_TLTIU:
|
2244 | cdc0faa6 | aurel32 | tcg_gen_brcond_tl(TCG_COND_GEU, t0, t1, l1); |
2245 | 6af0bf9c | bellard | break;
|
2246 | 6af0bf9c | bellard | case OPC_TNE:
|
2247 | 6af0bf9c | bellard | case OPC_TNEI:
|
2248 | cdc0faa6 | aurel32 | tcg_gen_brcond_tl(TCG_COND_EQ, t0, t1, l1); |
2249 | 6af0bf9c | bellard | break;
|
2250 | 6af0bf9c | bellard | } |
2251 | cdc0faa6 | aurel32 | generate_exception(ctx, EXCP_TRAP); |
2252 | 08ba7963 | ths | gen_set_label(l1); |
2253 | 08ba7963 | ths | } |
2254 | be24bb4f | ths | tcg_temp_free(t0); |
2255 | be24bb4f | ths | tcg_temp_free(t1); |
2256 | 6af0bf9c | bellard | } |
2257 | 6af0bf9c | bellard | |
2258 | 356265ae | ths | static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest) |
2259 | c53be334 | bellard | { |
2260 | 6e256c93 | bellard | TranslationBlock *tb; |
2261 | 6e256c93 | bellard | tb = ctx->tb; |
2262 | 6e256c93 | bellard | if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
|
2263 | 57fec1fe | bellard | tcg_gen_goto_tb(n); |
2264 | 9b9e4393 | ths | gen_save_pc(dest); |
2265 | 57fec1fe | bellard | tcg_gen_exit_tb((long)tb + n);
|
2266 | 6e256c93 | bellard | } else {
|
2267 | 9b9e4393 | ths | gen_save_pc(dest); |
2268 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
2269 | 6e256c93 | bellard | } |
2270 | c53be334 | bellard | } |
2271 | c53be334 | bellard | |
2272 | 6af0bf9c | bellard | /* Branches (before delay slot) */
|
2273 | 7a387fff | ths | static void gen_compute_branch (DisasContext *ctx, uint32_t opc, |
2274 | 6af0bf9c | bellard | int rs, int rt, int32_t offset) |
2275 | 6af0bf9c | bellard | { |
2276 | d077b6f7 | ths | target_ulong btgt = -1;
|
2277 | 3ad4bb2d | ths | int blink = 0; |
2278 | 2fdbad25 | aurel32 | int bcond_compute = 0; |
2279 | 1ba74fb8 | aurel32 | TCGv t0 = tcg_temp_new(); |
2280 | 1ba74fb8 | aurel32 | TCGv t1 = tcg_temp_new(); |
2281 | 3ad4bb2d | ths | |
2282 | 3ad4bb2d | ths | if (ctx->hflags & MIPS_HFLAG_BMASK) {
|
2283 | 923617a3 | ths | #ifdef MIPS_DEBUG_DISAS
|
2284 | d12d51d5 | aliguori | LOG_DISAS("Branch in delay slot at PC 0x" TARGET_FMT_lx "\n", ctx->pc); |
2285 | 923617a3 | ths | #endif
|
2286 | 3ad4bb2d | ths | generate_exception(ctx, EXCP_RI); |
2287 | 6c5c1e20 | ths | goto out;
|
2288 | 3ad4bb2d | ths | } |
2289 | 6af0bf9c | bellard | |
2290 | 6af0bf9c | bellard | /* Load needed operands */
|
2291 | 6af0bf9c | bellard | switch (opc) {
|
2292 | 6af0bf9c | bellard | case OPC_BEQ:
|
2293 | 6af0bf9c | bellard | case OPC_BEQL:
|
2294 | 6af0bf9c | bellard | case OPC_BNE:
|
2295 | 6af0bf9c | bellard | case OPC_BNEL:
|
2296 | 6af0bf9c | bellard | /* Compare two registers */
|
2297 | 6af0bf9c | bellard | if (rs != rt) {
|
2298 | 6c5c1e20 | ths | gen_load_gpr(t0, rs); |
2299 | 6c5c1e20 | ths | gen_load_gpr(t1, rt); |
2300 | 2fdbad25 | aurel32 | bcond_compute = 1;
|
2301 | 6af0bf9c | bellard | } |
2302 | d077b6f7 | ths | btgt = ctx->pc + 4 + offset;
|
2303 | 6af0bf9c | bellard | break;
|
2304 | 6af0bf9c | bellard | case OPC_BGEZ:
|
2305 | 6af0bf9c | bellard | case OPC_BGEZAL:
|
2306 | 6af0bf9c | bellard | case OPC_BGEZALL:
|
2307 | 6af0bf9c | bellard | case OPC_BGEZL:
|
2308 | 6af0bf9c | bellard | case OPC_BGTZ:
|
2309 | 6af0bf9c | bellard | case OPC_BGTZL:
|
2310 | 6af0bf9c | bellard | case OPC_BLEZ:
|
2311 | 6af0bf9c | bellard | case OPC_BLEZL:
|
2312 | 6af0bf9c | bellard | case OPC_BLTZ:
|
2313 | 6af0bf9c | bellard | case OPC_BLTZAL:
|
2314 | 6af0bf9c | bellard | case OPC_BLTZALL:
|
2315 | 6af0bf9c | bellard | case OPC_BLTZL:
|
2316 | 6af0bf9c | bellard | /* Compare to zero */
|
2317 | 6af0bf9c | bellard | if (rs != 0) { |
2318 | 6c5c1e20 | ths | gen_load_gpr(t0, rs); |
2319 | 2fdbad25 | aurel32 | bcond_compute = 1;
|
2320 | 6af0bf9c | bellard | } |
2321 | d077b6f7 | ths | btgt = ctx->pc + 4 + offset;
|
2322 | 6af0bf9c | bellard | break;
|
2323 | 6af0bf9c | bellard | case OPC_J:
|
2324 | 6af0bf9c | bellard | case OPC_JAL:
|
2325 | 6af0bf9c | bellard | /* Jump to immediate */
|
2326 | d077b6f7 | ths | btgt = ((ctx->pc + 4) & (int32_t)0xF0000000) | (uint32_t)offset; |
2327 | 6af0bf9c | bellard | break;
|
2328 | 6af0bf9c | bellard | case OPC_JR:
|
2329 | 6af0bf9c | bellard | case OPC_JALR:
|
2330 | 6af0bf9c | bellard | /* Jump to register */
|
2331 | 7a387fff | ths | if (offset != 0 && offset != 16) { |
2332 | 7a387fff | ths | /* Hint = 0 is JR/JALR, hint 16 is JR.HB/JALR.HB, the
|
2333 | cbeb0857 | ths | others are reserved. */
|
2334 | 923617a3 | ths | MIPS_INVAL("jump hint");
|
2335 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
2336 | 6c5c1e20 | ths | goto out;
|
2337 | 6af0bf9c | bellard | } |
2338 | d077b6f7 | ths | gen_load_gpr(btarget, rs); |
2339 | 6af0bf9c | bellard | break;
|
2340 | 6af0bf9c | bellard | default:
|
2341 | 6af0bf9c | bellard | MIPS_INVAL("branch/jump");
|
2342 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
2343 | 6c5c1e20 | ths | goto out;
|
2344 | 6af0bf9c | bellard | } |
2345 | 2fdbad25 | aurel32 | if (bcond_compute == 0) { |
2346 | 6af0bf9c | bellard | /* No condition to be computed */
|
2347 | 6af0bf9c | bellard | switch (opc) {
|
2348 | 6af0bf9c | bellard | case OPC_BEQ: /* rx == rx */ |
2349 | 6af0bf9c | bellard | case OPC_BEQL: /* rx == rx likely */ |
2350 | 6af0bf9c | bellard | case OPC_BGEZ: /* 0 >= 0 */ |
2351 | 6af0bf9c | bellard | case OPC_BGEZL: /* 0 >= 0 likely */ |
2352 | 6af0bf9c | bellard | case OPC_BLEZ: /* 0 <= 0 */ |
2353 | 6af0bf9c | bellard | case OPC_BLEZL: /* 0 <= 0 likely */ |
2354 | 6af0bf9c | bellard | /* Always take */
|
2355 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_B; |
2356 | 6af0bf9c | bellard | MIPS_DEBUG("balways");
|
2357 | 6af0bf9c | bellard | break;
|
2358 | 6af0bf9c | bellard | case OPC_BGEZAL: /* 0 >= 0 */ |
2359 | 6af0bf9c | bellard | case OPC_BGEZALL: /* 0 >= 0 likely */ |
2360 | 6af0bf9c | bellard | /* Always take and link */
|
2361 | 6af0bf9c | bellard | blink = 31;
|
2362 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_B; |
2363 | 6af0bf9c | bellard | MIPS_DEBUG("balways and link");
|
2364 | 6af0bf9c | bellard | break;
|
2365 | 6af0bf9c | bellard | case OPC_BNE: /* rx != rx */ |
2366 | 6af0bf9c | bellard | case OPC_BGTZ: /* 0 > 0 */ |
2367 | 6af0bf9c | bellard | case OPC_BLTZ: /* 0 < 0 */ |
2368 | ead9360e | ths | /* Treat as NOP. */
|
2369 | 6af0bf9c | bellard | MIPS_DEBUG("bnever (NOP)");
|
2370 | 6c5c1e20 | ths | goto out;
|
2371 | eeef26cd | bellard | case OPC_BLTZAL: /* 0 < 0 */ |
2372 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 8); |
2373 | 9898128f | ths | MIPS_DEBUG("bnever and link");
|
2374 | 6c5c1e20 | ths | goto out;
|
2375 | eeef26cd | bellard | case OPC_BLTZALL: /* 0 < 0 likely */ |
2376 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 8); |
2377 | 9898128f | ths | /* Skip the instruction in the delay slot */
|
2378 | 9898128f | ths | MIPS_DEBUG("bnever, link and skip");
|
2379 | 9898128f | ths | ctx->pc += 4;
|
2380 | 6c5c1e20 | ths | goto out;
|
2381 | 6af0bf9c | bellard | case OPC_BNEL: /* rx != rx likely */ |
2382 | 6af0bf9c | bellard | case OPC_BGTZL: /* 0 > 0 likely */ |
2383 | 6af0bf9c | bellard | case OPC_BLTZL: /* 0 < 0 likely */ |
2384 | 6af0bf9c | bellard | /* Skip the instruction in the delay slot */
|
2385 | 6af0bf9c | bellard | MIPS_DEBUG("bnever and skip");
|
2386 | 9898128f | ths | ctx->pc += 4;
|
2387 | 6c5c1e20 | ths | goto out;
|
2388 | 6af0bf9c | bellard | case OPC_J:
|
2389 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_B; |
2390 | d077b6f7 | ths | MIPS_DEBUG("j " TARGET_FMT_lx, btgt);
|
2391 | 6af0bf9c | bellard | break;
|
2392 | 6af0bf9c | bellard | case OPC_JAL:
|
2393 | 6af0bf9c | bellard | blink = 31;
|
2394 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_B; |
2395 | d077b6f7 | ths | MIPS_DEBUG("jal " TARGET_FMT_lx, btgt);
|
2396 | 6af0bf9c | bellard | break;
|
2397 | 6af0bf9c | bellard | case OPC_JR:
|
2398 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_BR; |
2399 | 6af0bf9c | bellard | MIPS_DEBUG("jr %s", regnames[rs]);
|
2400 | 6af0bf9c | bellard | break;
|
2401 | 6af0bf9c | bellard | case OPC_JALR:
|
2402 | 6af0bf9c | bellard | blink = rt; |
2403 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_BR; |
2404 | 6af0bf9c | bellard | MIPS_DEBUG("jalr %s, %s", regnames[rt], regnames[rs]);
|
2405 | 6af0bf9c | bellard | break;
|
2406 | 6af0bf9c | bellard | default:
|
2407 | 6af0bf9c | bellard | MIPS_INVAL("branch/jump");
|
2408 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
2409 | 6c5c1e20 | ths | goto out;
|
2410 | 6af0bf9c | bellard | } |
2411 | 6af0bf9c | bellard | } else {
|
2412 | 6af0bf9c | bellard | switch (opc) {
|
2413 | 6af0bf9c | bellard | case OPC_BEQ:
|
2414 | 1ba74fb8 | aurel32 | gen_op_eq(bcond, t0, t1); |
2415 | 923617a3 | ths | MIPS_DEBUG("beq %s, %s, " TARGET_FMT_lx,
|
2416 | d077b6f7 | ths | regnames[rs], regnames[rt], btgt); |
2417 | 6af0bf9c | bellard | goto not_likely;
|
2418 | 6af0bf9c | bellard | case OPC_BEQL:
|
2419 | 1ba74fb8 | aurel32 | gen_op_eq(bcond, t0, t1); |
2420 | 923617a3 | ths | MIPS_DEBUG("beql %s, %s, " TARGET_FMT_lx,
|
2421 | d077b6f7 | ths | regnames[rs], regnames[rt], btgt); |
2422 | 6af0bf9c | bellard | goto likely;
|
2423 | 6af0bf9c | bellard | case OPC_BNE:
|
2424 | 1ba74fb8 | aurel32 | gen_op_ne(bcond, t0, t1); |
2425 | 923617a3 | ths | MIPS_DEBUG("bne %s, %s, " TARGET_FMT_lx,
|
2426 | d077b6f7 | ths | regnames[rs], regnames[rt], btgt); |
2427 | 6af0bf9c | bellard | goto not_likely;
|
2428 | 6af0bf9c | bellard | case OPC_BNEL:
|
2429 | 1ba74fb8 | aurel32 | gen_op_ne(bcond, t0, t1); |
2430 | 923617a3 | ths | MIPS_DEBUG("bnel %s, %s, " TARGET_FMT_lx,
|
2431 | d077b6f7 | ths | regnames[rs], regnames[rt], btgt); |
2432 | 6af0bf9c | bellard | goto likely;
|
2433 | 6af0bf9c | bellard | case OPC_BGEZ:
|
2434 | 1ba74fb8 | aurel32 | gen_op_gez(bcond, t0); |
2435 | d077b6f7 | ths | MIPS_DEBUG("bgez %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2436 | 6af0bf9c | bellard | goto not_likely;
|
2437 | 6af0bf9c | bellard | case OPC_BGEZL:
|
2438 | 1ba74fb8 | aurel32 | gen_op_gez(bcond, t0); |
2439 | d077b6f7 | ths | MIPS_DEBUG("bgezl %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2440 | 6af0bf9c | bellard | goto likely;
|
2441 | 6af0bf9c | bellard | case OPC_BGEZAL:
|
2442 | 1ba74fb8 | aurel32 | gen_op_gez(bcond, t0); |
2443 | d077b6f7 | ths | MIPS_DEBUG("bgezal %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2444 | 6af0bf9c | bellard | blink = 31;
|
2445 | 6af0bf9c | bellard | goto not_likely;
|
2446 | 6af0bf9c | bellard | case OPC_BGEZALL:
|
2447 | 1ba74fb8 | aurel32 | gen_op_gez(bcond, t0); |
2448 | 6af0bf9c | bellard | blink = 31;
|
2449 | d077b6f7 | ths | MIPS_DEBUG("bgezall %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2450 | 6af0bf9c | bellard | goto likely;
|
2451 | 6af0bf9c | bellard | case OPC_BGTZ:
|
2452 | 1ba74fb8 | aurel32 | gen_op_gtz(bcond, t0); |
2453 | d077b6f7 | ths | MIPS_DEBUG("bgtz %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2454 | 6af0bf9c | bellard | goto not_likely;
|
2455 | 6af0bf9c | bellard | case OPC_BGTZL:
|
2456 | 1ba74fb8 | aurel32 | gen_op_gtz(bcond, t0); |
2457 | d077b6f7 | ths | MIPS_DEBUG("bgtzl %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2458 | 6af0bf9c | bellard | goto likely;
|
2459 | 6af0bf9c | bellard | case OPC_BLEZ:
|
2460 | 1ba74fb8 | aurel32 | gen_op_lez(bcond, t0); |
2461 | d077b6f7 | ths | MIPS_DEBUG("blez %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2462 | 6af0bf9c | bellard | goto not_likely;
|
2463 | 6af0bf9c | bellard | case OPC_BLEZL:
|
2464 | 1ba74fb8 | aurel32 | gen_op_lez(bcond, t0); |
2465 | d077b6f7 | ths | MIPS_DEBUG("blezl %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2466 | 6af0bf9c | bellard | goto likely;
|
2467 | 6af0bf9c | bellard | case OPC_BLTZ:
|
2468 | 1ba74fb8 | aurel32 | gen_op_ltz(bcond, t0); |
2469 | d077b6f7 | ths | MIPS_DEBUG("bltz %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2470 | 6af0bf9c | bellard | goto not_likely;
|
2471 | 6af0bf9c | bellard | case OPC_BLTZL:
|
2472 | 1ba74fb8 | aurel32 | gen_op_ltz(bcond, t0); |
2473 | d077b6f7 | ths | MIPS_DEBUG("bltzl %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2474 | 6af0bf9c | bellard | goto likely;
|
2475 | 6af0bf9c | bellard | case OPC_BLTZAL:
|
2476 | 1ba74fb8 | aurel32 | gen_op_ltz(bcond, t0); |
2477 | 6af0bf9c | bellard | blink = 31;
|
2478 | d077b6f7 | ths | MIPS_DEBUG("bltzal %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2479 | 6af0bf9c | bellard | not_likely:
|
2480 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_BC; |
2481 | 6af0bf9c | bellard | break;
|
2482 | 6af0bf9c | bellard | case OPC_BLTZALL:
|
2483 | 1ba74fb8 | aurel32 | gen_op_ltz(bcond, t0); |
2484 | 6af0bf9c | bellard | blink = 31;
|
2485 | d077b6f7 | ths | MIPS_DEBUG("bltzall %s, " TARGET_FMT_lx, regnames[rs], btgt);
|
2486 | 6af0bf9c | bellard | likely:
|
2487 | 4ad40f36 | bellard | ctx->hflags |= MIPS_HFLAG_BL; |
2488 | 6af0bf9c | bellard | break;
|
2489 | c53f4a62 | ths | default:
|
2490 | c53f4a62 | ths | MIPS_INVAL("conditional branch/jump");
|
2491 | c53f4a62 | ths | generate_exception(ctx, EXCP_RI); |
2492 | 6c5c1e20 | ths | goto out;
|
2493 | 6af0bf9c | bellard | } |
2494 | 6af0bf9c | bellard | } |
2495 | 923617a3 | ths | MIPS_DEBUG("enter ds: link %d cond %02x target " TARGET_FMT_lx,
|
2496 | d077b6f7 | ths | blink, ctx->hflags, btgt); |
2497 | 9b9e4393 | ths | |
2498 | d077b6f7 | ths | ctx->btarget = btgt; |
2499 | 6af0bf9c | bellard | if (blink > 0) { |
2500 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(cpu_gpr[blink], ctx->pc + 8);
|
2501 | 6af0bf9c | bellard | } |
2502 | 6c5c1e20 | ths | |
2503 | 6c5c1e20 | ths | out:
|
2504 | 6c5c1e20 | ths | tcg_temp_free(t0); |
2505 | 6c5c1e20 | ths | tcg_temp_free(t1); |
2506 | 6af0bf9c | bellard | } |
2507 | 6af0bf9c | bellard | |
2508 | 7a387fff | ths | /* special3 bitfield operations */
|
2509 | 7a387fff | ths | static void gen_bitops (DisasContext *ctx, uint32_t opc, int rt, |
2510 | 356265ae | ths | int rs, int lsb, int msb) |
2511 | 7a387fff | ths | { |
2512 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_new(); |
2513 | a7812ae4 | pbrook | TCGv t1 = tcg_temp_new(); |
2514 | 505ad7c2 | aurel32 | target_ulong mask; |
2515 | 6c5c1e20 | ths | |
2516 | 6c5c1e20 | ths | gen_load_gpr(t1, rs); |
2517 | 7a387fff | ths | switch (opc) {
|
2518 | 7a387fff | ths | case OPC_EXT:
|
2519 | 7a387fff | ths | if (lsb + msb > 31) |
2520 | 7a387fff | ths | goto fail;
|
2521 | 505ad7c2 | aurel32 | tcg_gen_shri_tl(t0, t1, lsb); |
2522 | 505ad7c2 | aurel32 | if (msb != 31) { |
2523 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t0, t0, (1 << (msb + 1)) - 1); |
2524 | 505ad7c2 | aurel32 | } else {
|
2525 | 505ad7c2 | aurel32 | tcg_gen_ext32s_tl(t0, t0); |
2526 | 505ad7c2 | aurel32 | } |
2527 | 7a387fff | ths | break;
|
2528 | c6d6dd7c | ths | #if defined(TARGET_MIPS64)
|
2529 | 7a387fff | ths | case OPC_DEXTM:
|
2530 | 505ad7c2 | aurel32 | tcg_gen_shri_tl(t0, t1, lsb); |
2531 | 505ad7c2 | aurel32 | if (msb != 31) { |
2532 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t0, t0, (1ULL << (msb + 1 + 32)) - 1); |
2533 | 505ad7c2 | aurel32 | } |
2534 | 7a387fff | ths | break;
|
2535 | 7a387fff | ths | case OPC_DEXTU:
|
2536 | 505ad7c2 | aurel32 | tcg_gen_shri_tl(t0, t1, lsb + 32);
|
2537 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t0, t0, (1ULL << (msb + 1)) - 1); |
2538 | 7a387fff | ths | break;
|
2539 | 7a387fff | ths | case OPC_DEXT:
|
2540 | 505ad7c2 | aurel32 | tcg_gen_shri_tl(t0, t1, lsb); |
2541 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t0, t0, (1ULL << (msb + 1)) - 1); |
2542 | 7a387fff | ths | break;
|
2543 | c6d6dd7c | ths | #endif
|
2544 | 7a387fff | ths | case OPC_INS:
|
2545 | 7a387fff | ths | if (lsb > msb)
|
2546 | 7a387fff | ths | goto fail;
|
2547 | 505ad7c2 | aurel32 | mask = ((msb - lsb + 1 < 32) ? ((1 << (msb - lsb + 1)) - 1) : ~0) << lsb; |
2548 | 6c5c1e20 | ths | gen_load_gpr(t0, rt); |
2549 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t0, t0, ~mask); |
2550 | 505ad7c2 | aurel32 | tcg_gen_shli_tl(t1, t1, lsb); |
2551 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t1, t1, mask); |
2552 | 505ad7c2 | aurel32 | tcg_gen_or_tl(t0, t0, t1); |
2553 | 505ad7c2 | aurel32 | tcg_gen_ext32s_tl(t0, t0); |
2554 | 7a387fff | ths | break;
|
2555 | c6d6dd7c | ths | #if defined(TARGET_MIPS64)
|
2556 | 7a387fff | ths | case OPC_DINSM:
|
2557 | 7a387fff | ths | if (lsb > msb)
|
2558 | 7a387fff | ths | goto fail;
|
2559 | 505ad7c2 | aurel32 | mask = ((msb - lsb + 1 + 32 < 64) ? ((1ULL << (msb - lsb + 1 + 32)) - 1) : ~0ULL) << lsb; |
2560 | 6c5c1e20 | ths | gen_load_gpr(t0, rt); |
2561 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t0, t0, ~mask); |
2562 | 505ad7c2 | aurel32 | tcg_gen_shli_tl(t1, t1, lsb); |
2563 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t1, t1, mask); |
2564 | 505ad7c2 | aurel32 | tcg_gen_or_tl(t0, t0, t1); |
2565 | 7a387fff | ths | break;
|
2566 | 7a387fff | ths | case OPC_DINSU:
|
2567 | 7a387fff | ths | if (lsb > msb)
|
2568 | 7a387fff | ths | goto fail;
|
2569 | 505ad7c2 | aurel32 | mask = ((1ULL << (msb - lsb + 1)) - 1) << lsb; |
2570 | 6c5c1e20 | ths | gen_load_gpr(t0, rt); |
2571 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t0, t0, ~mask); |
2572 | 505ad7c2 | aurel32 | tcg_gen_shli_tl(t1, t1, lsb + 32);
|
2573 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t1, t1, mask); |
2574 | 505ad7c2 | aurel32 | tcg_gen_or_tl(t0, t0, t1); |
2575 | 7a387fff | ths | break;
|
2576 | 7a387fff | ths | case OPC_DINS:
|
2577 | 7a387fff | ths | if (lsb > msb)
|
2578 | 7a387fff | ths | goto fail;
|
2579 | 6c5c1e20 | ths | gen_load_gpr(t0, rt); |
2580 | 505ad7c2 | aurel32 | mask = ((1ULL << (msb - lsb + 1)) - 1) << lsb; |
2581 | 505ad7c2 | aurel32 | gen_load_gpr(t0, rt); |
2582 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t0, t0, ~mask); |
2583 | 505ad7c2 | aurel32 | tcg_gen_shli_tl(t1, t1, lsb); |
2584 | 505ad7c2 | aurel32 | tcg_gen_andi_tl(t1, t1, mask); |
2585 | 505ad7c2 | aurel32 | tcg_gen_or_tl(t0, t0, t1); |
2586 | 7a387fff | ths | break;
|
2587 | c6d6dd7c | ths | #endif
|
2588 | 7a387fff | ths | default:
|
2589 | 7a387fff | ths | fail:
|
2590 | 7a387fff | ths | MIPS_INVAL("bitops");
|
2591 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
2592 | 6c5c1e20 | ths | tcg_temp_free(t0); |
2593 | 6c5c1e20 | ths | tcg_temp_free(t1); |
2594 | 7a387fff | ths | return;
|
2595 | 7a387fff | ths | } |
2596 | 6c5c1e20 | ths | gen_store_gpr(t0, rt); |
2597 | 6c5c1e20 | ths | tcg_temp_free(t0); |
2598 | 6c5c1e20 | ths | tcg_temp_free(t1); |
2599 | 7a387fff | ths | } |
2600 | 7a387fff | ths | |
2601 | 49bcf33c | aurel32 | static void gen_bshfl (DisasContext *ctx, uint32_t op2, int rt, int rd) |
2602 | 49bcf33c | aurel32 | { |
2603 | 3a55fa47 | aurel32 | TCGv t0; |
2604 | 49bcf33c | aurel32 | |
2605 | 3a55fa47 | aurel32 | if (rd == 0) { |
2606 | 3a55fa47 | aurel32 | /* If no destination, treat it as a NOP. */
|
2607 | 3a55fa47 | aurel32 | MIPS_DEBUG("NOP");
|
2608 | 3a55fa47 | aurel32 | return;
|
2609 | 3a55fa47 | aurel32 | } |
2610 | 3a55fa47 | aurel32 | |
2611 | 3a55fa47 | aurel32 | t0 = tcg_temp_new(); |
2612 | 3a55fa47 | aurel32 | gen_load_gpr(t0, rt); |
2613 | 49bcf33c | aurel32 | switch (op2) {
|
2614 | 49bcf33c | aurel32 | case OPC_WSBH:
|
2615 | 3a55fa47 | aurel32 | { |
2616 | 3a55fa47 | aurel32 | TCGv t1 = tcg_temp_new(); |
2617 | 3a55fa47 | aurel32 | |
2618 | 3a55fa47 | aurel32 | tcg_gen_shri_tl(t1, t0, 8);
|
2619 | 3a55fa47 | aurel32 | tcg_gen_andi_tl(t1, t1, 0x00FF00FF);
|
2620 | 3a55fa47 | aurel32 | tcg_gen_shli_tl(t0, t0, 8);
|
2621 | 3a55fa47 | aurel32 | tcg_gen_andi_tl(t0, t0, ~0x00FF00FF);
|
2622 | 3a55fa47 | aurel32 | tcg_gen_or_tl(t0, t0, t1); |
2623 | 3a55fa47 | aurel32 | tcg_temp_free(t1); |
2624 | 3a55fa47 | aurel32 | tcg_gen_ext32s_tl(cpu_gpr[rd], t0); |
2625 | 3a55fa47 | aurel32 | } |
2626 | 49bcf33c | aurel32 | break;
|
2627 | 49bcf33c | aurel32 | case OPC_SEB:
|
2628 | 3a55fa47 | aurel32 | tcg_gen_ext8s_tl(cpu_gpr[rd], t0); |
2629 | 49bcf33c | aurel32 | break;
|
2630 | 49bcf33c | aurel32 | case OPC_SEH:
|
2631 | 3a55fa47 | aurel32 | tcg_gen_ext16s_tl(cpu_gpr[rd], t0); |
2632 | 49bcf33c | aurel32 | break;
|
2633 | 49bcf33c | aurel32 | #if defined(TARGET_MIPS64)
|
2634 | 49bcf33c | aurel32 | case OPC_DSBH:
|
2635 | 3a55fa47 | aurel32 | { |
2636 | 3a55fa47 | aurel32 | TCGv t1 = tcg_temp_new(); |
2637 | 3a55fa47 | aurel32 | |
2638 | 3a55fa47 | aurel32 | tcg_gen_shri_tl(t1, t0, 8);
|
2639 | 3a55fa47 | aurel32 | tcg_gen_andi_tl(t1, t1, 0x00FF00FF00FF00FFULL);
|
2640 | 3a55fa47 | aurel32 | tcg_gen_shli_tl(t0, t0, 8);
|
2641 | 3a55fa47 | aurel32 | tcg_gen_andi_tl(t0, t0, ~0x00FF00FF00FF00FFULL);
|
2642 | 3a55fa47 | aurel32 | tcg_gen_or_tl(cpu_gpr[rd], t0, t1); |
2643 | 3a55fa47 | aurel32 | tcg_temp_free(t1); |
2644 | 3a55fa47 | aurel32 | } |
2645 | 49bcf33c | aurel32 | break;
|
2646 | 49bcf33c | aurel32 | case OPC_DSHD:
|
2647 | 3a55fa47 | aurel32 | { |
2648 | 3a55fa47 | aurel32 | TCGv t1 = tcg_temp_new(); |
2649 | 3a55fa47 | aurel32 | |
2650 | 3a55fa47 | aurel32 | tcg_gen_shri_tl(t1, t0, 16);
|
2651 | 3a55fa47 | aurel32 | tcg_gen_andi_tl(t1, t1, 0x0000FFFF0000FFFFULL);
|
2652 | 3a55fa47 | aurel32 | tcg_gen_shli_tl(t0, t0, 16);
|
2653 | 3a55fa47 | aurel32 | tcg_gen_andi_tl(t0, t0, ~0x0000FFFF0000FFFFULL);
|
2654 | 3a55fa47 | aurel32 | tcg_gen_or_tl(t0, t0, t1); |
2655 | 3a55fa47 | aurel32 | tcg_gen_shri_tl(t1, t0, 32);
|
2656 | 3a55fa47 | aurel32 | tcg_gen_shli_tl(t0, t0, 32);
|
2657 | 3a55fa47 | aurel32 | tcg_gen_or_tl(cpu_gpr[rd], t0, t1); |
2658 | 3a55fa47 | aurel32 | tcg_temp_free(t1); |
2659 | 3a55fa47 | aurel32 | } |
2660 | 49bcf33c | aurel32 | break;
|
2661 | 49bcf33c | aurel32 | #endif
|
2662 | 49bcf33c | aurel32 | default:
|
2663 | 49bcf33c | aurel32 | MIPS_INVAL("bsfhl");
|
2664 | 49bcf33c | aurel32 | generate_exception(ctx, EXCP_RI); |
2665 | 49bcf33c | aurel32 | tcg_temp_free(t0); |
2666 | 49bcf33c | aurel32 | return;
|
2667 | 49bcf33c | aurel32 | } |
2668 | 49bcf33c | aurel32 | tcg_temp_free(t0); |
2669 | 49bcf33c | aurel32 | } |
2670 | 49bcf33c | aurel32 | |
2671 | f1aa6320 | ths | #ifndef CONFIG_USER_ONLY
|
2672 | 0eaef5aa | ths | /* CP0 (MMU and control) */
|
2673 | 4f57689a | ths | static inline void gen_mfc0_load32 (TCGv t, target_ulong off) |
2674 | 4f57689a | ths | { |
2675 | a7812ae4 | pbrook | TCGv_i32 r_tmp = tcg_temp_new_i32(); |
2676 | 4f57689a | ths | |
2677 | 4f57689a | ths | tcg_gen_ld_i32(r_tmp, cpu_env, off); |
2678 | 4f57689a | ths | tcg_gen_ext_i32_tl(t, r_tmp); |
2679 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp); |
2680 | 4f57689a | ths | } |
2681 | 4f57689a | ths | |
2682 | 4f57689a | ths | static inline void gen_mfc0_load64 (TCGv t, target_ulong off) |
2683 | 4f57689a | ths | { |
2684 | 2c2435bd | ths | tcg_gen_ld_tl(t, cpu_env, off); |
2685 | 2c2435bd | ths | tcg_gen_ext32s_tl(t, t); |
2686 | 4f57689a | ths | } |
2687 | 4f57689a | ths | |
2688 | f1aa6320 | ths | static inline void gen_mtc0_store32 (TCGv t, target_ulong off) |
2689 | f1aa6320 | ths | { |
2690 | a7812ae4 | pbrook | TCGv_i32 r_tmp = tcg_temp_new_i32(); |
2691 | f1aa6320 | ths | |
2692 | f1aa6320 | ths | tcg_gen_trunc_tl_i32(r_tmp, t); |
2693 | f1aa6320 | ths | tcg_gen_st_i32(r_tmp, cpu_env, off); |
2694 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp); |
2695 | f1aa6320 | ths | } |
2696 | f1aa6320 | ths | |
2697 | f1aa6320 | ths | static inline void gen_mtc0_store64 (TCGv t, target_ulong off) |
2698 | f1aa6320 | ths | { |
2699 | 2c2435bd | ths | tcg_gen_ext32s_tl(t, t); |
2700 | 2c2435bd | ths | tcg_gen_st_tl(t, cpu_env, off); |
2701 | f1aa6320 | ths | } |
2702 | f1aa6320 | ths | |
2703 | 1a3fd9c3 | ths | static void gen_mfc0 (CPUState *env, DisasContext *ctx, TCGv t0, int reg, int sel) |
2704 | 873eb012 | ths | { |
2705 | 7a387fff | ths | const char *rn = "invalid"; |
2706 | 873eb012 | ths | |
2707 | e189e748 | ths | if (sel != 0) |
2708 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
2709 | e189e748 | ths | |
2710 | 873eb012 | ths | switch (reg) {
|
2711 | 873eb012 | ths | case 0: |
2712 | 7a387fff | ths | switch (sel) {
|
2713 | 7a387fff | ths | case 0: |
2714 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Index)); |
2715 | 7a387fff | ths | rn = "Index";
|
2716 | 7a387fff | ths | break;
|
2717 | 7a387fff | ths | case 1: |
2718 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2719 | a7812ae4 | pbrook | gen_helper_mfc0_mvpcontrol(t0); |
2720 | 7a387fff | ths | rn = "MVPControl";
|
2721 | ead9360e | ths | break;
|
2722 | 7a387fff | ths | case 2: |
2723 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2724 | a7812ae4 | pbrook | gen_helper_mfc0_mvpconf0(t0); |
2725 | 7a387fff | ths | rn = "MVPConf0";
|
2726 | ead9360e | ths | break;
|
2727 | 7a387fff | ths | case 3: |
2728 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2729 | a7812ae4 | pbrook | gen_helper_mfc0_mvpconf1(t0); |
2730 | 7a387fff | ths | rn = "MVPConf1";
|
2731 | ead9360e | ths | break;
|
2732 | 7a387fff | ths | default:
|
2733 | 7a387fff | ths | goto die;
|
2734 | 7a387fff | ths | } |
2735 | 873eb012 | ths | break;
|
2736 | 873eb012 | ths | case 1: |
2737 | 7a387fff | ths | switch (sel) {
|
2738 | 7a387fff | ths | case 0: |
2739 | a7812ae4 | pbrook | gen_helper_mfc0_random(t0); |
2740 | 7a387fff | ths | rn = "Random";
|
2741 | 2423f660 | ths | break;
|
2742 | 7a387fff | ths | case 1: |
2743 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2744 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_VPEControl)); |
2745 | 7a387fff | ths | rn = "VPEControl";
|
2746 | ead9360e | ths | break;
|
2747 | 7a387fff | ths | case 2: |
2748 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2749 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_VPEConf0)); |
2750 | 7a387fff | ths | rn = "VPEConf0";
|
2751 | ead9360e | ths | break;
|
2752 | 7a387fff | ths | case 3: |
2753 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2754 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_VPEConf1)); |
2755 | 7a387fff | ths | rn = "VPEConf1";
|
2756 | ead9360e | ths | break;
|
2757 | 7a387fff | ths | case 4: |
2758 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2759 | 1a3fd9c3 | ths | gen_mfc0_load64(t0, offsetof(CPUState, CP0_YQMask)); |
2760 | 7a387fff | ths | rn = "YQMask";
|
2761 | ead9360e | ths | break;
|
2762 | 7a387fff | ths | case 5: |
2763 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2764 | 1a3fd9c3 | ths | gen_mfc0_load64(t0, offsetof(CPUState, CP0_VPESchedule)); |
2765 | 7a387fff | ths | rn = "VPESchedule";
|
2766 | ead9360e | ths | break;
|
2767 | 7a387fff | ths | case 6: |
2768 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2769 | 1a3fd9c3 | ths | gen_mfc0_load64(t0, offsetof(CPUState, CP0_VPEScheFBack)); |
2770 | 7a387fff | ths | rn = "VPEScheFBack";
|
2771 | ead9360e | ths | break;
|
2772 | 7a387fff | ths | case 7: |
2773 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2774 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_VPEOpt)); |
2775 | 7a387fff | ths | rn = "VPEOpt";
|
2776 | ead9360e | ths | break;
|
2777 | 7a387fff | ths | default:
|
2778 | 7a387fff | ths | goto die;
|
2779 | 7a387fff | ths | } |
2780 | 873eb012 | ths | break;
|
2781 | 873eb012 | ths | case 2: |
2782 | 7a387fff | ths | switch (sel) {
|
2783 | 7a387fff | ths | case 0: |
2784 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_EntryLo0)); |
2785 | 1a3fd9c3 | ths | tcg_gen_ext32s_tl(t0, t0); |
2786 | 2423f660 | ths | rn = "EntryLo0";
|
2787 | 2423f660 | ths | break;
|
2788 | 7a387fff | ths | case 1: |
2789 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2790 | a7812ae4 | pbrook | gen_helper_mfc0_tcstatus(t0); |
2791 | 2423f660 | ths | rn = "TCStatus";
|
2792 | ead9360e | ths | break;
|
2793 | 7a387fff | ths | case 2: |
2794 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2795 | a7812ae4 | pbrook | gen_helper_mfc0_tcbind(t0); |
2796 | 2423f660 | ths | rn = "TCBind";
|
2797 | ead9360e | ths | break;
|
2798 | 7a387fff | ths | case 3: |
2799 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2800 | a7812ae4 | pbrook | gen_helper_mfc0_tcrestart(t0); |
2801 | 2423f660 | ths | rn = "TCRestart";
|
2802 | ead9360e | ths | break;
|
2803 | 7a387fff | ths | case 4: |
2804 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2805 | a7812ae4 | pbrook | gen_helper_mfc0_tchalt(t0); |
2806 | 2423f660 | ths | rn = "TCHalt";
|
2807 | ead9360e | ths | break;
|
2808 | 7a387fff | ths | case 5: |
2809 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2810 | a7812ae4 | pbrook | gen_helper_mfc0_tccontext(t0); |
2811 | 2423f660 | ths | rn = "TCContext";
|
2812 | ead9360e | ths | break;
|
2813 | 7a387fff | ths | case 6: |
2814 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2815 | a7812ae4 | pbrook | gen_helper_mfc0_tcschedule(t0); |
2816 | 2423f660 | ths | rn = "TCSchedule";
|
2817 | ead9360e | ths | break;
|
2818 | 7a387fff | ths | case 7: |
2819 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
2820 | a7812ae4 | pbrook | gen_helper_mfc0_tcschefback(t0); |
2821 | 2423f660 | ths | rn = "TCScheFBack";
|
2822 | ead9360e | ths | break;
|
2823 | 7a387fff | ths | default:
|
2824 | 7a387fff | ths | goto die;
|
2825 | 7a387fff | ths | } |
2826 | 873eb012 | ths | break;
|
2827 | 873eb012 | ths | case 3: |
2828 | 7a387fff | ths | switch (sel) {
|
2829 | 7a387fff | ths | case 0: |
2830 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_EntryLo1)); |
2831 | 1a3fd9c3 | ths | tcg_gen_ext32s_tl(t0, t0); |
2832 | 2423f660 | ths | rn = "EntryLo1";
|
2833 | 2423f660 | ths | break;
|
2834 | 7a387fff | ths | default:
|
2835 | 7a387fff | ths | goto die;
|
2836 | 1579a72e | ths | } |
2837 | 873eb012 | ths | break;
|
2838 | 873eb012 | ths | case 4: |
2839 | 7a387fff | ths | switch (sel) {
|
2840 | 7a387fff | ths | case 0: |
2841 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_Context)); |
2842 | 1a3fd9c3 | ths | tcg_gen_ext32s_tl(t0, t0); |
2843 | 2423f660 | ths | rn = "Context";
|
2844 | 2423f660 | ths | break;
|
2845 | 7a387fff | ths | case 1: |
2846 | a7812ae4 | pbrook | // gen_helper_mfc0_contextconfig(t0); /* SmartMIPS ASE */
|
2847 | 2423f660 | ths | rn = "ContextConfig";
|
2848 | 2423f660 | ths | // break;
|
2849 | 7a387fff | ths | default:
|
2850 | 7a387fff | ths | goto die;
|
2851 | 1579a72e | ths | } |
2852 | 873eb012 | ths | break;
|
2853 | 873eb012 | ths | case 5: |
2854 | 7a387fff | ths | switch (sel) {
|
2855 | 7a387fff | ths | case 0: |
2856 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_PageMask)); |
2857 | 2423f660 | ths | rn = "PageMask";
|
2858 | 2423f660 | ths | break;
|
2859 | 7a387fff | ths | case 1: |
2860 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2861 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_PageGrain)); |
2862 | 2423f660 | ths | rn = "PageGrain";
|
2863 | 2423f660 | ths | break;
|
2864 | 7a387fff | ths | default:
|
2865 | 7a387fff | ths | goto die;
|
2866 | 1579a72e | ths | } |
2867 | 873eb012 | ths | break;
|
2868 | 873eb012 | ths | case 6: |
2869 | 7a387fff | ths | switch (sel) {
|
2870 | 7a387fff | ths | case 0: |
2871 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Wired)); |
2872 | 2423f660 | ths | rn = "Wired";
|
2873 | 2423f660 | ths | break;
|
2874 | 7a387fff | ths | case 1: |
2875 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2876 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf0)); |
2877 | 2423f660 | ths | rn = "SRSConf0";
|
2878 | ead9360e | ths | break;
|
2879 | 7a387fff | ths | case 2: |
2880 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2881 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf1)); |
2882 | 2423f660 | ths | rn = "SRSConf1";
|
2883 | ead9360e | ths | break;
|
2884 | 7a387fff | ths | case 3: |
2885 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2886 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf2)); |
2887 | 2423f660 | ths | rn = "SRSConf2";
|
2888 | ead9360e | ths | break;
|
2889 | 7a387fff | ths | case 4: |
2890 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2891 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf3)); |
2892 | 2423f660 | ths | rn = "SRSConf3";
|
2893 | ead9360e | ths | break;
|
2894 | 7a387fff | ths | case 5: |
2895 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2896 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf4)); |
2897 | 2423f660 | ths | rn = "SRSConf4";
|
2898 | ead9360e | ths | break;
|
2899 | 7a387fff | ths | default:
|
2900 | 7a387fff | ths | goto die;
|
2901 | 1579a72e | ths | } |
2902 | 873eb012 | ths | break;
|
2903 | 8c0fdd85 | ths | case 7: |
2904 | 7a387fff | ths | switch (sel) {
|
2905 | 7a387fff | ths | case 0: |
2906 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2907 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_HWREna)); |
2908 | 2423f660 | ths | rn = "HWREna";
|
2909 | 2423f660 | ths | break;
|
2910 | 7a387fff | ths | default:
|
2911 | 7a387fff | ths | goto die;
|
2912 | 1579a72e | ths | } |
2913 | 8c0fdd85 | ths | break;
|
2914 | 873eb012 | ths | case 8: |
2915 | 7a387fff | ths | switch (sel) {
|
2916 | 7a387fff | ths | case 0: |
2917 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_BadVAddr)); |
2918 | 1a3fd9c3 | ths | tcg_gen_ext32s_tl(t0, t0); |
2919 | f0b3f3ae | ths | rn = "BadVAddr";
|
2920 | 2423f660 | ths | break;
|
2921 | 7a387fff | ths | default:
|
2922 | 7a387fff | ths | goto die;
|
2923 | 7a387fff | ths | } |
2924 | 873eb012 | ths | break;
|
2925 | 873eb012 | ths | case 9: |
2926 | 7a387fff | ths | switch (sel) {
|
2927 | 7a387fff | ths | case 0: |
2928 | 2e70f6ef | pbrook | /* Mark as an IO operation because we read the time. */
|
2929 | 2e70f6ef | pbrook | if (use_icount)
|
2930 | 2e70f6ef | pbrook | gen_io_start(); |
2931 | a7812ae4 | pbrook | gen_helper_mfc0_count(t0); |
2932 | 2e70f6ef | pbrook | if (use_icount) {
|
2933 | 2e70f6ef | pbrook | gen_io_end(); |
2934 | 2e70f6ef | pbrook | ctx->bstate = BS_STOP; |
2935 | 2e70f6ef | pbrook | } |
2936 | 2423f660 | ths | rn = "Count";
|
2937 | 2423f660 | ths | break;
|
2938 | 2423f660 | ths | /* 6,7 are implementation dependent */
|
2939 | 7a387fff | ths | default:
|
2940 | 7a387fff | ths | goto die;
|
2941 | 2423f660 | ths | } |
2942 | 873eb012 | ths | break;
|
2943 | 873eb012 | ths | case 10: |
2944 | 7a387fff | ths | switch (sel) {
|
2945 | 7a387fff | ths | case 0: |
2946 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_EntryHi)); |
2947 | 1a3fd9c3 | ths | tcg_gen_ext32s_tl(t0, t0); |
2948 | 2423f660 | ths | rn = "EntryHi";
|
2949 | 2423f660 | ths | break;
|
2950 | 7a387fff | ths | default:
|
2951 | 7a387fff | ths | goto die;
|
2952 | 1579a72e | ths | } |
2953 | 873eb012 | ths | break;
|
2954 | 873eb012 | ths | case 11: |
2955 | 7a387fff | ths | switch (sel) {
|
2956 | 7a387fff | ths | case 0: |
2957 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Compare)); |
2958 | 2423f660 | ths | rn = "Compare";
|
2959 | 2423f660 | ths | break;
|
2960 | 2423f660 | ths | /* 6,7 are implementation dependent */
|
2961 | 7a387fff | ths | default:
|
2962 | 7a387fff | ths | goto die;
|
2963 | 2423f660 | ths | } |
2964 | 873eb012 | ths | break;
|
2965 | 873eb012 | ths | case 12: |
2966 | 7a387fff | ths | switch (sel) {
|
2967 | 7a387fff | ths | case 0: |
2968 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Status)); |
2969 | 2423f660 | ths | rn = "Status";
|
2970 | 2423f660 | ths | break;
|
2971 | 7a387fff | ths | case 1: |
2972 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2973 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_IntCtl)); |
2974 | 2423f660 | ths | rn = "IntCtl";
|
2975 | 2423f660 | ths | break;
|
2976 | 7a387fff | ths | case 2: |
2977 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2978 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSCtl)); |
2979 | 2423f660 | ths | rn = "SRSCtl";
|
2980 | 2423f660 | ths | break;
|
2981 | 7a387fff | ths | case 3: |
2982 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
2983 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSMap)); |
2984 | 2423f660 | ths | rn = "SRSMap";
|
2985 | fd88b6ab | ths | break;
|
2986 | 7a387fff | ths | default:
|
2987 | 7a387fff | ths | goto die;
|
2988 | 7a387fff | ths | } |
2989 | 873eb012 | ths | break;
|
2990 | 873eb012 | ths | case 13: |
2991 | 7a387fff | ths | switch (sel) {
|
2992 | 7a387fff | ths | case 0: |
2993 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Cause)); |
2994 | 2423f660 | ths | rn = "Cause";
|
2995 | 2423f660 | ths | break;
|
2996 | 7a387fff | ths | default:
|
2997 | 7a387fff | ths | goto die;
|
2998 | 7a387fff | ths | } |
2999 | 873eb012 | ths | break;
|
3000 | 873eb012 | ths | case 14: |
3001 | 7a387fff | ths | switch (sel) {
|
3002 | 7a387fff | ths | case 0: |
3003 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_EPC)); |
3004 | 1a3fd9c3 | ths | tcg_gen_ext32s_tl(t0, t0); |
3005 | 2423f660 | ths | rn = "EPC";
|
3006 | 2423f660 | ths | break;
|
3007 | 7a387fff | ths | default:
|
3008 | 7a387fff | ths | goto die;
|
3009 | 1579a72e | ths | } |
3010 | 873eb012 | ths | break;
|
3011 | 873eb012 | ths | case 15: |
3012 | 7a387fff | ths | switch (sel) {
|
3013 | 7a387fff | ths | case 0: |
3014 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_PRid)); |
3015 | 2423f660 | ths | rn = "PRid";
|
3016 | 2423f660 | ths | break;
|
3017 | 7a387fff | ths | case 1: |
3018 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3019 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_EBase)); |
3020 | 2423f660 | ths | rn = "EBase";
|
3021 | 2423f660 | ths | break;
|
3022 | 7a387fff | ths | default:
|
3023 | 7a387fff | ths | goto die;
|
3024 | 7a387fff | ths | } |
3025 | 873eb012 | ths | break;
|
3026 | 873eb012 | ths | case 16: |
3027 | 873eb012 | ths | switch (sel) {
|
3028 | 873eb012 | ths | case 0: |
3029 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config0)); |
3030 | 873eb012 | ths | rn = "Config";
|
3031 | 873eb012 | ths | break;
|
3032 | 873eb012 | ths | case 1: |
3033 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config1)); |
3034 | 873eb012 | ths | rn = "Config1";
|
3035 | 873eb012 | ths | break;
|
3036 | 7a387fff | ths | case 2: |
3037 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config2)); |
3038 | 7a387fff | ths | rn = "Config2";
|
3039 | 7a387fff | ths | break;
|
3040 | 7a387fff | ths | case 3: |
3041 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config3)); |
3042 | 7a387fff | ths | rn = "Config3";
|
3043 | 7a387fff | ths | break;
|
3044 | e397ee33 | ths | /* 4,5 are reserved */
|
3045 | e397ee33 | ths | /* 6,7 are implementation dependent */
|
3046 | e397ee33 | ths | case 6: |
3047 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config6)); |
3048 | e397ee33 | ths | rn = "Config6";
|
3049 | e397ee33 | ths | break;
|
3050 | e397ee33 | ths | case 7: |
3051 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config7)); |
3052 | e397ee33 | ths | rn = "Config7";
|
3053 | e397ee33 | ths | break;
|
3054 | 873eb012 | ths | default:
|
3055 | 873eb012 | ths | goto die;
|
3056 | 873eb012 | ths | } |
3057 | 873eb012 | ths | break;
|
3058 | 873eb012 | ths | case 17: |
3059 | 7a387fff | ths | switch (sel) {
|
3060 | 7a387fff | ths | case 0: |
3061 | a7812ae4 | pbrook | gen_helper_mfc0_lladdr(t0); |
3062 | 2423f660 | ths | rn = "LLAddr";
|
3063 | 2423f660 | ths | break;
|
3064 | 7a387fff | ths | default:
|
3065 | 7a387fff | ths | goto die;
|
3066 | 7a387fff | ths | } |
3067 | 873eb012 | ths | break;
|
3068 | 873eb012 | ths | case 18: |
3069 | 7a387fff | ths | switch (sel) {
|
3070 | fd88b6ab | ths | case 0 ... 7: |
3071 | a7812ae4 | pbrook | gen_helper_1i(mfc0_watchlo, t0, sel); |
3072 | 2423f660 | ths | rn = "WatchLo";
|
3073 | 2423f660 | ths | break;
|
3074 | 7a387fff | ths | default:
|
3075 | 7a387fff | ths | goto die;
|
3076 | 7a387fff | ths | } |
3077 | 873eb012 | ths | break;
|
3078 | 873eb012 | ths | case 19: |
3079 | 7a387fff | ths | switch (sel) {
|
3080 | fd88b6ab | ths | case 0 ...7: |
3081 | a7812ae4 | pbrook | gen_helper_1i(mfc0_watchhi, t0, sel); |
3082 | 2423f660 | ths | rn = "WatchHi";
|
3083 | 2423f660 | ths | break;
|
3084 | 7a387fff | ths | default:
|
3085 | 7a387fff | ths | goto die;
|
3086 | 7a387fff | ths | } |
3087 | 873eb012 | ths | break;
|
3088 | 8c0fdd85 | ths | case 20: |
3089 | 7a387fff | ths | switch (sel) {
|
3090 | 7a387fff | ths | case 0: |
3091 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
3092 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
3093 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_XContext)); |
3094 | 1a3fd9c3 | ths | tcg_gen_ext32s_tl(t0, t0); |
3095 | 2423f660 | ths | rn = "XContext";
|
3096 | 2423f660 | ths | break;
|
3097 | 703eaf37 | ths | #endif
|
3098 | 7a387fff | ths | default:
|
3099 | 7a387fff | ths | goto die;
|
3100 | 7a387fff | ths | } |
3101 | 8c0fdd85 | ths | break;
|
3102 | 8c0fdd85 | ths | case 21: |
3103 | 7a387fff | ths | /* Officially reserved, but sel 0 is used for R1x000 framemask */
|
3104 | 7a387fff | ths | switch (sel) {
|
3105 | 7a387fff | ths | case 0: |
3106 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Framemask)); |
3107 | 2423f660 | ths | rn = "Framemask";
|
3108 | 2423f660 | ths | break;
|
3109 | 7a387fff | ths | default:
|
3110 | 7a387fff | ths | goto die;
|
3111 | 7a387fff | ths | } |
3112 | 8c0fdd85 | ths | break;
|
3113 | 8c0fdd85 | ths | case 22: |
3114 | da80682b | aurel32 | tcg_gen_movi_tl(t0, 0); /* unimplemented */ |
3115 | 2423f660 | ths | rn = "'Diagnostic"; /* implementation dependent */ |
3116 | 2423f660 | ths | break;
|
3117 | 873eb012 | ths | case 23: |
3118 | 7a387fff | ths | switch (sel) {
|
3119 | 7a387fff | ths | case 0: |
3120 | a7812ae4 | pbrook | gen_helper_mfc0_debug(t0); /* EJTAG support */
|
3121 | 2423f660 | ths | rn = "Debug";
|
3122 | 2423f660 | ths | break;
|
3123 | 7a387fff | ths | case 1: |
3124 | a7812ae4 | pbrook | // gen_helper_mfc0_tracecontrol(t0); /* PDtrace support */
|
3125 | 2423f660 | ths | rn = "TraceControl";
|
3126 | 2423f660 | ths | // break;
|
3127 | 7a387fff | ths | case 2: |
3128 | a7812ae4 | pbrook | // gen_helper_mfc0_tracecontrol2(t0); /* PDtrace support */
|
3129 | 2423f660 | ths | rn = "TraceControl2";
|
3130 | 2423f660 | ths | // break;
|
3131 | 7a387fff | ths | case 3: |
3132 | a7812ae4 | pbrook | // gen_helper_mfc0_usertracedata(t0); /* PDtrace support */
|
3133 | 2423f660 | ths | rn = "UserTraceData";
|
3134 | 2423f660 | ths | // break;
|
3135 | 7a387fff | ths | case 4: |
3136 | a7812ae4 | pbrook | // gen_helper_mfc0_tracebpc(t0); /* PDtrace support */
|
3137 | 2423f660 | ths | rn = "TraceBPC";
|
3138 | 2423f660 | ths | // break;
|
3139 | 7a387fff | ths | default:
|
3140 | 7a387fff | ths | goto die;
|
3141 | 7a387fff | ths | } |
3142 | 873eb012 | ths | break;
|
3143 | 873eb012 | ths | case 24: |
3144 | 7a387fff | ths | switch (sel) {
|
3145 | 7a387fff | ths | case 0: |
3146 | f0b3f3ae | ths | /* EJTAG support */
|
3147 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_DEPC)); |
3148 | 1a3fd9c3 | ths | tcg_gen_ext32s_tl(t0, t0); |
3149 | 2423f660 | ths | rn = "DEPC";
|
3150 | 2423f660 | ths | break;
|
3151 | 7a387fff | ths | default:
|
3152 | 7a387fff | ths | goto die;
|
3153 | 7a387fff | ths | } |
3154 | 873eb012 | ths | break;
|
3155 | 8c0fdd85 | ths | case 25: |
3156 | 7a387fff | ths | switch (sel) {
|
3157 | 7a387fff | ths | case 0: |
3158 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Performance0)); |
3159 | 2423f660 | ths | rn = "Performance0";
|
3160 | 7a387fff | ths | break;
|
3161 | 7a387fff | ths | case 1: |
3162 | a7812ae4 | pbrook | // gen_helper_mfc0_performance1(t0);
|
3163 | 2423f660 | ths | rn = "Performance1";
|
3164 | 2423f660 | ths | // break;
|
3165 | 7a387fff | ths | case 2: |
3166 | a7812ae4 | pbrook | // gen_helper_mfc0_performance2(t0);
|
3167 | 2423f660 | ths | rn = "Performance2";
|
3168 | 2423f660 | ths | // break;
|
3169 | 7a387fff | ths | case 3: |
3170 | a7812ae4 | pbrook | // gen_helper_mfc0_performance3(t0);
|
3171 | 2423f660 | ths | rn = "Performance3";
|
3172 | 2423f660 | ths | // break;
|
3173 | 7a387fff | ths | case 4: |
3174 | a7812ae4 | pbrook | // gen_helper_mfc0_performance4(t0);
|
3175 | 2423f660 | ths | rn = "Performance4";
|
3176 | 2423f660 | ths | // break;
|
3177 | 7a387fff | ths | case 5: |
3178 | a7812ae4 | pbrook | // gen_helper_mfc0_performance5(t0);
|
3179 | 2423f660 | ths | rn = "Performance5";
|
3180 | 2423f660 | ths | // break;
|
3181 | 7a387fff | ths | case 6: |
3182 | a7812ae4 | pbrook | // gen_helper_mfc0_performance6(t0);
|
3183 | 2423f660 | ths | rn = "Performance6";
|
3184 | 2423f660 | ths | // break;
|
3185 | 7a387fff | ths | case 7: |
3186 | a7812ae4 | pbrook | // gen_helper_mfc0_performance7(t0);
|
3187 | 2423f660 | ths | rn = "Performance7";
|
3188 | 2423f660 | ths | // break;
|
3189 | 7a387fff | ths | default:
|
3190 | 7a387fff | ths | goto die;
|
3191 | 7a387fff | ths | } |
3192 | 8c0fdd85 | ths | break;
|
3193 | 8c0fdd85 | ths | case 26: |
3194 | da80682b | aurel32 | tcg_gen_movi_tl(t0, 0); /* unimplemented */ |
3195 | da80682b | aurel32 | rn = "ECC";
|
3196 | da80682b | aurel32 | break;
|
3197 | 8c0fdd85 | ths | case 27: |
3198 | 7a387fff | ths | switch (sel) {
|
3199 | 7a387fff | ths | case 0 ... 3: |
3200 | da80682b | aurel32 | tcg_gen_movi_tl(t0, 0); /* unimplemented */ |
3201 | 2423f660 | ths | rn = "CacheErr";
|
3202 | 2423f660 | ths | break;
|
3203 | 7a387fff | ths | default:
|
3204 | 7a387fff | ths | goto die;
|
3205 | 7a387fff | ths | } |
3206 | 8c0fdd85 | ths | break;
|
3207 | 873eb012 | ths | case 28: |
3208 | 873eb012 | ths | switch (sel) {
|
3209 | 873eb012 | ths | case 0: |
3210 | 7a387fff | ths | case 2: |
3211 | 7a387fff | ths | case 4: |
3212 | 7a387fff | ths | case 6: |
3213 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_TagLo)); |
3214 | 873eb012 | ths | rn = "TagLo";
|
3215 | 873eb012 | ths | break;
|
3216 | 873eb012 | ths | case 1: |
3217 | 7a387fff | ths | case 3: |
3218 | 7a387fff | ths | case 5: |
3219 | 7a387fff | ths | case 7: |
3220 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_DataLo)); |
3221 | 873eb012 | ths | rn = "DataLo";
|
3222 | 873eb012 | ths | break;
|
3223 | 873eb012 | ths | default:
|
3224 | 873eb012 | ths | goto die;
|
3225 | 873eb012 | ths | } |
3226 | 873eb012 | ths | break;
|
3227 | 8c0fdd85 | ths | case 29: |
3228 | 7a387fff | ths | switch (sel) {
|
3229 | 7a387fff | ths | case 0: |
3230 | 7a387fff | ths | case 2: |
3231 | 7a387fff | ths | case 4: |
3232 | 7a387fff | ths | case 6: |
3233 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_TagHi)); |
3234 | 7a387fff | ths | rn = "TagHi";
|
3235 | 7a387fff | ths | break;
|
3236 | 7a387fff | ths | case 1: |
3237 | 7a387fff | ths | case 3: |
3238 | 7a387fff | ths | case 5: |
3239 | 7a387fff | ths | case 7: |
3240 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_DataHi)); |
3241 | 7a387fff | ths | rn = "DataHi";
|
3242 | 7a387fff | ths | break;
|
3243 | 7a387fff | ths | default:
|
3244 | 7a387fff | ths | goto die;
|
3245 | 7a387fff | ths | } |
3246 | 8c0fdd85 | ths | break;
|
3247 | 873eb012 | ths | case 30: |
3248 | 7a387fff | ths | switch (sel) {
|
3249 | 7a387fff | ths | case 0: |
3250 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_ErrorEPC)); |
3251 | 1a3fd9c3 | ths | tcg_gen_ext32s_tl(t0, t0); |
3252 | 2423f660 | ths | rn = "ErrorEPC";
|
3253 | 2423f660 | ths | break;
|
3254 | 7a387fff | ths | default:
|
3255 | 7a387fff | ths | goto die;
|
3256 | 7a387fff | ths | } |
3257 | 873eb012 | ths | break;
|
3258 | 873eb012 | ths | case 31: |
3259 | 7a387fff | ths | switch (sel) {
|
3260 | 7a387fff | ths | case 0: |
3261 | f0b3f3ae | ths | /* EJTAG support */
|
3262 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_DESAVE)); |
3263 | 2423f660 | ths | rn = "DESAVE";
|
3264 | 2423f660 | ths | break;
|
3265 | 7a387fff | ths | default:
|
3266 | 7a387fff | ths | goto die;
|
3267 | 7a387fff | ths | } |
3268 | 873eb012 | ths | break;
|
3269 | 873eb012 | ths | default:
|
3270 | 873eb012 | ths | goto die;
|
3271 | 873eb012 | ths | } |
3272 | d12d51d5 | aliguori | LOG_DISAS("mfc0 %s (reg %d sel %d)\n", rn, reg, sel);
|
3273 | 873eb012 | ths | return;
|
3274 | 873eb012 | ths | |
3275 | 873eb012 | ths | die:
|
3276 | d12d51d5 | aliguori | LOG_DISAS("mfc0 %s (reg %d sel %d)\n", rn, reg, sel);
|
3277 | 873eb012 | ths | generate_exception(ctx, EXCP_RI); |
3278 | 873eb012 | ths | } |
3279 | 873eb012 | ths | |
3280 | 1a3fd9c3 | ths | static void gen_mtc0 (CPUState *env, DisasContext *ctx, TCGv t0, int reg, int sel) |
3281 | 8c0fdd85 | ths | { |
3282 | 7a387fff | ths | const char *rn = "invalid"; |
3283 | 7a387fff | ths | |
3284 | e189e748 | ths | if (sel != 0) |
3285 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
3286 | e189e748 | ths | |
3287 | 2e70f6ef | pbrook | if (use_icount)
|
3288 | 2e70f6ef | pbrook | gen_io_start(); |
3289 | 2e70f6ef | pbrook | |
3290 | 8c0fdd85 | ths | switch (reg) {
|
3291 | 8c0fdd85 | ths | case 0: |
3292 | 7a387fff | ths | switch (sel) {
|
3293 | 7a387fff | ths | case 0: |
3294 | a7812ae4 | pbrook | gen_helper_mtc0_index(t0); |
3295 | 7a387fff | ths | rn = "Index";
|
3296 | 7a387fff | ths | break;
|
3297 | 7a387fff | ths | case 1: |
3298 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3299 | a7812ae4 | pbrook | gen_helper_mtc0_mvpcontrol(t0); |
3300 | 7a387fff | ths | rn = "MVPControl";
|
3301 | ead9360e | ths | break;
|
3302 | 7a387fff | ths | case 2: |
3303 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3304 | ead9360e | ths | /* ignored */
|
3305 | 7a387fff | ths | rn = "MVPConf0";
|
3306 | ead9360e | ths | break;
|
3307 | 7a387fff | ths | case 3: |
3308 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3309 | ead9360e | ths | /* ignored */
|
3310 | 7a387fff | ths | rn = "MVPConf1";
|
3311 | ead9360e | ths | break;
|
3312 | 7a387fff | ths | default:
|
3313 | 7a387fff | ths | goto die;
|
3314 | 7a387fff | ths | } |
3315 | 8c0fdd85 | ths | break;
|
3316 | 8c0fdd85 | ths | case 1: |
3317 | 7a387fff | ths | switch (sel) {
|
3318 | 7a387fff | ths | case 0: |
3319 | 2423f660 | ths | /* ignored */
|
3320 | 7a387fff | ths | rn = "Random";
|
3321 | 2423f660 | ths | break;
|
3322 | 7a387fff | ths | case 1: |
3323 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3324 | a7812ae4 | pbrook | gen_helper_mtc0_vpecontrol(t0); |
3325 | 7a387fff | ths | rn = "VPEControl";
|
3326 | ead9360e | ths | break;
|
3327 | 7a387fff | ths | case 2: |
3328 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3329 | a7812ae4 | pbrook | gen_helper_mtc0_vpeconf0(t0); |
3330 | 7a387fff | ths | rn = "VPEConf0";
|
3331 | ead9360e | ths | break;
|
3332 | 7a387fff | ths | case 3: |
3333 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3334 | a7812ae4 | pbrook | gen_helper_mtc0_vpeconf1(t0); |
3335 | 7a387fff | ths | rn = "VPEConf1";
|
3336 | ead9360e | ths | break;
|
3337 | 7a387fff | ths | case 4: |
3338 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3339 | a7812ae4 | pbrook | gen_helper_mtc0_yqmask(t0); |
3340 | 7a387fff | ths | rn = "YQMask";
|
3341 | ead9360e | ths | break;
|
3342 | 7a387fff | ths | case 5: |
3343 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3344 | 1a3fd9c3 | ths | gen_mtc0_store64(t0, offsetof(CPUState, CP0_VPESchedule)); |
3345 | 7a387fff | ths | rn = "VPESchedule";
|
3346 | ead9360e | ths | break;
|
3347 | 7a387fff | ths | case 6: |
3348 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3349 | 1a3fd9c3 | ths | gen_mtc0_store64(t0, offsetof(CPUState, CP0_VPEScheFBack)); |
3350 | 7a387fff | ths | rn = "VPEScheFBack";
|
3351 | ead9360e | ths | break;
|
3352 | 7a387fff | ths | case 7: |
3353 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3354 | a7812ae4 | pbrook | gen_helper_mtc0_vpeopt(t0); |
3355 | 7a387fff | ths | rn = "VPEOpt";
|
3356 | ead9360e | ths | break;
|
3357 | 7a387fff | ths | default:
|
3358 | 7a387fff | ths | goto die;
|
3359 | 7a387fff | ths | } |
3360 | 8c0fdd85 | ths | break;
|
3361 | 8c0fdd85 | ths | case 2: |
3362 | 7a387fff | ths | switch (sel) {
|
3363 | 7a387fff | ths | case 0: |
3364 | a7812ae4 | pbrook | gen_helper_mtc0_entrylo0(t0); |
3365 | 2423f660 | ths | rn = "EntryLo0";
|
3366 | 2423f660 | ths | break;
|
3367 | 7a387fff | ths | case 1: |
3368 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3369 | a7812ae4 | pbrook | gen_helper_mtc0_tcstatus(t0); |
3370 | 2423f660 | ths | rn = "TCStatus";
|
3371 | ead9360e | ths | break;
|
3372 | 7a387fff | ths | case 2: |
3373 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3374 | a7812ae4 | pbrook | gen_helper_mtc0_tcbind(t0); |
3375 | 2423f660 | ths | rn = "TCBind";
|
3376 | ead9360e | ths | break;
|
3377 | 7a387fff | ths | case 3: |
3378 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3379 | a7812ae4 | pbrook | gen_helper_mtc0_tcrestart(t0); |
3380 | 2423f660 | ths | rn = "TCRestart";
|
3381 | ead9360e | ths | break;
|
3382 | 7a387fff | ths | case 4: |
3383 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3384 | a7812ae4 | pbrook | gen_helper_mtc0_tchalt(t0); |
3385 | 2423f660 | ths | rn = "TCHalt";
|
3386 | ead9360e | ths | break;
|
3387 | 7a387fff | ths | case 5: |
3388 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3389 | a7812ae4 | pbrook | gen_helper_mtc0_tccontext(t0); |
3390 | 2423f660 | ths | rn = "TCContext";
|
3391 | ead9360e | ths | break;
|
3392 | 7a387fff | ths | case 6: |
3393 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3394 | a7812ae4 | pbrook | gen_helper_mtc0_tcschedule(t0); |
3395 | 2423f660 | ths | rn = "TCSchedule";
|
3396 | ead9360e | ths | break;
|
3397 | 7a387fff | ths | case 7: |
3398 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3399 | a7812ae4 | pbrook | gen_helper_mtc0_tcschefback(t0); |
3400 | 2423f660 | ths | rn = "TCScheFBack";
|
3401 | ead9360e | ths | break;
|
3402 | 7a387fff | ths | default:
|
3403 | 7a387fff | ths | goto die;
|
3404 | 7a387fff | ths | } |
3405 | 8c0fdd85 | ths | break;
|
3406 | 8c0fdd85 | ths | case 3: |
3407 | 7a387fff | ths | switch (sel) {
|
3408 | 7a387fff | ths | case 0: |
3409 | a7812ae4 | pbrook | gen_helper_mtc0_entrylo1(t0); |
3410 | 2423f660 | ths | rn = "EntryLo1";
|
3411 | 2423f660 | ths | break;
|
3412 | 7a387fff | ths | default:
|
3413 | 7a387fff | ths | goto die;
|
3414 | 876d4b07 | ths | } |
3415 | 8c0fdd85 | ths | break;
|
3416 | 8c0fdd85 | ths | case 4: |
3417 | 7a387fff | ths | switch (sel) {
|
3418 | 7a387fff | ths | case 0: |
3419 | a7812ae4 | pbrook | gen_helper_mtc0_context(t0); |
3420 | 2423f660 | ths | rn = "Context";
|
3421 | 2423f660 | ths | break;
|
3422 | 7a387fff | ths | case 1: |
3423 | a7812ae4 | pbrook | // gen_helper_mtc0_contextconfig(t0); /* SmartMIPS ASE */
|
3424 | 2423f660 | ths | rn = "ContextConfig";
|
3425 | 2423f660 | ths | // break;
|
3426 | 7a387fff | ths | default:
|
3427 | 7a387fff | ths | goto die;
|
3428 | 876d4b07 | ths | } |
3429 | 8c0fdd85 | ths | break;
|
3430 | 8c0fdd85 | ths | case 5: |
3431 | 7a387fff | ths | switch (sel) {
|
3432 | 7a387fff | ths | case 0: |
3433 | a7812ae4 | pbrook | gen_helper_mtc0_pagemask(t0); |
3434 | 2423f660 | ths | rn = "PageMask";
|
3435 | 2423f660 | ths | break;
|
3436 | 7a387fff | ths | case 1: |
3437 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3438 | a7812ae4 | pbrook | gen_helper_mtc0_pagegrain(t0); |
3439 | 2423f660 | ths | rn = "PageGrain";
|
3440 | 2423f660 | ths | break;
|
3441 | 7a387fff | ths | default:
|
3442 | 7a387fff | ths | goto die;
|
3443 | 876d4b07 | ths | } |
3444 | 8c0fdd85 | ths | break;
|
3445 | 8c0fdd85 | ths | case 6: |
3446 | 7a387fff | ths | switch (sel) {
|
3447 | 7a387fff | ths | case 0: |
3448 | a7812ae4 | pbrook | gen_helper_mtc0_wired(t0); |
3449 | 2423f660 | ths | rn = "Wired";
|
3450 | 2423f660 | ths | break;
|
3451 | 7a387fff | ths | case 1: |
3452 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3453 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf0(t0); |
3454 | 2423f660 | ths | rn = "SRSConf0";
|
3455 | ead9360e | ths | break;
|
3456 | 7a387fff | ths | case 2: |
3457 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3458 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf1(t0); |
3459 | 2423f660 | ths | rn = "SRSConf1";
|
3460 | ead9360e | ths | break;
|
3461 | 7a387fff | ths | case 3: |
3462 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3463 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf2(t0); |
3464 | 2423f660 | ths | rn = "SRSConf2";
|
3465 | ead9360e | ths | break;
|
3466 | 7a387fff | ths | case 4: |
3467 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3468 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf3(t0); |
3469 | 2423f660 | ths | rn = "SRSConf3";
|
3470 | ead9360e | ths | break;
|
3471 | 7a387fff | ths | case 5: |
3472 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3473 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf4(t0); |
3474 | 2423f660 | ths | rn = "SRSConf4";
|
3475 | ead9360e | ths | break;
|
3476 | 7a387fff | ths | default:
|
3477 | 7a387fff | ths | goto die;
|
3478 | 876d4b07 | ths | } |
3479 | 8c0fdd85 | ths | break;
|
3480 | 8c0fdd85 | ths | case 7: |
3481 | 7a387fff | ths | switch (sel) {
|
3482 | 7a387fff | ths | case 0: |
3483 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3484 | a7812ae4 | pbrook | gen_helper_mtc0_hwrena(t0); |
3485 | 2423f660 | ths | rn = "HWREna";
|
3486 | 2423f660 | ths | break;
|
3487 | 7a387fff | ths | default:
|
3488 | 7a387fff | ths | goto die;
|
3489 | 876d4b07 | ths | } |
3490 | 8c0fdd85 | ths | break;
|
3491 | 8c0fdd85 | ths | case 8: |
3492 | 7a387fff | ths | /* ignored */
|
3493 | f0b3f3ae | ths | rn = "BadVAddr";
|
3494 | 8c0fdd85 | ths | break;
|
3495 | 8c0fdd85 | ths | case 9: |
3496 | 7a387fff | ths | switch (sel) {
|
3497 | 7a387fff | ths | case 0: |
3498 | a7812ae4 | pbrook | gen_helper_mtc0_count(t0); |
3499 | 2423f660 | ths | rn = "Count";
|
3500 | 2423f660 | ths | break;
|
3501 | 876d4b07 | ths | /* 6,7 are implementation dependent */
|
3502 | 7a387fff | ths | default:
|
3503 | 7a387fff | ths | goto die;
|
3504 | 876d4b07 | ths | } |
3505 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
3506 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
3507 | 8c0fdd85 | ths | break;
|
3508 | 8c0fdd85 | ths | case 10: |
3509 | 7a387fff | ths | switch (sel) {
|
3510 | 7a387fff | ths | case 0: |
3511 | a7812ae4 | pbrook | gen_helper_mtc0_entryhi(t0); |
3512 | 2423f660 | ths | rn = "EntryHi";
|
3513 | 2423f660 | ths | break;
|
3514 | 7a387fff | ths | default:
|
3515 | 7a387fff | ths | goto die;
|
3516 | 876d4b07 | ths | } |
3517 | 8c0fdd85 | ths | break;
|
3518 | 8c0fdd85 | ths | case 11: |
3519 | 7a387fff | ths | switch (sel) {
|
3520 | 7a387fff | ths | case 0: |
3521 | a7812ae4 | pbrook | gen_helper_mtc0_compare(t0); |
3522 | 2423f660 | ths | rn = "Compare";
|
3523 | 2423f660 | ths | break;
|
3524 | 2423f660 | ths | /* 6,7 are implementation dependent */
|
3525 | 7a387fff | ths | default:
|
3526 | 7a387fff | ths | goto die;
|
3527 | 876d4b07 | ths | } |
3528 | de9a95f0 | aurel32 | /* Stop translation as we may have switched the execution mode */
|
3529 | de9a95f0 | aurel32 | ctx->bstate = BS_STOP; |
3530 | 8c0fdd85 | ths | break;
|
3531 | 8c0fdd85 | ths | case 12: |
3532 | 7a387fff | ths | switch (sel) {
|
3533 | 7a387fff | ths | case 0: |
3534 | a7812ae4 | pbrook | gen_helper_mtc0_status(t0); |
3535 | 8487327a | ths | /* BS_STOP isn't good enough here, hflags may have changed. */
|
3536 | 8487327a | ths | gen_save_pc(ctx->pc + 4);
|
3537 | 8487327a | ths | ctx->bstate = BS_EXCP; |
3538 | 2423f660 | ths | rn = "Status";
|
3539 | 2423f660 | ths | break;
|
3540 | 7a387fff | ths | case 1: |
3541 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3542 | a7812ae4 | pbrook | gen_helper_mtc0_intctl(t0); |
3543 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3544 | 8487327a | ths | ctx->bstate = BS_STOP; |
3545 | 2423f660 | ths | rn = "IntCtl";
|
3546 | 2423f660 | ths | break;
|
3547 | 7a387fff | ths | case 2: |
3548 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3549 | a7812ae4 | pbrook | gen_helper_mtc0_srsctl(t0); |
3550 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3551 | 8487327a | ths | ctx->bstate = BS_STOP; |
3552 | 2423f660 | ths | rn = "SRSCtl";
|
3553 | 2423f660 | ths | break;
|
3554 | 7a387fff | ths | case 3: |
3555 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3556 | 1a3fd9c3 | ths | gen_mtc0_store32(t0, offsetof(CPUState, CP0_SRSMap)); |
3557 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3558 | 8487327a | ths | ctx->bstate = BS_STOP; |
3559 | 2423f660 | ths | rn = "SRSMap";
|
3560 | fd88b6ab | ths | break;
|
3561 | 7a387fff | ths | default:
|
3562 | 7a387fff | ths | goto die;
|
3563 | 876d4b07 | ths | } |
3564 | 8c0fdd85 | ths | break;
|
3565 | 8c0fdd85 | ths | case 13: |
3566 | 7a387fff | ths | switch (sel) {
|
3567 | 7a387fff | ths | case 0: |
3568 | a7812ae4 | pbrook | gen_helper_mtc0_cause(t0); |
3569 | 2423f660 | ths | rn = "Cause";
|
3570 | 2423f660 | ths | break;
|
3571 | 7a387fff | ths | default:
|
3572 | 7a387fff | ths | goto die;
|
3573 | 876d4b07 | ths | } |
3574 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
3575 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
3576 | 8c0fdd85 | ths | break;
|
3577 | 8c0fdd85 | ths | case 14: |
3578 | 7a387fff | ths | switch (sel) {
|
3579 | 7a387fff | ths | case 0: |
3580 | 1a3fd9c3 | ths | gen_mtc0_store64(t0, offsetof(CPUState, CP0_EPC)); |
3581 | 2423f660 | ths | rn = "EPC";
|
3582 | 2423f660 | ths | break;
|
3583 | 7a387fff | ths | default:
|
3584 | 7a387fff | ths | goto die;
|
3585 | 876d4b07 | ths | } |
3586 | 8c0fdd85 | ths | break;
|
3587 | 8c0fdd85 | ths | case 15: |
3588 | 7a387fff | ths | switch (sel) {
|
3589 | 7a387fff | ths | case 0: |
3590 | 2423f660 | ths | /* ignored */
|
3591 | 2423f660 | ths | rn = "PRid";
|
3592 | 2423f660 | ths | break;
|
3593 | 7a387fff | ths | case 1: |
3594 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
3595 | a7812ae4 | pbrook | gen_helper_mtc0_ebase(t0); |
3596 | 2423f660 | ths | rn = "EBase";
|
3597 | 2423f660 | ths | break;
|
3598 | 7a387fff | ths | default:
|
3599 | 7a387fff | ths | goto die;
|
3600 | 1579a72e | ths | } |
3601 | 8c0fdd85 | ths | break;
|
3602 | 8c0fdd85 | ths | case 16: |
3603 | 8c0fdd85 | ths | switch (sel) {
|
3604 | 8c0fdd85 | ths | case 0: |
3605 | a7812ae4 | pbrook | gen_helper_mtc0_config0(t0); |
3606 | 7a387fff | ths | rn = "Config";
|
3607 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
3608 | 2423f660 | ths | ctx->bstate = BS_STOP; |
3609 | 7a387fff | ths | break;
|
3610 | 7a387fff | ths | case 1: |
3611 | e397ee33 | ths | /* ignored, read only */
|
3612 | 7a387fff | ths | rn = "Config1";
|
3613 | 7a387fff | ths | break;
|
3614 | 7a387fff | ths | case 2: |
3615 | a7812ae4 | pbrook | gen_helper_mtc0_config2(t0); |
3616 | 7a387fff | ths | rn = "Config2";
|
3617 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
3618 | 2423f660 | ths | ctx->bstate = BS_STOP; |
3619 | 8c0fdd85 | ths | break;
|
3620 | 7a387fff | ths | case 3: |
3621 | e397ee33 | ths | /* ignored, read only */
|
3622 | 7a387fff | ths | rn = "Config3";
|
3623 | 7a387fff | ths | break;
|
3624 | e397ee33 | ths | /* 4,5 are reserved */
|
3625 | e397ee33 | ths | /* 6,7 are implementation dependent */
|
3626 | e397ee33 | ths | case 6: |
3627 | e397ee33 | ths | /* ignored */
|
3628 | e397ee33 | ths | rn = "Config6";
|
3629 | e397ee33 | ths | break;
|
3630 | e397ee33 | ths | case 7: |
3631 | e397ee33 | ths | /* ignored */
|
3632 | e397ee33 | ths | rn = "Config7";
|
3633 | e397ee33 | ths | break;
|
3634 | 8c0fdd85 | ths | default:
|
3635 | 8c0fdd85 | ths | rn = "Invalid config selector";
|
3636 | 8c0fdd85 | ths | goto die;
|
3637 | 8c0fdd85 | ths | } |
3638 | 8c0fdd85 | ths | break;
|
3639 | 8c0fdd85 | ths | case 17: |
3640 | 7a387fff | ths | switch (sel) {
|
3641 | 7a387fff | ths | case 0: |
3642 | 2423f660 | ths | /* ignored */
|
3643 | 2423f660 | ths | rn = "LLAddr";
|
3644 | 2423f660 | ths | break;
|
3645 | 7a387fff | ths | default:
|
3646 | 7a387fff | ths | goto die;
|
3647 | 7a387fff | ths | } |
3648 | 8c0fdd85 | ths | break;
|
3649 | 8c0fdd85 | ths | case 18: |
3650 | 7a387fff | ths | switch (sel) {
|
3651 | fd88b6ab | ths | case 0 ... 7: |
3652 | a7812ae4 | pbrook | gen_helper_1i(mtc0_watchlo, t0, sel); |
3653 | 2423f660 | ths | rn = "WatchLo";
|
3654 | 2423f660 | ths | break;
|
3655 | 7a387fff | ths | default:
|
3656 | 7a387fff | ths | goto die;
|
3657 | 7a387fff | ths | } |
3658 | 8c0fdd85 | ths | break;
|
3659 | 8c0fdd85 | ths | case 19: |
3660 | 7a387fff | ths | switch (sel) {
|
3661 | fd88b6ab | ths | case 0 ... 7: |
3662 | a7812ae4 | pbrook | gen_helper_1i(mtc0_watchhi, t0, sel); |
3663 | 2423f660 | ths | rn = "WatchHi";
|
3664 | 2423f660 | ths | break;
|
3665 | 7a387fff | ths | default:
|
3666 | 7a387fff | ths | goto die;
|
3667 | 7a387fff | ths | } |
3668 | 8c0fdd85 | ths | break;
|
3669 | 8c0fdd85 | ths | case 20: |
3670 | 7a387fff | ths | switch (sel) {
|
3671 | 7a387fff | ths | case 0: |
3672 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
3673 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
3674 | a7812ae4 | pbrook | gen_helper_mtc0_xcontext(t0); |
3675 | 2423f660 | ths | rn = "XContext";
|
3676 | 2423f660 | ths | break;
|
3677 | 703eaf37 | ths | #endif
|
3678 | 7a387fff | ths | default:
|
3679 | 7a387fff | ths | goto die;
|
3680 | 7a387fff | ths | } |
3681 | 8c0fdd85 | ths | break;
|
3682 | 8c0fdd85 | ths | case 21: |
3683 | 7a387fff | ths | /* Officially reserved, but sel 0 is used for R1x000 framemask */
|
3684 | 7a387fff | ths | switch (sel) {
|
3685 | 7a387fff | ths | case 0: |
3686 | a7812ae4 | pbrook | gen_helper_mtc0_framemask(t0); |
3687 | 2423f660 | ths | rn = "Framemask";
|
3688 | 2423f660 | ths | break;
|
3689 | 7a387fff | ths | default:
|
3690 | 7a387fff | ths | goto die;
|
3691 | 7a387fff | ths | } |
3692 | 7a387fff | ths | break;
|
3693 | 8c0fdd85 | ths | case 22: |
3694 | 7a387fff | ths | /* ignored */
|
3695 | 7a387fff | ths | rn = "Diagnostic"; /* implementation dependent */ |
3696 | 2423f660 | ths | break;
|
3697 | 8c0fdd85 | ths | case 23: |
3698 | 7a387fff | ths | switch (sel) {
|
3699 | 7a387fff | ths | case 0: |
3700 | a7812ae4 | pbrook | gen_helper_mtc0_debug(t0); /* EJTAG support */
|
3701 | 8487327a | ths | /* BS_STOP isn't good enough here, hflags may have changed. */
|
3702 | 8487327a | ths | gen_save_pc(ctx->pc + 4);
|
3703 | 8487327a | ths | ctx->bstate = BS_EXCP; |
3704 | 2423f660 | ths | rn = "Debug";
|
3705 | 2423f660 | ths | break;
|
3706 | 7a387fff | ths | case 1: |
3707 | a7812ae4 | pbrook | // gen_helper_mtc0_tracecontrol(t0); /* PDtrace support */
|
3708 | 2423f660 | ths | rn = "TraceControl";
|
3709 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3710 | 8487327a | ths | ctx->bstate = BS_STOP; |
3711 | 2423f660 | ths | // break;
|
3712 | 7a387fff | ths | case 2: |
3713 | a7812ae4 | pbrook | // gen_helper_mtc0_tracecontrol2(t0); /* PDtrace support */
|
3714 | 2423f660 | ths | rn = "TraceControl2";
|
3715 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3716 | 8487327a | ths | ctx->bstate = BS_STOP; |
3717 | 2423f660 | ths | // break;
|
3718 | 7a387fff | ths | case 3: |
3719 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3720 | 8487327a | ths | ctx->bstate = BS_STOP; |
3721 | a7812ae4 | pbrook | // gen_helper_mtc0_usertracedata(t0); /* PDtrace support */
|
3722 | 2423f660 | ths | rn = "UserTraceData";
|
3723 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3724 | 8487327a | ths | ctx->bstate = BS_STOP; |
3725 | 2423f660 | ths | // break;
|
3726 | 7a387fff | ths | case 4: |
3727 | a7812ae4 | pbrook | // gen_helper_mtc0_tracebpc(t0); /* PDtrace support */
|
3728 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
3729 | 8487327a | ths | ctx->bstate = BS_STOP; |
3730 | 2423f660 | ths | rn = "TraceBPC";
|
3731 | 2423f660 | ths | // break;
|
3732 | 7a387fff | ths | default:
|
3733 | 7a387fff | ths | goto die;
|
3734 | 7a387fff | ths | } |
3735 | 8c0fdd85 | ths | break;
|
3736 | 8c0fdd85 | ths | case 24: |
3737 | 7a387fff | ths | switch (sel) {
|
3738 | 7a387fff | ths | case 0: |
3739 | f1aa6320 | ths | /* EJTAG support */
|
3740 | 1a3fd9c3 | ths | gen_mtc0_store64(t0, offsetof(CPUState, CP0_DEPC)); |
3741 | 2423f660 | ths | rn = "DEPC";
|
3742 | 2423f660 | ths | break;
|
3743 | 7a387fff | ths | default:
|
3744 | 7a387fff | ths | goto die;
|
3745 | 7a387fff | ths | } |
3746 | 8c0fdd85 | ths | break;
|
3747 | 8c0fdd85 | ths | case 25: |
3748 | 7a387fff | ths | switch (sel) {
|
3749 | 7a387fff | ths | case 0: |
3750 | a7812ae4 | pbrook | gen_helper_mtc0_performance0(t0); |
3751 | 2423f660 | ths | rn = "Performance0";
|
3752 | 2423f660 | ths | break;
|
3753 | 7a387fff | ths | case 1: |
3754 | a7812ae4 | pbrook | // gen_helper_mtc0_performance1(t0);
|
3755 | 2423f660 | ths | rn = "Performance1";
|
3756 | 2423f660 | ths | // break;
|
3757 | 7a387fff | ths | case 2: |
3758 | a7812ae4 | pbrook | // gen_helper_mtc0_performance2(t0);
|
3759 | 2423f660 | ths | rn = "Performance2";
|
3760 | 2423f660 | ths | // break;
|
3761 | 7a387fff | ths | case 3: |
3762 | a7812ae4 | pbrook | // gen_helper_mtc0_performance3(t0);
|
3763 | 2423f660 | ths | rn = "Performance3";
|
3764 | 2423f660 | ths | // break;
|
3765 | 7a387fff | ths | case 4: |
3766 | a7812ae4 | pbrook | // gen_helper_mtc0_performance4(t0);
|
3767 | 2423f660 | ths | rn = "Performance4";
|
3768 | 2423f660 | ths | // break;
|
3769 | 7a387fff | ths | case 5: |
3770 | a7812ae4 | pbrook | // gen_helper_mtc0_performance5(t0);
|
3771 | 2423f660 | ths | rn = "Performance5";
|
3772 | 2423f660 | ths | // break;
|
3773 | 7a387fff | ths | case 6: |
3774 | a7812ae4 | pbrook | // gen_helper_mtc0_performance6(t0);
|
3775 | 2423f660 | ths | rn = "Performance6";
|
3776 | 2423f660 | ths | // break;
|
3777 | 7a387fff | ths | case 7: |
3778 | a7812ae4 | pbrook | // gen_helper_mtc0_performance7(t0);
|
3779 | 2423f660 | ths | rn = "Performance7";
|
3780 | 2423f660 | ths | // break;
|
3781 | 7a387fff | ths | default:
|
3782 | 7a387fff | ths | goto die;
|
3783 | 7a387fff | ths | } |
3784 | 8c0fdd85 | ths | break;
|
3785 | 8c0fdd85 | ths | case 26: |
3786 | 2423f660 | ths | /* ignored */
|
3787 | 8c0fdd85 | ths | rn = "ECC";
|
3788 | 2423f660 | ths | break;
|
3789 | 8c0fdd85 | ths | case 27: |
3790 | 7a387fff | ths | switch (sel) {
|
3791 | 7a387fff | ths | case 0 ... 3: |
3792 | 2423f660 | ths | /* ignored */
|
3793 | 2423f660 | ths | rn = "CacheErr";
|
3794 | 2423f660 | ths | break;
|
3795 | 7a387fff | ths | default:
|
3796 | 7a387fff | ths | goto die;
|
3797 | 7a387fff | ths | } |
3798 | 8c0fdd85 | ths | break;
|
3799 | 8c0fdd85 | ths | case 28: |
3800 | 8c0fdd85 | ths | switch (sel) {
|
3801 | 8c0fdd85 | ths | case 0: |
3802 | 7a387fff | ths | case 2: |
3803 | 7a387fff | ths | case 4: |
3804 | 7a387fff | ths | case 6: |
3805 | a7812ae4 | pbrook | gen_helper_mtc0_taglo(t0); |
3806 | 8c0fdd85 | ths | rn = "TagLo";
|
3807 | 8c0fdd85 | ths | break;
|
3808 | 7a387fff | ths | case 1: |
3809 | 7a387fff | ths | case 3: |
3810 | 7a387fff | ths | case 5: |
3811 | 7a387fff | ths | case 7: |
3812 | a7812ae4 | pbrook | gen_helper_mtc0_datalo(t0); |
3813 | 7a387fff | ths | rn = "DataLo";
|
3814 | 7a387fff | ths | break;
|
3815 | 8c0fdd85 | ths | default:
|
3816 | 8c0fdd85 | ths | goto die;
|
3817 | 8c0fdd85 | ths | } |
3818 | 8c0fdd85 | ths | break;
|
3819 | 8c0fdd85 | ths | case 29: |
3820 | 7a387fff | ths | switch (sel) {
|
3821 | 7a387fff | ths | case 0: |
3822 | 7a387fff | ths | case 2: |
3823 | 7a387fff | ths | case 4: |
3824 | 7a387fff | ths | case 6: |
3825 | a7812ae4 | pbrook | gen_helper_mtc0_taghi(t0); |
3826 | 7a387fff | ths | rn = "TagHi";
|
3827 | 7a387fff | ths | break;
|
3828 | 7a387fff | ths | case 1: |
3829 | 7a387fff | ths | case 3: |
3830 | 7a387fff | ths | case 5: |
3831 | 7a387fff | ths | case 7: |
3832 | a7812ae4 | pbrook | gen_helper_mtc0_datahi(t0); |
3833 | 7a387fff | ths | rn = "DataHi";
|
3834 | 7a387fff | ths | break;
|
3835 | 7a387fff | ths | default:
|
3836 | 7a387fff | ths | rn = "invalid sel";
|
3837 | 7a387fff | ths | goto die;
|
3838 | 7a387fff | ths | } |
3839 | 8c0fdd85 | ths | break;
|
3840 | 8c0fdd85 | ths | case 30: |
3841 | 7a387fff | ths | switch (sel) {
|
3842 | 7a387fff | ths | case 0: |
3843 | 1a3fd9c3 | ths | gen_mtc0_store64(t0, offsetof(CPUState, CP0_ErrorEPC)); |
3844 | 2423f660 | ths | rn = "ErrorEPC";
|
3845 | 2423f660 | ths | break;
|
3846 | 7a387fff | ths | default:
|
3847 | 7a387fff | ths | goto die;
|
3848 | 7a387fff | ths | } |
3849 | 8c0fdd85 | ths | break;
|
3850 | 8c0fdd85 | ths | case 31: |
3851 | 7a387fff | ths | switch (sel) {
|
3852 | 7a387fff | ths | case 0: |
3853 | f1aa6320 | ths | /* EJTAG support */
|
3854 | 1a3fd9c3 | ths | gen_mtc0_store32(t0, offsetof(CPUState, CP0_DESAVE)); |
3855 | 2423f660 | ths | rn = "DESAVE";
|
3856 | 2423f660 | ths | break;
|
3857 | 7a387fff | ths | default:
|
3858 | 7a387fff | ths | goto die;
|
3859 | 7a387fff | ths | } |
3860 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
3861 | 2423f660 | ths | ctx->bstate = BS_STOP; |
3862 | 8c0fdd85 | ths | break;
|
3863 | 8c0fdd85 | ths | default:
|
3864 | 8c0fdd85 | ths | goto die;
|
3865 | 8c0fdd85 | ths | } |
3866 | d12d51d5 | aliguori | LOG_DISAS("mtc0 %s (reg %d sel %d)\n", rn, reg, sel);
|
3867 | bf20dc07 | ths | /* For simplicity assume that all writes can cause interrupts. */
|
3868 | 2e70f6ef | pbrook | if (use_icount) {
|
3869 | 2e70f6ef | pbrook | gen_io_end(); |
3870 | 2e70f6ef | pbrook | ctx->bstate = BS_STOP; |
3871 | 2e70f6ef | pbrook | } |
3872 | 8c0fdd85 | ths | return;
|
3873 | 8c0fdd85 | ths | |
3874 | 8c0fdd85 | ths | die:
|
3875 | d12d51d5 | aliguori | LOG_DISAS("mtc0 %s (reg %d sel %d)\n", rn, reg, sel);
|
3876 | 8c0fdd85 | ths | generate_exception(ctx, EXCP_RI); |
3877 | 8c0fdd85 | ths | } |
3878 | 8c0fdd85 | ths | |
3879 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
3880 | 1a3fd9c3 | ths | static void gen_dmfc0 (CPUState *env, DisasContext *ctx, TCGv t0, int reg, int sel) |
3881 | 9c2149c8 | ths | { |
3882 | 9c2149c8 | ths | const char *rn = "invalid"; |
3883 | 9c2149c8 | ths | |
3884 | e189e748 | ths | if (sel != 0) |
3885 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64); |
3886 | e189e748 | ths | |
3887 | 9c2149c8 | ths | switch (reg) {
|
3888 | 9c2149c8 | ths | case 0: |
3889 | 9c2149c8 | ths | switch (sel) {
|
3890 | 9c2149c8 | ths | case 0: |
3891 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Index)); |
3892 | 9c2149c8 | ths | rn = "Index";
|
3893 | 9c2149c8 | ths | break;
|
3894 | 9c2149c8 | ths | case 1: |
3895 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3896 | a7812ae4 | pbrook | gen_helper_mfc0_mvpcontrol(t0); |
3897 | 9c2149c8 | ths | rn = "MVPControl";
|
3898 | ead9360e | ths | break;
|
3899 | 9c2149c8 | ths | case 2: |
3900 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3901 | a7812ae4 | pbrook | gen_helper_mfc0_mvpconf0(t0); |
3902 | 9c2149c8 | ths | rn = "MVPConf0";
|
3903 | ead9360e | ths | break;
|
3904 | 9c2149c8 | ths | case 3: |
3905 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3906 | a7812ae4 | pbrook | gen_helper_mfc0_mvpconf1(t0); |
3907 | 9c2149c8 | ths | rn = "MVPConf1";
|
3908 | ead9360e | ths | break;
|
3909 | 9c2149c8 | ths | default:
|
3910 | 9c2149c8 | ths | goto die;
|
3911 | 9c2149c8 | ths | } |
3912 | 9c2149c8 | ths | break;
|
3913 | 9c2149c8 | ths | case 1: |
3914 | 9c2149c8 | ths | switch (sel) {
|
3915 | 9c2149c8 | ths | case 0: |
3916 | a7812ae4 | pbrook | gen_helper_mfc0_random(t0); |
3917 | 9c2149c8 | ths | rn = "Random";
|
3918 | 2423f660 | ths | break;
|
3919 | 9c2149c8 | ths | case 1: |
3920 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3921 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_VPEControl)); |
3922 | 9c2149c8 | ths | rn = "VPEControl";
|
3923 | ead9360e | ths | break;
|
3924 | 9c2149c8 | ths | case 2: |
3925 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3926 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_VPEConf0)); |
3927 | 9c2149c8 | ths | rn = "VPEConf0";
|
3928 | ead9360e | ths | break;
|
3929 | 9c2149c8 | ths | case 3: |
3930 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3931 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_VPEConf1)); |
3932 | 9c2149c8 | ths | rn = "VPEConf1";
|
3933 | ead9360e | ths | break;
|
3934 | 9c2149c8 | ths | case 4: |
3935 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3936 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_YQMask)); |
3937 | 9c2149c8 | ths | rn = "YQMask";
|
3938 | ead9360e | ths | break;
|
3939 | 9c2149c8 | ths | case 5: |
3940 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3941 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_VPESchedule)); |
3942 | 9c2149c8 | ths | rn = "VPESchedule";
|
3943 | ead9360e | ths | break;
|
3944 | 9c2149c8 | ths | case 6: |
3945 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3946 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_VPEScheFBack)); |
3947 | 9c2149c8 | ths | rn = "VPEScheFBack";
|
3948 | ead9360e | ths | break;
|
3949 | 9c2149c8 | ths | case 7: |
3950 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3951 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_VPEOpt)); |
3952 | 9c2149c8 | ths | rn = "VPEOpt";
|
3953 | ead9360e | ths | break;
|
3954 | 9c2149c8 | ths | default:
|
3955 | 9c2149c8 | ths | goto die;
|
3956 | 9c2149c8 | ths | } |
3957 | 9c2149c8 | ths | break;
|
3958 | 9c2149c8 | ths | case 2: |
3959 | 9c2149c8 | ths | switch (sel) {
|
3960 | 9c2149c8 | ths | case 0: |
3961 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_EntryLo0)); |
3962 | 2423f660 | ths | rn = "EntryLo0";
|
3963 | 2423f660 | ths | break;
|
3964 | 9c2149c8 | ths | case 1: |
3965 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3966 | a7812ae4 | pbrook | gen_helper_mfc0_tcstatus(t0); |
3967 | 2423f660 | ths | rn = "TCStatus";
|
3968 | ead9360e | ths | break;
|
3969 | 9c2149c8 | ths | case 2: |
3970 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3971 | a7812ae4 | pbrook | gen_helper_mfc0_tcbind(t0); |
3972 | 2423f660 | ths | rn = "TCBind";
|
3973 | ead9360e | ths | break;
|
3974 | 9c2149c8 | ths | case 3: |
3975 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3976 | a7812ae4 | pbrook | gen_helper_dmfc0_tcrestart(t0); |
3977 | 2423f660 | ths | rn = "TCRestart";
|
3978 | ead9360e | ths | break;
|
3979 | 9c2149c8 | ths | case 4: |
3980 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3981 | a7812ae4 | pbrook | gen_helper_dmfc0_tchalt(t0); |
3982 | 2423f660 | ths | rn = "TCHalt";
|
3983 | ead9360e | ths | break;
|
3984 | 9c2149c8 | ths | case 5: |
3985 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3986 | a7812ae4 | pbrook | gen_helper_dmfc0_tccontext(t0); |
3987 | 2423f660 | ths | rn = "TCContext";
|
3988 | ead9360e | ths | break;
|
3989 | 9c2149c8 | ths | case 6: |
3990 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3991 | a7812ae4 | pbrook | gen_helper_dmfc0_tcschedule(t0); |
3992 | 2423f660 | ths | rn = "TCSchedule";
|
3993 | ead9360e | ths | break;
|
3994 | 9c2149c8 | ths | case 7: |
3995 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
3996 | a7812ae4 | pbrook | gen_helper_dmfc0_tcschefback(t0); |
3997 | 2423f660 | ths | rn = "TCScheFBack";
|
3998 | ead9360e | ths | break;
|
3999 | 9c2149c8 | ths | default:
|
4000 | 9c2149c8 | ths | goto die;
|
4001 | 9c2149c8 | ths | } |
4002 | 9c2149c8 | ths | break;
|
4003 | 9c2149c8 | ths | case 3: |
4004 | 9c2149c8 | ths | switch (sel) {
|
4005 | 9c2149c8 | ths | case 0: |
4006 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_EntryLo1)); |
4007 | 2423f660 | ths | rn = "EntryLo1";
|
4008 | 2423f660 | ths | break;
|
4009 | 9c2149c8 | ths | default:
|
4010 | 9c2149c8 | ths | goto die;
|
4011 | 1579a72e | ths | } |
4012 | 9c2149c8 | ths | break;
|
4013 | 9c2149c8 | ths | case 4: |
4014 | 9c2149c8 | ths | switch (sel) {
|
4015 | 9c2149c8 | ths | case 0: |
4016 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_Context)); |
4017 | 2423f660 | ths | rn = "Context";
|
4018 | 2423f660 | ths | break;
|
4019 | 9c2149c8 | ths | case 1: |
4020 | a7812ae4 | pbrook | // gen_helper_dmfc0_contextconfig(t0); /* SmartMIPS ASE */
|
4021 | 2423f660 | ths | rn = "ContextConfig";
|
4022 | 2423f660 | ths | // break;
|
4023 | 9c2149c8 | ths | default:
|
4024 | 9c2149c8 | ths | goto die;
|
4025 | 876d4b07 | ths | } |
4026 | 9c2149c8 | ths | break;
|
4027 | 9c2149c8 | ths | case 5: |
4028 | 9c2149c8 | ths | switch (sel) {
|
4029 | 9c2149c8 | ths | case 0: |
4030 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_PageMask)); |
4031 | 2423f660 | ths | rn = "PageMask";
|
4032 | 2423f660 | ths | break;
|
4033 | 9c2149c8 | ths | case 1: |
4034 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4035 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_PageGrain)); |
4036 | 2423f660 | ths | rn = "PageGrain";
|
4037 | 2423f660 | ths | break;
|
4038 | 9c2149c8 | ths | default:
|
4039 | 9c2149c8 | ths | goto die;
|
4040 | 876d4b07 | ths | } |
4041 | 9c2149c8 | ths | break;
|
4042 | 9c2149c8 | ths | case 6: |
4043 | 9c2149c8 | ths | switch (sel) {
|
4044 | 9c2149c8 | ths | case 0: |
4045 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Wired)); |
4046 | 2423f660 | ths | rn = "Wired";
|
4047 | 2423f660 | ths | break;
|
4048 | 9c2149c8 | ths | case 1: |
4049 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4050 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf0)); |
4051 | 2423f660 | ths | rn = "SRSConf0";
|
4052 | ead9360e | ths | break;
|
4053 | 9c2149c8 | ths | case 2: |
4054 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4055 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf1)); |
4056 | 2423f660 | ths | rn = "SRSConf1";
|
4057 | ead9360e | ths | break;
|
4058 | 9c2149c8 | ths | case 3: |
4059 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4060 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf2)); |
4061 | 2423f660 | ths | rn = "SRSConf2";
|
4062 | ead9360e | ths | break;
|
4063 | 9c2149c8 | ths | case 4: |
4064 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4065 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf3)); |
4066 | 2423f660 | ths | rn = "SRSConf3";
|
4067 | ead9360e | ths | break;
|
4068 | 9c2149c8 | ths | case 5: |
4069 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4070 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSConf4)); |
4071 | 2423f660 | ths | rn = "SRSConf4";
|
4072 | ead9360e | ths | break;
|
4073 | 9c2149c8 | ths | default:
|
4074 | 9c2149c8 | ths | goto die;
|
4075 | 876d4b07 | ths | } |
4076 | 9c2149c8 | ths | break;
|
4077 | 9c2149c8 | ths | case 7: |
4078 | 9c2149c8 | ths | switch (sel) {
|
4079 | 9c2149c8 | ths | case 0: |
4080 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4081 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_HWREna)); |
4082 | 2423f660 | ths | rn = "HWREna";
|
4083 | 2423f660 | ths | break;
|
4084 | 9c2149c8 | ths | default:
|
4085 | 9c2149c8 | ths | goto die;
|
4086 | 876d4b07 | ths | } |
4087 | 9c2149c8 | ths | break;
|
4088 | 9c2149c8 | ths | case 8: |
4089 | 9c2149c8 | ths | switch (sel) {
|
4090 | 9c2149c8 | ths | case 0: |
4091 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_BadVAddr)); |
4092 | f0b3f3ae | ths | rn = "BadVAddr";
|
4093 | 2423f660 | ths | break;
|
4094 | 9c2149c8 | ths | default:
|
4095 | 9c2149c8 | ths | goto die;
|
4096 | 876d4b07 | ths | } |
4097 | 9c2149c8 | ths | break;
|
4098 | 9c2149c8 | ths | case 9: |
4099 | 9c2149c8 | ths | switch (sel) {
|
4100 | 9c2149c8 | ths | case 0: |
4101 | 2e70f6ef | pbrook | /* Mark as an IO operation because we read the time. */
|
4102 | 2e70f6ef | pbrook | if (use_icount)
|
4103 | 2e70f6ef | pbrook | gen_io_start(); |
4104 | a7812ae4 | pbrook | gen_helper_mfc0_count(t0); |
4105 | 2e70f6ef | pbrook | if (use_icount) {
|
4106 | 2e70f6ef | pbrook | gen_io_end(); |
4107 | 2e70f6ef | pbrook | ctx->bstate = BS_STOP; |
4108 | 2e70f6ef | pbrook | } |
4109 | 2423f660 | ths | rn = "Count";
|
4110 | 2423f660 | ths | break;
|
4111 | 2423f660 | ths | /* 6,7 are implementation dependent */
|
4112 | 9c2149c8 | ths | default:
|
4113 | 9c2149c8 | ths | goto die;
|
4114 | 876d4b07 | ths | } |
4115 | 9c2149c8 | ths | break;
|
4116 | 9c2149c8 | ths | case 10: |
4117 | 9c2149c8 | ths | switch (sel) {
|
4118 | 9c2149c8 | ths | case 0: |
4119 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_EntryHi)); |
4120 | 2423f660 | ths | rn = "EntryHi";
|
4121 | 2423f660 | ths | break;
|
4122 | 9c2149c8 | ths | default:
|
4123 | 9c2149c8 | ths | goto die;
|
4124 | 876d4b07 | ths | } |
4125 | 9c2149c8 | ths | break;
|
4126 | 9c2149c8 | ths | case 11: |
4127 | 9c2149c8 | ths | switch (sel) {
|
4128 | 9c2149c8 | ths | case 0: |
4129 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Compare)); |
4130 | 2423f660 | ths | rn = "Compare";
|
4131 | 2423f660 | ths | break;
|
4132 | 876d4b07 | ths | /* 6,7 are implementation dependent */
|
4133 | 9c2149c8 | ths | default:
|
4134 | 9c2149c8 | ths | goto die;
|
4135 | 876d4b07 | ths | } |
4136 | 9c2149c8 | ths | break;
|
4137 | 9c2149c8 | ths | case 12: |
4138 | 9c2149c8 | ths | switch (sel) {
|
4139 | 9c2149c8 | ths | case 0: |
4140 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Status)); |
4141 | 2423f660 | ths | rn = "Status";
|
4142 | 2423f660 | ths | break;
|
4143 | 9c2149c8 | ths | case 1: |
4144 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4145 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_IntCtl)); |
4146 | 2423f660 | ths | rn = "IntCtl";
|
4147 | 2423f660 | ths | break;
|
4148 | 9c2149c8 | ths | case 2: |
4149 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4150 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSCtl)); |
4151 | 2423f660 | ths | rn = "SRSCtl";
|
4152 | 2423f660 | ths | break;
|
4153 | 9c2149c8 | ths | case 3: |
4154 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4155 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_SRSMap)); |
4156 | 2423f660 | ths | rn = "SRSMap";
|
4157 | 2423f660 | ths | break;
|
4158 | 9c2149c8 | ths | default:
|
4159 | 9c2149c8 | ths | goto die;
|
4160 | 876d4b07 | ths | } |
4161 | 9c2149c8 | ths | break;
|
4162 | 9c2149c8 | ths | case 13: |
4163 | 9c2149c8 | ths | switch (sel) {
|
4164 | 9c2149c8 | ths | case 0: |
4165 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Cause)); |
4166 | 2423f660 | ths | rn = "Cause";
|
4167 | 2423f660 | ths | break;
|
4168 | 9c2149c8 | ths | default:
|
4169 | 9c2149c8 | ths | goto die;
|
4170 | 876d4b07 | ths | } |
4171 | 9c2149c8 | ths | break;
|
4172 | 9c2149c8 | ths | case 14: |
4173 | 9c2149c8 | ths | switch (sel) {
|
4174 | 9c2149c8 | ths | case 0: |
4175 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_EPC)); |
4176 | 2423f660 | ths | rn = "EPC";
|
4177 | 2423f660 | ths | break;
|
4178 | 9c2149c8 | ths | default:
|
4179 | 9c2149c8 | ths | goto die;
|
4180 | 876d4b07 | ths | } |
4181 | 9c2149c8 | ths | break;
|
4182 | 9c2149c8 | ths | case 15: |
4183 | 9c2149c8 | ths | switch (sel) {
|
4184 | 9c2149c8 | ths | case 0: |
4185 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_PRid)); |
4186 | 2423f660 | ths | rn = "PRid";
|
4187 | 2423f660 | ths | break;
|
4188 | 9c2149c8 | ths | case 1: |
4189 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4190 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_EBase)); |
4191 | 2423f660 | ths | rn = "EBase";
|
4192 | 2423f660 | ths | break;
|
4193 | 9c2149c8 | ths | default:
|
4194 | 9c2149c8 | ths | goto die;
|
4195 | 876d4b07 | ths | } |
4196 | 9c2149c8 | ths | break;
|
4197 | 9c2149c8 | ths | case 16: |
4198 | 9c2149c8 | ths | switch (sel) {
|
4199 | 9c2149c8 | ths | case 0: |
4200 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config0)); |
4201 | 9c2149c8 | ths | rn = "Config";
|
4202 | 9c2149c8 | ths | break;
|
4203 | 9c2149c8 | ths | case 1: |
4204 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config1)); |
4205 | 9c2149c8 | ths | rn = "Config1";
|
4206 | 9c2149c8 | ths | break;
|
4207 | 9c2149c8 | ths | case 2: |
4208 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config2)); |
4209 | 9c2149c8 | ths | rn = "Config2";
|
4210 | 9c2149c8 | ths | break;
|
4211 | 9c2149c8 | ths | case 3: |
4212 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config3)); |
4213 | 9c2149c8 | ths | rn = "Config3";
|
4214 | 9c2149c8 | ths | break;
|
4215 | 9c2149c8 | ths | /* 6,7 are implementation dependent */
|
4216 | f0b3f3ae | ths | case 6: |
4217 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config6)); |
4218 | f0b3f3ae | ths | rn = "Config6";
|
4219 | f0b3f3ae | ths | break;
|
4220 | f0b3f3ae | ths | case 7: |
4221 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Config7)); |
4222 | f0b3f3ae | ths | rn = "Config7";
|
4223 | f0b3f3ae | ths | break;
|
4224 | 9c2149c8 | ths | default:
|
4225 | 9c2149c8 | ths | goto die;
|
4226 | 9c2149c8 | ths | } |
4227 | 9c2149c8 | ths | break;
|
4228 | 9c2149c8 | ths | case 17: |
4229 | 9c2149c8 | ths | switch (sel) {
|
4230 | 9c2149c8 | ths | case 0: |
4231 | a7812ae4 | pbrook | gen_helper_dmfc0_lladdr(t0); |
4232 | 2423f660 | ths | rn = "LLAddr";
|
4233 | 2423f660 | ths | break;
|
4234 | 9c2149c8 | ths | default:
|
4235 | 9c2149c8 | ths | goto die;
|
4236 | 9c2149c8 | ths | } |
4237 | 9c2149c8 | ths | break;
|
4238 | 9c2149c8 | ths | case 18: |
4239 | 9c2149c8 | ths | switch (sel) {
|
4240 | fd88b6ab | ths | case 0 ... 7: |
4241 | a7812ae4 | pbrook | gen_helper_1i(dmfc0_watchlo, t0, sel); |
4242 | 2423f660 | ths | rn = "WatchLo";
|
4243 | 2423f660 | ths | break;
|
4244 | 9c2149c8 | ths | default:
|
4245 | 9c2149c8 | ths | goto die;
|
4246 | 9c2149c8 | ths | } |
4247 | 9c2149c8 | ths | break;
|
4248 | 9c2149c8 | ths | case 19: |
4249 | 9c2149c8 | ths | switch (sel) {
|
4250 | fd88b6ab | ths | case 0 ... 7: |
4251 | a7812ae4 | pbrook | gen_helper_1i(mfc0_watchhi, t0, sel); |
4252 | 2423f660 | ths | rn = "WatchHi";
|
4253 | 2423f660 | ths | break;
|
4254 | 9c2149c8 | ths | default:
|
4255 | 9c2149c8 | ths | goto die;
|
4256 | 9c2149c8 | ths | } |
4257 | 9c2149c8 | ths | break;
|
4258 | 9c2149c8 | ths | case 20: |
4259 | 9c2149c8 | ths | switch (sel) {
|
4260 | 9c2149c8 | ths | case 0: |
4261 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
4262 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_XContext)); |
4263 | 2423f660 | ths | rn = "XContext";
|
4264 | 2423f660 | ths | break;
|
4265 | 9c2149c8 | ths | default:
|
4266 | 9c2149c8 | ths | goto die;
|
4267 | 9c2149c8 | ths | } |
4268 | 9c2149c8 | ths | break;
|
4269 | 9c2149c8 | ths | case 21: |
4270 | 9c2149c8 | ths | /* Officially reserved, but sel 0 is used for R1x000 framemask */
|
4271 | 9c2149c8 | ths | switch (sel) {
|
4272 | 9c2149c8 | ths | case 0: |
4273 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Framemask)); |
4274 | 2423f660 | ths | rn = "Framemask";
|
4275 | 2423f660 | ths | break;
|
4276 | 9c2149c8 | ths | default:
|
4277 | 9c2149c8 | ths | goto die;
|
4278 | 9c2149c8 | ths | } |
4279 | 9c2149c8 | ths | break;
|
4280 | 9c2149c8 | ths | case 22: |
4281 | da80682b | aurel32 | tcg_gen_movi_tl(t0, 0); /* unimplemented */ |
4282 | 2423f660 | ths | rn = "'Diagnostic"; /* implementation dependent */ |
4283 | 2423f660 | ths | break;
|
4284 | 9c2149c8 | ths | case 23: |
4285 | 9c2149c8 | ths | switch (sel) {
|
4286 | 9c2149c8 | ths | case 0: |
4287 | a7812ae4 | pbrook | gen_helper_mfc0_debug(t0); /* EJTAG support */
|
4288 | 2423f660 | ths | rn = "Debug";
|
4289 | 2423f660 | ths | break;
|
4290 | 9c2149c8 | ths | case 1: |
4291 | a7812ae4 | pbrook | // gen_helper_dmfc0_tracecontrol(t0); /* PDtrace support */
|
4292 | 2423f660 | ths | rn = "TraceControl";
|
4293 | 2423f660 | ths | // break;
|
4294 | 9c2149c8 | ths | case 2: |
4295 | a7812ae4 | pbrook | // gen_helper_dmfc0_tracecontrol2(t0); /* PDtrace support */
|
4296 | 2423f660 | ths | rn = "TraceControl2";
|
4297 | 2423f660 | ths | // break;
|
4298 | 9c2149c8 | ths | case 3: |
4299 | a7812ae4 | pbrook | // gen_helper_dmfc0_usertracedata(t0); /* PDtrace support */
|
4300 | 2423f660 | ths | rn = "UserTraceData";
|
4301 | 2423f660 | ths | // break;
|
4302 | 9c2149c8 | ths | case 4: |
4303 | a7812ae4 | pbrook | // gen_helper_dmfc0_tracebpc(t0); /* PDtrace support */
|
4304 | 2423f660 | ths | rn = "TraceBPC";
|
4305 | 2423f660 | ths | // break;
|
4306 | 9c2149c8 | ths | default:
|
4307 | 9c2149c8 | ths | goto die;
|
4308 | 9c2149c8 | ths | } |
4309 | 9c2149c8 | ths | break;
|
4310 | 9c2149c8 | ths | case 24: |
4311 | 9c2149c8 | ths | switch (sel) {
|
4312 | 9c2149c8 | ths | case 0: |
4313 | f0b3f3ae | ths | /* EJTAG support */
|
4314 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_DEPC)); |
4315 | 2423f660 | ths | rn = "DEPC";
|
4316 | 2423f660 | ths | break;
|
4317 | 9c2149c8 | ths | default:
|
4318 | 9c2149c8 | ths | goto die;
|
4319 | 9c2149c8 | ths | } |
4320 | 9c2149c8 | ths | break;
|
4321 | 9c2149c8 | ths | case 25: |
4322 | 9c2149c8 | ths | switch (sel) {
|
4323 | 9c2149c8 | ths | case 0: |
4324 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_Performance0)); |
4325 | 2423f660 | ths | rn = "Performance0";
|
4326 | 9c2149c8 | ths | break;
|
4327 | 9c2149c8 | ths | case 1: |
4328 | a7812ae4 | pbrook | // gen_helper_dmfc0_performance1(t0);
|
4329 | 2423f660 | ths | rn = "Performance1";
|
4330 | 2423f660 | ths | // break;
|
4331 | 9c2149c8 | ths | case 2: |
4332 | a7812ae4 | pbrook | // gen_helper_dmfc0_performance2(t0);
|
4333 | 2423f660 | ths | rn = "Performance2";
|
4334 | 2423f660 | ths | // break;
|
4335 | 9c2149c8 | ths | case 3: |
4336 | a7812ae4 | pbrook | // gen_helper_dmfc0_performance3(t0);
|
4337 | 2423f660 | ths | rn = "Performance3";
|
4338 | 2423f660 | ths | // break;
|
4339 | 9c2149c8 | ths | case 4: |
4340 | a7812ae4 | pbrook | // gen_helper_dmfc0_performance4(t0);
|
4341 | 2423f660 | ths | rn = "Performance4";
|
4342 | 2423f660 | ths | // break;
|
4343 | 9c2149c8 | ths | case 5: |
4344 | a7812ae4 | pbrook | // gen_helper_dmfc0_performance5(t0);
|
4345 | 2423f660 | ths | rn = "Performance5";
|
4346 | 2423f660 | ths | // break;
|
4347 | 9c2149c8 | ths | case 6: |
4348 | a7812ae4 | pbrook | // gen_helper_dmfc0_performance6(t0);
|
4349 | 2423f660 | ths | rn = "Performance6";
|
4350 | 2423f660 | ths | // break;
|
4351 | 9c2149c8 | ths | case 7: |
4352 | a7812ae4 | pbrook | // gen_helper_dmfc0_performance7(t0);
|
4353 | 2423f660 | ths | rn = "Performance7";
|
4354 | 2423f660 | ths | // break;
|
4355 | 9c2149c8 | ths | default:
|
4356 | 9c2149c8 | ths | goto die;
|
4357 | 9c2149c8 | ths | } |
4358 | 9c2149c8 | ths | break;
|
4359 | 9c2149c8 | ths | case 26: |
4360 | da80682b | aurel32 | tcg_gen_movi_tl(t0, 0); /* unimplemented */ |
4361 | da80682b | aurel32 | rn = "ECC";
|
4362 | da80682b | aurel32 | break;
|
4363 | 9c2149c8 | ths | case 27: |
4364 | 9c2149c8 | ths | switch (sel) {
|
4365 | 9c2149c8 | ths | /* ignored */
|
4366 | 9c2149c8 | ths | case 0 ... 3: |
4367 | da80682b | aurel32 | tcg_gen_movi_tl(t0, 0); /* unimplemented */ |
4368 | 2423f660 | ths | rn = "CacheErr";
|
4369 | 2423f660 | ths | break;
|
4370 | 9c2149c8 | ths | default:
|
4371 | 9c2149c8 | ths | goto die;
|
4372 | 9c2149c8 | ths | } |
4373 | 9c2149c8 | ths | break;
|
4374 | 9c2149c8 | ths | case 28: |
4375 | 9c2149c8 | ths | switch (sel) {
|
4376 | 9c2149c8 | ths | case 0: |
4377 | 9c2149c8 | ths | case 2: |
4378 | 9c2149c8 | ths | case 4: |
4379 | 9c2149c8 | ths | case 6: |
4380 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_TagLo)); |
4381 | 9c2149c8 | ths | rn = "TagLo";
|
4382 | 9c2149c8 | ths | break;
|
4383 | 9c2149c8 | ths | case 1: |
4384 | 9c2149c8 | ths | case 3: |
4385 | 9c2149c8 | ths | case 5: |
4386 | 9c2149c8 | ths | case 7: |
4387 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_DataLo)); |
4388 | 9c2149c8 | ths | rn = "DataLo";
|
4389 | 9c2149c8 | ths | break;
|
4390 | 9c2149c8 | ths | default:
|
4391 | 9c2149c8 | ths | goto die;
|
4392 | 9c2149c8 | ths | } |
4393 | 9c2149c8 | ths | break;
|
4394 | 9c2149c8 | ths | case 29: |
4395 | 9c2149c8 | ths | switch (sel) {
|
4396 | 9c2149c8 | ths | case 0: |
4397 | 9c2149c8 | ths | case 2: |
4398 | 9c2149c8 | ths | case 4: |
4399 | 9c2149c8 | ths | case 6: |
4400 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_TagHi)); |
4401 | 9c2149c8 | ths | rn = "TagHi";
|
4402 | 9c2149c8 | ths | break;
|
4403 | 9c2149c8 | ths | case 1: |
4404 | 9c2149c8 | ths | case 3: |
4405 | 9c2149c8 | ths | case 5: |
4406 | 9c2149c8 | ths | case 7: |
4407 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_DataHi)); |
4408 | 9c2149c8 | ths | rn = "DataHi";
|
4409 | 9c2149c8 | ths | break;
|
4410 | 9c2149c8 | ths | default:
|
4411 | 9c2149c8 | ths | goto die;
|
4412 | 9c2149c8 | ths | } |
4413 | 9c2149c8 | ths | break;
|
4414 | 9c2149c8 | ths | case 30: |
4415 | 9c2149c8 | ths | switch (sel) {
|
4416 | 9c2149c8 | ths | case 0: |
4417 | 1a3fd9c3 | ths | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, CP0_ErrorEPC)); |
4418 | 2423f660 | ths | rn = "ErrorEPC";
|
4419 | 2423f660 | ths | break;
|
4420 | 9c2149c8 | ths | default:
|
4421 | 9c2149c8 | ths | goto die;
|
4422 | 9c2149c8 | ths | } |
4423 | 9c2149c8 | ths | break;
|
4424 | 9c2149c8 | ths | case 31: |
4425 | 9c2149c8 | ths | switch (sel) {
|
4426 | 9c2149c8 | ths | case 0: |
4427 | f0b3f3ae | ths | /* EJTAG support */
|
4428 | 1a3fd9c3 | ths | gen_mfc0_load32(t0, offsetof(CPUState, CP0_DESAVE)); |
4429 | 2423f660 | ths | rn = "DESAVE";
|
4430 | 2423f660 | ths | break;
|
4431 | 9c2149c8 | ths | default:
|
4432 | 9c2149c8 | ths | goto die;
|
4433 | 9c2149c8 | ths | } |
4434 | 9c2149c8 | ths | break;
|
4435 | 9c2149c8 | ths | default:
|
4436 | 876d4b07 | ths | goto die;
|
4437 | 9c2149c8 | ths | } |
4438 | d12d51d5 | aliguori | LOG_DISAS("dmfc0 %s (reg %d sel %d)\n", rn, reg, sel);
|
4439 | 9c2149c8 | ths | return;
|
4440 | 9c2149c8 | ths | |
4441 | 9c2149c8 | ths | die:
|
4442 | d12d51d5 | aliguori | LOG_DISAS("dmfc0 %s (reg %d sel %d)\n", rn, reg, sel);
|
4443 | 9c2149c8 | ths | generate_exception(ctx, EXCP_RI); |
4444 | 9c2149c8 | ths | } |
4445 | 9c2149c8 | ths | |
4446 | 1a3fd9c3 | ths | static void gen_dmtc0 (CPUState *env, DisasContext *ctx, TCGv t0, int reg, int sel) |
4447 | 9c2149c8 | ths | { |
4448 | 9c2149c8 | ths | const char *rn = "invalid"; |
4449 | 9c2149c8 | ths | |
4450 | e189e748 | ths | if (sel != 0) |
4451 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64); |
4452 | e189e748 | ths | |
4453 | 2e70f6ef | pbrook | if (use_icount)
|
4454 | 2e70f6ef | pbrook | gen_io_start(); |
4455 | 2e70f6ef | pbrook | |
4456 | 9c2149c8 | ths | switch (reg) {
|
4457 | 9c2149c8 | ths | case 0: |
4458 | 9c2149c8 | ths | switch (sel) {
|
4459 | 9c2149c8 | ths | case 0: |
4460 | a7812ae4 | pbrook | gen_helper_mtc0_index(t0); |
4461 | 9c2149c8 | ths | rn = "Index";
|
4462 | 9c2149c8 | ths | break;
|
4463 | 9c2149c8 | ths | case 1: |
4464 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4465 | a7812ae4 | pbrook | gen_helper_mtc0_mvpcontrol(t0); |
4466 | 9c2149c8 | ths | rn = "MVPControl";
|
4467 | ead9360e | ths | break;
|
4468 | 9c2149c8 | ths | case 2: |
4469 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4470 | ead9360e | ths | /* ignored */
|
4471 | 9c2149c8 | ths | rn = "MVPConf0";
|
4472 | ead9360e | ths | break;
|
4473 | 9c2149c8 | ths | case 3: |
4474 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4475 | ead9360e | ths | /* ignored */
|
4476 | 9c2149c8 | ths | rn = "MVPConf1";
|
4477 | ead9360e | ths | break;
|
4478 | 9c2149c8 | ths | default:
|
4479 | 9c2149c8 | ths | goto die;
|
4480 | 9c2149c8 | ths | } |
4481 | 9c2149c8 | ths | break;
|
4482 | 9c2149c8 | ths | case 1: |
4483 | 9c2149c8 | ths | switch (sel) {
|
4484 | 9c2149c8 | ths | case 0: |
4485 | 2423f660 | ths | /* ignored */
|
4486 | 9c2149c8 | ths | rn = "Random";
|
4487 | 2423f660 | ths | break;
|
4488 | 9c2149c8 | ths | case 1: |
4489 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4490 | a7812ae4 | pbrook | gen_helper_mtc0_vpecontrol(t0); |
4491 | 9c2149c8 | ths | rn = "VPEControl";
|
4492 | ead9360e | ths | break;
|
4493 | 9c2149c8 | ths | case 2: |
4494 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4495 | a7812ae4 | pbrook | gen_helper_mtc0_vpeconf0(t0); |
4496 | 9c2149c8 | ths | rn = "VPEConf0";
|
4497 | ead9360e | ths | break;
|
4498 | 9c2149c8 | ths | case 3: |
4499 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4500 | a7812ae4 | pbrook | gen_helper_mtc0_vpeconf1(t0); |
4501 | 9c2149c8 | ths | rn = "VPEConf1";
|
4502 | ead9360e | ths | break;
|
4503 | 9c2149c8 | ths | case 4: |
4504 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4505 | a7812ae4 | pbrook | gen_helper_mtc0_yqmask(t0); |
4506 | 9c2149c8 | ths | rn = "YQMask";
|
4507 | ead9360e | ths | break;
|
4508 | 9c2149c8 | ths | case 5: |
4509 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4510 | 1a3fd9c3 | ths | tcg_gen_st_tl(t0, cpu_env, offsetof(CPUState, CP0_VPESchedule)); |
4511 | 9c2149c8 | ths | rn = "VPESchedule";
|
4512 | ead9360e | ths | break;
|
4513 | 9c2149c8 | ths | case 6: |
4514 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4515 | 1a3fd9c3 | ths | tcg_gen_st_tl(t0, cpu_env, offsetof(CPUState, CP0_VPEScheFBack)); |
4516 | 9c2149c8 | ths | rn = "VPEScheFBack";
|
4517 | ead9360e | ths | break;
|
4518 | 9c2149c8 | ths | case 7: |
4519 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4520 | a7812ae4 | pbrook | gen_helper_mtc0_vpeopt(t0); |
4521 | 9c2149c8 | ths | rn = "VPEOpt";
|
4522 | ead9360e | ths | break;
|
4523 | 9c2149c8 | ths | default:
|
4524 | 9c2149c8 | ths | goto die;
|
4525 | 9c2149c8 | ths | } |
4526 | 9c2149c8 | ths | break;
|
4527 | 9c2149c8 | ths | case 2: |
4528 | 9c2149c8 | ths | switch (sel) {
|
4529 | 9c2149c8 | ths | case 0: |
4530 | a7812ae4 | pbrook | gen_helper_mtc0_entrylo0(t0); |
4531 | 2423f660 | ths | rn = "EntryLo0";
|
4532 | 2423f660 | ths | break;
|
4533 | 9c2149c8 | ths | case 1: |
4534 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4535 | a7812ae4 | pbrook | gen_helper_mtc0_tcstatus(t0); |
4536 | 2423f660 | ths | rn = "TCStatus";
|
4537 | ead9360e | ths | break;
|
4538 | 9c2149c8 | ths | case 2: |
4539 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4540 | a7812ae4 | pbrook | gen_helper_mtc0_tcbind(t0); |
4541 | 2423f660 | ths | rn = "TCBind";
|
4542 | ead9360e | ths | break;
|
4543 | 9c2149c8 | ths | case 3: |
4544 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4545 | a7812ae4 | pbrook | gen_helper_mtc0_tcrestart(t0); |
4546 | 2423f660 | ths | rn = "TCRestart";
|
4547 | ead9360e | ths | break;
|
4548 | 9c2149c8 | ths | case 4: |
4549 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4550 | a7812ae4 | pbrook | gen_helper_mtc0_tchalt(t0); |
4551 | 2423f660 | ths | rn = "TCHalt";
|
4552 | ead9360e | ths | break;
|
4553 | 9c2149c8 | ths | case 5: |
4554 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4555 | a7812ae4 | pbrook | gen_helper_mtc0_tccontext(t0); |
4556 | 2423f660 | ths | rn = "TCContext";
|
4557 | ead9360e | ths | break;
|
4558 | 9c2149c8 | ths | case 6: |
4559 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4560 | a7812ae4 | pbrook | gen_helper_mtc0_tcschedule(t0); |
4561 | 2423f660 | ths | rn = "TCSchedule";
|
4562 | ead9360e | ths | break;
|
4563 | 9c2149c8 | ths | case 7: |
4564 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
4565 | a7812ae4 | pbrook | gen_helper_mtc0_tcschefback(t0); |
4566 | 2423f660 | ths | rn = "TCScheFBack";
|
4567 | ead9360e | ths | break;
|
4568 | 9c2149c8 | ths | default:
|
4569 | 9c2149c8 | ths | goto die;
|
4570 | 9c2149c8 | ths | } |
4571 | 9c2149c8 | ths | break;
|
4572 | 9c2149c8 | ths | case 3: |
4573 | 9c2149c8 | ths | switch (sel) {
|
4574 | 9c2149c8 | ths | case 0: |
4575 | a7812ae4 | pbrook | gen_helper_mtc0_entrylo1(t0); |
4576 | 2423f660 | ths | rn = "EntryLo1";
|
4577 | 2423f660 | ths | break;
|
4578 | 9c2149c8 | ths | default:
|
4579 | 9c2149c8 | ths | goto die;
|
4580 | 876d4b07 | ths | } |
4581 | 9c2149c8 | ths | break;
|
4582 | 9c2149c8 | ths | case 4: |
4583 | 9c2149c8 | ths | switch (sel) {
|
4584 | 9c2149c8 | ths | case 0: |
4585 | a7812ae4 | pbrook | gen_helper_mtc0_context(t0); |
4586 | 2423f660 | ths | rn = "Context";
|
4587 | 2423f660 | ths | break;
|
4588 | 9c2149c8 | ths | case 1: |
4589 | a7812ae4 | pbrook | // gen_helper_mtc0_contextconfig(t0); /* SmartMIPS ASE */
|
4590 | 2423f660 | ths | rn = "ContextConfig";
|
4591 | 2423f660 | ths | // break;
|
4592 | 9c2149c8 | ths | default:
|
4593 | 9c2149c8 | ths | goto die;
|
4594 | 876d4b07 | ths | } |
4595 | 9c2149c8 | ths | break;
|
4596 | 9c2149c8 | ths | case 5: |
4597 | 9c2149c8 | ths | switch (sel) {
|
4598 | 9c2149c8 | ths | case 0: |
4599 | a7812ae4 | pbrook | gen_helper_mtc0_pagemask(t0); |
4600 | 2423f660 | ths | rn = "PageMask";
|
4601 | 2423f660 | ths | break;
|
4602 | 9c2149c8 | ths | case 1: |
4603 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4604 | a7812ae4 | pbrook | gen_helper_mtc0_pagegrain(t0); |
4605 | 2423f660 | ths | rn = "PageGrain";
|
4606 | 2423f660 | ths | break;
|
4607 | 9c2149c8 | ths | default:
|
4608 | 9c2149c8 | ths | goto die;
|
4609 | 876d4b07 | ths | } |
4610 | 9c2149c8 | ths | break;
|
4611 | 9c2149c8 | ths | case 6: |
4612 | 9c2149c8 | ths | switch (sel) {
|
4613 | 9c2149c8 | ths | case 0: |
4614 | a7812ae4 | pbrook | gen_helper_mtc0_wired(t0); |
4615 | 2423f660 | ths | rn = "Wired";
|
4616 | 2423f660 | ths | break;
|
4617 | 9c2149c8 | ths | case 1: |
4618 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4619 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf0(t0); |
4620 | 2423f660 | ths | rn = "SRSConf0";
|
4621 | ead9360e | ths | break;
|
4622 | 9c2149c8 | ths | case 2: |
4623 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4624 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf1(t0); |
4625 | 2423f660 | ths | rn = "SRSConf1";
|
4626 | ead9360e | ths | break;
|
4627 | 9c2149c8 | ths | case 3: |
4628 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4629 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf2(t0); |
4630 | 2423f660 | ths | rn = "SRSConf2";
|
4631 | ead9360e | ths | break;
|
4632 | 9c2149c8 | ths | case 4: |
4633 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4634 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf3(t0); |
4635 | 2423f660 | ths | rn = "SRSConf3";
|
4636 | ead9360e | ths | break;
|
4637 | 9c2149c8 | ths | case 5: |
4638 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4639 | a7812ae4 | pbrook | gen_helper_mtc0_srsconf4(t0); |
4640 | 2423f660 | ths | rn = "SRSConf4";
|
4641 | ead9360e | ths | break;
|
4642 | 9c2149c8 | ths | default:
|
4643 | 9c2149c8 | ths | goto die;
|
4644 | 876d4b07 | ths | } |
4645 | 9c2149c8 | ths | break;
|
4646 | 9c2149c8 | ths | case 7: |
4647 | 9c2149c8 | ths | switch (sel) {
|
4648 | 9c2149c8 | ths | case 0: |
4649 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4650 | a7812ae4 | pbrook | gen_helper_mtc0_hwrena(t0); |
4651 | 2423f660 | ths | rn = "HWREna";
|
4652 | 2423f660 | ths | break;
|
4653 | 9c2149c8 | ths | default:
|
4654 | 9c2149c8 | ths | goto die;
|
4655 | 876d4b07 | ths | } |
4656 | 9c2149c8 | ths | break;
|
4657 | 9c2149c8 | ths | case 8: |
4658 | 9c2149c8 | ths | /* ignored */
|
4659 | f0b3f3ae | ths | rn = "BadVAddr";
|
4660 | 9c2149c8 | ths | break;
|
4661 | 9c2149c8 | ths | case 9: |
4662 | 9c2149c8 | ths | switch (sel) {
|
4663 | 9c2149c8 | ths | case 0: |
4664 | a7812ae4 | pbrook | gen_helper_mtc0_count(t0); |
4665 | 2423f660 | ths | rn = "Count";
|
4666 | 2423f660 | ths | break;
|
4667 | 876d4b07 | ths | /* 6,7 are implementation dependent */
|
4668 | 9c2149c8 | ths | default:
|
4669 | 9c2149c8 | ths | goto die;
|
4670 | 876d4b07 | ths | } |
4671 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
4672 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
4673 | 9c2149c8 | ths | break;
|
4674 | 9c2149c8 | ths | case 10: |
4675 | 9c2149c8 | ths | switch (sel) {
|
4676 | 9c2149c8 | ths | case 0: |
4677 | a7812ae4 | pbrook | gen_helper_mtc0_entryhi(t0); |
4678 | 2423f660 | ths | rn = "EntryHi";
|
4679 | 2423f660 | ths | break;
|
4680 | 9c2149c8 | ths | default:
|
4681 | 9c2149c8 | ths | goto die;
|
4682 | 876d4b07 | ths | } |
4683 | 9c2149c8 | ths | break;
|
4684 | 9c2149c8 | ths | case 11: |
4685 | 9c2149c8 | ths | switch (sel) {
|
4686 | 9c2149c8 | ths | case 0: |
4687 | a7812ae4 | pbrook | gen_helper_mtc0_compare(t0); |
4688 | 2423f660 | ths | rn = "Compare";
|
4689 | 2423f660 | ths | break;
|
4690 | 876d4b07 | ths | /* 6,7 are implementation dependent */
|
4691 | 9c2149c8 | ths | default:
|
4692 | 9c2149c8 | ths | goto die;
|
4693 | 876d4b07 | ths | } |
4694 | de9a95f0 | aurel32 | /* Stop translation as we may have switched the execution mode */
|
4695 | de9a95f0 | aurel32 | ctx->bstate = BS_STOP; |
4696 | 9c2149c8 | ths | break;
|
4697 | 9c2149c8 | ths | case 12: |
4698 | 9c2149c8 | ths | switch (sel) {
|
4699 | 9c2149c8 | ths | case 0: |
4700 | a7812ae4 | pbrook | gen_helper_mtc0_status(t0); |
4701 | 8487327a | ths | /* BS_STOP isn't good enough here, hflags may have changed. */
|
4702 | 8487327a | ths | gen_save_pc(ctx->pc + 4);
|
4703 | 8487327a | ths | ctx->bstate = BS_EXCP; |
4704 | 2423f660 | ths | rn = "Status";
|
4705 | 2423f660 | ths | break;
|
4706 | 9c2149c8 | ths | case 1: |
4707 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4708 | a7812ae4 | pbrook | gen_helper_mtc0_intctl(t0); |
4709 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4710 | 8487327a | ths | ctx->bstate = BS_STOP; |
4711 | 2423f660 | ths | rn = "IntCtl";
|
4712 | 2423f660 | ths | break;
|
4713 | 9c2149c8 | ths | case 2: |
4714 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4715 | a7812ae4 | pbrook | gen_helper_mtc0_srsctl(t0); |
4716 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4717 | 8487327a | ths | ctx->bstate = BS_STOP; |
4718 | 2423f660 | ths | rn = "SRSCtl";
|
4719 | 2423f660 | ths | break;
|
4720 | 9c2149c8 | ths | case 3: |
4721 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4722 | 1a3fd9c3 | ths | gen_mtc0_store32(t0, offsetof(CPUState, CP0_SRSMap)); |
4723 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4724 | 8487327a | ths | ctx->bstate = BS_STOP; |
4725 | 2423f660 | ths | rn = "SRSMap";
|
4726 | 2423f660 | ths | break;
|
4727 | 2423f660 | ths | default:
|
4728 | 9c2149c8 | ths | goto die;
|
4729 | 876d4b07 | ths | } |
4730 | 9c2149c8 | ths | break;
|
4731 | 9c2149c8 | ths | case 13: |
4732 | 9c2149c8 | ths | switch (sel) {
|
4733 | 9c2149c8 | ths | case 0: |
4734 | a7812ae4 | pbrook | gen_helper_mtc0_cause(t0); |
4735 | 2423f660 | ths | rn = "Cause";
|
4736 | 2423f660 | ths | break;
|
4737 | 9c2149c8 | ths | default:
|
4738 | 9c2149c8 | ths | goto die;
|
4739 | 876d4b07 | ths | } |
4740 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
4741 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
4742 | 9c2149c8 | ths | break;
|
4743 | 9c2149c8 | ths | case 14: |
4744 | 9c2149c8 | ths | switch (sel) {
|
4745 | 9c2149c8 | ths | case 0: |
4746 | 1a3fd9c3 | ths | tcg_gen_st_tl(t0, cpu_env, offsetof(CPUState, CP0_EPC)); |
4747 | 2423f660 | ths | rn = "EPC";
|
4748 | 2423f660 | ths | break;
|
4749 | 9c2149c8 | ths | default:
|
4750 | 9c2149c8 | ths | goto die;
|
4751 | 876d4b07 | ths | } |
4752 | 9c2149c8 | ths | break;
|
4753 | 9c2149c8 | ths | case 15: |
4754 | 9c2149c8 | ths | switch (sel) {
|
4755 | 9c2149c8 | ths | case 0: |
4756 | 2423f660 | ths | /* ignored */
|
4757 | 2423f660 | ths | rn = "PRid";
|
4758 | 2423f660 | ths | break;
|
4759 | 9c2149c8 | ths | case 1: |
4760 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
4761 | a7812ae4 | pbrook | gen_helper_mtc0_ebase(t0); |
4762 | 2423f660 | ths | rn = "EBase";
|
4763 | 2423f660 | ths | break;
|
4764 | 9c2149c8 | ths | default:
|
4765 | 9c2149c8 | ths | goto die;
|
4766 | 876d4b07 | ths | } |
4767 | 9c2149c8 | ths | break;
|
4768 | 9c2149c8 | ths | case 16: |
4769 | 9c2149c8 | ths | switch (sel) {
|
4770 | 9c2149c8 | ths | case 0: |
4771 | a7812ae4 | pbrook | gen_helper_mtc0_config0(t0); |
4772 | 9c2149c8 | ths | rn = "Config";
|
4773 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
4774 | 2423f660 | ths | ctx->bstate = BS_STOP; |
4775 | 9c2149c8 | ths | break;
|
4776 | 9c2149c8 | ths | case 1: |
4777 | 2423f660 | ths | /* ignored */
|
4778 | 9c2149c8 | ths | rn = "Config1";
|
4779 | 9c2149c8 | ths | break;
|
4780 | 9c2149c8 | ths | case 2: |
4781 | a7812ae4 | pbrook | gen_helper_mtc0_config2(t0); |
4782 | 9c2149c8 | ths | rn = "Config2";
|
4783 | 2423f660 | ths | /* Stop translation as we may have switched the execution mode */
|
4784 | 2423f660 | ths | ctx->bstate = BS_STOP; |
4785 | 9c2149c8 | ths | break;
|
4786 | 9c2149c8 | ths | case 3: |
4787 | 2423f660 | ths | /* ignored */
|
4788 | 9c2149c8 | ths | rn = "Config3";
|
4789 | 9c2149c8 | ths | break;
|
4790 | 9c2149c8 | ths | /* 6,7 are implementation dependent */
|
4791 | 9c2149c8 | ths | default:
|
4792 | 9c2149c8 | ths | rn = "Invalid config selector";
|
4793 | 9c2149c8 | ths | goto die;
|
4794 | 9c2149c8 | ths | } |
4795 | 9c2149c8 | ths | break;
|
4796 | 9c2149c8 | ths | case 17: |
4797 | 9c2149c8 | ths | switch (sel) {
|
4798 | 9c2149c8 | ths | case 0: |
4799 | 2423f660 | ths | /* ignored */
|
4800 | 2423f660 | ths | rn = "LLAddr";
|
4801 | 2423f660 | ths | break;
|
4802 | 9c2149c8 | ths | default:
|
4803 | 9c2149c8 | ths | goto die;
|
4804 | 9c2149c8 | ths | } |
4805 | 9c2149c8 | ths | break;
|
4806 | 9c2149c8 | ths | case 18: |
4807 | 9c2149c8 | ths | switch (sel) {
|
4808 | fd88b6ab | ths | case 0 ... 7: |
4809 | a7812ae4 | pbrook | gen_helper_1i(mtc0_watchlo, t0, sel); |
4810 | 2423f660 | ths | rn = "WatchLo";
|
4811 | 2423f660 | ths | break;
|
4812 | 9c2149c8 | ths | default:
|
4813 | 9c2149c8 | ths | goto die;
|
4814 | 9c2149c8 | ths | } |
4815 | 9c2149c8 | ths | break;
|
4816 | 9c2149c8 | ths | case 19: |
4817 | 9c2149c8 | ths | switch (sel) {
|
4818 | fd88b6ab | ths | case 0 ... 7: |
4819 | a7812ae4 | pbrook | gen_helper_1i(mtc0_watchhi, t0, sel); |
4820 | 2423f660 | ths | rn = "WatchHi";
|
4821 | 2423f660 | ths | break;
|
4822 | 9c2149c8 | ths | default:
|
4823 | 9c2149c8 | ths | goto die;
|
4824 | 9c2149c8 | ths | } |
4825 | 9c2149c8 | ths | break;
|
4826 | 9c2149c8 | ths | case 20: |
4827 | 9c2149c8 | ths | switch (sel) {
|
4828 | 9c2149c8 | ths | case 0: |
4829 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
4830 | a7812ae4 | pbrook | gen_helper_mtc0_xcontext(t0); |
4831 | 2423f660 | ths | rn = "XContext";
|
4832 | 2423f660 | ths | break;
|
4833 | 9c2149c8 | ths | default:
|
4834 | 9c2149c8 | ths | goto die;
|
4835 | 9c2149c8 | ths | } |
4836 | 9c2149c8 | ths | break;
|
4837 | 9c2149c8 | ths | case 21: |
4838 | 9c2149c8 | ths | /* Officially reserved, but sel 0 is used for R1x000 framemask */
|
4839 | 9c2149c8 | ths | switch (sel) {
|
4840 | 9c2149c8 | ths | case 0: |
4841 | a7812ae4 | pbrook | gen_helper_mtc0_framemask(t0); |
4842 | 2423f660 | ths | rn = "Framemask";
|
4843 | 2423f660 | ths | break;
|
4844 | 9c2149c8 | ths | default:
|
4845 | 9c2149c8 | ths | goto die;
|
4846 | 9c2149c8 | ths | } |
4847 | 9c2149c8 | ths | break;
|
4848 | 9c2149c8 | ths | case 22: |
4849 | 9c2149c8 | ths | /* ignored */
|
4850 | 9c2149c8 | ths | rn = "Diagnostic"; /* implementation dependent */ |
4851 | 876d4b07 | ths | break;
|
4852 | 9c2149c8 | ths | case 23: |
4853 | 9c2149c8 | ths | switch (sel) {
|
4854 | 9c2149c8 | ths | case 0: |
4855 | a7812ae4 | pbrook | gen_helper_mtc0_debug(t0); /* EJTAG support */
|
4856 | 8487327a | ths | /* BS_STOP isn't good enough here, hflags may have changed. */
|
4857 | 8487327a | ths | gen_save_pc(ctx->pc + 4);
|
4858 | 8487327a | ths | ctx->bstate = BS_EXCP; |
4859 | 2423f660 | ths | rn = "Debug";
|
4860 | 2423f660 | ths | break;
|
4861 | 9c2149c8 | ths | case 1: |
4862 | a7812ae4 | pbrook | // gen_helper_mtc0_tracecontrol(t0); /* PDtrace support */
|
4863 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4864 | 8487327a | ths | ctx->bstate = BS_STOP; |
4865 | 2423f660 | ths | rn = "TraceControl";
|
4866 | 2423f660 | ths | // break;
|
4867 | 9c2149c8 | ths | case 2: |
4868 | a7812ae4 | pbrook | // gen_helper_mtc0_tracecontrol2(t0); /* PDtrace support */
|
4869 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4870 | 8487327a | ths | ctx->bstate = BS_STOP; |
4871 | 2423f660 | ths | rn = "TraceControl2";
|
4872 | 2423f660 | ths | // break;
|
4873 | 9c2149c8 | ths | case 3: |
4874 | a7812ae4 | pbrook | // gen_helper_mtc0_usertracedata(t0); /* PDtrace support */
|
4875 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4876 | 8487327a | ths | ctx->bstate = BS_STOP; |
4877 | 2423f660 | ths | rn = "UserTraceData";
|
4878 | 2423f660 | ths | // break;
|
4879 | 9c2149c8 | ths | case 4: |
4880 | a7812ae4 | pbrook | // gen_helper_mtc0_tracebpc(t0); /* PDtrace support */
|
4881 | 8487327a | ths | /* Stop translation as we may have switched the execution mode */
|
4882 | 8487327a | ths | ctx->bstate = BS_STOP; |
4883 | 2423f660 | ths | rn = "TraceBPC";
|
4884 | 2423f660 | ths | // break;
|
4885 | 9c2149c8 | ths | default:
|
4886 | 9c2149c8 | ths | goto die;
|
4887 | 9c2149c8 | ths | } |
4888 | 9c2149c8 | ths | break;
|
4889 | 9c2149c8 | ths | case 24: |
4890 | 9c2149c8 | ths | switch (sel) {
|
4891 | 9c2149c8 | ths | case 0: |
4892 | f1aa6320 | ths | /* EJTAG support */
|
4893 | 1a3fd9c3 | ths | tcg_gen_st_tl(t0, cpu_env, offsetof(CPUState, CP0_DEPC)); |
4894 | 2423f660 | ths | rn = "DEPC";
|
4895 | 2423f660 | ths | break;
|
4896 | 9c2149c8 | ths | default:
|
4897 | 9c2149c8 | ths | goto die;
|
4898 | 9c2149c8 | ths | } |
4899 | 9c2149c8 | ths | break;
|
4900 | 9c2149c8 | ths | case 25: |
4901 | 9c2149c8 | ths | switch (sel) {
|
4902 | 9c2149c8 | ths | case 0: |
4903 | a7812ae4 | pbrook | gen_helper_mtc0_performance0(t0); |
4904 | 2423f660 | ths | rn = "Performance0";
|
4905 | 2423f660 | ths | break;
|
4906 | 9c2149c8 | ths | case 1: |
4907 | a7812ae4 | pbrook | // gen_helper_mtc0_performance1(t0);
|
4908 | 2423f660 | ths | rn = "Performance1";
|
4909 | 2423f660 | ths | // break;
|
4910 | 9c2149c8 | ths | case 2: |
4911 | a7812ae4 | pbrook | // gen_helper_mtc0_performance2(t0);
|
4912 | 2423f660 | ths | rn = "Performance2";
|
4913 | 2423f660 | ths | // break;
|
4914 | 9c2149c8 | ths | case 3: |
4915 | a7812ae4 | pbrook | // gen_helper_mtc0_performance3(t0);
|
4916 | 2423f660 | ths | rn = "Performance3";
|
4917 | 2423f660 | ths | // break;
|
4918 | 9c2149c8 | ths | case 4: |
4919 | a7812ae4 | pbrook | // gen_helper_mtc0_performance4(t0);
|
4920 | 2423f660 | ths | rn = "Performance4";
|
4921 | 2423f660 | ths | // break;
|
4922 | 9c2149c8 | ths | case 5: |
4923 | a7812ae4 | pbrook | // gen_helper_mtc0_performance5(t0);
|
4924 | 2423f660 | ths | rn = "Performance5";
|
4925 | 2423f660 | ths | // break;
|
4926 | 9c2149c8 | ths | case 6: |
4927 | a7812ae4 | pbrook | // gen_helper_mtc0_performance6(t0);
|
4928 | 2423f660 | ths | rn = "Performance6";
|
4929 | 2423f660 | ths | // break;
|
4930 | 9c2149c8 | ths | case 7: |
4931 | a7812ae4 | pbrook | // gen_helper_mtc0_performance7(t0);
|
4932 | 2423f660 | ths | rn = "Performance7";
|
4933 | 2423f660 | ths | // break;
|
4934 | 9c2149c8 | ths | default:
|
4935 | 9c2149c8 | ths | goto die;
|
4936 | 9c2149c8 | ths | } |
4937 | 876d4b07 | ths | break;
|
4938 | 9c2149c8 | ths | case 26: |
4939 | 876d4b07 | ths | /* ignored */
|
4940 | 9c2149c8 | ths | rn = "ECC";
|
4941 | 876d4b07 | ths | break;
|
4942 | 9c2149c8 | ths | case 27: |
4943 | 9c2149c8 | ths | switch (sel) {
|
4944 | 9c2149c8 | ths | case 0 ... 3: |
4945 | 2423f660 | ths | /* ignored */
|
4946 | 2423f660 | ths | rn = "CacheErr";
|
4947 | 2423f660 | ths | break;
|
4948 | 9c2149c8 | ths | default:
|
4949 | 9c2149c8 | ths | goto die;
|
4950 | 9c2149c8 | ths | } |
4951 | 876d4b07 | ths | break;
|
4952 | 9c2149c8 | ths | case 28: |
4953 | 9c2149c8 | ths | switch (sel) {
|
4954 | 9c2149c8 | ths | case 0: |
4955 | 9c2149c8 | ths | case 2: |
4956 | 9c2149c8 | ths | case 4: |
4957 | 9c2149c8 | ths | case 6: |
4958 | a7812ae4 | pbrook | gen_helper_mtc0_taglo(t0); |
4959 | 9c2149c8 | ths | rn = "TagLo";
|
4960 | 9c2149c8 | ths | break;
|
4961 | 9c2149c8 | ths | case 1: |
4962 | 9c2149c8 | ths | case 3: |
4963 | 9c2149c8 | ths | case 5: |
4964 | 9c2149c8 | ths | case 7: |
4965 | a7812ae4 | pbrook | gen_helper_mtc0_datalo(t0); |
4966 | 9c2149c8 | ths | rn = "DataLo";
|
4967 | 9c2149c8 | ths | break;
|
4968 | 9c2149c8 | ths | default:
|
4969 | 9c2149c8 | ths | goto die;
|
4970 | 9c2149c8 | ths | } |
4971 | 9c2149c8 | ths | break;
|
4972 | 9c2149c8 | ths | case 29: |
4973 | 9c2149c8 | ths | switch (sel) {
|
4974 | 9c2149c8 | ths | case 0: |
4975 | 9c2149c8 | ths | case 2: |
4976 | 9c2149c8 | ths | case 4: |
4977 | 9c2149c8 | ths | case 6: |
4978 | a7812ae4 | pbrook | gen_helper_mtc0_taghi(t0); |
4979 | 9c2149c8 | ths | rn = "TagHi";
|
4980 | 9c2149c8 | ths | break;
|
4981 | 9c2149c8 | ths | case 1: |
4982 | 9c2149c8 | ths | case 3: |
4983 | 9c2149c8 | ths | case 5: |
4984 | 9c2149c8 | ths | case 7: |
4985 | a7812ae4 | pbrook | gen_helper_mtc0_datahi(t0); |
4986 | 9c2149c8 | ths | rn = "DataHi";
|
4987 | 9c2149c8 | ths | break;
|
4988 | 9c2149c8 | ths | default:
|
4989 | 9c2149c8 | ths | rn = "invalid sel";
|
4990 | 9c2149c8 | ths | goto die;
|
4991 | 9c2149c8 | ths | } |
4992 | 876d4b07 | ths | break;
|
4993 | 9c2149c8 | ths | case 30: |
4994 | 9c2149c8 | ths | switch (sel) {
|
4995 | 9c2149c8 | ths | case 0: |
4996 | 1a3fd9c3 | ths | tcg_gen_st_tl(t0, cpu_env, offsetof(CPUState, CP0_ErrorEPC)); |
4997 | 2423f660 | ths | rn = "ErrorEPC";
|
4998 | 2423f660 | ths | break;
|
4999 | 9c2149c8 | ths | default:
|
5000 | 9c2149c8 | ths | goto die;
|
5001 | 9c2149c8 | ths | } |
5002 | 9c2149c8 | ths | break;
|
5003 | 9c2149c8 | ths | case 31: |
5004 | 9c2149c8 | ths | switch (sel) {
|
5005 | 9c2149c8 | ths | case 0: |
5006 | f1aa6320 | ths | /* EJTAG support */
|
5007 | 1a3fd9c3 | ths | gen_mtc0_store32(t0, offsetof(CPUState, CP0_DESAVE)); |
5008 | 2423f660 | ths | rn = "DESAVE";
|
5009 | 2423f660 | ths | break;
|
5010 | 9c2149c8 | ths | default:
|
5011 | 9c2149c8 | ths | goto die;
|
5012 | 9c2149c8 | ths | } |
5013 | 876d4b07 | ths | /* Stop translation as we may have switched the execution mode */
|
5014 | 876d4b07 | ths | ctx->bstate = BS_STOP; |
5015 | 9c2149c8 | ths | break;
|
5016 | 9c2149c8 | ths | default:
|
5017 | 876d4b07 | ths | goto die;
|
5018 | 9c2149c8 | ths | } |
5019 | d12d51d5 | aliguori | LOG_DISAS("dmtc0 %s (reg %d sel %d)\n", rn, reg, sel);
|
5020 | bf20dc07 | ths | /* For simplicity assume that all writes can cause interrupts. */
|
5021 | 2e70f6ef | pbrook | if (use_icount) {
|
5022 | 2e70f6ef | pbrook | gen_io_end(); |
5023 | 2e70f6ef | pbrook | ctx->bstate = BS_STOP; |
5024 | 2e70f6ef | pbrook | } |
5025 | 9c2149c8 | ths | return;
|
5026 | 9c2149c8 | ths | |
5027 | 9c2149c8 | ths | die:
|
5028 | d12d51d5 | aliguori | LOG_DISAS("dmtc0 %s (reg %d sel %d)\n", rn, reg, sel);
|
5029 | 9c2149c8 | ths | generate_exception(ctx, EXCP_RI); |
5030 | 9c2149c8 | ths | } |
5031 | d26bc211 | ths | #endif /* TARGET_MIPS64 */ |
5032 | 9c2149c8 | ths | |
5033 | 6c5c1e20 | ths | static void gen_mftr(CPUState *env, DisasContext *ctx, int rt, int rd, |
5034 | ead9360e | ths | int u, int sel, int h) |
5035 | ead9360e | ths | { |
5036 | ead9360e | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
5037 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
5038 | ead9360e | ths | |
5039 | ead9360e | ths | if ((env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) == 0 && |
5040 | b5dc7732 | ths | ((env->tcs[other_tc].CP0_TCBind & (0xf << CP0TCBd_CurVPE)) !=
|
5041 | b5dc7732 | ths | (env->active_tc.CP0_TCBind & (0xf << CP0TCBd_CurVPE))))
|
5042 | 1a3fd9c3 | ths | tcg_gen_movi_tl(t0, -1);
|
5043 | ead9360e | ths | else if ((env->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) > |
5044 | ead9360e | ths | (env->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
|
5045 | 1a3fd9c3 | ths | tcg_gen_movi_tl(t0, -1);
|
5046 | ead9360e | ths | else if (u == 0) { |
5047 | ead9360e | ths | switch (rt) {
|
5048 | ead9360e | ths | case 2: |
5049 | ead9360e | ths | switch (sel) {
|
5050 | ead9360e | ths | case 1: |
5051 | a7812ae4 | pbrook | gen_helper_mftc0_tcstatus(t0); |
5052 | ead9360e | ths | break;
|
5053 | ead9360e | ths | case 2: |
5054 | a7812ae4 | pbrook | gen_helper_mftc0_tcbind(t0); |
5055 | ead9360e | ths | break;
|
5056 | ead9360e | ths | case 3: |
5057 | a7812ae4 | pbrook | gen_helper_mftc0_tcrestart(t0); |
5058 | ead9360e | ths | break;
|
5059 | ead9360e | ths | case 4: |
5060 | a7812ae4 | pbrook | gen_helper_mftc0_tchalt(t0); |
5061 | ead9360e | ths | break;
|
5062 | ead9360e | ths | case 5: |
5063 | a7812ae4 | pbrook | gen_helper_mftc0_tccontext(t0); |
5064 | ead9360e | ths | break;
|
5065 | ead9360e | ths | case 6: |
5066 | a7812ae4 | pbrook | gen_helper_mftc0_tcschedule(t0); |
5067 | ead9360e | ths | break;
|
5068 | ead9360e | ths | case 7: |
5069 | a7812ae4 | pbrook | gen_helper_mftc0_tcschefback(t0); |
5070 | ead9360e | ths | break;
|
5071 | ead9360e | ths | default:
|
5072 | 1a3fd9c3 | ths | gen_mfc0(env, ctx, t0, rt, sel); |
5073 | ead9360e | ths | break;
|
5074 | ead9360e | ths | } |
5075 | ead9360e | ths | break;
|
5076 | ead9360e | ths | case 10: |
5077 | ead9360e | ths | switch (sel) {
|
5078 | ead9360e | ths | case 0: |
5079 | a7812ae4 | pbrook | gen_helper_mftc0_entryhi(t0); |
5080 | ead9360e | ths | break;
|
5081 | ead9360e | ths | default:
|
5082 | 1a3fd9c3 | ths | gen_mfc0(env, ctx, t0, rt, sel); |
5083 | ead9360e | ths | break;
|
5084 | ead9360e | ths | } |
5085 | ead9360e | ths | case 12: |
5086 | ead9360e | ths | switch (sel) {
|
5087 | ead9360e | ths | case 0: |
5088 | a7812ae4 | pbrook | gen_helper_mftc0_status(t0); |
5089 | ead9360e | ths | break;
|
5090 | ead9360e | ths | default:
|
5091 | 1a3fd9c3 | ths | gen_mfc0(env, ctx, t0, rt, sel); |
5092 | ead9360e | ths | break;
|
5093 | ead9360e | ths | } |
5094 | ead9360e | ths | case 23: |
5095 | ead9360e | ths | switch (sel) {
|
5096 | ead9360e | ths | case 0: |
5097 | a7812ae4 | pbrook | gen_helper_mftc0_debug(t0); |
5098 | ead9360e | ths | break;
|
5099 | ead9360e | ths | default:
|
5100 | 1a3fd9c3 | ths | gen_mfc0(env, ctx, t0, rt, sel); |
5101 | ead9360e | ths | break;
|
5102 | ead9360e | ths | } |
5103 | ead9360e | ths | break;
|
5104 | ead9360e | ths | default:
|
5105 | 1a3fd9c3 | ths | gen_mfc0(env, ctx, t0, rt, sel); |
5106 | ead9360e | ths | } |
5107 | ead9360e | ths | } else switch (sel) { |
5108 | ead9360e | ths | /* GPR registers. */
|
5109 | ead9360e | ths | case 0: |
5110 | a7812ae4 | pbrook | gen_helper_1i(mftgpr, t0, rt); |
5111 | ead9360e | ths | break;
|
5112 | ead9360e | ths | /* Auxiliary CPU registers */
|
5113 | ead9360e | ths | case 1: |
5114 | ead9360e | ths | switch (rt) {
|
5115 | ead9360e | ths | case 0: |
5116 | a7812ae4 | pbrook | gen_helper_1i(mftlo, t0, 0);
|
5117 | ead9360e | ths | break;
|
5118 | ead9360e | ths | case 1: |
5119 | a7812ae4 | pbrook | gen_helper_1i(mfthi, t0, 0);
|
5120 | ead9360e | ths | break;
|
5121 | ead9360e | ths | case 2: |
5122 | a7812ae4 | pbrook | gen_helper_1i(mftacx, t0, 0);
|
5123 | ead9360e | ths | break;
|
5124 | ead9360e | ths | case 4: |
5125 | a7812ae4 | pbrook | gen_helper_1i(mftlo, t0, 1);
|
5126 | ead9360e | ths | break;
|
5127 | ead9360e | ths | case 5: |
5128 | a7812ae4 | pbrook | gen_helper_1i(mfthi, t0, 1);
|
5129 | ead9360e | ths | break;
|
5130 | ead9360e | ths | case 6: |
5131 | a7812ae4 | pbrook | gen_helper_1i(mftacx, t0, 1);
|
5132 | ead9360e | ths | break;
|
5133 | ead9360e | ths | case 8: |
5134 | a7812ae4 | pbrook | gen_helper_1i(mftlo, t0, 2);
|
5135 | ead9360e | ths | break;
|
5136 | ead9360e | ths | case 9: |
5137 | a7812ae4 | pbrook | gen_helper_1i(mfthi, t0, 2);
|
5138 | ead9360e | ths | break;
|
5139 | ead9360e | ths | case 10: |
5140 | a7812ae4 | pbrook | gen_helper_1i(mftacx, t0, 2);
|
5141 | ead9360e | ths | break;
|
5142 | ead9360e | ths | case 12: |
5143 | a7812ae4 | pbrook | gen_helper_1i(mftlo, t0, 3);
|
5144 | ead9360e | ths | break;
|
5145 | ead9360e | ths | case 13: |
5146 | a7812ae4 | pbrook | gen_helper_1i(mfthi, t0, 3);
|
5147 | ead9360e | ths | break;
|
5148 | ead9360e | ths | case 14: |
5149 | a7812ae4 | pbrook | gen_helper_1i(mftacx, t0, 3);
|
5150 | ead9360e | ths | break;
|
5151 | ead9360e | ths | case 16: |
5152 | a7812ae4 | pbrook | gen_helper_mftdsp(t0); |
5153 | ead9360e | ths | break;
|
5154 | ead9360e | ths | default:
|
5155 | ead9360e | ths | goto die;
|
5156 | ead9360e | ths | } |
5157 | ead9360e | ths | break;
|
5158 | ead9360e | ths | /* Floating point (COP1). */
|
5159 | ead9360e | ths | case 2: |
5160 | ead9360e | ths | /* XXX: For now we support only a single FPU context. */
|
5161 | ead9360e | ths | if (h == 0) { |
5162 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5163 | b6d96bed | ths | |
5164 | b6d96bed | ths | gen_load_fpr32(fp0, rt); |
5165 | b6d96bed | ths | tcg_gen_ext_i32_tl(t0, fp0); |
5166 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5167 | ead9360e | ths | } else {
|
5168 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5169 | b6d96bed | ths | |
5170 | b6d96bed | ths | gen_load_fpr32h(fp0, rt); |
5171 | b6d96bed | ths | tcg_gen_ext_i32_tl(t0, fp0); |
5172 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5173 | ead9360e | ths | } |
5174 | ead9360e | ths | break;
|
5175 | ead9360e | ths | case 3: |
5176 | ead9360e | ths | /* XXX: For now we support only a single FPU context. */
|
5177 | a7812ae4 | pbrook | gen_helper_1i(cfc1, t0, rt); |
5178 | ead9360e | ths | break;
|
5179 | ead9360e | ths | /* COP2: Not implemented. */
|
5180 | ead9360e | ths | case 4: |
5181 | ead9360e | ths | case 5: |
5182 | ead9360e | ths | /* fall through */
|
5183 | ead9360e | ths | default:
|
5184 | ead9360e | ths | goto die;
|
5185 | ead9360e | ths | } |
5186 | d12d51d5 | aliguori | LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt, u, sel, h);
|
5187 | 1a3fd9c3 | ths | gen_store_gpr(t0, rd); |
5188 | 1a3fd9c3 | ths | tcg_temp_free(t0); |
5189 | ead9360e | ths | return;
|
5190 | ead9360e | ths | |
5191 | ead9360e | ths | die:
|
5192 | 1a3fd9c3 | ths | tcg_temp_free(t0); |
5193 | d12d51d5 | aliguori | LOG_DISAS("mftr (reg %d u %d sel %d h %d)\n", rt, u, sel, h);
|
5194 | ead9360e | ths | generate_exception(ctx, EXCP_RI); |
5195 | ead9360e | ths | } |
5196 | ead9360e | ths | |
5197 | 6c5c1e20 | ths | static void gen_mttr(CPUState *env, DisasContext *ctx, int rd, int rt, |
5198 | ead9360e | ths | int u, int sel, int h) |
5199 | ead9360e | ths | { |
5200 | ead9360e | ths | int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); |
5201 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
5202 | ead9360e | ths | |
5203 | 1a3fd9c3 | ths | gen_load_gpr(t0, rt); |
5204 | ead9360e | ths | if ((env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) == 0 && |
5205 | b5dc7732 | ths | ((env->tcs[other_tc].CP0_TCBind & (0xf << CP0TCBd_CurVPE)) !=
|
5206 | b5dc7732 | ths | (env->active_tc.CP0_TCBind & (0xf << CP0TCBd_CurVPE))))
|
5207 | ead9360e | ths | /* NOP */ ;
|
5208 | ead9360e | ths | else if ((env->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) > |
5209 | ead9360e | ths | (env->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
|
5210 | ead9360e | ths | /* NOP */ ;
|
5211 | ead9360e | ths | else if (u == 0) { |
5212 | ead9360e | ths | switch (rd) {
|
5213 | ead9360e | ths | case 2: |
5214 | ead9360e | ths | switch (sel) {
|
5215 | ead9360e | ths | case 1: |
5216 | a7812ae4 | pbrook | gen_helper_mttc0_tcstatus(t0); |
5217 | ead9360e | ths | break;
|
5218 | ead9360e | ths | case 2: |
5219 | a7812ae4 | pbrook | gen_helper_mttc0_tcbind(t0); |
5220 | ead9360e | ths | break;
|
5221 | ead9360e | ths | case 3: |
5222 | a7812ae4 | pbrook | gen_helper_mttc0_tcrestart(t0); |
5223 | ead9360e | ths | break;
|
5224 | ead9360e | ths | case 4: |
5225 | a7812ae4 | pbrook | gen_helper_mttc0_tchalt(t0); |
5226 | ead9360e | ths | break;
|
5227 | ead9360e | ths | case 5: |
5228 | a7812ae4 | pbrook | gen_helper_mttc0_tccontext(t0); |
5229 | ead9360e | ths | break;
|
5230 | ead9360e | ths | case 6: |
5231 | a7812ae4 | pbrook | gen_helper_mttc0_tcschedule(t0); |
5232 | ead9360e | ths | break;
|
5233 | ead9360e | ths | case 7: |
5234 | a7812ae4 | pbrook | gen_helper_mttc0_tcschefback(t0); |
5235 | ead9360e | ths | break;
|
5236 | ead9360e | ths | default:
|
5237 | 1a3fd9c3 | ths | gen_mtc0(env, ctx, t0, rd, sel); |
5238 | ead9360e | ths | break;
|
5239 | ead9360e | ths | } |
5240 | ead9360e | ths | break;
|
5241 | ead9360e | ths | case 10: |
5242 | ead9360e | ths | switch (sel) {
|
5243 | ead9360e | ths | case 0: |
5244 | a7812ae4 | pbrook | gen_helper_mttc0_entryhi(t0); |
5245 | ead9360e | ths | break;
|
5246 | ead9360e | ths | default:
|
5247 | 1a3fd9c3 | ths | gen_mtc0(env, ctx, t0, rd, sel); |
5248 | ead9360e | ths | break;
|
5249 | ead9360e | ths | } |
5250 | ead9360e | ths | case 12: |
5251 | ead9360e | ths | switch (sel) {
|
5252 | ead9360e | ths | case 0: |
5253 | a7812ae4 | pbrook | gen_helper_mttc0_status(t0); |
5254 | ead9360e | ths | break;
|
5255 | ead9360e | ths | default:
|
5256 | 1a3fd9c3 | ths | gen_mtc0(env, ctx, t0, rd, sel); |
5257 | ead9360e | ths | break;
|
5258 | ead9360e | ths | } |
5259 | ead9360e | ths | case 23: |
5260 | ead9360e | ths | switch (sel) {
|
5261 | ead9360e | ths | case 0: |
5262 | a7812ae4 | pbrook | gen_helper_mttc0_debug(t0); |
5263 | ead9360e | ths | break;
|
5264 | ead9360e | ths | default:
|
5265 | 1a3fd9c3 | ths | gen_mtc0(env, ctx, t0, rd, sel); |
5266 | ead9360e | ths | break;
|
5267 | ead9360e | ths | } |
5268 | ead9360e | ths | break;
|
5269 | ead9360e | ths | default:
|
5270 | 1a3fd9c3 | ths | gen_mtc0(env, ctx, t0, rd, sel); |
5271 | ead9360e | ths | } |
5272 | ead9360e | ths | } else switch (sel) { |
5273 | ead9360e | ths | /* GPR registers. */
|
5274 | ead9360e | ths | case 0: |
5275 | a7812ae4 | pbrook | gen_helper_1i(mttgpr, t0, rd); |
5276 | ead9360e | ths | break;
|
5277 | ead9360e | ths | /* Auxiliary CPU registers */
|
5278 | ead9360e | ths | case 1: |
5279 | ead9360e | ths | switch (rd) {
|
5280 | ead9360e | ths | case 0: |
5281 | a7812ae4 | pbrook | gen_helper_1i(mttlo, t0, 0);
|
5282 | ead9360e | ths | break;
|
5283 | ead9360e | ths | case 1: |
5284 | a7812ae4 | pbrook | gen_helper_1i(mtthi, t0, 0);
|
5285 | ead9360e | ths | break;
|
5286 | ead9360e | ths | case 2: |
5287 | a7812ae4 | pbrook | gen_helper_1i(mttacx, t0, 0);
|
5288 | ead9360e | ths | break;
|
5289 | ead9360e | ths | case 4: |
5290 | a7812ae4 | pbrook | gen_helper_1i(mttlo, t0, 1);
|
5291 | ead9360e | ths | break;
|
5292 | ead9360e | ths | case 5: |
5293 | a7812ae4 | pbrook | gen_helper_1i(mtthi, t0, 1);
|
5294 | ead9360e | ths | break;
|
5295 | ead9360e | ths | case 6: |
5296 | a7812ae4 | pbrook | gen_helper_1i(mttacx, t0, 1);
|
5297 | ead9360e | ths | break;
|
5298 | ead9360e | ths | case 8: |
5299 | a7812ae4 | pbrook | gen_helper_1i(mttlo, t0, 2);
|
5300 | ead9360e | ths | break;
|
5301 | ead9360e | ths | case 9: |
5302 | a7812ae4 | pbrook | gen_helper_1i(mtthi, t0, 2);
|
5303 | ead9360e | ths | break;
|
5304 | ead9360e | ths | case 10: |
5305 | a7812ae4 | pbrook | gen_helper_1i(mttacx, t0, 2);
|
5306 | ead9360e | ths | break;
|
5307 | ead9360e | ths | case 12: |
5308 | a7812ae4 | pbrook | gen_helper_1i(mttlo, t0, 3);
|
5309 | ead9360e | ths | break;
|
5310 | ead9360e | ths | case 13: |
5311 | a7812ae4 | pbrook | gen_helper_1i(mtthi, t0, 3);
|
5312 | ead9360e | ths | break;
|
5313 | ead9360e | ths | case 14: |
5314 | a7812ae4 | pbrook | gen_helper_1i(mttacx, t0, 3);
|
5315 | ead9360e | ths | break;
|
5316 | ead9360e | ths | case 16: |
5317 | a7812ae4 | pbrook | gen_helper_mttdsp(t0); |
5318 | ead9360e | ths | break;
|
5319 | ead9360e | ths | default:
|
5320 | ead9360e | ths | goto die;
|
5321 | ead9360e | ths | } |
5322 | ead9360e | ths | break;
|
5323 | ead9360e | ths | /* Floating point (COP1). */
|
5324 | ead9360e | ths | case 2: |
5325 | ead9360e | ths | /* XXX: For now we support only a single FPU context. */
|
5326 | ead9360e | ths | if (h == 0) { |
5327 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5328 | b6d96bed | ths | |
5329 | b6d96bed | ths | tcg_gen_trunc_tl_i32(fp0, t0); |
5330 | b6d96bed | ths | gen_store_fpr32(fp0, rd); |
5331 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5332 | ead9360e | ths | } else {
|
5333 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5334 | b6d96bed | ths | |
5335 | b6d96bed | ths | tcg_gen_trunc_tl_i32(fp0, t0); |
5336 | b6d96bed | ths | gen_store_fpr32h(fp0, rd); |
5337 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5338 | ead9360e | ths | } |
5339 | ead9360e | ths | break;
|
5340 | ead9360e | ths | case 3: |
5341 | ead9360e | ths | /* XXX: For now we support only a single FPU context. */
|
5342 | a7812ae4 | pbrook | gen_helper_1i(ctc1, t0, rd); |
5343 | ead9360e | ths | break;
|
5344 | ead9360e | ths | /* COP2: Not implemented. */
|
5345 | ead9360e | ths | case 4: |
5346 | ead9360e | ths | case 5: |
5347 | ead9360e | ths | /* fall through */
|
5348 | ead9360e | ths | default:
|
5349 | ead9360e | ths | goto die;
|
5350 | ead9360e | ths | } |
5351 | d12d51d5 | aliguori | LOG_DISAS("mttr (reg %d u %d sel %d h %d)\n", rd, u, sel, h);
|
5352 | 1a3fd9c3 | ths | tcg_temp_free(t0); |
5353 | ead9360e | ths | return;
|
5354 | ead9360e | ths | |
5355 | ead9360e | ths | die:
|
5356 | 1a3fd9c3 | ths | tcg_temp_free(t0); |
5357 | d12d51d5 | aliguori | LOG_DISAS("mttr (reg %d u %d sel %d h %d)\n", rd, u, sel, h);
|
5358 | ead9360e | ths | generate_exception(ctx, EXCP_RI); |
5359 | ead9360e | ths | } |
5360 | ead9360e | ths | |
5361 | 29929e34 | ths | static void gen_cp0 (CPUState *env, DisasContext *ctx, uint32_t opc, int rt, int rd) |
5362 | 6af0bf9c | bellard | { |
5363 | 287c4b84 | ths | const char *opn = "ldst"; |
5364 | 6af0bf9c | bellard | |
5365 | 6af0bf9c | bellard | switch (opc) {
|
5366 | 6af0bf9c | bellard | case OPC_MFC0:
|
5367 | 6af0bf9c | bellard | if (rt == 0) { |
5368 | ead9360e | ths | /* Treat as NOP. */
|
5369 | 6af0bf9c | bellard | return;
|
5370 | 6af0bf9c | bellard | } |
5371 | 1a3fd9c3 | ths | { |
5372 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
5373 | 1a3fd9c3 | ths | |
5374 | 1a3fd9c3 | ths | gen_mfc0(env, ctx, t0, rd, ctx->opcode & 0x7);
|
5375 | 1a3fd9c3 | ths | gen_store_gpr(t0, rt); |
5376 | 1a3fd9c3 | ths | tcg_temp_free(t0); |
5377 | 1a3fd9c3 | ths | } |
5378 | 6af0bf9c | bellard | opn = "mfc0";
|
5379 | 6af0bf9c | bellard | break;
|
5380 | 6af0bf9c | bellard | case OPC_MTC0:
|
5381 | 1a3fd9c3 | ths | { |
5382 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
5383 | 1a3fd9c3 | ths | |
5384 | 1a3fd9c3 | ths | gen_load_gpr(t0, rt); |
5385 | 1a3fd9c3 | ths | save_cpu_state(ctx, 1);
|
5386 | 1a3fd9c3 | ths | gen_mtc0(env, ctx, t0, rd, ctx->opcode & 0x7);
|
5387 | 1a3fd9c3 | ths | tcg_temp_free(t0); |
5388 | 1a3fd9c3 | ths | } |
5389 | 6af0bf9c | bellard | opn = "mtc0";
|
5390 | 6af0bf9c | bellard | break;
|
5391 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
5392 | 9c2149c8 | ths | case OPC_DMFC0:
|
5393 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
5394 | 9c2149c8 | ths | if (rt == 0) { |
5395 | ead9360e | ths | /* Treat as NOP. */
|
5396 | 9c2149c8 | ths | return;
|
5397 | 9c2149c8 | ths | } |
5398 | 1a3fd9c3 | ths | { |
5399 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
5400 | 1a3fd9c3 | ths | |
5401 | 1a3fd9c3 | ths | gen_dmfc0(env, ctx, t0, rd, ctx->opcode & 0x7);
|
5402 | 1a3fd9c3 | ths | gen_store_gpr(t0, rt); |
5403 | 1a3fd9c3 | ths | tcg_temp_free(t0); |
5404 | 1a3fd9c3 | ths | } |
5405 | 9c2149c8 | ths | opn = "dmfc0";
|
5406 | 9c2149c8 | ths | break;
|
5407 | 9c2149c8 | ths | case OPC_DMTC0:
|
5408 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
5409 | 1a3fd9c3 | ths | { |
5410 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
5411 | 1a3fd9c3 | ths | |
5412 | 1a3fd9c3 | ths | gen_load_gpr(t0, rt); |
5413 | 1a3fd9c3 | ths | save_cpu_state(ctx, 1);
|
5414 | 1a3fd9c3 | ths | gen_dmtc0(env, ctx, t0, rd, ctx->opcode & 0x7);
|
5415 | 1a3fd9c3 | ths | tcg_temp_free(t0); |
5416 | 1a3fd9c3 | ths | } |
5417 | 9c2149c8 | ths | opn = "dmtc0";
|
5418 | 9c2149c8 | ths | break;
|
5419 | 534ce69f | ths | #endif
|
5420 | ead9360e | ths | case OPC_MFTR:
|
5421 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
5422 | ead9360e | ths | if (rd == 0) { |
5423 | ead9360e | ths | /* Treat as NOP. */
|
5424 | ead9360e | ths | return;
|
5425 | ead9360e | ths | } |
5426 | 6c5c1e20 | ths | gen_mftr(env, ctx, rt, rd, (ctx->opcode >> 5) & 1, |
5427 | ead9360e | ths | ctx->opcode & 0x7, (ctx->opcode >> 4) & 1); |
5428 | ead9360e | ths | opn = "mftr";
|
5429 | ead9360e | ths | break;
|
5430 | ead9360e | ths | case OPC_MTTR:
|
5431 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
5432 | 6c5c1e20 | ths | gen_mttr(env, ctx, rd, rt, (ctx->opcode >> 5) & 1, |
5433 | ead9360e | ths | ctx->opcode & 0x7, (ctx->opcode >> 4) & 1); |
5434 | ead9360e | ths | opn = "mttr";
|
5435 | ead9360e | ths | break;
|
5436 | 6af0bf9c | bellard | case OPC_TLBWI:
|
5437 | 6af0bf9c | bellard | opn = "tlbwi";
|
5438 | c01fccd2 | aurel32 | if (!env->tlb->helper_tlbwi)
|
5439 | 29929e34 | ths | goto die;
|
5440 | a7812ae4 | pbrook | gen_helper_tlbwi(); |
5441 | 6af0bf9c | bellard | break;
|
5442 | 6af0bf9c | bellard | case OPC_TLBWR:
|
5443 | 6af0bf9c | bellard | opn = "tlbwr";
|
5444 | c01fccd2 | aurel32 | if (!env->tlb->helper_tlbwr)
|
5445 | 29929e34 | ths | goto die;
|
5446 | a7812ae4 | pbrook | gen_helper_tlbwr(); |
5447 | 6af0bf9c | bellard | break;
|
5448 | 6af0bf9c | bellard | case OPC_TLBP:
|
5449 | 6af0bf9c | bellard | opn = "tlbp";
|
5450 | c01fccd2 | aurel32 | if (!env->tlb->helper_tlbp)
|
5451 | 29929e34 | ths | goto die;
|
5452 | a7812ae4 | pbrook | gen_helper_tlbp(); |
5453 | 6af0bf9c | bellard | break;
|
5454 | 6af0bf9c | bellard | case OPC_TLBR:
|
5455 | 6af0bf9c | bellard | opn = "tlbr";
|
5456 | c01fccd2 | aurel32 | if (!env->tlb->helper_tlbr)
|
5457 | 29929e34 | ths | goto die;
|
5458 | a7812ae4 | pbrook | gen_helper_tlbr(); |
5459 | 6af0bf9c | bellard | break;
|
5460 | 6af0bf9c | bellard | case OPC_ERET:
|
5461 | 6af0bf9c | bellard | opn = "eret";
|
5462 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS2); |
5463 | 387a8fe5 | ths | save_cpu_state(ctx, 1);
|
5464 | a7812ae4 | pbrook | gen_helper_eret(); |
5465 | 6af0bf9c | bellard | ctx->bstate = BS_EXCP; |
5466 | 6af0bf9c | bellard | break;
|
5467 | 6af0bf9c | bellard | case OPC_DERET:
|
5468 | 6af0bf9c | bellard | opn = "deret";
|
5469 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
5470 | 6af0bf9c | bellard | if (!(ctx->hflags & MIPS_HFLAG_DM)) {
|
5471 | 923617a3 | ths | MIPS_INVAL(opn); |
5472 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
5473 | 6af0bf9c | bellard | } else {
|
5474 | 387a8fe5 | ths | save_cpu_state(ctx, 1);
|
5475 | a7812ae4 | pbrook | gen_helper_deret(); |
5476 | 6af0bf9c | bellard | ctx->bstate = BS_EXCP; |
5477 | 6af0bf9c | bellard | } |
5478 | 6af0bf9c | bellard | break;
|
5479 | 4ad40f36 | bellard | case OPC_WAIT:
|
5480 | 4ad40f36 | bellard | opn = "wait";
|
5481 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32); |
5482 | 4ad40f36 | bellard | /* If we get an exception, we want to restart at next instruction */
|
5483 | 4ad40f36 | bellard | ctx->pc += 4;
|
5484 | 4ad40f36 | bellard | save_cpu_state(ctx, 1);
|
5485 | 4ad40f36 | bellard | ctx->pc -= 4;
|
5486 | a7812ae4 | pbrook | gen_helper_wait(); |
5487 | 4ad40f36 | bellard | ctx->bstate = BS_EXCP; |
5488 | 4ad40f36 | bellard | break;
|
5489 | 6af0bf9c | bellard | default:
|
5490 | 29929e34 | ths | die:
|
5491 | 923617a3 | ths | MIPS_INVAL(opn); |
5492 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
5493 | 6af0bf9c | bellard | return;
|
5494 | 6af0bf9c | bellard | } |
5495 | 6af0bf9c | bellard | MIPS_DEBUG("%s %s %d", opn, regnames[rt], rd);
|
5496 | 6af0bf9c | bellard | } |
5497 | f1aa6320 | ths | #endif /* !CONFIG_USER_ONLY */ |
5498 | 6af0bf9c | bellard | |
5499 | 6ea83fed | bellard | /* CP1 Branches (before delay slot) */
|
5500 | e189e748 | ths | static void gen_compute_branch1 (CPUState *env, DisasContext *ctx, uint32_t op, |
5501 | 5a5012ec | ths | int32_t cc, int32_t offset) |
5502 | 6ea83fed | bellard | { |
5503 | 6ea83fed | bellard | target_ulong btarget; |
5504 | 923617a3 | ths | const char *opn = "cp1 cond branch"; |
5505 | a7812ae4 | pbrook | TCGv_i32 t0 = tcg_temp_new_i32(); |
5506 | 6ea83fed | bellard | |
5507 | e189e748 | ths | if (cc != 0) |
5508 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); |
5509 | e189e748 | ths | |
5510 | 6ea83fed | bellard | btarget = ctx->pc + 4 + offset;
|
5511 | 6ea83fed | bellard | |
5512 | 7a387fff | ths | switch (op) {
|
5513 | 7a387fff | ths | case OPC_BC1F:
|
5514 | a16336e4 | ths | { |
5515 | a16336e4 | ths | int l1 = gen_new_label();
|
5516 | a16336e4 | ths | int l2 = gen_new_label();
|
5517 | a16336e4 | ths | |
5518 | a6e92a65 | aurel32 | get_fp_cond(t0); |
5519 | a6e92a65 | aurel32 | tcg_gen_andi_i32(t0, t0, 0x1 << cc);
|
5520 | a6e92a65 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, t0, 0, l1);
|
5521 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 0);
|
5522 | a16336e4 | ths | tcg_gen_br(l2); |
5523 | a16336e4 | ths | gen_set_label(l1); |
5524 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 1);
|
5525 | a16336e4 | ths | gen_set_label(l2); |
5526 | a16336e4 | ths | } |
5527 | 923617a3 | ths | opn = "bc1f";
|
5528 | 6ea83fed | bellard | goto not_likely;
|
5529 | 7a387fff | ths | case OPC_BC1FL:
|
5530 | a16336e4 | ths | { |
5531 | a16336e4 | ths | int l1 = gen_new_label();
|
5532 | a16336e4 | ths | int l2 = gen_new_label();
|
5533 | a16336e4 | ths | |
5534 | a6e92a65 | aurel32 | get_fp_cond(t0); |
5535 | a6e92a65 | aurel32 | tcg_gen_andi_i32(t0, t0, 0x1 << cc);
|
5536 | a6e92a65 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, t0, 0, l1);
|
5537 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 0);
|
5538 | a16336e4 | ths | tcg_gen_br(l2); |
5539 | a16336e4 | ths | gen_set_label(l1); |
5540 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 1);
|
5541 | a16336e4 | ths | gen_set_label(l2); |
5542 | a16336e4 | ths | } |
5543 | 923617a3 | ths | opn = "bc1fl";
|
5544 | 6ea83fed | bellard | goto likely;
|
5545 | 7a387fff | ths | case OPC_BC1T:
|
5546 | a16336e4 | ths | { |
5547 | a16336e4 | ths | int l1 = gen_new_label();
|
5548 | a16336e4 | ths | int l2 = gen_new_label();
|
5549 | a16336e4 | ths | |
5550 | a6e92a65 | aurel32 | get_fp_cond(t0); |
5551 | a6e92a65 | aurel32 | tcg_gen_andi_i32(t0, t0, 0x1 << cc);
|
5552 | a6e92a65 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_NE, t0, 0, l1);
|
5553 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 0);
|
5554 | a16336e4 | ths | tcg_gen_br(l2); |
5555 | a16336e4 | ths | gen_set_label(l1); |
5556 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 1);
|
5557 | a16336e4 | ths | gen_set_label(l2); |
5558 | a16336e4 | ths | } |
5559 | 923617a3 | ths | opn = "bc1t";
|
5560 | 5a5012ec | ths | goto not_likely;
|
5561 | 7a387fff | ths | case OPC_BC1TL:
|
5562 | a16336e4 | ths | { |
5563 | a16336e4 | ths | int l1 = gen_new_label();
|
5564 | a16336e4 | ths | int l2 = gen_new_label();
|
5565 | a16336e4 | ths | |
5566 | a6e92a65 | aurel32 | get_fp_cond(t0); |
5567 | a6e92a65 | aurel32 | tcg_gen_andi_i32(t0, t0, 0x1 << cc);
|
5568 | a6e92a65 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_NE, t0, 0, l1);
|
5569 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 0);
|
5570 | a16336e4 | ths | tcg_gen_br(l2); |
5571 | a16336e4 | ths | gen_set_label(l1); |
5572 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 1);
|
5573 | a16336e4 | ths | gen_set_label(l2); |
5574 | a16336e4 | ths | } |
5575 | 923617a3 | ths | opn = "bc1tl";
|
5576 | 6ea83fed | bellard | likely:
|
5577 | 6ea83fed | bellard | ctx->hflags |= MIPS_HFLAG_BL; |
5578 | 6ea83fed | bellard | break;
|
5579 | 5a5012ec | ths | case OPC_BC1FANY2:
|
5580 | a16336e4 | ths | { |
5581 | a16336e4 | ths | int l1 = gen_new_label();
|
5582 | a16336e4 | ths | int l2 = gen_new_label();
|
5583 | a16336e4 | ths | |
5584 | a6e92a65 | aurel32 | get_fp_cond(t0); |
5585 | a6e92a65 | aurel32 | tcg_gen_andi_i32(t0, t0, 0x3 << cc);
|
5586 | a6e92a65 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, t0, 0, l1);
|
5587 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 0);
|
5588 | a16336e4 | ths | tcg_gen_br(l2); |
5589 | a16336e4 | ths | gen_set_label(l1); |
5590 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 1);
|
5591 | a16336e4 | ths | gen_set_label(l2); |
5592 | a16336e4 | ths | } |
5593 | fd4a04eb | ths | opn = "bc1any2f";
|
5594 | 5a5012ec | ths | goto not_likely;
|
5595 | 5a5012ec | ths | case OPC_BC1TANY2:
|
5596 | a16336e4 | ths | { |
5597 | a16336e4 | ths | int l1 = gen_new_label();
|
5598 | a16336e4 | ths | int l2 = gen_new_label();
|
5599 | a16336e4 | ths | |
5600 | a6e92a65 | aurel32 | get_fp_cond(t0); |
5601 | a6e92a65 | aurel32 | tcg_gen_andi_i32(t0, t0, 0x3 << cc);
|
5602 | a6e92a65 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_NE, t0, 0, l1);
|
5603 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 0);
|
5604 | a16336e4 | ths | tcg_gen_br(l2); |
5605 | a16336e4 | ths | gen_set_label(l1); |
5606 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 1);
|
5607 | a16336e4 | ths | gen_set_label(l2); |
5608 | a16336e4 | ths | } |
5609 | fd4a04eb | ths | opn = "bc1any2t";
|
5610 | 5a5012ec | ths | goto not_likely;
|
5611 | 5a5012ec | ths | case OPC_BC1FANY4:
|
5612 | a16336e4 | ths | { |
5613 | a16336e4 | ths | int l1 = gen_new_label();
|
5614 | a16336e4 | ths | int l2 = gen_new_label();
|
5615 | a16336e4 | ths | |
5616 | a6e92a65 | aurel32 | get_fp_cond(t0); |
5617 | a6e92a65 | aurel32 | tcg_gen_andi_i32(t0, t0, 0xf << cc);
|
5618 | a6e92a65 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_EQ, t0, 0, l1);
|
5619 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 0);
|
5620 | a16336e4 | ths | tcg_gen_br(l2); |
5621 | a16336e4 | ths | gen_set_label(l1); |
5622 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 1);
|
5623 | a16336e4 | ths | gen_set_label(l2); |
5624 | a16336e4 | ths | } |
5625 | fd4a04eb | ths | opn = "bc1any4f";
|
5626 | 5a5012ec | ths | goto not_likely;
|
5627 | 5a5012ec | ths | case OPC_BC1TANY4:
|
5628 | a16336e4 | ths | { |
5629 | a16336e4 | ths | int l1 = gen_new_label();
|
5630 | a16336e4 | ths | int l2 = gen_new_label();
|
5631 | a16336e4 | ths | |
5632 | a6e92a65 | aurel32 | get_fp_cond(t0); |
5633 | a6e92a65 | aurel32 | tcg_gen_andi_i32(t0, t0, 0xf << cc);
|
5634 | a6e92a65 | aurel32 | tcg_gen_brcondi_i32(TCG_COND_NE, t0, 0, l1);
|
5635 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 0);
|
5636 | a16336e4 | ths | tcg_gen_br(l2); |
5637 | a16336e4 | ths | gen_set_label(l1); |
5638 | 1ba74fb8 | aurel32 | tcg_gen_movi_tl(bcond, 1);
|
5639 | a16336e4 | ths | gen_set_label(l2); |
5640 | a16336e4 | ths | } |
5641 | fd4a04eb | ths | opn = "bc1any4t";
|
5642 | 5a5012ec | ths | not_likely:
|
5643 | 5a5012ec | ths | ctx->hflags |= MIPS_HFLAG_BC; |
5644 | 5a5012ec | ths | break;
|
5645 | 5a5012ec | ths | default:
|
5646 | 923617a3 | ths | MIPS_INVAL(opn); |
5647 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
5648 | 6c5c1e20 | ths | goto out;
|
5649 | 6ea83fed | bellard | } |
5650 | 923617a3 | ths | MIPS_DEBUG("%s: cond %02x target " TARGET_FMT_lx, opn,
|
5651 | 6ea83fed | bellard | ctx->hflags, btarget); |
5652 | 6ea83fed | bellard | ctx->btarget = btarget; |
5653 | 6c5c1e20 | ths | |
5654 | 6c5c1e20 | ths | out:
|
5655 | a7812ae4 | pbrook | tcg_temp_free_i32(t0); |
5656 | 6ea83fed | bellard | } |
5657 | 6ea83fed | bellard | |
5658 | 6af0bf9c | bellard | /* Coprocessor 1 (FPU) */
|
5659 | 5a5012ec | ths | |
5660 | 5a5012ec | ths | #define FOP(func, fmt) (((fmt) << 21) | (func)) |
5661 | 5a5012ec | ths | |
5662 | 7a387fff | ths | static void gen_cp1 (DisasContext *ctx, uint32_t opc, int rt, int fs) |
5663 | 6ea83fed | bellard | { |
5664 | 923617a3 | ths | const char *opn = "cp1 move"; |
5665 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
5666 | 6ea83fed | bellard | |
5667 | 6ea83fed | bellard | switch (opc) {
|
5668 | 6ea83fed | bellard | case OPC_MFC1:
|
5669 | b6d96bed | ths | { |
5670 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5671 | b6d96bed | ths | |
5672 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
5673 | b6d96bed | ths | tcg_gen_ext_i32_tl(t0, fp0); |
5674 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5675 | 6958549d | aurel32 | } |
5676 | 6c5c1e20 | ths | gen_store_gpr(t0, rt); |
5677 | 6ea83fed | bellard | opn = "mfc1";
|
5678 | 6ea83fed | bellard | break;
|
5679 | 6ea83fed | bellard | case OPC_MTC1:
|
5680 | 6c5c1e20 | ths | gen_load_gpr(t0, rt); |
5681 | b6d96bed | ths | { |
5682 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5683 | b6d96bed | ths | |
5684 | b6d96bed | ths | tcg_gen_trunc_tl_i32(fp0, t0); |
5685 | b6d96bed | ths | gen_store_fpr32(fp0, fs); |
5686 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5687 | 6958549d | aurel32 | } |
5688 | 6ea83fed | bellard | opn = "mtc1";
|
5689 | 6ea83fed | bellard | break;
|
5690 | 6ea83fed | bellard | case OPC_CFC1:
|
5691 | a7812ae4 | pbrook | gen_helper_1i(cfc1, t0, fs); |
5692 | 6c5c1e20 | ths | gen_store_gpr(t0, rt); |
5693 | 6ea83fed | bellard | opn = "cfc1";
|
5694 | 6ea83fed | bellard | break;
|
5695 | 6ea83fed | bellard | case OPC_CTC1:
|
5696 | 6c5c1e20 | ths | gen_load_gpr(t0, rt); |
5697 | a7812ae4 | pbrook | gen_helper_1i(ctc1, t0, fs); |
5698 | 6ea83fed | bellard | opn = "ctc1";
|
5699 | 6ea83fed | bellard | break;
|
5700 | 9c2149c8 | ths | case OPC_DMFC1:
|
5701 | b6d96bed | ths | { |
5702 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
5703 | b6d96bed | ths | |
5704 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
5705 | a7812ae4 | pbrook | tcg_gen_trunc_i64_tl(t0, fp0); |
5706 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
5707 | 6958549d | aurel32 | } |
5708 | 6c5c1e20 | ths | gen_store_gpr(t0, rt); |
5709 | 5a5012ec | ths | opn = "dmfc1";
|
5710 | 5a5012ec | ths | break;
|
5711 | 9c2149c8 | ths | case OPC_DMTC1:
|
5712 | 6c5c1e20 | ths | gen_load_gpr(t0, rt); |
5713 | b6d96bed | ths | { |
5714 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
5715 | b6d96bed | ths | |
5716 | a7812ae4 | pbrook | tcg_gen_extu_tl_i64(fp0, t0); |
5717 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fs); |
5718 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
5719 | 6958549d | aurel32 | } |
5720 | 5a5012ec | ths | opn = "dmtc1";
|
5721 | 5a5012ec | ths | break;
|
5722 | 5a5012ec | ths | case OPC_MFHC1:
|
5723 | b6d96bed | ths | { |
5724 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5725 | b6d96bed | ths | |
5726 | b6d96bed | ths | gen_load_fpr32h(fp0, fs); |
5727 | b6d96bed | ths | tcg_gen_ext_i32_tl(t0, fp0); |
5728 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5729 | 6958549d | aurel32 | } |
5730 | 6c5c1e20 | ths | gen_store_gpr(t0, rt); |
5731 | 5a5012ec | ths | opn = "mfhc1";
|
5732 | 5a5012ec | ths | break;
|
5733 | 5a5012ec | ths | case OPC_MTHC1:
|
5734 | 6c5c1e20 | ths | gen_load_gpr(t0, rt); |
5735 | b6d96bed | ths | { |
5736 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5737 | b6d96bed | ths | |
5738 | b6d96bed | ths | tcg_gen_trunc_tl_i32(fp0, t0); |
5739 | b6d96bed | ths | gen_store_fpr32h(fp0, fs); |
5740 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5741 | 6958549d | aurel32 | } |
5742 | 5a5012ec | ths | opn = "mthc1";
|
5743 | 5a5012ec | ths | break;
|
5744 | 6ea83fed | bellard | default:
|
5745 | 923617a3 | ths | MIPS_INVAL(opn); |
5746 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
5747 | 6c5c1e20 | ths | goto out;
|
5748 | 6ea83fed | bellard | } |
5749 | 6ea83fed | bellard | MIPS_DEBUG("%s %s %s", opn, regnames[rt], fregnames[fs]);
|
5750 | 6c5c1e20 | ths | |
5751 | 6c5c1e20 | ths | out:
|
5752 | 6c5c1e20 | ths | tcg_temp_free(t0); |
5753 | 6ea83fed | bellard | } |
5754 | 6ea83fed | bellard | |
5755 | 5a5012ec | ths | static void gen_movci (DisasContext *ctx, int rd, int rs, int cc, int tf) |
5756 | 5a5012ec | ths | { |
5757 | e214b9bb | ths | int l1 = gen_new_label();
|
5758 | 5a5012ec | ths | uint32_t ccbit; |
5759 | e214b9bb | ths | TCGCond cond; |
5760 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
5761 | a7812ae4 | pbrook | TCGv_i32 r_tmp = tcg_temp_new_i32(); |
5762 | 6ea83fed | bellard | |
5763 | e214b9bb | ths | if (cc)
|
5764 | 5a5012ec | ths | ccbit = 1 << (24 + cc); |
5765 | e214b9bb | ths | else
|
5766 | 5a5012ec | ths | ccbit = 1 << 23; |
5767 | e214b9bb | ths | if (tf)
|
5768 | e214b9bb | ths | cond = TCG_COND_EQ; |
5769 | 27848470 | ths | else
|
5770 | 27848470 | ths | cond = TCG_COND_NE; |
5771 | 27848470 | ths | |
5772 | 6c5c1e20 | ths | gen_load_gpr(t0, rd); |
5773 | f01be154 | ths | tcg_gen_andi_i32(r_tmp, fpu_fcr31, ccbit); |
5774 | 920c608e | ths | tcg_gen_brcondi_i32(cond, r_tmp, 0, l1);
|
5775 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp); |
5776 | 9bf3eb2c | aurel32 | gen_load_gpr(t0, rs); |
5777 | e214b9bb | ths | gen_set_label(l1); |
5778 | 6c5c1e20 | ths | gen_store_gpr(t0, rd); |
5779 | 6c5c1e20 | ths | tcg_temp_free(t0); |
5780 | 5a5012ec | ths | } |
5781 | 5a5012ec | ths | |
5782 | b6d96bed | ths | static inline void gen_movcf_s (int fs, int fd, int cc, int tf) |
5783 | a16336e4 | ths | { |
5784 | a16336e4 | ths | uint32_t ccbit; |
5785 | a16336e4 | ths | int cond;
|
5786 | a7812ae4 | pbrook | TCGv_i32 r_tmp1 = tcg_temp_new_i32(); |
5787 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_local_new_i32(); |
5788 | a16336e4 | ths | int l1 = gen_new_label();
|
5789 | a16336e4 | ths | |
5790 | a16336e4 | ths | if (cc)
|
5791 | a16336e4 | ths | ccbit = 1 << (24 + cc); |
5792 | a16336e4 | ths | else
|
5793 | a16336e4 | ths | ccbit = 1 << 23; |
5794 | a16336e4 | ths | |
5795 | a16336e4 | ths | if (tf)
|
5796 | a16336e4 | ths | cond = TCG_COND_EQ; |
5797 | a16336e4 | ths | else
|
5798 | a16336e4 | ths | cond = TCG_COND_NE; |
5799 | a16336e4 | ths | |
5800 | 9bf3eb2c | aurel32 | gen_load_fpr32(fp0, fd); |
5801 | f01be154 | ths | tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit); |
5802 | a16336e4 | ths | tcg_gen_brcondi_i32(cond, r_tmp1, 0, l1);
|
5803 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp1); |
5804 | 9bf3eb2c | aurel32 | gen_load_fpr32(fp0, fs); |
5805 | a16336e4 | ths | gen_set_label(l1); |
5806 | 9bf3eb2c | aurel32 | gen_store_fpr32(fp0, fd); |
5807 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5808 | 5a5012ec | ths | } |
5809 | a16336e4 | ths | |
5810 | b6d96bed | ths | static inline void gen_movcf_d (DisasContext *ctx, int fs, int fd, int cc, int tf) |
5811 | a16336e4 | ths | { |
5812 | a16336e4 | ths | uint32_t ccbit; |
5813 | a16336e4 | ths | int cond;
|
5814 | a7812ae4 | pbrook | TCGv_i32 r_tmp1 = tcg_temp_new_i32(); |
5815 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_local_new_i64(); |
5816 | a16336e4 | ths | int l1 = gen_new_label();
|
5817 | a16336e4 | ths | |
5818 | a16336e4 | ths | if (cc)
|
5819 | a16336e4 | ths | ccbit = 1 << (24 + cc); |
5820 | a16336e4 | ths | else
|
5821 | a16336e4 | ths | ccbit = 1 << 23; |
5822 | a16336e4 | ths | |
5823 | a16336e4 | ths | if (tf)
|
5824 | a16336e4 | ths | cond = TCG_COND_EQ; |
5825 | a16336e4 | ths | else
|
5826 | a16336e4 | ths | cond = TCG_COND_NE; |
5827 | a16336e4 | ths | |
5828 | 9bf3eb2c | aurel32 | gen_load_fpr64(ctx, fp0, fd); |
5829 | f01be154 | ths | tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit); |
5830 | a16336e4 | ths | tcg_gen_brcondi_i32(cond, r_tmp1, 0, l1);
|
5831 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp1); |
5832 | 9bf3eb2c | aurel32 | gen_load_fpr64(ctx, fp0, fs); |
5833 | a16336e4 | ths | gen_set_label(l1); |
5834 | 9bf3eb2c | aurel32 | gen_store_fpr64(ctx, fp0, fd); |
5835 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
5836 | a16336e4 | ths | } |
5837 | a16336e4 | ths | |
5838 | b6d96bed | ths | static inline void gen_movcf_ps (int fs, int fd, int cc, int tf) |
5839 | a16336e4 | ths | { |
5840 | 9bf3eb2c | aurel32 | uint32_t ccbit1, ccbit2; |
5841 | a16336e4 | ths | int cond;
|
5842 | a7812ae4 | pbrook | TCGv_i32 r_tmp1 = tcg_temp_new_i32(); |
5843 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_local_new_i32(); |
5844 | a16336e4 | ths | int l1 = gen_new_label();
|
5845 | a16336e4 | ths | int l2 = gen_new_label();
|
5846 | a16336e4 | ths | |
5847 | 9bf3eb2c | aurel32 | if (cc) {
|
5848 | 9bf3eb2c | aurel32 | ccbit1 = 1 << (24 + cc); |
5849 | 9bf3eb2c | aurel32 | ccbit2 = 1 << (25 + cc); |
5850 | 9bf3eb2c | aurel32 | } else {
|
5851 | 9bf3eb2c | aurel32 | ccbit1 = 1 << 23; |
5852 | 9bf3eb2c | aurel32 | ccbit2 = 1 << 25; |
5853 | 9bf3eb2c | aurel32 | } |
5854 | 9bf3eb2c | aurel32 | |
5855 | a16336e4 | ths | if (tf)
|
5856 | a16336e4 | ths | cond = TCG_COND_EQ; |
5857 | a16336e4 | ths | else
|
5858 | a16336e4 | ths | cond = TCG_COND_NE; |
5859 | a16336e4 | ths | |
5860 | 9bf3eb2c | aurel32 | gen_load_fpr32(fp0, fd); |
5861 | 9bf3eb2c | aurel32 | tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit1); |
5862 | 9bf3eb2c | aurel32 | tcg_gen_brcondi_i32(cond, r_tmp1, 0, l1);
|
5863 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
5864 | a16336e4 | ths | gen_set_label(l1); |
5865 | 9bf3eb2c | aurel32 | gen_store_fpr32(fp0, fd); |
5866 | 9bf3eb2c | aurel32 | |
5867 | 9bf3eb2c | aurel32 | gen_load_fpr32h(fp0, fd); |
5868 | 9bf3eb2c | aurel32 | tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit2); |
5869 | 9bf3eb2c | aurel32 | tcg_gen_brcondi_i32(cond, r_tmp1, 0, l2);
|
5870 | 9bf3eb2c | aurel32 | gen_load_fpr32h(fp0, fs); |
5871 | a16336e4 | ths | gen_set_label(l2); |
5872 | 9bf3eb2c | aurel32 | gen_store_fpr32h(fp0, fd); |
5873 | 9bf3eb2c | aurel32 | |
5874 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp1); |
5875 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5876 | a16336e4 | ths | } |
5877 | a16336e4 | ths | |
5878 | 6ea83fed | bellard | |
5879 | 5e755519 | ths | static void gen_farith (DisasContext *ctx, uint32_t op1, |
5880 | 5e755519 | ths | int ft, int fs, int fd, int cc) |
5881 | 6ea83fed | bellard | { |
5882 | 923617a3 | ths | const char *opn = "farith"; |
5883 | 6ea83fed | bellard | const char *condnames[] = { |
5884 | 6ea83fed | bellard | "c.f",
|
5885 | 6ea83fed | bellard | "c.un",
|
5886 | 6ea83fed | bellard | "c.eq",
|
5887 | 6ea83fed | bellard | "c.ueq",
|
5888 | 6ea83fed | bellard | "c.olt",
|
5889 | 6ea83fed | bellard | "c.ult",
|
5890 | 6ea83fed | bellard | "c.ole",
|
5891 | 6ea83fed | bellard | "c.ule",
|
5892 | 6ea83fed | bellard | "c.sf",
|
5893 | 6ea83fed | bellard | "c.ngle",
|
5894 | 6ea83fed | bellard | "c.seq",
|
5895 | 6ea83fed | bellard | "c.ngl",
|
5896 | 6ea83fed | bellard | "c.lt",
|
5897 | 6ea83fed | bellard | "c.nge",
|
5898 | 6ea83fed | bellard | "c.le",
|
5899 | 6ea83fed | bellard | "c.ngt",
|
5900 | 6ea83fed | bellard | }; |
5901 | 5a1e8ffb | ths | const char *condnames_abs[] = { |
5902 | 5a1e8ffb | ths | "cabs.f",
|
5903 | 5a1e8ffb | ths | "cabs.un",
|
5904 | 5a1e8ffb | ths | "cabs.eq",
|
5905 | 5a1e8ffb | ths | "cabs.ueq",
|
5906 | 5a1e8ffb | ths | "cabs.olt",
|
5907 | 5a1e8ffb | ths | "cabs.ult",
|
5908 | 5a1e8ffb | ths | "cabs.ole",
|
5909 | 5a1e8ffb | ths | "cabs.ule",
|
5910 | 5a1e8ffb | ths | "cabs.sf",
|
5911 | 5a1e8ffb | ths | "cabs.ngle",
|
5912 | 5a1e8ffb | ths | "cabs.seq",
|
5913 | 5a1e8ffb | ths | "cabs.ngl",
|
5914 | 5a1e8ffb | ths | "cabs.lt",
|
5915 | 5a1e8ffb | ths | "cabs.nge",
|
5916 | 5a1e8ffb | ths | "cabs.le",
|
5917 | 5a1e8ffb | ths | "cabs.ngt",
|
5918 | 5a1e8ffb | ths | }; |
5919 | 5a1e8ffb | ths | enum { BINOP, CMPOP, OTHEROP } optype = OTHEROP;
|
5920 | 7a387fff | ths | uint32_t func = ctx->opcode & 0x3f;
|
5921 | 7a387fff | ths | |
5922 | 6ea83fed | bellard | switch (ctx->opcode & FOP(0x3f, 0x1f)) { |
5923 | 5a5012ec | ths | case FOP(0, 16): |
5924 | b6d96bed | ths | { |
5925 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5926 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
5927 | b6d96bed | ths | |
5928 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
5929 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
5930 | a7812ae4 | pbrook | gen_helper_float_add_s(fp0, fp0, fp1); |
5931 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
5932 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
5933 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5934 | b6d96bed | ths | } |
5935 | 5a5012ec | ths | opn = "add.s";
|
5936 | 5a1e8ffb | ths | optype = BINOP; |
5937 | 5a5012ec | ths | break;
|
5938 | 5a5012ec | ths | case FOP(1, 16): |
5939 | b6d96bed | ths | { |
5940 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5941 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
5942 | b6d96bed | ths | |
5943 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
5944 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
5945 | a7812ae4 | pbrook | gen_helper_float_sub_s(fp0, fp0, fp1); |
5946 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
5947 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
5948 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5949 | b6d96bed | ths | } |
5950 | 5a5012ec | ths | opn = "sub.s";
|
5951 | 5a1e8ffb | ths | optype = BINOP; |
5952 | 5a5012ec | ths | break;
|
5953 | 5a5012ec | ths | case FOP(2, 16): |
5954 | b6d96bed | ths | { |
5955 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5956 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
5957 | b6d96bed | ths | |
5958 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
5959 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
5960 | a7812ae4 | pbrook | gen_helper_float_mul_s(fp0, fp0, fp1); |
5961 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
5962 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
5963 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5964 | b6d96bed | ths | } |
5965 | 5a5012ec | ths | opn = "mul.s";
|
5966 | 5a1e8ffb | ths | optype = BINOP; |
5967 | 5a5012ec | ths | break;
|
5968 | 5a5012ec | ths | case FOP(3, 16): |
5969 | b6d96bed | ths | { |
5970 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5971 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
5972 | b6d96bed | ths | |
5973 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
5974 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
5975 | a7812ae4 | pbrook | gen_helper_float_div_s(fp0, fp0, fp1); |
5976 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
5977 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
5978 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5979 | b6d96bed | ths | } |
5980 | 5a5012ec | ths | opn = "div.s";
|
5981 | 5a1e8ffb | ths | optype = BINOP; |
5982 | 5a5012ec | ths | break;
|
5983 | 5a5012ec | ths | case FOP(4, 16): |
5984 | b6d96bed | ths | { |
5985 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5986 | b6d96bed | ths | |
5987 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
5988 | a7812ae4 | pbrook | gen_helper_float_sqrt_s(fp0, fp0); |
5989 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
5990 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
5991 | b6d96bed | ths | } |
5992 | 5a5012ec | ths | opn = "sqrt.s";
|
5993 | 5a5012ec | ths | break;
|
5994 | 5a5012ec | ths | case FOP(5, 16): |
5995 | b6d96bed | ths | { |
5996 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
5997 | b6d96bed | ths | |
5998 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
5999 | a7812ae4 | pbrook | gen_helper_float_abs_s(fp0, fp0); |
6000 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6001 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6002 | b6d96bed | ths | } |
6003 | 5a5012ec | ths | opn = "abs.s";
|
6004 | 5a5012ec | ths | break;
|
6005 | 5a5012ec | ths | case FOP(6, 16): |
6006 | b6d96bed | ths | { |
6007 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6008 | b6d96bed | ths | |
6009 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6010 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6011 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6012 | b6d96bed | ths | } |
6013 | 5a5012ec | ths | opn = "mov.s";
|
6014 | 5a5012ec | ths | break;
|
6015 | 5a5012ec | ths | case FOP(7, 16): |
6016 | b6d96bed | ths | { |
6017 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6018 | b6d96bed | ths | |
6019 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6020 | a7812ae4 | pbrook | gen_helper_float_chs_s(fp0, fp0); |
6021 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6022 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6023 | b6d96bed | ths | } |
6024 | 5a5012ec | ths | opn = "neg.s";
|
6025 | 5a5012ec | ths | break;
|
6026 | 5a5012ec | ths | case FOP(8, 16): |
6027 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6028 | b6d96bed | ths | { |
6029 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6030 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6031 | b6d96bed | ths | |
6032 | b6d96bed | ths | gen_load_fpr32(fp32, fs); |
6033 | a7812ae4 | pbrook | gen_helper_float_roundl_s(fp64, fp32); |
6034 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6035 | b6d96bed | ths | gen_store_fpr64(ctx, fp64, fd); |
6036 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6037 | b6d96bed | ths | } |
6038 | 5a5012ec | ths | opn = "round.l.s";
|
6039 | 5a5012ec | ths | break;
|
6040 | 5a5012ec | ths | case FOP(9, 16): |
6041 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6042 | b6d96bed | ths | { |
6043 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6044 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6045 | b6d96bed | ths | |
6046 | b6d96bed | ths | gen_load_fpr32(fp32, fs); |
6047 | a7812ae4 | pbrook | gen_helper_float_truncl_s(fp64, fp32); |
6048 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6049 | b6d96bed | ths | gen_store_fpr64(ctx, fp64, fd); |
6050 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6051 | b6d96bed | ths | } |
6052 | 5a5012ec | ths | opn = "trunc.l.s";
|
6053 | 5a5012ec | ths | break;
|
6054 | 5a5012ec | ths | case FOP(10, 16): |
6055 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6056 | b6d96bed | ths | { |
6057 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6058 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6059 | b6d96bed | ths | |
6060 | b6d96bed | ths | gen_load_fpr32(fp32, fs); |
6061 | a7812ae4 | pbrook | gen_helper_float_ceill_s(fp64, fp32); |
6062 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6063 | b6d96bed | ths | gen_store_fpr64(ctx, fp64, fd); |
6064 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6065 | b6d96bed | ths | } |
6066 | 5a5012ec | ths | opn = "ceil.l.s";
|
6067 | 5a5012ec | ths | break;
|
6068 | 5a5012ec | ths | case FOP(11, 16): |
6069 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6070 | b6d96bed | ths | { |
6071 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6072 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6073 | b6d96bed | ths | |
6074 | b6d96bed | ths | gen_load_fpr32(fp32, fs); |
6075 | a7812ae4 | pbrook | gen_helper_float_floorl_s(fp64, fp32); |
6076 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6077 | b6d96bed | ths | gen_store_fpr64(ctx, fp64, fd); |
6078 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6079 | b6d96bed | ths | } |
6080 | 5a5012ec | ths | opn = "floor.l.s";
|
6081 | 5a5012ec | ths | break;
|
6082 | 5a5012ec | ths | case FOP(12, 16): |
6083 | b6d96bed | ths | { |
6084 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6085 | b6d96bed | ths | |
6086 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6087 | a7812ae4 | pbrook | gen_helper_float_roundw_s(fp0, fp0); |
6088 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6089 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6090 | b6d96bed | ths | } |
6091 | 5a5012ec | ths | opn = "round.w.s";
|
6092 | 5a5012ec | ths | break;
|
6093 | 5a5012ec | ths | case FOP(13, 16): |
6094 | b6d96bed | ths | { |
6095 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6096 | b6d96bed | ths | |
6097 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6098 | a7812ae4 | pbrook | gen_helper_float_truncw_s(fp0, fp0); |
6099 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6100 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6101 | b6d96bed | ths | } |
6102 | 5a5012ec | ths | opn = "trunc.w.s";
|
6103 | 5a5012ec | ths | break;
|
6104 | 5a5012ec | ths | case FOP(14, 16): |
6105 | b6d96bed | ths | { |
6106 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6107 | b6d96bed | ths | |
6108 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6109 | a7812ae4 | pbrook | gen_helper_float_ceilw_s(fp0, fp0); |
6110 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6111 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6112 | b6d96bed | ths | } |
6113 | 5a5012ec | ths | opn = "ceil.w.s";
|
6114 | 5a5012ec | ths | break;
|
6115 | 5a5012ec | ths | case FOP(15, 16): |
6116 | b6d96bed | ths | { |
6117 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6118 | b6d96bed | ths | |
6119 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6120 | a7812ae4 | pbrook | gen_helper_float_floorw_s(fp0, fp0); |
6121 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6122 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6123 | b6d96bed | ths | } |
6124 | 5a5012ec | ths | opn = "floor.w.s";
|
6125 | 5a5012ec | ths | break;
|
6126 | 5a5012ec | ths | case FOP(17, 16): |
6127 | b6d96bed | ths | gen_movcf_s(fs, fd, (ft >> 2) & 0x7, ft & 0x1); |
6128 | 5a5012ec | ths | opn = "movcf.s";
|
6129 | 5a5012ec | ths | break;
|
6130 | 5a5012ec | ths | case FOP(18, 16): |
6131 | a16336e4 | ths | { |
6132 | a16336e4 | ths | int l1 = gen_new_label();
|
6133 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_new(); |
6134 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_local_new_i32(); |
6135 | a16336e4 | ths | |
6136 | 6c5c1e20 | ths | gen_load_gpr(t0, ft); |
6137 | 6c5c1e20 | ths | tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1);
|
6138 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6139 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6140 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6141 | a16336e4 | ths | gen_set_label(l1); |
6142 | 2a0ab998 | aurel32 | tcg_temp_free(t0); |
6143 | a16336e4 | ths | } |
6144 | 5a5012ec | ths | opn = "movz.s";
|
6145 | 5a5012ec | ths | break;
|
6146 | 5a5012ec | ths | case FOP(19, 16): |
6147 | a16336e4 | ths | { |
6148 | a16336e4 | ths | int l1 = gen_new_label();
|
6149 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_new(); |
6150 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_local_new_i32(); |
6151 | a16336e4 | ths | |
6152 | 6c5c1e20 | ths | gen_load_gpr(t0, ft); |
6153 | 6c5c1e20 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
6154 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6155 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6156 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6157 | a16336e4 | ths | gen_set_label(l1); |
6158 | 2a0ab998 | aurel32 | tcg_temp_free(t0); |
6159 | a16336e4 | ths | } |
6160 | 5a5012ec | ths | opn = "movn.s";
|
6161 | 5a5012ec | ths | break;
|
6162 | 57fa1fb3 | ths | case FOP(21, 16): |
6163 | b8aa4598 | ths | check_cop1x(ctx); |
6164 | b6d96bed | ths | { |
6165 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6166 | b6d96bed | ths | |
6167 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6168 | a7812ae4 | pbrook | gen_helper_float_recip_s(fp0, fp0); |
6169 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6170 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6171 | b6d96bed | ths | } |
6172 | 57fa1fb3 | ths | opn = "recip.s";
|
6173 | 57fa1fb3 | ths | break;
|
6174 | 57fa1fb3 | ths | case FOP(22, 16): |
6175 | b8aa4598 | ths | check_cop1x(ctx); |
6176 | b6d96bed | ths | { |
6177 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6178 | b6d96bed | ths | |
6179 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6180 | a7812ae4 | pbrook | gen_helper_float_rsqrt_s(fp0, fp0); |
6181 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6182 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6183 | b6d96bed | ths | } |
6184 | 57fa1fb3 | ths | opn = "rsqrt.s";
|
6185 | 57fa1fb3 | ths | break;
|
6186 | 57fa1fb3 | ths | case FOP(28, 16): |
6187 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6188 | b6d96bed | ths | { |
6189 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6190 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
6191 | b6d96bed | ths | |
6192 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6193 | b6d96bed | ths | gen_load_fpr32(fp1, fd); |
6194 | a7812ae4 | pbrook | gen_helper_float_recip2_s(fp0, fp0, fp1); |
6195 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
6196 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6197 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6198 | b6d96bed | ths | } |
6199 | 57fa1fb3 | ths | opn = "recip2.s";
|
6200 | 57fa1fb3 | ths | break;
|
6201 | 57fa1fb3 | ths | case FOP(29, 16): |
6202 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6203 | b6d96bed | ths | { |
6204 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6205 | b6d96bed | ths | |
6206 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6207 | a7812ae4 | pbrook | gen_helper_float_recip1_s(fp0, fp0); |
6208 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6209 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6210 | b6d96bed | ths | } |
6211 | 57fa1fb3 | ths | opn = "recip1.s";
|
6212 | 57fa1fb3 | ths | break;
|
6213 | 57fa1fb3 | ths | case FOP(30, 16): |
6214 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6215 | b6d96bed | ths | { |
6216 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6217 | b6d96bed | ths | |
6218 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6219 | a7812ae4 | pbrook | gen_helper_float_rsqrt1_s(fp0, fp0); |
6220 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6221 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6222 | b6d96bed | ths | } |
6223 | 57fa1fb3 | ths | opn = "rsqrt1.s";
|
6224 | 57fa1fb3 | ths | break;
|
6225 | 57fa1fb3 | ths | case FOP(31, 16): |
6226 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6227 | b6d96bed | ths | { |
6228 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6229 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
6230 | b6d96bed | ths | |
6231 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6232 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
6233 | a7812ae4 | pbrook | gen_helper_float_rsqrt2_s(fp0, fp0, fp1); |
6234 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
6235 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6236 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6237 | b6d96bed | ths | } |
6238 | 57fa1fb3 | ths | opn = "rsqrt2.s";
|
6239 | 57fa1fb3 | ths | break;
|
6240 | 5a5012ec | ths | case FOP(33, 16): |
6241 | 5e755519 | ths | check_cp1_registers(ctx, fd); |
6242 | b6d96bed | ths | { |
6243 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6244 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6245 | b6d96bed | ths | |
6246 | b6d96bed | ths | gen_load_fpr32(fp32, fs); |
6247 | a7812ae4 | pbrook | gen_helper_float_cvtd_s(fp64, fp32); |
6248 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6249 | b6d96bed | ths | gen_store_fpr64(ctx, fp64, fd); |
6250 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6251 | b6d96bed | ths | } |
6252 | 5a5012ec | ths | opn = "cvt.d.s";
|
6253 | 5a5012ec | ths | break;
|
6254 | 5a5012ec | ths | case FOP(36, 16): |
6255 | b6d96bed | ths | { |
6256 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6257 | b6d96bed | ths | |
6258 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6259 | a7812ae4 | pbrook | gen_helper_float_cvtw_s(fp0, fp0); |
6260 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6261 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6262 | b6d96bed | ths | } |
6263 | 5a5012ec | ths | opn = "cvt.w.s";
|
6264 | 5a5012ec | ths | break;
|
6265 | 5a5012ec | ths | case FOP(37, 16): |
6266 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6267 | b6d96bed | ths | { |
6268 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6269 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6270 | b6d96bed | ths | |
6271 | b6d96bed | ths | gen_load_fpr32(fp32, fs); |
6272 | a7812ae4 | pbrook | gen_helper_float_cvtl_s(fp64, fp32); |
6273 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6274 | b6d96bed | ths | gen_store_fpr64(ctx, fp64, fd); |
6275 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6276 | b6d96bed | ths | } |
6277 | 5a5012ec | ths | opn = "cvt.l.s";
|
6278 | 5a5012ec | ths | break;
|
6279 | 5a5012ec | ths | case FOP(38, 16): |
6280 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6281 | b6d96bed | ths | { |
6282 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6283 | a7812ae4 | pbrook | TCGv_i32 fp32_0 = tcg_temp_new_i32(); |
6284 | a7812ae4 | pbrook | TCGv_i32 fp32_1 = tcg_temp_new_i32(); |
6285 | b6d96bed | ths | |
6286 | b6d96bed | ths | gen_load_fpr32(fp32_0, fs); |
6287 | b6d96bed | ths | gen_load_fpr32(fp32_1, ft); |
6288 | 36aa55dc | pbrook | tcg_gen_concat_i32_i64(fp64, fp32_0, fp32_1); |
6289 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32_1); |
6290 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32_0); |
6291 | 36aa55dc | pbrook | gen_store_fpr64(ctx, fp64, fd); |
6292 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6293 | b6d96bed | ths | } |
6294 | 5a5012ec | ths | opn = "cvt.ps.s";
|
6295 | 5a5012ec | ths | break;
|
6296 | 5a5012ec | ths | case FOP(48, 16): |
6297 | 5a5012ec | ths | case FOP(49, 16): |
6298 | 5a5012ec | ths | case FOP(50, 16): |
6299 | 5a5012ec | ths | case FOP(51, 16): |
6300 | 5a5012ec | ths | case FOP(52, 16): |
6301 | 5a5012ec | ths | case FOP(53, 16): |
6302 | 5a5012ec | ths | case FOP(54, 16): |
6303 | 5a5012ec | ths | case FOP(55, 16): |
6304 | 5a5012ec | ths | case FOP(56, 16): |
6305 | 5a5012ec | ths | case FOP(57, 16): |
6306 | 5a5012ec | ths | case FOP(58, 16): |
6307 | 5a5012ec | ths | case FOP(59, 16): |
6308 | 5a5012ec | ths | case FOP(60, 16): |
6309 | 5a5012ec | ths | case FOP(61, 16): |
6310 | 5a5012ec | ths | case FOP(62, 16): |
6311 | 5a5012ec | ths | case FOP(63, 16): |
6312 | b6d96bed | ths | { |
6313 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6314 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
6315 | b6d96bed | ths | |
6316 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6317 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
6318 | b6d96bed | ths | if (ctx->opcode & (1 << 6)) { |
6319 | b6d96bed | ths | check_cop1x(ctx); |
6320 | b6d96bed | ths | gen_cmpabs_s(func-48, fp0, fp1, cc);
|
6321 | b6d96bed | ths | opn = condnames_abs[func-48];
|
6322 | b6d96bed | ths | } else {
|
6323 | b6d96bed | ths | gen_cmp_s(func-48, fp0, fp1, cc);
|
6324 | b6d96bed | ths | opn = condnames[func-48];
|
6325 | b6d96bed | ths | } |
6326 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6327 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
6328 | 5a1e8ffb | ths | } |
6329 | 5a5012ec | ths | break;
|
6330 | 6ea83fed | bellard | case FOP(0, 17): |
6331 | 5e755519 | ths | check_cp1_registers(ctx, fs | ft | fd); |
6332 | b6d96bed | ths | { |
6333 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6334 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6335 | b6d96bed | ths | |
6336 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6337 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6338 | a7812ae4 | pbrook | gen_helper_float_add_d(fp0, fp0, fp1); |
6339 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6340 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6341 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6342 | b6d96bed | ths | } |
6343 | 6ea83fed | bellard | opn = "add.d";
|
6344 | 5a1e8ffb | ths | optype = BINOP; |
6345 | 6ea83fed | bellard | break;
|
6346 | 6ea83fed | bellard | case FOP(1, 17): |
6347 | 5e755519 | ths | check_cp1_registers(ctx, fs | ft | fd); |
6348 | b6d96bed | ths | { |
6349 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6350 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6351 | b6d96bed | ths | |
6352 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6353 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6354 | a7812ae4 | pbrook | gen_helper_float_sub_d(fp0, fp0, fp1); |
6355 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6356 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6357 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6358 | b6d96bed | ths | } |
6359 | 6ea83fed | bellard | opn = "sub.d";
|
6360 | 5a1e8ffb | ths | optype = BINOP; |
6361 | 6ea83fed | bellard | break;
|
6362 | 6ea83fed | bellard | case FOP(2, 17): |
6363 | 5e755519 | ths | check_cp1_registers(ctx, fs | ft | fd); |
6364 | b6d96bed | ths | { |
6365 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6366 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6367 | b6d96bed | ths | |
6368 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6369 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6370 | a7812ae4 | pbrook | gen_helper_float_mul_d(fp0, fp0, fp1); |
6371 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6372 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6373 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6374 | b6d96bed | ths | } |
6375 | 6ea83fed | bellard | opn = "mul.d";
|
6376 | 5a1e8ffb | ths | optype = BINOP; |
6377 | 6ea83fed | bellard | break;
|
6378 | 6ea83fed | bellard | case FOP(3, 17): |
6379 | 5e755519 | ths | check_cp1_registers(ctx, fs | ft | fd); |
6380 | b6d96bed | ths | { |
6381 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6382 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6383 | b6d96bed | ths | |
6384 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6385 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6386 | a7812ae4 | pbrook | gen_helper_float_div_d(fp0, fp0, fp1); |
6387 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6388 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6389 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6390 | b6d96bed | ths | } |
6391 | 6ea83fed | bellard | opn = "div.d";
|
6392 | 5a1e8ffb | ths | optype = BINOP; |
6393 | 6ea83fed | bellard | break;
|
6394 | 6ea83fed | bellard | case FOP(4, 17): |
6395 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
6396 | b6d96bed | ths | { |
6397 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6398 | b6d96bed | ths | |
6399 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6400 | a7812ae4 | pbrook | gen_helper_float_sqrt_d(fp0, fp0); |
6401 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6402 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6403 | b6d96bed | ths | } |
6404 | 6ea83fed | bellard | opn = "sqrt.d";
|
6405 | 6ea83fed | bellard | break;
|
6406 | 6ea83fed | bellard | case FOP(5, 17): |
6407 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
6408 | b6d96bed | ths | { |
6409 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6410 | b6d96bed | ths | |
6411 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6412 | a7812ae4 | pbrook | gen_helper_float_abs_d(fp0, fp0); |
6413 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6414 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6415 | b6d96bed | ths | } |
6416 | 6ea83fed | bellard | opn = "abs.d";
|
6417 | 6ea83fed | bellard | break;
|
6418 | 6ea83fed | bellard | case FOP(6, 17): |
6419 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
6420 | b6d96bed | ths | { |
6421 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6422 | b6d96bed | ths | |
6423 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6424 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6425 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6426 | b6d96bed | ths | } |
6427 | 6ea83fed | bellard | opn = "mov.d";
|
6428 | 6ea83fed | bellard | break;
|
6429 | 6ea83fed | bellard | case FOP(7, 17): |
6430 | 5e755519 | ths | check_cp1_registers(ctx, fs | fd); |
6431 | b6d96bed | ths | { |
6432 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6433 | b6d96bed | ths | |
6434 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6435 | a7812ae4 | pbrook | gen_helper_float_chs_d(fp0, fp0); |
6436 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6437 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6438 | b6d96bed | ths | } |
6439 | 6ea83fed | bellard | opn = "neg.d";
|
6440 | 6ea83fed | bellard | break;
|
6441 | 5a5012ec | ths | case FOP(8, 17): |
6442 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6443 | b6d96bed | ths | { |
6444 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6445 | b6d96bed | ths | |
6446 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6447 | a7812ae4 | pbrook | gen_helper_float_roundl_d(fp0, fp0); |
6448 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6449 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6450 | b6d96bed | ths | } |
6451 | 5a5012ec | ths | opn = "round.l.d";
|
6452 | 5a5012ec | ths | break;
|
6453 | 5a5012ec | ths | case FOP(9, 17): |
6454 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6455 | b6d96bed | ths | { |
6456 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6457 | b6d96bed | ths | |
6458 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6459 | a7812ae4 | pbrook | gen_helper_float_truncl_d(fp0, fp0); |
6460 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6461 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6462 | b6d96bed | ths | } |
6463 | 5a5012ec | ths | opn = "trunc.l.d";
|
6464 | 5a5012ec | ths | break;
|
6465 | 5a5012ec | ths | case FOP(10, 17): |
6466 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6467 | b6d96bed | ths | { |
6468 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6469 | b6d96bed | ths | |
6470 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6471 | a7812ae4 | pbrook | gen_helper_float_ceill_d(fp0, fp0); |
6472 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6473 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6474 | b6d96bed | ths | } |
6475 | 5a5012ec | ths | opn = "ceil.l.d";
|
6476 | 5a5012ec | ths | break;
|
6477 | 5a5012ec | ths | case FOP(11, 17): |
6478 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6479 | b6d96bed | ths | { |
6480 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6481 | b6d96bed | ths | |
6482 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6483 | a7812ae4 | pbrook | gen_helper_float_floorl_d(fp0, fp0); |
6484 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6485 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6486 | b6d96bed | ths | } |
6487 | 5a5012ec | ths | opn = "floor.l.d";
|
6488 | 5a5012ec | ths | break;
|
6489 | 6ea83fed | bellard | case FOP(12, 17): |
6490 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
6491 | b6d96bed | ths | { |
6492 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6493 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6494 | b6d96bed | ths | |
6495 | b6d96bed | ths | gen_load_fpr64(ctx, fp64, fs); |
6496 | a7812ae4 | pbrook | gen_helper_float_roundw_d(fp32, fp64); |
6497 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6498 | b6d96bed | ths | gen_store_fpr32(fp32, fd); |
6499 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6500 | b6d96bed | ths | } |
6501 | 6ea83fed | bellard | opn = "round.w.d";
|
6502 | 6ea83fed | bellard | break;
|
6503 | 6ea83fed | bellard | case FOP(13, 17): |
6504 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
6505 | b6d96bed | ths | { |
6506 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6507 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6508 | b6d96bed | ths | |
6509 | b6d96bed | ths | gen_load_fpr64(ctx, fp64, fs); |
6510 | a7812ae4 | pbrook | gen_helper_float_truncw_d(fp32, fp64); |
6511 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6512 | b6d96bed | ths | gen_store_fpr32(fp32, fd); |
6513 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6514 | b6d96bed | ths | } |
6515 | 6ea83fed | bellard | opn = "trunc.w.d";
|
6516 | 6ea83fed | bellard | break;
|
6517 | 6ea83fed | bellard | case FOP(14, 17): |
6518 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
6519 | b6d96bed | ths | { |
6520 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6521 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6522 | b6d96bed | ths | |
6523 | b6d96bed | ths | gen_load_fpr64(ctx, fp64, fs); |
6524 | a7812ae4 | pbrook | gen_helper_float_ceilw_d(fp32, fp64); |
6525 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6526 | b6d96bed | ths | gen_store_fpr32(fp32, fd); |
6527 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6528 | b6d96bed | ths | } |
6529 | 6ea83fed | bellard | opn = "ceil.w.d";
|
6530 | 6ea83fed | bellard | break;
|
6531 | 6ea83fed | bellard | case FOP(15, 17): |
6532 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
6533 | b6d96bed | ths | { |
6534 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6535 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6536 | b6d96bed | ths | |
6537 | b6d96bed | ths | gen_load_fpr64(ctx, fp64, fs); |
6538 | a7812ae4 | pbrook | gen_helper_float_floorw_d(fp32, fp64); |
6539 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6540 | b6d96bed | ths | gen_store_fpr32(fp32, fd); |
6541 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6542 | b6d96bed | ths | } |
6543 | 7a387fff | ths | opn = "floor.w.d";
|
6544 | 6ea83fed | bellard | break;
|
6545 | 5a5012ec | ths | case FOP(17, 17): |
6546 | b6d96bed | ths | gen_movcf_d(ctx, fs, fd, (ft >> 2) & 0x7, ft & 0x1); |
6547 | 5a5012ec | ths | opn = "movcf.d";
|
6548 | dd016883 | bellard | break;
|
6549 | 5a5012ec | ths | case FOP(18, 17): |
6550 | a16336e4 | ths | { |
6551 | a16336e4 | ths | int l1 = gen_new_label();
|
6552 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_new(); |
6553 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_local_new_i64(); |
6554 | a16336e4 | ths | |
6555 | 6c5c1e20 | ths | gen_load_gpr(t0, ft); |
6556 | 6c5c1e20 | ths | tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1);
|
6557 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6558 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6559 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6560 | a16336e4 | ths | gen_set_label(l1); |
6561 | 2a0ab998 | aurel32 | tcg_temp_free(t0); |
6562 | a16336e4 | ths | } |
6563 | 5a5012ec | ths | opn = "movz.d";
|
6564 | 5a5012ec | ths | break;
|
6565 | 5a5012ec | ths | case FOP(19, 17): |
6566 | a16336e4 | ths | { |
6567 | a16336e4 | ths | int l1 = gen_new_label();
|
6568 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_new(); |
6569 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_local_new_i64(); |
6570 | a16336e4 | ths | |
6571 | 6c5c1e20 | ths | gen_load_gpr(t0, ft); |
6572 | 6c5c1e20 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
6573 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6574 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6575 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6576 | a16336e4 | ths | gen_set_label(l1); |
6577 | 2a0ab998 | aurel32 | tcg_temp_free(t0); |
6578 | a16336e4 | ths | } |
6579 | 5a5012ec | ths | opn = "movn.d";
|
6580 | 6ea83fed | bellard | break;
|
6581 | 57fa1fb3 | ths | case FOP(21, 17): |
6582 | b8aa4598 | ths | check_cp1_64bitmode(ctx); |
6583 | b6d96bed | ths | { |
6584 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6585 | b6d96bed | ths | |
6586 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6587 | a7812ae4 | pbrook | gen_helper_float_recip_d(fp0, fp0); |
6588 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6589 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6590 | b6d96bed | ths | } |
6591 | 57fa1fb3 | ths | opn = "recip.d";
|
6592 | 57fa1fb3 | ths | break;
|
6593 | 57fa1fb3 | ths | case FOP(22, 17): |
6594 | b8aa4598 | ths | check_cp1_64bitmode(ctx); |
6595 | b6d96bed | ths | { |
6596 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6597 | b6d96bed | ths | |
6598 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6599 | a7812ae4 | pbrook | gen_helper_float_rsqrt_d(fp0, fp0); |
6600 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6601 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6602 | b6d96bed | ths | } |
6603 | 57fa1fb3 | ths | opn = "rsqrt.d";
|
6604 | 57fa1fb3 | ths | break;
|
6605 | 57fa1fb3 | ths | case FOP(28, 17): |
6606 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6607 | b6d96bed | ths | { |
6608 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6609 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6610 | b6d96bed | ths | |
6611 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6612 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6613 | a7812ae4 | pbrook | gen_helper_float_recip2_d(fp0, fp0, fp1); |
6614 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6615 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6616 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6617 | b6d96bed | ths | } |
6618 | 57fa1fb3 | ths | opn = "recip2.d";
|
6619 | 57fa1fb3 | ths | break;
|
6620 | 57fa1fb3 | ths | case FOP(29, 17): |
6621 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6622 | b6d96bed | ths | { |
6623 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6624 | b6d96bed | ths | |
6625 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6626 | a7812ae4 | pbrook | gen_helper_float_recip1_d(fp0, fp0); |
6627 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6628 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6629 | b6d96bed | ths | } |
6630 | 57fa1fb3 | ths | opn = "recip1.d";
|
6631 | 57fa1fb3 | ths | break;
|
6632 | 57fa1fb3 | ths | case FOP(30, 17): |
6633 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6634 | b6d96bed | ths | { |
6635 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6636 | b6d96bed | ths | |
6637 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6638 | a7812ae4 | pbrook | gen_helper_float_rsqrt1_d(fp0, fp0); |
6639 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6640 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6641 | b6d96bed | ths | } |
6642 | 57fa1fb3 | ths | opn = "rsqrt1.d";
|
6643 | 57fa1fb3 | ths | break;
|
6644 | 57fa1fb3 | ths | case FOP(31, 17): |
6645 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6646 | b6d96bed | ths | { |
6647 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6648 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6649 | b6d96bed | ths | |
6650 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6651 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6652 | a7812ae4 | pbrook | gen_helper_float_rsqrt2_d(fp0, fp0, fp1); |
6653 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6654 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6655 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6656 | b6d96bed | ths | } |
6657 | 57fa1fb3 | ths | opn = "rsqrt2.d";
|
6658 | 57fa1fb3 | ths | break;
|
6659 | 6ea83fed | bellard | case FOP(48, 17): |
6660 | 6ea83fed | bellard | case FOP(49, 17): |
6661 | 6ea83fed | bellard | case FOP(50, 17): |
6662 | 6ea83fed | bellard | case FOP(51, 17): |
6663 | 6ea83fed | bellard | case FOP(52, 17): |
6664 | 6ea83fed | bellard | case FOP(53, 17): |
6665 | 6ea83fed | bellard | case FOP(54, 17): |
6666 | 6ea83fed | bellard | case FOP(55, 17): |
6667 | 6ea83fed | bellard | case FOP(56, 17): |
6668 | 6ea83fed | bellard | case FOP(57, 17): |
6669 | 6ea83fed | bellard | case FOP(58, 17): |
6670 | 6ea83fed | bellard | case FOP(59, 17): |
6671 | 6ea83fed | bellard | case FOP(60, 17): |
6672 | 6ea83fed | bellard | case FOP(61, 17): |
6673 | 6ea83fed | bellard | case FOP(62, 17): |
6674 | 6ea83fed | bellard | case FOP(63, 17): |
6675 | b6d96bed | ths | { |
6676 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6677 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6678 | b6d96bed | ths | |
6679 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6680 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6681 | b6d96bed | ths | if (ctx->opcode & (1 << 6)) { |
6682 | b6d96bed | ths | check_cop1x(ctx); |
6683 | b6d96bed | ths | check_cp1_registers(ctx, fs | ft); |
6684 | b6d96bed | ths | gen_cmpabs_d(func-48, fp0, fp1, cc);
|
6685 | b6d96bed | ths | opn = condnames_abs[func-48];
|
6686 | b6d96bed | ths | } else {
|
6687 | b6d96bed | ths | check_cp1_registers(ctx, fs | ft); |
6688 | b6d96bed | ths | gen_cmp_d(func-48, fp0, fp1, cc);
|
6689 | b6d96bed | ths | opn = condnames[func-48];
|
6690 | b6d96bed | ths | } |
6691 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6692 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6693 | 5a1e8ffb | ths | } |
6694 | 6ea83fed | bellard | break;
|
6695 | 5a5012ec | ths | case FOP(32, 17): |
6696 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
6697 | b6d96bed | ths | { |
6698 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6699 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6700 | b6d96bed | ths | |
6701 | b6d96bed | ths | gen_load_fpr64(ctx, fp64, fs); |
6702 | a7812ae4 | pbrook | gen_helper_float_cvts_d(fp32, fp64); |
6703 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6704 | b6d96bed | ths | gen_store_fpr32(fp32, fd); |
6705 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6706 | b6d96bed | ths | } |
6707 | 5a5012ec | ths | opn = "cvt.s.d";
|
6708 | 5a5012ec | ths | break;
|
6709 | 5a5012ec | ths | case FOP(36, 17): |
6710 | 5e755519 | ths | check_cp1_registers(ctx, fs); |
6711 | b6d96bed | ths | { |
6712 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6713 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6714 | b6d96bed | ths | |
6715 | b6d96bed | ths | gen_load_fpr64(ctx, fp64, fs); |
6716 | a7812ae4 | pbrook | gen_helper_float_cvtw_d(fp32, fp64); |
6717 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6718 | b6d96bed | ths | gen_store_fpr32(fp32, fd); |
6719 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6720 | b6d96bed | ths | } |
6721 | 5a5012ec | ths | opn = "cvt.w.d";
|
6722 | 5a5012ec | ths | break;
|
6723 | 5a5012ec | ths | case FOP(37, 17): |
6724 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6725 | b6d96bed | ths | { |
6726 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6727 | b6d96bed | ths | |
6728 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6729 | a7812ae4 | pbrook | gen_helper_float_cvtl_d(fp0, fp0); |
6730 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6731 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6732 | b6d96bed | ths | } |
6733 | 5a5012ec | ths | opn = "cvt.l.d";
|
6734 | 5a5012ec | ths | break;
|
6735 | 5a5012ec | ths | case FOP(32, 20): |
6736 | b6d96bed | ths | { |
6737 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
6738 | b6d96bed | ths | |
6739 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6740 | a7812ae4 | pbrook | gen_helper_float_cvts_w(fp0, fp0); |
6741 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6742 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6743 | b6d96bed | ths | } |
6744 | 5a5012ec | ths | opn = "cvt.s.w";
|
6745 | 6ea83fed | bellard | break;
|
6746 | 5a5012ec | ths | case FOP(33, 20): |
6747 | 5e755519 | ths | check_cp1_registers(ctx, fd); |
6748 | b6d96bed | ths | { |
6749 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6750 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6751 | b6d96bed | ths | |
6752 | b6d96bed | ths | gen_load_fpr32(fp32, fs); |
6753 | a7812ae4 | pbrook | gen_helper_float_cvtd_w(fp64, fp32); |
6754 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6755 | b6d96bed | ths | gen_store_fpr64(ctx, fp64, fd); |
6756 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6757 | b6d96bed | ths | } |
6758 | 5a5012ec | ths | opn = "cvt.d.w";
|
6759 | 5a5012ec | ths | break;
|
6760 | 5a5012ec | ths | case FOP(32, 21): |
6761 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6762 | b6d96bed | ths | { |
6763 | a7812ae4 | pbrook | TCGv_i32 fp32 = tcg_temp_new_i32(); |
6764 | a7812ae4 | pbrook | TCGv_i64 fp64 = tcg_temp_new_i64(); |
6765 | b6d96bed | ths | |
6766 | b6d96bed | ths | gen_load_fpr64(ctx, fp64, fs); |
6767 | a7812ae4 | pbrook | gen_helper_float_cvts_l(fp32, fp64); |
6768 | a7812ae4 | pbrook | tcg_temp_free_i64(fp64); |
6769 | b6d96bed | ths | gen_store_fpr32(fp32, fd); |
6770 | a7812ae4 | pbrook | tcg_temp_free_i32(fp32); |
6771 | b6d96bed | ths | } |
6772 | 5a5012ec | ths | opn = "cvt.s.l";
|
6773 | 5a5012ec | ths | break;
|
6774 | 5a5012ec | ths | case FOP(33, 21): |
6775 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6776 | b6d96bed | ths | { |
6777 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6778 | b6d96bed | ths | |
6779 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6780 | a7812ae4 | pbrook | gen_helper_float_cvtd_l(fp0, fp0); |
6781 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6782 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6783 | b6d96bed | ths | } |
6784 | 5a5012ec | ths | opn = "cvt.d.l";
|
6785 | 5a5012ec | ths | break;
|
6786 | 5a5012ec | ths | case FOP(38, 20): |
6787 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6788 | b6d96bed | ths | { |
6789 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6790 | b6d96bed | ths | |
6791 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6792 | a7812ae4 | pbrook | gen_helper_float_cvtps_pw(fp0, fp0); |
6793 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6794 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6795 | b6d96bed | ths | } |
6796 | 5a5012ec | ths | opn = "cvt.ps.pw";
|
6797 | 5a5012ec | ths | break;
|
6798 | 5a5012ec | ths | case FOP(0, 22): |
6799 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6800 | b6d96bed | ths | { |
6801 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6802 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6803 | b6d96bed | ths | |
6804 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6805 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6806 | a7812ae4 | pbrook | gen_helper_float_add_ps(fp0, fp0, fp1); |
6807 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6808 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6809 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6810 | b6d96bed | ths | } |
6811 | 5a5012ec | ths | opn = "add.ps";
|
6812 | 6ea83fed | bellard | break;
|
6813 | 5a5012ec | ths | case FOP(1, 22): |
6814 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6815 | b6d96bed | ths | { |
6816 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6817 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6818 | b6d96bed | ths | |
6819 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6820 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6821 | a7812ae4 | pbrook | gen_helper_float_sub_ps(fp0, fp0, fp1); |
6822 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6823 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6824 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6825 | b6d96bed | ths | } |
6826 | 5a5012ec | ths | opn = "sub.ps";
|
6827 | 6ea83fed | bellard | break;
|
6828 | 5a5012ec | ths | case FOP(2, 22): |
6829 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6830 | b6d96bed | ths | { |
6831 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6832 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6833 | b6d96bed | ths | |
6834 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6835 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
6836 | a7812ae4 | pbrook | gen_helper_float_mul_ps(fp0, fp0, fp1); |
6837 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6838 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6839 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6840 | b6d96bed | ths | } |
6841 | 5a5012ec | ths | opn = "mul.ps";
|
6842 | 6ea83fed | bellard | break;
|
6843 | 5a5012ec | ths | case FOP(5, 22): |
6844 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6845 | b6d96bed | ths | { |
6846 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6847 | b6d96bed | ths | |
6848 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6849 | a7812ae4 | pbrook | gen_helper_float_abs_ps(fp0, fp0); |
6850 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6851 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6852 | b6d96bed | ths | } |
6853 | 5a5012ec | ths | opn = "abs.ps";
|
6854 | 6ea83fed | bellard | break;
|
6855 | 5a5012ec | ths | case FOP(6, 22): |
6856 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6857 | b6d96bed | ths | { |
6858 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6859 | b6d96bed | ths | |
6860 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6861 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6862 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6863 | b6d96bed | ths | } |
6864 | 5a5012ec | ths | opn = "mov.ps";
|
6865 | 6ea83fed | bellard | break;
|
6866 | 5a5012ec | ths | case FOP(7, 22): |
6867 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6868 | b6d96bed | ths | { |
6869 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6870 | b6d96bed | ths | |
6871 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6872 | a7812ae4 | pbrook | gen_helper_float_chs_ps(fp0, fp0); |
6873 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6874 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6875 | b6d96bed | ths | } |
6876 | 5a5012ec | ths | opn = "neg.ps";
|
6877 | 6ea83fed | bellard | break;
|
6878 | 5a5012ec | ths | case FOP(17, 22): |
6879 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6880 | b6d96bed | ths | gen_movcf_ps(fs, fd, (ft >> 2) & 0x7, ft & 0x1); |
6881 | 5a5012ec | ths | opn = "movcf.ps";
|
6882 | 6ea83fed | bellard | break;
|
6883 | 5a5012ec | ths | case FOP(18, 22): |
6884 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6885 | a16336e4 | ths | { |
6886 | a16336e4 | ths | int l1 = gen_new_label();
|
6887 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_new(); |
6888 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_local_new_i32(); |
6889 | a7812ae4 | pbrook | TCGv_i32 fph0 = tcg_temp_local_new_i32(); |
6890 | a16336e4 | ths | |
6891 | 6c5c1e20 | ths | gen_load_gpr(t0, ft); |
6892 | 6c5c1e20 | ths | tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1);
|
6893 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6894 | b6d96bed | ths | gen_load_fpr32h(fph0, fs); |
6895 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6896 | b6d96bed | ths | gen_store_fpr32h(fph0, fd); |
6897 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6898 | a7812ae4 | pbrook | tcg_temp_free_i32(fph0); |
6899 | a16336e4 | ths | gen_set_label(l1); |
6900 | 2a0ab998 | aurel32 | tcg_temp_free(t0); |
6901 | a16336e4 | ths | } |
6902 | 5a5012ec | ths | opn = "movz.ps";
|
6903 | 6ea83fed | bellard | break;
|
6904 | 5a5012ec | ths | case FOP(19, 22): |
6905 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6906 | a16336e4 | ths | { |
6907 | a16336e4 | ths | int l1 = gen_new_label();
|
6908 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_new(); |
6909 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_local_new_i32(); |
6910 | a7812ae4 | pbrook | TCGv_i32 fph0 = tcg_temp_local_new_i32(); |
6911 | a16336e4 | ths | |
6912 | 6c5c1e20 | ths | gen_load_gpr(t0, ft); |
6913 | 6c5c1e20 | ths | tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
6914 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
6915 | b6d96bed | ths | gen_load_fpr32h(fph0, fs); |
6916 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
6917 | b6d96bed | ths | gen_store_fpr32h(fph0, fd); |
6918 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
6919 | a7812ae4 | pbrook | tcg_temp_free_i32(fph0); |
6920 | a16336e4 | ths | gen_set_label(l1); |
6921 | 2a0ab998 | aurel32 | tcg_temp_free(t0); |
6922 | a16336e4 | ths | } |
6923 | 5a5012ec | ths | opn = "movn.ps";
|
6924 | 6ea83fed | bellard | break;
|
6925 | fbcc6828 | ths | case FOP(24, 22): |
6926 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6927 | b6d96bed | ths | { |
6928 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6929 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6930 | b6d96bed | ths | |
6931 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, ft); |
6932 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, fs); |
6933 | a7812ae4 | pbrook | gen_helper_float_addr_ps(fp0, fp0, fp1); |
6934 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6935 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6936 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6937 | b6d96bed | ths | } |
6938 | fbcc6828 | ths | opn = "addr.ps";
|
6939 | fbcc6828 | ths | break;
|
6940 | 57fa1fb3 | ths | case FOP(26, 22): |
6941 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6942 | b6d96bed | ths | { |
6943 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6944 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6945 | b6d96bed | ths | |
6946 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, ft); |
6947 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, fs); |
6948 | a7812ae4 | pbrook | gen_helper_float_mulr_ps(fp0, fp0, fp1); |
6949 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6950 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6951 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6952 | b6d96bed | ths | } |
6953 | 57fa1fb3 | ths | opn = "mulr.ps";
|
6954 | 57fa1fb3 | ths | break;
|
6955 | 57fa1fb3 | ths | case FOP(28, 22): |
6956 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6957 | b6d96bed | ths | { |
6958 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6959 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6960 | b6d96bed | ths | |
6961 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6962 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, fd); |
6963 | a7812ae4 | pbrook | gen_helper_float_recip2_ps(fp0, fp0, fp1); |
6964 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
6965 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6966 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6967 | b6d96bed | ths | } |
6968 | 57fa1fb3 | ths | opn = "recip2.ps";
|
6969 | 57fa1fb3 | ths | break;
|
6970 | 57fa1fb3 | ths | case FOP(29, 22): |
6971 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6972 | b6d96bed | ths | { |
6973 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6974 | b6d96bed | ths | |
6975 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6976 | a7812ae4 | pbrook | gen_helper_float_recip1_ps(fp0, fp0); |
6977 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6978 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6979 | b6d96bed | ths | } |
6980 | 57fa1fb3 | ths | opn = "recip1.ps";
|
6981 | 57fa1fb3 | ths | break;
|
6982 | 57fa1fb3 | ths | case FOP(30, 22): |
6983 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6984 | b6d96bed | ths | { |
6985 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6986 | b6d96bed | ths | |
6987 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
6988 | a7812ae4 | pbrook | gen_helper_float_rsqrt1_ps(fp0, fp0); |
6989 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
6990 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
6991 | b6d96bed | ths | } |
6992 | 57fa1fb3 | ths | opn = "rsqrt1.ps";
|
6993 | 57fa1fb3 | ths | break;
|
6994 | 57fa1fb3 | ths | case FOP(31, 22): |
6995 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
6996 | b6d96bed | ths | { |
6997 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
6998 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
6999 | b6d96bed | ths | |
7000 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7001 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7002 | a7812ae4 | pbrook | gen_helper_float_rsqrt2_ps(fp0, fp0, fp1); |
7003 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7004 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
7005 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7006 | b6d96bed | ths | } |
7007 | 57fa1fb3 | ths | opn = "rsqrt2.ps";
|
7008 | 57fa1fb3 | ths | break;
|
7009 | 5a5012ec | ths | case FOP(32, 22): |
7010 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
7011 | b6d96bed | ths | { |
7012 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7013 | b6d96bed | ths | |
7014 | b6d96bed | ths | gen_load_fpr32h(fp0, fs); |
7015 | a7812ae4 | pbrook | gen_helper_float_cvts_pu(fp0, fp0); |
7016 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
7017 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7018 | b6d96bed | ths | } |
7019 | 5a5012ec | ths | opn = "cvt.s.pu";
|
7020 | dd016883 | bellard | break;
|
7021 | 5a5012ec | ths | case FOP(36, 22): |
7022 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
7023 | b6d96bed | ths | { |
7024 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7025 | b6d96bed | ths | |
7026 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7027 | a7812ae4 | pbrook | gen_helper_float_cvtpw_ps(fp0, fp0); |
7028 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
7029 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7030 | b6d96bed | ths | } |
7031 | 5a5012ec | ths | opn = "cvt.pw.ps";
|
7032 | 6ea83fed | bellard | break;
|
7033 | 5a5012ec | ths | case FOP(40, 22): |
7034 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
7035 | b6d96bed | ths | { |
7036 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7037 | b6d96bed | ths | |
7038 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
7039 | a7812ae4 | pbrook | gen_helper_float_cvts_pl(fp0, fp0); |
7040 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
7041 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7042 | b6d96bed | ths | } |
7043 | 5a5012ec | ths | opn = "cvt.s.pl";
|
7044 | 6ea83fed | bellard | break;
|
7045 | 5a5012ec | ths | case FOP(44, 22): |
7046 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
7047 | b6d96bed | ths | { |
7048 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7049 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
7050 | b6d96bed | ths | |
7051 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
7052 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
7053 | b6d96bed | ths | gen_store_fpr32h(fp0, fd); |
7054 | b6d96bed | ths | gen_store_fpr32(fp1, fd); |
7055 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7056 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
7057 | b6d96bed | ths | } |
7058 | 5a5012ec | ths | opn = "pll.ps";
|
7059 | 6ea83fed | bellard | break;
|
7060 | 5a5012ec | ths | case FOP(45, 22): |
7061 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
7062 | b6d96bed | ths | { |
7063 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7064 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
7065 | b6d96bed | ths | |
7066 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
7067 | b6d96bed | ths | gen_load_fpr32h(fp1, ft); |
7068 | b6d96bed | ths | gen_store_fpr32(fp1, fd); |
7069 | b6d96bed | ths | gen_store_fpr32h(fp0, fd); |
7070 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7071 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
7072 | b6d96bed | ths | } |
7073 | 5a5012ec | ths | opn = "plu.ps";
|
7074 | 5a5012ec | ths | break;
|
7075 | 5a5012ec | ths | case FOP(46, 22): |
7076 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
7077 | b6d96bed | ths | { |
7078 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7079 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
7080 | b6d96bed | ths | |
7081 | b6d96bed | ths | gen_load_fpr32h(fp0, fs); |
7082 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
7083 | b6d96bed | ths | gen_store_fpr32(fp1, fd); |
7084 | b6d96bed | ths | gen_store_fpr32h(fp0, fd); |
7085 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7086 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
7087 | b6d96bed | ths | } |
7088 | 5a5012ec | ths | opn = "pul.ps";
|
7089 | 5a5012ec | ths | break;
|
7090 | 5a5012ec | ths | case FOP(47, 22): |
7091 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
7092 | b6d96bed | ths | { |
7093 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7094 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
7095 | b6d96bed | ths | |
7096 | b6d96bed | ths | gen_load_fpr32h(fp0, fs); |
7097 | b6d96bed | ths | gen_load_fpr32h(fp1, ft); |
7098 | b6d96bed | ths | gen_store_fpr32(fp1, fd); |
7099 | b6d96bed | ths | gen_store_fpr32h(fp0, fd); |
7100 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7101 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
7102 | b6d96bed | ths | } |
7103 | 5a5012ec | ths | opn = "puu.ps";
|
7104 | 5a5012ec | ths | break;
|
7105 | 5a5012ec | ths | case FOP(48, 22): |
7106 | 5a5012ec | ths | case FOP(49, 22): |
7107 | 5a5012ec | ths | case FOP(50, 22): |
7108 | 5a5012ec | ths | case FOP(51, 22): |
7109 | 5a5012ec | ths | case FOP(52, 22): |
7110 | 5a5012ec | ths | case FOP(53, 22): |
7111 | 5a5012ec | ths | case FOP(54, 22): |
7112 | 5a5012ec | ths | case FOP(55, 22): |
7113 | 5a5012ec | ths | case FOP(56, 22): |
7114 | 5a5012ec | ths | case FOP(57, 22): |
7115 | 5a5012ec | ths | case FOP(58, 22): |
7116 | 5a5012ec | ths | case FOP(59, 22): |
7117 | 5a5012ec | ths | case FOP(60, 22): |
7118 | 5a5012ec | ths | case FOP(61, 22): |
7119 | 5a5012ec | ths | case FOP(62, 22): |
7120 | 5a5012ec | ths | case FOP(63, 22): |
7121 | 5e755519 | ths | check_cp1_64bitmode(ctx); |
7122 | b6d96bed | ths | { |
7123 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7124 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
7125 | b6d96bed | ths | |
7126 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7127 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7128 | b6d96bed | ths | if (ctx->opcode & (1 << 6)) { |
7129 | b6d96bed | ths | gen_cmpabs_ps(func-48, fp0, fp1, cc);
|
7130 | b6d96bed | ths | opn = condnames_abs[func-48];
|
7131 | b6d96bed | ths | } else {
|
7132 | b6d96bed | ths | gen_cmp_ps(func-48, fp0, fp1, cc);
|
7133 | b6d96bed | ths | opn = condnames[func-48];
|
7134 | b6d96bed | ths | } |
7135 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7136 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7137 | 5a1e8ffb | ths | } |
7138 | 6ea83fed | bellard | break;
|
7139 | 5a5012ec | ths | default:
|
7140 | 923617a3 | ths | MIPS_INVAL(opn); |
7141 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
7142 | 6ea83fed | bellard | return;
|
7143 | 6ea83fed | bellard | } |
7144 | 5a1e8ffb | ths | switch (optype) {
|
7145 | 5a1e8ffb | ths | case BINOP:
|
7146 | 6ea83fed | bellard | MIPS_DEBUG("%s %s, %s, %s", opn, fregnames[fd], fregnames[fs], fregnames[ft]);
|
7147 | 5a1e8ffb | ths | break;
|
7148 | 5a1e8ffb | ths | case CMPOP:
|
7149 | 5a1e8ffb | ths | MIPS_DEBUG("%s %s,%s", opn, fregnames[fs], fregnames[ft]);
|
7150 | 5a1e8ffb | ths | break;
|
7151 | 5a1e8ffb | ths | default:
|
7152 | 6ea83fed | bellard | MIPS_DEBUG("%s %s,%s", opn, fregnames[fd], fregnames[fs]);
|
7153 | 5a1e8ffb | ths | break;
|
7154 | 5a1e8ffb | ths | } |
7155 | 6ea83fed | bellard | } |
7156 | 6af0bf9c | bellard | |
7157 | 5a5012ec | ths | /* Coprocessor 3 (FPU) */
|
7158 | 5e755519 | ths | static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, |
7159 | 5e755519 | ths | int fd, int fs, int base, int index) |
7160 | 7a387fff | ths | { |
7161 | 923617a3 | ths | const char *opn = "extended float load/store"; |
7162 | 93b12ccc | ths | int store = 0; |
7163 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
7164 | a7812ae4 | pbrook | TCGv t1 = tcg_temp_local_new(); |
7165 | 7a387fff | ths | |
7166 | 93b12ccc | ths | if (base == 0) { |
7167 | 6c5c1e20 | ths | gen_load_gpr(t0, index); |
7168 | 93b12ccc | ths | } else if (index == 0) { |
7169 | 6c5c1e20 | ths | gen_load_gpr(t0, base); |
7170 | 93b12ccc | ths | } else {
|
7171 | e9203484 | aurel32 | gen_load_gpr(t0, index); |
7172 | e9203484 | aurel32 | gen_op_addr_add(ctx, t0, cpu_gpr[base]); |
7173 | 93b12ccc | ths | } |
7174 | 5a5012ec | ths | /* Don't do NOP if destination is zero: we must perform the actual
|
7175 | ead9360e | ths | memory access. */
|
7176 | 5a5012ec | ths | switch (opc) {
|
7177 | 5a5012ec | ths | case OPC_LWXC1:
|
7178 | b8aa4598 | ths | check_cop1x(ctx); |
7179 | b6d96bed | ths | { |
7180 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7181 | b6d96bed | ths | |
7182 | a7812ae4 | pbrook | tcg_gen_qemu_ld32s(t1, t0, ctx->mem_idx); |
7183 | a7812ae4 | pbrook | tcg_gen_trunc_tl_i32(fp0, t1); |
7184 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
7185 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7186 | b6d96bed | ths | } |
7187 | 5a5012ec | ths | opn = "lwxc1";
|
7188 | 5a5012ec | ths | break;
|
7189 | 5a5012ec | ths | case OPC_LDXC1:
|
7190 | b8aa4598 | ths | check_cop1x(ctx); |
7191 | b8aa4598 | ths | check_cp1_registers(ctx, fd); |
7192 | b6d96bed | ths | { |
7193 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7194 | b6d96bed | ths | |
7195 | b6d96bed | ths | tcg_gen_qemu_ld64(fp0, t0, ctx->mem_idx); |
7196 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
7197 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7198 | b6d96bed | ths | } |
7199 | 5a5012ec | ths | opn = "ldxc1";
|
7200 | 5a5012ec | ths | break;
|
7201 | 5a5012ec | ths | case OPC_LUXC1:
|
7202 | b8aa4598 | ths | check_cp1_64bitmode(ctx); |
7203 | 6c5c1e20 | ths | tcg_gen_andi_tl(t0, t0, ~0x7);
|
7204 | b6d96bed | ths | { |
7205 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7206 | b6d96bed | ths | |
7207 | b6d96bed | ths | tcg_gen_qemu_ld64(fp0, t0, ctx->mem_idx); |
7208 | b6d96bed | ths | gen_store_fpr64(ctx, fp0, fd); |
7209 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7210 | b6d96bed | ths | } |
7211 | 5a5012ec | ths | opn = "luxc1";
|
7212 | 5a5012ec | ths | break;
|
7213 | 5a5012ec | ths | case OPC_SWXC1:
|
7214 | b8aa4598 | ths | check_cop1x(ctx); |
7215 | b6d96bed | ths | { |
7216 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7217 | b6d96bed | ths | |
7218 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
7219 | a7812ae4 | pbrook | tcg_gen_extu_i32_tl(t1, fp0); |
7220 | a7812ae4 | pbrook | tcg_gen_qemu_st32(t1, t0, ctx->mem_idx); |
7221 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7222 | b6d96bed | ths | } |
7223 | 5a5012ec | ths | opn = "swxc1";
|
7224 | 93b12ccc | ths | store = 1;
|
7225 | 5a5012ec | ths | break;
|
7226 | 5a5012ec | ths | case OPC_SDXC1:
|
7227 | b8aa4598 | ths | check_cop1x(ctx); |
7228 | b8aa4598 | ths | check_cp1_registers(ctx, fs); |
7229 | b6d96bed | ths | { |
7230 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7231 | b6d96bed | ths | |
7232 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7233 | b6d96bed | ths | tcg_gen_qemu_st64(fp0, t0, ctx->mem_idx); |
7234 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7235 | b6d96bed | ths | } |
7236 | 5a5012ec | ths | opn = "sdxc1";
|
7237 | 93b12ccc | ths | store = 1;
|
7238 | 5a5012ec | ths | break;
|
7239 | 5a5012ec | ths | case OPC_SUXC1:
|
7240 | b8aa4598 | ths | check_cp1_64bitmode(ctx); |
7241 | 6c5c1e20 | ths | tcg_gen_andi_tl(t0, t0, ~0x7);
|
7242 | b6d96bed | ths | { |
7243 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7244 | b6d96bed | ths | |
7245 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7246 | b6d96bed | ths | tcg_gen_qemu_st64(fp0, t0, ctx->mem_idx); |
7247 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7248 | b6d96bed | ths | } |
7249 | 5a5012ec | ths | opn = "suxc1";
|
7250 | 93b12ccc | ths | store = 1;
|
7251 | 5a5012ec | ths | break;
|
7252 | 5a5012ec | ths | default:
|
7253 | 923617a3 | ths | MIPS_INVAL(opn); |
7254 | 5a5012ec | ths | generate_exception(ctx, EXCP_RI); |
7255 | 6c5c1e20 | ths | tcg_temp_free(t0); |
7256 | 6c5c1e20 | ths | tcg_temp_free(t1); |
7257 | 5a5012ec | ths | return;
|
7258 | 5a5012ec | ths | } |
7259 | 6c5c1e20 | ths | tcg_temp_free(t0); |
7260 | 6c5c1e20 | ths | tcg_temp_free(t1); |
7261 | 93b12ccc | ths | MIPS_DEBUG("%s %s, %s(%s)", opn, fregnames[store ? fs : fd],
|
7262 | 93b12ccc | ths | regnames[index], regnames[base]); |
7263 | 5a5012ec | ths | } |
7264 | 5a5012ec | ths | |
7265 | 5e755519 | ths | static void gen_flt3_arith (DisasContext *ctx, uint32_t opc, |
7266 | 5e755519 | ths | int fd, int fr, int fs, int ft) |
7267 | 5a5012ec | ths | { |
7268 | 923617a3 | ths | const char *opn = "flt3_arith"; |
7269 | 5a5012ec | ths | |
7270 | 5a5012ec | ths | switch (opc) {
|
7271 | 5a5012ec | ths | case OPC_ALNV_PS:
|
7272 | b8aa4598 | ths | check_cp1_64bitmode(ctx); |
7273 | a16336e4 | ths | { |
7274 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
7275 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_local_new_i32(); |
7276 | a7812ae4 | pbrook | TCGv_i32 fph0 = tcg_temp_local_new_i32(); |
7277 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_local_new_i32(); |
7278 | a7812ae4 | pbrook | TCGv_i32 fph1 = tcg_temp_local_new_i32(); |
7279 | a16336e4 | ths | int l1 = gen_new_label();
|
7280 | a16336e4 | ths | int l2 = gen_new_label();
|
7281 | a16336e4 | ths | |
7282 | 6c5c1e20 | ths | gen_load_gpr(t0, fr); |
7283 | 6c5c1e20 | ths | tcg_gen_andi_tl(t0, t0, 0x7);
|
7284 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
7285 | b6d96bed | ths | gen_load_fpr32h(fph0, fs); |
7286 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
7287 | b6d96bed | ths | gen_load_fpr32h(fph1, ft); |
7288 | 6c5c1e20 | ths | |
7289 | 6c5c1e20 | ths | tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1);
|
7290 | b6d96bed | ths | gen_store_fpr32(fp0, fd); |
7291 | b6d96bed | ths | gen_store_fpr32h(fph0, fd); |
7292 | a16336e4 | ths | tcg_gen_br(l2); |
7293 | a16336e4 | ths | gen_set_label(l1); |
7294 | 6c5c1e20 | ths | tcg_gen_brcondi_tl(TCG_COND_NE, t0, 4, l2);
|
7295 | 6c5c1e20 | ths | tcg_temp_free(t0); |
7296 | a16336e4 | ths | #ifdef TARGET_WORDS_BIGENDIAN
|
7297 | b6d96bed | ths | gen_store_fpr32(fph1, fd); |
7298 | b6d96bed | ths | gen_store_fpr32h(fp0, fd); |
7299 | a16336e4 | ths | #else
|
7300 | b6d96bed | ths | gen_store_fpr32(fph0, fd); |
7301 | b6d96bed | ths | gen_store_fpr32h(fp1, fd); |
7302 | a16336e4 | ths | #endif
|
7303 | a16336e4 | ths | gen_set_label(l2); |
7304 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7305 | a7812ae4 | pbrook | tcg_temp_free_i32(fph0); |
7306 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
7307 | a7812ae4 | pbrook | tcg_temp_free_i32(fph1); |
7308 | a16336e4 | ths | } |
7309 | 5a5012ec | ths | opn = "alnv.ps";
|
7310 | 5a5012ec | ths | break;
|
7311 | 5a5012ec | ths | case OPC_MADD_S:
|
7312 | b8aa4598 | ths | check_cop1x(ctx); |
7313 | b6d96bed | ths | { |
7314 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7315 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
7316 | a7812ae4 | pbrook | TCGv_i32 fp2 = tcg_temp_new_i32(); |
7317 | b6d96bed | ths | |
7318 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
7319 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
7320 | b6d96bed | ths | gen_load_fpr32(fp2, fr); |
7321 | a7812ae4 | pbrook | gen_helper_float_muladd_s(fp2, fp0, fp1, fp2); |
7322 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7323 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
7324 | b6d96bed | ths | gen_store_fpr32(fp2, fd); |
7325 | a7812ae4 | pbrook | tcg_temp_free_i32(fp2); |
7326 | b6d96bed | ths | } |
7327 | 5a5012ec | ths | opn = "madd.s";
|
7328 | 5a5012ec | ths | break;
|
7329 | 5a5012ec | ths | case OPC_MADD_D:
|
7330 | b8aa4598 | ths | check_cop1x(ctx); |
7331 | b8aa4598 | ths | check_cp1_registers(ctx, fd | fs | ft | fr); |
7332 | b6d96bed | ths | { |
7333 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7334 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
7335 | a7812ae4 | pbrook | TCGv_i64 fp2 = tcg_temp_new_i64(); |
7336 | b6d96bed | ths | |
7337 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7338 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7339 | b6d96bed | ths | gen_load_fpr64(ctx, fp2, fr); |
7340 | a7812ae4 | pbrook | gen_helper_float_muladd_d(fp2, fp0, fp1, fp2); |
7341 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7342 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7343 | b6d96bed | ths | gen_store_fpr64(ctx, fp2, fd); |
7344 | a7812ae4 | pbrook | tcg_temp_free_i64(fp2); |
7345 | b6d96bed | ths | } |
7346 | 5a5012ec | ths | opn = "madd.d";
|
7347 | 5a5012ec | ths | break;
|
7348 | 5a5012ec | ths | case OPC_MADD_PS:
|
7349 | b8aa4598 | ths | check_cp1_64bitmode(ctx); |
7350 | b6d96bed | ths | { |
7351 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7352 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
7353 | a7812ae4 | pbrook | TCGv_i64 fp2 = tcg_temp_new_i64(); |
7354 | b6d96bed | ths | |
7355 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7356 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7357 | b6d96bed | ths | gen_load_fpr64(ctx, fp2, fr); |
7358 | a7812ae4 | pbrook | gen_helper_float_muladd_ps(fp2, fp0, fp1, fp2); |
7359 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7360 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7361 | b6d96bed | ths | gen_store_fpr64(ctx, fp2, fd); |
7362 | a7812ae4 | pbrook | tcg_temp_free_i64(fp2); |
7363 | b6d96bed | ths | } |
7364 | 5a5012ec | ths | opn = "madd.ps";
|
7365 | 5a5012ec | ths | break;
|
7366 | 5a5012ec | ths | case OPC_MSUB_S:
|
7367 | b8aa4598 | ths | check_cop1x(ctx); |
7368 | b6d96bed | ths | { |
7369 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7370 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
7371 | a7812ae4 | pbrook | TCGv_i32 fp2 = tcg_temp_new_i32(); |
7372 | b6d96bed | ths | |
7373 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
7374 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
7375 | b6d96bed | ths | gen_load_fpr32(fp2, fr); |
7376 | a7812ae4 | pbrook | gen_helper_float_mulsub_s(fp2, fp0, fp1, fp2); |
7377 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7378 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
7379 | b6d96bed | ths | gen_store_fpr32(fp2, fd); |
7380 | a7812ae4 | pbrook | tcg_temp_free_i32(fp2); |
7381 | b6d96bed | ths | } |
7382 | 5a5012ec | ths | opn = "msub.s";
|
7383 | 5a5012ec | ths | break;
|
7384 | 5a5012ec | ths | case OPC_MSUB_D:
|
7385 | b8aa4598 | ths | check_cop1x(ctx); |
7386 | b8aa4598 | ths | check_cp1_registers(ctx, fd | fs | ft | fr); |
7387 | b6d96bed | ths | { |
7388 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7389 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
7390 | a7812ae4 | pbrook | TCGv_i64 fp2 = tcg_temp_new_i64(); |
7391 | b6d96bed | ths | |
7392 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7393 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7394 | b6d96bed | ths | gen_load_fpr64(ctx, fp2, fr); |
7395 | a7812ae4 | pbrook | gen_helper_float_mulsub_d(fp2, fp0, fp1, fp2); |
7396 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7397 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7398 | b6d96bed | ths | gen_store_fpr64(ctx, fp2, fd); |
7399 | a7812ae4 | pbrook | tcg_temp_free_i64(fp2); |
7400 | b6d96bed | ths | } |
7401 | 5a5012ec | ths | opn = "msub.d";
|
7402 | 5a5012ec | ths | break;
|
7403 | 5a5012ec | ths | case OPC_MSUB_PS:
|
7404 | b8aa4598 | ths | check_cp1_64bitmode(ctx); |
7405 | b6d96bed | ths | { |
7406 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7407 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
7408 | a7812ae4 | pbrook | TCGv_i64 fp2 = tcg_temp_new_i64(); |
7409 | b6d96bed | ths | |
7410 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7411 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7412 | b6d96bed | ths | gen_load_fpr64(ctx, fp2, fr); |
7413 | a7812ae4 | pbrook | gen_helper_float_mulsub_ps(fp2, fp0, fp1, fp2); |
7414 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7415 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7416 | b6d96bed | ths | gen_store_fpr64(ctx, fp2, fd); |
7417 | a7812ae4 | pbrook | tcg_temp_free_i64(fp2); |
7418 | b6d96bed | ths | } |
7419 | 5a5012ec | ths | opn = "msub.ps";
|
7420 | 5a5012ec | ths | break;
|
7421 | 5a5012ec | ths | case OPC_NMADD_S:
|
7422 | b8aa4598 | ths | check_cop1x(ctx); |
7423 | b6d96bed | ths | { |
7424 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7425 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
7426 | a7812ae4 | pbrook | TCGv_i32 fp2 = tcg_temp_new_i32(); |
7427 | b6d96bed | ths | |
7428 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
7429 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
7430 | b6d96bed | ths | gen_load_fpr32(fp2, fr); |
7431 | a7812ae4 | pbrook | gen_helper_float_nmuladd_s(fp2, fp0, fp1, fp2); |
7432 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7433 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
7434 | b6d96bed | ths | gen_store_fpr32(fp2, fd); |
7435 | a7812ae4 | pbrook | tcg_temp_free_i32(fp2); |
7436 | b6d96bed | ths | } |
7437 | 5a5012ec | ths | opn = "nmadd.s";
|
7438 | 5a5012ec | ths | break;
|
7439 | 5a5012ec | ths | case OPC_NMADD_D:
|
7440 | b8aa4598 | ths | check_cop1x(ctx); |
7441 | b8aa4598 | ths | check_cp1_registers(ctx, fd | fs | ft | fr); |
7442 | b6d96bed | ths | { |
7443 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7444 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
7445 | a7812ae4 | pbrook | TCGv_i64 fp2 = tcg_temp_new_i64(); |
7446 | b6d96bed | ths | |
7447 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7448 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7449 | b6d96bed | ths | gen_load_fpr64(ctx, fp2, fr); |
7450 | a7812ae4 | pbrook | gen_helper_float_nmuladd_d(fp2, fp0, fp1, fp2); |
7451 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7452 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7453 | b6d96bed | ths | gen_store_fpr64(ctx, fp2, fd); |
7454 | a7812ae4 | pbrook | tcg_temp_free_i64(fp2); |
7455 | b6d96bed | ths | } |
7456 | 5a5012ec | ths | opn = "nmadd.d";
|
7457 | 5a5012ec | ths | break;
|
7458 | 5a5012ec | ths | case OPC_NMADD_PS:
|
7459 | b8aa4598 | ths | check_cp1_64bitmode(ctx); |
7460 | b6d96bed | ths | { |
7461 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7462 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
7463 | a7812ae4 | pbrook | TCGv_i64 fp2 = tcg_temp_new_i64(); |
7464 | b6d96bed | ths | |
7465 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7466 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7467 | b6d96bed | ths | gen_load_fpr64(ctx, fp2, fr); |
7468 | a7812ae4 | pbrook | gen_helper_float_nmuladd_ps(fp2, fp0, fp1, fp2); |
7469 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7470 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7471 | b6d96bed | ths | gen_store_fpr64(ctx, fp2, fd); |
7472 | a7812ae4 | pbrook | tcg_temp_free_i64(fp2); |
7473 | b6d96bed | ths | } |
7474 | 5a5012ec | ths | opn = "nmadd.ps";
|
7475 | 5a5012ec | ths | break;
|
7476 | 5a5012ec | ths | case OPC_NMSUB_S:
|
7477 | b8aa4598 | ths | check_cop1x(ctx); |
7478 | b6d96bed | ths | { |
7479 | a7812ae4 | pbrook | TCGv_i32 fp0 = tcg_temp_new_i32(); |
7480 | a7812ae4 | pbrook | TCGv_i32 fp1 = tcg_temp_new_i32(); |
7481 | a7812ae4 | pbrook | TCGv_i32 fp2 = tcg_temp_new_i32(); |
7482 | b6d96bed | ths | |
7483 | b6d96bed | ths | gen_load_fpr32(fp0, fs); |
7484 | b6d96bed | ths | gen_load_fpr32(fp1, ft); |
7485 | b6d96bed | ths | gen_load_fpr32(fp2, fr); |
7486 | a7812ae4 | pbrook | gen_helper_float_nmulsub_s(fp2, fp0, fp1, fp2); |
7487 | a7812ae4 | pbrook | tcg_temp_free_i32(fp0); |
7488 | a7812ae4 | pbrook | tcg_temp_free_i32(fp1); |
7489 | b6d96bed | ths | gen_store_fpr32(fp2, fd); |
7490 | a7812ae4 | pbrook | tcg_temp_free_i32(fp2); |
7491 | b6d96bed | ths | } |
7492 | 5a5012ec | ths | opn = "nmsub.s";
|
7493 | 5a5012ec | ths | break;
|
7494 | 5a5012ec | ths | case OPC_NMSUB_D:
|
7495 | b8aa4598 | ths | check_cop1x(ctx); |
7496 | b8aa4598 | ths | check_cp1_registers(ctx, fd | fs | ft | fr); |
7497 | b6d96bed | ths | { |
7498 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7499 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
7500 | a7812ae4 | pbrook | TCGv_i64 fp2 = tcg_temp_new_i64(); |
7501 | b6d96bed | ths | |
7502 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7503 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7504 | b6d96bed | ths | gen_load_fpr64(ctx, fp2, fr); |
7505 | a7812ae4 | pbrook | gen_helper_float_nmulsub_d(fp2, fp0, fp1, fp2); |
7506 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7507 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7508 | b6d96bed | ths | gen_store_fpr64(ctx, fp2, fd); |
7509 | a7812ae4 | pbrook | tcg_temp_free_i64(fp2); |
7510 | b6d96bed | ths | } |
7511 | 5a5012ec | ths | opn = "nmsub.d";
|
7512 | 5a5012ec | ths | break;
|
7513 | 5a5012ec | ths | case OPC_NMSUB_PS:
|
7514 | b8aa4598 | ths | check_cp1_64bitmode(ctx); |
7515 | b6d96bed | ths | { |
7516 | a7812ae4 | pbrook | TCGv_i64 fp0 = tcg_temp_new_i64(); |
7517 | a7812ae4 | pbrook | TCGv_i64 fp1 = tcg_temp_new_i64(); |
7518 | a7812ae4 | pbrook | TCGv_i64 fp2 = tcg_temp_new_i64(); |
7519 | b6d96bed | ths | |
7520 | b6d96bed | ths | gen_load_fpr64(ctx, fp0, fs); |
7521 | b6d96bed | ths | gen_load_fpr64(ctx, fp1, ft); |
7522 | b6d96bed | ths | gen_load_fpr64(ctx, fp2, fr); |
7523 | a7812ae4 | pbrook | gen_helper_float_nmulsub_ps(fp2, fp0, fp1, fp2); |
7524 | a7812ae4 | pbrook | tcg_temp_free_i64(fp0); |
7525 | a7812ae4 | pbrook | tcg_temp_free_i64(fp1); |
7526 | b6d96bed | ths | gen_store_fpr64(ctx, fp2, fd); |
7527 | a7812ae4 | pbrook | tcg_temp_free_i64(fp2); |
7528 | b6d96bed | ths | } |
7529 | 5a5012ec | ths | opn = "nmsub.ps";
|
7530 | 5a5012ec | ths | break;
|
7531 | 923617a3 | ths | default:
|
7532 | 923617a3 | ths | MIPS_INVAL(opn); |
7533 | 5a5012ec | ths | generate_exception (ctx, EXCP_RI); |
7534 | 5a5012ec | ths | return;
|
7535 | 5a5012ec | ths | } |
7536 | 5a5012ec | ths | MIPS_DEBUG("%s %s, %s, %s, %s", opn, fregnames[fd], fregnames[fr],
|
7537 | 5a5012ec | ths | fregnames[fs], fregnames[ft]); |
7538 | 7a387fff | ths | } |
7539 | 7a387fff | ths | |
7540 | 7a387fff | ths | /* ISA extensions (ASEs) */
|
7541 | 6af0bf9c | bellard | /* MIPS16 extension to MIPS32 */
|
7542 | 6af0bf9c | bellard | /* SmartMIPS extension to MIPS32 */
|
7543 | 6af0bf9c | bellard | |
7544 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
7545 | 6af0bf9c | bellard | |
7546 | 6af0bf9c | bellard | /* MDMX extension to MIPS64 */
|
7547 | 6af0bf9c | bellard | |
7548 | 6af0bf9c | bellard | #endif
|
7549 | 6af0bf9c | bellard | |
7550 | 36d23958 | ths | static void decode_opc (CPUState *env, DisasContext *ctx) |
7551 | 6af0bf9c | bellard | { |
7552 | 6af0bf9c | bellard | int32_t offset; |
7553 | 6af0bf9c | bellard | int rs, rt, rd, sa;
|
7554 | 7a387fff | ths | uint32_t op, op1, op2; |
7555 | 6af0bf9c | bellard | int16_t imm; |
7556 | 6af0bf9c | bellard | |
7557 | d796321b | bellard | /* make sure instructions are on a word boundary */
|
7558 | d796321b | bellard | if (ctx->pc & 0x3) { |
7559 | cbeb0857 | ths | env->CP0_BadVAddr = ctx->pc; |
7560 | d796321b | bellard | generate_exception(ctx, EXCP_AdEL); |
7561 | d796321b | bellard | return;
|
7562 | d796321b | bellard | } |
7563 | d796321b | bellard | |
7564 | 8e9ade68 | ths | /* Handle blikely not taken case */
|
7565 | 4ad40f36 | bellard | if ((ctx->hflags & MIPS_HFLAG_BMASK) == MIPS_HFLAG_BL) {
|
7566 | 8e9ade68 | ths | int l1 = gen_new_label();
|
7567 | 8e9ade68 | ths | |
7568 | 3594c774 | ths | MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4); |
7569 | 1ba74fb8 | aurel32 | tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, l1);
|
7570 | 08ba7963 | ths | { |
7571 | a7812ae4 | pbrook | TCGv_i32 r_tmp = tcg_temp_new_i32(); |
7572 | 08ba7963 | ths | |
7573 | d077b6f7 | ths | tcg_gen_movi_i32(r_tmp, ctx->hflags & ~MIPS_HFLAG_BMASK); |
7574 | d077b6f7 | ths | tcg_gen_st_i32(r_tmp, cpu_env, offsetof(CPUState, hflags)); |
7575 | a7812ae4 | pbrook | tcg_temp_free_i32(r_tmp); |
7576 | 08ba7963 | ths | } |
7577 | 5a5012ec | ths | gen_goto_tb(ctx, 1, ctx->pc + 4); |
7578 | 5a5012ec | ths | gen_set_label(l1); |
7579 | 6af0bf9c | bellard | } |
7580 | 7a387fff | ths | op = MASK_OP_MAJOR(ctx->opcode); |
7581 | 7a387fff | ths | rs = (ctx->opcode >> 21) & 0x1f; |
7582 | 7a387fff | ths | rt = (ctx->opcode >> 16) & 0x1f; |
7583 | 7a387fff | ths | rd = (ctx->opcode >> 11) & 0x1f; |
7584 | 7a387fff | ths | sa = (ctx->opcode >> 6) & 0x1f; |
7585 | 6af0bf9c | bellard | imm = (int16_t)ctx->opcode; |
7586 | 6af0bf9c | bellard | switch (op) {
|
7587 | 7a387fff | ths | case OPC_SPECIAL:
|
7588 | 7a387fff | ths | op1 = MASK_SPECIAL(ctx->opcode); |
7589 | 6af0bf9c | bellard | switch (op1) {
|
7590 | 7a387fff | ths | case OPC_SLL: /* Arithmetic with immediate */ |
7591 | 7a387fff | ths | case OPC_SRL ... OPC_SRA:
|
7592 | e189e748 | ths | gen_arith_imm(env, ctx, op1, rd, rt, sa); |
7593 | 7a387fff | ths | break;
|
7594 | e189e748 | ths | case OPC_MOVZ ... OPC_MOVN:
|
7595 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); |
7596 | 7a387fff | ths | case OPC_SLLV: /* Arithmetic */ |
7597 | 7a387fff | ths | case OPC_SRLV ... OPC_SRAV:
|
7598 | 7a387fff | ths | case OPC_ADD ... OPC_NOR:
|
7599 | 7a387fff | ths | case OPC_SLT ... OPC_SLTU:
|
7600 | e189e748 | ths | gen_arith(env, ctx, op1, rd, rs, rt); |
7601 | 7a387fff | ths | break;
|
7602 | 7a387fff | ths | case OPC_MULT ... OPC_DIVU:
|
7603 | e9c71dd1 | ths | if (sa) {
|
7604 | e9c71dd1 | ths | check_insn(env, ctx, INSN_VR54XX); |
7605 | e9c71dd1 | ths | op1 = MASK_MUL_VR54XX(ctx->opcode); |
7606 | e9c71dd1 | ths | gen_mul_vr54xx(ctx, op1, rd, rs, rt); |
7607 | e9c71dd1 | ths | } else
|
7608 | e9c71dd1 | ths | gen_muldiv(ctx, op1, rs, rt); |
7609 | 7a387fff | ths | break;
|
7610 | 7a387fff | ths | case OPC_JR ... OPC_JALR:
|
7611 | 7a387fff | ths | gen_compute_branch(ctx, op1, rs, rd, sa); |
7612 | 6af0bf9c | bellard | return;
|
7613 | 7a387fff | ths | case OPC_TGE ... OPC_TEQ: /* Traps */ |
7614 | 7a387fff | ths | case OPC_TNE:
|
7615 | 7a387fff | ths | gen_trap(ctx, op1, rs, rt, -1);
|
7616 | 6af0bf9c | bellard | break;
|
7617 | 7a387fff | ths | case OPC_MFHI: /* Move from HI/LO */ |
7618 | 7a387fff | ths | case OPC_MFLO:
|
7619 | 7a387fff | ths | gen_HILO(ctx, op1, rd); |
7620 | 6af0bf9c | bellard | break;
|
7621 | 7a387fff | ths | case OPC_MTHI:
|
7622 | 7a387fff | ths | case OPC_MTLO: /* Move to HI/LO */ |
7623 | 7a387fff | ths | gen_HILO(ctx, op1, rs); |
7624 | 6af0bf9c | bellard | break;
|
7625 | b48cfdff | ths | case OPC_PMON: /* Pmon entry point, also R4010 selsl */ |
7626 | b48cfdff | ths | #ifdef MIPS_STRICT_STANDARD
|
7627 | b48cfdff | ths | MIPS_INVAL("PMON / selsl");
|
7628 | b48cfdff | ths | generate_exception(ctx, EXCP_RI); |
7629 | b48cfdff | ths | #else
|
7630 | a7812ae4 | pbrook | gen_helper_0i(pmon, sa); |
7631 | b48cfdff | ths | #endif
|
7632 | 7a387fff | ths | break;
|
7633 | 7a387fff | ths | case OPC_SYSCALL:
|
7634 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_SYSCALL); |
7635 | 6af0bf9c | bellard | break;
|
7636 | 7a387fff | ths | case OPC_BREAK:
|
7637 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_BREAK); |
7638 | 6af0bf9c | bellard | break;
|
7639 | b48cfdff | ths | case OPC_SPIM:
|
7640 | b48cfdff | ths | #ifdef MIPS_STRICT_STANDARD
|
7641 | b48cfdff | ths | MIPS_INVAL("SPIM");
|
7642 | b48cfdff | ths | generate_exception(ctx, EXCP_RI); |
7643 | b48cfdff | ths | #else
|
7644 | 7a387fff | ths | /* Implemented as RI exception for now. */
|
7645 | 7a387fff | ths | MIPS_INVAL("spim (unofficial)");
|
7646 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
7647 | b48cfdff | ths | #endif
|
7648 | 6af0bf9c | bellard | break;
|
7649 | 7a387fff | ths | case OPC_SYNC:
|
7650 | ead9360e | ths | /* Treat as NOP. */
|
7651 | 6af0bf9c | bellard | break;
|
7652 | 4ad40f36 | bellard | |
7653 | 7a387fff | ths | case OPC_MOVCI:
|
7654 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); |
7655 | 36d23958 | ths | if (env->CP0_Config1 & (1 << CP0C1_FP)) { |
7656 | e397ee33 | ths | save_cpu_state(ctx, 1);
|
7657 | 5e755519 | ths | check_cp1_enabled(ctx); |
7658 | 36d23958 | ths | gen_movci(ctx, rd, rs, (ctx->opcode >> 18) & 0x7, |
7659 | 36d23958 | ths | (ctx->opcode >> 16) & 1); |
7660 | 36d23958 | ths | } else {
|
7661 | e397ee33 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
7662 | 36d23958 | ths | } |
7663 | 4ad40f36 | bellard | break;
|
7664 | 4ad40f36 | bellard | |
7665 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
7666 | 7a387fff | ths | /* MIPS64 specific opcodes */
|
7667 | 7a387fff | ths | case OPC_DSLL:
|
7668 | 7a387fff | ths | case OPC_DSRL ... OPC_DSRA:
|
7669 | 7a387fff | ths | case OPC_DSLL32:
|
7670 | 7a387fff | ths | case OPC_DSRL32 ... OPC_DSRA32:
|
7671 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
7672 | e189e748 | ths | check_mips_64(ctx); |
7673 | e189e748 | ths | gen_arith_imm(env, ctx, op1, rd, rt, sa); |
7674 | 7a387fff | ths | break;
|
7675 | 7a387fff | ths | case OPC_DSLLV:
|
7676 | 7a387fff | ths | case OPC_DSRLV ... OPC_DSRAV:
|
7677 | 7a387fff | ths | case OPC_DADD ... OPC_DSUBU:
|
7678 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
7679 | e189e748 | ths | check_mips_64(ctx); |
7680 | e189e748 | ths | gen_arith(env, ctx, op1, rd, rs, rt); |
7681 | 7a387fff | ths | break;
|
7682 | 7a387fff | ths | case OPC_DMULT ... OPC_DDIVU:
|
7683 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
7684 | e189e748 | ths | check_mips_64(ctx); |
7685 | 7a387fff | ths | gen_muldiv(ctx, op1, rs, rt); |
7686 | 7a387fff | ths | break;
|
7687 | 6af0bf9c | bellard | #endif
|
7688 | 6af0bf9c | bellard | default: /* Invalid */ |
7689 | 6af0bf9c | bellard | MIPS_INVAL("special");
|
7690 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
7691 | 6af0bf9c | bellard | break;
|
7692 | 6af0bf9c | bellard | } |
7693 | 6af0bf9c | bellard | break;
|
7694 | 7a387fff | ths | case OPC_SPECIAL2:
|
7695 | 7a387fff | ths | op1 = MASK_SPECIAL2(ctx->opcode); |
7696 | 6af0bf9c | bellard | switch (op1) {
|
7697 | 7a387fff | ths | case OPC_MADD ... OPC_MADDU: /* Multiply and add/sub */ |
7698 | 7a387fff | ths | case OPC_MSUB ... OPC_MSUBU:
|
7699 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
7700 | 7a387fff | ths | gen_muldiv(ctx, op1, rs, rt); |
7701 | 6af0bf9c | bellard | break;
|
7702 | 7a387fff | ths | case OPC_MUL:
|
7703 | e189e748 | ths | gen_arith(env, ctx, op1, rd, rs, rt); |
7704 | 6af0bf9c | bellard | break;
|
7705 | 20e1fb52 | aurel32 | case OPC_CLO:
|
7706 | 20e1fb52 | aurel32 | case OPC_CLZ:
|
7707 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
7708 | 7a387fff | ths | gen_cl(ctx, op1, rd, rs); |
7709 | 6af0bf9c | bellard | break;
|
7710 | 7a387fff | ths | case OPC_SDBBP:
|
7711 | 6af0bf9c | bellard | /* XXX: not clear which exception should be raised
|
7712 | 6af0bf9c | bellard | * when in debug mode...
|
7713 | 6af0bf9c | bellard | */
|
7714 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32); |
7715 | 6af0bf9c | bellard | if (!(ctx->hflags & MIPS_HFLAG_DM)) {
|
7716 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_DBp); |
7717 | 6af0bf9c | bellard | } else {
|
7718 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_DBp); |
7719 | 6af0bf9c | bellard | } |
7720 | ead9360e | ths | /* Treat as NOP. */
|
7721 | 6af0bf9c | bellard | break;
|
7722 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
7723 | 20e1fb52 | aurel32 | case OPC_DCLO:
|
7724 | 20e1fb52 | aurel32 | case OPC_DCLZ:
|
7725 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64); |
7726 | e189e748 | ths | check_mips_64(ctx); |
7727 | 7a387fff | ths | gen_cl(ctx, op1, rd, rs); |
7728 | 7a387fff | ths | break;
|
7729 | 7a387fff | ths | #endif
|
7730 | 6af0bf9c | bellard | default: /* Invalid */ |
7731 | 6af0bf9c | bellard | MIPS_INVAL("special2");
|
7732 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
7733 | 6af0bf9c | bellard | break;
|
7734 | 6af0bf9c | bellard | } |
7735 | 6af0bf9c | bellard | break;
|
7736 | 7a387fff | ths | case OPC_SPECIAL3:
|
7737 | 2b0233ab | ths | op1 = MASK_SPECIAL3(ctx->opcode); |
7738 | 2b0233ab | ths | switch (op1) {
|
7739 | 2b0233ab | ths | case OPC_EXT:
|
7740 | 2b0233ab | ths | case OPC_INS:
|
7741 | 2b0233ab | ths | check_insn(env, ctx, ISA_MIPS32R2); |
7742 | 2b0233ab | ths | gen_bitops(ctx, op1, rt, rs, sa, rd); |
7743 | 2b0233ab | ths | break;
|
7744 | 2b0233ab | ths | case OPC_BSHFL:
|
7745 | 2b0233ab | ths | check_insn(env, ctx, ISA_MIPS32R2); |
7746 | 2b0233ab | ths | op2 = MASK_BSHFL(ctx->opcode); |
7747 | 49bcf33c | aurel32 | gen_bshfl(ctx, op2, rt, rd); |
7748 | 7a387fff | ths | break;
|
7749 | 1579a72e | ths | case OPC_RDHWR:
|
7750 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
7751 | 6c5c1e20 | ths | { |
7752 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
7753 | 6c5c1e20 | ths | |
7754 | 6c5c1e20 | ths | switch (rd) {
|
7755 | 6c5c1e20 | ths | case 0: |
7756 | 6c5c1e20 | ths | save_cpu_state(ctx, 1);
|
7757 | a7812ae4 | pbrook | gen_helper_rdhwr_cpunum(t0); |
7758 | 6c5c1e20 | ths | break;
|
7759 | 6c5c1e20 | ths | case 1: |
7760 | 6c5c1e20 | ths | save_cpu_state(ctx, 1);
|
7761 | a7812ae4 | pbrook | gen_helper_rdhwr_synci_step(t0); |
7762 | 6c5c1e20 | ths | break;
|
7763 | 6c5c1e20 | ths | case 2: |
7764 | 6c5c1e20 | ths | save_cpu_state(ctx, 1);
|
7765 | a7812ae4 | pbrook | gen_helper_rdhwr_cc(t0); |
7766 | 6c5c1e20 | ths | break;
|
7767 | 6c5c1e20 | ths | case 3: |
7768 | 6c5c1e20 | ths | save_cpu_state(ctx, 1);
|
7769 | a7812ae4 | pbrook | gen_helper_rdhwr_ccres(t0); |
7770 | 6c5c1e20 | ths | break;
|
7771 | 6c5c1e20 | ths | case 29: |
7772 | 932e71cd | aurel32 | #if defined(CONFIG_USER_ONLY)
|
7773 | 932e71cd | aurel32 | tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUState, tls_value)); |
7774 | 932e71cd | aurel32 | break;
|
7775 | 932e71cd | aurel32 | #else
|
7776 | 932e71cd | aurel32 | /* XXX: Some CPUs implement this in hardware.
|
7777 | 932e71cd | aurel32 | Not supported yet. */
|
7778 | 932e71cd | aurel32 | #endif
|
7779 | 6c5c1e20 | ths | default: /* Invalid */ |
7780 | 6c5c1e20 | ths | MIPS_INVAL("rdhwr");
|
7781 | 6c5c1e20 | ths | generate_exception(ctx, EXCP_RI); |
7782 | 6c5c1e20 | ths | break;
|
7783 | 6c5c1e20 | ths | } |
7784 | 6c5c1e20 | ths | gen_store_gpr(t0, rt); |
7785 | 6c5c1e20 | ths | tcg_temp_free(t0); |
7786 | 1579a72e | ths | } |
7787 | 1579a72e | ths | break;
|
7788 | ead9360e | ths | case OPC_FORK:
|
7789 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
7790 | 6c5c1e20 | ths | { |
7791 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
7792 | a7812ae4 | pbrook | TCGv t1 = tcg_temp_local_new(); |
7793 | 6c5c1e20 | ths | |
7794 | 6c5c1e20 | ths | gen_load_gpr(t0, rt); |
7795 | 6c5c1e20 | ths | gen_load_gpr(t1, rs); |
7796 | a7812ae4 | pbrook | gen_helper_fork(t0, t1); |
7797 | 6c5c1e20 | ths | tcg_temp_free(t0); |
7798 | 6c5c1e20 | ths | tcg_temp_free(t1); |
7799 | 6c5c1e20 | ths | } |
7800 | ead9360e | ths | break;
|
7801 | ead9360e | ths | case OPC_YIELD:
|
7802 | 7385ac0b | ths | check_insn(env, ctx, ASE_MT); |
7803 | 6c5c1e20 | ths | { |
7804 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
7805 | 6c5c1e20 | ths | |
7806 | 6c5c1e20 | ths | gen_load_gpr(t0, rs); |
7807 | a7812ae4 | pbrook | gen_helper_yield(t0, t0); |
7808 | 6c5c1e20 | ths | gen_store_gpr(t0, rd); |
7809 | 6c5c1e20 | ths | tcg_temp_free(t0); |
7810 | 6c5c1e20 | ths | } |
7811 | ead9360e | ths | break;
|
7812 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
7813 | 1579a72e | ths | case OPC_DEXTM ... OPC_DEXT:
|
7814 | 1579a72e | ths | case OPC_DINSM ... OPC_DINS:
|
7815 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64R2); |
7816 | e189e748 | ths | check_mips_64(ctx); |
7817 | 1579a72e | ths | gen_bitops(ctx, op1, rt, rs, sa, rd); |
7818 | 7a387fff | ths | break;
|
7819 | 1579a72e | ths | case OPC_DBSHFL:
|
7820 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS64R2); |
7821 | e189e748 | ths | check_mips_64(ctx); |
7822 | 1579a72e | ths | op2 = MASK_DBSHFL(ctx->opcode); |
7823 | 49bcf33c | aurel32 | gen_bshfl(ctx, op2, rt, rd); |
7824 | c6d6dd7c | ths | break;
|
7825 | 7a387fff | ths | #endif
|
7826 | 7a387fff | ths | default: /* Invalid */ |
7827 | 7a387fff | ths | MIPS_INVAL("special3");
|
7828 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
7829 | 7a387fff | ths | break;
|
7830 | 7a387fff | ths | } |
7831 | 7a387fff | ths | break;
|
7832 | 7a387fff | ths | case OPC_REGIMM:
|
7833 | 7a387fff | ths | op1 = MASK_REGIMM(ctx->opcode); |
7834 | 7a387fff | ths | switch (op1) {
|
7835 | 7a387fff | ths | case OPC_BLTZ ... OPC_BGEZL: /* REGIMM branches */ |
7836 | 7a387fff | ths | case OPC_BLTZAL ... OPC_BGEZALL:
|
7837 | 7a387fff | ths | gen_compute_branch(ctx, op1, rs, -1, imm << 2); |
7838 | 6af0bf9c | bellard | return;
|
7839 | 7a387fff | ths | case OPC_TGEI ... OPC_TEQI: /* REGIMM traps */ |
7840 | 7a387fff | ths | case OPC_TNEI:
|
7841 | 7a387fff | ths | gen_trap(ctx, op1, rs, -1, imm);
|
7842 | 7a387fff | ths | break;
|
7843 | 7a387fff | ths | case OPC_SYNCI:
|
7844 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
7845 | ead9360e | ths | /* Treat as NOP. */
|
7846 | 6af0bf9c | bellard | break;
|
7847 | 6af0bf9c | bellard | default: /* Invalid */ |
7848 | 923617a3 | ths | MIPS_INVAL("regimm");
|
7849 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
7850 | 6af0bf9c | bellard | break;
|
7851 | 6af0bf9c | bellard | } |
7852 | 6af0bf9c | bellard | break;
|
7853 | 7a387fff | ths | case OPC_CP0:
|
7854 | 387a8fe5 | ths | check_cp0_enabled(ctx); |
7855 | 7a387fff | ths | op1 = MASK_CP0(ctx->opcode); |
7856 | 6af0bf9c | bellard | switch (op1) {
|
7857 | 7a387fff | ths | case OPC_MFC0:
|
7858 | 7a387fff | ths | case OPC_MTC0:
|
7859 | ead9360e | ths | case OPC_MFTR:
|
7860 | ead9360e | ths | case OPC_MTTR:
|
7861 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
7862 | 7a387fff | ths | case OPC_DMFC0:
|
7863 | 7a387fff | ths | case OPC_DMTC0:
|
7864 | 7a387fff | ths | #endif
|
7865 | f1aa6320 | ths | #ifndef CONFIG_USER_ONLY
|
7866 | 932e71cd | aurel32 | gen_cp0(env, ctx, op1, rt, rd); |
7867 | 0eaef5aa | ths | #endif /* !CONFIG_USER_ONLY */ |
7868 | 7a387fff | ths | break;
|
7869 | 7a387fff | ths | case OPC_C0_FIRST ... OPC_C0_LAST:
|
7870 | f1aa6320 | ths | #ifndef CONFIG_USER_ONLY
|
7871 | 932e71cd | aurel32 | gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd); |
7872 | 0eaef5aa | ths | #endif /* !CONFIG_USER_ONLY */ |
7873 | 7a387fff | ths | break;
|
7874 | 7a387fff | ths | case OPC_MFMC0:
|
7875 | 8706c382 | ths | #ifndef CONFIG_USER_ONLY
|
7876 | 932e71cd | aurel32 | { |
7877 | a7812ae4 | pbrook | TCGv t0 = tcg_temp_local_new(); |
7878 | 6c5c1e20 | ths | |
7879 | 0eaef5aa | ths | op2 = MASK_MFMC0(ctx->opcode); |
7880 | 6c5c1e20 | ths | switch (op2) {
|
7881 | 6c5c1e20 | ths | case OPC_DMT:
|
7882 | 6c5c1e20 | ths | check_insn(env, ctx, ASE_MT); |
7883 | a7812ae4 | pbrook | gen_helper_dmt(t0, t0); |
7884 | 6c5c1e20 | ths | break;
|
7885 | 6c5c1e20 | ths | case OPC_EMT:
|
7886 | 6c5c1e20 | ths | check_insn(env, ctx, ASE_MT); |
7887 | a7812ae4 | pbrook | gen_helper_emt(t0, t0); |
7888 | da80682b | aurel32 | break;
|
7889 | 6c5c1e20 | ths | case OPC_DVPE:
|
7890 | 6c5c1e20 | ths | check_insn(env, ctx, ASE_MT); |
7891 | a7812ae4 | pbrook | gen_helper_dvpe(t0, t0); |
7892 | 6c5c1e20 | ths | break;
|
7893 | 6c5c1e20 | ths | case OPC_EVPE:
|
7894 | 6c5c1e20 | ths | check_insn(env, ctx, ASE_MT); |
7895 | a7812ae4 | pbrook | gen_helper_evpe(t0, t0); |
7896 | 6c5c1e20 | ths | break;
|
7897 | 6c5c1e20 | ths | case OPC_DI:
|
7898 | 6c5c1e20 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
7899 | 6c5c1e20 | ths | save_cpu_state(ctx, 1);
|
7900 | a7812ae4 | pbrook | gen_helper_di(t0); |
7901 | 6c5c1e20 | ths | /* Stop translation as we may have switched the execution mode */
|
7902 | 6c5c1e20 | ths | ctx->bstate = BS_STOP; |
7903 | 6c5c1e20 | ths | break;
|
7904 | 6c5c1e20 | ths | case OPC_EI:
|
7905 | 6c5c1e20 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
7906 | 6c5c1e20 | ths | save_cpu_state(ctx, 1);
|
7907 | a7812ae4 | pbrook | gen_helper_ei(t0); |
7908 | 6c5c1e20 | ths | /* Stop translation as we may have switched the execution mode */
|
7909 | 6c5c1e20 | ths | ctx->bstate = BS_STOP; |
7910 | 6c5c1e20 | ths | break;
|
7911 | 6c5c1e20 | ths | default: /* Invalid */ |
7912 | 6c5c1e20 | ths | MIPS_INVAL("mfmc0");
|
7913 | 6c5c1e20 | ths | generate_exception(ctx, EXCP_RI); |
7914 | 6c5c1e20 | ths | break;
|
7915 | 6c5c1e20 | ths | } |
7916 | 6c5c1e20 | ths | gen_store_gpr(t0, rt); |
7917 | 6c5c1e20 | ths | tcg_temp_free(t0); |
7918 | 7a387fff | ths | } |
7919 | 0eaef5aa | ths | #endif /* !CONFIG_USER_ONLY */ |
7920 | 6af0bf9c | bellard | break;
|
7921 | 7a387fff | ths | case OPC_RDPGPR:
|
7922 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
7923 | be24bb4f | ths | gen_load_srsgpr(rt, rd); |
7924 | ead9360e | ths | break;
|
7925 | 7a387fff | ths | case OPC_WRPGPR:
|
7926 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
7927 | be24bb4f | ths | gen_store_srsgpr(rt, rd); |
7928 | 38121543 | ths | break;
|
7929 | 6af0bf9c | bellard | default:
|
7930 | 923617a3 | ths | MIPS_INVAL("cp0");
|
7931 | 7a387fff | ths | generate_exception(ctx, EXCP_RI); |
7932 | 6af0bf9c | bellard | break;
|
7933 | 6af0bf9c | bellard | } |
7934 | 6af0bf9c | bellard | break;
|
7935 | 7a387fff | ths | case OPC_ADDI ... OPC_LUI: /* Arithmetic with immediate opcode */ |
7936 | e189e748 | ths | gen_arith_imm(env, ctx, op, rt, rs, imm); |
7937 | 7a387fff | ths | break;
|
7938 | 7a387fff | ths | case OPC_J ... OPC_JAL: /* Jump */ |
7939 | 7a387fff | ths | offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2; |
7940 | 7a387fff | ths | gen_compute_branch(ctx, op, rs, rt, offset); |
7941 | 7a387fff | ths | return;
|
7942 | 7a387fff | ths | case OPC_BEQ ... OPC_BGTZ: /* Branch */ |
7943 | 7a387fff | ths | case OPC_BEQL ... OPC_BGTZL:
|
7944 | 7a387fff | ths | gen_compute_branch(ctx, op, rs, rt, imm << 2);
|
7945 | 7a387fff | ths | return;
|
7946 | 7a387fff | ths | case OPC_LB ... OPC_LWR: /* Load and stores */ |
7947 | 7a387fff | ths | case OPC_SB ... OPC_SW:
|
7948 | 7a387fff | ths | case OPC_SWR:
|
7949 | 7a387fff | ths | case OPC_LL:
|
7950 | 7a387fff | ths | case OPC_SC:
|
7951 | 7a387fff | ths | gen_ldst(ctx, op, rt, rs, imm); |
7952 | 7a387fff | ths | break;
|
7953 | 7a387fff | ths | case OPC_CACHE:
|
7954 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3 | ISA_MIPS32); |
7955 | ead9360e | ths | /* Treat as NOP. */
|
7956 | 34ae7b51 | ths | break;
|
7957 | 7a387fff | ths | case OPC_PREF:
|
7958 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); |
7959 | ead9360e | ths | /* Treat as NOP. */
|
7960 | 6af0bf9c | bellard | break;
|
7961 | 4ad40f36 | bellard | |
7962 | 923617a3 | ths | /* Floating point (COP1). */
|
7963 | 7a387fff | ths | case OPC_LWC1:
|
7964 | 7a387fff | ths | case OPC_LDC1:
|
7965 | 7a387fff | ths | case OPC_SWC1:
|
7966 | 7a387fff | ths | case OPC_SDC1:
|
7967 | 36d23958 | ths | if (env->CP0_Config1 & (1 << CP0C1_FP)) { |
7968 | 36d23958 | ths | save_cpu_state(ctx, 1);
|
7969 | 5e755519 | ths | check_cp1_enabled(ctx); |
7970 | 36d23958 | ths | gen_flt_ldst(ctx, op, rt, rs, imm); |
7971 | 36d23958 | ths | } else {
|
7972 | 36d23958 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
7973 | 36d23958 | ths | } |
7974 | 6ea83fed | bellard | break;
|
7975 | 6ea83fed | bellard | |
7976 | 7a387fff | ths | case OPC_CP1:
|
7977 | 36d23958 | ths | if (env->CP0_Config1 & (1 << CP0C1_FP)) { |
7978 | 36d23958 | ths | save_cpu_state(ctx, 1);
|
7979 | 5e755519 | ths | check_cp1_enabled(ctx); |
7980 | 36d23958 | ths | op1 = MASK_CP1(ctx->opcode); |
7981 | 36d23958 | ths | switch (op1) {
|
7982 | 3a95e3a7 | ths | case OPC_MFHC1:
|
7983 | 3a95e3a7 | ths | case OPC_MTHC1:
|
7984 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS32R2); |
7985 | 36d23958 | ths | case OPC_MFC1:
|
7986 | 36d23958 | ths | case OPC_CFC1:
|
7987 | 36d23958 | ths | case OPC_MTC1:
|
7988 | 36d23958 | ths | case OPC_CTC1:
|
7989 | e189e748 | ths | gen_cp1(ctx, op1, rt, rd); |
7990 | e189e748 | ths | break;
|
7991 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
7992 | 36d23958 | ths | case OPC_DMFC1:
|
7993 | 36d23958 | ths | case OPC_DMTC1:
|
7994 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
7995 | 36d23958 | ths | gen_cp1(ctx, op1, rt, rd); |
7996 | 36d23958 | ths | break;
|
7997 | e189e748 | ths | #endif
|
7998 | fbcc6828 | ths | case OPC_BC1ANY2:
|
7999 | fbcc6828 | ths | case OPC_BC1ANY4:
|
8000 | b8aa4598 | ths | check_cop1x(ctx); |
8001 | 7385ac0b | ths | check_insn(env, ctx, ASE_MIPS3D); |
8002 | d8a5950a | ths | /* fall through */
|
8003 | d8a5950a | ths | case OPC_BC1:
|
8004 | e189e748 | ths | gen_compute_branch1(env, ctx, MASK_BC1(ctx->opcode), |
8005 | 5a5012ec | ths | (rt >> 2) & 0x7, imm << 2); |
8006 | 36d23958 | ths | return;
|
8007 | 36d23958 | ths | case OPC_S_FMT:
|
8008 | 36d23958 | ths | case OPC_D_FMT:
|
8009 | 36d23958 | ths | case OPC_W_FMT:
|
8010 | 36d23958 | ths | case OPC_L_FMT:
|
8011 | 5a5012ec | ths | case OPC_PS_FMT:
|
8012 | 5a5012ec | ths | gen_farith(ctx, MASK_CP1_FUNC(ctx->opcode), rt, rd, sa, |
8013 | 5a5012ec | ths | (imm >> 8) & 0x7); |
8014 | 36d23958 | ths | break;
|
8015 | 36d23958 | ths | default:
|
8016 | 923617a3 | ths | MIPS_INVAL("cp1");
|
8017 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
8018 | 36d23958 | ths | break;
|
8019 | 36d23958 | ths | } |
8020 | 36d23958 | ths | } else {
|
8021 | 36d23958 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
8022 | 6ea83fed | bellard | } |
8023 | 4ad40f36 | bellard | break;
|
8024 | 4ad40f36 | bellard | |
8025 | 4ad40f36 | bellard | /* COP2. */
|
8026 | 7a387fff | ths | case OPC_LWC2:
|
8027 | 7a387fff | ths | case OPC_LDC2:
|
8028 | 7a387fff | ths | case OPC_SWC2:
|
8029 | 7a387fff | ths | case OPC_SDC2:
|
8030 | 7a387fff | ths | case OPC_CP2:
|
8031 | 7a387fff | ths | /* COP2: Not implemented. */
|
8032 | 4ad40f36 | bellard | generate_exception_err(ctx, EXCP_CpU, 2);
|
8033 | 4ad40f36 | bellard | break;
|
8034 | 4ad40f36 | bellard | |
8035 | 7a387fff | ths | case OPC_CP3:
|
8036 | 36d23958 | ths | if (env->CP0_Config1 & (1 << CP0C1_FP)) { |
8037 | e397ee33 | ths | save_cpu_state(ctx, 1);
|
8038 | 5e755519 | ths | check_cp1_enabled(ctx); |
8039 | 36d23958 | ths | op1 = MASK_CP3(ctx->opcode); |
8040 | 36d23958 | ths | switch (op1) {
|
8041 | 5a5012ec | ths | case OPC_LWXC1:
|
8042 | 5a5012ec | ths | case OPC_LDXC1:
|
8043 | 5a5012ec | ths | case OPC_LUXC1:
|
8044 | 5a5012ec | ths | case OPC_SWXC1:
|
8045 | 5a5012ec | ths | case OPC_SDXC1:
|
8046 | 5a5012ec | ths | case OPC_SUXC1:
|
8047 | 93b12ccc | ths | gen_flt3_ldst(ctx, op1, sa, rd, rs, rt); |
8048 | 5a5012ec | ths | break;
|
8049 | e0c84da7 | ths | case OPC_PREFX:
|
8050 | ead9360e | ths | /* Treat as NOP. */
|
8051 | e0c84da7 | ths | break;
|
8052 | 5a5012ec | ths | case OPC_ALNV_PS:
|
8053 | 5a5012ec | ths | case OPC_MADD_S:
|
8054 | 5a5012ec | ths | case OPC_MADD_D:
|
8055 | 5a5012ec | ths | case OPC_MADD_PS:
|
8056 | 5a5012ec | ths | case OPC_MSUB_S:
|
8057 | 5a5012ec | ths | case OPC_MSUB_D:
|
8058 | 5a5012ec | ths | case OPC_MSUB_PS:
|
8059 | 5a5012ec | ths | case OPC_NMADD_S:
|
8060 | 5a5012ec | ths | case OPC_NMADD_D:
|
8061 | 5a5012ec | ths | case OPC_NMADD_PS:
|
8062 | 5a5012ec | ths | case OPC_NMSUB_S:
|
8063 | 5a5012ec | ths | case OPC_NMSUB_D:
|
8064 | 5a5012ec | ths | case OPC_NMSUB_PS:
|
8065 | 5a5012ec | ths | gen_flt3_arith(ctx, op1, sa, rs, rd, rt); |
8066 | 5a5012ec | ths | break;
|
8067 | 36d23958 | ths | default:
|
8068 | 923617a3 | ths | MIPS_INVAL("cp3");
|
8069 | e397ee33 | ths | generate_exception (ctx, EXCP_RI); |
8070 | 36d23958 | ths | break;
|
8071 | 36d23958 | ths | } |
8072 | 36d23958 | ths | } else {
|
8073 | e397ee33 | ths | generate_exception_err(ctx, EXCP_CpU, 1);
|
8074 | 7a387fff | ths | } |
8075 | 4ad40f36 | bellard | break;
|
8076 | 4ad40f36 | bellard | |
8077 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
8078 | 7a387fff | ths | /* MIPS64 opcodes */
|
8079 | 7a387fff | ths | case OPC_LWU:
|
8080 | 7a387fff | ths | case OPC_LDL ... OPC_LDR:
|
8081 | 7a387fff | ths | case OPC_SDL ... OPC_SDR:
|
8082 | 7a387fff | ths | case OPC_LLD:
|
8083 | 7a387fff | ths | case OPC_LD:
|
8084 | 7a387fff | ths | case OPC_SCD:
|
8085 | 7a387fff | ths | case OPC_SD:
|
8086 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
8087 | e189e748 | ths | check_mips_64(ctx); |
8088 | 7a387fff | ths | gen_ldst(ctx, op, rt, rs, imm); |
8089 | 7a387fff | ths | break;
|
8090 | 7a387fff | ths | case OPC_DADDI ... OPC_DADDIU:
|
8091 | e189e748 | ths | check_insn(env, ctx, ISA_MIPS3); |
8092 | e189e748 | ths | check_mips_64(ctx); |
8093 | e189e748 | ths | gen_arith_imm(env, ctx, op, rt, rs, imm); |
8094 | 7a387fff | ths | break;
|
8095 | 6af0bf9c | bellard | #endif
|
8096 | 7a387fff | ths | case OPC_JALX:
|
8097 | e189e748 | ths | check_insn(env, ctx, ASE_MIPS16); |
8098 | 7a387fff | ths | /* MIPS16: Not implemented. */
|
8099 | 7a387fff | ths | case OPC_MDMX:
|
8100 | e189e748 | ths | check_insn(env, ctx, ASE_MDMX); |
8101 | 7a387fff | ths | /* MDMX: Not implemented. */
|
8102 | 6af0bf9c | bellard | default: /* Invalid */ |
8103 | 923617a3 | ths | MIPS_INVAL("major opcode");
|
8104 | 6af0bf9c | bellard | generate_exception(ctx, EXCP_RI); |
8105 | 6af0bf9c | bellard | break;
|
8106 | 6af0bf9c | bellard | } |
8107 | 4ad40f36 | bellard | if (ctx->hflags & MIPS_HFLAG_BMASK) {
|
8108 | c53f4a62 | ths | int hflags = ctx->hflags & MIPS_HFLAG_BMASK;
|
8109 | 6af0bf9c | bellard | /* Branches completion */
|
8110 | 4ad40f36 | bellard | ctx->hflags &= ~MIPS_HFLAG_BMASK; |
8111 | 6af0bf9c | bellard | ctx->bstate = BS_BRANCH; |
8112 | 6af0bf9c | bellard | save_cpu_state(ctx, 0);
|
8113 | 2e70f6ef | pbrook | /* FIXME: Need to clear can_do_io. */
|
8114 | 5a5012ec | ths | switch (hflags) {
|
8115 | 6af0bf9c | bellard | case MIPS_HFLAG_B:
|
8116 | 6af0bf9c | bellard | /* unconditional branch */
|
8117 | 6af0bf9c | bellard | MIPS_DEBUG("unconditional branch");
|
8118 | 6e256c93 | bellard | gen_goto_tb(ctx, 0, ctx->btarget);
|
8119 | 6af0bf9c | bellard | break;
|
8120 | 6af0bf9c | bellard | case MIPS_HFLAG_BL:
|
8121 | 6af0bf9c | bellard | /* blikely taken case */
|
8122 | 6af0bf9c | bellard | MIPS_DEBUG("blikely branch taken");
|
8123 | 6e256c93 | bellard | gen_goto_tb(ctx, 0, ctx->btarget);
|
8124 | 6af0bf9c | bellard | break;
|
8125 | 6af0bf9c | bellard | case MIPS_HFLAG_BC:
|
8126 | 6af0bf9c | bellard | /* Conditional branch */
|
8127 | 6af0bf9c | bellard | MIPS_DEBUG("conditional branch");
|
8128 | c53be334 | bellard | { |
8129 | 8e9ade68 | ths | int l1 = gen_new_label();
|
8130 | 8e9ade68 | ths | |
8131 | 1ba74fb8 | aurel32 | tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, l1);
|
8132 | 8e9ade68 | ths | gen_goto_tb(ctx, 1, ctx->pc + 4); |
8133 | 8e9ade68 | ths | gen_set_label(l1); |
8134 | 8e9ade68 | ths | gen_goto_tb(ctx, 0, ctx->btarget);
|
8135 | c53be334 | bellard | } |
8136 | 6af0bf9c | bellard | break;
|
8137 | 6af0bf9c | bellard | case MIPS_HFLAG_BR:
|
8138 | 6af0bf9c | bellard | /* unconditional branch to register */
|
8139 | 6af0bf9c | bellard | MIPS_DEBUG("branch to register");
|
8140 | 4b2eb8d2 | ths | tcg_gen_mov_tl(cpu_PC, btarget); |
8141 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
8142 | 6af0bf9c | bellard | break;
|
8143 | 6af0bf9c | bellard | default:
|
8144 | 6af0bf9c | bellard | MIPS_DEBUG("unknown branch");
|
8145 | 6af0bf9c | bellard | break;
|
8146 | 6af0bf9c | bellard | } |
8147 | 6af0bf9c | bellard | } |
8148 | 6af0bf9c | bellard | } |
8149 | 6af0bf9c | bellard | |
8150 | 2cfc5f17 | ths | static inline void |
8151 | 820e00f2 | ths | gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, |
8152 | 820e00f2 | ths | int search_pc)
|
8153 | 6af0bf9c | bellard | { |
8154 | 278d0702 | ths | DisasContext ctx; |
8155 | 6af0bf9c | bellard | target_ulong pc_start; |
8156 | 6af0bf9c | bellard | uint16_t *gen_opc_end; |
8157 | a1d1bb31 | aliguori | CPUBreakpoint *bp; |
8158 | 6af0bf9c | bellard | int j, lj = -1; |
8159 | 2e70f6ef | pbrook | int num_insns;
|
8160 | 2e70f6ef | pbrook | int max_insns;
|
8161 | 6af0bf9c | bellard | |
8162 | 93fcfe39 | aliguori | if (search_pc)
|
8163 | 93fcfe39 | aliguori | qemu_log("search pc %d\n", search_pc);
|
8164 | 4ad40f36 | bellard | |
8165 | 6af0bf9c | bellard | pc_start = tb->pc; |
8166 | faf7aaa9 | ths | /* Leave some spare opc slots for branch handling. */
|
8167 | faf7aaa9 | ths | gen_opc_end = gen_opc_buf + OPC_MAX_SIZE - 16;
|
8168 | 6af0bf9c | bellard | ctx.pc = pc_start; |
8169 | 4ad40f36 | bellard | ctx.saved_pc = -1;
|
8170 | 6af0bf9c | bellard | ctx.tb = tb; |
8171 | 6af0bf9c | bellard | ctx.bstate = BS_NONE; |
8172 | 4ad40f36 | bellard | /* Restore delay slot state from the tb context. */
|
8173 | c068688b | j_mayer | ctx.hflags = (uint32_t)tb->flags; /* FIXME: maybe use 64 bits here? */
|
8174 | fd4a04eb | ths | restore_cpu_state(env, &ctx); |
8175 | 932e71cd | aurel32 | #ifdef CONFIG_USER_ONLY
|
8176 | 0eaef5aa | ths | ctx.mem_idx = MIPS_HFLAG_UM; |
8177 | 932e71cd | aurel32 | #else
|
8178 | 0eaef5aa | ths | ctx.mem_idx = ctx.hflags & MIPS_HFLAG_KSU; |
8179 | 932e71cd | aurel32 | #endif
|
8180 | 2e70f6ef | pbrook | num_insns = 0;
|
8181 | 2e70f6ef | pbrook | max_insns = tb->cflags & CF_COUNT_MASK; |
8182 | 2e70f6ef | pbrook | if (max_insns == 0) |
8183 | 2e70f6ef | pbrook | max_insns = CF_COUNT_MASK; |
8184 | 6af0bf9c | bellard | #ifdef DEBUG_DISAS
|
8185 | 93fcfe39 | aliguori | qemu_log_mask(CPU_LOG_TB_CPU, "------------------------------------------------\n");
|
8186 | 93fcfe39 | aliguori | /* FIXME: This may print out stale hflags from env... */
|
8187 | 93fcfe39 | aliguori | log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
|
8188 | 6af0bf9c | bellard | #endif
|
8189 | d12d51d5 | aliguori | LOG_DISAS("\ntb %p idx %d hflags %04x\n", tb, ctx.mem_idx, ctx.hflags);
|
8190 | 2e70f6ef | pbrook | gen_icount_start(); |
8191 | faf7aaa9 | ths | while (ctx.bstate == BS_NONE) {
|
8192 | c0ce998e | aliguori | if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
|
8193 | c0ce998e | aliguori | TAILQ_FOREACH(bp, &env->breakpoints, entry) { |
8194 | a1d1bb31 | aliguori | if (bp->pc == ctx.pc) {
|
8195 | 278d0702 | ths | save_cpu_state(&ctx, 1);
|
8196 | 4ad40f36 | bellard | ctx.bstate = BS_BRANCH; |
8197 | a7812ae4 | pbrook | gen_helper_0i(raise_exception, EXCP_DEBUG); |
8198 | ce62e5ba | ths | /* Include the breakpoint location or the tb won't
|
8199 | ce62e5ba | ths | * be flushed when it must be. */
|
8200 | ce62e5ba | ths | ctx.pc += 4;
|
8201 | 4ad40f36 | bellard | goto done_generating;
|
8202 | 4ad40f36 | bellard | } |
8203 | 4ad40f36 | bellard | } |
8204 | 4ad40f36 | bellard | } |
8205 | 4ad40f36 | bellard | |
8206 | 6af0bf9c | bellard | if (search_pc) {
|
8207 | 6af0bf9c | bellard | j = gen_opc_ptr - gen_opc_buf; |
8208 | 6af0bf9c | bellard | if (lj < j) {
|
8209 | 6af0bf9c | bellard | lj++; |
8210 | 6af0bf9c | bellard | while (lj < j)
|
8211 | 6af0bf9c | bellard | gen_opc_instr_start[lj++] = 0;
|
8212 | 6af0bf9c | bellard | } |
8213 | 4ad40f36 | bellard | gen_opc_pc[lj] = ctx.pc; |
8214 | 4ad40f36 | bellard | gen_opc_hflags[lj] = ctx.hflags & MIPS_HFLAG_BMASK; |
8215 | 4ad40f36 | bellard | gen_opc_instr_start[lj] = 1;
|
8216 | 2e70f6ef | pbrook | gen_opc_icount[lj] = num_insns; |
8217 | 6af0bf9c | bellard | } |
8218 | 2e70f6ef | pbrook | if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) |
8219 | 2e70f6ef | pbrook | gen_io_start(); |
8220 | 6af0bf9c | bellard | ctx.opcode = ldl_code(ctx.pc); |
8221 | 36d23958 | ths | decode_opc(env, &ctx); |
8222 | 6af0bf9c | bellard | ctx.pc += 4;
|
8223 | 2e70f6ef | pbrook | num_insns++; |
8224 | 4ad40f36 | bellard | |
8225 | 4ad40f36 | bellard | if (env->singlestep_enabled)
|
8226 | 4ad40f36 | bellard | break;
|
8227 | 4ad40f36 | bellard | |
8228 | 6af0bf9c | bellard | if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) |
8229 | 6af0bf9c | bellard | break;
|
8230 | 4ad40f36 | bellard | |
8231 | faf7aaa9 | ths | if (gen_opc_ptr >= gen_opc_end)
|
8232 | faf7aaa9 | ths | break;
|
8233 | faf7aaa9 | ths | |
8234 | 2e70f6ef | pbrook | if (num_insns >= max_insns)
|
8235 | 2e70f6ef | pbrook | break;
|
8236 | 6af0bf9c | bellard | #if defined (MIPS_SINGLE_STEP)
|
8237 | 6af0bf9c | bellard | break;
|
8238 | 6af0bf9c | bellard | #endif
|
8239 | 6af0bf9c | bellard | } |
8240 | 2e70f6ef | pbrook | if (tb->cflags & CF_LAST_IO)
|
8241 | 2e70f6ef | pbrook | gen_io_end(); |
8242 | 4ad40f36 | bellard | if (env->singlestep_enabled) {
|
8243 | 278d0702 | ths | save_cpu_state(&ctx, ctx.bstate == BS_NONE); |
8244 | a7812ae4 | pbrook | gen_helper_0i(raise_exception, EXCP_DEBUG); |
8245 | 16c00cb2 | ths | } else {
|
8246 | 6958549d | aurel32 | switch (ctx.bstate) {
|
8247 | 16c00cb2 | ths | case BS_STOP:
|
8248 | a7812ae4 | pbrook | gen_helper_interrupt_restart(); |
8249 | df1561e2 | ths | gen_goto_tb(&ctx, 0, ctx.pc);
|
8250 | df1561e2 | ths | break;
|
8251 | 16c00cb2 | ths | case BS_NONE:
|
8252 | 278d0702 | ths | save_cpu_state(&ctx, 0);
|
8253 | 16c00cb2 | ths | gen_goto_tb(&ctx, 0, ctx.pc);
|
8254 | 16c00cb2 | ths | break;
|
8255 | 5a5012ec | ths | case BS_EXCP:
|
8256 | a7812ae4 | pbrook | gen_helper_interrupt_restart(); |
8257 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
8258 | 16c00cb2 | ths | break;
|
8259 | 5a5012ec | ths | case BS_BRANCH:
|
8260 | 5a5012ec | ths | default:
|
8261 | 5a5012ec | ths | break;
|
8262 | 6958549d | aurel32 | } |
8263 | 6af0bf9c | bellard | } |
8264 | 4ad40f36 | bellard | done_generating:
|
8265 | 2e70f6ef | pbrook | gen_icount_end(tb, num_insns); |
8266 | 6af0bf9c | bellard | *gen_opc_ptr = INDEX_op_end; |
8267 | 6af0bf9c | bellard | if (search_pc) {
|
8268 | 6af0bf9c | bellard | j = gen_opc_ptr - gen_opc_buf; |
8269 | 6af0bf9c | bellard | lj++; |
8270 | 6af0bf9c | bellard | while (lj <= j)
|
8271 | 6af0bf9c | bellard | gen_opc_instr_start[lj++] = 0;
|
8272 | 6af0bf9c | bellard | } else {
|
8273 | 6af0bf9c | bellard | tb->size = ctx.pc - pc_start; |
8274 | 2e70f6ef | pbrook | tb->icount = num_insns; |
8275 | 6af0bf9c | bellard | } |
8276 | 6af0bf9c | bellard | #ifdef DEBUG_DISAS
|
8277 | d12d51d5 | aliguori | LOG_DISAS("\n");
|
8278 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
8279 | 93fcfe39 | aliguori | qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
8280 | 93fcfe39 | aliguori | log_target_disas(pc_start, ctx.pc - pc_start, 0);
|
8281 | 93fcfe39 | aliguori | qemu_log("\n");
|
8282 | 6af0bf9c | bellard | } |
8283 | 93fcfe39 | aliguori | qemu_log_mask(CPU_LOG_TB_CPU, "---------------- %d %08x\n", ctx.bstate, ctx.hflags);
|
8284 | 6af0bf9c | bellard | #endif
|
8285 | 6af0bf9c | bellard | } |
8286 | 6af0bf9c | bellard | |
8287 | 2cfc5f17 | ths | void gen_intermediate_code (CPUState *env, struct TranslationBlock *tb) |
8288 | 6af0bf9c | bellard | { |
8289 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 0);
|
8290 | 6af0bf9c | bellard | } |
8291 | 6af0bf9c | bellard | |
8292 | 2cfc5f17 | ths | void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb) |
8293 | 6af0bf9c | bellard | { |
8294 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 1);
|
8295 | 6af0bf9c | bellard | } |
8296 | 6af0bf9c | bellard | |
8297 | 8706c382 | ths | static void fpu_dump_state(CPUState *env, FILE *f, |
8298 | 8706c382 | ths | int (*fpu_fprintf)(FILE *f, const char *fmt, ...), |
8299 | 8706c382 | ths | int flags)
|
8300 | 6ea83fed | bellard | { |
8301 | 6ea83fed | bellard | int i;
|
8302 | 5e755519 | ths | int is_fpu64 = !!(env->hflags & MIPS_HFLAG_F64);
|
8303 | 5a5012ec | ths | |
8304 | 5a5012ec | ths | #define printfpr(fp) \
|
8305 | 5a5012ec | ths | do { \
|
8306 | 5a5012ec | ths | if (is_fpu64) \
|
8307 | 5a5012ec | ths | fpu_fprintf(f, "w:%08x d:%016lx fd:%13g fs:%13g psu: %13g\n", \
|
8308 | 5a5012ec | ths | (fp)->w[FP_ENDIAN_IDX], (fp)->d, (fp)->fd, \ |
8309 | 5a5012ec | ths | (fp)->fs[FP_ENDIAN_IDX], (fp)->fs[!FP_ENDIAN_IDX]); \ |
8310 | 5a5012ec | ths | else { \
|
8311 | 5a5012ec | ths | fpr_t tmp; \ |
8312 | 5a5012ec | ths | tmp.w[FP_ENDIAN_IDX] = (fp)->w[FP_ENDIAN_IDX]; \ |
8313 | 5a5012ec | ths | tmp.w[!FP_ENDIAN_IDX] = ((fp) + 1)->w[FP_ENDIAN_IDX]; \
|
8314 | 5a5012ec | ths | fpu_fprintf(f, "w:%08x d:%016lx fd:%13g fs:%13g psu:%13g\n", \
|
8315 | 5a5012ec | ths | tmp.w[FP_ENDIAN_IDX], tmp.d, tmp.fd, \ |
8316 | 5a5012ec | ths | tmp.fs[FP_ENDIAN_IDX], tmp.fs[!FP_ENDIAN_IDX]); \ |
8317 | 5a5012ec | ths | } \ |
8318 | 6ea83fed | bellard | } while(0) |
8319 | 6ea83fed | bellard | |
8320 | 5a5012ec | ths | |
8321 | 5a5012ec | ths | fpu_fprintf(f, "CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d fp_status 0x%08x(0x%02x)\n",
|
8322 | f01be154 | ths | env->active_fpu.fcr0, env->active_fpu.fcr31, is_fpu64, env->active_fpu.fp_status, |
8323 | f01be154 | ths | get_float_exception_flags(&env->active_fpu.fp_status)); |
8324 | 5a5012ec | ths | for (i = 0; i < 32; (is_fpu64) ? i++ : (i += 2)) { |
8325 | 5a5012ec | ths | fpu_fprintf(f, "%3s: ", fregnames[i]);
|
8326 | f01be154 | ths | printfpr(&env->active_fpu.fpr[i]); |
8327 | 6ea83fed | bellard | } |
8328 | 6ea83fed | bellard | |
8329 | 6ea83fed | bellard | #undef printfpr
|
8330 | 6ea83fed | bellard | } |
8331 | 6ea83fed | bellard | |
8332 | d26bc211 | ths | #if defined(TARGET_MIPS64) && defined(MIPS_DEBUG_SIGN_EXTENSIONS)
|
8333 | c570fd16 | ths | /* Debug help: The architecture requires 32bit code to maintain proper
|
8334 | c7e8a937 | ths | sign-extended values on 64bit machines. */
|
8335 | c570fd16 | ths | |
8336 | c570fd16 | ths | #define SIGN_EXT_P(val) ((((val) & ~0x7fffffff) == 0) || (((val) & ~0x7fffffff) == ~0x7fffffff)) |
8337 | c570fd16 | ths | |
8338 | 8706c382 | ths | static void |
8339 | 8706c382 | ths | cpu_mips_check_sign_extensions (CPUState *env, FILE *f, |
8340 | 8706c382 | ths | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
8341 | 8706c382 | ths | int flags)
|
8342 | c570fd16 | ths | { |
8343 | c570fd16 | ths | int i;
|
8344 | c570fd16 | ths | |
8345 | b5dc7732 | ths | if (!SIGN_EXT_P(env->active_tc.PC))
|
8346 | b5dc7732 | ths | cpu_fprintf(f, "BROKEN: pc=0x" TARGET_FMT_lx "\n", env->active_tc.PC); |
8347 | b5dc7732 | ths | if (!SIGN_EXT_P(env->active_tc.HI[0])) |
8348 | b5dc7732 | ths | cpu_fprintf(f, "BROKEN: HI=0x" TARGET_FMT_lx "\n", env->active_tc.HI[0]); |
8349 | b5dc7732 | ths | if (!SIGN_EXT_P(env->active_tc.LO[0])) |
8350 | b5dc7732 | ths | cpu_fprintf(f, "BROKEN: LO=0x" TARGET_FMT_lx "\n", env->active_tc.LO[0]); |
8351 | c570fd16 | ths | if (!SIGN_EXT_P(env->btarget))
|
8352 | 3594c774 | ths | cpu_fprintf(f, "BROKEN: btarget=0x" TARGET_FMT_lx "\n", env->btarget); |
8353 | c570fd16 | ths | |
8354 | c570fd16 | ths | for (i = 0; i < 32; i++) { |
8355 | b5dc7732 | ths | if (!SIGN_EXT_P(env->active_tc.gpr[i]))
|
8356 | b5dc7732 | ths | cpu_fprintf(f, "BROKEN: %s=0x" TARGET_FMT_lx "\n", regnames[i], env->active_tc.gpr[i]); |
8357 | c570fd16 | ths | } |
8358 | c570fd16 | ths | |
8359 | c570fd16 | ths | if (!SIGN_EXT_P(env->CP0_EPC))
|
8360 | 3594c774 | ths | cpu_fprintf(f, "BROKEN: EPC=0x" TARGET_FMT_lx "\n", env->CP0_EPC); |
8361 | c570fd16 | ths | if (!SIGN_EXT_P(env->CP0_LLAddr))
|
8362 | 3594c774 | ths | cpu_fprintf(f, "BROKEN: LLAddr=0x" TARGET_FMT_lx "\n", env->CP0_LLAddr); |
8363 | c570fd16 | ths | } |
8364 | c570fd16 | ths | #endif
|
8365 | c570fd16 | ths | |
8366 | 5fafdf24 | ths | void cpu_dump_state (CPUState *env, FILE *f,
|
8367 | 6af0bf9c | bellard | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
8368 | 6af0bf9c | bellard | int flags)
|
8369 | 6af0bf9c | bellard | { |
8370 | 6af0bf9c | bellard | int i;
|
8371 | 3b46e624 | ths | |
8372 | 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", |
8373 | 3d5be870 | ths | env->active_tc.PC, env->active_tc.HI[0], env->active_tc.LO[0], |
8374 | 3d5be870 | ths | env->hflags, env->btarget, env->bcond); |
8375 | 6af0bf9c | bellard | for (i = 0; i < 32; i++) { |
8376 | 6af0bf9c | bellard | if ((i & 3) == 0) |
8377 | 6af0bf9c | bellard | cpu_fprintf(f, "GPR%02d:", i);
|
8378 | b5dc7732 | ths | cpu_fprintf(f, " %s " TARGET_FMT_lx, regnames[i], env->active_tc.gpr[i]);
|
8379 | 6af0bf9c | bellard | if ((i & 3) == 3) |
8380 | 6af0bf9c | bellard | cpu_fprintf(f, "\n");
|
8381 | 6af0bf9c | bellard | } |
8382 | 568b600d | bellard | |
8383 | 3594c774 | ths | cpu_fprintf(f, "CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_FMT_lx "\n", |
8384 | 5e755519 | ths | env->CP0_Status, env->CP0_Cause, env->CP0_EPC); |
8385 | 3594c774 | ths | cpu_fprintf(f, " Config0 0x%08x Config1 0x%08x LLAddr 0x" TARGET_FMT_lx "\n", |
8386 | 6af0bf9c | bellard | env->CP0_Config0, env->CP0_Config1, env->CP0_LLAddr); |
8387 | 5e755519 | ths | if (env->hflags & MIPS_HFLAG_FPU)
|
8388 | 7a387fff | ths | fpu_dump_state(env, f, cpu_fprintf, flags); |
8389 | d26bc211 | ths | #if defined(TARGET_MIPS64) && defined(MIPS_DEBUG_SIGN_EXTENSIONS)
|
8390 | c570fd16 | ths | cpu_mips_check_sign_extensions(env, f, cpu_fprintf, flags); |
8391 | c570fd16 | ths | #endif
|
8392 | 6af0bf9c | bellard | } |
8393 | 6af0bf9c | bellard | |
8394 | 39454628 | ths | static void mips_tcg_init(void) |
8395 | 39454628 | ths | { |
8396 | f01be154 | ths | int i;
|
8397 | 39454628 | ths | static int inited; |
8398 | 39454628 | ths | |
8399 | 39454628 | ths | /* Initialize various static tables. */
|
8400 | 39454628 | ths | if (inited)
|
8401 | 6958549d | aurel32 | return;
|
8402 | 39454628 | ths | |
8403 | a7812ae4 | pbrook | cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
|
8404 | 4b2eb8d2 | ths | for (i = 0; i < 32; i++) |
8405 | a7812ae4 | pbrook | cpu_gpr[i] = tcg_global_mem_new(TCG_AREG0, |
8406 | 4b2eb8d2 | ths | offsetof(CPUState, active_tc.gpr[i]), |
8407 | 4b2eb8d2 | ths | regnames[i]); |
8408 | a7812ae4 | pbrook | cpu_PC = tcg_global_mem_new(TCG_AREG0, |
8409 | 4b2eb8d2 | ths | offsetof(CPUState, active_tc.PC), "PC");
|
8410 | 4b2eb8d2 | ths | for (i = 0; i < MIPS_DSP_ACC; i++) { |
8411 | a7812ae4 | pbrook | cpu_HI[i] = tcg_global_mem_new(TCG_AREG0, |
8412 | 4b2eb8d2 | ths | offsetof(CPUState, active_tc.HI[i]), |
8413 | 4b2eb8d2 | ths | regnames_HI[i]); |
8414 | a7812ae4 | pbrook | cpu_LO[i] = tcg_global_mem_new(TCG_AREG0, |
8415 | 4b2eb8d2 | ths | offsetof(CPUState, active_tc.LO[i]), |
8416 | 4b2eb8d2 | ths | regnames_LO[i]); |
8417 | a7812ae4 | pbrook | cpu_ACX[i] = tcg_global_mem_new(TCG_AREG0, |
8418 | 4b2eb8d2 | ths | offsetof(CPUState, active_tc.ACX[i]), |
8419 | 4b2eb8d2 | ths | regnames_ACX[i]); |
8420 | 4b2eb8d2 | ths | } |
8421 | a7812ae4 | pbrook | cpu_dspctrl = tcg_global_mem_new(TCG_AREG0, |
8422 | 4b2eb8d2 | ths | offsetof(CPUState, active_tc.DSPControl), |
8423 | 4b2eb8d2 | ths | "DSPControl");
|
8424 | 1ba74fb8 | aurel32 | bcond = tcg_global_mem_new(TCG_AREG0, |
8425 | 1ba74fb8 | aurel32 | offsetof(CPUState, bcond), "bcond");
|
8426 | a7812ae4 | pbrook | btarget = tcg_global_mem_new(TCG_AREG0, |
8427 | d077b6f7 | ths | offsetof(CPUState, btarget), "btarget");
|
8428 | f01be154 | ths | for (i = 0; i < 32; i++) |
8429 | a7812ae4 | pbrook | fpu_fpr32[i] = tcg_global_mem_new_i32(TCG_AREG0, |
8430 | a7812ae4 | pbrook | offsetof(CPUState, active_fpu.fpr[i].w[FP_ENDIAN_IDX]), |
8431 | a7812ae4 | pbrook | fregnames[i]); |
8432 | f01be154 | ths | for (i = 0; i < 32; i++) |
8433 | a7812ae4 | pbrook | fpu_fpr32h[i] = tcg_global_mem_new_i32(TCG_AREG0, |
8434 | a7812ae4 | pbrook | offsetof(CPUState, active_fpu.fpr[i].w[!FP_ENDIAN_IDX]), |
8435 | a7812ae4 | pbrook | fregnames_h[i]); |
8436 | a7812ae4 | pbrook | fpu_fcr0 = tcg_global_mem_new_i32(TCG_AREG0, |
8437 | a7812ae4 | pbrook | offsetof(CPUState, active_fpu.fcr0), |
8438 | a7812ae4 | pbrook | "fcr0");
|
8439 | a7812ae4 | pbrook | fpu_fcr31 = tcg_global_mem_new_i32(TCG_AREG0, |
8440 | a7812ae4 | pbrook | offsetof(CPUState, active_fpu.fcr31), |
8441 | a7812ae4 | pbrook | "fcr31");
|
8442 | 39454628 | ths | |
8443 | 7dd9e556 | ths | /* register helpers */
|
8444 | a7812ae4 | pbrook | #define GEN_HELPER 2 |
8445 | 7dd9e556 | ths | #include "helper.h" |
8446 | 7dd9e556 | ths | |
8447 | 39454628 | ths | inited = 1;
|
8448 | 39454628 | ths | } |
8449 | 39454628 | ths | |
8450 | aaed909a | bellard | #include "translate_init.c" |
8451 | aaed909a | bellard | |
8452 | aaed909a | bellard | CPUMIPSState *cpu_mips_init (const char *cpu_model) |
8453 | 6af0bf9c | bellard | { |
8454 | 6af0bf9c | bellard | CPUMIPSState *env; |
8455 | aaed909a | bellard | const mips_def_t *def;
|
8456 | 6af0bf9c | bellard | |
8457 | aaed909a | bellard | def = cpu_mips_find_by_name(cpu_model); |
8458 | aaed909a | bellard | if (!def)
|
8459 | aaed909a | bellard | return NULL; |
8460 | 6af0bf9c | bellard | env = qemu_mallocz(sizeof(CPUMIPSState));
|
8461 | aaed909a | bellard | env->cpu_model = def; |
8462 | aaed909a | bellard | |
8463 | 173d6cfe | bellard | cpu_exec_init(env); |
8464 | 01ba9816 | ths | env->cpu_model_str = cpu_model; |
8465 | 39454628 | ths | mips_tcg_init(); |
8466 | 6ae81775 | ths | cpu_reset(env); |
8467 | 6ae81775 | ths | return env;
|
8468 | 6ae81775 | ths | } |
8469 | 6ae81775 | ths | |
8470 | 6ae81775 | ths | void cpu_reset (CPUMIPSState *env)
|
8471 | 6ae81775 | ths | { |
8472 | eca1bdf4 | aliguori | if (qemu_loglevel_mask(CPU_LOG_RESET)) {
|
8473 | eca1bdf4 | aliguori | qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
|
8474 | eca1bdf4 | aliguori | log_cpu_state(env, 0);
|
8475 | eca1bdf4 | aliguori | } |
8476 | eca1bdf4 | aliguori | |
8477 | 6ae81775 | ths | memset(env, 0, offsetof(CPUMIPSState, breakpoints));
|
8478 | 6ae81775 | ths | |
8479 | 6af0bf9c | bellard | tlb_flush(env, 1);
|
8480 | 6ae81775 | ths | |
8481 | 6af0bf9c | bellard | /* Minimal init */
|
8482 | 0eaef5aa | ths | #if defined(CONFIG_USER_ONLY)
|
8483 | 932e71cd | aurel32 | env->hflags = MIPS_HFLAG_UM; |
8484 | 932e71cd | aurel32 | #else
|
8485 | 932e71cd | aurel32 | if (env->hflags & MIPS_HFLAG_BMASK) {
|
8486 | 932e71cd | aurel32 | /* If the exception was raised from a delay slot,
|
8487 | 932e71cd | aurel32 | come back to the jump. */
|
8488 | 932e71cd | aurel32 | env->CP0_ErrorEPC = env->active_tc.PC - 4;
|
8489 | aa328add | ths | } else {
|
8490 | 932e71cd | aurel32 | env->CP0_ErrorEPC = env->active_tc.PC; |
8491 | 932e71cd | aurel32 | } |
8492 | 932e71cd | aurel32 | env->active_tc.PC = (int32_t)0xBFC00000;
|
8493 | 932e71cd | aurel32 | env->CP0_Wired = 0;
|
8494 | 932e71cd | aurel32 | /* SMP not implemented */
|
8495 | 932e71cd | aurel32 | env->CP0_EBase = 0x80000000;
|
8496 | 932e71cd | aurel32 | env->CP0_Status = (1 << CP0St_BEV) | (1 << CP0St_ERL); |
8497 | 932e71cd | aurel32 | /* vectored interrupts not implemented, timer on int 7,
|
8498 | 932e71cd | aurel32 | no performance counters. */
|
8499 | 932e71cd | aurel32 | env->CP0_IntCtl = 0xe0000000;
|
8500 | 932e71cd | aurel32 | { |
8501 | 932e71cd | aurel32 | int i;
|
8502 | 932e71cd | aurel32 | |
8503 | 932e71cd | aurel32 | for (i = 0; i < 7; i++) { |
8504 | 932e71cd | aurel32 | env->CP0_WatchLo[i] = 0;
|
8505 | 932e71cd | aurel32 | env->CP0_WatchHi[i] = 0x80000000;
|
8506 | fd88b6ab | ths | } |
8507 | 932e71cd | aurel32 | env->CP0_WatchLo[7] = 0; |
8508 | 932e71cd | aurel32 | env->CP0_WatchHi[7] = 0; |
8509 | fd88b6ab | ths | } |
8510 | 932e71cd | aurel32 | /* Count register increments in debug mode, EJTAG version 1 */
|
8511 | 932e71cd | aurel32 | env->CP0_Debug = (1 << CP0DB_CNT) | (0x1 << CP0DB_VER); |
8512 | 932e71cd | aurel32 | env->hflags = MIPS_HFLAG_CP0; |
8513 | 932e71cd | aurel32 | #endif
|
8514 | 6af0bf9c | bellard | env->exception_index = EXCP_NONE; |
8515 | aaed909a | bellard | cpu_mips_register(env, env->cpu_model); |
8516 | 6af0bf9c | bellard | } |
8517 | d2856f1a | aurel32 | |
8518 | d2856f1a | aurel32 | void gen_pc_load(CPUState *env, TranslationBlock *tb,
|
8519 | d2856f1a | aurel32 | unsigned long searched_pc, int pc_pos, void *puc) |
8520 | d2856f1a | aurel32 | { |
8521 | b5dc7732 | ths | env->active_tc.PC = gen_opc_pc[pc_pos]; |
8522 | d2856f1a | aurel32 | env->hflags &= ~MIPS_HFLAG_BMASK; |
8523 | d2856f1a | aurel32 | env->hflags |= gen_opc_hflags[pc_pos]; |
8524 | d2856f1a | aurel32 | } |