From patchwork Tue Mar 12 12:43:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 779726 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2003778wrt; Tue, 12 Mar 2024 05:58:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW2Ecbl97f8nk0Oc/0XdpAun31PbeVv0lKb6tQSSF1rRU6XqNq3nOsrc859DjTKNox28QJiC3fG83k6bkSPLtYf X-Google-Smtp-Source: AGHT+IG8g/9PgjlJwvQ8Ne5+qQFyyF0QEkuw2iade+3SQZt6a4qc1c1JfFaEs8Np5cyakbpmUMUK X-Received: by 2002:a05:622a:1212:b0:42e:fa57:e07e with SMTP id y18-20020a05622a121200b0042efa57e07emr199035qtx.9.1710248319458; Tue, 12 Mar 2024 05:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710248319; cv=none; d=google.com; s=arc-20160816; b=kC0evX7wqYWd6LFnRLmguF19K55xYQ+i05hfja6yoWl4flFBv1OmaYxHKI6mxhA052 ie6ZoFZrtS+H/BQdMuUhCiobz+sO3D5kLWkFX9VtG6ptuq/MfMEEHT9R0NMlWNQqCQ13 FnCkDBzriq5NottKsChdVEOTeiGtF07k1BHfmJJNaMK8W2MphXyyy70ZiUoiIeWDMWNs qJzfHKDYrGTFaXKOYvlS0laVwCiIt/jIi/b7PkYLi4UHrlvM5+jakStl1z//y0+7H15j BLzwyiBOxn4W6YZzj764gU2Dl9/XMyTSNorAUIEVnraKgtB/IZ0LhJDPrAjGPWV9f1dS pSMw== 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=V47akZkB3MNNJPOVhp+e0c7sV+XYzBjWKfYo7JWtsuc=; fh=xpD0+Nm2ABumU/mBlFAMhYnHMwwvV4SYm24CjMhoGNM=; b=wQQejD7me97ghAnvJjnB2WNyjnxZUQ9xE8mSzRL0XsVcNiIsmsfBhRx82pM2amdxEU HGNnQVJLGy5rD3DM+Nea+syDATfM9UEfaZH00ouufnhTOP4cbhBN+FWxN89a4s4OmKuV YqkUcViIYIMEug7PKOmWIEiRxNXmUGOJGiNhUUy0s4ja3Bd8C2zdqL59+8WIXwUn111x EnTNQQQ7JtzMlUqYFt6HbI0mw6wX4Vj0mE6brDMNtgDNPCDL/tEnE+/Q7rqvLuYOc0ec o8tWDSBFGK7MhNGs11ZCi10KUir6mCnWl+YKwq8y9ZbxvWeUZCz9raKsV2ECTchlNR9Z zhNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M23zDx1E; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w15-20020a05622a134f00b0042ec2a49e0bsi7689839qtk.441.2024.03.12.05.58.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 05:58:39 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=M23zDx1E; 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=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk1Xu-0000Mn-GJ; Tue, 12 Mar 2024 08:47:54 -0400 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 1rk1VV-0005Mo-Uz for qemu-devel@nongnu.org; Tue, 12 Mar 2024 08:45:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rk1VT-0000s9-FW for qemu-devel@nongnu.org; Tue, 12 Mar 2024 08:45:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710247521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V47akZkB3MNNJPOVhp+e0c7sV+XYzBjWKfYo7JWtsuc=; b=M23zDx1EPjpc/Mgo4ggBl46oOLGro7HjC2jqq7W7ULTWFX/I7qGK7HAz9fzmofVm8plcGs eLS2xwbVJ2LQBeL5YqTCDrzgPgMlrD/qXfWXZizWmFxleC/WiYfS+V8HYnlHcoBAETGTl4 xbHE72RqAp3ismFe7DNmOWpkilzBDYw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-0plU7JbWPmSiAZsOXp7tsQ-1; Tue, 12 Mar 2024 08:45:18 -0400 X-MC-Unique: 0plU7JbWPmSiAZsOXp7tsQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A4C880026F; Tue, 12 Mar 2024 12:45:18 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C9CD492BC4; Tue, 12 Mar 2024 12:45:15 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Richard Henderson , Bastian Koppelmann Subject: [PULL 53/55] target/tricore: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Tue, 12 Mar 2024 13:43:37 +0100 Message-ID: <20240312124339.761630-54-thuth@redhat.com> In-Reply-To: <20240312124339.761630-1-thuth@redhat.com> References: <20240312124339.761630-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, 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=ham 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 From: Philippe Mathieu-Daudé 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 Reviewed-by: Bastian Koppelmann Message-ID: <20240129164514.73104-28-philmd@linaro.org> Signed-off-by: Thomas Huth --- target/tricore/cpu.c | 24 +++++------------------- target/tricore/gdbstub.c | 6 ++---- target/tricore/helper.c | 3 +-- target/tricore/translate.c | 3 +-- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 682fc290ac..a9af73aeb5 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -36,52 +36,38 @@ static const gchar *tricore_gdb_arch_name(CPUState *cs) static void tricore_cpu_set_pc(CPUState *cs, vaddr value) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; - - env->PC = value & ~(target_ulong)1; + cpu_env(cs)->PC = value & ~(target_ulong)1; } static vaddr tricore_cpu_get_pc(CPUState *cs) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; - - return env->PC; + return cpu_env(cs)->PC; } static void tricore_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; - tcg_debug_assert(!(cs->tcg_cflags & CF_PCREL)); - env->PC = tb->pc; + cpu_env(cs)->PC = tb->pc; } static void tricore_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; - - env->PC = data[0]; + cpu_env(cs)->PC = data[0]; } static void tricore_cpu_reset_hold(Object *obj) { CPUState *cs = CPU(obj); - TriCoreCPU *cpu = TRICORE_CPU(cs); TriCoreCPUClass *tcc = TRICORE_CPU_GET_CLASS(obj); - CPUTriCoreState *env = &cpu->env; if (tcc->parent_phases.hold) { tcc->parent_phases.hold(obj); } - cpu_state_reset(env); + cpu_state_reset(cpu_env(cs)); } static bool tricore_cpu_has_work(CPUState *cs) diff --git a/target/tricore/gdbstub.c b/target/tricore/gdbstub.c index e8f8e5e6ea..f9309c5e27 100644 --- a/target/tricore/gdbstub.c +++ b/target/tricore/gdbstub.c @@ -106,8 +106,7 @@ static void tricore_cpu_gdb_write_csfr(CPUTriCoreState *env, int n, int tricore_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; + CPUTriCoreState *env = cpu_env(cs); if (n < 16) { /* data registers */ return gdb_get_reg32(mem_buf, env->gpr_d[n]); @@ -121,8 +120,7 @@ int tricore_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int tricore_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; + CPUTriCoreState *env = cpu_env(cs); uint32_t tmp; tmp = ldl_p(mem_buf); diff --git a/target/tricore/helper.c b/target/tricore/helper.c index 649373a9cb..6d9e80cc0c 100644 --- a/target/tricore/helper.c +++ b/target/tricore/helper.c @@ -67,8 +67,7 @@ bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType rw, int mmu_idx, bool probe, uintptr_t retaddr) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; + CPUTriCoreState *env = cpu_env(cs); hwaddr physical; int prot; int ret = 0; diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 278c514ab0..c45e1d992e 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -95,8 +95,7 @@ enum { void tricore_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; + CPUTriCoreState *env = cpu_env(cs); uint32_t psw; int i;