From patchwork Tue Aug 17 21:17:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 498133 Delivered-To: patch@linaro.org Received: by 2002:a17:907:2648:0:0:0:0 with SMTP id ar8csp3530068ejc; Tue, 17 Aug 2021 14:25:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXIgFyN3XR4LJQBk6iAyoIujzDqQhtzSqYapXTle8x2I9jq94N2Ltj8W7ndiD6T69SK3SJ X-Received: by 2002:a02:caa1:: with SMTP id e1mr4731112jap.107.1629235502652; Tue, 17 Aug 2021 14:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629235502; cv=none; d=google.com; s=arc-20160816; b=ZauYqysDFhiSXHJ5HNEvoQ3oJ4ypAmJddTOiRnw76yjsrV4ObvLFinE94lERW/4/1c /bS+VZRdM9dvGe2i7NiAqfHnkEKSb0l18hdsPxHs9mnk5W8wPiF/9GZ6+PAtYaZZ9ulD jlCK5yv38YW0GqRMErvhMP7aSdv5UeFdIoLTYZaEWJQ0f1y2HvID66HH6i+yzZ0HWM8t 6BYf35+GLen74R4AUjXgasjYKJ8C3WyMFXrY45nSnUSbeUTyd8SgPGUbNj4GQIRa7oJz VOJ2ZozJ5mboc3xHJWg1UCjGlOom+NCEW7EhumYDPIpeRf4AYI6JvHdkHlO3BVzcARlU rizg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=KuLqHw6EmBFQhmSiZUuE3orIiC7schsJfqiWupX1ZH8=; b=I8CCVHm3NfyF5pgOKN+j0XPfMwD45+fEP8sM9Gofm9/q0cm6oUpAIDhFpLFxgfsbET jvOThkP+5YcnkiQvczMtg4H7aEJv1bQ4O9JkEcpQ0kBZukgTdzfAvaTCU55bEN82591n ZC81n1aNouMCrvGfmAdU6gx+p7qpQVxJPX5d89VoxarIryTXqviRlRsAm1kzF5+Azjs5 Z9VC6xEICTyDIQ8y4SDI6C6Uue1faRHDQHP/rDb+hRJwoTz7GeCBaRaC9w1WxVxGen4M y8DMrDZaRgJJxpUcxZ3pcnDI/tP+cUT/8ppNr11O/d6LN4SFB7DxfAcTJIjsohEE2BvQ A3/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vCmrYVDT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n8si3992173jat.62.2021.08.17.14.25.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Aug 2021 14:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vCmrYVDT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mG6Zx-0005UI-OP for patch@linaro.org; Tue, 17 Aug 2021 17:25:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mG6TZ-0001Rz-EV for qemu-devel@nongnu.org; Tue, 17 Aug 2021 17:18:25 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:46770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mG6TX-0001AQ-LS for qemu-devel@nongnu.org; Tue, 17 Aug 2021 17:18:25 -0400 Received: by mail-pf1-x42e.google.com with SMTP id y11so5907pfl.13 for ; Tue, 17 Aug 2021 14:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KuLqHw6EmBFQhmSiZUuE3orIiC7schsJfqiWupX1ZH8=; b=vCmrYVDT+DE0EcbieoxOrBWlX/TkPTNwXyBa23JQMLZkN2JCGWq1NbvRauikqFrb+G LXV5SSMdpRYPI7v1Cl//AK2esrmVSYgt04XO2EMvfp5szIIaVxKzgGhLwdc3BlmWhutO AlY+DP9L9Pjj5QiUERGjCqG5/4HWG8XhLHx3A+ZdcBRV4NGJ3J93k3cyxiawjvX5WwSm SstVIvFyImzryBS3VRrWhxekQjb88VOH7nybX3iDAp+M2vU+XG3+t8SkQItnRokIT3Il CwlIjVz7IC14WCNI8EL+YbWyLJXKr67Mb2nJvghMDryT0qEjIAC0mnLIuWvgJLS5OEOg Dhfg== 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=KuLqHw6EmBFQhmSiZUuE3orIiC7schsJfqiWupX1ZH8=; b=DoOby7sixH+9scgZgi1GvdTa8VRNbXu7trVzIIwzyMU09aBNPHlB7OvTtVBY1IKsyj 24O3tjpwYIlprhK/kPJIf3jxGvTfFWCqncOWyns2Xqucw8MaWLgFpo17TsTHCZ+4uWHq aG8nIM15NP0lagZvqLdzWxdykp/2KeZWhSA8tQTZXCFJb7x90+hMA1fq/49eI07IaFz1 Eh/dg881l5Ksrrq8F/da1J1pzeuL9LtewwaPicfmL+LKFnFODFbvyuZtRtMVvArHLzPG acZfuj1c1VguEfhA+dS58/rF0xSyITEPsnme1GQlsgJ2Hyidl8hK2Tqwza4iXWlWzgoV MSDw== X-Gm-Message-State: AOAM533ozUVJQmFewo6we0ObdvhA8LHYsycILpixG+u5nsavC501tbqS WLoET3m1NOvx8Z81CvsoLW/e0+N45vyHNw== X-Received: by 2002:a05:6a00:181c:b029:3c6:2258:a844 with SMTP id y28-20020a056a00181cb02903c62258a844mr5679370pfa.6.1629235102437; Tue, 17 Aug 2021 14:18:22 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id q1sm2978637pjl.44.2021.08.17.14.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 14:18:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/21] target/riscv: Add DisasExtend to gen_unary Date: Tue, 17 Aug 2021 11:17:52 -1000 Message-Id: <20210817211803.283639-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210817211803.283639-1-richard.henderson@linaro.org> References: <20210817211803.283639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-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: Alistair.Francis@wdc.com, bin.meng@windriver.com, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use ctx->w for ctpopw, which is the only one that can re-use the generic algorithm for the narrow operation. Signed-off-by: Richard Henderson --- target/riscv/translate.c | 14 ++++++-------- target/riscv/insn_trans/trans_rvb.c.inc | 24 +++++++++--------------- 2 files changed, 15 insertions(+), 23 deletions(-) -- 2.25.1 diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 8d96e70abb..178d317976 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -477,17 +477,15 @@ static bool gen_shiftiw(DisasContext *ctx, arg_shift *a, return true; } -static bool gen_unary(DisasContext *ctx, arg_r2 *a, - void(*func)(TCGv, TCGv)) +static bool gen_unary(DisasContext *ctx, arg_r2 *a, DisasExtend ext, + void (*func)(TCGv, TCGv)) { - TCGv source = tcg_temp_new(); + TCGv dest = dest_gpr(ctx, a->rd); + TCGv src1 = get_gpr(ctx, a->rs1, ext); - gen_get_gpr(ctx, source, a->rs1); + func(dest, src1); - (*func)(source, source); - - gen_set_gpr(ctx, a->rd, source); - tcg_temp_free(source); + gen_set_gpr(ctx, a->rd, dest); return true; } diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc index 73f088be23..e255678fff 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -26,7 +26,7 @@ static void gen_clz(TCGv ret, TCGv arg1) static bool trans_clz(DisasContext *ctx, arg_clz *a) { REQUIRE_EXT(ctx, RVB); - return gen_unary(ctx, a, gen_clz); + return gen_unary(ctx, a, EXT_ZERO, gen_clz); } static void gen_ctz(TCGv ret, TCGv arg1) @@ -37,13 +37,13 @@ static void gen_ctz(TCGv ret, TCGv arg1) static bool trans_ctz(DisasContext *ctx, arg_ctz *a) { REQUIRE_EXT(ctx, RVB); - return gen_unary(ctx, a, gen_ctz); + return gen_unary(ctx, a, EXT_ZERO, gen_ctz); } static bool trans_cpop(DisasContext *ctx, arg_cpop *a) { REQUIRE_EXT(ctx, RVB); - return gen_unary(ctx, a, tcg_gen_ctpop_tl); + return gen_unary(ctx, a, EXT_ZERO, tcg_gen_ctpop_tl); } static bool trans_andn(DisasContext *ctx, arg_andn *a) @@ -132,13 +132,13 @@ static bool trans_maxu(DisasContext *ctx, arg_maxu *a) static bool trans_sext_b(DisasContext *ctx, arg_sext_b *a) { REQUIRE_EXT(ctx, RVB); - return gen_unary(ctx, a, tcg_gen_ext8s_tl); + return gen_unary(ctx, a, EXT_NONE, tcg_gen_ext8s_tl); } static bool trans_sext_h(DisasContext *ctx, arg_sext_h *a) { REQUIRE_EXT(ctx, RVB); - return gen_unary(ctx, a, tcg_gen_ext16s_tl); + return gen_unary(ctx, a, EXT_NONE, tcg_gen_ext16s_tl); } static void gen_sbop_mask(TCGv ret, TCGv shamt) @@ -366,7 +366,6 @@ GEN_TRANS_SHADD(3) static void gen_clzw(TCGv ret, TCGv arg1) { - tcg_gen_ext32u_tl(ret, arg1); tcg_gen_clzi_tl(ret, ret, 64); tcg_gen_subi_tl(ret, ret, 32); } @@ -375,7 +374,7 @@ static bool trans_clzw(DisasContext *ctx, arg_clzw *a) { REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVB); - return gen_unary(ctx, a, gen_clzw); + return gen_unary(ctx, a, EXT_ZERO, gen_clzw); } static void gen_ctzw(TCGv ret, TCGv arg1) @@ -388,20 +387,15 @@ static bool trans_ctzw(DisasContext *ctx, arg_ctzw *a) { REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVB); - return gen_unary(ctx, a, gen_ctzw); -} - -static void gen_cpopw(TCGv ret, TCGv arg1) -{ - tcg_gen_ext32u_tl(arg1, arg1); - tcg_gen_ctpop_tl(ret, arg1); + return gen_unary(ctx, a, EXT_NONE, gen_ctzw); } static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a) { REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVB); - return gen_unary(ctx, a, gen_cpopw); + ctx->w = true; + return gen_unary(ctx, a, EXT_ZERO, tcg_gen_ctpop_tl); } static void gen_packw(TCGv ret, TCGv arg1, TCGv arg2)