1 |
1181 |
sfurman |
# OBSOLETE # Simulator main loop for fr30. -*- C -*-
|
2 |
|
|
# OBSOLETE # Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
3 |
|
|
# OBSOLETE # Contributed by Cygnus Solutions.
|
4 |
|
|
# OBSOLETE #
|
5 |
|
|
# OBSOLETE # This file is part of the GNU Simulators.
|
6 |
|
|
# OBSOLETE #
|
7 |
|
|
# OBSOLETE # This program is free software; you can redistribute it and/or modify
|
8 |
|
|
# OBSOLETE # it under the terms of the GNU General Public License as published by
|
9 |
|
|
# OBSOLETE # the Free Software Foundation; either version 2, or (at your option)
|
10 |
|
|
# OBSOLETE # any later version.
|
11 |
|
|
# OBSOLETE #
|
12 |
|
|
# OBSOLETE # This program is distributed in the hope that it will be useful,
|
13 |
|
|
# OBSOLETE # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
# OBSOLETE # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
# OBSOLETE # GNU General Public License for more details.
|
16 |
|
|
# OBSOLETE #
|
17 |
|
|
# OBSOLETE # You should have received a copy of the GNU General Public License along
|
18 |
|
|
# OBSOLETE # with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
|
|
# OBSOLETE # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
20 |
|
|
# OBSOLETE
|
21 |
|
|
# OBSOLETE # Syntax:
|
22 |
|
|
# OBSOLETE # /bin/sh mainloop.in command
|
23 |
|
|
# OBSOLETE #
|
24 |
|
|
# OBSOLETE # Command is one of:
|
25 |
|
|
# OBSOLETE #
|
26 |
|
|
# OBSOLETE # init
|
27 |
|
|
# OBSOLETE # support
|
28 |
|
|
# OBSOLETE # extract-{simple,scache,pbb}
|
29 |
|
|
# OBSOLETE # {full,fast}-exec-{simple,scache,pbb}
|
30 |
|
|
# OBSOLETE #
|
31 |
|
|
# OBSOLETE # A target need only provide a "full" version of one of simple,scache,pbb.
|
32 |
|
|
# OBSOLETE # If the target wants it can also provide a fast version of same.
|
33 |
|
|
# OBSOLETE # It can't provide more than this, however for illustration's sake the FR30
|
34 |
|
|
# OBSOLETE # port provides examples of all.
|
35 |
|
|
# OBSOLETE
|
36 |
|
|
# OBSOLETE # ??? After a few more ports are done, revisit.
|
37 |
|
|
# OBSOLETE # Will eventually need to machine generate a lot of this.
|
38 |
|
|
# OBSOLETE
|
39 |
|
|
# OBSOLETE case "x$1" in
|
40 |
|
|
# OBSOLETE
|
41 |
|
|
# OBSOLETE xsupport)
|
42 |
|
|
# OBSOLETE
|
43 |
|
|
# OBSOLETE cat <
|
44 |
|
|
# OBSOLETE
|
45 |
|
|
# OBSOLETE static INLINE const IDESC *
|
46 |
|
|
# OBSOLETE extract (SIM_CPU *current_cpu, PCADDR pc, CGEN_INSN_INT insn, ARGBUF *abuf,
|
47 |
|
|
# OBSOLETE int fast_p)
|
48 |
|
|
# OBSOLETE {
|
49 |
|
|
# OBSOLETE const IDESC *id = @cpu@_decode (current_cpu, pc, insn, abuf);
|
50 |
|
|
# OBSOLETE @cpu@_fill_argbuf (current_cpu, abuf, id, pc, fast_p);
|
51 |
|
|
# OBSOLETE if (! fast_p)
|
52 |
|
|
# OBSOLETE {
|
53 |
|
|
# OBSOLETE int trace_p = PC_IN_TRACE_RANGE_P (current_cpu, pc);
|
54 |
|
|
# OBSOLETE int profile_p = PC_IN_PROFILE_RANGE_P (current_cpu, pc);
|
55 |
|
|
# OBSOLETE @cpu@_fill_argbuf_tp (current_cpu, abuf, trace_p, profile_p);
|
56 |
|
|
# OBSOLETE }
|
57 |
|
|
# OBSOLETE return id;
|
58 |
|
|
# OBSOLETE }
|
59 |
|
|
# OBSOLETE
|
60 |
|
|
# OBSOLETE static INLINE SEM_PC
|
61 |
|
|
# OBSOLETE execute (SIM_CPU *current_cpu, SCACHE *sc, int fast_p)
|
62 |
|
|
# OBSOLETE {
|
63 |
|
|
# OBSOLETE SEM_PC vpc;
|
64 |
|
|
# OBSOLETE
|
65 |
|
|
# OBSOLETE if (fast_p)
|
66 |
|
|
# OBSOLETE {
|
67 |
|
|
# OBSOLETE #if ! WITH_SEM_SWITCH_FAST
|
68 |
|
|
# OBSOLETE #if WITH_SCACHE
|
69 |
|
|
# OBSOLETE vpc = (*sc->argbuf.semantic.sem_fast) (current_cpu, sc);
|
70 |
|
|
# OBSOLETE #else
|
71 |
|
|
# OBSOLETE vpc = (*sc->argbuf.semantic.sem_fast) (current_cpu, &sc->argbuf);
|
72 |
|
|
# OBSOLETE #endif
|
73 |
|
|
# OBSOLETE #else
|
74 |
|
|
# OBSOLETE abort ();
|
75 |
|
|
# OBSOLETE #endif /* WITH_SEM_SWITCH_FAST */
|
76 |
|
|
# OBSOLETE }
|
77 |
|
|
# OBSOLETE else
|
78 |
|
|
# OBSOLETE {
|
79 |
|
|
# OBSOLETE #if ! WITH_SEM_SWITCH_FULL
|
80 |
|
|
# OBSOLETE ARGBUF *abuf = &sc->argbuf;
|
81 |
|
|
# OBSOLETE const IDESC *idesc = abuf->idesc;
|
82 |
|
|
# OBSOLETE #if WITH_SCACHE_PBB
|
83 |
|
|
# OBSOLETE int virtual_p = CGEN_ATTR_VALUE (NULL, idesc->attrs, CGEN_INSN_VIRTUAL);
|
84 |
|
|
# OBSOLETE #else
|
85 |
|
|
# OBSOLETE int virtual_p = 0;
|
86 |
|
|
# OBSOLETE #endif
|
87 |
|
|
# OBSOLETE
|
88 |
|
|
# OBSOLETE if (! virtual_p)
|
89 |
|
|
# OBSOLETE {
|
90 |
|
|
# OBSOLETE /* FIXME: call x-before */
|
91 |
|
|
# OBSOLETE if (ARGBUF_PROFILE_P (abuf))
|
92 |
|
|
# OBSOLETE PROFILE_COUNT_INSN (current_cpu, abuf->addr, idesc->num);
|
93 |
|
|
# OBSOLETE /* FIXME: Later make cover macros: PROFILE_INSN_{INIT,FINI}. */
|
94 |
|
|
# OBSOLETE if (PROFILE_MODEL_P (current_cpu)
|
95 |
|
|
# OBSOLETE && ARGBUF_PROFILE_P (abuf))
|
96 |
|
|
# OBSOLETE @cpu@_model_insn_before (current_cpu, 1 /*first_p*/);
|
97 |
|
|
# OBSOLETE TRACE_INSN_INIT (current_cpu, abuf, 1);
|
98 |
|
|
# OBSOLETE TRACE_INSN (current_cpu, idesc->idata,
|
99 |
|
|
# OBSOLETE (const struct argbuf *) abuf, abuf->addr);
|
100 |
|
|
# OBSOLETE }
|
101 |
|
|
# OBSOLETE #if WITH_SCACHE
|
102 |
|
|
# OBSOLETE vpc = (*sc->argbuf.semantic.sem_full) (current_cpu, sc);
|
103 |
|
|
# OBSOLETE #else
|
104 |
|
|
# OBSOLETE vpc = (*sc->argbuf.semantic.sem_full) (current_cpu, abuf);
|
105 |
|
|
# OBSOLETE #endif
|
106 |
|
|
# OBSOLETE if (! virtual_p)
|
107 |
|
|
# OBSOLETE {
|
108 |
|
|
# OBSOLETE /* FIXME: call x-after */
|
109 |
|
|
# OBSOLETE if (PROFILE_MODEL_P (current_cpu)
|
110 |
|
|
# OBSOLETE && ARGBUF_PROFILE_P (abuf))
|
111 |
|
|
# OBSOLETE {
|
112 |
|
|
# OBSOLETE int cycles;
|
113 |
|
|
# OBSOLETE
|
114 |
|
|
# OBSOLETE cycles = (*idesc->timing->model_fn) (current_cpu, sc);
|
115 |
|
|
# OBSOLETE @cpu@_model_insn_after (current_cpu, 1 /*last_p*/, cycles);
|
116 |
|
|
# OBSOLETE }
|
117 |
|
|
# OBSOLETE TRACE_INSN_FINI (current_cpu, abuf, 1);
|
118 |
|
|
# OBSOLETE }
|
119 |
|
|
# OBSOLETE #else
|
120 |
|
|
# OBSOLETE abort ();
|
121 |
|
|
# OBSOLETE #endif /* WITH_SEM_SWITCH_FULL */
|
122 |
|
|
# OBSOLETE }
|
123 |
|
|
# OBSOLETE
|
124 |
|
|
# OBSOLETE return vpc;
|
125 |
|
|
# OBSOLETE }
|
126 |
|
|
# OBSOLETE
|
127 |
|
|
# OBSOLETE EOF
|
128 |
|
|
# OBSOLETE
|
129 |
|
|
# OBSOLETE ;;
|
130 |
|
|
# OBSOLETE
|
131 |
|
|
# OBSOLETE xinit)
|
132 |
|
|
# OBSOLETE
|
133 |
|
|
# OBSOLETE cat <
|
134 |
|
|
# OBSOLETE /*xxxinit*/
|
135 |
|
|
# OBSOLETE EOF
|
136 |
|
|
# OBSOLETE
|
137 |
|
|
# OBSOLETE ;;
|
138 |
|
|
# OBSOLETE
|
139 |
|
|
# OBSOLETE xextract-simple | xextract-scache)
|
140 |
|
|
# OBSOLETE
|
141 |
|
|
# OBSOLETE # Inputs: current_cpu, vpc, sc, FAST_P
|
142 |
|
|
# OBSOLETE # Outputs: sc filled in
|
143 |
|
|
# OBSOLETE
|
144 |
|
|
# OBSOLETE cat <
|
145 |
|
|
# OBSOLETE {
|
146 |
|
|
# OBSOLETE CGEN_INSN_INT insn = GETIMEMUHI (current_cpu, vpc);
|
147 |
|
|
# OBSOLETE extract (current_cpu, vpc, insn, SEM_ARGBUF (sc), FAST_P);
|
148 |
|
|
# OBSOLETE }
|
149 |
|
|
# OBSOLETE EOF
|
150 |
|
|
# OBSOLETE
|
151 |
|
|
# OBSOLETE ;;
|
152 |
|
|
# OBSOLETE
|
153 |
|
|
# OBSOLETE xextract-pbb)
|
154 |
|
|
# OBSOLETE
|
155 |
|
|
# OBSOLETE # Inputs: current_cpu, pc, sc, max_insns, FAST_P
|
156 |
|
|
# OBSOLETE # Outputs: sc, pc
|
157 |
|
|
# OBSOLETE # sc must be left pointing past the last created entry.
|
158 |
|
|
# OBSOLETE # pc must be left pointing past the last created entry.
|
159 |
|
|
# OBSOLETE # If the pbb is terminated by a cti insn, SET_CTI_VPC(sc) must be called
|
160 |
|
|
# OBSOLETE # to record the vpc of the cti insn.
|
161 |
|
|
# OBSOLETE # SET_INSN_COUNT(n) must be called to record number of real insns.
|
162 |
|
|
# OBSOLETE
|
163 |
|
|
# OBSOLETE cat <
|
164 |
|
|
# OBSOLETE {
|
165 |
|
|
# OBSOLETE const IDESC *idesc;
|
166 |
|
|
# OBSOLETE int icount = 0;
|
167 |
|
|
# OBSOLETE
|
168 |
|
|
# OBSOLETE while (max_insns > 0)
|
169 |
|
|
# OBSOLETE {
|
170 |
|
|
# OBSOLETE UHI insn = GETIMEMUHI (current_cpu, pc);
|
171 |
|
|
# OBSOLETE idesc = extract (current_cpu, pc, insn, &sc->argbuf, FAST_P);
|
172 |
|
|
# OBSOLETE ++sc;
|
173 |
|
|
# OBSOLETE --max_insns;
|
174 |
|
|
# OBSOLETE ++icount;
|
175 |
|
|
# OBSOLETE pc += idesc->length;
|
176 |
|
|
# OBSOLETE if (IDESC_CTI_P (idesc))
|
177 |
|
|
# OBSOLETE {
|
178 |
|
|
# OBSOLETE SET_CTI_VPC (sc - 1);
|
179 |
|
|
# OBSOLETE
|
180 |
|
|
# OBSOLETE /* Delay slot? */
|
181 |
|
|
# OBSOLETE /* ??? breakpoints in delay slots */
|
182 |
|
|
# OBSOLETE if (CGEN_ATTR_VALUE (NULL, idesc->attrs, CGEN_INSN_DELAY_SLOT))
|
183 |
|
|
# OBSOLETE {
|
184 |
|
|
# OBSOLETE UHI insn = GETIMEMUHI (current_cpu, pc);
|
185 |
|
|
# OBSOLETE idesc = extract (current_cpu, pc, insn, &sc->argbuf, FAST_P);
|
186 |
|
|
# OBSOLETE if (CGEN_ATTR_VALUE (NULL, idesc->attrs, CGEN_INSN_NOT_IN_DELAY_SLOT))
|
187 |
|
|
# OBSOLETE {
|
188 |
|
|
# OBSOLETE /* malformed program */
|
189 |
|
|
# OBSOLETE sim_io_eprintf (CPU_STATE (current_cpu),
|
190 |
|
|
# OBSOLETE "malformed program, \`%s' insn in delay slot\n",
|
191 |
|
|
# OBSOLETE CGEN_INSN_NAME (idesc->idata));
|
192 |
|
|
# OBSOLETE }
|
193 |
|
|
# OBSOLETE else
|
194 |
|
|
# OBSOLETE {
|
195 |
|
|
# OBSOLETE ++sc;
|
196 |
|
|
# OBSOLETE --max_insns;
|
197 |
|
|
# OBSOLETE ++icount;
|
198 |
|
|
# OBSOLETE pc += idesc->length;
|
199 |
|
|
# OBSOLETE }
|
200 |
|
|
# OBSOLETE }
|
201 |
|
|
# OBSOLETE break;
|
202 |
|
|
# OBSOLETE }
|
203 |
|
|
# OBSOLETE }
|
204 |
|
|
# OBSOLETE
|
205 |
|
|
# OBSOLETE Finish:
|
206 |
|
|
# OBSOLETE SET_INSN_COUNT (icount);
|
207 |
|
|
# OBSOLETE }
|
208 |
|
|
# OBSOLETE EOF
|
209 |
|
|
# OBSOLETE
|
210 |
|
|
# OBSOLETE ;;
|
211 |
|
|
# OBSOLETE
|
212 |
|
|
# OBSOLETE xfull-exec-* | xfast-exec-*)
|
213 |
|
|
# OBSOLETE
|
214 |
|
|
# OBSOLETE # Inputs: current_cpu, sc, FAST_P
|
215 |
|
|
# OBSOLETE # Outputs: vpc
|
216 |
|
|
# OBSOLETE # vpc contains the address of the next insn to execute
|
217 |
|
|
# OBSOLETE
|
218 |
|
|
# OBSOLETE cat <
|
219 |
|
|
# OBSOLETE {
|
220 |
|
|
# OBSOLETE #if (! FAST_P && WITH_SEM_SWITCH_FULL) || (FAST_P && WITH_SEM_SWITCH_FAST)
|
221 |
|
|
# OBSOLETE #define DEFINE_SWITCH
|
222 |
|
|
# OBSOLETE #include "sem-switch.c"
|
223 |
|
|
# OBSOLETE #else
|
224 |
|
|
# OBSOLETE vpc = execute (current_cpu, vpc, FAST_P);
|
225 |
|
|
# OBSOLETE #endif
|
226 |
|
|
# OBSOLETE }
|
227 |
|
|
# OBSOLETE EOF
|
228 |
|
|
# OBSOLETE
|
229 |
|
|
# OBSOLETE ;;
|
230 |
|
|
# OBSOLETE
|
231 |
|
|
# OBSOLETE *)
|
232 |
|
|
# OBSOLETE echo "Invalid argument to mainloop.in: $1" >&2
|
233 |
|
|
# OBSOLETE exit 1
|
234 |
|
|
# OBSOLETE ;;
|
235 |
|
|
# OBSOLETE
|
236 |
|
|
# OBSOLETE esac
|