From patchwork Tue Aug 17 21:17:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 498134 Delivered-To: patch@linaro.org Received: by 2002:a17:907:2648:0:0:0:0 with SMTP id ar8csp3530509ejc; Tue, 17 Aug 2021 14:25:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuW7pLTHlk5737xFCqUKIQmC+nrFMFyKeGOouCdnOTQjXR7TPdFruTMrbHeBhTUl1wutg6 X-Received: by 2002:a02:7a15:: with SMTP id a21mr1477506jac.128.1629235542197; Tue, 17 Aug 2021 14:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629235542; cv=none; d=google.com; s=arc-20160816; b=IK5R8gLwqqPNIcgZokvdNyKRt1HZXISLjPw8YTmwJ9LG1kt5idjD5JvhzB4T1nAaSW tM9cPNTqDdjtXUF5SWxt22GeUPOr5GrDk/a0dUhmL1W7e8fPx1LOSzU1xclPkH0sOWJW l54wcWYvVewTtD79MwGA4gZmSyPLedvPXqWOqG1S6IhO3dJh14XkMY7vo2g+34U9viJo lTdwUs3b70S7Yu3XzP5CCHThq1vpA3AZOpl8KGUGOgK9AknCcwrSIVXziuqWCFF6hu3N x07zO3gp2yiyHl+7h7VOeCHBcTO18j3yjpjtefXMJBdhC+/PSB0vuYQlbTdyDo8jBPUo PzUQ== 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=O4Nyyfchw7ka6xBuv/frcGz+7bIxeXKGfnY6JSWCHr0=; b=DJLRisduwVUcKSvpkEc6bNGj0DG9nPrWm1nk/79WNvZDdIUlgxdKbgqNs5Xq/95049 jkI9WzHgEZ9prLhAa49C/Hv6P+4h39tS4fsQoUkRCj9hSw9UhLjVooNEkGSY93F7KHtS EKsrk2lmw2EeSKxD+wi5KNjDACEWgJgFC8zPVIGZGWatQgsMFZh+t/3j+Ki1aE5hhrGq nxVZW+MAJFCPl/4yLh4pxUoeYMtgw5XPakB8q3TX02byYJFpMm+vGloo0pXFxqC+qYCN CjsPtTWPf0uDItoMuY9xi0o7Tp+2qTvCPFoeiRQTNiBvYerkKpraIJ526dRPF85BBaIc Bq8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=V+AgwGmg; 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 t3si3361563ilj.52.2021.08.17.14.25.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Aug 2021 14:25:42 -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=V+AgwGmg; 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]:34062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mG6ab-0007YZ-G8 for patch@linaro.org; Tue, 17 Aug 2021 17:25:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mG6Ti-0001nh-Ve for qemu-devel@nongnu.org; Tue, 17 Aug 2021 17:18:34 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:40489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mG6Tg-0001Ge-Cg for qemu-devel@nongnu.org; Tue, 17 Aug 2021 17:18:34 -0400 Received: by mail-pj1-x1030.google.com with SMTP id n13-20020a17090a4e0d00b0017946980d8dso7442038pjh.5 for ; Tue, 17 Aug 2021 14:18:32 -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=O4Nyyfchw7ka6xBuv/frcGz+7bIxeXKGfnY6JSWCHr0=; b=V+AgwGmgbeKYdFQt8JcaPXe+kM1AV/ypmTrOdCGFd+szLLKct//CPbSywjIV1zwwot VtzUA7aJgQVS+wwMuK18hphUrPPLglYA1ND27IMW/HqRpUtxlc9PX+3qCleH7933e+F0 n62I4NZtYiLeZYiq3hXQI1OJDtvA97VYd5dlQCf1PGUoIcK6/bRWxiDJPzrjJchiAfXX PxO6R5Q8qlN+HQINoBBIcKdBtnDnJoedzEXqPkiMpOwEh17hftSwT4ltSsFrn0rVGFwA aD0QoZWwBTt/QefB/TJdP+dROs9MjUBczpsPVkqT3dAPJRkOgST0qQRmzhJACuNGMZc/ LnGw== 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=O4Nyyfchw7ka6xBuv/frcGz+7bIxeXKGfnY6JSWCHr0=; b=jFIxZms/kd7MrtNPZ4h3R6/pM6Pz4UHcSG3X+GDHzLBwof52Cj9t8l2QDGojIhpwMV 2eXjYdr4LEoRwAXHZ5dMDewnWFeM5bimktiHR2NLXR8cLElp6h0Z6mmBjojsoJoLVVVc Vs6QF8zWASTJQkzNBqeg3yrKyPjRamfwTQ/imjmyTAv4784mf75GVcbPL+V6jdqTqnkH 1dpCH2Izt6ImRyUSzaPoQ3jxNP9m7eypxrOQttkRPM2D9Vu99nc1wMnl/7qdErapbT6+ 7nVcpUSZFHzrRe0pqWPg1RqBKO/52MEhjnnvCsYYtAiVtWmKMzk405u+6hGGx4mBVqQC pcYg== X-Gm-Message-State: AOAM532pDK7AOs0FEWE0SbPmbprJI7ejtj6DBDAKCajztkcfvPKWIqvp w06xsC/TwLwXZgW3+Eti7zyOyaA+EdtDYg== X-Received: by 2002:a17:902:a513:b029:11a:9be6:f1b9 with SMTP id s19-20020a170902a513b029011a9be6f1b9mr4318160plq.55.1629235111101; Tue, 17 Aug 2021 14:18:31 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id q1sm2978637pjl.44.2021.08.17.14.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 14:18:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 16/21] target/riscv: Use {get,dest}_gpr for RVA Date: Tue, 17 Aug 2021 11:17:58 -1000 Message-Id: <20210817211803.283639-17-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::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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" Signed-off-by: Richard Henderson --- target/riscv/insn_trans/trans_rva.c.inc | 47 ++++++++++--------------- 1 file changed, 19 insertions(+), 28 deletions(-) -- 2.25.1 Reviewed-by: Bin Meng diff --git a/target/riscv/insn_trans/trans_rva.c.inc b/target/riscv/insn_trans/trans_rva.c.inc index 3cc3c3b073..6ea07d89b0 100644 --- a/target/riscv/insn_trans/trans_rva.c.inc +++ b/target/riscv/insn_trans/trans_rva.c.inc @@ -18,11 +18,10 @@ * this program. If not, see . */ -static inline bool gen_lr(DisasContext *ctx, arg_atomic *a, MemOp mop) +static bool gen_lr(DisasContext *ctx, arg_atomic *a, MemOp mop) { - TCGv src1 = tcg_temp_new(); - /* Put addr in load_res, data in load_val. */ - gen_get_gpr(ctx, src1, a->rs1); + TCGv src1 = get_gpr(ctx, a->rs1, EXT_ZERO); + if (a->rl) { tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); } @@ -30,33 +29,33 @@ static inline bool gen_lr(DisasContext *ctx, arg_atomic *a, MemOp mop) if (a->aq) { tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); } + + /* Put addr in load_res, data in load_val. */ tcg_gen_mov_tl(load_res, src1); gen_set_gpr(ctx, a->rd, load_val); - tcg_temp_free(src1); return true; } -static inline bool gen_sc(DisasContext *ctx, arg_atomic *a, MemOp mop) +static bool gen_sc(DisasContext *ctx, arg_atomic *a, MemOp mop) { - TCGv src1 = tcg_temp_new(); - TCGv src2 = tcg_temp_new(); - TCGv dat = tcg_temp_new(); + TCGv dest, src1, src2; TCGLabel *l1 = gen_new_label(); TCGLabel *l2 = gen_new_label(); - gen_get_gpr(ctx, src1, a->rs1); + src1 = get_gpr(ctx, a->rs1, EXT_ZERO); tcg_gen_brcond_tl(TCG_COND_NE, load_res, src1, l1); - gen_get_gpr(ctx, src2, a->rs2); /* * Note that the TCG atomic primitives are SC, * so we can ignore AQ/RL along this path. */ - tcg_gen_atomic_cmpxchg_tl(src1, load_res, load_val, src2, + dest = dest_gpr(ctx, a->rd); + src2 = get_gpr(ctx, a->rs2, EXT_NONE); + tcg_gen_atomic_cmpxchg_tl(dest, load_res, load_val, src2, ctx->mem_idx, mop); - tcg_gen_setcond_tl(TCG_COND_NE, dat, src1, load_val); - gen_set_gpr(ctx, a->rd, dat); + tcg_gen_setcond_tl(TCG_COND_NE, dest, dest, load_val); + gen_set_gpr(ctx, a->rd, dest); tcg_gen_br(l2); gen_set_label(l1); @@ -65,8 +64,7 @@ static inline bool gen_sc(DisasContext *ctx, arg_atomic *a, MemOp mop) * provide the memory barrier implied by AQ/RL. */ tcg_gen_mb(TCG_MO_ALL + a->aq * TCG_BAR_LDAQ + a->rl * TCG_BAR_STRL); - tcg_gen_movi_tl(dat, 1); - gen_set_gpr(ctx, a->rd, dat); + gen_set_gpr(ctx, a->rd, tcg_constant_tl(1)); gen_set_label(l2); /* @@ -75,9 +73,6 @@ static inline bool gen_sc(DisasContext *ctx, arg_atomic *a, MemOp mop) */ tcg_gen_movi_tl(load_res, -1); - tcg_temp_free(dat); - tcg_temp_free(src1); - tcg_temp_free(src2); return true; } @@ -85,17 +80,13 @@ static bool gen_amo(DisasContext *ctx, arg_atomic *a, void(*func)(TCGv, TCGv, TCGv, TCGArg, MemOp), MemOp mop) { - TCGv src1 = tcg_temp_new(); - TCGv src2 = tcg_temp_new(); + TCGv dest = dest_gpr(ctx, a->rd); + TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE); + TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE); - gen_get_gpr(ctx, src1, a->rs1); - gen_get_gpr(ctx, src2, a->rs2); + func(dest, src1, src2, ctx->mem_idx, mop); - (*func)(src2, src1, src2, ctx->mem_idx, mop); - - gen_set_gpr(ctx, a->rd, src2); - tcg_temp_free(src1); - tcg_temp_free(src2); + gen_set_gpr(ctx, a->rd, dest); return true; }