From nobody Sat Nov 1 07:20:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526101844998385.22346610048044; Fri, 11 May 2018 22:10:44 -0700 (PDT) Received: from localhost ([::1]:45606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHMns-0005T4-5B for importer@patchew.org; Sat, 12 May 2018 01:10:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHMgS-00042D-0o for qemu-devel@nongnu.org; Sat, 12 May 2018 01:03:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHMgQ-0008Mx-OO for qemu-devel@nongnu.org; Sat, 12 May 2018 01:03:04 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:34437) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fHMgQ-0008Mn-GX for qemu-devel@nongnu.org; Sat, 12 May 2018 01:03:02 -0400 Received: by mail-pf0-x242.google.com with SMTP id a14-v6so3619363pfi.1 for ; Fri, 11 May 2018 22:03:02 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id x124-v6sm8999945pfx.72.2018.05.11.22.02.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 22:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oJwjsjbzZ8nnpGUKhg+8/csmYxbKT/f7eSwlxRP/Gd8=; b=A9tGZm/k3WIzylnSIKzaZeEnLUYGy/tltljFzPi5uqgRSdOfOa851jBoH0EKSADo4i h8XuyXV6leoYwD0626p5cyCRXI7rRxaSzruBwW7bcHI53c69S+G8A+lskYhtJIYWEr0y mZ0t/Zp7it/MxzOPfTX8ChaXEZccrLDW+uqXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oJwjsjbzZ8nnpGUKhg+8/csmYxbKT/f7eSwlxRP/Gd8=; b=OxQXWPiLY+k/AU60J4+63+qQjDIpuXiTI0E6IY5bPFe/JzxltyrQizP+ICqcxsmVHa WM9DUSIdQq7vYrxmsSgCruzkFIIJoclCPWWnYCMec6FDRG6uwRurCtUrO3m/G9kZJ7No aPRJ0Qqys9qhvCwCNAZchr+f3kiBiPNBkRaNOpIrSmlQK1i5DN23Lpb6dFnQ4gcVxLYj rLuN7PtdP6bDPA2cELmKgZFNsLMG/r/6P6VWVFhYcjjxr9zgT5nAAd/ksj4nWTKt+cNZ G6tCzFw9Qf8/hXnONRIx5cLK3jo6f69xyz8CHTGy3R7Dn3gyZtXK+a20Oxl2NkV3JhwR upKQ== X-Gm-Message-State: ALKqPweIo+eWTgJpmp5kZpjjFAYRhxX4yuLIFOpOR8vnC9IAwOyd5GL8 eZnQJCl3hAC3bcTzvvROTHy/EWo+MZs= X-Google-Smtp-Source: AB8JxZpU+fU7S0rxZFDvoS15q37AlZaK81FrxMCrL9CzaCnAW5qdCKuXvjHfUc/sRL3M4K89VVGwQw== X-Received: by 2002:a62:6c87:: with SMTP id h129-v6mr1657623pfc.179.1526101381059; Fri, 11 May 2018 22:03:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 11 May 2018 22:02:48 -0700 Message-Id: <20180512050250.12774-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180512050250.12774-1-richard.henderson@linaro.org> References: <20180512050250.12774-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH 7/9] target/m68k: Convert to TranslatorOps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- target/m68k/translate.c | 176 ++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 90 deletions(-) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 01d3265437..0ab9ab1148 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -6059,113 +6059,109 @@ static void disas_m68k_insn(CPUM68KState * env, D= isasContext *s) do_release(s); } =20 -/* generate intermediate code for basic block 'tb'. */ -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) +static void m68k_tr_init_disas_context(DisasContextBase *dcbase, CPUState = *cpu) { - CPUM68KState *env =3D cs->env_ptr; - DisasContext dc1, *dc =3D &dc1; - target_ulong pc_start; - int pc_offset; - int num_insns; - int max_insns; - - /* generate intermediate code */ - pc_start =3D tb->pc; - - dc->base.tb =3D tb; + DisasContext *dc =3D container_of(dcbase, DisasContext, base); + CPUM68KState *env =3D cpu->env_ptr; =20 dc->env =3D env; - dc->base.is_jmp =3D DISAS_NEXT; - dc->pc =3D pc_start; + dc->pc =3D dc->base.pc_first; dc->cc_op =3D CC_OP_DYNAMIC; dc->cc_op_synced =3D 1; - dc->base.singlestep_enabled =3D cs->singlestep_enabled; dc->done_mac =3D 0; dc->writeback_mask =3D 0; - num_insns =3D 0; - max_insns =3D tb_cflags(tb) & CF_COUNT_MASK; - if (max_insns =3D=3D 0) { - max_insns =3D CF_COUNT_MASK; - } - if (max_insns > TCG_MAX_INSNS) { - max_insns =3D TCG_MAX_INSNS; - } - init_release_array(dc); +} =20 - gen_tb_start(tb); - do { - pc_offset =3D dc->pc - pc_start; - tcg_gen_insn_start(dc->pc, dc->cc_op); - num_insns++; +static void m68k_tr_tb_start(DisasContextBase *dcbase, CPUState *cpu) +{ +} =20 - if (unlikely(cpu_breakpoint_test(cs, dc->pc, BP_ANY))) { - gen_exception(dc, dc->pc, EXCP_DEBUG); - /* The address covered by the breakpoint must be included in - [tb->pc, tb->pc + tb->size) in order to for it to be - properly cleared -- thus we increment the PC here so that - the logic setting tb->size below does the right thing. */ - dc->pc +=3D 2; - break; - } +static void m68k_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) +{ + DisasContext *dc =3D container_of(dcbase, DisasContext, base); + tcg_gen_insn_start(dc->base.pc_next, dc->cc_op); +} =20 - if (num_insns =3D=3D max_insns && (tb_cflags(tb) & CF_LAST_IO)) { - gen_io_start(); - } +static bool m68k_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *c= pu, + const CPUBreakpoint *bp) +{ + DisasContext *dc =3D container_of(dcbase, DisasContext, base); =20 - dc->base.pc_next =3D dc->pc; - disas_m68k_insn(env, dc); - } while (!dc->base.is_jmp && !tcg_op_buf_full() && - !cs->singlestep_enabled && - !singlestep && - (pc_offset) < (TARGET_PAGE_SIZE - 32) && - num_insns < max_insns); + gen_exception(dc, dc->base.pc_next, EXCP_DEBUG); + /* The address covered by the breakpoint must be included in + [tb->pc, tb->pc + tb->size) in order to for it to be + properly cleared -- thus we increment the PC here so that + the logic setting tb->size below does the right thing. */ + dc->base.pc_next +=3D 2; =20 - if (tb_cflags(tb) & CF_LAST_IO) - gen_io_end(); - if (unlikely(cs->singlestep_enabled)) { - /* Make sure the pc is updated, and raise a debug exception. */ - if (!dc->base.is_jmp) { - update_cc_op(dc); - tcg_gen_movi_i32(QREG_PC, dc->pc); - } + return true; +} + +static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) +{ + DisasContext *dc =3D container_of(dcbase, DisasContext, base); + + disas_m68k_insn(cpu->env_ptr, dc); + dc->base.pc_next =3D dc->pc; + + if (dc->base.is_jmp =3D=3D DISAS_NEXT + && dc->pc - dc->base.pc_first >=3D TARGET_PAGE_SIZE - 32) { + dc->base.is_jmp =3D DISAS_TOO_MANY; + } +} + +static void m68k_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) +{ + DisasContext *dc =3D container_of(dcbase, DisasContext, base); + + if (dc->base.is_jmp =3D=3D DISAS_NORETURN) { + return; + } + if (dc->base.singlestep_enabled) { gen_helper_raise_exception(cpu_env, tcg_const_i32(EXCP_DEBUG)); - } else { - switch(dc->base.is_jmp) { - case DISAS_NEXT: - update_cc_op(dc); - gen_jmp_tb(dc, 0, dc->pc); - break; - case DISAS_JUMP: - /* We updated CC_OP and PC in gen_jmp/gen_jmp_im. */ - tcg_gen_lookup_and_goto_ptr(); - break; - default: - case DISAS_EXIT: - /* We updated CC_OP and PC in gen_exit_tb, but also modified - other state that may require returning to the main loop. */ - tcg_gen_exit_tb(0); - break; - case DISAS_NORETURN: - /* nothing more to generate */ - break; - } + return; } - gen_tb_end(tb, num_insns); =20 -#ifdef DEBUG_DISAS - if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) - && qemu_log_in_addr_range(pc_start)) { - qemu_log_lock(); - qemu_log("----------------\n"); - qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start); - qemu_log("\n"); - qemu_log_unlock(); + switch (dc->base.is_jmp) { + case DISAS_TOO_MANY: + update_cc_op(dc); + gen_jmp_tb(dc, 0, dc->pc); + break; + case DISAS_JUMP: + /* We updated CC_OP and PC in gen_jmp/gen_jmp_im. */ + tcg_gen_lookup_and_goto_ptr(); + break; + case DISAS_EXIT: + /* We updated CC_OP and PC in gen_exit_tb, but also modified + other state that may require returning to the main loop. */ + tcg_gen_exit_tb(0); + break; + default: + g_assert_not_reached(); } -#endif - tb->size =3D dc->pc - pc_start; - tb->icount =3D num_insns; +} + +static void m68k_tr_disas_log(const DisasContextBase *dcbase, CPUState *cp= u) +{ + qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); + log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); +} + +static const TranslatorOps m68k_tr_ops =3D { + .init_disas_context =3D m68k_tr_init_disas_context, + .tb_start =3D m68k_tr_tb_start, + .insn_start =3D m68k_tr_insn_start, + .breakpoint_check =3D m68k_tr_breakpoint_check, + .translate_insn =3D m68k_tr_translate_insn, + .tb_stop =3D m68k_tr_tb_stop, + .disas_log =3D m68k_tr_disas_log, +}; + +void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) +{ + DisasContext dc; + translator_loop(&m68k_tr_ops, &dc.base, cpu, tb); } =20 static double floatx80_to_double(CPUM68KState *env, uint16_t high, uint64_= t low) --=20 2.17.0