12159047fSniklas /* mips.h. Mips opcode list for GDB, the GNU debugger. 2c074d1c9Sdrahn Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 3b55d4692Sfgsch Free Software Foundation, Inc. 42159047fSniklas Contributed by Ralph Campbell and OSF 52159047fSniklas Commented and modified by Ian Lance Taylor, Cygnus Support 62159047fSniklas 72159047fSniklas This file is part of GDB, GAS, and the GNU binutils. 82159047fSniklas 92159047fSniklas GDB, GAS, and the GNU binutils are free software; you can redistribute 102159047fSniklas them and/or modify them under the terms of the GNU General Public 112159047fSniklas License as published by the Free Software Foundation; either version 122159047fSniklas 1, or (at your option) any later version. 132159047fSniklas 142159047fSniklas GDB, GAS, and the GNU binutils are distributed in the hope that they 152159047fSniklas will be useful, but WITHOUT ANY WARRANTY; without even the implied 162159047fSniklas warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 172159047fSniklas the GNU General Public License for more details. 182159047fSniklas 192159047fSniklas You should have received a copy of the GNU General Public License 202159047fSniklas along with this file; see the file COPYING. If not, write to the Free 212159047fSniklas Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 222159047fSniklas 23b305b0f1Sespie #ifndef _MIPS_H_ 24b305b0f1Sespie #define _MIPS_H_ 25b305b0f1Sespie 262159047fSniklas /* These are bit masks and shift counts to use to access the various 272159047fSniklas fields of an instruction. To retrieve the X field of an 282159047fSniklas instruction, use the expression 292159047fSniklas (i >> OP_SH_X) & OP_MASK_X 302159047fSniklas To set the same field (to j), use 312159047fSniklas i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X) 322159047fSniklas 332159047fSniklas Make sure you use fields that are appropriate for the instruction, 342159047fSniklas of course. 352159047fSniklas 362159047fSniklas The 'i' format uses OP, RS, RT and IMMEDIATE. 372159047fSniklas 382159047fSniklas The 'j' format uses OP and TARGET. 392159047fSniklas 402159047fSniklas The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT. 412159047fSniklas 422159047fSniklas The 'b' format uses OP, RS, RT and DELTA. 432159047fSniklas 442159047fSniklas The floating point 'i' format uses OP, RS, RT and IMMEDIATE. 452159047fSniklas 462159047fSniklas The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT. 472159047fSniklas 482159047fSniklas A breakpoint instruction uses OP, CODE and SPEC (10 bits of the 492159047fSniklas breakpoint instruction are not defined; Kane says the breakpoint 502159047fSniklas code field in BREAK is 20 bits; yet MIPS assemblers and debuggers 51b305b0f1Sespie only use ten bits). An optional two-operand form of break/sdbbp 52b55d4692Sfgsch allows the lower ten bits to be set too, and MIPS32 and later 53b55d4692Sfgsch architectures allow 20 bits to be set with a signal operand 54b55d4692Sfgsch (using CODE20). 552159047fSniklas 56b55d4692Sfgsch The syscall instruction uses CODE20. 572159047fSniklas 582159047fSniklas The general coprocessor instructions use COPZ. */ 592159047fSniklas 602159047fSniklas #define OP_MASK_OP 0x3f 612159047fSniklas #define OP_SH_OP 26 622159047fSniklas #define OP_MASK_RS 0x1f 632159047fSniklas #define OP_SH_RS 21 642159047fSniklas #define OP_MASK_FR 0x1f 652159047fSniklas #define OP_SH_FR 21 662159047fSniklas #define OP_MASK_FMT 0x1f 672159047fSniklas #define OP_SH_FMT 21 682159047fSniklas #define OP_MASK_BCC 0x7 692159047fSniklas #define OP_SH_BCC 18 702159047fSniklas #define OP_MASK_CODE 0x3ff 712159047fSniklas #define OP_SH_CODE 16 72b305b0f1Sespie #define OP_MASK_CODE2 0x3ff 73b305b0f1Sespie #define OP_SH_CODE2 6 742159047fSniklas #define OP_MASK_RT 0x1f 752159047fSniklas #define OP_SH_RT 16 762159047fSniklas #define OP_MASK_FT 0x1f 772159047fSniklas #define OP_SH_FT 16 782159047fSniklas #define OP_MASK_CACHE 0x1f 792159047fSniklas #define OP_SH_CACHE 16 802159047fSniklas #define OP_MASK_RD 0x1f 812159047fSniklas #define OP_SH_RD 11 822159047fSniklas #define OP_MASK_FS 0x1f 832159047fSniklas #define OP_SH_FS 11 842159047fSniklas #define OP_MASK_PREFX 0x1f 852159047fSniklas #define OP_SH_PREFX 11 862159047fSniklas #define OP_MASK_CCC 0x7 872159047fSniklas #define OP_SH_CCC 8 88b55d4692Sfgsch #define OP_MASK_CODE20 0xfffff /* 20 bit syscall/breakpoint code. */ 89b55d4692Sfgsch #define OP_SH_CODE20 6 902159047fSniklas #define OP_MASK_SHAMT 0x1f 912159047fSniklas #define OP_SH_SHAMT 6 922159047fSniklas #define OP_MASK_FD 0x1f 932159047fSniklas #define OP_SH_FD 6 942159047fSniklas #define OP_MASK_TARGET 0x3ffffff 952159047fSniklas #define OP_SH_TARGET 0 962159047fSniklas #define OP_MASK_COPZ 0x1ffffff 972159047fSniklas #define OP_SH_COPZ 0 982159047fSniklas #define OP_MASK_IMMEDIATE 0xffff 992159047fSniklas #define OP_SH_IMMEDIATE 0 1002159047fSniklas #define OP_MASK_DELTA 0xffff 1012159047fSniklas #define OP_SH_DELTA 0 1022159047fSniklas #define OP_MASK_FUNCT 0x3f 1032159047fSniklas #define OP_SH_FUNCT 0 1042159047fSniklas #define OP_MASK_SPEC 0x3f 1052159047fSniklas #define OP_SH_SPEC 0 106b55d4692Sfgsch #define OP_SH_LOCC 8 /* FP condition code. */ 107b55d4692Sfgsch #define OP_SH_HICC 18 /* FP condition code. */ 1084361b62eSniklas #define OP_MASK_CC 0x7 109b55d4692Sfgsch #define OP_SH_COP1NORM 25 /* Normal COP1 encoding. */ 110b55d4692Sfgsch #define OP_MASK_COP1NORM 0x1 /* a single bit. */ 111b55d4692Sfgsch #define OP_SH_COP1SPEC 21 /* COP1 encodings. */ 1124361b62eSniklas #define OP_MASK_COP1SPEC 0xf 1134361b62eSniklas #define OP_MASK_COP1SCLR 0x4 1144361b62eSniklas #define OP_MASK_COP1CMP 0x3 1154361b62eSniklas #define OP_SH_COP1CMP 4 116b55d4692Sfgsch #define OP_SH_FORMAT 21 /* FP short format field. */ 1174361b62eSniklas #define OP_MASK_FORMAT 0x7 1184361b62eSniklas #define OP_SH_TRUE 16 1194361b62eSniklas #define OP_MASK_TRUE 0x1 1204361b62eSniklas #define OP_SH_GE 17 1214361b62eSniklas #define OP_MASK_GE 0x01 1224361b62eSniklas #define OP_SH_UNSIGNED 16 1234361b62eSniklas #define OP_MASK_UNSIGNED 0x1 1244361b62eSniklas #define OP_SH_HINT 16 1254361b62eSniklas #define OP_MASK_HINT 0x1f 126b55d4692Sfgsch #define OP_SH_MMI 0 /* Multimedia (parallel) op. */ 127b305b0f1Sespie #define OP_MASK_MMI 0x3f 128b305b0f1Sespie #define OP_SH_MMISUB 6 129b305b0f1Sespie #define OP_MASK_MMISUB 0x1f 130b55d4692Sfgsch #define OP_MASK_PERFREG 0x1f /* Performance monitoring. */ 131b305b0f1Sespie #define OP_SH_PERFREG 1 132b55d4692Sfgsch #define OP_SH_SEL 0 /* Coprocessor select field. */ 133b55d4692Sfgsch #define OP_MASK_SEL 0x7 /* The sel field of mfcZ and mtcZ. */ 134b55d4692Sfgsch #define OP_SH_CODE19 6 /* 19 bit wait code. */ 135b55d4692Sfgsch #define OP_MASK_CODE19 0x7ffff 136c074d1c9Sdrahn #define OP_SH_ALN 21 137c074d1c9Sdrahn #define OP_MASK_ALN 0x7 138c074d1c9Sdrahn #define OP_SH_VSEL 21 139c074d1c9Sdrahn #define OP_MASK_VSEL 0x1f 140c074d1c9Sdrahn #define OP_MASK_VECBYTE 0x7 /* Selector field is really 4 bits, 141c074d1c9Sdrahn but 0x8-0xf don't select bytes. */ 142c074d1c9Sdrahn #define OP_SH_VECBYTE 22 143c074d1c9Sdrahn #define OP_MASK_VECALIGN 0x7 /* Vector byte-align (alni.ob) op. */ 144c074d1c9Sdrahn #define OP_SH_VECALIGN 21 145c074d1c9Sdrahn #define OP_MASK_INSMSB 0x1f /* "ins" MSB. */ 146c074d1c9Sdrahn #define OP_SH_INSMSB 11 147c074d1c9Sdrahn #define OP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */ 148c074d1c9Sdrahn #define OP_SH_EXTMSBD 11 149c074d1c9Sdrahn 150c074d1c9Sdrahn #define OP_OP_COP0 0x10 151c074d1c9Sdrahn #define OP_OP_COP1 0x11 152c074d1c9Sdrahn #define OP_OP_COP2 0x12 153c074d1c9Sdrahn #define OP_OP_COP3 0x13 154c074d1c9Sdrahn #define OP_OP_LWC1 0x31 155c074d1c9Sdrahn #define OP_OP_LWC2 0x32 156c074d1c9Sdrahn #define OP_OP_LWC3 0x33 /* a.k.a. pref */ 157c074d1c9Sdrahn #define OP_OP_LDC1 0x35 158c074d1c9Sdrahn #define OP_OP_LDC2 0x36 159c074d1c9Sdrahn #define OP_OP_LDC3 0x37 /* a.k.a. ld */ 160c074d1c9Sdrahn #define OP_OP_SWC1 0x39 161c074d1c9Sdrahn #define OP_OP_SWC2 0x3a 162c074d1c9Sdrahn #define OP_OP_SWC3 0x3b 163c074d1c9Sdrahn #define OP_OP_SDC1 0x3d 164c074d1c9Sdrahn #define OP_OP_SDC2 0x3e 165c074d1c9Sdrahn #define OP_OP_SDC3 0x3f /* a.k.a. sd */ 166c074d1c9Sdrahn 167c074d1c9Sdrahn /* Values in the 'VSEL' field. */ 168c074d1c9Sdrahn #define MDMX_FMTSEL_IMM_QH 0x1d 169c074d1c9Sdrahn #define MDMX_FMTSEL_IMM_OB 0x1e 170c074d1c9Sdrahn #define MDMX_FMTSEL_VEC_QH 0x15 171c074d1c9Sdrahn #define MDMX_FMTSEL_VEC_OB 0x16 1722159047fSniklas 1732159047fSniklas /* This structure holds information for a particular instruction. */ 1742159047fSniklas 1752159047fSniklas struct mips_opcode 1762159047fSniklas { 1772159047fSniklas /* The name of the instruction. */ 1782159047fSniklas const char *name; 1792159047fSniklas /* A string describing the arguments for this instruction. */ 1802159047fSniklas const char *args; 1812159047fSniklas /* The basic opcode for the instruction. When assembling, this 1822159047fSniklas opcode is modified by the arguments to produce the actual opcode 183b305b0f1Sespie that is used. If pinfo is INSN_MACRO, then this is 0. */ 1842159047fSniklas unsigned long match; 1852159047fSniklas /* If pinfo is not INSN_MACRO, then this is a bit mask for the 1862159047fSniklas relevant portions of the opcode when disassembling. If the 1872159047fSniklas actual opcode anded with the match field equals the opcode field, 1882159047fSniklas then we have found the correct instruction. If pinfo is 1892159047fSniklas INSN_MACRO, then this field is the macro identifier. */ 1902159047fSniklas unsigned long mask; 1912159047fSniklas /* For a macro, this is INSN_MACRO. Otherwise, it is a collection 1922159047fSniklas of bits describing the instruction, notably any relevant hazard 1932159047fSniklas information. */ 1942159047fSniklas unsigned long pinfo; 195b305b0f1Sespie /* A collection of bits describing the instruction sets of which this 196b305b0f1Sespie instruction or macro is a member. */ 197b305b0f1Sespie unsigned long membership; 1982159047fSniklas }; 1992159047fSniklas 200c074d1c9Sdrahn /* These are the characters which may appear in the args field of an 2012159047fSniklas instruction. They appear in the order in which the fields appear 2022159047fSniklas when the instruction is used. Commas and parentheses in the args 2032159047fSniklas string are ignored when assembling, and written into the output 2042159047fSniklas when disassembling. 2052159047fSniklas 2062159047fSniklas Each of these characters corresponds to a mask field defined above. 2072159047fSniklas 2082159047fSniklas "<" 5 bit shift amount (OP_*_SHAMT) 2092159047fSniklas ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT) 2102159047fSniklas "a" 26 bit target address (OP_*_TARGET) 2112159047fSniklas "b" 5 bit base register (OP_*_RS) 2122159047fSniklas "c" 10 bit breakpoint code (OP_*_CODE) 2132159047fSniklas "d" 5 bit destination register specifier (OP_*_RD) 2142159047fSniklas "h" 5 bit prefx hint (OP_*_PREFX) 2152159047fSniklas "i" 16 bit unsigned immediate (OP_*_IMMEDIATE) 2162159047fSniklas "j" 16 bit signed immediate (OP_*_DELTA) 2172159047fSniklas "k" 5 bit cache opcode in target register position (OP_*_CACHE) 218c074d1c9Sdrahn Also used for immediate operands in vr5400 vector insns. 2192159047fSniklas "o" 16 bit signed offset (OP_*_DELTA) 2202159047fSniklas "p" 16 bit PC relative branch target address (OP_*_DELTA) 221b305b0f1Sespie "q" 10 bit extra breakpoint code (OP_*_CODE2) 2222159047fSniklas "r" 5 bit same register used as both source and target (OP_*_RS) 2232159047fSniklas "s" 5 bit source register specifier (OP_*_RS) 2242159047fSniklas "t" 5 bit target register (OP_*_RT) 2252159047fSniklas "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE) 2262159047fSniklas "v" 5 bit same register used as both source and destination (OP_*_RS) 2272159047fSniklas "w" 5 bit same register used as both target and destination (OP_*_RT) 228b55d4692Sfgsch "U" 5 bit same destination register in both OP_*_RD and OP_*_RT 229b55d4692Sfgsch (used by clo and clz) 2302159047fSniklas "C" 25 bit coprocessor function code (OP_*_COPZ) 231b55d4692Sfgsch "B" 20 bit syscall/breakpoint function code (OP_*_CODE20) 232b55d4692Sfgsch "J" 19 bit wait function code (OP_*_CODE19) 2332159047fSniklas "x" accept and ignore register name 2342159047fSniklas "z" must be zero register 235c074d1c9Sdrahn "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD) 236c074d1c9Sdrahn "+A" 5 bit ins/ext position, which becomes LSB (OP_*_SHAMT). 237c074d1c9Sdrahn Enforces: 0 <= pos < 32. 238c074d1c9Sdrahn "+B" 5 bit ins size, which becomes MSB (OP_*_INSMSB). 239007c2a45Smiod Requires that "+A" or "+E" occur first to set position. 240c074d1c9Sdrahn Enforces: 0 < (pos+size) <= 32. 241c074d1c9Sdrahn "+C" 5 bit ext size, which becomes MSBD (OP_*_EXTMSBD). 242007c2a45Smiod Requires that "+A" or "+E" occur first to set position. 243c074d1c9Sdrahn Enforces: 0 < (pos+size) <= 32. 244007c2a45Smiod (Also used by "dext" w/ different limits, but limits for 245007c2a45Smiod that are checked by the M_DEXT macro.) 246007c2a45Smiod "+E" 5 bit dins/dext position, which becomes LSB-32 (OP_*_SHAMT). 247007c2a45Smiod Enforces: 32 <= pos < 64. 248007c2a45Smiod "+F" 5 bit "dinsm" size, which becomes MSB-32 (OP_*_INSMSB). 249007c2a45Smiod Requires that "+A" or "+E" occur first to set position. 250007c2a45Smiod Enforces: 32 < (pos+size) <= 64. 251007c2a45Smiod "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD). 252007c2a45Smiod Requires that "+A" or "+E" occur first to set position. 253007c2a45Smiod Enforces: 32 < (pos+size) <= 64. 254007c2a45Smiod "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD). 255007c2a45Smiod Requires that "+A" or "+E" occur first to set position. 256007c2a45Smiod Enforces: 32 < (pos+size) <= 64. 2572159047fSniklas 2582159047fSniklas Floating point instructions: 2592159047fSniklas "D" 5 bit destination register (OP_*_FD) 2602159047fSniklas "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up) 2612159047fSniklas "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up) 2622159047fSniklas "S" 5 bit fs source 1 register (OP_*_FS) 2632159047fSniklas "T" 5 bit ft source 2 register (OP_*_FT) 2642159047fSniklas "R" 5 bit fr source 3 register (OP_*_FR) 2652159047fSniklas "V" 5 bit same register used as floating source and destination (OP_*_FS) 2662159047fSniklas "W" 5 bit same register used as floating target and destination (OP_*_FT) 2672159047fSniklas 2682159047fSniklas Coprocessor instructions: 2692159047fSniklas "E" 5 bit target register (OP_*_RT) 2702159047fSniklas "G" 5 bit destination register (OP_*_RD) 271c074d1c9Sdrahn "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL) 272b305b0f1Sespie "P" 5 bit performance-monitor register (OP_*_PERFREG) 273c074d1c9Sdrahn "e" 5 bit vector register byte specifier (OP_*_VECBYTE) 274c074d1c9Sdrahn "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN) 275c074d1c9Sdrahn see also "k" above 276c074d1c9Sdrahn "+D" Combined destination register ("G") and sel ("H") for CP0 ops, 277c074d1c9Sdrahn for pretty-printing in disassembly only. 2782159047fSniklas 2792159047fSniklas Macro instructions: 2802159047fSniklas "A" General 32 bit expression 281007c2a45Smiod "I" 32 bit immediate (value placed in imm_expr). 282007c2a45Smiod "+I" 32 bit immediate (value placed in imm2_expr). 2832159047fSniklas "F" 64 bit floating point constant in .rdata 2842159047fSniklas "L" 64 bit floating point constant in .lit8 2852159047fSniklas "f" 32 bit floating point constant 2862159047fSniklas "l" 32 bit floating point constant in .lit4 287b305b0f1Sespie 288c074d1c9Sdrahn MDMX instruction operands (note that while these use the FP register 289c074d1c9Sdrahn fields, they accept both $fN and $vN names for the registers): 290c074d1c9Sdrahn "O" MDMX alignment offset (OP_*_ALN) 291c074d1c9Sdrahn "Q" MDMX vector/scalar/immediate source (OP_*_VSEL and OP_*_FT) 292c074d1c9Sdrahn "X" MDMX destination register (OP_*_FD) 293c074d1c9Sdrahn "Y" MDMX source register (OP_*_FS) 294c074d1c9Sdrahn "Z" MDMX source register (OP_*_FT) 295c074d1c9Sdrahn 296b305b0f1Sespie Other: 297b305b0f1Sespie "()" parens surrounding optional value 298b305b0f1Sespie "," separates operands 299c074d1c9Sdrahn "[]" brackets around index for vector-op scalar operand specifier (vr5400) 300c074d1c9Sdrahn "+" Start of extension sequence. 301b305b0f1Sespie 302b305b0f1Sespie Characters used so far, for quick reference when adding more: 303c074d1c9Sdrahn "%[]<>(),+" 304c074d1c9Sdrahn "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 305c074d1c9Sdrahn "abcdefhijklopqrstuvwxz" 306c074d1c9Sdrahn 307c074d1c9Sdrahn Extension character sequences used so far ("+" followed by the 308c074d1c9Sdrahn following), for quick reference when adding more: 309007c2a45Smiod "ABCDEFGHI" 3102159047fSniklas */ 3112159047fSniklas 3122159047fSniklas /* These are the bits which may be set in the pinfo field of an 3132159047fSniklas instructions, if it is not equal to INSN_MACRO. */ 3142159047fSniklas 3152159047fSniklas /* Modifies the general purpose register in OP_*_RD. */ 3162159047fSniklas #define INSN_WRITE_GPR_D 0x00000001 3172159047fSniklas /* Modifies the general purpose register in OP_*_RT. */ 3182159047fSniklas #define INSN_WRITE_GPR_T 0x00000002 3192159047fSniklas /* Modifies general purpose register 31. */ 3202159047fSniklas #define INSN_WRITE_GPR_31 0x00000004 3212159047fSniklas /* Modifies the floating point register in OP_*_FD. */ 3222159047fSniklas #define INSN_WRITE_FPR_D 0x00000008 3232159047fSniklas /* Modifies the floating point register in OP_*_FS. */ 3242159047fSniklas #define INSN_WRITE_FPR_S 0x00000010 3252159047fSniklas /* Modifies the floating point register in OP_*_FT. */ 3262159047fSniklas #define INSN_WRITE_FPR_T 0x00000020 3272159047fSniklas /* Reads the general purpose register in OP_*_RS. */ 3282159047fSniklas #define INSN_READ_GPR_S 0x00000040 3292159047fSniklas /* Reads the general purpose register in OP_*_RT. */ 3302159047fSniklas #define INSN_READ_GPR_T 0x00000080 3312159047fSniklas /* Reads the floating point register in OP_*_FS. */ 3322159047fSniklas #define INSN_READ_FPR_S 0x00000100 3332159047fSniklas /* Reads the floating point register in OP_*_FT. */ 3342159047fSniklas #define INSN_READ_FPR_T 0x00000200 3352159047fSniklas /* Reads the floating point register in OP_*_FR. */ 3362159047fSniklas #define INSN_READ_FPR_R 0x00000400 3372159047fSniklas /* Modifies coprocessor condition code. */ 3382159047fSniklas #define INSN_WRITE_COND_CODE 0x00000800 3392159047fSniklas /* Reads coprocessor condition code. */ 3402159047fSniklas #define INSN_READ_COND_CODE 0x00001000 3412159047fSniklas /* TLB operation. */ 3422159047fSniklas #define INSN_TLB 0x00002000 3432159047fSniklas /* Reads coprocessor register other than floating point register. */ 3442159047fSniklas #define INSN_COP 0x00004000 3452159047fSniklas /* Instruction loads value from memory, requiring delay. */ 3462159047fSniklas #define INSN_LOAD_MEMORY_DELAY 0x00008000 3472159047fSniklas /* Instruction loads value from coprocessor, requiring delay. */ 3482159047fSniklas #define INSN_LOAD_COPROC_DELAY 0x00010000 3492159047fSniklas /* Instruction has unconditional branch delay slot. */ 3502159047fSniklas #define INSN_UNCOND_BRANCH_DELAY 0x00020000 3512159047fSniklas /* Instruction has conditional branch delay slot. */ 3522159047fSniklas #define INSN_COND_BRANCH_DELAY 0x00040000 3532159047fSniklas /* Conditional branch likely: if branch not taken, insn nullified. */ 3542159047fSniklas #define INSN_COND_BRANCH_LIKELY 0x00080000 3552159047fSniklas /* Moves to coprocessor register, requiring delay. */ 3562159047fSniklas #define INSN_COPROC_MOVE_DELAY 0x00100000 3572159047fSniklas /* Loads coprocessor register from memory, requiring delay. */ 3582159047fSniklas #define INSN_COPROC_MEMORY_DELAY 0x00200000 3592159047fSniklas /* Reads the HI register. */ 3602159047fSniklas #define INSN_READ_HI 0x00400000 3612159047fSniklas /* Reads the LO register. */ 3622159047fSniklas #define INSN_READ_LO 0x00800000 3632159047fSniklas /* Modifies the HI register. */ 3642159047fSniklas #define INSN_WRITE_HI 0x01000000 3652159047fSniklas /* Modifies the LO register. */ 3662159047fSniklas #define INSN_WRITE_LO 0x02000000 3672159047fSniklas /* Takes a trap (easier to keep out of delay slot). */ 3682159047fSniklas #define INSN_TRAP 0x04000000 3692159047fSniklas /* Instruction stores value into memory. */ 3702159047fSniklas #define INSN_STORE_MEMORY 0x08000000 371b305b0f1Sespie /* Instruction uses single precision floating point. */ 372b305b0f1Sespie #define FP_S 0x10000000 373b305b0f1Sespie /* Instruction uses double precision floating point. */ 374b305b0f1Sespie #define FP_D 0x20000000 375b305b0f1Sespie /* Instruction is part of the tx39's integer multiply family. */ 376b305b0f1Sespie #define INSN_MULT 0x40000000 377b305b0f1Sespie /* Instruction synchronize shared memory. */ 378b305b0f1Sespie #define INSN_SYNC 0x80000000 379c074d1c9Sdrahn /* Instruction reads MDMX accumulator. XXX FIXME: No bits left! */ 380c074d1c9Sdrahn #define INSN_READ_MDMX_ACC 0 381c074d1c9Sdrahn /* Instruction writes MDMX accumulator. XXX FIXME: No bits left! */ 382c074d1c9Sdrahn #define INSN_WRITE_MDMX_ACC 0 3832159047fSniklas 3842159047fSniklas /* Instruction is actually a macro. It should be ignored by the 3852159047fSniklas disassembler, and requires special treatment by the assembler. */ 3862159047fSniklas #define INSN_MACRO 0xffffffff 3872159047fSniklas 388b55d4692Sfgsch /* Masks used to mark instructions to indicate which MIPS ISA level 389b55d4692Sfgsch they were introduced in. ISAs, as defined below, are logical 390b55d4692Sfgsch ORs of these bits, indicating that they support the instructions 391b55d4692Sfgsch defined at the given level. */ 392b305b0f1Sespie 393c074d1c9Sdrahn #define INSN_ISA_MASK 0x00000fff 394c074d1c9Sdrahn #define INSN_ISA1 0x00000001 395c074d1c9Sdrahn #define INSN_ISA2 0x00000002 396c074d1c9Sdrahn #define INSN_ISA3 0x00000004 397c074d1c9Sdrahn #define INSN_ISA4 0x00000008 398c074d1c9Sdrahn #define INSN_ISA5 0x00000010 399c074d1c9Sdrahn #define INSN_ISA32 0x00000020 400c074d1c9Sdrahn #define INSN_ISA64 0x00000040 401c074d1c9Sdrahn #define INSN_ISA32R2 0x00000080 402007c2a45Smiod #define INSN_ISA64R2 0x00000100 403c074d1c9Sdrahn 404c074d1c9Sdrahn /* Masks used for MIPS-defined ASEs. */ 405c074d1c9Sdrahn #define INSN_ASE_MASK 0x0000f000 406c074d1c9Sdrahn 407c074d1c9Sdrahn /* MIPS 16 ASE */ 408c074d1c9Sdrahn #define INSN_MIPS16 0x00002000 409c074d1c9Sdrahn /* MIPS-3D ASE */ 410c074d1c9Sdrahn #define INSN_MIPS3D 0x00004000 411c074d1c9Sdrahn /* MDMX ASE */ 412c074d1c9Sdrahn #define INSN_MDMX 0x00008000 413b305b0f1Sespie 414b305b0f1Sespie /* Chip specific instructions. These are bitmasks. */ 415b305b0f1Sespie 416b55d4692Sfgsch /* MIPS R4650 instruction. */ 417b55d4692Sfgsch #define INSN_4650 0x00010000 418b55d4692Sfgsch /* LSI R4010 instruction. */ 419b55d4692Sfgsch #define INSN_4010 0x00020000 420b55d4692Sfgsch /* NEC VR4100 instruction. */ 421b55d4692Sfgsch #define INSN_4100 0x00040000 422b55d4692Sfgsch /* Toshiba R3900 instruction. */ 423b55d4692Sfgsch #define INSN_3900 0x00080000 424c074d1c9Sdrahn /* MIPS R10000 instruction. */ 425c074d1c9Sdrahn #define INSN_10000 0x00100000 426c074d1c9Sdrahn /* Broadcom SB-1 instruction. */ 427c074d1c9Sdrahn #define INSN_SB1 0x00200000 428c074d1c9Sdrahn /* NEC VR4111/VR4181 instruction. */ 429c074d1c9Sdrahn #define INSN_4111 0x00400000 430c074d1c9Sdrahn /* NEC VR4120 instruction. */ 431c074d1c9Sdrahn #define INSN_4120 0x00800000 432c074d1c9Sdrahn /* NEC VR5400 instruction. */ 433c074d1c9Sdrahn #define INSN_5400 0x01000000 434c074d1c9Sdrahn /* NEC VR5500 instruction. */ 435c074d1c9Sdrahn #define INSN_5500 0x02000000 436b55d4692Sfgsch 437b55d4692Sfgsch /* MIPS ISA defines, use instead of hardcoding ISA level. */ 438b55d4692Sfgsch 439b55d4692Sfgsch #define ISA_UNKNOWN 0 /* Gas internal use. */ 440b55d4692Sfgsch #define ISA_MIPS1 (INSN_ISA1) 441b55d4692Sfgsch #define ISA_MIPS2 (ISA_MIPS1 | INSN_ISA2) 442b55d4692Sfgsch #define ISA_MIPS3 (ISA_MIPS2 | INSN_ISA3) 443b55d4692Sfgsch #define ISA_MIPS4 (ISA_MIPS3 | INSN_ISA4) 444b55d4692Sfgsch #define ISA_MIPS5 (ISA_MIPS4 | INSN_ISA5) 445c074d1c9Sdrahn 446b55d4692Sfgsch #define ISA_MIPS32 (ISA_MIPS2 | INSN_ISA32) 447b55d4692Sfgsch #define ISA_MIPS64 (ISA_MIPS5 | INSN_ISA32 | INSN_ISA64) 448b55d4692Sfgsch 449c074d1c9Sdrahn #define ISA_MIPS32R2 (ISA_MIPS32 | INSN_ISA32R2) 450007c2a45Smiod #define ISA_MIPS64R2 (ISA_MIPS64 | INSN_ISA32R2 | INSN_ISA64R2) 451007c2a45Smiod 452c074d1c9Sdrahn 453b55d4692Sfgsch /* CPU defines, use instead of hardcoding processor number. Keep this 454b55d4692Sfgsch in sync with bfd/archures.c in order for machine selection to work. */ 455b55d4692Sfgsch #define CPU_UNKNOWN 0 /* Gas internal use. */ 456b55d4692Sfgsch #define CPU_R3000 3000 457b55d4692Sfgsch #define CPU_R3900 3900 458b55d4692Sfgsch #define CPU_R4000 4000 459b55d4692Sfgsch #define CPU_R4010 4010 460b55d4692Sfgsch #define CPU_VR4100 4100 461b55d4692Sfgsch #define CPU_R4111 4111 462c074d1c9Sdrahn #define CPU_VR4120 4120 463b55d4692Sfgsch #define CPU_R4300 4300 464b55d4692Sfgsch #define CPU_R4400 4400 465b55d4692Sfgsch #define CPU_R4600 4600 466b55d4692Sfgsch #define CPU_R4650 4650 467b55d4692Sfgsch #define CPU_R5000 5000 468c074d1c9Sdrahn #define CPU_VR5400 5400 469c074d1c9Sdrahn #define CPU_VR5500 5500 470b55d4692Sfgsch #define CPU_R6000 6000 471007c2a45Smiod #define CPU_RM7000 7000 472b55d4692Sfgsch #define CPU_R8000 8000 473b55d4692Sfgsch #define CPU_R10000 10000 474b55d4692Sfgsch #define CPU_R12000 12000 475b55d4692Sfgsch #define CPU_MIPS16 16 476b55d4692Sfgsch #define CPU_MIPS32 32 477c074d1c9Sdrahn #define CPU_MIPS32R2 33 478b55d4692Sfgsch #define CPU_MIPS5 5 479b55d4692Sfgsch #define CPU_MIPS64 64 480007c2a45Smiod #define CPU_MIPS64R2 65 481b55d4692Sfgsch #define CPU_SB1 12310201 /* octal 'SB', 01. */ 482b305b0f1Sespie 483c074d1c9Sdrahn /* Test for membership in an ISA including chip specific ISAs. INSN 484c074d1c9Sdrahn is pointer to an element of the opcode table; ISA is the specified 485c074d1c9Sdrahn ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to 486c074d1c9Sdrahn test, or zero if no CPU specific ISA test is desired. */ 487b305b0f1Sespie 488c074d1c9Sdrahn #define OPCODE_IS_MEMBER(insn, isa, cpu) \ 489c074d1c9Sdrahn (((insn)->membership & isa) != 0 \ 490b55d4692Sfgsch || (cpu == CPU_R4650 && ((insn)->membership & INSN_4650) != 0) \ 491007c2a45Smiod || (cpu == CPU_RM7000 && ((insn)->membership & INSN_4650) != 0) \ 492b55d4692Sfgsch || (cpu == CPU_R4010 && ((insn)->membership & INSN_4010) != 0) \ 493c074d1c9Sdrahn || (cpu == CPU_VR4100 && ((insn)->membership & INSN_4100) != 0) \ 494c074d1c9Sdrahn || (cpu == CPU_R3900 && ((insn)->membership & INSN_3900) != 0) \ 495c074d1c9Sdrahn || ((cpu == CPU_R10000 || cpu == CPU_R12000) \ 496c074d1c9Sdrahn && ((insn)->membership & INSN_10000) != 0) \ 497c074d1c9Sdrahn || (cpu == CPU_SB1 && ((insn)->membership & INSN_SB1) != 0) \ 498c074d1c9Sdrahn || (cpu == CPU_R4111 && ((insn)->membership & INSN_4111) != 0) \ 499c074d1c9Sdrahn || (cpu == CPU_VR4120 && ((insn)->membership & INSN_4120) != 0) \ 500c074d1c9Sdrahn || (cpu == CPU_VR5400 && ((insn)->membership & INSN_5400) != 0) \ 501c074d1c9Sdrahn || (cpu == CPU_VR5500 && ((insn)->membership & INSN_5500) != 0) \ 502c074d1c9Sdrahn || 0) /* Please keep this term for easier source merging. */ 503b305b0f1Sespie 5042159047fSniklas /* This is a list of macro expanded instructions. 505b55d4692Sfgsch 506b55d4692Sfgsch _I appended means immediate 507b55d4692Sfgsch _A appended means address 508b55d4692Sfgsch _AB appended means address with base register 509b55d4692Sfgsch _D appended means 64 bit floating point constant 510b55d4692Sfgsch _S appended means 32 bit floating point constant. */ 511b55d4692Sfgsch 512b55d4692Sfgsch enum 513b55d4692Sfgsch { 5142159047fSniklas M_ABS, 5152159047fSniklas M_ADD_I, 5162159047fSniklas M_ADDU_I, 5172159047fSniklas M_AND_I, 518b305b0f1Sespie M_BEQ, 5192159047fSniklas M_BEQ_I, 5202159047fSniklas M_BEQL_I, 5212159047fSniklas M_BGE, 5222159047fSniklas M_BGEL, 5232159047fSniklas M_BGE_I, 5242159047fSniklas M_BGEL_I, 5252159047fSniklas M_BGEU, 5262159047fSniklas M_BGEUL, 5272159047fSniklas M_BGEU_I, 5282159047fSniklas M_BGEUL_I, 5292159047fSniklas M_BGT, 5302159047fSniklas M_BGTL, 5312159047fSniklas M_BGT_I, 5322159047fSniklas M_BGTL_I, 5332159047fSniklas M_BGTU, 5342159047fSniklas M_BGTUL, 5352159047fSniklas M_BGTU_I, 5362159047fSniklas M_BGTUL_I, 5372159047fSniklas M_BLE, 5382159047fSniklas M_BLEL, 5392159047fSniklas M_BLE_I, 5402159047fSniklas M_BLEL_I, 5412159047fSniklas M_BLEU, 5422159047fSniklas M_BLEUL, 5432159047fSniklas M_BLEU_I, 5442159047fSniklas M_BLEUL_I, 5452159047fSniklas M_BLT, 5462159047fSniklas M_BLTL, 5472159047fSniklas M_BLT_I, 5482159047fSniklas M_BLTL_I, 5492159047fSniklas M_BLTU, 5502159047fSniklas M_BLTUL, 5512159047fSniklas M_BLTU_I, 5522159047fSniklas M_BLTUL_I, 553b305b0f1Sespie M_BNE, 5542159047fSniklas M_BNE_I, 5552159047fSniklas M_BNEL_I, 5562159047fSniklas M_DABS, 5572159047fSniklas M_DADD_I, 5582159047fSniklas M_DADDU_I, 5592159047fSniklas M_DDIV_3, 5602159047fSniklas M_DDIV_3I, 5612159047fSniklas M_DDIVU_3, 5622159047fSniklas M_DDIVU_3I, 563007c2a45Smiod M_DEXT, 564007c2a45Smiod M_DINS, 5652159047fSniklas M_DIV_3, 5662159047fSniklas M_DIV_3I, 5672159047fSniklas M_DIVU_3, 5682159047fSniklas M_DIVU_3I, 5692159047fSniklas M_DLA_AB, 570007c2a45Smiod M_DLCA_AB, 5712159047fSniklas M_DLI, 5722159047fSniklas M_DMUL, 5732159047fSniklas M_DMUL_I, 5742159047fSniklas M_DMULO, 5752159047fSniklas M_DMULO_I, 5762159047fSniklas M_DMULOU, 5772159047fSniklas M_DMULOU_I, 5782159047fSniklas M_DREM_3, 5792159047fSniklas M_DREM_3I, 5802159047fSniklas M_DREMU_3, 5812159047fSniklas M_DREMU_3I, 5822159047fSniklas M_DSUB_I, 5832159047fSniklas M_DSUBU_I, 584b305b0f1Sespie M_DSUBU_I_2, 585*e4ff4a19Smiod M_JR_S, 586*e4ff4a19Smiod M_J_S, 5872159047fSniklas M_J_A, 588*e4ff4a19Smiod M_JALR_S, 589*e4ff4a19Smiod M_JALR_DS, 5902159047fSniklas M_JAL_1, 5912159047fSniklas M_JAL_2, 5922159047fSniklas M_JAL_A, 5932159047fSniklas M_L_DOB, 5942159047fSniklas M_L_DAB, 5952159047fSniklas M_LA_AB, 5962159047fSniklas M_LB_A, 5972159047fSniklas M_LB_AB, 5982159047fSniklas M_LBU_A, 5992159047fSniklas M_LBU_AB, 600007c2a45Smiod M_LCA_AB, 6012159047fSniklas M_LD_A, 6022159047fSniklas M_LD_OB, 6032159047fSniklas M_LD_AB, 6042159047fSniklas M_LDC1_AB, 6052159047fSniklas M_LDC2_AB, 6062159047fSniklas M_LDC3_AB, 6072159047fSniklas M_LDL_AB, 6082159047fSniklas M_LDR_AB, 6092159047fSniklas M_LH_A, 6102159047fSniklas M_LH_AB, 6112159047fSniklas M_LHU_A, 6122159047fSniklas M_LHU_AB, 6132159047fSniklas M_LI, 6142159047fSniklas M_LI_D, 6152159047fSniklas M_LI_DD, 6162159047fSniklas M_LI_S, 6172159047fSniklas M_LI_SS, 6182159047fSniklas M_LL_AB, 6192159047fSniklas M_LLD_AB, 6202159047fSniklas M_LS_A, 6212159047fSniklas M_LW_A, 6222159047fSniklas M_LW_AB, 6232159047fSniklas M_LWC0_A, 6242159047fSniklas M_LWC0_AB, 6252159047fSniklas M_LWC1_A, 6262159047fSniklas M_LWC1_AB, 6272159047fSniklas M_LWC2_A, 6282159047fSniklas M_LWC2_AB, 6292159047fSniklas M_LWC3_A, 6302159047fSniklas M_LWC3_AB, 6312159047fSniklas M_LWL_A, 6322159047fSniklas M_LWL_AB, 6332159047fSniklas M_LWR_A, 6342159047fSniklas M_LWR_AB, 6352159047fSniklas M_LWU_AB, 636c074d1c9Sdrahn M_MOVE, 6372159047fSniklas M_MUL, 6382159047fSniklas M_MUL_I, 6392159047fSniklas M_MULO, 6402159047fSniklas M_MULO_I, 6412159047fSniklas M_MULOU, 6422159047fSniklas M_MULOU_I, 6432159047fSniklas M_NOR_I, 6442159047fSniklas M_OR_I, 6452159047fSniklas M_REM_3, 6462159047fSniklas M_REM_3I, 6472159047fSniklas M_REMU_3, 6482159047fSniklas M_REMU_3I, 649c074d1c9Sdrahn M_DROL, 6502159047fSniklas M_ROL, 651c074d1c9Sdrahn M_DROL_I, 6522159047fSniklas M_ROL_I, 653c074d1c9Sdrahn M_DROR, 6542159047fSniklas M_ROR, 655c074d1c9Sdrahn M_DROR_I, 6562159047fSniklas M_ROR_I, 6572159047fSniklas M_S_DA, 6582159047fSniklas M_S_DOB, 6592159047fSniklas M_S_DAB, 6602159047fSniklas M_S_S, 6612159047fSniklas M_SC_AB, 6622159047fSniklas M_SCD_AB, 6632159047fSniklas M_SD_A, 6642159047fSniklas M_SD_OB, 6652159047fSniklas M_SD_AB, 6662159047fSniklas M_SDC1_AB, 6672159047fSniklas M_SDC2_AB, 6682159047fSniklas M_SDC3_AB, 6692159047fSniklas M_SDL_AB, 6702159047fSniklas M_SDR_AB, 6712159047fSniklas M_SEQ, 6722159047fSniklas M_SEQ_I, 6732159047fSniklas M_SGE, 6742159047fSniklas M_SGE_I, 6752159047fSniklas M_SGEU, 6762159047fSniklas M_SGEU_I, 6772159047fSniklas M_SGT, 6782159047fSniklas M_SGT_I, 6792159047fSniklas M_SGTU, 6802159047fSniklas M_SGTU_I, 6812159047fSniklas M_SLE, 6822159047fSniklas M_SLE_I, 6832159047fSniklas M_SLEU, 6842159047fSniklas M_SLEU_I, 6852159047fSniklas M_SLT_I, 6862159047fSniklas M_SLTU_I, 6872159047fSniklas M_SNE, 6882159047fSniklas M_SNE_I, 6892159047fSniklas M_SB_A, 6902159047fSniklas M_SB_AB, 6912159047fSniklas M_SH_A, 6922159047fSniklas M_SH_AB, 6932159047fSniklas M_SW_A, 6942159047fSniklas M_SW_AB, 6952159047fSniklas M_SWC0_A, 6962159047fSniklas M_SWC0_AB, 6972159047fSniklas M_SWC1_A, 6982159047fSniklas M_SWC1_AB, 6992159047fSniklas M_SWC2_A, 7002159047fSniklas M_SWC2_AB, 7012159047fSniklas M_SWC3_A, 7022159047fSniklas M_SWC3_AB, 7032159047fSniklas M_SWL_A, 7042159047fSniklas M_SWL_AB, 7052159047fSniklas M_SWR_A, 7062159047fSniklas M_SWR_AB, 7072159047fSniklas M_SUB_I, 7082159047fSniklas M_SUBU_I, 709b305b0f1Sespie M_SUBU_I_2, 7102159047fSniklas M_TEQ_I, 7112159047fSniklas M_TGE_I, 7122159047fSniklas M_TGEU_I, 7132159047fSniklas M_TLT_I, 7142159047fSniklas M_TLTU_I, 7152159047fSniklas M_TNE_I, 7162159047fSniklas M_TRUNCWD, 7172159047fSniklas M_TRUNCWS, 7182159047fSniklas M_ULD, 7192159047fSniklas M_ULD_A, 7202159047fSniklas M_ULH, 7212159047fSniklas M_ULH_A, 7222159047fSniklas M_ULHU, 7232159047fSniklas M_ULHU_A, 7242159047fSniklas M_ULW, 7252159047fSniklas M_ULW_A, 7262159047fSniklas M_USH, 7272159047fSniklas M_USH_A, 7282159047fSniklas M_USW, 7292159047fSniklas M_USW_A, 7302159047fSniklas M_USD, 7312159047fSniklas M_USD_A, 732b305b0f1Sespie M_XOR_I, 733b305b0f1Sespie M_COP0, 734b305b0f1Sespie M_COP1, 735b305b0f1Sespie M_COP2, 736b305b0f1Sespie M_COP3, 737b305b0f1Sespie M_NUM_MACROS 7382159047fSniklas }; 7392159047fSniklas 740b305b0f1Sespie 7412159047fSniklas /* The order of overloaded instructions matters. Label arguments and 7422159047fSniklas register arguments look the same. Instructions that can have either 7432159047fSniklas for arguments must apear in the correct order in this table for the 7442159047fSniklas assembler to pick the right one. In other words, entries with 7452159047fSniklas immediate operands must apear after the same instruction with 7462159047fSniklas registers. 7472159047fSniklas 7482159047fSniklas Many instructions are short hand for other instructions (i.e., The 7492159047fSniklas jal <register> instruction is short for jalr <register>). */ 7502159047fSniklas 751b305b0f1Sespie extern const struct mips_opcode mips_builtin_opcodes[]; 752b305b0f1Sespie extern const int bfd_mips_num_builtin_opcodes; 753b305b0f1Sespie extern struct mips_opcode *mips_opcodes; 754b305b0f1Sespie extern int bfd_mips_num_opcodes; 7552159047fSniklas #define NUMOPCODES bfd_mips_num_opcodes 756b305b0f1Sespie 757b305b0f1Sespie 758b305b0f1Sespie /* The rest of this file adds definitions for the mips16 TinyRISC 759b305b0f1Sespie processor. */ 760b305b0f1Sespie 761b305b0f1Sespie /* These are the bitmasks and shift counts used for the different 762b305b0f1Sespie fields in the instruction formats. Other than OP, no masks are 763b305b0f1Sespie provided for the fixed portions of an instruction, since they are 764b305b0f1Sespie not needed. 765b305b0f1Sespie 766b305b0f1Sespie The I format uses IMM11. 767b305b0f1Sespie 768b305b0f1Sespie The RI format uses RX and IMM8. 769b305b0f1Sespie 770b305b0f1Sespie The RR format uses RX, and RY. 771b305b0f1Sespie 772b305b0f1Sespie The RRI format uses RX, RY, and IMM5. 773b305b0f1Sespie 774b305b0f1Sespie The RRR format uses RX, RY, and RZ. 775b305b0f1Sespie 776b305b0f1Sespie The RRI_A format uses RX, RY, and IMM4. 777b305b0f1Sespie 778b305b0f1Sespie The SHIFT format uses RX, RY, and SHAMT. 779b305b0f1Sespie 780b305b0f1Sespie The I8 format uses IMM8. 781b305b0f1Sespie 782b305b0f1Sespie The I8_MOVR32 format uses RY and REGR32. 783b305b0f1Sespie 784b305b0f1Sespie The IR_MOV32R format uses REG32R and MOV32Z. 785b305b0f1Sespie 786b305b0f1Sespie The I64 format uses IMM8. 787b305b0f1Sespie 788b305b0f1Sespie The RI64 format uses RY and IMM5. 789b305b0f1Sespie */ 790b305b0f1Sespie 791b305b0f1Sespie #define MIPS16OP_MASK_OP 0x1f 792b305b0f1Sespie #define MIPS16OP_SH_OP 11 793b305b0f1Sespie #define MIPS16OP_MASK_IMM11 0x7ff 794b305b0f1Sespie #define MIPS16OP_SH_IMM11 0 795b305b0f1Sespie #define MIPS16OP_MASK_RX 0x7 796b305b0f1Sespie #define MIPS16OP_SH_RX 8 797b305b0f1Sespie #define MIPS16OP_MASK_IMM8 0xff 798b305b0f1Sespie #define MIPS16OP_SH_IMM8 0 799b305b0f1Sespie #define MIPS16OP_MASK_RY 0x7 800b305b0f1Sespie #define MIPS16OP_SH_RY 5 801b305b0f1Sespie #define MIPS16OP_MASK_IMM5 0x1f 802b305b0f1Sespie #define MIPS16OP_SH_IMM5 0 803b305b0f1Sespie #define MIPS16OP_MASK_RZ 0x7 804b305b0f1Sespie #define MIPS16OP_SH_RZ 2 805b305b0f1Sespie #define MIPS16OP_MASK_IMM4 0xf 806b305b0f1Sespie #define MIPS16OP_SH_IMM4 0 807b305b0f1Sespie #define MIPS16OP_MASK_REGR32 0x1f 808b305b0f1Sespie #define MIPS16OP_SH_REGR32 0 809b305b0f1Sespie #define MIPS16OP_MASK_REG32R 0x1f 810b305b0f1Sespie #define MIPS16OP_SH_REG32R 3 811b305b0f1Sespie #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18)) 812b305b0f1Sespie #define MIPS16OP_MASK_MOVE32Z 0x7 813b305b0f1Sespie #define MIPS16OP_SH_MOVE32Z 0 814b305b0f1Sespie #define MIPS16OP_MASK_IMM6 0x3f 815b305b0f1Sespie #define MIPS16OP_SH_IMM6 5 816b305b0f1Sespie 817b305b0f1Sespie /* These are the characters which may appears in the args field of an 818b305b0f1Sespie instruction. They appear in the order in which the fields appear 819b305b0f1Sespie when the instruction is used. Commas and parentheses in the args 820b305b0f1Sespie string are ignored when assembling, and written into the output 821b305b0f1Sespie when disassembling. 822b305b0f1Sespie 823b305b0f1Sespie "y" 3 bit register (MIPS16OP_*_RY) 824b305b0f1Sespie "x" 3 bit register (MIPS16OP_*_RX) 825b305b0f1Sespie "z" 3 bit register (MIPS16OP_*_RZ) 826b305b0f1Sespie "Z" 3 bit register (MIPS16OP_*_MOVE32Z) 827b305b0f1Sespie "v" 3 bit same register as source and destination (MIPS16OP_*_RX) 828b305b0f1Sespie "w" 3 bit same register as source and destination (MIPS16OP_*_RY) 829b305b0f1Sespie "0" zero register ($0) 830b305b0f1Sespie "S" stack pointer ($sp or $29) 831b305b0f1Sespie "P" program counter 832b305b0f1Sespie "R" return address register ($ra or $31) 833b305b0f1Sespie "X" 5 bit MIPS register (MIPS16OP_*_REGR32) 834b305b0f1Sespie "Y" 5 bit MIPS register (MIPS16OP_*_REG32R) 835b305b0f1Sespie "6" 6 bit unsigned break code (MIPS16OP_*_IMM6) 836b305b0f1Sespie "a" 26 bit jump address 837b305b0f1Sespie "e" 11 bit extension value 838b305b0f1Sespie "l" register list for entry instruction 839b305b0f1Sespie "L" register list for exit instruction 840b305b0f1Sespie 841b305b0f1Sespie The remaining codes may be extended. Except as otherwise noted, 842b305b0f1Sespie the full extended operand is a 16 bit signed value. 843b305b0f1Sespie "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned) 844b305b0f1Sespie ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned) 845b305b0f1Sespie "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned) 846b305b0f1Sespie "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned) 847b305b0f1Sespie "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed) 848b305b0f1Sespie "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5) 849b305b0f1Sespie "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5) 850b305b0f1Sespie "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5) 851b305b0f1Sespie "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5) 852b305b0f1Sespie "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5) 853b305b0f1Sespie "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) 854b305b0f1Sespie "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8) 855b305b0f1Sespie "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8) 856b305b0f1Sespie "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned) 857b305b0f1Sespie "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8) 858b305b0f1Sespie "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8) 859b305b0f1Sespie "p" 8 bit conditional branch address (MIPS16OP_*_IMM8) 860b305b0f1Sespie "q" 11 bit branch address (MIPS16OP_*_IMM11) 861b305b0f1Sespie "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8) 862b305b0f1Sespie "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5) 863b305b0f1Sespie "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5) 864b305b0f1Sespie */ 865b305b0f1Sespie 866b305b0f1Sespie /* For the mips16, we use the same opcode table format and a few of 867b305b0f1Sespie the same flags. However, most of the flags are different. */ 868b305b0f1Sespie 869b305b0f1Sespie /* Modifies the register in MIPS16OP_*_RX. */ 870b305b0f1Sespie #define MIPS16_INSN_WRITE_X 0x00000001 871b305b0f1Sespie /* Modifies the register in MIPS16OP_*_RY. */ 872b305b0f1Sespie #define MIPS16_INSN_WRITE_Y 0x00000002 873b305b0f1Sespie /* Modifies the register in MIPS16OP_*_RZ. */ 874b305b0f1Sespie #define MIPS16_INSN_WRITE_Z 0x00000004 875b305b0f1Sespie /* Modifies the T ($24) register. */ 876b305b0f1Sespie #define MIPS16_INSN_WRITE_T 0x00000008 877b305b0f1Sespie /* Modifies the SP ($29) register. */ 878b305b0f1Sespie #define MIPS16_INSN_WRITE_SP 0x00000010 879b305b0f1Sespie /* Modifies the RA ($31) register. */ 880b305b0f1Sespie #define MIPS16_INSN_WRITE_31 0x00000020 881b305b0f1Sespie /* Modifies the general purpose register in MIPS16OP_*_REG32R. */ 882b305b0f1Sespie #define MIPS16_INSN_WRITE_GPR_Y 0x00000040 883b305b0f1Sespie /* Reads the register in MIPS16OP_*_RX. */ 884b305b0f1Sespie #define MIPS16_INSN_READ_X 0x00000080 885b305b0f1Sespie /* Reads the register in MIPS16OP_*_RY. */ 886b305b0f1Sespie #define MIPS16_INSN_READ_Y 0x00000100 887b305b0f1Sespie /* Reads the register in MIPS16OP_*_MOVE32Z. */ 888b305b0f1Sespie #define MIPS16_INSN_READ_Z 0x00000200 889b305b0f1Sespie /* Reads the T ($24) register. */ 890b305b0f1Sespie #define MIPS16_INSN_READ_T 0x00000400 891b305b0f1Sespie /* Reads the SP ($29) register. */ 892b305b0f1Sespie #define MIPS16_INSN_READ_SP 0x00000800 893b305b0f1Sespie /* Reads the RA ($31) register. */ 894b305b0f1Sespie #define MIPS16_INSN_READ_31 0x00001000 895b305b0f1Sespie /* Reads the program counter. */ 896b305b0f1Sespie #define MIPS16_INSN_READ_PC 0x00002000 897b305b0f1Sespie /* Reads the general purpose register in MIPS16OP_*_REGR32. */ 898b305b0f1Sespie #define MIPS16_INSN_READ_GPR_X 0x00004000 899b305b0f1Sespie /* Is a branch insn. */ 900b305b0f1Sespie #define MIPS16_INSN_BRANCH 0x00010000 901b305b0f1Sespie 902b305b0f1Sespie /* The following flags have the same value for the mips16 opcode 903b305b0f1Sespie table: 904b305b0f1Sespie INSN_UNCOND_BRANCH_DELAY 905b305b0f1Sespie INSN_COND_BRANCH_DELAY 906b305b0f1Sespie INSN_COND_BRANCH_LIKELY (never used) 907b305b0f1Sespie INSN_READ_HI 908b305b0f1Sespie INSN_READ_LO 909b305b0f1Sespie INSN_WRITE_HI 910b305b0f1Sespie INSN_WRITE_LO 911b305b0f1Sespie INSN_TRAP 912b305b0f1Sespie INSN_ISA3 913b305b0f1Sespie */ 914b305b0f1Sespie 915b305b0f1Sespie extern const struct mips_opcode mips16_opcodes[]; 916b305b0f1Sespie extern const int bfd_mips16_num_opcodes; 917b305b0f1Sespie 918b305b0f1Sespie #endif /* _MIPS_H_ */ 919