From patchwork Fri Dec 6 13:19:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22125 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6004023A4E for ; Fri, 6 Dec 2013 13:19:25 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id p10sf2760524pdj.3 for ; Fri, 06 Dec 2013 05:19:24 -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=dztzwKwK/P8xKv/VqUiPGgE5EFlrX5B5RARho96p0jE=; b=hpZ7PRDvnmzZFvO5QrxHqfbBaHMcnCsYe35Hza0Q2DqlKfd3PYeUcFCKSjY95ah0KN 1q2xhp4zm10y2gih6yJVg9qcSBT24Zs7wHNIbtyaYepJxnEUlC0jhzX4/9cRz9noXLSV YSddMkad3cG2d3VjbfD6MbCXuZzh2ijuSiZZCAu68kV2Cud+me9vggw4GF29KmRgwJzr qfAwu4zBcYDguhbqgoRb7qnJtdGNv4GdVuXSnPKCB2qRqbeOKgqluQel/sKC0jzg31OA FvT80t9Dlr6SoGlpGTrlLN+A7hkGdF8WWT2SlC/Wqdm8OMAJemvpYNDogKc2QSAxanup Ch6Q== X-Gm-Message-State: ALoCoQnRGgc8dXh8z/KqDDZmMCYbmh1/oyrYezIxj/d4EueqogJ8k+0yMaOIs780ApAv/hnPP68S X-Received: by 10.68.136.229 with SMTP id qd5mr1971014pbb.6.1386335964513; Fri, 06 Dec 2013 05:19:24 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.170 with SMTP id w10ls1237070qeu.58.gmail; Fri, 06 Dec 2013 05:19:24 -0800 (PST) X-Received: by 10.52.118.98 with SMTP id kl2mr1548149vdb.30.1386335964365; Fri, 06 Dec 2013 05:19:24 -0800 (PST) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id er6si1573887vdc.153.2013.12.06.05.19.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Dec 2013 05:19:24 -0800 (PST) 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 c14so741592vea.0 for ; Fri, 06 Dec 2013 05:19:24 -0800 (PST) X-Received: by 10.220.199.5 with SMTP id eq5mr1937554vcb.16.1386335964174; Fri, 06 Dec 2013 05:19:24 -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 u4csp99118vcz; Fri, 6 Dec 2013 05:19:23 -0800 (PST) X-Received: by 10.181.5.40 with SMTP id cj8mr2492604wid.18.1386335961276; Fri, 06 Dec 2013 05:19:21 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id m8si1252157wib.15.2013.12.06.05.19.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 06 Dec 2013 05:19:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VovJJ-0007Wr-Q7; Fri, 06 Dec 2013 13:19:13 +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 v2 10/13] target-arm: A64: add support for bitfield insns Date: Fri, 6 Dec 2013 13:19:10 +0000 Message-Id: <1386335953-28876-11-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386335953-28876-1-git-send-email-peter.maydell@linaro.org> References: <1386335953-28876-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: , 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 dfbbe00..ee2ecb4 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