From patchwork Tue Nov 7 03:02:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 741794 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1419687wrr; Mon, 6 Nov 2023 19:07:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGg7WyXBeoHtZ0L4npt4OczFwFLZLuq9D/uj8yvikOpJRA+EozKgn7211nWm+w0rHNqGV+w X-Received: by 2002:a05:6214:21e3:b0:66d:2eb6:f3f6 with SMTP id p3-20020a05621421e300b0066d2eb6f3f6mr32034651qvj.32.1699326426731; Mon, 06 Nov 2023 19:07:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699326426; cv=none; d=google.com; s=arc-20160816; b=xwkXt/Ro1DG/kRZ2Cks9AjA1i+Jlf3HsxaoOXBPMIoc4IICHn4OfzBiJl2LKDo4Ovf cZSukrHu0AubAcZmpvHwjWnQTsmUrjswOUJHSRGtSqgsiLyFlbi0bBlVzNBysFgkiKuB GPH5LNCYNawuTU3cSQLSSya+yX4JPSKc5B5vBlmGyNdXZQWkWipCU+2tP/ZMLiwjF6Yz TCvcvAzdCkYAi8WDg+JiqOrrsfqa+fIKaiotK9U4VTRFmdDCvcXS4jcfVtdLeydmvoUY 7K+Vq+3RfZqc9KVk0O/uSpE/ziGFrIYzwr1WMTADe4WMrKG2tiAyNhuxJUdl9HurHIIi M8Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=TPY1sdpy0MpwadGHKWVBaHzMfJjgShg6fGAA7ikVCVc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=E9c0lzBojWvH27Jycb34BoHVUvFbQcoFbxchgCWcLRfLrg43xrMh2oGwYBrjdjp0Qd /7vHX3lJ9lMZR2OT8JeUSjiHTk29vNTMLBeKIrHgFu7XHzE/IurgYuG7KBt4UDilgdPR +UGVpic6umhrwMcxAGmrsnt8Otd/Mnkfdhzg2oAvJhh885bfhK1CSdcANOMOU7M1npo0 scp91RgMa3piwhpmIzbwfhG3+P/Dt0lUQeMhoVnyNKNcc3iYt9Ny5MZDqO/44xqN+/so mu9yw3nIg5UlRcNv6SbVxBG6cVehjMNFr2h4kzJxKcNI6BCR5zJZFWens9FX1Mj1c/2W zkNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GdLLetd0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t6-20020a05620a0b0600b00778b8c8d2fcsi5907908qkg.716.2023.11.06.19.07.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Nov 2023 19:07:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GdLLetd0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0COM-0006cq-4L; Mon, 06 Nov 2023 22:04:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0CO6-0006Ma-Ap for qemu-devel@nongnu.org; Mon, 06 Nov 2023 22:04:22 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0CO4-0000eZ-Bi for qemu-devel@nongnu.org; Mon, 06 Nov 2023 22:04:22 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1cc5b6d6228so34173875ad.2 for ; Mon, 06 Nov 2023 19:04:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699326259; x=1699931059; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=TPY1sdpy0MpwadGHKWVBaHzMfJjgShg6fGAA7ikVCVc=; b=GdLLetd0i8Pd6k1PQH3dKA8cYqidJS5dWJvdGvZd1BhFodOBmFRWQ5SvwMwzuKqk96 7JJyv2GPKiREkwJZ7FDxv7XnlRMkKYQtHQc6w9RABsfM2lFfP5jdf8XWVtMxl1SVAuw2 3uQPk2wg8MuAIZOaAipjFpbQvWTV6sfcYQrGuettrwB4OMZdM0axinD7id9XcQJeZwhy VU0F5S6x6P0IFGm6evhjY5Xv2MavtxnUyKcGucjQtp8ACXcETZdIiFadVEwVqBPMdZHa gbZVwiA8lJ6lPj7Nf6GF3i83AZ+7uhlq7yFkbFE2kBRR28xnV1F5JA1mI8zI28VxKzca utSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699326259; x=1699931059; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TPY1sdpy0MpwadGHKWVBaHzMfJjgShg6fGAA7ikVCVc=; b=IFmJZ1RZzZcx07iqFtr1nT+M2kR+/G78SMEv20e3S/dJwwmqEdb4A1jnfvS+KXGY2U 1BeSiLC+l+35aBZl1c+B6FGK6Hwl6Mda8qYX8B8M3djMQGASBKgCq/MYxlBeEbOm+e4t c91yofVP2LV1SpMddAIqyjEAPi1OAX9vV93ZSnm8wjpr3VGvaYYXR4m9/rAfV7RF4QK7 5ZR3w6L9h4lMUK3zcGtkvY06mC4twD26bd2uPzXjTzzY1ApR8urE1vlDAKliZ4z2+N7W JiDr0ejstitmBRdF9gIPTJ1PwuThNUviHJPDhI+jFr6G8s0ZkHxg8IWtuUQIF0E9R5VJ c67A== X-Gm-Message-State: AOJu0YwOavj1IiYeiN6+3+vqJ6He3SSSRamCntQH5GuGlnIqhwLo32L9 vTET0Mtqe951lLbDwJrVgjOf64JLfM71ihd7Kx4= X-Received: by 2002:a17:903:10a:b0:1cc:6101:2086 with SMTP id y10-20020a170903010a00b001cc61012086mr14286566plc.11.1699326258762; Mon, 06 Nov 2023 19:04:18 -0800 (PST) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id u9-20020a17090282c900b001c72d5e16acsm6518012plz.57.2023.11.06.19.04.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 19:04:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 13/85] target/hppa: Fix trans_ds for hppa64 Date: Mon, 6 Nov 2023 19:02:55 -0800 Message-Id: <20231107030407.8979-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231107030407.8979-1-richard.henderson@linaro.org> References: <20231107030407.8979-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This instruction always uses the input carry from bit 32, but produces all 16 output carry bits. Signed-off-by: Richard Henderson --- target/hppa/translate.c | 48 +++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index d6ccce020a..8ba95ae320 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -803,6 +803,12 @@ static bool cond_need_cb(int c) return c == 4 || c == 5; } +/* Need extensions from TCGv_i32 to TCGv_reg. */ +static bool cond_need_ext(DisasContext *ctx, bool d) +{ + return TARGET_REGISTER_BITS == 64 && !d; +} + /* * Compute conditional for arithmetic. See Page 5-3, Table 5-1, of * the Parisc 1.1 Architecture Reference Manual for details. @@ -1040,6 +1046,22 @@ static DisasCond do_unit_cond(unsigned cf, TCGv_reg res, return cond; } +static TCGv_reg get_carry(DisasContext *ctx, bool d, + TCGv_reg cb, TCGv_reg cb_msb) +{ + if (cond_need_ext(ctx, d)) { + TCGv_reg t = tcg_temp_new(); + tcg_gen_extract_reg(t, cb, 32, 1); + return t; + } + return cb_msb; +} + +static TCGv_reg get_psw_carry(DisasContext *ctx, bool d) +{ + return get_carry(ctx, d, cpu_psw_cb, cpu_psw_cb_msb); +} + /* Compute signed overflow for addition. */ static TCGv_reg do_add_sv(DisasContext *ctx, TCGv_reg res, TCGv_reg in1, TCGv_reg in2) @@ -2712,6 +2734,7 @@ static bool trans_dcor_i(DisasContext *ctx, arg_rr_cf *a) static bool trans_ds(DisasContext *ctx, arg_rrr_cf *a) { TCGv_reg dest, add1, add2, addc, zero, in1, in2; + TCGv_reg cout; nullify_over(ctx); @@ -2726,18 +2749,20 @@ static bool trans_ds(DisasContext *ctx, arg_rrr_cf *a) /* Form R1 << 1 | PSW[CB]{8}. */ tcg_gen_add_reg(add1, in1, in1); - tcg_gen_add_reg(add1, add1, cpu_psw_cb_msb); + tcg_gen_add_reg(add1, add1, get_psw_carry(ctx, false)); - /* Add or subtract R2, depending on PSW[V]. Proper computation of - carry{8} requires that we subtract via + ~R2 + 1, as described in - the manual. By extracting and masking V, we can produce the - proper inputs to the addition without movcond. */ - tcg_gen_sari_reg(addc, cpu_psw_v, TARGET_REGISTER_BITS - 1); + /* + * Add or subtract R2, depending on PSW[V]. Proper computation of + * carry requires that we subtract via + ~R2 + 1, as described in + * the manual. By extracting and masking V, we can produce the + * proper inputs to the addition without movcond. + */ + tcg_gen_sextract_reg(addc, cpu_psw_v, 31, 1); tcg_gen_xor_reg(add2, in2, addc); tcg_gen_andi_reg(addc, addc, 1); - /* ??? This is only correct for 32-bit. */ - tcg_gen_add2_i32(dest, cpu_psw_cb_msb, add1, zero, add2, zero); - tcg_gen_add2_i32(dest, cpu_psw_cb_msb, dest, cpu_psw_cb_msb, addc, zero); + + tcg_gen_add2_reg(dest, cpu_psw_cb_msb, add1, zero, add2, zero); + tcg_gen_add2_reg(dest, cpu_psw_cb_msb, dest, cpu_psw_cb_msb, addc, zero); /* Write back the result register. */ save_gpr(ctx, a->t, dest); @@ -2747,7 +2772,8 @@ static bool trans_ds(DisasContext *ctx, arg_rrr_cf *a) tcg_gen_xor_reg(cpu_psw_cb, cpu_psw_cb, dest); /* Write back PSW[V] for the division step. */ - tcg_gen_neg_reg(cpu_psw_v, cpu_psw_cb_msb); + cout = get_psw_carry(ctx, false); + tcg_gen_neg_reg(cpu_psw_v, cout); tcg_gen_xor_reg(cpu_psw_v, cpu_psw_v, in2); /* Install the new nullification. */ @@ -2757,7 +2783,7 @@ static bool trans_ds(DisasContext *ctx, arg_rrr_cf *a) /* ??? The lshift is supposed to contribute to overflow. */ sv = do_add_sv(ctx, dest, add1, add2); } - ctx->null_cond = do_cond(a->cf, dest, cpu_psw_cb_msb, sv); + ctx->null_cond = do_cond(a->cf, dest, cout, sv); } return nullify_end(ctx);