aboutsummaryrefslogtreecommitdiff
path: root/sim/m32r/mloopx.in
blob: 533aca5ad0e52ab036ad8b406d2a5f7943a474ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Simulator main loop for m32rx. -*- C -*-
# Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
#
# This file is part of the GNU Simulators.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# Syntax:
# /bin/sh mainloop.in init|support|{full,fast}-{extract,exec}-{scache,noscache}

# ??? After a few more ports are done, revisit.
# Will eventually need to machine generate a lot of this.

case "x$1" in

xsupport)

cat <<EOF

EOF

;;

xinit)

cat <<EOF
  USI insn,insn1,insn2;
  DECODE *decode,*d1,*d2;
  int icount,icount2;
  ARGBUF abufs[MAX_PARALLEL_INSNS];
  SEM_ARG sem_arg;

EOF

;;

xfull-extract-* | xfast-extract-*)

cat <<EOF
{
  PCADDR pc = CPU (h_pc);

  if ((pc & 3) != 0)
    {
      insn1 = GETIMEMUHI (current_cpu, pc);
      insn1 &= 0x7fff;
      d1 = m32rx_decode (current_cpu, pc, insn1);
      icount = 1;
    }
  else
    {
      insn1 = GETIMEMUSI (current_cpu, pc);
      if ((SI) insn1 < 0)
	{
	  d1 = m32rx_decode (current_cpu, pc, insn1 >> 16);
	  icount = 1;
	}
      else
	{
	  if (insn & 0x8000)
	    {
	      insn2 = insn1 & 0x7fff;
	      insn1 = insn1 >> 16;
	      d1 = m32rx_decode (current_cpu, pc, insn1);
	      d2 = m32rx_decode (current_cpu, pc, insn2);
	      icount = 2;
	    }
	  else
	    {
	      insn1 = insn1 >> 16;
	      d1 = m32rx_decode (current_cpu, pc, insn1);
	      icount = 1;
	    }
	}
    }

  icount2 = icount;
  insn = insn1;
  decode = d1;
  do
    {
#define DEFINE_SWITCH
#include "readx.c"

      insn = insn2;
      decode = d2;
    }
  while (--icount2 > 0);
}
EOF

;;

xfull-exec-* | xfast-exec-*)

cat <<EOF
{
  decode = d1;
  do
    {
      PCADDR new_pc;
      TRACE_INSN_INIT (current_cpu);
      TRACE_INSN (current_cpu, sc->argbuf.opcode, (const struct argbuf *) &sc->argbuf, sc->argbuf.addr);
      new_pc = (*decode->semantic) (current_cpu, &sc->argbuf);
      TRACE_INSN_FINI (current_cpu);
      PROFILE_COUNT_INSN (current_cpu, pc, CGEN_INSN_INDEX (sc->argbuf.opcode));
      CPU (h_pc) = new_pc;
      decode = d2;
    }
  while (--icount > 0);
}
EOF

;;

*)
  echo "Invalid argument to mainloop.in: $1" >&2
  exit 1
  ;;

esac