From patchwork Mon Aug 23 19:55:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 501566 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp2499190jab; Mon, 23 Aug 2021 13:08:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAyl1gujkzF0UcLOuZR3HMm8rsFhGsGsb9NIsN/LsAFsW/QtbaVr3TV2XjhsIge7+E1WS/ X-Received: by 2002:a05:6602:25da:: with SMTP id d26mr27837320iop.106.1629749306916; Mon, 23 Aug 2021 13:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629749306; cv=none; d=google.com; s=arc-20160816; b=yf3WLg4tV8ODntcWL5us+dGd8XRIKwhMhVf56s8j6+lwKw8qdr3Zd9C16hHm7GXqbX +J2Q1medTLdZd7QM3f7P34qtDP9Zk118DywlmMVcydhXi0Dvg/pnHIspLFWz02hEd8H7 rz3REJH+QERTi+YCQ4c3XhHWJEEY73NMd5K0SdmZGBNL8At9W9uIUPd+MszQJIZvCWFl NoMae+Ifo5UIQOJjofM5KhZ9LwxR20VHd66uF/ZRmuyH8cuTOJVTHXib6OaeY5kZ/Cav 9Ju3zCCTxQpSjYEztUFH7HpNAfXsgCeysZpQy66wu4FGR82Wi9PPIphtNnpTwI3WCN/X 42Jw== 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=urxvHl5SZl0AUXgAfuDktqh3BI/95sm7pa73udvu/YjrM2hzBOfUytT31x8nwhNfXl 4S4BySxTMuFPhsGUvgH+S5JyHYW8hn+Ubt3Gnfvv1I1tfcieb+fdT0U3abd1p6NT5jQw ZQldeYNqTjKQtd+KaR7THdHdIO/DNBlVtOJb1NxqkxtjYcTvz26ZCuZemUcB5ZmA7qwS pDevs/BY5NdW8Pjp7wGYbgjBIBDqF51XaP9NsNDS975oSZCn4w29D63fgqENaUOSSK6c TQshQ1gOox8Enj07F4jZOl0hJoBIpevABA2Mn0QfvoscbaWhiTo5Ht1p7hhQ5JJ6N9D7 LhdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CDMwc9va; 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 f18si733252jat.62.2021.08.23.13.08.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Aug 2021 13:08:26 -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=CDMwc9va; 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]:59826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIGF8-0002P3-6w for patch@linaro.org; Mon, 23 Aug 2021 16:08:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIG32-0006hl-Gc for qemu-devel@nongnu.org; Mon, 23 Aug 2021 15:55:56 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:43968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIG2s-0003Co-4s for qemu-devel@nongnu.org; Mon, 23 Aug 2021 15:55:56 -0400 Received: by mail-pl1-x632.google.com with SMTP id x15so1387020plg.10 for ; Mon, 23 Aug 2021 12:55:45 -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=CDMwc9va8r7E361Wjo6ztVn78gQZ4hKp5l1C8rdBi8exNrsCbSS/pWGGVb+swAO/b5 DNJYQm7wpJjC6su1QVePTZyrfuTDfXoFIh0bgWBIACfze7q0yNIxI8/QOSdm1y4yKbvY oCWXZZeFVrEJYerH/XMF3K2WqCQau2ViVZZAs0fQ5TouG2s9AOBOElZu1Cr7kXRWESJb DZ/Ebg5LViTWa/BHvcD2yyP7dl9CVfPiS9tdOivF/l7dWJ9BR8fFjtpe+wiL4R5/6HO3 oX4Razsfj/DfKBrDuy7HCHfiCXvY6frzH/ZvitiFXpbSNFYqIzCroqtILphltoVoIN6T UrbQ== 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=PCMg6IGvje6qP8obkh7+r6zbjGDH0gqrOzWxgaF+xyJwc+jKkQXMZFtef8QqtTSVge h+NwZCBr4R7JSbHvw6ZPlK6fdy4Zdce/dyVTKuBDoMASc5bELnvtqM7b9UH+zcog3dLV OvPvnt0BOzatTfFELLQla7LeDcix4vmXKN6mLgG+dFzrsmsC83cqUsFudZEuXuim9y5w pAy4/rmpo2fLp4V4HWqzS7JpcyzvulTwK5DnDTYeZeqWfKfdw5dWJE4vUeN9WKpgvvqH hHl+iLVLzW0xAgTkBIXycZB6YDO/LuAf3YQW4jiAZVvjGqnD0IWzHwnlFjeRa4h/S1uy lIzg== X-Gm-Message-State: AOAM533+GEhaCCxMqc+jXg4K8pob3qAAmI2YIFe4A2v2PGGr/3zVD6O/ 3+ekVs/xUszTdTPwt1fLrigGuw8dDRdMUg== X-Received: by 2002:a17:90a:a389:: with SMTP id x9mr217450pjp.167.1629748544382; Mon, 23 Aug 2021 12:55:44 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id v15sm16685078pff.105.2021.08.23.12.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 12:55:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 19/24] target/riscv: Use {get,dest}_gpr for RVA Date: Mon, 23 Aug 2021 12:55:24 -0700 Message-Id: <20210823195529.560295-20-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, 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 Reviewed-by: Alistair Francis 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; }