From nobody Tue Nov 26 16:38:24 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=1706307171; cv=none; d=zohomail.com; s=zohoarc; b=V+1vPsYdxjC8aG4W0nm1Z/vrebZkw1Y7GNYO+/mVOdC1VhdT8xOc73NRaP2nKzRYVMYvYuZm0W+SnYvXHDWHBBFdpQH1zbjvhvDuBR0tgz9FnVplv003one5elzOBNHZXAcZyiCbzj7eGtiG8i+UAUn2mN+jRdu8iTcoBAdaLO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706307171; 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=YtuQrPEiaOdoOF8LUQEAgkD/kFrAu5dyJpYlVEeXrYA=; b=lL5lbUzRjp+25ykFu/QcAYvyoIRS7DVchpWwt+9JBrG56bR9gsLdQmtG6Ko0NhoD2ps02xPlet3Su4xijCBtJbmvGkTmAlvX7uUCr2U9WLpWsJgg+3cXODlKHCDmMnWEbwzYihQ+0/76Lxv5FCxGVp7MghUNcJF0Wkq7Pwq4En8= 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 1706307171684618.896235397571; Fri, 26 Jan 2024 14:12:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTULX-0004Hm-Iu; Fri, 26 Jan 2024 17:06:47 -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 1rTULM-0002nm-HA for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:06:36 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTULG-0004Yu-RF for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:06:36 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40ed356a6ecso6722905e9.2 for ; Fri, 26 Jan 2024 14:06:16 -0800 (PST) Received: from m1x-phil.lan ([176.176.142.39]) by smtp.gmail.com with ESMTPSA id bu25-20020a056000079900b0033921b2a5d4sm2097084wrb.75.2024.01.26.14.06.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 26 Jan 2024 14:06:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706306775; x=1706911575; 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=YtuQrPEiaOdoOF8LUQEAgkD/kFrAu5dyJpYlVEeXrYA=; b=IiJX0UpKkpMgBf2OA2JAYYuXd0mT/4locTLZ4E9cIe3UkQRclRUAn+ue7Hr8QGkKbf u7nzYXP+dggmiJY3OEsRETL1+dEqaD8OxBg0MYIUw17EoXGYAQFeOOQpqQAYzYLFdILo PhXx2Gp/ULSptV7FUBb8ceT5Q/YCIopnS9JlRjmC9zFPhpMmONjiOI/c+N3vkun7aSQJ lU+VmiwQAS3NRXBd40x+7LQwWLpLLR3+6uLq/m46fKIcJx67Nt7aVUPr8Vxvhc5I13Y5 dCmUmi8Z+liu4voXC6CJrvGKXS89ALLUKgyrq93WoO7RBL+B0FUSIgaRSY3c2Te/Lu2w VNqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706306775; x=1706911575; 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=YtuQrPEiaOdoOF8LUQEAgkD/kFrAu5dyJpYlVEeXrYA=; b=PEaiXFs2zyyZRCt9At1LRGcUL9mehRUuUVc+u3pw/K0pPDP4IXlT+UGtWrAxUWI7LZ lmgnv4v68KqnVPUEAgB6khlcBxZzlW6gXDEtuhJ6Il5nHR0dcyLOoaHZAaYh8aNpg4Jj JJN30ljQb0LbSGHkODTjjisQSiRfmsfkXm/SduZ1eXyZ9WkuqBDbfAfsMJH00QUKrJuj PZt8RSDd2LL16hEi9R8KbR5NAIsWj5x3nJzKw3jUCmjPSIhHYIYVby+ibK1BbbEwOmkZ wRq4HrSonS4WvdcqsFdij3rp0/qrhCbujOusYQoa7St4bawi6eSaV1ZdsyhIQ9e8RIX7 wxNg== X-Gm-Message-State: AOJu0YxqMjQNUAlniwfvvEi0Hw+deY/Ptz+MH8AtrbqLdP7z2Yl8dza4 Hd+tp7qKQxHTIbseG2TW58Tr8pfLZFCQSiZbPIoTXGH2tfAsxPy5wF27xCZjxJrScApaMtnQjlv q X-Google-Smtp-Source: AGHT+IGAJd1+nxpnhxNSxbbDkweDQV7fyyewwmnnG2Uh8Gfd0V5Pa5JSlH8Cjw1RHP8jg3sEePPxpg== X-Received: by 2002:a05:600c:b8a:b0:40e:5947:bcf9 with SMTP id fl10-20020a05600c0b8a00b0040e5947bcf9mr535667wmb.18.1706306774930; Fri, 26 Jan 2024 14:06:14 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Thomas Huth , qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Eduardo Habkost , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Richard Henderson , Vladimir Sementsov-Ogievskiy , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yoshinori Sato Subject: [PATCH v2 20/23] target/sh4: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Fri, 26 Jan 2024 23:04:02 +0100 Message-ID: <20240126220407.95022-21-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240126220407.95022-1-philmd@linaro.org> References: <20240126220407.95022-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::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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: 1706307173396100001 Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/sh4/cpu.c | 15 +++++---------- target/sh4/gdbstub.c | 6 ++---- target/sh4/helper.c | 11 +++-------- target/sh4/translate.c | 3 +-- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 806a0ef875..786c77615e 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -71,8 +71,7 @@ static void superh_restore_state_to_opc(CPUState *cs, static bool superh_io_recompile_replay_branch(CPUState *cs, const TranslationBlock *tb) { - SuperHCPU *cpu =3D SUPERH_CPU(cs); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(cs); =20 if ((env->flags & (TB_FLAG_DELAY_SLOT | TB_FLAG_DELAY_SLOT_COND)) && !(cs->tcg_cflags & CF_PCREL) && env->pc !=3D tb->pc) { @@ -144,8 +143,7 @@ out: =20 static void sh7750r_cpu_initfn(Object *obj) { - SuperHCPU *cpu =3D SUPERH_CPU(obj); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(CPU(obj)); =20 env->id =3D SH_CPU_SH7750R; env->features =3D SH_FEATURE_BCR3_AND_BCR4; @@ -162,8 +160,7 @@ static void sh7750r_class_init(ObjectClass *oc, void *d= ata) =20 static void sh7751r_cpu_initfn(Object *obj) { - SuperHCPU *cpu =3D SUPERH_CPU(obj); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(CPU(obj)); =20 env->id =3D SH_CPU_SH7751R; env->features =3D SH_FEATURE_BCR3_AND_BCR4; @@ -180,8 +177,7 @@ static void sh7751r_class_init(ObjectClass *oc, void *d= ata) =20 static void sh7785_cpu_initfn(Object *obj) { - SuperHCPU *cpu =3D SUPERH_CPU(obj); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(CPU(obj)); =20 env->id =3D SH_CPU_SH7785; env->features =3D SH_FEATURE_SH4A; @@ -216,8 +212,7 @@ static void superh_cpu_realizefn(DeviceState *dev, Erro= r **errp) =20 static void superh_cpu_initfn(Object *obj) { - SuperHCPU *cpu =3D SUPERH_CPU(obj); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(CPU(obj)); =20 env->movcal_backup_tail =3D &(env->movcal_backup); } diff --git a/target/sh4/gdbstub.c b/target/sh4/gdbstub.c index d8e199fc06..75926d4e04 100644 --- a/target/sh4/gdbstub.c +++ b/target/sh4/gdbstub.c @@ -26,8 +26,7 @@ =20 int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - SuperHCPU *cpu =3D SUPERH_CPU(cs); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(cs); =20 switch (n) { case 0 ... 7: @@ -76,8 +75,7 @@ int superh_cpu_gdb_read_register(CPUState *cs, GByteArray= *mem_buf, int n) =20 int superh_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - SuperHCPU *cpu =3D SUPERH_CPU(cs); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(cs); =20 switch (n) { case 0 ... 7: diff --git a/target/sh4/helper.c b/target/sh4/helper.c index 5a6f653c12..28b81a5c54 100644 --- a/target/sh4/helper.c +++ b/target/sh4/helper.c @@ -55,8 +55,7 @@ int cpu_sh4_is_cached(CPUSH4State *env, target_ulong addr) =20 void superh_cpu_do_interrupt(CPUState *cs) { - SuperHCPU *cpu =3D SUPERH_CPU(cs); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(cs); int do_irq =3D cs->interrupt_request & CPU_INTERRUPT_HARD; int do_exp, irq_vector =3D cs->exception_index; =20 @@ -782,11 +781,8 @@ int cpu_sh4_is_cached(CPUSH4State * env, target_ulong = addr) bool superh_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { if (interrupt_request & CPU_INTERRUPT_HARD) { - SuperHCPU *cpu =3D SUPERH_CPU(cs); - CPUSH4State *env =3D &cpu->env; - /* Delay slots are indivisible, ignore interrupts */ - if (env->flags & TB_FLAG_DELAY_SLOT_MASK) { + if (cpu_env(cs)->flags & TB_FLAG_DELAY_SLOT_MASK) { return false; } else { superh_cpu_do_interrupt(cs); @@ -800,8 +796,7 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, i= nt size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - SuperHCPU *cpu =3D SUPERH_CPU(cs); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(cs); int ret; =20 target_ulong physical; diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 81f825f125..4a933adad8 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -159,8 +159,7 @@ void sh4_translate_init(void) =20 void superh_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - SuperHCPU *cpu =3D SUPERH_CPU(cs); - CPUSH4State *env =3D &cpu->env; + CPUSH4State *env =3D cpu_env(cs); int i; =20 qemu_fprintf(f, "pc=3D0x%08x sr=3D0x%08x pr=3D0x%08x fpscr=3D0x%08x\n", --=20 2.41.0