From patchwork Tue Oct 25 19:03:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9395253 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 58BC560233 for ; Tue, 25 Oct 2016 19:20:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 014EE28C65 for ; Tue, 25 Oct 2016 19:14:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9BCF29736; Tue, 25 Oct 2016 19:14:10 +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 4EA2028C65 for ; Tue, 25 Oct 2016 19:14:10 +0000 (UTC) Received: from localhost ([::1]:57664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz7An-0005b3-FM for patchwork-qemu-devel@patchwork.kernel.org; Tue, 25 Oct 2016 15:14:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz714-0006EI-Ov for qemu-devel@nongnu.org; Tue, 25 Oct 2016 15:04:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bz711-00084p-Li for qemu-devel@nongnu.org; Tue, 25 Oct 2016 15:04:06 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:57034) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bz711-00083I-AV for qemu-devel@nongnu.org; Tue, 25 Oct 2016 15:04:03 -0400 Received: from Quad.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0LqUEr-1ccJaA402r-00e6Vq; Tue, 25 Oct 2016 21:03:44 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 25 Oct 2016 21:03:19 +0200 Message-Id: <1477422199-11208-24-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477422199-11208-1-git-send-email-laurent@vivier.eu> References: <1477422199-11208-1-git-send-email-laurent@vivier.eu> X-Provags-ID: V03:K0:sR8U//ZVTeAJMfCcwBwncqNORqMAmQBxPtLuAjvNb2v7+k9Iw06 XLBW7qz/GyzRHSdVgP7P09CzEWYfNJ7YPmLTHzMbGkE4Suue9CTqC1OZzY4MDkfVFdk1Gvv Xq+/1ou6NQHibBlY0Jj4lr07BCxc4LSNzx/gUBiRQsSjw4Sk7+OgMGvUL9op/pkXEqwdpz7 BQk/TsEG7DtXgQXwEnpxg== X-UI-Out-Filterresults: notjunk:1; V01:K0:l0Hf/aZMSWI=:HNoGGvc+swnR4a2pqIkvWy 7UySF323EB6nxV0neElAcuIRPkMO8EXl8tWluc1OpuZc7X8xBnyYOzxdIvLNO0ArvuTfBdrgT ZOyT+RAmPEeWKCtlK+tSfRnDyk85RnyPDiyJLssLEdncEgQYPYeCiRIDvcBh5j8u+0svtANeY iZQYzYpEsfJUAVIqTlsqgFeNOct3nZa1a4gd8/+5vAAq08wF5zzvWKLAsverm3xO4sf/RKnMv Tkg9BQzoEBnZISW0EEEMMroGyKqPcNg/9vl6b79nxLtMnkm7MAVrWjieFH/q1dRLgKhwl6lF1 pxzWudQZJ8t16ODtP/GnZml6aa8fFn8Yjn9GQi7Hr42maFR1rBwUP+2rx7wYMkStibFqRjeCG KdF2+nAPSkwDwQF6+aS9oem6SAdyZzNl/QhT/+3ogZQuUuVuI3nTGjHlU2iQfUezJaVPdhylO 9zcdrZ70OLyWRybrQoM9heAG3vjuhQIsbCOysH8iIuyKgl24E7Iv6+s9AsOwZDZg2WJMXLEo0 WnFx+f2W0QEAl0B22WhWIXONz8Ywfe2MjrIZOMRP78L8pM8lBoFlDo6Mygz1M7VJ23YU5JrDw DlZ6eUQj3NUmlCMPfCHiT61x12MsJ2+AeusLHmFGHAvOyHuP77TPTzfWvFfBeZ9KANfXTZ4sP 8jVZHi64Ed1dt9A5XMRFYkyH9JdrCIq8HvsLCJcWjn5plwmvw7BLJ1MziDsF2nXX2BHY= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.13 Subject: [Qemu-devel] [PULL 23/23] target-m68k: Optimize gen_flush_flags 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 From: Richard Henderson Signed-off-by: Richard Henderson Signed-off-by: Laurent Vivier --- target-m68k/translate.c | 56 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/target-m68k/translate.c b/target-m68k/translate.c index 52aa800..6c6173a 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -458,18 +458,66 @@ static TCGv gen_lea_indexed(CPUM68KState *env, DisasContext *s, TCGv base) static void gen_flush_flags(DisasContext *s) { - TCGv tmp; + TCGv t0, t1; switch (s->cc_op) { case CC_OP_FLAGS: return; + + case CC_OP_ADD: + tcg_gen_mov_i32(QREG_CC_C, QREG_CC_X); + tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N); + /* Compute signed overflow for addition. */ + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + tcg_gen_sub_i32(t0, QREG_CC_N, QREG_CC_V); + tcg_gen_xor_i32(t1, QREG_CC_N, QREG_CC_V); + tcg_gen_xor_i32(QREG_CC_V, QREG_CC_V, t0); + tcg_temp_free(t0); + tcg_gen_andc_i32(QREG_CC_V, t1, QREG_CC_V); + tcg_temp_free(t1); + break; + + case CC_OP_SUB: + tcg_gen_mov_i32(QREG_CC_C, QREG_CC_X); + tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N); + /* Compute signed overflow for subtraction. */ + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + tcg_gen_add_i32(t0, QREG_CC_N, QREG_CC_V); + tcg_gen_xor_i32(t1, QREG_CC_N, QREG_CC_V); + tcg_gen_xor_i32(QREG_CC_V, QREG_CC_V, t0); + tcg_temp_free(t0); + tcg_gen_and_i32(QREG_CC_V, QREG_CC_V, t1); + tcg_temp_free(t1); + break; + + case CC_OP_CMP: + tcg_gen_setcond_i32(TCG_COND_LTU, QREG_CC_C, QREG_CC_N, QREG_CC_V); + tcg_gen_sub_i32(QREG_CC_Z, QREG_CC_N, QREG_CC_V); + /* Compute signed overflow for subtraction. */ + t0 = tcg_temp_new(); + tcg_gen_xor_i32(t0, QREG_CC_Z, QREG_CC_N); + tcg_gen_xor_i32(QREG_CC_V, QREG_CC_V, QREG_CC_N); + tcg_gen_and_i32(QREG_CC_V, QREG_CC_V, t0); + tcg_temp_free(t0); + tcg_gen_mov_i32(QREG_CC_N, QREG_CC_Z); + break; + + case CC_OP_LOGIC: + tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N); + tcg_gen_movi_i32(QREG_CC_C, 0); + tcg_gen_movi_i32(QREG_CC_V, 0); + break; + case CC_OP_DYNAMIC: gen_helper_flush_flags(cpu_env, QREG_CC_OP); break; + default: - tmp = tcg_const_i32(s->cc_op); - gen_helper_flush_flags(cpu_env, tmp); - tcg_temp_free(tmp); + t0 = tcg_const_i32(s->cc_op); + gen_helper_flush_flags(cpu_env, t0); + tcg_temp_free(t0); break; }