Revision fb170183 target-sparc/translate.c

b/target-sparc/translate.c
662 662
    tcg_gen_mov_tl(dst, cpu_cc_dst);
663 663
}
664 664

  
665
static inline void gen_op_umul(TCGv dst, TCGv src1, TCGv src2)
665
static inline void gen_op_multiply(TCGv dst, TCGv src1, TCGv src2, int sign_ext)
666 666
{
667
    TCGv_i32 r_src1, r_src2;
667 668
    TCGv_i64 r_temp, r_temp2;
668 669

  
670
    r_src1 = tcg_temp_new_i32();
671
    r_src2 = tcg_temp_new_i32();
672

  
673
    tcg_gen_trunc_tl_i32(r_src1, src1);
674
    tcg_gen_trunc_tl_i32(r_src2, src2);
675

  
669 676
    r_temp = tcg_temp_new_i64();
670 677
    r_temp2 = tcg_temp_new_i64();
671 678

  
672
    tcg_gen_extu_tl_i64(r_temp, src2);
673
    tcg_gen_extu_tl_i64(r_temp2, src1);
679
    if (sign_ext) {
680
        tcg_gen_ext_i32_i64(r_temp, r_src2);
681
        tcg_gen_ext_i32_i64(r_temp2, r_src1);
682
    } else {
683
        tcg_gen_extu_i32_i64(r_temp, r_src2);
684
        tcg_gen_extu_i32_i64(r_temp2, r_src1);
685
    }
686

  
674 687
    tcg_gen_mul_i64(r_temp2, r_temp, r_temp2);
675 688

  
676 689
    tcg_gen_shri_i64(r_temp, r_temp2, 32);
677 690
    tcg_gen_trunc_i64_tl(cpu_tmp0, r_temp);
678 691
    tcg_temp_free_i64(r_temp);
679 692
    tcg_gen_andi_tl(cpu_y, cpu_tmp0, 0xffffffff);
680
#ifdef TARGET_SPARC64
681
    tcg_gen_mov_i64(dst, r_temp2);
682
#else
693

  
683 694
    tcg_gen_trunc_i64_tl(dst, r_temp2);
684
#endif
695

  
685 696
    tcg_temp_free_i64(r_temp2);
697

  
698
    tcg_temp_free_i32(r_src1);
699
    tcg_temp_free_i32(r_src2);
686 700
}
687 701

  
688
static inline void gen_op_smul(TCGv dst, TCGv src1, TCGv src2)
702
static inline void gen_op_umul(TCGv dst, TCGv src1, TCGv src2)
689 703
{
690
    TCGv_i64 r_temp, r_temp2;
691

  
692
    r_temp = tcg_temp_new_i64();
693
    r_temp2 = tcg_temp_new_i64();
694

  
695
    tcg_gen_ext_tl_i64(r_temp, src2);
696
    tcg_gen_ext_tl_i64(r_temp2, src1);
697
    tcg_gen_mul_i64(r_temp2, r_temp, r_temp2);
704
    /* zero-extend truncated operands before multiplication */
705
    gen_op_multiply(dst, src1, src2, 0);
706
}
698 707

  
699
    tcg_gen_shri_i64(r_temp, r_temp2, 32);
700
    tcg_gen_trunc_i64_tl(cpu_tmp0, r_temp);
701
    tcg_temp_free_i64(r_temp);
702
    tcg_gen_andi_tl(cpu_y, cpu_tmp0, 0xffffffff);
703
#ifdef TARGET_SPARC64
704
    tcg_gen_mov_i64(dst, r_temp2);
705
#else
706
    tcg_gen_trunc_i64_tl(dst, r_temp2);
707
#endif
708
    tcg_temp_free_i64(r_temp2);
708
static inline void gen_op_smul(TCGv dst, TCGv src1, TCGv src2)
709
{
710
    /* sign-extend truncated operands before multiplication */
711
    gen_op_multiply(dst, src1, src2, 1);
709 712
}
710 713

  
711 714
#ifdef TARGET_SPARC64

Also available in: Unified diff