mloop-compact.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /* This file is generated by the genmloop script. DO NOT EDIT! */
  2. /* Enable switch() support in cgen headers. */
  3. #define SEM_IN_SWITCH
  4. #define WANT_CPU sh64
  5. #define WANT_CPU_SH64
  6. #include "sim-main.h"
  7. #include "bfd.h"
  8. #include "cgen-mem.h"
  9. #include "cgen-ops.h"
  10. #include "sim-assert.h"
  11. /* Fill in the administrative ARGBUF fields required by all insns,
  12. virtual and real. */
  13. static INLINE void
  14. sh64_compact_fill_argbuf (const SIM_CPU *cpu, ARGBUF *abuf, const IDESC *idesc,
  15. PCADDR pc, int fast_p)
  16. {
  17. #if WITH_SCACHE
  18. SEM_SET_CODE (abuf, idesc, fast_p);
  19. ARGBUF_ADDR (abuf) = pc;
  20. #endif
  21. ARGBUF_IDESC (abuf) = idesc;
  22. }
  23. /* Fill in tracing/profiling fields of an ARGBUF. */
  24. static INLINE void
  25. sh64_compact_fill_argbuf_tp (const SIM_CPU *cpu, ARGBUF *abuf,
  26. int trace_p, int profile_p)
  27. {
  28. ARGBUF_TRACE_P (abuf) = trace_p;
  29. ARGBUF_PROFILE_P (abuf) = profile_p;
  30. }
  31. #if WITH_SCACHE_PBB
  32. /* Emit the "x-before" handler.
  33. x-before is emitted before each insn (serial or parallel).
  34. This is as opposed to x-after which is only emitted at the end of a group
  35. of parallel insns. */
  36. static INLINE void
  37. sh64_compact_emit_before (SIM_CPU *current_cpu, SCACHE *sc, PCADDR pc, int first_p)
  38. {
  39. ARGBUF *abuf = &sc[0].argbuf;
  40. const IDESC *id = & CPU_IDESC (current_cpu) [SH64_COMPACT_INSN_X_BEFORE];
  41. abuf->fields.before.first_p = first_p;
  42. sh64_compact_fill_argbuf (current_cpu, abuf, id, pc, 0);
  43. /* no need to set trace_p,profile_p */
  44. }
  45. /* Emit the "x-after" handler.
  46. x-after is emitted after a serial insn or at the end of a group of
  47. parallel insns. */
  48. static INLINE void
  49. sh64_compact_emit_after (SIM_CPU *current_cpu, SCACHE *sc, PCADDR pc)
  50. {
  51. ARGBUF *abuf = &sc[0].argbuf;
  52. const IDESC *id = & CPU_IDESC (current_cpu) [SH64_COMPACT_INSN_X_AFTER];
  53. sh64_compact_fill_argbuf (current_cpu, abuf, id, pc, 0);
  54. /* no need to set trace_p,profile_p */
  55. }
  56. #endif /* WITH_SCACHE_PBB */
  57. static INLINE const IDESC *
  58. extract (SIM_CPU *current_cpu, PCADDR pc, CGEN_INSN_INT insn, ARGBUF *abuf,
  59. int fast_p)
  60. {
  61. const IDESC *id = sh64_compact_decode (current_cpu, pc, insn, insn, abuf);
  62. sh64_compact_fill_argbuf (current_cpu, abuf, id, pc, fast_p);
  63. if (! fast_p)
  64. {
  65. int trace_p = PC_IN_TRACE_RANGE_P (current_cpu, pc);
  66. int profile_p = PC_IN_PROFILE_RANGE_P (current_cpu, pc);
  67. sh64_compact_fill_argbuf_tp (current_cpu, abuf, trace_p, profile_p);
  68. }
  69. return id;
  70. }
  71. static INLINE SEM_PC
  72. execute (SIM_CPU *current_cpu, SCACHE *sc, int fast_p)
  73. {
  74. SEM_PC vpc;
  75. if (fast_p)
  76. {
  77. #if ! WITH_SEM_SWITCH_FAST
  78. #if WITH_SCACHE
  79. vpc = (*sc->argbuf.semantic.sem_fast) (current_cpu, sc);
  80. #else
  81. vpc = (*sc->argbuf.semantic.sem_fast) (current_cpu, &sc->argbuf);
  82. #endif
  83. #else
  84. abort ();
  85. #endif /* WITH_SEM_SWITCH_FAST */
  86. }
  87. else
  88. {
  89. #if ! WITH_SEM_SWITCH_FULL
  90. ARGBUF *abuf = &sc->argbuf;
  91. const IDESC *idesc = abuf->idesc;
  92. #if WITH_SCACHE_PBB
  93. int virtual_p = CGEN_ATTR_VALUE (NULL, idesc->attrs, CGEN_INSN_VIRTUAL);
  94. #else
  95. int virtual_p = 0;
  96. #endif
  97. if (! virtual_p)
  98. {
  99. /* FIXME: call x-before */
  100. if (ARGBUF_PROFILE_P (abuf))
  101. PROFILE_COUNT_INSN (current_cpu, abuf->addr, idesc->num);
  102. /* FIXME: Later make cover macros: PROFILE_INSN_{INIT,FINI}. */
  103. if (PROFILE_MODEL_P (current_cpu)
  104. && ARGBUF_PROFILE_P (abuf))
  105. sh64_compact_model_insn_before (current_cpu, 1 /*first_p*/);
  106. CGEN_TRACE_INSN_INIT (current_cpu, abuf, 1);
  107. CGEN_TRACE_INSN (current_cpu, idesc->idata,
  108. (const struct argbuf *) abuf, abuf->addr);
  109. }
  110. #if WITH_SCACHE
  111. vpc = (*sc->argbuf.semantic.sem_full) (current_cpu, sc);
  112. #else
  113. vpc = (*sc->argbuf.semantic.sem_full) (current_cpu, abuf);
  114. #endif
  115. if (! virtual_p)
  116. {
  117. /* FIXME: call x-after */
  118. if (PROFILE_MODEL_P (current_cpu)
  119. && ARGBUF_PROFILE_P (abuf))
  120. {
  121. int cycles;
  122. cycles = (*idesc->timing->model_fn) (current_cpu, sc);
  123. sh64_compact_model_insn_after (current_cpu, 1 /*last_p*/, cycles);
  124. }
  125. CGEN_TRACE_INSN_FINI (current_cpu, abuf, 1);
  126. }
  127. #else
  128. abort ();
  129. #endif /* WITH_SEM_SWITCH_FULL */
  130. }
  131. return vpc;
  132. }
  133. /* Record address of cti terminating a pbb. */
  134. #define SET_CTI_VPC(sc) do { _cti_sc = (sc); } while (0)
  135. /* Record number of [real] insns in pbb. */
  136. #define SET_INSN_COUNT(n) do { _insn_count = (n); } while (0)
  137. /* Fetch and extract a pseudo-basic-block.
  138. FAST_P is non-zero if no tracing/profiling/etc. is wanted. */
  139. INLINE SEM_PC
  140. sh64_compact_pbb_begin (SIM_CPU *current_cpu, int FAST_P)
  141. {
  142. SEM_PC new_vpc;
  143. PCADDR pc;
  144. SCACHE *sc;
  145. int max_insns = CPU_SCACHE_MAX_CHAIN_LENGTH (current_cpu);
  146. pc = GET_H_PC ();
  147. new_vpc = scache_lookup_or_alloc (current_cpu, pc, max_insns, &sc);
  148. if (! new_vpc)
  149. {
  150. /* Leading '_' to avoid collision with mainloop.in. */
  151. int _insn_count = 0;
  152. SCACHE *orig_sc = sc;
  153. SCACHE *_cti_sc = NULL;
  154. int slice_insns = CPU_MAX_SLICE_INSNS (current_cpu);
  155. /* First figure out how many instructions to compile.
  156. MAX_INSNS is the size of the allocated buffer, which includes space
  157. for before/after handlers if they're being used.
  158. SLICE_INSNS is the maxinum number of real insns that can be
  159. executed. Zero means "as many as we want". */
  160. /* ??? max_insns is serving two incompatible roles.
  161. 1) Number of slots available in scache buffer.
  162. 2) Number of real insns to execute.
  163. They're incompatible because there are virtual insns emitted too
  164. (chain,cti-chain,before,after handlers). */
  165. if (slice_insns == 1)
  166. {
  167. /* No need to worry about extra slots required for virtual insns
  168. and parallel exec support because MAX_CHAIN_LENGTH is
  169. guaranteed to be big enough to execute at least 1 insn! */
  170. max_insns = 1;
  171. }
  172. else
  173. {
  174. /* Allow enough slop so that while compiling insns, if max_insns > 0
  175. then there's guaranteed to be enough space to emit one real insn.
  176. MAX_CHAIN_LENGTH is typically much longer than
  177. the normal number of insns between cti's anyway. */
  178. max_insns -= (1 /* one for the trailing chain insn */
  179. + (FAST_P
  180. ? 0
  181. : (1 + MAX_PARALLEL_INSNS) /* before+after */)
  182. + (MAX_PARALLEL_INSNS > 1
  183. ? (MAX_PARALLEL_INSNS * 2)
  184. : 0));
  185. /* Account for before/after handlers. */
  186. if (! FAST_P)
  187. slice_insns *= 3;
  188. if (slice_insns > 0
  189. && slice_insns < max_insns)
  190. max_insns = slice_insns;
  191. }
  192. new_vpc = sc;
  193. /* SC,PC must be updated to point passed the last entry used.
  194. SET_CTI_VPC must be called if pbb is terminated by a cti.
  195. SET_INSN_COUNT must be called to record number of real insns in
  196. pbb [could be computed by us of course, extra cpu but perhaps
  197. negligible enough]. */
  198. /* begin extract-pbb */
  199. {
  200. const IDESC *idesc;
  201. int icount = 0;
  202. while (max_insns > 0)
  203. {
  204. UHI insn = GETIMEMUHI (current_cpu, pc);
  205. idesc = extract (current_cpu, pc, insn, &sc->argbuf, FAST_P);
  206. SEM_SKIP_COMPILE (current_cpu, sc, 1);
  207. ++sc;
  208. --max_insns;
  209. ++icount;
  210. pc += idesc->length;
  211. if (IDESC_CTI_P (idesc))
  212. {
  213. SET_CTI_VPC (sc - 1);
  214. if (CGEN_ATTR_VALUE (NULL, idesc->attrs, CGEN_INSN_DELAY_SLOT))
  215. {
  216. USI insn = GETIMEMUHI (current_cpu, pc);
  217. idesc = extract (current_cpu, pc, insn, &sc->argbuf, FAST_P);
  218. if (IDESC_CTI_P (idesc) ||
  219. CGEN_ATTR_VALUE (NULL, idesc->attrs, CGEN_INSN_ILLSLOT))
  220. {
  221. SIM_DESC sd = CPU_STATE (current_cpu);
  222. sim_io_eprintf (CPU_STATE (current_cpu),
  223. "malformed program, `%s' insn in delay slot\n",
  224. CGEN_INSN_NAME (idesc->idata));
  225. sim_engine_halt (sd, current_cpu, NULL, pc,
  226. sim_stopped, SIM_SIGILL);
  227. }
  228. else
  229. {
  230. ++sc;
  231. --max_insns;
  232. ++icount;
  233. pc += idesc->length;
  234. }
  235. }
  236. break;
  237. }
  238. }
  239. Finish:
  240. SET_INSN_COUNT (icount);
  241. }
  242. /* end extract-pbb */
  243. /* The last one is a pseudo-insn to link to the next chain.
  244. It is also used to record the insn count for this chain. */
  245. {
  246. const IDESC *id;
  247. /* Was pbb terminated by a cti? */
  248. if (_cti_sc)
  249. {
  250. id = & CPU_IDESC (current_cpu) [SH64_COMPACT_INSN_X_CTI_CHAIN];
  251. }
  252. else
  253. {
  254. id = & CPU_IDESC (current_cpu) [SH64_COMPACT_INSN_X_CHAIN];
  255. }
  256. SEM_SET_CODE (&sc->argbuf, id, FAST_P);
  257. sc->argbuf.idesc = id;
  258. sc->argbuf.addr = pc;
  259. sc->argbuf.fields.chain.insn_count = _insn_count;
  260. sc->argbuf.fields.chain.next = 0;
  261. sc->argbuf.fields.chain.branch_target = 0;
  262. ++sc;
  263. }
  264. /* Update the pointer to the next free entry, may not have used as
  265. many entries as was asked for. */
  266. CPU_SCACHE_NEXT_FREE (current_cpu) = sc;
  267. /* Record length of chain if profiling.
  268. This includes virtual insns since they count against
  269. max_insns too. */
  270. if (! FAST_P)
  271. PROFILE_COUNT_SCACHE_CHAIN_LENGTH (current_cpu, sc - orig_sc);
  272. }
  273. return new_vpc;
  274. }
  275. /* Chain to the next block from a non-cti terminated previous block. */
  276. INLINE SEM_PC
  277. sh64_compact_pbb_chain (SIM_CPU *current_cpu, SEM_ARG sem_arg)
  278. {
  279. ARGBUF *abuf = SEM_ARGBUF (sem_arg);
  280. PBB_UPDATE_INSN_COUNT (current_cpu, sem_arg);
  281. SET_H_PC (abuf->addr);
  282. /* If not running forever, exit back to main loop. */
  283. if (CPU_MAX_SLICE_INSNS (current_cpu) != 0
  284. /* Also exit back to main loop if there's an event.
  285. Note that if CPU_MAX_SLICE_INSNS != 1, events won't get processed
  286. at the "right" time, but then that was what was asked for.
  287. There is no silver bullet for simulator engines.
  288. ??? Clearly this needs a cleaner interface.
  289. At present it's just so Ctrl-C works. */
  290. || STATE_EVENTS (CPU_STATE (current_cpu))->work_pending)
  291. CPU_RUNNING_P (current_cpu) = 0;
  292. /* If chained to next block, go straight to it. */
  293. if (abuf->fields.chain.next)
  294. return abuf->fields.chain.next;
  295. /* See if next block has already been compiled. */
  296. abuf->fields.chain.next = scache_lookup (current_cpu, abuf->addr);
  297. if (abuf->fields.chain.next)
  298. return abuf->fields.chain.next;
  299. /* Nope, so next insn is a virtual insn to invoke the compiler
  300. (begin a pbb). */
  301. return CPU_SCACHE_PBB_BEGIN (current_cpu);
  302. }
  303. /* Chain to the next block from a cti terminated previous block.
  304. BR_TYPE indicates whether the branch was taken and whether we can cache
  305. the vpc of the branch target.
  306. NEW_PC is the target's branch address, and is only valid if
  307. BR_TYPE != SEM_BRANCH_UNTAKEN. */
  308. INLINE SEM_PC
  309. sh64_compact_pbb_cti_chain (SIM_CPU *current_cpu, SEM_ARG sem_arg,
  310. SEM_BRANCH_TYPE br_type, PCADDR new_pc)
  311. {
  312. SEM_PC *new_vpc_ptr;
  313. PBB_UPDATE_INSN_COUNT (current_cpu, sem_arg);
  314. /* If we have switched ISAs, exit back to main loop.
  315. Set idesc to 0 to cause the engine to point to the right insn table. */
  316. if (new_pc & 1)
  317. {
  318. /* Switch to SHmedia. */
  319. CPU_IDESC_SEM_INIT_P (current_cpu) = 0;
  320. CPU_RUNNING_P (current_cpu) = 0;
  321. }
  322. /* If not running forever, exit back to main loop. */
  323. if (CPU_MAX_SLICE_INSNS (current_cpu) != 0
  324. /* Also exit back to main loop if there's an event.
  325. Note that if CPU_MAX_SLICE_INSNS != 1, events won't get processed
  326. at the "right" time, but then that was what was asked for.
  327. There is no silver bullet for simulator engines.
  328. ??? Clearly this needs a cleaner interface.
  329. At present it's just so Ctrl-C works. */
  330. || STATE_EVENTS (CPU_STATE (current_cpu))->work_pending)
  331. CPU_RUNNING_P (current_cpu) = 0;
  332. /* Restart compiler if we branched to an uncacheable address
  333. (e.g. "j reg"). */
  334. if (br_type == SEM_BRANCH_UNCACHEABLE)
  335. {
  336. SET_H_PC (new_pc);
  337. return CPU_SCACHE_PBB_BEGIN (current_cpu);
  338. }
  339. /* If branch wasn't taken, update the pc and set BR_ADDR_PTR to our
  340. next chain ptr. */
  341. if (br_type == SEM_BRANCH_UNTAKEN)
  342. {
  343. ARGBUF *abuf = SEM_ARGBUF (sem_arg);
  344. new_pc = abuf->addr;
  345. SET_H_PC (new_pc);
  346. new_vpc_ptr = &abuf->fields.chain.next;
  347. }
  348. else
  349. {
  350. ARGBUF *abuf = SEM_ARGBUF (sem_arg);
  351. SET_H_PC (new_pc);
  352. new_vpc_ptr = &abuf->fields.chain.branch_target;
  353. }
  354. /* If chained to next block, go straight to it. */
  355. if (*new_vpc_ptr)
  356. return *new_vpc_ptr;
  357. /* See if next block has already been compiled. */
  358. *new_vpc_ptr = scache_lookup (current_cpu, new_pc);
  359. if (*new_vpc_ptr)
  360. return *new_vpc_ptr;
  361. /* Nope, so next insn is a virtual insn to invoke the compiler
  362. (begin a pbb). */
  363. return CPU_SCACHE_PBB_BEGIN (current_cpu);
  364. }
  365. /* x-before handler.
  366. This is called before each insn. */
  367. void
  368. sh64_compact_pbb_before (SIM_CPU *current_cpu, SCACHE *sc)
  369. {
  370. SEM_ARG sem_arg = sc;
  371. const ARGBUF *abuf = SEM_ARGBUF (sem_arg);
  372. int first_p = abuf->fields.before.first_p;
  373. const ARGBUF *cur_abuf = SEM_ARGBUF (sc + 1);
  374. const IDESC *cur_idesc = cur_abuf->idesc;
  375. PCADDR pc = cur_abuf->addr;
  376. if (ARGBUF_PROFILE_P (cur_abuf))
  377. PROFILE_COUNT_INSN (current_cpu, pc, cur_idesc->num);
  378. /* If this isn't the first insn, finish up the previous one. */
  379. if (! first_p)
  380. {
  381. if (PROFILE_MODEL_P (current_cpu))
  382. {
  383. const SEM_ARG prev_sem_arg = sc - 1;
  384. const ARGBUF *prev_abuf = SEM_ARGBUF (prev_sem_arg);
  385. const IDESC *prev_idesc = prev_abuf->idesc;
  386. int cycles;
  387. /* ??? May want to measure all insns if doing insn tracing. */
  388. if (ARGBUF_PROFILE_P (prev_abuf))
  389. {
  390. cycles = (*prev_idesc->timing->model_fn) (current_cpu, prev_sem_arg);
  391. sh64_compact_model_insn_after (current_cpu, 0 /*last_p*/, cycles);
  392. }
  393. }
  394. CGEN_TRACE_INSN_FINI (current_cpu, cur_abuf, 0 /*last_p*/);
  395. }
  396. /* FIXME: Later make cover macros: PROFILE_INSN_{INIT,FINI}. */
  397. if (PROFILE_MODEL_P (current_cpu)
  398. && ARGBUF_PROFILE_P (cur_abuf))
  399. sh64_compact_model_insn_before (current_cpu, first_p);
  400. CGEN_TRACE_INSN_INIT (current_cpu, cur_abuf, first_p);
  401. CGEN_TRACE_INSN (current_cpu, cur_idesc->idata, cur_abuf, pc);
  402. }
  403. /* x-after handler.
  404. This is called after a serial insn or at the end of a group of parallel
  405. insns. */
  406. void
  407. sh64_compact_pbb_after (SIM_CPU *current_cpu, SCACHE *sc)
  408. {
  409. SEM_ARG sem_arg = sc;
  410. const ARGBUF *abuf = SEM_ARGBUF (sem_arg);
  411. const SEM_ARG prev_sem_arg = sc - 1;
  412. const ARGBUF *prev_abuf = SEM_ARGBUF (prev_sem_arg);
  413. /* ??? May want to measure all insns if doing insn tracing. */
  414. if (PROFILE_MODEL_P (current_cpu)
  415. && ARGBUF_PROFILE_P (prev_abuf))
  416. {
  417. const IDESC *prev_idesc = prev_abuf->idesc;
  418. int cycles;
  419. cycles = (*prev_idesc->timing->model_fn) (current_cpu, prev_sem_arg);
  420. sh64_compact_model_insn_after (current_cpu, 1 /*last_p*/, cycles);
  421. }
  422. CGEN_TRACE_INSN_FINI (current_cpu, prev_abuf, 1 /*last_p*/);
  423. }
  424. #define FAST_P 0
  425. void
  426. sh64_compact_engine_run_full (SIM_CPU *current_cpu)
  427. {
  428. SIM_DESC current_state = CPU_STATE (current_cpu);
  429. SCACHE *scache = CPU_SCACHE_CACHE (current_cpu);
  430. /* virtual program counter */
  431. SEM_PC vpc;
  432. #if WITH_SEM_SWITCH_FULL
  433. /* For communication between cti's and cti-chain. */
  434. SEM_BRANCH_TYPE pbb_br_type;
  435. PCADDR pbb_br_npc;
  436. #endif
  437. if (! CPU_IDESC_SEM_INIT_P (current_cpu))
  438. {
  439. /* ??? 'twould be nice to move this up a level and only call it once.
  440. On the other hand, in the "let's go fast" case the test is only done
  441. once per pbb (since we only return to the main loop at the end of
  442. a pbb). And in the "let's run until we're done" case we don't return
  443. until the program exits. */
  444. #if WITH_SEM_SWITCH_FULL
  445. #if defined (__GNUC__)
  446. /* ??? Later maybe paste sem-switch.c in when building mainloop.c. */
  447. #define DEFINE_LABELS
  448. #include "sem-compact-switch.c"
  449. #endif
  450. #else
  451. sh64_compact_sem_init_idesc_table (current_cpu);
  452. #endif
  453. /* Initialize the "begin (compile) a pbb" virtual insn. */
  454. vpc = CPU_SCACHE_PBB_BEGIN (current_cpu);
  455. SEM_SET_FULL_CODE (SEM_ARGBUF (vpc),
  456. & CPU_IDESC (current_cpu) [SH64_COMPACT_INSN_X_BEGIN]);
  457. vpc->argbuf.idesc = & CPU_IDESC (current_cpu) [SH64_COMPACT_INSN_X_BEGIN];
  458. CPU_IDESC_SEM_INIT_P (current_cpu) = 1;
  459. }
  460. CPU_RUNNING_P (current_cpu) = 1;
  461. /* ??? In the case where we're returning to the main loop after every
  462. pbb we don't want to call pbb_begin each time (which hashes on the pc
  463. and does a table lookup). A way to speed this up is to save vpc
  464. between calls. */
  465. vpc = sh64_compact_pbb_begin (current_cpu, FAST_P);
  466. do
  467. {
  468. /* begin full-exec-pbb */
  469. {
  470. #if (! FAST_P && WITH_SEM_SWITCH_FULL) || (FAST_P && WITH_SEM_SWITCH_FAST)
  471. #define DEFINE_SWITCH
  472. #include "sem-compact-switch.c"
  473. #else
  474. vpc = execute (current_cpu, vpc, FAST_P);
  475. #endif
  476. }
  477. /* end full-exec-pbb */
  478. }
  479. while (CPU_RUNNING_P (current_cpu));
  480. }
  481. #undef FAST_P
  482. #define FAST_P 1
  483. void
  484. sh64_compact_engine_run_fast (SIM_CPU *current_cpu)
  485. {
  486. SIM_DESC current_state = CPU_STATE (current_cpu);
  487. SCACHE *scache = CPU_SCACHE_CACHE (current_cpu);
  488. /* virtual program counter */
  489. SEM_PC vpc;
  490. #if WITH_SEM_SWITCH_FAST
  491. /* For communication between cti's and cti-chain. */
  492. SEM_BRANCH_TYPE pbb_br_type;
  493. PCADDR pbb_br_npc;
  494. #endif
  495. if (! CPU_IDESC_SEM_INIT_P (current_cpu))
  496. {
  497. /* ??? 'twould be nice to move this up a level and only call it once.
  498. On the other hand, in the "let's go fast" case the test is only done
  499. once per pbb (since we only return to the main loop at the end of
  500. a pbb). And in the "let's run until we're done" case we don't return
  501. until the program exits. */
  502. #if WITH_SEM_SWITCH_FAST
  503. #if defined (__GNUC__)
  504. /* ??? Later maybe paste sem-switch.c in when building mainloop.c. */
  505. #define DEFINE_LABELS
  506. #include "sem-compact-switch.c"
  507. #endif
  508. #else
  509. sh64_compact_semf_init_idesc_table (current_cpu);
  510. #endif
  511. /* Initialize the "begin (compile) a pbb" virtual insn. */
  512. vpc = CPU_SCACHE_PBB_BEGIN (current_cpu);
  513. SEM_SET_FAST_CODE (SEM_ARGBUF (vpc),
  514. & CPU_IDESC (current_cpu) [SH64_COMPACT_INSN_X_BEGIN]);
  515. vpc->argbuf.idesc = & CPU_IDESC (current_cpu) [SH64_COMPACT_INSN_X_BEGIN];
  516. CPU_IDESC_SEM_INIT_P (current_cpu) = 1;
  517. }
  518. CPU_RUNNING_P (current_cpu) = 1;
  519. /* ??? In the case where we're returning to the main loop after every
  520. pbb we don't want to call pbb_begin each time (which hashes on the pc
  521. and does a table lookup). A way to speed this up is to save vpc
  522. between calls. */
  523. vpc = sh64_compact_pbb_begin (current_cpu, FAST_P);
  524. do
  525. {
  526. /* begin fast-exec-pbb */
  527. {
  528. #if (! FAST_P && WITH_SEM_SWITCH_FULL) || (FAST_P && WITH_SEM_SWITCH_FAST)
  529. #define DEFINE_SWITCH
  530. #include "sem-compact-switch.c"
  531. #else
  532. vpc = execute (current_cpu, vpc, FAST_P);
  533. #endif
  534. }
  535. /* end fast-exec-pbb */
  536. }
  537. while (CPU_RUNNING_P (current_cpu));
  538. }
  539. #undef FAST_P