Commit 53cd92731207a4bc53ed778e5d6bd21155513170

Authored by blueswir1
1 parent b4e3104b

Update based on Stuart Brady's comments


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4026 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 43 additions and 39 deletions
tcg/sparc/tcg-target.c
@@ -297,7 +297,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -297,7 +297,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
297 297
298 switch (opc) { 298 switch (opc) {
299 case INDEX_op_exit_tb: 299 case INDEX_op_exit_tb:
300 - tcg_out_movi(s, TCG_TYPE_TL, TCG_REG_O0, args[0]); 300 + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_O0, args[0]);
301 tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_O7) | 301 tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_O7) |
302 INSN_IMM13(8)); 302 INSN_IMM13(8));
303 tcg_out_nop(s); 303 tcg_out_nop(s);
@@ -305,16 +305,15 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -305,16 +305,15 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
305 case INDEX_op_goto_tb: 305 case INDEX_op_goto_tb:
306 if (s->tb_jmp_offset) { 306 if (s->tb_jmp_offset) {
307 /* direct jump method */ 307 /* direct jump method */
308 - tcg_out32(s, CALL | 0); 308 + tcg_out_movi(s, TCG_TYPE_TL, TCG_REG_I5, args[0]);
309 s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; 309 s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
310 - tcg_out_nop(s);  
311 } else { 310 } else {
312 /* indirect jump method */ 311 /* indirect jump method */
313 - tcg_out_ld_raw(s, TCG_REG_O7, (tcg_target_long)(s->tb_next + args[0]));  
314 - tcg_out32(s, JMPL | INSN_RD(TCG_REG_O7) | INSN_RS1(TCG_REG_O7) |  
315 - INSN_RS2(TCG_REG_G0));  
316 - tcg_out_nop(s); 312 + tcg_out_ld_raw(s, TCG_REG_I5, (tcg_target_long)(s->tb_next + args[0]));
317 } 313 }
  314 + tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) |
  315 + INSN_RS2(TCG_REG_G0));
  316 + tcg_out_nop(s);
318 s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf; 317 s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
319 break; 318 break;
320 case INDEX_op_call: 319 case INDEX_op_call:
@@ -362,7 +361,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -362,7 +361,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
362 break; 361 break;
363 case INDEX_op_ld_i32: 362 case INDEX_op_ld_i32:
364 #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) 363 #if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
365 - case INDEX_op_ld_i32u_i64: 364 + case INDEX_op_ld32u_i64:
366 #endif 365 #endif
367 tcg_out_ldst(s, args[0], args[1], args[2], LDUW); 366 tcg_out_ldst(s, args[0], args[1], args[2], LDUW);
368 break; 367 break;
@@ -374,10 +373,13 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -374,10 +373,13 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
374 break; 373 break;
375 case INDEX_op_st_i32: 374 case INDEX_op_st_i32:
376 #if defined(__sparc_v9__) && !defined(__sparc_v8plus__) 375 #if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
377 - case INDEX_op_st_i32_i64: 376 + case INDEX_op_st32_i64:
378 #endif 377 #endif
379 tcg_out_ldst(s, args[0], args[1], args[2], STW); 378 tcg_out_ldst(s, args[0], args[1], args[2], STW);
380 break; 379 break;
  380 + OP_32_64(add);
  381 + c = ARITH_ADD;
  382 + goto gen_arith32;
381 OP_32_64(sub); 383 OP_32_64(sub);
382 c = ARITH_SUB; 384 c = ARITH_SUB;
383 goto gen_arith32; 385 goto gen_arith32;
@@ -402,16 +404,6 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -402,16 +404,6 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
402 case INDEX_op_mul_i32: 404 case INDEX_op_mul_i32:
403 c = ARITH_UMUL; 405 c = ARITH_UMUL;
404 goto gen_arith32; 406 goto gen_arith32;
405 - OP_32_64(add);  
406 - c = ARITH_ADD;  
407 - gen_arith32:  
408 - if (const_args[2]) {  
409 - tcg_out_arithi(s, args[0], args[1], args[2], c);  
410 - } else {  
411 - tcg_out_arith(s, args[0], args[1], args[2], c);  
412 - }  
413 - break;  
414 -  
415 case INDEX_op_div2_i32: 407 case INDEX_op_div2_i32:
416 #if defined(__sparc_v9__) || defined(__sparc_v8plus__) 408 #if defined(__sparc_v9__) || defined(__sparc_v8plus__)
417 c = ARITH_SDIVX; 409 c = ARITH_SDIVX;
@@ -467,6 +459,9 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -467,6 +459,9 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
467 case INDEX_op_movi_i64: 459 case INDEX_op_movi_i64:
468 tcg_out_movi(s, TCG_TYPE_I64, args[0], args[1]); 460 tcg_out_movi(s, TCG_TYPE_I64, args[0], args[1]);
469 break; 461 break;
  462 + case INDEX_op_ld32s_i64:
  463 + tcg_out_ldst(s, args[0], args[1], args[2], LDSW);
  464 + break;
470 case INDEX_op_ld_i64: 465 case INDEX_op_ld_i64:
471 tcg_out_ldst(s, args[0], args[1], args[2], LDX); 466 tcg_out_ldst(s, args[0], args[1], args[2], LDX);
472 break; 467 break;
@@ -486,7 +481,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -486,7 +481,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
486 c = ARITH_MULX; 481 c = ARITH_MULX;
487 goto gen_arith32; 482 goto gen_arith32;
488 case INDEX_op_div2_i64: 483 case INDEX_op_div2_i64:
489 - c = ARITH_DIVX; 484 + c = ARITH_SDIVX;
490 goto gen_arith32; 485 goto gen_arith32;
491 case INDEX_op_divu2_i64: 486 case INDEX_op_divu2_i64:
492 c = ARITH_UDIVX; 487 c = ARITH_UDIVX;
@@ -503,6 +498,14 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -503,6 +498,14 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
503 break; 498 break;
504 499
505 #endif 500 #endif
  501 + gen_arith32:
  502 + if (const_args[2]) {
  503 + tcg_out_arithi(s, args[0], args[1], args[2], c);
  504 + } else {
  505 + tcg_out_arith(s, args[0], args[1], args[2], c);
  506 + }
  507 + break;
  508 +
506 default: 509 default:
507 fprintf(stderr, "unknown opcode 0x%x\n", opc); 510 fprintf(stderr, "unknown opcode 0x%x\n", opc);
508 tcg_abort(); 511 tcg_abort();
@@ -511,7 +514,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -511,7 +514,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
511 514
512 static const TCGTargetOpDef sparc_op_defs[] = { 515 static const TCGTargetOpDef sparc_op_defs[] = {
513 { INDEX_op_exit_tb, { } }, 516 { INDEX_op_exit_tb, { } },
514 - { INDEX_op_goto_tb, { } }, 517 + { INDEX_op_goto_tb, { "r" } },
515 { INDEX_op_call, { "ri" } }, 518 { INDEX_op_call, { "ri" } },
516 { INDEX_op_jmp, { "ri" } }, 519 { INDEX_op_jmp, { "ri" } },
517 { INDEX_op_br, { } }, 520 { INDEX_op_br, { } },
@@ -527,18 +530,18 @@ static const TCGTargetOpDef sparc_op_defs[] = { @@ -527,18 +530,18 @@ static const TCGTargetOpDef sparc_op_defs[] = {
527 { INDEX_op_st16_i32, { "r", "r" } }, 530 { INDEX_op_st16_i32, { "r", "r" } },
528 { INDEX_op_st_i32, { "r", "r" } }, 531 { INDEX_op_st_i32, { "r", "r" } },
529 532
530 - { INDEX_op_add_i32, { "r", "0", "rJ" } },  
531 - { INDEX_op_mul_i32, { "r", "0", "rJ" } }, 533 + { INDEX_op_add_i32, { "r", "r", "rJ" } },
  534 + { INDEX_op_mul_i32, { "r", "r", "rJ" } },
532 { INDEX_op_div2_i32, { "r", "r", "0", "1", "r" } }, 535 { INDEX_op_div2_i32, { "r", "r", "0", "1", "r" } },
533 { INDEX_op_divu2_i32, { "r", "r", "0", "1", "r" } }, 536 { INDEX_op_divu2_i32, { "r", "r", "0", "1", "r" } },
534 - { INDEX_op_sub_i32, { "r", "0", "rJ" } },  
535 - { INDEX_op_and_i32, { "r", "0", "rJ" } },  
536 - { INDEX_op_or_i32, { "r", "0", "rJ" } },  
537 - { INDEX_op_xor_i32, { "r", "0", "rJ" } }, 537 + { INDEX_op_sub_i32, { "r", "r", "rJ" } },
  538 + { INDEX_op_and_i32, { "r", "r", "rJ" } },
  539 + { INDEX_op_or_i32, { "r", "r", "rJ" } },
  540 + { INDEX_op_xor_i32, { "r", "r", "rJ" } },
538 541
539 - { INDEX_op_shl_i32, { "r", "0", "rJ" } },  
540 - { INDEX_op_shr_i32, { "r", "0", "rJ" } },  
541 - { INDEX_op_sar_i32, { "r", "0", "rJ" } }, 542 + { INDEX_op_shl_i32, { "r", "r", "rJ" } },
  543 + { INDEX_op_shr_i32, { "r", "r", "rJ" } },
  544 + { INDEX_op_sar_i32, { "r", "r", "rJ" } },
542 545
543 { INDEX_op_brcond_i32, { "r", "ri" } }, 546 { INDEX_op_brcond_i32, { "r", "ri" } },
544 547
@@ -568,18 +571,18 @@ static const TCGTargetOpDef sparc_op_defs[] = { @@ -568,18 +571,18 @@ static const TCGTargetOpDef sparc_op_defs[] = {
568 { INDEX_op_st32_i64, { "r", "r" } }, 571 { INDEX_op_st32_i64, { "r", "r" } },
569 { INDEX_op_st_i64, { "r", "r" } }, 572 { INDEX_op_st_i64, { "r", "r" } },
570 573
571 - { INDEX_op_add_i64, { "r", "0", "rJ" } },  
572 - { INDEX_op_mul_i64, { "r", "0", "rJ" } }, 574 + { INDEX_op_add_i64, { "r", "r", "rJ" } },
  575 + { INDEX_op_mul_i64, { "r", "r", "rJ" } },
573 { INDEX_op_div2_i64, { "r", "r", "0", "1", "r" } }, 576 { INDEX_op_div2_i64, { "r", "r", "0", "1", "r" } },
574 { INDEX_op_divu2_i64, { "r", "r", "0", "1", "r" } }, 577 { INDEX_op_divu2_i64, { "r", "r", "0", "1", "r" } },
575 - { INDEX_op_sub_i64, { "r", "0", "rJ" } },  
576 - { INDEX_op_and_i64, { "r", "0", "rJ" } },  
577 - { INDEX_op_or_i64, { "r", "0", "rJ" } },  
578 - { INDEX_op_xor_i64, { "r", "0", "rJ" } }, 578 + { INDEX_op_sub_i64, { "r", "r", "rJ" } },
  579 + { INDEX_op_and_i64, { "r", "r", "rJ" } },
  580 + { INDEX_op_or_i64, { "r", "r", "rJ" } },
  581 + { INDEX_op_xor_i64, { "r", "r", "rJ" } },
579 582
580 - { INDEX_op_shl_i64, { "r", "0", "rJ" } },  
581 - { INDEX_op_shr_i64, { "r", "0", "rJ" } },  
582 - { INDEX_op_sar_i64, { "r", "0", "rJ" } }, 583 + { INDEX_op_shl_i64, { "r", "r", "rJ" } },
  584 + { INDEX_op_shr_i64, { "r", "r", "rJ" } },
  585 + { INDEX_op_sar_i64, { "r", "r", "rJ" } },
583 586
584 { INDEX_op_brcond_i64, { "r", "ri" } }, 587 { INDEX_op_brcond_i64, { "r", "ri" } },
585 #endif 588 #endif
@@ -604,6 +607,7 @@ void tcg_target_init(TCGContext *s) @@ -604,6 +607,7 @@ void tcg_target_init(TCGContext *s)
604 607
605 tcg_regset_clear(s->reserved_regs); 608 tcg_regset_clear(s->reserved_regs);
606 tcg_regset_set_reg(s->reserved_regs, TCG_REG_G0); 609 tcg_regset_set_reg(s->reserved_regs, TCG_REG_G0);
  610 + tcg_regset_set_reg(s->reserved_regs, TCG_REG_I5); // for internal use
607 tcg_regset_set_reg(s->reserved_regs, TCG_REG_I6); 611 tcg_regset_set_reg(s->reserved_regs, TCG_REG_I6);
608 tcg_regset_set_reg(s->reserved_regs, TCG_REG_I7); 612 tcg_regset_set_reg(s->reserved_regs, TCG_REG_I7);
609 tcg_regset_set_reg(s->reserved_regs, TCG_REG_O6); 613 tcg_regset_set_reg(s->reserved_regs, TCG_REG_O6);