1 # Simulator main loop for m32r. -*- C -*-
2 # Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 # This file is part of the GNU Simulators.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 # /bin/sh mainloop.in init|support|{full,fast}-{extract,exec}-{scache,noscache}
23 # ??? After a few more ports are done, revisit.
24 # Will eventually need to machine generate a lot of this.
33 extract16 (SIM_CPU *current_cpu, PCADDR pc, insn_t insn,
34 SCACHE *sc, int fast_p)
36 const IDESC *d = @cpu@_decode (current_cpu, pc, insn);
37 (*d->extract) (current_cpu, pc, insn, &sc->argbuf);
40 #if WITH_SEM_SWITCH_FAST
42 sc->semantic.sem_case = d->sem_fast_lab;
44 sc->semantic.sem_case = d->num;
47 sc->semantic.sem_fast = d->sem_fast;
52 sc->semantic.sem_full = d->sem_full;
59 extract32 (SIM_CPU *current_cpu, PCADDR pc, insn_t insn,
60 SCACHE *sc, int fast_p)
62 const IDESC *d = @cpu@_decode (current_cpu, pc, (USI) insn >> 16);
63 (*d->extract) (current_cpu, pc, insn, &sc->argbuf);
66 #if WITH_SEM_SWITCH_FAST
68 sc->semantic.sem_case = d->sem_fast_lab;
70 sc->semantic.sem_case = d->num;
73 sc->semantic.sem_fast_fn = d->sem_fast;
78 sc->semantic.sem_full = d->sem_full;
85 execute (SIM_CPU *current_cpu, SCACHE *sc, int fast_p)
91 #if WITH_SCACHE && ! WITH_SEM_SWITCH_FAST
92 pc = (*sc->semantic.sem_fast) (current_cpu, sc);
95 pc = (*sc->semantic.sem_full) (current_cpu, &sc->argbuf);
97 pc = (*sc->semantic.sem_full) (current_cpu, sc);
103 m32r_model_init_insn_cycles (current_cpu, 1);
104 TRACE_INSN_INIT (current_cpu, 1);
105 TRACE_INSN (current_cpu, sc->argbuf.idesc->opcode, (const struct argbuf *) &sc->argbuf, sc->argbuf.addr);
107 pc = (*sc->semantic.sem_full) (current_cpu, &sc->argbuf);
109 pc = (*sc->semantic.sem_full) (current_cpu, sc);
111 m32r_model_update_insn_cycles (current_cpu, 1);
112 TRACE_INSN_FINI (current_cpu, 1);
130 xfull-extract-* | xfast-extract-*)
134 PCADDR pc = CPU (h_pc);
138 /* This only occurs when single stepping.
139 The test is unnecessary otherwise, but the cost is teensy,
140 compared with decoding/extraction. */
141 UHI insn = GETIMEMUHI (current_cpu, pc);
142 extract16 (current_cpu, pc, insn & 0x7fff, sc, FAST_P);
146 USI insn = GETIMEMUSI (current_cpu, pc);
149 extract32 (current_cpu, pc, insn, sc, FAST_P);
153 extract16 (current_cpu, pc, insn >> 16, sc, FAST_P);
154 extract16 (current_cpu, pc + 2, insn & 0x7fff, sc + 1, FAST_P);
155 /* The m32r doesn't support parallel execution. */
156 if ((insn & 0x8000) != 0
157 && (insn & 0x7fff) != 0x7000) /* parallel nops are ok */
158 sim_engine_illegal_insn (current_cpu, pc);
166 xfull-exec-* | xfast-exec-*)
170 #if WITH_SCACHE && FAST_P && WITH_SEM_SWITCH_FAST
171 #define DEFINE_SWITCH
172 #include "sem-switch.c"
174 PCADDR new_pc = execute (current_cpu, sc, FAST_P);
183 echo "Invalid argument to mainloop.in: $1" >&2