From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630675558652622.3842833205463; Fri, 3 Sep 2021 06:25:58 -0700 (PDT) Received: from localhost ([::1]:45784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9Cf-0006Wr-Bb for importer@patchew.org; Fri, 03 Sep 2021 09:25:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91Y-0001yY-L9 for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:28 -0400 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:37561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91T-0003bf-RK for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:28 -0400 Received: by mail-lf1-x12b.google.com with SMTP id l10so11694535lfg.4 for ; Fri, 03 Sep 2021 06:14:22 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UZI0NUZRO7vu+9LyPmqcshPjbI4d0gEmRAaBgXSjJvo=; b=HGiX3k1mr7XUm7fUfsQ9UEfQFLi/lBr81Nmk/IjFvq/4kOHbstO22gZtVqKDXuKN5o k+/iMi2icwippGhiGZ3pPS2TaEdOm+oA45Dg0ezAsGwbwtDy77UMTdDjsukzdPnL1eM5 wNOHSY+tSM+bV2N8KxYHVxK9k3PJh2xyS+gKOpx1BtaE9ogsWP6oyK9eaRGFB9FNcQn8 l0TPlKOAjxccPr67LQua/4tmv7sUFKYRdFqtKHPHgv5JAOAqOfaTM0OGyvsCH4VcTNXQ vViGPZK1nkjj2spv1jk9u/tlccWX058B5UTyF+cboVCwb7BU2iSsh7KXQ59LuGcQEK+g 1NUQ== 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:mime-version:content-transfer-encoding; bh=UZI0NUZRO7vu+9LyPmqcshPjbI4d0gEmRAaBgXSjJvo=; b=OwJxw3Qk7WiQa7FOWHdCvD+5KkEntNurpEs53KbiORL4hxcF+AkHzuosN1fl43KDCz t2N1mGaqk4WcovAw7LtgbRfDi2nVRqTsvRljssJB5LdiajidjrGhKXVTCWvBmaUBdafj P+QHenz/Jahrot0n69B2Jb0gmtQCCw65YJn23Oh92tk73n6LGFgq/iTWy/pPc6hgx5ok mXPlx49KFoWyy7noLB7gdNbkafQSFdQCqICM0A1jYmi22EO4iTG9cO+q50dIWwnxR+vP 5O2GDYO6bisgDSFoMeQRjc9JGVwu/ghjzJ1dpnzDKAD6kg6ujzWY61FprSVevaVBM2xZ 2yzQ== X-Gm-Message-State: AOAM530vXBJVYJfCECaspclugW5sGQ8WChQMv7J8L06i26mq5FuaGQSy sa5EnvBKtbjpRDj1N9yL4W4moQbtuD97id/lrFE= X-Google-Smtp-Source: ABdhPJxj2m6hKEr12igLciVC0JdZMr0gAyIe8pgqAtPVeg3As69cj1G34bV4gt5u/MVTsF9yAcYn6w== X-Received: by 2002:a05:6512:39cd:: with SMTP id k13mr2792207lfu.258.1630674860676; Fri, 03 Sep 2021 06:14:20 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 01/14] target/riscv: Add x-zba, x-zbb, x-zbc and x-zbs properties Date: Fri, 3 Sep 2021 15:14:04 +0200 Message-Id: <20210903131417.2248471-2-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lf1-x12b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630675559495100001 Content-Type: text/plain; charset="utf-8" The bitmanipulation ISA extensions will be ratified as individual small extension packages instead of a large B-extension. The first new instructions through the door (these have completed public review) are Zb[abcs]. This adds new 'x-zba', 'x-zbb', 'x-zbc' and 'x-zbs' properties for these in target/riscv/cpu.[ch]. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v3) Changes in v3: - Split off removal of 'x-b' property and 'ext_b' field into a separate patch to ensure bisectability. target/riscv/cpu.c | 4 ++++ target/riscv/cpu.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 991a6bb760..c7bc1f9f44 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -585,6 +585,10 @@ static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("u", RISCVCPU, cfg.ext_u, true), /* This is experimental so mark with 'x-' */ DEFINE_PROP_BOOL("x-b", RISCVCPU, cfg.ext_b, false), + DEFINE_PROP_BOOL("x-zba", RISCVCPU, cfg.ext_zba, false), + DEFINE_PROP_BOOL("x-zbb", RISCVCPU, cfg.ext_zbb, false), + DEFINE_PROP_BOOL("x-zbc", RISCVCPU, cfg.ext_zbc, false), + DEFINE_PROP_BOOL("x-zbs", RISCVCPU, cfg.ext_zbs, false), DEFINE_PROP_BOOL("x-h", RISCVCPU, cfg.ext_h, false), DEFINE_PROP_BOOL("x-v", RISCVCPU, cfg.ext_v, false), DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true), diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index bf1c899c00..7c4cd8ea89 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -293,6 +293,10 @@ struct RISCVCPU { bool ext_u; bool ext_h; bool ext_v; + bool ext_zba; + bool ext_zbb; + bool ext_zbc; + bool ext_zbs; bool ext_counters; bool ext_ifencei; bool ext_icsr; --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630675744146944.313290735179; Fri, 3 Sep 2021 06:29:04 -0700 (PDT) Received: from localhost ([::1]:55528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9Ff-0004yS-1o for importer@patchew.org; Fri, 03 Sep 2021 09:29:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91Z-000201-1C for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:29 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:36376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91U-0003by-IM for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:28 -0400 Received: by mail-lj1-x236.google.com with SMTP id p15so9592752ljn.3 for ; Fri, 03 Sep 2021 06:14:23 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EOxuTXsFP1/9WcDOvR6tVZS46pyXRqel41EuM3dI2L8=; b=ydwCbkFVJfU7QnN1Jy+b0xdXI88y9AE4dfSSC16Ri+VHvyHspP+bg6XgCGaG8FxNnX 24QGHPO4/DQvWZhvSaO3bJBHhxjGlGrQBCpGbOR22bJzbmChwSiU4Lu7JEAclH1izvRJ Rlr6kIqrFPuUfvMVHHd2FvgKnVaMTMe8p+o+e3T7/clGi8HJzM1OejPm8PSZUNJ7lehG XefVIULHBhlhmauqKuid6ycZ3i+aeU5jz5TcJaoT4u1lwjlhut06t79Y3609jSBNIYhj xRJ17ET/GLXivr/2C7mTXQ9ouRHu19Y8pahP7ciR7z0Vvsma1KXNiNf53sltSe09eoW3 /OlA== 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:mime-version:content-transfer-encoding; bh=EOxuTXsFP1/9WcDOvR6tVZS46pyXRqel41EuM3dI2L8=; b=RHogiwZfCfgo3yriTav3EMdEWArRsGDrabcOUc9M4Gr4QVqcJtBjJOq8Z45yXFU6mg e+HXXfQgdBxpJMufKTe4rjk0dASGGupAdT7491Vxmht5knkSEZrcli0WVvVADkW4TXge v/7FUa45X7+KfuPj7Wr8M2Knwg6Ja3kbKaVj/HdGIrLptSkJWBl6o+HWkLO6/RLavGbH Y2fYZwkzMRCDJEIz70Pn851v0x3s1gOE3NvzPW5gcuwRtKrAXVC0gZv2rIdOe2RLY3D8 kkHgZFZRpa3/48IBnZBrAOrawxVTZnRQJxO6Nh2jeM/ujU1KAGNtB/hF0DyDY9SIC25X iEug== X-Gm-Message-State: AOAM530zhcUgIXVY0jsunQ9ibg1blSJOZ/oflCVLQELulUYMYzox1UvK u6tlVyrijNFEnb0xv07GR5xivCVXWmEPRd13+RE= X-Google-Smtp-Source: ABdhPJxnuW7ZRSoTtgqOZwllxjzSgRpnnmyKhE3n28x87prQTSfut7uHrNGLlNDgHpW4b8RYO7HE2w== X-Received: by 2002:a2e:7303:: with SMTP id o3mr2801690ljc.273.1630674861678; Fri, 03 Sep 2021 06:14:21 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 02/14] target/riscv: Reassign instructions to the Zba-extension Date: Fri, 3 Sep 2021 15:14:05 +0200 Message-Id: <20210903131417.2248471-3-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x236.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630675745582100001 Content-Type: text/plain; charset="utf-8" The following instructions are part of Zba: - add.uw (RV64 only) - sh[123]add (RV32 and RV64) - sh[123]add.uw (RV64-only) - slli.uw (RV64-only) Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v3) Changes in v3: - The changes to the Zba instructions (i.e. the REQUIRE_ZBA macro and its use for qualifying the Zba instructions) are moved into a separate commit. target/riscv/insn32.decode | 20 ++++++++++++-------- target/riscv/insn_trans/trans_rvb.c.inc | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index f09f8d5faf..68b163b72d 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -659,6 +659,18 @@ vamomaxd_v 10100 . . ..... ..... 111 ..... 010111= 1 @r_wdvm vamominud_v 11000 . . ..... ..... 111 ..... 0101111 @r_wdvm vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm =20 +# *** RV32 Zba Standard Extension *** +sh1add 0010000 .......... 010 ..... 0110011 @r +sh2add 0010000 .......... 100 ..... 0110011 @r +sh3add 0010000 .......... 110 ..... 0110011 @r + +# *** RV64 Zba Standard Extension (in addition to RV32 Zba) *** +add_uw 0000100 .......... 000 ..... 0111011 @r +sh1add_uw 0010000 .......... 010 ..... 0111011 @r +sh2add_uw 0010000 .......... 100 ..... 0111011 @r +sh3add_uw 0010000 .......... 110 ..... 0111011 @r +slli_uw 00001 ............ 001 ..... 0011011 @sh + # *** RV32B Standard Extension *** clz 011000 000000 ..... 001 ..... 0010011 @r2 ctz 011000 000001 ..... 001 ..... 0010011 @r2 @@ -686,9 +698,6 @@ ror 0110000 .......... 101 ..... 0110011 @r rol 0110000 .......... 001 ..... 0110011 @r grev 0110100 .......... 101 ..... 0110011 @r gorc 0010100 .......... 101 ..... 0110011 @r -sh1add 0010000 .......... 010 ..... 0110011 @r -sh2add 0010000 .......... 100 ..... 0110011 @r -sh3add 0010000 .......... 110 ..... 0110011 @r =20 bseti 00101. ........... 001 ..... 0010011 @sh bclri 01001. ........... 001 ..... 0010011 @sh @@ -717,10 +726,6 @@ rorw 0110000 .......... 101 ..... 0111011 @r rolw 0110000 .......... 001 ..... 0111011 @r grevw 0110100 .......... 101 ..... 0111011 @r gorcw 0010100 .......... 101 ..... 0111011 @r -sh1add_uw 0010000 .......... 010 ..... 0111011 @r -sh2add_uw 0010000 .......... 100 ..... 0111011 @r -sh3add_uw 0010000 .......... 110 ..... 0111011 @r -add_uw 0000100 .......... 000 ..... 0111011 @r =20 bsetiw 0010100 .......... 001 ..... 0011011 @sh5 bclriw 0100100 .......... 001 ..... 0011011 @sh5 @@ -731,4 +736,3 @@ roriw 0110000 .......... 101 ..... 0011011 @sh5 greviw 0110100 .......... 101 ..... 0011011 @sh5 gorciw 0010100 .......... 101 ..... 0011011 @sh5 =20 -slli_uw 00001. ........... 001 ..... 0011011 @sh diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index 9e81f6e3de..3cdd70a2b9 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -1,8 +1,9 @@ /* - * RISC-V translation routines for the RVB Standard Extension. + * RISC-V translation routines for the RVB draft and Zba Standard Extensio= n. * * Copyright (c) 2020 Kito Cheng, kito.cheng@sifive.com * Copyright (c) 2020 Frank Chang, frank.chang@sifive.com + * Copyright (c) 2021 Philipp Tomsich, philipp.tomsich@vrull.eu * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -17,6 +18,12 @@ * this program. If not, see . */ =20 +#define REQUIRE_ZBA(ctx) do { \ + if (!RISCV_CPU(ctx->cs)->cfg.ext_zba) { \ + return false; \ + } \ +} while (0) + static bool trans_clz(DisasContext *ctx, arg_clz *a) { REQUIRE_EXT(ctx, RVB); @@ -229,7 +236,7 @@ static bool trans_gorci(DisasContext *ctx, arg_gorci *a) #define GEN_TRANS_SHADD(SHAMT) = \ static bool trans_sh##SHAMT##add(DisasContext *ctx, arg_sh##SHAMT##add *a)= \ { = \ - REQUIRE_EXT(ctx, RVB); = \ + REQUIRE_ZBA(ctx); = \ return gen_arith(ctx, a, gen_sh##SHAMT##add); = \ } =20 @@ -403,7 +410,7 @@ static bool trans_sh##SHAMT##add_uw(DisasContext *ctx, = \ arg_sh##SHAMT##add_uw *a) \ { \ REQUIRE_64BIT(ctx); \ - REQUIRE_EXT(ctx, RVB); \ + REQUIRE_ZBA(ctx); \ return gen_arith(ctx, a, gen_sh##SHAMT##add_uw); \ } =20 @@ -414,14 +421,14 @@ GEN_TRANS_SHADD_UW(3) static bool trans_add_uw(DisasContext *ctx, arg_add_uw *a) { REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBA(ctx); return gen_arith(ctx, a, gen_add_uw); } =20 static bool trans_slli_uw(DisasContext *ctx, arg_slli_uw *a) { REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBA(ctx); =20 TCGv source1 =3D tcg_temp_new(); gen_get_gpr(source1, a->rs1); --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630675570978828.9872436896522; Fri, 3 Sep 2021 06:26:10 -0700 (PDT) Received: from localhost ([::1]:46648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9Cr-00076q-QV for importer@patchew.org; Fri, 03 Sep 2021 09:26:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91X-0001ux-M8 for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:27 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]:34452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91V-0003cA-GD for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:27 -0400 Received: by mail-lj1-x235.google.com with SMTP id f2so9598289ljn.1 for ; Fri, 03 Sep 2021 06:14:24 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NB+2ymxcOdJCsq3x7YLHFtrO+ls7rryMPAaZ7huJY0o=; b=zyT2OPUOiXeS3K00svb/gMjZxsps/2KSwXiM8Wyw7RDTLle63BKUuJco0z3jRS+pia nBs5b1X8oHimUw+ciGaxPOKxpHoYDbTBy1da3MHNVeB5g9SkKKRESOzoQEULeQPOhFM2 iKiY2tetBmUL8aihw5EZrFyQpg4+2N9QdCHXQJCK/337KpxGO19LuOamFaBWJiNVfOPc B2ccSBdLLsUODoHOJRZzb7qewJKiM3tcXI7kE9xrC0cciddaFGYEPo79UIwSrZZbTuLo AjvtE8Sd9YfbwQX8zoD3HgrXPd/0VdvdPoR3m9pO0FZPcBvIi92O0aZ9ynQ7QFpro2q6 VIPA== 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:mime-version:content-transfer-encoding; bh=NB+2ymxcOdJCsq3x7YLHFtrO+ls7rryMPAaZ7huJY0o=; b=NA3oSP3kAg9pAe+534uqTcUgCGfi554gAPgEvZyPAiM4mcCT/tsMuhj50BVJr0x5uN 3zB+qGu43sdbtZnuURJJ8s/2baKxRnIp/miS6MuiSH1vtlfS7wqgxY+6N2dte8+yIxfH 7oWx6u+uRsW5qslnml7XX8j/BEEc2NI9hatBs1khaNR8Kne6AQKyFKGN4SIGJS3XL0hs 2VoZr7rXWIvQGO6cfalSTPZOh9wcRfjqK+g+pypibDqjmaXrBV1gLR9wnFnxVLJIApuX iUbeow3vxFlD4wC7jW+KxLNYMzoYvyvyIsOgYkmUm1eFizBVK4tgRz6TkpkAND7Ol/3i aOGQ== X-Gm-Message-State: AOAM532PW+pjA5xNm0rEkB1pZ8fsWcNS/s1eiP+GaQlHSvRorbF9/pdu r8+GeGk5xVpz6CK3iLvWn/E02oUboQqLbP/lLcw= X-Google-Smtp-Source: ABdhPJyz1FesxXl/D31j3pw+1lGuD/sNnIcvROV6IRfvPJxhZE54qDHxF6+99JJ6Z+ymDd0Es3sl9A== X-Received: by 2002:a05:651c:170b:: with SMTP id be11mr2791450ljb.219.1630674862604; Fri, 03 Sep 2021 06:14:22 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 03/14] target/riscv: slli.uw is only a valid encoding if shamt first in 64 bits Date: Fri, 3 Sep 2021 15:14:06 +0200 Message-Id: <20210903131417.2248471-4-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x235.google.com X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630675572863100001 Content-Type: text/plain; charset="utf-8" For RV64, the shamt field in slli.uw is 6 bits wide. While the encoding space currently reserves a wider shamt-field (for use is a future RV128 ISA), setting the additional bit to 1 will not map to slli.uw for RV64 and needs to be treated as an illegal instruction. Note that this encoding being reserved for a future RV128 does not imply that no other instructions for RV64-only could be added in this encoding space in the future. As the implementation is separate from the gen_shifti helpers, we keep it that way and add the check for the shamt-width here. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v3) Changes in v3: - Instead of defining a new decoding format, we treat slli.uw as if it had a 7bit-wide field for shamt (the 7th bit is reserved for RV128) and check for validity of the encoding in C code. target/riscv/insn_trans/trans_rvb.c.inc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index 3cdd70a2b9..dcc7b6893d 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -430,6 +430,15 @@ static bool trans_slli_uw(DisasContext *ctx, arg_slli_= uw *a) REQUIRE_64BIT(ctx); REQUIRE_ZBA(ctx); =20 + /* + * The shamt field is only 6 bits for RV64 (with the 7th bit + * remaining reserved for RV128). If the reserved bit is set + * on RV64, the encoding is illegal. + */ + if (a->shamt >=3D TARGET_LONG_BITS) { + return false; + } + TCGv source1 =3D tcg_temp_new(); gen_get_gpr(source1, a->rs1); =20 --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630675576974978.7743657833444; Fri, 3 Sep 2021 06:26:16 -0700 (PDT) Received: from localhost ([::1]:47060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9Cy-0007UW-03 for importer@patchew.org; Fri, 03 Sep 2021 09:26:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91X-0001vQ-Pu for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:27 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]:39813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91V-0003d7-HY for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:27 -0400 Received: by mail-lj1-x235.google.com with SMTP id q21so9554280ljj.6 for ; Fri, 03 Sep 2021 06:14:25 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NKF6J4Nz/aYSq0iBWLPg/Wi+N+rJR7n5q7HTT+s2dwc=; b=r72Qe0/FjVrn1ycr+QaiQ6cUkUimjZ8gVXGjA3U+9kVaL3O7lUUuJtc5B/eF23I2ls J5QxTTmpar9m0V5/HW56opfWMoXXgkg2RBzSp7kA+l3IgVFuhfVBoUpTLqbUASVQrrhN lzRs3/DHV4TE0Wd8YEe+UmnEpWxFbQl09NU4oMhsv7fK4JvmHY6oSp3/WWCXyTEXBWdd Ac5mDNfkbvsfsDB5zTOvJF837Dwx1Oz0ydFEkFOJPpZl3FrcF00CJf885b3stP9XkLbb c9EakjKlcBVaq0mX/5mGJDV7BRyahYTucptjCv7ljIKIMyNtaWxvE+Bao3bzSubsXugi 5aNQ== 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:mime-version:content-transfer-encoding; bh=NKF6J4Nz/aYSq0iBWLPg/Wi+N+rJR7n5q7HTT+s2dwc=; b=espBHggpVeayOB7yqtB39j7kHiFeEcVNPlf++Q3I1HNv/EKdVq/9cNsS/MaQ0m/IK7 Xd0siz6Z4yQ8wEoGop14fB0YE7i14lxcpTl+2u5QsdWbRfbyRUKwpJ99dFRyUW+3R+yj /79wbm8vG3YoxzkJ+z7f/ywhHs/hPhheMSkY5mzbByCFTA8X8nHuqEydvrO/fdI+xWS4 WBjys2VAkbOvDI69zZClKpvOur37vD1g6fo+Ls/XGQHNe4mA1YHRBlM7fPCmYStOeoC/ nN+cf3vMcFEyCynq1pSBFhJ6dhZQw/56D6D7NLsjXGhghekIgIiBgIIfvoBGboSNxmvm SPyw== X-Gm-Message-State: AOAM530H8X4iMs68CU89tWLB/Iyi1zN0B55nShOiaTzzTJ/BOaQEw5ox bZ7+Yiwr5uI5ArLGyQe8zEP4uwZO3umU0nxblMQ= X-Google-Smtp-Source: ABdhPJyyMB5HvjypIA8UWAetAh1KvrukwruNTqBFdFf0pca4jI/m8tzSXg2nq/Uz9+Q7l/SYugiNCg== X-Received: by 2002:a2e:8511:: with SMTP id j17mr2844923lji.407.1630674863815; Fri, 03 Sep 2021 06:14:23 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 04/14] target/riscv: Remove the W-form instructions from Zbs Date: Fri, 3 Sep 2021 15:14:07 +0200 Message-Id: <20210903131417.2248471-5-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x235.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630675577919100001 Content-Type: text/plain; charset="utf-8" Zbs 1.0.0 (just as the 0.93 draft-B before) does no provide for W-form instructions for Zbs (single-bit instructions). Remove them. Note that these instructions had already been removed for the 0.93 version of the draft-B extenstion and have not been present in the binutils patches circulating in January 2021. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v3) Changes in v3: - Remove the W-form instructions from Zbs in a separate commit. target/riscv/insn32.decode | 7 ---- target/riscv/insn_trans/trans_rvb.c.inc | 49 ------------------------- 2 files changed, 56 deletions(-) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 68b163b72d..9abdbcb799 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -716,10 +716,6 @@ cpopw 0110000 00010 ..... 001 ..... 0011011 @r2 =20 packw 0000100 .......... 100 ..... 0111011 @r packuw 0100100 .......... 100 ..... 0111011 @r -bsetw 0010100 .......... 001 ..... 0111011 @r -bclrw 0100100 .......... 001 ..... 0111011 @r -binvw 0110100 .......... 001 ..... 0111011 @r -bextw 0100100 .......... 101 ..... 0111011 @r slow 0010000 .......... 001 ..... 0111011 @r srow 0010000 .......... 101 ..... 0111011 @r rorw 0110000 .......... 101 ..... 0111011 @r @@ -727,9 +723,6 @@ rolw 0110000 .......... 001 ..... 0111011 @r grevw 0110100 .......... 101 ..... 0111011 @r gorcw 0010100 .......... 101 ..... 0111011 @r =20 -bsetiw 0010100 .......... 001 ..... 0011011 @sh5 -bclriw 0100100 .......... 001 ..... 0011011 @sh5 -binviw 0110100 .......... 001 ..... 0011011 @sh5 sloiw 0010000 .......... 001 ..... 0011011 @sh5 sroiw 0010000 .......... 101 ..... 0011011 @sh5 roriw 0110000 .......... 101 ..... 0011011 @sh5 diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index dcc7b6893d..975492d45c 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -279,55 +279,6 @@ static bool trans_packuw(DisasContext *ctx, arg_packuw= *a) return gen_arith(ctx, a, gen_packuw); } =20 -static bool trans_bsetw(DisasContext *ctx, arg_bsetw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftw(ctx, a, gen_bset); -} - -static bool trans_bsetiw(DisasContext *ctx, arg_bsetiw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftiw(ctx, a, gen_bset); -} - -static bool trans_bclrw(DisasContext *ctx, arg_bclrw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftw(ctx, a, gen_bclr); -} - -static bool trans_bclriw(DisasContext *ctx, arg_bclriw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftiw(ctx, a, gen_bclr); -} - -static bool trans_binvw(DisasContext *ctx, arg_binvw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftw(ctx, a, gen_binv); -} - -static bool trans_binviw(DisasContext *ctx, arg_binviw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftiw(ctx, a, gen_binv); -} - -static bool trans_bextw(DisasContext *ctx, arg_bextw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftw(ctx, a, gen_bext); -} - static bool trans_slow(DisasContext *ctx, arg_slow *a) { REQUIRE_64BIT(ctx); --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630675749334347.6974242238106; Fri, 3 Sep 2021 06:29:09 -0700 (PDT) Received: from localhost ([::1]:56004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9Fk-0005HW-BT for importer@patchew.org; Fri, 03 Sep 2021 09:29:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91Y-0001xk-FF for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:28 -0400 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]:38803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91W-0003dL-If for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:28 -0400 Received: by mail-lj1-x229.google.com with SMTP id g14so9558663ljk.5 for ; Fri, 03 Sep 2021 06:14:26 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iMopUCg9QAzWlunfdm/GsDlTDvbpbsrVAzOY1rKxOCQ=; b=cjYr3duJgHt4zlpQnlRJPjIz4s7z7URU8GSeQbd5HdEwqbo3pap1MFeFxZNtHHX/ii gUEJl2lz48Vp3jJ0dnWlYjzQE04LRsNmwSx12Bihra8MxvnasLZsRcHhW4la7VhPoBPk 6VM9IFcnhhH++5HCLjDbQBSjRjIjxkAVgRJ9oc25V8keFHjWKqGMeR3TkelwcZif2/TP yhjL8LeIPuo/Ollrucy9K1AAwTqjxc//p3hkgZyBeZZxE+vk7Ho9pRKO5T4t2WDQOpN+ 1KY8V3BFbXC+Q2vP+SkfY+xuoqjhL1XTA0zCXVxn5Yli8fAuEPIlu+TD8ATEQcLhyuTy t9ww== 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:mime-version:content-transfer-encoding; bh=iMopUCg9QAzWlunfdm/GsDlTDvbpbsrVAzOY1rKxOCQ=; b=lUzjsziIN8GM2F8DjqkOgDKgpdni1iiasOykIHhH+zn8NcJgptoOvL8kQRK+0EinSn u9XKLLf29JuL+CHxcjoWWSynwP3y5GxyB+2X450hKURPkd9UQhmD7ehKzEmxZZqEc8wF JxyuQ+oTTervyh90rrg8CJTmk/+4llkuQrNFsdARp4eTkRYlafj3rjg4rjPKOpZDFvRe ABwGDDCKV6edndGePeNNXhq8HXv5Wq0tdzt2ZxmJ9zgQilMOdFoEgU4muXukiXLQrfah i1U+PRolqIHVMXkd+OLzdJtb5zB9NNZCv2ekdTbe6jG0HV0BvbRZgw0GtEH/Njdzmanx 4TmQ== X-Gm-Message-State: AOAM531S1LeUqVQm/oacIaCqikxv0inMJQkYhR9LuXlsKt1aqrRembL4 oRejR1p8EGvvmEY7li3c1aJYuQ8rFLY+40BPcWQ= X-Google-Smtp-Source: ABdhPJzgblvDtLnSdvCHgI+UqwlAPcd2QJ7H56twq4ULtG4vwVA23v30AL2vTcp6VWzbkWU2IphLFQ== X-Received: by 2002:a2e:8495:: with SMTP id b21mr2906251ljh.4.1630674864879; Fri, 03 Sep 2021 06:14:24 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 05/14] target/riscv: Remove shift-one instructions (proposed Zbo in pre-0.93 draft-B) Date: Fri, 3 Sep 2021 15:14:08 +0200 Message-Id: <20210903131417.2248471-6-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x229.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630675749973100001 Content-Type: text/plain; charset="utf-8" The Zb[abcs] ratification package does not include the proposed shift-one instructions. There currently is no clear plan to whether these (or variants of them) will be ratified as Zbo (or a different extension) or what the timeframe for such a decision could be. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v3) Changes in v3: - Remove shift-one instructions in a separate commit. target/riscv/insn32.decode | 8 ---- target/riscv/insn_trans/trans_rvb.c.inc | 52 ------------------------- target/riscv/translate.c | 14 ------- 3 files changed, 74 deletions(-) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 9abdbcb799..7e38477553 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -692,8 +692,6 @@ bset 0010100 .......... 001 ..... 0110011 @r bclr 0100100 .......... 001 ..... 0110011 @r binv 0110100 .......... 001 ..... 0110011 @r bext 0100100 .......... 101 ..... 0110011 @r -slo 0010000 .......... 001 ..... 0110011 @r -sro 0010000 .......... 101 ..... 0110011 @r ror 0110000 .......... 101 ..... 0110011 @r rol 0110000 .......... 001 ..... 0110011 @r grev 0110100 .......... 101 ..... 0110011 @r @@ -703,8 +701,6 @@ bseti 00101. ........... 001 ..... 0010011 @sh bclri 01001. ........... 001 ..... 0010011 @sh binvi 01101. ........... 001 ..... 0010011 @sh bexti 01001. ........... 101 ..... 0010011 @sh -sloi 00100. ........... 001 ..... 0010011 @sh -sroi 00100. ........... 101 ..... 0010011 @sh rori 01100. ........... 101 ..... 0010011 @sh grevi 01101. ........... 101 ..... 0010011 @sh gorci 00101. ........... 101 ..... 0010011 @sh @@ -716,15 +712,11 @@ cpopw 0110000 00010 ..... 001 ..... 0011011 @r2 =20 packw 0000100 .......... 100 ..... 0111011 @r packuw 0100100 .......... 100 ..... 0111011 @r -slow 0010000 .......... 001 ..... 0111011 @r -srow 0010000 .......... 101 ..... 0111011 @r rorw 0110000 .......... 101 ..... 0111011 @r rolw 0110000 .......... 001 ..... 0111011 @r grevw 0110100 .......... 101 ..... 0111011 @r gorcw 0010100 .......... 101 ..... 0111011 @r =20 -sloiw 0010000 .......... 001 ..... 0011011 @sh5 -sroiw 0010000 .......... 101 ..... 0011011 @sh5 roriw 0110000 .......... 101 ..... 0011011 @sh5 greviw 0110100 .......... 101 ..... 0011011 @sh5 gorciw 0010100 .......... 101 ..... 0011011 @sh5 diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index 975492d45c..ac706349f5 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -162,30 +162,6 @@ static bool trans_bexti(DisasContext *ctx, arg_bexti *= a) return gen_shifti(ctx, a, gen_bext); } =20 -static bool trans_slo(DisasContext *ctx, arg_slo *a) -{ - REQUIRE_EXT(ctx, RVB); - return gen_shift(ctx, a, gen_slo); -} - -static bool trans_sloi(DisasContext *ctx, arg_sloi *a) -{ - REQUIRE_EXT(ctx, RVB); - return gen_shifti(ctx, a, gen_slo); -} - -static bool trans_sro(DisasContext *ctx, arg_sro *a) -{ - REQUIRE_EXT(ctx, RVB); - return gen_shift(ctx, a, gen_sro); -} - -static bool trans_sroi(DisasContext *ctx, arg_sroi *a) -{ - REQUIRE_EXT(ctx, RVB); - return gen_shifti(ctx, a, gen_sro); -} - static bool trans_ror(DisasContext *ctx, arg_ror *a) { REQUIRE_EXT(ctx, RVB); @@ -279,34 +255,6 @@ static bool trans_packuw(DisasContext *ctx, arg_packuw= *a) return gen_arith(ctx, a, gen_packuw); } =20 -static bool trans_slow(DisasContext *ctx, arg_slow *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftw(ctx, a, gen_slo); -} - -static bool trans_sloiw(DisasContext *ctx, arg_sloiw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftiw(ctx, a, gen_slo); -} - -static bool trans_srow(DisasContext *ctx, arg_srow *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftw(ctx, a, gen_sro); -} - -static bool trans_sroiw(DisasContext *ctx, arg_sroiw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftiw(ctx, a, gen_sro); -} - static bool trans_rorw(DisasContext *ctx, arg_rorw *a) { REQUIRE_64BIT(ctx); diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 6983be5723..fc22ae82d0 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -595,20 +595,6 @@ static void gen_bext(TCGv ret, TCGv arg1, TCGv shamt) tcg_gen_andi_tl(ret, ret, 1); } =20 -static void gen_slo(TCGv ret, TCGv arg1, TCGv arg2) -{ - tcg_gen_not_tl(ret, arg1); - tcg_gen_shl_tl(ret, ret, arg2); - tcg_gen_not_tl(ret, ret); -} - -static void gen_sro(TCGv ret, TCGv arg1, TCGv arg2) -{ - tcg_gen_not_tl(ret, arg1); - tcg_gen_shr_tl(ret, ret, arg2); - tcg_gen_not_tl(ret, ret); -} - static bool gen_grevi(DisasContext *ctx, arg_grevi *a) { TCGv source1 =3D tcg_temp_new(); --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630675980176514.1632580369886; Fri, 3 Sep 2021 06:33:00 -0700 (PDT) Received: from localhost ([::1]:36052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9JT-0002ZD-70 for importer@patchew.org; Fri, 03 Sep 2021 09:32:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91Z-00021k-F5 for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:29 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]:39806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91X-0003dc-Mr for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:29 -0400 Received: by mail-lj1-x22d.google.com with SMTP id q21so9554452ljj.6 for ; Fri, 03 Sep 2021 06:14:27 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LRnVrwRCuMr+9UoCLC0NdtbpN+j1zxeD7w+qDcSesiQ=; b=dRZeZqZlU69sQZOhx0h8/RFvnO4pxl1OctVZkw/x1DnA9vxTlG8jPBQo9CYueZCF2Z nrjHBTFy+FiPImINEMAxL0WX6E9XSybAV6Jr153f78U14tCDnwPUch70ew7odb8og7Wc QPPRLCgUuRQuk0NZls2uc35bOi/ty6zwIfjuQ9QxMkbBCPS9YdcbqFh1fSxU6MCwKAzo VwG8NrhZAS2cSTEeZZvuNn/scH5z1lIJ+sooqxj6Qa9yMUvi6/Cdh2uIcq0MmZLwwDlE q3yzL90mnP9Xk+k8X3pL94UZegLaPdTHydJTiqDmmLveY5aQgH1Pe7SRzH4NA0IVTBck jZ1w== 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:mime-version:content-transfer-encoding; bh=LRnVrwRCuMr+9UoCLC0NdtbpN+j1zxeD7w+qDcSesiQ=; b=s+gcQ+d5C2+72krcYhcg7ATwcBUM2hsd9QRLut3/uHaPdc0V2KZnLZmhWcKLWAsXNY cwQ5+iLD+tMr9DF1bzyZe+3yLDJ6f084HyC+9XGx2BZsAL2ndCbJ/tAdq0sJa/6TYCej d+ONqzzGQ3t0K4qZo7eKpEOHlgAUjyJPiJXulTR69Z83eompZpAj867WBhiM32i5++Cl NviYVD9qbueguYNuBu+m6Z2kfZywsAnDOAkTFnHlg0jI79sJFlmmmUmMeQWJ1sYcW1Ts BdD8/OVI7fAU6/9kuybO2imQiK2q2D/y1OsPrWivaSwXOxMmgzLSWXTSD2XhIa0asQ/O nayA== X-Gm-Message-State: AOAM5315GDsNL4qLgRnIF/pFENm4WrfHTXBGkxg6JtfOfHdVFcsQcA1f 5OV86aVyzORRD7eszAQmI7kc6tdBTHjvUKoECgw= X-Google-Smtp-Source: ABdhPJwcG1gYwf/tihODpGUzl1EwH+SoButjBkfWnpSq3o4xr0qe429kUQ8cwJGnv1C0Dj3XotqiEA== X-Received: by 2002:a2e:90cf:: with SMTP id o15mr2919186ljg.14.1630674865909; Fri, 03 Sep 2021 06:14:25 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 06/14] target/riscv: Reassign instructions to the Zbs-extension Date: Fri, 3 Sep 2021 15:14:09 +0200 Message-Id: <20210903131417.2248471-7-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x22d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630675981379100001 Content-Type: text/plain; charset="utf-8" The following instructions are part of Zbs: - b{set,clr,ext,inv} - b{set,clr,ext,inv}i Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v3) Changes in v3: - The changes to the Zbs instructions (i.e. the REQUIRE_ZBS macro) and its use for qualifying the Zba instructions) are moved into a separate commit. target/riscv/insn32.decode | 17 +++++++++-------- target/riscv/insn_trans/trans_rvb.c.inc | 24 +++++++++++++++--------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 7e38477553..1166e7f648 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -688,19 +688,11 @@ min 0000101 .......... 100 ..... 0110011 @r minu 0000101 .......... 101 ..... 0110011 @r max 0000101 .......... 110 ..... 0110011 @r maxu 0000101 .......... 111 ..... 0110011 @r -bset 0010100 .......... 001 ..... 0110011 @r -bclr 0100100 .......... 001 ..... 0110011 @r -binv 0110100 .......... 001 ..... 0110011 @r -bext 0100100 .......... 101 ..... 0110011 @r ror 0110000 .......... 101 ..... 0110011 @r rol 0110000 .......... 001 ..... 0110011 @r grev 0110100 .......... 101 ..... 0110011 @r gorc 0010100 .......... 101 ..... 0110011 @r =20 -bseti 00101. ........... 001 ..... 0010011 @sh -bclri 01001. ........... 001 ..... 0010011 @sh -binvi 01101. ........... 001 ..... 0010011 @sh -bexti 01001. ........... 101 ..... 0010011 @sh rori 01100. ........... 101 ..... 0010011 @sh grevi 01101. ........... 101 ..... 0010011 @sh gorci 00101. ........... 101 ..... 0010011 @sh @@ -721,3 +713,12 @@ roriw 0110000 .......... 101 ..... 0011011 @sh5 greviw 0110100 .......... 101 ..... 0011011 @sh5 gorciw 0010100 .......... 101 ..... 0011011 @sh5 =20 +# *** RV32 Zbs Standard Extension *** +bclr 0100100 .......... 001 ..... 0110011 @r +bclri 01001. ........... 001 ..... 0010011 @sh +bext 0100100 .......... 101 ..... 0110011 @r +bexti 01001. ........... 101 ..... 0010011 @sh +binv 0110100 .......... 001 ..... 0110011 @r +binvi 01101. ........... 001 ..... 0010011 @sh +bset 0010100 .......... 001 ..... 0110011 @r +bseti 00101. ........... 001 ..... 0010011 @sh diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index ac706349f5..21d713df27 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -1,5 +1,5 @@ /* - * RISC-V translation routines for the RVB draft and Zba Standard Extensio= n. + * RISC-V translation routines for the RVB draft Zb[as] Standard Extension. * * Copyright (c) 2020 Kito Cheng, kito.cheng@sifive.com * Copyright (c) 2020 Frank Chang, frank.chang@sifive.com @@ -24,6 +24,12 @@ } \ } while (0) =20 +#define REQUIRE_ZBS(ctx) do { \ + if (!RISCV_CPU(ctx->cs)->cfg.ext_zbs) { \ + return false; \ + } \ +} while (0) + static bool trans_clz(DisasContext *ctx, arg_clz *a) { REQUIRE_EXT(ctx, RVB); @@ -116,49 +122,49 @@ static bool trans_sext_h(DisasContext *ctx, arg_sext_= h *a) =20 static bool trans_bset(DisasContext *ctx, arg_bset *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBS(ctx); return gen_shift(ctx, a, gen_bset); } =20 static bool trans_bseti(DisasContext *ctx, arg_bseti *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBS(ctx); return gen_shifti(ctx, a, gen_bset); } =20 static bool trans_bclr(DisasContext *ctx, arg_bclr *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBS(ctx); return gen_shift(ctx, a, gen_bclr); } =20 static bool trans_bclri(DisasContext *ctx, arg_bclri *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBS(ctx); return gen_shifti(ctx, a, gen_bclr); } =20 static bool trans_binv(DisasContext *ctx, arg_binv *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBS(ctx); return gen_shift(ctx, a, gen_binv); } =20 static bool trans_binvi(DisasContext *ctx, arg_binvi *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBS(ctx); return gen_shifti(ctx, a, gen_binv); } =20 static bool trans_bext(DisasContext *ctx, arg_bext *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBS(ctx); return gen_shift(ctx, a, gen_bext); } =20 static bool trans_bexti(DisasContext *ctx, arg_bexti *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBS(ctx); return gen_shifti(ctx, a, gen_bext); } =20 --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630676157245101.01092957159085; Fri, 3 Sep 2021 06:35:57 -0700 (PDT) Received: from localhost ([::1]:44490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9MK-0008Dd-2j for importer@patchew.org; Fri, 03 Sep 2021 09:35:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91a-00025X-GC for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:30 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]:38807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91Y-0003eI-KV for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:30 -0400 Received: by mail-lj1-x22d.google.com with SMTP id g14so9558810ljk.5 for ; Fri, 03 Sep 2021 06:14:28 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HycvoCCgp/53Ee06/rG+hLdouDE3hVlriXsJsVmcqnU=; b=qR2XBmYy0OoNq/X42GZFw5j4PfFqNz/GWc3oTm4p/ZfhFai9HK35zAxVi7veq0yUYH xz7m01Lal5EsUdWsPXv8WJTqwTIUwX6ejgGy0ECX9nTzJGnS8E/GFcrAXm/qnkxrFIFd y7J0lmGXbnu+0muUMUOPl8QRrlqq9vm6jL5OZwu4npV5KXpzuMWh/2vfQghHXISUnYH4 p9H0zq10/stjyqKPQrxEPju6+l6MHPehb5I1ubedvO6AzROHfrtf3Q+u9VmgC9zkfUPQ 0rO6qee1hKVfXtMYLPciyVycKoop6u0t6yIzUjCQN02rfHUs4fTolPsM0Bx7+wc5eFuk ZLjw== 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:mime-version:content-transfer-encoding; bh=HycvoCCgp/53Ee06/rG+hLdouDE3hVlriXsJsVmcqnU=; b=a5NgjMH75Bc1pALt4XLeAtFu3y0b0JFt5j1wrvL5j26NbAqwyGYsFdin/PiSoMkLx8 2rGfBWufNAfm+NeA5gRp4xYCbmRqmXkwv1FNxmkZ43Upo8VMyEghBshqawWFrCiQZoRP O1SqQwm+7No9uDbg7oyBo3qbOBxqJuIRX7ltGCnwqWNFLPdpbd00tvdBYMWMubOtvCGU zjxB3ZdASUqFup0QOQhW1MdmELdYDEt43niZjb5SwDbrsXaGRv9OQwJd+mDXweCmQMKC J48vYIVW9af8PwW1P7A0dmkNOh501l5Yx/D7Nd/sS6ANH8VS24wAFMIyc46UW03p0lkO kH6w== X-Gm-Message-State: AOAM532gcn9EMZEng1qqzEmVQRFHoZ/rqKgre3WyuDANa6ZpaPgZQdxq HR7k4lA0ApcSPRkjV/kV9nWBBf3850309UPJQBU= X-Google-Smtp-Source: ABdhPJyXWBrsRWsHcZrZkyluWlBAnu5U9bL8djKCczM2KvioIDZzD/wcJmAZhI/1u+xJPqkBMfacEQ== X-Received: by 2002:a2e:9b12:: with SMTP id u18mr2884965lji.350.1630674866887; Fri, 03 Sep 2021 06:14:26 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 07/14] target/riscv: Add instructions of the Zbc-extension Date: Fri, 3 Sep 2021 15:14:10 +0200 Message-Id: <20210903131417.2248471-8-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x22d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630676158449100001 Content-Type: text/plain; charset="utf-8" The following instructions are part of Zbc: - clmul - clmulh - clmulr Note that these instructions were already defined in the pre-0.93 and the 0.93 draft-B proposals, but had not been omitted in the earlier addition of draft-B to QEmu. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v6) Changes in v6: - Move gen_clmulh to trans_rvb.c.inc, as per Richard H's request. Changes in v5: - Introduce gen_clmulh (as suggested by Richard H) and use to simplify trans_clmulh(). Changes in v3: - This adds the Zbc instructions as a spearate commit. - Uses a helper for clmul/clmulr instead of inlining the calculation of the result (addressing a comment from Richard Henderson). target/riscv/bitmanip_helper.c | 27 +++++++++++++++++++++ target/riscv/helper.h | 2 ++ target/riscv/insn32.decode | 5 ++++ target/riscv/insn_trans/trans_rvb.c.inc | 32 ++++++++++++++++++++++++- 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/target/riscv/bitmanip_helper.c b/target/riscv/bitmanip_helper.c index 5b2f795d03..73be5a81c7 100644 --- a/target/riscv/bitmanip_helper.c +++ b/target/riscv/bitmanip_helper.c @@ -3,6 +3,7 @@ * * Copyright (c) 2020 Kito Cheng, kito.cheng@sifive.com * Copyright (c) 2020 Frank Chang, frank.chang@sifive.com + * Copyright (c) 2021 Philipp Tomsich, philipp.tomsich@vrull.eu * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -88,3 +89,29 @@ target_ulong HELPER(gorcw)(target_ulong rs1, target_ulon= g rs2) { return do_gorc(rs1, rs2, 32); } + +target_ulong HELPER(clmul)(target_ulong rs1, target_ulong rs2) +{ + target_ulong result =3D 0; + + for (int i =3D 0; i < TARGET_LONG_BITS; i++) { + if ((rs2 >> i) & 1) { + result ^=3D (rs1 << i); + } + } + + return result; +} + +target_ulong HELPER(clmulr)(target_ulong rs1, target_ulong rs2) +{ + target_ulong result =3D 0; + + for (int i =3D 0; i < TARGET_LONG_BITS; i++) { + if ((rs2 >> i) & 1) { + result ^=3D (rs1 >> (TARGET_LONG_BITS - i - 1)); + } + } + + return result; +} diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 415e37bc37..c559c860a7 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -63,6 +63,8 @@ DEF_HELPER_FLAGS_2(grev, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_2(grevw, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_2(gorc, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_2(gorcw, TCG_CALL_NO_RWG_SE, tl, tl, tl) +DEF_HELPER_FLAGS_2(clmul, TCG_CALL_NO_RWG_SE, tl, tl, tl) +DEF_HELPER_FLAGS_2(clmulr, TCG_CALL_NO_RWG_SE, tl, tl, tl) =20 /* Special functions */ DEF_HELPER_3(csrrw, tl, env, tl, tl) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 1166e7f648..04711111c8 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -713,6 +713,11 @@ roriw 0110000 .......... 101 ..... 0011011 @sh5 greviw 0110100 .......... 101 ..... 0011011 @sh5 gorciw 0010100 .......... 101 ..... 0011011 @sh5 =20 +# *** RV32 Zbc Standard Extension *** +clmul 0000101 .......... 001 ..... 0110011 @r +clmulh 0000101 .......... 011 ..... 0110011 @r +clmulr 0000101 .......... 010 ..... 0110011 @r + # *** RV32 Zbs Standard Extension *** bclr 0100100 .......... 001 ..... 0110011 @r bclri 01001. ........... 001 ..... 0010011 @sh diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index 21d713df27..6a3e0c6a09 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -1,5 +1,5 @@ /* - * RISC-V translation routines for the RVB draft Zb[as] Standard Extension. + * RISC-V translation routines for the Zb[acs] Standard Extension. * * Copyright (c) 2020 Kito Cheng, kito.cheng@sifive.com * Copyright (c) 2020 Frank Chang, frank.chang@sifive.com @@ -24,6 +24,12 @@ } \ } while (0) =20 +#define REQUIRE_ZBC(ctx) do { \ + if (!RISCV_CPU(ctx->cs)->cfg.ext_zbc) { \ + return false; \ + } \ +} while (0) + #define REQUIRE_ZBS(ctx) do { \ if (!RISCV_CPU(ctx->cs)->cfg.ext_zbs) { \ return false; \ @@ -357,3 +363,27 @@ static bool trans_slli_uw(DisasContext *ctx, arg_slli_= uw *a) tcg_temp_free(source1); return true; } + +static bool trans_clmul(DisasContext *ctx, arg_clmul *a) +{ + REQUIRE_ZBC(ctx); + return gen_arith(ctx, a, gen_helper_clmul); +} + +static void gen_clmulh(TCGv dst, TCGv src1, TCGv src2) +{ + gen_helper_clmulr(dst, src1, src2); + tcg_gen_shri_tl(dst, dst, 1); +} + +static bool trans_clmulh(DisasContext *ctx, arg_clmulr *a) +{ + REQUIRE_ZBC(ctx); + return gen_arith(ctx, a, gen_clmulh); +} + +static bool trans_clmulr(DisasContext *ctx, arg_clmulh *a) +{ + REQUIRE_ZBC(ctx); + return gen_arith(ctx, a, gen_helper_clmulr); +} --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630675720796833.1508373273703; Fri, 3 Sep 2021 06:28:40 -0700 (PDT) Received: from localhost ([::1]:54668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9FH-0004PH-LG for importer@patchew.org; Fri, 03 Sep 2021 09:28:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91b-00029Y-NS for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:31 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]:37561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91Z-0003eq-KM for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:31 -0400 Received: by mail-lf1-x129.google.com with SMTP id l10so11695230lfg.4 for ; Fri, 03 Sep 2021 06:14:29 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W+qraWhApYIgOAw0HYJqg9de+z4vJYIu327P57tVcvo=; b=tHDZ6yFjcwP1P02S2ysjw97ec/1y4ExpzxICZLeFlAnwzLYwBxUfyYYnE3rdXgZUS5 mod+snQ4vhxOoq2+g3yCKJt70dTQwdC+HbZFyBER+U0YalYcpnkzKn3CYA7Izg8jlFLP 2f64Ks24ErG6UUQ5h0uV3mN8KpaDz7cSE0aiCYSzT0Tm0iL6xRq9N4iHNPppPaHxYyCx qU6iSBKcxJas3hE0IFZjpv7Xzp2U+q9NwRCKlVpGDNX1pAiuf6bIDzB8B4tewQw6CpS2 9O0iBGZrnGAePAl6/x/N/OUhQEBR6ilQfglXT+ulPQt0TeCPgzj6IRm4wmMIjNZGjR1c xLmw== 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:mime-version:content-transfer-encoding; bh=W+qraWhApYIgOAw0HYJqg9de+z4vJYIu327P57tVcvo=; b=pvXf5zX/s3y9YFW5pjumfwckT1WILB40OjY/I2APttJapUMOqsTassPeRM5uCcShlI nNYQ4y0ZIO6bwk9V08IxSVuIaIp0xMrHfpjfO721VPTcrkp949vscTl6exMZIydZz+8f 2Y+vEtGf4i1Mze2dMugydHXxd3rk4m7fyr3U1T8XkCYVsjVTWybM9IRFeGUEQaYJccwf ZoPbGnU1+ozETBQj45z2G9wfev/yd5iaKgda6b4DmHhTiRvrQwpGTUAQeBFtlnMH5wZF EVcQpslOiJEKKkpQx7L/PagiqxHjUEjCRiTx2eXJ74d+QmiO5qYISvqpOjMXauFUa1tw l/JA== X-Gm-Message-State: AOAM533Yw47on7l/i53TlSgiG814QTPe4HZSs4LoRe6e4m58ak4/fQzj YlGo7MjOGf3RI1T3F87LdnsBmvJV5Mxo2LMTnpc= X-Google-Smtp-Source: ABdhPJzy4RZyNBE7gNLB1gcgbbE4G+aky4rxBU3LgPUC2pbYP7ufsG3o9wn8hX+qK2n0dnubFhmG5A== X-Received: by 2002:a05:6512:2206:: with SMTP id h6mr2635043lfu.621.1630674867677; Fri, 03 Sep 2021 06:14:27 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 08/14] target/riscv: Reassign instructions to the Zbb-extension Date: Fri, 3 Sep 2021 15:14:11 +0200 Message-Id: <20210903131417.2248471-9-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lf1-x129.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630675722732100001 Content-Type: text/plain; charset="utf-8" This reassigns the instructions that are part of Zbb into it, with the notable exceptions of the instructions (rev8, zext.w and orc.b) that changed due to gorci, grevi and pack not being part of Zb[abcs]. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v3) Changes in v3: - The changes to the Zbb instructions (i.e. use the REQUIRE_ZBB macro) are now in a separate commit. target/riscv/insn32.decode | 40 ++++++++++---------- target/riscv/insn_trans/trans_rvb.c.inc | 50 ++++++++++++++----------- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 04711111c8..faa56836d8 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -671,45 +671,47 @@ sh2add_uw 0010000 .......... 100 ..... 0111011 @r sh3add_uw 0010000 .......... 110 ..... 0111011 @r slli_uw 00001 ............ 001 ..... 0011011 @sh =20 -# *** RV32B Standard Extension *** +# *** RV32 Zbb Standard Extension *** +andn 0100000 .......... 111 ..... 0110011 @r clz 011000 000000 ..... 001 ..... 0010011 @r2 -ctz 011000 000001 ..... 001 ..... 0010011 @r2 cpop 011000 000010 ..... 001 ..... 0010011 @r2 +ctz 011000 000001 ..... 001 ..... 0010011 @r2 +max 0000101 .......... 110 ..... 0110011 @r +maxu 0000101 .......... 111 ..... 0110011 @r +min 0000101 .......... 100 ..... 0110011 @r +minu 0000101 .......... 101 ..... 0110011 @r +orn 0100000 .......... 110 ..... 0110011 @r +rol 0110000 .......... 001 ..... 0110011 @r +ror 0110000 .......... 101 ..... 0110011 @r +rori 01100 ............ 101 ..... 0010011 @sh sext_b 011000 000100 ..... 001 ..... 0010011 @r2 sext_h 011000 000101 ..... 001 ..... 0010011 @r2 - -andn 0100000 .......... 111 ..... 0110011 @r -orn 0100000 .......... 110 ..... 0110011 @r xnor 0100000 .......... 100 ..... 0110011 @r + +# *** RV64 Zbb Standard Extension (in addition to RV32 Zbb) *** +clzw 0110000 00000 ..... 001 ..... 0011011 @r2 +ctzw 0110000 00001 ..... 001 ..... 0011011 @r2 +cpopw 0110000 00010 ..... 001 ..... 0011011 @r2 +rolw 0110000 .......... 001 ..... 0111011 @r +roriw 0110000 .......... 101 ..... 0011011 @sh5 +rorw 0110000 .......... 101 ..... 0111011 @r + +# *** RV32B Standard Extension *** pack 0000100 .......... 100 ..... 0110011 @r packu 0100100 .......... 100 ..... 0110011 @r packh 0000100 .......... 111 ..... 0110011 @r -min 0000101 .......... 100 ..... 0110011 @r -minu 0000101 .......... 101 ..... 0110011 @r -max 0000101 .......... 110 ..... 0110011 @r -maxu 0000101 .......... 111 ..... 0110011 @r -ror 0110000 .......... 101 ..... 0110011 @r -rol 0110000 .......... 001 ..... 0110011 @r grev 0110100 .......... 101 ..... 0110011 @r gorc 0010100 .......... 101 ..... 0110011 @r =20 -rori 01100. ........... 101 ..... 0010011 @sh grevi 01101. ........... 101 ..... 0010011 @sh gorci 00101. ........... 101 ..... 0010011 @sh =20 # *** RV64B Standard Extension (in addition to RV32B) *** -clzw 0110000 00000 ..... 001 ..... 0011011 @r2 -ctzw 0110000 00001 ..... 001 ..... 0011011 @r2 -cpopw 0110000 00010 ..... 001 ..... 0011011 @r2 - packw 0000100 .......... 100 ..... 0111011 @r packuw 0100100 .......... 100 ..... 0111011 @r -rorw 0110000 .......... 101 ..... 0111011 @r -rolw 0110000 .......... 001 ..... 0111011 @r grevw 0110100 .......... 101 ..... 0111011 @r gorcw 0010100 .......... 101 ..... 0111011 @r =20 -roriw 0110000 .......... 101 ..... 0011011 @sh5 greviw 0110100 .......... 101 ..... 0011011 @sh5 gorciw 0010100 .......... 101 ..... 0011011 @sh5 =20 diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index 6a3e0c6a09..03b3724c96 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -1,5 +1,5 @@ /* - * RISC-V translation routines for the Zb[acs] Standard Extension. + * RISC-V translation routines for the Zb[abcs] Standard Extension. * * Copyright (c) 2020 Kito Cheng, kito.cheng@sifive.com * Copyright (c) 2020 Frank Chang, frank.chang@sifive.com @@ -24,6 +24,12 @@ } \ } while (0) =20 +#define REQUIRE_ZBB(ctx) do { \ + if (!RISCV_CPU(ctx->cs)->cfg.ext_zbb) { \ + return false; \ + } \ +} while (0) + #define REQUIRE_ZBC(ctx) do { \ if (!RISCV_CPU(ctx->cs)->cfg.ext_zbc) { \ return false; \ @@ -38,37 +44,37 @@ =20 static bool trans_clz(DisasContext *ctx, arg_clz *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_unary(ctx, a, gen_clz); } =20 static bool trans_ctz(DisasContext *ctx, arg_ctz *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_unary(ctx, a, gen_ctz); } =20 static bool trans_cpop(DisasContext *ctx, arg_cpop *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_unary(ctx, a, tcg_gen_ctpop_tl); } =20 static bool trans_andn(DisasContext *ctx, arg_andn *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_arith(ctx, a, tcg_gen_andc_tl); } =20 static bool trans_orn(DisasContext *ctx, arg_orn *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_arith(ctx, a, tcg_gen_orc_tl); } =20 static bool trans_xnor(DisasContext *ctx, arg_xnor *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_arith(ctx, a, tcg_gen_eqv_tl); } =20 @@ -92,37 +98,37 @@ static bool trans_packh(DisasContext *ctx, arg_packh *a) =20 static bool trans_min(DisasContext *ctx, arg_min *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_arith(ctx, a, tcg_gen_smin_tl); } =20 static bool trans_max(DisasContext *ctx, arg_max *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_arith(ctx, a, tcg_gen_smax_tl); } =20 static bool trans_minu(DisasContext *ctx, arg_minu *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_arith(ctx, a, tcg_gen_umin_tl); } =20 static bool trans_maxu(DisasContext *ctx, arg_maxu *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_arith(ctx, a, tcg_gen_umax_tl); } =20 static bool trans_sext_b(DisasContext *ctx, arg_sext_b *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_unary(ctx, a, tcg_gen_ext8s_tl); } =20 static bool trans_sext_h(DisasContext *ctx, arg_sext_h *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_unary(ctx, a, tcg_gen_ext16s_tl); } =20 @@ -176,19 +182,19 @@ static bool trans_bexti(DisasContext *ctx, arg_bexti = *a) =20 static bool trans_ror(DisasContext *ctx, arg_ror *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_shift(ctx, a, tcg_gen_rotr_tl); } =20 static bool trans_rori(DisasContext *ctx, arg_rori *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_shifti(ctx, a, tcg_gen_rotr_tl); } =20 static bool trans_rol(DisasContext *ctx, arg_rol *a) { - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_shift(ctx, a, tcg_gen_rotl_tl); } =20 @@ -235,21 +241,21 @@ GEN_TRANS_SHADD(3) static bool trans_clzw(DisasContext *ctx, arg_clzw *a) { REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_unary(ctx, a, gen_clzw); } =20 static bool trans_ctzw(DisasContext *ctx, arg_ctzw *a) { REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_unary(ctx, a, gen_ctzw); } =20 static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a) { REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_unary(ctx, a, gen_cpopw); } =20 @@ -270,21 +276,21 @@ static bool trans_packuw(DisasContext *ctx, arg_packu= w *a) static bool trans_rorw(DisasContext *ctx, arg_rorw *a) { REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_shiftw(ctx, a, gen_rorw); } =20 static bool trans_roriw(DisasContext *ctx, arg_roriw *a) { REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_shiftiw(ctx, a, gen_rorw); } =20 static bool trans_rolw(DisasContext *ctx, arg_rolw *a) { REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); + REQUIRE_ZBB(ctx); return gen_shiftw(ctx, a, gen_rolw); } =20 --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630676344869462.4436802227847; Fri, 3 Sep 2021 06:39:04 -0700 (PDT) Received: from localhost ([::1]:55192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9PL-0007tF-PH for importer@patchew.org; Fri, 03 Sep 2021 09:39:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91c-0002BZ-BA for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:32 -0400 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]:38812) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91a-0003f3-ET for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:32 -0400 Received: by mail-lj1-x232.google.com with SMTP id g14so9558928ljk.5 for ; Fri, 03 Sep 2021 06:14:29 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DjLjdwFSbm4xzMAjC5qDkizEsYo/Ac3PxFcpct98gg8=; b=fOedZzddHtG0cAadyhCQuFcWZUe4NnRSMKSz0wpAAwPV6/tUPSuRvp0myFXWbDK4CN zvdsduNQ5NUJJ4RNAe/4XqazHOMrqF5GStMN0yZDJ+zwz6Mr07ryzqyPVB/CWmmkhnso y44hBKveRPWOk/I5w88uPptNFlJj5g8AYyfGQHU8zAp2y/TB9+PROVgT34Grogq/OWN1 y2NT0hPgz8a+00//08nMhW4y3wH7By/CqWXO4CH8lQ+n3NIL3BR7NPcn/jc45UhR5CPz vMG4zsIUHfnsWfGU9inW9I8m+piMJLQzX8qPGC0GioQWSS1Z4gC4lvIAUHiCndaeQvZu HmTg== 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:mime-version:content-transfer-encoding; bh=DjLjdwFSbm4xzMAjC5qDkizEsYo/Ac3PxFcpct98gg8=; b=TUnFdeyoHYBsiIX3QPlv32/JrRsl1puC6CdDrDo4NN8BZ/IZgLlKfozohXME6ED/pk GKN5S04DCi998x1nLUi1u9FG8SDJTkSDra3iT2QYoKSiH4BGtkCjhEKdNzncjA8Pk4oc 7lLLEse/FfwpiozCEEz/DDVO2e6FPj7czU9ujtbYAPEVFBGq3K5awAZ0Hb3/2gyg2ibu GYks7YJe4JvW9PQvhpJQ6jCUlsKTEiSAOu/Rba/VI8nukXneVbkRSbwVj4FTUDqH4v2W kzJWBPE1Wwm8AYAbCXJ/c9SMfQpH279e2bSDTwt7AgENbBsAp38mcJ8tPF1ao0wkasAQ B9bw== X-Gm-Message-State: AOAM5304ousP+bI2QXmyEeMDM5TX3wMbYpreJULKpMIDs7lDMxODOS6D zaMqTMyOigytFnceLt+2gCxaKs1n8mljnchudsQ= X-Google-Smtp-Source: ABdhPJwLqLPzu7SB8GcwIjHL5kjYlbOvwThmSWNRboOZUBwU0DZDRrtyoavdp/uTurUNpZW3rp0kVw== X-Received: by 2002:a2e:9798:: with SMTP id y24mr2832588lji.165.1630674868582; Fri, 03 Sep 2021 06:14:28 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 09/14] target/riscv: Add orc.b instruction for Zbb, removing gorc/gorci Date: Fri, 3 Sep 2021 15:14:12 +0200 Message-Id: <20210903131417.2248471-10-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x232.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630676346063100001 Content-Type: text/plain; charset="utf-8" The 1.0.0 version of Zbb does not contain gorc/gorci. Instead, a orc.b instruction (equivalent to the orc.b pseudo-instruction built on gorci from pre-0.93 draft-B) is available, mainly targeting string-processing workloads. This commit adds the new orc.b instruction and removed gorc/gorci. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson --- Changes in v8: - Optimize orc.b further by reordering the shift/and, updating the comment to reflect that we put the truth-value into the LSB, and putting the (now only) constant in a temporary - Fold the final bitwise-not into the second and, using and andc. Changes in v7: - Free TCG temporary in gen_orc_b(). Changes in v6: - Fixed orc.b (now passes SPEC w/ optimized string functions) by adding the missing final negation. Changes in v4: - Change orc.b to implementation suggested by Richard Henderson Changes in v3: - Moved orc.b and gorc/gorci changes into separate commit. - Using the simpler orc.b implementation suggested by Richard Henderson target/riscv/bitmanip_helper.c | 26 ----------------- target/riscv/helper.h | 2 -- target/riscv/insn32.decode | 6 +--- target/riscv/insn_trans/trans_rvb.c.inc | 38 ++++++++++++------------- target/riscv/translate.c | 6 ---- 5 files changed, 19 insertions(+), 59 deletions(-) diff --git a/target/riscv/bitmanip_helper.c b/target/riscv/bitmanip_helper.c index 73be5a81c7..bb48388fcd 100644 --- a/target/riscv/bitmanip_helper.c +++ b/target/riscv/bitmanip_helper.c @@ -64,32 +64,6 @@ target_ulong HELPER(grevw)(target_ulong rs1, target_ulon= g rs2) return do_grev(rs1, rs2, 32); } =20 -static target_ulong do_gorc(target_ulong rs1, - target_ulong rs2, - int bits) -{ - target_ulong x =3D rs1; - int i, shift; - - for (i =3D 0, shift =3D 1; shift < bits; i++, shift <<=3D 1) { - if (rs2 & shift) { - x |=3D do_swap(x, adjacent_masks[i], shift); - } - } - - return x; -} - -target_ulong HELPER(gorc)(target_ulong rs1, target_ulong rs2) -{ - return do_gorc(rs1, rs2, TARGET_LONG_BITS); -} - -target_ulong HELPER(gorcw)(target_ulong rs1, target_ulong rs2) -{ - return do_gorc(rs1, rs2, 32); -} - target_ulong HELPER(clmul)(target_ulong rs1, target_ulong rs2) { target_ulong result =3D 0; diff --git a/target/riscv/helper.h b/target/riscv/helper.h index c559c860a7..80561e8866 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -61,8 +61,6 @@ DEF_HELPER_FLAGS_1(fclass_d, TCG_CALL_NO_RWG_SE, tl, i64) /* Bitmanip */ DEF_HELPER_FLAGS_2(grev, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_2(grevw, TCG_CALL_NO_RWG_SE, tl, tl, tl) -DEF_HELPER_FLAGS_2(gorc, TCG_CALL_NO_RWG_SE, tl, tl, tl) -DEF_HELPER_FLAGS_2(gorcw, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_2(clmul, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_2(clmulr, TCG_CALL_NO_RWG_SE, tl, tl, tl) =20 diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index faa56836d8..8bcb602455 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -680,6 +680,7 @@ max 0000101 .......... 110 ..... 0110011 @r maxu 0000101 .......... 111 ..... 0110011 @r min 0000101 .......... 100 ..... 0110011 @r minu 0000101 .......... 101 ..... 0110011 @r +orc_b 001010 000111 ..... 101 ..... 0010011 @r2 orn 0100000 .......... 110 ..... 0110011 @r rol 0110000 .......... 001 ..... 0110011 @r ror 0110000 .......... 101 ..... 0110011 @r @@ -701,19 +702,14 @@ pack 0000100 .......... 100 ..... 0110011 @r packu 0100100 .......... 100 ..... 0110011 @r packh 0000100 .......... 111 ..... 0110011 @r grev 0110100 .......... 101 ..... 0110011 @r -gorc 0010100 .......... 101 ..... 0110011 @r - grevi 01101. ........... 101 ..... 0010011 @sh -gorci 00101. ........... 101 ..... 0010011 @sh =20 # *** RV64B Standard Extension (in addition to RV32B) *** packw 0000100 .......... 100 ..... 0111011 @r packuw 0100100 .......... 100 ..... 0111011 @r grevw 0110100 .......... 101 ..... 0111011 @r -gorcw 0010100 .......... 101 ..... 0111011 @r =20 greviw 0110100 .......... 101 ..... 0011011 @sh5 -gorciw 0010100 .......... 101 ..... 0011011 @sh5 =20 # *** RV32 Zbc Standard Extension *** clmul 0000101 .......... 001 ..... 0110011 @r diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index 03b3724c96..22ab622557 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -215,18 +215,30 @@ static bool trans_grevi(DisasContext *ctx, arg_grevi = *a) return gen_grevi(ctx, a); } =20 -static bool trans_gorc(DisasContext *ctx, arg_gorc *a) +static void gen_orc_b(TCGv ret, TCGv source1) { - REQUIRE_EXT(ctx, RVB); - return gen_shift(ctx, a, gen_helper_gorc); + TCGv tmp =3D tcg_temp_new(); + TCGv ones =3D tcg_constant_tl(dup_const(MO_8, 0x01)); + + /* Set lsb in each byte if the byte was zero. */ + tcg_gen_sub_tl(tmp, source1, ones); + tcg_gen_andc_tl(tmp, tmp, source1); + tcg_gen_shri_tl(tmp, tmp, 7); + tcg_gen_andc_tl(tmp, ones, tmp); + + /* Replicate the lsb of each byte across the byte. */ + tcg_gen_muli_tl(ret, tmp, 0xff); + + tcg_temp_free(tmp); } =20 -static bool trans_gorci(DisasContext *ctx, arg_gorci *a) +static bool trans_orc_b(DisasContext *ctx, arg_orc_b *a) { - REQUIRE_EXT(ctx, RVB); - return gen_shifti(ctx, a, gen_helper_gorc); + REQUIRE_ZBB(ctx); + return gen_unary(ctx, a, &gen_orc_b); } =20 + #define GEN_TRANS_SHADD(SHAMT) = \ static bool trans_sh##SHAMT##add(DisasContext *ctx, arg_sh##SHAMT##add *a)= \ { = \ @@ -308,20 +320,6 @@ static bool trans_greviw(DisasContext *ctx, arg_greviw= *a) return gen_shiftiw(ctx, a, gen_grevw); } =20 -static bool trans_gorcw(DisasContext *ctx, arg_gorcw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftw(ctx, a, gen_gorcw); -} - -static bool trans_gorciw(DisasContext *ctx, arg_gorciw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftiw(ctx, a, gen_gorcw); -} - #define GEN_TRANS_SHADD_UW(SHAMT) \ static bool trans_sh##SHAMT##add_uw(DisasContext *ctx, \ arg_sh##SHAMT##add_uw *a) \ diff --git a/target/riscv/translate.c b/target/riscv/translate.c index fc22ae82d0..5c099ff007 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -710,12 +710,6 @@ static void gen_grevw(TCGv ret, TCGv arg1, TCGv arg2) gen_helper_grev(ret, arg1, arg2); } =20 -static void gen_gorcw(TCGv ret, TCGv arg1, TCGv arg2) -{ - tcg_gen_ext32u_tl(arg1, arg1); - gen_helper_gorcw(ret, arg1, arg2); -} - #define GEN_SHADD_UW(SHAMT) \ static void gen_sh##SHAMT##add_uw(TCGv ret, TCGv arg1, TCGv arg2) \ { \ --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630676039713240.6850265163979; Fri, 3 Sep 2021 06:33:59 -0700 (PDT) Received: from localhost ([::1]:39490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9KQ-0004q4-O0 for importer@patchew.org; Fri, 03 Sep 2021 09:33:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91e-0002L5-Kq for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:34 -0400 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:39902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91b-0003fE-AL for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:34 -0400 Received: by mail-lf1-x12b.google.com with SMTP id m28so11710327lfj.6 for ; Fri, 03 Sep 2021 06:14:30 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iFrdZ0kMv+PZ8RQYkPNFa0LTHTFe0e6o8JJ2FLkYzDY=; b=maVg8mBryzStQIMU8a98gP4RbolD0pHqvaEvHYNx2hju4HLR5gVwfrHotKRY71yUiQ dxd9xfhpJIjiu9WzAq2iAivqNjAzu2y+Lcgyoitgq3UA2ds1p8oO2BGUYg/yJ56PKcws uIyEILyOGnH2uyc6Zm8TXxAH7Kt2yltnW3ohCSphZH1NT4XeLhmAWgjVxMEPyzzFHaRA XjuM3i9629eliFLO2IlAiyA4N9EpMEDaBEvd8AJVjdVnIbrMvvxMH0HnW+GE/H/BJiM6 mpbvNDGRFfCYodR7I4hWK0+3/IfIseA/kCw6vNk1vMOe+WvqbAmaaEAfzTCIrL8JOb3/ wifg== 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:mime-version:content-transfer-encoding; bh=iFrdZ0kMv+PZ8RQYkPNFa0LTHTFe0e6o8JJ2FLkYzDY=; b=WKrlwUbuvF/OdYEhMGqmcoxPdjJlZK0EIP498bY1WefnmSzsvyoMpXBDKnap16DAY0 6zDHgJ5Rn5rlQOxHJxuJNk/PEwEOGfy/crUrYApfaUxr14pDZ+FA4cajRizaeXzQNpcG EvysMvEgTJuo0fD081mSl/1epWZtznkr1Uk70kqOEYaiWJAxl9EZ8MmZUN2nNFQXVRxi VVJUXmNw7yBjD3BobqZmi/gMCtrIClgPDixG9iAPWXXzPsec0ZfW7DXWgvCXWmDit/oP mX5XCMBUx9UQQ/FLfLa0ZAFPgeSRILSeza2kSfLS+uIsF/A+VhKwyrolPamFSZ357d1O nhQQ== X-Gm-Message-State: AOAM530cg51U1yc2FfrW/daVX/jr7LZfBKxxfsODmb5cBL3iNOrteOJi MHO+1ree75RC1Avh0l4AKKSpXeq7K3kHf9X1Pvk= X-Google-Smtp-Source: ABdhPJy8CL3Q3kUFDP5HfQEhwJkDjHZocyay8XrOXglsTJuIvTS/3ob59z7omTGk0eoyOcUj+NkGng== X-Received: by 2002:a05:6512:eaa:: with SMTP id bi42mr2791976lfb.328.1630674869463; Fri, 03 Sep 2021 06:14:29 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 10/14] target/riscv: Add a REQUIRE_32BIT macro Date: Fri, 3 Sep 2021 15:14:13 +0200 Message-Id: <20210903131417.2248471-11-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lf1-x12b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630676040675100001 Content-Type: text/plain; charset="utf-8" With the changes to Zb[abcs], there's some encodings that are different in RV64 and RV32 (e.g., for rev8 and zext.h). For these, we'll need a helper macro allowing us to select on RV32, as well. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v3) Changes in v3: - Moved the REQUIRE_32BIT macro into a separate commit. target/riscv/translate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 5c099ff007..aabdd44663 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -417,6 +417,12 @@ EX_SH(12) } \ } while (0) =20 +#define REQUIRE_32BIT(ctx) do { \ + if (!is_32bit(ctx)) { \ + return false; \ + } \ +} while (0) + #define REQUIRE_64BIT(ctx) do { \ if (is_32bit(ctx)) { \ return false; \ --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630676495743570.1818222661478; Fri, 3 Sep 2021 06:41:35 -0700 (PDT) Received: from localhost ([::1]:59482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9Rm-0002cI-6K for importer@patchew.org; Fri, 03 Sep 2021 09:41:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91e-0002Ir-1K for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:34 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]:42968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91c-0003fr-3z for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:33 -0400 Received: by mail-lj1-x22d.google.com with SMTP id h1so9544334ljl.9 for ; Fri, 03 Sep 2021 06:14:31 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZY/8QpMjcSV4eh9Fjbsq1SusiOjsfeYOn0/dg6li2sU=; b=svVkfj/JalQU8dHuE1/tf+SdY3dhKRXrm6eu4tky9pW4Ci8I7CyCcy44YNC1gm1wN9 q6U9qdc3/xlcY7fktxzAgbjPMkyLG7QxrIRO95qjhe/0hvkbFA4mTA6/v5q3M9OKyAzR PR4Kdwci3w3gb65Ab/xDe8tCjve84TMnWUIHOLG6espYMbSxN4E5Gc10n6Dlr+Fmq01K VzHHdJVncytzr4w7qD1wmmu7vEsuFTO4zdVBzW5yAa3UeKIDRLPRpBduthON2Ua6p9k9 jni84VU/4jfcFlcLMHFpnoJAYelU1SixQm1luDMo9o5279p9i8SfKSSOunKSAGpmRoIF MtcA== 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:mime-version:content-transfer-encoding; bh=ZY/8QpMjcSV4eh9Fjbsq1SusiOjsfeYOn0/dg6li2sU=; b=EaLStNhJ5mpB6fGs8V2P6MFYKAUzuKZ6JhJ9ZoO4oe5Pxm+9s3YZR1Zm8teSL0h4bp G2hZz/lVXEh1JQhras57FrS+NXp7GRB95dhKfie9vXYD6OYz1IcdMV4ZOkBzU5SiIgIa UET5eLwTahEvLJaHQ4meCBT1iLsG66fPQFPdKr+yo0Xnh1VrltpL+Ad7KSM8br2k1x5S aJgIIti1QDVtJZE5D38vnbfdC6hKSSB+nzeEZRvvhtyKJ8iM0JWYoLRW39p7M0ZabxSz V9yFY85eCiaw5dXqT58DLH94qALy8MvmFfjAwf5haCkGhgz6uPKXUY+dva5rSKJ3624H 7zrQ== X-Gm-Message-State: AOAM5333k7nROcgut0cqM3VFIL5WpXjoazMaujc2epIf+7joTDuLjTWD hpr4+oS9LP+B4Z/C7jnQCgLY5P3VlXGEE6B2Jow= X-Google-Smtp-Source: ABdhPJxWfA8e3Er+OAwTryNWulONgvYSubb7TY0RrqwdDOB9xvwU+aUpUd57FNLlx0/jo6BGxvJsiw== X-Received: by 2002:a2e:8109:: with SMTP id d9mr2825269ljg.495.1630674870287; Fri, 03 Sep 2021 06:14:30 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 11/14] target/riscv: Add rev8 instruction, removing grev/grevi Date: Fri, 3 Sep 2021 15:14:14 +0200 Message-Id: <20210903131417.2248471-12-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x22d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630676496590100001 Content-Type: text/plain; charset="utf-8" The 1.0.0 version of Zbb does not contain grev/grevi. Instead, a rev8 instruction (equivalent to the rev8 pseudo-instruction built on grevi from pre-0.93 draft-B) is available. This commit adds the new rev8 instruction and removes grev/grevi. Note that there is no W-form of this instruction (both a sign-extending and zero-extending 32-bit version can easily be synthesized by following rev8 with either a srai or srli instruction on RV64) and that the opcode encodings for rev8 in RV32 and RV64 are different. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v4) Changes in v4: - reorder trans_rev8* functions to be sequential - rename rev8 to rev8_32 in decoder Changes in v3: - rev8-addition & grevi*-removal moved to a separate commit target/riscv/bitmanip_helper.c | 40 ------------------------- target/riscv/helper.h | 2 -- target/riscv/insn32.decode | 12 ++++---- target/riscv/insn_trans/trans_rvb.c.inc | 34 ++++++--------------- target/riscv/translate.c | 28 ----------------- 5 files changed, 16 insertions(+), 100 deletions(-) diff --git a/target/riscv/bitmanip_helper.c b/target/riscv/bitmanip_helper.c index bb48388fcd..f1b5e5549f 100644 --- a/target/riscv/bitmanip_helper.c +++ b/target/riscv/bitmanip_helper.c @@ -24,46 +24,6 @@ #include "exec/helper-proto.h" #include "tcg/tcg.h" =20 -static const uint64_t adjacent_masks[] =3D { - dup_const(MO_8, 0x55), - dup_const(MO_8, 0x33), - dup_const(MO_8, 0x0f), - dup_const(MO_16, 0xff), - dup_const(MO_32, 0xffff), - UINT32_MAX -}; - -static inline target_ulong do_swap(target_ulong x, uint64_t mask, int shif= t) -{ - return ((x & mask) << shift) | ((x & ~mask) >> shift); -} - -static target_ulong do_grev(target_ulong rs1, - target_ulong rs2, - int bits) -{ - target_ulong x =3D rs1; - int i, shift; - - for (i =3D 0, shift =3D 1; shift < bits; i++, shift <<=3D 1) { - if (rs2 & shift) { - x =3D do_swap(x, adjacent_masks[i], shift); - } - } - - return x; -} - -target_ulong HELPER(grev)(target_ulong rs1, target_ulong rs2) -{ - return do_grev(rs1, rs2, TARGET_LONG_BITS); -} - -target_ulong HELPER(grevw)(target_ulong rs1, target_ulong rs2) -{ - return do_grev(rs1, rs2, 32); -} - target_ulong HELPER(clmul)(target_ulong rs1, target_ulong rs2) { target_ulong result =3D 0; diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 80561e8866..ae2e94542c 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -59,8 +59,6 @@ DEF_HELPER_FLAGS_2(fcvt_d_lu, TCG_CALL_NO_RWG, i64, env, = tl) DEF_HELPER_FLAGS_1(fclass_d, TCG_CALL_NO_RWG_SE, tl, i64) =20 /* Bitmanip */ -DEF_HELPER_FLAGS_2(grev, TCG_CALL_NO_RWG_SE, tl, tl, tl) -DEF_HELPER_FLAGS_2(grevw, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_2(clmul, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_2(clmulr, TCG_CALL_NO_RWG_SE, tl, tl, tl) =20 diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 8bcb602455..017eb50a49 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -682,6 +682,9 @@ min 0000101 .......... 100 ..... 0110011 @r minu 0000101 .......... 101 ..... 0110011 @r orc_b 001010 000111 ..... 101 ..... 0010011 @r2 orn 0100000 .......... 110 ..... 0110011 @r +# The encoding for rev8 differs between RV32 and RV64.=20 +# rev8_32 denotes the RV32 variant. +rev8_32 011010 011000 ..... 101 ..... 0010011 @r2 rol 0110000 .......... 001 ..... 0110011 @r ror 0110000 .......... 101 ..... 0110011 @r rori 01100 ............ 101 ..... 0010011 @sh @@ -693,6 +696,10 @@ xnor 0100000 .......... 100 ..... 0110011 @r clzw 0110000 00000 ..... 001 ..... 0011011 @r2 ctzw 0110000 00001 ..... 001 ..... 0011011 @r2 cpopw 0110000 00010 ..... 001 ..... 0011011 @r2 +# The encoding for rev8 differs between RV32 and RV64. +# When executing on RV64, the encoding used in RV32 is an illegal +# instruction, so we use different handler functions to differentiate. +rev8_64 011010 111000 ..... 101 ..... 0010011 @r2 rolw 0110000 .......... 001 ..... 0111011 @r roriw 0110000 .......... 101 ..... 0011011 @sh5 rorw 0110000 .......... 101 ..... 0111011 @r @@ -701,15 +708,10 @@ rorw 0110000 .......... 101 ..... 0111011 @r pack 0000100 .......... 100 ..... 0110011 @r packu 0100100 .......... 100 ..... 0110011 @r packh 0000100 .......... 111 ..... 0110011 @r -grev 0110100 .......... 101 ..... 0110011 @r -grevi 01101. ........... 101 ..... 0010011 @sh =20 # *** RV64B Standard Extension (in addition to RV32B) *** packw 0000100 .......... 100 ..... 0111011 @r packuw 0100100 .......... 100 ..... 0111011 @r -grevw 0110100 .......... 101 ..... 0111011 @r - -greviw 0110100 .......... 101 ..... 0011011 @sh5 =20 # *** RV32 Zbc Standard Extension *** clmul 0000101 .......... 001 ..... 0110011 @r diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index 22ab622557..2f37bad477 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -198,23 +198,21 @@ static bool trans_rol(DisasContext *ctx, arg_rol *a) return gen_shift(ctx, a, tcg_gen_rotl_tl); } =20 -static bool trans_grev(DisasContext *ctx, arg_grev *a) +static bool trans_rev8_32(DisasContext *ctx, arg_rev8_32 *a) { - REQUIRE_EXT(ctx, RVB); - return gen_shift(ctx, a, gen_helper_grev); + REQUIRE_32BIT(ctx); + REQUIRE_ZBB(ctx); + return gen_unary(ctx, a, &tcg_gen_bswap_tl); } =20 -static bool trans_grevi(DisasContext *ctx, arg_grevi *a) +static bool trans_rev8_64(DisasContext *ctx, arg_rev8_64 *a) { - REQUIRE_EXT(ctx, RVB); - - if (a->shamt >=3D TARGET_LONG_BITS) { - return false; - } - - return gen_grevi(ctx, a); + REQUIRE_64BIT(ctx); + REQUIRE_ZBB(ctx); + return gen_unary(ctx, a, &tcg_gen_bswap_tl); } =20 + static void gen_orc_b(TCGv ret, TCGv source1) { TCGv tmp =3D tcg_temp_new(); @@ -306,20 +304,6 @@ static bool trans_rolw(DisasContext *ctx, arg_rolw *a) return gen_shiftw(ctx, a, gen_rolw); } =20 -static bool trans_grevw(DisasContext *ctx, arg_grevw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftw(ctx, a, gen_grevw); -} - -static bool trans_greviw(DisasContext *ctx, arg_greviw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_shiftiw(ctx, a, gen_grevw); -} - #define GEN_TRANS_SHADD_UW(SHAMT) \ static bool trans_sh##SHAMT##add_uw(DisasContext *ctx, \ arg_sh##SHAMT##add_uw *a) \ diff --git a/target/riscv/translate.c b/target/riscv/translate.c index aabdd44663..f16ac8bb1a 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -601,28 +601,6 @@ static void gen_bext(TCGv ret, TCGv arg1, TCGv shamt) tcg_gen_andi_tl(ret, ret, 1); } =20 -static bool gen_grevi(DisasContext *ctx, arg_grevi *a) -{ - TCGv source1 =3D tcg_temp_new(); - TCGv source2; - - gen_get_gpr(source1, a->rs1); - - if (a->shamt =3D=3D (TARGET_LONG_BITS - 8)) { - /* rev8, byte swaps */ - tcg_gen_bswap_tl(source1, source1); - } else { - source2 =3D tcg_temp_new(); - tcg_gen_movi_tl(source2, a->shamt); - gen_helper_grev(source1, source1, source2); - tcg_temp_free(source2); - } - - gen_set_gpr(a->rd, source1); - tcg_temp_free(source1); - return true; -} - #define GEN_SHADD(SHAMT) \ static void gen_sh##SHAMT##add(TCGv ret, TCGv arg1, TCGv arg2) \ { \ @@ -710,12 +688,6 @@ static void gen_rolw(TCGv ret, TCGv arg1, TCGv arg2) tcg_temp_free_i32(t2); } =20 -static void gen_grevw(TCGv ret, TCGv arg1, TCGv arg2) -{ - tcg_gen_ext32u_tl(arg1, arg1); - gen_helper_grev(ret, arg1, arg2); -} - #define GEN_SHADD_UW(SHAMT) \ static void gen_sh##SHAMT##add_uw(TCGv ret, TCGv arg1, TCGv arg2) \ { \ --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630675972022471.6741172052499; Fri, 3 Sep 2021 06:32:52 -0700 (PDT) Received: from localhost ([::1]:35184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9JK-0001zK-PQ for importer@patchew.org; Fri, 03 Sep 2021 09:32:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91f-0002QX-Tz for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:35 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]:39807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91c-0003gN-Se for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:35 -0400 Received: by mail-lj1-x22d.google.com with SMTP id q21so9554822ljj.6 for ; Fri, 03 Sep 2021 06:14:32 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rmA6mk06PJ6n3WtKBlk/DHFJLC4efi4TCq+bnBQAj2Q=; b=Xl/Me96p4G/kKBHKqBeBYNOC61+FLClgM7L4WWknO8sgPH8drIkWf0DTVPlQ+t5MJB 25/1szZjvFgz+pAtrF4DvwyMJRhQVvyQBgN9zMXRbfj4igBGor9DaSpQaPrzbGnzKOm7 OLi3m5jKKxdzdpe8Mrfl/7nm41s7b/Ti4fV3ik2u92lecRfJlgOr++JFETmioMIsDtUQ U6dALKT6hGqP+NWJWyd1HOA7kneewyNtGTNyQVN4TED+s7Lt99O1T7JeVYcHMuHOCADl KaxSqYgwAhWWExFWhT6WndnTVGS+MsHPgyJUHLLBiWpX+hIzrB01VthYsRYGuEiqrJfF j2SQ== 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:mime-version:content-transfer-encoding; bh=rmA6mk06PJ6n3WtKBlk/DHFJLC4efi4TCq+bnBQAj2Q=; b=SLukR4x4XK6SH9X1lzGpVkVOjMPV1hWnzQPvTiMbUFBTYFcbDoBNo/y2vJ+C/MBK/J lXVBo6d1ksjVhpb2gnZwmU+ywvNEe2rrhQ3sZraaKj8t2C/x6Eh9xjuezYBKl0VKycGf 2MDZVeyvrjNt7nl+Y4mHCtNQSg6xsVU4F4/ZwptgIRIZQEs5hA5mEskFa6u6ZS2CHj4t xTeFgZapLs4KYlsEa3Ey13hhiRJwzUBwShf0E3ARuzIXZh+Q9YmOf7KjL1vA62tJ3gqR 606A7Kp5inYWoCy4bdETP3xFl2g8xVrqEItg/7Piq3cZY/eDpREN5PNQhe4WfIqZvAMn wG0Q== X-Gm-Message-State: AOAM531g9xanLPzUcauJK+bfPDtfBAW1Wrd3CLrfA9hCpxYaMm3Z9und cXDxu2cFIgb5DZNP7vl6pd7Eh48GmvwTG2Xyq7o= X-Google-Smtp-Source: ABdhPJz5leaVUiuOjUH8UnNtt4xfUGfG/RZHSY7+kc42m6DXtKY26f3I80nLJk/qNVpqlEk8xTVNLw== X-Received: by 2002:a2e:a36c:: with SMTP id i12mr2873397ljn.427.1630674871195; Fri, 03 Sep 2021 06:14:31 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 12/14] target/riscv: Add zext.h instructions to Zbb, removing pack/packu/packh Date: Fri, 3 Sep 2021 15:14:15 +0200 Message-Id: <20210903131417.2248471-13-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x22d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630675973642100001 Content-Type: text/plain; charset="utf-8" The 1.0.0 version of Zbb does not contain pack/packu/packh. However, a zext.h instruction is provided (built on pack/packh from pre-0.93 draft-B) is available. This commit adds zext.h and removes the pack* instructions. Note that the encodings for zext.h are different between RV32 and RV64, which is handled through REQUIRE_32BIT. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v4) Changes in v4: - Renamed RV32 variant to zext_h_32. - Reordered trans_zext_h_{32,64} to be next to each other. Changes in v3: - Moved zext.h-addition & pack*-removal to a separate commit. target/riscv/insn32.decode | 12 ++++--- target/riscv/insn_trans/trans_rvb.c.inc | 46 ++++++++----------------- target/riscv/translate.c | 40 --------------------- 3 files changed, 21 insertions(+), 77 deletions(-) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 017eb50a49..abf794095a 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -691,6 +691,9 @@ rori 01100 ............ 101 ..... 0010011 @sh sext_b 011000 000100 ..... 001 ..... 0010011 @r2 sext_h 011000 000101 ..... 001 ..... 0010011 @r2 xnor 0100000 .......... 100 ..... 0110011 @r +# The encoding for zext.h differs between RV32 and RV64. +# zext_h_32 denotes the RV32 variant. +zext_h_32 0000100 00000 ..... 100 ..... 0110011 @r2 =20 # *** RV64 Zbb Standard Extension (in addition to RV32 Zbb) *** clzw 0110000 00000 ..... 001 ..... 0011011 @r2 @@ -703,15 +706,14 @@ rev8_64 011010 111000 ..... 101 ..... 0010011 @r2 rolw 0110000 .......... 001 ..... 0111011 @r roriw 0110000 .......... 101 ..... 0011011 @sh5 rorw 0110000 .......... 101 ..... 0111011 @r +# The encoding for zext.h differs between RV32 and RV64. +# When executing on RV64, the encoding used in RV32 is an illegal +# instruction, so we use different handler functions to differentiate. +zext_h_64 0000100 00000 ..... 100 ..... 0111011 @r2 =20 # *** RV32B Standard Extension *** -pack 0000100 .......... 100 ..... 0110011 @r -packu 0100100 .......... 100 ..... 0110011 @r -packh 0000100 .......... 111 ..... 0110011 @r =20 # *** RV64B Standard Extension (in addition to RV32B) *** -packw 0000100 .......... 100 ..... 0111011 @r -packuw 0100100 .......... 100 ..... 0111011 @r =20 # *** RV32 Zbc Standard Extension *** clmul 0000101 .......... 001 ..... 0110011 @r diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_tr= ans/trans_rvb.c.inc index 2f37bad477..ca389f4fe2 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -78,24 +78,6 @@ static bool trans_xnor(DisasContext *ctx, arg_xnor *a) return gen_arith(ctx, a, tcg_gen_eqv_tl); } =20 -static bool trans_pack(DisasContext *ctx, arg_pack *a) -{ - REQUIRE_EXT(ctx, RVB); - return gen_arith(ctx, a, gen_pack); -} - -static bool trans_packu(DisasContext *ctx, arg_packu *a) -{ - REQUIRE_EXT(ctx, RVB); - return gen_arith(ctx, a, gen_packu); -} - -static bool trans_packh(DisasContext *ctx, arg_packh *a) -{ - REQUIRE_EXT(ctx, RVB); - return gen_arith(ctx, a, gen_packh); -} - static bool trans_min(DisasContext *ctx, arg_min *a) { REQUIRE_ZBB(ctx); @@ -236,6 +218,20 @@ static bool trans_orc_b(DisasContext *ctx, arg_orc_b *= a) return gen_unary(ctx, a, &gen_orc_b); } =20 +static bool trans_zext_h_32(DisasContext *ctx, arg_zext_h_32 *a) +{ + REQUIRE_32BIT(ctx); + REQUIRE_ZBB(ctx); + return gen_unary(ctx, a, &tcg_gen_ext16u_tl); +} + +static bool trans_zext_h_64(DisasContext *ctx, arg_zext_h_64 *a) +{ + REQUIRE_64BIT(ctx); + REQUIRE_ZBB(ctx); + return gen_unary(ctx, a, &tcg_gen_ext16u_tl); +} + =20 #define GEN_TRANS_SHADD(SHAMT) = \ static bool trans_sh##SHAMT##add(DisasContext *ctx, arg_sh##SHAMT##add *a)= \ @@ -269,20 +265,6 @@ static bool trans_cpopw(DisasContext *ctx, arg_cpopw *= a) return gen_unary(ctx, a, gen_cpopw); } =20 -static bool trans_packw(DisasContext *ctx, arg_packw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_arith(ctx, a, gen_packw); -} - -static bool trans_packuw(DisasContext *ctx, arg_packuw *a) -{ - REQUIRE_64BIT(ctx); - REQUIRE_EXT(ctx, RVB); - return gen_arith(ctx, a, gen_packuw); -} - static bool trans_rorw(DisasContext *ctx, arg_rorw *a) { REQUIRE_64BIT(ctx); diff --git a/target/riscv/translate.c b/target/riscv/translate.c index f16ac8bb1a..639f34b8f6 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -536,29 +536,6 @@ static bool gen_arith_div_uw(DisasContext *ctx, arg_r = *a, return true; } =20 -static void gen_pack(TCGv ret, TCGv arg1, TCGv arg2) -{ - tcg_gen_deposit_tl(ret, arg1, arg2, - TARGET_LONG_BITS / 2, - TARGET_LONG_BITS / 2); -} - -static void gen_packu(TCGv ret, TCGv arg1, TCGv arg2) -{ - TCGv t =3D tcg_temp_new(); - tcg_gen_shri_tl(t, arg1, TARGET_LONG_BITS / 2); - tcg_gen_deposit_tl(ret, arg2, t, 0, TARGET_LONG_BITS / 2); - tcg_temp_free(t); -} - -static void gen_packh(TCGv ret, TCGv arg1, TCGv arg2) -{ - TCGv t =3D tcg_temp_new(); - tcg_gen_ext8u_tl(t, arg2); - tcg_gen_deposit_tl(ret, arg1, t, 8, TARGET_LONG_BITS - 8); - tcg_temp_free(t); -} - static void gen_sbop_mask(TCGv ret, TCGv shamt) { tcg_gen_movi_tl(ret, 1); @@ -635,23 +612,6 @@ static void gen_cpopw(TCGv ret, TCGv arg1) tcg_gen_ctpop_tl(ret, arg1); } =20 -static void gen_packw(TCGv ret, TCGv arg1, TCGv arg2) -{ - TCGv t =3D tcg_temp_new(); - tcg_gen_ext16s_tl(t, arg2); - tcg_gen_deposit_tl(ret, arg1, t, 16, 48); - tcg_temp_free(t); -} - -static void gen_packuw(TCGv ret, TCGv arg1, TCGv arg2) -{ - TCGv t =3D tcg_temp_new(); - tcg_gen_shri_tl(t, arg1, 16); - tcg_gen_deposit_tl(ret, arg2, t, 0, 16); - tcg_gen_ext32s_tl(ret, ret); - tcg_temp_free(t); -} - static void gen_rorw(TCGv ret, TCGv arg1, TCGv arg2) { TCGv_i32 t1 =3D tcg_temp_new_i32(); --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630676147045598.7818216038884; Fri, 3 Sep 2021 06:35:47 -0700 (PDT) Received: from localhost ([::1]:43734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9M9-0007jM-VG for importer@patchew.org; Fri, 03 Sep 2021 09:35:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91k-0002Ye-MR for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:40 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:40799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91d-0003ga-TK for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:39 -0400 Received: by mail-lj1-x236.google.com with SMTP id i28so9546876ljm.7 for ; Fri, 03 Sep 2021 06:14:33 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mj1oSizWUqYn/kFlxtQ1GxX/TiBaZDktZ4mAMNcuV9Q=; b=Z77XsZy744uiYDQWK/9ojyXGMWanYcaQXA4sbqs82HDcqxyR+xSLKyfvUwG+cIRj5y Dhn9U0UmBSfED0NqSb7vDu8JX4nUBAukx1eyex+WukW50pNffVPXk25SeVlFuq0r+nm5 tpTnMiOVihzNHE2rvr43kU2axjCBW2/iG7KDtD6TFzaYdTBAF4b64kLtf9DbH6fPWR34 nNMGDWasNKRO3TvsIgMoE2PSh4ryS5JO5CUWCHhbGmiHAND7BJSd4jP5pvHmOE/lP6sw 8jbwahIjnn8MkiVX0fZ24pGeYKPx/KNH7/NKMMDByzNXG/SqGz3A4rvyQglPhIQQbSFu xB2A== 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:mime-version:content-transfer-encoding; bh=mj1oSizWUqYn/kFlxtQ1GxX/TiBaZDktZ4mAMNcuV9Q=; b=eBq8suoUHjDe4manBvOIZgBb2eJ8zOPtLMd/AzAniKXp+IXZm17y3IQoSbQBhdrR1b rsKaOwmwnowWERGtL3zq/Dc6amAk9Z4kgCFNWGxPL8DRk3Fx9lXUvD25unkI1YgOvRVk 59y8mwYJ6P5t6nPeidt9m9kMNhbP3qwhnPKxIuGTdM5BEOB0MvQfbABwj1KPy1+O0ZyY sIYprincAXgJg7IVJB285v3lYeYw/fdmt5K+yKrOA8b3OUnngDkH1NVg7k08dHjAIAmV GhUhI89IfOqu9Ev1B1MofjrgEyi7As5zsHornstuLWDW3Vxrazs4xTuAzpDNDWuHH6s7 WcQg== X-Gm-Message-State: AOAM533AshPDgNi3pKs3B7Nq22xqUtK1dNx5dTDS+IkkAVykjldYGE5n nnWntZTQwqqBNqrfg3dkp/a7Ldxc0R7UYAo6g3c= X-Google-Smtp-Source: ABdhPJxJz1d/rFoA20zSBHMuhe3nj7yEs0GdO3PR22ygp6z9sCJ7IGbiD4fPqodHt/Q/+1cc1s8SDw== X-Received: by 2002:a05:651c:225:: with SMTP id z5mr2868449ljn.409.1630674872185; Fri, 03 Sep 2021 06:14:32 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 13/14] target/riscv: Remove RVB (replaced by Zb[abcs] Date: Fri, 3 Sep 2021 15:14:16 +0200 Message-Id: <20210903131417.2248471-14-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lj1-x236.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630676149277100003 Content-Type: text/plain; charset="utf-8" With everything classified as Zb[abcs] and pre-0.93 draft-B instructions that are not part of Zb[abcs] removed, we can remove the remaining support code for RVB. Note that RVB has been retired for good and misa.B will neither mean 'some' or 'all of' Zb*: https://lists.riscv.org/g/tech-bitmanip/message/532 Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- (no changes since v3) Changes in v3: - Removing RVB moved into a separate commit at the tail-end of the series. target/riscv/cpu.c | 27 --------------------------- target/riscv/cpu.h | 3 --- target/riscv/insn32.decode | 4 ---- 3 files changed, 34 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index c7bc1f9f44..93bd8f7802 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -127,11 +127,6 @@ static void set_priv_version(CPURISCVState *env, int p= riv_ver) env->priv_ver =3D priv_ver; } =20 -static void set_bext_version(CPURISCVState *env, int bext_ver) -{ - env->bext_ver =3D bext_ver; -} - static void set_vext_version(CPURISCVState *env, int vext_ver) { env->vext_ver =3D vext_ver; @@ -393,7 +388,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error *= *errp) CPURISCVState *env =3D &cpu->env; RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(dev); int priv_version =3D PRIV_VERSION_1_11_0; - int bext_version =3D BEXT_VERSION_0_93_0; int vext_version =3D VEXT_VERSION_0_07_1; target_ulong target_misa =3D env->misa; Error *local_err =3D NULL; @@ -418,7 +412,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error *= *errp) } =20 set_priv_version(env, priv_version); - set_bext_version(env, bext_version); set_vext_version(env, vext_version); =20 if (cpu->cfg.mmu) { @@ -496,24 +489,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) if (cpu->cfg.ext_h) { target_misa |=3D RVH; } - if (cpu->cfg.ext_b) { - target_misa |=3D RVB; - - if (cpu->cfg.bext_spec) { - if (!g_strcmp0(cpu->cfg.bext_spec, "v0.93")) { - bext_version =3D BEXT_VERSION_0_93_0; - } else { - error_setg(errp, - "Unsupported bitmanip spec version '%s'", - cpu->cfg.bext_spec); - return; - } - } else { - qemu_log("bitmanip version is not specified, " - "use the default value v0.93\n"); - } - set_bext_version(env, bext_version); - } if (cpu->cfg.ext_v) { target_misa |=3D RVV; if (!is_power_of_2(cpu->cfg.vlen)) { @@ -584,7 +559,6 @@ static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("s", RISCVCPU, cfg.ext_s, true), DEFINE_PROP_BOOL("u", RISCVCPU, cfg.ext_u, true), /* This is experimental so mark with 'x-' */ - DEFINE_PROP_BOOL("x-b", RISCVCPU, cfg.ext_b, false), DEFINE_PROP_BOOL("x-zba", RISCVCPU, cfg.ext_zba, false), DEFINE_PROP_BOOL("x-zbb", RISCVCPU, cfg.ext_zbb, false), DEFINE_PROP_BOOL("x-zbc", RISCVCPU, cfg.ext_zbc, false), @@ -595,7 +569,6 @@ static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), - DEFINE_PROP_STRING("bext_spec", RISCVCPU, cfg.bext_spec), DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7c4cd8ea89..77e8b06106 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -67,7 +67,6 @@ #define RVS RV('S') #define RVU RV('U') #define RVH RV('H') -#define RVB RV('B') =20 /* S extension denotes that Supervisor mode exists, however it is possible to have a core that support S mode but does not have an MMU and there @@ -83,7 +82,6 @@ enum { #define PRIV_VERSION_1_10_0 0x00011000 #define PRIV_VERSION_1_11_0 0x00011100 =20 -#define BEXT_VERSION_0_93_0 0x00009300 #define VEXT_VERSION_0_07_1 0x00000701 =20 enum { @@ -288,7 +286,6 @@ struct RISCVCPU { bool ext_f; bool ext_d; bool ext_c; - bool ext_b; bool ext_s; bool ext_u; bool ext_h; diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index abf794095a..0f6020ccb1 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -711,10 +711,6 @@ rorw 0110000 .......... 101 ..... 0111011 @r # instruction, so we use different handler functions to differentiate. zext_h_64 0000100 00000 ..... 100 ..... 0111011 @r2 =20 -# *** RV32B Standard Extension *** - -# *** RV64B Standard Extension (in addition to RV32B) *** - # *** RV32 Zbc Standard Extension *** clmul 0000101 .......... 001 ..... 0110011 @r clmulh 0000101 .......... 011 ..... 0110011 @r --=20 2.25.1 From nobody Wed May 1 13:26:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630676617981738.2831250038273; Fri, 3 Sep 2021 06:43:37 -0700 (PDT) Received: from localhost ([::1]:35550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM9Tk-0005XA-R6 for importer@patchew.org; Fri, 03 Sep 2021 09:43:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM91i-0002Uz-6Z for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:39 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]:46777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM91f-0003gi-0O for qemu-devel@nongnu.org; Fri, 03 Sep 2021 09:14:37 -0400 Received: by mail-lf1-x133.google.com with SMTP id t19so11671605lfe.13 for ; Fri, 03 Sep 2021 06:14:34 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id n5sm577995ljj.97.2021.09.03.06.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 06:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xjHbcU4jd4/FFyGkcPZC0fU+deSURo/V2puvaJZ+g/s=; b=fZVXzDtDmps8l759grorMlr5p2qluipebNhfb928crq50wkXCJ2WtH9G4oTxjOYW4l pcgNQVNG7Y4Wz0QBKXpsxrUC6f04iJCsMUTmvu8UhjWJKXScugaWl876J5e+BDhNhSWZ isMGYf9N16dNLUT8T+2skU1s9rnvmS7k07BpDqg88UMntKkl6stFucwIqUf8DWSc0Po7 KdNak36fYk+ijeCttLxTEfpDwwXiGGctTu6JRPVEIgLzVtYArKL4r8rCsBE6weDpWjmd jYzbx/JM3GkbAndqsJ77mNjCiF2B6edPVNGVFwrVDvDiBixQOSVFOLMNa/VgDKFYoxb9 kZtQ== 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:mime-version:content-transfer-encoding; bh=xjHbcU4jd4/FFyGkcPZC0fU+deSURo/V2puvaJZ+g/s=; b=biJm+lSJ2ccgfqRgiL72p3T84Ld0nFBtlqVHFgVPMTkdDatcI3wahG2c4afUhwaKwO Y5z3qO6YK+J0R25aTMZ4ppxxtdEaI3fbkviGFqHxDUTdsst2KVX8Nm78Rs3d6u+zG6l1 KJhkDeJkx6b1s00LM5ZIN6XCGOHrj5Fp7mNVjibx9TAXMGRGPNaihBmnlforrbDwaVy5 Il5JlvtewYHdwmVSI/mVaGibTGXc0vFWh8JCAZuHINXPX9KYY6ASIe7bKWHqudOzqsjb T8Z/l1fonwTsO45Kx8aYLPqmiVh5pPu71OBriV2WSIZcOpFiVzz1FKYcta7tVXKvGUbK mlAA== X-Gm-Message-State: AOAM531esGLIUmc30raJ+UO8kfmnylbyJfUl588HGWxrU0Kdb5QxWb11 ouEeQXdqpt0uUVTRdzvAmUz2Uzt9Ai+FVvYDUQg= X-Google-Smtp-Source: ABdhPJxLN5TSKQ9NCx7N3XueiJ1yMw0we5idU+klnk/A73pu5LQPxg1l8s5GD0EJw5wN9EHYoq248w== X-Received: by 2002:a05:6512:b92:: with SMTP id b18mr2663719lfv.577.1630674873071; Fri, 03 Sep 2021 06:14:33 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v8 14/14] disas/riscv: Add Zb[abcs] instructions Date: Fri, 3 Sep 2021 15:14:17 +0200 Message-Id: <20210903131417.2248471-15-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> References: <20210903131417.2248471-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lf1-x133.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Richard Henderson , Kito Cheng , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630676619583100001 Content-Type: text/plain; charset="utf-8" With the addition of Zb[abcs], we also need to add disassembler support for these new instructions. Signed-off-by: Philipp Tomsich Acked-by: Alistair Francis --- (no changes since v2) Changes in v2: - Fix missing ';' from last-minute whitespace cleanups. disas/riscv.c | 157 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 3 deletions(-) diff --git a/disas/riscv.c b/disas/riscv.c index 278d9be924..793ad14c27 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -478,6 +478,49 @@ typedef enum { rv_op_fsflags =3D 316, rv_op_fsrmi =3D 317, rv_op_fsflagsi =3D 318, + rv_op_bseti =3D 319, + rv_op_bclri =3D 320, + rv_op_binvi =3D 321, + rv_op_bexti =3D 322, + rv_op_rori =3D 323, + rv_op_clz =3D 324, + rv_op_ctz =3D 325, + rv_op_cpop =3D 326, + rv_op_sext_h =3D 327, + rv_op_sext_b =3D 328, + rv_op_xnor =3D 329, + rv_op_orn =3D 330, + rv_op_andn =3D 331, + rv_op_rol =3D 332, + rv_op_ror =3D 333, + rv_op_sh1add =3D 334, + rv_op_sh2add =3D 335, + rv_op_sh3add =3D 336, + rv_op_sh1add_uw =3D 337, + rv_op_sh2add_uw =3D 338, + rv_op_sh3add_uw =3D 339, + rv_op_clmul =3D 340, + rv_op_clmulr =3D 341, + rv_op_clmulh =3D 342, + rv_op_min =3D 343, + rv_op_minu =3D 344, + rv_op_max =3D 345, + rv_op_maxu =3D 346, + rv_op_clzw =3D 347, + rv_op_ctzw =3D 348, + rv_op_cpopw =3D 349, + rv_op_slli_uw =3D 350, + rv_op_add_uw =3D 351, + rv_op_rolw =3D 352, + rv_op_rorw =3D 353, + rv_op_rev8 =3D 354, + rv_op_zext_h =3D 355, + rv_op_roriw =3D 356, + rv_op_orc_b =3D 357, + rv_op_bset =3D 358, + rv_op_bclr =3D 359, + rv_op_binv =3D 360, + rv_op_bext =3D 361, } rv_op; =20 /* structures */ @@ -1117,6 +1160,49 @@ const rv_opcode_data opcode_data[] =3D { { "fsflags", rv_codec_i_csr, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, { "fsrmi", rv_codec_i_csr, rv_fmt_rd_zimm, NULL, 0, 0, 0 }, { "fsflagsi", rv_codec_i_csr, rv_fmt_rd_zimm, NULL, 0, 0, 0 }, + { "bseti", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, + { "bclri", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, + { "binvi", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, + { "bexti", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, + { "rori", rv_codec_i_sh7, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, + { "clz", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "ctz", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "cpop", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "sext.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "sext.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "xnor", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "orn", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "andn", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "rol", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "ror", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "sh1add", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "sh2add", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "sh3add", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "sh1add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "sh2add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "sh3add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "clmul", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "clmulr", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "clmulh", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "min", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "minu", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "max", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "maxu", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "clzw", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "clzw", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "cpopw", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "slli.uw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "add.uw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "rolw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "rorw", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "rev8", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "zext.h", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "roriw", rv_codec_i_sh5, rv_fmt_rd_rs1_imm, NULL, 0, 0, 0 }, + { "orc.b", rv_codec_r, rv_fmt_rd_rs1, NULL, 0, 0, 0 }, + { "bset", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "bclr", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "binv", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, + { "bext", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 }, }; =20 /* CSR names */ @@ -1507,7 +1593,20 @@ static void decode_inst_opcode(rv_decode *dec, rv_is= a isa) case 0: op =3D rv_op_addi; break; case 1: switch (((inst >> 27) & 0b11111)) { - case 0: op =3D rv_op_slli; break; + case 0b00000: op =3D rv_op_slli; break; + case 0b00101: op =3D rv_op_bseti; break; + case 0b01001: op =3D rv_op_bclri; break; + case 0b01101: op =3D rv_op_binvi; break; + case 0b01100: + switch (((inst >> 20) & 0b1111111)) { + case 0b0000000: op =3D rv_op_clz; break; + case 0b0000001: op =3D rv_op_ctz; break; + case 0b0000010: op =3D rv_op_cpop; break; + /* 0b0000011 */ + case 0b0000100: op =3D rv_op_sext_b; break; + case 0b0000101: op =3D rv_op_sext_h; break; + } + break; } break; case 2: op =3D rv_op_slti; break; @@ -1515,8 +1614,16 @@ static void decode_inst_opcode(rv_decode *dec, rv_is= a isa) case 4: op =3D rv_op_xori; break; case 5: switch (((inst >> 27) & 0b11111)) { - case 0: op =3D rv_op_srli; break; - case 8: op =3D rv_op_srai; break; + case 0b00000: op =3D rv_op_srli; break; + case 0b00101: op =3D rv_op_orc_b; break; + case 0b01000: op =3D rv_op_srai; break; + case 0b01001: op =3D rv_op_bexti; break; + case 0b01100: op =3D rv_op_rori; break; + case 0b01101: + switch ((inst >> 20) & 0b1111111) { + case 0b0111000: op =3D rv_op_rev8; break; + } + break; } break; case 6: op =3D rv_op_ori; break; @@ -1530,12 +1637,21 @@ static void decode_inst_opcode(rv_decode *dec, rv_i= sa isa) case 1: switch (((inst >> 25) & 0b1111111)) { case 0: op =3D rv_op_slliw; break; + case 4: op =3D rv_op_slli_uw; break; + case 48: + switch ((inst >> 20) & 0b11111) { + case 0b00000: op =3D rv_op_clzw; break; + case 0b00001: op =3D rv_op_ctzw; break; + case 0b00010: op =3D rv_op_cpopw; break; + } + break; } break; case 5: switch (((inst >> 25) & 0b1111111)) { case 0: op =3D rv_op_srliw; break; case 32: op =3D rv_op_sraiw; break; + case 48: op =3D rv_op_roriw; break; } break; } @@ -1623,8 +1739,32 @@ static void decode_inst_opcode(rv_decode *dec, rv_is= a isa) case 13: op =3D rv_op_divu; break; case 14: op =3D rv_op_rem; break; case 15: op =3D rv_op_remu; break; + case 36: + switch ((inst >> 20) & 0b11111) { + case 0: op =3D rv_op_zext_h; break; + } + break; + case 41: op =3D rv_op_clmul; break; + case 42: op =3D rv_op_clmulr; break; + case 43: op =3D rv_op_clmulh; break; + case 44: op =3D rv_op_min; break; + case 45: op =3D rv_op_minu; break; + case 46: op =3D rv_op_max; break; + case 47: op =3D rv_op_maxu; break; + case 130: op =3D rv_op_sh1add; break; + case 132: op =3D rv_op_sh2add; break; + case 134: op =3D rv_op_sh3add; break; + case 161: op =3D rv_op_bset; break; case 256: op =3D rv_op_sub; break; + case 260: op =3D rv_op_xnor; break; case 261: op =3D rv_op_sra; break; + case 262: op =3D rv_op_orn; break; + case 263: op =3D rv_op_andn; break; + case 289: op =3D rv_op_bclr; break; + case 293: op =3D rv_op_bext; break; + case 385: op =3D rv_op_rol; break; + case 386: op =3D rv_op_ror; break; + case 417: op =3D rv_op_binv; break; } break; case 13: op =3D rv_op_lui; break; @@ -1638,8 +1778,19 @@ static void decode_inst_opcode(rv_decode *dec, rv_is= a isa) case 13: op =3D rv_op_divuw; break; case 14: op =3D rv_op_remw; break; case 15: op =3D rv_op_remuw; break; + case 32: op =3D rv_op_add_uw; break; + case 36: + switch ((inst >> 20) & 0b11111) { + case 0: op =3D rv_op_zext_h; break; + } + break; + case 130: op =3D rv_op_sh1add_uw; break; + case 132: op =3D rv_op_sh2add_uw; break; + case 134: op =3D rv_op_sh3add_uw; break; case 256: op =3D rv_op_subw; break; case 261: op =3D rv_op_sraw; break; + case 385: op =3D rv_op_rolw; break; + case 389: op =3D rv_op_rorw; break; } break; case 16: --=20 2.25.1