diff mbox series

[RFC,08/11] target/ppc: wrapped some TCG only logic with ifdefs

Message ID 20210512140813.112884-9-bruno.larsen@eldorado.org.br (mailing list archive)
State New, archived
Headers show
Series target/ppc: add support to disable-tcg | expand

Commit Message

Bruno Larsen (billionai) May 12, 2021, 2:08 p.m. UTC
Wrapped some function calls in cpu_init.c and gdbstub.c that were TCG only
with ifdef CONFIG_TCG, to make it easier to build without it.

This seemed to be the minimum amount of changes to make the project
compile, but we wanted some feedback about wether we excluded something
important or if we should reorder some code to minimize ifdef count

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
---
 include/exec/helper-proto.h | 2 ++
 target/ppc/cpu_init.c       | 8 ++++++++
 target/ppc/excp_helper.c    | 6 +++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

Comments

Richard Henderson May 12, 2021, 6:33 p.m. UTC | #1
On 5/12/21 9:08 AM, Bruno Larsen (billionai) wrote:
> diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
> index ba100793a7..ce287222ee 100644
> --- a/include/exec/helper-proto.h
> +++ b/include/exec/helper-proto.h
> @@ -38,7 +38,9 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \
>   #define IN_HELPER_PROTO
>   
>   #include "helper.h"
> +#ifdef CONFIG_TCG
>   #include "trace/generated-helpers.h"
> +#endif
>   #include "accel/tcg/tcg-runtime.h"
>   #include "accel/tcg/plugin-helpers.h"
>   

Um.. this file is exclusively TCG already.
Are you missing some use of helper_foo()?


> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index d0fa219880..9d72dc49cf 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -1204,11 +1204,13 @@ static void register_BookE206_sprs(CPUPPCState *env, uint32_t mas_mask,
>       /* TLB assist registers */
>       /* XXX : not implemented */
>       for (i = 0; i < 8; i++) {
> +#ifdef CONFIG_TCG
>           void (*uea_write)(DisasContext *ctx, int sprn, int gprn) =
>               &spr_write_generic32;
>           if (i == 2 && (mas_mask & (1 << i)) && (env->insns_flags & PPC_64B)) {
>               uea_write = &spr_write_generic;
>           }
> +#endif

You could move this condition into

>           if (mas_mask & (1 << i)) {
>               spr_register(env, mas_sprn[i], mas_names[i],
>                            SPR_NOACCESS, SPR_NOACCESS,

... the call here, so that it all automatically compiles out:

   spr_register(env, ...,
                spr_read_generic,
                (i == 2 && (env->insns_flags & PPC_64B)
                 ? spr_write_generic : spr_write_generic32),
                0x00000000);

> @@ -8606,7 +8608,9 @@ static void ppc_cpu_realize(DeviceState *dev, Error **errp)
>           }
>       }
>   
> +#ifdef CONFIG_TCG
>       create_ppc_opcodes(cpu, &local_err);
> +#endif
>       if (local_err != NULL) {
>           error_propagate(errp, local_err);
>           goto unrealize;

Include the error checking into the ifdef.


> @@ -8799,7 +8803,9 @@ static void ppc_cpu_unrealize(DeviceState *dev)
>   
>       cpu_remove_sync(CPU(cpu));
>   
> +#ifdef CONFIG_TCG
>       destroy_ppc_opcodes(cpu);
> +#endif
>   }
>   
>   static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b)
> @@ -9297,7 +9303,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
>       cc->class_by_name = ppc_cpu_class_by_name;
>       cc->has_work = ppc_cpu_has_work;
>       cc->dump_state = ppc_cpu_dump_state;
> +#ifdef CONFIG_TCG
>       cc->dump_statistics = ppc_cpu_dump_statistics;
> +#endif

We should just drop this entirely.  It's supposedly a generic thing, but only 
used by ppc.  But even then only with source modification to enable 
DO_PPC_STATISTICS.  And even then as we convert to decodetree, said statistics 
will not be collected.

We should delete everything from cpu_dump_statistics on down.


r~
Bruno Larsen (billionai) May 12, 2021, 6:57 p.m. UTC | #2
On 12/05/2021 15:33, Richard Henderson wrote:
> On 5/12/21 9:08 AM, Bruno Larsen (billionai) wrote:
>> diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
>> index ba100793a7..ce287222ee 100644
>> --- a/include/exec/helper-proto.h
>> +++ b/include/exec/helper-proto.h
>> @@ -38,7 +38,9 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), 
>> dh_ctype(t2), dh_ctype(t3), \
>>   #define IN_HELPER_PROTO
>>     #include "helper.h"
>> +#ifdef CONFIG_TCG
>>   #include "trace/generated-helpers.h"
>> +#endif
>>   #include "accel/tcg/tcg-runtime.h"
>>   #include "accel/tcg/plugin-helpers.h"
>
> Um.. this file is exclusively TCG already.
> Are you missing some use of helper_foo()?
A lot of files that we are compiling (mainly mmu-*, excp_helper and 
gdbstub IIRC). We could comb through all of them and remove all 
declarations of helpers and wrap the inclusion of helper-proto itself in 
ifdefs, but it felt unnecessarily long. If it is preferable, we can do it.
>
>> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
>> index d0fa219880..9d72dc49cf 100644
>> --- a/target/ppc/cpu_init.c
>> +++ b/target/ppc/cpu_init.c
>> @@ -1204,11 +1204,13 @@ static void 
>> register_BookE206_sprs(CPUPPCState *env, uint32_t mas_mask,
>>       /* TLB assist registers */
>>       /* XXX : not implemented */
>>       for (i = 0; i < 8; i++) {
>> +#ifdef CONFIG_TCG
>>           void (*uea_write)(DisasContext *ctx, int sprn, int gprn) =
>>               &spr_write_generic32;
>>           if (i == 2 && (mas_mask & (1 << i)) && (env->insns_flags & 
>> PPC_64B)) {
>>               uea_write = &spr_write_generic;
>>           }
>> +#endif
>
> You could move this condition into
>
>>           if (mas_mask & (1 << i)) {
>>               spr_register(env, mas_sprn[i], mas_names[i],
>>                            SPR_NOACCESS, SPR_NOACCESS,
>
> ... the call here, so that it all automatically compiles out:
>
>   spr_register(env, ...,
>                spr_read_generic,
>                (i == 2 && (env->insns_flags & PPC_64B)
>                 ? spr_write_generic : spr_write_generic32),
>                0x00000000);
>
Yeah, sounds like a better plan.
>> @@ -8606,7 +8608,9 @@ static void ppc_cpu_realize(DeviceState *dev, 
>> Error **errp)
>>           }
>>       }
>>   +#ifdef CONFIG_TCG
>>       create_ppc_opcodes(cpu, &local_err);
>> +#endif
>>       if (local_err != NULL) {
>>           error_propagate(errp, local_err);
>>           goto unrealize;
>
> Include the error checking into the ifdef.
Ah, yeah, good idea
>
>
>> @@ -8799,7 +8803,9 @@ static void ppc_cpu_unrealize(DeviceState *dev)
>>         cpu_remove_sync(CPU(cpu));
>>   +#ifdef CONFIG_TCG
>>       destroy_ppc_opcodes(cpu);
>> +#endif
>>   }
>>     static gint ppc_cpu_compare_class_pvr(gconstpointer a, 
>> gconstpointer b)
>> @@ -9297,7 +9303,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, 
>> void *data)
>>       cc->class_by_name = ppc_cpu_class_by_name;
>>       cc->has_work = ppc_cpu_has_work;
>>       cc->dump_state = ppc_cpu_dump_state;
>> +#ifdef CONFIG_TCG
>>       cc->dump_statistics = ppc_cpu_dump_statistics;
>> +#endif
>
> We should just drop this entirely.  It's supposedly a generic thing, 
> but only used by ppc.  But even then only with source modification to 
> enable DO_PPC_STATISTICS.  And even then as we convert to decodetree, 
> said statistics will not be collected.
>
> We should delete everything from cpu_dump_statistics on down.
uhm, sure. We can do it, but I think should be left as future cleanup 
once we get disable-tcg working
>
>
> r~
Bruno Larsen (billionai) May 14, 2021, 1:29 p.m. UTC | #3
On 12/05/2021 15:57, Bruno Piazera Larsen wrote:
> On 12/05/2021 15:33, Richard Henderson wrote:
>> On 5/12/21 9:08 AM, Bruno Larsen (billionai) wrote:
>>> diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
>>> index ba100793a7..ce287222ee 100644
>>> --- a/include/exec/helper-proto.h
>>> +++ b/include/exec/helper-proto.h
>>> @@ -38,7 +38,9 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), 
>>> dh_ctype(t2), dh_ctype(t3), \
>>>   #define IN_HELPER_PROTO
>>>     #include "helper.h"
>>> +#ifdef CONFIG_TCG
>>>   #include "trace/generated-helpers.h"
>>> +#endif
>>>   #include "accel/tcg/tcg-runtime.h"
>>>   #include "accel/tcg/plugin-helpers.h"
>>
>> Um.. this file is exclusively TCG already.
>> Are you missing some use of helper_foo()?
> A lot of files that we are compiling (mainly mmu-*, excp_helper and 
> gdbstub IIRC). We could comb through all of them and remove all 
> declarations of helpers and wrap the inclusion of helper-proto itself 
> in ifdefs, but it felt unnecessarily long. If it is preferable, we can 
> do it.
>
So, I just looked and we'd need to change excp_helper.c and 
mmu-hash64.c, encasing 14 and 8 helper_foo() declarations. Is it better 
to work on those 2 files, or to change helper-proto?
Richard Henderson May 14, 2021, 2:44 p.m. UTC | #4
On 5/14/21 8:29 AM, Bruno Piazera Larsen wrote:
> 
> On 12/05/2021 15:57, Bruno Piazera Larsen wrote:
>> On 12/05/2021 15:33, Richard Henderson wrote:
>>> On 5/12/21 9:08 AM, Bruno Larsen (billionai) wrote:
>>>> diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
>>>> index ba100793a7..ce287222ee 100644
>>>> --- a/include/exec/helper-proto.h
>>>> +++ b/include/exec/helper-proto.h
>>>> @@ -38,7 +38,9 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), 
>>>> dh_ctype(t3), \
>>>>   #define IN_HELPER_PROTO
>>>>     #include "helper.h"
>>>> +#ifdef CONFIG_TCG
>>>>   #include "trace/generated-helpers.h"
>>>> +#endif
>>>>   #include "accel/tcg/tcg-runtime.h"
>>>>   #include "accel/tcg/plugin-helpers.h"
>>>
>>> Um.. this file is exclusively TCG already.
>>> Are you missing some use of helper_foo()?
>> A lot of files that we are compiling (mainly mmu-*, excp_helper and gdbstub 
>> IIRC). We could comb through all of them and remove all declarations of 
>> helpers and wrap the inclusion of helper-proto itself in ifdefs, but it felt 
>> unnecessarily long. If it is preferable, we can do it.
>>
> So, I just looked and we'd need to change excp_helper.c and mmu-hash64.c, 
> encasing 14 and 8 helper_foo() declarations. Is it better to work on those 2 
> files, or to change helper-proto?

Let's work on excp_helper.c and mmu-hash64.c.

For excp_helper.c, ideally everything in there would be tcg related.  Either 
explicitly as helper_foo() or by being one of the TCGCPUOps functions like 
ppc_cpu_exec_interrupt.

For mmu-hash64.c... I guess the easiest thing in the short term is to put big 
ifdefs around helper_slbi{a,e,eg}.  Or they could be moved to mmu_helper.c, 
with slb_lookup declared in mmu-hash64.h.


r~
Bruno Larsen (billionai) May 14, 2021, 4:22 p.m. UTC | #5
On 14/05/2021 11:44, Richard Henderson wrote:
> On 5/14/21 8:29 AM, Bruno Piazera Larsen wrote:
>>
>> On 12/05/2021 15:57, Bruno Piazera Larsen wrote:
>>> On 12/05/2021 15:33, Richard Henderson wrote:
>>>> On 5/12/21 9:08 AM, Bruno Larsen (billionai) wrote:
>>>>> diff --git a/include/exec/helper-proto.h 
>>>>> b/include/exec/helper-proto.h
>>>>> index ba100793a7..ce287222ee 100644
>>>>> --- a/include/exec/helper-proto.h
>>>>> +++ b/include/exec/helper-proto.h
>>>>> @@ -38,7 +38,9 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), 
>>>>> dh_ctype(t2), dh_ctype(t3), \
>>>>>   #define IN_HELPER_PROTO
>>>>>     #include "helper.h"
>>>>> +#ifdef CONFIG_TCG
>>>>>   #include "trace/generated-helpers.h"
>>>>> +#endif
>>>>>   #include "accel/tcg/tcg-runtime.h"
>>>>>   #include "accel/tcg/plugin-helpers.h"
>>>>
>>>> Um.. this file is exclusively TCG already.
>>>> Are you missing some use of helper_foo()?
>>> A lot of files that we are compiling (mainly mmu-*, excp_helper and 
>>> gdbstub IIRC). We could comb through all of them and remove all 
>>> declarations of helpers and wrap the inclusion of helper-proto 
>>> itself in ifdefs, but it felt unnecessarily long. If it is 
>>> preferable, we can do it.
>>>
>> So, I just looked and we'd need to change excp_helper.c and 
>> mmu-hash64.c, encasing 14 and 8 helper_foo() declarations. Is it 
>> better to work on those 2 files, or to change helper-proto?
>
> Let's work on excp_helper.c and mmu-hash64.c.
>
> For excp_helper.c, ideally everything in there would be tcg related.  
> Either explicitly as helper_foo() or by being one of the TCGCPUOps 
> functions like ppc_cpu_exec_interrupt.

Removing excp_helper.c gives linker errors for the functions:

* ppc_cpu_do_system_reset, on hw/ppc/pnv.c and hw/ppc/spapr.c

* ppc_do_cpu_interrupt, on hw/ppc/spapr_events.c and target/ppc/kvm.c, 
and from what was discussed on the IRC this should still be compiled

* ppc_cpu_do_fwnmi_machine_check, on hw/ppc/spapr_events.c


I think ppc_do_cpu_interrupt could go to cpu.c, but no clue where the 
others should go.

>
> For mmu-hash64.c... I guess the easiest thing in the short term is to 
> put big ifdefs around helper_slbi{a,e,eg}.  Or they could be moved to 
> mmu_helper.c, with slb_lookup declared in mmu-hash64.h.
>
The ifdefs are easy enough, and not compiling it gives way too many 
linker errors. Moving the helpers and static functions sounds the 
cleanest though, so I'll look into it while I wait for the excp_helper help
>
> r~
David Gibson May 17, 2021, 4 a.m. UTC | #6
On Fri, May 14, 2021 at 09:44:36AM -0500, Richard Henderson wrote:
> On 5/14/21 8:29 AM, Bruno Piazera Larsen wrote:
> > 
> > On 12/05/2021 15:57, Bruno Piazera Larsen wrote:
> > > On 12/05/2021 15:33, Richard Henderson wrote:
> > > > On 5/12/21 9:08 AM, Bruno Larsen (billionai) wrote:
> > > > > diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
> > > > > index ba100793a7..ce287222ee 100644
> > > > > --- a/include/exec/helper-proto.h
> > > > > +++ b/include/exec/helper-proto.h
> > > > > @@ -38,7 +38,9 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1),
> > > > > dh_ctype(t2), dh_ctype(t3), \
> > > > >   #define IN_HELPER_PROTO
> > > > >     #include "helper.h"
> > > > > +#ifdef CONFIG_TCG
> > > > >   #include "trace/generated-helpers.h"
> > > > > +#endif
> > > > >   #include "accel/tcg/tcg-runtime.h"
> > > > >   #include "accel/tcg/plugin-helpers.h"
> > > > 
> > > > Um.. this file is exclusively TCG already.
> > > > Are you missing some use of helper_foo()?
> > > A lot of files that we are compiling (mainly mmu-*, excp_helper and
> > > gdbstub IIRC). We could comb through all of them and remove all
> > > declarations of helpers and wrap the inclusion of helper-proto
> > > itself in ifdefs, but it felt unnecessarily long. If it is
> > > preferable, we can do it.
> > > 
> > So, I just looked and we'd need to change excp_helper.c and
> > mmu-hash64.c, encasing 14 and 8 helper_foo() declarations. Is it better
> > to work on those 2 files, or to change helper-proto?
> 
> Let's work on excp_helper.c and mmu-hash64.c.
> 
> For excp_helper.c, ideally everything in there would be tcg related.  Either
> explicitly as helper_foo() or by being one of the TCGCPUOps functions like
> ppc_cpu_exec_interrupt.
> 
> For mmu-hash64.c... I guess the easiest thing in the short term is to put
> big ifdefs around helper_slbi{a,e,eg}.  Or they could be moved to
> mmu_helper.c, with slb_lookup declared in mmu-hash64.h.

I think the ifdefs are the lesser evil here.  I created mmu-hash64.*
because I think dividing things by MMU family is much more useful than
dividing by how it fits into the TCG/SOFTMMU model which how things
kind of were done historically (and still are for the many MMU familes
I've never had time or knowledge to rework).
David Gibson May 17, 2021, 4:10 a.m. UTC | #7
On Fri, May 14, 2021 at 01:22:48PM -0300, Bruno Piazera Larsen wrote:
> 
> On 14/05/2021 11:44, Richard Henderson wrote:
> > On 5/14/21 8:29 AM, Bruno Piazera Larsen wrote:
> > > 
> > > On 12/05/2021 15:57, Bruno Piazera Larsen wrote:
> > > > On 12/05/2021 15:33, Richard Henderson wrote:
> > > > > On 5/12/21 9:08 AM, Bruno Larsen (billionai) wrote:
> > > > > > diff --git a/include/exec/helper-proto.h
> > > > > > b/include/exec/helper-proto.h
> > > > > > index ba100793a7..ce287222ee 100644
> > > > > > --- a/include/exec/helper-proto.h
> > > > > > +++ b/include/exec/helper-proto.h
> > > > > > @@ -38,7 +38,9 @@ dh_ctype(ret) HELPER(name)
> > > > > > (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \
> > > > > >   #define IN_HELPER_PROTO
> > > > > >     #include "helper.h"
> > > > > > +#ifdef CONFIG_TCG
> > > > > >   #include "trace/generated-helpers.h"
> > > > > > +#endif
> > > > > >   #include "accel/tcg/tcg-runtime.h"
> > > > > >   #include "accel/tcg/plugin-helpers.h"
> > > > > 
> > > > > Um.. this file is exclusively TCG already.
> > > > > Are you missing some use of helper_foo()?
> > > > A lot of files that we are compiling (mainly mmu-*, excp_helper
> > > > and gdbstub IIRC). We could comb through all of them and remove
> > > > all declarations of helpers and wrap the inclusion of
> > > > helper-proto itself in ifdefs, but it felt unnecessarily long.
> > > > If it is preferable, we can do it.
> > > > 
> > > So, I just looked and we'd need to change excp_helper.c and
> > > mmu-hash64.c, encasing 14 and 8 helper_foo() declarations. Is it
> > > better to work on those 2 files, or to change helper-proto?
> > 
> > Let's work on excp_helper.c and mmu-hash64.c.
> > 
> > For excp_helper.c, ideally everything in there would be tcg related. 
> > Either explicitly as helper_foo() or by being one of the TCGCPUOps
> > functions like ppc_cpu_exec_interrupt.
> 
> Removing excp_helper.c gives linker errors for the functions:
> 
> * ppc_cpu_do_system_reset, on hw/ppc/pnv.c and hw/ppc/spapr.c

Oof, that's a bit tricky.  We definitely do need this system reset
injection for KVM as well as TCG.  Unfortunately it calls into
powerpc_excp() which I think has a bunch of TCG specific stuff as
well.

Long term, I think the thing would be to remove the giant ugly
multiplexer in powerpc_excp() in favour of different entry points.
But that's a big job.

Short term, littering it with ifdefs might be the least worst we can
do.  Richard, any better ideas?


> * ppc_do_cpu_interrupt, on hw/ppc/spapr_events.c and target/ppc/kvm.c, and
> from what was discussed on the IRC this should still be compiled

Similar situation to above, but much easier because it doesn't go
through the giant multiplexer.
> 
> 
> I think ppc_do_cpu_interrupt could go to cpu.c, but no clue where the others
> should go.

Yes, moving ppc_cpu_do_interrupt() to common code is the right call.

> 
> > 
> > For mmu-hash64.c... I guess the easiest thing in the short term is to
> > put big ifdefs around helper_slbi{a,e,eg}.  Or they could be moved to
> > mmu_helper.c, with slb_lookup declared in mmu-hash64.h.
> > 
> The ifdefs are easy enough, and not compiling it gives way too many linker
> errors. Moving the helpers and static functions sounds the cleanest though,
> so I'll look into it while I wait for the excp_helper help
> > 
> > r~
Richard Henderson May 17, 2021, 4:07 p.m. UTC | #8
On 5/16/21 11:10 PM, David Gibson wrote:
>> Removing excp_helper.c gives linker errors for the functions:
>>
>> * ppc_cpu_do_system_reset, on hw/ppc/pnv.c and hw/ppc/spapr.c
> 
> Oof, that's a bit tricky.  We definitely do need this system reset
> injection for KVM as well as TCG.  Unfortunately it calls into
> powerpc_excp() which I think has a bunch of TCG specific stuff as
> well.
> 
> Long term, I think the thing would be to remove the giant ugly
> multiplexer in powerpc_excp() in favour of different entry points.
> But that's a big job.
> 
> Short term, littering it with ifdefs might be the least worst we can
> do.  Richard, any better ideas?

Nope, no better ideas here.


r~
Bruno Larsen (billionai) May 24, 2021, 6:01 p.m. UTC | #9
>> @@ -8799,7 +8803,9 @@ static void ppc_cpu_unrealize(DeviceState *dev)
>>         cpu_remove_sync(CPU(cpu));
>>   +#ifdef CONFIG_TCG
>>       destroy_ppc_opcodes(cpu);
>> +#endif
>>   }
>>     static gint ppc_cpu_compare_class_pvr(gconstpointer a, 
>> gconstpointer b)
>> @@ -9297,7 +9303,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, 
>> void *data)
>>       cc->class_by_name = ppc_cpu_class_by_name;
>>       cc->has_work = ppc_cpu_has_work;
>>       cc->dump_state = ppc_cpu_dump_state;
>> +#ifdef CONFIG_TCG
>>       cc->dump_statistics = ppc_cpu_dump_statistics;
>> +#endif
>
> We should just drop this entirely.  It's supposedly a generic thing, 
> but only used by ppc.  But even then only with source modification to 
> enable DO_PPC_STATISTICS.  And even then as we convert to decodetree, 
> said statistics will not be collected.
>
> We should delete everything from cpu_dump_statistics on down.

So, now that we have a version of disable-tcg that is functional, I'm 
inclined to look at this cleanup. Just to make sure I got it right: 
everything related to ppc_cpu_dump_statistics and the stuff related to 
ifdef DO_PPC_STATISTICS can be removed, yeah?
Richard Henderson May 24, 2021, 8:03 p.m. UTC | #10
On 5/24/21 11:01 AM, Bruno Piazera Larsen wrote:
>>> +#ifdef CONFIG_TCG
>>>       cc->dump_statistics = ppc_cpu_dump_statistics;
>>> +#endif
>>
>> We should just drop this entirely.  It's supposedly a generic thing, but only 
>> used by ppc.  But even then only with source modification to enable 
>> DO_PPC_STATISTICS.  And even then as we convert to decodetree, said 
>> statistics will not be collected.
>>
>> We should delete everything from cpu_dump_statistics on down.
> 
> So, now that we have a version of disable-tcg that is functional, I'm inclined 
> to look at this cleanup. Just to make sure I got it right: everything related 
> to ppc_cpu_dump_statistics and the stuff related to ifdef DO_PPC_STATISTICS can 
> be removed, yeah?

I would imagine a set of patches:

(1) DO_PPC_STATISTICS
(2) ppc_cpu_dump_statistics (which will be empty now).
(3) CPUClass.dump_statistics (which now has no setters),
     and cpu_dump_statistics (which is closely related).
(4) hmp_info_cpustats (which now does nothing).


r~
diff mbox series

Patch

diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h
index ba100793a7..ce287222ee 100644
--- a/include/exec/helper-proto.h
+++ b/include/exec/helper-proto.h
@@ -38,7 +38,9 @@  dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \
 #define IN_HELPER_PROTO
 
 #include "helper.h"
+#ifdef CONFIG_TCG
 #include "trace/generated-helpers.h"
+#endif
 #include "accel/tcg/tcg-runtime.h"
 #include "accel/tcg/plugin-helpers.h"
 
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index d0fa219880..9d72dc49cf 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -1204,11 +1204,13 @@  static void register_BookE206_sprs(CPUPPCState *env, uint32_t mas_mask,
     /* TLB assist registers */
     /* XXX : not implemented */
     for (i = 0; i < 8; i++) {
+#ifdef CONFIG_TCG
         void (*uea_write)(DisasContext *ctx, int sprn, int gprn) =
             &spr_write_generic32;
         if (i == 2 && (mas_mask & (1 << i)) && (env->insns_flags & PPC_64B)) {
             uea_write = &spr_write_generic;
         }
+#endif
         if (mas_mask & (1 << i)) {
             spr_register(env, mas_sprn[i], mas_names[i],
                          SPR_NOACCESS, SPR_NOACCESS,
@@ -8606,7 +8608,9 @@  static void ppc_cpu_realize(DeviceState *dev, Error **errp)
         }
     }
 
+#ifdef CONFIG_TCG
     create_ppc_opcodes(cpu, &local_err);
+#endif
     if (local_err != NULL) {
         error_propagate(errp, local_err);
         goto unrealize;
@@ -8799,7 +8803,9 @@  static void ppc_cpu_unrealize(DeviceState *dev)
 
     cpu_remove_sync(CPU(cpu));
 
+#ifdef CONFIG_TCG
     destroy_ppc_opcodes(cpu);
+#endif
 }
 
 static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b)
@@ -9297,7 +9303,9 @@  static void ppc_cpu_class_init(ObjectClass *oc, void *data)
     cc->class_by_name = ppc_cpu_class_by_name;
     cc->has_work = ppc_cpu_has_work;
     cc->dump_state = ppc_cpu_dump_state;
+#ifdef CONFIG_TCG
     cc->dump_statistics = ppc_cpu_dump_statistics;
+#endif
     cc->set_pc = ppc_cpu_set_pc;
     cc->gdb_read_register = ppc_cpu_gdb_read_register;
     cc->gdb_write_register = ppc_cpu_gdb_write_register;
diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
index f4f15279eb..824e16a32a 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -21,7 +21,9 @@ 
 #include "cpu.h"
 #include "exec/helper-proto.h"
 #include "exec/exec-all.h"
+#ifdef CONFIG_TCG
 #include "exec/cpu_ldst.h"
+#endif
 #include "internal.h"
 #include "helper_regs.h"
 
@@ -1492,7 +1494,7 @@  void helper_book3s_msgsnd(target_ulong rb)
     book3s_msgsnd_common(pir, PPC_INTERRUPT_HDOORBELL);
 }
 
-#if defined(TARGET_PPC64)
+#if defined(TARGET_PPC64) && defined(CONFIG_TCG)
 void helper_book3s_msgclrp(CPUPPCState *env, target_ulong rb)
 {
     helper_hfscr_facility_check(env, HFSCR_MSGP, "msgclrp", HFSCR_IC_MSGP);
@@ -1525,6 +1527,7 @@  void helper_book3s_msgsndp(CPUPPCState *env, target_ulong rb)
 #endif
 #endif
 
+#ifdef CONFIG_TCG
 void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
                                  MMUAccessType access_type,
                                  int mmu_idx, uintptr_t retaddr)
@@ -1540,3 +1543,4 @@  void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
     env->error_code = insn & 0x03FF0000;
     cpu_loop_exit(cs);
 }
+#endif