From patchwork Wed Aug 28 19:04:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 172434 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1193895ily; Wed, 28 Aug 2019 12:27:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqziuapmW+yJMYYAfPHw7TiKZXllk0iBiqrp8P2vTBoJCGCsrF3330dwKYUr8MxJvZS0SVo1 X-Received: by 2002:a0c:f150:: with SMTP id y16mr4042629qvl.28.1567020420458; Wed, 28 Aug 2019 12:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567020420; cv=none; d=google.com; s=arc-20160816; b=pMlMwjbeKK6ALHzL5493T6/8+wozBWlGjZop43/Ef+bi93ag1TYeB8FR5GXYec5+2S S4qnHhWFJJkSKF5VB+Pa9aPBFojI+8I+kXV+FSWZOldLIFAVoHCv3QJ5tEuJyum1q0Qd QBlmJXq61QOBas0Y2PBGGU7hR3grHnhjZUyMnBieGt6txtE2fOdJsIm4gwiePgaxeji5 vkFq7Aed0iiLXYBffsu71wloTfL6G70wRqJtJ1Ycjq0Aj4ud3KST6aXdPBOkhRMJ+BfV k20APXq3MFsU4X78bUSeVTVNXQEnwohLkvmhTSEcbP4sTC/3Lt3rWoRQhItolJA1GAe2 ac4g== 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=kMYNrgdh+zVmbpqY6NRWPsaPYHb8zLq/GT6BXuVbbI8=; b=pHe6vhsOdqbMFaiSPllhDYWl4sRtl3PBltFnvCHJAp767WLson6sdYLuKnDJ2YXVRu xf+JAYfL8h2uIw5I5Uqx2YMgphRxafjFmk8ecXzTLHIM1fnWnwiPMw9QBKxusS47V9NG UD0JNqcUdUkrRu5FebKAnfqpif9pOUDXgQxDzDlVsFXahXaAXOM77YoemKaGUR0SjLvh F2+rqLDCJwdKC+786SwgGHMPLQx0gRdl2zUtAm8CR3qRTG/OQbNkLbHgSnfsuUIQSmtx ghfDzleEuyy5FOuYNDCpX+z1svBLe9bHO2TA9MidEHratFGfpMFfk5UBiVbVPSpfhzDl fgzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oBxrWRj0; 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 c1si185645qvc.92.2019.08.28.12.27.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Aug 2019 12:27:00 -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=oBxrWRj0; 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]:41250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i33at-0007n1-Az for patch@linaro.org; Wed, 28 Aug 2019 15:26:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37668) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i33Fy-0003FS-53 for qemu-devel@nongnu.org; Wed, 28 Aug 2019 15:05:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i33Fv-0008PH-Ct for qemu-devel@nongnu.org; Wed, 28 Aug 2019 15:05:20 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45023) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i33Fv-0008OV-6p for qemu-devel@nongnu.org; Wed, 28 Aug 2019 15:05:19 -0400 Received: by mail-pl1-x641.google.com with SMTP id t14so383414plr.11 for ; Wed, 28 Aug 2019 12:05:19 -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=kMYNrgdh+zVmbpqY6NRWPsaPYHb8zLq/GT6BXuVbbI8=; b=oBxrWRj01us5QbyPRWalje+lJg7geKNc++aF95qu35DuHUO5XHialqu+pfvQmv3Zow buMJ6MzFJOZJ8Vhhl4QPwVi0UrlOikzOvSR/K+oEw4oinkdW3R+Osyurr5zRM9U34BIW pRIpJfFMtUGdDzYNIkQPUAOm3vD7WxjRPr9K5Y3udF1+XIbPYzTmFw+XBiLctpbuxZtj 8rKhrSjNCGpX/UQbmZO7dJwuboGLHO2lBRaoJDduubx4ZMmP2J2rCXn+F8k53VVAnGGJ hKzc3jR/kXeSVn3dSTHFQ3uw32QdzmxfDjiYmgy5KemW/lyWU9NOiAnh3maLxoR6Z9cC HYiQ== 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=kMYNrgdh+zVmbpqY6NRWPsaPYHb8zLq/GT6BXuVbbI8=; b=EXeAASBRo7RrfpHxm2Fup2N52bregNMW3toeTZiKDiy2Nxv9e7ShoXzsxr9JONxmIQ t/RAKEGh63LrqndTXWZM3vx2smDd2BhCYcZHzTmyZaeKe5aNKoWCE9VmflVrDiGxtRfb lw0bfDKD2Mv7NJfFfdWPphyjTrRkOeiWmdnE34Sa8yV5oCUdjQjrf8QPvS/XPUKDWp2V r241KlmUBm7kyxbnnEIOQL4dQqd6xUe7HipuADKkBOYVd8LunankmzjwmpgQTXBWkbyS wkG6W6KcFKNmVPJb9FhXW4RnmjZewyFe0u825atZQ/5s5QteCbnQdiHwKliAdDAI6056 DJQg== X-Gm-Message-State: APjAAAVpPQDVIA21RTJj8PafwVAaO1wMDFLBkHWfi04jQRZB+wuNxegr Fu6Fs69AYoxxl++blZgS7Gehj4O88lg= X-Received: by 2002:a17:902:8e8b:: with SMTP id bg11mr5737621plb.93.1567019117927; Wed, 28 Aug 2019 12:05: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 f27sm2967944pgm.60.2019.08.28.12.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 12:05:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 28 Aug 2019 12:04:01 -0700 Message-Id: <20190828190456.30315-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190828190456.30315-1-richard.henderson@linaro.org> References: <20190828190456.30315-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::641 Subject: [Qemu-devel] [PATCH v3 14/69] target/arm: Convert Cyclic Redundancy Check 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" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate.c | 121 +++++++++++++++++++---------------------- target/arm/a32.decode | 9 +++ target/arm/t32.decode | 7 +++ 3 files changed, 72 insertions(+), 65 deletions(-) -- 2.17.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 491c8bdc8b..c2420ff45e 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8294,6 +8294,57 @@ static bool trans_MSR_imm(DisasContext *s, arg_MSR_imm *a) return true; } +/* + * Cyclic Redundancy Check + */ + +static bool op_crc32(DisasContext *s, arg_rrr *a, bool c, TCGMemOp sz) +{ + TCGv_i32 t1, t2, t3; + + if (!dc_isar_feature(aa32_crc32, s)) { + return false; + } + + t1 = load_reg(s, a->rn); + t2 = load_reg(s, a->rm); + switch (sz) { + case MO_8: + gen_uxtb(t2); + break; + case MO_16: + gen_uxth(t2); + break; + case MO_32: + break; + default: + g_assert_not_reached(); + } + t3 = tcg_const_i32(1 << sz); + if (c) { + gen_helper_crc32c(t1, t1, t2, t3); + } else { + gen_helper_crc32(t1, t1, t2, t3); + } + tcg_temp_free_i32(t2); + tcg_temp_free_i32(t3); + store_reg(s, a->rd, t1); + return true; +} + +#define DO_CRC32(NAME, c, sz) \ +static bool trans_##NAME(DisasContext *s, arg_rrr *a) \ + { return op_crc32(s, a, c, sz); } + +DO_CRC32(CRC32B, false, MO_8) +DO_CRC32(CRC32H, false, MO_16) +DO_CRC32(CRC32W, false, MO_32) +DO_CRC32(CRC32CB, true, MO_8) +DO_CRC32(CRC32CH, true, MO_16) +DO_CRC32(CRC32CW, true, MO_32) + +#undef DO_CRC32 + /* * Miscellaneous instructions */ @@ -8709,39 +8760,9 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) gen_bx(s, tmp); break; case 0x4: - { - /* crc32/crc32c */ - uint32_t c = extract32(insn, 8, 4); - - /* Check this CPU supports ARMv8 CRC instructions. - * op1 == 3 is UNPREDICTABLE but handle as UNDEFINED. - * Bits 8, 10 and 11 should be zero. - */ - if (!dc_isar_feature(aa32_crc32, s) || op1 == 0x3 || (c & 0xd) != 0) { - goto illegal_op; - } - - rn = extract32(insn, 16, 4); - rd = extract32(insn, 12, 4); - - tmp = load_reg(s, rn); - tmp2 = load_reg(s, rm); - if (op1 == 0) { - tcg_gen_andi_i32(tmp2, tmp2, 0xff); - } else if (op1 == 1) { - tcg_gen_andi_i32(tmp2, tmp2, 0xffff); - } - tmp3 = tcg_const_i32(1 << op1); - if (c & 0x2) { - gen_helper_crc32c(tmp, tmp, tmp2, tmp3); - } else { - gen_helper_crc32(tmp, tmp, tmp2, tmp3); - } - tcg_temp_free_i32(tmp2); - tcg_temp_free_i32(tmp3); - store_reg(s, rd, tmp); - break; - } + /* crc32 */ + /* All done in decodetree. Illegal ops reach here. */ + goto illegal_op; case 0x5: /* Saturating addition and subtraction. */ /* All done in decodetree. Reach here for illegal ops. */ @@ -10181,16 +10202,13 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) goto illegal_op; } break; - case 0x20: /* crc32/crc32c */ + case 0x20: /* crc32/crc32c, in decodetree */ case 0x21: case 0x22: case 0x28: case 0x29: case 0x2a: - if (!dc_isar_feature(aa32_crc32, s)) { - goto illegal_op; - } - break; + goto illegal_op; default: goto illegal_op; } @@ -10219,33 +10237,6 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) case 0x18: /* clz */ tcg_gen_clzi_i32(tmp, tmp, 32); break; - case 0x20: - case 0x21: - case 0x22: - case 0x28: - case 0x29: - case 0x2a: - { - /* crc32/crc32c */ - uint32_t sz = op & 0x3; - uint32_t c = op & 0x8; - - tmp2 = load_reg(s, rm); - if (sz == 0) { - tcg_gen_andi_i32(tmp2, tmp2, 0xff); - } else if (sz == 1) { - tcg_gen_andi_i32(tmp2, tmp2, 0xffff); - } - tmp3 = tcg_const_i32(1 << sz); - if (c) { - gen_helper_crc32c(tmp, tmp, tmp2, tmp3); - } else { - gen_helper_crc32(tmp, tmp, tmp2, tmp3); - } - tcg_temp_free_i32(tmp2); - tcg_temp_free_i32(tmp3); - break; - } default: g_assert_not_reached(); } diff --git a/target/arm/a32.decode b/target/arm/a32.decode index 6ee12c1140..a8ef435b15 100644 --- a/target/arm/a32.decode +++ b/target/arm/a32.decode @@ -182,6 +182,15 @@ SMULTT .... 0001 0110 .... 0000 .... 1110 .... @rd0mn } MSR_imm .... 0011 0110 .... 1111 .... .... .... @msr_i r=1 +# Cyclic Redundancy Check + +CRC32B .... 0001 0000 .... .... 0000 0100 .... @rndm +CRC32H .... 0001 0010 .... .... 0000 0100 .... @rndm +CRC32W .... 0001 0100 .... .... 0000 0100 .... @rndm +CRC32CB .... 0001 0000 .... .... 0010 0100 .... @rndm +CRC32CH .... 0001 0010 .... .... 0010 0100 .... @rndm +CRC32CW .... 0001 0100 .... .... 0010 0100 .... @rndm + # Miscellaneous instructions %sysm 8:1 16:4 diff --git a/target/arm/t32.decode b/target/arm/t32.decode index 98b682e7ec..261db100ff 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -172,6 +172,13 @@ QSUB 1111 1010 1000 .... 1111 .... 1010 .... @rndm QDADD 1111 1010 1000 .... 1111 .... 1001 .... @rndm QDSUB 1111 1010 1000 .... 1111 .... 1011 .... @rndm +CRC32B 1111 1010 1100 .... 1111 .... 1000 .... @rndm +CRC32H 1111 1010 1100 .... 1111 .... 1001 .... @rndm +CRC32W 1111 1010 1100 .... 1111 .... 1010 .... @rndm +CRC32CB 1111 1010 1101 .... 1111 .... 1000 .... @rndm +CRC32CH 1111 1010 1101 .... 1111 .... 1001 .... @rndm +CRC32CW 1111 1010 1101 .... 1111 .... 1010 .... @rndm + # Branches and miscellaneous control %msr_sysm 4:1 8:4