From patchwork Thu Sep 5 14:38:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 19773 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f200.google.com (mail-ye0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9389325E09 for ; Thu, 5 Sep 2013 14:38:33 +0000 (UTC) Received: by mail-ye0-f200.google.com with SMTP id r3sf1916268yen.11 for ; Thu, 05 Sep 2013 07:38:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=I1CyGhbbs1lFp0vln6iqlmv8XO2LAaZ23QufTHivYmk=; b=Y1koNgtZpS9plgYQ3I1jpV6fR2qtgHNd+KX0JJfDNTgwTRP46EzECyr+DA7j9NTPrW rUSvVeCLDUS8xGaJPkDZ1Z+ZXxaTSj+VLmwb7R+If/axaAXJ45++SwLYVo27zyHW1tO/ RxqfczcEYwb9VoD6nODSmi+1VFZf2SLxDKAt5Z4xBwRpjS4OFRcAeior+zSJBGO+l7kZ 1AHWAaae5T9ni3mvsPk+Qq4aGikOsot1ke45rVYyQC4NWaepcN6ZP8BZngmND43gtsW6 eX9+n6rQz30QYcv/tmK1zydnKqTcCXsllwXJHUOfyxK+syxdGt0bMOjfJZ54L+vYbc+I Zolg== X-Received: by 10.236.116.135 with SMTP id g7mr531632yhh.53.1378391913090; Thu, 05 Sep 2013 07:38:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.39.193 with SMTP id r1ls535860qek.30.gmail; Thu, 05 Sep 2013 07:38:33 -0700 (PDT) X-Received: by 10.58.198.13 with SMTP id iy13mr8190799vec.11.1378391912999; Thu, 05 Sep 2013 07:38:32 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id tg9si7312480vcb.107.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 07:38:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id id13so1175983vcb.4 for ; Thu, 05 Sep 2013 07:38:32 -0700 (PDT) X-Gm-Message-State: ALoCoQmWm+odzI7TlEnF77SCZgNo4JMYV+Azvw35yuZVzS4aCnJ/EMrZQ2c5+a0UtV3XtO7EKAKm X-Received: by 10.220.10.194 with SMTP id q2mr2420242vcq.2.1378391912930; Thu, 05 Sep 2013 07:38:32 -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 u4csp283835vcz; Thu, 5 Sep 2013 07:38:32 -0700 (PDT) X-Received: by 10.180.109.35 with SMTP id hp3mr6601470wib.52.1378391910205; Thu, 05 Sep 2013 07:38:30 -0700 (PDT) Received: from chiark.greenend.org.uk (v6.chiark.greenend.org.uk. [2001:ba8:1e3::]) by mx.google.com with ESMTPS id m5si11264184wjy.111.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Sep 2013 07:38:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pmaydell@chiark.greenend.org.uk designates 2001:ba8:1e3:: as permitted sender) client-ip=2001:ba8:1e3::; Received: by chiark.greenend.org.uk (Debian Exim 4.72 #1) with local (return-path pmaydell@chiark.greenend.org.uk) id 1VHahY-0005lV-ST; Thu, 05 Sep 2013 15:38:28 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Richard Henderson Subject: [PATCH v2 1/2] target-arm: Use sextract32() in branch decode Date: Thu, 5 Sep 2013 15:38:27 +0100 Message-Id: <1378391908-22137-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1378391908-22137-1-git-send-email-peter.maydell@linaro.org> References: <1378391908-22137-1-git-send-email-peter.maydell@linaro.org> Sender: Peter Maydell 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.220.173 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 4f4a0a9..8bcfaf3 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 @@ -7957,8 +7958,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;