[PATCH] sim: cgen: move cgen_cpu_max_extra_bytes logic into the common code
Andrew Burgess
andrew.burgess@embecosm.com
Mon Jan 11 11:01:43 GMT 2021
* Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> [2021-01-10 03:25:03 -0500]:
> Every arch handles this the same way, so move it to the common code.
> This will also make unifying the sim_cpu structure easier.
Please can you include the ChangeLog entries with the patch
submissions.
Could we not remove the `extra_bytes` parameter from sim_cpu_alloc_all
now? As far as I can tell it is always passed as 0? Or have I missed
something?
Thanks,
Andrew
> ---
> sim/arm/wrapper.c | 2 +-
> sim/avr/interp.c | 2 +-
> sim/bfin/interp.c | 2 +-
> sim/bpf/sim-if.c | 3 +--
> sim/common/sim-cpu.c | 4 ++++
> sim/cr16/interp.c | 2 +-
> sim/cris/sim-if.c | 2 +-
> sim/d10v/interp.c | 2 +-
> sim/frv/sim-if.c | 2 +-
> sim/ft32/interp.c | 2 +-
> sim/h8300/compile.c | 2 +-
> sim/iq2000/sim-if.c | 2 +-
> sim/lm32/sim-if.c | 2 +-
> sim/m32r/sim-if.c | 2 +-
> sim/m68hc11/interp.c | 2 +-
> sim/mcore/interp.c | 2 +-
> sim/microblaze/interp.c | 2 +-
> sim/mips/interp.c | 2 +-
> sim/mn10300/interp.c | 2 +-
> sim/moxie/interp.c | 2 +-
> sim/msp430/msp430-sim.c | 2 +-
> sim/or1k/sim-if.c | 2 +-
> sim/pru/interp.c | 2 +-
> sim/sh/interp.c | 2 +-
> sim/v850/interp.c | 2 +-
> 25 files changed, 28 insertions(+), 25 deletions(-)
>
> diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
> index 5fc753a71af2..7f0e1a5a35ef 100644
> --- a/sim/arm/wrapper.c
> +++ b/sim/arm/wrapper.c
> @@ -800,7 +800,7 @@ sim_open (SIM_OPEN_KIND kind,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/avr/interp.c b/sim/avr/interp.c
> index deaf711e1040..837cca6181cd 100644
> --- a/sim/avr/interp.c
> +++ b/sim/avr/interp.c
> @@ -1685,7 +1685,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
> index e26a8221b20a..0470991a40e7 100644
> --- a/sim/bfin/interp.c
> +++ b/sim/bfin/interp.c
> @@ -723,7 +723,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
> SIM_DESC sd = sim_state_alloc (kind, callback);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/bpf/sim-if.c b/sim/bpf/sim-if.c
> index ad75ac4affa6..1d77c4f937d3 100644
> --- a/sim/bpf/sim-if.c
> +++ b/sim/bpf/sim-if.c
> @@ -122,8 +122,7 @@ sim_open (SIM_OPEN_KIND kind,
>
> SIM_DESC sd = sim_state_alloc (kind, callback);
>
> - if (sim_cpu_alloc_all (sd, 1, cgen_cpu_max_extra_bytes ())
> - != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> goto error;
>
> if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
> diff --git a/sim/common/sim-cpu.c b/sim/common/sim-cpu.c
> index a00846cd4c6a..a7aa13e6fb2b 100644
> --- a/sim/common/sim-cpu.c
> +++ b/sim/common/sim-cpu.c
> @@ -43,6 +43,10 @@ sim_cpu_alloc_all (SIM_DESC sd, int ncpus, int extra_bytes)
> sim_cpu *
> sim_cpu_alloc (SIM_DESC sd, int extra_bytes)
> {
> +#ifdef CGEN_ARCH
> + extra_bytes += cgen_cpu_max_extra_bytes ();
> +#endif
> +
> return zalloc (sizeof (sim_cpu) + extra_bytes);
> }
>
> diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c
> index cff7b8857189..fb63b1954cc1 100644
> --- a/sim/cr16/interp.c
> +++ b/sim/cr16/interp.c
> @@ -397,7 +397,7 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *cb,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c
> index b8c7cb2a96e7..3e1bff0de6c3 100644
> --- a/sim/cris/sim-if.c
> +++ b/sim/cris/sim-if.c
> @@ -661,7 +661,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
> bfd_byte sp_init[4] = {0, 0, 0, 0};
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, cgen_cpu_max_extra_bytes ()) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
> index 5c70b38d9d8f..d0272e816213 100644
> --- a/sim/d10v/interp.c
> +++ b/sim/d10v/interp.c
> @@ -760,7 +760,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c
> index 2eb6e6da5f3f..da41f1e97608 100644
> --- a/sim/frv/sim-if.c
> +++ b/sim/frv/sim-if.c
> @@ -57,7 +57,7 @@ sim_open (kind, callback, abfd, argv)
> SIM_DESC sd = sim_state_alloc (kind, callback);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, cgen_cpu_max_extra_bytes ()) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/ft32/interp.c b/sim/ft32/interp.c
> index 1b3db9bc0082..ecf33054a17c 100644
> --- a/sim/ft32/interp.c
> +++ b/sim/ft32/interp.c
> @@ -807,7 +807,7 @@ sim_open (SIM_OPEN_KIND kind,
> SIM_DESC sd = sim_state_alloc (kind, cb);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
> index 3a3b2e7241bb..644da035694e 100644
> --- a/sim/h8300/compile.c
> +++ b/sim/h8300/compile.c
> @@ -4712,7 +4712,7 @@ sim_open (SIM_OPEN_KIND kind,
> sd = sim_state_alloc (kind, callback);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c
> index 238ec97e47db..95796704081b 100644
> --- a/sim/iq2000/sim-if.c
> +++ b/sim/iq2000/sim-if.c
> @@ -61,7 +61,7 @@ sim_open (kind, callback, abfd, argv)
> SIM_DESC sd = sim_state_alloc (kind, callback);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, cgen_cpu_max_extra_bytes ()) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c
> index cbe975113b3d..14d120545eb6 100644
> --- a/sim/lm32/sim-if.c
> +++ b/sim/lm32/sim-if.c
> @@ -94,7 +94,7 @@ sim_open (kind, callback, abfd, argv)
> unsigned long base, limit;
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, cgen_cpu_max_extra_bytes ()) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c
> index c25d9a859c2c..3525259c328d 100644
> --- a/sim/m32r/sim-if.c
> +++ b/sim/m32r/sim-if.c
> @@ -63,7 +63,7 @@ sim_open (kind, callback, abfd, argv)
> int i;
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, cgen_cpu_max_extra_bytes ()) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/m68hc11/interp.c b/sim/m68hc11/interp.c
> index 26f2d1527beb..93641b2a205a 100644
> --- a/sim/m68hc11/interp.c
> +++ b/sim/m68hc11/interp.c
> @@ -404,7 +404,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c
> index 9981517e1e69..5f17bbd88a53 100644
> --- a/sim/mcore/interp.c
> +++ b/sim/mcore/interp.c
> @@ -1349,7 +1349,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
> index 5b125a64da27..b3d1a849db1a 100644
> --- a/sim/microblaze/interp.c
> +++ b/sim/microblaze/interp.c
> @@ -393,7 +393,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/mips/interp.c b/sim/mips/interp.c
> index 9dbac8c58fc7..13fe58645236 100644
> --- a/sim/mips/interp.c
> +++ b/sim/mips/interp.c
> @@ -357,7 +357,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> return 0;
>
> cpu = STATE_CPU (sd, 0); /* FIXME */
> diff --git a/sim/mn10300/interp.c b/sim/mn10300/interp.c
> index 7f0655f3f472..376243edf0e4 100644
> --- a/sim/mn10300/interp.c
> +++ b/sim/mn10300/interp.c
> @@ -103,7 +103,7 @@ sim_open (SIM_OPEN_KIND kind,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> return 0;
>
> /* for compatibility */
> diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c
> index f895af6f1bb4..7d04bd22d1e4 100644
> --- a/sim/moxie/interp.c
> +++ b/sim/moxie/interp.c
> @@ -1197,7 +1197,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c
> index ea7a157231cf..982fc9fd5c0d 100644
> --- a/sim/msp430/msp430-sim.c
> +++ b/sim/msp430/msp430-sim.c
> @@ -110,7 +110,7 @@ sim_open (SIM_OPEN_KIND kind,
>
> /* Initialise the simulator. */
>
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> sim_state_free (sd);
> return 0;
> diff --git a/sim/or1k/sim-if.c b/sim/or1k/sim-if.c
> index 18f70387063f..e022c7eab61b 100644
> --- a/sim/or1k/sim-if.c
> +++ b/sim/or1k/sim-if.c
> @@ -166,7 +166,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
> int i;
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, cgen_cpu_max_extra_bytes ()) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/pru/interp.c b/sim/pru/interp.c
> index 2933075bd08f..090a28537d4b 100644
> --- a/sim/pru/interp.c
> +++ b/sim/pru/interp.c
> @@ -744,7 +744,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/sh/interp.c b/sim/sh/interp.c
> index c77cf3b1d3bf..2267bedfb8b8 100644
> --- a/sim/sh/interp.c
> +++ b/sim/sh/interp.c
> @@ -2373,7 +2373,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> {
> free_state (sd);
> return 0;
> diff --git a/sim/v850/interp.c b/sim/v850/interp.c
> index daf961801768..7a9fabae2834 100644
> --- a/sim/v850/interp.c
> +++ b/sim/v850/interp.c
> @@ -204,7 +204,7 @@ sim_open (SIM_OPEN_KIND kind,
> SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
>
> /* The cpu data is kept in a separately allocated chunk of memory. */
> - if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
> + if (sim_cpu_alloc_all (sd, 1, 0) != SIM_RC_OK)
> return 0;
>
> /* for compatibility */
> --
> 2.28.0
>
More information about the Gdb-patches
mailing list