From patchwork Mon Aug 19 21:37:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171683 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3542212ily; Mon, 19 Aug 2019 14:56:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqgRq61ufPeU7bcLVadXnyBtRfO5SEw4pNXlyMJzHjpSY4G8ZU00zmjhN3bfgU91cMHPEA X-Received: by 2002:a50:ac1a:: with SMTP id v26mr27610635edc.131.1566251787023; Mon, 19 Aug 2019 14:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566251787; cv=none; d=google.com; s=arc-20160816; b=Ep4xsPDKPigBdeVcqx270hpr1wEWpKKP4siSsZyjI3MAl7avxSeFAKUIJyCBSYxGWM S6tKVFsZqbfjGJdx+Cq2iFvxCpYLFMvUPXGl19kn2plL/8hL9NJ3RRHwXM5kaVFh9w1L JOWVLWA95c9ZzrNxCZE5dTr+mfFoU9EyWlR2rs4d0bB9MLmsQTiAl3c8Ob60HFcyTguO 5Idt8SIpmhlJ8fDQbdYT0okG/U9IvJudjrv2dWtgXKjO6YW1tI4tl7kH/Ag1wzKzSH01 aG5CGR3z7w+TSp2fTkuhyyDwZie5ttzdLtDD/DR/OPqasIQELw9uUQivPtczYDut8wSz RI6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=zZYWccT7CCrzOlrmxHsfHjAEIVHw6UJ7WILoC7VO3SU=; b=dYAwpvqyR+1PBo7Js81d775kfH/m7Vrxqx9OTeRuYzX9aXG0XYGf+maVwr/CRsUDKy B5Se6Ib0dxzn2FujJx9P8HZlgrWG//jnscMAJoIVYZu69sqq4m/7pkuWyxxeypH7vp2G BPE7EZoTHVf9cMaBYE0+p2l+IkepR1+6ddlSfCoJO6dmTe2XEVPHbsUbyAq8sOhMnxE2 7zvETAByUvFwD5x0ffE5XECz0V0+JHHA/jd8l8G85vfeT6WMytOv++vr2Z/r1oWhne3Y x+OfPv6b7cYTdw69ycMMZtbPM1r5Tl72gkdVVNd4y44Ewx4M7fKirKmP17qffmouIk09 z+4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PPb1t8l9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b7si7619271ejv.168.2019.08.19.14.56.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 14:56:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PPb1t8l9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzpdZ-0007pR-8d for patch@linaro.org; Mon, 19 Aug 2019 17:56:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58837) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzpM4-0001eB-FI for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:38:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzpM2-0006A0-Sb for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:38:20 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:41903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzpM2-00069R-Mc for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:38:18 -0400 Received: by mail-pg1-x541.google.com with SMTP id x15so1926604pgg.8 for ; Mon, 19 Aug 2019 14:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zZYWccT7CCrzOlrmxHsfHjAEIVHw6UJ7WILoC7VO3SU=; b=PPb1t8l9YP39KVfPVkg+miZTF3Jpd18TujsLmnHArLFTCMt3WmDDzdA6EsoAqoVjBP 9XYQLpHfU9Dtg03+e7F8WObuM9K8a2qXgNojBce1Z1WW/ZzX1fM+drr23SPgMr5L/Lg/ pBHY+l6/RwDzHbfz+YCpWwPW7yyg4eL1AlnDU1zL4XIEuXEYRqaazEB3ysP1ATZPiARm d3/nToby9TXFpQWg+doyEX24e3ugljUBAreYveJSuvwY0EV7OZ38V70yZTrxdG3ihNtm NwAS3XSVFmisUOZJqoA8KAx4gPTDYllXP1sO7uPKaMWbIvZJtKqLKxv+uk+XMEIpRftJ 4Z+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zZYWccT7CCrzOlrmxHsfHjAEIVHw6UJ7WILoC7VO3SU=; b=bJJ1wfDH0849zny+DL2W6qLlFhwmYWkAtvmAmPXOiHcFpxaBCMI9KiOpOtYwUZ74F8 mcyW/JE6nkGw3ZrsYAI/hF8wd9EcsExVaTKFdHAV/BrhNe86mNmMdyFYfA/pjH9OTDa/ BsPultStD8ClOS6fFyhRQarK4OunRZLwViDoYPStcVXw5Hpc9oz5T0/v3/FSrbvINXa6 SFo2rfGICwVj5gQTk1l1xm6MWGRtp+8Ng1oASD5/+PGs4rWqnwg9rplh86SwZYDSrFP5 7qywwx6QbiyY/1Y2U+PFlKwP+dvHIwrNTt1jyW/jof5Cyvza4hRPTuzPZKAGruD1yBwl SSqQ== X-Gm-Message-State: APjAAAWi+Xa8ywQSmdaMWb4ORBo9kMOpvDwtOmIysXdQ62qeoYJnDzf1 sem+T0b2KguSwpKa2s6vrZxm1B1ZA+A= X-Received: by 2002:a63:1f03:: with SMTP id f3mr21523509pgf.249.1566250697329; Mon, 19 Aug 2019 14:38:17 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id d2sm13446951pjs.21.2019.08.19.14.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 14:38:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Aug 2019 14:37:03 -0700 Message-Id: <20190819213755.26175-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819213755.26175-1-richard.henderson@linaro.org> References: <20190819213755.26175-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v2 16/68] target/arm: Convert CLZ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Document our choice about the T32 CONSTRAINED UNPREDICTABLE behaviour. This matches the undocumented choice made by the legacy decoder. Signed-off-by: Richard Henderson --- target/arm/translate.c | 31 +++++++++++++++---------------- target/arm/a32.decode | 4 ++++ target/arm/t32.decode | 5 +++++ 3 files changed, 24 insertions(+), 16 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/arm/translate.c b/target/arm/translate.c index ef26ed7b57..f0fa5253b6 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8461,6 +8461,19 @@ static bool trans_BLX_r(DisasContext *s, arg_BLX_r *a) return true; } +static bool trans_CLZ(DisasContext *s, arg_CLZ *a) +{ + TCGv_i32 tmp; + + if (!ENABLE_ARCH_5) { + return false; + } + tmp = load_reg(s, a->rm); + tcg_gen_clzi_i32(tmp, tmp, 32); + store_reg(s, a->rd, tmp); + return true; +} + /* * Legacy decoder. */ @@ -8749,18 +8762,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) /* MSR/MRS (banked/register) */ /* All done in decodetree. Illegal ops already signalled. */ g_assert_not_reached(); - case 0x1: - if (op1 == 3) { - /* clz */ - ARCH(5); - rd = (insn >> 12) & 0xf; - tmp = load_reg(s, rm); - tcg_gen_clzi_i32(tmp, tmp, 32); - store_reg(s, rd, tmp); - } else { - goto illegal_op; - } - break; + case 0x1: /* bx, clz */ case 0x2: /* bxj */ case 0x3: /* blx */ case 0x4: /* crc32 */ @@ -10201,13 +10203,13 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) case 0x08: /* rev */ case 0x09: /* rev16 */ case 0x0b: /* revsh */ - case 0x18: /* clz */ break; case 0x10: /* sel */ if (!arm_dc_feature(s, ARM_FEATURE_THUMB_DSP)) { goto illegal_op; } break; + case 0x18: /* clz, in decodetree */ case 0x20: /* crc32/crc32c, in decodetree */ case 0x21: case 0x22: @@ -10240,9 +10242,6 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) tcg_temp_free_i32(tmp3); tcg_temp_free_i32(tmp2); break; - case 0x18: /* clz */ - tcg_gen_clzi_i32(tmp, tmp, 32); - break; default: g_assert_not_reached(); } diff --git a/target/arm/a32.decode b/target/arm/a32.decode index 6cb9c16e2f..182f2b6725 100644 --- a/target/arm/a32.decode +++ b/target/arm/a32.decode @@ -29,6 +29,7 @@ &s_rrrr s rd rn rm ra &rrrr rd rn rm ra &rrr rd rn rm +&rr rd rm &r rm &msr_reg rn r mask &mrs_reg rd r @@ -197,6 +198,7 @@ CRC32CW .... 0001 0100 .... .... 0010 0100 .... @rndm %sysm 8:1 16:4 @rm ---- .... .... .... .... .... .... rm:4 &r +@rdm ---- .... .... .... rd:4 .... .... rm:4 &rr MRS_bank ---- 0001 0 r:1 00 .... rd:4 001. 0000 0000 &mrs_bank %sysm MSR_bank ---- 0001 0 r:1 10 .... 1111 001. 0000 rn:4 &msr_bank %sysm @@ -207,3 +209,5 @@ MSR_reg ---- 0001 0 r:1 10 mask:4 1111 0000 0000 rn:4 &msr_reg BX .... 0001 0010 1111 1111 1111 0001 .... @rm BXJ .... 0001 0010 1111 1111 1111 0010 .... @rm BLX_r .... 0001 0010 1111 1111 1111 0011 .... @rm + +CLZ .... 0001 0110 1111 .... 1111 0001 .... @rdm diff --git a/target/arm/t32.decode b/target/arm/t32.decode index 337706ebbe..67724efe4b 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -26,6 +26,7 @@ &s_rrrr !extern s rd rn rm ra &rrrr !extern rd rn rm ra &rrr !extern rd rn rm +&rr !extern rd rm &r !extern rm &msr_reg !extern rn r mask &mrs_reg !extern rd r @@ -126,6 +127,7 @@ RSB_rri 1111 0.0 1110 . .... 0 ... .... ........ @s_rri_rot @rnadm .... .... .... rn:4 ra:4 rd:4 .... rm:4 &rrrr @rn0dm .... .... .... rn:4 .... rd:4 .... rm:4 &rrrr ra=0 @rndm .... .... .... rn:4 .... rd:4 .... rm:4 &rrr +@rdm .... .... .... .... .... rd:4 .... rm:4 &rr { MUL 1111 1011 0000 .... 1111 .... 0000 .... @s0_rn0dm @@ -180,6 +182,9 @@ CRC32CB 1111 1010 1101 .... 1111 .... 1000 .... @rndm CRC32CH 1111 1010 1101 .... 1111 .... 1001 .... @rndm CRC32CW 1111 1010 1101 .... 1111 .... 1010 .... @rndm +# Note rn != rm is CONSTRAINED UNPREDICTABLE; we choose to ignore rn. +CLZ 1111 1010 1011 ---- 1111 .... 1000 .... @rdm + # Branches and miscellaneous control %msr_sysm 4:1 8:4