From patchwork Wed Feb 13 15:53:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10810307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C671E13A4 for ; Wed, 13 Feb 2019 16:15:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B34402DF68 for ; Wed, 13 Feb 2019 16:15:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7BCE2DF62; Wed, 13 Feb 2019 16:15:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 315AD2DF62 for ; Wed, 13 Feb 2019 16:15:10 +0000 (UTC) Received: from localhost ([127.0.0.1]:59369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtxBl-0007Zc-E7 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Feb 2019 11:15:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtwtU-00024S-5n for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:56:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtwtN-0002zP-2U for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:56:15 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:32969) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtwtM-0001RJ-Lv for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:56:08 -0500 Received: by mail-pl1-x630.google.com with SMTP id y10so1360031plp.0 for ; Wed, 13 Feb 2019 07:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=subject:date:message-id:in-reply-to:references:cc:from:to; bh=8EypunTKjsEtiRMX5hY7rGFR1bKZQLM2m6PHUljo33Q=; b=Qt+f9HDsLVqkoxj1wAD00kYbdevk/qI0PzZe9T5OM1ULf4Ai65mZV3yJXhsYnk3zcr 1Kn6mHO/67mHYKH7Pe7b1UaexugHtI0AiDOi8Ty3DszC4yAj44aqiwFmsFw5priK7p10 Dj3oUPwOrLs1NuFr2XVzmfQwjU7AodkfGCHb+ZgwSo84cr1WVt8bVkMDT2b+pH8g/V5a Lc9zlaG0hDYDhqNExei2hpDHiWzZIBoCNW+t6Uufx3XGSPQ7eIM7S9CL0RBhZoGsN2Bh 5n3Mqrof9gu5TEFfarvsmntxDi2GoLKpUhAOMTuqPhDeP8wB/1+ilpf9S5MJZaD6SBiq 3mGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :cc:from:to; bh=8EypunTKjsEtiRMX5hY7rGFR1bKZQLM2m6PHUljo33Q=; b=DbDDBW3Z54iiMJlxoeHu5TEk8Hh6d6RuBXsijEOwRnNuLavM5EpOd4hTRt3Rj1stdC FZOOIPQDmvnItkrQyGR/bu2ZJb6gYeS9WkRfx+1DYW9/y1J+xo0K4/gAUzWrNWTYKg0l ocmZdu+k+JHpLKIauaiE+L5/9rGS7wNclbZgImLehovK8F1pWaX+ooDaSQ7LRB/B6FIb Ehib/PB/a9jcs42BglNfIxIEU8iCQhDD1JxwBRoehso1tHlh7Whi8/30PsbWP+o31K8i 1Ppp3ntt2ffZ1cXDaKdmz0I4Fj20H+p9jXW+DP4RX334/nRmmmPynOa3bxxUsvrlH1Jd bXTw== X-Gm-Message-State: AHQUAubiPtOWske8T8lE00Us3CkxxHYUMqUn5LRLcgDJdmYbYWVYwExc uoj33V/jbDbWzaUYotNcrKndA+1zMWU= X-Google-Smtp-Source: AHgI3IbVtde79pR+JYl1Rd5oV3USHIjfhHfP0FLCwienMmDt9RFnvXRxy2hUPPJVoI7d+agM3+4VYg== X-Received: by 2002:a17:902:7148:: with SMTP id u8mr1202659plm.110.1550073309197; Wed, 13 Feb 2019 07:55:09 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id j8sm7565293pfe.130.2019.02.13.07.55.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 07:55:08 -0800 (PST) Date: Wed, 13 Feb 2019 07:53:59 -0800 Message-Id: <20190213155414.22285-21-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190213155414.22285-1-palmer@sifive.com> References: <20190213155414.22285-1-palmer@sifive.com> From: Palmer Dabbelt To: qemu-riscv@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::630 Subject: [Qemu-devel] [PATCH v7 20/35] target/riscv: Remove gen_jalr() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bastian Koppelmann , Peer Adelt , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Bastian Koppelmann trans_jalr() is the only caller, so move the code into trans_jalr(). Acked-by: Alistair Francis Reviewed-by: Richard Henderson Signed-off-by: Bastian Koppelmann Signed-off-by: Peer Adelt --- target/riscv/insn_trans/trans_rvi.inc.c | 28 +++++++++++++++++- target/riscv/translate.c | 38 ------------------------- 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvi.inc.c b/target/riscv/insn_trans/trans_rvi.inc.c index 4a23372cb823..39af38081ede 100644 --- a/target/riscv/insn_trans/trans_rvi.inc.c +++ b/target/riscv/insn_trans/trans_rvi.inc.c @@ -42,7 +42,33 @@ static bool trans_jal(DisasContext *ctx, arg_jal *a) static bool trans_jalr(DisasContext *ctx, arg_jalr *a) { - gen_jalr(ctx, OPC_RISC_JALR, a->rd, a->rs1, a->imm); + /* no chaining with JALR */ + TCGLabel *misaligned = NULL; + TCGv t0 = tcg_temp_new(); + + + gen_get_gpr(cpu_pc, a->rs1); + tcg_gen_addi_tl(cpu_pc, cpu_pc, a->imm); + tcg_gen_andi_tl(cpu_pc, cpu_pc, (target_ulong)-2); + + if (!riscv_has_ext(ctx->env, RVC)) { + misaligned = gen_new_label(); + tcg_gen_andi_tl(t0, cpu_pc, 0x2); + tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0x0, misaligned); + } + + if (a->rd != 0) { + tcg_gen_movi_tl(cpu_gpr[a->rd], ctx->pc_succ_insn); + } + tcg_gen_lookup_and_goto_ptr(); + + if (misaligned) { + gen_set_label(misaligned); + gen_exception_inst_addr_mis(ctx); + } + ctx->base.is_jmp = DISAS_NORETURN; + + tcg_temp_free(t0); return true; } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index c9a8fdda8a85..abdcd0631af4 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -532,44 +532,6 @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm) ctx->base.is_jmp = DISAS_NORETURN; } -static void gen_jalr(DisasContext *ctx, uint32_t opc, int rd, int rs1, - target_long imm) -{ - /* no chaining with JALR */ - TCGLabel *misaligned = NULL; - TCGv t0 = tcg_temp_new(); - - switch (opc) { - case OPC_RISC_JALR: - gen_get_gpr(cpu_pc, rs1); - tcg_gen_addi_tl(cpu_pc, cpu_pc, imm); - tcg_gen_andi_tl(cpu_pc, cpu_pc, (target_ulong)-2); - - if (!has_ext(ctx, RVC)) { - misaligned = gen_new_label(); - tcg_gen_andi_tl(t0, cpu_pc, 0x2); - tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0x0, misaligned); - } - - if (rd != 0) { - tcg_gen_movi_tl(cpu_gpr[rd], ctx->pc_succ_insn); - } - tcg_gen_lookup_and_goto_ptr(); - - if (misaligned) { - gen_set_label(misaligned); - gen_exception_inst_addr_mis(ctx); - } - ctx->base.is_jmp = DISAS_NORETURN; - break; - - default: - gen_exception_illegal(ctx); - break; - } - tcg_temp_free(t0); -} - static void gen_branch(DisasContext *ctx, uint32_t opc, int rs1, int rs2, target_long bimm) {