* sparc-desc.c: New file.
[external/binutils.git] / sim / sparc / mloop64.in
1 # Simulator main loop for sparc64. -*- C -*-
2 # Copyright (C) 1999 Cygnus Solutions.
3
4 # Syntax:
5 # /bin/sh mainloop.in command
6 #
7 # Command is one of:
8 #
9 # init
10 # support
11 # extract-{simple,scache,pbb}
12 # {full,fast}-exec-{simple,scache,pbb}
13 #
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
17 # one of scache/pbb.
18 # A target can't provide more than this.
19
20 # ??? After a few more ports are done, revisit.
21 # Will eventually need to machine generate a lot of this.
22
23 case "x$1" in
24
25 xsupport)
26
27 cat <<EOF
28
29 static INLINE void
30 execute (SIM_CPU *current_cpu, SCACHE *sc)
31 {
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));
36
37   if (fast_p)
38     {
39       const IDESC *id = @cpu@_decode (current_cpu, pc, insn, insn, abuf);
40
41       @cpu@_fill_argbuf (current_cpu, abuf, id, pc, fast_p);
42       (*id->sem_full) (current_cpu, sc, insn);
43     }
44   else
45     {
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);
50
51       @cpu@_fill_argbuf (current_cpu, abuf, id, pc, fast_p);
52       @cpu@_fill_argbuf_tp (current_cpu, abuf, trace_p, profile_p);
53
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);
63
64       (*id->sem_full) (current_cpu, sc, insn);
65
66       /* FIXME: call x-after */
67       if (PROFILE_MODEL_P (current_cpu)
68           && ARGBUF_PROFILE_P (abuf))
69         {
70           int cycles;
71
72           cycles = (*id->timing->model_fn) (current_cpu, sc);
73           @cpu@_model_insn_after (current_cpu, 1 /*last_p*/, cycles);
74         }
75       TRACE_INSN_FINI (current_cpu, abuf, 1);
76     }
77 }
78
79 static INLINE void
80 do_annul (SIM_CPU *current_cpu)
81 {
82   IADDR npc = GET_H_NPC ();
83
84   /* ??? log profiling data */
85   /* ??? anything else */
86
87   SET_H_PC (npc);
88   SET_H_NPC (npc + 4);
89 }
90
91 EOF
92
93 ;;
94
95 xinit)
96
97 # Nothing needed.
98
99 ;;
100
101 xfull-exec-simple)
102
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
108 # sc is used.
109
110 cat <<EOF
111
112 {
113   if (GET_H_ANNUL_P ())
114     {
115       do_annul (current_cpu);
116       SET_H_ANNUL_P (0);
117     }
118   else
119     {
120       execute (current_cpu, sc);
121     }
122 }
123
124 EOF
125
126 ;;
127
128 *)
129   echo "Invalid argument to mainloop.in: $1" >&2
130   exit 1
131   ;;
132
133 esac