From patchwork Thu Aug 19 09:04:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 499723 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp334221jab; Thu, 19 Aug 2021 02:16:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEpYYLqhphxhvJGy9IFpO/h9axmwpB9Pwq+ekx2Os7g9UZ6W70GmuFXxZuj7Fv8lTxoXmw X-Received: by 2002:a25:b845:: with SMTP id b5mr16950317ybm.343.1629364577271; Thu, 19 Aug 2021 02:16:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629364577; cv=none; d=google.com; s=arc-20160816; b=wzaX6UlxfAh7eMUHaLQM8ulJH7bpFp6Tlk4TovoF00JHaRIdcng9+aYsXCS3KhbxtJ 1YKQJKbfwAMhuw6Pfh84WlNKZ49BxzPaubWGPXHeTVPCCXl9Zxs8hQLKnX1/M4s9w8Ut UaHTew+ASzuzJJ9LUg6khYT7SasqctYhcFrs/y80VwB+VPw5inf2oQ7z0xR3Lf5WsYK1 jlD8K/qDwC5JKzmCq6k5e0WD/zIJKWyyjFv4PJkojvSZE0E0mvIU5yPHg3P+IfvGg8tI 5/+03SF+jr3Kb2yhbDtIPPHg9C4ZxqKFsN5egiPleGmBp1ttdPMyYScKhzB1jrR51AJB syEg== 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=qlhkq1KnWytqWQYMYVE1HHAXhG14CZ9/5+/6OOdC+lU=; b=0fMwWxaW72k7dYZcFsyeodJ/P5ryJYuleTRlvI6Wwh/FNB2IkWz8seGzkasP7n0VFX MCjs3W0gmxy6PkePTHdDfIMFaQobtezjI2PRQj7hEdOQLJvShkWDdCGtQmrovmnMDvKM w0YES0u+0eMrG0vToCRFSwOLK6hEjTi3XetyI3pMSsJ4LGmGj+yGrMwOpZ1pMtVupmZh XCLV8A9GxwRfZY7Wcqydyj31SQ2gjqozWP+GXzn6Na83u9JYcty+g7SUMiEcDjHM8alg x1WYzt8pSzSx6zAmDDJ7yLor2gy+q9d/wCSXBVtnA/5yK5XDAZ2aSnP0LeBq0qE4hbTF PIzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g4BqTObA; 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 m4si1940808yba.475.2021.08.19.02.16.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Aug 2021 02:16:17 -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=g4BqTObA; 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]:58654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGe9o-00064I-Kc for patch@linaro.org; Thu, 19 Aug 2021 05:16:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGdzS-0006hB-Fz for qemu-devel@nongnu.org; Thu, 19 Aug 2021 05:05:35 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:55959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGdzQ-0000Ll-Jy for qemu-devel@nongnu.org; Thu, 19 Aug 2021 05:05:34 -0400 Received: by mail-pj1-x102a.google.com with SMTP id mq3so4462573pjb.5 for ; Thu, 19 Aug 2021 02:05: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=qlhkq1KnWytqWQYMYVE1HHAXhG14CZ9/5+/6OOdC+lU=; b=g4BqTObA5H3rUDexejHqjXzJ/3HCN6bF+sKbeOSPR9rbIMDkRvgFjnD07oSzmn1VK/ ppNXwz5Z9bOzqcLcOz2TIDDTGiI+e6ZHFwkmEy2kcIErAvmQ5eGrMPODnWbFXdoWeaDM qcxQonNNQr/UNMwHQYMn+K+aSJfW7TaaAWDVZrKBsjggR8keS3VN218/wel6mdRIXXGJ 3UPtnYfP01dAV+ugSVN/EMYJ+ISObmwpBF92ZsERYwz0JumbK4LT4V05TuxsJ08Hr2Ng 3mRVzrOp46+1ILSF9VmZT6tU2fGgoegS7rCJcj3zypufrlLfLOvPn9tWqxExvPNeXNVe O95g== 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=qlhkq1KnWytqWQYMYVE1HHAXhG14CZ9/5+/6OOdC+lU=; b=WtRd6/exUK/h9a7929CwxIjVasR+kvTG+Jh9U7FYShMwcvxIzXGbj+QlaVnyie87Uc 3YmHQn/85GXLTpTyjR7ghFB1miqAHJGA5Mn9AlsOsdo8ZGuwvOqw3KvX8CBOH/2NJDSZ sG3ukROaYDnioUJNpo4ia6xMCXshDbh2Xl2PKlgq22Jm+3l2PwyBRoNjJpqqfCku5Fvm 3fdoRxg4eyQJqozpWdQ1fyZfSY4rOFjSVg1OI2qeMPVCh07Lpd7bXjri8lB4F8eR8SrY zN3GI7Dj1b4/SG+Cw77q5egOHpxFBgX0cPySb5bpdafCjWgTzTprHVRHLXQtUEAHV1Xm hTOQ== X-Gm-Message-State: AOAM532lT0e5hC+YFXKniuJJD4yWWDtAm3sV2Nh+M84xxMY/egnQ40uA BdkgzA9YOu+a1QYOVo4kWOTC/lMjUnHlFA== X-Received: by 2002:a17:90a:5d12:: with SMTP id s18mr11476677pji.35.1629363931226; Thu, 19 Aug 2021 02:05:31 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id j13sm2944707pgp.29.2021.08.19.02.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 02:05:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/21] target/riscv: Use {get,dest}_gpr for RVA Date: Wed, 18 Aug 2021 23:04:57 -1000 Message-Id: <20210819090502.428068-17-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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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, Bin Meng Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Bin Meng Signed-off-by: Richard Henderson --- target/riscv/insn_trans/trans_rva.c.inc | 47 ++++++++++--------------- 1 file changed, 19 insertions(+), 28 deletions(-) -- 2.25.1 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; }