1 # Simulator main loop for sparc64. -*- C -*-
2 # Copyright (C) 1999 Cygnus Solutions.
5 # /bin/sh mainloop.in command
11 # extract-{simple,scache,pbb}
12 # {full,fast}-exec-{simple,scache,pbb}
14 # A target need only provide a "full" version of one of simple,scache,pbb.
15 # If the target wants it can also provide a fast version of same, or if
16 # the slow (full featured) version is `simple', then the fast version can be
18 # A target can't provide more than this.
20 # ??? After a few more ports are done, revisit.
21 # Will eventually need to machine generate a lot of this.
30 execute (SIM_CPU *current_cpu, SCACHE *sc)
32 ARGBUF *abuf = &sc->argbuf;
33 IADDR pc = GET_H_PC ();
34 USI insn = GETIMEMUSI (current_cpu, pc);
35 int fast_p = STATE_RUN_FAST_P (CPU_STATE (current_cpu));
39 const IDESC *id = @cpu@_decode (current_cpu, pc, insn, insn, abuf);
41 @cpu@_fill_argbuf (current_cpu, abuf, id, pc, fast_p);
42 (*id->sem_full) (current_cpu, sc, insn);
46 const IDESC *id = @cpu@_decode (current_cpu, pc, insn, insn, abuf);
47 const CGEN_INSN *idata = id->idata;
48 int trace_p = PC_IN_TRACE_RANGE_P (current_cpu, pc);
49 int profile_p = PC_IN_PROFILE_RANGE_P (current_cpu, pc);
51 @cpu@_fill_argbuf (current_cpu, abuf, id, pc, fast_p);
52 @cpu@_fill_argbuf_tp (current_cpu, abuf, trace_p, profile_p);
54 /* FIXME: call x-before */
55 if (ARGBUF_PROFILE_P (abuf))
56 PROFILE_COUNT_INSN (current_cpu, pc, id->num);
57 /* FIXME: Later make cover macros: PROFILE_INSN_{INIT,FINI}. */
58 if (PROFILE_MODEL_P (current_cpu)
59 && ARGBUF_PROFILE_P (abuf))
60 @cpu@_model_insn_before (current_cpu, 1 /*first_p*/);
61 TRACE_INSN_INIT (current_cpu, abuf, 1);
62 TRACE_INSN (current_cpu, idata, abuf, pc);
64 (*id->sem_full) (current_cpu, sc, insn);
66 /* FIXME: call x-after */
67 if (PROFILE_MODEL_P (current_cpu)
68 && ARGBUF_PROFILE_P (abuf))
72 cycles = (*id->timing->model_fn) (current_cpu, sc);
73 @cpu@_model_insn_after (current_cpu, 1 /*last_p*/, cycles);
75 TRACE_INSN_FINI (current_cpu, abuf, 1);
80 do_annul (SIM_CPU *current_cpu)
82 IADDR npc = GET_H_NPC ();
84 /* ??? log profiling data */
85 /* ??? anything else */
103 # Inputs: current_cpu, sc, FAST_P
104 # Outputs: none, instruction is fetched and executed
105 # Recorded PC is updated after every insn.
106 # ??? Use of `sc' is a bit of a hack as we don't use the scache.
107 # We do however use ARGBUF so for consistency with the other engine flavours
113 if (GET_H_ANNUL_P ())
115 do_annul (current_cpu);
120 execute (current_cpu, sc);
129 echo "Invalid argument to mainloop.in: $1" >&2