/* Engine header for Cpu tools GENerated simulators.
- Copyright (C) 1998, 1999, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file is part of GDB, the GNU debugger.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/* This file must be included after eng.h and before ${cpu}.h.
+/* This file is included by ${cpu}.h.
+ It needs CGEN_INSN_WORD which is defined by ${cpu}.h.
??? A lot of this could be moved to genmloop.sh to be put in eng.h
- and thus remove some conditional compilation. Worth it? */
+ and thus remove some conditional compilation. We'd still need
+ CGEN_INSN_WORD though. */
/* Semantic functions come in six versions on two axes:
fast/full-featured, and using one of the simple/scache/compilation engines.
/* Instruction field support macros. */
-#define EXTRACT_MSB0_INT(val, total, start, length) \
+#define EXTRACT_MSB0_SINT(val, total, start, length) \
(((INT) (val) << ((sizeof (INT) * 8) - (total) + (start))) \
>> ((sizeof (INT) * 8) - (length)))
#define EXTRACT_MSB0_UINT(val, total, start, length) \
(((UINT) (val) << ((sizeof (UINT) * 8) - (total) + (start))) \
>> ((sizeof (UINT) * 8) - (length)))
-#define EXTRACT_LSB0_INT(val, total, start, length) \
+#define EXTRACT_LSB0_SINT(val, total, start, length) \
(((INT) (val) << ((sizeof (INT) * 8) - (start) - 1)) \
>> ((sizeof (INT) * 8) - (length)))
#define EXTRACT_LSB0_UINT(val, total, start, length) \
(((UINT) (val) << ((sizeof (UINT) * 8) - (start) - 1)) \
>> ((sizeof (UINT) * 8) - (length)))
+
+#define EXTRACT_MSB0_LGSINT(val, total, start, length) \
+(((CGEN_INSN_LGSINT) (val) << ((sizeof (CGEN_INSN_LGSINT) * 8) - (total) + (start))) \
+ >> ((sizeof (CGEN_INSN_LGSINT) * 8) - (length)))
+#define EXTRACT_MSB0_LGUINT(val, total, start, length) \
+(((CGEN_INSN_UINT) (val) << ((sizeof (CGEN_INSN_LGUINT) * 8) - (total) + (start))) \
+ >> ((sizeof (CGEN_INSN_LGUINT) * 8) - (length)))
+
+#define EXTRACT_LSB0_LGSINT(val, total, start, length) \
+(((CGEN_INSN_LGSINT) (val) << ((sizeof (CGEN_INSN_LGSINT) * 8) - (start) - 1)) \
+ >> ((sizeof (CGEN_INSN_LGSINT) * 8) - (length)))
+#define EXTRACT_LSB0_LGUINT(val, total, start, length) \
+(((CGEN_INSN_LGUINT) (val) << ((sizeof (CGEN_INSN_LGUINT) * 8) - (start) - 1)) \
+ >> ((sizeof (CGEN_INSN_LGUINT) * 8) - (length)))
\f
/* Semantic routines. */
/* Type of the machine generated extraction fns. */
/* ??? No longer used. */
-typedef void (EXTRACT_FN) (SIM_CPU *, IADDR, CGEN_INSN_INT, ARGBUF *);
+typedef void (EXTRACT_FN) (SIM_CPU *, IADDR, CGEN_INSN_WORD, ARGBUF *);
/* Type of the machine generated semantic fns. */
/* Instruction fields are extracted by the semantic routine.
??? TODO: multi word insns. */
#if HAVE_PARALLEL_INSNS && ! WITH_PARALLEL_GENWRITE
-typedef SEM_STATUS (SEMANTIC_FN) (SIM_CPU *, SEM_ARG, PAREXEC *, CGEN_INSN_INT);
+typedef SEM_STATUS (SEMANTIC_FN) (SIM_CPU *, SEM_ARG, PAREXEC *, CGEN_INSN_WORD);
#else
-typedef SEM_STATUS (SEMANTIC_FN) (SIM_CPU *, SEM_ARG, CGEN_INSN_INT);
+typedef SEM_STATUS (SEMANTIC_FN) (SIM_CPU *, SEM_ARG, CGEN_INSN_WORD);
#endif
#endif
/* Return pointer to ARGBUF given ptr to SCACHE. */
#define SEM_ARGBUF(sem_arg) (& (sem_arg) -> argbuf)
-/* There are several styles of engines, all generally supported by the
- same code:
-
- WITH_SCACHE && WITH_SCACHE_PBB - pseudo-basic-block scaching
- WITH_SCACHE && !WITH_SCACHE_PBB - scaching on an insn by insn basis
- !WITH_SCACHE - simple engine: fetch an insn, execute an insn
-
- ??? The !WITH_SCACHE case can also be broken up into two flavours:
- extract the fields of the insn into an ARGBUF struct, or defer the
- extraction to the semantic handler. The WITH_SCACHE case always
- extracts the fields into an ARGBUF struct. */
-
#if WITH_SCACHE
#define CIA_ADDR(cia) (cia)