sim: replace CIA_{GET,SET} with CPU_PC_{GET,SET}

The CIA_{GET,SET} macros serve the same function as CPU_PC_{GET,SET}
except the latter adds a layer of indirection via the sim state.  This
lets models set up different functions at runtime and doesn't reach so
directly into the arch-specific cpu state.

It also doesn't make sense to have two sets of macros that do exactly
the same thing, so lets standardize on the one that gets us more.
This commit is contained in:
Mike Frysinger 2015-04-16 02:11:12 -04:00
parent 27b97b40bc
commit 034685f9ce
64 changed files with 184 additions and 116 deletions

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* wrapper.c (arm_pc_get, arm_pc_set): New functions.

View File

@ -33,9 +33,6 @@ typedef struct _sim_cpu SIM_CPU;
extern struct ARMul_State *state;
#define CIA_GET(cpu) PC
#define CIA_SET(cpu,val) ARMul_SetPC (state, (val))
struct _sim_cpu {
sim_cpu_base base;

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-16 Mike Frysinger <vapier@gentoo.org>
* interp.c (avr_pc_get, avr_pc_set): New functions.

View File

@ -24,9 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
typedef address_word sim_cia;
extern unsigned int pc;
#define CIA_GET(cpu) pc
#define CIA_SET(cpu,val) (pc) = (val)
typedef struct _sim_cpu SIM_CPU;
#include "sim-base.h"

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -26,9 +26,6 @@
typedef unsigned32 sim_cia;
#define CIA_GET(cpu) CPU_PC_GET (cpu)
#define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val))
typedef struct _sim_cpu SIM_CPU;
#include "bfin-sim.h"

View File

@ -1,3 +1,11 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* cgen-utils.c (cgen_rtx_error): Change CIA_GET to CPU_PC_GET.
* sim-core.c (sim_core_read_buffer, sim_core_write_buffer): Likewise.
* sim-engine.h (SIM_ENGINE_HALT_HOOK): Change CIA_SET to CPU_PC_SET.
* sim-run.c (sim_engine_run): Change CIA_GET to CPU_PC_GET and
CIA_SET to CPU_PC_SET.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_NEW_COMMON_OBJS): Add sim-cpu.o.

View File

@ -434,5 +434,5 @@ cgen_rtx_error (SIM_CPU *cpu, const char * msg)
sim_io_printf (sd, msg);
sim_io_printf (sd, "\n");
sim_engine_halt (sd, cpu, NULL, CIA_GET (cpu), sim_stopped, SIM_SIGTRAP);
sim_engine_halt (sd, cpu, NULL, CPU_PC_GET (cpu), sim_stopped, SIM_SIGTRAP);
}

View File

@ -531,7 +531,7 @@ sim_core_read_buffer (SIM_DESC sd,
if (mapping->device != NULL)
{
int nr_bytes = len - count;
sim_cia cia = cpu ? CIA_GET (cpu) : NULL_CIA;
sim_cia cia = cpu ? CPU_PC_GET (cpu) : NULL_CIA;
if (raddr + nr_bytes - 1> mapping->bound)
nr_bytes = mapping->bound - raddr + 1;
if (device_io_read_buffer (mapping->device,
@ -598,7 +598,7 @@ sim_core_write_buffer (SIM_DESC sd,
&& mapping->device != NULL)
{
int nr_bytes = len - count;
sim_cia cia = cpu ? CIA_GET (cpu) : NULL_CIA;
sim_cia cia = cpu ? CPU_PC_GET (cpu) : NULL_CIA;
if (raddr + nr_bytes - 1 > mapping->bound)
nr_bytes = mapping->bound - raddr + 1;
if (device_io_write_buffer (mapping->device,

View File

@ -69,7 +69,7 @@ extern void sim_engine_halt
#if !defined (SIM_ENGINE_HALT_HOOK)
#define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) \
if ((LAST_CPU) != NULL) CIA_SET (LAST_CPU, CIA)
if ((LAST_CPU) != NULL) CPU_PC_SET (LAST_CPU, CIA)
#endif
/* NB: If a port uses the SIM_CPU_EXCEPTION_* hooks, the default

View File

@ -35,7 +35,7 @@ sim_engine_run (SIM_DESC sd,
sim_cpu *cpu;
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
cpu = STATE_CPU (sd, 0);
cia = CIA_GET (cpu);
cia = CPU_PC_GET (cpu);
while (1)
{
instruction_word insn = IMEM32 (cia);
@ -43,7 +43,7 @@ sim_engine_run (SIM_DESC sd,
/* process any events */
if (sim_events_tick (sd))
{
CIA_SET (cpu, cia);
CPU_PC_SET (cpu, cia);
sim_events_process (sd);
}
}

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* interp.c (cr16_pc_get, cr16_pc_set): New functions.

View File

@ -32,9 +32,6 @@ typedef struct _sim_cpu SIM_CPU;
#include "cr16_sim.h"
#define CIA_GET(cpu) PC
#define CIA_SET(cpu,val) SET_PC (val)
struct _sim_cpu {
sim_cpu_base base;

View File

@ -1,3 +1,9 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* crisv10f.c (deliver_interrupt): Change CIA_GET to CPU_PC_GET.
* crisv32f.c (deliver_interrupt): Likewise.
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -86,7 +86,7 @@ MY (deliver_interrupt) (SIM_CPU *current_cpu,
GET_H_SR (H_SR_PRE_V32_IBR) + vec * 4, 4) == 0)
{
/* Nothing to do actually; either abort or send a signal. */
sim_core_signal (sd, current_cpu, CIA_GET (current_cpu), 0, 4,
sim_core_signal (sd, current_cpu, CPU_PC_GET (current_cpu), 0, 4,
GET_H_SR (H_SR_PRE_V32_IBR) + vec * 4,
read_transfer, sim_core_unmapped_signal);
return 0;

View File

@ -615,7 +615,7 @@ MY (deliver_interrupt) (SIM_CPU *current_cpu,
GET_H_SR (H_SR_EBP) + vec * 4, 4) == 0)
{
/* Nothing to do actually; either abort or send a signal. */
sim_core_signal (sd, current_cpu, CIA_GET (current_cpu), 0, 4,
sim_core_signal (sd, current_cpu, CPU_PC_GET (current_cpu), 0, 4,
GET_H_SR (H_SR_EBP) + vec * 4,
read_transfer, sim_core_unmapped_signal);
return 0;

View File

@ -39,9 +39,6 @@ typedef struct _sim_cpu SIM_CPU;
/* These must be defined before sim-base.h. */
typedef USI sim_cia;
#define CIA_GET(cpu) CPU_PC_GET (cpu)
#define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val))
#define SIM_ENGINE_HALT_HOOK(sd, cpu, cia) \
do { \
if (cpu) /* Null if ctrl-c. */ \

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* interp.c (d10v_pc_get, d10v_pc_set): New functions.

View File

@ -32,9 +32,6 @@ typedef struct _sim_cpu SIM_CPU;
#include "d10v_sim.h"
#define CIA_GET(cpu) PC
#define CIA_SET(cpu,val) SET_PC (val)
struct _sim_cpu {
sim_cpu_base base;

View File

@ -1,3 +1,8 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
* traps.c (frv_sim_engine_halt_hook): Change CIA_SET to CPU_PC_SET.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -43,9 +43,6 @@ typedef struct _sim_cpu SIM_CPU;
/* These must be defined before sim-base.h. */
typedef USI sim_cia;
#define CIA_GET(cpu) CPU_PC_GET (cpu)
#define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val))
void frv_sim_engine_halt_hook (SIM_DESC, SIM_CPU *, sim_cia);
#define SIM_ENGINE_HALT_HOOK(SD, LAST_CPU, CIA) \
frv_sim_engine_halt_hook ((SD), (LAST_CPU), (CIA))

View File

@ -65,7 +65,7 @@ frv_sim_engine_halt_hook (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia)
{
int i;
if (current_cpu != NULL)
CIA_SET (current_cpu, cia);
CPU_PC_SET (current_cpu, cia);
/* Invalidate the insn and data caches of all cpus. */
for (i = 0; i < MAX_NR_PROCESSORS; ++i)

View File

@ -1,3 +1,10 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* interp.c (ft32_read_item): Change CIA_GET to CPU_PC_GET.
(ft32_write_item): Likewise.
(step_once): Likewise.
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -110,7 +110,7 @@ static uint32_t
ft32_read_item (SIM_DESC sd, int dw, uint32_t ea)
{
sim_cpu *cpu = STATE_CPU (sd, 0);
address_word cia = CIA_GET (cpu);
address_word cia = CPU_PC_GET (cpu);
uint8_t byte[4];
uint32_t r;
@ -133,7 +133,7 @@ static void
ft32_write_item (SIM_DESC sd, int dw, uint32_t ea, uint32_t v)
{
sim_cpu *cpu = STATE_CPU (sd, 0);
address_word cia = CIA_GET (cpu);
address_word cia = CPU_PC_GET (cpu);
uint8_t byte[4];
ea = ft32_align (dw, ea);
@ -311,7 +311,7 @@ static void
step_once (SIM_DESC sd)
{
sim_cpu *cpu = STATE_CPU (sd, 0);
address_word cia = CIA_GET (cpu);
address_word cia = CPU_PC_GET (cpu);
uint32_t inst;
uint32_t dw;
uint32_t cb;

View File

@ -35,8 +35,6 @@ typedef struct _sim_cpu SIM_CPU;
struct _sim_cpu {
/* The following are internal simulator state variables: */
#define CIA_GET(CPU) ((CPU)->state.pc + 0)
#define CIA_SET(CPU,CIA) ((CPU)->state.pc = (CIA))
struct ft32_cpu_state state;

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* compile.c (h8300_pc_get, h8300_pc_set): New functions.

View File

@ -155,8 +155,6 @@ struct sim_state {
/* The current state of the processor; registers, memory, etc. */
#define CIA_GET(CPU) (cpu_get_pc (CPU))
#define CIA_SET(CPU, VAL) (cpu_set_pc ((CPU), (VAL)))
#define cpu_set_pc(CPU, VAL) (((CPU)->pc) = (VAL))
#define cpu_get_pc(CPU) (((CPU)->pc))

View File

@ -1,3 +1,8 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* gen-engine.c (print_run_body): Change CIA_GET to CPU_PC_GET and
CIA_SET to CPU_PC_SET.
2015-03-31 Mike Frysinger <vapier@gentoo.org>
* configure: Regenerate.

View File

@ -116,7 +116,7 @@ cache. */\n\
lf_putstr (file, "/* prime the main loop */\n");
lf_putstr (file, "SIM_ASSERT (current_cpu == 0);\n");
lf_putstr (file, "SIM_ASSERT (nr_cpus == 1);\n");
lf_putstr (file, "cia = CIA_GET (CPU);\n");
lf_putstr (file, "cia = CPU_PC_GET (CPU);\n");
lf_putstr (file, "\n");
lf_putstr (file, "while (1)\n");
@ -202,9 +202,9 @@ cache. */\n\
lf_putstr (file, "/* process any events */\n");
lf_putstr (file, "if (sim_events_tick (sd))\n");
lf_putstr (file, " {\n");
lf_putstr (file, " CIA_SET (CPU, cia);\n");
lf_putstr (file, " CPU_PC_SET (CPU, cia);\n");
lf_putstr (file, " sim_events_process (sd);\n");
lf_putstr (file, " cia = CIA_GET (CPU);\n");
lf_putstr (file, " cia = CPU_PC_GET (CPU);\n");
lf_putstr (file, " }\n");
lf_indent (file, -4);
@ -236,7 +236,7 @@ after all the other CPU's and the event queue have been processed */\n\
lf_putstr (file, " {\n");
lf_indent (file, +4);
lf_putstr (file, "sim_cpu *cpu = STATE_CPU (sd, current_cpu);\n");
lf_putstr (file, "instruction_address cia = CIA_GET (cpu);\n");
lf_putstr (file, "instruction_address cia = CPU_PC_GET (cpu);\n");
lf_putstr (file, "\n");
if (!options.gen.icache)
@ -245,7 +245,7 @@ after all the other CPU's and the event queue have been processed */\n\
options.insn_bit_size);
print_engine_issue_prefix_hook (file);
print_idecode_body (file, table, "cia =");
lf_putstr (file, "CIA_SET (cpu, cia);\n");
lf_putstr (file, "CPU_PC_SET (cpu, cia);\n");
print_engine_issue_postfix_hook (file);
}

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -26,9 +26,6 @@ typedef struct _sim_cpu SIM_CPU;
/* These must be defined before sim-base.h. */
typedef USI sim_cia;
#define CIA_GET(cpu) CPU_PC_GET (cpu)
#define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val))
#include "sim-base.h"
#include "cgen-sim.h"
#include "iq2000-sim.h"

View File

@ -1,3 +1,11 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* dv-lm32cpu.c (deliver_lm32cpu_interrupt): Change CIA_GET to
CPU_PC_GET.
(lm32cpu_port_event): Likewise.
* sim-main.h (CIA_GET, CIA_SET): Delete.
* traps.c (lm32_core_signal): Change CIA_SET to CPU_PC_SET.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -137,7 +137,7 @@ deliver_lm32cpu_interrupt (struct hw *me, void *data)
struct lm32cpu *controller = hw_data (me);
SIM_DESC sd = hw_system (me);
sim_cpu *cpu = STATE_CPU (sd, 0); /* NB: fix CPU 0. */
address_word cia = CIA_GET (cpu);
address_word cia = CPU_PC_GET (cpu);
int interrupt = (int) data;
@ -192,7 +192,7 @@ lm32cpu_port_event (struct hw *me,
struct lm32cpu *controller = hw_data (me);
SIM_DESC sd = hw_system (me);
sim_cpu *cpu = STATE_CPU (sd, 0); /* NB: fix CPU 0. */
address_word cia = CIA_GET (cpu);
address_word cia = CPU_PC_GET (cpu);
HW_TRACE ((me, "interrupt event on port %d, level %d", my_port, level));

View File

@ -38,9 +38,6 @@ typedef struct _sim_cpu SIM_CPU;
/* These must be defined before sim-base.h. */
typedef USI sim_cia;
#define CIA_GET(cpu) CPU_PC_GET (cpu)
#define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val))
#define SIM_ENGINE_HALT_HOOK(sd, cpu, cia) \
do { \
if (cpu) /* null if ctrl-c */ \

View File

@ -245,7 +245,7 @@ lm32_core_signal (SIM_DESC sd,
SET_H_GR (30, ip);
/* Save and clear interrupt enable. */
SET_H_CSR (LM32_CSR_IE, (GET_H_CSR (LM32_CSR_IE) & 1) << 1);
CIA_SET (cpu, GET_H_CSR (LM32_CSR_EBA) + LM32_EID_DATA_BUS_ERROR * 32);
CPU_PC_SET (cpu, GET_H_CSR (LM32_CSR_EBA) + LM32_EID_DATA_BUS_ERROR * 32);
sim_engine_halt (sd, cpu, NULL, LM32_EID_DATA_BUS_ERROR * 32,
sim_stopped, SIM_SIGSEGV);
break;
@ -257,7 +257,7 @@ lm32_core_signal (SIM_DESC sd,
SET_H_GR (30, ip);
/* Save and clear interrupt enable. */
SET_H_CSR (LM32_CSR_IE, (GET_H_CSR (LM32_CSR_IE) & 1) << 1);
CIA_SET (cpu, GET_H_CSR (LM32_CSR_EBA) + LM32_EID_DATA_BUS_ERROR * 32);
CPU_PC_SET (cpu, GET_H_CSR (LM32_CSR_EBA) + LM32_EID_DATA_BUS_ERROR * 32);
sim_engine_halt (sd, cpu, NULL, LM32_EID_DATA_BUS_ERROR * 32,
sim_stopped, SIM_SIGBUS);
break;

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -18,9 +18,6 @@ typedef struct _sim_cpu SIM_CPU;
/* These must be defined before sim-base.h. */
typedef USI sim_cia;
#define CIA_GET(cpu) CPU_PC_GET (cpu)
#define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val))
#define SIM_ENGINE_HALT_HOOK(sd, cpu, cia) \
do { \
if (cpu) /* null if ctrl-c */ \

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -574,9 +574,6 @@ extern void m68hc11cpu_set_port (struct hw *me, sim_cpu *cpu,
/* The current state of the processor; registers, memory, etc. */
#define CIA_GET(CPU) (cpu_get_pc (CPU))
#define CIA_SET(CPU,VAL) (cpu_set_pc ((CPU), (VAL)))
struct sim_state {
sim_cpu *cpu[MAX_NR_PROCESSORS];
device *devices;

View File

@ -1,3 +1,11 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* interp.c (set_initial_gprs): Change CIA_SET to CPU_PC_SET.
(sim_resume): Change CIA_GET to CPU_PC_GET and CIA_SET to
CPU_PC_SET.
(sim_create_inferior): Change CIA_SET to CPU_PC_SET.
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-16 Mike Frysinger <vapier@gentoo.org>
* interp.c (mcore_pc_get, mcore_pc_set): New functions.

View File

@ -397,7 +397,7 @@ set_initial_gprs (SIM_CPU *scpu)
init_pointers ();
/* Set up machine just out of reset. */
CIA_SET (scpu, 0);
CPU_PC_SET (scpu, 0);
cpu.sr = 0;
memsize = cpu.asregs.msize / (1024 * 1024);
@ -716,7 +716,7 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
word WLhash;
cpu.asregs.exception = step ? SIGTRAP: 0;
pc = CIA_GET (scpu);
pc = CPU_PC_GET (scpu);
/* Fetch the initial instructions that we'll decode. */
ibuf = rlat (pc & 0xFFFFFFFC);
@ -1648,7 +1648,7 @@ sim_resume (SIM_DESC sd, int step, int siggnal)
while (!cpu.asregs.exception);
/* Hide away the things we've cached while executing. */
CIA_SET (scpu, pc);
CPU_PC_SET (scpu, pc);
cpu.asregs.insts += insts; /* instructions done ... */
cpu.asregs.cycles += insts; /* and each takes a cycle */
cpu.asregs.cycles += bonus_cycles; /* and extra cycles for branches */
@ -1905,7 +1905,7 @@ sim_create_inferior (SIM_DESC sd, struct bfd *prog_bfd, char **argv, char **env)
issue_messages = l;
hi_stack = cpu.asregs.msize - 4;
CIA_SET (scpu, bfd_get_start_address (prog_bfd));
CPU_PC_SET (scpu, bfd_get_start_address (prog_bfd));
/* Calculate the argument and environment strings. */
s_length = 0;

View File

@ -30,9 +30,6 @@ typedef struct _sim_cpu SIM_CPU;
#include "sim-base.h"
#include "bfd.h"
#define CIA_GET(cpu) (cpu)->pc
#define CIA_SET(cpu,val) (cpu)->pc = (val)
struct _sim_cpu {
word pc;

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* interp.c (microblaze_pc_get, microblaze_pc_set): New functions.

View File

@ -23,9 +23,6 @@
typedef address_word sim_cia;
#define CIA_GET(cpu) (cpu)->microblaze_cpu.spregs[0]
#define CIA_SET(cpu,val) (cpu)->microblaze_cpu.spregs[0] = (val)
typedef struct _sim_cpu SIM_CPU;
#include "sim-base.h"

View File

@ -1,3 +1,13 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* dv-tx3904cpu.c (deliver_tx3904cpu_interrupt): Change CIA_GET to
PU_PC_GET.
* interp.c (interrupt_event): Change CIA_GET to CPU_PC_GET.
(sim_create_inferior): Change CIA_SET to CPU_PC_SET.
* m16run.c (sim_engine_run): Change CIA_GET to CPU_PC_GET and
CIA_SET to CPU_PC_SET.
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -141,7 +141,7 @@ deliver_tx3904cpu_interrupt (struct hw *me,
struct tx3904cpu *controller = hw_data (me);
SIM_DESC sd = hw_system (me);
sim_cpu *cpu = STATE_CPU (sd, 0); /* NB: fix CPU 0. */
address_word cia = CIA_GET (cpu);
address_word cia = CPU_PC_GET (cpu);
#define CPU cpu
#define SD current_state
@ -149,20 +149,20 @@ deliver_tx3904cpu_interrupt (struct hw *me,
if (controller->pending_reset)
{
controller->pending_reset = 0;
HW_TRACE ((me, "reset pc=0x%08lx", (long) CIA_GET (cpu)));
HW_TRACE ((me, "reset pc=0x%08lx", (long) CPU_PC_GET (cpu)));
SignalExceptionNMIReset();
}
else if (controller->pending_nmi)
{
controller->pending_nmi = 0;
HW_TRACE ((me, "nmi pc=0x%08lx", (long) CIA_GET (cpu)));
HW_TRACE ((me, "nmi pc=0x%08lx", (long) CPU_PC_GET (cpu)));
SignalExceptionNMIReset();
}
else if (controller->pending_level)
{
HW_TRACE ((me, "interrupt level=%d pc=0x%08lx sr=0x%08lx",
controller->pending_level,
(long) CIA_GET (cpu), (long) SR));
(long) CPU_PC_GET (cpu), (long) SR));
/* Clear CAUSE register. It may stay this way if the interrupt
was cleared with a negative pending_level. */

View File

@ -311,7 +311,7 @@ void
interrupt_event (SIM_DESC sd, void *data)
{
sim_cpu *cpu = STATE_CPU (sd, 0); /* FIXME */
address_word cia = CIA_GET (cpu);
address_word cia = CPU_PC_GET (cpu);
if (SR & status_IE)
{
interrupt_pending = 0;
@ -1112,7 +1112,7 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char **argv, char **env)
for (cpu_nr = 0; cpu_nr < sim_engine_nr_cpus (sd); cpu_nr++)
{
sim_cpu *cpu = STATE_CPU (sd, cpu_nr);
CIA_SET (cpu, (unsigned64) bfd_get_start_address (abfd));
CPU_PC_SET (cpu, (unsigned64) bfd_get_start_address (abfd));
}
}

View File

@ -33,7 +33,7 @@ sim_engine_run (SIM_DESC sd,
int siggnal) /* ignore */
{
sim_cpu *cpu = STATE_CPU (sd, next_cpu_nr);
address_word cia = CIA_GET (cpu);
address_word cia = CPU_PC_GET (cpu);
while (1)
{
@ -64,9 +64,9 @@ sim_engine_run (SIM_DESC sd,
/* process any events */
if (sim_events_tick (sd))
{
CIA_SET (CPU, cia);
CPU_PC_SET (CPU, cia);
sim_events_process (sd);
cia = CIA_GET (CPU);
cia = CPU_PC_GET (CPU);
}
}

View File

@ -257,8 +257,6 @@ struct _sim_cpu {
/* The following are internal simulator state variables: */
#define CIA_GET(CPU) ((CPU)->registers[PCIDX] + 0)
#define CIA_SET(CPU,CIA) ((CPU)->registers[PCIDX] = (CIA))
address_word dspc; /* delay-slot PC */
#define DSPC ((CPU)->dspc)

View File

@ -1,3 +1,15 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* dv-mn103cpu.c (deliver_mn103cpu_interrupt): Change CIA_GET to
CPU_PC_GET and CIA_SET to CPU_PC_SET.
* interp.c (sim_create_inferior): Change CIA_SET to CPU_PC_SET.
(program_interrupt): Change CIA_GET to CPU_PC_GET and CIA_SET to
CPU_PC_SET.
(mn10300_cpu_exception_trigger): Change CIA_SET to CPU_PC_SET.
(mn10300_cpu_exception_suspend): Likewise.
(mn10300_cpu_exception_resume): Likewise.
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (MN10300_OBJS): Delete sim-cpu.o.

View File

@ -227,31 +227,31 @@ deliver_mn103cpu_interrupt (struct hw *me,
else if (controller->pending_nmi)
{
controller->pending_nmi = 0;
store_word (SP - 4, CIA_GET (cpu));
store_word (SP - 4, CPU_PC_GET (cpu));
store_half (SP - 8, PSW);
PSW &= ~PSW_IE;
SP = SP - 8;
CIA_SET (cpu, 0x40000008);
CPU_PC_SET (cpu, 0x40000008);
HW_TRACE ((me, "nmi pc=0x%08lx psw=0x%04x sp=0x%08lx",
(long) CIA_GET (cpu), (unsigned) PSW, (long) SP));
(long) CPU_PC_GET (cpu), (unsigned) PSW, (long) SP));
}
else if ((controller->pending_level < EXTRACT_PSW_LM)
&& (PSW & PSW_IE))
{
/* Don't clear pending level. Request continues to be pending
until the interrupt controller clears/changes it */
store_word (SP - 4, CIA_GET (cpu));
store_word (SP - 4, CPU_PC_GET (cpu));
store_half (SP - 8, PSW);
PSW &= ~PSW_IE;
PSW &= ~PSW_LM;
PSW |= INSERT_PSW_LM (controller->pending_level);
SP = SP - 8;
CIA_SET (cpu, 0x40000000 + controller->interrupt_vector[controller->pending_level]);
CPU_PC_SET (cpu, 0x40000000 + controller->interrupt_vector[controller->pending_level]);
HW_TRACE ((me, "port-out ack %d", controller->pending_level));
hw_port_event (me, ACK_PORT, controller->pending_level);
HW_TRACE ((me, "int level=%d pc=0x%08lx psw=0x%04x sp=0x%08lx",
controller->pending_level,
(long) CIA_GET (cpu), (unsigned) PSW, (long) SP));
(long) CPU_PC_GET (cpu), (unsigned) PSW, (long) SP));
}
if (controller->pending_level < 7) /* FIXME */

View File

@ -346,7 +346,7 @@ sim_create_inferior (SIM_DESC sd,
} else {
PC = 0;
}
CIA_SET (STATE_CPU (sd, 0), (unsigned64) PC);
CPU_PC_SET (STATE_CPU (sd, 0), (unsigned64) PC);
if (STATE_ARCHITECTURE (sd)->mach == bfd_mach_am33_2)
PSW |= PSW_FE;
@ -482,7 +482,7 @@ program_interrupt (SIM_DESC sd,
{
in_interrupt = 1;
/* copy NMI handler code from dv-mn103cpu.c */
store_word (SP - 4, CIA_GET (cpu));
store_word (SP - 4, CPU_PC_GET (cpu));
store_half (SP - 8, PSW);
/* Set the SYSEF flag in NMICR by backdoor method. See
@ -496,7 +496,7 @@ program_interrupt (SIM_DESC sd,
PSW &= ~PSW_IE;
SP = SP - 8;
CIA_SET (cpu, 0x40000008);
CPU_PC_SET (cpu, 0x40000008);
in_interrupt = 0;
sim_engine_halt(sd, cpu, NULL, cia, sim_stopped, sig);
@ -511,7 +511,7 @@ mn10300_cpu_exception_trigger(SIM_DESC sd, sim_cpu* cpu, address_word cia)
if(State.exc_suspended > 0)
sim_io_eprintf(sd, "Warning, nested exception triggered (%d)\n", State.exc_suspended);
CIA_SET (cpu, cia);
CPU_PC_SET (cpu, cia);
memcpy(State.exc_trigger_regs, State.regs, sizeof(State.exc_trigger_regs));
State.exc_suspended = 0;
}
@ -527,7 +527,7 @@ mn10300_cpu_exception_suspend(SIM_DESC sd, sim_cpu* cpu, int exception)
memcpy(State.exc_suspend_regs, State.regs, sizeof(State.exc_suspend_regs));
memcpy(State.regs, State.exc_trigger_regs, sizeof(State.regs));
CIA_SET (cpu, PC); /* copy PC back from new State.regs */
CPU_PC_SET (cpu, PC); /* copy PC back from new State.regs */
State.exc_suspended = exception;
}
@ -549,7 +549,7 @@ mn10300_cpu_exception_resume(SIM_DESC sd, sim_cpu* cpu, int exception)
State.exc_suspended, exception);
memcpy(State.regs, State.exc_suspend_regs, sizeof(State.regs));
CIA_SET (cpu, PC); /* copy PC back from new State.regs */
CPU_PC_SET (cpu, PC); /* copy PC back from new State.regs */
}
else if(exception != 0 && State.exc_suspended == 0)
{

View File

@ -71,9 +71,6 @@ mn10300_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), (TRANSFER),
/* FIXME: For moment, save/restore PC value found in struct State.
Struct State will one day go away, being placed in the sim_cpu
state. */
#define CIA_GET(CPU) ((PC) + 0)
#define CIA_SET(CPU,VAL) ((CPU)->cia = (VAL), PC = (VAL))
struct _sim_cpu {
sim_event *pending_nmi;

View File

@ -1,3 +1,9 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* interp.c (wbat, wsat, wlat, rsat, rbat, rlat, sim_engine_run):
Change CIA_GET to CPU_PC_GET.
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-16 Mike Frysinger <vapier@gentoo.org>
* interp.c (moxie_pc_get, moxie_pc_set): New functions.

View File

@ -151,7 +151,7 @@ set_initial_gprs (void)
static INLINE void
wbat (sim_cpu *scpu, word pc, word x, word v)
{
address_word cia = CIA_GET (scpu);
address_word cia = CPU_PC_GET (scpu);
sim_core_write_aligned_1 (scpu, cia, write_map, x, v);
}
@ -161,7 +161,7 @@ wbat (sim_cpu *scpu, word pc, word x, word v)
static INLINE void
wsat (sim_cpu *scpu, word pc, word x, word v)
{
address_word cia = CIA_GET (scpu);
address_word cia = CPU_PC_GET (scpu);
sim_core_write_aligned_2 (scpu, cia, write_map, x, v);
}
@ -171,7 +171,7 @@ wsat (sim_cpu *scpu, word pc, word x, word v)
static INLINE void
wlat (sim_cpu *scpu, word pc, word x, word v)
{
address_word cia = CIA_GET (scpu);
address_word cia = CPU_PC_GET (scpu);
sim_core_write_aligned_4 (scpu, cia, write_map, x, v);
}
@ -181,7 +181,7 @@ wlat (sim_cpu *scpu, word pc, word x, word v)
static INLINE int
rsat (sim_cpu *scpu, word pc, word x)
{
address_word cia = CIA_GET (scpu);
address_word cia = CPU_PC_GET (scpu);
return (sim_core_read_aligned_2 (scpu, cia, read_map, x));
}
@ -191,7 +191,7 @@ rsat (sim_cpu *scpu, word pc, word x)
static INLINE int
rbat (sim_cpu *scpu, word pc, word x)
{
address_word cia = CIA_GET (scpu);
address_word cia = CPU_PC_GET (scpu);
return (sim_core_read_aligned_1 (scpu, cia, read_map, x));
}
@ -201,7 +201,7 @@ rbat (sim_cpu *scpu, word pc, word x)
static INLINE int
rlat (sim_cpu *scpu, word pc, word x)
{
address_word cia = CIA_GET (scpu);
address_word cia = CPU_PC_GET (scpu);
return (sim_core_read_aligned_4 (scpu, cia, read_map, x));
}
@ -243,7 +243,7 @@ sim_engine_run (SIM_DESC sd,
word pc, opc;
unsigned short inst;
sim_cpu *scpu = STATE_CPU (sd, 0); /* FIXME */
address_word cia = CIA_GET (scpu);
address_word cia = CPU_PC_GET (scpu);
pc = cpu.asregs.regs[PC_REGNO];

View File

@ -34,8 +34,6 @@ typedef struct _sim_cpu SIM_CPU;
struct _sim_cpu {
/* The following are internal simulator state variables: */
#define CIA_GET(CPU) ((CPU)->registers[PCIDX] + 0)
#define CIA_SET(CPU,CIA) ((CPU)->registers[PCIDX] = (CIA))
/* To keep this default simulator simple, and fast, we use a direct
vector of registers. The internal simulator engine then uses
@ -54,4 +52,3 @@ struct sim_state {
};
#endif

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -54,9 +54,6 @@ struct sim_state
#define MSP430_CPU(sd) (STATE_CPU ((sd), 0))
#define MSP430_CPU_STATE(sd) (MSP430_CPU ((sd)->state))
#define CIA_GET(CPU) ((CPU)->state.regs[0] + 0)
#define CIA_SET(CPU,VAL) ((CPU)->state.regs[0] = (VAL))
#include "sim-config.h"
#include "sim-types.h"
#include "sim-engine.h"

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* interp.c (sh_pc_get, sh_pc_set): New functions.

View File

@ -23,9 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
typedef address_word sim_cia;
#define CIA_GET(cpu) saved_state.asregs.pc
#define CIA_SET(cpu,val) saved_state.asregs.pc = (val)
typedef struct _sim_cpu SIM_CPU;
#include "sim-base.h"

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -22,9 +22,6 @@ typedef struct _sim_cpu SIM_CPU;
/* These must be defined before sim-base.h. */
typedef UDI sim_cia;
#define CIA_GET(cpu) CPU_PC_GET (cpu)
#define CIA_SET(cpu,val) CPU_PC_SET ((cpu), (val) | (sh64_h_ism_get (cpu)))
#include "sim-base.h"
#include "cgen-sim.h"
#include "sh64-sim.h"

View File

@ -1,3 +1,7 @@
2015-04-17 Mike Frysinger <vapier@gentoo.org>
* sim-main.h (CIA_GET, CIA_SET): Delete.
2015-04-15 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-cpu.o.

View File

@ -61,9 +61,6 @@ struct _sim_cpu
sim_cpu_base base;
};
#define CIA_GET(CPU) ((CPU)->reg.pc + 0)
#define CIA_SET(CPU,VAL) ((CPU)->reg.pc = (VAL))
struct sim_state {
sim_cpu *cpu[MAX_NR_PROCESSORS];
#if 0