From patchwork Mon Aug 23 19:55:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 501559 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp2495767jab; Mon, 23 Aug 2021 13:03:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR+KavjIhUND6yjC1gcHBlDAuBRkGwjG2YrkByQKaQfVpE8o1d1FJHadjiRpXN2/93tlPW X-Received: by 2002:a05:6402:2158:: with SMTP id bq24mr39561640edb.8.1629749031327; Mon, 23 Aug 2021 13:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629749031; cv=none; d=google.com; s=arc-20160816; b=GXUBqhd0QeVqRPZCBeJyj3PDlec9CZ2AwfDa8KdGlKR9y+DRbNvfZTPAFR1QDbUiZl /mH+14WhElPRBoFmAFExOEeEqmu847N9uSwp1IIjXZDL1p2cweTsfLLklcxTTNu5WqVJ bTEZHi31oUQUlZrx4QpmX3GXOxd9+2AugtycX9HoPdv31aBLksAcNtynNQZKP4RjqVzv Dwh0oeLeru8jCwb4/S1SwdKKu9xFwpUOTSrDwG8S3sJk14aRtPZE7o7Li6JniKNFKmnO DNky20RXOZbBAWkpMhKabxyVZl4DBhedo46mOcXti4gqFMNiVNzH557g+GX9iaK+s5qr GgHA== 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=kVyJzLAMP/AO1yuDPHJJ+rMmTd5Fqy79KswtGPvssO8=; b=X3JbazFcA/HPbcuylIIslKTjvRJToPiBo+YA/0rtAGH1HpBA7mO3qPB0ZTWSKXofDk c/ag7+tXSvwuuNc1wKLqXEioepBSCTzTCuUzjvdPUaYxOTUxQ0YCG4YKUF6XYZwV81gZ uMoW6AZ6CKCdPNG3OqOUMuz8W8NLWu/k0TQ0f12PGAxqtPrLdavBXM2RBZB58m7w9kfe dO8aPh72YRcAUDqxZyR2FZJ8WGzXfKtZhKF/huQhC2jf/gJ3AcCC6jOvZofx6WiDeQ7z 5Ovh56fK8ga7tJV+G2YZ3qftldjh3qWWE7WLJ9dS9mV3KNuwa4SWVb65RogmH1ftN7Cw 7d4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=rpOBlLK+; 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 y10si10056710edp.359.2021.08.23.13.03.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Aug 2021 13:03:51 -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=rpOBlLK+; 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]:40976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIGAg-0006mL-9f for patch@linaro.org; Mon, 23 Aug 2021 16:03:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIG2r-0006Ba-OZ for qemu-devel@nongnu.org; Mon, 23 Aug 2021 15:55:45 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:39883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIG2n-00037n-0M for qemu-devel@nongnu.org; Mon, 23 Aug 2021 15:55:45 -0400 Received: by mail-pl1-x635.google.com with SMTP id m17so3767194plc.6 for ; Mon, 23 Aug 2021 12:55:40 -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=kVyJzLAMP/AO1yuDPHJJ+rMmTd5Fqy79KswtGPvssO8=; b=rpOBlLK+JV5zPYTom0I/4+eKSANnWByUniSHLlNbSdWrAvtEauDzJSc9MGe43UKhcj D6/CP1Hefrfqt/mkgaCj8CKf3yMLOQ4uefgHmt1oqR6a4yACe6oxx1xkuXkqxnjSeDpS FJ30nwm2sDLFTrosnJZoP4e6e+m4++llJ6k1PxypEG+dSxkujggStAT7Ckm/wVA/5Ftw Jiy8DbKPo1bQPc6ejlscAfFN0mmo66yL0JEmYJKleSuvU0a66dTYHpScAemX3fw5Dkie V1/MjVwMwPljnFteKnDigeIZijH+4sFc7Ex2udNG62yND8YWIAxDPlUEX2E92OKpiEj+ 8GqQ== 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=kVyJzLAMP/AO1yuDPHJJ+rMmTd5Fqy79KswtGPvssO8=; b=efAdrx6GjcpwkhgCCugoF6SoldAvrf3ANVAfdc/jYeUKg02jSCg6nkz05HFtnDfsdb kZjnbuXwBhS9K+Pj7mQ2cjwSg957TzuRCG4lD0kAxGO9pZTTJRjoRLD4LlUTfZ58iqlK HeRYBZMvTGF0Y5rHtxygE+gdZVNODMmr0CRrUgXLcHY2vo2nZz/zULQCjimHdGN0asU0 Rx4hvvbb4jnKbsAZnV9mnwzArnLmCOSblR8m0fD54dyI5mn6w7bmawjsiXRhubKJQDvn IX0NZ0ORvGIutiGjZgsQD46VD25bjz1u8ATcY0JjSH7nxZZXqUOMi82oMM8vQeIcC5Sf 5V8g== X-Gm-Message-State: AOAM531+mKZ42Bf4HptxWRjbgOSFsKaRZ+GjFvuUBBVk3QIj3SZiWIjt 2rWSsHoSumt88DkmDzuB0x54YlLTXS6gcQ== X-Received: by 2002:a17:90a:5107:: with SMTP id t7mr268771pjh.74.1629748539453; Mon, 23 Aug 2021 12:55:39 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id v15sm16685078pff.105.2021.08.23.12.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 12:55:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 11/24] target/riscv: Add DisasExtend to gen_unary Date: Mon, 23 Aug 2021 12:55:16 -0700 Message-Id: <20210823195529.560295-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210823195529.560295-1-richard.henderson@linaro.org> References: <20210823195529.560295-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 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. Reviewed-by: Alistair Francis 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)