Patchwork [42/57] target-i386: Make helper_cc_compute_all const

login
register
mail settings
Submitter Richard Henderson
Date Jan. 24, 2013, 4:03 a.m.
Message ID <1359000221-19834-43-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/215231/
State New
Headers show

Comments

Richard Henderson - Jan. 24, 2013, 4:03 a.m.
Pass the data in explicitly, rather than indirectly via env.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target-i386/cc_helper.c | 16 +++++-----------
 target-i386/helper.h    |  2 +-
 target-i386/translate.c | 32 ++++++++++++++++++++++++++++++--
 3 files changed, 36 insertions(+), 14 deletions(-)

Patch

diff --git a/target-i386/cc_helper.c b/target-i386/cc_helper.c
index 4dd73cc..b209b57 100644
--- a/target-i386/cc_helper.c
+++ b/target-i386/cc_helper.c
@@ -75,21 +75,15 @@  const uint8_t parity_table[256] = {
 
 #endif
 
-static int compute_all_eflags(int dst, int src1, int src2)
+target_ulong helper_cc_compute_all(target_ulong dst, target_ulong src1,
+                                   target_ulong src2, int op)
 {
-    return src1;
-}
-
-uint32_t helper_cc_compute_all(CPUX86State *env, int op)
-{
-    target_ulong dst = CC_DST, src1 = CC_SRC, src2 = CC_SRC2;
-
     switch (op) {
     default: /* should never happen */
         return 0;
 
     case CC_OP_EFLAGS:
-        return compute_all_eflags(dst, src1, src2);
+        return src1;
 
     case CC_OP_MULB:
         return compute_all_mulb(dst, src1, src2);
@@ -188,7 +182,7 @@  uint32_t helper_cc_compute_all(CPUX86State *env, int op)
 
 uint32_t cpu_cc_compute_all(CPUX86State *env, int op)
 {
-    return helper_cc_compute_all(env, op);
+    return helper_cc_compute_all(CC_DST, CC_SRC, CC_SRC2, op);
 }
 
 void helper_write_eflags(CPUX86State *env, target_ulong t0,
@@ -201,7 +195,7 @@  target_ulong helper_read_eflags(CPUX86State *env)
 {
     uint32_t eflags;
 
-    eflags = helper_cc_compute_all(env, CC_OP);
+    eflags = cpu_cc_compute_all(env, CC_OP);
     eflags |= (DF & DF_MASK);
     eflags |= env->eflags & ~(VM_MASK | RF_MASK);
     return eflags;
diff --git a/target-i386/helper.h b/target-i386/helper.h
index 89076d3..aa313bd 100644
--- a/target-i386/helper.h
+++ b/target-i386/helper.h
@@ -1,6 +1,6 @@ 
 #include "exec/def-helper.h"
 
-DEF_HELPER_FLAGS_2(cc_compute_all, TCG_CALL_NO_SE, i32, env, int)
+DEF_HELPER_FLAGS_4(cc_compute_all, TCG_CALL_NO_RWG_SE, tl, tl, tl, tl, int)
 
 DEF_HELPER_0(lock, void)
 DEF_HELPER_0(unlock, void)
diff --git a/target-i386/translate.c b/target-i386/translate.c
index 77d86b0..2616a5c 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -898,13 +898,41 @@  static void gen_op_update_neg_cc(void)
 /* compute all eflags to cc_src */
 static void gen_compute_eflags(DisasContext *s)
 {
+    TCGv zero, dst, src1, src2;
+    int live, dead;
+
     if (s->cc_op == CC_OP_EFLAGS) {
         return;
     }
+
+    TCGV_UNUSED(zero);
+    dst = cpu_cc_dst;
+    src1 = cpu_cc_src;
+    src2 = cpu_cc_src2;
+
+    /* Take care to not read values that are not live.  */
+    live = cc_op_live[s->cc_op] & ~cc_op_opt[s->cc_op];
+    dead = live ^ (USES_CC_DST | USES_CC_SRC | USES_CC_SRC2);
+    if (dead) {
+        zero = tcg_const_tl(0);
+        if (dead & USES_CC_DST) {
+            dst = zero;
+        }
+        if (dead & USES_CC_SRC) {
+            src1 = zero;
+        }
+        if (dead & USES_CC_SRC2) {
+            src2 = zero;
+        }
+    }
+
     gen_update_cc_op(s);
-    gen_helper_cc_compute_all(cpu_tmp2_i32, cpu_env, cpu_cc_op);
+    gen_helper_cc_compute_all(cpu_cc_src, dst, src1, src2, cpu_cc_op);
     set_cc_op(s, CC_OP_EFLAGS);
-    tcg_gen_extu_i32_tl(cpu_cc_src, cpu_tmp2_i32);
+
+    if (dead) {
+        tcg_temp_free(zero);
+    }
 }
 
 typedef struct CCPrepare {