sim: h8300: delete global callback/kind/name

We can use the sim state everywhere now to get these values on the fly.
This commit is contained in:
Mike Frysinger 2015-11-20 20:49:35 -08:00
parent d320201dbe
commit c1fc4b4d17
2 changed files with 27 additions and 47 deletions

View File

@ -1,3 +1,12 @@
2015-11-21 Mike Frysinger <vapier@gentoo.org>
* compile.c (sim_callback, sim_kind, myname): Delete.
(init_pointers, sim_store_register, sim_fetch_register, sim_info):
Change sim_callback->printf_filtered calls to sim_io_printf.
(sim_resume): Likewise. Declare sim_callback.
(sim_open): Delete sim_callback, sim_kind, and myname assignment.
(sim_load); Use sd to look up myname, sim_callback, and sim_kind.
2015-11-15 Mike Frysinger <vapier@gentoo.org> 2015-11-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-reason.o and sim-stop.o. * Makefile.in (SIM_OBJS): Delete sim-reason.o and sim-stop.o.

View File

@ -42,11 +42,6 @@
int debug; int debug;
host_callback *sim_callback;
static SIM_OPEN_KIND sim_kind;
static char *myname;
/* FIXME: Needs to live in header file. /* FIXME: Needs to live in header file.
This header should also include the things in remote-sim.h. This header should also include the things in remote-sim.h.
One could move this to remote-sim.h but this function isn't needed One could move this to remote-sim.h but this function isn't needed
@ -1769,8 +1764,8 @@ init_pointers (SIM_DESC sd)
/* `msize' must be a power of two. */ /* `msize' must be a power of two. */
if ((memory_size & (memory_size - 1)) != 0) if ((memory_size & (memory_size - 1)) != 0)
{ {
(*sim_callback->printf_filtered) sim_io_printf
(sim_callback, (sd,
"init_pointers: bad memory size %d, defaulting to %d.\n", "init_pointers: bad memory size %d, defaulting to %d.\n",
memory_size, memory_size = H8300S_MSIZE); memory_size, memory_size = H8300S_MSIZE);
} }
@ -1830,8 +1825,7 @@ init_pointers (SIM_DESC sd)
} }
if (wreg[i] == 0 || wreg[i + 8] == 0) if (wreg[i] == 0 || wreg[i + 8] == 0)
(*sim_callback->printf_filtered) (sim_callback, sim_io_printf (sd, "init_pointers: internal error.\n");
"init_pointers: internal error.\n");
h8_set_reg (sd, i, 0); h8_set_reg (sd, i, 0);
lreg[i] = h8_get_reg_buf (sd) + i; lreg[i] = h8_get_reg_buf (sd) + i;
@ -1884,6 +1878,7 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
int oldmask; int oldmask;
enum sim_stop reason; enum sim_stop reason;
int sigrc; int sigrc;
host_callback *sim_callback = STATE_CALLBACK (sd);
init_pointers (sd); init_pointers (sd);
@ -4337,8 +4332,7 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
} }
(*sim_callback->printf_filtered) (sim_callback, sim_io_printf (sd, "sim_resume: internal error.\n");
"sim_resume: internal error.\n");
sim_engine_set_run_state (sd, sim_stopped, SIGILL); sim_engine_set_run_state (sd, sim_stopped, SIGILL);
goto end; goto end;
@ -4631,9 +4625,7 @@ sim_store_register (SIM_DESC sd, int rn, unsigned char *value, int length)
h8_set_pc (sd, intval); h8_set_pc (sd, intval);
break; break;
default: default:
(*sim_callback->printf_filtered) (sim_callback, sim_io_printf (sd, "sim_store_register: bad regnum %d.\n", rn);
"sim_store_register: bad regnum %d.\n",
rn);
case R0_REGNUM: case R0_REGNUM:
case R1_REGNUM: case R1_REGNUM:
case R2_REGNUM: case R2_REGNUM:
@ -4690,9 +4682,7 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *buf, int length)
switch (rn) switch (rn)
{ {
default: default:
(*sim_callback->printf_filtered) (sim_callback, sim_io_printf (sd, "sim_fetch_register: bad regnum %d.\n", rn);
"sim_fetch_register: bad regnum %d.\n",
rn);
v = 0; v = 0;
break; break;
case CCR_REGNUM: case CCR_REGNUM:
@ -4774,28 +4764,14 @@ sim_info (SIM_DESC sd, int verbose)
double timetaken = (double) h8_get_ticks (sd) / (double) now_persec (); double timetaken = (double) h8_get_ticks (sd) / (double) now_persec ();
double virttime = h8_get_cycles (sd) / 10.0e6; double virttime = h8_get_cycles (sd) / 10.0e6;
(*sim_callback->printf_filtered) (sim_callback, sim_io_printf (sd, "\n\n#instructions executed %10d\n", h8_get_insts (sd));
"\n\n#instructions executed %10d\n", sim_io_printf (sd, "#cycles (v approximate) %10d\n", h8_get_cycles (sd));
h8_get_insts (sd)); sim_io_printf (sd, "#real time taken %10.4f\n", timetaken);
(*sim_callback->printf_filtered) (sim_callback, sim_io_printf (sd, "#virtual time taken %10.4f\n", virttime);
"#cycles (v approximate) %10d\n",
h8_get_cycles (sd));
(*sim_callback->printf_filtered) (sim_callback,
"#real time taken %10.4f\n",
timetaken);
(*sim_callback->printf_filtered) (sim_callback,
"#virtual time taken %10.4f\n",
virttime);
if (timetaken != 0.0) if (timetaken != 0.0)
(*sim_callback->printf_filtered) (sim_callback, sim_io_printf (sd, "#simulation ratio %10.4f\n", virttime / timetaken);
"#simulation ratio %10.4f\n", sim_io_printf (sd, "#compiles %10d\n", h8_get_compiles (sd));
virttime / timetaken); sim_io_printf (sd, "#cache size %10d\n", sd->sim_cache_size);
(*sim_callback->printf_filtered) (sim_callback,
"#compiles %10d\n",
h8_get_compiles (sd));
(*sim_callback->printf_filtered) (sim_callback,
"#cache size %10d\n",
sd->sim_cache_size);
#ifdef ADEBUG #ifdef ADEBUG
/* This to be conditional on `what' (aka `verbose'), /* This to be conditional on `what' (aka `verbose'),
@ -4806,8 +4782,7 @@ sim_info (SIM_DESC sd, int verbose)
for (i = 0; i < O_LAST; i++) for (i = 0; i < O_LAST; i++)
{ {
if (h8_get_stats (sd, i)) if (h8_get_stats (sd, i))
(*sim_callback->printf_filtered) (sim_callback, "%d: %d\n", sim_io_printf (sd, "%d: %d\n", i, h8_get_stats (sd, i));
i, h8_get_stats (sd, i));
} }
} }
#endif #endif
@ -4946,9 +4921,6 @@ sim_open (SIM_OPEN_KIND kind,
/* FIXME: Much of the code in sim_load can be moved here. */ /* FIXME: Much of the code in sim_load can be moved here. */
sim_kind = kind;
myname = argv[0];
sim_callback = callback;
return sd; return sd;
} }
@ -5018,14 +4990,13 @@ sim_load (SIM_DESC sd, const char *prog, bfd *abfd, int from_tty)
/* `msize' must be a power of two. */ /* `msize' must be a power of two. */
if ((memory_size & (memory_size - 1)) != 0) if ((memory_size & (memory_size - 1)) != 0)
{ {
(*sim_callback->printf_filtered) (sim_callback, sim_io_printf (sd, "sim_load: bad memory size.\n");
"sim_load: bad memory size.\n");
return SIM_RC_FAIL; return SIM_RC_FAIL;
} }
h8_set_mask (sd, memory_size - 1); h8_set_mask (sd, memory_size - 1);
if (sim_load_file (sd, myname, sim_callback, prog, prog_bfd, if (sim_load_file (sd, STATE_MY_NAME (sd), STATE_CALLBACK (sd), prog,
sim_kind == SIM_OPEN_DEBUG, prog_bfd, STATE_OPEN_KIND (sd) == SIM_OPEN_DEBUG,
0, sim_write) 0, sim_write)
== NULL) == NULL)
{ {