From patchwork Fri Jan 26 22:04:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 766403 Delivered-To: patch@linaro.org Received: by 2002:adf:a314:0:b0:337:62d3:c6d5 with SMTP id c20csp455005wrb; Fri, 26 Jan 2024 14:12:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVvJ//LXDHLeZrV7BJblmkbt02dKsch1aMffOR7rbGEptrlNECt5qQTprtNTFLfOcVf3f7 X-Received: by 2002:a05:6808:1929:b0:3bd:d7d4:2e2c with SMTP id bf41-20020a056808192900b003bdd7d42e2cmr543641oib.35.1706307171457; Fri, 26 Jan 2024 14:12:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706307171; cv=none; d=google.com; s=arc-20160816; b=A7KMPgxygmg83E87L8C+KqA+rF8rRRMUQ4DBOD3WwscHGBEFB/oxp2NuXHcfAkhEgn hdbwVIrN623pjVn7pak6G7eY2AN9d818bGgjr2YseZVHNCQv96tcaiUeW0YOqvJukCcs Cc807E7rUCAmV9zb4XMd0rbezNbVpREet2eiM2wVZn8ApI/bcW/IZHaSPIhEuS93Zz7J bsLKbQHd9rqzm71qeO3wpef0uwhYnWBuN/i6VQ7qGHYKoJeN5F0w+4hUslKhMvSnv1Pe STwOC8iG7bRWzAyhX7YY+v9F0Bfbb8jAY8A+oONjeoeWjW8jRgjvd/pOjaHE20bOfOml GYLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=YtuQrPEiaOdoOF8LUQEAgkD/kFrAu5dyJpYlVEeXrYA=; fh=Tzw7ry3evXwnVWACvzmwEOdsg3J6VzcKR4bd6HttjTI=; b=vyDXUDx+kRx7krH15pXUEKxZlttnwK2c7KVR6l69uFCF4qmg/V/6GmF3VZv3dfj2HY BZEHhRieei2Gt40iFlcvPvlvK0oZo39nDtLDYq74eJ8qvZPnnoz6gIw6ipdF9vw6ePw+ J5VorI0isscrAem7RdmxEH+hK8mvBrjNc1DeCsiFAdjGb5INApgT0xjv5+iV4JNlkBlb pWNR9jplZBfZ9Lzyns1jbtOuJaAslXi9LY3HMZ6NUuPrsmg+kd+I0gsVZ+lw8Of7A026 BO3Ue4x1j2ogYQYuurdZ9WUBUrRzfcTNZS2FVibj2ts0msxY3N8Uaw2CVzPDaEAGXlX3 JPow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IiJX0UpK; 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=pass (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 o5-20020ac87c45000000b0042a8a24b934si392947qtv.229.2024.01.26.14.12.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2024 14:12:51 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=IiJX0UpK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé 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 = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); if ((env->flags & (TB_FLAG_DELAY_SLOT | TB_FLAG_DELAY_SLOT_COND)) && !(cs->tcg_cflags & CF_PCREL) && env->pc != tb->pc) { @@ -144,8 +143,7 @@ out: static void sh7750r_cpu_initfn(Object *obj) { - SuperHCPU *cpu = SUPERH_CPU(obj); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(CPU(obj)); env->id = SH_CPU_SH7750R; env->features = SH_FEATURE_BCR3_AND_BCR4; @@ -162,8 +160,7 @@ static void sh7750r_class_init(ObjectClass *oc, void *data) static void sh7751r_cpu_initfn(Object *obj) { - SuperHCPU *cpu = SUPERH_CPU(obj); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(CPU(obj)); env->id = SH_CPU_SH7751R; env->features = SH_FEATURE_BCR3_AND_BCR4; @@ -180,8 +177,7 @@ static void sh7751r_class_init(ObjectClass *oc, void *data) static void sh7785_cpu_initfn(Object *obj) { - SuperHCPU *cpu = SUPERH_CPU(obj); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(CPU(obj)); env->id = SH_CPU_SH7785; env->features = SH_FEATURE_SH4A; @@ -216,8 +212,7 @@ static void superh_cpu_realizefn(DeviceState *dev, Error **errp) static void superh_cpu_initfn(Object *obj) { - SuperHCPU *cpu = SUPERH_CPU(obj); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(CPU(obj)); env->movcal_backup_tail = &(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 @@ int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); switch (n) { case 0 ... 7: @@ -76,8 +75,7 @@ int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int superh_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); 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) void superh_cpu_do_interrupt(CPUState *cs) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); int do_irq = cs->interrupt_request & CPU_INTERRUPT_HARD; int do_exp, irq_vector = cs->exception_index; @@ -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 = SUPERH_CPU(cs); - CPUSH4State *env = &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, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); int ret; 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) void superh_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - SuperHCPU *cpu = SUPERH_CPU(cs); - CPUSH4State *env = &cpu->env; + CPUSH4State *env = cpu_env(cs); int i; qemu_fprintf(f, "pc=0x%08x sr=0x%08x pr=0x%08x fpscr=0x%08x\n",