[06/40] sim/cris: Move declarations of f_specific_init

Message ID 3904a5c3e80f8548150d8088a92059dd728c7ff8.1666258361.git.research_trasio@irq.a4lg.com
State Committed
Headers
Series sim+gdb: Suppress warnings if built with Clang (big batch 1) |

Commit Message

Tsukasa OI Oct. 20, 2022, 9:32 a.m. UTC
  Declarations for MY (f_specific_init) functions are defined in CGEN-
generated header files: sim/cris/decodev10.h (crisv10f_specific_init) and
sim/cris/decodev32.h (crisv32f_specific_init).  However, those declarations
are manually added by the commit 4e6e8ba7c565 ("sim: cris: clean up missing
func prototype warnings") as a hack and not a CGEN-generated part.

Those definitions are required by $(builddir)/sim/cris/mloopv{10,32}f.c,
generated from $(srcdir)/sim/cris/mloop.in.  If we define a declaration in
mloop.in, we no longer need manually added one.

This commit adds a template for function declaration so that we no longer
have to touch CGEN-generated code.  With this and the previous commit
"cpu/cris: Add stall unit to CRIS v32", we can now safely regenerate
CRIS CPU declarations with CGEN.
---
 sim/cris/cris-tmpl.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Mike Frysinger Oct. 23, 2022, 2:26 p.m. UTC | #1
On 20 Oct 2022 09:32, Tsukasa OI wrote:
> Declarations for MY (f_specific_init) functions are defined in CGEN-
> generated header files: sim/cris/decodev10.h (crisv10f_specific_init) and
> sim/cris/decodev32.h (crisv32f_specific_init).  However, those declarations
> are manually added by the commit 4e6e8ba7c565 ("sim: cris: clean up missing
> func prototype warnings") as a hack and not a CGEN-generated part.
> 
> Those definitions are required by $(builddir)/sim/cris/mloopv{10,32}f.c,
> generated from $(srcdir)/sim/cris/mloop.in.  If we define a declaration in
> mloop.in, we no longer need manually added one.
> 
> This commit adds a template for function declaration so that we no longer
> have to touch CGEN-generated code.  With this and the previous commit
> "cpu/cris: Add stall unit to CRIS v32", we can now safely regenerate
> CRIS CPU declarations with CGEN.
> ---
>  sim/cris/cris-tmpl.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sim/cris/cris-tmpl.c b/sim/cris/cris-tmpl.c
> index 9f0c06e755e..8694d38b2af 100644
> --- a/sim/cris/cris-tmpl.c
> +++ b/sim/cris/cris-tmpl.c
> @@ -264,6 +264,8 @@ MY (make_thread_cpu_data) (SIM_CPU *current_cpu, void *context)
>  
>  /* Hook function for per-cpu simulator initialization.  */
>  
> +extern void MY (f_specific_init) (SIM_CPU *);
> +
>  void
>  MY (f_specific_init) (SIM_CPU *current_cpu)
>  {

putting the prototype here means function definition & function usage can fall
out of sync and not get any compile error.  that's why it has to be in a header
that both places include.

cris uses cris-sim.h for non-standard funcs like this (e.g. break_handler), so
the specific_init prototypes should be moved there too.
-mike
  

Patch

diff --git a/sim/cris/cris-tmpl.c b/sim/cris/cris-tmpl.c
index 9f0c06e755e..8694d38b2af 100644
--- a/sim/cris/cris-tmpl.c
+++ b/sim/cris/cris-tmpl.c
@@ -264,6 +264,8 @@  MY (make_thread_cpu_data) (SIM_CPU *current_cpu, void *context)
 
 /* Hook function for per-cpu simulator initialization.  */
 
+extern void MY (f_specific_init) (SIM_CPU *);
+
 void
 MY (f_specific_init) (SIM_CPU *current_cpu)
 {