From patchwork Fri Dec 6 13:19:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22132 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4D5DD23A4E for ; Fri, 6 Dec 2013 13:19:55 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id tp5sf2167238ieb.9 for ; Fri, 06 Dec 2013 05:19:55 -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=Mu8oOztCDqsierw1gj/BGeRRZNibpnA6t+Ow1qhFddw=; b=I65Txu5X/HRV6rcPhYBd612tT35VpImcQzUcBNYKXUhM48RQTVPCKD1YAdMGpdRw9s yba4BarvXrW5gs5/J/UUOmMimFEdEHKQO8ID2eX6nHe5Pm/Valk1kbxRiKyrdXzSvY/3 dX+QAly2c4fHL5CP4pPEq6vRx6OjaEBdvK3ASqMJVyEn0iOvaFdavU0FglRC5xV391wS BMvIub4V9ncTekuS55pU/ZVH1U3fAkbxbRM6P0aeweyNBdEiE4FcKuuibCIHcHTs5KgU qjr0cMjWWpZ4mnKT6lvIzDvUhwhGHVQma6afvJszysGXKx7Rr9MiCKPnUTa8GHpk934Q UYbQ== X-Gm-Message-State: ALoCoQl1nAAAD1B1bTkN2qaLtcekSEl9I9Wif47ik4ky0e3U+6Cey7i7pPrQ3Ly4oSN7GNu0QfvQ X-Received: by 10.182.111.227 with SMTP id il3mr1132222obb.41.1386335994954; Fri, 06 Dec 2013 05:19:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.35.18 with SMTP id d18ls1356119qej.14.gmail; Fri, 06 Dec 2013 05:19:54 -0800 (PST) X-Received: by 10.52.26.231 with SMTP id o7mr264924vdg.88.1386335994775; Fri, 06 Dec 2013 05:19:54 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id er6si1574792vdc.75.2013.12.06.05.19.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Dec 2013 05:19:54 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 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.174; Received: by mail-ve0-f174.google.com with SMTP id pa12so733493veb.33 for ; Fri, 06 Dec 2013 05:19:54 -0800 (PST) X-Received: by 10.52.72.100 with SMTP id c4mr257979vdv.86.1386335994634; Fri, 06 Dec 2013 05:19:54 -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 u4csp99151vcz; Fri, 6 Dec 2013 05:19:54 -0800 (PST) X-Received: by 10.180.74.174 with SMTP id u14mr2406980wiv.45.1386335993878; Fri, 06 Dec 2013 05:19:53 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id 18si27788691wjo.151.2013.12.06.05.19.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 06 Dec 2013 05:19:53 -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-0007Wf-Kf; 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 07/13] target-arm: A64: add support for 1-src data processing and CLZ Date: Fri, 6 Dec 2013 13:19:07 +0000 Message-Id: <1386335953-28876-8-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.174 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 486db8b..e9d9a88 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -1036,10 +1036,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,