From patchwork Fri Aug 23 16:12:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 19493 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0EC93248E6 for ; Fri, 23 Aug 2013 16:12:44 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id z20sf612071yhz.9 for ; Fri, 23 Aug 2013 09:12:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=5LpKDE1h0BFNi8YHsaKlcSRYU50VSVYSEUJNlghZpmw=; b=a2uzWZKzAjvpPaqg4iqBAlKvAcO6VSiozNH9JTWX0ND7dsLAWRWV7EBMo5UP8Zau0Y wuftKuQqvJZzJH1k0MEFPCzKhp5mvik0eLWBcAMkgP6DbFwZ/4uYCSsw1m+c3yi94LWD bEBoqqT5213z/YT7M3UuvlCafCkChxI5SSyXd+ZvV/v+yMP8hDuTepPaWOr4ghoi2nWy 4M9inanY6odfpPBkx6vWyj4W+b72Nzp4x4epMRowkiG+jIWXnjfn8uYMdkBDB8t+0yfj eSA4rgOmyI41Mh3QuTpfwlVwuTN0kR3tBQTg6WHX2DNUzcC4BOKJCXKA/73SilGjzo61 giRw== X-Received: by 10.236.68.2 with SMTP id k2mr161584yhd.16.1377274363815; Fri, 23 Aug 2013 09:12:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.51.40 with SMTP id h8ls1584443qeo.28.gmail; Fri, 23 Aug 2013 09:12:43 -0700 (PDT) X-Received: by 10.52.173.71 with SMTP id bi7mr156721vdc.38.1377274363728; Fri, 23 Aug 2013 09:12:43 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id h3si137377vca.148.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 09:12:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id db10so595450veb.14 for ; Fri, 23 Aug 2013 09:12:43 -0700 (PDT) X-Gm-Message-State: ALoCoQk66lGd5wLcayRe4zor8K6Ed3S6/+M2wE1AHPjfaqZtUJM5kRuUYbfBFYuPFbMr6sni6zeG X-Received: by 10.58.188.52 with SMTP id fx20mr171905vec.47.1377274363660; Fri, 23 Aug 2013 09:12:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp101702vcz; Fri, 23 Aug 2013 09:12:43 -0700 (PDT) X-Received: by 10.14.22.68 with SMTP id s44mr493186ees.74.1377274361648; Fri, 23 Aug 2013 09:12:41 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id 7si419554eeo.169.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 Aug 2013 09:12:41 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VCtyZ-0002Gx-WB; Fri, 23 Aug 2013 17:12:40 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH 1/2] target-arm: Use sextract32() in branch decode Date: Fri, 23 Aug 2013 17:12:38 +0100 Message-Id: <1377274359-8707-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1377274359-8707-1-git-send-email-peter.maydell@linaro.org> References: <1377274359-8707-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In the decode of ARM B and BL insns, swap the order of the "append 2 implicit zeros to imm24" and the sign extend, and use the new sextract32() utility function to do the latter. This avoids a direct dependency on the undefined C behaviour of shifting into the sign bit of an integer. Signed-off-by: Peter Maydell --- target-arm/translate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target-arm/translate.c b/target-arm/translate.c index d1e8538..ebf5d4f 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -28,6 +28,7 @@ #include "disas/disas.h" #include "tcg-op.h" #include "qemu/log.h" +#include "qemu/bitops.h" #include "helper.h" #define GEN_HELPER 1 @@ -7956,8 +7957,8 @@ static void disas_arm_insn(CPUARMState * env, DisasContext *s) tcg_gen_movi_i32(tmp, val); store_reg(s, 14, tmp); } - offset = (((int32_t)insn << 8) >> 8); - val += (offset << 2) + 4; + offset = sextract32(insn << 2, 0, 26); + val += offset + 4; gen_jmp(s, val); } break;