From patchwork Sun Jan 20 19:30:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 213984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E5C9E2C0087 for ; Mon, 21 Jan 2013 06:31:12 +1100 (EST) Received: from localhost ([::1]:33579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tx0bn-0001di-24 for incoming@patchwork.ozlabs.org; Sun, 20 Jan 2013 14:31:11 -0500 Received: from eggs.gnu.org ([208.118.235.92]:33329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tx0bc-0001dd-GN for qemu-devel@nongnu.org; Sun, 20 Jan 2013 14:31:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tx0bZ-0000Xa-Tv for qemu-devel@nongnu.org; Sun, 20 Jan 2013 14:31:00 -0500 Received: from mail-wg0-f50.google.com ([74.125.82.50]:62754) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tx0bZ-0000XV-Ht for qemu-devel@nongnu.org; Sun, 20 Jan 2013 14:30:57 -0500 Received: by mail-wg0-f50.google.com with SMTP id es5so3232698wgb.17 for ; Sun, 20 Jan 2013 11:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version:content-type; bh=K3VnBokNiksPTmWj3bkYGYfmoqfM9smJ/fB+OwGfvbU=; b=RlNLZft63UvZD76QbOu1cKa/EmAuZU5FwDG2TnKsyFTaFbJ3my7r8VnK0aycM1NeeC AoNS+7zoL/w50fEX+jgd3os9FK4faHvzDdQdKEPFGRvPZttn57tuJAR+9joEZtEphQxS paunlwcLWwIkzYn2Hcc/t0Eslt8FYSmq26bmKBxgnUIGGQeGXKJvRcjNqY6lvTsNnDVl 9vYQswM0A3/v8aP13IFmMboq/01jw32WAvq2Rt031bSJ5E+XzUvs72Zlt4bA9YPVjgFO UG0cYmm7jsSDJTTQOpeKyyHzzIiRw7sHomkL/BFQjzF952EQpYNKZ2VNEHOMfd5gLSrB z0Bg== X-Received: by 10.180.80.230 with SMTP id u6mr11842675wix.20.1358710256427; Sun, 20 Jan 2013 11:30:56 -0800 (PST) Received: from localhost ([2.26.205.107]) by mx.google.com with ESMTPS id l5sm15085578wia.10.2013.01.20.11.30.54 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 20 Jan 2013 11:30:55 -0800 (PST) From: Richard Sandiford To: qemu-devel@nongnu.org, aurelien@aurel32.net Mail-Followup-To: qemu-devel@nongnu.org, aurelien@aurel32.net, rdsandiford@googlemail.com Date: Sun, 20 Jan 2013 19:30:54 +0000 Message-ID: <87pq0zlki9.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 74.125.82.50 Subject: [Qemu-devel] [PATCH] target-mips: Sign-extend the result of LWR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sign-extend the result of LWR, as is already done for LWL. This is necessary in the case where LWR loads the full word (i.e. the address is actually aligned). In the other cases, it is implementation defined whether the upper 32 bits of the result are unchanged or a copy of bit 31. The latter seems easier to implement. Previously the code used: (oldval & (0xfffffffe << (31 - bitshift))) | (newval >> bitshift) which zeroed the upper bits of the register, losing any previous sign extension in the unaligned cases. Signed-off-by: Richard Sandiford Reviewed-by: Richard Henderson --- target-mips/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target-mips/translate.c b/target-mips/translate.c index 623edd0..08e28f3 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -1735,6 +1735,7 @@ static void gen_ld (CPUMIPSState *env, DisasContext *ctx, uint32_t opc, tcg_temp_free(t2); tcg_gen_or_tl(t0, t0, t1); tcg_temp_free(t1); + tcg_gen_ext32s_tl(t0, t0); gen_store_gpr(t0, rt); opn = "lwr"; break;