target/sparc: Prefer fast cpu_env() over slower CPU QOM cast macro

Mechanical patch produced running the command documented
in scripts/coccinelle/cpu_env.cocci_template header.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240129164514.73104-27-philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2024-01-29 17:45:08 +01:00 committed by Thomas Huth
parent 795bec9652
commit 7797676965
7 changed files with 18 additions and 38 deletions

View File

@ -32,9 +32,8 @@
static void sparc_cpu_reset_hold(Object *obj) static void sparc_cpu_reset_hold(Object *obj)
{ {
CPUState *cs = CPU(obj); CPUState *cs = CPU(obj);
SPARCCPU *cpu = SPARC_CPU(cs);
SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj); SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj);
CPUSPARCState *env = &cpu->env; CPUSPARCState *env = cpu_env(cs);
if (scc->parent_phases.hold) { if (scc->parent_phases.hold) {
scc->parent_phases.hold(obj); scc->parent_phases.hold(obj);
@ -83,8 +82,7 @@ static void sparc_cpu_reset_hold(Object *obj)
static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
{ {
if (interrupt_request & CPU_INTERRUPT_HARD) { if (interrupt_request & CPU_INTERRUPT_HARD) {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
if (cpu_interrupts_enabled(env) && env->interrupt_index > 0) { if (cpu_interrupts_enabled(env) && env->interrupt_index > 0) {
int pil = env->interrupt_index & 0xf; int pil = env->interrupt_index & 0xf;
@ -613,8 +611,7 @@ static void cpu_print_cc(FILE *f, uint32_t cc)
static void sparc_cpu_dump_state(CPUState *cs, FILE *f, int flags) static void sparc_cpu_dump_state(CPUState *cs, FILE *f, int flags)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
int i, x; int i, x;
qemu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env->pc, qemu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env->pc,
@ -711,11 +708,8 @@ static void sparc_cpu_synchronize_from_tb(CPUState *cs,
static bool sparc_cpu_has_work(CPUState *cs) static bool sparc_cpu_has_work(CPUState *cs)
{ {
SPARCCPU *cpu = SPARC_CPU(cs);
CPUSPARCState *env = &cpu->env;
return (cs->interrupt_request & CPU_INTERRUPT_HARD) && return (cs->interrupt_request & CPU_INTERRUPT_HARD) &&
cpu_interrupts_enabled(env); cpu_interrupts_enabled(cpu_env(cs));
} }
static int sparc_cpu_mmu_index(CPUState *cs, bool ifetch) static int sparc_cpu_mmu_index(CPUState *cs, bool ifetch)
@ -777,8 +771,7 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
CPUState *cs = CPU(dev); CPUState *cs = CPU(dev);
SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(dev); SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(dev);
Error *local_err = NULL; Error *local_err = NULL;
SPARCCPU *cpu = SPARC_CPU(dev); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
#if defined(CONFIG_USER_ONLY) #if defined(CONFIG_USER_ONLY)
/* We are emulating the kernel, which will trap and emulate float128. */ /* We are emulating the kernel, which will trap and emulate float128. */

View File

@ -29,8 +29,7 @@
int sparc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int sparc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
if (n < 8) { if (n < 8) {
/* g0..g7 */ /* g0..g7 */

View File

@ -99,8 +99,7 @@ void cpu_check_irqs(CPUSPARCState *env)
void sparc_cpu_do_interrupt(CPUState *cs) void sparc_cpu_do_interrupt(CPUState *cs)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
int cwp, intno = cs->exception_index; int cwp, intno = cs->exception_index;
if (qemu_loglevel_mask(CPU_LOG_INT)) { if (qemu_loglevel_mask(CPU_LOG_INT)) {

View File

@ -130,8 +130,7 @@ void cpu_check_irqs(CPUSPARCState *env)
void sparc_cpu_do_interrupt(CPUState *cs) void sparc_cpu_do_interrupt(CPUState *cs)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
int intno = cs->exception_index; int intno = cs->exception_index;
trap_state *tsptr; trap_state *tsptr;

View File

@ -418,8 +418,7 @@ static void sparc_raise_mmu_fault(CPUState *cs, hwaddr addr,
bool is_write, bool is_exec, int is_asi, bool is_write, bool is_exec, int is_asi,
unsigned size, uintptr_t retaddr) unsigned size, uintptr_t retaddr)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
int fault_type; int fault_type;
#ifdef DEBUG_UNASSIGNED #ifdef DEBUG_UNASSIGNED
@ -480,8 +479,7 @@ static void sparc_raise_mmu_fault(CPUState *cs, hwaddr addr,
bool is_write, bool is_exec, int is_asi, bool is_write, bool is_exec, int is_asi,
unsigned size, uintptr_t retaddr) unsigned size, uintptr_t retaddr)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
#ifdef DEBUG_UNASSIGNED #ifdef DEBUG_UNASSIGNED
printf("Unassigned mem access to " HWADDR_FMT_plx " from " TARGET_FMT_lx printf("Unassigned mem access to " HWADDR_FMT_plx " from " TARGET_FMT_lx

View File

@ -206,8 +206,7 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
MMUAccessType access_type, int mmu_idx, MMUAccessType access_type, int mmu_idx,
bool probe, uintptr_t retaddr) bool probe, uintptr_t retaddr)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
CPUTLBEntryFull full = {}; CPUTLBEntryFull full = {};
target_ulong vaddr; target_ulong vaddr;
int error_code = 0, access_index; int error_code = 0, access_index;
@ -391,8 +390,7 @@ void dump_mmu(CPUSPARCState *env)
int sparc_cpu_memory_rw_debug(CPUState *cs, vaddr address, int sparc_cpu_memory_rw_debug(CPUState *cs, vaddr address,
uint8_t *buf, int len, bool is_write) uint8_t *buf, int len, bool is_write)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
target_ulong addr = address; target_ulong addr = address;
int i; int i;
int len1; int len1;
@ -759,8 +757,7 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
MMUAccessType access_type, int mmu_idx, MMUAccessType access_type, int mmu_idx,
bool probe, uintptr_t retaddr) bool probe, uintptr_t retaddr)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
CPUTLBEntryFull full = {}; CPUTLBEntryFull full = {};
int error_code = 0, access_index; int error_code = 0, access_index;
@ -898,8 +895,7 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr,
hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
hwaddr phys_addr; hwaddr phys_addr;
int mmu_idx = cpu_mmu_index(cs, false); int mmu_idx = cpu_mmu_index(cs, false);
@ -916,8 +912,7 @@ G_NORETURN void sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
int mmu_idx, int mmu_idx,
uintptr_t retaddr) uintptr_t retaddr)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
#ifdef TARGET_SPARC64 #ifdef TARGET_SPARC64
env->dmmu.sfsr = build_sfsr(env, mmu_idx, access_type); env->dmmu.sfsr = build_sfsr(env, mmu_idx, access_type);

View File

@ -4844,13 +4844,12 @@ TRANS(FCMPEq, ALL, do_fcmpq, a, true)
static void sparc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) static void sparc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
{ {
DisasContext *dc = container_of(dcbase, DisasContext, base); DisasContext *dc = container_of(dcbase, DisasContext, base);
CPUSPARCState *env = cpu_env(cs);
int bound; int bound;
dc->pc = dc->base.pc_first; dc->pc = dc->base.pc_first;
dc->npc = (target_ulong)dc->base.tb->cs_base; dc->npc = (target_ulong)dc->base.tb->cs_base;
dc->mem_idx = dc->base.tb->flags & TB_FLAG_MMU_MASK; dc->mem_idx = dc->base.tb->flags & TB_FLAG_MMU_MASK;
dc->def = &env->def; dc->def = &cpu_env(cs)->def;
dc->fpu_enabled = tb_fpu_enabled(dc->base.tb->flags); dc->fpu_enabled = tb_fpu_enabled(dc->base.tb->flags);
dc->address_mask_32bit = tb_am_enabled(dc->base.tb->flags); dc->address_mask_32bit = tb_am_enabled(dc->base.tb->flags);
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
@ -4900,10 +4899,9 @@ static void sparc_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
{ {
DisasContext *dc = container_of(dcbase, DisasContext, base); DisasContext *dc = container_of(dcbase, DisasContext, base);
CPUSPARCState *env = cpu_env(cs);
unsigned int insn; unsigned int insn;
insn = translator_ldl(env, &dc->base, dc->pc); insn = translator_ldl(cpu_env(cs), &dc->base, dc->pc);
dc->base.pc_next += 4; dc->base.pc_next += 4;
if (!decode(dc, insn)) { if (!decode(dc, insn)) {
@ -5106,8 +5104,7 @@ void sparc_restore_state_to_opc(CPUState *cs,
const TranslationBlock *tb, const TranslationBlock *tb,
const uint64_t *data) const uint64_t *data)
{ {
SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = cpu_env(cs);
CPUSPARCState *env = &cpu->env;
target_ulong pc = data[0]; target_ulong pc = data[0];
target_ulong npc = data[1]; target_ulong npc = data[1];