From patchwork Thu Dec 5 21:51:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22101 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3DB9524002 for ; Thu, 5 Dec 2013 21:51:38 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id 1sf34823587qec.4 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=/Pbbemf0HJx7TKcTLjMyhmALk/wExayCPWSn+H0IRsg=; b=emE1qeLLc6MKFEpxsaEWiw2KP5n302U7VUJxwZO9W3EcA0ajjkHCsrAhx07cedCk38 kB47Zl/t9lTlLMjq+71sgu45i6O9lAxinYensBP4UuoZk/a9wN7j/rQbhYmzR1a3wIlk 5sXBq6Umum7wDohjG4DZE6JuW5HLjJs4WkNSxj7BwTn3O/4MEq/AKQXJtwW01kkufz51 d34wQ75cOE1tAxHrqkAYHca9k0k7/6ed2n5FQCOKt/9SJxwzNXdVziOLvTNzjTYBvJVY ZcjmTLZVJlxgorcJbaiJRd+WfRwpUXHTciUioQA3R6cGGTNx1Psk5zOfsWsIVpFkOdwO MxHA== X-Gm-Message-State: ALoCoQlVaosc8Bktw0ENCmiYjH9jtzejIejMEzi1Aua1OO5x49Z4GBBPH0Eoj1bQed08Bl2viuzr X-Received: by 10.236.0.232 with SMTP id 68mr5305yhb.16.1386280298011; Thu, 05 Dec 2013 13:51:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.132.164 with SMTP id ov4ls1043525qeb.32.gmail; Thu, 05 Dec 2013 13:51:37 -0800 (PST) X-Received: by 10.58.210.39 with SMTP id mr7mr4167vec.18.1386280297789; Thu, 05 Dec 2013 13:51:37 -0800 (PST) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id pu5si35406990veb.97.2013.12.05.13.51.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 13:51:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.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.220.171; Received: by mail-vc0-f171.google.com with SMTP id ik5so13524151vcb.2 for ; Thu, 05 Dec 2013 13:51:37 -0800 (PST) X-Received: by 10.52.72.100 with SMTP id c4mr8302vdv.86.1386280297577; Thu, 05 Dec 2013 13:51:37 -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 u4csp50140vcz; Thu, 5 Dec 2013 13:51:37 -0800 (PST) X-Received: by 10.180.13.74 with SMTP id f10mr33953wic.34.1386280294983; Thu, 05 Dec 2013 13:51:34 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id dk6si35306981wjb.63.2013.12.05.13.51.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Dec 2013 13:51:34 -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-0007Cf-KB; 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 07/13] target-arm: A64: add support for 1-src data processing and CLZ Date: Thu, 5 Dec 2013 21:51:23 +0000 Message-Id: <1386280289-27636-8-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.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 adds support for decoding 1-src data processing insns, and the first user, C5.6.40 CLZ (count leading zeroes). Signed-off-by: Claudio Fontana Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target-arm/helper-a64.c | 5 +++++ target-arm/helper-a64.h | 1 + target-arm/translate-a64.c | 52 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c index abb98c0..e4c5346 100644 --- a/target-arm/helper-a64.c +++ b/target-arm/helper-a64.c @@ -44,3 +44,8 @@ int64_t HELPER(sdiv64)(int64_t num, int64_t den) } return num / den; } + +uint64_t HELPER(clz64)(uint64_t x) +{ + return clz64(x); +} diff --git a/target-arm/helper-a64.h b/target-arm/helper-a64.h index e0d6506..b10b6c3 100644 --- a/target-arm/helper-a64.h +++ b/target-arm/helper-a64.h @@ -18,3 +18,4 @@ */ DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64) +DEF_HELPER_FLAGS_1(clz64, TCG_CALL_NO_RWG_SE, i64, i64) diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index c2d0308..3ee2674 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -1005,10 +1005,58 @@ static void disas_cond_select(DisasContext *s, uint32_t insn) } } -/* Data-processing (1 source) */ +static void handle_clz(DisasContext *s, unsigned int sf, + unsigned int rn, unsigned int rd) +{ + TCGv_i64 tcg_rd, tcg_rn; + tcg_rd = cpu_reg(s, rd); + tcg_rn = cpu_reg(s, rn); + + if (sf) { + gen_helper_clz64(tcg_rd, tcg_rn); + } else { + TCGv_i32 tcg_tmp32 = tcg_temp_new_i32(); + tcg_gen_trunc_i64_i32(tcg_tmp32, tcg_rn); + gen_helper_clz(tcg_tmp32, tcg_tmp32); + tcg_gen_extu_i32_i64(tcg_rd, tcg_tmp32); + tcg_temp_free_i32(tcg_tmp32); + } +} + +/* C3.5.7 Data-processing (1 source) + * 31 30 29 28 21 20 16 15 10 9 5 4 0 + * +----+---+---+-----------------+---------+--------+------+------+ + * | sf | 1 | S | 1 1 0 1 0 1 1 0 | opcode2 | opcode | Rn | Rd | + * +----+---+---+-----------------+---------+--------+------+------+ + */ static void disas_data_proc_1src(DisasContext *s, uint32_t insn) { - unsupported_encoding(s, insn); + unsigned int sf, opcode, rn, rd; + + if (extract32(insn, 29, 1) || extract32(insn, 16, 5)) { + unallocated_encoding(s); + return; + } + + sf = extract32(insn, 31, 1); + opcode = extract32(insn, 10, 6); + rn = extract32(insn, 5, 5); + rd = extract32(insn, 0, 5); + + switch (opcode) { + case 0: /* RBIT */ + case 1: /* REV16 */ + case 2: /* REV32 */ + case 3: /* REV64 */ + unsupported_encoding(s, insn); + break; + case 4: /* CLZ */ + handle_clz(s, sf, rn, rd); + break; + case 5: /* CLS */ + unsupported_encoding(s, insn); + break; + } } static void handle_div(DisasContext *s, bool is_signed, unsigned int sf,