old-cross-binutils/sim/m32r/mloopx.in

134 lines
2.7 KiB
Text
Raw Normal View History

# 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