From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH 02/10] target-i386: Introduce mo_stacksize
Date: Thu, 9 Jul 2015 08:15:14 +0100 [thread overview]
Message-ID: <1436426122-12276-3-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1436426122-12276-1-git-send-email-rth@twiddle.net>
Centralize computation of a MO_SIZE for the stack pointer.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
target-i386/translate.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/target-i386/translate.c b/target-i386/translate.c
index 2c6c5ec..a900508 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -310,6 +310,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)
{
@@ -2291,31 +2297,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);
@@ -2324,7 +2321,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);
--
2.4.3
next prev parent reply other threads:[~2015-07-09 7:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-09 7:15 [Qemu-devel] [PATCH 00/10] target-i386 addressing cleanups Richard Henderson
2015-07-09 7:15 ` [Qemu-devel] [PATCH 01/10] target-i386: Create gen_lea_v_seg Richard Henderson
2015-07-09 7:15 ` Richard Henderson [this message]
2015-07-09 7:15 ` [Qemu-devel] [PATCH 03/10] target-i386: Use gen_lea_v_seg in gen_lea_modrm Richard Henderson
2015-07-09 7:15 ` [Qemu-devel] [PATCH 04/10] target-i386: Use gen_lea_v_seg in stack subroutines Richard Henderson
2015-07-09 7:15 ` [Qemu-devel] [PATCH 05/10] target-i386: Access segs via TCG registers Richard Henderson
2015-07-09 13:30 ` Paolo Bonzini
2015-07-10 6:48 ` Richard Henderson
2015-07-09 7:15 ` [Qemu-devel] [PATCH 06/10] target-i386: Use gen_lea_v_seg in pusha/popa Richard Henderson
2015-07-09 7:15 ` [Qemu-devel] [PATCH 07/10] target-i386: Rewrite gen_enter inline Richard Henderson
2015-07-09 7:15 ` [Qemu-devel] [PATCH 08/10] target-i386: Rewrite leave Richard Henderson
2015-07-09 7:15 ` [Qemu-devel] [PATCH 09/10] target-i386: Tidy gen_add_A0_im Richard Henderson
2015-07-09 7:15 ` [Qemu-devel] [PATCH 10/10] target-i386: Deconstruct the cpu_T array Richard Henderson
2015-07-09 13:32 ` [Qemu-devel] [PATCH 00/10] target-i386 addressing cleanups Paolo Bonzini
2015-09-24 4:10 ` Richard Henderson
2015-09-25 16:56 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436426122-12276-3-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).