From nobody Tue Nov 26 16:31:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706547399; cv=none; d=zohomail.com; s=zohoarc; b=gAI1gG641qnwYvwXfZc0QIXBvkBH4Wp+sA6GfuvaK+VmuiEmrMwAf8mOeJI0TLNP0BkEngVj2lgk9DwRcp3fYRTh9lPVldLDcCY23AeJ2kNJSC0QJB7uklSYxcKYqcSiaDAd8kp9WW8Y8vipLsBtlDQOGrja0oWDosStgSA3Pds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706547399; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a+WHgRt8aoFwU9PH4yyhsDxrOBo9TuwHJWddMcT5sv4=; b=LAzbrGvn2P76ms7KXQbD/s2U+suBdzsjzP8kLyqoTOOM32XqwwwQY1Oq3+qxFbztRPaLYMwxbKb9XbFXLCBnP40pTNlBDUCpC26mhHJfi0ff23n2svVuSgLLDluU9NwehzGFw3tBGzcdMJ4UmKuMW45Bla54sytOoGZs/jhsRoA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706547399268880.0210234230066; Mon, 29 Jan 2024 08:56:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUUoL-0005gX-R7; Mon, 29 Jan 2024 11:48:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUUn5-00009p-3q for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:47:28 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUUn1-0004Ay-2g for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:47:22 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40e5afc18f5so34956315e9.3 for ; Mon, 29 Jan 2024 08:47:17 -0800 (PST) Received: from m1x-phil.lan ([176.187.219.39]) by smtp.gmail.com with ESMTPSA id l29-20020a05600c1d1d00b0040ef8aa4822sm2704220wms.38.2024.01.29.08.47.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Jan 2024 08:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706546836; x=1707151636; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a+WHgRt8aoFwU9PH4yyhsDxrOBo9TuwHJWddMcT5sv4=; b=PSiux/CnR2ucLc4rXWhKj7NH0VoLrYvuHpWajN4yWMJWzM0/IKYr2psYdM7V+1+5K8 lF4GQzoSeXMJSLcALNb73RgtKH4BpD2DTmf7bcSaLSWjfUv+gPiPCaToqfHi+TRzPabb TrA8ZnObYxiG7L/GGW6Ux4rWg8h/4NHj/3f7W7R7IDuYSOZpTwN/SndwnHDuHFwPkTFe mGS8/LxWdsa7NzejwU2ZZYtZ4xz2znITLZIic7+TvJDt5VQA3QrGeZzwkI26DO8yrpjm XkZsl+s47tX8AoVhYQyCkmccZxkqVkYwTs9/SFaI+pMaJD21iGJChpsTX+sp5Kw8DXCG 7luA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706546836; x=1707151636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a+WHgRt8aoFwU9PH4yyhsDxrOBo9TuwHJWddMcT5sv4=; b=Dc5eSotOxYpPCkcVRjGHvilcxbfP39WEx4LILieYLsXi7AmXFnSLgtn4ib3ku9BV4u Lm7Iy6Ob0fqiULX7ZHpS3iFNu7xab4wDduJkQZyt/xf1zDK/1+Td+/DYYkFf0uQ11mqG O/HpnDVI5h5ijKodn07FFgZTuqmhjt+n7vlgM0E8YELJkkdm77ff2T0io9jPhmRBLgso Ue5pUEdr4mKz9Px/9lLLxu8LeBWvFWdd2Bjokrrte4ufJ7TEhsE3w19Nm4zfUn1x1hkU cMVTEYPUaomN7+tUjr8N62pdGLdlYZMnverJdkIW66CLZ9NNTTVRXKPkGwNdI6W0NbOn nHKA== X-Gm-Message-State: AOJu0Yz4t6+hE0zirrzeDOtOVOJKdn/SkM6Mw3LltlNX+0jVM6rqMtKM Dk+9GQyvJEy+IFhEKWrrGTe6t311eUmIFxr2x8HE/WXP4QYEvi+t57qpfsr8Fl9CU2UZreTYnp2 a X-Google-Smtp-Source: AGHT+IGYhnGe776oZg8Nf+XW6qyKWUfG5CSd+AahADH4rgW9WuZbEKC9nCTJSkL02Ck+OeTkF8tuTg== X-Received: by 2002:a05:600c:4689:b0:40d:5575:a197 with SMTP id p9-20020a05600c468900b0040d5575a197mr5396356wmo.12.1706546836062; Mon, 29 Jan 2024 08:47:16 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Paolo Bonzini , kvm@vger.kernel.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Chris Wulff , Marek Vasut Subject: [PATCH v3 19/29] target/nios2: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Mon, 29 Jan 2024 17:45:01 +0100 Message-ID: <20240129164514.73104-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240129164514.73104-1-philmd@linaro.org> References: <20240129164514.73104-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706547400277100003 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/nios2/cpu.c | 15 +++------------ target/nios2/helper.c | 3 +-- target/nios2/nios2-semi.c | 6 ++---- target/nios2/translate.c | 3 +-- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 09b122e24d..b5b3773fb8 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -28,28 +28,19 @@ =20 static void nios2_cpu_set_pc(CPUState *cs, vaddr value) { - Nios2CPU *cpu =3D NIOS2_CPU(cs); - CPUNios2State *env =3D &cpu->env; - - env->pc =3D value; + cpu_env(cs)->pc =3D value; } =20 static vaddr nios2_cpu_get_pc(CPUState *cs) { - Nios2CPU *cpu =3D NIOS2_CPU(cs); - CPUNios2State *env =3D &cpu->env; - - return env->pc; + return cpu_env(cs)->pc; } =20 static void nios2_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - Nios2CPU *cpu =3D NIOS2_CPU(cs); - CPUNios2State *env =3D &cpu->env; - - env->pc =3D data[0]; + cpu_env(cs)->pc =3D data[0]; } =20 static bool nios2_cpu_has_work(CPUState *cs) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index bb3b09e5a7..ac57121afc 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -287,8 +287,7 @@ void nios2_cpu_do_unaligned_access(CPUState *cs, vaddr = addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - Nios2CPU *cpu =3D NIOS2_CPU(cs); - CPUNios2State *env =3D &cpu->env; + CPUNios2State *env =3D cpu_env(cs); =20 env->ctrl[CR_BADADDR] =3D addr; cs->exception_index =3D EXCP_UNALIGN; diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index 0b84fcb6b6..420702e293 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -75,8 +75,7 @@ static int host_to_gdb_errno(int err) =20 static void nios2_semi_u32_cb(CPUState *cs, uint64_t ret, int err) { - Nios2CPU *cpu =3D NIOS2_CPU(cs); - CPUNios2State *env =3D &cpu->env; + CPUNios2State *env =3D cpu_env(cs); target_ulong args =3D env->regs[R_ARG1]; =20 if (put_user_u32(ret, args) || @@ -93,8 +92,7 @@ static void nios2_semi_u32_cb(CPUState *cs, uint64_t ret,= int err) =20 static void nios2_semi_u64_cb(CPUState *cs, uint64_t ret, int err) { - Nios2CPU *cpu =3D NIOS2_CPU(cs); - CPUNios2State *env =3D &cpu->env; + CPUNios2State *env =3D cpu_env(cs); target_ulong args =3D env->regs[R_ARG1]; =20 if (put_user_u32(ret >> 32, args) || diff --git a/target/nios2/translate.c b/target/nios2/translate.c index e806623594..30beb303f9 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -970,7 +970,6 @@ static void nios2_tr_insn_start(DisasContextBase *dcbas= e, CPUState *cs) static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc =3D container_of(dcbase, DisasContext, base); - CPUNios2State *env =3D cpu_env(cs); const Nios2Instruction *instr; uint32_t code, pc; uint8_t op; @@ -980,7 +979,7 @@ static void nios2_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cs) dc->base.pc_next =3D pc + 4; =20 /* Decode an instruction */ - code =3D cpu_ldl_code(env, pc); + code =3D cpu_ldl_code(cpu_env(cs), pc); op =3D get_opcode(code); =20 if (unlikely(op >=3D ARRAY_SIZE(i_type_instructions))) { --=20 2.41.0