1 # This shell script emits a C file. -*- C -*-
2 # Generate the main loop of the simulator.
3 # Syntax: genmloop.sh mono|multi cpu mainloop.in
4 # FIXME: "multi" support is wip.
11 /* This file is is generated by the genmloop script. DO NOT EDIT! */
13 /* Main loop for CGEN-based simulators.
14 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
15 Contributed by Cygnus Support.
17 This file is part of GDB, the GNU debugger.
19 This program is free software; you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation; either version 2, or (at your option)
24 This program is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 GNU General Public License for more details.
29 You should have received a copy of the GNU General Public License along
30 with this program; if not, write to the Free Software Foundation, Inc.,
31 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
33 /* We want the simcache version of SEM_ARG. */
40 #include "cgen-scache.h"
44 /* Tell sim_main_loop to use the cache if it's active.
45 Collecting profile data and tracing slow us down so we don't do them in
47 There are 2 possibilities on 2 axes:
48 - use or don't use the cache
49 - run normally (full featured) or run fast
50 Supporting all four possibilities in one executable is a bit much but
51 supporting normal/fast seems reasonable.
52 If the cache is configured in it is always used.
53 ??? Need to see whether it speeds up profiling significantly or not.
54 Speeding up tracing doesn't seem worth it.
55 ??? Sometimes supporting more than one set of semantic functions will make
56 the simulator too large - this should be configurable.
60 #define RUN_FAST_P(cpu) (STATE_RUN_FAST_P (CPU_STATE (cpu)))
62 #define RUN_FAST_P(cpu) 0
65 #ifndef SIM_PRE_EXEC_HOOK
66 #define SIM_PRE_EXEC_HOOK(state)
69 #ifndef SIM_POST_EXEC_HOOK
70 #define SIM_POST_EXEC_HOOK(state)
75 ${SHELL} $file support
79 static volatile int keep_running;
82 engine_stop (SIM_DESC sd)
89 engine_run (SIM_DESC sd, int step, int siggnal)
93 if (USING_SCACHE_P (sd))
96 engine_resume (sd, step, siggnal);
100 engine_resume (SIM_DESC sd, int step, int siggnal)
103 /* These are volatile to survive setjmp/longjmp.
104 This will slow down the simulation a teensy bit, but we want to
105 measure simulator speed even in fast mode. */
106 volatile unsigned long insn_count;
107 volatile SIM_ELAPSED_TIME start_time;
109 /* ??? Not sure what to do for K&R C. */
110 static unsigned long insn_count;
111 static SIM_ELAPSED_TIME start_time;
113 SIM_DESC current_state = sd;
114 sim_cpu *current_cpu = STATE_CPU (sd, 0);
117 start_time = sim_elapsed_time_get ();
120 if (setjmp (STATE_HALT_JMP_BUF (sd)))
122 TRACE_INSN_FINI (current_cpu);
123 PROFILE_EXEC_TIME (CPU_PROFILE_DATA (current_cpu))
124 += sim_elapsed_time_since (start_time);
125 PROFILE_TOTAL_INSN_COUNT (CPU_PROFILE_DATA (current_cpu))
132 # Any initialization code before looping starts.
137 /* ??? Restart support to be added in time. */
140 || !RUN_FAST_P (current_cpu))
144 #define FAST 0 /* ??? Hopefully this name won't collide with anything. */
145 /* FIXME: Later check every insn for events and such. */
147 SIM_PRE_EXEC_HOOK (current_cpu);
151 # Copy of main loop that uses the various compiled in features.
152 # FIXME: May want more than one copy of this.
153 ${SHELL} $file normal
157 SIM_POST_EXEC_HOOK (current_cpu);
161 engine_halt (current_cpu, EXEC_STATE_STOPPED, SIM_SIGTRAP);
163 while (keep_running);
164 /* If the loop exists, engine_stop was called. */
165 engine_halt (current_cpu, EXEC_STATE_STOPPED, SIM_SIGINT);
176 # Copy of main loop that is run purely for fast execution.
184 while (keep_running);
185 /* If the loop exists, engine_stop was called. */
186 engine_halt (current_cpu, EXEC_STATE_STOPPED, SIM_SIGINT);
This page took 0.033772 seconds and 5 git commands to generate.