[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 13/22] tcg-i386: Tidy push/pop.
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 13/22] tcg-i386: Tidy push/pop. |
Date: |
Wed, 14 Apr 2010 10:59:48 -0700 |
Move tcg_out_push/pop up in the file so that they can be used
by qemu_ld/st. Define a tcg_out_pushi to be used as well.
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/i386/tcg-target.c | 50 +++++++++++++++++++++++++++++++-----------------
1 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index 06946e5..58fcd23 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -183,6 +183,10 @@ static inline int tcg_target_const_match(tcg_target_long
val,
#define OPC_MOVZWL (0xb7 | P_EXT)
#define OPC_MOVSBL (0xbe | P_EXT)
#define OPC_MOVSWL (0xbf | P_EXT)
+#define OPC_POP_r32 (0x58)
+#define OPC_PUSH_r32 (0x50)
+#define OPC_PUSH_Iv (0x68)
+#define OPC_PUSH_Ib (0x6a)
#define OPC_SHIFT_1 (0xd1)
#define OPC_SHIFT_Ib (0xc1)
#define OPC_SHIFT_cl (0xd3)
@@ -311,6 +315,29 @@ static inline void tcg_out_movi(TCGContext *s, TCGType
type,
}
}
+#if defined(CONFIG_SOFTMMU)
+static void tcg_out_pushi(TCGContext *s, tcg_target_long val)
+{
+ if (val == (int8_t)val) {
+ tcg_out_opc(s, OPC_PUSH_Ib);
+ tcg_out8(s, val);
+ } else {
+ tcg_out_opc(s, OPC_PUSH_Iv);
+ tcg_out32(s, val);
+ }
+}
+#endif
+
+static inline void tcg_out_push(TCGContext *s, int reg)
+{
+ tcg_out_opc(s, OPC_PUSH_r32 + reg);
+}
+
+static inline void tcg_out_pop(TCGContext *s, int reg)
+{
+ tcg_out_opc(s, OPC_POP_r32 + reg);
+}
+
static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret,
int arg1, tcg_target_long arg2)
{
@@ -910,8 +937,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg
*args,
if (opc == 3) {
tcg_out_mov(s, TCG_REG_EDX, data_reg);
tcg_out_mov(s, TCG_REG_ECX, data_reg2);
- tcg_out8(s, 0x6a); /* push Ib */
- tcg_out8(s, mem_index);
+ tcg_out_pushi(s, mem_index);
tcg_out8(s, 0xe8);
tcg_out32(s, (tcg_target_long)qemu_st_helpers[s_bits] -
(tcg_target_long)s->code_ptr - 4);
@@ -936,10 +962,9 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg
*args,
#else
if (opc == 3) {
tcg_out_mov(s, TCG_REG_EDX, addr_reg2);
- tcg_out8(s, 0x6a); /* push Ib */
- tcg_out8(s, mem_index);
- tcg_out_opc(s, 0x50 + data_reg2); /* push */
- tcg_out_opc(s, 0x50 + data_reg); /* push */
+ tcg_out_pushi(s, mem_index);
+ tcg_out_push(s, data_reg2);
+ tcg_out_push(s, data_reg);
tcg_out8(s, 0xe8);
tcg_out32(s, (tcg_target_long)qemu_st_helpers[s_bits] -
(tcg_target_long)s->code_ptr - 4);
@@ -957,8 +982,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg
*args,
tcg_out_mov(s, TCG_REG_ECX, data_reg);
break;
}
- tcg_out8(s, 0x6a); /* push Ib */
- tcg_out8(s, mem_index);
+ tcg_out_pushi(s, mem_index);
tcg_out8(s, 0xe8);
tcg_out32(s, (tcg_target_long)qemu_st_helpers[s_bits] -
(tcg_target_long)s->code_ptr - 4);
@@ -1371,16 +1395,6 @@ static int tcg_target_callee_save_regs[] = {
TCG_REG_EDI,
};
-static inline void tcg_out_push(TCGContext *s, int reg)
-{
- tcg_out_opc(s, 0x50 + reg);
-}
-
-static inline void tcg_out_pop(TCGContext *s, int reg)
-{
- tcg_out_opc(s, 0x58 + reg);
-}
-
/* Generate global QEMU prologue and epilogue code */
void tcg_target_qemu_prologue(TCGContext *s)
{
--
1.6.6.1
- [Qemu-devel] [PATCH 00/22] tcg-i386 cleanup and improvement, v2, Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 02/22] tcg-i386: Tidy initialization of tcg_target_call_clobber_regs., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 13/22] tcg-i386: Tidy push/pop.,
Richard Henderson <=
- [Qemu-devel] [PATCH 08/22] tcg-i386: Eliminate extra move from qemu_ld64., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 09/22] tcg-i386: Tidy jumps., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 04/22] tcg-i386: Tidy ext8s and ext16s operations., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 03/22] tcg-i386: Tidy ext8u and ext16u operations., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 12/22] tcg-i386: Tidy movi., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 10/22] tcg-i386: Tidy immediate arithmetic operations., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 07/22] tcg-i386: Tidy move operations., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 01/22] tcg-i386: Allocate call-saved registers first., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 11/22] tcg-i386: Tidy non-immediate arithmetic operations., Richard Henderson, 2010/04/28
- [Qemu-devel] [PATCH 06/22] tcg-i386: Tidy shift operations., Richard Henderson, 2010/04/28