root / target-mips / op.c @ e0c84da7
History | View | Annotate | Download (41.9 kB)
1 | 6af0bf9c | bellard | /*
|
---|---|---|---|
2 | 6af0bf9c | bellard | * MIPS emulation micro-operations for qemu.
|
3 | 6af0bf9c | bellard | *
|
4 | 6af0bf9c | bellard | * Copyright (c) 2004-2005 Jocelyn Mayer
|
5 | 6ea83fed | bellard | * Copyright (c) 2006 Marius Groeger (FPU operations)
|
6 | 6af0bf9c | bellard | *
|
7 | 6af0bf9c | bellard | * This library is free software; you can redistribute it and/or
|
8 | 6af0bf9c | bellard | * modify it under the terms of the GNU Lesser General Public
|
9 | 6af0bf9c | bellard | * License as published by the Free Software Foundation; either
|
10 | 6af0bf9c | bellard | * version 2 of the License, or (at your option) any later version.
|
11 | 6af0bf9c | bellard | *
|
12 | 6af0bf9c | bellard | * This library is distributed in the hope that it will be useful,
|
13 | 6af0bf9c | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | 6af0bf9c | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 | 6af0bf9c | bellard | * Lesser General Public License for more details.
|
16 | 6af0bf9c | bellard | *
|
17 | 6af0bf9c | bellard | * You should have received a copy of the GNU Lesser General Public
|
18 | 6af0bf9c | bellard | * License along with this library; if not, write to the Free Software
|
19 | 6af0bf9c | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20 | 6af0bf9c | bellard | */
|
21 | 6af0bf9c | bellard | |
22 | 6af0bf9c | bellard | #include "config.h" |
23 | 6af0bf9c | bellard | #include "exec.h" |
24 | 6af0bf9c | bellard | |
25 | 1b351e52 | bellard | #ifndef CALL_FROM_TB0
|
26 | 1b351e52 | bellard | #define CALL_FROM_TB0(func) func();
|
27 | 1b351e52 | bellard | #endif
|
28 | 1b351e52 | bellard | #ifndef CALL_FROM_TB1
|
29 | 1b351e52 | bellard | #define CALL_FROM_TB1(func, arg0) func(arg0);
|
30 | 1b351e52 | bellard | #endif
|
31 | 1b351e52 | bellard | #ifndef CALL_FROM_TB1_CONST16
|
32 | 1b351e52 | bellard | #define CALL_FROM_TB1_CONST16(func, arg0) CALL_FROM_TB1(func, arg0);
|
33 | 1b351e52 | bellard | #endif
|
34 | 1b351e52 | bellard | #ifndef CALL_FROM_TB2
|
35 | 1b351e52 | bellard | #define CALL_FROM_TB2(func, arg0, arg1) func(arg0, arg1);
|
36 | 1b351e52 | bellard | #endif
|
37 | 1b351e52 | bellard | #ifndef CALL_FROM_TB2_CONST16
|
38 | 1b351e52 | bellard | #define CALL_FROM_TB2_CONST16(func, arg0, arg1) \
|
39 | 1b351e52 | bellard | CALL_FROM_TB2(func, arg0, arg1); |
40 | 1b351e52 | bellard | #endif
|
41 | 1b351e52 | bellard | #ifndef CALL_FROM_TB3
|
42 | 1b351e52 | bellard | #define CALL_FROM_TB3(func, arg0, arg1, arg2) func(arg0, arg1, arg2);
|
43 | 1b351e52 | bellard | #endif
|
44 | 1b351e52 | bellard | #ifndef CALL_FROM_TB4
|
45 | 1b351e52 | bellard | #define CALL_FROM_TB4(func, arg0, arg1, arg2, arg3) \
|
46 | 1b351e52 | bellard | func(arg0, arg1, arg2, arg3); |
47 | 1b351e52 | bellard | #endif
|
48 | 1b351e52 | bellard | |
49 | 6af0bf9c | bellard | #define REG 1 |
50 | 6af0bf9c | bellard | #include "op_template.c" |
51 | 6af0bf9c | bellard | #undef REG
|
52 | 6af0bf9c | bellard | #define REG 2 |
53 | 6af0bf9c | bellard | #include "op_template.c" |
54 | 6af0bf9c | bellard | #undef REG
|
55 | 6af0bf9c | bellard | #define REG 3 |
56 | 6af0bf9c | bellard | #include "op_template.c" |
57 | 6af0bf9c | bellard | #undef REG
|
58 | 6af0bf9c | bellard | #define REG 4 |
59 | 6af0bf9c | bellard | #include "op_template.c" |
60 | 6af0bf9c | bellard | #undef REG
|
61 | 6af0bf9c | bellard | #define REG 5 |
62 | 6af0bf9c | bellard | #include "op_template.c" |
63 | 6af0bf9c | bellard | #undef REG
|
64 | 6af0bf9c | bellard | #define REG 6 |
65 | 6af0bf9c | bellard | #include "op_template.c" |
66 | 6af0bf9c | bellard | #undef REG
|
67 | 6af0bf9c | bellard | #define REG 7 |
68 | 6af0bf9c | bellard | #include "op_template.c" |
69 | 6af0bf9c | bellard | #undef REG
|
70 | 6af0bf9c | bellard | #define REG 8 |
71 | 6af0bf9c | bellard | #include "op_template.c" |
72 | 6af0bf9c | bellard | #undef REG
|
73 | 6af0bf9c | bellard | #define REG 9 |
74 | 6af0bf9c | bellard | #include "op_template.c" |
75 | 6af0bf9c | bellard | #undef REG
|
76 | 6af0bf9c | bellard | #define REG 10 |
77 | 6af0bf9c | bellard | #include "op_template.c" |
78 | 6af0bf9c | bellard | #undef REG
|
79 | 6af0bf9c | bellard | #define REG 11 |
80 | 6af0bf9c | bellard | #include "op_template.c" |
81 | 6af0bf9c | bellard | #undef REG
|
82 | 6af0bf9c | bellard | #define REG 12 |
83 | 6af0bf9c | bellard | #include "op_template.c" |
84 | 6af0bf9c | bellard | #undef REG
|
85 | 6af0bf9c | bellard | #define REG 13 |
86 | 6af0bf9c | bellard | #include "op_template.c" |
87 | 6af0bf9c | bellard | #undef REG
|
88 | 6af0bf9c | bellard | #define REG 14 |
89 | 6af0bf9c | bellard | #include "op_template.c" |
90 | 6af0bf9c | bellard | #undef REG
|
91 | 6af0bf9c | bellard | #define REG 15 |
92 | 6af0bf9c | bellard | #include "op_template.c" |
93 | 6af0bf9c | bellard | #undef REG
|
94 | 6af0bf9c | bellard | #define REG 16 |
95 | 6af0bf9c | bellard | #include "op_template.c" |
96 | 6af0bf9c | bellard | #undef REG
|
97 | 6af0bf9c | bellard | #define REG 17 |
98 | 6af0bf9c | bellard | #include "op_template.c" |
99 | 6af0bf9c | bellard | #undef REG
|
100 | 6af0bf9c | bellard | #define REG 18 |
101 | 6af0bf9c | bellard | #include "op_template.c" |
102 | 6af0bf9c | bellard | #undef REG
|
103 | 6af0bf9c | bellard | #define REG 19 |
104 | 6af0bf9c | bellard | #include "op_template.c" |
105 | 6af0bf9c | bellard | #undef REG
|
106 | 6af0bf9c | bellard | #define REG 20 |
107 | 6af0bf9c | bellard | #include "op_template.c" |
108 | 6af0bf9c | bellard | #undef REG
|
109 | 6af0bf9c | bellard | #define REG 21 |
110 | 6af0bf9c | bellard | #include "op_template.c" |
111 | 6af0bf9c | bellard | #undef REG
|
112 | 6af0bf9c | bellard | #define REG 22 |
113 | 6af0bf9c | bellard | #include "op_template.c" |
114 | 6af0bf9c | bellard | #undef REG
|
115 | 6af0bf9c | bellard | #define REG 23 |
116 | 6af0bf9c | bellard | #include "op_template.c" |
117 | 6af0bf9c | bellard | #undef REG
|
118 | 6af0bf9c | bellard | #define REG 24 |
119 | 6af0bf9c | bellard | #include "op_template.c" |
120 | 6af0bf9c | bellard | #undef REG
|
121 | 6af0bf9c | bellard | #define REG 25 |
122 | 6af0bf9c | bellard | #include "op_template.c" |
123 | 6af0bf9c | bellard | #undef REG
|
124 | 6af0bf9c | bellard | #define REG 26 |
125 | 6af0bf9c | bellard | #include "op_template.c" |
126 | 6af0bf9c | bellard | #undef REG
|
127 | 6af0bf9c | bellard | #define REG 27 |
128 | 6af0bf9c | bellard | #include "op_template.c" |
129 | 6af0bf9c | bellard | #undef REG
|
130 | 6af0bf9c | bellard | #define REG 28 |
131 | 6af0bf9c | bellard | #include "op_template.c" |
132 | 6af0bf9c | bellard | #undef REG
|
133 | 6af0bf9c | bellard | #define REG 29 |
134 | 6af0bf9c | bellard | #include "op_template.c" |
135 | 6af0bf9c | bellard | #undef REG
|
136 | 6af0bf9c | bellard | #define REG 30 |
137 | 6af0bf9c | bellard | #include "op_template.c" |
138 | 6af0bf9c | bellard | #undef REG
|
139 | 6af0bf9c | bellard | #define REG 31 |
140 | 6af0bf9c | bellard | #include "op_template.c" |
141 | 6af0bf9c | bellard | #undef REG
|
142 | 6af0bf9c | bellard | |
143 | c570fd16 | ths | #define TN
|
144 | 6af0bf9c | bellard | #include "op_template.c" |
145 | 6af0bf9c | bellard | #undef TN
|
146 | 6af0bf9c | bellard | |
147 | 6ea83fed | bellard | #define SFREG 0 |
148 | 6ea83fed | bellard | #define DFREG 0 |
149 | 6ea83fed | bellard | #include "fop_template.c" |
150 | 6ea83fed | bellard | #undef SFREG
|
151 | 6ea83fed | bellard | #undef DFREG
|
152 | 6ea83fed | bellard | #define SFREG 1 |
153 | 6ea83fed | bellard | #include "fop_template.c" |
154 | 6ea83fed | bellard | #undef SFREG
|
155 | 6ea83fed | bellard | #define SFREG 2 |
156 | 6ea83fed | bellard | #define DFREG 2 |
157 | 6ea83fed | bellard | #include "fop_template.c" |
158 | 6ea83fed | bellard | #undef SFREG
|
159 | 6ea83fed | bellard | #undef DFREG
|
160 | 6ea83fed | bellard | #define SFREG 3 |
161 | 6ea83fed | bellard | #include "fop_template.c" |
162 | 6ea83fed | bellard | #undef SFREG
|
163 | 6ea83fed | bellard | #define SFREG 4 |
164 | 6ea83fed | bellard | #define DFREG 4 |
165 | 6ea83fed | bellard | #include "fop_template.c" |
166 | 6ea83fed | bellard | #undef SFREG
|
167 | 6ea83fed | bellard | #undef DFREG
|
168 | 6ea83fed | bellard | #define SFREG 5 |
169 | 6ea83fed | bellard | #include "fop_template.c" |
170 | 6ea83fed | bellard | #undef SFREG
|
171 | 6ea83fed | bellard | #define SFREG 6 |
172 | 6ea83fed | bellard | #define DFREG 6 |
173 | 6ea83fed | bellard | #include "fop_template.c" |
174 | 6ea83fed | bellard | #undef SFREG
|
175 | 6ea83fed | bellard | #undef DFREG
|
176 | 6ea83fed | bellard | #define SFREG 7 |
177 | 6ea83fed | bellard | #include "fop_template.c" |
178 | 6ea83fed | bellard | #undef SFREG
|
179 | 6ea83fed | bellard | #define SFREG 8 |
180 | 6ea83fed | bellard | #define DFREG 8 |
181 | 6ea83fed | bellard | #include "fop_template.c" |
182 | 6ea83fed | bellard | #undef SFREG
|
183 | 6ea83fed | bellard | #undef DFREG
|
184 | 6ea83fed | bellard | #define SFREG 9 |
185 | 6ea83fed | bellard | #include "fop_template.c" |
186 | 6ea83fed | bellard | #undef SFREG
|
187 | 6ea83fed | bellard | #define SFREG 10 |
188 | 6ea83fed | bellard | #define DFREG 10 |
189 | 6ea83fed | bellard | #include "fop_template.c" |
190 | 6ea83fed | bellard | #undef SFREG
|
191 | 6ea83fed | bellard | #undef DFREG
|
192 | 6ea83fed | bellard | #define SFREG 11 |
193 | 6ea83fed | bellard | #include "fop_template.c" |
194 | 6ea83fed | bellard | #undef SFREG
|
195 | 6ea83fed | bellard | #define SFREG 12 |
196 | 6ea83fed | bellard | #define DFREG 12 |
197 | 6ea83fed | bellard | #include "fop_template.c" |
198 | 6ea83fed | bellard | #undef SFREG
|
199 | 6ea83fed | bellard | #undef DFREG
|
200 | 6ea83fed | bellard | #define SFREG 13 |
201 | 6ea83fed | bellard | #include "fop_template.c" |
202 | 6ea83fed | bellard | #undef SFREG
|
203 | 6ea83fed | bellard | #define SFREG 14 |
204 | 6ea83fed | bellard | #define DFREG 14 |
205 | 6ea83fed | bellard | #include "fop_template.c" |
206 | 6ea83fed | bellard | #undef SFREG
|
207 | 6ea83fed | bellard | #undef DFREG
|
208 | 6ea83fed | bellard | #define SFREG 15 |
209 | 6ea83fed | bellard | #include "fop_template.c" |
210 | 6ea83fed | bellard | #undef SFREG
|
211 | 6ea83fed | bellard | #define SFREG 16 |
212 | 6ea83fed | bellard | #define DFREG 16 |
213 | 6ea83fed | bellard | #include "fop_template.c" |
214 | 6ea83fed | bellard | #undef SFREG
|
215 | 6ea83fed | bellard | #undef DFREG
|
216 | 6ea83fed | bellard | #define SFREG 17 |
217 | 6ea83fed | bellard | #include "fop_template.c" |
218 | 6ea83fed | bellard | #undef SFREG
|
219 | 6ea83fed | bellard | #define SFREG 18 |
220 | 6ea83fed | bellard | #define DFREG 18 |
221 | 6ea83fed | bellard | #include "fop_template.c" |
222 | 6ea83fed | bellard | #undef SFREG
|
223 | 6ea83fed | bellard | #undef DFREG
|
224 | 6ea83fed | bellard | #define SFREG 19 |
225 | 6ea83fed | bellard | #include "fop_template.c" |
226 | 6ea83fed | bellard | #undef SFREG
|
227 | 6ea83fed | bellard | #define SFREG 20 |
228 | 6ea83fed | bellard | #define DFREG 20 |
229 | 6ea83fed | bellard | #include "fop_template.c" |
230 | 6ea83fed | bellard | #undef SFREG
|
231 | 6ea83fed | bellard | #undef DFREG
|
232 | 6ea83fed | bellard | #define SFREG 21 |
233 | 6ea83fed | bellard | #include "fop_template.c" |
234 | 6ea83fed | bellard | #undef SFREG
|
235 | 6ea83fed | bellard | #define SFREG 22 |
236 | 6ea83fed | bellard | #define DFREG 22 |
237 | 6ea83fed | bellard | #include "fop_template.c" |
238 | 6ea83fed | bellard | #undef SFREG
|
239 | 6ea83fed | bellard | #undef DFREG
|
240 | 6ea83fed | bellard | #define SFREG 23 |
241 | 6ea83fed | bellard | #include "fop_template.c" |
242 | 6ea83fed | bellard | #undef SFREG
|
243 | 6ea83fed | bellard | #define SFREG 24 |
244 | 6ea83fed | bellard | #define DFREG 24 |
245 | 6ea83fed | bellard | #include "fop_template.c" |
246 | 6ea83fed | bellard | #undef SFREG
|
247 | 6ea83fed | bellard | #undef DFREG
|
248 | 6ea83fed | bellard | #define SFREG 25 |
249 | 6ea83fed | bellard | #include "fop_template.c" |
250 | 6ea83fed | bellard | #undef SFREG
|
251 | 6ea83fed | bellard | #define SFREG 26 |
252 | 6ea83fed | bellard | #define DFREG 26 |
253 | 6ea83fed | bellard | #include "fop_template.c" |
254 | 6ea83fed | bellard | #undef SFREG
|
255 | 6ea83fed | bellard | #undef DFREG
|
256 | 6ea83fed | bellard | #define SFREG 27 |
257 | 6ea83fed | bellard | #include "fop_template.c" |
258 | 6ea83fed | bellard | #undef SFREG
|
259 | 6ea83fed | bellard | #define SFREG 28 |
260 | 6ea83fed | bellard | #define DFREG 28 |
261 | 6ea83fed | bellard | #include "fop_template.c" |
262 | 6ea83fed | bellard | #undef SFREG
|
263 | 6ea83fed | bellard | #undef DFREG
|
264 | 6ea83fed | bellard | #define SFREG 29 |
265 | 6ea83fed | bellard | #include "fop_template.c" |
266 | 6ea83fed | bellard | #undef SFREG
|
267 | 6ea83fed | bellard | #define SFREG 30 |
268 | 6ea83fed | bellard | #define DFREG 30 |
269 | 6ea83fed | bellard | #include "fop_template.c" |
270 | 6ea83fed | bellard | #undef SFREG
|
271 | 6ea83fed | bellard | #undef DFREG
|
272 | 6ea83fed | bellard | #define SFREG 31 |
273 | 6ea83fed | bellard | #include "fop_template.c" |
274 | 6ea83fed | bellard | #undef SFREG
|
275 | 6ea83fed | bellard | |
276 | 6ea83fed | bellard | #define FTN
|
277 | 6ea83fed | bellard | #include "fop_template.c" |
278 | 6ea83fed | bellard | #undef FTN
|
279 | 6ea83fed | bellard | |
280 | 6af0bf9c | bellard | void op_dup_T0 (void) |
281 | 6af0bf9c | bellard | { |
282 | 6af0bf9c | bellard | T2 = T0; |
283 | 6af0bf9c | bellard | RETURN(); |
284 | 6af0bf9c | bellard | } |
285 | 6af0bf9c | bellard | |
286 | 6af0bf9c | bellard | void op_load_HI (void) |
287 | 6af0bf9c | bellard | { |
288 | 6af0bf9c | bellard | T0 = env->HI; |
289 | 6af0bf9c | bellard | RETURN(); |
290 | 6af0bf9c | bellard | } |
291 | 6af0bf9c | bellard | |
292 | 6af0bf9c | bellard | void op_store_HI (void) |
293 | 6af0bf9c | bellard | { |
294 | 6af0bf9c | bellard | env->HI = T0; |
295 | 6af0bf9c | bellard | RETURN(); |
296 | 6af0bf9c | bellard | } |
297 | 6af0bf9c | bellard | |
298 | 6af0bf9c | bellard | void op_load_LO (void) |
299 | 6af0bf9c | bellard | { |
300 | 6af0bf9c | bellard | T0 = env->LO; |
301 | 6af0bf9c | bellard | RETURN(); |
302 | 6af0bf9c | bellard | } |
303 | 6af0bf9c | bellard | |
304 | 6af0bf9c | bellard | void op_store_LO (void) |
305 | 6af0bf9c | bellard | { |
306 | 6af0bf9c | bellard | env->LO = T0; |
307 | 6af0bf9c | bellard | RETURN(); |
308 | 6af0bf9c | bellard | } |
309 | 6af0bf9c | bellard | |
310 | 6af0bf9c | bellard | /* Load and store */
|
311 | 6af0bf9c | bellard | #define MEMSUFFIX _raw
|
312 | 6af0bf9c | bellard | #include "op_mem.c" |
313 | 6af0bf9c | bellard | #undef MEMSUFFIX
|
314 | 6af0bf9c | bellard | #if !defined(CONFIG_USER_ONLY)
|
315 | 6af0bf9c | bellard | #define MEMSUFFIX _user
|
316 | 6af0bf9c | bellard | #include "op_mem.c" |
317 | 6af0bf9c | bellard | #undef MEMSUFFIX
|
318 | 6af0bf9c | bellard | |
319 | 6af0bf9c | bellard | #define MEMSUFFIX _kernel
|
320 | 6af0bf9c | bellard | #include "op_mem.c" |
321 | 6af0bf9c | bellard | #undef MEMSUFFIX
|
322 | 6af0bf9c | bellard | #endif
|
323 | 6af0bf9c | bellard | |
324 | 6af0bf9c | bellard | /* Arithmetic */
|
325 | 6af0bf9c | bellard | void op_add (void) |
326 | 6af0bf9c | bellard | { |
327 | 5dc4b744 | ths | T0 = (int32_t)((int32_t)T0 + (int32_t)T1); |
328 | 6af0bf9c | bellard | RETURN(); |
329 | 6af0bf9c | bellard | } |
330 | 6af0bf9c | bellard | |
331 | 6af0bf9c | bellard | void op_addo (void) |
332 | 6af0bf9c | bellard | { |
333 | 6af0bf9c | bellard | target_ulong tmp; |
334 | 6af0bf9c | bellard | |
335 | c570fd16 | ths | tmp = (int32_t)T0; |
336 | c570fd16 | ths | T0 = (int32_t)T0 + (int32_t)T1; |
337 | 76e050c2 | bellard | if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) { |
338 | c570fd16 | ths | /* operands of same sign, result different sign */
|
339 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW); |
340 | 6af0bf9c | bellard | } |
341 | 5dc4b744 | ths | T0 = (int32_t)T0; |
342 | 6af0bf9c | bellard | RETURN(); |
343 | 6af0bf9c | bellard | } |
344 | 6af0bf9c | bellard | |
345 | 6af0bf9c | bellard | void op_sub (void) |
346 | 6af0bf9c | bellard | { |
347 | 5dc4b744 | ths | T0 = (int32_t)((int32_t)T0 - (int32_t)T1); |
348 | 6af0bf9c | bellard | RETURN(); |
349 | 6af0bf9c | bellard | } |
350 | 6af0bf9c | bellard | |
351 | 6af0bf9c | bellard | void op_subo (void) |
352 | 6af0bf9c | bellard | { |
353 | 6af0bf9c | bellard | target_ulong tmp; |
354 | 6af0bf9c | bellard | |
355 | c570fd16 | ths | tmp = (int32_t)T0; |
356 | 6af0bf9c | bellard | T0 = (int32_t)T0 - (int32_t)T1; |
357 | 76e050c2 | bellard | if (((tmp ^ T1) & (tmp ^ T0)) >> 31) { |
358 | c570fd16 | ths | /* operands of different sign, first operand and result different sign */
|
359 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW); |
360 | 6af0bf9c | bellard | } |
361 | 5dc4b744 | ths | T0 = (int32_t)T0; |
362 | 6af0bf9c | bellard | RETURN(); |
363 | 6af0bf9c | bellard | } |
364 | 6af0bf9c | bellard | |
365 | 6af0bf9c | bellard | void op_mul (void) |
366 | 6af0bf9c | bellard | { |
367 | 5dc4b744 | ths | T0 = (int32_t)((int32_t)T0 * (int32_t)T1); |
368 | 6af0bf9c | bellard | RETURN(); |
369 | 6af0bf9c | bellard | } |
370 | 6af0bf9c | bellard | |
371 | 6af0bf9c | bellard | void op_div (void) |
372 | 6af0bf9c | bellard | { |
373 | 6af0bf9c | bellard | if (T1 != 0) { |
374 | 5dc4b744 | ths | env->LO = (int32_t)((int32_t)T0 / (int32_t)T1); |
375 | 5dc4b744 | ths | env->HI = (int32_t)((int32_t)T0 % (int32_t)T1); |
376 | 6af0bf9c | bellard | } |
377 | 6af0bf9c | bellard | RETURN(); |
378 | 6af0bf9c | bellard | } |
379 | 6af0bf9c | bellard | |
380 | 6af0bf9c | bellard | void op_divu (void) |
381 | 6af0bf9c | bellard | { |
382 | 6af0bf9c | bellard | if (T1 != 0) { |
383 | 5dc4b744 | ths | env->LO = (int32_t)((uint32_t)T0 / (uint32_t)T1); |
384 | 5dc4b744 | ths | env->HI = (int32_t)((uint32_t)T0 % (uint32_t)T1); |
385 | c570fd16 | ths | } |
386 | c570fd16 | ths | RETURN(); |
387 | c570fd16 | ths | } |
388 | c570fd16 | ths | |
389 | 60aa19ab | ths | #ifdef TARGET_MIPS64
|
390 | c570fd16 | ths | /* Arithmetic */
|
391 | c570fd16 | ths | void op_dadd (void) |
392 | c570fd16 | ths | { |
393 | c570fd16 | ths | T0 += T1; |
394 | c570fd16 | ths | RETURN(); |
395 | c570fd16 | ths | } |
396 | c570fd16 | ths | |
397 | c570fd16 | ths | void op_daddo (void) |
398 | c570fd16 | ths | { |
399 | c570fd16 | ths | target_long tmp; |
400 | c570fd16 | ths | |
401 | c570fd16 | ths | tmp = T0; |
402 | c570fd16 | ths | T0 += T1; |
403 | c570fd16 | ths | if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 63) { |
404 | c570fd16 | ths | /* operands of same sign, result different sign */
|
405 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW); |
406 | c570fd16 | ths | } |
407 | c570fd16 | ths | RETURN(); |
408 | c570fd16 | ths | } |
409 | c570fd16 | ths | |
410 | c570fd16 | ths | void op_dsub (void) |
411 | c570fd16 | ths | { |
412 | c570fd16 | ths | T0 -= T1; |
413 | c570fd16 | ths | RETURN(); |
414 | c570fd16 | ths | } |
415 | c570fd16 | ths | |
416 | c570fd16 | ths | void op_dsubo (void) |
417 | c570fd16 | ths | { |
418 | c570fd16 | ths | target_long tmp; |
419 | c570fd16 | ths | |
420 | c570fd16 | ths | tmp = T0; |
421 | c570fd16 | ths | T0 = (int64_t)T0 - (int64_t)T1; |
422 | c570fd16 | ths | if (((tmp ^ T1) & (tmp ^ T0)) >> 63) { |
423 | c570fd16 | ths | /* operands of different sign, first operand and result different sign */
|
424 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW); |
425 | c570fd16 | ths | } |
426 | c570fd16 | ths | RETURN(); |
427 | c570fd16 | ths | } |
428 | c570fd16 | ths | |
429 | c570fd16 | ths | void op_dmul (void) |
430 | c570fd16 | ths | { |
431 | c570fd16 | ths | T0 = (int64_t)T0 * (int64_t)T1; |
432 | c570fd16 | ths | RETURN(); |
433 | c570fd16 | ths | } |
434 | c570fd16 | ths | |
435 | c570fd16 | ths | #if TARGET_LONG_BITS > HOST_LONG_BITS
|
436 | c570fd16 | ths | /* Those might call libgcc functions. */
|
437 | c570fd16 | ths | void op_ddiv (void) |
438 | c570fd16 | ths | { |
439 | c570fd16 | ths | do_ddiv(); |
440 | c570fd16 | ths | RETURN(); |
441 | c570fd16 | ths | } |
442 | c570fd16 | ths | |
443 | c570fd16 | ths | void op_ddivu (void) |
444 | c570fd16 | ths | { |
445 | c570fd16 | ths | do_ddivu(); |
446 | c570fd16 | ths | RETURN(); |
447 | c570fd16 | ths | } |
448 | c570fd16 | ths | #else
|
449 | c570fd16 | ths | void op_ddiv (void) |
450 | c570fd16 | ths | { |
451 | c570fd16 | ths | if (T1 != 0) { |
452 | c570fd16 | ths | env->LO = (int64_t)T0 / (int64_t)T1; |
453 | c570fd16 | ths | env->HI = (int64_t)T0 % (int64_t)T1; |
454 | c570fd16 | ths | } |
455 | c570fd16 | ths | RETURN(); |
456 | c570fd16 | ths | } |
457 | c570fd16 | ths | |
458 | c570fd16 | ths | void op_ddivu (void) |
459 | c570fd16 | ths | { |
460 | c570fd16 | ths | if (T1 != 0) { |
461 | 6af0bf9c | bellard | env->LO = T0 / T1; |
462 | 6af0bf9c | bellard | env->HI = T0 % T1; |
463 | 6af0bf9c | bellard | } |
464 | 6af0bf9c | bellard | RETURN(); |
465 | 6af0bf9c | bellard | } |
466 | c570fd16 | ths | #endif
|
467 | 60aa19ab | ths | #endif /* TARGET_MIPS64 */ |
468 | 6af0bf9c | bellard | |
469 | 6af0bf9c | bellard | /* Logical */
|
470 | 6af0bf9c | bellard | void op_and (void) |
471 | 6af0bf9c | bellard | { |
472 | 6af0bf9c | bellard | T0 &= T1; |
473 | 6af0bf9c | bellard | RETURN(); |
474 | 6af0bf9c | bellard | } |
475 | 6af0bf9c | bellard | |
476 | 6af0bf9c | bellard | void op_nor (void) |
477 | 6af0bf9c | bellard | { |
478 | 6af0bf9c | bellard | T0 = ~(T0 | T1); |
479 | 6af0bf9c | bellard | RETURN(); |
480 | 6af0bf9c | bellard | } |
481 | 6af0bf9c | bellard | |
482 | 6af0bf9c | bellard | void op_or (void) |
483 | 6af0bf9c | bellard | { |
484 | 6af0bf9c | bellard | T0 |= T1; |
485 | 6af0bf9c | bellard | RETURN(); |
486 | 6af0bf9c | bellard | } |
487 | 6af0bf9c | bellard | |
488 | 6af0bf9c | bellard | void op_xor (void) |
489 | 6af0bf9c | bellard | { |
490 | 6af0bf9c | bellard | T0 ^= T1; |
491 | 6af0bf9c | bellard | RETURN(); |
492 | 6af0bf9c | bellard | } |
493 | 6af0bf9c | bellard | |
494 | 6af0bf9c | bellard | void op_sll (void) |
495 | 6af0bf9c | bellard | { |
496 | 5a63bcb2 | ths | T0 = (int32_t)((uint32_t)T0 << T1); |
497 | 6af0bf9c | bellard | RETURN(); |
498 | 6af0bf9c | bellard | } |
499 | 6af0bf9c | bellard | |
500 | 6af0bf9c | bellard | void op_sra (void) |
501 | 6af0bf9c | bellard | { |
502 | 5a63bcb2 | ths | T0 = (int32_t)((int32_t)T0 >> T1); |
503 | 6af0bf9c | bellard | RETURN(); |
504 | 6af0bf9c | bellard | } |
505 | 6af0bf9c | bellard | |
506 | 6af0bf9c | bellard | void op_srl (void) |
507 | 6af0bf9c | bellard | { |
508 | 5a63bcb2 | ths | T0 = (int32_t)((uint32_t)T0 >> T1); |
509 | 6af0bf9c | bellard | RETURN(); |
510 | 6af0bf9c | bellard | } |
511 | 6af0bf9c | bellard | |
512 | 7a387fff | ths | void op_rotr (void) |
513 | 7a387fff | ths | { |
514 | 7a387fff | ths | target_ulong tmp; |
515 | 7a387fff | ths | |
516 | 7a387fff | ths | if (T1) {
|
517 | 5a63bcb2 | ths | tmp = (int32_t)((uint32_t)T0 << (0x20 - T1));
|
518 | 5a63bcb2 | ths | T0 = (int32_t)((uint32_t)T0 >> T1) | tmp; |
519 | 5a63bcb2 | ths | } |
520 | 7a387fff | ths | RETURN(); |
521 | 7a387fff | ths | } |
522 | 7a387fff | ths | |
523 | 6af0bf9c | bellard | void op_sllv (void) |
524 | 6af0bf9c | bellard | { |
525 | 5dc4b744 | ths | T0 = (int32_t)((uint32_t)T1 << ((uint32_t)T0 & 0x1F));
|
526 | 6af0bf9c | bellard | RETURN(); |
527 | 6af0bf9c | bellard | } |
528 | 6af0bf9c | bellard | |
529 | 6af0bf9c | bellard | void op_srav (void) |
530 | 6af0bf9c | bellard | { |
531 | 5dc4b744 | ths | T0 = (int32_t)((int32_t)T1 >> (T0 & 0x1F));
|
532 | 6af0bf9c | bellard | RETURN(); |
533 | 6af0bf9c | bellard | } |
534 | 6af0bf9c | bellard | |
535 | 6af0bf9c | bellard | void op_srlv (void) |
536 | 6af0bf9c | bellard | { |
537 | 5dc4b744 | ths | T0 = (int32_t)((uint32_t)T1 >> (T0 & 0x1F));
|
538 | 6af0bf9c | bellard | RETURN(); |
539 | 6af0bf9c | bellard | } |
540 | 6af0bf9c | bellard | |
541 | 7a387fff | ths | void op_rotrv (void) |
542 | 7a387fff | ths | { |
543 | 7a387fff | ths | target_ulong tmp; |
544 | 7a387fff | ths | |
545 | 7a387fff | ths | T0 &= 0x1F;
|
546 | 7a387fff | ths | if (T0) {
|
547 | 5dc4b744 | ths | tmp = (int32_t)((uint32_t)T1 << (0x20 - T0));
|
548 | 5dc4b744 | ths | T0 = (int32_t)((uint32_t)T1 >> T0) | tmp; |
549 | 7a387fff | ths | } else
|
550 | 7a387fff | ths | T0 = T1; |
551 | 7a387fff | ths | RETURN(); |
552 | 7a387fff | ths | } |
553 | 7a387fff | ths | |
554 | 6af0bf9c | bellard | void op_clo (void) |
555 | 6af0bf9c | bellard | { |
556 | 6af0bf9c | bellard | int n;
|
557 | 6af0bf9c | bellard | |
558 | c570fd16 | ths | if (T0 == ~((target_ulong)0)) { |
559 | 6af0bf9c | bellard | T0 = 32;
|
560 | 6af0bf9c | bellard | } else {
|
561 | 6af0bf9c | bellard | for (n = 0; n < 32; n++) { |
562 | 6af0bf9c | bellard | if (!(T0 & (1 << 31))) |
563 | 6af0bf9c | bellard | break;
|
564 | 6af0bf9c | bellard | T0 = T0 << 1;
|
565 | 6af0bf9c | bellard | } |
566 | 6af0bf9c | bellard | T0 = n; |
567 | 6af0bf9c | bellard | } |
568 | 6af0bf9c | bellard | RETURN(); |
569 | 6af0bf9c | bellard | } |
570 | 6af0bf9c | bellard | |
571 | 6af0bf9c | bellard | void op_clz (void) |
572 | 6af0bf9c | bellard | { |
573 | 6af0bf9c | bellard | int n;
|
574 | 6af0bf9c | bellard | |
575 | 6af0bf9c | bellard | if (T0 == 0) { |
576 | 6af0bf9c | bellard | T0 = 32;
|
577 | 6af0bf9c | bellard | } else {
|
578 | 6af0bf9c | bellard | for (n = 0; n < 32; n++) { |
579 | 6af0bf9c | bellard | if (T0 & (1 << 31)) |
580 | 6af0bf9c | bellard | break;
|
581 | 6af0bf9c | bellard | T0 = T0 << 1;
|
582 | 6af0bf9c | bellard | } |
583 | 6af0bf9c | bellard | T0 = n; |
584 | 6af0bf9c | bellard | } |
585 | 6af0bf9c | bellard | RETURN(); |
586 | 6af0bf9c | bellard | } |
587 | 6af0bf9c | bellard | |
588 | 60aa19ab | ths | #ifdef TARGET_MIPS64
|
589 | c570fd16 | ths | |
590 | c570fd16 | ths | #if TARGET_LONG_BITS > HOST_LONG_BITS
|
591 | c570fd16 | ths | /* Those might call libgcc functions. */
|
592 | c570fd16 | ths | void op_dsll (void) |
593 | 6af0bf9c | bellard | { |
594 | c570fd16 | ths | CALL_FROM_TB0(do_dsll); |
595 | c570fd16 | ths | RETURN(); |
596 | 6af0bf9c | bellard | } |
597 | 6af0bf9c | bellard | |
598 | c570fd16 | ths | void op_dsll32 (void) |
599 | 6af0bf9c | bellard | { |
600 | c570fd16 | ths | CALL_FROM_TB0(do_dsll32); |
601 | c570fd16 | ths | RETURN(); |
602 | 6af0bf9c | bellard | } |
603 | 6af0bf9c | bellard | |
604 | c570fd16 | ths | void op_dsra (void) |
605 | 6af0bf9c | bellard | { |
606 | c570fd16 | ths | CALL_FROM_TB0(do_dsra); |
607 | 6af0bf9c | bellard | RETURN(); |
608 | 6af0bf9c | bellard | } |
609 | 6af0bf9c | bellard | |
610 | c570fd16 | ths | void op_dsra32 (void) |
611 | 6af0bf9c | bellard | { |
612 | c570fd16 | ths | CALL_FROM_TB0(do_dsra32); |
613 | 6af0bf9c | bellard | RETURN(); |
614 | 6af0bf9c | bellard | } |
615 | 6af0bf9c | bellard | |
616 | c570fd16 | ths | void op_dsrl (void) |
617 | 6af0bf9c | bellard | { |
618 | c570fd16 | ths | CALL_FROM_TB0(do_dsrl); |
619 | c570fd16 | ths | RETURN(); |
620 | c570fd16 | ths | } |
621 | 6af0bf9c | bellard | |
622 | c570fd16 | ths | void op_dsrl32 (void) |
623 | c570fd16 | ths | { |
624 | c570fd16 | ths | CALL_FROM_TB0(do_dsrl32); |
625 | 6af0bf9c | bellard | RETURN(); |
626 | 6af0bf9c | bellard | } |
627 | 6af0bf9c | bellard | |
628 | c570fd16 | ths | void op_drotr (void) |
629 | 6af0bf9c | bellard | { |
630 | c570fd16 | ths | CALL_FROM_TB0(do_drotr); |
631 | c570fd16 | ths | RETURN(); |
632 | c570fd16 | ths | } |
633 | 6af0bf9c | bellard | |
634 | c570fd16 | ths | void op_drotr32 (void) |
635 | c570fd16 | ths | { |
636 | c570fd16 | ths | CALL_FROM_TB0(do_drotr32); |
637 | 6af0bf9c | bellard | RETURN(); |
638 | 6af0bf9c | bellard | } |
639 | 6af0bf9c | bellard | |
640 | c570fd16 | ths | void op_dsllv (void) |
641 | 6af0bf9c | bellard | { |
642 | c570fd16 | ths | CALL_FROM_TB0(do_dsllv); |
643 | c570fd16 | ths | RETURN(); |
644 | c570fd16 | ths | } |
645 | 6af0bf9c | bellard | |
646 | c570fd16 | ths | void op_dsrav (void) |
647 | c570fd16 | ths | { |
648 | c570fd16 | ths | CALL_FROM_TB0(do_dsrav); |
649 | 6af0bf9c | bellard | RETURN(); |
650 | 6af0bf9c | bellard | } |
651 | 6af0bf9c | bellard | |
652 | c570fd16 | ths | void op_dsrlv (void) |
653 | 6af0bf9c | bellard | { |
654 | c570fd16 | ths | CALL_FROM_TB0(do_dsrlv); |
655 | c570fd16 | ths | RETURN(); |
656 | c570fd16 | ths | } |
657 | 6af0bf9c | bellard | |
658 | c570fd16 | ths | void op_drotrv (void) |
659 | c570fd16 | ths | { |
660 | c570fd16 | ths | CALL_FROM_TB0(do_drotrv); |
661 | 6af0bf9c | bellard | RETURN(); |
662 | 6af0bf9c | bellard | } |
663 | c570fd16 | ths | |
664 | c570fd16 | ths | #else /* TARGET_LONG_BITS > HOST_LONG_BITS */ |
665 | c570fd16 | ths | |
666 | c570fd16 | ths | void op_dsll (void) |
667 | c570fd16 | ths | { |
668 | c570fd16 | ths | T0 = T0 << T1; |
669 | c570fd16 | ths | RETURN(); |
670 | c570fd16 | ths | } |
671 | c570fd16 | ths | |
672 | c570fd16 | ths | void op_dsll32 (void) |
673 | c570fd16 | ths | { |
674 | c570fd16 | ths | T0 = T0 << (T1 + 32);
|
675 | c570fd16 | ths | RETURN(); |
676 | c570fd16 | ths | } |
677 | c570fd16 | ths | |
678 | c570fd16 | ths | void op_dsra (void) |
679 | c570fd16 | ths | { |
680 | c570fd16 | ths | T0 = (int64_t)T0 >> T1; |
681 | c570fd16 | ths | RETURN(); |
682 | c570fd16 | ths | } |
683 | c570fd16 | ths | |
684 | c570fd16 | ths | void op_dsra32 (void) |
685 | c570fd16 | ths | { |
686 | c570fd16 | ths | T0 = (int64_t)T0 >> (T1 + 32);
|
687 | c570fd16 | ths | RETURN(); |
688 | c570fd16 | ths | } |
689 | c570fd16 | ths | |
690 | c570fd16 | ths | void op_dsrl (void) |
691 | c570fd16 | ths | { |
692 | c570fd16 | ths | T0 = T0 >> T1; |
693 | c570fd16 | ths | RETURN(); |
694 | c570fd16 | ths | } |
695 | c570fd16 | ths | |
696 | c570fd16 | ths | void op_dsrl32 (void) |
697 | c570fd16 | ths | { |
698 | c570fd16 | ths | T0 = T0 >> (T1 + 32);
|
699 | c570fd16 | ths | RETURN(); |
700 | c570fd16 | ths | } |
701 | c570fd16 | ths | |
702 | c570fd16 | ths | void op_drotr (void) |
703 | c570fd16 | ths | { |
704 | c570fd16 | ths | target_ulong tmp; |
705 | c570fd16 | ths | |
706 | c570fd16 | ths | if (T1) {
|
707 | c570fd16 | ths | tmp = T0 << (0x40 - T1);
|
708 | c570fd16 | ths | T0 = (T0 >> T1) | tmp; |
709 | 5a63bcb2 | ths | } |
710 | c570fd16 | ths | RETURN(); |
711 | c570fd16 | ths | } |
712 | c570fd16 | ths | |
713 | c570fd16 | ths | void op_drotr32 (void) |
714 | c570fd16 | ths | { |
715 | c570fd16 | ths | target_ulong tmp; |
716 | c570fd16 | ths | |
717 | c570fd16 | ths | if (T1) {
|
718 | c570fd16 | ths | tmp = T0 << (0x40 - (32 + T1)); |
719 | c570fd16 | ths | T0 = (T0 >> (32 + T1)) | tmp;
|
720 | 5a63bcb2 | ths | } |
721 | c570fd16 | ths | RETURN(); |
722 | c570fd16 | ths | } |
723 | c570fd16 | ths | |
724 | c570fd16 | ths | void op_dsllv (void) |
725 | c570fd16 | ths | { |
726 | c570fd16 | ths | T0 = T1 << (T0 & 0x3F);
|
727 | c570fd16 | ths | RETURN(); |
728 | c570fd16 | ths | } |
729 | c570fd16 | ths | |
730 | c570fd16 | ths | void op_dsrav (void) |
731 | c570fd16 | ths | { |
732 | c570fd16 | ths | T0 = (int64_t)T1 >> (T0 & 0x3F);
|
733 | c570fd16 | ths | RETURN(); |
734 | c570fd16 | ths | } |
735 | c570fd16 | ths | |
736 | c570fd16 | ths | void op_dsrlv (void) |
737 | c570fd16 | ths | { |
738 | c570fd16 | ths | T0 = T1 >> (T0 & 0x3F);
|
739 | c570fd16 | ths | RETURN(); |
740 | c570fd16 | ths | } |
741 | c570fd16 | ths | |
742 | c570fd16 | ths | void op_drotrv (void) |
743 | c570fd16 | ths | { |
744 | c570fd16 | ths | target_ulong tmp; |
745 | c570fd16 | ths | |
746 | c570fd16 | ths | T0 &= 0x3F;
|
747 | c570fd16 | ths | if (T0) {
|
748 | c570fd16 | ths | tmp = T1 << (0x40 - T0);
|
749 | c570fd16 | ths | T0 = (T1 >> T0) | tmp; |
750 | c570fd16 | ths | } else
|
751 | c570fd16 | ths | T0 = T1; |
752 | c570fd16 | ths | RETURN(); |
753 | c570fd16 | ths | } |
754 | c570fd16 | ths | #endif /* TARGET_LONG_BITS > HOST_LONG_BITS */ |
755 | c570fd16 | ths | |
756 | c570fd16 | ths | void op_dclo (void) |
757 | c570fd16 | ths | { |
758 | c570fd16 | ths | int n;
|
759 | c570fd16 | ths | |
760 | c570fd16 | ths | if (T0 == ~((target_ulong)0)) { |
761 | c570fd16 | ths | T0 = 64;
|
762 | c570fd16 | ths | } else {
|
763 | c570fd16 | ths | for (n = 0; n < 64; n++) { |
764 | c570fd16 | ths | if (!(T0 & (1ULL << 63))) |
765 | c570fd16 | ths | break;
|
766 | c570fd16 | ths | T0 = T0 << 1;
|
767 | c570fd16 | ths | } |
768 | c570fd16 | ths | T0 = n; |
769 | c570fd16 | ths | } |
770 | c570fd16 | ths | RETURN(); |
771 | c570fd16 | ths | } |
772 | c570fd16 | ths | |
773 | c570fd16 | ths | void op_dclz (void) |
774 | c570fd16 | ths | { |
775 | c570fd16 | ths | int n;
|
776 | c570fd16 | ths | |
777 | c570fd16 | ths | if (T0 == 0) { |
778 | c570fd16 | ths | T0 = 64;
|
779 | c570fd16 | ths | } else {
|
780 | c570fd16 | ths | for (n = 0; n < 64; n++) { |
781 | c570fd16 | ths | if (T0 & (1ULL << 63)) |
782 | c570fd16 | ths | break;
|
783 | c570fd16 | ths | T0 = T0 << 1;
|
784 | c570fd16 | ths | } |
785 | c570fd16 | ths | T0 = n; |
786 | c570fd16 | ths | } |
787 | c570fd16 | ths | RETURN(); |
788 | c570fd16 | ths | } |
789 | c570fd16 | ths | #endif
|
790 | c570fd16 | ths | |
791 | c570fd16 | ths | /* 64 bits arithmetic */
|
792 | c570fd16 | ths | #if TARGET_LONG_BITS > HOST_LONG_BITS
|
793 | 6af0bf9c | bellard | void op_mult (void) |
794 | 6af0bf9c | bellard | { |
795 | 6af0bf9c | bellard | CALL_FROM_TB0(do_mult); |
796 | 6af0bf9c | bellard | RETURN(); |
797 | 6af0bf9c | bellard | } |
798 | 6af0bf9c | bellard | |
799 | 6af0bf9c | bellard | void op_multu (void) |
800 | 6af0bf9c | bellard | { |
801 | 6af0bf9c | bellard | CALL_FROM_TB0(do_multu); |
802 | 6af0bf9c | bellard | RETURN(); |
803 | 6af0bf9c | bellard | } |
804 | 6af0bf9c | bellard | |
805 | 6af0bf9c | bellard | void op_madd (void) |
806 | 6af0bf9c | bellard | { |
807 | 6af0bf9c | bellard | CALL_FROM_TB0(do_madd); |
808 | 6af0bf9c | bellard | RETURN(); |
809 | 6af0bf9c | bellard | } |
810 | 6af0bf9c | bellard | |
811 | 6af0bf9c | bellard | void op_maddu (void) |
812 | 6af0bf9c | bellard | { |
813 | 6af0bf9c | bellard | CALL_FROM_TB0(do_maddu); |
814 | 6af0bf9c | bellard | RETURN(); |
815 | 6af0bf9c | bellard | } |
816 | 6af0bf9c | bellard | |
817 | 6af0bf9c | bellard | void op_msub (void) |
818 | 6af0bf9c | bellard | { |
819 | 6af0bf9c | bellard | CALL_FROM_TB0(do_msub); |
820 | 6af0bf9c | bellard | RETURN(); |
821 | 6af0bf9c | bellard | } |
822 | 6af0bf9c | bellard | |
823 | 6af0bf9c | bellard | void op_msubu (void) |
824 | 6af0bf9c | bellard | { |
825 | 6af0bf9c | bellard | CALL_FROM_TB0(do_msubu); |
826 | 6af0bf9c | bellard | RETURN(); |
827 | 6af0bf9c | bellard | } |
828 | c570fd16 | ths | |
829 | c570fd16 | ths | #else /* TARGET_LONG_BITS > HOST_LONG_BITS */ |
830 | c570fd16 | ths | |
831 | c570fd16 | ths | static inline uint64_t get_HILO (void) |
832 | c570fd16 | ths | { |
833 | c570fd16 | ths | return ((uint64_t)env->HI << 32) | ((uint64_t)(uint32_t)env->LO); |
834 | c570fd16 | ths | } |
835 | c570fd16 | ths | |
836 | c570fd16 | ths | static inline void set_HILO (uint64_t HILO) |
837 | c570fd16 | ths | { |
838 | 5dc4b744 | ths | env->LO = (int32_t)(HILO & 0xFFFFFFFF);
|
839 | 5dc4b744 | ths | env->HI = (int32_t)(HILO >> 32);
|
840 | c570fd16 | ths | } |
841 | c570fd16 | ths | |
842 | c570fd16 | ths | void op_mult (void) |
843 | c570fd16 | ths | { |
844 | c570fd16 | ths | set_HILO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
845 | c570fd16 | ths | RETURN(); |
846 | c570fd16 | ths | } |
847 | c570fd16 | ths | |
848 | c570fd16 | ths | void op_multu (void) |
849 | c570fd16 | ths | { |
850 | c570fd16 | ths | set_HILO((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1); |
851 | c570fd16 | ths | RETURN(); |
852 | c570fd16 | ths | } |
853 | c570fd16 | ths | |
854 | c570fd16 | ths | void op_madd (void) |
855 | c570fd16 | ths | { |
856 | c570fd16 | ths | int64_t tmp; |
857 | c570fd16 | ths | |
858 | c570fd16 | ths | tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
859 | c570fd16 | ths | set_HILO((int64_t)get_HILO() + tmp); |
860 | c570fd16 | ths | RETURN(); |
861 | c570fd16 | ths | } |
862 | c570fd16 | ths | |
863 | c570fd16 | ths | void op_maddu (void) |
864 | c570fd16 | ths | { |
865 | c570fd16 | ths | uint64_t tmp; |
866 | c570fd16 | ths | |
867 | c570fd16 | ths | tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1); |
868 | c570fd16 | ths | set_HILO(get_HILO() + tmp); |
869 | c570fd16 | ths | RETURN(); |
870 | c570fd16 | ths | } |
871 | c570fd16 | ths | |
872 | c570fd16 | ths | void op_msub (void) |
873 | c570fd16 | ths | { |
874 | c570fd16 | ths | int64_t tmp; |
875 | c570fd16 | ths | |
876 | c570fd16 | ths | tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
877 | c570fd16 | ths | set_HILO((int64_t)get_HILO() - tmp); |
878 | c570fd16 | ths | RETURN(); |
879 | c570fd16 | ths | } |
880 | c570fd16 | ths | |
881 | c570fd16 | ths | void op_msubu (void) |
882 | c570fd16 | ths | { |
883 | c570fd16 | ths | uint64_t tmp; |
884 | c570fd16 | ths | |
885 | c570fd16 | ths | tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1); |
886 | c570fd16 | ths | set_HILO(get_HILO() - tmp); |
887 | c570fd16 | ths | RETURN(); |
888 | c570fd16 | ths | } |
889 | c570fd16 | ths | #endif /* TARGET_LONG_BITS > HOST_LONG_BITS */ |
890 | c570fd16 | ths | |
891 | 60aa19ab | ths | #ifdef TARGET_MIPS64
|
892 | c570fd16 | ths | void op_dmult (void) |
893 | c570fd16 | ths | { |
894 | c570fd16 | ths | CALL_FROM_TB0(do_dmult); |
895 | c570fd16 | ths | RETURN(); |
896 | c570fd16 | ths | } |
897 | c570fd16 | ths | |
898 | c570fd16 | ths | void op_dmultu (void) |
899 | c570fd16 | ths | { |
900 | c570fd16 | ths | CALL_FROM_TB0(do_dmultu); |
901 | c570fd16 | ths | RETURN(); |
902 | c570fd16 | ths | } |
903 | 6af0bf9c | bellard | #endif
|
904 | 6af0bf9c | bellard | |
905 | 6af0bf9c | bellard | /* Conditional moves */
|
906 | 6af0bf9c | bellard | void op_movn (void) |
907 | 6af0bf9c | bellard | { |
908 | 6af0bf9c | bellard | if (T1 != 0) |
909 | 6af0bf9c | bellard | env->gpr[PARAM1] = T0; |
910 | 6af0bf9c | bellard | RETURN(); |
911 | 6af0bf9c | bellard | } |
912 | 6af0bf9c | bellard | |
913 | 6af0bf9c | bellard | void op_movz (void) |
914 | 6af0bf9c | bellard | { |
915 | 6af0bf9c | bellard | if (T1 == 0) |
916 | 6af0bf9c | bellard | env->gpr[PARAM1] = T0; |
917 | 6af0bf9c | bellard | RETURN(); |
918 | 6af0bf9c | bellard | } |
919 | 6af0bf9c | bellard | |
920 | 7a387fff | ths | void op_movf (void) |
921 | 7a387fff | ths | { |
922 | 7a387fff | ths | if (!(env->fcr31 & PARAM1))
|
923 | 7a387fff | ths | env->gpr[PARAM2] = env->gpr[PARAM3]; |
924 | 7a387fff | ths | RETURN(); |
925 | 7a387fff | ths | } |
926 | 7a387fff | ths | |
927 | 7a387fff | ths | void op_movt (void) |
928 | 7a387fff | ths | { |
929 | 7a387fff | ths | if (env->fcr31 & PARAM1)
|
930 | 7a387fff | ths | env->gpr[PARAM2] = env->gpr[PARAM3]; |
931 | 7a387fff | ths | RETURN(); |
932 | 7a387fff | ths | } |
933 | 7a387fff | ths | |
934 | 6af0bf9c | bellard | /* Tests */
|
935 | 6af0bf9c | bellard | #define OP_COND(name, cond) \
|
936 | 6af0bf9c | bellard | void glue(op_, name) (void) \ |
937 | 6af0bf9c | bellard | { \ |
938 | 6af0bf9c | bellard | if (cond) { \
|
939 | 6af0bf9c | bellard | T0 = 1; \
|
940 | 6af0bf9c | bellard | } else { \
|
941 | 6af0bf9c | bellard | T0 = 0; \
|
942 | 6af0bf9c | bellard | } \ |
943 | 6af0bf9c | bellard | RETURN(); \ |
944 | 6af0bf9c | bellard | } |
945 | 6af0bf9c | bellard | |
946 | 6af0bf9c | bellard | OP_COND(eq, T0 == T1); |
947 | 6af0bf9c | bellard | OP_COND(ne, T0 != T1); |
948 | 6af0bf9c | bellard | OP_COND(ge, (int32_t)T0 >= (int32_t)T1); |
949 | 6af0bf9c | bellard | OP_COND(geu, T0 >= T1); |
950 | 6af0bf9c | bellard | OP_COND(lt, (int32_t)T0 < (int32_t)T1); |
951 | 6af0bf9c | bellard | OP_COND(ltu, T0 < T1); |
952 | 6af0bf9c | bellard | OP_COND(gez, (int32_t)T0 >= 0);
|
953 | 6af0bf9c | bellard | OP_COND(gtz, (int32_t)T0 > 0);
|
954 | 6af0bf9c | bellard | OP_COND(lez, (int32_t)T0 <= 0);
|
955 | 6af0bf9c | bellard | OP_COND(ltz, (int32_t)T0 < 0);
|
956 | 6af0bf9c | bellard | |
957 | 7a387fff | ths | /* Branches */
|
958 | 6af0bf9c | bellard | //#undef USE_DIRECT_JUMP
|
959 | c53be334 | bellard | |
960 | c53be334 | bellard | void OPPROTO op_goto_tb0(void) |
961 | c53be334 | bellard | { |
962 | c53be334 | bellard | GOTO_TB(op_goto_tb0, PARAM1, 0);
|
963 | 7a387fff | ths | RETURN(); |
964 | c53be334 | bellard | } |
965 | c53be334 | bellard | |
966 | c53be334 | bellard | void OPPROTO op_goto_tb1(void) |
967 | c53be334 | bellard | { |
968 | c53be334 | bellard | GOTO_TB(op_goto_tb1, PARAM1, 1);
|
969 | 7a387fff | ths | RETURN(); |
970 | c53be334 | bellard | } |
971 | 6af0bf9c | bellard | |
972 | 6af0bf9c | bellard | /* Branch to register */
|
973 | 6af0bf9c | bellard | void op_save_breg_target (void) |
974 | 6af0bf9c | bellard | { |
975 | 6af0bf9c | bellard | env->btarget = T2; |
976 | 7a387fff | ths | RETURN(); |
977 | 6af0bf9c | bellard | } |
978 | 6af0bf9c | bellard | |
979 | 6af0bf9c | bellard | void op_restore_breg_target (void) |
980 | 6af0bf9c | bellard | { |
981 | 6af0bf9c | bellard | T2 = env->btarget; |
982 | 7a387fff | ths | RETURN(); |
983 | 6af0bf9c | bellard | } |
984 | 6af0bf9c | bellard | |
985 | 6af0bf9c | bellard | void op_breg (void) |
986 | 6af0bf9c | bellard | { |
987 | 6af0bf9c | bellard | env->PC = T2; |
988 | 6af0bf9c | bellard | RETURN(); |
989 | 6af0bf9c | bellard | } |
990 | 6af0bf9c | bellard | |
991 | 6af0bf9c | bellard | void op_save_btarget (void) |
992 | 6af0bf9c | bellard | { |
993 | 6af0bf9c | bellard | env->btarget = PARAM1; |
994 | 6af0bf9c | bellard | RETURN(); |
995 | 6af0bf9c | bellard | } |
996 | 6af0bf9c | bellard | |
997 | 6af0bf9c | bellard | /* Conditional branch */
|
998 | 6af0bf9c | bellard | void op_set_bcond (void) |
999 | 6af0bf9c | bellard | { |
1000 | 6af0bf9c | bellard | T2 = T0; |
1001 | 6af0bf9c | bellard | RETURN(); |
1002 | 6af0bf9c | bellard | } |
1003 | 6af0bf9c | bellard | |
1004 | 6af0bf9c | bellard | void op_save_bcond (void) |
1005 | 6af0bf9c | bellard | { |
1006 | 6af0bf9c | bellard | env->bcond = T2; |
1007 | 6af0bf9c | bellard | RETURN(); |
1008 | 6af0bf9c | bellard | } |
1009 | 6af0bf9c | bellard | |
1010 | 6af0bf9c | bellard | void op_restore_bcond (void) |
1011 | 6af0bf9c | bellard | { |
1012 | 6af0bf9c | bellard | T2 = env->bcond; |
1013 | 6af0bf9c | bellard | RETURN(); |
1014 | 6af0bf9c | bellard | } |
1015 | 6af0bf9c | bellard | |
1016 | c53be334 | bellard | void op_jnz_T2 (void) |
1017 | 6af0bf9c | bellard | { |
1018 | c53be334 | bellard | if (T2)
|
1019 | c53be334 | bellard | GOTO_LABEL_PARAM(1);
|
1020 | 6af0bf9c | bellard | RETURN(); |
1021 | 6af0bf9c | bellard | } |
1022 | 6af0bf9c | bellard | |
1023 | 6af0bf9c | bellard | /* CP0 functions */
|
1024 | 873eb012 | ths | void op_mfc0_index (void) |
1025 | 6af0bf9c | bellard | { |
1026 | 9c2149c8 | ths | T0 = env->CP0_Index; |
1027 | 873eb012 | ths | RETURN(); |
1028 | 873eb012 | ths | } |
1029 | 873eb012 | ths | |
1030 | 873eb012 | ths | void op_mfc0_random (void) |
1031 | 873eb012 | ths | { |
1032 | 873eb012 | ths | CALL_FROM_TB0(do_mfc0_random); |
1033 | 873eb012 | ths | RETURN(); |
1034 | 873eb012 | ths | } |
1035 | 873eb012 | ths | |
1036 | 873eb012 | ths | void op_mfc0_entrylo0 (void) |
1037 | 873eb012 | ths | { |
1038 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_EntryLo0; |
1039 | 873eb012 | ths | RETURN(); |
1040 | 873eb012 | ths | } |
1041 | 873eb012 | ths | |
1042 | 873eb012 | ths | void op_mfc0_entrylo1 (void) |
1043 | 873eb012 | ths | { |
1044 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_EntryLo1; |
1045 | 873eb012 | ths | RETURN(); |
1046 | 873eb012 | ths | } |
1047 | 873eb012 | ths | |
1048 | 873eb012 | ths | void op_mfc0_context (void) |
1049 | 873eb012 | ths | { |
1050 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_Context; |
1051 | 873eb012 | ths | RETURN(); |
1052 | 873eb012 | ths | } |
1053 | 873eb012 | ths | |
1054 | 873eb012 | ths | void op_mfc0_pagemask (void) |
1055 | 873eb012 | ths | { |
1056 | 9c2149c8 | ths | T0 = env->CP0_PageMask; |
1057 | 873eb012 | ths | RETURN(); |
1058 | 873eb012 | ths | } |
1059 | 873eb012 | ths | |
1060 | 7a387fff | ths | void op_mfc0_pagegrain (void) |
1061 | 7a387fff | ths | { |
1062 | 9c2149c8 | ths | T0 = env->CP0_PageGrain; |
1063 | 7a387fff | ths | RETURN(); |
1064 | 7a387fff | ths | } |
1065 | 7a387fff | ths | |
1066 | 873eb012 | ths | void op_mfc0_wired (void) |
1067 | 873eb012 | ths | { |
1068 | 9c2149c8 | ths | T0 = env->CP0_Wired; |
1069 | 873eb012 | ths | RETURN(); |
1070 | 873eb012 | ths | } |
1071 | 873eb012 | ths | |
1072 | 7a387fff | ths | void op_mfc0_hwrena (void) |
1073 | 7a387fff | ths | { |
1074 | 9c2149c8 | ths | T0 = env->CP0_HWREna; |
1075 | 7a387fff | ths | RETURN(); |
1076 | 7a387fff | ths | } |
1077 | 7a387fff | ths | |
1078 | 873eb012 | ths | void op_mfc0_badvaddr (void) |
1079 | 873eb012 | ths | { |
1080 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_BadVAddr; |
1081 | 873eb012 | ths | RETURN(); |
1082 | 873eb012 | ths | } |
1083 | 873eb012 | ths | |
1084 | 873eb012 | ths | void op_mfc0_count (void) |
1085 | 873eb012 | ths | { |
1086 | 873eb012 | ths | CALL_FROM_TB0(do_mfc0_count); |
1087 | 873eb012 | ths | RETURN(); |
1088 | 873eb012 | ths | } |
1089 | 873eb012 | ths | |
1090 | 873eb012 | ths | void op_mfc0_entryhi (void) |
1091 | 873eb012 | ths | { |
1092 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_EntryHi; |
1093 | 873eb012 | ths | RETURN(); |
1094 | 873eb012 | ths | } |
1095 | 873eb012 | ths | |
1096 | 873eb012 | ths | void op_mfc0_compare (void) |
1097 | 873eb012 | ths | { |
1098 | 9c2149c8 | ths | T0 = env->CP0_Compare; |
1099 | 873eb012 | ths | RETURN(); |
1100 | 873eb012 | ths | } |
1101 | 873eb012 | ths | |
1102 | 873eb012 | ths | void op_mfc0_status (void) |
1103 | 873eb012 | ths | { |
1104 | 9c2149c8 | ths | T0 = env->CP0_Status; |
1105 | 873eb012 | ths | RETURN(); |
1106 | 873eb012 | ths | } |
1107 | 873eb012 | ths | |
1108 | 7a387fff | ths | void op_mfc0_intctl (void) |
1109 | 7a387fff | ths | { |
1110 | 9c2149c8 | ths | T0 = env->CP0_IntCtl; |
1111 | 7a387fff | ths | RETURN(); |
1112 | 7a387fff | ths | } |
1113 | 7a387fff | ths | |
1114 | 7a387fff | ths | void op_mfc0_srsctl (void) |
1115 | 7a387fff | ths | { |
1116 | 9c2149c8 | ths | T0 = env->CP0_SRSCtl; |
1117 | 9c2149c8 | ths | RETURN(); |
1118 | 9c2149c8 | ths | } |
1119 | 9c2149c8 | ths | |
1120 | 9c2149c8 | ths | void op_mfc0_srsmap (void) |
1121 | 9c2149c8 | ths | { |
1122 | 9c2149c8 | ths | T0 = env->CP0_SRSMap; |
1123 | 7a387fff | ths | RETURN(); |
1124 | 7a387fff | ths | } |
1125 | 7a387fff | ths | |
1126 | 873eb012 | ths | void op_mfc0_cause (void) |
1127 | 873eb012 | ths | { |
1128 | 9c2149c8 | ths | T0 = env->CP0_Cause; |
1129 | 873eb012 | ths | RETURN(); |
1130 | 873eb012 | ths | } |
1131 | 873eb012 | ths | |
1132 | 873eb012 | ths | void op_mfc0_epc (void) |
1133 | 873eb012 | ths | { |
1134 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_EPC; |
1135 | 873eb012 | ths | RETURN(); |
1136 | 873eb012 | ths | } |
1137 | 873eb012 | ths | |
1138 | 873eb012 | ths | void op_mfc0_prid (void) |
1139 | 873eb012 | ths | { |
1140 | 9c2149c8 | ths | T0 = env->CP0_PRid; |
1141 | 873eb012 | ths | RETURN(); |
1142 | 873eb012 | ths | } |
1143 | 873eb012 | ths | |
1144 | 7a387fff | ths | void op_mfc0_ebase (void) |
1145 | 7a387fff | ths | { |
1146 | b29a0341 | ths | T0 = env->CP0_EBase; |
1147 | 7a387fff | ths | RETURN(); |
1148 | 7a387fff | ths | } |
1149 | 7a387fff | ths | |
1150 | 873eb012 | ths | void op_mfc0_config0 (void) |
1151 | 873eb012 | ths | { |
1152 | 9c2149c8 | ths | T0 = env->CP0_Config0; |
1153 | 873eb012 | ths | RETURN(); |
1154 | 873eb012 | ths | } |
1155 | 873eb012 | ths | |
1156 | 873eb012 | ths | void op_mfc0_config1 (void) |
1157 | 873eb012 | ths | { |
1158 | 9c2149c8 | ths | T0 = env->CP0_Config1; |
1159 | 873eb012 | ths | RETURN(); |
1160 | 873eb012 | ths | } |
1161 | 873eb012 | ths | |
1162 | 7a387fff | ths | void op_mfc0_config2 (void) |
1163 | 7a387fff | ths | { |
1164 | 9c2149c8 | ths | T0 = env->CP0_Config2; |
1165 | 7a387fff | ths | RETURN(); |
1166 | 7a387fff | ths | } |
1167 | 7a387fff | ths | |
1168 | 7a387fff | ths | void op_mfc0_config3 (void) |
1169 | 7a387fff | ths | { |
1170 | 9c2149c8 | ths | T0 = env->CP0_Config3; |
1171 | 7a387fff | ths | RETURN(); |
1172 | 7a387fff | ths | } |
1173 | 7a387fff | ths | |
1174 | e397ee33 | ths | void op_mfc0_config6 (void) |
1175 | e397ee33 | ths | { |
1176 | e397ee33 | ths | T0 = env->CP0_Config6; |
1177 | e397ee33 | ths | RETURN(); |
1178 | e397ee33 | ths | } |
1179 | e397ee33 | ths | |
1180 | e397ee33 | ths | void op_mfc0_config7 (void) |
1181 | e397ee33 | ths | { |
1182 | e397ee33 | ths | T0 = env->CP0_Config7; |
1183 | e397ee33 | ths | RETURN(); |
1184 | e397ee33 | ths | } |
1185 | e397ee33 | ths | |
1186 | 873eb012 | ths | void op_mfc0_lladdr (void) |
1187 | 873eb012 | ths | { |
1188 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_LLAddr >> 4;
|
1189 | 873eb012 | ths | RETURN(); |
1190 | 873eb012 | ths | } |
1191 | 873eb012 | ths | |
1192 | 7a387fff | ths | void op_mfc0_watchlo0 (void) |
1193 | 873eb012 | ths | { |
1194 | 5dc4b744 | ths | T0 = (int32_t)env->CP0_WatchLo; |
1195 | 873eb012 | ths | RETURN(); |
1196 | 873eb012 | ths | } |
1197 | 873eb012 | ths | |
1198 | 7a387fff | ths | void op_mfc0_watchhi0 (void) |
1199 | 873eb012 | ths | { |
1200 | 9c2149c8 | ths | T0 = env->CP0_WatchHi; |
1201 | 873eb012 | ths | RETURN(); |
1202 | 873eb012 | ths | } |
1203 | 873eb012 | ths | |
1204 | 7a387fff | ths | void op_mfc0_xcontext (void) |
1205 | 7a387fff | ths | { |
1206 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_XContext; |
1207 | 7a387fff | ths | RETURN(); |
1208 | 7a387fff | ths | } |
1209 | 7a387fff | ths | |
1210 | 7a387fff | ths | void op_mfc0_framemask (void) |
1211 | 7a387fff | ths | { |
1212 | 7a387fff | ths | T0 = env->CP0_Framemask; |
1213 | 7a387fff | ths | RETURN(); |
1214 | 7a387fff | ths | } |
1215 | 7a387fff | ths | |
1216 | 873eb012 | ths | void op_mfc0_debug (void) |
1217 | 873eb012 | ths | { |
1218 | 9c2149c8 | ths | T0 = env->CP0_Debug; |
1219 | 873eb012 | ths | if (env->hflags & MIPS_HFLAG_DM)
|
1220 | 873eb012 | ths | T0 |= 1 << CP0DB_DM;
|
1221 | 873eb012 | ths | RETURN(); |
1222 | 873eb012 | ths | } |
1223 | 873eb012 | ths | |
1224 | 873eb012 | ths | void op_mfc0_depc (void) |
1225 | 873eb012 | ths | { |
1226 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_DEPC; |
1227 | 873eb012 | ths | RETURN(); |
1228 | 873eb012 | ths | } |
1229 | 873eb012 | ths | |
1230 | 7a387fff | ths | void op_mfc0_performance0 (void) |
1231 | 7a387fff | ths | { |
1232 | 9c2149c8 | ths | T0 = env->CP0_Performance0; |
1233 | 7a387fff | ths | RETURN(); |
1234 | 7a387fff | ths | } |
1235 | 7a387fff | ths | |
1236 | 873eb012 | ths | void op_mfc0_taglo (void) |
1237 | 873eb012 | ths | { |
1238 | 9c2149c8 | ths | T0 = env->CP0_TagLo; |
1239 | 873eb012 | ths | RETURN(); |
1240 | 873eb012 | ths | } |
1241 | 873eb012 | ths | |
1242 | 873eb012 | ths | void op_mfc0_datalo (void) |
1243 | 873eb012 | ths | { |
1244 | 9c2149c8 | ths | T0 = env->CP0_DataLo; |
1245 | 873eb012 | ths | RETURN(); |
1246 | 873eb012 | ths | } |
1247 | 873eb012 | ths | |
1248 | 7a387fff | ths | void op_mfc0_taghi (void) |
1249 | 7a387fff | ths | { |
1250 | 9c2149c8 | ths | T0 = env->CP0_TagHi; |
1251 | 7a387fff | ths | RETURN(); |
1252 | 7a387fff | ths | } |
1253 | 7a387fff | ths | |
1254 | 7a387fff | ths | void op_mfc0_datahi (void) |
1255 | 7a387fff | ths | { |
1256 | 9c2149c8 | ths | T0 = env->CP0_DataHi; |
1257 | 7a387fff | ths | RETURN(); |
1258 | 7a387fff | ths | } |
1259 | 7a387fff | ths | |
1260 | 873eb012 | ths | void op_mfc0_errorepc (void) |
1261 | 873eb012 | ths | { |
1262 | 9c2149c8 | ths | T0 = (int32_t)env->CP0_ErrorEPC; |
1263 | 873eb012 | ths | RETURN(); |
1264 | 873eb012 | ths | } |
1265 | 873eb012 | ths | |
1266 | 873eb012 | ths | void op_mfc0_desave (void) |
1267 | 873eb012 | ths | { |
1268 | 9c2149c8 | ths | T0 = env->CP0_DESAVE; |
1269 | 6af0bf9c | bellard | RETURN(); |
1270 | 6af0bf9c | bellard | } |
1271 | 6af0bf9c | bellard | |
1272 | 8c0fdd85 | ths | void op_mtc0_index (void) |
1273 | 6af0bf9c | bellard | { |
1274 | 9c2149c8 | ths | env->CP0_Index = (env->CP0_Index & 0x80000000) | (T0 & (MIPS_TLB_NB - 1)); |
1275 | 8c0fdd85 | ths | RETURN(); |
1276 | 8c0fdd85 | ths | } |
1277 | 8c0fdd85 | ths | |
1278 | 8c0fdd85 | ths | void op_mtc0_entrylo0 (void) |
1279 | 8c0fdd85 | ths | { |
1280 | 7a387fff | ths | /* Large physaddr not implemented */
|
1281 | 7a387fff | ths | /* 1k pages not implemented */
|
1282 | 9c2149c8 | ths | env->CP0_EntryLo0 = (int32_t)T0 & 0x3FFFFFFF;
|
1283 | 8c0fdd85 | ths | RETURN(); |
1284 | 8c0fdd85 | ths | } |
1285 | 8c0fdd85 | ths | |
1286 | 8c0fdd85 | ths | void op_mtc0_entrylo1 (void) |
1287 | 8c0fdd85 | ths | { |
1288 | 7a387fff | ths | /* Large physaddr not implemented */
|
1289 | 7a387fff | ths | /* 1k pages not implemented */
|
1290 | 9c2149c8 | ths | env->CP0_EntryLo1 = (int32_t)T0 & 0x3FFFFFFF;
|
1291 | 8c0fdd85 | ths | RETURN(); |
1292 | 8c0fdd85 | ths | } |
1293 | 8c0fdd85 | ths | |
1294 | 8c0fdd85 | ths | void op_mtc0_context (void) |
1295 | 8c0fdd85 | ths | { |
1296 | 7a387fff | ths | env->CP0_Context = (env->CP0_Context & ~0x007FFFFF) | (T0 & 0x007FFFF0); |
1297 | 8c0fdd85 | ths | RETURN(); |
1298 | 8c0fdd85 | ths | } |
1299 | 8c0fdd85 | ths | |
1300 | 8c0fdd85 | ths | void op_mtc0_pagemask (void) |
1301 | 8c0fdd85 | ths | { |
1302 | 7a387fff | ths | /* 1k pages not implemented */
|
1303 | 7a387fff | ths | env->CP0_PageMask = T0 & 0x1FFFE000;
|
1304 | 7a387fff | ths | RETURN(); |
1305 | 7a387fff | ths | } |
1306 | 7a387fff | ths | |
1307 | 7a387fff | ths | void op_mtc0_pagegrain (void) |
1308 | 7a387fff | ths | { |
1309 | 7a387fff | ths | /* SmartMIPS not implemented */
|
1310 | 7a387fff | ths | /* Large physaddr not implemented */
|
1311 | 7a387fff | ths | /* 1k pages not implemented */
|
1312 | 7a387fff | ths | env->CP0_PageGrain = 0;
|
1313 | 8c0fdd85 | ths | RETURN(); |
1314 | 8c0fdd85 | ths | } |
1315 | 8c0fdd85 | ths | |
1316 | 8c0fdd85 | ths | void op_mtc0_wired (void) |
1317 | 8c0fdd85 | ths | { |
1318 | 7a387fff | ths | env->CP0_Wired = T0 & (MIPS_TLB_NB - 1);
|
1319 | 7a387fff | ths | RETURN(); |
1320 | 7a387fff | ths | } |
1321 | 7a387fff | ths | |
1322 | 7a387fff | ths | void op_mtc0_hwrena (void) |
1323 | 7a387fff | ths | { |
1324 | 7a387fff | ths | env->CP0_HWREna = T0 & 0x0000000F;
|
1325 | 8c0fdd85 | ths | RETURN(); |
1326 | 8c0fdd85 | ths | } |
1327 | 8c0fdd85 | ths | |
1328 | 8c0fdd85 | ths | void op_mtc0_count (void) |
1329 | 8c0fdd85 | ths | { |
1330 | 8c0fdd85 | ths | CALL_FROM_TB2(cpu_mips_store_count, env, T0); |
1331 | 8c0fdd85 | ths | RETURN(); |
1332 | 8c0fdd85 | ths | } |
1333 | 8c0fdd85 | ths | |
1334 | 8c0fdd85 | ths | void op_mtc0_entryhi (void) |
1335 | 8c0fdd85 | ths | { |
1336 | 0feef828 | ths | target_ulong old, val; |
1337 | 8c0fdd85 | ths | |
1338 | 7a387fff | ths | /* 1k pages not implemented */
|
1339 | 7a387fff | ths | /* Ignore MIPS64 TLB for now */
|
1340 | 925fd0f2 | ths | val = (target_ulong)(int32_t)T0 & ~(target_ulong)0x1F00;
|
1341 | 8c0fdd85 | ths | old = env->CP0_EntryHi; |
1342 | 8c0fdd85 | ths | env->CP0_EntryHi = val; |
1343 | 8c0fdd85 | ths | /* If the ASID changes, flush qemu's TLB. */
|
1344 | 8c0fdd85 | ths | if ((old & 0xFF) != (val & 0xFF)) |
1345 | 8c0fdd85 | ths | CALL_FROM_TB2(cpu_mips_tlb_flush, env, 1);
|
1346 | 8c0fdd85 | ths | RETURN(); |
1347 | 8c0fdd85 | ths | } |
1348 | 8c0fdd85 | ths | |
1349 | 8c0fdd85 | ths | void op_mtc0_compare (void) |
1350 | 8c0fdd85 | ths | { |
1351 | 8c0fdd85 | ths | CALL_FROM_TB2(cpu_mips_store_compare, env, T0); |
1352 | 8c0fdd85 | ths | RETURN(); |
1353 | 8c0fdd85 | ths | } |
1354 | 8c0fdd85 | ths | |
1355 | 8c0fdd85 | ths | void op_mtc0_status (void) |
1356 | 8c0fdd85 | ths | { |
1357 | 4de9b249 | ths | uint32_t val, old; |
1358 | 8c0fdd85 | ths | |
1359 | 24c7b0e3 | ths | /* No 64bit FPU, no reverse endianness, no MDMX/DSP, no 64bit ops,
|
1360 | 24c7b0e3 | ths | no 64bit addressing implemented. */
|
1361 | 24c7b0e3 | ths | val = (int32_t)T0 & 0xF878FF17;
|
1362 | 8c0fdd85 | ths | old = env->CP0_Status; |
1363 | f41c52f1 | ths | if (!(val & (1 << CP0St_EXL)) && |
1364 | f41c52f1 | ths | !(val & (1 << CP0St_ERL)) &&
|
1365 | f41c52f1 | ths | !(env->hflags & MIPS_HFLAG_DM) && |
1366 | f41c52f1 | ths | (val & (1 << CP0St_UM)))
|
1367 | f41c52f1 | ths | env->hflags |= MIPS_HFLAG_UM; |
1368 | 8c0fdd85 | ths | env->CP0_Status = val; |
1369 | f41c52f1 | ths | if (loglevel & CPU_LOG_EXEC)
|
1370 | f41c52f1 | ths | CALL_FROM_TB2(do_mtc0_status_debug, old, val); |
1371 | 4de9b249 | ths | CALL_FROM_TB1(cpu_mips_update_irq, env); |
1372 | 8c0fdd85 | ths | RETURN(); |
1373 | 8c0fdd85 | ths | } |
1374 | 8c0fdd85 | ths | |
1375 | 7a387fff | ths | void op_mtc0_intctl (void) |
1376 | 7a387fff | ths | { |
1377 | 7a387fff | ths | /* vectored interrupts not implemented */
|
1378 | 7a387fff | ths | env->CP0_IntCtl = 0;
|
1379 | 7a387fff | ths | RETURN(); |
1380 | 7a387fff | ths | } |
1381 | 7a387fff | ths | |
1382 | 7a387fff | ths | void op_mtc0_srsctl (void) |
1383 | 7a387fff | ths | { |
1384 | 7a387fff | ths | /* shadow registers not implemented */
|
1385 | 7a387fff | ths | env->CP0_SRSCtl = 0;
|
1386 | 7a387fff | ths | RETURN(); |
1387 | 7a387fff | ths | } |
1388 | 7a387fff | ths | |
1389 | 9c2149c8 | ths | void op_mtc0_srsmap (void) |
1390 | 9c2149c8 | ths | { |
1391 | 9c2149c8 | ths | /* shadow registers not implemented */
|
1392 | 9c2149c8 | ths | env->CP0_SRSMap = 0;
|
1393 | 9c2149c8 | ths | RETURN(); |
1394 | 9c2149c8 | ths | } |
1395 | 9c2149c8 | ths | |
1396 | 8c0fdd85 | ths | void op_mtc0_cause (void) |
1397 | 8c0fdd85 | ths | { |
1398 | 39d51eb8 | ths | uint32_t mask = 0x00C00300;
|
1399 | 39d51eb8 | ths | |
1400 | 39d51eb8 | ths | if ((env->CP0_Config0 & (0x7 << CP0C0_AR)) == (1 << CP0C0_AR)) |
1401 | 39d51eb8 | ths | mask |= 1 << CP0Ca_DC;
|
1402 | 39d51eb8 | ths | |
1403 | 39d51eb8 | ths | env->CP0_Cause = (env->CP0_Cause & 0xFCC0FF7C) | (T0 & mask);
|
1404 | 8c0fdd85 | ths | |
1405 | 4de9b249 | ths | /* Handle the software interrupt as an hardware one, as they
|
1406 | 4de9b249 | ths | are very similar */
|
1407 | 4de9b249 | ths | if (T0 & CP0Ca_IP_mask) {
|
1408 | 4de9b249 | ths | CALL_FROM_TB1(cpu_mips_update_irq, env); |
1409 | 8c0fdd85 | ths | } |
1410 | 8c0fdd85 | ths | RETURN(); |
1411 | 8c0fdd85 | ths | } |
1412 | 8c0fdd85 | ths | |
1413 | 8c0fdd85 | ths | void op_mtc0_epc (void) |
1414 | 8c0fdd85 | ths | { |
1415 | 9c2149c8 | ths | env->CP0_EPC = (int32_t)T0; |
1416 | 8c0fdd85 | ths | RETURN(); |
1417 | 8c0fdd85 | ths | } |
1418 | 8c0fdd85 | ths | |
1419 | 7a387fff | ths | void op_mtc0_ebase (void) |
1420 | 7a387fff | ths | { |
1421 | 7a387fff | ths | /* vectored interrupts not implemented */
|
1422 | 7a387fff | ths | /* Multi-CPU not implemented */
|
1423 | b29a0341 | ths | env->CP0_EBase = 0x80000000 | (T0 & 0x3FFFF000); |
1424 | 7a387fff | ths | RETURN(); |
1425 | 7a387fff | ths | } |
1426 | 7a387fff | ths | |
1427 | 8c0fdd85 | ths | void op_mtc0_config0 (void) |
1428 | 8c0fdd85 | ths | { |
1429 | 8c0fdd85 | ths | #if defined(MIPS_USES_R4K_TLB)
|
1430 | 7a387fff | ths | /* Fixed mapping MMU not implemented */
|
1431 | 7a387fff | ths | env->CP0_Config0 = (env->CP0_Config0 & 0x8017FF88) | (T0 & 0x00000001); |
1432 | 8c0fdd85 | ths | #else
|
1433 | 7a387fff | ths | env->CP0_Config0 = (env->CP0_Config0 & 0xFE17FF88) | (T0 & 0x00000001); |
1434 | 8c0fdd85 | ths | #endif
|
1435 | 8c0fdd85 | ths | RETURN(); |
1436 | 8c0fdd85 | ths | } |
1437 | 8c0fdd85 | ths | |
1438 | 7a387fff | ths | void op_mtc0_config2 (void) |
1439 | 7a387fff | ths | { |
1440 | 7a387fff | ths | /* tertiary/secondary caches not implemented */
|
1441 | 7a387fff | ths | env->CP0_Config2 = (env->CP0_Config2 & 0x8FFF0FFF);
|
1442 | 7a387fff | ths | RETURN(); |
1443 | 7a387fff | ths | } |
1444 | 7a387fff | ths | |
1445 | 7a387fff | ths | void op_mtc0_watchlo0 (void) |
1446 | 8c0fdd85 | ths | { |
1447 | 9c2149c8 | ths | env->CP0_WatchLo = (int32_t)T0; |
1448 | 8c0fdd85 | ths | RETURN(); |
1449 | 8c0fdd85 | ths | } |
1450 | 8c0fdd85 | ths | |
1451 | 7a387fff | ths | void op_mtc0_watchhi0 (void) |
1452 | 8c0fdd85 | ths | { |
1453 | 8c0fdd85 | ths | env->CP0_WatchHi = T0 & 0x40FF0FF8;
|
1454 | 8c0fdd85 | ths | RETURN(); |
1455 | 8c0fdd85 | ths | } |
1456 | 8c0fdd85 | ths | |
1457 | 7a387fff | ths | void op_mtc0_xcontext (void) |
1458 | 7a387fff | ths | { |
1459 | 9c2149c8 | ths | env->CP0_XContext = (int32_t)T0; /* XXX */
|
1460 | 7a387fff | ths | RETURN(); |
1461 | 7a387fff | ths | } |
1462 | 7a387fff | ths | |
1463 | 7a387fff | ths | void op_mtc0_framemask (void) |
1464 | 7a387fff | ths | { |
1465 | 7a387fff | ths | env->CP0_Framemask = T0; /* XXX */
|
1466 | 7a387fff | ths | RETURN(); |
1467 | 7a387fff | ths | } |
1468 | 7a387fff | ths | |
1469 | 8c0fdd85 | ths | void op_mtc0_debug (void) |
1470 | 8c0fdd85 | ths | { |
1471 | 8c0fdd85 | ths | env->CP0_Debug = (env->CP0_Debug & 0x8C03FC1F) | (T0 & 0x13300120); |
1472 | 8c0fdd85 | ths | if (T0 & (1 << CP0DB_DM)) |
1473 | 8c0fdd85 | ths | env->hflags |= MIPS_HFLAG_DM; |
1474 | 8c0fdd85 | ths | else
|
1475 | 8c0fdd85 | ths | env->hflags &= ~MIPS_HFLAG_DM; |
1476 | 8c0fdd85 | ths | RETURN(); |
1477 | 8c0fdd85 | ths | } |
1478 | 8c0fdd85 | ths | |
1479 | 8c0fdd85 | ths | void op_mtc0_depc (void) |
1480 | 8c0fdd85 | ths | { |
1481 | 9c2149c8 | ths | env->CP0_DEPC = (int32_t)T0; |
1482 | 8c0fdd85 | ths | RETURN(); |
1483 | 8c0fdd85 | ths | } |
1484 | 8c0fdd85 | ths | |
1485 | 7a387fff | ths | void op_mtc0_performance0 (void) |
1486 | 7a387fff | ths | { |
1487 | 7a387fff | ths | env->CP0_Performance0 = T0; /* XXX */
|
1488 | 7a387fff | ths | RETURN(); |
1489 | 7a387fff | ths | } |
1490 | 7a387fff | ths | |
1491 | 8c0fdd85 | ths | void op_mtc0_taglo (void) |
1492 | 8c0fdd85 | ths | { |
1493 | 9c2149c8 | ths | env->CP0_TagLo = T0 & 0xFFFFFCF6;
|
1494 | 8c0fdd85 | ths | RETURN(); |
1495 | 8c0fdd85 | ths | } |
1496 | 8c0fdd85 | ths | |
1497 | 7a387fff | ths | void op_mtc0_datalo (void) |
1498 | 7a387fff | ths | { |
1499 | 7a387fff | ths | env->CP0_DataLo = T0; /* XXX */
|
1500 | 7a387fff | ths | RETURN(); |
1501 | 7a387fff | ths | } |
1502 | 7a387fff | ths | |
1503 | 7a387fff | ths | void op_mtc0_taghi (void) |
1504 | 7a387fff | ths | { |
1505 | 7a387fff | ths | env->CP0_TagHi = T0; /* XXX */
|
1506 | 7a387fff | ths | RETURN(); |
1507 | 7a387fff | ths | } |
1508 | 7a387fff | ths | |
1509 | 7a387fff | ths | void op_mtc0_datahi (void) |
1510 | 7a387fff | ths | { |
1511 | 7a387fff | ths | env->CP0_DataHi = T0; /* XXX */
|
1512 | 7a387fff | ths | RETURN(); |
1513 | 7a387fff | ths | } |
1514 | 7a387fff | ths | |
1515 | 8c0fdd85 | ths | void op_mtc0_errorepc (void) |
1516 | 8c0fdd85 | ths | { |
1517 | 9c2149c8 | ths | env->CP0_ErrorEPC = (int32_t)T0; |
1518 | 8c0fdd85 | ths | RETURN(); |
1519 | 8c0fdd85 | ths | } |
1520 | 8c0fdd85 | ths | |
1521 | 8c0fdd85 | ths | void op_mtc0_desave (void) |
1522 | 8c0fdd85 | ths | { |
1523 | 8c0fdd85 | ths | env->CP0_DESAVE = T0; |
1524 | 6af0bf9c | bellard | RETURN(); |
1525 | 6af0bf9c | bellard | } |
1526 | 6af0bf9c | bellard | |
1527 | 9c2149c8 | ths | void op_dmfc0_entrylo0 (void) |
1528 | 9c2149c8 | ths | { |
1529 | 9c2149c8 | ths | T0 = env->CP0_EntryLo0; |
1530 | 9c2149c8 | ths | RETURN(); |
1531 | 9c2149c8 | ths | } |
1532 | 9c2149c8 | ths | |
1533 | 9c2149c8 | ths | void op_dmfc0_entrylo1 (void) |
1534 | 9c2149c8 | ths | { |
1535 | 9c2149c8 | ths | T0 = env->CP0_EntryLo1; |
1536 | 9c2149c8 | ths | RETURN(); |
1537 | 9c2149c8 | ths | } |
1538 | 9c2149c8 | ths | |
1539 | 9c2149c8 | ths | void op_dmfc0_context (void) |
1540 | 9c2149c8 | ths | { |
1541 | 9c2149c8 | ths | T0 = env->CP0_Context; |
1542 | 9c2149c8 | ths | RETURN(); |
1543 | 9c2149c8 | ths | } |
1544 | 9c2149c8 | ths | |
1545 | 9c2149c8 | ths | void op_dmfc0_badvaddr (void) |
1546 | 9c2149c8 | ths | { |
1547 | 9c2149c8 | ths | T0 = env->CP0_BadVAddr; |
1548 | 9c2149c8 | ths | RETURN(); |
1549 | 9c2149c8 | ths | } |
1550 | 9c2149c8 | ths | |
1551 | 9c2149c8 | ths | void op_dmfc0_entryhi (void) |
1552 | 9c2149c8 | ths | { |
1553 | 9c2149c8 | ths | T0 = env->CP0_EntryHi; |
1554 | 9c2149c8 | ths | RETURN(); |
1555 | 9c2149c8 | ths | } |
1556 | 9c2149c8 | ths | |
1557 | 9c2149c8 | ths | void op_dmfc0_epc (void) |
1558 | 9c2149c8 | ths | { |
1559 | 9c2149c8 | ths | T0 = env->CP0_EPC; |
1560 | 9c2149c8 | ths | RETURN(); |
1561 | 9c2149c8 | ths | } |
1562 | 9c2149c8 | ths | |
1563 | 9c2149c8 | ths | void op_dmfc0_lladdr (void) |
1564 | 9c2149c8 | ths | { |
1565 | 9c2149c8 | ths | T0 = env->CP0_LLAddr >> 4;
|
1566 | 9c2149c8 | ths | RETURN(); |
1567 | 9c2149c8 | ths | } |
1568 | 9c2149c8 | ths | |
1569 | 9c2149c8 | ths | void op_dmfc0_watchlo0 (void) |
1570 | 9c2149c8 | ths | { |
1571 | 9c2149c8 | ths | T0 = env->CP0_WatchLo; |
1572 | 9c2149c8 | ths | RETURN(); |
1573 | 9c2149c8 | ths | } |
1574 | 9c2149c8 | ths | |
1575 | 9c2149c8 | ths | void op_dmfc0_xcontext (void) |
1576 | 9c2149c8 | ths | { |
1577 | 9c2149c8 | ths | T0 = env->CP0_XContext; |
1578 | 9c2149c8 | ths | RETURN(); |
1579 | 9c2149c8 | ths | } |
1580 | 9c2149c8 | ths | |
1581 | 9c2149c8 | ths | void op_dmfc0_depc (void) |
1582 | 9c2149c8 | ths | { |
1583 | 9c2149c8 | ths | T0 = env->CP0_DEPC; |
1584 | 9c2149c8 | ths | RETURN(); |
1585 | 9c2149c8 | ths | } |
1586 | 9c2149c8 | ths | |
1587 | 9c2149c8 | ths | void op_dmfc0_errorepc (void) |
1588 | 9c2149c8 | ths | { |
1589 | 9c2149c8 | ths | T0 = env->CP0_ErrorEPC; |
1590 | 9c2149c8 | ths | RETURN(); |
1591 | 9c2149c8 | ths | } |
1592 | 9c2149c8 | ths | |
1593 | 9c2149c8 | ths | void op_dmtc0_entrylo0 (void) |
1594 | 9c2149c8 | ths | { |
1595 | 9c2149c8 | ths | /* Large physaddr not implemented */
|
1596 | 9c2149c8 | ths | /* 1k pages not implemented */
|
1597 | 9c2149c8 | ths | env->CP0_EntryLo0 = T0 & 0x3FFFFFFF;
|
1598 | 9c2149c8 | ths | RETURN(); |
1599 | 9c2149c8 | ths | } |
1600 | 9c2149c8 | ths | |
1601 | 9c2149c8 | ths | void op_dmtc0_entrylo1 (void) |
1602 | 9c2149c8 | ths | { |
1603 | 9c2149c8 | ths | /* Large physaddr not implemented */
|
1604 | 9c2149c8 | ths | /* 1k pages not implemented */
|
1605 | 9c2149c8 | ths | env->CP0_EntryLo1 = T0 & 0x3FFFFFFF;
|
1606 | 9c2149c8 | ths | RETURN(); |
1607 | 9c2149c8 | ths | } |
1608 | 9c2149c8 | ths | |
1609 | 9c2149c8 | ths | void op_dmtc0_context (void) |
1610 | 9c2149c8 | ths | { |
1611 | 9c2149c8 | ths | env->CP0_Context = (env->CP0_Context & ~0x007FFFFF) | (T0 & 0x007FFFF0); |
1612 | 9c2149c8 | ths | RETURN(); |
1613 | 9c2149c8 | ths | } |
1614 | 9c2149c8 | ths | |
1615 | 9c2149c8 | ths | void op_dmtc0_epc (void) |
1616 | 9c2149c8 | ths | { |
1617 | 9c2149c8 | ths | env->CP0_EPC = T0; |
1618 | 9c2149c8 | ths | RETURN(); |
1619 | 9c2149c8 | ths | } |
1620 | 9c2149c8 | ths | |
1621 | 9c2149c8 | ths | void op_dmtc0_watchlo0 (void) |
1622 | 9c2149c8 | ths | { |
1623 | 9c2149c8 | ths | env->CP0_WatchLo = T0; |
1624 | 9c2149c8 | ths | RETURN(); |
1625 | 9c2149c8 | ths | } |
1626 | 9c2149c8 | ths | |
1627 | 9c2149c8 | ths | void op_dmtc0_xcontext (void) |
1628 | 9c2149c8 | ths | { |
1629 | 9c2149c8 | ths | env->CP0_XContext = T0; /* XXX */
|
1630 | 9c2149c8 | ths | RETURN(); |
1631 | 9c2149c8 | ths | } |
1632 | 9c2149c8 | ths | |
1633 | 9c2149c8 | ths | void op_dmtc0_depc (void) |
1634 | 9c2149c8 | ths | { |
1635 | 9c2149c8 | ths | env->CP0_DEPC = T0; |
1636 | 9c2149c8 | ths | RETURN(); |
1637 | 9c2149c8 | ths | } |
1638 | 9c2149c8 | ths | |
1639 | 9c2149c8 | ths | void op_dmtc0_errorepc (void) |
1640 | 9c2149c8 | ths | { |
1641 | 9c2149c8 | ths | env->CP0_ErrorEPC = T0; |
1642 | 9c2149c8 | ths | RETURN(); |
1643 | 9c2149c8 | ths | } |
1644 | 9c2149c8 | ths | |
1645 | 6ea83fed | bellard | #if 0
|
1646 | 6ea83fed | bellard | # define DEBUG_FPU_STATE() CALL_FROM_TB1(dump_fpu, env)
|
1647 | 6ea83fed | bellard | #else
|
1648 | 6ea83fed | bellard | # define DEBUG_FPU_STATE() do { } while(0) |
1649 | 6ea83fed | bellard | #endif
|
1650 | 6ea83fed | bellard | |
1651 | 24c7b0e3 | ths | void op_cp0_enabled(void) |
1652 | 24c7b0e3 | ths | { |
1653 | 24c7b0e3 | ths | if (!(env->CP0_Status & (1 << CP0St_CU0)) && |
1654 | 24c7b0e3 | ths | (env->hflags & MIPS_HFLAG_UM)) { |
1655 | 1579a72e | ths | CALL_FROM_TB2(do_raise_exception_err, EXCP_CpU, 0);
|
1656 | 24c7b0e3 | ths | } |
1657 | 24c7b0e3 | ths | RETURN(); |
1658 | 24c7b0e3 | ths | } |
1659 | 24c7b0e3 | ths | |
1660 | 6ea83fed | bellard | void op_cp1_enabled(void) |
1661 | 6ea83fed | bellard | { |
1662 | 6ea83fed | bellard | if (!(env->CP0_Status & (1 << CP0St_CU1))) { |
1663 | 1579a72e | ths | CALL_FROM_TB2(do_raise_exception_err, EXCP_CpU, 1);
|
1664 | 6ea83fed | bellard | } |
1665 | 6ea83fed | bellard | RETURN(); |
1666 | 6ea83fed | bellard | } |
1667 | 6ea83fed | bellard | |
1668 | 6ea83fed | bellard | /* CP1 functions */
|
1669 | 6ea83fed | bellard | void op_cfc1 (void) |
1670 | 6ea83fed | bellard | { |
1671 | 6ea83fed | bellard | if (T1 == 0) { |
1672 | 6ea83fed | bellard | T0 = env->fcr0; |
1673 | 6ea83fed | bellard | } |
1674 | 6ea83fed | bellard | else {
|
1675 | 6ea83fed | bellard | /* fetch fcr31, masking unused bits */
|
1676 | 6ea83fed | bellard | T0 = env->fcr31 & 0x0183FFFF;
|
1677 | 6ea83fed | bellard | } |
1678 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1679 | 6ea83fed | bellard | RETURN(); |
1680 | 6ea83fed | bellard | } |
1681 | 6ea83fed | bellard | |
1682 | 6ea83fed | bellard | /* convert MIPS rounding mode in FCR31 to IEEE library */
|
1683 | 6ea83fed | bellard | unsigned int ieee_rm[] = { |
1684 | 6ea83fed | bellard | float_round_nearest_even, |
1685 | 6ea83fed | bellard | float_round_to_zero, |
1686 | 6ea83fed | bellard | float_round_up, |
1687 | 6ea83fed | bellard | float_round_down |
1688 | 6ea83fed | bellard | }; |
1689 | 6ea83fed | bellard | |
1690 | 6ea83fed | bellard | #define RESTORE_ROUNDING_MODE \
|
1691 | 6ea83fed | bellard | set_float_rounding_mode(ieee_rm[env->fcr31 & 3], &env->fp_status)
|
1692 | 6ea83fed | bellard | |
1693 | 6ea83fed | bellard | void op_ctc1 (void) |
1694 | 6ea83fed | bellard | { |
1695 | 6ea83fed | bellard | if (T1 == 0) { |
1696 | 6ea83fed | bellard | /* XXX should this throw an exception?
|
1697 | 6ea83fed | bellard | * don't write to FCR0.
|
1698 | 6ea83fed | bellard | * env->fcr0 = T0;
|
1699 | 6ea83fed | bellard | */
|
1700 | 6ea83fed | bellard | } |
1701 | 6ea83fed | bellard | else {
|
1702 | 6ea83fed | bellard | /* store new fcr31, masking unused bits */
|
1703 | 6ea83fed | bellard | env->fcr31 = T0 & 0x0183FFFF;
|
1704 | 6ea83fed | bellard | |
1705 | 6ea83fed | bellard | /* set rounding mode */
|
1706 | 6ea83fed | bellard | RESTORE_ROUNDING_MODE; |
1707 | 6ea83fed | bellard | |
1708 | 6ea83fed | bellard | #ifndef CONFIG_SOFTFLOAT
|
1709 | 6ea83fed | bellard | /* no floating point exception for native float */
|
1710 | 6ea83fed | bellard | SET_FP_ENABLE(env->fcr31, 0);
|
1711 | 6ea83fed | bellard | #endif
|
1712 | 6ea83fed | bellard | } |
1713 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1714 | 6ea83fed | bellard | RETURN(); |
1715 | 6ea83fed | bellard | } |
1716 | 6ea83fed | bellard | |
1717 | 6ea83fed | bellard | void op_mfc1 (void) |
1718 | 6ea83fed | bellard | { |
1719 | 6ea83fed | bellard | T0 = WT0; |
1720 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1721 | 6ea83fed | bellard | RETURN(); |
1722 | 6ea83fed | bellard | } |
1723 | 6ea83fed | bellard | |
1724 | 6ea83fed | bellard | void op_mtc1 (void) |
1725 | 6ea83fed | bellard | { |
1726 | 6ea83fed | bellard | WT0 = T0; |
1727 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1728 | 6ea83fed | bellard | RETURN(); |
1729 | 6ea83fed | bellard | } |
1730 | 6ea83fed | bellard | |
1731 | 6ea83fed | bellard | /* Float support.
|
1732 | 6ea83fed | bellard | Single precition routines have a "s" suffix, double precision a
|
1733 | 6ea83fed | bellard | "d" suffix. */
|
1734 | 6ea83fed | bellard | |
1735 | 6ea83fed | bellard | #define FLOAT_OP(name, p) void OPPROTO op_float_##name##_##p(void) |
1736 | 6ea83fed | bellard | |
1737 | dd016883 | bellard | FLOAT_OP(cvtd, s) |
1738 | dd016883 | bellard | { |
1739 | 00a709c7 | ths | FDT2 = float32_to_float64(FST0, &env->fp_status); |
1740 | dd016883 | bellard | DEBUG_FPU_STATE(); |
1741 | dd016883 | bellard | RETURN(); |
1742 | dd016883 | bellard | } |
1743 | 6ea83fed | bellard | FLOAT_OP(cvtd, w) |
1744 | 6ea83fed | bellard | { |
1745 | 6ea83fed | bellard | FDT2 = int32_to_float64(WT0, &env->fp_status); |
1746 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1747 | 6ea83fed | bellard | RETURN(); |
1748 | 6ea83fed | bellard | } |
1749 | dd016883 | bellard | FLOAT_OP(cvts, d) |
1750 | dd016883 | bellard | { |
1751 | 417f38f0 | pbrook | FST2 = float64_to_float32(FDT0, &env->fp_status); |
1752 | dd016883 | bellard | DEBUG_FPU_STATE(); |
1753 | dd016883 | bellard | RETURN(); |
1754 | dd016883 | bellard | } |
1755 | 6ea83fed | bellard | FLOAT_OP(cvts, w) |
1756 | 6ea83fed | bellard | { |
1757 | 6ea83fed | bellard | FST2 = int32_to_float32(WT0, &env->fp_status); |
1758 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1759 | 6ea83fed | bellard | RETURN(); |
1760 | 6ea83fed | bellard | } |
1761 | 6ea83fed | bellard | FLOAT_OP(cvtw, s) |
1762 | 6ea83fed | bellard | { |
1763 | 6ea83fed | bellard | WT2 = float32_to_int32(FST0, &env->fp_status); |
1764 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1765 | 6ea83fed | bellard | RETURN(); |
1766 | 6ea83fed | bellard | } |
1767 | 6ea83fed | bellard | FLOAT_OP(cvtw, d) |
1768 | 6ea83fed | bellard | { |
1769 | 6ea83fed | bellard | WT2 = float64_to_int32(FDT0, &env->fp_status); |
1770 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1771 | 6ea83fed | bellard | RETURN(); |
1772 | 6ea83fed | bellard | } |
1773 | 6ea83fed | bellard | |
1774 | 6ea83fed | bellard | FLOAT_OP(roundw, d) |
1775 | 6ea83fed | bellard | { |
1776 | 6ea83fed | bellard | set_float_rounding_mode(float_round_nearest_even, &env->fp_status); |
1777 | 6ea83fed | bellard | WT2 = float64_round_to_int(FDT0, &env->fp_status); |
1778 | 6ea83fed | bellard | RESTORE_ROUNDING_MODE; |
1779 | 6ea83fed | bellard | |
1780 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1781 | 6ea83fed | bellard | RETURN(); |
1782 | 6ea83fed | bellard | } |
1783 | 6ea83fed | bellard | FLOAT_OP(roundw, s) |
1784 | 6ea83fed | bellard | { |
1785 | 6ea83fed | bellard | set_float_rounding_mode(float_round_nearest_even, &env->fp_status); |
1786 | 6ea83fed | bellard | WT2 = float32_round_to_int(FST0, &env->fp_status); |
1787 | 6ea83fed | bellard | RESTORE_ROUNDING_MODE; |
1788 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1789 | 6ea83fed | bellard | RETURN(); |
1790 | 6ea83fed | bellard | } |
1791 | 6ea83fed | bellard | |
1792 | 6ea83fed | bellard | FLOAT_OP(truncw, d) |
1793 | 6ea83fed | bellard | { |
1794 | 6ea83fed | bellard | WT2 = float64_to_int32_round_to_zero(FDT0, &env->fp_status); |
1795 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1796 | 6ea83fed | bellard | RETURN(); |
1797 | 6ea83fed | bellard | } |
1798 | 6ea83fed | bellard | FLOAT_OP(truncw, s) |
1799 | 6ea83fed | bellard | { |
1800 | 6ea83fed | bellard | WT2 = float32_to_int32_round_to_zero(FST0, &env->fp_status); |
1801 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1802 | 6ea83fed | bellard | RETURN(); |
1803 | 6ea83fed | bellard | } |
1804 | 6ea83fed | bellard | |
1805 | 6ea83fed | bellard | FLOAT_OP(ceilw, d) |
1806 | 6ea83fed | bellard | { |
1807 | 6ea83fed | bellard | set_float_rounding_mode(float_round_up, &env->fp_status); |
1808 | 6ea83fed | bellard | WT2 = float64_round_to_int(FDT0, &env->fp_status); |
1809 | 6ea83fed | bellard | RESTORE_ROUNDING_MODE; |
1810 | 6ea83fed | bellard | |
1811 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1812 | 6ea83fed | bellard | RETURN(); |
1813 | 6ea83fed | bellard | } |
1814 | 6ea83fed | bellard | FLOAT_OP(ceilw, s) |
1815 | 6ea83fed | bellard | { |
1816 | 6ea83fed | bellard | set_float_rounding_mode(float_round_up, &env->fp_status); |
1817 | 6ea83fed | bellard | WT2 = float32_round_to_int(FST0, &env->fp_status); |
1818 | 6ea83fed | bellard | RESTORE_ROUNDING_MODE; |
1819 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1820 | 6ea83fed | bellard | RETURN(); |
1821 | 6ea83fed | bellard | } |
1822 | 6ea83fed | bellard | |
1823 | 6ea83fed | bellard | FLOAT_OP(floorw, d) |
1824 | 6ea83fed | bellard | { |
1825 | 6ea83fed | bellard | set_float_rounding_mode(float_round_down, &env->fp_status); |
1826 | 6ea83fed | bellard | WT2 = float64_round_to_int(FDT0, &env->fp_status); |
1827 | 6ea83fed | bellard | RESTORE_ROUNDING_MODE; |
1828 | 6ea83fed | bellard | |
1829 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1830 | 6ea83fed | bellard | RETURN(); |
1831 | 6ea83fed | bellard | } |
1832 | 6ea83fed | bellard | FLOAT_OP(floorw, s) |
1833 | 6ea83fed | bellard | { |
1834 | 6ea83fed | bellard | set_float_rounding_mode(float_round_down, &env->fp_status); |
1835 | 6ea83fed | bellard | WT2 = float32_round_to_int(FST0, &env->fp_status); |
1836 | 6ea83fed | bellard | RESTORE_ROUNDING_MODE; |
1837 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1838 | 6ea83fed | bellard | RETURN(); |
1839 | 6ea83fed | bellard | } |
1840 | 6ea83fed | bellard | |
1841 | 6ea83fed | bellard | /* binary operations */
|
1842 | 6ea83fed | bellard | #define FLOAT_BINOP(name) \
|
1843 | 6ea83fed | bellard | FLOAT_OP(name, d) \ |
1844 | 6ea83fed | bellard | { \ |
1845 | 6ea83fed | bellard | FDT2 = float64_ ## name (FDT0, FDT1, &env->fp_status); \ |
1846 | 6ea83fed | bellard | DEBUG_FPU_STATE(); \ |
1847 | 6ea83fed | bellard | } \ |
1848 | 6ea83fed | bellard | FLOAT_OP(name, s) \ |
1849 | 6ea83fed | bellard | { \ |
1850 | 6ea83fed | bellard | FST2 = float32_ ## name (FST0, FST1, &env->fp_status); \ |
1851 | 6ea83fed | bellard | DEBUG_FPU_STATE(); \ |
1852 | 6ea83fed | bellard | } |
1853 | 6ea83fed | bellard | FLOAT_BINOP(add) |
1854 | 6ea83fed | bellard | FLOAT_BINOP(sub) |
1855 | 6ea83fed | bellard | FLOAT_BINOP(mul) |
1856 | 6ea83fed | bellard | FLOAT_BINOP(div) |
1857 | 6ea83fed | bellard | #undef FLOAT_BINOP
|
1858 | 6ea83fed | bellard | |
1859 | 6ea83fed | bellard | /* unary operations, modifying fp status */
|
1860 | 6ea83fed | bellard | #define FLOAT_UNOP(name) \
|
1861 | 6ea83fed | bellard | FLOAT_OP(name, d) \ |
1862 | 6ea83fed | bellard | { \ |
1863 | 6ea83fed | bellard | FDT2 = float64_ ## name(FDT0, &env->fp_status); \ |
1864 | 6ea83fed | bellard | DEBUG_FPU_STATE(); \ |
1865 | 6ea83fed | bellard | } \ |
1866 | 6ea83fed | bellard | FLOAT_OP(name, s) \ |
1867 | 6ea83fed | bellard | { \ |
1868 | 6ea83fed | bellard | FST2 = float32_ ## name(FST0, &env->fp_status); \ |
1869 | 6ea83fed | bellard | DEBUG_FPU_STATE(); \ |
1870 | 6ea83fed | bellard | } |
1871 | 6ea83fed | bellard | FLOAT_UNOP(sqrt) |
1872 | 6ea83fed | bellard | #undef FLOAT_UNOP
|
1873 | 6ea83fed | bellard | |
1874 | 6ea83fed | bellard | /* unary operations, not modifying fp status */
|
1875 | 6ea83fed | bellard | #define FLOAT_UNOP(name) \
|
1876 | 6ea83fed | bellard | FLOAT_OP(name, d) \ |
1877 | 6ea83fed | bellard | { \ |
1878 | 6ea83fed | bellard | FDT2 = float64_ ## name(FDT0); \ |
1879 | 6ea83fed | bellard | DEBUG_FPU_STATE(); \ |
1880 | 6ea83fed | bellard | } \ |
1881 | 6ea83fed | bellard | FLOAT_OP(name, s) \ |
1882 | 6ea83fed | bellard | { \ |
1883 | 6ea83fed | bellard | FST2 = float32_ ## name(FST0); \ |
1884 | 6ea83fed | bellard | DEBUG_FPU_STATE(); \ |
1885 | 6ea83fed | bellard | } |
1886 | 6ea83fed | bellard | FLOAT_UNOP(abs) |
1887 | 6ea83fed | bellard | FLOAT_UNOP(chs) |
1888 | 6ea83fed | bellard | #undef FLOAT_UNOP
|
1889 | 6ea83fed | bellard | |
1890 | 6ea83fed | bellard | FLOAT_OP(mov, d) |
1891 | 6ea83fed | bellard | { |
1892 | 6ea83fed | bellard | FDT2 = FDT0; |
1893 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1894 | 6ea83fed | bellard | RETURN(); |
1895 | 6ea83fed | bellard | } |
1896 | 6ea83fed | bellard | FLOAT_OP(mov, s) |
1897 | 6ea83fed | bellard | { |
1898 | 6ea83fed | bellard | FST2 = FST0; |
1899 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1900 | 6ea83fed | bellard | RETURN(); |
1901 | 6ea83fed | bellard | } |
1902 | 6ea83fed | bellard | |
1903 | 6ea83fed | bellard | #ifdef CONFIG_SOFTFLOAT
|
1904 | 6ea83fed | bellard | #define clear_invalid() do { \ |
1905 | 6ea83fed | bellard | int flags = get_float_exception_flags(&env->fp_status); \
|
1906 | 6ea83fed | bellard | flags &= ~float_flag_invalid; \ |
1907 | 6ea83fed | bellard | set_float_exception_flags(flags, &env->fp_status); \ |
1908 | 6ea83fed | bellard | } while(0) |
1909 | 6ea83fed | bellard | #else
|
1910 | 6ea83fed | bellard | #define clear_invalid() do { } while(0) |
1911 | 6ea83fed | bellard | #endif
|
1912 | 6ea83fed | bellard | |
1913 | 6ea83fed | bellard | extern void dump_fpu_s(CPUState *env); |
1914 | 6ea83fed | bellard | |
1915 | 6ea83fed | bellard | #define FOP_COND(fmt, op, sig, cond) \
|
1916 | 6ea83fed | bellard | void op_cmp_ ## fmt ## _ ## op (void) \ |
1917 | 6ea83fed | bellard | { \ |
1918 | 6ea83fed | bellard | if (cond) \
|
1919 | 6ea83fed | bellard | SET_FP_COND(env->fcr31); \ |
1920 | 6ea83fed | bellard | else \
|
1921 | 6ea83fed | bellard | CLEAR_FP_COND(env->fcr31); \ |
1922 | 6ea83fed | bellard | if (!sig) \
|
1923 | 6ea83fed | bellard | clear_invalid(); \ |
1924 | 6ea83fed | bellard | /*CALL_FROM_TB1(dump_fpu_s, env);*/ \
|
1925 | 6ea83fed | bellard | DEBUG_FPU_STATE(); \ |
1926 | 6ea83fed | bellard | RETURN(); \ |
1927 | 6ea83fed | bellard | } |
1928 | 6ea83fed | bellard | |
1929 | 569f5d66 | bellard | int float64_is_unordered(float64 a, float64 b STATUS_PARAM)
|
1930 | 6ea83fed | bellard | { |
1931 | 6ea83fed | bellard | if (float64_is_nan(a) || float64_is_nan(b)) {
|
1932 | 6ea83fed | bellard | float_raise(float_flag_invalid, status); |
1933 | 6ea83fed | bellard | return 1; |
1934 | 6ea83fed | bellard | } |
1935 | 6ea83fed | bellard | else {
|
1936 | 6ea83fed | bellard | return 0; |
1937 | 6ea83fed | bellard | } |
1938 | 6ea83fed | bellard | } |
1939 | 6ea83fed | bellard | |
1940 | 6ea83fed | bellard | FOP_COND(d, f, 0, 0) |
1941 | 6ea83fed | bellard | FOP_COND(d, un, 0, float64_is_unordered(FDT1, FDT0, &env->fp_status))
|
1942 | 6ea83fed | bellard | FOP_COND(d, eq, 0, float64_eq(FDT0, FDT1, &env->fp_status))
|
1943 | 6ea83fed | bellard | FOP_COND(d, ueq, 0, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_eq(FDT0, FDT1, &env->fp_status))
|
1944 | 6ea83fed | bellard | FOP_COND(d, olt, 0, float64_lt(FDT0, FDT1, &env->fp_status))
|
1945 | 6ea83fed | bellard | FOP_COND(d, ult, 0, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_lt(FDT0, FDT1, &env->fp_status))
|
1946 | 6ea83fed | bellard | FOP_COND(d, ole, 0, float64_le(FDT0, FDT1, &env->fp_status))
|
1947 | 6ea83fed | bellard | FOP_COND(d, ule, 0, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_le(FDT0, FDT1, &env->fp_status))
|
1948 | 6ea83fed | bellard | /* NOTE: the comma operator will make "cond" to eval to false,
|
1949 | 6ea83fed | bellard | * but float*_is_unordered() is still called
|
1950 | 6ea83fed | bellard | */
|
1951 | 6ea83fed | bellard | FOP_COND(d, sf, 1, (float64_is_unordered(FDT0, FDT1, &env->fp_status), 0)) |
1952 | 6ea83fed | bellard | FOP_COND(d, ngle,1, float64_is_unordered(FDT1, FDT0, &env->fp_status))
|
1953 | 6ea83fed | bellard | FOP_COND(d, seq, 1, float64_eq(FDT0, FDT1, &env->fp_status))
|
1954 | 6ea83fed | bellard | FOP_COND(d, ngl, 1, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_eq(FDT0, FDT1, &env->fp_status))
|
1955 | 6ea83fed | bellard | FOP_COND(d, lt, 1, float64_lt(FDT0, FDT1, &env->fp_status))
|
1956 | 6ea83fed | bellard | FOP_COND(d, nge, 1, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_lt(FDT0, FDT1, &env->fp_status))
|
1957 | 6ea83fed | bellard | FOP_COND(d, le, 1, float64_le(FDT0, FDT1, &env->fp_status))
|
1958 | 6ea83fed | bellard | FOP_COND(d, ngt, 1, float64_is_unordered(FDT1, FDT0, &env->fp_status) || float64_le(FDT0, FDT1, &env->fp_status))
|
1959 | 6ea83fed | bellard | |
1960 | 6ea83fed | bellard | flag float32_is_unordered(float32 a, float32 b STATUS_PARAM) |
1961 | 6ea83fed | bellard | { |
1962 | 6ea83fed | bellard | extern flag float32_is_nan( float32 a );
|
1963 | 6ea83fed | bellard | if (float32_is_nan(a) || float32_is_nan(b)) {
|
1964 | 6ea83fed | bellard | float_raise(float_flag_invalid, status); |
1965 | 6ea83fed | bellard | return 1; |
1966 | 6ea83fed | bellard | } |
1967 | 6ea83fed | bellard | else {
|
1968 | 6ea83fed | bellard | return 0; |
1969 | 6ea83fed | bellard | } |
1970 | 6ea83fed | bellard | } |
1971 | 6ea83fed | bellard | |
1972 | 6ea83fed | bellard | /* NOTE: the comma operator will make "cond" to eval to false,
|
1973 | 6ea83fed | bellard | * but float*_is_unordered() is still called
|
1974 | 6ea83fed | bellard | */
|
1975 | 6ea83fed | bellard | FOP_COND(s, f, 0, 0) |
1976 | 6ea83fed | bellard | FOP_COND(s, un, 0, float32_is_unordered(FST1, FST0, &env->fp_status))
|
1977 | 6ea83fed | bellard | FOP_COND(s, eq, 0, float32_eq(FST0, FST1, &env->fp_status))
|
1978 | 6ea83fed | bellard | FOP_COND(s, ueq, 0, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_eq(FST0, FST1, &env->fp_status))
|
1979 | 6ea83fed | bellard | FOP_COND(s, olt, 0, float32_lt(FST0, FST1, &env->fp_status))
|
1980 | 6ea83fed | bellard | FOP_COND(s, ult, 0, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_lt(FST0, FST1, &env->fp_status))
|
1981 | 6ea83fed | bellard | FOP_COND(s, ole, 0, float32_le(FST0, FST1, &env->fp_status))
|
1982 | 6ea83fed | bellard | FOP_COND(s, ule, 0, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_le(FST0, FST1, &env->fp_status))
|
1983 | 6ea83fed | bellard | /* NOTE: the comma operator will make "cond" to eval to false,
|
1984 | 6ea83fed | bellard | * but float*_is_unordered() is still called
|
1985 | 6ea83fed | bellard | */
|
1986 | 6ea83fed | bellard | FOP_COND(s, sf, 1, (float32_is_unordered(FST0, FST1, &env->fp_status), 0)) |
1987 | 6ea83fed | bellard | FOP_COND(s, ngle,1, float32_is_unordered(FST1, FST0, &env->fp_status))
|
1988 | 6ea83fed | bellard | FOP_COND(s, seq, 1, float32_eq(FST0, FST1, &env->fp_status))
|
1989 | 6ea83fed | bellard | FOP_COND(s, ngl, 1, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_eq(FST0, FST1, &env->fp_status))
|
1990 | 6ea83fed | bellard | FOP_COND(s, lt, 1, float32_lt(FST0, FST1, &env->fp_status))
|
1991 | 6ea83fed | bellard | FOP_COND(s, nge, 1, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_lt(FST0, FST1, &env->fp_status))
|
1992 | 6ea83fed | bellard | FOP_COND(s, le, 1, float32_le(FST0, FST1, &env->fp_status))
|
1993 | 6ea83fed | bellard | FOP_COND(s, ngt, 1, float32_is_unordered(FST1, FST0, &env->fp_status) || float32_le(FST0, FST1, &env->fp_status))
|
1994 | 6ea83fed | bellard | |
1995 | 6ea83fed | bellard | void op_bc1f (void) |
1996 | 6ea83fed | bellard | { |
1997 | 6ea83fed | bellard | T0 = ! IS_FP_COND_SET(env->fcr31); |
1998 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
1999 | 6ea83fed | bellard | RETURN(); |
2000 | 6ea83fed | bellard | } |
2001 | 6ea83fed | bellard | |
2002 | 6ea83fed | bellard | void op_bc1t (void) |
2003 | 6ea83fed | bellard | { |
2004 | 6ea83fed | bellard | T0 = IS_FP_COND_SET(env->fcr31); |
2005 | 6ea83fed | bellard | DEBUG_FPU_STATE(); |
2006 | 6ea83fed | bellard | RETURN(); |
2007 | 6ea83fed | bellard | } |
2008 | 6ea83fed | bellard | |
2009 | 6af0bf9c | bellard | #if defined(MIPS_USES_R4K_TLB)
|
2010 | 6af0bf9c | bellard | void op_tlbwi (void) |
2011 | 6af0bf9c | bellard | { |
2012 | 6af0bf9c | bellard | CALL_FROM_TB0(do_tlbwi); |
2013 | 6af0bf9c | bellard | RETURN(); |
2014 | 6af0bf9c | bellard | } |
2015 | 6af0bf9c | bellard | |
2016 | 6af0bf9c | bellard | void op_tlbwr (void) |
2017 | 6af0bf9c | bellard | { |
2018 | 6af0bf9c | bellard | CALL_FROM_TB0(do_tlbwr); |
2019 | 6af0bf9c | bellard | RETURN(); |
2020 | 6af0bf9c | bellard | } |
2021 | 6af0bf9c | bellard | |
2022 | 6af0bf9c | bellard | void op_tlbp (void) |
2023 | 6af0bf9c | bellard | { |
2024 | 6af0bf9c | bellard | CALL_FROM_TB0(do_tlbp); |
2025 | 6af0bf9c | bellard | RETURN(); |
2026 | 6af0bf9c | bellard | } |
2027 | 6af0bf9c | bellard | |
2028 | 6af0bf9c | bellard | void op_tlbr (void) |
2029 | 6af0bf9c | bellard | { |
2030 | 6af0bf9c | bellard | CALL_FROM_TB0(do_tlbr); |
2031 | 6af0bf9c | bellard | RETURN(); |
2032 | 6af0bf9c | bellard | } |
2033 | 6af0bf9c | bellard | #endif
|
2034 | 6af0bf9c | bellard | |
2035 | 6af0bf9c | bellard | /* Specials */
|
2036 | 6f5b89a0 | ths | #if defined (CONFIG_USER_ONLY)
|
2037 | 6f5b89a0 | ths | void op_tls_value (void) |
2038 | 6f5b89a0 | ths | { |
2039 | 6f5b89a0 | ths | T0 = env->tls_value; |
2040 | 6f5b89a0 | ths | } |
2041 | 6f5b89a0 | ths | #endif
|
2042 | 6f5b89a0 | ths | |
2043 | 6af0bf9c | bellard | void op_pmon (void) |
2044 | 6af0bf9c | bellard | { |
2045 | 6af0bf9c | bellard | CALL_FROM_TB1(do_pmon, PARAM1); |
2046 | 7a387fff | ths | RETURN(); |
2047 | 7a387fff | ths | } |
2048 | 7a387fff | ths | |
2049 | 7a387fff | ths | void op_di (void) |
2050 | 7a387fff | ths | { |
2051 | 7a387fff | ths | T0 = env->CP0_Status; |
2052 | 4de9b249 | ths | env->CP0_Status = T0 & ~(1 << CP0St_IE);
|
2053 | 4de9b249 | ths | CALL_FROM_TB1(cpu_mips_update_irq, env); |
2054 | 7a387fff | ths | RETURN(); |
2055 | 7a387fff | ths | } |
2056 | 7a387fff | ths | |
2057 | 7a387fff | ths | void op_ei (void) |
2058 | 7a387fff | ths | { |
2059 | 7a387fff | ths | T0 = env->CP0_Status; |
2060 | 4de9b249 | ths | env->CP0_Status = T0 | (1 << CP0St_IE);
|
2061 | 4de9b249 | ths | CALL_FROM_TB1(cpu_mips_update_irq, env); |
2062 | 7a387fff | ths | RETURN(); |
2063 | 6af0bf9c | bellard | } |
2064 | 6af0bf9c | bellard | |
2065 | 6af0bf9c | bellard | void op_trap (void) |
2066 | 6af0bf9c | bellard | { |
2067 | 6af0bf9c | bellard | if (T0) {
|
2068 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_TRAP); |
2069 | 6af0bf9c | bellard | } |
2070 | 6af0bf9c | bellard | RETURN(); |
2071 | 6af0bf9c | bellard | } |
2072 | 6af0bf9c | bellard | |
2073 | 4ad40f36 | bellard | void op_debug (void) |
2074 | 4ad40f36 | bellard | { |
2075 | 7a387fff | ths | CALL_FROM_TB1(do_raise_exception, EXCP_DEBUG); |
2076 | 7a387fff | ths | RETURN(); |
2077 | 4ad40f36 | bellard | } |
2078 | 4ad40f36 | bellard | |
2079 | 6af0bf9c | bellard | void op_set_lladdr (void) |
2080 | 6af0bf9c | bellard | { |
2081 | 6af0bf9c | bellard | env->CP0_LLAddr = T2; |
2082 | 7a387fff | ths | RETURN(); |
2083 | 6af0bf9c | bellard | } |
2084 | 6af0bf9c | bellard | |
2085 | f41c52f1 | ths | void debug_pre_eret (void); |
2086 | f41c52f1 | ths | void debug_post_eret (void); |
2087 | 6af0bf9c | bellard | void op_eret (void) |
2088 | 6af0bf9c | bellard | { |
2089 | f41c52f1 | ths | if (loglevel & CPU_LOG_EXEC)
|
2090 | f41c52f1 | ths | CALL_FROM_TB0(debug_pre_eret); |
2091 | 24c7b0e3 | ths | if (env->CP0_Status & (1 << CP0St_ERL)) { |
2092 | 6af0bf9c | bellard | env->PC = env->CP0_ErrorEPC; |
2093 | 24c7b0e3 | ths | env->CP0_Status &= ~(1 << CP0St_ERL);
|
2094 | 51e11d9e | bellard | } else {
|
2095 | 6af0bf9c | bellard | env->PC = env->CP0_EPC; |
2096 | 24c7b0e3 | ths | env->CP0_Status &= ~(1 << CP0St_EXL);
|
2097 | 51e11d9e | bellard | } |
2098 | 24c7b0e3 | ths | if (!(env->CP0_Status & (1 << CP0St_EXL)) && |
2099 | 24c7b0e3 | ths | !(env->CP0_Status & (1 << CP0St_ERL)) &&
|
2100 | 24c7b0e3 | ths | !(env->hflags & MIPS_HFLAG_DM) && |
2101 | 24c7b0e3 | ths | (env->CP0_Status & (1 << CP0St_UM)))
|
2102 | 24c7b0e3 | ths | env->hflags |= MIPS_HFLAG_UM; |
2103 | f41c52f1 | ths | if (loglevel & CPU_LOG_EXEC)
|
2104 | f41c52f1 | ths | CALL_FROM_TB0(debug_post_eret); |
2105 | 6af0bf9c | bellard | env->CP0_LLAddr = 1;
|
2106 | 7a387fff | ths | RETURN(); |
2107 | 6af0bf9c | bellard | } |
2108 | 6af0bf9c | bellard | |
2109 | 6af0bf9c | bellard | void op_deret (void) |
2110 | 6af0bf9c | bellard | { |
2111 | f41c52f1 | ths | if (loglevel & CPU_LOG_EXEC)
|
2112 | f41c52f1 | ths | CALL_FROM_TB0(debug_pre_eret); |
2113 | 6af0bf9c | bellard | env->PC = env->CP0_DEPC; |
2114 | 24c7b0e3 | ths | env->hflags |= MIPS_HFLAG_DM; |
2115 | 24c7b0e3 | ths | if (!(env->CP0_Status & (1 << CP0St_EXL)) && |
2116 | 24c7b0e3 | ths | !(env->CP0_Status & (1 << CP0St_ERL)) &&
|
2117 | 24c7b0e3 | ths | !(env->hflags & MIPS_HFLAG_DM) && |
2118 | 24c7b0e3 | ths | (env->CP0_Status & (1 << CP0St_UM)))
|
2119 | 24c7b0e3 | ths | env->hflags |= MIPS_HFLAG_UM; |
2120 | f41c52f1 | ths | if (loglevel & CPU_LOG_EXEC)
|
2121 | f41c52f1 | ths | CALL_FROM_TB0(debug_post_eret); |
2122 | 24c7b0e3 | ths | env->CP0_LLAddr = 1;
|
2123 | 7a387fff | ths | RETURN(); |
2124 | 7a387fff | ths | } |
2125 | 7a387fff | ths | |
2126 | 7a387fff | ths | void op_rdhwr_cpunum(void) |
2127 | 7a387fff | ths | { |
2128 | 1579a72e | ths | if (!(env->hflags & MIPS_HFLAG_UM) ||
|
2129 | 1579a72e | ths | (env->CP0_HWREna & (1 << 0)) || |
2130 | 1579a72e | ths | (env->CP0_Status & (1 << CP0St_CU0)))
|
2131 | 1579a72e | ths | T0 = env->CP0_EBase & 0x3ff;
|
2132 | 7a387fff | ths | else
|
2133 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_RI); |
2134 | 7a387fff | ths | RETURN(); |
2135 | 7a387fff | ths | } |
2136 | 7a387fff | ths | |
2137 | 7a387fff | ths | void op_rdhwr_synci_step(void) |
2138 | 7a387fff | ths | { |
2139 | 1579a72e | ths | if (!(env->hflags & MIPS_HFLAG_UM) ||
|
2140 | 1579a72e | ths | (env->CP0_HWREna & (1 << 1)) || |
2141 | 1579a72e | ths | (env->CP0_Status & (1 << CP0St_CU0)))
|
2142 | 1579a72e | ths | T0 = env->SYNCI_Step; |
2143 | 7a387fff | ths | else
|
2144 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_RI); |
2145 | 7a387fff | ths | RETURN(); |
2146 | 7a387fff | ths | } |
2147 | 7a387fff | ths | |
2148 | 7a387fff | ths | void op_rdhwr_cc(void) |
2149 | 7a387fff | ths | { |
2150 | 1579a72e | ths | if (!(env->hflags & MIPS_HFLAG_UM) ||
|
2151 | 1579a72e | ths | (env->CP0_HWREna & (1 << 2)) || |
2152 | 1579a72e | ths | (env->CP0_Status & (1 << CP0St_CU0)))
|
2153 | 1579a72e | ths | T0 = env->CP0_Count; |
2154 | 7a387fff | ths | else
|
2155 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_RI); |
2156 | 7a387fff | ths | RETURN(); |
2157 | 7a387fff | ths | } |
2158 | 7a387fff | ths | |
2159 | 7a387fff | ths | void op_rdhwr_ccres(void) |
2160 | 7a387fff | ths | { |
2161 | 1579a72e | ths | if (!(env->hflags & MIPS_HFLAG_UM) ||
|
2162 | 1579a72e | ths | (env->CP0_HWREna & (1 << 3)) || |
2163 | 1579a72e | ths | (env->CP0_Status & (1 << CP0St_CU0)))
|
2164 | 1579a72e | ths | T0 = env->CCRes; |
2165 | 7a387fff | ths | else
|
2166 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_RI); |
2167 | 1579a72e | ths | RETURN(); |
2168 | 1579a72e | ths | } |
2169 | 1579a72e | ths | |
2170 | 1579a72e | ths | void op_rdhwr_unimpl30(void) |
2171 | 1579a72e | ths | { |
2172 | 1579a72e | ths | if (!(env->hflags & MIPS_HFLAG_UM) ||
|
2173 | 1579a72e | ths | (env->CP0_HWREna & (1 << 30)) || |
2174 | 1579a72e | ths | (env->CP0_Status & (1 << CP0St_CU0)))
|
2175 | 1579a72e | ths | T0 = 0;
|
2176 | 1579a72e | ths | else
|
2177 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_RI); |
2178 | 1579a72e | ths | RETURN(); |
2179 | 1579a72e | ths | } |
2180 | 1579a72e | ths | |
2181 | 1579a72e | ths | void op_rdhwr_unimpl31(void) |
2182 | 1579a72e | ths | { |
2183 | 1579a72e | ths | if (!(env->hflags & MIPS_HFLAG_UM) ||
|
2184 | 1579a72e | ths | (env->CP0_HWREna & (1 << 31)) || |
2185 | 1579a72e | ths | (env->CP0_Status & (1 << CP0St_CU0)))
|
2186 | 1579a72e | ths | T0 = 0;
|
2187 | 1579a72e | ths | else
|
2188 | 1579a72e | ths | CALL_FROM_TB1(do_raise_exception, EXCP_RI); |
2189 | 7a387fff | ths | RETURN(); |
2190 | 6af0bf9c | bellard | } |
2191 | 6af0bf9c | bellard | |
2192 | 6af0bf9c | bellard | void op_save_state (void) |
2193 | 6af0bf9c | bellard | { |
2194 | 6af0bf9c | bellard | env->hflags = PARAM1; |
2195 | 6af0bf9c | bellard | RETURN(); |
2196 | 6af0bf9c | bellard | } |
2197 | 6af0bf9c | bellard | |
2198 | 6af0bf9c | bellard | void op_save_pc (void) |
2199 | 6af0bf9c | bellard | { |
2200 | 6af0bf9c | bellard | env->PC = PARAM1; |
2201 | 6af0bf9c | bellard | RETURN(); |
2202 | 6af0bf9c | bellard | } |
2203 | 6af0bf9c | bellard | |
2204 | 6af0bf9c | bellard | void op_raise_exception (void) |
2205 | 6af0bf9c | bellard | { |
2206 | 6af0bf9c | bellard | CALL_FROM_TB1(do_raise_exception, PARAM1); |
2207 | 6af0bf9c | bellard | RETURN(); |
2208 | 6af0bf9c | bellard | } |
2209 | 6af0bf9c | bellard | |
2210 | 6af0bf9c | bellard | void op_raise_exception_err (void) |
2211 | 6af0bf9c | bellard | { |
2212 | 6af0bf9c | bellard | CALL_FROM_TB2(do_raise_exception_err, PARAM1, PARAM2); |
2213 | 6af0bf9c | bellard | RETURN(); |
2214 | 6af0bf9c | bellard | } |
2215 | 6af0bf9c | bellard | |
2216 | 6af0bf9c | bellard | void op_exit_tb (void) |
2217 | 6af0bf9c | bellard | { |
2218 | 6af0bf9c | bellard | EXIT_TB(); |
2219 | 7a387fff | ths | RETURN(); |
2220 | 6af0bf9c | bellard | } |
2221 | 6af0bf9c | bellard | |
2222 | 4ad40f36 | bellard | void op_wait (void) |
2223 | 4ad40f36 | bellard | { |
2224 | 4ad40f36 | bellard | env->halted = 1;
|
2225 | 4ad40f36 | bellard | CALL_FROM_TB1(do_raise_exception, EXCP_HLT); |
2226 | 7a387fff | ths | RETURN(); |
2227 | 7a387fff | ths | } |
2228 | 7a387fff | ths | |
2229 | 7a387fff | ths | /* Bitfield operations. */
|
2230 | 7a387fff | ths | void op_ext(void) |
2231 | 7a387fff | ths | { |
2232 | 7a387fff | ths | unsigned int pos = PARAM1; |
2233 | 7a387fff | ths | unsigned int size = PARAM2; |
2234 | 7a387fff | ths | |
2235 | f757d6ff | ths | T0 = ((uint32_t)T1 >> pos) & ((size < 32) ? ((1 << size) - 1) : ~0); |
2236 | 7a387fff | ths | RETURN(); |
2237 | 7a387fff | ths | } |
2238 | 7a387fff | ths | |
2239 | 7a387fff | ths | void op_ins(void) |
2240 | 7a387fff | ths | { |
2241 | 7a387fff | ths | unsigned int pos = PARAM1; |
2242 | 7a387fff | ths | unsigned int size = PARAM2; |
2243 | f757d6ff | ths | target_ulong mask = ((size < 32) ? ((1 << size) - 1) : ~0) << pos; |
2244 | 7a387fff | ths | |
2245 | c570fd16 | ths | T0 = (T2 & ~mask) | (((uint32_t)T1 << pos) & mask); |
2246 | 7a387fff | ths | RETURN(); |
2247 | 7a387fff | ths | } |
2248 | 7a387fff | ths | |
2249 | 7a387fff | ths | void op_wsbh(void) |
2250 | 7a387fff | ths | { |
2251 | 7a387fff | ths | T0 = ((T1 << 8) & ~0x00FF00FF) | ((T1 >> 8) & 0x00FF00FF); |
2252 | 7a387fff | ths | RETURN(); |
2253 | 7a387fff | ths | } |
2254 | 7a387fff | ths | |
2255 | 60aa19ab | ths | #ifdef TARGET_MIPS64
|
2256 | c570fd16 | ths | void op_dext(void) |
2257 | c570fd16 | ths | { |
2258 | c570fd16 | ths | unsigned int pos = PARAM1; |
2259 | c570fd16 | ths | unsigned int size = PARAM2; |
2260 | c570fd16 | ths | |
2261 | f757d6ff | ths | T0 = (T1 >> pos) & ((size < 32) ? ((1 << size) - 1) : ~0); |
2262 | c570fd16 | ths | RETURN(); |
2263 | c570fd16 | ths | } |
2264 | c570fd16 | ths | |
2265 | c570fd16 | ths | void op_dins(void) |
2266 | c570fd16 | ths | { |
2267 | c570fd16 | ths | unsigned int pos = PARAM1; |
2268 | c570fd16 | ths | unsigned int size = PARAM2; |
2269 | f757d6ff | ths | target_ulong mask = ((size < 32) ? ((1 << size) - 1) : ~0) << pos; |
2270 | c570fd16 | ths | |
2271 | c570fd16 | ths | T0 = (T2 & ~mask) | ((T1 << pos) & mask); |
2272 | c570fd16 | ths | RETURN(); |
2273 | c570fd16 | ths | } |
2274 | c570fd16 | ths | |
2275 | 7a387fff | ths | void op_dsbh(void) |
2276 | 7a387fff | ths | { |
2277 | 7a387fff | ths | T0 = ((T1 << 8) & ~0x00FF00FF00FF00FFULL) | ((T1 >> 8) & 0x00FF00FF00FF00FFULL); |
2278 | 7a387fff | ths | RETURN(); |
2279 | 7a387fff | ths | } |
2280 | 7a387fff | ths | |
2281 | 7a387fff | ths | void op_dshd(void) |
2282 | 7a387fff | ths | { |
2283 | 7a387fff | ths | T0 = ((T1 << 16) & ~0x0000FFFF0000FFFFULL) | ((T1 >> 16) & 0x0000FFFF0000FFFFULL); |
2284 | 7a387fff | ths | RETURN(); |
2285 | 7a387fff | ths | } |
2286 | c570fd16 | ths | #endif
|
2287 | 7a387fff | ths | |
2288 | 7a387fff | ths | void op_seb(void) |
2289 | 7a387fff | ths | { |
2290 | 7a387fff | ths | T0 = ((T1 & 0xFF) ^ 0x80) - 0x80; |
2291 | 7a387fff | ths | RETURN(); |
2292 | 7a387fff | ths | } |
2293 | 7a387fff | ths | |
2294 | 7a387fff | ths | void op_seh(void) |
2295 | 7a387fff | ths | { |
2296 | 7a387fff | ths | T0 = ((T1 & 0xFFFF) ^ 0x8000) - 0x8000; |
2297 | 7a387fff | ths | RETURN(); |
2298 | 4ad40f36 | bellard | } |