xref: /openbsd-src/gnu/usr.bin/binutils-2.17/include/opcode/mips.h (revision 5cffd0fab60657bcc687ecee270eb4b9b406d28e)
13d8817e4Smiod /* mips.h.  Mips opcode list for GDB, the GNU debugger.
23d8817e4Smiod    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
33d8817e4Smiod    2003, 2004, 2005
43d8817e4Smiod    Free Software Foundation, Inc.
53d8817e4Smiod    Contributed by Ralph Campbell and OSF
63d8817e4Smiod    Commented and modified by Ian Lance Taylor, Cygnus Support
73d8817e4Smiod 
83d8817e4Smiod This file is part of GDB, GAS, and the GNU binutils.
93d8817e4Smiod 
103d8817e4Smiod GDB, GAS, and the GNU binutils are free software; you can redistribute
113d8817e4Smiod them and/or modify them under the terms of the GNU General Public
123d8817e4Smiod License as published by the Free Software Foundation; either version
133d8817e4Smiod 1, or (at your option) any later version.
143d8817e4Smiod 
153d8817e4Smiod GDB, GAS, and the GNU binutils are distributed in the hope that they
163d8817e4Smiod will be useful, but WITHOUT ANY WARRANTY; without even the implied
173d8817e4Smiod warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
183d8817e4Smiod the GNU General Public License for more details.
193d8817e4Smiod 
203d8817e4Smiod You should have received a copy of the GNU General Public License
213d8817e4Smiod along with this file; see the file COPYING.  If not, write to the Free
223d8817e4Smiod Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
233d8817e4Smiod 
243d8817e4Smiod #ifndef _MIPS_H_
253d8817e4Smiod #define _MIPS_H_
263d8817e4Smiod 
273d8817e4Smiod /* These are bit masks and shift counts to use to access the various
283d8817e4Smiod    fields of an instruction.  To retrieve the X field of an
293d8817e4Smiod    instruction, use the expression
303d8817e4Smiod 	(i >> OP_SH_X) & OP_MASK_X
313d8817e4Smiod    To set the same field (to j), use
323d8817e4Smiod 	i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X)
333d8817e4Smiod 
343d8817e4Smiod    Make sure you use fields that are appropriate for the instruction,
353d8817e4Smiod    of course.
363d8817e4Smiod 
373d8817e4Smiod    The 'i' format uses OP, RS, RT and IMMEDIATE.
383d8817e4Smiod 
393d8817e4Smiod    The 'j' format uses OP and TARGET.
403d8817e4Smiod 
413d8817e4Smiod    The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT.
423d8817e4Smiod 
433d8817e4Smiod    The 'b' format uses OP, RS, RT and DELTA.
443d8817e4Smiod 
453d8817e4Smiod    The floating point 'i' format uses OP, RS, RT and IMMEDIATE.
463d8817e4Smiod 
473d8817e4Smiod    The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT.
483d8817e4Smiod 
493d8817e4Smiod    A breakpoint instruction uses OP, CODE and SPEC (10 bits of the
503d8817e4Smiod    breakpoint instruction are not defined; Kane says the breakpoint
513d8817e4Smiod    code field in BREAK is 20 bits; yet MIPS assemblers and debuggers
523d8817e4Smiod    only use ten bits).  An optional two-operand form of break/sdbbp
533d8817e4Smiod    allows the lower ten bits to be set too, and MIPS32 and later
543d8817e4Smiod    architectures allow 20 bits to be set with a signal operand
553d8817e4Smiod    (using CODE20).
563d8817e4Smiod 
573d8817e4Smiod    The syscall instruction uses CODE20.
583d8817e4Smiod 
593d8817e4Smiod    The general coprocessor instructions use COPZ.  */
603d8817e4Smiod 
613d8817e4Smiod #define OP_MASK_OP		0x3f
623d8817e4Smiod #define OP_SH_OP		26
633d8817e4Smiod #define OP_MASK_RS		0x1f
643d8817e4Smiod #define OP_SH_RS		21
653d8817e4Smiod #define OP_MASK_FR		0x1f
663d8817e4Smiod #define OP_SH_FR		21
673d8817e4Smiod #define OP_MASK_FMT		0x1f
683d8817e4Smiod #define OP_SH_FMT		21
693d8817e4Smiod #define OP_MASK_BCC		0x7
703d8817e4Smiod #define OP_SH_BCC		18
713d8817e4Smiod #define OP_MASK_CODE		0x3ff
723d8817e4Smiod #define OP_SH_CODE		16
733d8817e4Smiod #define OP_MASK_CODE2		0x3ff
743d8817e4Smiod #define OP_SH_CODE2		6
753d8817e4Smiod #define OP_MASK_RT		0x1f
763d8817e4Smiod #define OP_SH_RT		16
773d8817e4Smiod #define OP_MASK_FT		0x1f
783d8817e4Smiod #define OP_SH_FT		16
793d8817e4Smiod #define OP_MASK_CACHE		0x1f
803d8817e4Smiod #define OP_SH_CACHE		16
813d8817e4Smiod #define OP_MASK_RD		0x1f
823d8817e4Smiod #define OP_SH_RD		11
833d8817e4Smiod #define OP_MASK_FS		0x1f
843d8817e4Smiod #define OP_SH_FS		11
853d8817e4Smiod #define OP_MASK_PREFX		0x1f
863d8817e4Smiod #define OP_SH_PREFX		11
873d8817e4Smiod #define OP_MASK_CCC		0x7
883d8817e4Smiod #define OP_SH_CCC		8
893d8817e4Smiod #define OP_MASK_CODE20		0xfffff /* 20 bit syscall/breakpoint code.  */
903d8817e4Smiod #define OP_SH_CODE20		6
913d8817e4Smiod #define OP_MASK_SHAMT		0x1f
923d8817e4Smiod #define OP_SH_SHAMT		6
933d8817e4Smiod #define OP_MASK_FD		0x1f
943d8817e4Smiod #define OP_SH_FD		6
953d8817e4Smiod #define OP_MASK_TARGET		0x3ffffff
963d8817e4Smiod #define OP_SH_TARGET		0
973d8817e4Smiod #define OP_MASK_COPZ		0x1ffffff
983d8817e4Smiod #define OP_SH_COPZ		0
993d8817e4Smiod #define OP_MASK_IMMEDIATE	0xffff
1003d8817e4Smiod #define OP_SH_IMMEDIATE		0
1013d8817e4Smiod #define OP_MASK_DELTA		0xffff
1023d8817e4Smiod #define OP_SH_DELTA		0
1033d8817e4Smiod #define OP_MASK_FUNCT		0x3f
1043d8817e4Smiod #define OP_SH_FUNCT		0
1053d8817e4Smiod #define OP_MASK_SPEC		0x3f
1063d8817e4Smiod #define OP_SH_SPEC		0
1073d8817e4Smiod #define OP_SH_LOCC              8       /* FP condition code.  */
1083d8817e4Smiod #define OP_SH_HICC              18      /* FP condition code.  */
1093d8817e4Smiod #define OP_MASK_CC              0x7
1103d8817e4Smiod #define OP_SH_COP1NORM          25      /* Normal COP1 encoding.  */
1113d8817e4Smiod #define OP_MASK_COP1NORM        0x1     /* a single bit.  */
1123d8817e4Smiod #define OP_SH_COP1SPEC          21      /* COP1 encodings.  */
1133d8817e4Smiod #define OP_MASK_COP1SPEC        0xf
1143d8817e4Smiod #define OP_MASK_COP1SCLR        0x4
1153d8817e4Smiod #define OP_MASK_COP1CMP         0x3
1163d8817e4Smiod #define OP_SH_COP1CMP           4
1173d8817e4Smiod #define OP_SH_FORMAT            21      /* FP short format field.  */
1183d8817e4Smiod #define OP_MASK_FORMAT          0x7
1193d8817e4Smiod #define OP_SH_TRUE              16
1203d8817e4Smiod #define OP_MASK_TRUE            0x1
1213d8817e4Smiod #define OP_SH_GE                17
1223d8817e4Smiod #define OP_MASK_GE              0x01
1233d8817e4Smiod #define OP_SH_UNSIGNED          16
1243d8817e4Smiod #define OP_MASK_UNSIGNED        0x1
1253d8817e4Smiod #define OP_SH_HINT              16
1263d8817e4Smiod #define OP_MASK_HINT            0x1f
1273d8817e4Smiod #define OP_SH_MMI               0       /* Multimedia (parallel) op.  */
1283d8817e4Smiod #define OP_MASK_MMI             0x3f
1293d8817e4Smiod #define OP_SH_MMISUB            6
1303d8817e4Smiod #define OP_MASK_MMISUB          0x1f
1313d8817e4Smiod #define OP_MASK_PERFREG		0x1f	/* Performance monitoring.  */
1323d8817e4Smiod #define OP_SH_PERFREG		1
1333d8817e4Smiod #define OP_SH_SEL		0	/* Coprocessor select field.  */
1343d8817e4Smiod #define OP_MASK_SEL		0x7	/* The sel field of mfcZ and mtcZ.  */
1353d8817e4Smiod #define OP_SH_CODE19		6       /* 19 bit wait code.  */
1363d8817e4Smiod #define OP_MASK_CODE19		0x7ffff
1373d8817e4Smiod #define OP_SH_ALN		21
1383d8817e4Smiod #define OP_MASK_ALN		0x7
1393d8817e4Smiod #define OP_SH_VSEL		21
1403d8817e4Smiod #define OP_MASK_VSEL		0x1f
1413d8817e4Smiod #define OP_MASK_VECBYTE		0x7	/* Selector field is really 4 bits,
1423d8817e4Smiod 					   but 0x8-0xf don't select bytes.  */
1433d8817e4Smiod #define OP_SH_VECBYTE		22
1443d8817e4Smiod #define OP_MASK_VECALIGN	0x7	/* Vector byte-align (alni.ob) op.  */
1453d8817e4Smiod #define OP_SH_VECALIGN		21
1463d8817e4Smiod #define OP_MASK_INSMSB		0x1f	/* "ins" MSB.  */
1473d8817e4Smiod #define OP_SH_INSMSB		11
1483d8817e4Smiod #define OP_MASK_EXTMSBD		0x1f	/* "ext" MSBD.  */
1493d8817e4Smiod #define OP_SH_EXTMSBD		11
1503d8817e4Smiod 
1513d8817e4Smiod /* MIPS DSP ASE */
1523d8817e4Smiod #define OP_SH_DSPACC		11
1533d8817e4Smiod #define OP_MASK_DSPACC  	0x3
1543d8817e4Smiod #define OP_SH_DSPACC_S  	21
1553d8817e4Smiod #define OP_MASK_DSPACC_S	0x3
1563d8817e4Smiod #define OP_SH_DSPSFT		20
1573d8817e4Smiod #define OP_MASK_DSPSFT  	0x3f
1583d8817e4Smiod #define OP_SH_DSPSFT_7  	19
1593d8817e4Smiod #define OP_MASK_DSPSFT_7	0x7f
1603d8817e4Smiod #define OP_SH_SA3		21
1613d8817e4Smiod #define OP_MASK_SA3		0x7
1623d8817e4Smiod #define OP_SH_SA4		21
1633d8817e4Smiod #define OP_MASK_SA4		0xf
1643d8817e4Smiod #define OP_SH_IMM8		16
1653d8817e4Smiod #define OP_MASK_IMM8		0xff
1663d8817e4Smiod #define OP_SH_IMM10		16
1673d8817e4Smiod #define OP_MASK_IMM10		0x3ff
1683d8817e4Smiod #define OP_SH_WRDSP		11
1693d8817e4Smiod #define OP_MASK_WRDSP		0x3f
1703d8817e4Smiod #define OP_SH_RDDSP		16
1713d8817e4Smiod #define OP_MASK_RDDSP		0x3f
1723d8817e4Smiod 
1733d8817e4Smiod /* MIPS MT ASE */
1743d8817e4Smiod #define OP_SH_MT_U		5
1753d8817e4Smiod #define OP_MASK_MT_U		0x1
1763d8817e4Smiod #define OP_SH_MT_H		4
1773d8817e4Smiod #define OP_MASK_MT_H		0x1
1783d8817e4Smiod #define OP_SH_MTACC_T		18
1793d8817e4Smiod #define OP_MASK_MTACC_T		0x3
1803d8817e4Smiod #define OP_SH_MTACC_D		13
1813d8817e4Smiod #define OP_MASK_MTACC_D		0x3
1823d8817e4Smiod 
1833d8817e4Smiod #define	OP_OP_COP0		0x10
1843d8817e4Smiod #define	OP_OP_COP1		0x11
1853d8817e4Smiod #define	OP_OP_COP2		0x12
1863d8817e4Smiod #define	OP_OP_COP3		0x13
1873d8817e4Smiod #define	OP_OP_LWC1		0x31
1883d8817e4Smiod #define	OP_OP_LWC2		0x32
1893d8817e4Smiod #define	OP_OP_LWC3		0x33	/* a.k.a. pref */
1903d8817e4Smiod #define	OP_OP_LDC1		0x35
1913d8817e4Smiod #define	OP_OP_LDC2		0x36
1923d8817e4Smiod #define	OP_OP_LDC3		0x37	/* a.k.a. ld */
1933d8817e4Smiod #define	OP_OP_SWC1		0x39
1943d8817e4Smiod #define	OP_OP_SWC2		0x3a
1953d8817e4Smiod #define	OP_OP_SWC3		0x3b
1963d8817e4Smiod #define	OP_OP_SDC1		0x3d
1973d8817e4Smiod #define	OP_OP_SDC2		0x3e
1983d8817e4Smiod #define	OP_OP_SDC3		0x3f	/* a.k.a. sd */
1993d8817e4Smiod 
2003d8817e4Smiod /* Values in the 'VSEL' field.  */
2013d8817e4Smiod #define MDMX_FMTSEL_IMM_QH	0x1d
2023d8817e4Smiod #define MDMX_FMTSEL_IMM_OB	0x1e
2033d8817e4Smiod #define MDMX_FMTSEL_VEC_QH	0x15
2043d8817e4Smiod #define MDMX_FMTSEL_VEC_OB	0x16
2053d8817e4Smiod 
2063d8817e4Smiod /* This structure holds information for a particular instruction.  */
2073d8817e4Smiod 
2083d8817e4Smiod struct mips_opcode
2093d8817e4Smiod {
2103d8817e4Smiod   /* The name of the instruction.  */
2113d8817e4Smiod   const char *name;
2123d8817e4Smiod   /* A string describing the arguments for this instruction.  */
2133d8817e4Smiod   const char *args;
2143d8817e4Smiod   /* The basic opcode for the instruction.  When assembling, this
2153d8817e4Smiod      opcode is modified by the arguments to produce the actual opcode
2163d8817e4Smiod      that is used.  If pinfo is INSN_MACRO, then this is 0.  */
2173d8817e4Smiod   unsigned long match;
2183d8817e4Smiod   /* If pinfo is not INSN_MACRO, then this is a bit mask for the
2193d8817e4Smiod      relevant portions of the opcode when disassembling.  If the
2203d8817e4Smiod      actual opcode anded with the match field equals the opcode field,
2213d8817e4Smiod      then we have found the correct instruction.  If pinfo is
2223d8817e4Smiod      INSN_MACRO, then this field is the macro identifier.  */
2233d8817e4Smiod   unsigned long mask;
2243d8817e4Smiod   /* For a macro, this is INSN_MACRO.  Otherwise, it is a collection
2253d8817e4Smiod      of bits describing the instruction, notably any relevant hazard
2263d8817e4Smiod      information.  */
2273d8817e4Smiod   unsigned long pinfo;
2283d8817e4Smiod   /* A collection of additional bits describing the instruction. */
2293d8817e4Smiod   unsigned long pinfo2;
2303d8817e4Smiod   /* A collection of bits describing the instruction sets of which this
2313d8817e4Smiod      instruction or macro is a member. */
2323d8817e4Smiod   unsigned long membership;
2333d8817e4Smiod };
2343d8817e4Smiod 
2353d8817e4Smiod /* These are the characters which may appear in the args field of an
2363d8817e4Smiod    instruction.  They appear in the order in which the fields appear
2373d8817e4Smiod    when the instruction is used.  Commas and parentheses in the args
2383d8817e4Smiod    string are ignored when assembling, and written into the output
2393d8817e4Smiod    when disassembling.
2403d8817e4Smiod 
2413d8817e4Smiod    Each of these characters corresponds to a mask field defined above.
2423d8817e4Smiod 
2433d8817e4Smiod    "<" 5 bit shift amount (OP_*_SHAMT)
2443d8817e4Smiod    ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
2453d8817e4Smiod    "a" 26 bit target address (OP_*_TARGET)
2463d8817e4Smiod    "b" 5 bit base register (OP_*_RS)
2473d8817e4Smiod    "c" 10 bit breakpoint code (OP_*_CODE)
2483d8817e4Smiod    "d" 5 bit destination register specifier (OP_*_RD)
2493d8817e4Smiod    "h" 5 bit prefx hint (OP_*_PREFX)
2503d8817e4Smiod    "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
2513d8817e4Smiod    "j" 16 bit signed immediate (OP_*_DELTA)
2523d8817e4Smiod    "k" 5 bit cache opcode in target register position (OP_*_CACHE)
2533d8817e4Smiod        Also used for immediate operands in vr5400 vector insns.
2543d8817e4Smiod    "o" 16 bit signed offset (OP_*_DELTA)
2553d8817e4Smiod    "p" 16 bit PC relative branch target address (OP_*_DELTA)
2563d8817e4Smiod    "q" 10 bit extra breakpoint code (OP_*_CODE2)
2573d8817e4Smiod    "r" 5 bit same register used as both source and target (OP_*_RS)
2583d8817e4Smiod    "s" 5 bit source register specifier (OP_*_RS)
2593d8817e4Smiod    "t" 5 bit target register (OP_*_RT)
2603d8817e4Smiod    "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
2613d8817e4Smiod    "v" 5 bit same register used as both source and destination (OP_*_RS)
2623d8817e4Smiod    "w" 5 bit same register used as both target and destination (OP_*_RT)
2633d8817e4Smiod    "U" 5 bit same destination register in both OP_*_RD and OP_*_RT
2643d8817e4Smiod        (used by clo and clz)
2653d8817e4Smiod    "C" 25 bit coprocessor function code (OP_*_COPZ)
2663d8817e4Smiod    "B" 20 bit syscall/breakpoint function code (OP_*_CODE20)
2673d8817e4Smiod    "J" 19 bit wait function code (OP_*_CODE19)
2683d8817e4Smiod    "x" accept and ignore register name
2693d8817e4Smiod    "z" must be zero register
2703d8817e4Smiod    "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD)
2713d8817e4Smiod    "+A" 5 bit ins/ext position, which becomes LSB (OP_*_SHAMT).
2723d8817e4Smiod 	Enforces: 0 <= pos < 32.
2733d8817e4Smiod    "+B" 5 bit ins size, which becomes MSB (OP_*_INSMSB).
2743d8817e4Smiod 	Requires that "+A" or "+E" occur first to set position.
2753d8817e4Smiod 	Enforces: 0 < (pos+size) <= 32.
2763d8817e4Smiod    "+C" 5 bit ext size, which becomes MSBD (OP_*_EXTMSBD).
2773d8817e4Smiod 	Requires that "+A" or "+E" occur first to set position.
2783d8817e4Smiod 	Enforces: 0 < (pos+size) <= 32.
2793d8817e4Smiod 	(Also used by "dext" w/ different limits, but limits for
2803d8817e4Smiod 	that are checked by the M_DEXT macro.)
2813d8817e4Smiod    "+E" 5 bit dins/dext position, which becomes LSB-32 (OP_*_SHAMT).
2823d8817e4Smiod 	Enforces: 32 <= pos < 64.
2833d8817e4Smiod    "+F" 5 bit "dinsm" size, which becomes MSB-32 (OP_*_INSMSB).
2843d8817e4Smiod 	Requires that "+A" or "+E" occur first to set position.
2853d8817e4Smiod 	Enforces: 32 < (pos+size) <= 64.
2863d8817e4Smiod    "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD).
2873d8817e4Smiod 	Requires that "+A" or "+E" occur first to set position.
2883d8817e4Smiod 	Enforces: 32 < (pos+size) <= 64.
2893d8817e4Smiod    "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD).
2903d8817e4Smiod 	Requires that "+A" or "+E" occur first to set position.
2913d8817e4Smiod 	Enforces: 32 < (pos+size) <= 64.
2923d8817e4Smiod 
2933d8817e4Smiod    Floating point instructions:
2943d8817e4Smiod    "D" 5 bit destination register (OP_*_FD)
2953d8817e4Smiod    "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
2963d8817e4Smiod    "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
2973d8817e4Smiod    "S" 5 bit fs source 1 register (OP_*_FS)
2983d8817e4Smiod    "T" 5 bit ft source 2 register (OP_*_FT)
2993d8817e4Smiod    "R" 5 bit fr source 3 register (OP_*_FR)
3003d8817e4Smiod    "V" 5 bit same register used as floating source and destination (OP_*_FS)
3013d8817e4Smiod    "W" 5 bit same register used as floating target and destination (OP_*_FT)
3023d8817e4Smiod 
3033d8817e4Smiod    Coprocessor instructions:
3043d8817e4Smiod    "E" 5 bit target register (OP_*_RT)
3053d8817e4Smiod    "G" 5 bit destination register (OP_*_RD)
3063d8817e4Smiod    "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL)
3073d8817e4Smiod    "P" 5 bit performance-monitor register (OP_*_PERFREG)
3083d8817e4Smiod    "e" 5 bit vector register byte specifier (OP_*_VECBYTE)
3093d8817e4Smiod    "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN)
3103d8817e4Smiod    see also "k" above
3113d8817e4Smiod    "+D" Combined destination register ("G") and sel ("H") for CP0 ops,
3123d8817e4Smiod 	for pretty-printing in disassembly only.
3133d8817e4Smiod 
3143d8817e4Smiod    Macro instructions:
3153d8817e4Smiod    "A" General 32 bit expression
3163d8817e4Smiod    "I" 32 bit immediate (value placed in imm_expr).
3173d8817e4Smiod    "+I" 32 bit immediate (value placed in imm2_expr).
3183d8817e4Smiod    "F" 64 bit floating point constant in .rdata
3193d8817e4Smiod    "L" 64 bit floating point constant in .lit8
3203d8817e4Smiod    "f" 32 bit floating point constant
3213d8817e4Smiod    "l" 32 bit floating point constant in .lit4
3223d8817e4Smiod 
3233d8817e4Smiod    MDMX instruction operands (note that while these use the FP register
3243d8817e4Smiod    fields, they accept both $fN and $vN names for the registers):
3253d8817e4Smiod    "O"	MDMX alignment offset (OP_*_ALN)
3263d8817e4Smiod    "Q"	MDMX vector/scalar/immediate source (OP_*_VSEL and OP_*_FT)
3273d8817e4Smiod    "X"	MDMX destination register (OP_*_FD)
3283d8817e4Smiod    "Y"	MDMX source register (OP_*_FS)
3293d8817e4Smiod    "Z"	MDMX source register (OP_*_FT)
3303d8817e4Smiod 
3313d8817e4Smiod    DSP ASE usage:
3323d8817e4Smiod    "3" 3 bit unsigned immediate (OP_*_SA3)
3333d8817e4Smiod    "4" 4 bit unsigned immediate (OP_*_SA4)
3343d8817e4Smiod    "5" 8 bit unsigned immediate (OP_*_IMM8)
3353d8817e4Smiod    "6" 5 bit unsigned immediate (OP_*_RS)
3363d8817e4Smiod    "7" 2 bit dsp accumulator register (OP_*_DSPACC)
3373d8817e4Smiod    "8" 6 bit unsigned immediate (OP_*_WRDSP)
3383d8817e4Smiod    "9" 2 bit dsp accumulator register (OP_*_DSPACC_S)
3393d8817e4Smiod    "0" 6 bit signed immediate (OP_*_DSPSFT)
3403d8817e4Smiod    ":" 7 bit signed immediate (OP_*_DSPSFT_7)
3413d8817e4Smiod    "'" 6 bit unsigned immediate (OP_*_RDDSP)
3423d8817e4Smiod    "@" 10 bit signed immediate (OP_*_IMM10)
3433d8817e4Smiod 
3443d8817e4Smiod    MT ASE usage:
3453d8817e4Smiod    "!" 1 bit immediate at bit 5
3463d8817e4Smiod    "$" 1 bit immediate at bit 4
3473d8817e4Smiod    "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T)
3483d8817e4Smiod    "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D)
3493d8817e4Smiod    "g" 5 bit coprocessor 1 and 2 destination register (OP_*_RD)
3503d8817e4Smiod    "+t" 5 bit coprocessor 0 destination register (OP_*_RT)
3513d8817e4Smiod    "+T" 5 bit coprocessor 0 destination register (OP_*_RT) - disassembly only
3523d8817e4Smiod 
3533d8817e4Smiod    Other:
3543d8817e4Smiod    "()" parens surrounding optional value
3553d8817e4Smiod    ","  separates operands
3563d8817e4Smiod    "[]" brackets around index for vector-op scalar operand specifier (vr5400)
3573d8817e4Smiod    "+"  Start of extension sequence.
3583d8817e4Smiod 
3593d8817e4Smiod    Characters used so far, for quick reference when adding more:
3603d8817e4Smiod    "34567890"
3613d8817e4Smiod    "%[]<>(),+:'@!$*&"
3623d8817e4Smiod    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3633d8817e4Smiod    "abcdefghijklopqrstuvwxz"
3643d8817e4Smiod 
3653d8817e4Smiod    Extension character sequences used so far ("+" followed by the
3663d8817e4Smiod    following), for quick reference when adding more:
3673d8817e4Smiod    "ABCDEFGHIT"
3683d8817e4Smiod    "t"
3693d8817e4Smiod */
3703d8817e4Smiod 
3713d8817e4Smiod /* These are the bits which may be set in the pinfo field of an
3723d8817e4Smiod    instructions, if it is not equal to INSN_MACRO.  */
3733d8817e4Smiod 
3743d8817e4Smiod /* Modifies the general purpose register in OP_*_RD.  */
3753d8817e4Smiod #define INSN_WRITE_GPR_D            0x00000001
3763d8817e4Smiod /* Modifies the general purpose register in OP_*_RT.  */
3773d8817e4Smiod #define INSN_WRITE_GPR_T            0x00000002
3783d8817e4Smiod /* Modifies general purpose register 31.  */
3793d8817e4Smiod #define INSN_WRITE_GPR_31           0x00000004
3803d8817e4Smiod /* Modifies the floating point register in OP_*_FD.  */
3813d8817e4Smiod #define INSN_WRITE_FPR_D            0x00000008
3823d8817e4Smiod /* Modifies the floating point register in OP_*_FS.  */
3833d8817e4Smiod #define INSN_WRITE_FPR_S            0x00000010
3843d8817e4Smiod /* Modifies the floating point register in OP_*_FT.  */
3853d8817e4Smiod #define INSN_WRITE_FPR_T            0x00000020
3863d8817e4Smiod /* Reads the general purpose register in OP_*_RS.  */
3873d8817e4Smiod #define INSN_READ_GPR_S             0x00000040
3883d8817e4Smiod /* Reads the general purpose register in OP_*_RT.  */
3893d8817e4Smiod #define INSN_READ_GPR_T             0x00000080
3903d8817e4Smiod /* Reads the floating point register in OP_*_FS.  */
3913d8817e4Smiod #define INSN_READ_FPR_S             0x00000100
3923d8817e4Smiod /* Reads the floating point register in OP_*_FT.  */
3933d8817e4Smiod #define INSN_READ_FPR_T             0x00000200
3943d8817e4Smiod /* Reads the floating point register in OP_*_FR.  */
3953d8817e4Smiod #define INSN_READ_FPR_R		    0x00000400
3963d8817e4Smiod /* Modifies coprocessor condition code.  */
3973d8817e4Smiod #define INSN_WRITE_COND_CODE        0x00000800
3983d8817e4Smiod /* Reads coprocessor condition code.  */
3993d8817e4Smiod #define INSN_READ_COND_CODE         0x00001000
4003d8817e4Smiod /* TLB operation.  */
4013d8817e4Smiod #define INSN_TLB                    0x00002000
4023d8817e4Smiod /* Reads coprocessor register other than floating point register.  */
4033d8817e4Smiod #define INSN_COP                    0x00004000
4043d8817e4Smiod /* Instruction loads value from memory, requiring delay.  */
4053d8817e4Smiod #define INSN_LOAD_MEMORY_DELAY      0x00008000
4063d8817e4Smiod /* Instruction loads value from coprocessor, requiring delay.  */
4073d8817e4Smiod #define INSN_LOAD_COPROC_DELAY	    0x00010000
4083d8817e4Smiod /* Instruction has unconditional branch delay slot.  */
4093d8817e4Smiod #define INSN_UNCOND_BRANCH_DELAY    0x00020000
4103d8817e4Smiod /* Instruction has conditional branch delay slot.  */
4113d8817e4Smiod #define INSN_COND_BRANCH_DELAY      0x00040000
4123d8817e4Smiod /* Conditional branch likely: if branch not taken, insn nullified.  */
4133d8817e4Smiod #define INSN_COND_BRANCH_LIKELY	    0x00080000
4143d8817e4Smiod /* Moves to coprocessor register, requiring delay.  */
4153d8817e4Smiod #define INSN_COPROC_MOVE_DELAY      0x00100000
4163d8817e4Smiod /* Loads coprocessor register from memory, requiring delay.  */
4173d8817e4Smiod #define INSN_COPROC_MEMORY_DELAY    0x00200000
4183d8817e4Smiod /* Reads the HI register.  */
4193d8817e4Smiod #define INSN_READ_HI		    0x00400000
4203d8817e4Smiod /* Reads the LO register.  */
4213d8817e4Smiod #define INSN_READ_LO		    0x00800000
4223d8817e4Smiod /* Modifies the HI register.  */
4233d8817e4Smiod #define INSN_WRITE_HI		    0x01000000
4243d8817e4Smiod /* Modifies the LO register.  */
4253d8817e4Smiod #define INSN_WRITE_LO		    0x02000000
4263d8817e4Smiod /* Takes a trap (easier to keep out of delay slot).  */
4273d8817e4Smiod #define INSN_TRAP                   0x04000000
4283d8817e4Smiod /* Instruction stores value into memory.  */
4293d8817e4Smiod #define INSN_STORE_MEMORY	    0x08000000
4303d8817e4Smiod /* Instruction uses single precision floating point.  */
4313d8817e4Smiod #define FP_S			    0x10000000
4323d8817e4Smiod /* Instruction uses double precision floating point.  */
4333d8817e4Smiod #define FP_D			    0x20000000
4343d8817e4Smiod /* Instruction is part of the tx39's integer multiply family.    */
4353d8817e4Smiod #define INSN_MULT                   0x40000000
4363d8817e4Smiod /* Instruction synchronize shared memory.  */
4373d8817e4Smiod #define INSN_SYNC		    0x80000000
4383d8817e4Smiod 
4393d8817e4Smiod /* These are the bits which may be set in the pinfo2 field of an
4403d8817e4Smiod    instruction. */
4413d8817e4Smiod 
4423d8817e4Smiod /* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */
4433d8817e4Smiod #define	INSN2_ALIAS		    0x00000001
4443d8817e4Smiod /* Instruction reads MDMX accumulator. */
4453d8817e4Smiod #define INSN2_READ_MDMX_ACC	    0x00000002
4463d8817e4Smiod /* Instruction writes MDMX accumulator. */
4473d8817e4Smiod #define INSN2_WRITE_MDMX_ACC	    0x00000004
4483d8817e4Smiod 
4493d8817e4Smiod /* Instruction is actually a macro.  It should be ignored by the
4503d8817e4Smiod    disassembler, and requires special treatment by the assembler.  */
4513d8817e4Smiod #define INSN_MACRO                  0xffffffff
4523d8817e4Smiod 
4533d8817e4Smiod /* Masks used to mark instructions to indicate which MIPS ISA level
4543d8817e4Smiod    they were introduced in.  ISAs, as defined below, are logical
4553d8817e4Smiod    ORs of these bits, indicating that they support the instructions
4563d8817e4Smiod    defined at the given level.  */
4573d8817e4Smiod 
4583d8817e4Smiod #define INSN_ISA_MASK		  0x00000fff
4593d8817e4Smiod #define INSN_ISA1                 0x00000001
4603d8817e4Smiod #define INSN_ISA2                 0x00000002
4613d8817e4Smiod #define INSN_ISA3                 0x00000004
4623d8817e4Smiod #define INSN_ISA4                 0x00000008
4633d8817e4Smiod #define INSN_ISA5                 0x00000010
4643d8817e4Smiod #define INSN_ISA32                0x00000020
4653d8817e4Smiod #define INSN_ISA64                0x00000040
4663d8817e4Smiod #define INSN_ISA32R2              0x00000080
4673d8817e4Smiod #define INSN_ISA64R2              0x00000100
4683d8817e4Smiod 
4693d8817e4Smiod /* Masks used for MIPS-defined ASEs.  */
4703d8817e4Smiod #define INSN_ASE_MASK		  0x0400f000
4713d8817e4Smiod 
4723d8817e4Smiod /* DSP ASE */
4733d8817e4Smiod #define INSN_DSP                  0x00001000
4743d8817e4Smiod /* MIPS 16 ASE */
4753d8817e4Smiod #define INSN_MIPS16               0x00002000
4763d8817e4Smiod /* MIPS-3D ASE */
4773d8817e4Smiod #define INSN_MIPS3D               0x00004000
4783d8817e4Smiod /* MDMX ASE */
4793d8817e4Smiod #define INSN_MDMX                 0x00008000
4803d8817e4Smiod 
4813d8817e4Smiod /* Chip specific instructions.  These are bitmasks.  */
4823d8817e4Smiod 
483*5cffd0faSpirofti #define INSN_CHIP_MASK            0x0bff0000
484*5cffd0faSpirofti 
4853d8817e4Smiod /* MIPS R4650 instruction.  */
4863d8817e4Smiod #define INSN_4650                 0x00010000
4873d8817e4Smiod /* LSI R4010 instruction.  */
4883d8817e4Smiod #define INSN_4010                 0x00020000
4893d8817e4Smiod /* NEC VR4100 instruction.  */
4903d8817e4Smiod #define INSN_4100                 0x00040000
4913d8817e4Smiod /* Toshiba R3900 instruction.  */
4923d8817e4Smiod #define INSN_3900                 0x00080000
4933d8817e4Smiod /* MIPS R10000 instruction.  */
4943d8817e4Smiod #define INSN_10000                0x00100000
4953d8817e4Smiod /* Broadcom SB-1 instruction.  */
4963d8817e4Smiod #define INSN_SB1                  0x00200000
4973d8817e4Smiod /* NEC VR4111/VR4181 instruction.  */
4983d8817e4Smiod #define INSN_4111                 0x00400000
4993d8817e4Smiod /* NEC VR4120 instruction.  */
5003d8817e4Smiod #define INSN_4120                 0x00800000
5013d8817e4Smiod /* NEC VR5400 instruction.  */
5023d8817e4Smiod #define INSN_5400		  0x01000000
5033d8817e4Smiod /* NEC VR5500 instruction.  */
5043d8817e4Smiod #define INSN_5500		  0x02000000
5053d8817e4Smiod /* MT ASE */
5063d8817e4Smiod #define INSN_MT                   0x04000000
507*5cffd0faSpirofti /* Cavium Networks Octeon instruction.  */
508*5cffd0faSpirofti #define INSN_OCTEON               0x08000000
509*5cffd0faSpirofti 
5103d8817e4Smiod 
5113d8817e4Smiod /* MIPS ISA defines, use instead of hardcoding ISA level.  */
5123d8817e4Smiod 
5133d8817e4Smiod #define       ISA_UNKNOWN     0               /* Gas internal use.  */
5143d8817e4Smiod #define       ISA_MIPS1       (INSN_ISA1)
5153d8817e4Smiod #define       ISA_MIPS2       (ISA_MIPS1 | INSN_ISA2)
5163d8817e4Smiod #define       ISA_MIPS3       (ISA_MIPS2 | INSN_ISA3)
5173d8817e4Smiod #define       ISA_MIPS4       (ISA_MIPS3 | INSN_ISA4)
5183d8817e4Smiod #define       ISA_MIPS5       (ISA_MIPS4 | INSN_ISA5)
5193d8817e4Smiod 
5203d8817e4Smiod #define       ISA_MIPS32      (ISA_MIPS2 | INSN_ISA32)
5213d8817e4Smiod #define       ISA_MIPS64      (ISA_MIPS5 | INSN_ISA32 | INSN_ISA64)
5223d8817e4Smiod 
5233d8817e4Smiod #define       ISA_MIPS32R2    (ISA_MIPS32 | INSN_ISA32R2)
5243d8817e4Smiod #define       ISA_MIPS64R2    (ISA_MIPS64 | INSN_ISA32R2 | INSN_ISA64R2)
5253d8817e4Smiod 
5263d8817e4Smiod 
5273d8817e4Smiod /* CPU defines, use instead of hardcoding processor number. Keep this
5283d8817e4Smiod    in sync with bfd/archures.c in order for machine selection to work.  */
5293d8817e4Smiod #define CPU_UNKNOWN	0               /* Gas internal use.  */
5303d8817e4Smiod #define CPU_R3000	3000
5313d8817e4Smiod #define CPU_R3900	3900
5323d8817e4Smiod #define CPU_R4000	4000
5333d8817e4Smiod #define CPU_R4010	4010
5343d8817e4Smiod #define CPU_VR4100	4100
5353d8817e4Smiod #define CPU_R4111	4111
5363d8817e4Smiod #define CPU_VR4120	4120
5373d8817e4Smiod #define CPU_R4300	4300
5383d8817e4Smiod #define CPU_R4400	4400
5393d8817e4Smiod #define CPU_R4600	4600
5403d8817e4Smiod #define CPU_R4650	4650
5413d8817e4Smiod #define CPU_R5000	5000
5423d8817e4Smiod #define CPU_VR5400	5400
5433d8817e4Smiod #define CPU_VR5500	5500
5443d8817e4Smiod #define CPU_R6000	6000
5453d8817e4Smiod #define CPU_RM7000	7000
5463d8817e4Smiod #define CPU_R8000	8000
5473d8817e4Smiod #define CPU_RM9000	9000
5483d8817e4Smiod #define CPU_R10000	10000
5493d8817e4Smiod #define CPU_R12000	12000
5503d8817e4Smiod #define CPU_MIPS16	16
5513d8817e4Smiod #define CPU_MIPS32	32
5523d8817e4Smiod #define CPU_MIPS32R2	33
5533d8817e4Smiod #define CPU_MIPS5       5
5543d8817e4Smiod #define CPU_MIPS64      64
5553d8817e4Smiod #define CPU_MIPS64R2	65
5563d8817e4Smiod #define CPU_SB1         12310201        /* octal 'SB', 01.  */
557*5cffd0faSpirofti #define CPU_OCTEON	6501
5583d8817e4Smiod 
5593d8817e4Smiod /* Test for membership in an ISA including chip specific ISAs.  INSN
5603d8817e4Smiod    is pointer to an element of the opcode table; ISA is the specified
5613d8817e4Smiod    ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
5623d8817e4Smiod    test, or zero if no CPU specific ISA test is desired.  */
5633d8817e4Smiod 
5643d8817e4Smiod #define OPCODE_IS_MEMBER(insn, isa, cpu)				\
5653d8817e4Smiod     (((insn)->membership & isa) != 0					\
5663d8817e4Smiod      || (cpu == CPU_R4650 && ((insn)->membership & INSN_4650) != 0)	\
5673d8817e4Smiod      || (cpu == CPU_RM7000 && ((insn)->membership & INSN_4650) != 0)	\
5683d8817e4Smiod      || (cpu == CPU_RM9000 && ((insn)->membership & INSN_4650) != 0)	\
5693d8817e4Smiod      || (cpu == CPU_R4010 && ((insn)->membership & INSN_4010) != 0)	\
5703d8817e4Smiod      || (cpu == CPU_VR4100 && ((insn)->membership & INSN_4100) != 0)	\
5713d8817e4Smiod      || (cpu == CPU_R3900 && ((insn)->membership & INSN_3900) != 0)	\
5723d8817e4Smiod      || ((cpu == CPU_R10000 || cpu == CPU_R12000)			\
5733d8817e4Smiod 	 && ((insn)->membership & INSN_10000) != 0)			\
5743d8817e4Smiod      || (cpu == CPU_SB1 && ((insn)->membership & INSN_SB1) != 0)	\
5753d8817e4Smiod      || (cpu == CPU_R4111 && ((insn)->membership & INSN_4111) != 0)	\
5763d8817e4Smiod      || (cpu == CPU_VR4120 && ((insn)->membership & INSN_4120) != 0)	\
5773d8817e4Smiod      || (cpu == CPU_VR5400 && ((insn)->membership & INSN_5400) != 0)	\
5783d8817e4Smiod      || (cpu == CPU_VR5500 && ((insn)->membership & INSN_5500) != 0)	\
579*5cffd0faSpirofti      || (cpu == CPU_OCTEON && ((insn)->membership & INSN_OCTEON) != 0)	\
5803d8817e4Smiod      || 0)	/* Please keep this term for easier source merging.  */
5813d8817e4Smiod 
5823d8817e4Smiod /* This is a list of macro expanded instructions.
5833d8817e4Smiod 
5843d8817e4Smiod    _I appended means immediate
5853d8817e4Smiod    _A appended means address
5863d8817e4Smiod    _AB appended means address with base register
5873d8817e4Smiod    _D appended means 64 bit floating point constant
5883d8817e4Smiod    _S appended means 32 bit floating point constant.  */
5893d8817e4Smiod 
5903d8817e4Smiod enum
5913d8817e4Smiod {
5923d8817e4Smiod   M_ABS,
5933d8817e4Smiod   M_ADD_I,
5943d8817e4Smiod   M_ADDU_I,
5953d8817e4Smiod   M_AND_I,
5963d8817e4Smiod   M_BEQ,
5973d8817e4Smiod   M_BEQ_I,
5983d8817e4Smiod   M_BEQL_I,
5993d8817e4Smiod   M_BGE,
6003d8817e4Smiod   M_BGEL,
6013d8817e4Smiod   M_BGE_I,
6023d8817e4Smiod   M_BGEL_I,
6033d8817e4Smiod   M_BGEU,
6043d8817e4Smiod   M_BGEUL,
6053d8817e4Smiod   M_BGEU_I,
6063d8817e4Smiod   M_BGEUL_I,
6073d8817e4Smiod   M_BGT,
6083d8817e4Smiod   M_BGTL,
6093d8817e4Smiod   M_BGT_I,
6103d8817e4Smiod   M_BGTL_I,
6113d8817e4Smiod   M_BGTU,
6123d8817e4Smiod   M_BGTUL,
6133d8817e4Smiod   M_BGTU_I,
6143d8817e4Smiod   M_BGTUL_I,
6153d8817e4Smiod   M_BLE,
6163d8817e4Smiod   M_BLEL,
6173d8817e4Smiod   M_BLE_I,
6183d8817e4Smiod   M_BLEL_I,
6193d8817e4Smiod   M_BLEU,
6203d8817e4Smiod   M_BLEUL,
6213d8817e4Smiod   M_BLEU_I,
6223d8817e4Smiod   M_BLEUL_I,
6233d8817e4Smiod   M_BLT,
6243d8817e4Smiod   M_BLTL,
6253d8817e4Smiod   M_BLT_I,
6263d8817e4Smiod   M_BLTL_I,
6273d8817e4Smiod   M_BLTU,
6283d8817e4Smiod   M_BLTUL,
6293d8817e4Smiod   M_BLTU_I,
6303d8817e4Smiod   M_BLTUL_I,
6313d8817e4Smiod   M_BNE,
6323d8817e4Smiod   M_BNE_I,
6333d8817e4Smiod   M_BNEL_I,
6343d8817e4Smiod   M_DABS,
6353d8817e4Smiod   M_DADD_I,
6363d8817e4Smiod   M_DADDU_I,
6373d8817e4Smiod   M_DDIV_3,
6383d8817e4Smiod   M_DDIV_3I,
6393d8817e4Smiod   M_DDIVU_3,
6403d8817e4Smiod   M_DDIVU_3I,
6413d8817e4Smiod   M_DEXT,
6423d8817e4Smiod   M_DINS,
6433d8817e4Smiod   M_DIV_3,
6443d8817e4Smiod   M_DIV_3I,
6453d8817e4Smiod   M_DIVU_3,
6463d8817e4Smiod   M_DIVU_3I,
6473d8817e4Smiod   M_DLA_AB,
6483d8817e4Smiod   M_DLCA_AB,
6493d8817e4Smiod   M_DLI,
6503d8817e4Smiod   M_DMUL,
6513d8817e4Smiod   M_DMUL_I,
6523d8817e4Smiod   M_DMULO,
6533d8817e4Smiod   M_DMULO_I,
6543d8817e4Smiod   M_DMULOU,
6553d8817e4Smiod   M_DMULOU_I,
6563d8817e4Smiod   M_DREM_3,
6573d8817e4Smiod   M_DREM_3I,
6583d8817e4Smiod   M_DREMU_3,
6593d8817e4Smiod   M_DREMU_3I,
6603d8817e4Smiod   M_DSUB_I,
6613d8817e4Smiod   M_DSUBU_I,
6623d8817e4Smiod   M_DSUBU_I_2,
663d2386abeSmiod   M_JR_S,
664d2386abeSmiod   M_J_S,
6653d8817e4Smiod   M_J_A,
666d2386abeSmiod   M_JALR_S,
667d2386abeSmiod   M_JALR_DS,
6683d8817e4Smiod   M_JAL_1,
6693d8817e4Smiod   M_JAL_2,
6703d8817e4Smiod   M_JAL_A,
6713d8817e4Smiod   M_L_DOB,
6723d8817e4Smiod   M_L_DAB,
6733d8817e4Smiod   M_LA_AB,
6743d8817e4Smiod   M_LB_A,
6753d8817e4Smiod   M_LB_AB,
6763d8817e4Smiod   M_LBU_A,
6773d8817e4Smiod   M_LBU_AB,
6783d8817e4Smiod   M_LCA_AB,
6793d8817e4Smiod   M_LD_A,
6803d8817e4Smiod   M_LD_OB,
6813d8817e4Smiod   M_LD_AB,
6823d8817e4Smiod   M_LDC1_AB,
6833d8817e4Smiod   M_LDC2_AB,
6843d8817e4Smiod   M_LDC3_AB,
6853d8817e4Smiod   M_LDL_AB,
6863d8817e4Smiod   M_LDR_AB,
6873d8817e4Smiod   M_LH_A,
6883d8817e4Smiod   M_LH_AB,
6893d8817e4Smiod   M_LHU_A,
6903d8817e4Smiod   M_LHU_AB,
6913d8817e4Smiod   M_LI,
6923d8817e4Smiod   M_LI_D,
6933d8817e4Smiod   M_LI_DD,
6943d8817e4Smiod   M_LI_S,
6953d8817e4Smiod   M_LI_SS,
6963d8817e4Smiod   M_LL_AB,
6973d8817e4Smiod   M_LLD_AB,
6983d8817e4Smiod   M_LS_A,
6993d8817e4Smiod   M_LW_A,
7003d8817e4Smiod   M_LW_AB,
7013d8817e4Smiod   M_LWC0_A,
7023d8817e4Smiod   M_LWC0_AB,
7033d8817e4Smiod   M_LWC1_A,
7043d8817e4Smiod   M_LWC1_AB,
7053d8817e4Smiod   M_LWC2_A,
7063d8817e4Smiod   M_LWC2_AB,
7073d8817e4Smiod   M_LWC3_A,
7083d8817e4Smiod   M_LWC3_AB,
7093d8817e4Smiod   M_LWL_A,
7103d8817e4Smiod   M_LWL_AB,
7113d8817e4Smiod   M_LWR_A,
7123d8817e4Smiod   M_LWR_AB,
7133d8817e4Smiod   M_LWU_AB,
7143d8817e4Smiod   M_MOVE,
7153d8817e4Smiod   M_MUL,
7163d8817e4Smiod   M_MUL_I,
7173d8817e4Smiod   M_MULO,
7183d8817e4Smiod   M_MULO_I,
7193d8817e4Smiod   M_MULOU,
7203d8817e4Smiod   M_MULOU_I,
7213d8817e4Smiod   M_NOR_I,
7223d8817e4Smiod   M_OR_I,
7233d8817e4Smiod   M_REM_3,
7243d8817e4Smiod   M_REM_3I,
7253d8817e4Smiod   M_REMU_3,
7263d8817e4Smiod   M_REMU_3I,
7273d8817e4Smiod   M_DROL,
7283d8817e4Smiod   M_ROL,
7293d8817e4Smiod   M_DROL_I,
7303d8817e4Smiod   M_ROL_I,
7313d8817e4Smiod   M_DROR,
7323d8817e4Smiod   M_ROR,
7333d8817e4Smiod   M_DROR_I,
7343d8817e4Smiod   M_ROR_I,
7353d8817e4Smiod   M_S_DA,
7363d8817e4Smiod   M_S_DOB,
7373d8817e4Smiod   M_S_DAB,
7383d8817e4Smiod   M_S_S,
7393d8817e4Smiod   M_SC_AB,
7403d8817e4Smiod   M_SCD_AB,
7413d8817e4Smiod   M_SD_A,
7423d8817e4Smiod   M_SD_OB,
7433d8817e4Smiod   M_SD_AB,
7443d8817e4Smiod   M_SDC1_AB,
7453d8817e4Smiod   M_SDC2_AB,
7463d8817e4Smiod   M_SDC3_AB,
7473d8817e4Smiod   M_SDL_AB,
7483d8817e4Smiod   M_SDR_AB,
7493d8817e4Smiod   M_SEQ,
7503d8817e4Smiod   M_SEQ_I,
7513d8817e4Smiod   M_SGE,
7523d8817e4Smiod   M_SGE_I,
7533d8817e4Smiod   M_SGEU,
7543d8817e4Smiod   M_SGEU_I,
7553d8817e4Smiod   M_SGT,
7563d8817e4Smiod   M_SGT_I,
7573d8817e4Smiod   M_SGTU,
7583d8817e4Smiod   M_SGTU_I,
7593d8817e4Smiod   M_SLE,
7603d8817e4Smiod   M_SLE_I,
7613d8817e4Smiod   M_SLEU,
7623d8817e4Smiod   M_SLEU_I,
7633d8817e4Smiod   M_SLT_I,
7643d8817e4Smiod   M_SLTU_I,
7653d8817e4Smiod   M_SNE,
7663d8817e4Smiod   M_SNE_I,
7673d8817e4Smiod   M_SB_A,
7683d8817e4Smiod   M_SB_AB,
7693d8817e4Smiod   M_SH_A,
7703d8817e4Smiod   M_SH_AB,
7713d8817e4Smiod   M_SW_A,
7723d8817e4Smiod   M_SW_AB,
7733d8817e4Smiod   M_SWC0_A,
7743d8817e4Smiod   M_SWC0_AB,
7753d8817e4Smiod   M_SWC1_A,
7763d8817e4Smiod   M_SWC1_AB,
7773d8817e4Smiod   M_SWC2_A,
7783d8817e4Smiod   M_SWC2_AB,
7793d8817e4Smiod   M_SWC3_A,
7803d8817e4Smiod   M_SWC3_AB,
7813d8817e4Smiod   M_SWL_A,
7823d8817e4Smiod   M_SWL_AB,
7833d8817e4Smiod   M_SWR_A,
7843d8817e4Smiod   M_SWR_AB,
7853d8817e4Smiod   M_SUB_I,
7863d8817e4Smiod   M_SUBU_I,
7873d8817e4Smiod   M_SUBU_I_2,
7883d8817e4Smiod   M_TEQ_I,
7893d8817e4Smiod   M_TGE_I,
7903d8817e4Smiod   M_TGEU_I,
7913d8817e4Smiod   M_TLT_I,
7923d8817e4Smiod   M_TLTU_I,
7933d8817e4Smiod   M_TNE_I,
7943d8817e4Smiod   M_TRUNCWD,
7953d8817e4Smiod   M_TRUNCWS,
7963d8817e4Smiod   M_ULD,
7973d8817e4Smiod   M_ULD_A,
7983d8817e4Smiod   M_ULH,
7993d8817e4Smiod   M_ULH_A,
8003d8817e4Smiod   M_ULHU,
8013d8817e4Smiod   M_ULHU_A,
8023d8817e4Smiod   M_ULW,
8033d8817e4Smiod   M_ULW_A,
8043d8817e4Smiod   M_USH,
8053d8817e4Smiod   M_USH_A,
8063d8817e4Smiod   M_USW,
8073d8817e4Smiod   M_USW_A,
8083d8817e4Smiod   M_USD,
8093d8817e4Smiod   M_USD_A,
8103d8817e4Smiod   M_XOR_I,
8113d8817e4Smiod   M_COP0,
8123d8817e4Smiod   M_COP1,
8133d8817e4Smiod   M_COP2,
8143d8817e4Smiod   M_COP3,
8153d8817e4Smiod   M_NUM_MACROS
8163d8817e4Smiod };
8173d8817e4Smiod 
8183d8817e4Smiod 
8193d8817e4Smiod /* The order of overloaded instructions matters.  Label arguments and
8203d8817e4Smiod    register arguments look the same. Instructions that can have either
8213d8817e4Smiod    for arguments must apear in the correct order in this table for the
8223d8817e4Smiod    assembler to pick the right one. In other words, entries with
8233d8817e4Smiod    immediate operands must apear after the same instruction with
8243d8817e4Smiod    registers.
8253d8817e4Smiod 
8263d8817e4Smiod    Many instructions are short hand for other instructions (i.e., The
8273d8817e4Smiod    jal <register> instruction is short for jalr <register>).  */
8283d8817e4Smiod 
8293d8817e4Smiod extern const struct mips_opcode mips_builtin_opcodes[];
8303d8817e4Smiod extern const int bfd_mips_num_builtin_opcodes;
8313d8817e4Smiod extern struct mips_opcode *mips_opcodes;
8323d8817e4Smiod extern int bfd_mips_num_opcodes;
8333d8817e4Smiod #define NUMOPCODES bfd_mips_num_opcodes
8343d8817e4Smiod 
8353d8817e4Smiod 
8363d8817e4Smiod /* The rest of this file adds definitions for the mips16 TinyRISC
8373d8817e4Smiod    processor.  */
8383d8817e4Smiod 
8393d8817e4Smiod /* These are the bitmasks and shift counts used for the different
8403d8817e4Smiod    fields in the instruction formats.  Other than OP, no masks are
8413d8817e4Smiod    provided for the fixed portions of an instruction, since they are
8423d8817e4Smiod    not needed.
8433d8817e4Smiod 
8443d8817e4Smiod    The I format uses IMM11.
8453d8817e4Smiod 
8463d8817e4Smiod    The RI format uses RX and IMM8.
8473d8817e4Smiod 
8483d8817e4Smiod    The RR format uses RX, and RY.
8493d8817e4Smiod 
8503d8817e4Smiod    The RRI format uses RX, RY, and IMM5.
8513d8817e4Smiod 
8523d8817e4Smiod    The RRR format uses RX, RY, and RZ.
8533d8817e4Smiod 
8543d8817e4Smiod    The RRI_A format uses RX, RY, and IMM4.
8553d8817e4Smiod 
8563d8817e4Smiod    The SHIFT format uses RX, RY, and SHAMT.
8573d8817e4Smiod 
8583d8817e4Smiod    The I8 format uses IMM8.
8593d8817e4Smiod 
8603d8817e4Smiod    The I8_MOVR32 format uses RY and REGR32.
8613d8817e4Smiod 
8623d8817e4Smiod    The IR_MOV32R format uses REG32R and MOV32Z.
8633d8817e4Smiod 
8643d8817e4Smiod    The I64 format uses IMM8.
8653d8817e4Smiod 
8663d8817e4Smiod    The RI64 format uses RY and IMM5.
8673d8817e4Smiod    */
8683d8817e4Smiod 
8693d8817e4Smiod #define MIPS16OP_MASK_OP	0x1f
8703d8817e4Smiod #define MIPS16OP_SH_OP		11
8713d8817e4Smiod #define MIPS16OP_MASK_IMM11	0x7ff
8723d8817e4Smiod #define MIPS16OP_SH_IMM11	0
8733d8817e4Smiod #define MIPS16OP_MASK_RX	0x7
8743d8817e4Smiod #define MIPS16OP_SH_RX		8
8753d8817e4Smiod #define MIPS16OP_MASK_IMM8	0xff
8763d8817e4Smiod #define MIPS16OP_SH_IMM8	0
8773d8817e4Smiod #define MIPS16OP_MASK_RY	0x7
8783d8817e4Smiod #define MIPS16OP_SH_RY		5
8793d8817e4Smiod #define MIPS16OP_MASK_IMM5	0x1f
8803d8817e4Smiod #define MIPS16OP_SH_IMM5	0
8813d8817e4Smiod #define MIPS16OP_MASK_RZ	0x7
8823d8817e4Smiod #define MIPS16OP_SH_RZ		2
8833d8817e4Smiod #define MIPS16OP_MASK_IMM4	0xf
8843d8817e4Smiod #define MIPS16OP_SH_IMM4	0
8853d8817e4Smiod #define MIPS16OP_MASK_REGR32	0x1f
8863d8817e4Smiod #define MIPS16OP_SH_REGR32	0
8873d8817e4Smiod #define MIPS16OP_MASK_REG32R	0x1f
8883d8817e4Smiod #define MIPS16OP_SH_REG32R	3
8893d8817e4Smiod #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
8903d8817e4Smiod #define MIPS16OP_MASK_MOVE32Z	0x7
8913d8817e4Smiod #define MIPS16OP_SH_MOVE32Z	0
8923d8817e4Smiod #define MIPS16OP_MASK_IMM6	0x3f
8933d8817e4Smiod #define MIPS16OP_SH_IMM6	5
8943d8817e4Smiod 
8953d8817e4Smiod /* These are the characters which may appears in the args field of an
8963d8817e4Smiod    instruction.  They appear in the order in which the fields appear
8973d8817e4Smiod    when the instruction is used.  Commas and parentheses in the args
8983d8817e4Smiod    string are ignored when assembling, and written into the output
8993d8817e4Smiod    when disassembling.
9003d8817e4Smiod 
9013d8817e4Smiod    "y" 3 bit register (MIPS16OP_*_RY)
9023d8817e4Smiod    "x" 3 bit register (MIPS16OP_*_RX)
9033d8817e4Smiod    "z" 3 bit register (MIPS16OP_*_RZ)
9043d8817e4Smiod    "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
9053d8817e4Smiod    "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
9063d8817e4Smiod    "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
9073d8817e4Smiod    "0" zero register ($0)
9083d8817e4Smiod    "S" stack pointer ($sp or $29)
9093d8817e4Smiod    "P" program counter
9103d8817e4Smiod    "R" return address register ($ra or $31)
9113d8817e4Smiod    "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
9123d8817e4Smiod    "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
9133d8817e4Smiod    "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
9143d8817e4Smiod    "a" 26 bit jump address
9153d8817e4Smiod    "e" 11 bit extension value
9163d8817e4Smiod    "l" register list for entry instruction
9173d8817e4Smiod    "L" register list for exit instruction
9183d8817e4Smiod 
9193d8817e4Smiod    The remaining codes may be extended.  Except as otherwise noted,
9203d8817e4Smiod    the full extended operand is a 16 bit signed value.
9213d8817e4Smiod    "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
9223d8817e4Smiod    ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned)
9233d8817e4Smiod    "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
9243d8817e4Smiod    "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
9253d8817e4Smiod    "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
9263d8817e4Smiod    "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
9273d8817e4Smiod    "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
9283d8817e4Smiod    "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
9293d8817e4Smiod    "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
9303d8817e4Smiod    "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
9313d8817e4Smiod    "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
9323d8817e4Smiod    "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
9333d8817e4Smiod    "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
9343d8817e4Smiod    "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
9353d8817e4Smiod    "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
9363d8817e4Smiod    "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
9373d8817e4Smiod    "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
9383d8817e4Smiod    "q" 11 bit branch address (MIPS16OP_*_IMM11)
9393d8817e4Smiod    "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
9403d8817e4Smiod    "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
9413d8817e4Smiod    "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
9423d8817e4Smiod    "m" 7 bit register list for save instruction (18 bit extended)
9433d8817e4Smiod    "M" 7 bit register list for restore instruction (18 bit extended)
9443d8817e4Smiod   */
9453d8817e4Smiod 
9463d8817e4Smiod /* Save/restore encoding for the args field when all 4 registers are
9473d8817e4Smiod    either saved as arguments or saved/restored as statics.  */
9483d8817e4Smiod #define MIPS16_ALL_ARGS    0xe
9493d8817e4Smiod #define MIPS16_ALL_STATICS 0xb
9503d8817e4Smiod 
9513d8817e4Smiod /* For the mips16, we use the same opcode table format and a few of
9523d8817e4Smiod    the same flags.  However, most of the flags are different.  */
9533d8817e4Smiod 
9543d8817e4Smiod /* Modifies the register in MIPS16OP_*_RX.  */
9553d8817e4Smiod #define MIPS16_INSN_WRITE_X		    0x00000001
9563d8817e4Smiod /* Modifies the register in MIPS16OP_*_RY.  */
9573d8817e4Smiod #define MIPS16_INSN_WRITE_Y		    0x00000002
9583d8817e4Smiod /* Modifies the register in MIPS16OP_*_RZ.  */
9593d8817e4Smiod #define MIPS16_INSN_WRITE_Z		    0x00000004
9603d8817e4Smiod /* Modifies the T ($24) register.  */
9613d8817e4Smiod #define MIPS16_INSN_WRITE_T		    0x00000008
9623d8817e4Smiod /* Modifies the SP ($29) register.  */
9633d8817e4Smiod #define MIPS16_INSN_WRITE_SP		    0x00000010
9643d8817e4Smiod /* Modifies the RA ($31) register.  */
9653d8817e4Smiod #define MIPS16_INSN_WRITE_31		    0x00000020
9663d8817e4Smiod /* Modifies the general purpose register in MIPS16OP_*_REG32R.  */
9673d8817e4Smiod #define MIPS16_INSN_WRITE_GPR_Y		    0x00000040
9683d8817e4Smiod /* Reads the register in MIPS16OP_*_RX.  */
9693d8817e4Smiod #define MIPS16_INSN_READ_X		    0x00000080
9703d8817e4Smiod /* Reads the register in MIPS16OP_*_RY.  */
9713d8817e4Smiod #define MIPS16_INSN_READ_Y		    0x00000100
9723d8817e4Smiod /* Reads the register in MIPS16OP_*_MOVE32Z.  */
9733d8817e4Smiod #define MIPS16_INSN_READ_Z		    0x00000200
9743d8817e4Smiod /* Reads the T ($24) register.  */
9753d8817e4Smiod #define MIPS16_INSN_READ_T		    0x00000400
9763d8817e4Smiod /* Reads the SP ($29) register.  */
9773d8817e4Smiod #define MIPS16_INSN_READ_SP		    0x00000800
9783d8817e4Smiod /* Reads the RA ($31) register.  */
9793d8817e4Smiod #define MIPS16_INSN_READ_31		    0x00001000
9803d8817e4Smiod /* Reads the program counter.  */
9813d8817e4Smiod #define MIPS16_INSN_READ_PC		    0x00002000
9823d8817e4Smiod /* Reads the general purpose register in MIPS16OP_*_REGR32.  */
9833d8817e4Smiod #define MIPS16_INSN_READ_GPR_X		    0x00004000
9843d8817e4Smiod /* Is a branch insn. */
9853d8817e4Smiod #define MIPS16_INSN_BRANCH                  0x00010000
9863d8817e4Smiod 
9873d8817e4Smiod /* The following flags have the same value for the mips16 opcode
9883d8817e4Smiod    table:
9893d8817e4Smiod    INSN_UNCOND_BRANCH_DELAY
9903d8817e4Smiod    INSN_COND_BRANCH_DELAY
9913d8817e4Smiod    INSN_COND_BRANCH_LIKELY (never used)
9923d8817e4Smiod    INSN_READ_HI
9933d8817e4Smiod    INSN_READ_LO
9943d8817e4Smiod    INSN_WRITE_HI
9953d8817e4Smiod    INSN_WRITE_LO
9963d8817e4Smiod    INSN_TRAP
9973d8817e4Smiod    INSN_ISA3
9983d8817e4Smiod    */
9993d8817e4Smiod 
10003d8817e4Smiod extern const struct mips_opcode mips16_opcodes[];
10013d8817e4Smiod extern const int bfd_mips16_num_opcodes;
10023d8817e4Smiod 
10033d8817e4Smiod #endif /* _MIPS_H_ */
1004