From patchwork Fri Jan 26 22:03:49 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: 766391 Delivered-To: patch@linaro.org Received: by 2002:adf:a314:0:b0:337:62d3:c6d5 with SMTP id c20csp453334wrb; Fri, 26 Jan 2024 14:07:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnwToGLFhnzBfzCKHWH0Ia+VyN9xXVt/446/S00sSW1RPGDoOLEKfllP56LE/WPwMrJZwI X-Received: by 2002:a05:622a:2c5:b0:42a:88d1:1a59 with SMTP id a5-20020a05622a02c500b0042a88d11a59mr688463qtx.34.1706306850978; Fri, 26 Jan 2024 14:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706306850; cv=none; d=google.com; s=arc-20160816; b=saSNCZVUZtsJcEJL/o/2XJPvtiOE0UuCMMqwN0N2q+5JdjNUfx1pXpNdmj4NPM4iNN Qg/Gj5CVYVV0U0nUalcC8qeY+whpk95rb0xOwZT9qw7AkTLjwc+hg6emZtDfJl9uFkEd VP9DFNPZYjvemOCmfdg/+REZO1UVQRk/5/UxEyF5HimmIp2wUOxCwPun1njO3tQ0wvqT sBAFvfFoTXW0i1R4bqepP+wfdCfNNv+AxjXb6jtAektlOFi9aDS4vYAhSxvOk8sNKMTN sFjWcqgWO3HC8m1W6SMem7yUYbxMPGEdI3Q6h3QX+zD/0lrBNTHkE9vDHB7xGyFevNYI HXXg== 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=Geu08y2HUryuTkvO9FvgDhonl3J2Z6omRaCFm/Ev3sk=; fh=JzhVemc00xik1+5NTs5WGA4OD4DYEexqMVR4HQQclJ4=; b=XaNABCtk7qzDtcAnw3EMUarbWg4roaWX9eeTSLPUM8SeMbyDPNebEfO8M0hJ82rXHP VI7nraTfc639ssvVZj4dhRMRtUDNbchVepkSwFAFZ39NeG68ZiHIzwkyLKK/A2A9UfLE bS87qQiDWJH2MfMZdvs5eosXqA0OVxpTEWjWJSBhZs0jNMfxHQ3G4Yvx3CpmbcEtcLhi 1P+QkiNnAXWLb2h17gfSb9aaN3zqnLDtCfnlxjjtwzjIqTKSb3kDjZhH9lR2yARORHbC Nhd1oFUn7O2LLONdsFr8ukU1VWR9fD67dtb/2xIazoYelOL7rHQsm/og6IcdZ8HomkTZ zTyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PLplYAn8; 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 b18-20020ac87fd2000000b00429e73b5c44si2226820qtk.184.2024.01.26.14.07.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2024 14:07:30 -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=PLplYAn8; 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 1rTUJn-0007W2-TL; Fri, 26 Jan 2024 17:04:59 -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 1rTUJl-0007UI-Lb for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:04:57 -0500 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTUJi-0003ea-FQ for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:04:57 -0500 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-55783b7b47aso693602a12.0 for ; Fri, 26 Jan 2024 14:04:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706306692; x=1706911492; 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=Geu08y2HUryuTkvO9FvgDhonl3J2Z6omRaCFm/Ev3sk=; b=PLplYAn86eS4s6l9QxiiOwSEmuilz7CDtnluxQV8rNuMeBPPIhJQwyGhmpPgmA2NVQ kFvTQ6+6no3393Q32Hk/kY45SLQKUL6715MSchA5uScG6z3qozVaQv4PsliXQCCezqoU pH9P/syc2aSrNt+EJlYektTbutkcjY7writt07FlAVk8h8pojxUknS8I26GCKCUdfAWn 5XolXAGDAIHy5Xa14RLWM6bcSTril+1wrgXA85YHgVWePud/U0GzuF81W3O4/FLj9nd2 mmnBUpt+/3gIrllkt6/LGzHA7f8YGZwBjmLz4KdcMLYb3Fc1xbZar06fRDs2zb+SQUoT bjfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706306692; x=1706911492; 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=Geu08y2HUryuTkvO9FvgDhonl3J2Z6omRaCFm/Ev3sk=; b=JriT6Z3Gf1C5j09Zh9QvQDvHielRNKM3lwlT3P2EPH68dM9PbVhJfuutEVpFKrpElF 19E0OhLEShhzB8MvJvUfCtrmX/oeAvBaGX1Q0IUGYG/6kR93qRZ4APe/YeQ00rcpPqDo g12zMLI8sDnXdX2Y0zVhTg60txARoV5l/iJ3FDtf4+y1fZd8m3VV23tci+TssUZJs9cn SiB9clHxI+nenNXRUmsO4faAn/IH0DL3SUCD77gskdjHGDXTdNV79JAw1Y53rKelLEQF OTuOLv2XU0Twn1HRgVJLHBkINrbBVkggBxAvNAdVkbb7bm4oKAoVWKVh6hRt8jonP3mZ 8B9g== X-Gm-Message-State: AOJu0YxdruJcRd1LgKOMik0ltA5KGq82/UL/HBRA5uuq1+y60bCsu5CK mn0Y6rUbRPEaphWasJe1ykLXbUkhqR3UN4FqElAAgC2Is0HS4ufgqWZb6An23vJikFqtpaqEEGW m X-Received: by 2002:a05:6402:5243:b0:55d:164d:6f57 with SMTP id t3-20020a056402524300b0055d164d6f57mr246874edd.9.1706306692566; Fri, 26 Jan 2024 14:04:52 -0800 (PST) Received: from m1x-phil.lan ([176.176.142.39]) by smtp.gmail.com with ESMTPSA id ig9-20020a056402458900b00559bb146ecbsm1011608edb.6.2024.01.26.14.04.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 26 Jan 2024 14:04:52 -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?= , "Edgar E. Iglesias" Subject: [PATCH v2 07/23] target/cris: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Fri, 26 Jan 2024 23:03:49 +0100 Message-ID: <20240126220407.95022-8-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::52d; envelope-from=philmd@linaro.org; helo=mail-ed1-x52d.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/cris/cpu.c | 5 +---- target/cris/gdbstub.c | 9 +++------ target/cris/helper.c | 12 ++++-------- target/cris/translate.c | 3 +-- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 9ba08e8b0c..8ec32fade8 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -142,10 +142,7 @@ static void cris_cpu_set_irq(void *opaque, int irq, int level) static void cris_disas_set_info(CPUState *cpu, disassemble_info *info) { - CRISCPU *cc = CRIS_CPU(cpu); - CPUCRISState *env = &cc->env; - - if (env->pregs[PR_VR] != 32) { + if (cpu_env(cpu)->pregs[PR_VR] != 32) { info->mach = bfd_mach_cris_v0_v10; info->print_insn = print_insn_crisv10; } else { diff --git a/target/cris/gdbstub.c b/target/cris/gdbstub.c index 25c0ca33a5..9e87069da8 100644 --- a/target/cris/gdbstub.c +++ b/target/cris/gdbstub.c @@ -23,8 +23,7 @@ int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); if (n < 15) { return gdb_get_reg32(mem_buf, env->regs[n]); @@ -55,8 +54,7 @@ int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); uint8_t srs; srs = env->pregs[PR_SRS]; @@ -90,8 +88,7 @@ int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int cris_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); uint32_t tmp; if (n > 49) { diff --git a/target/cris/helper.c b/target/cris/helper.c index c0bf987e3e..1c3f86876f 100644 --- a/target/cris/helper.c +++ b/target/cris/helper.c @@ -53,8 +53,7 @@ bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); struct cris_mmu_result res; int prot, miss; target_ulong phy; @@ -97,8 +96,7 @@ bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int size, void crisv10_cpu_do_interrupt(CPUState *cs) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); int ex_vec = -1; D_LOG("exception index=%d interrupt_req=%d\n", @@ -159,8 +157,7 @@ void crisv10_cpu_do_interrupt(CPUState *cs) void cris_cpu_do_interrupt(CPUState *cs) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); int ex_vec = -1; D_LOG("exception index=%d interrupt_req=%d\n", @@ -262,8 +259,7 @@ hwaddr cris_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) bool cris_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { CPUClass *cc = CPU_GET_CLASS(cs); - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); bool ret = false; if (interrupt_request & CPU_INTERRUPT_HARD diff --git a/target/cris/translate.c b/target/cris/translate.c index b3974ba0bb..a935167f00 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3180,8 +3180,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags) { - CRISCPU *cpu = CRIS_CPU(cs); - CPUCRISState *env = &cpu->env; + CPUCRISState *env = cpu_env(cs); const char * const *regnames; const char * const *pregnames; int i;