Commit 48d38ca52b6d9c33066e139226eba2966d0c88d3

Authored by ths
1 parent 8c99506c

Switch most MIPS logical and arithmetic instructions to TCG.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4496 c046a42c-6fe2-441c-8c8c-71466251a162
target-mips/exec.h
@@ -118,8 +118,6 @@ void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra); @@ -118,8 +118,6 @@ void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra);
118 void cpu_loop_exit(void); 118 void cpu_loop_exit(void);
119 void do_raise_exception_err (uint32_t exception, int error_code); 119 void do_raise_exception_err (uint32_t exception, int error_code);
120 void do_raise_exception (uint32_t exception); 120 void do_raise_exception (uint32_t exception);
121 -void do_raise_exception_direct_err (uint32_t exception, int error_code);  
122 -void do_raise_exception_direct (uint32_t exception);  
123 121
124 void cpu_dump_state(CPUState *env, FILE *f, 122 void cpu_dump_state(CPUState *env, FILE *f,
125 int (*cpu_fprintf)(FILE *f, const char *fmt, ...), 123 int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
target-mips/op.c
@@ -167,251 +167,7 @@ @@ -167,251 +167,7 @@
167 #undef MEMSUFFIX 167 #undef MEMSUFFIX
168 #endif 168 #endif
169 169
170 -/* Addresses computation */  
171 -void op_addr_add (void)  
172 -{  
173 -/* For compatibility with 32-bit code, data reference in user mode  
174 - with Status_UX = 0 should be casted to 32-bit and sign extended.  
175 - See the MIPS64 PRA manual, section 4.10. */  
176 -#if defined(TARGET_MIPS64)  
177 - if (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&  
178 - !(env->CP0_Status & (1 << CP0St_UX)))  
179 - T0 = (int64_t)(int32_t)(T0 + T1);  
180 - else  
181 -#endif  
182 - T0 += T1;  
183 - FORCE_RET();  
184 -}  
185 -  
186 -/* Arithmetic */  
187 -void op_add (void)  
188 -{  
189 - T0 = (int32_t)((int32_t)T0 + (int32_t)T1);  
190 - FORCE_RET();  
191 -}  
192 -  
193 -void op_addo (void)  
194 -{  
195 - target_ulong tmp;  
196 -  
197 - tmp = (int32_t)T0;  
198 - T0 = (int32_t)T0 + (int32_t)T1;  
199 - if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {  
200 - /* operands of same sign, result different sign */  
201 - CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);  
202 - }  
203 - T0 = (int32_t)T0;  
204 - FORCE_RET();  
205 -}  
206 -  
207 -void op_sub (void)  
208 -{  
209 - T0 = (int32_t)((int32_t)T0 - (int32_t)T1);  
210 - FORCE_RET();  
211 -}  
212 -  
213 -void op_subo (void)  
214 -{  
215 - target_ulong tmp;  
216 -  
217 - tmp = (int32_t)T0;  
218 - T0 = (int32_t)T0 - (int32_t)T1;  
219 - if (((tmp ^ T1) & (tmp ^ T0)) >> 31) {  
220 - /* operands of different sign, first operand and result different sign */  
221 - CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);  
222 - }  
223 - T0 = (int32_t)T0;  
224 - FORCE_RET();  
225 -}  
226 -  
227 -void op_mul (void)  
228 -{  
229 - T0 = (int32_t)((int32_t)T0 * (int32_t)T1);  
230 - FORCE_RET();  
231 -}  
232 -  
233 -#if HOST_LONG_BITS < 64  
234 -void op_div (void)  
235 -{  
236 - CALL_FROM_TB0(do_div);  
237 - FORCE_RET();  
238 -}  
239 -#else  
240 -void op_div (void)  
241 -{  
242 - if (T1 != 0) {  
243 - env->LO[env->current_tc][0] = (int32_t)((int64_t)(int32_t)T0 / (int32_t)T1);  
244 - env->HI[env->current_tc][0] = (int32_t)((int64_t)(int32_t)T0 % (int32_t)T1);  
245 - }  
246 - FORCE_RET();  
247 -}  
248 -#endif  
249 -  
250 -void op_divu (void)  
251 -{  
252 - if (T1 != 0) {  
253 - env->LO[env->current_tc][0] = (int32_t)((uint32_t)T0 / (uint32_t)T1);  
254 - env->HI[env->current_tc][0] = (int32_t)((uint32_t)T0 % (uint32_t)T1);  
255 - }  
256 - FORCE_RET();  
257 -}  
258 -  
259 -#if defined(TARGET_MIPS64)  
260 -/* Arithmetic */  
261 -void op_dadd (void)  
262 -{  
263 - T0 += T1;  
264 - FORCE_RET();  
265 -}  
266 -  
267 -void op_daddo (void)  
268 -{  
269 - target_long tmp;  
270 -  
271 - tmp = T0;  
272 - T0 += T1;  
273 - if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 63) {  
274 - /* operands of same sign, result different sign */  
275 - CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);  
276 - }  
277 - FORCE_RET();  
278 -}  
279 -  
280 -void op_dsub (void)  
281 -{  
282 - T0 -= T1;  
283 - FORCE_RET();  
284 -}  
285 -  
286 -void op_dsubo (void)  
287 -{  
288 - target_long tmp;  
289 -  
290 - tmp = T0;  
291 - T0 = (int64_t)T0 - (int64_t)T1;  
292 - if (((tmp ^ T1) & (tmp ^ T0)) >> 63) {  
293 - /* operands of different sign, first operand and result different sign */  
294 - CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);  
295 - }  
296 - FORCE_RET();  
297 -}  
298 -  
299 -void op_dmul (void)  
300 -{  
301 - T0 = (int64_t)T0 * (int64_t)T1;  
302 - FORCE_RET();  
303 -}  
304 -  
305 -/* Those might call libgcc functions. */  
306 -void op_ddiv (void)  
307 -{  
308 - do_ddiv();  
309 - FORCE_RET();  
310 -}  
311 -  
312 -#if TARGET_LONG_BITS > HOST_LONG_BITS  
313 -void op_ddivu (void)  
314 -{  
315 - do_ddivu();  
316 - FORCE_RET();  
317 -}  
318 -#else  
319 -void op_ddivu (void)  
320 -{  
321 - if (T1 != 0) {  
322 - env->LO[env->current_tc][0] = T0 / T1;  
323 - env->HI[env->current_tc][0] = T0 % T1;  
324 - }  
325 - FORCE_RET();  
326 -}  
327 -#endif  
328 -#endif /* TARGET_MIPS64 */  
329 -  
330 /* Logical */ 170 /* Logical */
331 -void op_and (void)  
332 -{  
333 - T0 &= T1;  
334 - FORCE_RET();  
335 -}  
336 -  
337 -void op_nor (void)  
338 -{  
339 - T0 = ~(T0 | T1);  
340 - FORCE_RET();  
341 -}  
342 -  
343 -void op_or (void)  
344 -{  
345 - T0 |= T1;  
346 - FORCE_RET();  
347 -}  
348 -  
349 -void op_xor (void)  
350 -{  
351 - T0 ^= T1;  
352 - FORCE_RET();  
353 -}  
354 -  
355 -void op_sll (void)  
356 -{  
357 - T0 = (int32_t)((uint32_t)T0 << T1);  
358 - FORCE_RET();  
359 -}  
360 -  
361 -void op_sra (void)  
362 -{  
363 - T0 = (int32_t)((int32_t)T0 >> T1);  
364 - FORCE_RET();  
365 -}  
366 -  
367 -void op_srl (void)  
368 -{  
369 - T0 = (int32_t)((uint32_t)T0 >> T1);  
370 - FORCE_RET();  
371 -}  
372 -  
373 -void op_rotr (void)  
374 -{  
375 - target_ulong tmp;  
376 -  
377 - if (T1) {  
378 - tmp = (int32_t)((uint32_t)T0 << (0x20 - T1));  
379 - T0 = (int32_t)((uint32_t)T0 >> T1) | tmp;  
380 - }  
381 - FORCE_RET();  
382 -}  
383 -  
384 -void op_sllv (void)  
385 -{  
386 - T0 = (int32_t)((uint32_t)T1 << ((uint32_t)T0 & 0x1F));  
387 - FORCE_RET();  
388 -}  
389 -  
390 -void op_srav (void)  
391 -{  
392 - T0 = (int32_t)((int32_t)T1 >> (T0 & 0x1F));  
393 - FORCE_RET();  
394 -}  
395 -  
396 -void op_srlv (void)  
397 -{  
398 - T0 = (int32_t)((uint32_t)T1 >> (T0 & 0x1F));  
399 - FORCE_RET();  
400 -}  
401 -  
402 -void op_rotrv (void)  
403 -{  
404 - target_ulong tmp;  
405 -  
406 - T0 &= 0x1F;  
407 - if (T0) {  
408 - tmp = (int32_t)((uint32_t)T1 << (0x20 - T0));  
409 - T0 = (int32_t)((uint32_t)T1 >> T0) | tmp;  
410 - } else  
411 - T0 = T1;  
412 - FORCE_RET();  
413 -}  
414 -  
415 void op_clo (void) 171 void op_clo (void)
416 { 172 {
417 T0 = clo32(T0); 173 T0 = clo32(T0);
@@ -428,78 +184,6 @@ void op_clz (void) @@ -428,78 +184,6 @@ void op_clz (void)
428 184
429 #if TARGET_LONG_BITS > HOST_LONG_BITS 185 #if TARGET_LONG_BITS > HOST_LONG_BITS
430 /* Those might call libgcc functions. */ 186 /* Those might call libgcc functions. */
431 -void op_dsll (void)  
432 -{  
433 - CALL_FROM_TB0(do_dsll);  
434 - FORCE_RET();  
435 -}  
436 -  
437 -void op_dsll32 (void)  
438 -{  
439 - CALL_FROM_TB0(do_dsll32);  
440 - FORCE_RET();  
441 -}  
442 -  
443 -void op_dsra (void)  
444 -{  
445 - CALL_FROM_TB0(do_dsra);  
446 - FORCE_RET();  
447 -}  
448 -  
449 -void op_dsra32 (void)  
450 -{  
451 - CALL_FROM_TB0(do_dsra32);  
452 - FORCE_RET();  
453 -}  
454 -  
455 -void op_dsrl (void)  
456 -{  
457 - CALL_FROM_TB0(do_dsrl);  
458 - FORCE_RET();  
459 -}  
460 -  
461 -void op_dsrl32 (void)  
462 -{  
463 - CALL_FROM_TB0(do_dsrl32);  
464 - FORCE_RET();  
465 -}  
466 -  
467 -void op_drotr (void)  
468 -{  
469 - CALL_FROM_TB0(do_drotr);  
470 - FORCE_RET();  
471 -}  
472 -  
473 -void op_drotr32 (void)  
474 -{  
475 - CALL_FROM_TB0(do_drotr32);  
476 - FORCE_RET();  
477 -}  
478 -  
479 -void op_dsllv (void)  
480 -{  
481 - CALL_FROM_TB0(do_dsllv);  
482 - FORCE_RET();  
483 -}  
484 -  
485 -void op_dsrav (void)  
486 -{  
487 - CALL_FROM_TB0(do_dsrav);  
488 - FORCE_RET();  
489 -}  
490 -  
491 -void op_dsrlv (void)  
492 -{  
493 - CALL_FROM_TB0(do_dsrlv);  
494 - FORCE_RET();  
495 -}  
496 -  
497 -void op_drotrv (void)  
498 -{  
499 - CALL_FROM_TB0(do_drotrv);  
500 - FORCE_RET();  
501 -}  
502 -  
503 void op_dclo (void) 187 void op_dclo (void)
504 { 188 {
505 CALL_FROM_TB0(do_dclo); 189 CALL_FROM_TB0(do_dclo);
@@ -514,93 +198,6 @@ void op_dclz (void) @@ -514,93 +198,6 @@ void op_dclz (void)
514 198
515 #else /* TARGET_LONG_BITS > HOST_LONG_BITS */ 199 #else /* TARGET_LONG_BITS > HOST_LONG_BITS */
516 200
517 -void op_dsll (void)  
518 -{  
519 - T0 = T0 << T1;  
520 - FORCE_RET();  
521 -}  
522 -  
523 -void op_dsll32 (void)  
524 -{  
525 - T0 = T0 << (T1 + 32);  
526 - FORCE_RET();  
527 -}  
528 -  
529 -void op_dsra (void)  
530 -{  
531 - T0 = (int64_t)T0 >> T1;  
532 - FORCE_RET();  
533 -}  
534 -  
535 -void op_dsra32 (void)  
536 -{  
537 - T0 = (int64_t)T0 >> (T1 + 32);  
538 - FORCE_RET();  
539 -}  
540 -  
541 -void op_dsrl (void)  
542 -{  
543 - T0 = T0 >> T1;  
544 - FORCE_RET();  
545 -}  
546 -  
547 -void op_dsrl32 (void)  
548 -{  
549 - T0 = T0 >> (T1 + 32);  
550 - FORCE_RET();  
551 -}  
552 -  
553 -void op_drotr (void)  
554 -{  
555 - target_ulong tmp;  
556 -  
557 - if (T1) {  
558 - tmp = T0 << (0x40 - T1);  
559 - T0 = (T0 >> T1) | tmp;  
560 - }  
561 - FORCE_RET();  
562 -}  
563 -  
564 -void op_drotr32 (void)  
565 -{  
566 - target_ulong tmp;  
567 -  
568 - tmp = T0 << (0x40 - (32 + T1));  
569 - T0 = (T0 >> (32 + T1)) | tmp;  
570 - FORCE_RET();  
571 -}  
572 -  
573 -void op_dsllv (void)  
574 -{  
575 - T0 = T1 << (T0 & 0x3F);  
576 - FORCE_RET();  
577 -}  
578 -  
579 -void op_dsrav (void)  
580 -{  
581 - T0 = (int64_t)T1 >> (T0 & 0x3F);  
582 - FORCE_RET();  
583 -}  
584 -  
585 -void op_dsrlv (void)  
586 -{  
587 - T0 = T1 >> (T0 & 0x3F);  
588 - FORCE_RET();  
589 -}  
590 -  
591 -void op_drotrv (void)  
592 -{  
593 - target_ulong tmp;  
594 -  
595 - T0 &= 0x3F;  
596 - if (T0) {  
597 - tmp = T1 << (0x40 - T0);  
598 - T0 = (T1 >> T0) | tmp;  
599 - } else  
600 - T0 = T1;  
601 - FORCE_RET();  
602 -}  
603 -  
604 void op_dclo (void) 201 void op_dclo (void)
605 { 202 {
606 T0 = clo64(T0); 203 T0 = clo64(T0);
@@ -3063,31 +2660,6 @@ void op_save_pc64 (void) @@ -3063,31 +2660,6 @@ void op_save_pc64 (void)
3063 } 2660 }
3064 #endif 2661 #endif
3065 2662
3066 -void op_interrupt_restart (void)  
3067 -{  
3068 - if (!(env->CP0_Status & (1 << CP0St_EXL)) &&  
3069 - !(env->CP0_Status & (1 << CP0St_ERL)) &&  
3070 - !(env->hflags & MIPS_HFLAG_DM) &&  
3071 - (env->CP0_Status & (1 << CP0St_IE)) &&  
3072 - (env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask)) {  
3073 - env->CP0_Cause &= ~(0x1f << CP0Ca_EC);  
3074 - CALL_FROM_TB1(do_raise_exception, EXCP_EXT_INTERRUPT);  
3075 - }  
3076 - FORCE_RET();  
3077 -}  
3078 -  
3079 -void op_raise_exception (void)  
3080 -{  
3081 - CALL_FROM_TB1(do_raise_exception, PARAM1);  
3082 - FORCE_RET();  
3083 -}  
3084 -  
3085 -void op_raise_exception_err (void)  
3086 -{  
3087 - CALL_FROM_TB2(do_raise_exception_err, PARAM1, PARAM2);  
3088 - FORCE_RET();  
3089 -}  
3090 -  
3091 void op_wait (void) 2663 void op_wait (void)
3092 { 2664 {
3093 env->halted = 1; 2665 env->halted = 1;
@@ -3154,15 +2726,3 @@ void op_dshd(void) @@ -3154,15 +2726,3 @@ void op_dshd(void)
3154 FORCE_RET(); 2726 FORCE_RET();
3155 } 2727 }
3156 #endif 2728 #endif
3157 -  
3158 -void op_seb(void)  
3159 -{  
3160 - T0 = ((T1 & 0xFF) ^ 0x80) - 0x80;  
3161 - FORCE_RET();  
3162 -}  
3163 -  
3164 -void op_seh(void)  
3165 -{  
3166 - T0 = ((T1 & 0xFFFF) ^ 0x8000) - 0x8000;  
3167 - FORCE_RET();  
3168 -}  
target-mips/op_helper.c
@@ -48,6 +48,18 @@ void do_raise_exception (uint32_t exception) @@ -48,6 +48,18 @@ void do_raise_exception (uint32_t exception)
48 do_raise_exception_err(exception, 0); 48 do_raise_exception_err(exception, 0);
49 } 49 }
50 50
  51 +void do_interrupt_restart (void)
  52 +{
  53 + if (!(env->CP0_Status & (1 << CP0St_EXL)) &&
  54 + !(env->CP0_Status & (1 << CP0St_ERL)) &&
  55 + !(env->hflags & MIPS_HFLAG_DM) &&
  56 + (env->CP0_Status & (1 << CP0St_IE)) &&
  57 + (env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask)) {
  58 + env->CP0_Cause &= ~(0x1f << CP0Ca_EC);
  59 + do_raise_exception(EXCP_EXT_INTERRUPT);
  60 + }
  61 +}
  62 +
51 void do_restore_state (void *pc_ptr) 63 void do_restore_state (void *pc_ptr)
52 { 64 {
53 TranslationBlock *tb; 65 TranslationBlock *tb;
@@ -59,17 +71,6 @@ void do_restore_state (void *pc_ptr) @@ -59,17 +71,6 @@ void do_restore_state (void *pc_ptr)
59 } 71 }
60 } 72 }
61 73
62 -void do_raise_exception_direct_err (uint32_t exception, int error_code)  
63 -{  
64 - do_restore_state (GETPC ());  
65 - do_raise_exception_err (exception, error_code);  
66 -}  
67 -  
68 -void do_raise_exception_direct (uint32_t exception)  
69 -{  
70 - do_raise_exception_direct_err (exception, 0);  
71 -}  
72 -  
73 #if defined(TARGET_MIPS64) 74 #if defined(TARGET_MIPS64)
74 #if TARGET_LONG_BITS > HOST_LONG_BITS 75 #if TARGET_LONG_BITS > HOST_LONG_BITS
75 /* Those might call libgcc functions. */ 76 /* Those might call libgcc functions. */
@@ -300,45 +301,6 @@ void do_mulshiu (void) @@ -300,45 +301,6 @@ void do_mulshiu (void)
300 } 301 }
301 #endif /* TARGET_LONG_BITS > HOST_LONG_BITS */ 302 #endif /* TARGET_LONG_BITS > HOST_LONG_BITS */
302 303
303 -#if HOST_LONG_BITS < 64  
304 -void do_div (void)  
305 -{  
306 - /* 64bit datatypes because we may see overflow/underflow. */  
307 - if (T1 != 0) {  
308 - env->LO[env->current_tc][0] = (int32_t)((int64_t)(int32_t)T0 / (int32_t)T1);  
309 - env->HI[env->current_tc][0] = (int32_t)((int64_t)(int32_t)T0 % (int32_t)T1);  
310 - }  
311 -}  
312 -#endif  
313 -  
314 -#if defined(TARGET_MIPS64)  
315 -void do_ddiv (void)  
316 -{  
317 - if (T1 != 0) {  
318 - int64_t arg0 = (int64_t)T0;  
319 - int64_t arg1 = (int64_t)T1;  
320 - if (arg0 == ((int64_t)-1 << 63) && arg1 == (int64_t)-1) {  
321 - env->LO[env->current_tc][0] = arg0;  
322 - env->HI[env->current_tc][0] = 0;  
323 - } else {  
324 - lldiv_t res = lldiv(arg0, arg1);  
325 - env->LO[env->current_tc][0] = res.quot;  
326 - env->HI[env->current_tc][0] = res.rem;  
327 - }  
328 - }  
329 -}  
330 -  
331 -#if TARGET_LONG_BITS > HOST_LONG_BITS  
332 -void do_ddivu (void)  
333 -{  
334 - if (T1 != 0) {  
335 - env->LO[env->current_tc][0] = T0 / T1;  
336 - env->HI[env->current_tc][0] = T0 % T1;  
337 - }  
338 -}  
339 -#endif  
340 -#endif /* TARGET_MIPS64 */  
341 -  
342 #if defined(CONFIG_USER_ONLY) 304 #if defined(CONFIG_USER_ONLY)
343 void do_mfc0_random (void) 305 void do_mfc0_random (void)
344 { 306 {
target-mips/translate.c
@@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
29 #include "cpu.h" 29 #include "cpu.h"
30 #include "exec-all.h" 30 #include "exec-all.h"
31 #include "disas.h" 31 #include "disas.h"
  32 +#include "helper.h"
32 #include "tcg-op.h" 33 #include "tcg-op.h"
33 #include "qemu-common.h" 34 #include "qemu-common.h"
34 35
@@ -833,40 +834,47 @@ static always_inline void restore_cpu_state (CPUState *env, DisasContext *ctx) @@ -833,40 +834,47 @@ static always_inline void restore_cpu_state (CPUState *env, DisasContext *ctx)
833 } 834 }
834 835
835 static always_inline void 836 static always_inline void
836 -generate_tcg_exception_err (DisasContext *ctx, int excp, int err) 837 +generate_exception_err (DisasContext *ctx, int excp, int err)
837 { 838 {
838 save_cpu_state(ctx, 1); 839 save_cpu_state(ctx, 1);
839 - if (err == 0)  
840 - gen_op_raise_exception(excp);  
841 - else  
842 - gen_op_raise_exception_err(excp, err);  
843 - gen_op_interrupt_restart(); 840 + tcg_gen_helper_0_2(do_raise_exception_err, tcg_const_i32(excp), tcg_const_i32(err));
  841 + tcg_gen_helper_0_0(do_interrupt_restart);
844 tcg_gen_exit_tb(0); 842 tcg_gen_exit_tb(0);
845 } 843 }
846 844
847 static always_inline void 845 static always_inline void
848 -generate_tcg_exception (DisasContext *ctx, int excp) 846 +generate_exception (DisasContext *ctx, int excp)
849 { 847 {
850 - generate_tcg_exception_err (ctx, excp, 0);  
851 -}  
852 -  
853 -static always_inline void generate_exception_err (DisasContext *ctx, int excp, int err)  
854 -{  
855 -#if defined MIPS_DEBUG_DISAS  
856 - if (loglevel & CPU_LOG_TB_IN_ASM)  
857 - fprintf(logfile, "%s: raise exception %d\n", __func__, excp);  
858 -#endif  
859 save_cpu_state(ctx, 1); 848 save_cpu_state(ctx, 1);
860 - if (err == 0)  
861 - gen_op_raise_exception(excp);  
862 - else  
863 - gen_op_raise_exception_err(excp, err);  
864 - ctx->bstate = BS_EXCP; 849 + tcg_gen_helper_0_1(do_raise_exception, tcg_const_i32(excp));
  850 + tcg_gen_helper_0_0(do_interrupt_restart);
  851 + tcg_gen_exit_tb(0);
865 } 852 }
866 853
867 -static always_inline void generate_exception (DisasContext *ctx, int excp) 854 +/* Addresses computation */
  855 +static inline void gen_op_addr_add (void)
868 { 856 {
869 - generate_exception_err (ctx, excp, 0); 857 + tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
  858 +
  859 +#if defined(TARGET_MIPS64)
  860 + /* For compatibility with 32-bit code, data reference in user mode
  861 + with Status_UX = 0 should be casted to 32-bit and sign extended.
  862 + See the MIPS64 PRA manual, section 4.10. */
  863 + {
  864 + TCGv r_tmp = new_tmp();
  865 + int l1 = gen_new_label();
  866 +
  867 + tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, hflags));
  868 + tcg_gen_andi_i32(r_tmp, r_tmp, MIPS_HFLAG_KSU);
  869 + tcg_gen_brcond_i32(TCG_COND_NE, r_tmp, tcg_const_i32(MIPS_HFLAG_UM), l1);
  870 + tcg_gen_ld_i32(r_tmp, cpu_env, offsetof(CPUState, CP0_Status));
  871 + tcg_gen_andi_i32(r_tmp, r_tmp, (1 << CP0St_UX));
  872 + tcg_gen_brcond_i32(TCG_COND_NE, r_tmp, tcg_const_i32(0), l1);
  873 + tcg_gen_ext32s_i64(cpu_T[0], cpu_T[0]);
  874 + gen_set_label(l1);
  875 + dead_tmp(r_tmp);
  876 + }
  877 +#endif
870 } 878 }
871 879
872 static always_inline void check_cp0_enabled(DisasContext *ctx) 880 static always_inline void check_cp0_enabled(DisasContext *ctx)
@@ -1024,7 +1032,7 @@ void inline op_ldst_##insn(DisasContext *ctx) \ @@ -1024,7 +1032,7 @@ void inline op_ldst_##insn(DisasContext *ctx) \
1024 tcg_gen_andi_tl(r_tmp, cpu_T[0], almask); \ 1032 tcg_gen_andi_tl(r_tmp, cpu_T[0], almask); \
1025 tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp, tcg_const_tl(0), l1); \ 1033 tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp, tcg_const_tl(0), l1); \
1026 tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_BadVAddr)); \ 1034 tcg_gen_st_tl(cpu_T[0], cpu_env, offsetof(CPUState, CP0_BadVAddr)); \
1027 - generate_tcg_exception(ctx, EXCP_AdES); \ 1035 + generate_exception(ctx, EXCP_AdES); \
1028 gen_set_label(l1); \ 1036 gen_set_label(l1); \
1029 tcg_gen_ld_tl(r_tmp, cpu_env, offsetof(CPUState, CP0_LLAddr)); \ 1037 tcg_gen_ld_tl(r_tmp, cpu_env, offsetof(CPUState, CP0_LLAddr)); \
1030 tcg_gen_brcond_tl(TCG_COND_NE, cpu_T[0], r_tmp, l2); \ 1038 tcg_gen_brcond_tl(TCG_COND_NE, cpu_T[0], r_tmp, l2); \
@@ -1282,12 +1290,12 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc, @@ -1282,12 +1290,12 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
1282 case OPC_SLTI: 1290 case OPC_SLTI:
1283 case OPC_SLTIU: 1291 case OPC_SLTIU:
1284 uimm = (target_long)imm; /* Sign extend to 32/64 bits */ 1292 uimm = (target_long)imm; /* Sign extend to 32/64 bits */
  1293 + GEN_LOAD_IMM_TN(T1, uimm);
1285 /* Fall through. */ 1294 /* Fall through. */
1286 case OPC_ANDI: 1295 case OPC_ANDI:
1287 case OPC_ORI: 1296 case OPC_ORI:
1288 case OPC_XORI: 1297 case OPC_XORI:
1289 GEN_LOAD_REG_T0(rs); 1298 GEN_LOAD_REG_T0(rs);
1290 - GEN_LOAD_IMM_TN(T1, uimm);  
1291 break; 1299 break;
1292 case OPC_LUI: 1300 case OPC_LUI:
1293 GEN_LOAD_IMM_TN(T0, imm << 16); 1301 GEN_LOAD_IMM_TN(T0, imm << 16);
@@ -1305,27 +1313,64 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc, @@ -1305,27 +1313,64 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
1305 #endif 1313 #endif
1306 uimm &= 0x1f; 1314 uimm &= 0x1f;
1307 GEN_LOAD_REG_T0(rs); 1315 GEN_LOAD_REG_T0(rs);
1308 - GEN_LOAD_IMM_TN(T1, uimm);  
1309 break; 1316 break;
1310 } 1317 }
1311 switch (opc) { 1318 switch (opc) {
1312 case OPC_ADDI: 1319 case OPC_ADDI:
1313 - save_cpu_state(ctx, 1);  
1314 - gen_op_addo(); 1320 + {
  1321 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
  1322 + TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
  1323 + int l1 = gen_new_label();
  1324 +
  1325 + save_cpu_state(ctx, 1);
  1326 + tcg_gen_ext32s_tl(r_tmp1, cpu_T[0]);
  1327 + tcg_gen_addi_tl(cpu_T[0], r_tmp1, uimm);
  1328 +
  1329 + tcg_gen_xori_tl(r_tmp1, r_tmp1, uimm);
  1330 + tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
  1331 + tcg_gen_xori_tl(r_tmp2, cpu_T[0], uimm);
  1332 + tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
  1333 + tcg_gen_shri_tl(r_tmp1, r_tmp1, 31);
  1334 + tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
  1335 + /* operands of same sign, result different sign */
  1336 + generate_exception(ctx, EXCP_OVERFLOW);
  1337 + gen_set_label(l1);
  1338 +
  1339 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
  1340 + }
1315 opn = "addi"; 1341 opn = "addi";
1316 break; 1342 break;
1317 case OPC_ADDIU: 1343 case OPC_ADDIU:
1318 - gen_op_add(); 1344 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
  1345 + tcg_gen_addi_tl(cpu_T[0], cpu_T[0], uimm);
  1346 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1319 opn = "addiu"; 1347 opn = "addiu";
1320 break; 1348 break;
1321 #if defined(TARGET_MIPS64) 1349 #if defined(TARGET_MIPS64)
1322 case OPC_DADDI: 1350 case OPC_DADDI:
1323 - save_cpu_state(ctx, 1);  
1324 - gen_op_daddo(); 1351 + {
  1352 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
  1353 + TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
  1354 + int l1 = gen_new_label();
  1355 +
  1356 + save_cpu_state(ctx, 1);
  1357 + tcg_gen_mov_tl(r_tmp1, cpu_T[0]);
  1358 + tcg_gen_addi_tl(cpu_T[0], cpu_T[0], uimm);
  1359 +
  1360 + tcg_gen_xori_tl(r_tmp1, r_tmp1, uimm);
  1361 + tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
  1362 + tcg_gen_xori_tl(r_tmp2, cpu_T[0], uimm);
  1363 + tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
  1364 + tcg_gen_shri_tl(r_tmp1, r_tmp1, 63);
  1365 + tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
  1366 + /* operands of same sign, result different sign */
  1367 + generate_exception(ctx, EXCP_OVERFLOW);
  1368 + gen_set_label(l1);
  1369 + }
1325 opn = "daddi"; 1370 opn = "daddi";
1326 break; 1371 break;
1327 case OPC_DADDIU: 1372 case OPC_DADDIU:
1328 - gen_op_dadd(); 1373 + tcg_gen_addi_tl(cpu_T[0], cpu_T[0], uimm);
1329 opn = "daddiu"; 1374 opn = "daddiu";
1330 break; 1375 break;
1331 #endif 1376 #endif
@@ -1338,41 +1383,62 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc, @@ -1338,41 +1383,62 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
1338 opn = "sltiu"; 1383 opn = "sltiu";
1339 break; 1384 break;
1340 case OPC_ANDI: 1385 case OPC_ANDI:
1341 - gen_op_and(); 1386 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], uimm);
1342 opn = "andi"; 1387 opn = "andi";
1343 break; 1388 break;
1344 case OPC_ORI: 1389 case OPC_ORI:
1345 - gen_op_or(); 1390 + tcg_gen_ori_tl(cpu_T[0], cpu_T[0], uimm);
1346 opn = "ori"; 1391 opn = "ori";
1347 break; 1392 break;
1348 case OPC_XORI: 1393 case OPC_XORI:
1349 - gen_op_xor(); 1394 + tcg_gen_xori_tl(cpu_T[0], cpu_T[0], uimm);
1350 opn = "xori"; 1395 opn = "xori";
1351 break; 1396 break;
1352 case OPC_LUI: 1397 case OPC_LUI:
1353 opn = "lui"; 1398 opn = "lui";
1354 break; 1399 break;
1355 case OPC_SLL: 1400 case OPC_SLL:
1356 - gen_op_sll(); 1401 + tcg_gen_ext32u_tl(cpu_T[0], cpu_T[0]);
  1402 + tcg_gen_shli_tl(cpu_T[0], cpu_T[0], uimm);
  1403 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1357 opn = "sll"; 1404 opn = "sll";
1358 break; 1405 break;
1359 case OPC_SRA: 1406 case OPC_SRA:
1360 - gen_op_sra(); 1407 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
  1408 + tcg_gen_sari_tl(cpu_T[0], cpu_T[0], uimm);
  1409 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1361 opn = "sra"; 1410 opn = "sra";
1362 break; 1411 break;
1363 case OPC_SRL: 1412 case OPC_SRL:
1364 switch ((ctx->opcode >> 21) & 0x1f) { 1413 switch ((ctx->opcode >> 21) & 0x1f) {
1365 case 0: 1414 case 0:
1366 - gen_op_srl(); 1415 + tcg_gen_ext32u_tl(cpu_T[0], cpu_T[0]);
  1416 + tcg_gen_shri_tl(cpu_T[0], cpu_T[0], uimm);
  1417 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1367 opn = "srl"; 1418 opn = "srl";
1368 break; 1419 break;
1369 case 1: 1420 case 1:
1370 /* rotr is decoded as srl on non-R2 CPUs */ 1421 /* rotr is decoded as srl on non-R2 CPUs */
1371 if (env->insn_flags & ISA_MIPS32R2) { 1422 if (env->insn_flags & ISA_MIPS32R2) {
1372 - gen_op_rotr(); 1423 + if (uimm != 0) {
  1424 + TCGv r_tmp1 = new_tmp();
  1425 + TCGv r_tmp2 = new_tmp();
  1426 +
  1427 + tcg_gen_trunc_tl_i32(r_tmp1, cpu_T[0]);
  1428 + tcg_gen_movi_i32(r_tmp2, 0x20);
  1429 + tcg_gen_subi_i32(r_tmp2, r_tmp2, uimm);
  1430 + tcg_gen_shl_i32(r_tmp2, r_tmp1, r_tmp2);
  1431 + tcg_gen_shri_i32(r_tmp1, r_tmp1, uimm);
  1432 + tcg_gen_or_i32(r_tmp1, r_tmp1, r_tmp2);
  1433 + tcg_gen_ext_i32_tl(r_tmp1, cpu_T[0]);
  1434 + dead_tmp(r_tmp1);
  1435 + dead_tmp(r_tmp2);
  1436 + }
1373 opn = "rotr"; 1437 opn = "rotr";
1374 } else { 1438 } else {
1375 - gen_op_srl(); 1439 + tcg_gen_ext32u_tl(cpu_T[0], cpu_T[0]);
  1440 + tcg_gen_shri_tl(cpu_T[0], cpu_T[0], uimm);
  1441 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1376 opn = "srl"; 1442 opn = "srl";
1377 } 1443 }
1378 break; 1444 break;
@@ -1384,26 +1450,34 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc, @@ -1384,26 +1450,34 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
1384 break; 1450 break;
1385 #if defined(TARGET_MIPS64) 1451 #if defined(TARGET_MIPS64)
1386 case OPC_DSLL: 1452 case OPC_DSLL:
1387 - gen_op_dsll(); 1453 + tcg_gen_shli_tl(cpu_T[0], cpu_T[0], uimm);
1388 opn = "dsll"; 1454 opn = "dsll";
1389 break; 1455 break;
1390 case OPC_DSRA: 1456 case OPC_DSRA:
1391 - gen_op_dsra(); 1457 + tcg_gen_sari_tl(cpu_T[0], cpu_T[0], uimm);
1392 opn = "dsra"; 1458 opn = "dsra";
1393 break; 1459 break;
1394 case OPC_DSRL: 1460 case OPC_DSRL:
1395 switch ((ctx->opcode >> 21) & 0x1f) { 1461 switch ((ctx->opcode >> 21) & 0x1f) {
1396 case 0: 1462 case 0:
1397 - gen_op_dsrl(); 1463 + tcg_gen_shri_tl(cpu_T[0], cpu_T[0], uimm);
1398 opn = "dsrl"; 1464 opn = "dsrl";
1399 break; 1465 break;
1400 case 1: 1466 case 1:
1401 /* drotr is decoded as dsrl on non-R2 CPUs */ 1467 /* drotr is decoded as dsrl on non-R2 CPUs */
1402 if (env->insn_flags & ISA_MIPS32R2) { 1468 if (env->insn_flags & ISA_MIPS32R2) {
1403 - gen_op_drotr(); 1469 + if (uimm != 0) {
  1470 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
  1471 +
  1472 + tcg_gen_movi_tl(r_tmp1, 0x40);
  1473 + tcg_gen_subi_tl(r_tmp1, r_tmp1, uimm);
  1474 + tcg_gen_shl_tl(r_tmp1, cpu_T[0], r_tmp1);
  1475 + tcg_gen_shri_tl(cpu_T[0], cpu_T[0], uimm);
  1476 + tcg_gen_or_tl(cpu_T[0], cpu_T[0], r_tmp1);
  1477 + }
1404 opn = "drotr"; 1478 opn = "drotr";
1405 } else { 1479 } else {
1406 - gen_op_dsrl(); 1480 + tcg_gen_shri_tl(cpu_T[0], cpu_T[0], uimm);
1407 opn = "dsrl"; 1481 opn = "dsrl";
1408 } 1482 }
1409 break; 1483 break;
@@ -1414,26 +1488,35 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc, @@ -1414,26 +1488,35 @@ static void gen_arith_imm (CPUState *env, DisasContext *ctx, uint32_t opc,
1414 } 1488 }
1415 break; 1489 break;
1416 case OPC_DSLL32: 1490 case OPC_DSLL32:
1417 - gen_op_dsll32(); 1491 + tcg_gen_shli_tl(cpu_T[0], cpu_T[0], uimm + 32);
1418 opn = "dsll32"; 1492 opn = "dsll32";
1419 break; 1493 break;
1420 case OPC_DSRA32: 1494 case OPC_DSRA32:
1421 - gen_op_dsra32(); 1495 + tcg_gen_sari_tl(cpu_T[0], cpu_T[0], uimm + 32);
1422 opn = "dsra32"; 1496 opn = "dsra32";
1423 break; 1497 break;
1424 case OPC_DSRL32: 1498 case OPC_DSRL32:
1425 switch ((ctx->opcode >> 21) & 0x1f) { 1499 switch ((ctx->opcode >> 21) & 0x1f) {
1426 case 0: 1500 case 0:
1427 - gen_op_dsrl32(); 1501 + tcg_gen_shri_tl(cpu_T[0], cpu_T[0], uimm + 32);
1428 opn = "dsrl32"; 1502 opn = "dsrl32";
1429 break; 1503 break;
1430 case 1: 1504 case 1:
1431 /* drotr32 is decoded as dsrl32 on non-R2 CPUs */ 1505 /* drotr32 is decoded as dsrl32 on non-R2 CPUs */
1432 if (env->insn_flags & ISA_MIPS32R2) { 1506 if (env->insn_flags & ISA_MIPS32R2) {
1433 - gen_op_drotr32(); 1507 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
  1508 + TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
  1509 +
  1510 + tcg_gen_movi_tl(r_tmp1, 0x40);
  1511 + tcg_gen_movi_tl(r_tmp2, 32);
  1512 + tcg_gen_addi_tl(r_tmp2, r_tmp2, uimm);
  1513 + tcg_gen_sub_tl(r_tmp1, r_tmp1, r_tmp2);
  1514 + tcg_gen_shl_tl(r_tmp1, cpu_T[0], r_tmp1);
  1515 + tcg_gen_shr_tl(cpu_T[0], cpu_T[0], r_tmp2);
  1516 + tcg_gen_or_tl(cpu_T[0], cpu_T[0], r_tmp1);
1434 opn = "drotr32"; 1517 opn = "drotr32";
1435 } else { 1518 } else {
1436 - gen_op_dsrl32(); 1519 + tcg_gen_shri_tl(cpu_T[0], cpu_T[0], uimm + 32);
1437 opn = "dsrl32"; 1520 opn = "dsrl32";
1438 } 1521 }
1439 break; 1522 break;
@@ -1476,40 +1559,118 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc, @@ -1476,40 +1559,118 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
1476 GEN_LOAD_REG_T1(rt); 1559 GEN_LOAD_REG_T1(rt);
1477 switch (opc) { 1560 switch (opc) {
1478 case OPC_ADD: 1561 case OPC_ADD:
1479 - save_cpu_state(ctx, 1);  
1480 - gen_op_addo(); 1562 + {
  1563 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
  1564 + TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
  1565 + int l1 = gen_new_label();
  1566 +
  1567 + save_cpu_state(ctx, 1);
  1568 + tcg_gen_ext32s_tl(r_tmp1, cpu_T[0]);
  1569 + tcg_gen_ext32s_tl(r_tmp2, cpu_T[1]);
  1570 + tcg_gen_add_tl(cpu_T[0], r_tmp1, r_tmp2);
  1571 +
  1572 + tcg_gen_xor_tl(r_tmp1, r_tmp1, cpu_T[1]);
  1573 + tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
  1574 + tcg_gen_xor_tl(r_tmp2, cpu_T[0], cpu_T[1]);
  1575 + tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
  1576 + tcg_gen_shri_tl(r_tmp1, r_tmp1, 31);
  1577 + tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
  1578 + /* operands of same sign, result different sign */
  1579 + generate_exception(ctx, EXCP_OVERFLOW);
  1580 + gen_set_label(l1);
  1581 +
  1582 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
  1583 + }
1481 opn = "add"; 1584 opn = "add";
1482 break; 1585 break;
1483 case OPC_ADDU: 1586 case OPC_ADDU:
1484 - gen_op_add(); 1587 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
  1588 + tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
  1589 + tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
  1590 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1485 opn = "addu"; 1591 opn = "addu";
1486 break; 1592 break;
1487 case OPC_SUB: 1593 case OPC_SUB:
1488 - save_cpu_state(ctx, 1);  
1489 - gen_op_subo(); 1594 + {
  1595 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
  1596 + TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
  1597 + int l1 = gen_new_label();
  1598 +
  1599 + save_cpu_state(ctx, 1);
  1600 + tcg_gen_ext32s_tl(r_tmp1, cpu_T[0]);
  1601 + tcg_gen_ext32s_tl(r_tmp2, cpu_T[1]);
  1602 + tcg_gen_sub_tl(cpu_T[0], r_tmp1, r_tmp2);
  1603 +
  1604 + tcg_gen_xor_tl(r_tmp2, r_tmp1, cpu_T[1]);
  1605 + tcg_gen_xor_tl(r_tmp1, r_tmp1, cpu_T[0]);
  1606 + tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
  1607 + tcg_gen_shri_tl(r_tmp1, r_tmp1, 31);
  1608 + tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
  1609 + /* operands of different sign, first operand and result different sign */
  1610 + generate_exception(ctx, EXCP_OVERFLOW);
  1611 + gen_set_label(l1);
  1612 +
  1613 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
  1614 + }
1490 opn = "sub"; 1615 opn = "sub";
1491 break; 1616 break;
1492 case OPC_SUBU: 1617 case OPC_SUBU:
1493 - gen_op_sub(); 1618 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
  1619 + tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
  1620 + tcg_gen_sub_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
  1621 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1494 opn = "subu"; 1622 opn = "subu";
1495 break; 1623 break;
1496 #if defined(TARGET_MIPS64) 1624 #if defined(TARGET_MIPS64)
1497 case OPC_DADD: 1625 case OPC_DADD:
1498 - save_cpu_state(ctx, 1);  
1499 - gen_op_daddo(); 1626 + {
  1627 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
  1628 + TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
  1629 + int l1 = gen_new_label();
  1630 +
  1631 + save_cpu_state(ctx, 1);
  1632 + tcg_gen_mov_tl(r_tmp1, cpu_T[0]);
  1633 + tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
  1634 +
  1635 + tcg_gen_xor_tl(r_tmp1, r_tmp1, cpu_T[1]);
  1636 + tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
  1637 + tcg_gen_xor_tl(r_tmp2, cpu_T[0], cpu_T[1]);
  1638 + tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
  1639 + tcg_gen_shri_tl(r_tmp1, r_tmp1, 63);
  1640 + tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
  1641 + /* operands of same sign, result different sign */
  1642 + generate_exception(ctx, EXCP_OVERFLOW);
  1643 + gen_set_label(l1);
  1644 + }
1500 opn = "dadd"; 1645 opn = "dadd";
1501 break; 1646 break;
1502 case OPC_DADDU: 1647 case OPC_DADDU:
1503 - gen_op_dadd(); 1648 + tcg_gen_add_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
1504 opn = "daddu"; 1649 opn = "daddu";
1505 break; 1650 break;
1506 case OPC_DSUB: 1651 case OPC_DSUB:
1507 - save_cpu_state(ctx, 1);  
1508 - gen_op_dsubo(); 1652 + {
  1653 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
  1654 + TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
  1655 + int l1 = gen_new_label();
  1656 +
  1657 + save_cpu_state(ctx, 1);
  1658 + tcg_gen_mov_tl(r_tmp1, cpu_T[0]);
  1659 + tcg_gen_sub_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
  1660 +
  1661 + tcg_gen_xor_tl(r_tmp2, r_tmp1, cpu_T[1]);
  1662 + tcg_gen_xor_tl(r_tmp1, r_tmp1, cpu_T[0]);
  1663 + tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
  1664 + tcg_gen_shri_tl(r_tmp1, r_tmp1, 63);
  1665 + tcg_gen_brcond_tl(TCG_COND_EQ, r_tmp1, tcg_const_tl(0), l1);
  1666 + /* operands of different sign, first operand and result different sign */
  1667 + generate_exception(ctx, EXCP_OVERFLOW);
  1668 + gen_set_label(l1);
  1669 + }
1509 opn = "dsub"; 1670 opn = "dsub";
1510 break; 1671 break;
1511 case OPC_DSUBU: 1672 case OPC_DSUBU:
1512 - gen_op_dsub(); 1673 + tcg_gen_sub_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
1513 opn = "dsubu"; 1674 opn = "dsubu";
1514 break; 1675 break;
1515 #endif 1676 #endif
@@ -1522,23 +1683,27 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc, @@ -1522,23 +1683,27 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
1522 opn = "sltu"; 1683 opn = "sltu";
1523 break; 1684 break;
1524 case OPC_AND: 1685 case OPC_AND:
1525 - gen_op_and(); 1686 + tcg_gen_and_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
1526 opn = "and"; 1687 opn = "and";
1527 break; 1688 break;
1528 case OPC_NOR: 1689 case OPC_NOR:
1529 - gen_op_nor(); 1690 + tcg_gen_or_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
  1691 + tcg_gen_not_tl(cpu_T[0], cpu_T[0]);
1530 opn = "nor"; 1692 opn = "nor";
1531 break; 1693 break;
1532 case OPC_OR: 1694 case OPC_OR:
1533 - gen_op_or(); 1695 + tcg_gen_or_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
1534 opn = "or"; 1696 opn = "or";
1535 break; 1697 break;
1536 case OPC_XOR: 1698 case OPC_XOR:
1537 - gen_op_xor(); 1699 + tcg_gen_xor_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
1538 opn = "xor"; 1700 opn = "xor";
1539 break; 1701 break;
1540 case OPC_MUL: 1702 case OPC_MUL:
1541 - gen_op_mul(); 1703 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
  1704 + tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
  1705 + tcg_gen_mul_tl(cpu_T[0], cpu_T[0], cpu_T[1]);
  1706 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1542 opn = "mul"; 1707 opn = "mul";
1543 break; 1708 break;
1544 case OPC_MOVN: 1709 case OPC_MOVN:
@@ -1550,26 +1715,64 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc, @@ -1550,26 +1715,64 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
1550 opn = "movz"; 1715 opn = "movz";
1551 goto print; 1716 goto print;
1552 case OPC_SLLV: 1717 case OPC_SLLV:
1553 - gen_op_sllv(); 1718 + tcg_gen_ext32u_tl(cpu_T[0], cpu_T[0]);
  1719 + tcg_gen_ext32u_tl(cpu_T[1], cpu_T[1]);
  1720 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x1f);
  1721 + tcg_gen_shl_tl(cpu_T[0], cpu_T[1], cpu_T[0]);
  1722 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1554 opn = "sllv"; 1723 opn = "sllv";
1555 break; 1724 break;
1556 case OPC_SRAV: 1725 case OPC_SRAV:
1557 - gen_op_srav(); 1726 + tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
  1727 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x1f);
  1728 + tcg_gen_sar_tl(cpu_T[0], cpu_T[1], cpu_T[0]);
  1729 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1558 opn = "srav"; 1730 opn = "srav";
1559 break; 1731 break;
1560 case OPC_SRLV: 1732 case OPC_SRLV:
1561 switch ((ctx->opcode >> 6) & 0x1f) { 1733 switch ((ctx->opcode >> 6) & 0x1f) {
1562 case 0: 1734 case 0:
1563 - gen_op_srlv(); 1735 + tcg_gen_ext32u_tl(cpu_T[1], cpu_T[1]);
  1736 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x1f);
  1737 + tcg_gen_shr_tl(cpu_T[0], cpu_T[1], cpu_T[0]);
  1738 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1564 opn = "srlv"; 1739 opn = "srlv";
1565 break; 1740 break;
1566 case 1: 1741 case 1:
1567 /* rotrv is decoded as srlv on non-R2 CPUs */ 1742 /* rotrv is decoded as srlv on non-R2 CPUs */
1568 if (env->insn_flags & ISA_MIPS32R2) { 1743 if (env->insn_flags & ISA_MIPS32R2) {
1569 - gen_op_rotrv(); 1744 + int l1 = gen_new_label();
  1745 + int l2 = gen_new_label();
  1746 +
  1747 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x1f);
  1748 + tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[0], tcg_const_tl(0), l1);
  1749 + {
  1750 + TCGv r_tmp1 = new_tmp();
  1751 + TCGv r_tmp2 = new_tmp();
  1752 + TCGv r_tmp3 = new_tmp();
  1753 +
  1754 + tcg_gen_trunc_tl_i32(r_tmp1, cpu_T[0]);
  1755 + tcg_gen_trunc_tl_i32(r_tmp2, cpu_T[1]);
  1756 + tcg_gen_movi_i32(r_tmp3, 0x20);
  1757 + tcg_gen_sub_i32(r_tmp3, r_tmp3, r_tmp1);
  1758 + tcg_gen_shl_i32(r_tmp3, r_tmp2, r_tmp3);
  1759 + tcg_gen_shr_i32(r_tmp1, r_tmp2, r_tmp1);
  1760 + tcg_gen_or_i32(r_tmp1, r_tmp1, r_tmp3);
  1761 + tcg_gen_ext_i32_tl(r_tmp1, cpu_T[0]);
  1762 + dead_tmp(r_tmp1);
  1763 + dead_tmp(r_tmp2);
  1764 + dead_tmp(r_tmp3);
  1765 + tcg_gen_br(l2);
  1766 + }
  1767 + gen_set_label(l1);
  1768 + tcg_gen_mov_tl(cpu_T[0], cpu_T[1]);
  1769 + gen_set_label(l2);
1570 opn = "rotrv"; 1770 opn = "rotrv";
1571 } else { 1771 } else {
1572 - gen_op_srlv(); 1772 + tcg_gen_ext32u_tl(cpu_T[1], cpu_T[1]);
  1773 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x1f);
  1774 + tcg_gen_shr_tl(cpu_T[0], cpu_T[1], cpu_T[0]);
  1775 + tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
1573 opn = "srlv"; 1776 opn = "srlv";
1574 } 1777 }
1575 break; 1778 break;
@@ -1581,26 +1784,47 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc, @@ -1581,26 +1784,47 @@ static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
1581 break; 1784 break;
1582 #if defined(TARGET_MIPS64) 1785 #if defined(TARGET_MIPS64)
1583 case OPC_DSLLV: 1786 case OPC_DSLLV:
1584 - gen_op_dsllv(); 1787 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x3f);
  1788 + tcg_gen_shl_tl(cpu_T[0], cpu_T[1], cpu_T[0]);
1585 opn = "dsllv"; 1789 opn = "dsllv";
1586 break; 1790 break;
1587 case OPC_DSRAV: 1791 case OPC_DSRAV:
1588 - gen_op_dsrav(); 1792 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x3f);
  1793 + tcg_gen_sar_tl(cpu_T[0], cpu_T[1], cpu_T[0]);
1589 opn = "dsrav"; 1794 opn = "dsrav";
1590 break; 1795 break;
1591 case OPC_DSRLV: 1796 case OPC_DSRLV:
1592 switch ((ctx->opcode >> 6) & 0x1f) { 1797 switch ((ctx->opcode >> 6) & 0x1f) {
1593 case 0: 1798 case 0:
1594 - gen_op_dsrlv(); 1799 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x3f);
  1800 + tcg_gen_shr_tl(cpu_T[0], cpu_T[1], cpu_T[0]);
1595 opn = "dsrlv"; 1801 opn = "dsrlv";
1596 break; 1802 break;
1597 case 1: 1803 case 1:
1598 /* drotrv is decoded as dsrlv on non-R2 CPUs */ 1804 /* drotrv is decoded as dsrlv on non-R2 CPUs */
1599 if (env->insn_flags & ISA_MIPS32R2) { 1805 if (env->insn_flags & ISA_MIPS32R2) {
1600 - gen_op_drotrv(); 1806 + int l1 = gen_new_label();
  1807 + int l2 = gen_new_label();
  1808 +
  1809 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x3f);
  1810 + tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[0], tcg_const_tl(0), l1);
  1811 + {
  1812 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_TL);
  1813 +
  1814 + tcg_gen_movi_tl(r_tmp1, 0x40);
  1815 + tcg_gen_sub_tl(r_tmp1, r_tmp1, cpu_T[0]);
  1816 + tcg_gen_shl_tl(r_tmp1, cpu_T[1], r_tmp1);
  1817 + tcg_gen_shr_tl(cpu_T[0], cpu_T[1], cpu_T[0]);
  1818 + tcg_gen_or_tl(cpu_T[0], cpu_T[0], r_tmp1);
  1819 + tcg_gen_br(l2);
  1820 + }
  1821 + gen_set_label(l1);
  1822 + tcg_gen_mov_tl(cpu_T[0], cpu_T[1]);
  1823 + gen_set_label(l2);
1601 opn = "drotrv"; 1824 opn = "drotrv";
1602 } else { 1825 } else {
1603 - gen_op_dsrlv(); 1826 + tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 0x3f);
  1827 + tcg_gen_shr_tl(cpu_T[0], cpu_T[1], cpu_T[0]);
1604 opn = "dsrlv"; 1828 opn = "dsrlv";
1605 } 1829 }
1606 break; 1830 break;
@@ -1669,11 +1893,71 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, @@ -1669,11 +1893,71 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,
1669 GEN_LOAD_REG_T1(rt); 1893 GEN_LOAD_REG_T1(rt);
1670 switch (opc) { 1894 switch (opc) {
1671 case OPC_DIV: 1895 case OPC_DIV:
1672 - gen_op_div(); 1896 + {
  1897 + int l1 = gen_new_label();
  1898 +
  1899 + tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[1], tcg_const_tl(0), l1);
  1900 + {
  1901 + TCGv r_tmp1 = new_tmp();
  1902 + TCGv r_tmp2 = new_tmp();
  1903 + TCGv r_tmp3 = new_tmp();
  1904 + TCGv r_tc_off = new_tmp();
  1905 + TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
  1906 + TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
  1907 +
  1908 + tcg_gen_ext_i32_tl(r_tmp1, cpu_T[0]);
  1909 + tcg_gen_ext_i32_tl(r_tmp2, cpu_T[1]);
  1910 + tcg_gen_div_i32(r_tmp3, r_tmp1, r_tmp2);
  1911 + tcg_gen_rem_i32(r_tmp1, r_tmp1, r_tmp2);
  1912 + tcg_gen_trunc_tl_i32(cpu_T[0], r_tmp3);
  1913 + tcg_gen_trunc_tl_i32(cpu_T[1], r_tmp1);
  1914 + dead_tmp(r_tmp1);
  1915 + dead_tmp(r_tmp2);
  1916 + dead_tmp(r_tmp3);
  1917 + tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
  1918 + tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
  1919 + tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
  1920 + tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
  1921 + tcg_gen_st_tl(cpu_T[0], r_ptr, offsetof(CPUState, LO));
  1922 + tcg_gen_st_tl(cpu_T[1], r_ptr, offsetof(CPUState, HI));
  1923 + dead_tmp(r_tc_off);
  1924 + }
  1925 + gen_set_label(l1);
  1926 + }
1673 opn = "div"; 1927 opn = "div";
1674 break; 1928 break;
1675 case OPC_DIVU: 1929 case OPC_DIVU:
1676 - gen_op_divu(); 1930 + {
  1931 + int l1 = gen_new_label();
  1932 +
  1933 + tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[1], tcg_const_tl(0), l1);
  1934 + {
  1935 + TCGv r_tmp1 = new_tmp();
  1936 + TCGv r_tmp2 = new_tmp();
  1937 + TCGv r_tmp3 = new_tmp();
  1938 + TCGv r_tc_off = new_tmp();
  1939 + TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
  1940 + TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
  1941 +
  1942 + tcg_gen_ext_i32_tl(r_tmp1, cpu_T[0]);
  1943 + tcg_gen_ext_i32_tl(r_tmp2, cpu_T[1]);
  1944 + tcg_gen_divu_i32(r_tmp3, r_tmp1, r_tmp2);
  1945 + tcg_gen_remu_i32(r_tmp1, r_tmp1, r_tmp2);
  1946 + tcg_gen_trunc_tl_i32(cpu_T[0], r_tmp3);
  1947 + tcg_gen_trunc_tl_i32(cpu_T[1], r_tmp1);
  1948 + dead_tmp(r_tmp1);
  1949 + dead_tmp(r_tmp2);
  1950 + dead_tmp(r_tmp3);
  1951 + tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
  1952 + tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
  1953 + tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
  1954 + tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
  1955 + tcg_gen_st_tl(cpu_T[0], r_ptr, offsetof(CPUState, LO));
  1956 + tcg_gen_st_tl(cpu_T[1], r_ptr, offsetof(CPUState, HI));
  1957 + dead_tmp(r_tc_off);
  1958 + }
  1959 + gen_set_label(l1);
  1960 + }
1677 opn = "divu"; 1961 opn = "divu";
1678 break; 1962 break;
1679 case OPC_MULT: 1963 case OPC_MULT:
@@ -1686,11 +1970,63 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, @@ -1686,11 +1970,63 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,
1686 break; 1970 break;
1687 #if defined(TARGET_MIPS64) 1971 #if defined(TARGET_MIPS64)
1688 case OPC_DDIV: 1972 case OPC_DDIV:
1689 - gen_op_ddiv(); 1973 + {
  1974 + int l1 = gen_new_label();
  1975 +
  1976 + tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[1], tcg_const_tl(0), l1);
  1977 + {
  1978 + TCGv r_tc_off = new_tmp();
  1979 + TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
  1980 + TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
  1981 + int l2 = gen_new_label();
  1982 + int l3 = gen_new_label();
  1983 +
  1984 + tcg_gen_brcond_tl(TCG_COND_NE, cpu_T[0], tcg_const_tl(1ULL << 63), l2);
  1985 + tcg_gen_brcond_tl(TCG_COND_NE, cpu_T[1], tcg_const_tl(-1ULL), l2);
  1986 + tcg_gen_div_i64(cpu_T[0], cpu_T[0], cpu_T[1]);
  1987 + tcg_gen_movi_tl(cpu_T[1], 0);
  1988 + tcg_gen_br(l3);
  1989 + gen_set_label(l2);
  1990 + tcg_gen_div_i64(cpu_T[0], cpu_T[0], cpu_T[1]);
  1991 + tcg_gen_rem_i64(cpu_T[1], cpu_T[0], cpu_T[1]);
  1992 + gen_set_label(l3);
  1993 +
  1994 + tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
  1995 + tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
  1996 + tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
  1997 + tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
  1998 + tcg_gen_st_tl(cpu_T[0], r_ptr, offsetof(CPUState, LO));
  1999 + tcg_gen_st_tl(cpu_T[1], r_ptr, offsetof(CPUState, HI));
  2000 + dead_tmp(r_tc_off);
  2001 + }
  2002 + gen_set_label(l1);
  2003 + }
1690 opn = "ddiv"; 2004 opn = "ddiv";
1691 break; 2005 break;
1692 case OPC_DDIVU: 2006 case OPC_DDIVU:
1693 - gen_op_ddivu(); 2007 + {
  2008 + int l1 = gen_new_label();
  2009 +
  2010 + tcg_gen_brcond_tl(TCG_COND_EQ, cpu_T[1], tcg_const_tl(0), l1);
  2011 + {
  2012 + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I64);
  2013 + TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I64);
  2014 + TCGv r_tc_off = new_tmp();
  2015 + TCGv r_tc_off_tl = tcg_temp_new(TCG_TYPE_TL);
  2016 + TCGv r_ptr = tcg_temp_new(TCG_TYPE_PTR);
  2017 +
  2018 + tcg_gen_divu_i64(r_tmp1, cpu_T[0], cpu_T[1]);
  2019 + tcg_gen_remu_i64(r_tmp2, cpu_T[0], cpu_T[1]);
  2020 + tcg_gen_ld_i32(r_tc_off, cpu_env, offsetof(CPUState, current_tc));
  2021 + tcg_gen_muli_i32(r_tc_off, r_tc_off, sizeof(target_ulong));
  2022 + tcg_gen_ext_i32_ptr(r_tc_off_tl, r_tc_off);
  2023 + tcg_gen_add_ptr(r_ptr, cpu_env, r_tc_off_tl);
  2024 + tcg_gen_st_tl(r_tmp1, r_ptr, offsetof(CPUState, LO));
  2025 + tcg_gen_st_tl(r_tmp2, r_ptr, offsetof(CPUState, HI));
  2026 + dead_tmp(r_tc_off);
  2027 + }
  2028 + gen_set_label(l1);
  2029 + }
1694 opn = "ddivu"; 2030 opn = "ddivu";
1695 break; 2031 break;
1696 case OPC_DMULT: 2032 case OPC_DMULT:
@@ -6424,11 +6760,11 @@ static void decode_opc (CPUState *env, DisasContext *ctx) @@ -6424,11 +6760,11 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
6424 break; 6760 break;
6425 case OPC_SEB: 6761 case OPC_SEB:
6426 GEN_LOAD_REG_T1(rt); 6762 GEN_LOAD_REG_T1(rt);
6427 - gen_op_seb(); 6763 + tcg_gen_ext8s_tl(cpu_T[0], cpu_T[1]);
6428 break; 6764 break;
6429 case OPC_SEH: 6765 case OPC_SEH:
6430 GEN_LOAD_REG_T1(rt); 6766 GEN_LOAD_REG_T1(rt);
6431 - gen_op_seh(); 6767 + tcg_gen_ext16s_tl(cpu_T[0], cpu_T[1]);
6432 break; 6768 break;
6433 default: /* Invalid */ 6769 default: /* Invalid */
6434 MIPS_INVAL("bshfl"); 6770 MIPS_INVAL("bshfl");
@@ -6837,6 +7173,9 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, @@ -6837,6 +7173,9 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
6837 num_temps = 0; 7173 num_temps = 0;
6838 memset(temps, 0, sizeof(temps)); 7174 memset(temps, 0, sizeof(temps));
6839 7175
  7176 + num_temps = 0;
  7177 + memset(temps, 0, sizeof(temps));
  7178 +
6840 pc_start = tb->pc; 7179 pc_start = tb->pc;
6841 gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; 7180 gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
6842 ctx.pc = pc_start; 7181 ctx.pc = pc_start;
@@ -6915,7 +7254,7 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, @@ -6915,7 +7254,7 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
6915 } else { 7254 } else {
6916 switch (ctx.bstate) { 7255 switch (ctx.bstate) {
6917 case BS_STOP: 7256 case BS_STOP:
6918 - gen_op_interrupt_restart(); 7257 + tcg_gen_helper_0_0(do_interrupt_restart);
6919 gen_goto_tb(&ctx, 0, ctx.pc); 7258 gen_goto_tb(&ctx, 0, ctx.pc);
6920 break; 7259 break;
6921 case BS_NONE: 7260 case BS_NONE:
@@ -6923,7 +7262,7 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, @@ -6923,7 +7262,7 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
6923 gen_goto_tb(&ctx, 0, ctx.pc); 7262 gen_goto_tb(&ctx, 0, ctx.pc);
6924 break; 7263 break;
6925 case BS_EXCP: 7264 case BS_EXCP:
6926 - gen_op_interrupt_restart(); 7265 + tcg_gen_helper_0_0(do_interrupt_restart);
6927 tcg_gen_exit_tb(0); 7266 tcg_gen_exit_tb(0);
6928 break; 7267 break;
6929 case BS_BRANCH: 7268 case BS_BRANCH:
tcg/tcg-op.h
@@ -1553,8 +1553,12 @@ static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index) @@ -1553,8 +1553,12 @@ static inline void tcg_gen_qemu_st64(TCGv arg, TCGv addr, int mem_index)
1553 #endif 1553 #endif
1554 1554
1555 #if TCG_TARGET_REG_BITS == 32 1555 #if TCG_TARGET_REG_BITS == 32
  1556 +#define tcg_gen_add_ptr tcg_gen_add_i32
1556 #define tcg_gen_addi_ptr tcg_gen_addi_i32 1557 #define tcg_gen_addi_ptr tcg_gen_addi_i32
  1558 +#define tcg_gen_ext_i32_ptr tcg_gen_mov_i32
1557 #else /* TCG_TARGET_REG_BITS == 32 */ 1559 #else /* TCG_TARGET_REG_BITS == 32 */
  1560 +#define tcg_gen_add_ptr tcg_gen_add_i64
1558 #define tcg_gen_addi_ptr tcg_gen_addi_i64 1561 #define tcg_gen_addi_ptr tcg_gen_addi_i64
  1562 +#define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64
1559 #endif /* TCG_TARGET_REG_BITS != 32 */ 1563 #endif /* TCG_TARGET_REG_BITS != 32 */
1560 1564