diff options
author | Richard Henderson <rth@twiddle.net> | 2015-12-17 11:19:18 -0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-02-09 15:45:27 +0100 |
commit | 64ae256c2450262e27f07657c5734d3197458d95 (patch) | |
tree | de7266399bd0199b635e12773a2ff2658defadfa | |
parent | ca2f29f555805d07fb0b9ebfbbfc4e3656530977 (diff) |
target-i386: Introduce mo_stacksize
Centralize computation of a MO_SIZE for the stack pointer.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Message-Id: <1450379966-28198-3-git-send-email-rth@twiddle.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | target-i386/translate.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/target-i386/translate.c b/target-i386/translate.c index 4d65eb309f..836ef1c101 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -304,6 +304,12 @@ static inline TCGMemOp mo_pushpop(DisasContext *s, TCGMemOp ot) } } +/* Select the size of the stack pointer. */ +static inline TCGMemOp mo_stacksize(DisasContext *s) +{ + return CODE64(s) ? MO_64 : s->ss32 ? MO_32 : MO_16; +} + /* Select only size 64 else 32. Used for SSE operand sizes. */ static inline TCGMemOp mo_64_32(TCGMemOp ot) { @@ -2289,31 +2295,22 @@ gen_svm_check_intercept(DisasContext *s, target_ulong pc_start, uint64_t type) static inline void gen_stack_update(DisasContext *s, int addend) { -#ifdef TARGET_X86_64 - if (CODE64(s)) { - gen_op_add_reg_im(MO_64, R_ESP, addend); - } else -#endif - if (s->ss32) { - gen_op_add_reg_im(MO_32, R_ESP, addend); - } else { - gen_op_add_reg_im(MO_16, R_ESP, addend); - } + gen_op_add_reg_im(mo_stacksize(s), R_ESP, addend); } /* Generate a push. It depends on ss32, addseg and dflag. */ static void gen_push_v(DisasContext *s, TCGv val) { - TCGMemOp a_ot, d_ot = mo_pushpop(s, s->dflag); + TCGMemOp d_ot = mo_pushpop(s, s->dflag); + TCGMemOp a_ot = mo_stacksize(s); int size = 1 << d_ot; TCGv new_esp = cpu_A0; tcg_gen_subi_tl(cpu_A0, cpu_regs[R_ESP], size); if (CODE64(s)) { - a_ot = MO_64; + /* No special handling. */ } else if (s->ss32) { - a_ot = MO_32; if (s->addseg) { new_esp = cpu_tmp4; tcg_gen_mov_tl(new_esp, cpu_A0); @@ -2322,7 +2319,6 @@ static void gen_push_v(DisasContext *s, TCGv val) tcg_gen_ext32u_tl(cpu_A0, cpu_A0); } } else { - a_ot = MO_16; new_esp = cpu_tmp4; tcg_gen_ext16u_tl(cpu_A0, cpu_A0); tcg_gen_mov_tl(new_esp, cpu_A0); |