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>
* Makefile.in (SIM_OBJS): Delete sim-reason.o and sim-stop.o.

View File

@ -42,11 +42,6 @@
int debug;
host_callback *sim_callback;
static SIM_OPEN_KIND sim_kind;
static char *myname;
/* FIXME: Needs to live in header file.
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
@ -1769,8 +1764,8 @@ init_pointers (SIM_DESC sd)
/* `msize' must be a power of two. */
if ((memory_size & (memory_size - 1)) != 0)
{
(*sim_callback->printf_filtered)
(sim_callback,
sim_io_printf
(sd,
"init_pointers: bad memory size %d, defaulting to %d.\n",
memory_size, memory_size = H8300S_MSIZE);
}
@ -1830,8 +1825,7 @@ init_pointers (SIM_DESC sd)
}
if (wreg[i] == 0 || wreg[i + 8] == 0)
(*sim_callback->printf_filtered) (sim_callback,
"init_pointers: internal error.\n");
sim_io_printf (sd, "init_pointers: internal error.\n");
h8_set_reg (sd, i, 0);
lreg[i] = h8_get_reg_buf (sd) + i;
@ -1884,6 +1878,7 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
int oldmask;
enum sim_stop reason;
int sigrc;
host_callback *sim_callback = STATE_CALLBACK (sd);
init_pointers (sd);
@ -4337,8 +4332,7 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
}
(*sim_callback->printf_filtered) (sim_callback,
"sim_resume: internal error.\n");
sim_io_printf (sd, "sim_resume: internal error.\n");
sim_engine_set_run_state (sd, sim_stopped, SIGILL);
goto end;
@ -4631,9 +4625,7 @@ sim_store_register (SIM_DESC sd, int rn, unsigned char *value, int length)
h8_set_pc (sd, intval);
break;
default:
(*sim_callback->printf_filtered) (sim_callback,
"sim_store_register: bad regnum %d.\n",
rn);
sim_io_printf (sd, "sim_store_register: bad regnum %d.\n", rn);
case R0_REGNUM:
case R1_REGNUM:
case R2_REGNUM:
@ -4690,9 +4682,7 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *buf, int length)
switch (rn)
{
default:
(*sim_callback->printf_filtered) (sim_callback,
"sim_fetch_register: bad regnum %d.\n",
rn);
sim_io_printf (sd, "sim_fetch_register: bad regnum %d.\n", rn);
v = 0;
break;
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 virttime = h8_get_cycles (sd) / 10.0e6;
(*sim_callback->printf_filtered) (sim_callback,
"\n\n#instructions executed %10d\n",
h8_get_insts (sd));
(*sim_callback->printf_filtered) (sim_callback,
"#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);
sim_io_printf (sd, "\n\n#instructions executed %10d\n", h8_get_insts (sd));
sim_io_printf (sd, "#cycles (v approximate) %10d\n", h8_get_cycles (sd));
sim_io_printf (sd, "#real time taken %10.4f\n", timetaken);
sim_io_printf (sd, "#virtual time taken %10.4f\n", virttime);
if (timetaken != 0.0)
(*sim_callback->printf_filtered) (sim_callback,
"#simulation ratio %10.4f\n",
virttime / timetaken);
(*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);
sim_io_printf (sd, "#simulation ratio %10.4f\n", virttime / timetaken);
sim_io_printf (sd, "#compiles %10d\n", h8_get_compiles (sd));
sim_io_printf (sd, "#cache size %10d\n", sd->sim_cache_size);
#ifdef ADEBUG
/* 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++)
{
if (h8_get_stats (sd, i))
(*sim_callback->printf_filtered) (sim_callback, "%d: %d\n",
i, h8_get_stats (sd, i));
sim_io_printf (sd, "%d: %d\n", i, h8_get_stats (sd, i));
}
}
#endif
@ -4946,9 +4921,6 @@ sim_open (SIM_OPEN_KIND kind,
/* FIXME: Much of the code in sim_load can be moved here. */
sim_kind = kind;
myname = argv[0];
sim_callback = callback;
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. */
if ((memory_size & (memory_size - 1)) != 0)
{
(*sim_callback->printf_filtered) (sim_callback,
"sim_load: bad memory size.\n");
sim_io_printf (sd, "sim_load: bad memory size.\n");
return SIM_RC_FAIL;
}
h8_set_mask (sd, memory_size - 1);
if (sim_load_file (sd, myname, sim_callback, prog, prog_bfd,
sim_kind == SIM_OPEN_DEBUG,
if (sim_load_file (sd, STATE_MY_NAME (sd), STATE_CALLBACK (sd), prog,
prog_bfd, STATE_OPEN_KIND (sd) == SIM_OPEN_DEBUG,
0, sim_write)
== NULL)
{