From patchwork Mon Aug 23 19:55:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 501561 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp2496227jab; Mon, 23 Aug 2021 13:04:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMmW7n4tcNl7zmlk/mHh1qHtgz9cxgbd0tLlOczSok1stAuL/171A8h/tDuXvs/tG0BoxA X-Received: by 2002:a05:6402:4303:: with SMTP id m3mr39540576edc.379.1629749065897; Mon, 23 Aug 2021 13:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629749065; cv=none; d=google.com; s=arc-20160816; b=edQzUiGNHLIwZNML8NEwx3hKKujfs5i2Nbh8pHaBa6/df/qM7JTkcY/MQcuEMvZFU3 mt/TxCtIrYcm/jFQsy3oZoZIKm0qzAuEiGfW6jBV4WcdUg0Ni2pf3feHwF99jseM6mlk p6KEF4Xqn/i6BEnwDrxNWx5J/qZPoICBv2GgA0vJkQCipuXaR+iEX+f+/BjkvX/TMhb6 im1nZME1vQfPxXWwRpQTiL+IGz+VZ4zodNS8Wb1WyRGEPGCgu1BuFAe/Zgrj0MP5GWVD iU+Ewbo0FxeB0OyzWCItNUoTtqsFKpmVt858a5pVNh83aSoBZ2nEDKAGX9/oWHASvrm3 eh6w== 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=vJ/pmJnEHhfxg/ptEpqhuR5Wn/nbZbRjoP5x1AyfD8g=; b=Cc+OiwATNkyJOnD+l2hpq/qgqRobrPMLCuCYd/hP0pyeG8qXVT8Upxu3Toe42fmBEq v21s1JFTorP+MBn+2rgFmo//+Wu9Eij9PnXQA9sLLnOg1iDNfbqs3VdDDXboSb+wmH3u AQAaVAQXJ17h9nqFHUH4K3bP/Lbd6LsnFl5x/X6mzHJgxLj0/DcQGBi/ZcAWF6ORoIBv Y9x4k3QmMYM5aBW+faZJOO+75DqJej06kZI50YgI2JaDYTh8hCvrfyxF7noTKDwPedme JoXYpwRGVFMPslUc43Fdn+kPRfrt0kpEU7tj6293FTsAW0+sEbmBx2L1JiPLPMEuGTT5 6wNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kkkATWy9; 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 g16si3631865edb.129.2021.08.23.13.04.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Aug 2021 13:04:25 -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=kkkATWy9; 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]:42926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIGBE-00082C-Ni for patch@linaro.org; Mon, 23 Aug 2021 16:04:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIG2y-0006Sr-FY for qemu-devel@nongnu.org; Mon, 23 Aug 2021 15:55:52 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:55844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIG2o-00039h-R6 for qemu-devel@nongnu.org; Mon, 23 Aug 2021 15:55:52 -0400 Received: by mail-pj1-x1029.google.com with SMTP id mq3so12661156pjb.5 for ; Mon, 23 Aug 2021 12:55:42 -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=vJ/pmJnEHhfxg/ptEpqhuR5Wn/nbZbRjoP5x1AyfD8g=; b=kkkATWy9uBhIZ58lDcdCsI+9cR8r1979UkjyLUSdvj8Vh7Unx0uV7l9JQY9+QmPCIo n6rCHYl8wVii5tU+VPKDVroIMM+vIidF8dyd4SFa+FW140/p9jfeNFq8vxUxUXnOIU5Q 1ynukNSwvkv7ys0RpruUsWSknc3MiQgGgi6VckjM144v3M/jo/vu1SkshNUM9zksMPnL wntxiqxRap5qdssIjicChoYJ9oFomUgtTIOILBXriMrpWqc+qxVLHIp/reK0p0fO2diq UsyUgecMBeQ1RFnUiDx+4RBQktEXxjep2TLgvU2KfuC0jHxSGAZviPTxlTurfNiW19or IoUg== 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=vJ/pmJnEHhfxg/ptEpqhuR5Wn/nbZbRjoP5x1AyfD8g=; b=K3OJEoSSkR7T0H6chky59fY6EbfDzmmmAqn33rZOMhKdNEmAPE/FLzhPZXCs//Qbad W2l3NRKArVjzhILVDhPpbI8PuaPi9DZxNURzb8LGIVrdFXQYT25hbPxHInTCAgJjoYQV kX41d6QG6Wp+AdW+hkxkZJPi7KuwjeHU8U3fZavEBtsO5qOPNUsEvViwXN+FeW0m8k1j k6fwiPFJihlw2AaNoAXzgk+lxF6Vs1IeXoYyr5zfrTjDLwqd1MjrBLW/nIAps65hIugp JYIVYvqwkx3H4yZWPeAd88cpchZmSpFmtwbrpnBom0QuHzbXMq6vObHMiqqc+rFXyCDL TsMA== X-Gm-Message-State: AOAM5312uA2rOhObkVwZjuY7sPzeGvQ/CPOI8p8AUEwOVSMbBzYpDXpz bP0z+Q7x8PMt/ULuAPAQzA+FyKIjooi7ug== X-Received: by 2002:a17:90a:b795:: with SMTP id m21mr227222pjr.143.1629748541297; Mon, 23 Aug 2021 12:55:41 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id v15sm16685078pff.105.2021.08.23.12.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 12:55:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 14/24] target/riscv: Use get_gpr in branches Date: Mon, 23 Aug 2021 12:55:19 -0700 Message-Id: <20210823195529.560295-15-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::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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" Narrow the scope of t0 in trans_jalr. Reviewed-by: Bin Meng Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- target/riscv/insn_trans/trans_rvi.c.inc | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) -- 2.25.1 diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc index 9e8d99be51..a5249e71c2 100644 --- a/target/riscv/insn_trans/trans_rvi.c.inc +++ b/target/riscv/insn_trans/trans_rvi.c.inc @@ -54,24 +54,25 @@ static bool trans_jal(DisasContext *ctx, arg_jal *a) static bool trans_jalr(DisasContext *ctx, arg_jalr *a) { - /* no chaining with JALR */ TCGLabel *misaligned = NULL; - TCGv t0 = tcg_temp_new(); - - gen_get_gpr(ctx, cpu_pc, a->rs1); - tcg_gen_addi_tl(cpu_pc, cpu_pc, a->imm); + tcg_gen_addi_tl(cpu_pc, get_gpr(ctx, a->rs1, EXT_NONE), a->imm); tcg_gen_andi_tl(cpu_pc, cpu_pc, (target_ulong)-2); if (!has_ext(ctx, RVC)) { + TCGv t0 = tcg_temp_new(); + misaligned = gen_new_label(); tcg_gen_andi_tl(t0, cpu_pc, 0x2); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0x0, misaligned); + tcg_temp_free(t0); } if (a->rd != 0) { tcg_gen_movi_tl(cpu_gpr[a->rd], ctx->pc_succ_insn); } + + /* No chaining with JALR. */ lookup_and_goto_ptr(ctx); if (misaligned) { @@ -80,21 +81,18 @@ static bool trans_jalr(DisasContext *ctx, arg_jalr *a) } ctx->base.is_jmp = DISAS_NORETURN; - tcg_temp_free(t0); return true; } static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond) { TCGLabel *l = gen_new_label(); - TCGv source1, source2; - source1 = tcg_temp_new(); - source2 = tcg_temp_new(); - gen_get_gpr(ctx, source1, a->rs1); - gen_get_gpr(ctx, source2, a->rs2); + TCGv src1 = get_gpr(ctx, a->rs1, EXT_SIGN); + TCGv src2 = get_gpr(ctx, a->rs2, EXT_SIGN); - tcg_gen_brcond_tl(cond, source1, source2, l); + tcg_gen_brcond_tl(cond, src1, src2, l); gen_goto_tb(ctx, 1, ctx->pc_succ_insn); + gen_set_label(l); /* branch taken */ if (!has_ext(ctx, RVC) && ((ctx->base.pc_next + a->imm) & 0x3)) { @@ -105,9 +103,6 @@ static bool gen_branch(DisasContext *ctx, arg_b *a, TCGCond cond) } ctx->base.is_jmp = DISAS_NORETURN; - tcg_temp_free(source1); - tcg_temp_free(source2); - return true; }