From patchwork Wed Sep 4 19:30:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 172982 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp367467ilq; Wed, 4 Sep 2019 12:50:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+b1t0Cx1j37a7P1rrN5R1Pcwoxe+vz8nKELoDWbldfDidF8PFi7cjrtFR8SNq314FcYAE X-Received: by 2002:a37:f518:: with SMTP id l24mr39547363qkk.54.1567626654683; Wed, 04 Sep 2019 12:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567626654; cv=none; d=google.com; s=arc-20160816; b=iku1x+eYv7IknE6Y21LQzqRgCy/HZqVDFFhOhGqxk0Cwu/+D60pckr9pkjUKVafzOJ n5hU4Gy04NN3r6EsreY2khZYJ0gFqHjBv/cCLF7uXPldGi1dEe+/zenJzO5y8CutzLrW bL9iosKriwWDPNE8XaS1eAUEXrjyBs8LmXmhd7unQJFF1+yOVjCs6mVPrbjTFOj4o4Eq E0cRJ5Skq38AoU81TJ6hdJ2mfak0bCjpRpCXFvo5K46UUTYTplGF4ApdwdxQNTjft9Ja L6ubabO0x4GRQoTSuC+W0Y4ABzy80tcPIn+rK8Fi4IcmwsH4a28nHGLBYe6dAd2m+C+x WcCQ== 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=gVoXo3oBV5rjG7odbH2AUIPExjRoZyxfBk+LHOtrM+4=; b=bgrx2BxubW/WwOgY0vAnbTrLKxizC0LW/j7y8D219FTGurZWe1FchppYFmIAywxWrq EABzaC6hyFLjBVEC8fyKFHAAAETYIaaZ0CDgZhQXfeuYPRWC5Pz1Wx/bERjTvZBU95sD RtzARMX2VNYgYbYMZNrP/4TlSzzZfqRvu6Uo+dxSnNh65tJ0zxgMAY/joFLckOL/mM0U BnVhBDtmw2ldhRNE3n33t4RDtoN6+5peg7QWvXVaY2D43um8Y5z1+Lor1YGprBITw8qm SLy1nrVw6zDI/SFPHLsxhoUGyuGi1Bt2TdCvvw92NKInqEYQZbTDrf+RTJSMfHvqM/0b rOvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Vwo8qtj1; 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 j1si8674037qtd.317.2019.09.04.12.50.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 12:50:54 -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=Vwo8qtj1; 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]:37856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5bIr-0006Fa-Jc for patch@linaro.org; Wed, 04 Sep 2019 15:50:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40082) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5b00-0004Qt-8B for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:31:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5azy-0002JG-Dn for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:31:23 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:41025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5azy-0002Ic-6l for qemu-devel@nongnu.org; Wed, 04 Sep 2019 15:31:22 -0400 Received: by mail-pg1-x543.google.com with SMTP id x15so11778859pgg.8 for ; Wed, 04 Sep 2019 12:31:22 -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=gVoXo3oBV5rjG7odbH2AUIPExjRoZyxfBk+LHOtrM+4=; b=Vwo8qtj1VcyQsHwTJghLoAhJf6TUVmZs/MhHhGWfHYzpl/doUFuVSYsdDJxJmWcZtr uWppIDVTcI7WJHzhDfQ2CBMlOeh8DLVE6EDuVyXeUZko+BSwrFTaGulLxDi/Ds4jBIsB Rh0ExsQA9f3hurtn9fbCnwa5g32SBtXBuYVyIlS6iZTuYNvGN6+0MbMeQ+4mgQXUz8H2 u45LA45eom3+qWEbJTR2K9IFIJcfeI/IkYiiKJx2PkO0btuXZmXq+mazOVrdOKTQJntw yu5lBduQu4jAFxiLM1JUjwFy1p0yj910I/dqFrA/VEQD3HfFW3AvyhCP2Xj2aJAyxBPX x0pw== 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=gVoXo3oBV5rjG7odbH2AUIPExjRoZyxfBk+LHOtrM+4=; b=d5WNfKzdtz44TPPrcP+gdRKHuM5tbv2q7lQqrXhIFCCJLSgwUnvX9bFTxErecWK7gV XyG9LE9j1tcrDL3utVV7//qNzNS/z58pJUrsp9hQMPn7H/9EwCe/Oq02MLj7jWyh+pKK 2/FdgxEmwJtP7yB76QiGJOqXca8rd8uHyrqw18MXLEHUWMtON3uQfAyzmX2qysPy0c+X NO0e98u9p6RZxO9SXMtI1Wc/t5jojTSMbqnpBqeMAnqzjf/funnlPjekjQ3EXXlVQhiV p7vSYA78BtSdxT03VGIoWHjmhNMjkDgLGtXQT73Ww9vjBG9QzHtxp/ISCr3xqgyalSFh kQIA== X-Gm-Message-State: APjAAAVVk1UV+bl/6wVT2W2d1eAlsr+QFOzs+3nI38qn+e+oeCVt5+Ve d8Ghxt1cSNlTZjOCVWjP5fOGvYCGTek= X-Received: by 2002:aa7:98d2:: with SMTP id e18mr10640019pfm.188.1567625480867; Wed, 04 Sep 2019 12:31:20 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id f6sm18999174pga.50.2019.09.04.12.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 12:31:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 4 Sep 2019 12:30:06 -0700 Message-Id: <20190904193059.26202-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904193059.26202-1-richard.henderson@linaro.org> References: <20190904193059.26202-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::543 Subject: [Qemu-devel] [PATCH v4 16/69] 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. Reviewed-by: Peter Maydell 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 diff --git a/target/arm/translate.c b/target/arm/translate.c index 386a460bf5..7de6949db3 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8490,6 +8490,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. */ @@ -8778,18 +8791,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 */ @@ -10236,13 +10238,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: @@ -10275,9 +10277,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