]> git.proxmox.com Git - mirror_qemu.git/commitdiff
Convert udiv/sdiv
authorBlue Swirl <blauwirbel@gmail.com>
Sun, 10 May 2009 07:42:54 +0000 (07:42 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Sun, 10 May 2009 07:42:54 +0000 (07:42 +0000)
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
target-sparc/op_helper.c
target-sparc/translate.c

index ddfe152000f43cd986a7a5ab5283cfe38f36f95d..9de74c46c2f4d1db0df878f178e32fb0c1b1e1e1 100644 (file)
@@ -790,6 +790,29 @@ static inline uint32_t get_NZ_xcc(target_ulong dst)
 }
 #endif
 
+static inline uint32_t get_V_div_icc(target_ulong src2)
+{
+    uint32_t ret = 0;
+
+    if (src2 != 0)
+        ret |= PSR_OVF;
+    return ret;
+}
+
+static uint32_t compute_all_div(void)
+{
+    uint32_t ret;
+
+    ret = get_NZ_icc(CC_DST);
+    ret |= get_V_div_icc(CC_SRC2);
+    return ret;
+}
+
+static uint32_t compute_C_div(void)
+{
+    return 0;
+}
+
 static inline uint32_t get_C_add_icc(target_ulong dst, target_ulong src1)
 {
     uint32_t ret = 0;
@@ -1108,6 +1131,7 @@ typedef struct CCTable {
 static const CCTable icc_table[CC_OP_NB] = {
     /* CC_OP_DYNAMIC should never happen */
     [CC_OP_FLAGS] = { compute_all_flags, compute_C_flags },
+    [CC_OP_DIV] = { compute_all_div, compute_C_div },
     [CC_OP_ADD] = { compute_all_add, compute_C_add },
     [CC_OP_ADDX] = { compute_all_addx, compute_C_addx },
     [CC_OP_TADD] = { compute_all_tadd, compute_C_tadd },
@@ -1123,6 +1147,7 @@ static const CCTable icc_table[CC_OP_NB] = {
 static const CCTable xcc_table[CC_OP_NB] = {
     /* CC_OP_DYNAMIC should never happen */
     [CC_OP_FLAGS] = { compute_all_flags_xcc, compute_C_flags_xcc },
+    [CC_OP_DIV] = { compute_all_logic_xcc, compute_C_logic },
     [CC_OP_ADD] = { compute_all_add_xcc, compute_C_add_xcc },
     [CC_OP_ADDX] = { compute_all_addx_xcc, compute_C_addx_xcc },
     [CC_OP_TADD] = { compute_all_add_xcc, compute_C_add_xcc },
index 91ff6044956cf3e0506e459823155f9b712fd62b..a69c708dda6da483781c03121df1c9f24158071d 100644 (file)
@@ -701,19 +701,6 @@ static inline void gen_op_sdivx(TCGv dst, TCGv src1, TCGv src2)
 }
 #endif
 
-static inline void gen_op_div_cc(TCGv dst)
-{
-    int l1;
-
-    tcg_gen_mov_tl(cpu_cc_dst, dst);
-    gen_cc_clear_icc();
-    gen_cc_NZ_icc(cpu_cc_dst);
-    l1 = gen_new_label();
-    tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_cc_src2, 0, l1);
-    tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF);
-    gen_set_label(l1);
-}
-
 // 1
 static inline void gen_op_eval_ba(TCGv dst)
 {
@@ -3151,18 +3138,18 @@ static void disas_sparc_insn(DisasContext * dc)
                         CHECK_IU_FEATURE(dc, DIV);
                         gen_helper_udiv(cpu_dst, cpu_src1, cpu_src2);
                         if (xop & 0x10) {
-                            gen_op_div_cc(cpu_dst);
-                            tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS);
-                            dc->cc_op = CC_OP_FLAGS;
+                            tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
+                            tcg_gen_movi_i32(cpu_cc_op, CC_OP_DIV);
+                            dc->cc_op = CC_OP_DIV;
                         }
                         break;
                     case 0xf: /* sdiv */
                         CHECK_IU_FEATURE(dc, DIV);
                         gen_helper_sdiv(cpu_dst, cpu_src1, cpu_src2);
                         if (xop & 0x10) {
-                            gen_op_div_cc(cpu_dst);
-                            tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS);
-                            dc->cc_op = CC_OP_FLAGS;
+                            tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
+                            tcg_gen_movi_i32(cpu_cc_op, CC_OP_DIV);
+                            dc->cc_op = CC_OP_DIV;
                         }
                         break;
                     default: