target/cris: 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>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240129164514.73104-11-philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2024-01-29 17:44:52 +01:00 committed by Thomas Huth
parent 2db5b94d83
commit 2df4ab2fbc
4 changed files with 12 additions and 25 deletions

View File

@ -63,10 +63,9 @@ static int cris_cpu_mmu_index(CPUState *cs, bool ifetch)
static void cris_cpu_reset_hold(Object *obj) static void cris_cpu_reset_hold(Object *obj)
{ {
CPUState *s = CPU(obj); CPUState *cs = CPU(obj);
CRISCPU *cpu = CRIS_CPU(s);
CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(obj); CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(obj);
CPUCRISState *env = &cpu->env; CPUCRISState *env = cpu_env(cs);
uint32_t vr; uint32_t vr;
if (ccc->parent_phases.hold) { if (ccc->parent_phases.hold) {
@ -147,10 +146,7 @@ static void cris_cpu_set_irq(void *opaque, int irq, int level)
static void cris_disas_set_info(CPUState *cpu, disassemble_info *info) static void cris_disas_set_info(CPUState *cpu, disassemble_info *info)
{ {
CRISCPU *cc = CRIS_CPU(cpu); if (cpu_env(cpu)->pregs[PR_VR] != 32) {
CPUCRISState *env = &cc->env;
if (env->pregs[PR_VR] != 32) {
info->mach = bfd_mach_cris_v0_v10; info->mach = bfd_mach_cris_v0_v10;
info->print_insn = print_insn_crisv10; info->print_insn = print_insn_crisv10;
} else { } else {

View File

@ -23,8 +23,7 @@
int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
{ {
CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = cpu_env(cs);
CPUCRISState *env = &cpu->env;
if (n < 15) { if (n < 15) {
return gdb_get_reg32(mem_buf, env->regs[n]); 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) int cris_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
{ {
CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = cpu_env(cs);
CPUCRISState *env = &cpu->env;
uint8_t srs; uint8_t srs;
srs = env->pregs[PR_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) int cris_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
{ {
CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = cpu_env(cs);
CPUCRISState *env = &cpu->env;
uint32_t tmp; uint32_t tmp;
if (n > 49) { if (n > 49) {

View File

@ -53,8 +53,7 @@ bool cris_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)
{ {
CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = cpu_env(cs);
CPUCRISState *env = &cpu->env;
struct cris_mmu_result res; struct cris_mmu_result res;
int prot, miss; int prot, miss;
target_ulong phy; 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) void crisv10_cpu_do_interrupt(CPUState *cs)
{ {
CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = cpu_env(cs);
CPUCRISState *env = &cpu->env;
int ex_vec = -1; int ex_vec = -1;
D_LOG("exception index=%d interrupt_req=%d\n", 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) void cris_cpu_do_interrupt(CPUState *cs)
{ {
CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = cpu_env(cs);
CPUCRISState *env = &cpu->env;
int ex_vec = -1; int ex_vec = -1;
D_LOG("exception index=%d interrupt_req=%d\n", 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) bool cris_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
{ {
CPUClass *cc = CPU_GET_CLASS(cs); CPUClass *cc = CPU_GET_CLASS(cs);
CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = cpu_env(cs);
CPUCRISState *env = &cpu->env;
bool ret = false; bool ret = false;
if (interrupt_request & CPU_INTERRUPT_HARD if (interrupt_request & CPU_INTERRUPT_HARD

View File

@ -3002,7 +3002,6 @@ static void cris_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
static void cris_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) static void cris_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
{ {
DisasContext *dc = container_of(dcbase, DisasContext, base); DisasContext *dc = container_of(dcbase, DisasContext, base);
CPUCRISState *env = cpu_env(cs);
unsigned int insn_len; unsigned int insn_len;
/* Pretty disas. */ /* Pretty disas. */
@ -3010,7 +3009,7 @@ static void cris_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
dc->clear_x = 1; dc->clear_x = 1;
insn_len = dc->decoder(env, dc); insn_len = dc->decoder(cpu_env(cs), dc);
dc->ppc = dc->pc; dc->ppc = dc->pc;
dc->pc += insn_len; dc->pc += insn_len;
dc->base.pc_next += insn_len; dc->base.pc_next += insn_len;
@ -3176,8 +3175,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags) void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags)
{ {
CRISCPU *cpu = CRIS_CPU(cs); CPUCRISState *env = cpu_env(cs);
CPUCRISState *env = &cpu->env;
const char * const *regnames; const char * const *regnames;
const char * const *pregnames; const char * const *pregnames;
int i; int i;