From patchwork Mon Feb 11 18:19:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 10806609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8C8E922 for ; Mon, 11 Feb 2019 18:23:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8E9F2852C for ; Mon, 11 Feb 2019 18:23:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7458285A3; Mon, 11 Feb 2019 18:23:58 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EEEDE2852C for ; Mon, 11 Feb 2019 18:23:57 +0000 (UTC) Received: from localhost ([127.0.0.1]:54304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGFI-0006oL-QX for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Feb 2019 13:23:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtGCM-0004uW-9g for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtGCI-0004XJ-SW for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:54 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:54998) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtGCI-00047G-Kt for qemu-devel@nongnu.org; Mon, 11 Feb 2019 13:20:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=QJeX0cli1IUHWgWpFB/XHIDBbWil5RL48reG8jGdENo=; b=N9/21EyobERoiQlk/jemB3UehR A9REshPLqpRHdKH2rjEAS8lco5O1I8DGdNvkNNW55F6u9r/BMMXtxLBTR/p9YER91pvtV/jyIrMfq GKkSmG7QTaOESKQfDfQVBr9U6KrPqbhvlVnweQJ/CRVv49N9uGO2HwN2/NzBUV3crynI=; Received: from hsi-kbw-109-193-150-175.hsi7.kabel-badenwuerttemberg.de ([109.193.150.175] helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1gtGBr-0007Z5-Tl; Mon, 11 Feb 2019 19:20:24 +0100 From: Sven Schnelle To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 19:19:04 +0100 Message-Id: <20190211181907.2219-3-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211181907.2219-2-svens@stackframe.org> References: <20190211181907.2219-2-svens@stackframe.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH 2/5] target/hppa: fix ' List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: deller@gmx.de, Sven Schnelle , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP These condition include the signed overflow bit. See Page 5-3 of the Parisc 1.1 Architecture Reference manual for details. Signed-off-by: Sven Schnelle --- target/hppa/translate.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 51bfd9849d..0e8cc8117a 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -404,6 +404,11 @@ static DisasCond cond_make_n(void) }; } +static bool cond_need_sv(int c) +{ + return c == 2 || c == 3 || c == 6; +} + static DisasCond cond_make_0(TCGCond c, TCGv_reg a0) { DisasCond r = { .c = c, .a1 = NULL, .a1_is_0 = true }; @@ -910,11 +915,17 @@ static DisasCond do_cond(unsigned cf, TCGv_reg res, case 1: /* = / <> (Z / !Z) */ cond = cond_make_0(TCG_COND_EQ, res); break; - case 2: /* < / >= (N / !N) */ - cond = cond_make_0(TCG_COND_LT, res); + case 2: /* < / >= (N ^ V / !(N ^ V)) */ + tmp = tcg_temp_new(); + tcg_gen_xor_reg(tmp, res, sv); + cond = cond_make_0(TCG_COND_LT, tmp); + tcg_temp_free(tmp); break; case 3: /* <= / > (N | Z / !N & !Z) */ - cond = cond_make_0(TCG_COND_LE, res); + tmp = tcg_temp_new(); + tcg_gen_xor_reg(tmp, res, sv); + cond = cond_make_0(TCG_COND_LE, tmp); + tcg_temp_free(tmp); break; case 4: /* NUV / UV (!C / C) */ cond = cond_make_0(TCG_COND_EQ, cb_msb); @@ -1159,7 +1170,7 @@ static DisasJumpType do_add(DisasContext *ctx, unsigned rt, TCGv_reg in1, /* Compute signed overflow if required. */ sv = NULL; - if (is_tsv || c == 6) { + if (is_tsv || cond_need_sv(c)) { sv = do_add_sv(ctx, dest, in1, in2); if (is_tsv) { /* ??? Need to include overflow from shift. */ @@ -1223,7 +1234,7 @@ static DisasJumpType do_sub(DisasContext *ctx, unsigned rt, TCGv_reg in1, /* Compute signed overflow if required. */ sv = NULL; - if (is_tsv || c == 6) { + if (is_tsv || cond_need_sv(c)) { sv = do_sub_sv(ctx, dest, in1, in2); if (is_tsv) { gen_helper_tsv(cpu_env, sv); @@ -1263,13 +1274,14 @@ static DisasJumpType do_cmpclr(DisasContext *ctx, unsigned rt, TCGv_reg in1, { TCGv_reg dest, sv; DisasCond cond; + int c = cf >> 1; dest = tcg_temp_new(); tcg_gen_sub_reg(dest, in1, in2); /* Compute signed overflow if required. */ sv = NULL; - if ((cf >> 1) == 6) { + if (cond_need_sv(c)) { sv = do_sub_sv(ctx, dest, in1, in2); } @@ -2808,7 +2820,7 @@ static DisasJumpType trans_ds(DisasContext *ctx, uint32_t insn, /* Install the new nullification. */ if (cf) { TCGv_reg sv = NULL; - if (cf >> 1 == 6) { + if (cond_need_sv(cf >> 1)) { /* ??? The lshift is supposed to contribute to overflow. */ sv = do_add_sv(ctx, dest, add1, add2); } @@ -3369,7 +3381,7 @@ static DisasJumpType trans_cmpb(DisasContext *ctx, uint32_t insn, tcg_gen_sub_reg(dest, in1, in2); sv = NULL; - if (c == 6) { + if (cond_need_sv(c)) { sv = do_sub_sv(ctx, dest, in1, in2); } @@ -3409,6 +3421,8 @@ static DisasJumpType trans_addb(DisasContext *ctx, uint32_t insn, tcg_gen_movi_reg(cb_msb, 0); tcg_gen_add2_reg(dest, cb_msb, in1, cb_msb, in2, cb_msb); break; + case 2: + case 3: case 6: tcg_gen_add_reg(dest, in1, in2); sv = do_add_sv(ctx, dest, in1, in2);