Patchwork [44/62] tcg-s390: Tidy user qemu_ld/st.

login
register
mail settings
Submitter Richard Henderson
Date May 27, 2010, 8:46 p.m.
Message ID <1274993204-30766-45-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/53832/
State New
Headers show

Comments

Richard Henderson - May 27, 2010, 8:46 p.m.
Create a tcg_prepare_user_ldst to prep the host address to
be used to implement the guest memory operation.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/s390/tcg-target.c |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

Patch

diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c
index 000a646..fa089ab 100644
--- a/tcg/s390/tcg-target.c
+++ b/tcg/s390/tcg-target.c
@@ -1047,6 +1047,17 @@  static void tcg_finish_qemu_ldst(TCGContext* s, uint16_t *label2_ptr)
     *(label2_ptr + 1) = ((unsigned long)s->code_ptr -
                          (unsigned long)label2_ptr) >> 1;
 }
+#else
+static void tcg_prepare_user_ldst(TCGContext *s, TCGReg *addr_reg,
+                                  TCGReg *index_reg, tcg_target_long *disp)
+{
+    *index_reg = 0;
+    *disp = 0;
+    if (TARGET_LONG_BITS == 32) {
+        tgen_ext32u(s, TCG_TMP0, *addr_reg);
+        *addr_reg = TCG_TMP0;
+    }
+}
 #endif /* CONFIG_SOFTMMU */
 
 /* load data with address translation (if applicable)
@@ -1057,6 +1068,9 @@  static void tcg_out_qemu_ld(TCGContext* s, const TCGArg* args, int opc)
 #if defined(CONFIG_SOFTMMU)
     int mem_index;
     uint16_t *label2_ptr;
+#else
+    TCGReg index_reg;
+    tcg_target_long disp;
 #endif
 
     data_reg = *args++;
@@ -1072,12 +1086,8 @@  static void tcg_out_qemu_ld(TCGContext* s, const TCGArg* args, int opc)
 
     tcg_finish_qemu_ldst(s, label2_ptr);
 #else
-    if (TARGET_LONG_BITS == 32) {
-        tgen_ext32u(s, TCG_TMP0, addr_reg);
-        tcg_out_qemu_ld_direct(s, opc, data_reg, TCG_TMP0, 0, 0);
-    } else {
-        tcg_out_qemu_ld_direct(s, opc, data_reg, addr_reg, 0, 0);
-    }
+    tcg_prepare_user_ldst(s, &addr_reg, &index_reg, &disp);
+    tcg_out_qemu_ld_direct(s, opc, data_reg, addr_reg, index_reg, disp);
 #endif
 }
 
@@ -1087,6 +1097,9 @@  static void tcg_out_qemu_st(TCGContext* s, const TCGArg* args, int opc)
 #if defined(CONFIG_SOFTMMU)
     int mem_index;
     uint16_t *label2_ptr;
+#else
+    TCGReg index_reg;
+    tcg_target_long disp;
 #endif
 
     data_reg = *args++;
@@ -1102,12 +1115,8 @@  static void tcg_out_qemu_st(TCGContext* s, const TCGArg* args, int opc)
 
     tcg_finish_qemu_ldst(s, label2_ptr);
 #else
-    if (TARGET_LONG_BITS == 32) {
-        tgen_ext32u(s, TCG_TMP0, addr_reg);
-        tcg_out_qemu_st_direct(s, opc, data_reg, TCG_TMP0, 0, 0);
-    } else {
-        tcg_out_qemu_st_direct(s, opc, data_reg, addr_reg, 0, 0);
-    }
+    tcg_prepare_user_ldst(s, &addr_reg, &index_reg, &disp);
+    tcg_out_qemu_st_direct(s, opc, data_reg, addr_reg, index_reg, disp);
 #endif
 }