From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Subject: [PULL 06/24] target/i386: cpu_load_eflags already sets cc_op
Date: Sat, 25 May 2024 13:33:14 +0200 [thread overview]
Message-ID: <20240525113332.1404158-7-pbonzini@redhat.com> (raw)
In-Reply-To: <20240525113332.1404158-1-pbonzini@redhat.com>
No need to set it again at the end of the translation block, cc_op_dirty
can be set to false.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/tcg/translate.c | 37 ++++++++++++++++++++++++-------------
target/i386/tcg/emit.c.inc | 2 +-
2 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 920d854c2b5..25c973e20c6 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -309,7 +309,7 @@ static const uint8_t cc_op_live[CC_OP_NB] = {
[CC_OP_POPCNT] = USES_CC_SRC,
};
-static void set_cc_op(DisasContext *s, CCOp op)
+static void set_cc_op_1(DisasContext *s, CCOp op, bool dirty)
{
int dead;
@@ -332,20 +332,27 @@ static void set_cc_op(DisasContext *s, CCOp op)
tcg_gen_discard_tl(s->cc_srcT);
}
- if (op == CC_OP_DYNAMIC) {
- /* The DYNAMIC setting is translator only, and should never be
- stored. Thus we always consider it clean. */
- s->cc_op_dirty = false;
- } else {
- /* Discard any computed CC_OP value (see shifts). */
- if (s->cc_op == CC_OP_DYNAMIC) {
- tcg_gen_discard_i32(cpu_cc_op);
- }
- s->cc_op_dirty = true;
+ if (dirty && s->cc_op == CC_OP_DYNAMIC) {
+ tcg_gen_discard_i32(cpu_cc_op);
}
+ s->cc_op_dirty = dirty;
s->cc_op = op;
}
+static void set_cc_op(DisasContext *s, CCOp op)
+{
+ /*
+ * The DYNAMIC setting is translator only, everything else
+ * will be spilled later.
+ */
+ set_cc_op_1(s, op, op != CC_OP_DYNAMIC);
+}
+
+static void assume_cc_op(DisasContext *s, CCOp op)
+{
+ set_cc_op_1(s, op, false);
+}
+
static void gen_update_cc_op(DisasContext *s)
{
if (s->cc_op_dirty) {
@@ -3554,6 +3561,10 @@ static void disas_insn_old(DisasContext *s, CPUState *cpu, int b)
gen_update_cc_op(s);
gen_update_eip_cur(s);
gen_helper_syscall(tcg_env, cur_insn_len_i32(s));
+ /* condition codes are modified only in long mode */
+ if (LMA(s)) {
+ assume_cc_op(s, CC_OP_EFLAGS);
+ }
/* TF handling for the syscall insn is different. The TF bit is checked
after the syscall insn completes. This allows #DB to not be
generated after one has entered CPL0 if TF is set in FMASK. */
@@ -3570,7 +3581,7 @@ static void disas_insn_old(DisasContext *s, CPUState *cpu, int b)
gen_helper_sysret(tcg_env, tcg_constant_i32(dflag - 1));
/* condition codes are modified only in long mode */
if (LMA(s)) {
- set_cc_op(s, CC_OP_EFLAGS);
+ assume_cc_op(s, CC_OP_EFLAGS);
}
/* TF handling for the sysret insn is different. The TF bit is
checked after the sysret insn completes. This allows #DB to be
@@ -4489,7 +4500,7 @@ static void disas_insn_old(DisasContext *s, CPUState *cpu, int b)
g_assert_not_reached();
#else
gen_helper_rsm(tcg_env);
- set_cc_op(s, CC_OP_EFLAGS);
+ assume_cc_op(s, CC_OP_EFLAGS);
#endif /* CONFIG_USER_ONLY */
s->base.is_jmp = DISAS_EOB_ONLY;
break;
diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index c78e35b1e28..3f2ae0aa7e7 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -1883,7 +1883,7 @@ static void gen_IRET(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
gen_helper_iret_protected(tcg_env, tcg_constant_i32(s->dflag - 1),
eip_next_i32(s));
}
- set_cc_op(s, CC_OP_EFLAGS);
+ assume_cc_op(s, CC_OP_EFLAGS);
s->base.is_jmp = DISAS_EOB_ONLY;
}
--
2.45.1
next prev parent reply other threads:[~2024-05-25 11:38 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-25 11:33 [PULL 00/24] Build system and target/i386/translate.c cleanups for 2025-05-25 Paolo Bonzini
2024-05-25 11:33 ` [PULL 01/24] configure: move -mcx16 flag out of CPU_CFLAGS Paolo Bonzini
2024-10-04 16:08 ` Alex Bennée
2024-10-04 22:42 ` Pierrick Bouvier
2024-05-25 11:33 ` [PULL 02/24] target/i386: disable jmp_opt if EFLAGS.RF is 1 Paolo Bonzini
2024-05-25 11:33 ` [PULL 03/24] target/i386: no single-step exception after MOV or POP SS Paolo Bonzini
2024-05-25 11:33 ` [PULL 04/24] target/i386: cleanup eob handling of RSM Paolo Bonzini
2024-05-25 11:33 ` [PULL 05/24] target/i386: remove unnecessary gen_update_cc_op before gen_eob* Paolo Bonzini
2024-05-25 11:33 ` Paolo Bonzini [this message]
2024-05-25 11:33 ` [PULL 07/24] target/i386: set CC_OP in helpers if they want CC_OP_EFLAGS Paolo Bonzini
2024-05-25 11:33 ` [PULL 08/24] target/i386: document and group DISAS_* constants Paolo Bonzini
2024-05-25 11:33 ` [PULL 09/24] target/i386: avoid calling gen_eob_syscall before tb_stop Paolo Bonzini
2024-05-25 11:33 ` [PULL 10/24] target/i386: avoid calling gen_eob_inhibit_irq " Paolo Bonzini
2024-05-25 11:33 ` [PULL 11/24] target/i386: assert that gen_update_eip_cur and gen_update_eip_next are the same in tb_stop Paolo Bonzini
2024-05-25 11:33 ` [PULL 12/24] target/i386: raze the gen_eob* jungle Paolo Bonzini
2024-05-25 11:33 ` [PULL 13/24] target/i386: reg in gen_ldst_modrm is always OR_TMP0 Paolo Bonzini
2024-05-25 11:33 ` [PULL 14/24] target/i386: split gen_ldst_modrm for load and store Paolo Bonzini
2024-05-25 11:33 ` [PULL 15/24] target/i386: inline gen_add_A0_ds_seg Paolo Bonzini
2024-05-25 11:33 ` [PULL 16/24] target/i386: use mo_stacksize more Paolo Bonzini
2024-05-25 11:33 ` [PULL 17/24] target/i386: introduce gen_lea_ss_ofs Paolo Bonzini
2024-05-25 11:33 ` [PULL 18/24] target/i386: clean up repeated string operations Paolo Bonzini
2024-05-25 11:33 ` [PULL 19/24] target/i386: remove aflag argument of gen_lea_v_seg Paolo Bonzini
2024-05-25 11:33 ` [PULL 20/24] meson: remove unnecessary reference to libm Paolo Bonzini
2024-05-25 11:33 ` [PULL 21/24] meson: remove unnecessary dependency Paolo Bonzini
2024-05-25 11:33 ` [PULL 22/24] tcg: include dependencies in static_library() Paolo Bonzini
2024-05-25 11:33 ` [PULL 23/24] meson: do not query modules before they are processed Paolo Bonzini
2024-05-25 11:33 ` [PULL 24/24] migration: remove unnecessary zlib dependency Paolo Bonzini
2024-05-26 1:34 ` [PULL 00/24] Build system and target/i386/translate.c cleanups for 2025-05-25 Richard Henderson
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=20240525113332.1404158-7-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).