12a6b7db3Sskrll /* mips.h. Mips opcode list for GDB, the GNU debugger.
2*dd7241dfSchristos Copyright (C) 1993-2024 Free Software Foundation, Inc.
32a6b7db3Sskrll Contributed by Ralph Campbell and OSF
42a6b7db3Sskrll Commented and modified by Ian Lance Taylor, Cygnus Support
52a6b7db3Sskrll
62a6b7db3Sskrll This file is part of GDB, GAS, and the GNU binutils.
72a6b7db3Sskrll
82a6b7db3Sskrll GDB, GAS, and the GNU binutils are free software; you can redistribute
92a6b7db3Sskrll them and/or modify them under the terms of the GNU General Public
1032998b1cSchristos License as published by the Free Software Foundation; either version 3,
1132998b1cSchristos or (at your option) any later version.
122a6b7db3Sskrll
132a6b7db3Sskrll GDB, GAS, and the GNU binutils are distributed in the hope that they
142a6b7db3Sskrll will be useful, but WITHOUT ANY WARRANTY; without even the implied
152a6b7db3Sskrll warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
162a6b7db3Sskrll the GNU General Public License for more details.
172a6b7db3Sskrll
182a6b7db3Sskrll You should have received a copy of the GNU General Public License
1932998b1cSchristos along with this file; see the file COPYING3. If not, write to the Free
2032998b1cSchristos Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
2132998b1cSchristos MA 02110-1301, USA. */
222a6b7db3Sskrll
232a6b7db3Sskrll #ifndef _MIPS_H_
242a6b7db3Sskrll #define _MIPS_H_
252a6b7db3Sskrll
26b410d692Schristos #include "bfd.h"
27b410d692Schristos
282f15a542Schristos #ifdef __cplusplus
292f15a542Schristos extern "C" {
302f15a542Schristos #endif
312f15a542Schristos
322a6b7db3Sskrll /* These are bit masks and shift counts to use to access the various
332a6b7db3Sskrll fields of an instruction. To retrieve the X field of an
342a6b7db3Sskrll instruction, use the expression
352a6b7db3Sskrll (i >> OP_SH_X) & OP_MASK_X
362a6b7db3Sskrll To set the same field (to j), use
372a6b7db3Sskrll i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X)
382a6b7db3Sskrll
392a6b7db3Sskrll Make sure you use fields that are appropriate for the instruction,
402a6b7db3Sskrll of course.
412a6b7db3Sskrll
422a6b7db3Sskrll The 'i' format uses OP, RS, RT and IMMEDIATE.
432a6b7db3Sskrll
442a6b7db3Sskrll The 'j' format uses OP and TARGET.
452a6b7db3Sskrll
462a6b7db3Sskrll The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT.
472a6b7db3Sskrll
482a6b7db3Sskrll The 'b' format uses OP, RS, RT and DELTA.
492a6b7db3Sskrll
502a6b7db3Sskrll The floating point 'i' format uses OP, RS, RT and IMMEDIATE.
512a6b7db3Sskrll
522a6b7db3Sskrll The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT.
532a6b7db3Sskrll
542a6b7db3Sskrll A breakpoint instruction uses OP, CODE and SPEC (10 bits of the
552a6b7db3Sskrll breakpoint instruction are not defined; Kane says the breakpoint
562a6b7db3Sskrll code field in BREAK is 20 bits; yet MIPS assemblers and debuggers
572a6b7db3Sskrll only use ten bits). An optional two-operand form of break/sdbbp
582a6b7db3Sskrll allows the lower ten bits to be set too, and MIPS32 and later
59106c59e5Schristos architectures allow 20 bits to be set with a single operand for
60106c59e5Schristos the sdbbp instruction (using CODE20).
612a6b7db3Sskrll
622a6b7db3Sskrll The syscall instruction uses CODE20.
632a6b7db3Sskrll
642a6b7db3Sskrll The general coprocessor instructions use COPZ. */
652a6b7db3Sskrll
662a6b7db3Sskrll #define OP_MASK_OP 0x3f
672a6b7db3Sskrll #define OP_SH_OP 26
682a6b7db3Sskrll #define OP_MASK_RS 0x1f
692a6b7db3Sskrll #define OP_SH_RS 21
702a6b7db3Sskrll #define OP_MASK_FR 0x1f
712a6b7db3Sskrll #define OP_SH_FR 21
722a6b7db3Sskrll #define OP_MASK_FMT 0x1f
732a6b7db3Sskrll #define OP_SH_FMT 21
742a6b7db3Sskrll #define OP_MASK_BCC 0x7
752a6b7db3Sskrll #define OP_SH_BCC 18
762a6b7db3Sskrll #define OP_MASK_CODE 0x3ff
772a6b7db3Sskrll #define OP_SH_CODE 16
782a6b7db3Sskrll #define OP_MASK_CODE2 0x3ff
792a6b7db3Sskrll #define OP_SH_CODE2 6
802a6b7db3Sskrll #define OP_MASK_RT 0x1f
812a6b7db3Sskrll #define OP_SH_RT 16
822a6b7db3Sskrll #define OP_MASK_FT 0x1f
832a6b7db3Sskrll #define OP_SH_FT 16
842a6b7db3Sskrll #define OP_MASK_CACHE 0x1f
852a6b7db3Sskrll #define OP_SH_CACHE 16
862a6b7db3Sskrll #define OP_MASK_RD 0x1f
872a6b7db3Sskrll #define OP_SH_RD 11
882a6b7db3Sskrll #define OP_MASK_FS 0x1f
892a6b7db3Sskrll #define OP_SH_FS 11
902a6b7db3Sskrll #define OP_MASK_PREFX 0x1f
912a6b7db3Sskrll #define OP_SH_PREFX 11
922a6b7db3Sskrll #define OP_MASK_CCC 0x7
932a6b7db3Sskrll #define OP_SH_CCC 8
942a6b7db3Sskrll #define OP_MASK_CODE20 0xfffff /* 20 bit syscall/breakpoint code. */
952a6b7db3Sskrll #define OP_SH_CODE20 6
962a6b7db3Sskrll #define OP_MASK_SHAMT 0x1f
972a6b7db3Sskrll #define OP_SH_SHAMT 6
98b410d692Schristos #define OP_MASK_EXTLSB OP_MASK_SHAMT
99b410d692Schristos #define OP_SH_EXTLSB OP_SH_SHAMT
100b410d692Schristos #define OP_MASK_STYPE OP_MASK_SHAMT
101b410d692Schristos #define OP_SH_STYPE OP_SH_SHAMT
1022a6b7db3Sskrll #define OP_MASK_FD 0x1f
1032a6b7db3Sskrll #define OP_SH_FD 6
1042a6b7db3Sskrll #define OP_MASK_TARGET 0x3ffffff
1052a6b7db3Sskrll #define OP_SH_TARGET 0
1062a6b7db3Sskrll #define OP_MASK_COPZ 0x1ffffff
1072a6b7db3Sskrll #define OP_SH_COPZ 0
1082a6b7db3Sskrll #define OP_MASK_IMMEDIATE 0xffff
1092a6b7db3Sskrll #define OP_SH_IMMEDIATE 0
1102a6b7db3Sskrll #define OP_MASK_DELTA 0xffff
1112a6b7db3Sskrll #define OP_SH_DELTA 0
1122a6b7db3Sskrll #define OP_MASK_FUNCT 0x3f
1132a6b7db3Sskrll #define OP_SH_FUNCT 0
1142a6b7db3Sskrll #define OP_MASK_SPEC 0x3f
1152a6b7db3Sskrll #define OP_SH_SPEC 0
1162a6b7db3Sskrll #define OP_SH_LOCC 8 /* FP condition code. */
1172a6b7db3Sskrll #define OP_SH_HICC 18 /* FP condition code. */
1182a6b7db3Sskrll #define OP_MASK_CC 0x7
1192a6b7db3Sskrll #define OP_SH_COP1NORM 25 /* Normal COP1 encoding. */
1202a6b7db3Sskrll #define OP_MASK_COP1NORM 0x1 /* a single bit. */
1212a6b7db3Sskrll #define OP_SH_COP1SPEC 21 /* COP1 encodings. */
1222a6b7db3Sskrll #define OP_MASK_COP1SPEC 0xf
1232a6b7db3Sskrll #define OP_MASK_COP1SCLR 0x4
1242a6b7db3Sskrll #define OP_MASK_COP1CMP 0x3
1252a6b7db3Sskrll #define OP_SH_COP1CMP 4
1262a6b7db3Sskrll #define OP_SH_FORMAT 21 /* FP short format field. */
1272a6b7db3Sskrll #define OP_MASK_FORMAT 0x7
1282a6b7db3Sskrll #define OP_SH_TRUE 16
1292a6b7db3Sskrll #define OP_MASK_TRUE 0x1
1302a6b7db3Sskrll #define OP_SH_GE 17
1312a6b7db3Sskrll #define OP_MASK_GE 0x01
1322a6b7db3Sskrll #define OP_SH_UNSIGNED 16
1332a6b7db3Sskrll #define OP_MASK_UNSIGNED 0x1
1342a6b7db3Sskrll #define OP_SH_HINT 16
1352a6b7db3Sskrll #define OP_MASK_HINT 0x1f
1362a6b7db3Sskrll #define OP_SH_MMI 0 /* Multimedia (parallel) op. */
1372a6b7db3Sskrll #define OP_MASK_MMI 0x3f
1382a6b7db3Sskrll #define OP_SH_MMISUB 6
1392a6b7db3Sskrll #define OP_MASK_MMISUB 0x1f
1402a6b7db3Sskrll #define OP_MASK_PERFREG 0x1f /* Performance monitoring. */
1412a6b7db3Sskrll #define OP_SH_PERFREG 1
1422a6b7db3Sskrll #define OP_SH_SEL 0 /* Coprocessor select field. */
1432a6b7db3Sskrll #define OP_MASK_SEL 0x7 /* The sel field of mfcZ and mtcZ. */
1442a6b7db3Sskrll #define OP_SH_CODE19 6 /* 19 bit wait code. */
1452a6b7db3Sskrll #define OP_MASK_CODE19 0x7ffff
1462a6b7db3Sskrll #define OP_SH_ALN 21
1472a6b7db3Sskrll #define OP_MASK_ALN 0x7
1482a6b7db3Sskrll #define OP_SH_VSEL 21
1492a6b7db3Sskrll #define OP_MASK_VSEL 0x1f
1502a6b7db3Sskrll #define OP_MASK_VECBYTE 0x7 /* Selector field is really 4 bits,
1512a6b7db3Sskrll but 0x8-0xf don't select bytes. */
1522a6b7db3Sskrll #define OP_SH_VECBYTE 22
1532a6b7db3Sskrll #define OP_MASK_VECALIGN 0x7 /* Vector byte-align (alni.ob) op. */
1542a6b7db3Sskrll #define OP_SH_VECALIGN 21
1552a6b7db3Sskrll #define OP_MASK_INSMSB 0x1f /* "ins" MSB. */
1562a6b7db3Sskrll #define OP_SH_INSMSB 11
1572a6b7db3Sskrll #define OP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */
1582a6b7db3Sskrll #define OP_SH_EXTMSBD 11
1592a6b7db3Sskrll
1602a6b7db3Sskrll /* MIPS DSP ASE */
1612a6b7db3Sskrll #define OP_SH_DSPACC 11
1622a6b7db3Sskrll #define OP_MASK_DSPACC 0x3
1632a6b7db3Sskrll #define OP_SH_DSPACC_S 21
1642a6b7db3Sskrll #define OP_MASK_DSPACC_S 0x3
1652a6b7db3Sskrll #define OP_SH_DSPSFT 20
1662a6b7db3Sskrll #define OP_MASK_DSPSFT 0x3f
1672a6b7db3Sskrll #define OP_SH_DSPSFT_7 19
1682a6b7db3Sskrll #define OP_MASK_DSPSFT_7 0x7f
1692a6b7db3Sskrll #define OP_SH_SA3 21
1702a6b7db3Sskrll #define OP_MASK_SA3 0x7
1712a6b7db3Sskrll #define OP_SH_SA4 21
1722a6b7db3Sskrll #define OP_MASK_SA4 0xf
1732a6b7db3Sskrll #define OP_SH_IMM8 16
1742a6b7db3Sskrll #define OP_MASK_IMM8 0xff
1752a6b7db3Sskrll #define OP_SH_IMM10 16
1762a6b7db3Sskrll #define OP_MASK_IMM10 0x3ff
1772a6b7db3Sskrll #define OP_SH_WRDSP 11
1782a6b7db3Sskrll #define OP_MASK_WRDSP 0x3f
1792a6b7db3Sskrll #define OP_SH_RDDSP 16
1802a6b7db3Sskrll #define OP_MASK_RDDSP 0x3f
1812a6b7db3Sskrll #define OP_SH_BP 11
1822a6b7db3Sskrll #define OP_MASK_BP 0x3
1832a6b7db3Sskrll
1842a6b7db3Sskrll /* MIPS MT ASE */
1852a6b7db3Sskrll #define OP_SH_MT_U 5
1862a6b7db3Sskrll #define OP_MASK_MT_U 0x1
1872a6b7db3Sskrll #define OP_SH_MT_H 4
1882a6b7db3Sskrll #define OP_MASK_MT_H 0x1
1892a6b7db3Sskrll #define OP_SH_MTACC_T 18
1902a6b7db3Sskrll #define OP_MASK_MTACC_T 0x3
1912a6b7db3Sskrll #define OP_SH_MTACC_D 13
1922a6b7db3Sskrll #define OP_MASK_MTACC_D 0x3
1932a6b7db3Sskrll
194b410d692Schristos /* MIPS MCU ASE */
195b410d692Schristos #define OP_MASK_3BITPOS 0x7
196b410d692Schristos #define OP_SH_3BITPOS 12
197b410d692Schristos #define OP_MASK_OFFSET12 0xfff
198b410d692Schristos #define OP_SH_OFFSET12 0
199b410d692Schristos
2002a6b7db3Sskrll #define OP_OP_COP0 0x10
2012a6b7db3Sskrll #define OP_OP_COP1 0x11
2022a6b7db3Sskrll #define OP_OP_COP2 0x12
2032a6b7db3Sskrll #define OP_OP_COP3 0x13
2042a6b7db3Sskrll #define OP_OP_LWC1 0x31
2052a6b7db3Sskrll #define OP_OP_LWC2 0x32
2062a6b7db3Sskrll #define OP_OP_LWC3 0x33 /* a.k.a. pref */
2072a6b7db3Sskrll #define OP_OP_LDC1 0x35
2082a6b7db3Sskrll #define OP_OP_LDC2 0x36
2092a6b7db3Sskrll #define OP_OP_LDC3 0x37 /* a.k.a. ld */
2102a6b7db3Sskrll #define OP_OP_SWC1 0x39
2112a6b7db3Sskrll #define OP_OP_SWC2 0x3a
2122a6b7db3Sskrll #define OP_OP_SWC3 0x3b
2132a6b7db3Sskrll #define OP_OP_SDC1 0x3d
2142a6b7db3Sskrll #define OP_OP_SDC2 0x3e
2152a6b7db3Sskrll #define OP_OP_SDC3 0x3f /* a.k.a. sd */
2162a6b7db3Sskrll
2175f4eaf39Schristos /* MIPS VIRT ASE */
2185f4eaf39Schristos #define OP_MASK_CODE10 0x3ff
2195f4eaf39Schristos #define OP_SH_CODE10 11
2205f4eaf39Schristos
2212a6b7db3Sskrll /* Values in the 'VSEL' field. */
2222a6b7db3Sskrll #define MDMX_FMTSEL_IMM_QH 0x1d
2232a6b7db3Sskrll #define MDMX_FMTSEL_IMM_OB 0x1e
2242a6b7db3Sskrll #define MDMX_FMTSEL_VEC_QH 0x15
2252a6b7db3Sskrll #define MDMX_FMTSEL_VEC_OB 0x16
2262a6b7db3Sskrll
2272a6b7db3Sskrll /* UDI */
2282a6b7db3Sskrll #define OP_SH_UDI1 6
2292a6b7db3Sskrll #define OP_MASK_UDI1 0x1f
2302a6b7db3Sskrll #define OP_SH_UDI2 6
2312a6b7db3Sskrll #define OP_MASK_UDI2 0x3ff
2322a6b7db3Sskrll #define OP_SH_UDI3 6
2332a6b7db3Sskrll #define OP_MASK_UDI3 0x7fff
2342a6b7db3Sskrll #define OP_SH_UDI4 6
2352a6b7db3Sskrll #define OP_MASK_UDI4 0xfffff
2362a6b7db3Sskrll
2372a6b7db3Sskrll /* Octeon */
2382a6b7db3Sskrll #define OP_SH_BBITIND 16
2392a6b7db3Sskrll #define OP_MASK_BBITIND 0x1f
2402a6b7db3Sskrll #define OP_SH_CINSPOS 6
2412a6b7db3Sskrll #define OP_MASK_CINSPOS 0x1f
2422a6b7db3Sskrll #define OP_SH_CINSLM1 11
2432a6b7db3Sskrll #define OP_MASK_CINSLM1 0x1f
2442a6b7db3Sskrll #define OP_SH_SEQI 6
2452a6b7db3Sskrll #define OP_MASK_SEQI 0x3ff
2462a6b7db3Sskrll
247b410d692Schristos /* Loongson */
248b410d692Schristos #define OP_SH_OFFSET_A 6
249b410d692Schristos #define OP_MASK_OFFSET_A 0xff
250b410d692Schristos #define OP_SH_OFFSET_B 3
251b410d692Schristos #define OP_MASK_OFFSET_B 0xff
252b410d692Schristos #define OP_SH_OFFSET_C 6
253b410d692Schristos #define OP_MASK_OFFSET_C 0x1ff
254b410d692Schristos #define OP_SH_RZ 0
255b410d692Schristos #define OP_MASK_RZ 0x1f
256b410d692Schristos #define OP_SH_FZ 0
257b410d692Schristos #define OP_MASK_FZ 0x1f
258b410d692Schristos
259b410d692Schristos /* Every MICROMIPSOP_X definition requires a corresponding OP_X
260b410d692Schristos definition, and vice versa. This simplifies various parts
261b410d692Schristos of the operand handling in GAS. The fields below only exist
262b410d692Schristos in the microMIPS encoding, so define each one to have an empty
263b410d692Schristos range. */
264b410d692Schristos #define OP_MASK_TRAP 0
265b410d692Schristos #define OP_SH_TRAP 0
266b410d692Schristos #define OP_MASK_OFFSET10 0
267b410d692Schristos #define OP_SH_OFFSET10 0
268b410d692Schristos #define OP_MASK_RS3 0
269b410d692Schristos #define OP_SH_RS3 0
270b410d692Schristos #define OP_MASK_MB 0
271b410d692Schristos #define OP_SH_MB 0
272b410d692Schristos #define OP_MASK_MC 0
273b410d692Schristos #define OP_SH_MC 0
274b410d692Schristos #define OP_MASK_MD 0
275b410d692Schristos #define OP_SH_MD 0
276b410d692Schristos #define OP_MASK_ME 0
277b410d692Schristos #define OP_SH_ME 0
278b410d692Schristos #define OP_MASK_MF 0
279b410d692Schristos #define OP_SH_MF 0
280b410d692Schristos #define OP_MASK_MG 0
281b410d692Schristos #define OP_SH_MG 0
282b410d692Schristos #define OP_MASK_MH 0
283b410d692Schristos #define OP_SH_MH 0
284b410d692Schristos #define OP_MASK_MJ 0
285b410d692Schristos #define OP_SH_MJ 0
286b410d692Schristos #define OP_MASK_ML 0
287b410d692Schristos #define OP_SH_ML 0
288b410d692Schristos #define OP_MASK_MM 0
289b410d692Schristos #define OP_SH_MM 0
290b410d692Schristos #define OP_MASK_MN 0
291b410d692Schristos #define OP_SH_MN 0
292b410d692Schristos #define OP_MASK_MP 0
293b410d692Schristos #define OP_SH_MP 0
294b410d692Schristos #define OP_MASK_MQ 0
295b410d692Schristos #define OP_SH_MQ 0
296b410d692Schristos #define OP_MASK_IMMA 0
297b410d692Schristos #define OP_SH_IMMA 0
298b410d692Schristos #define OP_MASK_IMMB 0
299b410d692Schristos #define OP_SH_IMMB 0
300b410d692Schristos #define OP_MASK_IMMC 0
301b410d692Schristos #define OP_SH_IMMC 0
302b410d692Schristos #define OP_MASK_IMMF 0
303b410d692Schristos #define OP_SH_IMMF 0
304b410d692Schristos #define OP_MASK_IMMG 0
305b410d692Schristos #define OP_SH_IMMG 0
306b410d692Schristos #define OP_MASK_IMMH 0
307b410d692Schristos #define OP_SH_IMMH 0
308b410d692Schristos #define OP_MASK_IMMI 0
309b410d692Schristos #define OP_SH_IMMI 0
310b410d692Schristos #define OP_MASK_IMMJ 0
311b410d692Schristos #define OP_SH_IMMJ 0
312b410d692Schristos #define OP_MASK_IMML 0
313b410d692Schristos #define OP_SH_IMML 0
314b410d692Schristos #define OP_MASK_IMMM 0
315b410d692Schristos #define OP_SH_IMMM 0
316b410d692Schristos #define OP_MASK_IMMN 0
317b410d692Schristos #define OP_SH_IMMN 0
318b410d692Schristos #define OP_MASK_IMMO 0
319b410d692Schristos #define OP_SH_IMMO 0
320b410d692Schristos #define OP_MASK_IMMP 0
321b410d692Schristos #define OP_SH_IMMP 0
322b410d692Schristos #define OP_MASK_IMMQ 0
323b410d692Schristos #define OP_SH_IMMQ 0
324b410d692Schristos #define OP_MASK_IMMU 0
325b410d692Schristos #define OP_SH_IMMU 0
326b410d692Schristos #define OP_MASK_IMMW 0
327b410d692Schristos #define OP_SH_IMMW 0
328b410d692Schristos #define OP_MASK_IMMX 0
329b410d692Schristos #define OP_SH_IMMX 0
330b410d692Schristos #define OP_MASK_IMMY 0
331b410d692Schristos #define OP_SH_IMMY 0
332b410d692Schristos
3335f4eaf39Schristos /* Enhanced VA Scheme */
3345f4eaf39Schristos #define OP_SH_EVAOFFSET 7
3355f4eaf39Schristos #define OP_MASK_EVAOFFSET 0x1ff
3365f4eaf39Schristos
3375f4eaf39Schristos /* Enumerates the various types of MIPS operand. */
3385f4eaf39Schristos enum mips_operand_type {
3395f4eaf39Schristos /* Described by mips_int_operand. */
3405f4eaf39Schristos OP_INT,
3415f4eaf39Schristos
3425f4eaf39Schristos /* Described by mips_mapped_int_operand. */
3435f4eaf39Schristos OP_MAPPED_INT,
3445f4eaf39Schristos
3455f4eaf39Schristos /* Described by mips_msb_operand. */
3465f4eaf39Schristos OP_MSB,
3475f4eaf39Schristos
3485f4eaf39Schristos /* Described by mips_reg_operand. */
3495f4eaf39Schristos OP_REG,
3505f4eaf39Schristos
3515f4eaf39Schristos /* Like OP_REG, but can be omitted if the register is the same as the
3525f4eaf39Schristos previous operand. */
3535f4eaf39Schristos OP_OPTIONAL_REG,
3545f4eaf39Schristos
3555f4eaf39Schristos /* Described by mips_reg_pair_operand. */
3565f4eaf39Schristos OP_REG_PAIR,
3575f4eaf39Schristos
3585f4eaf39Schristos /* Described by mips_pcrel_operand. */
3595f4eaf39Schristos OP_PCREL,
3605f4eaf39Schristos
3615f4eaf39Schristos /* A performance register. The field is 5 bits in size, but the supported
3625f4eaf39Schristos values are much more restricted. */
3635f4eaf39Schristos OP_PERF_REG,
3645f4eaf39Schristos
3655f4eaf39Schristos /* The final operand in a microMIPS ADDIUSP instruction. It mostly acts
3665f4eaf39Schristos as a normal 9-bit signed offset that is multiplied by four, but there
3675f4eaf39Schristos are four special cases:
3685f4eaf39Schristos
3695f4eaf39Schristos -2 * 4 => -258 * 4
3705f4eaf39Schristos -1 * 4 => -257 * 4
3715f4eaf39Schristos 0 * 4 => 256 * 4
3725f4eaf39Schristos 1 * 4 => 257 * 4. */
3735f4eaf39Schristos OP_ADDIUSP_INT,
3745f4eaf39Schristos
3755f4eaf39Schristos /* The target of a (D)CLO or (D)CLZ instruction. The operand spans two
3765f4eaf39Schristos 5-bit register fields, both of which must be set to the destination
3775f4eaf39Schristos register. */
3785f4eaf39Schristos OP_CLO_CLZ_DEST,
3795f4eaf39Schristos
3805f4eaf39Schristos /* A register list for a microMIPS LWM or SWM instruction. The operand
3815f4eaf39Schristos size determines whether the 16-bit or 32-bit encoding is required. */
3825f4eaf39Schristos OP_LWM_SWM_LIST,
3835f4eaf39Schristos
3845f4eaf39Schristos /* The register list for an emulated MIPS16 ENTRY or EXIT instruction. */
3855f4eaf39Schristos OP_ENTRY_EXIT_LIST,
3865f4eaf39Schristos
3875f4eaf39Schristos /* The register list and frame size for a MIPS16 SAVE or RESTORE
3885f4eaf39Schristos instruction. */
3895f4eaf39Schristos OP_SAVE_RESTORE_LIST,
3905f4eaf39Schristos
3915f4eaf39Schristos /* A 10-bit field VVVVVNNNNN used for octobyte and quadhalf instructions:
3925f4eaf39Schristos
3935f4eaf39Schristos V Meaning
3945f4eaf39Schristos ----- -------
3955f4eaf39Schristos 0EEE0 8 copies of $vN[E], OB format
3965f4eaf39Schristos 0EE01 4 copies of $vN[E], QH format
3975f4eaf39Schristos 10110 all 8 elements of $vN, OB format
3985f4eaf39Schristos 10101 all 4 elements of $vN, QH format
3995f4eaf39Schristos 11110 8 copies of immediate N, OB format
4005f4eaf39Schristos 11101 4 copies of immediate N, QH format. */
4015f4eaf39Schristos OP_MDMX_IMM_REG,
4025f4eaf39Schristos
4035f4eaf39Schristos /* A register operand that must match the destination register. */
4045f4eaf39Schristos OP_REPEAT_DEST_REG,
4055f4eaf39Schristos
4065f4eaf39Schristos /* A register operand that must match the previous register. */
4075f4eaf39Schristos OP_REPEAT_PREV_REG,
4085f4eaf39Schristos
4095f4eaf39Schristos /* $pc, which has no encoding in the architectural instruction. */
4105f4eaf39Schristos OP_PC,
4115f4eaf39Schristos
4126f226886Schristos /* $28, which has no encoding in the MIPS16e architectural instruction. */
4136f226886Schristos OP_REG28,
4146f226886Schristos
4155f4eaf39Schristos /* A 4-bit XYZW channel mask or 2-bit XYZW index; the size determines
4165f4eaf39Schristos which. */
4175f4eaf39Schristos OP_VU0_SUFFIX,
4185f4eaf39Schristos
4195f4eaf39Schristos /* Like OP_VU0_SUFFIX, but used when the operand's value has already
4205f4eaf39Schristos been set. Any suffix used here must match the previous value. */
4215f4eaf39Schristos OP_VU0_MATCH_SUFFIX,
4225f4eaf39Schristos
4235f4eaf39Schristos /* An index selected by an integer, e.g. [1]. */
4245f4eaf39Schristos OP_IMM_INDEX,
4255f4eaf39Schristos
4265f4eaf39Schristos /* An index selected by a register, e.g. [$2]. */
4275f4eaf39Schristos OP_REG_INDEX,
4285f4eaf39Schristos
4295f4eaf39Schristos /* The operand spans two 5-bit register fields, both of which must be set to
4305f4eaf39Schristos the source register. */
4315f4eaf39Schristos OP_SAME_RS_RT,
4325f4eaf39Schristos
4335f4eaf39Schristos /* Described by mips_prev_operand. */
4345f4eaf39Schristos OP_CHECK_PREV,
4355f4eaf39Schristos
4365f4eaf39Schristos /* A register operand that must not be zero. */
4375f4eaf39Schristos OP_NON_ZERO_REG
4385f4eaf39Schristos };
4395f4eaf39Schristos
4405f4eaf39Schristos /* Enumerates the types of MIPS register. */
4415f4eaf39Schristos enum mips_reg_operand_type {
4425f4eaf39Schristos /* General registers $0-$31. Software names like $at can also be used. */
4435f4eaf39Schristos OP_REG_GP,
4445f4eaf39Schristos
4455f4eaf39Schristos /* Floating-point registers $f0-$f31. */
4465f4eaf39Schristos OP_REG_FP,
4475f4eaf39Schristos
4485f4eaf39Schristos /* Coprocessor condition code registers $cc0-$cc7. FPU condition codes
4495f4eaf39Schristos can also be written $fcc0-$fcc7. */
4505f4eaf39Schristos OP_REG_CCC,
4515f4eaf39Schristos
4525f4eaf39Schristos /* FPRs used in a vector capacity. They can be written $f0-$f31
4535f4eaf39Schristos or $v0-$v31, although the latter form is not used for the VR5400
4545f4eaf39Schristos vector instructions. */
4555f4eaf39Schristos OP_REG_VEC,
4565f4eaf39Schristos
4575f4eaf39Schristos /* DSP accumulator registers $ac0-$ac3. */
4585f4eaf39Schristos OP_REG_ACC,
4595f4eaf39Schristos
4605f4eaf39Schristos /* Coprocessor registers $0-$31. Mnemonic names like c0_cause can
4615f4eaf39Schristos also be used in some contexts. */
4625f4eaf39Schristos OP_REG_COPRO,
4635f4eaf39Schristos
46403f5171aSchristos /* Coprocessor control registers $0-$31. Mnemonic names like c1_fcsr can
46503f5171aSchristos also be used in some contexts. */
46603f5171aSchristos OP_REG_CONTROL,
46703f5171aSchristos
4685f4eaf39Schristos /* Hardware registers $0-$31. Mnemonic names like hwr_cpunum can
4695f4eaf39Schristos also be used in some contexts. */
4705f4eaf39Schristos OP_REG_HW,
4715f4eaf39Schristos
4725f4eaf39Schristos /* Floating-point registers $vf0-$vf31. */
4735f4eaf39Schristos OP_REG_VF,
4745f4eaf39Schristos
4755f4eaf39Schristos /* Integer registers $vi0-$vi31. */
4765f4eaf39Schristos OP_REG_VI,
4775f4eaf39Schristos
4785f4eaf39Schristos /* R5900 VU0 registers $I, $Q, $R and $ACC. */
4795f4eaf39Schristos OP_REG_R5900_I,
4805f4eaf39Schristos OP_REG_R5900_Q,
4815f4eaf39Schristos OP_REG_R5900_R,
4825f4eaf39Schristos OP_REG_R5900_ACC,
4835f4eaf39Schristos
4845f4eaf39Schristos /* MSA registers $w0-$w31. */
4855f4eaf39Schristos OP_REG_MSA,
4865f4eaf39Schristos
4875f4eaf39Schristos /* MSA control registers $0-$31. */
4885f4eaf39Schristos OP_REG_MSA_CTRL
4895f4eaf39Schristos };
4905f4eaf39Schristos
4915f4eaf39Schristos /* Base class for all operands. */
4925f4eaf39Schristos struct mips_operand
4935f4eaf39Schristos {
4945f4eaf39Schristos /* The type of the operand. */
4955f4eaf39Schristos enum mips_operand_type type;
4965f4eaf39Schristos
4975f4eaf39Schristos /* The operand occupies SIZE bits of the instruction, starting at LSB. */
4985f4eaf39Schristos unsigned short size;
4995f4eaf39Schristos unsigned short lsb;
5005f4eaf39Schristos };
5015f4eaf39Schristos
5025f4eaf39Schristos /* Describes an integer operand with a regular encoding pattern. */
5035f4eaf39Schristos struct mips_int_operand
5045f4eaf39Schristos {
5055f4eaf39Schristos struct mips_operand root;
5065f4eaf39Schristos
5075f4eaf39Schristos /* The low ROOT.SIZE bits of MAX_VAL encodes (MAX_VAL + BIAS) << SHIFT.
5085f4eaf39Schristos The cyclically previous field value encodes 1 << SHIFT less than that,
5095f4eaf39Schristos and so on. E.g.
5105f4eaf39Schristos
5115f4eaf39Schristos - for { { T, 4, L }, 14, 0, 0 }, field values 0...14 encode themselves,
5125f4eaf39Schristos but 15 encodes -1.
5135f4eaf39Schristos
5145f4eaf39Schristos - { { T, 8, L }, 127, 0, 2 } is a normal signed 8-bit operand that is
5155f4eaf39Schristos shifted left two places.
5165f4eaf39Schristos
5175f4eaf39Schristos - { { T, 3, L }, 8, 0, 0 } is a normal unsigned 3-bit operand except
5185f4eaf39Schristos that 0 encodes 8.
5195f4eaf39Schristos
5205f4eaf39Schristos - { { ... }, 0, 1, 3 } means that N encodes (N + 1) << 3. */
5215f4eaf39Schristos unsigned int max_val;
5225f4eaf39Schristos int bias;
5235f4eaf39Schristos unsigned int shift;
5245f4eaf39Schristos
5255f4eaf39Schristos /* True if the operand should be printed as hex rather than decimal. */
52603f5171aSchristos bool print_hex;
5275f4eaf39Schristos };
5285f4eaf39Schristos
5295f4eaf39Schristos /* Uses a lookup table to describe a small integer operand. */
5305f4eaf39Schristos struct mips_mapped_int_operand
5315f4eaf39Schristos {
5325f4eaf39Schristos struct mips_operand root;
5335f4eaf39Schristos
5345f4eaf39Schristos /* Maps each encoding value to the integer that it represents. */
5355f4eaf39Schristos const int *int_map;
5365f4eaf39Schristos
5375f4eaf39Schristos /* True if the operand should be printed as hex rather than decimal. */
53803f5171aSchristos bool print_hex;
5395f4eaf39Schristos };
5405f4eaf39Schristos
5415f4eaf39Schristos /* An operand that encodes the most significant bit position of a bitfield.
5425f4eaf39Schristos Given a bitfield that spans bits [MSB, LSB], some operands of this type
5435f4eaf39Schristos encode MSB directly while others encode MSB - LSB. Each operand of this
5445f4eaf39Schristos type is preceded by an integer operand that specifies LSB.
5455f4eaf39Schristos
5465f4eaf39Schristos The assembly form varies between instructions. For some instructions,
5475f4eaf39Schristos such as EXT, the operand is written as the bitfield size. For others,
5485f4eaf39Schristos such as EXTS, it is written in raw MSB - LSB form. */
5495f4eaf39Schristos struct mips_msb_operand
5505f4eaf39Schristos {
5515f4eaf39Schristos struct mips_operand root;
5525f4eaf39Schristos
5535f4eaf39Schristos /* The assembly-level operand encoded by a field value of 0. */
5545f4eaf39Schristos int bias;
5555f4eaf39Schristos
5565f4eaf39Schristos /* True if the operand encodes MSB directly, false if it encodes
5575f4eaf39Schristos MSB - LSB. */
55803f5171aSchristos bool add_lsb;
5595f4eaf39Schristos
5605f4eaf39Schristos /* The maximum value of MSB + 1. */
5615f4eaf39Schristos unsigned int opsize;
5625f4eaf39Schristos };
5635f4eaf39Schristos
5645f4eaf39Schristos /* Describes a single register operand. */
5655f4eaf39Schristos struct mips_reg_operand
5665f4eaf39Schristos {
5675f4eaf39Schristos struct mips_operand root;
5685f4eaf39Schristos
5695f4eaf39Schristos /* The type of register. */
5705f4eaf39Schristos enum mips_reg_operand_type reg_type;
5715f4eaf39Schristos
5725f4eaf39Schristos /* If nonnull, REG_MAP[N] gives the register associated with encoding N,
5735f4eaf39Schristos otherwise the encoding is the same as the register number. */
5745f4eaf39Schristos const unsigned char *reg_map;
5755f4eaf39Schristos };
5765f4eaf39Schristos
5775f4eaf39Schristos /* Describes an operand that which must match a condition based on the
5785f4eaf39Schristos previous operand. */
5795f4eaf39Schristos struct mips_check_prev_operand
5805f4eaf39Schristos {
5815f4eaf39Schristos struct mips_operand root;
5825f4eaf39Schristos
58303f5171aSchristos bool greater_than_ok;
58403f5171aSchristos bool less_than_ok;
58503f5171aSchristos bool equal_ok;
58603f5171aSchristos bool zero_ok;
5875f4eaf39Schristos };
5885f4eaf39Schristos
5895f4eaf39Schristos /* Describes an operand that encodes a pair of registers. */
5905f4eaf39Schristos struct mips_reg_pair_operand
5915f4eaf39Schristos {
5925f4eaf39Schristos struct mips_operand root;
5935f4eaf39Schristos
5945f4eaf39Schristos /* The type of register. */
5955f4eaf39Schristos enum mips_reg_operand_type reg_type;
5965f4eaf39Schristos
5975f4eaf39Schristos /* Encoding N represents REG1_MAP[N], REG2_MAP[N]. */
5985f4eaf39Schristos unsigned char *reg1_map;
5995f4eaf39Schristos unsigned char *reg2_map;
6005f4eaf39Schristos };
6015f4eaf39Schristos
6025f4eaf39Schristos /* Describes an operand that is calculated relative to a base PC.
6035f4eaf39Schristos The base PC is usually the address of the following instruction,
6045f4eaf39Schristos but the rules for MIPS16 instructions like ADDIUPC are more complicated. */
6055f4eaf39Schristos struct mips_pcrel_operand
6065f4eaf39Schristos {
6075f4eaf39Schristos /* Encodes the offset. */
6085f4eaf39Schristos struct mips_int_operand root;
6095f4eaf39Schristos
6105f4eaf39Schristos /* The low ALIGN_LOG2 bits of the base PC are cleared to give PC',
6115f4eaf39Schristos which is then added to the offset encoded by ROOT. */
6125f4eaf39Schristos unsigned int align_log2 : 8;
6135f4eaf39Schristos
6145f4eaf39Schristos /* If INCLUDE_ISA_BIT, the ISA bit of the original base PC is then
6155f4eaf39Schristos reinstated. This is true for jumps and branches and false for
6165f4eaf39Schristos PC-relative data instructions. */
6175f4eaf39Schristos unsigned int include_isa_bit : 1;
6185f4eaf39Schristos
6195f4eaf39Schristos /* If FLIP_ISA_BIT, the ISA bit of the result is inverted.
6205f4eaf39Schristos This is true for JALX and false otherwise. */
6215f4eaf39Schristos unsigned int flip_isa_bit : 1;
6225f4eaf39Schristos };
6235f4eaf39Schristos
6245f4eaf39Schristos /* Return true if the assembly syntax allows OPERAND to be omitted. */
6255f4eaf39Schristos
62603f5171aSchristos static inline bool
mips_optional_operand_p(const struct mips_operand * operand)6275f4eaf39Schristos mips_optional_operand_p (const struct mips_operand *operand)
6285f4eaf39Schristos {
6295f4eaf39Schristos return (operand->type == OP_OPTIONAL_REG
6305f4eaf39Schristos || operand->type == OP_REPEAT_PREV_REG);
6315f4eaf39Schristos }
6325f4eaf39Schristos
6335f4eaf39Schristos /* Return a version of INSN in which the field specified by OPERAND
6345f4eaf39Schristos has value UVAL. */
6355f4eaf39Schristos
6365f4eaf39Schristos static inline unsigned int
mips_insert_operand(const struct mips_operand * operand,unsigned int insn,unsigned int uval)6375f4eaf39Schristos mips_insert_operand (const struct mips_operand *operand, unsigned int insn,
6385f4eaf39Schristos unsigned int uval)
6395f4eaf39Schristos {
6405f4eaf39Schristos unsigned int mask;
6415f4eaf39Schristos
6425f4eaf39Schristos mask = (1 << operand->size) - 1;
6435f4eaf39Schristos insn &= ~(mask << operand->lsb);
6445f4eaf39Schristos insn |= (uval & mask) << operand->lsb;
6455f4eaf39Schristos return insn;
6465f4eaf39Schristos }
6475f4eaf39Schristos
6485f4eaf39Schristos /* Extract OPERAND from instruction INSN. */
6495f4eaf39Schristos
6505f4eaf39Schristos static inline unsigned int
mips_extract_operand(const struct mips_operand * operand,unsigned int insn)6515f4eaf39Schristos mips_extract_operand (const struct mips_operand *operand, unsigned int insn)
6525f4eaf39Schristos {
6535f4eaf39Schristos return (insn >> operand->lsb) & ((1 << operand->size) - 1);
6545f4eaf39Schristos }
6555f4eaf39Schristos
6565f4eaf39Schristos /* UVAL is the value encoded by OPERAND. Return it in signed form. */
6575f4eaf39Schristos
6585f4eaf39Schristos static inline int
mips_signed_operand(const struct mips_operand * operand,unsigned int uval)6595f4eaf39Schristos mips_signed_operand (const struct mips_operand *operand, unsigned int uval)
6605f4eaf39Schristos {
6615f4eaf39Schristos unsigned int sign_bit, mask;
6625f4eaf39Schristos
6635f4eaf39Schristos mask = (1 << operand->size) - 1;
6645f4eaf39Schristos sign_bit = 1 << (operand->size - 1);
6655f4eaf39Schristos return ((uval + sign_bit) & mask) - sign_bit;
6665f4eaf39Schristos }
6675f4eaf39Schristos
6685f4eaf39Schristos /* Return the integer that OPERAND encodes as UVAL. */
6695f4eaf39Schristos
6705f4eaf39Schristos static inline int
mips_decode_int_operand(const struct mips_int_operand * operand,unsigned int uval)6715f4eaf39Schristos mips_decode_int_operand (const struct mips_int_operand *operand,
6725f4eaf39Schristos unsigned int uval)
6735f4eaf39Schristos {
6745f4eaf39Schristos uval |= (operand->max_val - uval) & -(1 << operand->root.size);
6755f4eaf39Schristos uval += operand->bias;
6765f4eaf39Schristos uval <<= operand->shift;
6775f4eaf39Schristos return uval;
6785f4eaf39Schristos }
6795f4eaf39Schristos
6805f4eaf39Schristos /* Return the maximum value that can be encoded by OPERAND. */
6815f4eaf39Schristos
6825f4eaf39Schristos static inline int
mips_int_operand_max(const struct mips_int_operand * operand)6835f4eaf39Schristos mips_int_operand_max (const struct mips_int_operand *operand)
6845f4eaf39Schristos {
6855f4eaf39Schristos return (operand->max_val + operand->bias) << operand->shift;
6865f4eaf39Schristos }
6875f4eaf39Schristos
6885f4eaf39Schristos /* Return the minimum value that can be encoded by OPERAND. */
6895f4eaf39Schristos
6905f4eaf39Schristos static inline int
mips_int_operand_min(const struct mips_int_operand * operand)6915f4eaf39Schristos mips_int_operand_min (const struct mips_int_operand *operand)
6925f4eaf39Schristos {
6935f4eaf39Schristos unsigned int mask;
6945f4eaf39Schristos
6955f4eaf39Schristos mask = (1 << operand->root.size) - 1;
6965f4eaf39Schristos return mips_int_operand_max (operand) - (mask << operand->shift);
6975f4eaf39Schristos }
6985f4eaf39Schristos
6995f4eaf39Schristos /* Return the register that OPERAND encodes as UVAL. */
7005f4eaf39Schristos
7015f4eaf39Schristos static inline int
mips_decode_reg_operand(const struct mips_reg_operand * operand,unsigned int uval)7025f4eaf39Schristos mips_decode_reg_operand (const struct mips_reg_operand *operand,
7035f4eaf39Schristos unsigned int uval)
7045f4eaf39Schristos {
7055f4eaf39Schristos if (operand->reg_map)
7065f4eaf39Schristos uval = operand->reg_map[uval];
7075f4eaf39Schristos return uval;
7085f4eaf39Schristos }
7095f4eaf39Schristos
7105f4eaf39Schristos /* PC-relative operand OPERAND has value UVAL and is relative to BASE_PC.
7115f4eaf39Schristos Return the address that it encodes. */
7125f4eaf39Schristos
7135f4eaf39Schristos static inline bfd_vma
mips_decode_pcrel_operand(const struct mips_pcrel_operand * operand,bfd_vma base_pc,unsigned int uval)7145f4eaf39Schristos mips_decode_pcrel_operand (const struct mips_pcrel_operand *operand,
7155f4eaf39Schristos bfd_vma base_pc, unsigned int uval)
7165f4eaf39Schristos {
7175f4eaf39Schristos bfd_vma addr;
7185f4eaf39Schristos
7195f4eaf39Schristos addr = base_pc & -(1 << operand->align_log2);
7205f4eaf39Schristos addr += mips_decode_int_operand (&operand->root, uval);
7215f4eaf39Schristos if (operand->include_isa_bit)
7225f4eaf39Schristos addr |= base_pc & 1;
7235f4eaf39Schristos if (operand->flip_isa_bit)
7245f4eaf39Schristos addr ^= 1;
7255f4eaf39Schristos return addr;
7265f4eaf39Schristos }
7275f4eaf39Schristos
7282a6b7db3Sskrll /* This structure holds information for a particular instruction. */
7292a6b7db3Sskrll
7302a6b7db3Sskrll struct mips_opcode
7312a6b7db3Sskrll {
7322a6b7db3Sskrll /* The name of the instruction. */
7332a6b7db3Sskrll const char *name;
7342a6b7db3Sskrll /* A string describing the arguments for this instruction. */
7352a6b7db3Sskrll const char *args;
7362a6b7db3Sskrll /* The basic opcode for the instruction. When assembling, this
7372a6b7db3Sskrll opcode is modified by the arguments to produce the actual opcode
7382a6b7db3Sskrll that is used. If pinfo is INSN_MACRO, then this is 0. */
7392a6b7db3Sskrll unsigned long match;
7402a6b7db3Sskrll /* If pinfo is not INSN_MACRO, then this is a bit mask for the
7412a6b7db3Sskrll relevant portions of the opcode when disassembling. If the
7422a6b7db3Sskrll actual opcode anded with the match field equals the opcode field,
7432a6b7db3Sskrll then we have found the correct instruction. If pinfo is
7442a6b7db3Sskrll INSN_MACRO, then this field is the macro identifier. */
7452a6b7db3Sskrll unsigned long mask;
7462a6b7db3Sskrll /* For a macro, this is INSN_MACRO. Otherwise, it is a collection
7472a6b7db3Sskrll of bits describing the instruction, notably any relevant hazard
7482a6b7db3Sskrll information. */
7492a6b7db3Sskrll unsigned long pinfo;
7502a6b7db3Sskrll /* A collection of additional bits describing the instruction. */
7512a6b7db3Sskrll unsigned long pinfo2;
7522a6b7db3Sskrll /* A collection of bits describing the instruction sets of which this
7532a6b7db3Sskrll instruction or macro is a member. */
7542a6b7db3Sskrll unsigned long membership;
7555f4eaf39Schristos /* A collection of bits describing the ASE of which this instruction
7565f4eaf39Schristos or macro is a member. */
7575f4eaf39Schristos unsigned long ase;
758b410d692Schristos /* A collection of bits describing the instruction sets of which this
759b410d692Schristos instruction or macro is not a member. */
760b410d692Schristos unsigned long exclusions;
7612a6b7db3Sskrll };
7622a6b7db3Sskrll
7636f226886Schristos /* Return true if MO is an instruction that requires 32-bit encoding. */
7646f226886Schristos
76503f5171aSchristos static inline bool
mips_opcode_32bit_p(const struct mips_opcode * mo)7666f226886Schristos mips_opcode_32bit_p (const struct mips_opcode *mo)
7676f226886Schristos {
7686f226886Schristos return mo->mask >> 16 != 0;
7696f226886Schristos }
7706f226886Schristos
7712a6b7db3Sskrll /* These are the characters which may appear in the args field of an
7722a6b7db3Sskrll instruction. They appear in the order in which the fields appear
7732a6b7db3Sskrll when the instruction is used. Commas and parentheses in the args
7742a6b7db3Sskrll string are ignored when assembling, and written into the output
7752a6b7db3Sskrll when disassembling.
7762a6b7db3Sskrll
7772a6b7db3Sskrll Each of these characters corresponds to a mask field defined above.
7782a6b7db3Sskrll
7795f4eaf39Schristos "1" 5 bit sync type (OP_*_STYPE)
7802a6b7db3Sskrll "<" 5 bit shift amount (OP_*_SHAMT)
7812a6b7db3Sskrll ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
7822a6b7db3Sskrll "a" 26 bit target address (OP_*_TARGET)
7835f4eaf39Schristos "+i" likewise, but flips bit 0
7842a6b7db3Sskrll "b" 5 bit base register (OP_*_RS)
7852a6b7db3Sskrll "c" 10 bit breakpoint code (OP_*_CODE)
7862a6b7db3Sskrll "d" 5 bit destination register specifier (OP_*_RD)
7872a6b7db3Sskrll "h" 5 bit prefx hint (OP_*_PREFX)
7882a6b7db3Sskrll "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
7892a6b7db3Sskrll "j" 16 bit signed immediate (OP_*_DELTA)
7902a6b7db3Sskrll "k" 5 bit cache opcode in target register position (OP_*_CACHE)
7912a6b7db3Sskrll "o" 16 bit signed offset (OP_*_DELTA)
7922a6b7db3Sskrll "p" 16 bit PC relative branch target address (OP_*_DELTA)
7932a6b7db3Sskrll "q" 10 bit extra breakpoint code (OP_*_CODE2)
7942a6b7db3Sskrll "r" 5 bit same register used as both source and target (OP_*_RS)
7952a6b7db3Sskrll "s" 5 bit source register specifier (OP_*_RS)
7962a6b7db3Sskrll "t" 5 bit target register (OP_*_RT)
7972a6b7db3Sskrll "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
7982a6b7db3Sskrll "v" 5 bit same register used as both source and destination (OP_*_RS)
7992a6b7db3Sskrll "w" 5 bit same register used as both target and destination (OP_*_RT)
8002a6b7db3Sskrll "U" 5 bit same destination register in both OP_*_RD and OP_*_RT
8012a6b7db3Sskrll (used by clo and clz)
8022a6b7db3Sskrll "C" 25 bit coprocessor function code (OP_*_COPZ)
8032a6b7db3Sskrll "B" 20 bit syscall/breakpoint function code (OP_*_CODE20)
8042a6b7db3Sskrll "J" 19 bit wait function code (OP_*_CODE19)
8052a6b7db3Sskrll "x" accept and ignore register name
8062a6b7db3Sskrll "z" must be zero register
8072a6b7db3Sskrll "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD)
8082a6b7db3Sskrll "+A" 5 bit ins/ext/dins/dext/dinsm/dextm position, which becomes
809b410d692Schristos LSB (OP_*_SHAMT; OP_*_EXTLSB or OP_*_STYPE may be used for
810b410d692Schristos microMIPS compatibility).
8112a6b7db3Sskrll Enforces: 0 <= pos < 32.
8122a6b7db3Sskrll "+B" 5 bit ins/dins size, which becomes MSB (OP_*_INSMSB).
8132a6b7db3Sskrll Requires that "+A" or "+E" occur first to set position.
8142a6b7db3Sskrll Enforces: 0 < (pos+size) <= 32.
8152a6b7db3Sskrll "+C" 5 bit ext/dext size, which becomes MSBD (OP_*_EXTMSBD).
8162a6b7db3Sskrll Requires that "+A" or "+E" occur first to set position.
8172a6b7db3Sskrll Enforces: 0 < (pos+size) <= 32.
8182a6b7db3Sskrll (Also used by "dext" w/ different limits, but limits for
8192a6b7db3Sskrll that are checked by the M_DEXT macro.)
8202a6b7db3Sskrll "+E" 5 bit dinsu/dextu position, which becomes LSB-32 (OP_*_SHAMT).
8212a6b7db3Sskrll Enforces: 32 <= pos < 64.
8222a6b7db3Sskrll "+F" 5 bit "dinsm/dinsu" size, which becomes MSB-32 (OP_*_INSMSB).
8232a6b7db3Sskrll Requires that "+A" or "+E" occur first to set position.
8242a6b7db3Sskrll Enforces: 32 < (pos+size) <= 64.
8252a6b7db3Sskrll "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD).
8262a6b7db3Sskrll Requires that "+A" or "+E" occur first to set position.
8272a6b7db3Sskrll Enforces: 32 < (pos+size) <= 64.
8282a6b7db3Sskrll "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD).
8292a6b7db3Sskrll Requires that "+A" or "+E" occur first to set position.
8302a6b7db3Sskrll Enforces: 32 < (pos+size) <= 64.
8312a6b7db3Sskrll
8322a6b7db3Sskrll Floating point instructions:
8332a6b7db3Sskrll "D" 5 bit destination register (OP_*_FD)
8342a6b7db3Sskrll "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
8352a6b7db3Sskrll "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
8362a6b7db3Sskrll "S" 5 bit fs source 1 register (OP_*_FS)
8372a6b7db3Sskrll "T" 5 bit ft source 2 register (OP_*_FT)
8382a6b7db3Sskrll "R" 5 bit fr source 3 register (OP_*_FR)
8392a6b7db3Sskrll "V" 5 bit same register used as floating source and destination (OP_*_FS)
8402a6b7db3Sskrll "W" 5 bit same register used as floating target and destination (OP_*_FT)
8412a6b7db3Sskrll
8422a6b7db3Sskrll Coprocessor instructions:
8432a6b7db3Sskrll "E" 5 bit target register (OP_*_RT)
8442a6b7db3Sskrll "G" 5 bit destination register (OP_*_RD)
8452a6b7db3Sskrll "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL)
8462a6b7db3Sskrll "P" 5 bit performance-monitor register (OP_*_PERFREG)
8472a6b7db3Sskrll "e" 5 bit vector register byte specifier (OP_*_VECBYTE)
84803f5171aSchristos "g" 5 bit control destination register (OP_*_RD)
8492a6b7db3Sskrll "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN)
8502a6b7db3Sskrll
8512a6b7db3Sskrll Macro instructions:
8522a6b7db3Sskrll "A" General 32 bit expression
8532a6b7db3Sskrll "I" 32 bit immediate (value placed in imm_expr).
8542a6b7db3Sskrll "F" 64 bit floating point constant in .rdata
8552a6b7db3Sskrll "L" 64 bit floating point constant in .lit8
8562a6b7db3Sskrll "f" 32 bit floating point constant
8572a6b7db3Sskrll "l" 32 bit floating point constant in .lit4
8582a6b7db3Sskrll
8595f4eaf39Schristos MDMX and VR5400 instruction operands (note that while these use the
8605f4eaf39Schristos FP register fields, the MDMX instructions accept both $fN and $vN names
8615f4eaf39Schristos for the registers):
8625f4eaf39Schristos "O" alignment offset (OP_*_ALN)
8635f4eaf39Schristos "Q" vector/scalar/immediate source (OP_*_VSEL and OP_*_FT)
8645f4eaf39Schristos "X" destination register (OP_*_FD)
8655f4eaf39Schristos "Y" source register (OP_*_FS)
8665f4eaf39Schristos "Z" source register (OP_*_FT)
8675f4eaf39Schristos
8685f4eaf39Schristos R5900 VU0 Macromode instructions:
8695f4eaf39Schristos "+5" 5 bit floating point register (FD)
8705f4eaf39Schristos "+6" 5 bit floating point register (FS)
8715f4eaf39Schristos "+7" 5 bit floating point register (FT)
8725f4eaf39Schristos "+8" 5 bit integer register (FD)
8735f4eaf39Schristos "+9" 5 bit integer register (FS)
8745f4eaf39Schristos "+0" 5 bit integer register (FT)
8755f4eaf39Schristos "+K" match an existing 4-bit channel mask starting at bit 21
8765f4eaf39Schristos "+L" 2-bit channel index starting at bit 21
8775f4eaf39Schristos "+M" 2-bit channel index starting at bit 23
8785f4eaf39Schristos "+N" match an existing 2-bit channel index starting at bit 0
8795f4eaf39Schristos "+f" 15 bit immediate for VCALLMS
8805f4eaf39Schristos "+g" 5 bit signed immediate for VIADDI
8815f4eaf39Schristos "+m" $ACC register (syntax only)
8825f4eaf39Schristos "+q" $Q register (syntax only)
8835f4eaf39Schristos "+r" $R register (syntax only)
8845f4eaf39Schristos "+y" $I register (syntax only)
8855f4eaf39Schristos "#+" "++" decorator in ($reg++) sequence
8865f4eaf39Schristos "#-" "--" decorator in (--$reg) sequence
8872a6b7db3Sskrll
8882a6b7db3Sskrll DSP ASE usage:
8892a6b7db3Sskrll "2" 2 bit unsigned immediate for byte align (OP_*_BP)
8902a6b7db3Sskrll "3" 3 bit unsigned immediate (OP_*_SA3)
8912a6b7db3Sskrll "4" 4 bit unsigned immediate (OP_*_SA4)
8922a6b7db3Sskrll "5" 8 bit unsigned immediate (OP_*_IMM8)
8932a6b7db3Sskrll "6" 5 bit unsigned immediate (OP_*_RS)
8942a6b7db3Sskrll "7" 2 bit dsp accumulator register (OP_*_DSPACC)
8952a6b7db3Sskrll "8" 6 bit unsigned immediate (OP_*_WRDSP)
8962a6b7db3Sskrll "9" 2 bit dsp accumulator register (OP_*_DSPACC_S)
8972a6b7db3Sskrll "0" 6 bit signed immediate (OP_*_DSPSFT)
8982a6b7db3Sskrll ":" 7 bit signed immediate (OP_*_DSPSFT_7)
8992a6b7db3Sskrll "'" 6 bit unsigned immediate (OP_*_RDDSP)
9002a6b7db3Sskrll "@" 10 bit signed immediate (OP_*_IMM10)
9012a6b7db3Sskrll
9022a6b7db3Sskrll MT ASE usage:
9032a6b7db3Sskrll "!" 1 bit usermode flag (OP_*_MT_U)
9042a6b7db3Sskrll "$" 1 bit load high flag (OP_*_MT_H)
9052a6b7db3Sskrll "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T)
9062a6b7db3Sskrll "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D)
90703f5171aSchristos "y" 5 bit control target register (OP_*_RT)
9082a6b7db3Sskrll "+t" 5 bit coprocessor 0 destination register (OP_*_RT)
9092a6b7db3Sskrll
910b410d692Schristos MCU ASE usage:
911b410d692Schristos "~" 12 bit offset (OP_*_OFFSET12)
912b410d692Schristos "\" 3 bit position for aset and aclr (OP_*_3BITPOS)
913b410d692Schristos
9145f4eaf39Schristos VIRT ASE usage:
9155f4eaf39Schristos "+J" 10-bit hypcall code (OP_*CODE10)
9165f4eaf39Schristos
9172a6b7db3Sskrll UDI immediates:
9182a6b7db3Sskrll "+1" UDI immediate bits 6-10
9192a6b7db3Sskrll "+2" UDI immediate bits 6-15
9202a6b7db3Sskrll "+3" UDI immediate bits 6-20
9212a6b7db3Sskrll "+4" UDI immediate bits 6-25
9222a6b7db3Sskrll
9232a6b7db3Sskrll Octeon:
9242a6b7db3Sskrll "+x" Bit index field of bbit. Enforces: 0 <= index < 32.
9252a6b7db3Sskrll "+X" Bit index field of bbit aliasing bbit32. Matches if 32 <= index < 64,
9262a6b7db3Sskrll otherwise skips to next candidate.
9272a6b7db3Sskrll "+p" Position field of cins/cins32/exts/exts32. Enforces 0 <= pos < 32.
9282a6b7db3Sskrll "+P" Position field of cins/exts aliasing cins32/exts32. Matches if
9292a6b7db3Sskrll 32 <= pos < 64, otherwise skips to next candidate.
9302a6b7db3Sskrll "+Q" Immediate field of seqi/snei. Enforces -512 <= imm < 512.
9315f4eaf39Schristos "+s" Length-minus-one field of cins32/exts32. Requires msb position
9325f4eaf39Schristos of the field to be <= 31.
9335f4eaf39Schristos "+S" Length-minus-one field of cins/exts. Requires msb position
9345f4eaf39Schristos of the field to be <= 63.
9352a6b7db3Sskrll
936106c59e5Schristos Loongson-ext ASE:
937b410d692Schristos "+a" 8-bit signed offset in bit 6 (OP_*_OFFSET_A)
938b410d692Schristos "+b" 8-bit signed offset in bit 3 (OP_*_OFFSET_B)
939b410d692Schristos "+c" 9-bit signed offset in bit 6 (OP_*_OFFSET_C)
940b410d692Schristos "+z" 5-bit rz register (OP_*_RZ)
941b410d692Schristos "+Z" 5-bit fz register (OP_*_FZ)
942b410d692Schristos
9436f226886Schristos interAptiv MR2:
9446f226886Schristos "-m" register list for SAVE/RESTORE instruction
9456f226886Schristos
9465f4eaf39Schristos Enhanced VA Scheme:
9475f4eaf39Schristos "+j" 9-bit signed offset in bit 7 (OP_*_EVAOFFSET)
9485f4eaf39Schristos
9495f4eaf39Schristos MSA Extension:
9505f4eaf39Schristos "+d" 5-bit MSA register (FD)
9515f4eaf39Schristos "+e" 5-bit MSA register (FS)
9525f4eaf39Schristos "+h" 5-bit MSA register (FT)
9535f4eaf39Schristos "+k" 5-bit GPR at bit 6
9545f4eaf39Schristos "+l" 5-bit MSA control register at bit 6
9555f4eaf39Schristos "+n" 5-bit MSA control register at bit 11
9565f4eaf39Schristos "+o" 4-bit vector element index at bit 16
9575f4eaf39Schristos "+u" 3-bit vector element index at bit 16
9585f4eaf39Schristos "+v" 2-bit vector element index at bit 16
9595f4eaf39Schristos "+w" 1-bit vector element index at bit 16
9605f4eaf39Schristos "+T" (-512 .. 511) << 0 at bit 16
9615f4eaf39Schristos "+U" (-512 .. 511) << 1 at bit 16
9625f4eaf39Schristos "+V" (-512 .. 511) << 2 at bit 16
9635f4eaf39Schristos "+W" (-512 .. 511) << 3 at bit 16
9645f4eaf39Schristos "+~" 2 bit LSA/DLSA shift amount from 1 to 4 at bit 6
9655f4eaf39Schristos "+!" 3 bit unsigned bit position at bit 16
9665f4eaf39Schristos "+@" 4 bit unsigned bit position at bit 16
9675f4eaf39Schristos "+#" 6 bit unsigned bit position at bit 16
9685f4eaf39Schristos "+$" 5 bit unsigned immediate at bit 16
9695f4eaf39Schristos "+%" 5 bit signed immediate at bit 16
9705f4eaf39Schristos "+^" 10 bit signed immediate at bit 11
9715f4eaf39Schristos "+&" 0 vector element index
9725f4eaf39Schristos "+*" 5-bit register vector element index at bit 16
9735f4eaf39Schristos "+|" 8-bit mask at bit 16
9745f4eaf39Schristos
9755f4eaf39Schristos MIPS R6:
9765f4eaf39Schristos "+:" 11-bit mask at bit 0
9775f4eaf39Schristos "+'" 26 bit PC relative branch target address
9785f4eaf39Schristos "+"" 21 bit PC relative branch target address
9795f4eaf39Schristos "+;" 5 bit same register in both OP_*_RS and OP_*_RT
9805f4eaf39Schristos "+I" 2bit unsigned bit position at bit 6
9815f4eaf39Schristos "+O" 3bit unsigned bit position at bit 6
9825f4eaf39Schristos "+R" must be program counter
9835f4eaf39Schristos "-a" (-262144 .. 262143) << 2 at bit 0
9845f4eaf39Schristos "-b" (-131072 .. 131071) << 3 at bit 0
9855f4eaf39Schristos "-d" Same as destination register GP
9865f4eaf39Schristos "-s" 5 bit source register specifier (OP_*_RS) not $0
9875f4eaf39Schristos "-t" 5 bit source register specifier (OP_*_RT) not $0
9885f4eaf39Schristos "-u" 5 bit source register specifier (OP_*_RT) greater than OP_*_RS
9895f4eaf39Schristos "-v" 5 bit source register specifier (OP_*_RT) not $0 not OP_*_RS
9905f4eaf39Schristos "-w" 5 bit source register specifier (OP_*_RT) less than or equal to OP_*_RS
9915f4eaf39Schristos "-x" 5 bit source register specifier (OP_*_RT) greater than or
9925f4eaf39Schristos equal to OP_*_RS
9935f4eaf39Schristos "-y" 5 bit source register specifier (OP_*_RT) not $0 less than OP_*_RS
9945f4eaf39Schristos "-A" symbolic offset (-262144 .. 262143) << 2 at bit 0
9955f4eaf39Schristos "-B" symbolic offset (-131072 .. 131071) << 3 at bit 0
9965f4eaf39Schristos
9977c6f6726Schristos GINV ASE usage:
9987c6f6726Schristos "+\" 2 bit Global TLB invalidate type at bit 8
9997c6f6726Schristos
10002a6b7db3Sskrll Other:
10012a6b7db3Sskrll "()" parens surrounding optional value
10022a6b7db3Sskrll "," separates operands
10032a6b7db3Sskrll "+" Start of extension sequence.
10042a6b7db3Sskrll
10052a6b7db3Sskrll Characters used so far, for quick reference when adding more:
100632998b1cSchristos "1234567890"
10075f4eaf39Schristos "%[]<>(),+-:'@!#$*&\~"
10082a6b7db3Sskrll "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
100903f5171aSchristos "abcdef hijkl opqrstuvwxyz"
10102a6b7db3Sskrll
10112a6b7db3Sskrll Extension character sequences used so far ("+" followed by the
10122a6b7db3Sskrll following), for quick reference when adding more:
10135f4eaf39Schristos "1234567890"
10147c6f6726Schristos "~!@#$%^&*|:'";\"
10155f4eaf39Schristos "ABCEFGHIJKLMNOPQRSTUVWXZ"
10165f4eaf39Schristos "abcdefghijklmnopqrstuvwxyz"
10175f4eaf39Schristos
10185f4eaf39Schristos Extension character sequences used so far ("-" followed by the
10195f4eaf39Schristos following), for quick reference when adding more:
10205f4eaf39Schristos "AB"
10216f226886Schristos "abdmstuvwxy"
10222a6b7db3Sskrll */
10232a6b7db3Sskrll
10242a6b7db3Sskrll /* These are the bits which may be set in the pinfo field of an
10252a6b7db3Sskrll instructions, if it is not equal to INSN_MACRO. */
10262a6b7db3Sskrll
10275f4eaf39Schristos /* Writes to operand number N. */
10285f4eaf39Schristos #define INSN_WRITE_SHIFT 0
10295f4eaf39Schristos #define INSN_WRITE_1 0x00000001
10305f4eaf39Schristos #define INSN_WRITE_2 0x00000002
10315f4eaf39Schristos #define INSN_WRITE_ALL 0x00000003
10325f4eaf39Schristos /* Reads from operand number N. */
10335f4eaf39Schristos #define INSN_READ_SHIFT 2
10345f4eaf39Schristos #define INSN_READ_1 0x00000004
10355f4eaf39Schristos #define INSN_READ_2 0x00000008
10365f4eaf39Schristos #define INSN_READ_3 0x00000010
10375f4eaf39Schristos #define INSN_READ_4 0x00000020
10385f4eaf39Schristos #define INSN_READ_ALL 0x0000003c
10392a6b7db3Sskrll /* Modifies general purpose register 31. */
10405f4eaf39Schristos #define INSN_WRITE_GPR_31 0x00000040
10412a6b7db3Sskrll /* Modifies coprocessor condition code. */
10425f4eaf39Schristos #define INSN_WRITE_COND_CODE 0x00000080
10432a6b7db3Sskrll /* Reads coprocessor condition code. */
10445f4eaf39Schristos #define INSN_READ_COND_CODE 0x00000100
10452a6b7db3Sskrll /* TLB operation. */
10465f4eaf39Schristos #define INSN_TLB 0x00000200
10472a6b7db3Sskrll /* Reads coprocessor register other than floating point register. */
10485f4eaf39Schristos #define INSN_COP 0x00000400
10495f4eaf39Schristos /* Instruction loads value from memory. */
10505f4eaf39Schristos #define INSN_LOAD_MEMORY 0x00000800
10515f4eaf39Schristos /* Instruction loads value from coprocessor, (may require delay). */
10525f4eaf39Schristos #define INSN_LOAD_COPROC 0x00001000
10532a6b7db3Sskrll /* Instruction has unconditional branch delay slot. */
10545f4eaf39Schristos #define INSN_UNCOND_BRANCH_DELAY 0x00002000
10552a6b7db3Sskrll /* Instruction has conditional branch delay slot. */
10565f4eaf39Schristos #define INSN_COND_BRANCH_DELAY 0x00004000
10572a6b7db3Sskrll /* Conditional branch likely: if branch not taken, insn nullified. */
10585f4eaf39Schristos #define INSN_COND_BRANCH_LIKELY 0x00008000
10595f4eaf39Schristos /* Moves to coprocessor register, (may require delay). */
10605f4eaf39Schristos #define INSN_COPROC_MOVE 0x00010000
10612a6b7db3Sskrll /* Loads coprocessor register from memory, requiring delay. */
10625f4eaf39Schristos #define INSN_COPROC_MEMORY_DELAY 0x00020000
10632a6b7db3Sskrll /* Reads the HI register. */
10645f4eaf39Schristos #define INSN_READ_HI 0x00040000
10652a6b7db3Sskrll /* Reads the LO register. */
10665f4eaf39Schristos #define INSN_READ_LO 0x00080000
10672a6b7db3Sskrll /* Modifies the HI register. */
10685f4eaf39Schristos #define INSN_WRITE_HI 0x00100000
10692a6b7db3Sskrll /* Modifies the LO register. */
10705f4eaf39Schristos #define INSN_WRITE_LO 0x00200000
1071b410d692Schristos /* Not to be placed in a branch delay slot, either architecturally
1072b410d692Schristos or for ease of handling (such as with instructions that take a trap). */
10735f4eaf39Schristos #define INSN_NO_DELAY_SLOT 0x00400000
10742a6b7db3Sskrll /* Instruction stores value into memory. */
10755f4eaf39Schristos #define INSN_STORE_MEMORY 0x00800000
10762a6b7db3Sskrll /* Instruction uses single precision floating point. */
10775f4eaf39Schristos #define FP_S 0x01000000
10782a6b7db3Sskrll /* Instruction uses double precision floating point. */
10795f4eaf39Schristos #define FP_D 0x02000000
10802a6b7db3Sskrll /* Instruction is part of the tx39's integer multiply family. */
10815f4eaf39Schristos #define INSN_MULT 0x04000000
10825f4eaf39Schristos /* Reads general purpose register 24. */
10835f4eaf39Schristos #define INSN_READ_GPR_24 0x08000000
10845f4eaf39Schristos /* Writes to general purpose register 24. */
10855f4eaf39Schristos #define INSN_WRITE_GPR_24 0x10000000
10865f4eaf39Schristos /* A user-defined instruction. */
10875f4eaf39Schristos #define INSN_UDI 0x20000000
10882a6b7db3Sskrll /* Instruction is actually a macro. It should be ignored by the
10892a6b7db3Sskrll disassembler, and requires special treatment by the assembler. */
10902a6b7db3Sskrll #define INSN_MACRO 0xffffffff
10912a6b7db3Sskrll
10922a6b7db3Sskrll /* These are the bits which may be set in the pinfo2 field of an
10932a6b7db3Sskrll instruction. */
10942a6b7db3Sskrll
10952a6b7db3Sskrll /* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */
10962a6b7db3Sskrll #define INSN2_ALIAS 0x00000001
10972a6b7db3Sskrll /* Instruction reads MDMX accumulator. */
10982a6b7db3Sskrll #define INSN2_READ_MDMX_ACC 0x00000002
10992a6b7db3Sskrll /* Instruction writes MDMX accumulator. */
11002a6b7db3Sskrll #define INSN2_WRITE_MDMX_ACC 0x00000004
11012a6b7db3Sskrll /* Macro uses single-precision floating-point instructions. This should
11022a6b7db3Sskrll only be set for macros. For instructions, FP_S in pinfo carries the
11032a6b7db3Sskrll same information. */
11042a6b7db3Sskrll #define INSN2_M_FP_S 0x00000008
11052a6b7db3Sskrll /* Macro uses double-precision floating-point instructions. This should
11062a6b7db3Sskrll only be set for macros. For instructions, FP_D in pinfo carries the
11072a6b7db3Sskrll same information. */
11082a6b7db3Sskrll #define INSN2_M_FP_D 0x00000010
1109b410d692Schristos /* Instruction has a branch delay slot that requires a 16-bit instruction. */
11105f4eaf39Schristos #define INSN2_BRANCH_DELAY_16BIT 0x00000020
1111b410d692Schristos /* Instruction has a branch delay slot that requires a 32-bit instruction. */
11125f4eaf39Schristos #define INSN2_BRANCH_DELAY_32BIT 0x00000040
11135f4eaf39Schristos /* Writes to the stack pointer ($29). */
11145f4eaf39Schristos #define INSN2_WRITE_SP 0x00000080
11155f4eaf39Schristos /* Reads from the stack pointer ($29). */
11165f4eaf39Schristos #define INSN2_READ_SP 0x00000100
1117b410d692Schristos /* Reads the RA ($31) register. */
11185f4eaf39Schristos #define INSN2_READ_GPR_31 0x00000200
1119b410d692Schristos /* Reads the program counter ($pc). */
11205f4eaf39Schristos #define INSN2_READ_PC 0x00000400
1121b410d692Schristos /* Is an unconditional branch insn. */
11225f4eaf39Schristos #define INSN2_UNCOND_BRANCH 0x00000800
1123b410d692Schristos /* Is a conditional branch insn. */
11245f4eaf39Schristos #define INSN2_COND_BRANCH 0x00001000
11255f4eaf39Schristos /* Reads from $16. This is true of the MIPS16 0x6500 nop. */
11265f4eaf39Schristos #define INSN2_READ_GPR_16 0x00002000
11275f4eaf39Schristos /* Has an "\.x?y?z?w?" suffix based on mips_vu0_channel_mask. */
11285f4eaf39Schristos #define INSN2_VU0_CHANNEL_SUFFIX 0x00004000
11295f4eaf39Schristos /* Instruction has a forbidden slot. */
11305f4eaf39Schristos #define INSN2_FORBIDDEN_SLOT 0x00008000
11316f226886Schristos /* Opcode table entry is for a short MIPS16 form only. An extended
11326f226886Schristos encoding may still exist, but with a separate opcode table entry
11336f226886Schristos required. In disassembly the presence of this flag in an otherwise
11346f226886Schristos successful match against an extended instruction encoding inhibits
11356f226886Schristos matching against any subsequent short table entry even if it does
11366f226886Schristos not have this flag set. A table entry matching the full extended
11376f226886Schristos encoding is needed or otherwise the final EXTEND entry will apply,
11386f226886Schristos for the disassembly of the prefix only. */
11396f226886Schristos #define INSN2_SHORT_ONLY 0x00010000
11402a6b7db3Sskrll
11412a6b7db3Sskrll /* Masks used to mark instructions to indicate which MIPS ISA level
11422a6b7db3Sskrll they were introduced in. INSN_ISA_MASK masks an enumeration that
11432a6b7db3Sskrll specifies the base ISA level(s). The remainder of a 32-bit
11442a6b7db3Sskrll word constructed using these macros is a bitmask of the remaining
11452a6b7db3Sskrll INSN_* values below. */
11462a6b7db3Sskrll
11475f4eaf39Schristos #define INSN_ISA_MASK 0x0000001ful
11482a6b7db3Sskrll
11492a6b7db3Sskrll /* We cannot start at zero due to ISA_UNKNOWN below. */
11502a6b7db3Sskrll #define INSN_ISA1 1
11512a6b7db3Sskrll #define INSN_ISA2 2
11522a6b7db3Sskrll #define INSN_ISA3 3
11532a6b7db3Sskrll #define INSN_ISA4 4
11542a6b7db3Sskrll #define INSN_ISA5 5
11552a6b7db3Sskrll #define INSN_ISA32 6
11562a6b7db3Sskrll #define INSN_ISA32R2 7
11575f4eaf39Schristos #define INSN_ISA32R3 8
11585f4eaf39Schristos #define INSN_ISA32R5 9
11595f4eaf39Schristos #define INSN_ISA32R6 10
11605f4eaf39Schristos #define INSN_ISA64 11
11615f4eaf39Schristos #define INSN_ISA64R2 12
11625f4eaf39Schristos #define INSN_ISA64R3 13
11635f4eaf39Schristos #define INSN_ISA64R5 14
11645f4eaf39Schristos #define INSN_ISA64R6 15
11652a6b7db3Sskrll /* Below this point the INSN_* values correspond to combinations of ISAs.
11662a6b7db3Sskrll They are only for use in the opcodes table to indicate membership of
11672a6b7db3Sskrll a combination of ISAs that cannot be expressed using the usual inclusion
11682a6b7db3Sskrll ordering on the above INSN_* values. */
11695f4eaf39Schristos #define INSN_ISA3_32 16
11705f4eaf39Schristos #define INSN_ISA3_32R2 17
11715f4eaf39Schristos #define INSN_ISA4_32 18
11725f4eaf39Schristos #define INSN_ISA4_32R2 19
11735f4eaf39Schristos #define INSN_ISA5_32R2 20
11742a6b7db3Sskrll
11755f4eaf39Schristos /* The R6 definitions shown below state that they support all previous ISAs.
11765f4eaf39Schristos This is not actually true as some instructions are removed in R6.
11775f4eaf39Schristos The problem is that the removed instructions in R6 come from different
11785f4eaf39Schristos ISAs. One approach to solve this would be to describe in the membership
11795f4eaf39Schristos field of the opcode table the different ISAs an instruction belongs to.
11805f4eaf39Schristos This would require us to create a large amount of different ISA
11815f4eaf39Schristos combinations which is hard to manage. A cleaner approach (which is
11825f4eaf39Schristos implemented here) is to say that R6 is an extension of R5 and then to
11835f4eaf39Schristos deal with the removed instructions by adding instruction exclusions
11845f4eaf39Schristos for R6 in the opcode table. */
11855f4eaf39Schristos
11865f4eaf39Schristos /* Bit INSN_ISA<X> - 1 of INSN_UPTO<Y> is set if ISA Y includes ISA X. */
11875f4eaf39Schristos
11885f4eaf39Schristos #define ISAF(X) (1 << (INSN_ISA##X - 1))
11895f4eaf39Schristos #define INSN_UPTO1 ISAF(1)
11905f4eaf39Schristos #define INSN_UPTO2 INSN_UPTO1 | ISAF(2)
11915f4eaf39Schristos #define INSN_UPTO3 INSN_UPTO2 | ISAF(3) | ISAF(3_32) | ISAF(3_32R2)
11925f4eaf39Schristos #define INSN_UPTO4 INSN_UPTO3 | ISAF(4) | ISAF(4_32) | ISAF(4_32R2)
11935f4eaf39Schristos #define INSN_UPTO5 INSN_UPTO4 | ISAF(5) | ISAF(5_32R2)
11945f4eaf39Schristos #define INSN_UPTO32 INSN_UPTO2 | ISAF(32) | ISAF(3_32) | ISAF(4_32)
11955f4eaf39Schristos #define INSN_UPTO32R2 INSN_UPTO32 | ISAF(32R2) \
11965f4eaf39Schristos | ISAF(3_32R2) | ISAF(4_32R2) | ISAF(5_32R2)
11975f4eaf39Schristos #define INSN_UPTO32R3 INSN_UPTO32R2 | ISAF(32R3)
11985f4eaf39Schristos #define INSN_UPTO32R5 INSN_UPTO32R3 | ISAF(32R5)
11995f4eaf39Schristos #define INSN_UPTO32R6 INSN_UPTO32R5 | ISAF(32R6)
12005f4eaf39Schristos #define INSN_UPTO64 INSN_UPTO5 | ISAF(64) | ISAF(32)
12015f4eaf39Schristos #define INSN_UPTO64R2 INSN_UPTO64 | ISAF(64R2) | ISAF(32R2)
12025f4eaf39Schristos #define INSN_UPTO64R3 INSN_UPTO64R2 | ISAF(64R3) | ISAF(32R3)
12035f4eaf39Schristos #define INSN_UPTO64R5 INSN_UPTO64R3 | ISAF(64R5) | ISAF(32R5)
12045f4eaf39Schristos #define INSN_UPTO64R6 INSN_UPTO64R5 | ISAF(64R6) | ISAF(32R6)
12055f4eaf39Schristos
12065f4eaf39Schristos /* The same information in table form: bit INSN_ISA<X> - 1 of index
12075f4eaf39Schristos INSN_UPTO<Y> - 1 is set if ISA Y includes ISA X. */
12085f4eaf39Schristos static const unsigned int mips_isa_table[] = {
12095f4eaf39Schristos INSN_UPTO1,
12105f4eaf39Schristos INSN_UPTO2,
12115f4eaf39Schristos INSN_UPTO3,
12125f4eaf39Schristos INSN_UPTO4,
12135f4eaf39Schristos INSN_UPTO5,
12145f4eaf39Schristos INSN_UPTO32,
12155f4eaf39Schristos INSN_UPTO32R2,
12165f4eaf39Schristos INSN_UPTO32R3,
12175f4eaf39Schristos INSN_UPTO32R5,
12185f4eaf39Schristos INSN_UPTO32R6,
12195f4eaf39Schristos INSN_UPTO64,
12205f4eaf39Schristos INSN_UPTO64R2,
12215f4eaf39Schristos INSN_UPTO64R3,
12225f4eaf39Schristos INSN_UPTO64R5,
12235f4eaf39Schristos INSN_UPTO64R6
12245f4eaf39Schristos };
12255f4eaf39Schristos #undef ISAF
12262a6b7db3Sskrll
12272a6b7db3Sskrll /* Masks used for Chip specific instructions. */
12286f226886Schristos #define INSN_CHIP_MASK 0xc7ff4f60
12292a6b7db3Sskrll
12302a6b7db3Sskrll /* Cavium Networks Octeon instructions. */
12312a6b7db3Sskrll #define INSN_OCTEON 0x00000800
1232b410d692Schristos #define INSN_OCTEONP 0x00000200
1233b410d692Schristos #define INSN_OCTEON2 0x00000100
12345f4eaf39Schristos #define INSN_OCTEON3 0x00000040
12352a6b7db3Sskrll
12365f4eaf39Schristos /* MIPS R5900 instruction */
12375f4eaf39Schristos #define INSN_5900 0x00004000
12382a6b7db3Sskrll
12392a6b7db3Sskrll /* MIPS R4650 instruction. */
12402a6b7db3Sskrll #define INSN_4650 0x00010000
12412a6b7db3Sskrll /* LSI R4010 instruction. */
12422a6b7db3Sskrll #define INSN_4010 0x00020000
12432a6b7db3Sskrll /* NEC VR4100 instruction. */
12442a6b7db3Sskrll #define INSN_4100 0x00040000
12452a6b7db3Sskrll /* Toshiba R3900 instruction. */
12462a6b7db3Sskrll #define INSN_3900 0x00080000
12472a6b7db3Sskrll /* MIPS R10000 instruction. */
12482a6b7db3Sskrll #define INSN_10000 0x00100000
12492a6b7db3Sskrll /* Broadcom SB-1 instruction. */
12502a6b7db3Sskrll #define INSN_SB1 0x00200000
12512a6b7db3Sskrll /* NEC VR4111/VR4181 instruction. */
12522a6b7db3Sskrll #define INSN_4111 0x00400000
12532a6b7db3Sskrll /* NEC VR4120 instruction. */
12542a6b7db3Sskrll #define INSN_4120 0x00800000
12552a6b7db3Sskrll /* NEC VR5400 instruction. */
12562a6b7db3Sskrll #define INSN_5400 0x01000000
12572a6b7db3Sskrll /* NEC VR5500 instruction. */
12582a6b7db3Sskrll #define INSN_5500 0x02000000
12592a6b7db3Sskrll
12602a6b7db3Sskrll /* ST Microelectronics Loongson 2E. */
12612a6b7db3Sskrll #define INSN_LOONGSON_2E 0x40000000
12622a6b7db3Sskrll /* ST Microelectronics Loongson 2F. */
12632a6b7db3Sskrll #define INSN_LOONGSON_2F 0x80000000
126491f4e65aSmatt /* RMI Xlr instruction */
126591f4e65aSmatt #define INSN_XLR 0x00000020
12666f226886Schristos /* Imagination interAptiv MR2. */
12676f226886Schristos #define INSN_INTERAPTIV_MR2 0x04000000
1268*dd7241dfSchristos /* Sony PSP Allegrex instruction. */
1269*dd7241dfSchristos #define INSN_ALLEGREX 0x08000000
12702a6b7db3Sskrll
12715f4eaf39Schristos /* DSP ASE */
12725f4eaf39Schristos #define ASE_DSP 0x00000001
12735f4eaf39Schristos #define ASE_DSP64 0x00000002
12745f4eaf39Schristos /* DSP R2 ASE */
12755f4eaf39Schristos #define ASE_DSPR2 0x00000004
12765f4eaf39Schristos /* Enhanced VA Scheme */
12775f4eaf39Schristos #define ASE_EVA 0x00000008
1278b410d692Schristos /* MCU (MicroController) ASE */
12795f4eaf39Schristos #define ASE_MCU 0x00000010
12805f4eaf39Schristos /* MDMX ASE */
12815f4eaf39Schristos #define ASE_MDMX 0x00000020
12825f4eaf39Schristos /* MIPS-3D ASE */
12835f4eaf39Schristos #define ASE_MIPS3D 0x00000040
12845f4eaf39Schristos /* MT ASE */
12855f4eaf39Schristos #define ASE_MT 0x00000080
12865f4eaf39Schristos /* SmartMIPS ASE */
12875f4eaf39Schristos #define ASE_SMARTMIPS 0x00000100
12885f4eaf39Schristos /* Virtualization ASE */
12895f4eaf39Schristos #define ASE_VIRT 0x00000200
12905f4eaf39Schristos #define ASE_VIRT64 0x00000400
12915f4eaf39Schristos /* MSA Extension */
12925f4eaf39Schristos #define ASE_MSA 0x00000800
12935f4eaf39Schristos #define ASE_MSA64 0x00001000
12945f4eaf39Schristos /* eXtended Physical Address (XPA) Extension. */
12955f4eaf39Schristos #define ASE_XPA 0x00002000
12966f226886Schristos /* DSP R3 Module. */
12972f15a542Schristos #define ASE_DSPR3 0x00004000
12986f226886Schristos /* MIPS16e2 ASE. */
12996f226886Schristos #define ASE_MIPS16E2 0x00008000
13006f226886Schristos /* MIPS16e2 MT ASE instructions. */
13016f226886Schristos #define ASE_MIPS16E2_MT 0x00010000
13026f226886Schristos /* The Virtualization ASE has eXtended Physical Addressing (XPA)
13036f226886Schristos instructions which are only valid when both ASEs are enabled. */
13046f226886Schristos #define ASE_XPA_VIRT 0x00020000
13057c6f6726Schristos /* Cyclic redundancy check (CRC) ASE. */
13067c6f6726Schristos #define ASE_CRC 0x00040000
13077c6f6726Schristos #define ASE_CRC64 0x00080000
13087c6f6726Schristos /* Global INValidate Extension. */
13097c6f6726Schristos #define ASE_GINV 0x00100000
1310106c59e5Schristos /* Loongson MultiMedia extensions Instructions (MMI). */
1311106c59e5Schristos #define ASE_LOONGSON_MMI 0x00200000
1312106c59e5Schristos /* Loongson Content Address Memory (CAM). */
1313106c59e5Schristos #define ASE_LOONGSON_CAM 0x00400000
1314106c59e5Schristos /* Loongson EXTensions (EXT) instructions. */
1315106c59e5Schristos #define ASE_LOONGSON_EXT 0x00800000
1316106c59e5Schristos /* Loongson EXTensions R2 (EXT2) instructions. */
1317106c59e5Schristos #define ASE_LOONGSON_EXT2 0x01000000
1318106c59e5Schristos /* The Enhanced VA Scheme (EVA) extension has instructions which are
1319106c59e5Schristos only valid for the R6 ISA. */
1320106c59e5Schristos #define ASE_EVA_R6 0x02000000
1321b410d692Schristos
13222a6b7db3Sskrll /* MIPS ISA defines, use instead of hardcoding ISA level. */
13232a6b7db3Sskrll
13242a6b7db3Sskrll #define ISA_UNKNOWN 0 /* Gas internal use. */
13252a6b7db3Sskrll #define ISA_MIPS1 INSN_ISA1
13262a6b7db3Sskrll #define ISA_MIPS2 INSN_ISA2
13272a6b7db3Sskrll #define ISA_MIPS3 INSN_ISA3
13282a6b7db3Sskrll #define ISA_MIPS4 INSN_ISA4
13292a6b7db3Sskrll #define ISA_MIPS5 INSN_ISA5
13302a6b7db3Sskrll
13312a6b7db3Sskrll #define ISA_MIPS32 INSN_ISA32
13322a6b7db3Sskrll #define ISA_MIPS64 INSN_ISA64
13332a6b7db3Sskrll
13342a6b7db3Sskrll #define ISA_MIPS32R2 INSN_ISA32R2
13355f4eaf39Schristos #define ISA_MIPS32R3 INSN_ISA32R3
13365f4eaf39Schristos #define ISA_MIPS32R5 INSN_ISA32R5
13372a6b7db3Sskrll #define ISA_MIPS64R2 INSN_ISA64R2
13385f4eaf39Schristos #define ISA_MIPS64R3 INSN_ISA64R3
13395f4eaf39Schristos #define ISA_MIPS64R5 INSN_ISA64R5
13402a6b7db3Sskrll
13415f4eaf39Schristos #define ISA_MIPS32R6 INSN_ISA32R6
13425f4eaf39Schristos #define ISA_MIPS64R6 INSN_ISA64R6
13432a6b7db3Sskrll
13442a6b7db3Sskrll /* CPU defines, use instead of hardcoding processor number. Keep this
13452a6b7db3Sskrll in sync with bfd/archures.c in order for machine selection to work. */
13462a6b7db3Sskrll #define CPU_UNKNOWN 0 /* Gas internal use. */
13472a6b7db3Sskrll #define CPU_R3000 3000
13482a6b7db3Sskrll #define CPU_R3900 3900
13492a6b7db3Sskrll #define CPU_R4000 4000
13502a6b7db3Sskrll #define CPU_R4010 4010
13512a6b7db3Sskrll #define CPU_VR4100 4100
13522a6b7db3Sskrll #define CPU_R4111 4111
13532a6b7db3Sskrll #define CPU_VR4120 4120
13542a6b7db3Sskrll #define CPU_R4300 4300
13552a6b7db3Sskrll #define CPU_R4400 4400
13562a6b7db3Sskrll #define CPU_R4600 4600
13572a6b7db3Sskrll #define CPU_R4650 4650
13582a6b7db3Sskrll #define CPU_R5000 5000
13592a6b7db3Sskrll #define CPU_VR5400 5400
13602a6b7db3Sskrll #define CPU_VR5500 5500
13615f4eaf39Schristos #define CPU_R5900 5900
13622a6b7db3Sskrll #define CPU_R6000 6000
13632a6b7db3Sskrll #define CPU_RM7000 7000
13642a6b7db3Sskrll #define CPU_R8000 8000
13652a6b7db3Sskrll #define CPU_RM9000 9000
13662a6b7db3Sskrll #define CPU_R10000 10000
13672a6b7db3Sskrll #define CPU_R12000 12000
136832998b1cSchristos #define CPU_R14000 14000
136932998b1cSchristos #define CPU_R16000 16000
13702a6b7db3Sskrll #define CPU_MIPS16 16
13712a6b7db3Sskrll #define CPU_MIPS32 32
13722a6b7db3Sskrll #define CPU_MIPS32R2 33
13735f4eaf39Schristos #define CPU_MIPS32R3 34
13745f4eaf39Schristos #define CPU_MIPS32R5 36
13755f4eaf39Schristos #define CPU_MIPS32R6 37
13762a6b7db3Sskrll #define CPU_MIPS5 5
13772a6b7db3Sskrll #define CPU_MIPS64 64
13782a6b7db3Sskrll #define CPU_MIPS64R2 65
13795f4eaf39Schristos #define CPU_MIPS64R3 66
13805f4eaf39Schristos #define CPU_MIPS64R5 68
13815f4eaf39Schristos #define CPU_MIPS64R6 69
1382*dd7241dfSchristos #define CPU_ALLEGREX 10111431 /* octal 'AL', 31. */
13832a6b7db3Sskrll #define CPU_SB1 12310201 /* octal 'SB', 01. */
13842a6b7db3Sskrll #define CPU_LOONGSON_2E 3001
13852a6b7db3Sskrll #define CPU_LOONGSON_2F 3002
1386106c59e5Schristos #define CPU_GS464 3003
1387106c59e5Schristos #define CPU_GS464E 3004
1388106c59e5Schristos #define CPU_GS264E 3005
13892a6b7db3Sskrll #define CPU_OCTEON 6501
1390b410d692Schristos #define CPU_OCTEONP 6601
1391b410d692Schristos #define CPU_OCTEON2 6502
13925f4eaf39Schristos #define CPU_OCTEON3 6503
139391f4e65aSmatt #define CPU_XLR 887682 /* decimal 'XLR' */
13946f226886Schristos #define CPU_INTERAPTIV_MR2 736550 /* decimal 'IA2' */
13952a6b7db3Sskrll
1396b410d692Schristos /* Return true if the given CPU is included in INSN_* mask MASK. */
1397b410d692Schristos
139803f5171aSchristos static inline bool
cpu_is_member(int cpu,unsigned int mask)1399b410d692Schristos cpu_is_member (int cpu, unsigned int mask)
1400b410d692Schristos {
1401b410d692Schristos switch (cpu)
1402b410d692Schristos {
1403b410d692Schristos case CPU_R4650:
1404b410d692Schristos case CPU_RM7000:
1405b410d692Schristos case CPU_RM9000:
1406b410d692Schristos return (mask & INSN_4650) != 0;
1407b410d692Schristos
1408b410d692Schristos case CPU_R4010:
1409b410d692Schristos return (mask & INSN_4010) != 0;
1410b410d692Schristos
1411b410d692Schristos case CPU_VR4100:
1412b410d692Schristos return (mask & INSN_4100) != 0;
1413b410d692Schristos
1414b410d692Schristos case CPU_R3900:
1415b410d692Schristos return (mask & INSN_3900) != 0;
1416b410d692Schristos
1417b410d692Schristos case CPU_R10000:
1418b410d692Schristos case CPU_R12000:
1419b410d692Schristos case CPU_R14000:
1420b410d692Schristos case CPU_R16000:
1421b410d692Schristos return (mask & INSN_10000) != 0;
1422b410d692Schristos
1423b410d692Schristos case CPU_SB1:
1424b410d692Schristos return (mask & INSN_SB1) != 0;
1425b410d692Schristos
1426b410d692Schristos case CPU_R4111:
1427b410d692Schristos return (mask & INSN_4111) != 0;
1428b410d692Schristos
1429b410d692Schristos case CPU_VR4120:
1430b410d692Schristos return (mask & INSN_4120) != 0;
1431b410d692Schristos
1432b410d692Schristos case CPU_VR5400:
1433b410d692Schristos return (mask & INSN_5400) != 0;
1434b410d692Schristos
1435b410d692Schristos case CPU_VR5500:
1436b410d692Schristos return (mask & INSN_5500) != 0;
1437b410d692Schristos
14385f4eaf39Schristos case CPU_R5900:
14395f4eaf39Schristos return (mask & INSN_5900) != 0;
14405f4eaf39Schristos
1441b410d692Schristos case CPU_LOONGSON_2E:
1442b410d692Schristos return (mask & INSN_LOONGSON_2E) != 0;
1443b410d692Schristos
1444b410d692Schristos case CPU_LOONGSON_2F:
1445b410d692Schristos return (mask & INSN_LOONGSON_2F) != 0;
1446b410d692Schristos
1447b410d692Schristos case CPU_OCTEON:
1448b410d692Schristos return (mask & INSN_OCTEON) != 0;
1449b410d692Schristos
1450b410d692Schristos case CPU_OCTEONP:
1451b410d692Schristos return (mask & INSN_OCTEONP) != 0;
1452b410d692Schristos
1453b410d692Schristos case CPU_OCTEON2:
1454b410d692Schristos return (mask & INSN_OCTEON2) != 0;
1455b410d692Schristos
14565f4eaf39Schristos case CPU_OCTEON3:
14575f4eaf39Schristos return (mask & INSN_OCTEON3) != 0;
14585f4eaf39Schristos
1459b410d692Schristos case CPU_XLR:
1460b410d692Schristos return (mask & INSN_XLR) != 0;
1461b410d692Schristos
14626f226886Schristos case CPU_INTERAPTIV_MR2:
14636f226886Schristos return (mask & INSN_INTERAPTIV_MR2) != 0;
14646f226886Schristos
1465*dd7241dfSchristos case CPU_ALLEGREX:
1466*dd7241dfSchristos return (mask & INSN_ALLEGREX) != 0;
1467*dd7241dfSchristos
1468b410d692Schristos default:
146903f5171aSchristos return false;
1470b410d692Schristos }
1471b410d692Schristos }
1472b410d692Schristos
147303f5171aSchristos /* Return true if the given ISA is included in INSN_* mask MASK. */
147403f5171aSchristos
147503f5171aSchristos static inline bool
isa_is_member(int isa,unsigned int mask)147603f5171aSchristos isa_is_member (int isa, unsigned int mask)
147703f5171aSchristos {
147803f5171aSchristos isa &= INSN_ISA_MASK;
147903f5171aSchristos mask &= INSN_ISA_MASK;
148003f5171aSchristos
148103f5171aSchristos if (isa == 0)
148203f5171aSchristos return false;
148303f5171aSchristos
148403f5171aSchristos if (mask == 0)
148503f5171aSchristos return false;
148603f5171aSchristos
148703f5171aSchristos if (((mips_isa_table[isa - 1] >> (mask - 1)) & 1) == 0)
148803f5171aSchristos return false;
148903f5171aSchristos
149003f5171aSchristos return true;
149103f5171aSchristos }
149203f5171aSchristos
14932a6b7db3Sskrll /* Test for membership in an ISA including chip specific ISAs. INSN
14942a6b7db3Sskrll is pointer to an element of the opcode table; ISA is the specified
14952a6b7db3Sskrll ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
1496b410d692Schristos test, or zero if no CPU specific ISA test is desired. Return true
1497b410d692Schristos if instruction INSN is available to the given ISA and CPU. */
14982a6b7db3Sskrll
149903f5171aSchristos static inline bool
opcode_is_member(const struct mips_opcode * insn,int isa,int ase,int cpu)15005f4eaf39Schristos opcode_is_member (const struct mips_opcode *insn, int isa, int ase, int cpu)
1501b410d692Schristos {
150203f5171aSchristos /* Test for ISA level exclusion. */
150303f5171aSchristos if (isa_is_member (isa, insn->exclusions))
150403f5171aSchristos return false;
150503f5171aSchristos
150603f5171aSchristos /* Test for processor-specific exclusion. */
150703f5171aSchristos if (cpu_is_member (cpu, insn->exclusions))
150803f5171aSchristos return false;
150903f5171aSchristos
1510b410d692Schristos /* Test for ISA level compatibility. */
151103f5171aSchristos if (isa_is_member (isa, insn->membership))
151203f5171aSchristos return true;
1513b410d692Schristos
1514b410d692Schristos /* Test for ASE compatibility. */
15155f4eaf39Schristos if ((ase & insn->ase) != 0)
151603f5171aSchristos return true;
1517b410d692Schristos
1518b410d692Schristos /* Test for processor-specific extensions. */
1519b410d692Schristos if (cpu_is_member (cpu, insn->membership))
152003f5171aSchristos return true;
152103f5171aSchristos
152203f5171aSchristos return false;
1523b410d692Schristos }
15242a6b7db3Sskrll
15252a6b7db3Sskrll /* This is a list of macro expanded instructions.
15262a6b7db3Sskrll
15272a6b7db3Sskrll _I appended means immediate
15285f4eaf39Schristos _A appended means target address of a jump
15295f4eaf39Schristos _AB appended means address with (possibly zero) base register
15302a6b7db3Sskrll _D appended means 64 bit floating point constant
15312a6b7db3Sskrll _S appended means 32 bit floating point constant. */
15322a6b7db3Sskrll
15332a6b7db3Sskrll enum
15342a6b7db3Sskrll {
15352a6b7db3Sskrll M_ABS,
1536b410d692Schristos M_ACLR_AB,
15372a6b7db3Sskrll M_ADD_I,
15382a6b7db3Sskrll M_ADDU_I,
15392a6b7db3Sskrll M_AND_I,
1540b410d692Schristos M_ASET_AB,
15412a6b7db3Sskrll M_BALIGN,
1542b410d692Schristos M_BC1FL,
1543b410d692Schristos M_BC1TL,
1544b410d692Schristos M_BC2FL,
1545b410d692Schristos M_BC2TL,
15462a6b7db3Sskrll M_BEQ,
15472a6b7db3Sskrll M_BEQ_I,
1548b410d692Schristos M_BEQL,
15492a6b7db3Sskrll M_BEQL_I,
15502a6b7db3Sskrll M_BGE,
15512a6b7db3Sskrll M_BGEL,
15522a6b7db3Sskrll M_BGE_I,
15532a6b7db3Sskrll M_BGEL_I,
15542a6b7db3Sskrll M_BGEU,
15552a6b7db3Sskrll M_BGEUL,
15562a6b7db3Sskrll M_BGEU_I,
15572a6b7db3Sskrll M_BGEUL_I,
1558b410d692Schristos M_BGEZ,
1559b410d692Schristos M_BGEZL,
1560b410d692Schristos M_BGEZALL,
15612a6b7db3Sskrll M_BGT,
15622a6b7db3Sskrll M_BGTL,
15632a6b7db3Sskrll M_BGT_I,
15642a6b7db3Sskrll M_BGTL_I,
15652a6b7db3Sskrll M_BGTU,
15662a6b7db3Sskrll M_BGTUL,
15672a6b7db3Sskrll M_BGTU_I,
15682a6b7db3Sskrll M_BGTUL_I,
1569b410d692Schristos M_BGTZ,
1570b410d692Schristos M_BGTZL,
15712a6b7db3Sskrll M_BLE,
15722a6b7db3Sskrll M_BLEL,
15732a6b7db3Sskrll M_BLE_I,
15742a6b7db3Sskrll M_BLEL_I,
15752a6b7db3Sskrll M_BLEU,
15762a6b7db3Sskrll M_BLEUL,
15772a6b7db3Sskrll M_BLEU_I,
15782a6b7db3Sskrll M_BLEUL_I,
1579b410d692Schristos M_BLEZ,
1580b410d692Schristos M_BLEZL,
15812a6b7db3Sskrll M_BLT,
15822a6b7db3Sskrll M_BLTL,
15832a6b7db3Sskrll M_BLT_I,
15842a6b7db3Sskrll M_BLTL_I,
15852a6b7db3Sskrll M_BLTU,
15862a6b7db3Sskrll M_BLTUL,
15872a6b7db3Sskrll M_BLTU_I,
15882a6b7db3Sskrll M_BLTUL_I,
1589b410d692Schristos M_BLTZ,
1590b410d692Schristos M_BLTZL,
1591b410d692Schristos M_BLTZALL,
15922a6b7db3Sskrll M_BNE,
1593b410d692Schristos M_BNEL,
15942a6b7db3Sskrll M_BNE_I,
15952a6b7db3Sskrll M_BNEL_I,
15962a6b7db3Sskrll M_CACHE_AB,
15975f4eaf39Schristos M_CACHEE_AB,
15982a6b7db3Sskrll M_DABS,
15992a6b7db3Sskrll M_DADD_I,
16002a6b7db3Sskrll M_DADDU_I,
16012a6b7db3Sskrll M_DDIV_3,
16022a6b7db3Sskrll M_DDIV_3I,
16032a6b7db3Sskrll M_DDIVU_3,
16042a6b7db3Sskrll M_DDIVU_3I,
16052a6b7db3Sskrll M_DIV_3,
16062a6b7db3Sskrll M_DIV_3I,
16072a6b7db3Sskrll M_DIVU_3,
16082a6b7db3Sskrll M_DIVU_3I,
16092a6b7db3Sskrll M_DLA_AB,
16102a6b7db3Sskrll M_DLCA_AB,
16112a6b7db3Sskrll M_DLI,
16122a6b7db3Sskrll M_DMUL,
16132a6b7db3Sskrll M_DMUL_I,
16142a6b7db3Sskrll M_DMULO,
16152a6b7db3Sskrll M_DMULO_I,
16162a6b7db3Sskrll M_DMULOU,
16172a6b7db3Sskrll M_DMULOU_I,
16182a6b7db3Sskrll M_DREM_3,
16192a6b7db3Sskrll M_DREM_3I,
16202a6b7db3Sskrll M_DREMU_3,
16212a6b7db3Sskrll M_DREMU_3I,
16222a6b7db3Sskrll M_DSUB_I,
16232a6b7db3Sskrll M_DSUBU_I,
16242a6b7db3Sskrll M_DSUBU_I_2,
16250c15c4beSbouyer M_JR_S,
16260c15c4beSbouyer M_J_S,
16272a6b7db3Sskrll M_J_A,
16280c15c4beSbouyer M_JALR_S,
16290c15c4beSbouyer M_JALR_DS,
16302a6b7db3Sskrll M_JAL_1,
16312a6b7db3Sskrll M_JAL_2,
16322a6b7db3Sskrll M_JAL_A,
1633b410d692Schristos M_JALS_1,
1634b410d692Schristos M_JALS_2,
1635b410d692Schristos M_JALS_A,
16365f4eaf39Schristos M_JRADDIUSP,
16375f4eaf39Schristos M_JRC,
16382a6b7db3Sskrll M_L_DAB,
16392a6b7db3Sskrll M_LA_AB,
16402a6b7db3Sskrll M_LB_AB,
16415f4eaf39Schristos M_LBE_AB,
16422a6b7db3Sskrll M_LBU_AB,
16435f4eaf39Schristos M_LBUE_AB,
16442a6b7db3Sskrll M_LCA_AB,
16452a6b7db3Sskrll M_LD_AB,
16462a6b7db3Sskrll M_LDC1_AB,
16472a6b7db3Sskrll M_LDC2_AB,
16485f4eaf39Schristos M_LQC2_AB,
16492a6b7db3Sskrll M_LDC3_AB,
16502a6b7db3Sskrll M_LDL_AB,
1651b410d692Schristos M_LDM_AB,
1652b410d692Schristos M_LDP_AB,
16532a6b7db3Sskrll M_LDR_AB,
16542a6b7db3Sskrll M_LH_AB,
16555f4eaf39Schristos M_LHE_AB,
16562a6b7db3Sskrll M_LHU_AB,
16575f4eaf39Schristos M_LHUE_AB,
16582a6b7db3Sskrll M_LI,
16592a6b7db3Sskrll M_LI_D,
16602a6b7db3Sskrll M_LI_DD,
16612a6b7db3Sskrll M_LI_S,
16622a6b7db3Sskrll M_LI_SS,
16632a6b7db3Sskrll M_LL_AB,
16642a6b7db3Sskrll M_LLD_AB,
1665106c59e5Schristos M_LLDP_AB,
16665f4eaf39Schristos M_LLE_AB,
1667106c59e5Schristos M_LLWP_AB,
1668106c59e5Schristos M_LLWPE_AB,
16695f4eaf39Schristos M_LQ_AB,
16702a6b7db3Sskrll M_LW_AB,
16715f4eaf39Schristos M_LWE_AB,
16722a6b7db3Sskrll M_LWC0_AB,
16732a6b7db3Sskrll M_LWC1_AB,
16742a6b7db3Sskrll M_LWC2_AB,
16752a6b7db3Sskrll M_LWC3_AB,
16762a6b7db3Sskrll M_LWL_AB,
16775f4eaf39Schristos M_LWLE_AB,
1678b410d692Schristos M_LWM_AB,
1679b410d692Schristos M_LWP_AB,
16802a6b7db3Sskrll M_LWR_AB,
16815f4eaf39Schristos M_LWRE_AB,
16822a6b7db3Sskrll M_LWU_AB,
168391f4e65aSmatt M_MSGSND,
168491f4e65aSmatt M_MSGLD,
168591f4e65aSmatt M_MSGLD_T,
168691f4e65aSmatt M_MSGWAIT,
168791f4e65aSmatt M_MSGWAIT_T,
16882a6b7db3Sskrll M_MOVE,
16895f4eaf39Schristos M_MOVEP,
16902a6b7db3Sskrll M_MUL,
16912a6b7db3Sskrll M_MUL_I,
16922a6b7db3Sskrll M_MULO,
16932a6b7db3Sskrll M_MULO_I,
16942a6b7db3Sskrll M_MULOU,
16952a6b7db3Sskrll M_MULOU_I,
16962a6b7db3Sskrll M_NOR_I,
16972a6b7db3Sskrll M_OR_I,
1698b410d692Schristos M_PREF_AB,
16995f4eaf39Schristos M_PREFE_AB,
17002a6b7db3Sskrll M_REM_3,
17012a6b7db3Sskrll M_REM_3I,
17022a6b7db3Sskrll M_REMU_3,
17032a6b7db3Sskrll M_REMU_3I,
17042a6b7db3Sskrll M_DROL,
17052a6b7db3Sskrll M_ROL,
17062a6b7db3Sskrll M_DROL_I,
17072a6b7db3Sskrll M_ROL_I,
17082a6b7db3Sskrll M_DROR,
17092a6b7db3Sskrll M_ROR,
17102a6b7db3Sskrll M_DROR_I,
17112a6b7db3Sskrll M_ROR_I,
17122a6b7db3Sskrll M_S_DA,
17132a6b7db3Sskrll M_S_DAB,
17142a6b7db3Sskrll M_S_S,
1715b410d692Schristos M_SAA_AB,
1716b410d692Schristos M_SAAD_AB,
17172a6b7db3Sskrll M_SC_AB,
17182a6b7db3Sskrll M_SCD_AB,
1719106c59e5Schristos M_SCDP_AB,
17205f4eaf39Schristos M_SCE_AB,
1721106c59e5Schristos M_SCWP_AB,
1722106c59e5Schristos M_SCWPE_AB,
17232a6b7db3Sskrll M_SD_AB,
17242a6b7db3Sskrll M_SDC1_AB,
17252a6b7db3Sskrll M_SDC2_AB,
17265f4eaf39Schristos M_SQC2_AB,
17272a6b7db3Sskrll M_SDC3_AB,
17282a6b7db3Sskrll M_SDL_AB,
1729b410d692Schristos M_SDM_AB,
1730b410d692Schristos M_SDP_AB,
17312a6b7db3Sskrll M_SDR_AB,
17322a6b7db3Sskrll M_SEQ,
17332a6b7db3Sskrll M_SEQ_I,
17342a6b7db3Sskrll M_SGE,
17352a6b7db3Sskrll M_SGE_I,
17362a6b7db3Sskrll M_SGEU,
17372a6b7db3Sskrll M_SGEU_I,
17382a6b7db3Sskrll M_SGT,
17392a6b7db3Sskrll M_SGT_I,
17402a6b7db3Sskrll M_SGTU,
17412a6b7db3Sskrll M_SGTU_I,
17422a6b7db3Sskrll M_SLE,
17432a6b7db3Sskrll M_SLE_I,
17442a6b7db3Sskrll M_SLEU,
17452a6b7db3Sskrll M_SLEU_I,
17462a6b7db3Sskrll M_SLT_I,
17472a6b7db3Sskrll M_SLTU_I,
17482a6b7db3Sskrll M_SNE,
17492a6b7db3Sskrll M_SNE_I,
17502a6b7db3Sskrll M_SB_AB,
17515f4eaf39Schristos M_SBE_AB,
17522a6b7db3Sskrll M_SH_AB,
17535f4eaf39Schristos M_SHE_AB,
17545f4eaf39Schristos M_SQ_AB,
17552a6b7db3Sskrll M_SW_AB,
17565f4eaf39Schristos M_SWE_AB,
17572a6b7db3Sskrll M_SWC0_AB,
17582a6b7db3Sskrll M_SWC1_AB,
17592a6b7db3Sskrll M_SWC2_AB,
17602a6b7db3Sskrll M_SWC3_AB,
17612a6b7db3Sskrll M_SWL_AB,
17625f4eaf39Schristos M_SWLE_AB,
1763b410d692Schristos M_SWM_AB,
1764b410d692Schristos M_SWP_AB,
17652a6b7db3Sskrll M_SWR_AB,
17665f4eaf39Schristos M_SWRE_AB,
17672a6b7db3Sskrll M_SUB_I,
17682a6b7db3Sskrll M_SUBU_I,
17692a6b7db3Sskrll M_SUBU_I_2,
17702a6b7db3Sskrll M_TEQ_I,
17712a6b7db3Sskrll M_TGE_I,
17722a6b7db3Sskrll M_TGEU_I,
17732a6b7db3Sskrll M_TLT_I,
17742a6b7db3Sskrll M_TLTU_I,
17752a6b7db3Sskrll M_TNE_I,
17762a6b7db3Sskrll M_TRUNCWD,
17772a6b7db3Sskrll M_TRUNCWS,
17785f4eaf39Schristos M_ULD_AB,
17795f4eaf39Schristos M_ULH_AB,
17805f4eaf39Schristos M_ULHU_AB,
17815f4eaf39Schristos M_ULW_AB,
17825f4eaf39Schristos M_USH_AB,
17835f4eaf39Schristos M_USW_AB,
17845f4eaf39Schristos M_USD_AB,
17852a6b7db3Sskrll M_XOR_I,
17862a6b7db3Sskrll M_COP0,
17872a6b7db3Sskrll M_COP1,
17882a6b7db3Sskrll M_COP2,
17892a6b7db3Sskrll M_COP3,
17902a6b7db3Sskrll M_NUM_MACROS
17912a6b7db3Sskrll };
17922a6b7db3Sskrll
17932a6b7db3Sskrll
17942a6b7db3Sskrll /* The order of overloaded instructions matters. Label arguments and
17952a6b7db3Sskrll register arguments look the same. Instructions that can have either
17962a6b7db3Sskrll for arguments must apear in the correct order in this table for the
17972a6b7db3Sskrll assembler to pick the right one. In other words, entries with
17982a6b7db3Sskrll immediate operands must apear after the same instruction with
17992a6b7db3Sskrll registers.
18002a6b7db3Sskrll
18012a6b7db3Sskrll Many instructions are short hand for other instructions (i.e., The
18022a6b7db3Sskrll jal <register> instruction is short for jalr <register>). */
18032a6b7db3Sskrll
18045f4eaf39Schristos extern const struct mips_operand mips_vu0_channel_mask;
18055f4eaf39Schristos extern const struct mips_operand *decode_mips_operand (const char *);
18062a6b7db3Sskrll extern const struct mips_opcode mips_builtin_opcodes[];
18072a6b7db3Sskrll extern const int bfd_mips_num_builtin_opcodes;
18082a6b7db3Sskrll extern struct mips_opcode *mips_opcodes;
18092a6b7db3Sskrll extern int bfd_mips_num_opcodes;
18102a6b7db3Sskrll #define NUMOPCODES bfd_mips_num_opcodes
18112a6b7db3Sskrll
18122a6b7db3Sskrll
18132a6b7db3Sskrll /* The rest of this file adds definitions for the mips16 TinyRISC
18142a6b7db3Sskrll processor. */
18152a6b7db3Sskrll
18162a6b7db3Sskrll /* These are the bitmasks and shift counts used for the different
18172a6b7db3Sskrll fields in the instruction formats. Other than OP, no masks are
18182a6b7db3Sskrll provided for the fixed portions of an instruction, since they are
18192a6b7db3Sskrll not needed.
18202a6b7db3Sskrll
18212a6b7db3Sskrll The I format uses IMM11.
18222a6b7db3Sskrll
18232a6b7db3Sskrll The RI format uses RX and IMM8.
18242a6b7db3Sskrll
18252a6b7db3Sskrll The RR format uses RX, and RY.
18262a6b7db3Sskrll
18272a6b7db3Sskrll The RRI format uses RX, RY, and IMM5.
18282a6b7db3Sskrll
18292a6b7db3Sskrll The RRR format uses RX, RY, and RZ.
18302a6b7db3Sskrll
18312a6b7db3Sskrll The RRI_A format uses RX, RY, and IMM4.
18322a6b7db3Sskrll
18332a6b7db3Sskrll The SHIFT format uses RX, RY, and SHAMT.
18342a6b7db3Sskrll
18352a6b7db3Sskrll The I8 format uses IMM8.
18362a6b7db3Sskrll
18372a6b7db3Sskrll The I8_MOVR32 format uses RY and REGR32.
18382a6b7db3Sskrll
18392a6b7db3Sskrll The IR_MOV32R format uses REG32R and MOV32Z.
18402a6b7db3Sskrll
18412a6b7db3Sskrll The I64 format uses IMM8.
18422a6b7db3Sskrll
18432a6b7db3Sskrll The RI64 format uses RY and IMM5.
18442a6b7db3Sskrll */
18452a6b7db3Sskrll
18462a6b7db3Sskrll #define MIPS16OP_MASK_OP 0x1f
18472a6b7db3Sskrll #define MIPS16OP_SH_OP 11
18482a6b7db3Sskrll #define MIPS16OP_MASK_IMM11 0x7ff
18492a6b7db3Sskrll #define MIPS16OP_SH_IMM11 0
18502a6b7db3Sskrll #define MIPS16OP_MASK_RX 0x7
18512a6b7db3Sskrll #define MIPS16OP_SH_RX 8
18522a6b7db3Sskrll #define MIPS16OP_MASK_IMM8 0xff
18532a6b7db3Sskrll #define MIPS16OP_SH_IMM8 0
18542a6b7db3Sskrll #define MIPS16OP_MASK_RY 0x7
18552a6b7db3Sskrll #define MIPS16OP_SH_RY 5
18562a6b7db3Sskrll #define MIPS16OP_MASK_IMM5 0x1f
18572a6b7db3Sskrll #define MIPS16OP_SH_IMM5 0
18582a6b7db3Sskrll #define MIPS16OP_MASK_RZ 0x7
18592a6b7db3Sskrll #define MIPS16OP_SH_RZ 2
18602a6b7db3Sskrll #define MIPS16OP_MASK_IMM4 0xf
18612a6b7db3Sskrll #define MIPS16OP_SH_IMM4 0
18622a6b7db3Sskrll #define MIPS16OP_MASK_REGR32 0x1f
18632a6b7db3Sskrll #define MIPS16OP_SH_REGR32 0
18642a6b7db3Sskrll #define MIPS16OP_MASK_REG32R 0x1f
18652a6b7db3Sskrll #define MIPS16OP_SH_REG32R 3
18662a6b7db3Sskrll #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
18672a6b7db3Sskrll #define MIPS16OP_MASK_MOVE32Z 0x7
18682a6b7db3Sskrll #define MIPS16OP_SH_MOVE32Z 0
18692a6b7db3Sskrll #define MIPS16OP_MASK_IMM6 0x3f
18702a6b7db3Sskrll #define MIPS16OP_SH_IMM6 5
18712a6b7db3Sskrll
18722a6b7db3Sskrll /* These are the characters which may appears in the args field of a MIPS16
18732a6b7db3Sskrll instruction. They appear in the order in which the fields appear when the
18742a6b7db3Sskrll instruction is used. Commas and parentheses in the args string are ignored
18752a6b7db3Sskrll when assembling, and written into the output when disassembling.
18762a6b7db3Sskrll
18772a6b7db3Sskrll "y" 3 bit register (MIPS16OP_*_RY)
18782a6b7db3Sskrll "x" 3 bit register (MIPS16OP_*_RX)
18792a6b7db3Sskrll "z" 3 bit register (MIPS16OP_*_RZ)
18802a6b7db3Sskrll "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
18812a6b7db3Sskrll "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
18822a6b7db3Sskrll "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
18836f226886Schristos "." zero register ($0)
18842a6b7db3Sskrll "S" stack pointer ($sp or $29)
18852a6b7db3Sskrll "P" program counter
18862a6b7db3Sskrll "R" return address register ($ra or $31)
18872a6b7db3Sskrll "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
18882a6b7db3Sskrll "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
18896f226886Schristos "0" 5-bit ASMACRO p0 immediate
18906f226886Schristos "1" 3-bit ASMACRO p1 immediate
18916f226886Schristos "2" 3-bit ASMACRO p2 immediate
18926f226886Schristos "3" 5-bit ASMACRO p3 immediate
18936f226886Schristos "4" 3-bit ASMACRO p4 immediate
18942a6b7db3Sskrll "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
18952a6b7db3Sskrll "a" 26 bit jump address
18965f4eaf39Schristos "i" likewise, but flips bit 0
18972a6b7db3Sskrll "e" 11 bit extension value
18982a6b7db3Sskrll "l" register list for entry instruction
18992a6b7db3Sskrll "L" register list for exit instruction
19006f226886Schristos ">" 5-bit SYNC code
19016f226886Schristos "9" 9-bit signed immediate
19026f226886Schristos "G" global pointer ($gp or $28)
19036f226886Schristos "N" 5-bit coprocessor register
19046f226886Schristos "O" 3-bit sel field for MFC0/MTC0
19056f226886Schristos "Q" 5-bit hardware register
19066f226886Schristos "T" 5-bit CACHE opcode or PREF hint
19076f226886Schristos "b" 5-bit INS/EXT position, which becomes LSB
19086f226886Schristos Enforces: 0 <= pos < 32.
19096f226886Schristos "c" 5-bit INS size, which becomes MSB
19106f226886Schristos Requires that "b" occurs first to set position.
19116f226886Schristos Enforces: 0 < (pos+size) <= 32.
19126f226886Schristos "d" 5-bit EXT size, which becomes MSBD
19136f226886Schristos Requires that "b" occurs first to set position.
19146f226886Schristos Enforces: 0 < (pos+size) <= 32.
19156f226886Schristos "n" 2-bit immediate (1 .. 4)
19166f226886Schristos "o" 5-bit unsigned immediate * 16
19176f226886Schristos "r" 3-bit register
19186f226886Schristos "s" 3-bit ASMACRO select immediate
19196f226886Schristos "u" 16-bit unsigned immediate
19202a6b7db3Sskrll
19215f4eaf39Schristos "I" an immediate value used for macros
19225f4eaf39Schristos
19232a6b7db3Sskrll The remaining codes may be extended. Except as otherwise noted,
19242a6b7db3Sskrll the full extended operand is a 16 bit signed value.
19252a6b7db3Sskrll "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
19262a6b7db3Sskrll "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
19272a6b7db3Sskrll "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
19282a6b7db3Sskrll "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
19296f226886Schristos "F" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
19302a6b7db3Sskrll "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
19312a6b7db3Sskrll "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
19322a6b7db3Sskrll "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
19332a6b7db3Sskrll "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
19342a6b7db3Sskrll "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
19352a6b7db3Sskrll "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
19362a6b7db3Sskrll "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
19372a6b7db3Sskrll "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
19382a6b7db3Sskrll "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
19392a6b7db3Sskrll "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
19402a6b7db3Sskrll "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
19412a6b7db3Sskrll "q" 11 bit branch address (MIPS16OP_*_IMM11)
19422a6b7db3Sskrll "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
19432a6b7db3Sskrll "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
19442a6b7db3Sskrll "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
19457c6f6726Schristos "m" 7 bit register list for SAVE/RESTORE instruction (18 bit extended)
19462f15a542Schristos
19472f15a542Schristos Characters used so far, for quick reference when adding more:
19486f226886Schristos "0123456 89"
19496f226886Schristos ".[]<>"
19507c6f6726Schristos "ABCDEFGHI KL NOPQRSTUVWXYZ"
19516f226886Schristos "abcde ijklmnopqrs uvwxyz"
19522a6b7db3Sskrll */
19532a6b7db3Sskrll
19542a6b7db3Sskrll /* Save/restore encoding for the args field when all 4 registers are
19552a6b7db3Sskrll either saved as arguments or saved/restored as statics. */
19566f226886Schristos #define MIPS_SVRS_ALL_ARGS 0xe
19576f226886Schristos #define MIPS_SVRS_ALL_STATICS 0xb
19582a6b7db3Sskrll
19592a6b7db3Sskrll /* The following flags have the same value for the mips16 opcode
19602a6b7db3Sskrll table:
1961b410d692Schristos
1962b410d692Schristos INSN_ISA3
1963b410d692Schristos
19642a6b7db3Sskrll INSN_UNCOND_BRANCH_DELAY
19652a6b7db3Sskrll INSN_COND_BRANCH_DELAY
19662a6b7db3Sskrll INSN_COND_BRANCH_LIKELY (never used)
19672a6b7db3Sskrll INSN_READ_HI
19682a6b7db3Sskrll INSN_READ_LO
19692a6b7db3Sskrll INSN_WRITE_HI
19702a6b7db3Sskrll INSN_WRITE_LO
19712a6b7db3Sskrll INSN_TRAP
1972b410d692Schristos FP_D (never used)
19732a6b7db3Sskrll */
19742a6b7db3Sskrll
197503f5171aSchristos extern const struct mips_operand *decode_mips16_operand (char, bool);
19762a6b7db3Sskrll extern const struct mips_opcode mips16_opcodes[];
19772a6b7db3Sskrll extern const int bfd_mips16_num_opcodes;
19782a6b7db3Sskrll
1979b410d692Schristos /* These are the bit masks and shift counts used for the different fields
1980b410d692Schristos in the microMIPS instruction formats. No masks are provided for the
1981b410d692Schristos fixed portions of an instruction, since they are not needed. */
1982b410d692Schristos
1983b410d692Schristos #define MICROMIPSOP_MASK_IMMEDIATE 0xffff
1984b410d692Schristos #define MICROMIPSOP_SH_IMMEDIATE 0
1985b410d692Schristos #define MICROMIPSOP_MASK_DELTA 0xffff
1986b410d692Schristos #define MICROMIPSOP_SH_DELTA 0
1987b410d692Schristos #define MICROMIPSOP_MASK_CODE10 0x3ff
1988b410d692Schristos #define MICROMIPSOP_SH_CODE10 16 /* 10-bit wait code. */
1989b410d692Schristos #define MICROMIPSOP_MASK_TRAP 0xf
1990b410d692Schristos #define MICROMIPSOP_SH_TRAP 12 /* 4-bit trap code. */
1991b410d692Schristos #define MICROMIPSOP_MASK_SHAMT 0x1f
1992b410d692Schristos #define MICROMIPSOP_SH_SHAMT 11
1993b410d692Schristos #define MICROMIPSOP_MASK_TARGET 0x3ffffff
1994b410d692Schristos #define MICROMIPSOP_SH_TARGET 0
1995b410d692Schristos #define MICROMIPSOP_MASK_EXTLSB 0x1f /* "ext" LSB. */
1996b410d692Schristos #define MICROMIPSOP_SH_EXTLSB 6
1997b410d692Schristos #define MICROMIPSOP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */
1998b410d692Schristos #define MICROMIPSOP_SH_EXTMSBD 11
1999b410d692Schristos #define MICROMIPSOP_MASK_INSMSB 0x1f /* "ins" MSB. */
2000b410d692Schristos #define MICROMIPSOP_SH_INSMSB 11
2001b410d692Schristos #define MICROMIPSOP_MASK_CODE 0x3ff
2002b410d692Schristos #define MICROMIPSOP_SH_CODE 16 /* 10-bit higher break code. */
2003b410d692Schristos #define MICROMIPSOP_MASK_CODE2 0x3ff
2004b410d692Schristos #define MICROMIPSOP_SH_CODE2 6 /* 10-bit lower break code. */
2005b410d692Schristos #define MICROMIPSOP_MASK_CACHE 0x1f
2006b410d692Schristos #define MICROMIPSOP_SH_CACHE 21 /* 5-bit cache op. */
2007b410d692Schristos #define MICROMIPSOP_MASK_SEL 0x7
2008b410d692Schristos #define MICROMIPSOP_SH_SEL 11
2009b410d692Schristos #define MICROMIPSOP_MASK_OFFSET12 0xfff
2010b410d692Schristos #define MICROMIPSOP_SH_OFFSET12 0
2011b410d692Schristos #define MICROMIPSOP_MASK_3BITPOS 0x7
2012b410d692Schristos #define MICROMIPSOP_SH_3BITPOS 21
2013b410d692Schristos #define MICROMIPSOP_MASK_STYPE 0x1f
2014b410d692Schristos #define MICROMIPSOP_SH_STYPE 16
2015b410d692Schristos #define MICROMIPSOP_MASK_OFFSET10 0x3ff
2016b410d692Schristos #define MICROMIPSOP_SH_OFFSET10 6
2017b410d692Schristos #define MICROMIPSOP_MASK_RS 0x1f
2018b410d692Schristos #define MICROMIPSOP_SH_RS 16
2019b410d692Schristos #define MICROMIPSOP_MASK_RT 0x1f
2020b410d692Schristos #define MICROMIPSOP_SH_RT 21
2021b410d692Schristos #define MICROMIPSOP_MASK_RD 0x1f
2022b410d692Schristos #define MICROMIPSOP_SH_RD 11
2023b410d692Schristos #define MICROMIPSOP_MASK_FS 0x1f
2024b410d692Schristos #define MICROMIPSOP_SH_FS 16
2025b410d692Schristos #define MICROMIPSOP_MASK_FT 0x1f
2026b410d692Schristos #define MICROMIPSOP_SH_FT 21
2027b410d692Schristos #define MICROMIPSOP_MASK_FD 0x1f
2028b410d692Schristos #define MICROMIPSOP_SH_FD 11
2029b410d692Schristos #define MICROMIPSOP_MASK_FR 0x1f
2030b410d692Schristos #define MICROMIPSOP_SH_FR 6
2031b410d692Schristos #define MICROMIPSOP_MASK_RS3 0x1f
2032b410d692Schristos #define MICROMIPSOP_SH_RS3 6
2033b410d692Schristos #define MICROMIPSOP_MASK_PREFX 0x1f
2034b410d692Schristos #define MICROMIPSOP_SH_PREFX 11
2035b410d692Schristos #define MICROMIPSOP_MASK_BCC 0x7
2036b410d692Schristos #define MICROMIPSOP_SH_BCC 18
2037b410d692Schristos #define MICROMIPSOP_MASK_CCC 0x7
2038b410d692Schristos #define MICROMIPSOP_SH_CCC 13
2039b410d692Schristos #define MICROMIPSOP_MASK_COPZ 0x7fffff
2040b410d692Schristos #define MICROMIPSOP_SH_COPZ 3
2041b410d692Schristos
2042b410d692Schristos #define MICROMIPSOP_MASK_MB 0x7
2043b410d692Schristos #define MICROMIPSOP_SH_MB 23
2044b410d692Schristos #define MICROMIPSOP_MASK_MC 0x7
2045b410d692Schristos #define MICROMIPSOP_SH_MC 4
2046b410d692Schristos #define MICROMIPSOP_MASK_MD 0x7
2047b410d692Schristos #define MICROMIPSOP_SH_MD 7
2048b410d692Schristos #define MICROMIPSOP_MASK_ME 0x7
2049b410d692Schristos #define MICROMIPSOP_SH_ME 1
2050b410d692Schristos #define MICROMIPSOP_MASK_MF 0x7
2051b410d692Schristos #define MICROMIPSOP_SH_MF 3
2052b410d692Schristos #define MICROMIPSOP_MASK_MG 0x7
2053b410d692Schristos #define MICROMIPSOP_SH_MG 0
2054b410d692Schristos #define MICROMIPSOP_MASK_MH 0x7
2055b410d692Schristos #define MICROMIPSOP_SH_MH 7
2056b410d692Schristos #define MICROMIPSOP_MASK_MJ 0x1f
2057b410d692Schristos #define MICROMIPSOP_SH_MJ 0
2058b410d692Schristos #define MICROMIPSOP_MASK_ML 0x7
2059b410d692Schristos #define MICROMIPSOP_SH_ML 4
2060b410d692Schristos #define MICROMIPSOP_MASK_MM 0x7
2061b410d692Schristos #define MICROMIPSOP_SH_MM 1
2062b410d692Schristos #define MICROMIPSOP_MASK_MN 0x7
2063b410d692Schristos #define MICROMIPSOP_SH_MN 4
2064b410d692Schristos #define MICROMIPSOP_MASK_MP 0x1f
2065b410d692Schristos #define MICROMIPSOP_SH_MP 5
2066b410d692Schristos #define MICROMIPSOP_MASK_MQ 0x7
2067b410d692Schristos #define MICROMIPSOP_SH_MQ 7
2068b410d692Schristos
2069b410d692Schristos #define MICROMIPSOP_MASK_IMMA 0x7f
2070b410d692Schristos #define MICROMIPSOP_SH_IMMA 0
2071b410d692Schristos #define MICROMIPSOP_MASK_IMMB 0x7
2072b410d692Schristos #define MICROMIPSOP_SH_IMMB 1
2073b410d692Schristos #define MICROMIPSOP_MASK_IMMC 0xf
2074b410d692Schristos #define MICROMIPSOP_SH_IMMC 0
2075b410d692Schristos #define MICROMIPSOP_MASK_IMMD 0x3ff
2076b410d692Schristos #define MICROMIPSOP_SH_IMMD 0
2077b410d692Schristos #define MICROMIPSOP_MASK_IMME 0x7f
2078b410d692Schristos #define MICROMIPSOP_SH_IMME 0
2079b410d692Schristos #define MICROMIPSOP_MASK_IMMF 0xf
2080b410d692Schristos #define MICROMIPSOP_SH_IMMF 0
2081b410d692Schristos #define MICROMIPSOP_MASK_IMMG 0xf
2082b410d692Schristos #define MICROMIPSOP_SH_IMMG 0
2083b410d692Schristos #define MICROMIPSOP_MASK_IMMH 0xf
2084b410d692Schristos #define MICROMIPSOP_SH_IMMH 0
2085b410d692Schristos #define MICROMIPSOP_MASK_IMMI 0x7f
2086b410d692Schristos #define MICROMIPSOP_SH_IMMI 0
2087b410d692Schristos #define MICROMIPSOP_MASK_IMMJ 0xf
2088b410d692Schristos #define MICROMIPSOP_SH_IMMJ 0
2089b410d692Schristos #define MICROMIPSOP_MASK_IMML 0xf
2090b410d692Schristos #define MICROMIPSOP_SH_IMML 0
2091b410d692Schristos #define MICROMIPSOP_MASK_IMMM 0x7
2092b410d692Schristos #define MICROMIPSOP_SH_IMMM 1
2093b410d692Schristos #define MICROMIPSOP_MASK_IMMN 0x3
2094b410d692Schristos #define MICROMIPSOP_SH_IMMN 4
2095b410d692Schristos #define MICROMIPSOP_MASK_IMMO 0xf
2096b410d692Schristos #define MICROMIPSOP_SH_IMMO 0
2097b410d692Schristos #define MICROMIPSOP_MASK_IMMP 0x1f
2098b410d692Schristos #define MICROMIPSOP_SH_IMMP 0
2099b410d692Schristos #define MICROMIPSOP_MASK_IMMQ 0x7fffff
2100b410d692Schristos #define MICROMIPSOP_SH_IMMQ 0
2101b410d692Schristos #define MICROMIPSOP_MASK_IMMU 0x1f
2102b410d692Schristos #define MICROMIPSOP_SH_IMMU 0
2103b410d692Schristos #define MICROMIPSOP_MASK_IMMW 0x3f
2104b410d692Schristos #define MICROMIPSOP_SH_IMMW 1
2105b410d692Schristos #define MICROMIPSOP_MASK_IMMX 0xf
2106b410d692Schristos #define MICROMIPSOP_SH_IMMX 1
2107b410d692Schristos #define MICROMIPSOP_MASK_IMMY 0x1ff
2108b410d692Schristos #define MICROMIPSOP_SH_IMMY 1
2109b410d692Schristos
2110b410d692Schristos /* MIPS DSP ASE */
2111b410d692Schristos #define MICROMIPSOP_MASK_DSPACC 0x3
2112b410d692Schristos #define MICROMIPSOP_SH_DSPACC 14
2113b410d692Schristos #define MICROMIPSOP_MASK_DSPSFT 0x3f
2114b410d692Schristos #define MICROMIPSOP_SH_DSPSFT 16
2115b410d692Schristos #define MICROMIPSOP_MASK_SA3 0x7
2116b410d692Schristos #define MICROMIPSOP_SH_SA3 13
2117b410d692Schristos #define MICROMIPSOP_MASK_SA4 0xf
2118b410d692Schristos #define MICROMIPSOP_SH_SA4 12
2119b410d692Schristos #define MICROMIPSOP_MASK_IMM8 0xff
2120b410d692Schristos #define MICROMIPSOP_SH_IMM8 13
2121b410d692Schristos #define MICROMIPSOP_MASK_IMM10 0x3ff
2122b410d692Schristos #define MICROMIPSOP_SH_IMM10 16
2123b410d692Schristos #define MICROMIPSOP_MASK_WRDSP 0x3f
2124b410d692Schristos #define MICROMIPSOP_SH_WRDSP 14
2125b410d692Schristos #define MICROMIPSOP_MASK_BP 0x3
2126b410d692Schristos #define MICROMIPSOP_SH_BP 14
2127b410d692Schristos
2128b410d692Schristos /* Placeholders for fields that only exist in the traditional 32-bit
2129b410d692Schristos instruction encoding; see the comment above for details. */
2130b410d692Schristos #define MICROMIPSOP_MASK_CODE20 0
2131b410d692Schristos #define MICROMIPSOP_SH_CODE20 0
2132b410d692Schristos #define MICROMIPSOP_MASK_PERFREG 0
2133b410d692Schristos #define MICROMIPSOP_SH_PERFREG 0
2134b410d692Schristos #define MICROMIPSOP_MASK_CODE19 0
2135b410d692Schristos #define MICROMIPSOP_SH_CODE19 0
2136b410d692Schristos #define MICROMIPSOP_MASK_ALN 0
2137b410d692Schristos #define MICROMIPSOP_SH_ALN 0
2138b410d692Schristos #define MICROMIPSOP_MASK_VECBYTE 0
2139b410d692Schristos #define MICROMIPSOP_SH_VECBYTE 0
2140b410d692Schristos #define MICROMIPSOP_MASK_VECALIGN 0
2141b410d692Schristos #define MICROMIPSOP_SH_VECALIGN 0
2142b410d692Schristos #define MICROMIPSOP_MASK_DSPACC_S 0
2143b410d692Schristos #define MICROMIPSOP_SH_DSPACC_S 0
2144b410d692Schristos #define MICROMIPSOP_MASK_DSPSFT_7 0
2145b410d692Schristos #define MICROMIPSOP_SH_DSPSFT_7 0
2146b410d692Schristos #define MICROMIPSOP_MASK_RDDSP 0
2147b410d692Schristos #define MICROMIPSOP_SH_RDDSP 0
2148b410d692Schristos #define MICROMIPSOP_MASK_MT_U 0
2149b410d692Schristos #define MICROMIPSOP_SH_MT_U 0
2150b410d692Schristos #define MICROMIPSOP_MASK_MT_H 0
2151b410d692Schristos #define MICROMIPSOP_SH_MT_H 0
2152b410d692Schristos #define MICROMIPSOP_MASK_MTACC_T 0
2153b410d692Schristos #define MICROMIPSOP_SH_MTACC_T 0
2154b410d692Schristos #define MICROMIPSOP_MASK_MTACC_D 0
2155b410d692Schristos #define MICROMIPSOP_SH_MTACC_D 0
2156b410d692Schristos #define MICROMIPSOP_MASK_BBITIND 0
2157b410d692Schristos #define MICROMIPSOP_SH_BBITIND 0
2158b410d692Schristos #define MICROMIPSOP_MASK_CINSPOS 0
2159b410d692Schristos #define MICROMIPSOP_SH_CINSPOS 0
2160b410d692Schristos #define MICROMIPSOP_MASK_CINSLM1 0
2161b410d692Schristos #define MICROMIPSOP_SH_CINSLM1 0
2162b410d692Schristos #define MICROMIPSOP_MASK_SEQI 0
2163b410d692Schristos #define MICROMIPSOP_SH_SEQI 0
2164b410d692Schristos #define MICROMIPSOP_SH_OFFSET_A 0
2165b410d692Schristos #define MICROMIPSOP_MASK_OFFSET_A 0
2166b410d692Schristos #define MICROMIPSOP_SH_OFFSET_B 0
2167b410d692Schristos #define MICROMIPSOP_MASK_OFFSET_B 0
2168b410d692Schristos #define MICROMIPSOP_SH_OFFSET_C 0
2169b410d692Schristos #define MICROMIPSOP_MASK_OFFSET_C 0
2170b410d692Schristos #define MICROMIPSOP_SH_RZ 0
2171b410d692Schristos #define MICROMIPSOP_MASK_RZ 0
2172b410d692Schristos #define MICROMIPSOP_SH_FZ 0
2173b410d692Schristos #define MICROMIPSOP_MASK_FZ 0
2174b410d692Schristos
21755f4eaf39Schristos /* microMIPS Enhanced VA Scheme */
21765f4eaf39Schristos #define MICROMIPSOP_SH_EVAOFFSET 0
21775f4eaf39Schristos #define MICROMIPSOP_MASK_EVAOFFSET 0x1ff
21785f4eaf39Schristos
2179b410d692Schristos /* These are the characters which may appears in the args field of a microMIPS
2180b410d692Schristos instruction. They appear in the order in which the fields appear
2181b410d692Schristos when the instruction is used. Commas and parentheses in the args
2182b410d692Schristos string are ignored when assembling, and written into the output
2183b410d692Schristos when disassembling.
2184b410d692Schristos
2185b410d692Schristos The followings are for 16-bit microMIPS instructions.
2186b410d692Schristos
2187b410d692Schristos "ma" must be $28
2188b410d692Schristos "mc" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MC) at bit 4
2189b410d692Schristos The same register used as both source and target.
2190b410d692Schristos "md" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MD) at bit 7
2191b410d692Schristos "me" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ME) at bit 1
2192b410d692Schristos The same register used as both source and target.
2193b410d692Schristos "mf" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MF) at bit 3
2194b410d692Schristos "mg" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MG) at bit 0
21955f4eaf39Schristos "mh" 3-bit MIPS register pair (MICROMIPSOP_*_MH) at bit 7
2196b410d692Schristos "mj" 5-bit MIPS registers (MICROMIPSOP_*_MJ) at bit 0
2197b410d692Schristos "ml" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ML) at bit 4
2198b410d692Schristos "mm" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MM) at bit 1
2199b410d692Schristos "mn" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MN) at bit 4
2200b410d692Schristos "mp" 5-bit MIPS registers (MICROMIPSOP_*_MP) at bit 5
2201b410d692Schristos "mq" 3-bit MIPS registers 0, 2-7, 17 (MICROMIPSOP_*_MQ) at bit 7
2202b410d692Schristos "mr" must be program counter
2203b410d692Schristos "ms" must be $29
2204b410d692Schristos "mt" must be the same as the previous register
2205b410d692Schristos "mx" must be the same as the destination register
2206b410d692Schristos "my" must be $31
2207b410d692Schristos "mz" must be $0
2208b410d692Schristos
2209b410d692Schristos "mA" 7-bit immediate (-64 .. 63) << 2 (MICROMIPSOP_*_IMMA)
2210b410d692Schristos "mB" 3-bit immediate (-1, 1, 4, 8, 12, 16, 20, 24) (MICROMIPSOP_*_IMMB)
2211b410d692Schristos "mC" 4-bit immediate (1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64, 128, 255,
2212b410d692Schristos 32768, 65535) (MICROMIPSOP_*_IMMC)
2213b410d692Schristos "mD" 10-bit branch address (-512 .. 511) << 1 (MICROMIPSOP_*_IMMD)
2214b410d692Schristos "mE" 7-bit branch address (-64 .. 63) << 1 (MICROMIPSOP_*_IMME)
2215b410d692Schristos "mF" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMMF)
2216b410d692Schristos "mG" 4-bit immediate (-1 .. 14) (MICROMIPSOP_*_IMMG)
2217b410d692Schristos "mH" 4-bit immediate (0 .. 15) << 1 (MICROMIPSOP_*_IMMH)
2218b410d692Schristos "mI" 7-bit immediate (-1 .. 126) (MICROMIPSOP_*_IMMI)
2219b410d692Schristos "mJ" 4-bit immediate (0 .. 15) << 2 (MICROMIPSOP_*_IMMJ)
2220b410d692Schristos "mL" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
2221b410d692Schristos "mM" 3-bit immediate (1 .. 8) (MICROMIPSOP_*_IMMM)
2222b410d692Schristos "mN" 2-bit immediate (0 .. 3) for register list (MICROMIPSOP_*_IMMN)
2223b410d692Schristos "mO" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
2224b410d692Schristos "mP" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMP)
2225b410d692Schristos "mU" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMU)
2226b410d692Schristos "mW" 6-bit immediate (0 .. 63) << 2 (MICROMIPSOP_*_IMMW)
2227b410d692Schristos "mX" 4-bit immediate (-8 .. 7) (MICROMIPSOP_*_IMMX)
2228b410d692Schristos "mY" 9-bit immediate (-258 .. -3, 2 .. 257) << 2 (MICROMIPSOP_*_IMMY)
2229b410d692Schristos "mZ" must be zero
2230b410d692Schristos
2231b410d692Schristos In most cases 32-bit microMIPS instructions use the same characters
2232b410d692Schristos as MIPS (with ADDIUPC being a notable exception, but there are some
2233b410d692Schristos others too).
2234b410d692Schristos
2235b410d692Schristos "." 10-bit signed offset/number (MICROMIPSOP_*_OFFSET10)
22365f4eaf39Schristos "1" 5-bit sync type (MICROMIPSOP_*_STYPE)
2237b410d692Schristos "<" 5-bit shift amount (MICROMIPSOP_*_SHAMT)
2238b410d692Schristos ">" shift amount between 32 and 63, stored after subtracting 32
2239b410d692Schristos (MICROMIPSOP_*_SHAMT)
2240b410d692Schristos "\" 3-bit position for ASET and ACLR (MICROMIPSOP_*_3BITPOS)
2241b410d692Schristos "|" 4-bit trap code (MICROMIPSOP_*_TRAP)
2242b410d692Schristos "~" 12-bit signed offset (MICROMIPSOP_*_OFFSET12)
2243b410d692Schristos "a" 26-bit target address (MICROMIPSOP_*_TARGET)
22445f4eaf39Schristos "+i" likewise, but flips bit 0
2245b410d692Schristos "b" 5-bit base register (MICROMIPSOP_*_RS)
2246b410d692Schristos "c" 10-bit higher breakpoint code (MICROMIPSOP_*_CODE)
2247b410d692Schristos "d" 5-bit destination register specifier (MICROMIPSOP_*_RD)
2248b410d692Schristos "h" 5-bit PREFX hint (MICROMIPSOP_*_PREFX)
2249b410d692Schristos "i" 16-bit unsigned immediate (MICROMIPSOP_*_IMMEDIATE)
2250b410d692Schristos "j" 16-bit signed immediate (MICROMIPSOP_*_DELTA)
2251b410d692Schristos "k" 5-bit cache opcode in target register position (MICROMIPSOP_*_CACHE)
2252b410d692Schristos "n" register list for 32-bit LWM/SWM instruction (MICROMIPSOP_*_RT)
2253b410d692Schristos "o" 16-bit signed offset (MICROMIPSOP_*_DELTA)
2254b410d692Schristos "p" 16-bit PC-relative branch target address (MICROMIPSOP_*_DELTA)
2255b410d692Schristos "q" 10-bit lower breakpoint code (MICROMIPSOP_*_CODE2)
2256b410d692Schristos "r" 5-bit same register used as both source and target (MICROMIPSOP_*_RS)
2257b410d692Schristos "s" 5-bit source register specifier (MICROMIPSOP_*_RS)
2258b410d692Schristos "t" 5-bit target register (MICROMIPSOP_*_RT)
2259b410d692Schristos "u" 16-bit upper 16 bits of address (MICROMIPSOP_*_IMMEDIATE)
2260b410d692Schristos "v" 5-bit same register used as both source and destination
2261b410d692Schristos (MICROMIPSOP_*_RS)
2262b410d692Schristos "w" 5-bit same register used as both target and destination
2263b410d692Schristos (MICROMIPSOP_*_RT)
2264b410d692Schristos "y" 5-bit source 3 register for ALNV.PS (MICROMIPSOP_*_RS3)
2265b410d692Schristos "z" must be zero register
2266b410d692Schristos "C" 23-bit coprocessor function code (MICROMIPSOP_*_COPZ)
2267b410d692Schristos "K" 5-bit Hardware Register (RDHWR instruction) (MICROMIPSOP_*_RS)
2268b410d692Schristos
2269b410d692Schristos "+A" 5-bit INS/EXT/DINS/DEXT/DINSM/DEXTM position, which becomes
2270b410d692Schristos LSB (MICROMIPSOP_*_EXTLSB).
2271b410d692Schristos Enforces: 0 <= pos < 32.
2272b410d692Schristos "+B" 5-bit INS/DINS size, which becomes MSB (MICROMIPSOP_*_INSMSB).
2273b410d692Schristos Requires that "+A" or "+E" occur first to set position.
2274b410d692Schristos Enforces: 0 < (pos+size) <= 32.
2275b410d692Schristos "+C" 5-bit EXT/DEXT size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
2276b410d692Schristos Requires that "+A" or "+E" occur first to set position.
2277b410d692Schristos Enforces: 0 < (pos+size) <= 32.
2278b410d692Schristos (Also used by DEXT w/ different limits, but limits for
2279b410d692Schristos that are checked by the M_DEXT macro.)
2280b410d692Schristos "+E" 5-bit DINSU/DEXTU position, which becomes LSB-32 (MICROMIPSOP_*_EXTLSB).
2281b410d692Schristos Enforces: 32 <= pos < 64.
2282b410d692Schristos "+F" 5-bit DINSM/DINSU size, which becomes MSB-32 (MICROMIPSOP_*_INSMSB).
2283b410d692Schristos Requires that "+A" or "+E" occur first to set position.
2284b410d692Schristos Enforces: 32 < (pos+size) <= 64.
2285b410d692Schristos "+G" 5-bit DEXTM size, which becomes MSBD-32 (MICROMIPSOP_*_EXTMSBD).
2286b410d692Schristos Requires that "+A" or "+E" occur first to set position.
2287b410d692Schristos Enforces: 32 < (pos+size) <= 64.
2288b410d692Schristos "+H" 5-bit DEXTU size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
2289b410d692Schristos Requires that "+A" or "+E" occur first to set position.
2290b410d692Schristos Enforces: 32 < (pos+size) <= 64.
22915f4eaf39Schristos "+J" 10-bit SYSCALL/WAIT/SDBBP/HYPCALL function code
22925f4eaf39Schristos (MICROMIPSOP_*_CODE10)
2293b410d692Schristos
2294b410d692Schristos PC-relative addition (ADDIUPC) instruction:
2295b410d692Schristos "mQ" 23-bit offset (-4194304 .. 4194303) << 2 (MICROMIPSOP_*_IMMQ)
2296b410d692Schristos "mb" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MB) at bit 23
2297b410d692Schristos
2298b410d692Schristos Floating point instructions:
2299b410d692Schristos "D" 5-bit destination register (MICROMIPSOP_*_FD)
2300b410d692Schristos "M" 3-bit compare condition code (MICROMIPSOP_*_CCC)
2301b410d692Schristos "N" 3-bit branch condition code (MICROMIPSOP_*_BCC)
2302b410d692Schristos "R" 5-bit fr source 3 register (MICROMIPSOP_*_FR)
2303b410d692Schristos "S" 5-bit fs source 1 register (MICROMIPSOP_*_FS)
2304b410d692Schristos "T" 5-bit ft source 2 register (MICROMIPSOP_*_FT)
2305b410d692Schristos "V" 5-bit same register used as floating source and destination or target
2306b410d692Schristos (MICROMIPSOP_*_FS)
2307b410d692Schristos
2308b410d692Schristos Coprocessor instructions:
2309b410d692Schristos "E" 5-bit target register (MICROMIPSOP_*_RT)
23105f4eaf39Schristos "G" 5-bit source register (MICROMIPSOP_*_RS)
2311b410d692Schristos "H" 3-bit sel field for (D)MTC* and (D)MFC* (MICROMIPSOP_*_SEL)
231203f5171aSchristos "g" 5-bit control source register (MICROMIPSOP_*_RS)
2313b410d692Schristos
2314b410d692Schristos Macro instructions:
2315b410d692Schristos "A" general 32 bit expression
2316b410d692Schristos "I" 32-bit immediate (value placed in imm_expr).
2317b410d692Schristos "F" 64-bit floating point constant in .rdata
2318b410d692Schristos "L" 64-bit floating point constant in .lit8
2319b410d692Schristos "f" 32-bit floating point constant
2320b410d692Schristos "l" 32-bit floating point constant in .lit4
2321b410d692Schristos
2322b410d692Schristos DSP ASE usage:
2323b410d692Schristos "2" 2-bit unsigned immediate for byte align (MICROMIPSOP_*_BP)
2324b410d692Schristos "3" 3-bit unsigned immediate (MICROMIPSOP_*_SA3)
2325b410d692Schristos "4" 4-bit unsigned immediate (MICROMIPSOP_*_SA4)
2326b410d692Schristos "5" 8-bit unsigned immediate (MICROMIPSOP_*_IMM8)
2327b410d692Schristos "6" 5-bit unsigned immediate (MICROMIPSOP_*_RS)
2328b410d692Schristos "7" 2-bit DSP accumulator register (MICROMIPSOP_*_DSPACC)
2329b410d692Schristos "8" 6-bit unsigned immediate (MICROMIPSOP_*_WRDSP)
2330b410d692Schristos "0" 6-bit signed immediate (MICROMIPSOP_*_DSPSFT)
2331b410d692Schristos "@" 10-bit signed immediate (MICROMIPSOP_*_IMM10)
2332b410d692Schristos "^" 5-bit unsigned immediate (MICROMIPSOP_*_RD)
2333b410d692Schristos
23345f4eaf39Schristos microMIPS Enhanced VA Scheme:
23355f4eaf39Schristos "+j" 9-bit signed offset in bit 0 (OP_*_EVAOFFSET)
23365f4eaf39Schristos
23375f4eaf39Schristos MSA Extension:
23385f4eaf39Schristos "+d" 5-bit MSA register (FD)
23395f4eaf39Schristos "+e" 5-bit MSA register (FS)
23405f4eaf39Schristos "+h" 5-bit MSA register (FT)
23415f4eaf39Schristos "+k" 5-bit GPR at bit 6
23425f4eaf39Schristos "+l" 5-bit MSA control register at bit 6
23435f4eaf39Schristos "+n" 5-bit MSA control register at bit 11
23445f4eaf39Schristos "+o" 4-bit vector element index at bit 16
23455f4eaf39Schristos "+u" 3-bit vector element index at bit 16
23465f4eaf39Schristos "+v" 2-bit vector element index at bit 16
23475f4eaf39Schristos "+w" 1-bit vector element index at bit 16
23485f4eaf39Schristos "+x" 5-bit shift amount at bit 16
23495f4eaf39Schristos "+T" (-512 .. 511) << 0 at bit 16
23505f4eaf39Schristos "+U" (-512 .. 511) << 1 at bit 16
23515f4eaf39Schristos "+V" (-512 .. 511) << 2 at bit 16
23525f4eaf39Schristos "+W" (-512 .. 511) << 3 at bit 16
23535f4eaf39Schristos "+~" 2 bit LSA/DLSA shift amount from 1 to 4 at bit 6
23545f4eaf39Schristos "+!" 3 bit unsigned bit position at bit 16
23555f4eaf39Schristos "+@" 4 bit unsigned bit position at bit 16
23565f4eaf39Schristos "+#" 6 bit unsigned bit position at bit 16
23575f4eaf39Schristos "+$" 5 bit unsigned immediate at bit 16
23585f4eaf39Schristos "+%" 5 bit signed immediate at bit 16
23595f4eaf39Schristos "+^" 10 bit signed immediate at bit 11
23605f4eaf39Schristos "+&" 0 vector element index
23615f4eaf39Schristos "+*" 5-bit register vector element index at bit 16
23625f4eaf39Schristos "+|" 8-bit mask at bit 16
23635f4eaf39Schristos
2364b410d692Schristos Other:
2365b410d692Schristos "()" parens surrounding optional value
2366b410d692Schristos "," separates operands
2367b410d692Schristos "+" start of extension sequence
2368b410d692Schristos "m" start of microMIPS extension sequence
2369b410d692Schristos
2370b410d692Schristos Characters used so far, for quick reference when adding more:
2371b410d692Schristos "12345678 0"
23725f4eaf39Schristos "<>(),+-.@\^|~"
2373b410d692Schristos "ABCDEFGHI KLMN RST V "
237403f5171aSchristos "abcd fghijklmnopqrstuvw yz"
2375b410d692Schristos
2376b410d692Schristos Extension character sequences used so far ("+" followed by the
2377b410d692Schristos following), for quick reference when adding more:
2378b410d692Schristos ""
23795f4eaf39Schristos "~!@#$%^&*|"
23805f4eaf39Schristos "ABCEFGHJTUVW"
23815f4eaf39Schristos "dehijklnouvwx"
2382b410d692Schristos
2383b410d692Schristos Extension character sequences used so far ("m" followed by the
2384b410d692Schristos following), for quick reference when adding more:
2385b410d692Schristos ""
2386b410d692Schristos ""
2387b410d692Schristos " BCDEFGHIJ LMNOPQ U WXYZ"
2388b410d692Schristos " bcdefghij lmn pq st xyz"
23895f4eaf39Schristos
23905f4eaf39Schristos Extension character sequences used so far ("-" followed by the
23915f4eaf39Schristos following), for quick reference when adding more:
23925f4eaf39Schristos ""
23935f4eaf39Schristos ""
23945f4eaf39Schristos <none so far>
2395b410d692Schristos */
2396b410d692Schristos
23975f4eaf39Schristos extern const struct mips_operand *decode_micromips_operand (const char *);
2398b410d692Schristos extern const struct mips_opcode micromips_opcodes[];
2399b410d692Schristos extern const int bfd_micromips_num_opcodes;
2400b410d692Schristos
2401c8f6ff28Smatt /* A NOP insn impemented as "or at,at,zero".
2402c8f6ff28Smatt Used to implement -mfix-loongson2f. */
2403c8f6ff28Smatt #define LOONGSON2F_NOP_INSN 0x00200825
2404c8f6ff28Smatt
24052f15a542Schristos #ifdef __cplusplus
24062f15a542Schristos }
24072f15a542Schristos #endif
24082f15a542Schristos
24092a6b7db3Sskrll #endif /* _MIPS_H_ */
2410