From patchwork Thu Aug 19 09:04:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 499720 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp332602jab; Thu, 19 Aug 2021 02:14:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFV1D8+5Qkdun20cLruXVmavHnXnmsD4T0ceKQ+34vfEedTBPlUGmSvoy9s/3DqK4OmqST X-Received: by 2002:a92:dd09:: with SMTP id n9mr8974082ilm.298.1629364448967; Thu, 19 Aug 2021 02:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629364448; cv=none; d=google.com; s=arc-20160816; b=VPfKEplNVkmuamjN7TRHhVPd8dabn3kLCLLWTVRz6I9lCEffs9HjENQhijgs2xDgHe bucNT65uLAzSBIQghrnAIHqM1cz6v8efgCyd+4c+jJAU22kduZ15HcDESQLmts+iqUnU L08qGTpDsqfVuzRb+dmAu2XTPpAtyb19Fhw6PiaHNRVUOH2uSLH2j87cdxb0a62/Bprw oINDU5xPM/itIS2sjtnaAstBtJaIAXjqIZXwwzO9KcGAb75fmZhrIU6vJm3rjKKgd18g Ti13sd0tlXSeoBXmyrpGbAN8cT/Bjck+p04SghndmOwzDgm9agdb/wDKB4o1rBZ8xSGp BDEA== 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=kD7mJuftY22HTobeiFgod9RkHOG3VKFi3PUsGZtJYQ0=; b=VSqq3QO0PpThkjq7ixg1bye5ChgsLx2L8p7OQ01w5e20U92NHCplIlLe3QitahpP85 Ydej4LBd/BUf12fI3I6VhgctjxdQOol5wk8cipo0M+WczoWOzbf1IfMUfVbHJ7uxxsBc PvPg9TD23NfqoD/vDkEBYO89KkGCU4hurQRITK3+PW5oE+fuCrkuQlOl/rHlbc1qtJIk YRJb0WxukA5mYZvbJmtbLFTa2TuGODyjCyNL6qDLe4vVcuXq7YNsLxp9PViqn1tgOg8Y Z6kzV+CgVWsVjV4v01tu7+zf1QutEegWs5FadoYLrUOtNDjF1tSl3f+tCjwlWooVZzs+ NHZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="hGFod1e/"; 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 b3si1523323ile.20.2021.08.19.02.14.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Aug 2021 02:14:08 -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="hGFod1e/"; 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]:50432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGe7k-0000cI-Cd for patch@linaro.org; Thu, 19 Aug 2021 05:14:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGdzK-0006B6-1x for qemu-devel@nongnu.org; Thu, 19 Aug 2021 05:05:26 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:45984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGdzH-0000F6-Vk for qemu-devel@nongnu.org; Thu, 19 Aug 2021 05:05:25 -0400 Received: by mail-pg1-x530.google.com with SMTP id n18so5279093pgm.12 for ; Thu, 19 Aug 2021 02:05: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=kD7mJuftY22HTobeiFgod9RkHOG3VKFi3PUsGZtJYQ0=; b=hGFod1e/2vQfYpZ3U77yMDYPtUNGvSvOCg0Z13Moh5ykgExZfPWcGCaAtqziv3GFrS EFB7l+eiRfsgXFaq2sshXUelg/a/7092B0wlzgiy1DykNPp0NcScAgmAEjbr/z+sdjxK nGRQ6xdsFj6hn81jHPcBU58mjwJ+QN0Gm8vWPBrNp9JlTWjNRNa1zZgrJkx6s13Q5NA2 gx8I+kvRBC3SuMGPEOSDwJR2rQ+U60J3wSXfkuYmetIudQoIND6lJ5OrutG2oa+8nIjx KaHyOh31b/kb5RAhscfqgyv5mJllt0D7sXGkUyxIwvTAw8P8G+LE6toIXWWEg/lrv1mE AyAQ== 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=kD7mJuftY22HTobeiFgod9RkHOG3VKFi3PUsGZtJYQ0=; b=gs7EJ3DZJmqotBywwdU2VotRy8l3AWq34wa6nt1davs4xo45X/9wnnPl+blCu4YPc8 QWgS30e4KvituiSCLMhSmki19QidC3SzvR4toAE/K5liX1hWRZ994QXvexe2wvgOO7Lt bHpbRvRoj32YHXAedPTZObS6wQ/F4/KYTQPKaNeUTcxa4jdVB7Gv3pE15KIaaPY/k6HD ToQi8NTzwK0ypYOnE50iVY99r0Mdp6oRwlFO2dG53bSYsm8gVl1u36MvpkbxMizl0gVc S6zI5ot7CMOBFaUwDqDgCpcowSrxmY9s641u4wRIvkOpD6jY8kCpFD4vWHmFxYPKeRwk A2fA== X-Gm-Message-State: AOAM5333+EbWXdQS7Y72q0TkzhKQvJl/pTnVKyV+XmK9GPrQNHy3Yegv 4zadvcESFU5d37L2oqg+miknbv5fMLPhOg== X-Received: by 2002:a05:6a00:1a14:b0:3e1:e81d:cef2 with SMTP id g20-20020a056a001a1400b003e1e81dcef2mr13630717pfv.54.1629363922620; Thu, 19 Aug 2021 02:05:22 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id j13sm2944707pgp.29.2021.08.19.02.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 02:05:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/21] target/riscv: Add DisasExtend to gen_unary Date: Wed, 18 Aug 2021 23:04:51 -1000 Message-Id: <20210819090502.428068-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210819090502.428068-1-richard.henderson@linaro.org> References: <20210819090502.428068-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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 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 09853530c4..785e9e58cc 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -478,17 +478,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)