All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: cota@braap.org, vilanova@ac.upc.edu
Subject: [Qemu-devel] [PATCH v15 18/32] target/arm: [tcg] Port to tb_start
Date: Mon, 24 Jul 2017 13:27:14 -0700	[thread overview]
Message-ID: <20170724202728.25960-19-rth@twiddle.net> (raw)
In-Reply-To: <20170724202728.25960-1-rth@twiddle.net>

From: Lluís Vilanova <vilanova@ac.upc.edu>

Incrementally paves the way towards using the generic instruction translation
loop.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Alex Benneé <alex.benee@linaro.org>
Message-Id: <150002364681.22386.1701754996184325808.stgit@frigg.lan>
[rth: Adjust for tb_start interface change.]
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target/arm/translate.c | 82 +++++++++++++++++++++++++++-----------------------
 1 file changed, 44 insertions(+), 38 deletions(-)

diff --git a/target/arm/translate.c b/target/arm/translate.c
index 4e9e3c46b3..5acdeabebb 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -11863,6 +11863,49 @@ static int arm_tr_init_disas_context(DisasContextBase *dcbase,
     return max_insns;
 }
 
+static void arm_tr_tb_start(DisasContextBase *dcbase, CPUState *cpu)
+{
+    DisasContext *dc = container_of(dcbase, DisasContext, base);
+
+    /* A note on handling of the condexec (IT) bits:
+     *
+     * We want to avoid the overhead of having to write the updated condexec
+     * bits back to the CPUARMState for every instruction in an IT block. So:
+     * (1) if the condexec bits are not already zero then we write
+     * zero back into the CPUARMState now. This avoids complications trying
+     * to do it at the end of the block. (For example if we don't do this
+     * it's hard to identify whether we can safely skip writing condexec
+     * at the end of the TB, which we definitely want to do for the case
+     * where a TB doesn't do anything with the IT state at all.)
+     * (2) if we are going to leave the TB then we call gen_set_condexec()
+     * which will write the correct value into CPUARMState if zero is wrong.
+     * This is done both for leaving the TB at the end, and for leaving
+     * it because of an exception we know will happen, which is done in
+     * gen_exception_insn(). The latter is necessary because we need to
+     * leave the TB with the PC/IT state just prior to execution of the
+     * instruction which caused the exception.
+     * (3) if we leave the TB unexpectedly (eg a data abort on a load)
+     * then the CPUARMState will be wrong and we need to reset it.
+     * This is handled in the same way as restoration of the
+     * PC in these situations; we save the value of the condexec bits
+     * for each PC via tcg_gen_insn_start(), and restore_state_to_opc()
+     * then uses this to restore them after an exception.
+     *
+     * Note that there are no instructions which can read the condexec
+     * bits, and none which can write non-static values to them, so
+     * we don't need to care about whether CPUARMState is correct in the
+     * middle of a TB.
+     */
+
+    /* Reset the conditional execution bits immediately. This avoids
+       complications trying to do it at the end of the block.  */
+    if (dc->condexec_mask || dc->condexec_cond) {
+        TCGv_i32 tmp = tcg_temp_new_i32();
+        tcg_gen_movi_i32(tmp, 0);
+        store_cpu_field(tmp, condexec_bits);
+    }
+}
+
 /* generate intermediate code for basic block 'tb'.  */
 void gen_intermediate_code(CPUState *cs, TranslationBlock *tb)
 {
@@ -11902,45 +11945,8 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb)
     gen_tb_start(tb);
 
     tcg_clear_temp_count();
+    arm_tr_tb_start(&dc->base, cs);
 
-    /* A note on handling of the condexec (IT) bits:
-     *
-     * We want to avoid the overhead of having to write the updated condexec
-     * bits back to the CPUARMState for every instruction in an IT block. So:
-     * (1) if the condexec bits are not already zero then we write
-     * zero back into the CPUARMState now. This avoids complications trying
-     * to do it at the end of the block. (For example if we don't do this
-     * it's hard to identify whether we can safely skip writing condexec
-     * at the end of the TB, which we definitely want to do for the case
-     * where a TB doesn't do anything with the IT state at all.)
-     * (2) if we are going to leave the TB then we call gen_set_condexec()
-     * which will write the correct value into CPUARMState if zero is wrong.
-     * This is done both for leaving the TB at the end, and for leaving
-     * it because of an exception we know will happen, which is done in
-     * gen_exception_insn(). The latter is necessary because we need to
-     * leave the TB with the PC/IT state just prior to execution of the
-     * instruction which caused the exception.
-     * (3) if we leave the TB unexpectedly (eg a data abort on a load)
-     * then the CPUARMState will be wrong and we need to reset it.
-     * This is handled in the same way as restoration of the
-     * PC in these situations; we save the value of the condexec bits
-     * for each PC via tcg_gen_insn_start(), and restore_state_to_opc()
-     * then uses this to restore them after an exception.
-     *
-     * Note that there are no instructions which can read the condexec
-     * bits, and none which can write non-static values to them, so
-     * we don't need to care about whether CPUARMState is correct in the
-     * middle of a TB.
-     */
-
-    /* Reset the conditional execution bits immediately. This avoids
-       complications trying to do it at the end of the block.  */
-    if (dc->condexec_mask || dc->condexec_cond)
-      {
-        TCGv_i32 tmp = tcg_temp_new_i32();
-        tcg_gen_movi_i32(tmp, 0);
-        store_cpu_field(tmp, condexec_bits);
-      }
     do {
         dc->base.num_insns++;
         dc->insn_start_idx = tcg_op_buf_count();
-- 
2.13.3

  parent reply	other threads:[~2017-07-24 20:28 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24 20:26 [Qemu-devel] [PATCH v15 00/32] Generic translation framework Richard Henderson
2017-07-24 20:26 ` [Qemu-devel] [PATCH v15 01/32] tcg: Add generic DISAS_NORETURN Richard Henderson
2017-07-24 20:26 ` [Qemu-devel] [PATCH v15 02/32] target/i386: Use generic DISAS_* enumerators Richard Henderson
2017-07-24 20:26 ` [Qemu-devel] [PATCH v15 03/32] target/arm: Use DISAS_NORETURN Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 04/32] target: [tcg] Use a generic enum for DISAS_ values Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 05/32] target/arm: Delay check for magic kernel page Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 06/32] tcg: Add generic translation framework Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 07/32] target/i386: [tcg] Port to DisasContextBase Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 08/32] target/i386: [tcg] Port to init_disas_context Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 09/32] target/i386: [tcg] Port to insn_start Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 10/32] target/i386: [tcg] Port to breakpoint_check Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 11/32] target/i386: [tcg] Port to translate_insn Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 12/32] target/i386: [tcg] Port to tb_stop Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 13/32] target/i386: [tcg] Port to disas_log Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 14/32] target/i386: [tcg] Port to generic translation framework Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 15/32] target/arm: [tcg] Port to DisasContextBase Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 16/32] target/arm: [tcg] Port to init_disas_context Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 17/32] target/arm: [tcg, a64] " Richard Henderson
2017-07-24 20:27 ` Richard Henderson [this message]
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 19/32] target/arm: [tcg] Port to insn_start Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 20/32] target/arm: [tcg, a64] " Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 21/32] target/arm: [tcg, a64] Port to breakpoint_check Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 22/32] target/arm: [tcg] Port to translate_insn Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 23/32] target/arm: [tcg, a64] " Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 24/32] target/arm: [tcg] Port to tb_stop Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 25/32] target/arm: [tcg, a64] " Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 26/32] target/arm: [tcg] Port to disas_log Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 27/32] target/arm: [tcg, a64] " Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 28/32] target/arm: [tcg] Port to generic translation framework Richard Henderson
2017-07-24 21:00   ` Emilio G. Cota
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 29/32] target/arm: [a64] Move page and ss checks to init_disas_context Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 30/32] target/arm: Move ss check " Richard Henderson
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 31/32] target/arm: Split out thumb_tr_translate_insn Richard Henderson
2017-07-24 21:01   ` Emilio G. Cota
2017-07-24 20:27 ` [Qemu-devel] [PATCH v15 32/32] target/arm: Perform per-insn cross-page check only for Thumb 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=20170724202728.25960-19-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=cota@braap.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vilanova@ac.upc.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.