From patchwork Tue Oct 25 14:50:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9394687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B0C5B6077F for ; Tue, 25 Oct 2016 15:03:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A18352960C for ; Tue, 25 Oct 2016 15:03:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94D4B29621; Tue, 25 Oct 2016 15:03:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id EB0AB2960C for ; Tue, 25 Oct 2016 15:03:46 +0000 (UTC) Received: from localhost ([::1]:55250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz3GU-0002Gu-07 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 25 Oct 2016 11:03:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz33s-0008VN-Hj for qemu-devel@nongnu.org; Tue, 25 Oct 2016 10:50:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bz33o-00060M-8o for qemu-devel@nongnu.org; Tue, 25 Oct 2016 10:50:44 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:50235) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bz33n-0005yV-SW for qemu-devel@nongnu.org; Tue, 25 Oct 2016 10:50:40 -0400 Received: from Quad.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue003) with ESMTPSA (Nemesis) id 0LwmRY-1d0s2V1CBc-016Mgb; Tue, 25 Oct 2016 16:50:35 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 25 Oct 2016 16:50:12 +0200 Message-Id: <1477407021-30755-15-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477407021-30755-1-git-send-email-laurent@vivier.eu> References: <1477407021-30755-1-git-send-email-laurent@vivier.eu> X-Provags-ID: V03:K0:q/VdjNLcTfSa6gPkHx/CoFHfCzJxqKQumWyfc6W3ZVJYHx1YDPw 8HhHmW7df389Gs8PKBbC5aqiGzJ5uO6jXePWVG0nxuN4Xz0hqIxVkpKZOG/L5uBDM0/ehTM Tq90uJe+m2BZU/PMLCXPKHGhzCIThHByrXRUIhHOMEiWPV7vxmlIKr2cbyMcKKkgRGJwCmF KUZ9+eVKr64WuC6xJmkJA== X-UI-Out-Filterresults: notjunk:1; V01:K0:EoR5Lp5oPSg=:S0ES4q9ByQGdHmy/syDOIE 0advNcytf/6w7o0maP5OJowON1VzcrJXwaphyRGfbTq0sNtnGWvm1xIb4DKTn3qKQBChcPweL K6773U1yQGfmv17SL1I9ZybSxJh9mAiN+IfRn6bbhyL7ZQUxGQSHvFUCQBzN8Epw/70I4RMn5 pHaqquRA8Kz5rTWbMsnGa9U9iGBl2GrW1N3EBHQxokxlLQMPz/WsGaO4YF7C8lWKHHWeDZyui 3Laujv0N0s5K8jBcbcyQn/gs3fi8pkkX4Uvk/VbA+bSCFflSkgJpbA7GKx/ImubSTzIiLsfLK YhwiqUKgmR5zWX37B3KGdaYavNdz8QXQqEDf3B5Udfe0CxepxCD3GYr6FFI84tDjPVzVFjzu0 HefSuypnuT+0HBYiXurxX8CO6wi09SrFbM6dhn6taQgWYYDM+eUx3itrQmbD5UQ9p8iTT87S0 d4kSmh1LqpnROgWqzXkqkwg7RxZJaCKVCD59f0aikulSV4ehYGYSzQFwKK8yqCg50T6vDHV1W e2ojXDzBFaes/+0CdWsK4kpo25imt6OJ9vU9oYnPL138OZEPWOrfLbXmI1/J9EHL++IGczdbS 94dDmcLZajpSJYcsdaCdUQ2d7/kJhmnlbYmNXdCHhnKdPQtEsE0Yz2//OguCMK48N9XPz8WRw Om6jPsTOta1p44yUK9aTKwdIexax8iHshiwAa2+EHUQtJfIrBjsMSBzcZ2yFI4LAdXPU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.133 Subject: [Qemu-devel] [PATCH 14/23] 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 , gerg@uclinux.org, schwab@linux-m68k.org, agraf@suse.de, Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 f055ef6..72a939e 100644 --- a/target-m68k/cpu.h +++ b/target-m68k/cpu.h @@ -158,7 +158,6 @@ M68kCPU *cpu_m68k_init(const char *cpu_model); 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); /* Instead of computing the condition codes after each m68k instruction, diff --git a/target-m68k/helper.c b/target-m68k/helper.c index 92d1ded..0a1ff11 100644 --- a/target-m68k/helper.c +++ b/target-m68k/helper.c @@ -132,9 +132,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; @@ -202,7 +201,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; @@ -268,10 +267,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) @@ -422,20 +420,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; @@ -445,20 +444,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; @@ -790,9 +790,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 37faefe..3db7918 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -424,7 +424,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; } @@ -719,6 +719,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); @@ -1673,7 +1674,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();