From patchwork Wed May 4 20:11:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9018531 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2A93BBF29F for ; Wed, 4 May 2016 20:23:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71C05203E3 for ; Wed, 4 May 2016 20:23:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E1892020F for ; Wed, 4 May 2016 20:23:06 +0000 (UTC) Received: from localhost ([::1]:50068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay3K2-0001uU-ME for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 May 2016 16:23:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay3Bz-0001uO-3E for qemu-devel@nongnu.org; Wed, 04 May 2016 16:14:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ay3Bn-0003bw-5b for qemu-devel@nongnu.org; Wed, 04 May 2016 16:14:37 -0400 Received: from smtp1-g21.free.fr ([212.27.42.1]:29710) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay3Bm-0003Ux-QI for qemu-devel@nongnu.org; Wed, 04 May 2016 16:14:31 -0400 Received: from Quad.localdomain (unknown [IPv6:2a01:e34:eeee:5240:12c3:7bff:fe6b:9a76]) by smtp1-g21.free.fr (Postfix) with ESMTPS id EB63CB00509; Wed, 4 May 2016 20:07:52 +0200 (CEST) From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 4 May 2016 22:11:55 +0200 Message-Id: <1462392752-17703-16-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1462392752-17703-1-git-send-email-laurent@vivier.eu> References: <1462392752-17703-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.1 Subject: [Qemu-devel] [PATCH 15/52] target-m68k: don't update cc_dest in helpers 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 , rth@twiddle.net, schwab@linux-m68k.org, agraf@suse.de, gerg@uclinux.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson --- target-m68k/cpu.h | 1 - target-m68k/helper.c | 28 ++++++++++++++-------------- target-m68k/helper.h | 2 +- target-m68k/translate.c | 4 ++-- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h index 0e4ff08..d3acd33 100644 --- a/target-m68k/cpu.h +++ b/target-m68k/cpu.h @@ -129,7 +129,6 @@ int cpu_m68k_exec(CPUState *cpu); is returned if the signal was handled by the virtual CPU. */ int cpu_m68k_signal_handler(int host_signum, void *pinfo, void *puc); -void cpu_m68k_flush_flags(CPUM68KState *, int); enum { CC_OP_DYNAMIC, /* Use env->cc_op */ diff --git a/target-m68k/helper.c b/target-m68k/helper.c index ec37c9d..c3e4380 100644 --- a/target-m68k/helper.c +++ b/target-m68k/helper.c @@ -131,9 +131,8 @@ void m68k_cpu_init_gdb(M68kCPU *cpu) /* TODO: Add [E]MAC registers. */ } -void cpu_m68k_flush_flags(CPUM68KState *env, int cc_op) +static uint32_t cpu_m68k_flush_flags(CPUM68KState *env, int op) { - M68kCPU *cpu = m68k_env_get_cpu(env); int flags; uint32_t src; uint32_t dest; @@ -201,7 +200,7 @@ void cpu_m68k_flush_flags(CPUM68KState *env, int cc_op) flags = 0; src = env->cc_src; dest = env->cc_dest; - switch (cc_op) { + switch (op) { case CC_OP_FLAGS: flags = dest; break; @@ -267,10 +266,9 @@ set_x: SET_FLAGS_SHIFT(int32_t); break; default: - cpu_abort(CPU(cpu), "Bad CC_OP %d", cc_op); + g_assert_not_reached(); } - env->cc_op = CC_OP_FLAGS; - env->cc_dest = flags; + return flags; } void HELPER(movec)(CPUM68KState *env, uint32_t reg, uint32_t val) @@ -421,20 +419,21 @@ uint32_t HELPER(subx_cc)(CPUM68KState *env, uint32_t op1, uint32_t op2) { uint32_t res; uint32_t old_flags; + int op; old_flags = env->cc_dest; if (env->cc_x) { env->cc_x = (op1 <= op2); - env->cc_op = CC_OP_SUBX; + op = CC_OP_SUBX; res = op1 - (op2 + 1); } else { env->cc_x = (op1 < op2); - env->cc_op = CC_OP_SUB; + op = CC_OP_SUB; res = op1 - op2; } env->cc_dest = res; env->cc_src = op2; - cpu_m68k_flush_flags(env, env->cc_op); + env->cc_dest = cpu_m68k_flush_flags(env, op); /* !Z is sticky. */ env->cc_dest &= (old_flags | ~CCF_Z); return res; @@ -444,20 +443,21 @@ uint32_t HELPER(addx_cc)(CPUM68KState *env, uint32_t op1, uint32_t op2) { uint32_t res; uint32_t old_flags; + int op; old_flags = env->cc_dest; if (env->cc_x) { res = op1 + op2 + 1; env->cc_x = (res <= op2); - env->cc_op = CC_OP_ADDX; + op = CC_OP_ADDX; } else { res = op1 + op2; env->cc_x = (res < op2); - env->cc_op = CC_OP_ADD; + op = CC_OP_ADD; } env->cc_dest = res; env->cc_src = op2; - cpu_m68k_flush_flags(env, env->cc_op); + env->cc_dest = cpu_m68k_flush_flags(env, op); /* !Z is sticky. */ env->cc_dest &= (old_flags | ~CCF_Z); return res; @@ -789,9 +789,9 @@ void HELPER(mac_set_flags)(CPUM68KState *env, uint32_t acc) } } -void HELPER(flush_flags)(CPUM68KState *env, uint32_t cc_op) +uint32_t HELPER(flush_flags)(CPUM68KState *env, uint32_t op) { - cpu_m68k_flush_flags(env, cc_op); + return cpu_m68k_flush_flags(env, op); } uint32_t HELPER(get_macf)(CPUM68KState *env, uint64_t val) diff --git a/target-m68k/helper.h b/target-m68k/helper.h index c24ace5..0f5a7cf 100644 --- a/target-m68k/helper.h +++ b/target-m68k/helper.h @@ -45,5 +45,5 @@ DEF_HELPER_3(set_mac_extf, void, env, i32, i32) DEF_HELPER_3(set_mac_exts, void, env, i32, i32) DEF_HELPER_3(set_mac_extu, void, env, i32, i32) -DEF_HELPER_2(flush_flags, void, env, i32) +DEF_HELPER_2(flush_flags, i32, env, i32) DEF_HELPER_2(raise_exception, void, env, i32) diff --git a/target-m68k/translate.c b/target-m68k/translate.c index cddc2b5..16f09ca 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -422,7 +422,7 @@ static inline void gen_flush_flags(DisasContext *s) if (s->cc_op == CC_OP_FLAGS) return; gen_flush_cc_op(s); - gen_helper_flush_flags(cpu_env, QREG_CC_OP); + gen_helper_flush_flags(QREG_CC_DEST, cpu_env, QREG_CC_OP); s->cc_op = CC_OP_FLAGS; } @@ -716,6 +716,7 @@ static void gen_jmpcc(DisasContext *s, int cond, TCGLabel *l1) /* TODO: Optimize compare/branch pairs rather than always flushing flag state to CC_OP_FLAGS. */ gen_flush_flags(s); + gen_flush_cc_op(s); switch (cond) { case 0: /* T */ tcg_gen_br(l1); @@ -1669,7 +1670,6 @@ DISAS_INSN(branch) /* bsr */ gen_push(s, tcg_const_i32(s->pc)); } - gen_flush_cc_op(s); if (op > 1) { /* Bcc */ l1 = gen_new_label();