All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Richard Henderson" <rth@twiddle.net>,
	"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>
Subject: [Qemu-devel] [PATCH v9 07/26] target: [tcg, i386] Refactor init_disas_context
Date: Sun, 25 Jun 2017 12:12:00 +0300	[thread overview]
Message-ID: <149838191990.6497.6153382313093413628.stgit@frigg.lan> (raw)
In-Reply-To: <149838022308.6497.2104916050645246693.stgit@frigg.lan>

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

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 target/i386/translate.c |   43 ++++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/target/i386/translate.c b/target/i386/translate.c
index 5a801766e5..84ff49030b 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -8396,21 +8396,12 @@ void tcg_x86_init(void)
     }
 }
 
-/* generate intermediate code for basic block 'tb'.  */
-void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)
+static void i386_trblock_init_disas_context(DisasContextBase *db, CPUState *cpu)
 {
+    DisasContext *dc = container_of(db, DisasContext, base);
     CPUX86State *env = cpu->env_ptr;
-    DisasContext dc1, *dc = &dc1;
-    DisasContextBase *db = &dc1.base;
-    uint32_t flags;
-    target_ulong cs_base;
-    int num_insns;
-    int max_insns;
-
-    /* generate intermediate code */
-    db->pc_first = tb->pc;
-    cs_base = tb->cs_base;
-    flags = tb->flags;
+    uint32_t flags = db->tb->flags;
+    target_ulong cs_base = db->tb->cs_base;
 
     dc->pe = (flags >> HF_PE_SHIFT) & 1;
     dc->code32 = (flags >> HF_CS32_SHIFT) & 1;
@@ -8421,11 +8412,9 @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)
     dc->cpl = (flags >> HF_CPL_SHIFT) & 3;
     dc->iopl = (flags >> IOPL_SHIFT) & 3;
     dc->tf = (flags >> TF_SHIFT) & 1;
-    db->singlestep_enabled = cpu->singlestep_enabled;
     dc->cc_op = CC_OP_DYNAMIC;
     dc->cc_op_dirty = false;
     dc->cs_base = cs_base;
-    db->tb = tb;
     dc->popl_esp_hack = 0;
     /* select memory access functions */
     dc->mem_index = 0;
@@ -8455,12 +8444,30 @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)
        record/replay modes and there will always be an
        additional step for ecx=0 when icount is enabled.
      */
-    dc->repz_opt = !dc->jmp_opt && !(tb->cflags & CF_USE_ICOUNT);
+    dc->repz_opt = !dc->jmp_opt && !(db->tb->cflags & CF_USE_ICOUNT);
 #if 0
     /* check addseg logic */
     if (!dc->addseg && (dc->vm86 || !dc->pe || !dc->code32))
         printf("ERROR addseg\n");
 #endif
+}
+
+/* generate intermediate code for basic block 'tb'.  */
+void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)
+{
+    CPUX86State *env = cpu->env_ptr;
+    DisasContext dc1, *dc = &dc1;
+    DisasContextBase *db = &dc1.base;
+    int num_insns;
+    int max_insns;
+
+    /* generate intermediate code */
+    db->singlestep_enabled = cpu->singlestep_enabled;
+    db->tb = tb;
+    db->is_jmp = DISAS_NEXT;
+    db->pc_first = tb->pc;
+    db->pc_next = db->pc_first;
+    i386_trblock_init_disas_context(db, cpu);
 
     cpu_T0 = tcg_temp_new();
     cpu_T1 = tcg_temp_new();
@@ -8475,8 +8482,6 @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)
     cpu_ptr1 = tcg_temp_new_ptr();
     cpu_cc_srcT = tcg_temp_local_new();
 
-    db->is_jmp = DISAS_NEXT;
-    db->pc_next = db->pc_first;
     num_insns = 0;
     max_insns = tb->cflags & CF_COUNT_MASK;
     if (max_insns == 0) {
@@ -8518,7 +8523,7 @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb)
            the flag and abort the translation to give the irqs a
            change to be happen */
         if (dc->tf || db->singlestep_enabled ||
-            (flags & HF_INHIBIT_IRQ_MASK)) {
+            (db->tb->flags & HF_INHIBIT_IRQ_MASK)) {
             gen_jmp_im(db->pc_next - dc->cs_base);
             gen_eob(dc);
             break;

  parent reply	other threads:[~2017-06-25  9:12 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-25  8:43 [Qemu-devel] [RFC PATCH v9 00/26] translate: [tcg] Generic translation framework Lluís Vilanova
2017-06-25  8:47 ` [Qemu-devel] [PATCH v9 01/26] Pass generic CPUState to gen_intermediate_code() Lluís Vilanova
2017-06-26 10:04   ` [Qemu-devel] [PATCH] fixup! " Alex Bennée
2017-06-26 12:37     ` Lluís Vilanova
2017-06-26 17:50   ` [Qemu-devel] [PATCH v9 01/26] " Emilio G. Cota
2017-06-25  8:51 ` [Qemu-devel] [PATCH v9 02/26] queue: Add macro for incremental traversal Lluís Vilanova
2017-06-25  8:55 ` [Qemu-devel] [PATCH v9 03/26] cpu-exec: Avoid global variables in icount-related functions Lluís Vilanova
2017-06-26 17:53   ` Emilio G. Cota
2017-06-25  8:59 ` [Qemu-devel] [PATCH v9 04/26] target: [tcg] Add generic translation framework Lluís Vilanova
2017-06-26 10:14   ` Alex Bennée
2017-06-26 12:50     ` Lluís Vilanova
2017-06-26 18:21       ` Peter Maydell
2017-06-27  3:22         ` Richard Henderson
2017-06-27  9:23           ` Peter Maydell
2017-06-27  2:47     ` Richard Henderson
2017-06-26 17:57   ` Emilio G. Cota
2017-06-26 18:12   ` Emilio G. Cota
2017-06-27 11:32     ` Lluís Vilanova
2017-06-27  2:39   ` Richard Henderson
2017-06-27 15:41     ` Lluís Vilanova
2017-06-25  9:03 ` [Qemu-devel] [PATCH v9 05/26] target: [tcg] Redefine DISAS_* onto the generic translation framework (DJ_*) Lluís Vilanova
2017-06-26 11:28   ` [Qemu-devel] [PATCH] maybe fixup! " Alex Bennée
2017-06-26 18:05   ` [Qemu-devel] [PATCH v9 05/26] " Emilio G. Cota
2017-06-25  9:07 ` [Qemu-devel] [PATCH v9 06/26] target: [tcg, i386] Port to DisasContextBase Lluís Vilanova
2017-06-26 18:14   ` Emilio G. Cota
2017-06-28 11:23     ` Lluís Vilanova
2017-06-29 21:50       ` Emilio G. Cota
2017-06-25  9:12 ` Lluís Vilanova [this message]
2017-06-27  2:57   ` [Qemu-devel] [PATCH v9 07/26] target: [tcg, i386] Refactor init_disas_context Richard Henderson
2017-06-27  6:07     ` Lluís Vilanova
2017-06-25  9:16 ` [Qemu-devel] [PATCH v9 08/26] target: [tcg, i386] Refactor init_globals Lluís Vilanova
2017-06-25  9:20 ` [Qemu-devel] [PATCH v9 09/26] target: [tcg, i386] Refactor insn_start Lluís Vilanova
2017-06-25  9:24 ` [Qemu-devel] [PATCH v9 10/26] target: [tcg, i386] Refactor breakpoint_check Lluís Vilanova
2017-06-25  9:28 ` [Qemu-devel] [PATCH v9 11/26] target: [tcg, i386] Refactor disas_insn Lluís Vilanova
2017-06-25  9:32 ` [Qemu-devel] [PATCH v9 12/26] target: [tcg,i386] Refactor tb_stop Lluís Vilanova
2017-06-25  9:36 ` [Qemu-devel] [PATCH v9 13/26] target: [tcg, i386] Refactor disas_flags Lluís Vilanova
2017-06-25  9:40 ` [Qemu-devel] [PATCH v9 14/26] target: [tcg, i386] Replace DISAS_* with DJ_* Lluís Vilanova
2017-06-25  9:48 ` [Qemu-devel] [PATCH v9 16/26] target: [tcg, arm] " Lluís Vilanova
2017-06-26 18:08   ` Emilio G. Cota
2017-06-25  9:52 ` [Qemu-devel] [PATCH v9 17/26] target: [tcg, arm] Port to DisasContextBase Lluís Vilanova
2017-06-25  9:56 ` [Qemu-devel] [PATCH v9 18/26] target: [tcg, arm] Port to init_disas_context Lluís Vilanova
2017-06-25 10:00 ` [Qemu-devel] [PATCH v9 19/26] target: [tcg, arm] Port to init_globals Lluís Vilanova
2017-06-25 10:04 ` [Qemu-devel] [PATCH v9 20/26] target: [tcg,arm] Port to tb_start Lluís Vilanova
2017-06-25 10:08 ` [Qemu-devel] [PATCH v9 21/26] target: [tcg, arm] Port to insn_start Lluís Vilanova
2017-06-26 11:31   ` Alex Bennée
2017-06-27  3:33   ` Richard Henderson
2017-06-28 11:48     ` Lluís Vilanova
2017-06-25 10:12 ` [Qemu-devel] [PATCH v9 22/26] target: [tcg, arm] Port to breakpoint_check Lluís Vilanova
2017-06-25 10:16 ` [Qemu-devel] [PATCH v9 23/26] target: [tcg, arm] Port to disas_insn Lluís Vilanova
2017-06-25 10:20 ` [Qemu-devel] [PATCH v9 24/26] target: [tcg,arm] Port to tb_stop Lluís Vilanova
2017-06-25 10:24 ` [Qemu-devel] [PATCH v9 25/26] target: [tcg, arm] Port to disas_flags Lluís Vilanova
2017-06-25 10:28 ` [Qemu-devel] [PATCH v9 26/26] target: [tcg, arm] Port to generic translation framework Lluís Vilanova
2017-06-27  3:47   ` Richard Henderson
2017-06-26 11:34 ` [Qemu-devel] [RFC PATCH v9 00/26] translate: [tcg] Generic " Alex Bennée
2017-06-26 13:02   ` Lluís Vilanova
2017-06-27  3:00 ` Eric Blake
2017-06-27 12:23   ` Lluís Vilanova

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=149838191990.6497.6153382313093413628.stgit@frigg.lan \
    --to=vilanova@ac.upc.edu \
    --cc=alex.bennee@linaro.org \
    --cc=crosthwaite.peter@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.