From patchwork Mon Dec 9 12:37:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22179 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3A52323FBA for ; Mon, 9 Dec 2013 12:37:48 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id v10sf17239338pde.4 for ; Mon, 09 Dec 2013 04:37:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version: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=lPrK5+06o7PEvsts/dsDEj+ImYye16x6hpCmi+YbIV0=; b=ZXws+ign1MqcMRYeg/4UraKolX9yQldh3tdVzOb3hphD8PDC+AQIzaKqliwjKQvpxS azuNfnB/Obh2bVWnhcZVNbtVHEQ2OZaZWqT/RZfuXxm1f9PsI3amy5IzwC203jf6Fnqb UXQR7uiEakJeEXyTO+7XdOdKJG67uMR489INCBceam0SgY8DOa34WYmZ2t5Up0TVoiF1 cLJNC9q8M2KjUDp+v7cXY60Foki4A0YUijrFTblJTK0Wb+3lcQt4K7PN2zmnTPO/qaKX nnKubgKYEMwuNlUzh92gBzo5+JoVT3B3OXEO+/TXrb2tGh/1yn6Eppf8e10KLGf4+yO/ W8qQ== X-Gm-Message-State: ALoCoQlYnrbtCFcwoPIuczrRLD0vrdgGgCY42UAvavC1NQkKYwNLsR4p/doBTqVCJ+3WekHULIID X-Received: by 10.66.221.137 with SMTP id qe9mr10085373pac.4.1386592667539; Mon, 09 Dec 2013 04:37:47 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.65 with SMTP id m1ls2098746qed.91.gmail; Mon, 09 Dec 2013 04:37:47 -0800 (PST) X-Received: by 10.52.168.4 with SMTP id zs4mr514848vdb.59.1386592667397; Mon, 09 Dec 2013 04:37:47 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id ks3si3798025vec.13.2013.12.09.04.37.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Dec 2013 04:37:47 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so3505695veb.30 for ; Mon, 09 Dec 2013 04:37:47 -0800 (PST) X-Received: by 10.220.16.73 with SMTP id n9mr1587964vca.24.1386592667315; Mon, 09 Dec 2013 04:37:47 -0800 (PST) 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 u4csp103382vcz; Mon, 9 Dec 2013 04:37:46 -0800 (PST) X-Received: by 10.14.113.199 with SMTP id a47mr12678618eeh.41.1386592662841; Mon, 09 Dec 2013 04:37:42 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id g5si9292341eev.196.2013.12.09.04.37.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 09 Dec 2013 04:37:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Vq05e-00006z-NR; Mon, 09 Dec 2013 12:37:34 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Michael Matz , Claudio Fontana , Dirk Mueller , Laurent Desnogues , kvmarm@lists.cs.columbia.edu, Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Christoffer Dall , Will Newton Subject: [PATCH v3 10/13] target-arm: A64: add support for bitfield insns Date: Mon, 9 Dec 2013 12:37:31 +0000 Message-Id: <1386592654-362-11-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386592654-362-1-git-send-email-peter.maydell@linaro.org> References: <1386592654-362-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.171 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: , From: Claudio Fontana This patch implements the C3.4.2 Bitfield instructions: SBFM, BFM, UBFM. Signed-off-by: Claudio Fontana Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target-arm/translate-a64.c | 56 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index 0663e4c..045a25e 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -698,10 +698,62 @@ static void disas_movw_imm(DisasContext *s, uint32_t insn) unsupported_encoding(s, insn); } -/* Bitfield */ +/* C3.4.2 Bitfield + * 31 30 29 28 23 22 21 16 15 10 9 5 4 0 + * +----+-----+-------------+---+------+------+------+------+ + * | sf | opc | 1 0 0 1 1 0 | N | immr | imms | Rn | Rd | + * +----+-----+-------------+---+------+------+------+------+ + */ static void disas_bitfield(DisasContext *s, uint32_t insn) { - unsupported_encoding(s, insn); + unsigned int sf, n, opc, ri, si, rn, rd, bitsize, pos, len; + TCGv_i64 tcg_rd, tcg_tmp; + + sf = extract32(insn, 31, 1); + opc = extract32(insn, 29, 2); + n = extract32(insn, 22, 1); + ri = extract32(insn, 16, 6); + si = extract32(insn, 10, 6); + rn = extract32(insn, 5, 5); + rd = extract32(insn, 0, 5); + bitsize = sf ? 64 : 32; + + if (sf != n || ri >= bitsize || si >= bitsize || opc > 2) { + unallocated_encoding(s); + return; + } + + tcg_rd = cpu_reg(s, rd); + tcg_tmp = read_cpu_reg(s, rn, sf); + + /* OPTME: probably worth recognizing common cases of ext{8,16,32}{u,s} */ + + if (opc != 1) { /* SBFM or UBFM */ + tcg_gen_movi_i64(tcg_rd, 0); + } + + /* do the bit move operation */ + if (si >= ri) { + /* Wd = Wn */ + tcg_gen_shri_i64(tcg_tmp, tcg_tmp, ri); + pos = 0; + len = (si - ri) + 1; + } else { + /* Wd<32+s-r,32-r> = Wn */ + pos = bitsize - ri; + len = si + 1; + } + + tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); + + if (opc == 0) { /* SBFM - sign extend the destination field */ + tcg_gen_shli_i64(tcg_rd, tcg_rd, 64 - (pos + len)); + tcg_gen_sari_i64(tcg_rd, tcg_rd, 64 - (pos + len)); + } + + if (!sf) { /* zero extend final result */ + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); + } } /* C3.4.3 Extract