From patchwork Wed Feb 13 15:53:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10810255 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 ACBCD922 for ; Wed, 13 Feb 2019 16:02:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AA482DC24 for ; Wed, 13 Feb 2019 16:02:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87B3C2DC98; Wed, 13 Feb 2019 16:02:39 +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 0CEFB2DC93 for ; Wed, 13 Feb 2019 16:02:38 +0000 (UTC) Received: from localhost ([127.0.0.1]:59181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtwze-0007SI-A3 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Feb 2019 11:02:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtwtL-0001ut-CM for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:56:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtwtJ-0002rk-Su for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:56:07 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:37409) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtwtH-0000rK-CF for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:56:05 -0500 Received: by mail-pf1-x441.google.com with SMTP id s22so1326992pfh.4 for ; Wed, 13 Feb 2019 07:54:39 -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=Y7QlvuNBEJtOWvnrX8nX22Tnl1f2RmFv/qKHDggdEv4=; b=AtLEoa1ampzTddVV0v8tbSrQ5BWZiSMi8GhEgYAE57qEHZ+qXhO/SaU/NpQGxeNXCO a5RNNBt5+ZUMNoinxQq7fbEInOKoJjlbagw6GXBVrm0AFRLzCs+ACIINijTCjlDpQSD1 3rJZJqFYG3+pQGbtZ+4ePiKOhRoLGJhyn/kjoasSazPjcbApgSj5QH2salS4mCG1ISFO Bv5dewE1dW8bAiwTLpvZ15RGVpA1F+RutR2mBMtxmvGoH+QmLgMq28jv3AznUMssRdPH kJXtXFgABdbNykw+r9U0xAJ3/C5uVJpO6b0nLVzFOia6kIBFdr13XlG8EtPr8sFhBXqi JLRQ== 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=Y7QlvuNBEJtOWvnrX8nX22Tnl1f2RmFv/qKHDggdEv4=; b=DUb2iIL05g5iPdvmDQr5VHWq+vqK5mP3w0K3U0wPvVZjDsdtHOlpU9FfCtYyvw/H42 c8KCcDdpKAb7Voo9sDmG1+5L4rLMDWEy/4Tzdm7zjwAgyapddSK8rw9m95TCB0pqtwvL 2HanOJaH05ZZO58DC38nwX0qQiy7OhHwNxMOx8+hCz8InPPhNdCtkpleixu5sGRgIgZ9 WXg3RYphbBmAtfU4M4bpNtwxAJqx08K4cjqChyiN2vpNPwa48aHcvCXr5UOSA6Xm3+PP RFkKWEHQaom64ghiUDJ3LIzRQtSV3UZqR7wpkBnXruFFVkBgNPlpSISdsno9PrD8Jelh S0MQ== X-Gm-Message-State: AHQUAubQFetSKEyq7rLeReitzqm/edxIcqgWDjhREsGN8nlV3JiJqkk0 0+M+a9ubHpHiZjPnIPJV/tjAGojJc0o= X-Google-Smtp-Source: AHgI3IZ1SbKh9ySN8ksd9Jnqd8CLx9V9rYM4gboLVFcm2WWHZ8MHsdezfIqG+Vawvn1y0TeXOBmc+A== X-Received: by 2002:a62:b2c3:: with SMTP id z64mr1106239pfl.149.1550073278263; Wed, 13 Feb 2019 07:54:38 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id w185sm25443328pfb.135.2019.02.13.07.54.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 07:54:37 -0800 (PST) Date: Wed, 13 Feb 2019 07:53:40 -0800 Message-Id: <20190213155414.22285-2-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::441 Subject: [Qemu-devel] [PATCH v7 01/35] target/riscv: Move CPURISCVState pointer to DisasContext 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 , 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 CPURISCVState is rarely used, so there is no need to pass it to every translate function. This paves the way for decodetree which only passes DisasContext to translate functions. Reviewed-by: Palmer Dabbelt Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Signed-off-by: Bastian Koppelmann --- target/riscv/translate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index b7176cbf98e1..9e06eb8c2de5 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -54,6 +54,7 @@ typedef struct DisasContext { to any system register, which includes CSR_FRM, so we do not have to reset this known value. */ int frm; + CPURISCVState *env; } DisasContext; /* convert riscv funct3 to qemu memop for load/store */ @@ -2003,7 +2004,7 @@ static void decode_opc(DisasContext *ctx) { /* check for compressed insn */ if (extract32(ctx->opcode, 0, 2) != 3) { - if (!has_ext(ctx, RVC)) { + if (!riscv_has_ext(ctx->env, RVC)) { gen_exception_illegal(ctx); } else { ctx->pc_succ_insn = ctx->base.pc_next + 2; @@ -2058,9 +2059,9 @@ static bool riscv_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *ctx = container_of(dcbase, DisasContext, base); - CPURISCVState *env = cpu->env_ptr; + ctx->env = cpu->env_ptr; - ctx->opcode = cpu_ldl_code(env, ctx->base.pc_next); + ctx->opcode = cpu_ldl_code(ctx->env, ctx->base.pc_next); decode_opc(ctx); ctx->base.pc_next = ctx->pc_succ_insn;