From patchwork Thu Dec 5 21:51:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22102 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2D79A24AAD for ; Thu, 5 Dec 2013 21:51:39 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hu19sf38047096vcb.3 for ; Thu, 05 Dec 2013 13:51:38 -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=i3PpbkIXVhY1pGMxT4tndDRctFPTCWiN1yeVFFs1FGQ=; b=YTH22hZxl3CiFNF8msMZQWWYQJs6aav883r8Il9T/TAKEMzbZs25BZwXkOG2k9P66s 9DWRFVxNdGSnm9JnBcHr3iJ8KRHah4lQYc9T768Pcol+/WOIPL1OdSBmS1Gk452EYZnT 3AWw+f7XYPJbn7LHfbZa45i2NmKb0WylJmg9arF4QERQiQ0gx1GM97kuP7hUNfO1jNqN 9knVMkX/E1ZxHME8FYvXHD2vebUw7EKuI1PhmTuP9fqD5S5SHVlb/WodKebxy3N51qhw iL8JtAMaR9KhBjED2CRZNwiBz0Q/RwnDNqCDcP1u/QlAuUB/GhZI8QBF/YJtC+m9fz8v 0DzA== X-Gm-Message-State: ALoCoQnaIsI9fTB+LQQS5CttyrBXGdpDPg5ksLe72IlHjGLt2+Sxr8YTZEOaV1juqyC8FtagtXg1 X-Received: by 10.58.237.10 with SMTP id uy10mr91777vec.16.1386280298689; Thu, 05 Dec 2013 13:51:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.50.196 with SMTP id e4ls1003040qeo.3.gmail; Thu, 05 Dec 2013 13:51:38 -0800 (PST) X-Received: by 10.52.231.130 with SMTP id tg2mr3476vdc.16.1386280298461; Thu, 05 Dec 2013 13:51:38 -0800 (PST) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id xn8si10678905vdc.22.2013.12.05.13.51.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 13:51:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.179 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.179; Received: by mail-vc0-f179.google.com with SMTP id ie18so13618031vcb.38 for ; Thu, 05 Dec 2013 13:51:38 -0800 (PST) X-Received: by 10.52.162.168 with SMTP id yb8mr3247vdb.8.1386280298276; Thu, 05 Dec 2013 13:51:38 -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 u4csp50142vcz; Thu, 5 Dec 2013 13:51:37 -0800 (PST) X-Received: by 10.204.114.68 with SMTP id d4mr295345bkq.13.1386280295108; Thu, 05 Dec 2013 13:51:35 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id oi6si5966378bkb.143.2013.12.05.13.51.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Dec 2013 13:51:35 -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 1VogpV-0007CT-FS; Thu, 05 Dec 2013 21:51:29 +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 04/13] target-arm: A64: add support for EXTR Date: Thu, 5 Dec 2013 21:51:20 +0000 Message-Id: <1386280289-27636-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386280289-27636-1-git-send-email-peter.maydell@linaro.org> References: <1386280289-27636-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.220.179 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: Alexander Graf This patch adds emulation support for the EXTR instruction. Signed-off-by: Alexander Graf [claudio: adapted for new decoder, removed a few temporaries, fixed the 32bit bug, added checks for more unallocated cases] Signed-off-by: Claudio Fontana Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target-arm/translate-a64.c | 48 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index bff7071..2ab17af 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -704,10 +704,54 @@ static void disas_bitfield(DisasContext *s, uint32_t insn) unsupported_encoding(s, insn); } -/* Extract */ +/* C3.4.3 Extract + * 31 30 29 28 23 22 21 20 16 15 10 9 5 4 0 + * +----+------+-------------+---+----+------+--------+------+------+ + * | sf | op21 | 1 0 0 1 1 1 | N | o0 | Rm | imms | Rn | Rd | + * +----+------+-------------+---+----+------+--------+------+------+ + */ static void disas_extract(DisasContext *s, uint32_t insn) { - unsupported_encoding(s, insn); + unsigned int sf, n, rm, imm, rn, rd, bitsize, op21, op0; + + sf = extract32(insn, 31, 1); + n = extract32(insn, 22, 1); + rm = extract32(insn, 16, 5); + imm = extract32(insn, 10, 6); + rn = extract32(insn, 5, 5); + rd = extract32(insn, 0, 5); + op21 = extract32(insn, 29, 2); + op0 = extract32(insn, 21, 1); + bitsize = sf ? 64 : 32; + + if (sf != n || op21 || op0 || imm >= bitsize) { + unallocated_encoding(s); + } else { + TCGv_i64 tcg_rd, tcg_rm, tcg_rn; + + tcg_rd = cpu_reg(s, rd); + + if (imm) { + tcg_rm = read_cpu_reg(s, rm, sf); + tcg_rn = read_cpu_reg(s, rn, sf); + tcg_gen_shri_i64(tcg_rm, tcg_rm, imm); + tcg_gen_shli_i64(tcg_rn, tcg_rn, bitsize - imm); + tcg_gen_or_i64(tcg_rd, tcg_rm, tcg_rn); + if (!sf) { + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); + } + } else { + /* tcg shl_i32/shl_i64 is undefined for 32/64 bit shifts, + * so an extract from bit 0 is a special case. + */ + if (sf) { + tcg_gen_mov_i64(tcg_rd, cpu_reg(s, rm)); + } else { + tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, rm)); + } + } + + } } /* C3.4 Data processing - immediate */