xref: /netbsd-src/external/gpl3/gdb.old/dist/include/opcode/mips.h (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1a5a4af3bSchristos /* mips.h.  Mips opcode list for GDB, the GNU debugger.
2*8b657b07Schristos    Copyright (C) 1993-2022 Free Software Foundation, Inc.
3a5a4af3bSchristos    Contributed by Ralph Campbell and OSF
4a5a4af3bSchristos    Commented and modified by Ian Lance Taylor, Cygnus Support
5a5a4af3bSchristos 
6a5a4af3bSchristos    This file is part of GDB, GAS, and the GNU binutils.
7a5a4af3bSchristos 
8a5a4af3bSchristos    GDB, GAS, and the GNU binutils are free software; you can redistribute
9a5a4af3bSchristos    them and/or modify them under the terms of the GNU General Public
10a5a4af3bSchristos    License as published by the Free Software Foundation; either version 3,
11a5a4af3bSchristos    or (at your option) any later version.
12a5a4af3bSchristos 
13a5a4af3bSchristos    GDB, GAS, and the GNU binutils are distributed in the hope that they
14a5a4af3bSchristos    will be useful, but WITHOUT ANY WARRANTY; without even the implied
15a5a4af3bSchristos    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
16a5a4af3bSchristos    the GNU General Public License for more details.
17a5a4af3bSchristos 
18a5a4af3bSchristos    You should have received a copy of the GNU General Public License
19a5a4af3bSchristos    along with this file; see the file COPYING3.  If not, write to the Free
20a5a4af3bSchristos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
21a5a4af3bSchristos    MA 02110-1301, USA.  */
22a5a4af3bSchristos 
23a5a4af3bSchristos #ifndef _MIPS_H_
24a5a4af3bSchristos #define _MIPS_H_
25a5a4af3bSchristos 
26a5a4af3bSchristos #include "bfd.h"
27a5a4af3bSchristos 
28e5cb852cSchristos #ifdef __cplusplus
29e5cb852cSchristos extern "C" {
30e5cb852cSchristos #endif
31e5cb852cSchristos 
32a5a4af3bSchristos /* These are bit masks and shift counts to use to access the various
33a5a4af3bSchristos    fields of an instruction.  To retrieve the X field of an
34a5a4af3bSchristos    instruction, use the expression
35a5a4af3bSchristos 	(i >> OP_SH_X) & OP_MASK_X
36a5a4af3bSchristos    To set the same field (to j), use
37a5a4af3bSchristos 	i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X)
38a5a4af3bSchristos 
39a5a4af3bSchristos    Make sure you use fields that are appropriate for the instruction,
40a5a4af3bSchristos    of course.
41a5a4af3bSchristos 
42a5a4af3bSchristos    The 'i' format uses OP, RS, RT and IMMEDIATE.
43a5a4af3bSchristos 
44a5a4af3bSchristos    The 'j' format uses OP and TARGET.
45a5a4af3bSchristos 
46a5a4af3bSchristos    The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT.
47a5a4af3bSchristos 
48a5a4af3bSchristos    The 'b' format uses OP, RS, RT and DELTA.
49a5a4af3bSchristos 
50a5a4af3bSchristos    The floating point 'i' format uses OP, RS, RT and IMMEDIATE.
51a5a4af3bSchristos 
52a5a4af3bSchristos    The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT.
53a5a4af3bSchristos 
54a5a4af3bSchristos    A breakpoint instruction uses OP, CODE and SPEC (10 bits of the
55a5a4af3bSchristos    breakpoint instruction are not defined; Kane says the breakpoint
56a5a4af3bSchristos    code field in BREAK is 20 bits; yet MIPS assemblers and debuggers
57a5a4af3bSchristos    only use ten bits).  An optional two-operand form of break/sdbbp
58a5a4af3bSchristos    allows the lower ten bits to be set too, and MIPS32 and later
5982650ea5Schristos    architectures allow 20 bits to be set with a single operand for
6082650ea5Schristos    the sdbbp instruction (using CODE20).
61a5a4af3bSchristos 
62a5a4af3bSchristos    The syscall instruction uses CODE20.
63a5a4af3bSchristos 
64a5a4af3bSchristos    The general coprocessor instructions use COPZ.  */
65a5a4af3bSchristos 
66a5a4af3bSchristos #define OP_MASK_OP		0x3f
67a5a4af3bSchristos #define OP_SH_OP		26
68a5a4af3bSchristos #define OP_MASK_RS		0x1f
69a5a4af3bSchristos #define OP_SH_RS		21
70a5a4af3bSchristos #define OP_MASK_FR		0x1f
71a5a4af3bSchristos #define OP_SH_FR		21
72a5a4af3bSchristos #define OP_MASK_FMT		0x1f
73a5a4af3bSchristos #define OP_SH_FMT		21
74a5a4af3bSchristos #define OP_MASK_BCC		0x7
75a5a4af3bSchristos #define OP_SH_BCC		18
76a5a4af3bSchristos #define OP_MASK_CODE		0x3ff
77a5a4af3bSchristos #define OP_SH_CODE		16
78a5a4af3bSchristos #define OP_MASK_CODE2		0x3ff
79a5a4af3bSchristos #define OP_SH_CODE2		6
80a5a4af3bSchristos #define OP_MASK_RT		0x1f
81a5a4af3bSchristos #define OP_SH_RT		16
82a5a4af3bSchristos #define OP_MASK_FT		0x1f
83a5a4af3bSchristos #define OP_SH_FT		16
84a5a4af3bSchristos #define OP_MASK_CACHE		0x1f
85a5a4af3bSchristos #define OP_SH_CACHE		16
86a5a4af3bSchristos #define OP_MASK_RD		0x1f
87a5a4af3bSchristos #define OP_SH_RD		11
88a5a4af3bSchristos #define OP_MASK_FS		0x1f
89a5a4af3bSchristos #define OP_SH_FS		11
90a5a4af3bSchristos #define OP_MASK_PREFX		0x1f
91a5a4af3bSchristos #define OP_SH_PREFX		11
92a5a4af3bSchristos #define OP_MASK_CCC		0x7
93a5a4af3bSchristos #define OP_SH_CCC		8
94a5a4af3bSchristos #define OP_MASK_CODE20		0xfffff /* 20 bit syscall/breakpoint code.  */
95a5a4af3bSchristos #define OP_SH_CODE20		6
96a5a4af3bSchristos #define OP_MASK_SHAMT		0x1f
97a5a4af3bSchristos #define OP_SH_SHAMT		6
98a5a4af3bSchristos #define OP_MASK_EXTLSB		OP_MASK_SHAMT
99a5a4af3bSchristos #define OP_SH_EXTLSB		OP_SH_SHAMT
100a5a4af3bSchristos #define OP_MASK_STYPE		OP_MASK_SHAMT
101a5a4af3bSchristos #define OP_SH_STYPE		OP_SH_SHAMT
102a5a4af3bSchristos #define OP_MASK_FD		0x1f
103a5a4af3bSchristos #define OP_SH_FD		6
104a5a4af3bSchristos #define OP_MASK_TARGET		0x3ffffff
105a5a4af3bSchristos #define OP_SH_TARGET		0
106a5a4af3bSchristos #define OP_MASK_COPZ		0x1ffffff
107a5a4af3bSchristos #define OP_SH_COPZ		0
108a5a4af3bSchristos #define OP_MASK_IMMEDIATE	0xffff
109a5a4af3bSchristos #define OP_SH_IMMEDIATE		0
110a5a4af3bSchristos #define OP_MASK_DELTA		0xffff
111a5a4af3bSchristos #define OP_SH_DELTA		0
112a5a4af3bSchristos #define OP_MASK_FUNCT		0x3f
113a5a4af3bSchristos #define OP_SH_FUNCT		0
114a5a4af3bSchristos #define OP_MASK_SPEC		0x3f
115a5a4af3bSchristos #define OP_SH_SPEC		0
116a5a4af3bSchristos #define OP_SH_LOCC              8       /* FP condition code.  */
117a5a4af3bSchristos #define OP_SH_HICC              18      /* FP condition code.  */
118a5a4af3bSchristos #define OP_MASK_CC              0x7
119a5a4af3bSchristos #define OP_SH_COP1NORM          25      /* Normal COP1 encoding.  */
120a5a4af3bSchristos #define OP_MASK_COP1NORM        0x1     /* a single bit.  */
121a5a4af3bSchristos #define OP_SH_COP1SPEC          21      /* COP1 encodings.  */
122a5a4af3bSchristos #define OP_MASK_COP1SPEC        0xf
123a5a4af3bSchristos #define OP_MASK_COP1SCLR        0x4
124a5a4af3bSchristos #define OP_MASK_COP1CMP         0x3
125a5a4af3bSchristos #define OP_SH_COP1CMP           4
126a5a4af3bSchristos #define OP_SH_FORMAT            21      /* FP short format field.  */
127a5a4af3bSchristos #define OP_MASK_FORMAT          0x7
128a5a4af3bSchristos #define OP_SH_TRUE              16
129a5a4af3bSchristos #define OP_MASK_TRUE            0x1
130a5a4af3bSchristos #define OP_SH_GE                17
131a5a4af3bSchristos #define OP_MASK_GE              0x01
132a5a4af3bSchristos #define OP_SH_UNSIGNED          16
133a5a4af3bSchristos #define OP_MASK_UNSIGNED        0x1
134a5a4af3bSchristos #define OP_SH_HINT              16
135a5a4af3bSchristos #define OP_MASK_HINT            0x1f
136a5a4af3bSchristos #define OP_SH_MMI               0       /* Multimedia (parallel) op.  */
137a5a4af3bSchristos #define OP_MASK_MMI             0x3f
138a5a4af3bSchristos #define OP_SH_MMISUB            6
139a5a4af3bSchristos #define OP_MASK_MMISUB          0x1f
140a5a4af3bSchristos #define OP_MASK_PERFREG		0x1f	/* Performance monitoring.  */
141a5a4af3bSchristos #define OP_SH_PERFREG		1
142a5a4af3bSchristos #define OP_SH_SEL		0	/* Coprocessor select field.  */
143a5a4af3bSchristos #define OP_MASK_SEL		0x7	/* The sel field of mfcZ and mtcZ.  */
144a5a4af3bSchristos #define OP_SH_CODE19		6       /* 19 bit wait code.  */
145a5a4af3bSchristos #define OP_MASK_CODE19		0x7ffff
146a5a4af3bSchristos #define OP_SH_ALN		21
147a5a4af3bSchristos #define OP_MASK_ALN		0x7
148a5a4af3bSchristos #define OP_SH_VSEL		21
149a5a4af3bSchristos #define OP_MASK_VSEL		0x1f
150a5a4af3bSchristos #define OP_MASK_VECBYTE		0x7	/* Selector field is really 4 bits,
151a5a4af3bSchristos 					   but 0x8-0xf don't select bytes.  */
152a5a4af3bSchristos #define OP_SH_VECBYTE		22
153a5a4af3bSchristos #define OP_MASK_VECALIGN	0x7	/* Vector byte-align (alni.ob) op.  */
154a5a4af3bSchristos #define OP_SH_VECALIGN		21
155a5a4af3bSchristos #define OP_MASK_INSMSB		0x1f	/* "ins" MSB.  */
156a5a4af3bSchristos #define OP_SH_INSMSB		11
157a5a4af3bSchristos #define OP_MASK_EXTMSBD		0x1f	/* "ext" MSBD.  */
158a5a4af3bSchristos #define OP_SH_EXTMSBD		11
159a5a4af3bSchristos 
160a5a4af3bSchristos /* MIPS DSP ASE */
161a5a4af3bSchristos #define OP_SH_DSPACC		11
162a5a4af3bSchristos #define OP_MASK_DSPACC  	0x3
163a5a4af3bSchristos #define OP_SH_DSPACC_S  	21
164a5a4af3bSchristos #define OP_MASK_DSPACC_S	0x3
165a5a4af3bSchristos #define OP_SH_DSPSFT		20
166a5a4af3bSchristos #define OP_MASK_DSPSFT  	0x3f
167a5a4af3bSchristos #define OP_SH_DSPSFT_7  	19
168a5a4af3bSchristos #define OP_MASK_DSPSFT_7	0x7f
169a5a4af3bSchristos #define OP_SH_SA3		21
170a5a4af3bSchristos #define OP_MASK_SA3		0x7
171a5a4af3bSchristos #define OP_SH_SA4		21
172a5a4af3bSchristos #define OP_MASK_SA4		0xf
173a5a4af3bSchristos #define OP_SH_IMM8		16
174a5a4af3bSchristos #define OP_MASK_IMM8		0xff
175a5a4af3bSchristos #define OP_SH_IMM10		16
176a5a4af3bSchristos #define OP_MASK_IMM10		0x3ff
177a5a4af3bSchristos #define OP_SH_WRDSP		11
178a5a4af3bSchristos #define OP_MASK_WRDSP		0x3f
179a5a4af3bSchristos #define OP_SH_RDDSP		16
180a5a4af3bSchristos #define OP_MASK_RDDSP		0x3f
181a5a4af3bSchristos #define OP_SH_BP		11
182a5a4af3bSchristos #define OP_MASK_BP		0x3
183a5a4af3bSchristos 
184a5a4af3bSchristos /* MIPS MT ASE */
185a5a4af3bSchristos #define OP_SH_MT_U		5
186a5a4af3bSchristos #define OP_MASK_MT_U		0x1
187a5a4af3bSchristos #define OP_SH_MT_H		4
188a5a4af3bSchristos #define OP_MASK_MT_H		0x1
189a5a4af3bSchristos #define OP_SH_MTACC_T		18
190a5a4af3bSchristos #define OP_MASK_MTACC_T		0x3
191a5a4af3bSchristos #define OP_SH_MTACC_D		13
192a5a4af3bSchristos #define OP_MASK_MTACC_D		0x3
193a5a4af3bSchristos 
194a5a4af3bSchristos /* MIPS MCU ASE */
195a5a4af3bSchristos #define OP_MASK_3BITPOS		0x7
196a5a4af3bSchristos #define OP_SH_3BITPOS		12
197a5a4af3bSchristos #define OP_MASK_OFFSET12	0xfff
198a5a4af3bSchristos #define OP_SH_OFFSET12		0
199a5a4af3bSchristos 
200a5a4af3bSchristos #define	OP_OP_COP0		0x10
201a5a4af3bSchristos #define	OP_OP_COP1		0x11
202a5a4af3bSchristos #define	OP_OP_COP2		0x12
203a5a4af3bSchristos #define	OP_OP_COP3		0x13
204a5a4af3bSchristos #define	OP_OP_LWC1		0x31
205a5a4af3bSchristos #define	OP_OP_LWC2		0x32
206a5a4af3bSchristos #define	OP_OP_LWC3		0x33	/* a.k.a. pref */
207a5a4af3bSchristos #define	OP_OP_LDC1		0x35
208a5a4af3bSchristos #define	OP_OP_LDC2		0x36
209a5a4af3bSchristos #define	OP_OP_LDC3		0x37	/* a.k.a. ld */
210a5a4af3bSchristos #define	OP_OP_SWC1		0x39
211a5a4af3bSchristos #define	OP_OP_SWC2		0x3a
212a5a4af3bSchristos #define	OP_OP_SWC3		0x3b
213a5a4af3bSchristos #define	OP_OP_SDC1		0x3d
214a5a4af3bSchristos #define	OP_OP_SDC2		0x3e
215a5a4af3bSchristos #define	OP_OP_SDC3		0x3f	/* a.k.a. sd */
216a5a4af3bSchristos 
217a5a4af3bSchristos /* MIPS VIRT ASE */
218a5a4af3bSchristos #define OP_MASK_CODE10		0x3ff
219a5a4af3bSchristos #define OP_SH_CODE10		11
220a5a4af3bSchristos 
221a5a4af3bSchristos /* Values in the 'VSEL' field.  */
222a5a4af3bSchristos #define MDMX_FMTSEL_IMM_QH	0x1d
223a5a4af3bSchristos #define MDMX_FMTSEL_IMM_OB	0x1e
224a5a4af3bSchristos #define MDMX_FMTSEL_VEC_QH	0x15
225a5a4af3bSchristos #define MDMX_FMTSEL_VEC_OB	0x16
226a5a4af3bSchristos 
227a5a4af3bSchristos /* UDI */
228a5a4af3bSchristos #define OP_SH_UDI1		6
229a5a4af3bSchristos #define OP_MASK_UDI1		0x1f
230a5a4af3bSchristos #define OP_SH_UDI2		6
231a5a4af3bSchristos #define OP_MASK_UDI2		0x3ff
232a5a4af3bSchristos #define OP_SH_UDI3		6
233a5a4af3bSchristos #define OP_MASK_UDI3		0x7fff
234a5a4af3bSchristos #define OP_SH_UDI4		6
235a5a4af3bSchristos #define OP_MASK_UDI4		0xfffff
236a5a4af3bSchristos 
237a5a4af3bSchristos /* Octeon */
238a5a4af3bSchristos #define OP_SH_BBITIND		16
239a5a4af3bSchristos #define OP_MASK_BBITIND		0x1f
240a5a4af3bSchristos #define OP_SH_CINSPOS		6
241a5a4af3bSchristos #define OP_MASK_CINSPOS		0x1f
242a5a4af3bSchristos #define OP_SH_CINSLM1		11
243a5a4af3bSchristos #define OP_MASK_CINSLM1		0x1f
244a5a4af3bSchristos #define OP_SH_SEQI		6
245a5a4af3bSchristos #define OP_MASK_SEQI		0x3ff
246a5a4af3bSchristos 
247a5a4af3bSchristos /* Loongson */
248a5a4af3bSchristos #define OP_SH_OFFSET_A		6
249a5a4af3bSchristos #define OP_MASK_OFFSET_A	0xff
250a5a4af3bSchristos #define OP_SH_OFFSET_B		3
251a5a4af3bSchristos #define OP_MASK_OFFSET_B	0xff
252a5a4af3bSchristos #define OP_SH_OFFSET_C		6
253a5a4af3bSchristos #define OP_MASK_OFFSET_C	0x1ff
254a5a4af3bSchristos #define OP_SH_RZ		0
255a5a4af3bSchristos #define OP_MASK_RZ		0x1f
256a5a4af3bSchristos #define OP_SH_FZ		0
257a5a4af3bSchristos #define OP_MASK_FZ		0x1f
258a5a4af3bSchristos 
259a5a4af3bSchristos /* Every MICROMIPSOP_X definition requires a corresponding OP_X
260a5a4af3bSchristos    definition, and vice versa.  This simplifies various parts
261a5a4af3bSchristos    of the operand handling in GAS.  The fields below only exist
262a5a4af3bSchristos    in the microMIPS encoding, so define each one to have an empty
263a5a4af3bSchristos    range.  */
264a5a4af3bSchristos #define OP_MASK_TRAP		0
265a5a4af3bSchristos #define OP_SH_TRAP		0
266a5a4af3bSchristos #define OP_MASK_OFFSET10	0
267a5a4af3bSchristos #define OP_SH_OFFSET10		0
268a5a4af3bSchristos #define OP_MASK_RS3		0
269a5a4af3bSchristos #define OP_SH_RS3		0
270a5a4af3bSchristos #define OP_MASK_MB		0
271a5a4af3bSchristos #define OP_SH_MB		0
272a5a4af3bSchristos #define OP_MASK_MC		0
273a5a4af3bSchristos #define OP_SH_MC		0
274a5a4af3bSchristos #define OP_MASK_MD		0
275a5a4af3bSchristos #define OP_SH_MD		0
276a5a4af3bSchristos #define OP_MASK_ME		0
277a5a4af3bSchristos #define OP_SH_ME		0
278a5a4af3bSchristos #define OP_MASK_MF		0
279a5a4af3bSchristos #define OP_SH_MF		0
280a5a4af3bSchristos #define OP_MASK_MG		0
281a5a4af3bSchristos #define OP_SH_MG		0
282a5a4af3bSchristos #define OP_MASK_MH		0
283a5a4af3bSchristos #define OP_SH_MH		0
284a5a4af3bSchristos #define OP_MASK_MJ		0
285a5a4af3bSchristos #define OP_SH_MJ		0
286a5a4af3bSchristos #define OP_MASK_ML		0
287a5a4af3bSchristos #define OP_SH_ML		0
288a5a4af3bSchristos #define OP_MASK_MM		0
289a5a4af3bSchristos #define OP_SH_MM		0
290a5a4af3bSchristos #define OP_MASK_MN		0
291a5a4af3bSchristos #define OP_SH_MN		0
292a5a4af3bSchristos #define OP_MASK_MP		0
293a5a4af3bSchristos #define OP_SH_MP		0
294a5a4af3bSchristos #define OP_MASK_MQ		0
295a5a4af3bSchristos #define OP_SH_MQ		0
296a5a4af3bSchristos #define OP_MASK_IMMA		0
297a5a4af3bSchristos #define OP_SH_IMMA		0
298a5a4af3bSchristos #define OP_MASK_IMMB		0
299a5a4af3bSchristos #define OP_SH_IMMB		0
300a5a4af3bSchristos #define OP_MASK_IMMC		0
301a5a4af3bSchristos #define OP_SH_IMMC		0
302a5a4af3bSchristos #define OP_MASK_IMMF		0
303a5a4af3bSchristos #define OP_SH_IMMF		0
304a5a4af3bSchristos #define OP_MASK_IMMG		0
305a5a4af3bSchristos #define OP_SH_IMMG		0
306a5a4af3bSchristos #define OP_MASK_IMMH		0
307a5a4af3bSchristos #define OP_SH_IMMH		0
308a5a4af3bSchristos #define OP_MASK_IMMI		0
309a5a4af3bSchristos #define OP_SH_IMMI		0
310a5a4af3bSchristos #define OP_MASK_IMMJ		0
311a5a4af3bSchristos #define OP_SH_IMMJ		0
312a5a4af3bSchristos #define OP_MASK_IMML		0
313a5a4af3bSchristos #define OP_SH_IMML		0
314a5a4af3bSchristos #define OP_MASK_IMMM		0
315a5a4af3bSchristos #define OP_SH_IMMM		0
316a5a4af3bSchristos #define OP_MASK_IMMN		0
317a5a4af3bSchristos #define OP_SH_IMMN		0
318a5a4af3bSchristos #define OP_MASK_IMMO		0
319a5a4af3bSchristos #define OP_SH_IMMO		0
320a5a4af3bSchristos #define OP_MASK_IMMP		0
321a5a4af3bSchristos #define OP_SH_IMMP		0
322a5a4af3bSchristos #define OP_MASK_IMMQ		0
323a5a4af3bSchristos #define OP_SH_IMMQ		0
324a5a4af3bSchristos #define OP_MASK_IMMU		0
325a5a4af3bSchristos #define OP_SH_IMMU		0
326a5a4af3bSchristos #define OP_MASK_IMMW		0
327a5a4af3bSchristos #define OP_SH_IMMW		0
328a5a4af3bSchristos #define OP_MASK_IMMX		0
329a5a4af3bSchristos #define OP_SH_IMMX		0
330a5a4af3bSchristos #define OP_MASK_IMMY		0
331a5a4af3bSchristos #define OP_SH_IMMY		0
332a5a4af3bSchristos 
333a5a4af3bSchristos /* Enhanced VA Scheme */
334a5a4af3bSchristos #define OP_SH_EVAOFFSET		7
335a5a4af3bSchristos #define OP_MASK_EVAOFFSET	0x1ff
336a5a4af3bSchristos 
337a5a4af3bSchristos /* Enumerates the various types of MIPS operand.  */
338a5a4af3bSchristos enum mips_operand_type {
339a5a4af3bSchristos   /* Described by mips_int_operand.  */
340a5a4af3bSchristos   OP_INT,
341a5a4af3bSchristos 
342a5a4af3bSchristos   /* Described by mips_mapped_int_operand.  */
343a5a4af3bSchristos   OP_MAPPED_INT,
344a5a4af3bSchristos 
345a5a4af3bSchristos   /* Described by mips_msb_operand.  */
346a5a4af3bSchristos   OP_MSB,
347a5a4af3bSchristos 
348a5a4af3bSchristos   /* Described by mips_reg_operand.  */
349a5a4af3bSchristos   OP_REG,
350a5a4af3bSchristos 
351a5a4af3bSchristos   /* Like OP_REG, but can be omitted if the register is the same as the
352a5a4af3bSchristos      previous operand.  */
353a5a4af3bSchristos   OP_OPTIONAL_REG,
354a5a4af3bSchristos 
355a5a4af3bSchristos   /* Described by mips_reg_pair_operand.  */
356a5a4af3bSchristos   OP_REG_PAIR,
357a5a4af3bSchristos 
358a5a4af3bSchristos   /* Described by mips_pcrel_operand.  */
359a5a4af3bSchristos   OP_PCREL,
360a5a4af3bSchristos 
361a5a4af3bSchristos   /* A performance register.  The field is 5 bits in size, but the supported
362a5a4af3bSchristos      values are much more restricted.  */
363a5a4af3bSchristos   OP_PERF_REG,
364a5a4af3bSchristos 
365a5a4af3bSchristos   /* The final operand in a microMIPS ADDIUSP instruction.  It mostly acts
366a5a4af3bSchristos      as a normal 9-bit signed offset that is multiplied by four, but there
367a5a4af3bSchristos      are four special cases:
368a5a4af3bSchristos 
369a5a4af3bSchristos      -2 * 4 => -258 * 4
370a5a4af3bSchristos      -1 * 4 => -257 * 4
371a5a4af3bSchristos       0 * 4 =>  256 * 4
372a5a4af3bSchristos       1 * 4 =>  257 * 4.  */
373a5a4af3bSchristos   OP_ADDIUSP_INT,
374a5a4af3bSchristos 
375a5a4af3bSchristos   /* The target of a (D)CLO or (D)CLZ instruction.  The operand spans two
376a5a4af3bSchristos      5-bit register fields, both of which must be set to the destination
377a5a4af3bSchristos      register.  */
378a5a4af3bSchristos   OP_CLO_CLZ_DEST,
379a5a4af3bSchristos 
380a5a4af3bSchristos   /* A register list for a microMIPS LWM or SWM instruction.  The operand
381a5a4af3bSchristos      size determines whether the 16-bit or 32-bit encoding is required.  */
382a5a4af3bSchristos   OP_LWM_SWM_LIST,
383a5a4af3bSchristos 
384a5a4af3bSchristos   /* The register list for an emulated MIPS16 ENTRY or EXIT instruction.  */
385a5a4af3bSchristos   OP_ENTRY_EXIT_LIST,
386a5a4af3bSchristos 
387a5a4af3bSchristos   /* The register list and frame size for a MIPS16 SAVE or RESTORE
388a5a4af3bSchristos      instruction.  */
389a5a4af3bSchristos   OP_SAVE_RESTORE_LIST,
390a5a4af3bSchristos 
391a5a4af3bSchristos   /* A 10-bit field VVVVVNNNNN used for octobyte and quadhalf instructions:
392a5a4af3bSchristos 
393a5a4af3bSchristos      V      Meaning
394a5a4af3bSchristos      -----  -------
395a5a4af3bSchristos      0EEE0  8 copies of $vN[E], OB format
396a5a4af3bSchristos      0EE01  4 copies of $vN[E], QH format
397a5a4af3bSchristos      10110  all 8 elements of $vN, OB format
398a5a4af3bSchristos      10101  all 4 elements of $vN, QH format
399a5a4af3bSchristos      11110  8 copies of immediate N, OB format
400a5a4af3bSchristos      11101  4 copies of immediate N, QH format.  */
401a5a4af3bSchristos   OP_MDMX_IMM_REG,
402a5a4af3bSchristos 
403a5a4af3bSchristos   /* A register operand that must match the destination register.  */
404a5a4af3bSchristos   OP_REPEAT_DEST_REG,
405a5a4af3bSchristos 
406a5a4af3bSchristos   /* A register operand that must match the previous register.  */
407a5a4af3bSchristos   OP_REPEAT_PREV_REG,
408a5a4af3bSchristos 
409a5a4af3bSchristos   /* $pc, which has no encoding in the architectural instruction.  */
410a5a4af3bSchristos   OP_PC,
411a5a4af3bSchristos 
41247c37bc2Schristos   /* $28, which has no encoding in the MIPS16e architectural instruction.  */
41347c37bc2Schristos   OP_REG28,
41447c37bc2Schristos 
415a5a4af3bSchristos   /* A 4-bit XYZW channel mask or 2-bit XYZW index; the size determines
416a5a4af3bSchristos      which.  */
417a5a4af3bSchristos   OP_VU0_SUFFIX,
418a5a4af3bSchristos 
419a5a4af3bSchristos   /* Like OP_VU0_SUFFIX, but used when the operand's value has already
420a5a4af3bSchristos      been set.  Any suffix used here must match the previous value.  */
421a5a4af3bSchristos   OP_VU0_MATCH_SUFFIX,
422a5a4af3bSchristos 
423a5a4af3bSchristos   /* An index selected by an integer, e.g. [1].  */
424a5a4af3bSchristos   OP_IMM_INDEX,
425a5a4af3bSchristos 
426a5a4af3bSchristos   /* An index selected by a register, e.g. [$2].  */
427a5a4af3bSchristos   OP_REG_INDEX,
428a5a4af3bSchristos 
429a5a4af3bSchristos   /* The operand spans two 5-bit register fields, both of which must be set to
430a5a4af3bSchristos      the source register.  */
431a5a4af3bSchristos   OP_SAME_RS_RT,
432a5a4af3bSchristos 
433a5a4af3bSchristos   /* Described by mips_prev_operand.  */
434a5a4af3bSchristos   OP_CHECK_PREV,
435a5a4af3bSchristos 
436a5a4af3bSchristos   /* A register operand that must not be zero.  */
437a5a4af3bSchristos   OP_NON_ZERO_REG
438a5a4af3bSchristos };
439a5a4af3bSchristos 
440a5a4af3bSchristos /* Enumerates the types of MIPS register.  */
441a5a4af3bSchristos enum mips_reg_operand_type {
442a5a4af3bSchristos   /* General registers $0-$31.  Software names like $at can also be used.  */
443a5a4af3bSchristos   OP_REG_GP,
444a5a4af3bSchristos 
445a5a4af3bSchristos   /* Floating-point registers $f0-$f31.  */
446a5a4af3bSchristos   OP_REG_FP,
447a5a4af3bSchristos 
448a5a4af3bSchristos   /* Coprocessor condition code registers $cc0-$cc7.  FPU condition codes
449a5a4af3bSchristos      can also be written $fcc0-$fcc7.  */
450a5a4af3bSchristos   OP_REG_CCC,
451a5a4af3bSchristos 
452a5a4af3bSchristos   /* FPRs used in a vector capacity.  They can be written $f0-$f31
453a5a4af3bSchristos      or $v0-$v31, although the latter form is not used for the VR5400
454a5a4af3bSchristos      vector instructions.  */
455a5a4af3bSchristos   OP_REG_VEC,
456a5a4af3bSchristos 
457a5a4af3bSchristos   /* DSP accumulator registers $ac0-$ac3.  */
458a5a4af3bSchristos   OP_REG_ACC,
459a5a4af3bSchristos 
460a5a4af3bSchristos   /* Coprocessor registers $0-$31.  Mnemonic names like c0_cause can
461a5a4af3bSchristos      also be used in some contexts.  */
462a5a4af3bSchristos   OP_REG_COPRO,
463a5a4af3bSchristos 
464*8b657b07Schristos   /* Coprocessor control registers $0-$31.  Mnemonic names like c1_fcsr can
465*8b657b07Schristos      also be used in some contexts.  */
466*8b657b07Schristos   OP_REG_CONTROL,
467*8b657b07Schristos 
468a5a4af3bSchristos   /* Hardware registers $0-$31.  Mnemonic names like hwr_cpunum can
469a5a4af3bSchristos      also be used in some contexts.  */
470a5a4af3bSchristos   OP_REG_HW,
471a5a4af3bSchristos 
472a5a4af3bSchristos   /* Floating-point registers $vf0-$vf31.  */
473a5a4af3bSchristos   OP_REG_VF,
474a5a4af3bSchristos 
475a5a4af3bSchristos   /* Integer registers $vi0-$vi31.  */
476a5a4af3bSchristos   OP_REG_VI,
477a5a4af3bSchristos 
478a5a4af3bSchristos   /* R5900 VU0 registers $I, $Q, $R and $ACC.  */
479a5a4af3bSchristos   OP_REG_R5900_I,
480a5a4af3bSchristos   OP_REG_R5900_Q,
481a5a4af3bSchristos   OP_REG_R5900_R,
482a5a4af3bSchristos   OP_REG_R5900_ACC,
483a5a4af3bSchristos 
484a5a4af3bSchristos   /* MSA registers $w0-$w31.  */
485a5a4af3bSchristos   OP_REG_MSA,
486a5a4af3bSchristos 
487a5a4af3bSchristos   /* MSA control registers $0-$31.  */
488a5a4af3bSchristos   OP_REG_MSA_CTRL
489a5a4af3bSchristos };
490a5a4af3bSchristos 
491a5a4af3bSchristos /* Base class for all operands.  */
492a5a4af3bSchristos struct mips_operand
493a5a4af3bSchristos {
494a5a4af3bSchristos   /* The type of the operand.  */
495a5a4af3bSchristos   enum mips_operand_type type;
496a5a4af3bSchristos 
497a5a4af3bSchristos   /* The operand occupies SIZE bits of the instruction, starting at LSB.  */
498a5a4af3bSchristos   unsigned short size;
499a5a4af3bSchristos   unsigned short lsb;
500a5a4af3bSchristos };
501a5a4af3bSchristos 
502a5a4af3bSchristos /* Describes an integer operand with a regular encoding pattern.  */
503a5a4af3bSchristos struct mips_int_operand
504a5a4af3bSchristos {
505a5a4af3bSchristos   struct mips_operand root;
506a5a4af3bSchristos 
507a5a4af3bSchristos   /* The low ROOT.SIZE bits of MAX_VAL encodes (MAX_VAL + BIAS) << SHIFT.
508a5a4af3bSchristos      The cyclically previous field value encodes 1 << SHIFT less than that,
509a5a4af3bSchristos      and so on.  E.g.
510a5a4af3bSchristos 
511a5a4af3bSchristos      - for { { T, 4, L }, 14, 0, 0 }, field values 0...14 encode themselves,
512a5a4af3bSchristos        but 15 encodes -1.
513a5a4af3bSchristos 
514a5a4af3bSchristos      - { { T, 8, L }, 127, 0, 2 } is a normal signed 8-bit operand that is
515a5a4af3bSchristos        shifted left two places.
516a5a4af3bSchristos 
517a5a4af3bSchristos      - { { T, 3, L }, 8, 0, 0 } is a normal unsigned 3-bit operand except
518a5a4af3bSchristos        that 0 encodes 8.
519a5a4af3bSchristos 
520a5a4af3bSchristos      - { { ... }, 0, 1, 3 } means that N encodes (N + 1) << 3.  */
521a5a4af3bSchristos   unsigned int max_val;
522a5a4af3bSchristos   int bias;
523a5a4af3bSchristos   unsigned int shift;
524a5a4af3bSchristos 
525a5a4af3bSchristos   /* True if the operand should be printed as hex rather than decimal.  */
526*8b657b07Schristos   bool print_hex;
527a5a4af3bSchristos };
528a5a4af3bSchristos 
529a5a4af3bSchristos /* Uses a lookup table to describe a small integer operand.  */
530a5a4af3bSchristos struct mips_mapped_int_operand
531a5a4af3bSchristos {
532a5a4af3bSchristos   struct mips_operand root;
533a5a4af3bSchristos 
534a5a4af3bSchristos   /* Maps each encoding value to the integer that it represents.  */
535a5a4af3bSchristos   const int *int_map;
536a5a4af3bSchristos 
537a5a4af3bSchristos   /* True if the operand should be printed as hex rather than decimal.  */
538*8b657b07Schristos   bool print_hex;
539a5a4af3bSchristos };
540a5a4af3bSchristos 
541a5a4af3bSchristos /* An operand that encodes the most significant bit position of a bitfield.
542a5a4af3bSchristos    Given a bitfield that spans bits [MSB, LSB], some operands of this type
543a5a4af3bSchristos    encode MSB directly while others encode MSB - LSB.  Each operand of this
544a5a4af3bSchristos    type is preceded by an integer operand that specifies LSB.
545a5a4af3bSchristos 
546a5a4af3bSchristos    The assembly form varies between instructions.  For some instructions,
547a5a4af3bSchristos    such as EXT, the operand is written as the bitfield size.  For others,
548a5a4af3bSchristos    such as EXTS, it is written in raw MSB - LSB form.  */
549a5a4af3bSchristos struct mips_msb_operand
550a5a4af3bSchristos {
551a5a4af3bSchristos   struct mips_operand root;
552a5a4af3bSchristos 
553a5a4af3bSchristos   /* The assembly-level operand encoded by a field value of 0.  */
554a5a4af3bSchristos   int bias;
555a5a4af3bSchristos 
556a5a4af3bSchristos   /* True if the operand encodes MSB directly, false if it encodes
557a5a4af3bSchristos      MSB - LSB.  */
558*8b657b07Schristos   bool add_lsb;
559a5a4af3bSchristos 
560a5a4af3bSchristos   /* The maximum value of MSB + 1.  */
561a5a4af3bSchristos   unsigned int opsize;
562a5a4af3bSchristos };
563a5a4af3bSchristos 
564a5a4af3bSchristos /* Describes a single register operand.  */
565a5a4af3bSchristos struct mips_reg_operand
566a5a4af3bSchristos {
567a5a4af3bSchristos   struct mips_operand root;
568a5a4af3bSchristos 
569a5a4af3bSchristos   /* The type of register.  */
570a5a4af3bSchristos   enum mips_reg_operand_type reg_type;
571a5a4af3bSchristos 
572a5a4af3bSchristos   /* If nonnull, REG_MAP[N] gives the register associated with encoding N,
573a5a4af3bSchristos      otherwise the encoding is the same as the register number.  */
574a5a4af3bSchristos   const unsigned char *reg_map;
575a5a4af3bSchristos };
576a5a4af3bSchristos 
577a5a4af3bSchristos /* Describes an operand that which must match a condition based on the
578a5a4af3bSchristos    previous operand.  */
579a5a4af3bSchristos struct mips_check_prev_operand
580a5a4af3bSchristos {
581a5a4af3bSchristos   struct mips_operand root;
582a5a4af3bSchristos 
583*8b657b07Schristos   bool greater_than_ok;
584*8b657b07Schristos   bool less_than_ok;
585*8b657b07Schristos   bool equal_ok;
586*8b657b07Schristos   bool zero_ok;
587a5a4af3bSchristos };
588a5a4af3bSchristos 
589a5a4af3bSchristos /* Describes an operand that encodes a pair of registers.  */
590a5a4af3bSchristos struct mips_reg_pair_operand
591a5a4af3bSchristos {
592a5a4af3bSchristos   struct mips_operand root;
593a5a4af3bSchristos 
594a5a4af3bSchristos   /* The type of register.  */
595a5a4af3bSchristos   enum mips_reg_operand_type reg_type;
596a5a4af3bSchristos 
597a5a4af3bSchristos   /* Encoding N represents REG1_MAP[N], REG2_MAP[N].  */
598a5a4af3bSchristos   unsigned char *reg1_map;
599a5a4af3bSchristos   unsigned char *reg2_map;
600a5a4af3bSchristos };
601a5a4af3bSchristos 
602a5a4af3bSchristos /* Describes an operand that is calculated relative to a base PC.
603a5a4af3bSchristos    The base PC is usually the address of the following instruction,
604a5a4af3bSchristos    but the rules for MIPS16 instructions like ADDIUPC are more complicated.  */
605a5a4af3bSchristos struct mips_pcrel_operand
606a5a4af3bSchristos {
607a5a4af3bSchristos   /* Encodes the offset.  */
608a5a4af3bSchristos   struct mips_int_operand root;
609a5a4af3bSchristos 
610a5a4af3bSchristos   /* The low ALIGN_LOG2 bits of the base PC are cleared to give PC',
611a5a4af3bSchristos      which is then added to the offset encoded by ROOT.  */
612a5a4af3bSchristos   unsigned int align_log2 : 8;
613a5a4af3bSchristos 
614a5a4af3bSchristos   /* If INCLUDE_ISA_BIT, the ISA bit of the original base PC is then
615a5a4af3bSchristos      reinstated.  This is true for jumps and branches and false for
616a5a4af3bSchristos      PC-relative data instructions.  */
617a5a4af3bSchristos   unsigned int include_isa_bit : 1;
618a5a4af3bSchristos 
619a5a4af3bSchristos   /* If FLIP_ISA_BIT, the ISA bit of the result is inverted.
620a5a4af3bSchristos      This is true for JALX and false otherwise.  */
621a5a4af3bSchristos   unsigned int flip_isa_bit : 1;
622a5a4af3bSchristos };
623a5a4af3bSchristos 
624a5a4af3bSchristos /* Return true if the assembly syntax allows OPERAND to be omitted.  */
625a5a4af3bSchristos 
626*8b657b07Schristos static inline bool
627a5a4af3bSchristos mips_optional_operand_p (const struct mips_operand *operand)
628a5a4af3bSchristos {
629a5a4af3bSchristos   return (operand->type == OP_OPTIONAL_REG
630a5a4af3bSchristos 	  || operand->type == OP_REPEAT_PREV_REG);
631a5a4af3bSchristos }
632a5a4af3bSchristos 
633a5a4af3bSchristos /* Return a version of INSN in which the field specified by OPERAND
634a5a4af3bSchristos    has value UVAL.  */
635a5a4af3bSchristos 
636a5a4af3bSchristos static inline unsigned int
637a5a4af3bSchristos mips_insert_operand (const struct mips_operand *operand, unsigned int insn,
638a5a4af3bSchristos 		     unsigned int uval)
639a5a4af3bSchristos {
640a5a4af3bSchristos   unsigned int mask;
641a5a4af3bSchristos 
642a5a4af3bSchristos   mask = (1 << operand->size) - 1;
643a5a4af3bSchristos   insn &= ~(mask << operand->lsb);
644a5a4af3bSchristos   insn |= (uval & mask) << operand->lsb;
645a5a4af3bSchristos   return insn;
646a5a4af3bSchristos }
647a5a4af3bSchristos 
648a5a4af3bSchristos /* Extract OPERAND from instruction INSN.  */
649a5a4af3bSchristos 
650a5a4af3bSchristos static inline unsigned int
651a5a4af3bSchristos mips_extract_operand (const struct mips_operand *operand, unsigned int insn)
652a5a4af3bSchristos {
653a5a4af3bSchristos   return (insn >> operand->lsb) & ((1 << operand->size) - 1);
654a5a4af3bSchristos }
655a5a4af3bSchristos 
656a5a4af3bSchristos /* UVAL is the value encoded by OPERAND.  Return it in signed form.  */
657a5a4af3bSchristos 
658a5a4af3bSchristos static inline int
659a5a4af3bSchristos mips_signed_operand (const struct mips_operand *operand, unsigned int uval)
660a5a4af3bSchristos {
661a5a4af3bSchristos   unsigned int sign_bit, mask;
662a5a4af3bSchristos 
663a5a4af3bSchristos   mask = (1 << operand->size) - 1;
664a5a4af3bSchristos   sign_bit = 1 << (operand->size - 1);
665a5a4af3bSchristos   return ((uval + sign_bit) & mask) - sign_bit;
666a5a4af3bSchristos }
667a5a4af3bSchristos 
668a5a4af3bSchristos /* Return the integer that OPERAND encodes as UVAL.  */
669a5a4af3bSchristos 
670a5a4af3bSchristos static inline int
671a5a4af3bSchristos mips_decode_int_operand (const struct mips_int_operand *operand,
672a5a4af3bSchristos 			 unsigned int uval)
673a5a4af3bSchristos {
674a5a4af3bSchristos   uval |= (operand->max_val - uval) & -(1 << operand->root.size);
675a5a4af3bSchristos   uval += operand->bias;
676a5a4af3bSchristos   uval <<= operand->shift;
677a5a4af3bSchristos   return uval;
678a5a4af3bSchristos }
679a5a4af3bSchristos 
680a5a4af3bSchristos /* Return the maximum value that can be encoded by OPERAND.  */
681a5a4af3bSchristos 
682a5a4af3bSchristos static inline int
683a5a4af3bSchristos mips_int_operand_max (const struct mips_int_operand *operand)
684a5a4af3bSchristos {
685a5a4af3bSchristos   return (operand->max_val + operand->bias) << operand->shift;
686a5a4af3bSchristos }
687a5a4af3bSchristos 
688a5a4af3bSchristos /* Return the minimum value that can be encoded by OPERAND.  */
689a5a4af3bSchristos 
690a5a4af3bSchristos static inline int
691a5a4af3bSchristos mips_int_operand_min (const struct mips_int_operand *operand)
692a5a4af3bSchristos {
693a5a4af3bSchristos   unsigned int mask;
694a5a4af3bSchristos 
695a5a4af3bSchristos   mask = (1 << operand->root.size) - 1;
696a5a4af3bSchristos   return mips_int_operand_max (operand) - (mask << operand->shift);
697a5a4af3bSchristos }
698a5a4af3bSchristos 
699a5a4af3bSchristos /* Return the register that OPERAND encodes as UVAL.  */
700a5a4af3bSchristos 
701a5a4af3bSchristos static inline int
702a5a4af3bSchristos mips_decode_reg_operand (const struct mips_reg_operand *operand,
703a5a4af3bSchristos 			 unsigned int uval)
704a5a4af3bSchristos {
705a5a4af3bSchristos   if (operand->reg_map)
706a5a4af3bSchristos     uval = operand->reg_map[uval];
707a5a4af3bSchristos   return uval;
708a5a4af3bSchristos }
709a5a4af3bSchristos 
710a5a4af3bSchristos /* PC-relative operand OPERAND has value UVAL and is relative to BASE_PC.
711a5a4af3bSchristos    Return the address that it encodes.  */
712a5a4af3bSchristos 
713a5a4af3bSchristos static inline bfd_vma
714a5a4af3bSchristos mips_decode_pcrel_operand (const struct mips_pcrel_operand *operand,
715a5a4af3bSchristos 			   bfd_vma base_pc, unsigned int uval)
716a5a4af3bSchristos {
717a5a4af3bSchristos   bfd_vma addr;
718a5a4af3bSchristos 
719a5a4af3bSchristos   addr = base_pc & -(1 << operand->align_log2);
720a5a4af3bSchristos   addr += mips_decode_int_operand (&operand->root, uval);
721a5a4af3bSchristos   if (operand->include_isa_bit)
722a5a4af3bSchristos     addr |= base_pc & 1;
723a5a4af3bSchristos   if (operand->flip_isa_bit)
724a5a4af3bSchristos     addr ^= 1;
725a5a4af3bSchristos   return addr;
726a5a4af3bSchristos }
727a5a4af3bSchristos 
728a5a4af3bSchristos /* This structure holds information for a particular instruction.  */
729a5a4af3bSchristos 
730a5a4af3bSchristos struct mips_opcode
731a5a4af3bSchristos {
732a5a4af3bSchristos   /* The name of the instruction.  */
733a5a4af3bSchristos   const char *name;
734a5a4af3bSchristos   /* A string describing the arguments for this instruction.  */
735a5a4af3bSchristos   const char *args;
736a5a4af3bSchristos   /* The basic opcode for the instruction.  When assembling, this
737a5a4af3bSchristos      opcode is modified by the arguments to produce the actual opcode
738a5a4af3bSchristos      that is used.  If pinfo is INSN_MACRO, then this is 0.  */
739a5a4af3bSchristos   unsigned long match;
740a5a4af3bSchristos   /* If pinfo is not INSN_MACRO, then this is a bit mask for the
741a5a4af3bSchristos      relevant portions of the opcode when disassembling.  If the
742a5a4af3bSchristos      actual opcode anded with the match field equals the opcode field,
743a5a4af3bSchristos      then we have found the correct instruction.  If pinfo is
744a5a4af3bSchristos      INSN_MACRO, then this field is the macro identifier.  */
745a5a4af3bSchristos   unsigned long mask;
746a5a4af3bSchristos   /* For a macro, this is INSN_MACRO.  Otherwise, it is a collection
747a5a4af3bSchristos      of bits describing the instruction, notably any relevant hazard
748a5a4af3bSchristos      information.  */
749a5a4af3bSchristos   unsigned long pinfo;
750a5a4af3bSchristos   /* A collection of additional bits describing the instruction. */
751a5a4af3bSchristos   unsigned long pinfo2;
752a5a4af3bSchristos   /* A collection of bits describing the instruction sets of which this
753a5a4af3bSchristos      instruction or macro is a member. */
754a5a4af3bSchristos   unsigned long membership;
755a5a4af3bSchristos   /* A collection of bits describing the ASE of which this instruction
756a5a4af3bSchristos      or macro is a member.  */
757a5a4af3bSchristos   unsigned long ase;
758a5a4af3bSchristos   /* A collection of bits describing the instruction sets of which this
759a5a4af3bSchristos      instruction or macro is not a member.  */
760a5a4af3bSchristos   unsigned long exclusions;
761a5a4af3bSchristos };
762a5a4af3bSchristos 
76399e23f81Schristos /* Return true if MO is an instruction that requires 32-bit encoding.  */
76499e23f81Schristos 
765*8b657b07Schristos static inline bool
76699e23f81Schristos mips_opcode_32bit_p (const struct mips_opcode *mo)
76799e23f81Schristos {
76899e23f81Schristos   return mo->mask >> 16 != 0;
76999e23f81Schristos }
77099e23f81Schristos 
771a5a4af3bSchristos /* These are the characters which may appear in the args field of an
772a5a4af3bSchristos    instruction.  They appear in the order in which the fields appear
773a5a4af3bSchristos    when the instruction is used.  Commas and parentheses in the args
774a5a4af3bSchristos    string are ignored when assembling, and written into the output
775a5a4af3bSchristos    when disassembling.
776a5a4af3bSchristos 
777a5a4af3bSchristos    Each of these characters corresponds to a mask field defined above.
778a5a4af3bSchristos 
779a5a4af3bSchristos    "1" 5 bit sync type (OP_*_STYPE)
780a5a4af3bSchristos    "<" 5 bit shift amount (OP_*_SHAMT)
781a5a4af3bSchristos    ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
782a5a4af3bSchristos    "a" 26 bit target address (OP_*_TARGET)
783a5a4af3bSchristos    "+i" likewise, but flips bit 0
784a5a4af3bSchristos    "b" 5 bit base register (OP_*_RS)
785a5a4af3bSchristos    "c" 10 bit breakpoint code (OP_*_CODE)
786a5a4af3bSchristos    "d" 5 bit destination register specifier (OP_*_RD)
787a5a4af3bSchristos    "h" 5 bit prefx hint (OP_*_PREFX)
788a5a4af3bSchristos    "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
789a5a4af3bSchristos    "j" 16 bit signed immediate (OP_*_DELTA)
790a5a4af3bSchristos    "k" 5 bit cache opcode in target register position (OP_*_CACHE)
791a5a4af3bSchristos    "o" 16 bit signed offset (OP_*_DELTA)
792a5a4af3bSchristos    "p" 16 bit PC relative branch target address (OP_*_DELTA)
793a5a4af3bSchristos    "q" 10 bit extra breakpoint code (OP_*_CODE2)
794a5a4af3bSchristos    "r" 5 bit same register used as both source and target (OP_*_RS)
795a5a4af3bSchristos    "s" 5 bit source register specifier (OP_*_RS)
796a5a4af3bSchristos    "t" 5 bit target register (OP_*_RT)
797a5a4af3bSchristos    "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
798a5a4af3bSchristos    "v" 5 bit same register used as both source and destination (OP_*_RS)
799a5a4af3bSchristos    "w" 5 bit same register used as both target and destination (OP_*_RT)
800a5a4af3bSchristos    "U" 5 bit same destination register in both OP_*_RD and OP_*_RT
801a5a4af3bSchristos        (used by clo and clz)
802a5a4af3bSchristos    "C" 25 bit coprocessor function code (OP_*_COPZ)
803a5a4af3bSchristos    "B" 20 bit syscall/breakpoint function code (OP_*_CODE20)
804a5a4af3bSchristos    "J" 19 bit wait function code (OP_*_CODE19)
805a5a4af3bSchristos    "x" accept and ignore register name
806a5a4af3bSchristos    "z" must be zero register
807a5a4af3bSchristos    "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD)
808a5a4af3bSchristos    "+A" 5 bit ins/ext/dins/dext/dinsm/dextm position, which becomes
809a5a4af3bSchristos         LSB (OP_*_SHAMT; OP_*_EXTLSB or OP_*_STYPE may be used for
810a5a4af3bSchristos         microMIPS compatibility).
811a5a4af3bSchristos 	Enforces: 0 <= pos < 32.
812a5a4af3bSchristos    "+B" 5 bit ins/dins size, which becomes MSB (OP_*_INSMSB).
813a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
814a5a4af3bSchristos 	Enforces: 0 < (pos+size) <= 32.
815a5a4af3bSchristos    "+C" 5 bit ext/dext size, which becomes MSBD (OP_*_EXTMSBD).
816a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
817a5a4af3bSchristos 	Enforces: 0 < (pos+size) <= 32.
818a5a4af3bSchristos 	(Also used by "dext" w/ different limits, but limits for
819a5a4af3bSchristos 	that are checked by the M_DEXT macro.)
820a5a4af3bSchristos    "+E" 5 bit dinsu/dextu position, which becomes LSB-32 (OP_*_SHAMT).
821a5a4af3bSchristos 	Enforces: 32 <= pos < 64.
822a5a4af3bSchristos    "+F" 5 bit "dinsm/dinsu" size, which becomes MSB-32 (OP_*_INSMSB).
823a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
824a5a4af3bSchristos 	Enforces: 32 < (pos+size) <= 64.
825a5a4af3bSchristos    "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD).
826a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
827a5a4af3bSchristos 	Enforces: 32 < (pos+size) <= 64.
828a5a4af3bSchristos    "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD).
829a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
830a5a4af3bSchristos 	Enforces: 32 < (pos+size) <= 64.
831a5a4af3bSchristos 
832a5a4af3bSchristos    Floating point instructions:
833a5a4af3bSchristos    "D" 5 bit destination register (OP_*_FD)
834a5a4af3bSchristos    "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
835a5a4af3bSchristos    "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
836a5a4af3bSchristos    "S" 5 bit fs source 1 register (OP_*_FS)
837a5a4af3bSchristos    "T" 5 bit ft source 2 register (OP_*_FT)
838a5a4af3bSchristos    "R" 5 bit fr source 3 register (OP_*_FR)
839a5a4af3bSchristos    "V" 5 bit same register used as floating source and destination (OP_*_FS)
840a5a4af3bSchristos    "W" 5 bit same register used as floating target and destination (OP_*_FT)
841a5a4af3bSchristos 
842a5a4af3bSchristos    Coprocessor instructions:
843a5a4af3bSchristos    "E" 5 bit target register (OP_*_RT)
844a5a4af3bSchristos    "G" 5 bit destination register (OP_*_RD)
845a5a4af3bSchristos    "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL)
846a5a4af3bSchristos    "P" 5 bit performance-monitor register (OP_*_PERFREG)
847a5a4af3bSchristos    "e" 5 bit vector register byte specifier (OP_*_VECBYTE)
848*8b657b07Schristos    "g" 5 bit control destination register (OP_*_RD)
849a5a4af3bSchristos    "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN)
850a5a4af3bSchristos 
851a5a4af3bSchristos    Macro instructions:
852a5a4af3bSchristos    "A" General 32 bit expression
853a5a4af3bSchristos    "I" 32 bit immediate (value placed in imm_expr).
854a5a4af3bSchristos    "F" 64 bit floating point constant in .rdata
855a5a4af3bSchristos    "L" 64 bit floating point constant in .lit8
856a5a4af3bSchristos    "f" 32 bit floating point constant
857a5a4af3bSchristos    "l" 32 bit floating point constant in .lit4
858a5a4af3bSchristos 
859a5a4af3bSchristos    MDMX and VR5400 instruction operands (note that while these use the
860a5a4af3bSchristos    FP register fields, the MDMX instructions accept both $fN and $vN names
861a5a4af3bSchristos    for the registers):
862a5a4af3bSchristos    "O"	alignment offset (OP_*_ALN)
863a5a4af3bSchristos    "Q"	vector/scalar/immediate source (OP_*_VSEL and OP_*_FT)
864a5a4af3bSchristos    "X"	destination register (OP_*_FD)
865a5a4af3bSchristos    "Y"	source register (OP_*_FS)
866a5a4af3bSchristos    "Z"	source register (OP_*_FT)
867a5a4af3bSchristos 
868a5a4af3bSchristos    R5900 VU0 Macromode instructions:
869a5a4af3bSchristos    "+5" 5 bit floating point register (FD)
870a5a4af3bSchristos    "+6" 5 bit floating point register (FS)
871a5a4af3bSchristos    "+7" 5 bit floating point register (FT)
872a5a4af3bSchristos    "+8" 5 bit integer register (FD)
873a5a4af3bSchristos    "+9" 5 bit integer register (FS)
874a5a4af3bSchristos    "+0" 5 bit integer register (FT)
875a5a4af3bSchristos    "+K" match an existing 4-bit channel mask starting at bit 21
876a5a4af3bSchristos    "+L" 2-bit channel index starting at bit 21
877a5a4af3bSchristos    "+M" 2-bit channel index starting at bit 23
878a5a4af3bSchristos    "+N" match an existing 2-bit channel index starting at bit 0
879a5a4af3bSchristos    "+f" 15 bit immediate for VCALLMS
880a5a4af3bSchristos    "+g" 5 bit signed immediate for VIADDI
881a5a4af3bSchristos    "+m" $ACC register (syntax only)
882a5a4af3bSchristos    "+q" $Q register (syntax only)
883a5a4af3bSchristos    "+r" $R register (syntax only)
884a5a4af3bSchristos    "+y" $I register (syntax only)
885a5a4af3bSchristos    "#+" "++" decorator in ($reg++) sequence
886a5a4af3bSchristos    "#-" "--" decorator in (--$reg) sequence
887a5a4af3bSchristos 
888a5a4af3bSchristos    DSP ASE usage:
889a5a4af3bSchristos    "2" 2 bit unsigned immediate for byte align (OP_*_BP)
890a5a4af3bSchristos    "3" 3 bit unsigned immediate (OP_*_SA3)
891a5a4af3bSchristos    "4" 4 bit unsigned immediate (OP_*_SA4)
892a5a4af3bSchristos    "5" 8 bit unsigned immediate (OP_*_IMM8)
893a5a4af3bSchristos    "6" 5 bit unsigned immediate (OP_*_RS)
894a5a4af3bSchristos    "7" 2 bit dsp accumulator register (OP_*_DSPACC)
895a5a4af3bSchristos    "8" 6 bit unsigned immediate (OP_*_WRDSP)
896a5a4af3bSchristos    "9" 2 bit dsp accumulator register (OP_*_DSPACC_S)
897a5a4af3bSchristos    "0" 6 bit signed immediate (OP_*_DSPSFT)
898a5a4af3bSchristos    ":" 7 bit signed immediate (OP_*_DSPSFT_7)
899a5a4af3bSchristos    "'" 6 bit unsigned immediate (OP_*_RDDSP)
900a5a4af3bSchristos    "@" 10 bit signed immediate (OP_*_IMM10)
901a5a4af3bSchristos 
902a5a4af3bSchristos    MT ASE usage:
903a5a4af3bSchristos    "!" 1 bit usermode flag (OP_*_MT_U)
904a5a4af3bSchristos    "$" 1 bit load high flag (OP_*_MT_H)
905a5a4af3bSchristos    "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T)
906a5a4af3bSchristos    "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D)
907*8b657b07Schristos    "y" 5 bit control target register (OP_*_RT)
908a5a4af3bSchristos    "+t" 5 bit coprocessor 0 destination register (OP_*_RT)
909a5a4af3bSchristos 
910a5a4af3bSchristos    MCU ASE usage:
911a5a4af3bSchristos    "~" 12 bit offset (OP_*_OFFSET12)
912a5a4af3bSchristos    "\" 3 bit position for aset and aclr (OP_*_3BITPOS)
913a5a4af3bSchristos 
914a5a4af3bSchristos    VIRT ASE usage:
915a5a4af3bSchristos    "+J" 10-bit hypcall code (OP_*CODE10)
916a5a4af3bSchristos 
917a5a4af3bSchristos    UDI immediates:
918a5a4af3bSchristos    "+1" UDI immediate bits 6-10
919a5a4af3bSchristos    "+2" UDI immediate bits 6-15
920a5a4af3bSchristos    "+3" UDI immediate bits 6-20
921a5a4af3bSchristos    "+4" UDI immediate bits 6-25
922a5a4af3bSchristos 
923a5a4af3bSchristos    Octeon:
924a5a4af3bSchristos    "+x" Bit index field of bbit.  Enforces: 0 <= index < 32.
925a5a4af3bSchristos    "+X" Bit index field of bbit aliasing bbit32.  Matches if 32 <= index < 64,
926a5a4af3bSchristos 	otherwise skips to next candidate.
927a5a4af3bSchristos    "+p" Position field of cins/cins32/exts/exts32. Enforces 0 <= pos < 32.
928a5a4af3bSchristos    "+P" Position field of cins/exts aliasing cins32/exts32.  Matches if
929a5a4af3bSchristos 	32 <= pos < 64, otherwise skips to next candidate.
930a5a4af3bSchristos    "+Q" Immediate field of seqi/snei.  Enforces -512 <= imm < 512.
931a5a4af3bSchristos    "+s" Length-minus-one field of cins32/exts32.  Requires msb position
932a5a4af3bSchristos 	of the field to be <= 31.
933a5a4af3bSchristos    "+S" Length-minus-one field of cins/exts.  Requires msb position
934a5a4af3bSchristos 	of the field to be <= 63.
935a5a4af3bSchristos 
93647c37bc2Schristos    Loongson-ext ASE:
937a5a4af3bSchristos    "+a" 8-bit signed offset in bit 6 (OP_*_OFFSET_A)
938a5a4af3bSchristos    "+b" 8-bit signed offset in bit 3 (OP_*_OFFSET_B)
939a5a4af3bSchristos    "+c" 9-bit signed offset in bit 6 (OP_*_OFFSET_C)
940a5a4af3bSchristos    "+z" 5-bit rz register (OP_*_RZ)
941a5a4af3bSchristos    "+Z" 5-bit fz register (OP_*_FZ)
942a5a4af3bSchristos 
94347c37bc2Schristos    interAptiv MR2:
94447c37bc2Schristos    "-m" register list for SAVE/RESTORE instruction
94547c37bc2Schristos 
946a5a4af3bSchristos    Enhanced VA Scheme:
947a5a4af3bSchristos    "+j" 9-bit signed offset in bit 7 (OP_*_EVAOFFSET)
948a5a4af3bSchristos 
949a5a4af3bSchristos    MSA Extension:
950a5a4af3bSchristos    "+d" 5-bit MSA register (FD)
951a5a4af3bSchristos    "+e" 5-bit MSA register (FS)
952a5a4af3bSchristos    "+h" 5-bit MSA register (FT)
953a5a4af3bSchristos    "+k" 5-bit GPR at bit 6
954a5a4af3bSchristos    "+l" 5-bit MSA control register at bit 6
955a5a4af3bSchristos    "+n" 5-bit MSA control register at bit 11
956a5a4af3bSchristos    "+o" 4-bit vector element index at bit 16
957a5a4af3bSchristos    "+u" 3-bit vector element index at bit 16
958a5a4af3bSchristos    "+v" 2-bit vector element index at bit 16
959a5a4af3bSchristos    "+w" 1-bit vector element index at bit 16
960a5a4af3bSchristos    "+T" (-512 .. 511) << 0 at bit 16
961a5a4af3bSchristos    "+U" (-512 .. 511) << 1 at bit 16
962a5a4af3bSchristos    "+V" (-512 .. 511) << 2 at bit 16
963a5a4af3bSchristos    "+W" (-512 .. 511) << 3 at bit 16
964a5a4af3bSchristos    "+~" 2 bit LSA/DLSA shift amount from 1 to 4 at bit 6
965a5a4af3bSchristos    "+!" 3 bit unsigned bit position at bit 16
966a5a4af3bSchristos    "+@" 4 bit unsigned bit position at bit 16
967a5a4af3bSchristos    "+#" 6 bit unsigned bit position at bit 16
968a5a4af3bSchristos    "+$" 5 bit unsigned immediate at bit 16
969a5a4af3bSchristos    "+%" 5 bit signed immediate at bit 16
970a5a4af3bSchristos    "+^" 10 bit signed immediate at bit 11
971a5a4af3bSchristos    "+&" 0 vector element index
972a5a4af3bSchristos    "+*" 5-bit register vector element index at bit 16
973a5a4af3bSchristos    "+|" 8-bit mask at bit 16
974a5a4af3bSchristos 
975a5a4af3bSchristos    MIPS R6:
976a5a4af3bSchristos    "+:" 11-bit mask at bit 0
977a5a4af3bSchristos    "+'" 26 bit PC relative branch target address
978a5a4af3bSchristos    "+"" 21 bit PC relative branch target address
979a5a4af3bSchristos    "+;" 5 bit same register in both OP_*_RS and OP_*_RT
980a5a4af3bSchristos    "+I" 2bit unsigned bit position at bit 6
981a5a4af3bSchristos    "+O" 3bit unsigned bit position at bit 6
982a5a4af3bSchristos    "+R" must be program counter
983a5a4af3bSchristos    "-a" (-262144 .. 262143) << 2 at bit 0
984a5a4af3bSchristos    "-b" (-131072 .. 131071) << 3 at bit 0
985a5a4af3bSchristos    "-d" Same as destination register GP
986a5a4af3bSchristos    "-s" 5 bit source register specifier (OP_*_RS) not $0
987a5a4af3bSchristos    "-t" 5 bit source register specifier (OP_*_RT) not $0
988a5a4af3bSchristos    "-u" 5 bit source register specifier (OP_*_RT) greater than OP_*_RS
989a5a4af3bSchristos    "-v" 5 bit source register specifier (OP_*_RT) not $0 not OP_*_RS
990a5a4af3bSchristos    "-w" 5 bit source register specifier (OP_*_RT) less than or equal to OP_*_RS
991a5a4af3bSchristos    "-x" 5 bit source register specifier (OP_*_RT) greater than or
992a5a4af3bSchristos         equal to OP_*_RS
993a5a4af3bSchristos    "-y" 5 bit source register specifier (OP_*_RT) not $0 less than OP_*_RS
994a5a4af3bSchristos    "-A" symbolic offset (-262144 .. 262143) << 2 at bit 0
995a5a4af3bSchristos    "-B" symbolic offset (-131072 .. 131071) << 3 at bit 0
996a5a4af3bSchristos 
99747c37bc2Schristos    GINV ASE usage:
99847c37bc2Schristos    "+\" 2 bit Global TLB invalidate type at bit 8
99947c37bc2Schristos 
1000a5a4af3bSchristos    Other:
1001a5a4af3bSchristos    "()" parens surrounding optional value
1002a5a4af3bSchristos    ","  separates operands
1003a5a4af3bSchristos    "+"  Start of extension sequence.
1004a5a4af3bSchristos 
1005a5a4af3bSchristos    Characters used so far, for quick reference when adding more:
1006a5a4af3bSchristos    "1234567890"
1007a5a4af3bSchristos    "%[]<>(),+-:'@!#$*&\~"
1008a5a4af3bSchristos    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1009*8b657b07Schristos    "abcdef hijkl  opqrstuvwxyz"
1010a5a4af3bSchristos 
1011a5a4af3bSchristos    Extension character sequences used so far ("+" followed by the
1012a5a4af3bSchristos    following), for quick reference when adding more:
1013a5a4af3bSchristos    "1234567890"
101447c37bc2Schristos    "~!@#$%^&*|:'";\"
1015a5a4af3bSchristos    "ABCEFGHIJKLMNOPQRSTUVWXZ"
1016a5a4af3bSchristos    "abcdefghijklmnopqrstuvwxyz"
1017a5a4af3bSchristos 
1018a5a4af3bSchristos    Extension character sequences used so far ("-" followed by the
1019a5a4af3bSchristos    following), for quick reference when adding more:
1020a5a4af3bSchristos    "AB"
102147c37bc2Schristos    "abdmstuvwxy"
1022a5a4af3bSchristos */
1023a5a4af3bSchristos 
1024a5a4af3bSchristos /* These are the bits which may be set in the pinfo field of an
1025a5a4af3bSchristos    instructions, if it is not equal to INSN_MACRO.  */
1026a5a4af3bSchristos 
1027a5a4af3bSchristos /* Writes to operand number N.  */
1028a5a4af3bSchristos #define INSN_WRITE_SHIFT            0
1029a5a4af3bSchristos #define INSN_WRITE_1                0x00000001
1030a5a4af3bSchristos #define INSN_WRITE_2                0x00000002
1031a5a4af3bSchristos #define INSN_WRITE_ALL              0x00000003
1032a5a4af3bSchristos /* Reads from operand number N.  */
1033a5a4af3bSchristos #define INSN_READ_SHIFT             2
1034a5a4af3bSchristos #define INSN_READ_1                 0x00000004
1035a5a4af3bSchristos #define INSN_READ_2                 0x00000008
1036a5a4af3bSchristos #define INSN_READ_3                 0x00000010
1037a5a4af3bSchristos #define INSN_READ_4                 0x00000020
1038a5a4af3bSchristos #define INSN_READ_ALL               0x0000003c
1039a5a4af3bSchristos /* Modifies general purpose register 31.  */
1040a5a4af3bSchristos #define INSN_WRITE_GPR_31           0x00000040
1041a5a4af3bSchristos /* Modifies coprocessor condition code.  */
1042a5a4af3bSchristos #define INSN_WRITE_COND_CODE        0x00000080
1043a5a4af3bSchristos /* Reads coprocessor condition code.  */
1044a5a4af3bSchristos #define INSN_READ_COND_CODE         0x00000100
1045a5a4af3bSchristos /* TLB operation.  */
1046a5a4af3bSchristos #define INSN_TLB                    0x00000200
1047a5a4af3bSchristos /* Reads coprocessor register other than floating point register.  */
1048a5a4af3bSchristos #define INSN_COP                    0x00000400
1049a5a4af3bSchristos /* Instruction loads value from memory.  */
1050a5a4af3bSchristos #define INSN_LOAD_MEMORY	    0x00000800
1051a5a4af3bSchristos /* Instruction loads value from coprocessor, (may require delay).  */
1052a5a4af3bSchristos #define INSN_LOAD_COPROC	    0x00001000
1053a5a4af3bSchristos /* Instruction has unconditional branch delay slot.  */
1054a5a4af3bSchristos #define INSN_UNCOND_BRANCH_DELAY    0x00002000
1055a5a4af3bSchristos /* Instruction has conditional branch delay slot.  */
1056a5a4af3bSchristos #define INSN_COND_BRANCH_DELAY      0x00004000
1057a5a4af3bSchristos /* Conditional branch likely: if branch not taken, insn nullified.  */
1058a5a4af3bSchristos #define INSN_COND_BRANCH_LIKELY	    0x00008000
1059a5a4af3bSchristos /* Moves to coprocessor register, (may require delay).  */
1060a5a4af3bSchristos #define INSN_COPROC_MOVE            0x00010000
1061a5a4af3bSchristos /* Loads coprocessor register from memory, requiring delay.  */
1062a5a4af3bSchristos #define INSN_COPROC_MEMORY_DELAY    0x00020000
1063a5a4af3bSchristos /* Reads the HI register.  */
1064a5a4af3bSchristos #define INSN_READ_HI		    0x00040000
1065a5a4af3bSchristos /* Reads the LO register.  */
1066a5a4af3bSchristos #define INSN_READ_LO		    0x00080000
1067a5a4af3bSchristos /* Modifies the HI register.  */
1068a5a4af3bSchristos #define INSN_WRITE_HI		    0x00100000
1069a5a4af3bSchristos /* Modifies the LO register.  */
1070a5a4af3bSchristos #define INSN_WRITE_LO		    0x00200000
1071a5a4af3bSchristos /* Not to be placed in a branch delay slot, either architecturally
1072a5a4af3bSchristos    or for ease of handling (such as with instructions that take a trap).  */
1073a5a4af3bSchristos #define INSN_NO_DELAY_SLOT	    0x00400000
1074a5a4af3bSchristos /* Instruction stores value into memory.  */
1075a5a4af3bSchristos #define INSN_STORE_MEMORY	    0x00800000
1076a5a4af3bSchristos /* Instruction uses single precision floating point.  */
1077a5a4af3bSchristos #define FP_S			    0x01000000
1078a5a4af3bSchristos /* Instruction uses double precision floating point.  */
1079a5a4af3bSchristos #define FP_D			    0x02000000
1080a5a4af3bSchristos /* Instruction is part of the tx39's integer multiply family.    */
1081a5a4af3bSchristos #define INSN_MULT                   0x04000000
1082a5a4af3bSchristos /* Reads general purpose register 24.  */
1083a5a4af3bSchristos #define INSN_READ_GPR_24            0x08000000
1084a5a4af3bSchristos /* Writes to general purpose register 24.  */
1085a5a4af3bSchristos #define INSN_WRITE_GPR_24           0x10000000
1086a5a4af3bSchristos /* A user-defined instruction.  */
1087a5a4af3bSchristos #define INSN_UDI                    0x20000000
1088a5a4af3bSchristos /* Instruction is actually a macro.  It should be ignored by the
1089a5a4af3bSchristos    disassembler, and requires special treatment by the assembler.  */
1090a5a4af3bSchristos #define INSN_MACRO                  0xffffffff
1091a5a4af3bSchristos 
1092a5a4af3bSchristos /* These are the bits which may be set in the pinfo2 field of an
1093a5a4af3bSchristos    instruction. */
1094a5a4af3bSchristos 
1095a5a4af3bSchristos /* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */
1096a5a4af3bSchristos #define	INSN2_ALIAS		    0x00000001
1097a5a4af3bSchristos /* Instruction reads MDMX accumulator. */
1098a5a4af3bSchristos #define INSN2_READ_MDMX_ACC	    0x00000002
1099a5a4af3bSchristos /* Instruction writes MDMX accumulator. */
1100a5a4af3bSchristos #define INSN2_WRITE_MDMX_ACC	    0x00000004
1101a5a4af3bSchristos /* Macro uses single-precision floating-point instructions.  This should
1102a5a4af3bSchristos    only be set for macros.  For instructions, FP_S in pinfo carries the
1103a5a4af3bSchristos    same information.  */
1104a5a4af3bSchristos #define INSN2_M_FP_S		    0x00000008
1105a5a4af3bSchristos /* Macro uses double-precision floating-point instructions.  This should
1106a5a4af3bSchristos    only be set for macros.  For instructions, FP_D in pinfo carries the
1107a5a4af3bSchristos    same information.  */
1108a5a4af3bSchristos #define INSN2_M_FP_D		    0x00000010
1109a5a4af3bSchristos /* Instruction has a branch delay slot that requires a 16-bit instruction.  */
1110a5a4af3bSchristos #define INSN2_BRANCH_DELAY_16BIT    0x00000020
1111a5a4af3bSchristos /* Instruction has a branch delay slot that requires a 32-bit instruction.  */
1112a5a4af3bSchristos #define INSN2_BRANCH_DELAY_32BIT    0x00000040
1113a5a4af3bSchristos /* Writes to the stack pointer ($29).  */
1114a5a4af3bSchristos #define INSN2_WRITE_SP		    0x00000080
1115a5a4af3bSchristos /* Reads from the stack pointer ($29).  */
1116a5a4af3bSchristos #define INSN2_READ_SP		    0x00000100
1117a5a4af3bSchristos /* Reads the RA ($31) register.  */
1118a5a4af3bSchristos #define INSN2_READ_GPR_31	    0x00000200
1119a5a4af3bSchristos /* Reads the program counter ($pc).  */
1120a5a4af3bSchristos #define INSN2_READ_PC		    0x00000400
1121a5a4af3bSchristos /* Is an unconditional branch insn. */
1122a5a4af3bSchristos #define INSN2_UNCOND_BRANCH	    0x00000800
1123a5a4af3bSchristos /* Is a conditional branch insn. */
1124a5a4af3bSchristos #define INSN2_COND_BRANCH	    0x00001000
1125a5a4af3bSchristos /* Reads from $16.  This is true of the MIPS16 0x6500 nop.  */
1126a5a4af3bSchristos #define INSN2_READ_GPR_16           0x00002000
1127a5a4af3bSchristos /* Has an "\.x?y?z?w?" suffix based on mips_vu0_channel_mask.  */
1128a5a4af3bSchristos #define INSN2_VU0_CHANNEL_SUFFIX    0x00004000
1129a5a4af3bSchristos /* Instruction has a forbidden slot.  */
1130a5a4af3bSchristos #define INSN2_FORBIDDEN_SLOT        0x00008000
113199e23f81Schristos /* Opcode table entry is for a short MIPS16 form only.  An extended
113299e23f81Schristos    encoding may still exist, but with a separate opcode table entry
113347c37bc2Schristos    required.  In disassembly the presence of this flag in an otherwise
113447c37bc2Schristos    successful match against an extended instruction encoding inhibits
113547c37bc2Schristos    matching against any subsequent short table entry even if it does
113647c37bc2Schristos    not have this flag set.  A table entry matching the full extended
113747c37bc2Schristos    encoding is needed or otherwise the final EXTEND entry will apply,
113847c37bc2Schristos    for the disassembly of the prefix only.  */
113999e23f81Schristos #define INSN2_SHORT_ONLY	    0x00010000
1140a5a4af3bSchristos 
1141a5a4af3bSchristos /* Masks used to mark instructions to indicate which MIPS ISA level
1142a5a4af3bSchristos    they were introduced in.  INSN_ISA_MASK masks an enumeration that
1143a5a4af3bSchristos    specifies the base ISA level(s).  The remainder of a 32-bit
1144a5a4af3bSchristos    word constructed using these macros is a bitmask of the remaining
1145a5a4af3bSchristos    INSN_* values below.  */
1146a5a4af3bSchristos 
1147a5a4af3bSchristos #define INSN_ISA_MASK		  0x0000001ful
1148a5a4af3bSchristos 
1149a5a4af3bSchristos /* We cannot start at zero due to ISA_UNKNOWN below.  */
1150a5a4af3bSchristos #define INSN_ISA1                 1
1151a5a4af3bSchristos #define INSN_ISA2                 2
1152a5a4af3bSchristos #define INSN_ISA3                 3
1153a5a4af3bSchristos #define INSN_ISA4                 4
1154a5a4af3bSchristos #define INSN_ISA5                 5
1155a5a4af3bSchristos #define INSN_ISA32                6
1156a5a4af3bSchristos #define INSN_ISA32R2              7
1157a5a4af3bSchristos #define INSN_ISA32R3              8
1158a5a4af3bSchristos #define INSN_ISA32R5              9
1159a5a4af3bSchristos #define INSN_ISA32R6              10
1160a5a4af3bSchristos #define INSN_ISA64                11
1161a5a4af3bSchristos #define INSN_ISA64R2              12
1162a5a4af3bSchristos #define INSN_ISA64R3              13
1163a5a4af3bSchristos #define INSN_ISA64R5              14
1164a5a4af3bSchristos #define INSN_ISA64R6              15
1165a5a4af3bSchristos /* Below this point the INSN_* values correspond to combinations of ISAs.
1166a5a4af3bSchristos    They are only for use in the opcodes table to indicate membership of
1167a5a4af3bSchristos    a combination of ISAs that cannot be expressed using the usual inclusion
1168a5a4af3bSchristos    ordering on the above INSN_* values.  */
1169a5a4af3bSchristos #define INSN_ISA3_32              16
1170a5a4af3bSchristos #define INSN_ISA3_32R2            17
1171a5a4af3bSchristos #define INSN_ISA4_32              18
1172a5a4af3bSchristos #define INSN_ISA4_32R2            19
1173a5a4af3bSchristos #define INSN_ISA5_32R2            20
1174a5a4af3bSchristos 
1175a5a4af3bSchristos /* The R6 definitions shown below state that they support all previous ISAs.
1176a5a4af3bSchristos    This is not actually true as some instructions are removed in R6.
1177a5a4af3bSchristos    The problem is that the removed instructions in R6 come from different
1178a5a4af3bSchristos    ISAs.  One approach to solve this would be to describe in the membership
1179a5a4af3bSchristos    field of the opcode table the different ISAs an instruction belongs to.
1180a5a4af3bSchristos    This would require us to create a large amount of different ISA
1181a5a4af3bSchristos    combinations which is hard to manage.  A cleaner approach (which is
1182a5a4af3bSchristos    implemented here) is to say that R6 is an extension of R5 and then to
1183a5a4af3bSchristos    deal with the removed instructions by adding instruction exclusions
1184a5a4af3bSchristos    for R6 in the opcode table.  */
1185a5a4af3bSchristos 
1186a5a4af3bSchristos /* Bit INSN_ISA<X> - 1 of INSN_UPTO<Y> is set if ISA Y includes ISA X.  */
1187a5a4af3bSchristos 
1188a5a4af3bSchristos #define ISAF(X) (1 << (INSN_ISA##X - 1))
1189a5a4af3bSchristos #define INSN_UPTO1    ISAF(1)
1190a5a4af3bSchristos #define INSN_UPTO2    INSN_UPTO1 | ISAF(2)
1191a5a4af3bSchristos #define INSN_UPTO3    INSN_UPTO2 | ISAF(3) | ISAF(3_32) | ISAF(3_32R2)
1192a5a4af3bSchristos #define INSN_UPTO4    INSN_UPTO3 | ISAF(4) | ISAF(4_32) | ISAF(4_32R2)
1193a5a4af3bSchristos #define INSN_UPTO5    INSN_UPTO4 | ISAF(5) | ISAF(5_32R2)
1194a5a4af3bSchristos #define INSN_UPTO32   INSN_UPTO2 | ISAF(32) | ISAF(3_32) | ISAF(4_32)
1195a5a4af3bSchristos #define INSN_UPTO32R2 INSN_UPTO32 | ISAF(32R2) \
1196a5a4af3bSchristos 			| ISAF(3_32R2) | ISAF(4_32R2) | ISAF(5_32R2)
1197a5a4af3bSchristos #define INSN_UPTO32R3 INSN_UPTO32R2 | ISAF(32R3)
1198a5a4af3bSchristos #define INSN_UPTO32R5 INSN_UPTO32R3 | ISAF(32R5)
1199a5a4af3bSchristos #define INSN_UPTO32R6 INSN_UPTO32R5 | ISAF(32R6)
1200a5a4af3bSchristos #define INSN_UPTO64   INSN_UPTO5 | ISAF(64) | ISAF(32)
1201a5a4af3bSchristos #define INSN_UPTO64R2 INSN_UPTO64 | ISAF(64R2) | ISAF(32R2)
1202a5a4af3bSchristos #define INSN_UPTO64R3 INSN_UPTO64R2 | ISAF(64R3) | ISAF(32R3)
1203a5a4af3bSchristos #define INSN_UPTO64R5 INSN_UPTO64R3 | ISAF(64R5) | ISAF(32R5)
1204a5a4af3bSchristos #define INSN_UPTO64R6 INSN_UPTO64R5 | ISAF(64R6) | ISAF(32R6)
1205a5a4af3bSchristos 
1206a5a4af3bSchristos /* The same information in table form: bit INSN_ISA<X> - 1 of index
1207a5a4af3bSchristos    INSN_UPTO<Y> - 1 is set if ISA Y includes ISA X.  */
1208a5a4af3bSchristos static const unsigned int mips_isa_table[] = {
1209a5a4af3bSchristos   INSN_UPTO1,
1210a5a4af3bSchristos   INSN_UPTO2,
1211a5a4af3bSchristos   INSN_UPTO3,
1212a5a4af3bSchristos   INSN_UPTO4,
1213a5a4af3bSchristos   INSN_UPTO5,
1214a5a4af3bSchristos   INSN_UPTO32,
1215a5a4af3bSchristos   INSN_UPTO32R2,
1216a5a4af3bSchristos   INSN_UPTO32R3,
1217a5a4af3bSchristos   INSN_UPTO32R5,
1218a5a4af3bSchristos   INSN_UPTO32R6,
1219a5a4af3bSchristos   INSN_UPTO64,
1220a5a4af3bSchristos   INSN_UPTO64R2,
1221a5a4af3bSchristos   INSN_UPTO64R3,
1222a5a4af3bSchristos   INSN_UPTO64R5,
1223a5a4af3bSchristos   INSN_UPTO64R6
1224a5a4af3bSchristos };
1225a5a4af3bSchristos #undef ISAF
1226a5a4af3bSchristos 
1227a5a4af3bSchristos /* Masks used for Chip specific instructions.  */
122847c37bc2Schristos #define INSN_CHIP_MASK		  0xc7ff4f60
1229a5a4af3bSchristos 
1230a5a4af3bSchristos /* Cavium Networks Octeon instructions.  */
1231a5a4af3bSchristos #define INSN_OCTEON		  0x00000800
1232a5a4af3bSchristos #define INSN_OCTEONP		  0x00000200
1233a5a4af3bSchristos #define INSN_OCTEON2		  0x00000100
1234a5a4af3bSchristos #define INSN_OCTEON3		  0x00000040
1235a5a4af3bSchristos 
1236a5a4af3bSchristos /* MIPS R5900 instruction */
1237a5a4af3bSchristos #define INSN_5900                 0x00004000
1238a5a4af3bSchristos 
1239a5a4af3bSchristos /* MIPS R4650 instruction.  */
1240a5a4af3bSchristos #define INSN_4650                 0x00010000
1241a5a4af3bSchristos /* LSI R4010 instruction.  */
1242a5a4af3bSchristos #define INSN_4010                 0x00020000
1243a5a4af3bSchristos /* NEC VR4100 instruction.  */
1244a5a4af3bSchristos #define INSN_4100                 0x00040000
1245a5a4af3bSchristos /* Toshiba R3900 instruction.  */
1246a5a4af3bSchristos #define INSN_3900                 0x00080000
1247a5a4af3bSchristos /* MIPS R10000 instruction.  */
1248a5a4af3bSchristos #define INSN_10000                0x00100000
1249a5a4af3bSchristos /* Broadcom SB-1 instruction.  */
1250a5a4af3bSchristos #define INSN_SB1                  0x00200000
1251a5a4af3bSchristos /* NEC VR4111/VR4181 instruction.  */
1252a5a4af3bSchristos #define INSN_4111                 0x00400000
1253a5a4af3bSchristos /* NEC VR4120 instruction.  */
1254a5a4af3bSchristos #define INSN_4120                 0x00800000
1255a5a4af3bSchristos /* NEC VR5400 instruction.  */
1256a5a4af3bSchristos #define INSN_5400		  0x01000000
1257a5a4af3bSchristos /* NEC VR5500 instruction.  */
1258a5a4af3bSchristos #define INSN_5500		  0x02000000
1259a5a4af3bSchristos 
1260a5a4af3bSchristos /* ST Microelectronics Loongson 2E.  */
1261a5a4af3bSchristos #define INSN_LOONGSON_2E          0x40000000
1262a5a4af3bSchristos /* ST Microelectronics Loongson 2F.  */
1263a5a4af3bSchristos #define INSN_LOONGSON_2F          0x80000000
1264a5a4af3bSchristos /* RMI Xlr instruction */
1265a5a4af3bSchristos #define INSN_XLR                 0x00000020
126647c37bc2Schristos /* Imagination interAptiv MR2.  */
126747c37bc2Schristos #define INSN_INTERAPTIV_MR2	  0x04000000
1268a5a4af3bSchristos 
1269a5a4af3bSchristos /* DSP ASE */
1270a5a4af3bSchristos #define ASE_DSP			0x00000001
1271a5a4af3bSchristos #define ASE_DSP64		0x00000002
1272a5a4af3bSchristos /* DSP R2 ASE  */
1273a5a4af3bSchristos #define ASE_DSPR2		0x00000004
1274a5a4af3bSchristos /* Enhanced VA Scheme */
1275a5a4af3bSchristos #define ASE_EVA			0x00000008
1276a5a4af3bSchristos /* MCU (MicroController) ASE */
1277a5a4af3bSchristos #define ASE_MCU			0x00000010
1278a5a4af3bSchristos /* MDMX ASE */
1279a5a4af3bSchristos #define ASE_MDMX		0x00000020
1280a5a4af3bSchristos /* MIPS-3D ASE */
1281a5a4af3bSchristos #define ASE_MIPS3D		0x00000040
1282a5a4af3bSchristos /* MT ASE */
1283a5a4af3bSchristos #define ASE_MT			0x00000080
1284a5a4af3bSchristos /* SmartMIPS ASE  */
1285a5a4af3bSchristos #define ASE_SMARTMIPS		0x00000100
1286a5a4af3bSchristos /* Virtualization ASE */
1287a5a4af3bSchristos #define ASE_VIRT		0x00000200
1288a5a4af3bSchristos #define ASE_VIRT64		0x00000400
1289a5a4af3bSchristos /* MSA Extension  */
1290a5a4af3bSchristos #define ASE_MSA			0x00000800
1291a5a4af3bSchristos #define ASE_MSA64		0x00001000
1292a5a4af3bSchristos /* eXtended Physical Address (XPA) Extension.  */
1293a5a4af3bSchristos #define ASE_XPA			0x00002000
129499e23f81Schristos /* DSP R3 Module.  */
1295e5cb852cSchristos #define ASE_DSPR3		0x00004000
129647c37bc2Schristos /* MIPS16e2 ASE.  */
129747c37bc2Schristos #define ASE_MIPS16E2		0x00008000
129847c37bc2Schristos /* MIPS16e2 MT ASE instructions.  */
129947c37bc2Schristos #define ASE_MIPS16E2_MT		0x00010000
130047c37bc2Schristos /* The Virtualization ASE has eXtended Physical Addressing (XPA)
130147c37bc2Schristos    instructions which are only valid when both ASEs are enabled.  */
130247c37bc2Schristos #define ASE_XPA_VIRT		0x00020000
130347c37bc2Schristos /* Cyclic redundancy check (CRC) ASE.  */
130447c37bc2Schristos #define ASE_CRC			0x00040000
130547c37bc2Schristos #define ASE_CRC64		0x00080000
130647c37bc2Schristos /* Global INValidate Extension.  */
130747c37bc2Schristos #define ASE_GINV		0x00100000
130847c37bc2Schristos /* Loongson MultiMedia extensions Instructions (MMI).  */
130947c37bc2Schristos #define ASE_LOONGSON_MMI	0x00200000
131047c37bc2Schristos /* Loongson Content Address Memory (CAM).  */
131147c37bc2Schristos #define ASE_LOONGSON_CAM	0x00400000
131247c37bc2Schristos /* Loongson EXTensions (EXT) instructions.  */
131347c37bc2Schristos #define ASE_LOONGSON_EXT	0x00800000
131447c37bc2Schristos /* Loongson EXTensions R2 (EXT2) instructions.  */
131547c37bc2Schristos #define ASE_LOONGSON_EXT2	0x01000000
131682650ea5Schristos /* The Enhanced VA Scheme (EVA) extension has instructions which are
131782650ea5Schristos    only valid for the R6 ISA.  */
131882650ea5Schristos #define ASE_EVA_R6		0x02000000
1319a5a4af3bSchristos 
1320a5a4af3bSchristos /* MIPS ISA defines, use instead of hardcoding ISA level.  */
1321a5a4af3bSchristos 
1322a5a4af3bSchristos #define       ISA_UNKNOWN     0               /* Gas internal use.  */
1323a5a4af3bSchristos #define       ISA_MIPS1       INSN_ISA1
1324a5a4af3bSchristos #define       ISA_MIPS2       INSN_ISA2
1325a5a4af3bSchristos #define       ISA_MIPS3       INSN_ISA3
1326a5a4af3bSchristos #define       ISA_MIPS4       INSN_ISA4
1327a5a4af3bSchristos #define       ISA_MIPS5       INSN_ISA5
1328a5a4af3bSchristos 
1329a5a4af3bSchristos #define       ISA_MIPS32      INSN_ISA32
1330a5a4af3bSchristos #define       ISA_MIPS64      INSN_ISA64
1331a5a4af3bSchristos 
1332a5a4af3bSchristos #define       ISA_MIPS32R2    INSN_ISA32R2
1333a5a4af3bSchristos #define       ISA_MIPS32R3    INSN_ISA32R3
1334a5a4af3bSchristos #define       ISA_MIPS32R5    INSN_ISA32R5
1335a5a4af3bSchristos #define       ISA_MIPS64R2    INSN_ISA64R2
1336a5a4af3bSchristos #define       ISA_MIPS64R3    INSN_ISA64R3
1337a5a4af3bSchristos #define       ISA_MIPS64R5    INSN_ISA64R5
1338a5a4af3bSchristos 
1339a5a4af3bSchristos #define       ISA_MIPS32R6    INSN_ISA32R6
1340a5a4af3bSchristos #define       ISA_MIPS64R6    INSN_ISA64R6
1341a5a4af3bSchristos 
1342a5a4af3bSchristos /* CPU defines, use instead of hardcoding processor number. Keep this
1343a5a4af3bSchristos    in sync with bfd/archures.c in order for machine selection to work.  */
1344a5a4af3bSchristos #define CPU_UNKNOWN	0               /* Gas internal use.  */
1345a5a4af3bSchristos #define CPU_R3000	3000
1346a5a4af3bSchristos #define CPU_R3900	3900
1347a5a4af3bSchristos #define CPU_R4000	4000
1348a5a4af3bSchristos #define CPU_R4010	4010
1349a5a4af3bSchristos #define CPU_VR4100	4100
1350a5a4af3bSchristos #define CPU_R4111	4111
1351a5a4af3bSchristos #define CPU_VR4120	4120
1352a5a4af3bSchristos #define CPU_R4300	4300
1353a5a4af3bSchristos #define CPU_R4400	4400
1354a5a4af3bSchristos #define CPU_R4600	4600
1355a5a4af3bSchristos #define CPU_R4650	4650
1356a5a4af3bSchristos #define CPU_R5000	5000
1357a5a4af3bSchristos #define CPU_VR5400	5400
1358a5a4af3bSchristos #define CPU_VR5500	5500
1359a5a4af3bSchristos #define CPU_R5900	5900
1360a5a4af3bSchristos #define CPU_R6000	6000
1361a5a4af3bSchristos #define CPU_RM7000	7000
1362a5a4af3bSchristos #define CPU_R8000	8000
1363a5a4af3bSchristos #define CPU_RM9000	9000
1364a5a4af3bSchristos #define CPU_R10000	10000
1365a5a4af3bSchristos #define CPU_R12000	12000
1366a5a4af3bSchristos #define CPU_R14000	14000
1367a5a4af3bSchristos #define CPU_R16000	16000
1368a5a4af3bSchristos #define CPU_MIPS16	16
1369a5a4af3bSchristos #define CPU_MIPS32	32
1370a5a4af3bSchristos #define CPU_MIPS32R2	33
1371a5a4af3bSchristos #define CPU_MIPS32R3	34
1372a5a4af3bSchristos #define CPU_MIPS32R5	36
1373a5a4af3bSchristos #define CPU_MIPS32R6	37
1374a5a4af3bSchristos #define CPU_MIPS5       5
1375a5a4af3bSchristos #define CPU_MIPS64      64
1376a5a4af3bSchristos #define CPU_MIPS64R2	65
1377a5a4af3bSchristos #define CPU_MIPS64R3	66
1378a5a4af3bSchristos #define CPU_MIPS64R5	68
1379a5a4af3bSchristos #define CPU_MIPS64R6	69
1380a5a4af3bSchristos #define CPU_SB1         12310201        /* octal 'SB', 01.  */
1381a5a4af3bSchristos #define CPU_LOONGSON_2E 3001
1382a5a4af3bSchristos #define CPU_LOONGSON_2F 3002
138347c37bc2Schristos #define CPU_GS464	3003
138447c37bc2Schristos #define CPU_GS464E	3004
138547c37bc2Schristos #define CPU_GS264E	3005
1386a5a4af3bSchristos #define CPU_OCTEON	6501
1387a5a4af3bSchristos #define CPU_OCTEONP	6601
1388a5a4af3bSchristos #define CPU_OCTEON2	6502
1389a5a4af3bSchristos #define CPU_OCTEON3	6503
1390a5a4af3bSchristos #define CPU_XLR     	887682   	/* decimal 'XLR'   */
139147c37bc2Schristos #define CPU_INTERAPTIV_MR2 736550	/* decimal 'IA2'  */
1392a5a4af3bSchristos 
1393a5a4af3bSchristos /* Return true if the given CPU is included in INSN_* mask MASK.  */
1394a5a4af3bSchristos 
1395*8b657b07Schristos static inline bool
1396a5a4af3bSchristos cpu_is_member (int cpu, unsigned int mask)
1397a5a4af3bSchristos {
1398a5a4af3bSchristos   switch (cpu)
1399a5a4af3bSchristos     {
1400a5a4af3bSchristos     case CPU_R4650:
1401a5a4af3bSchristos     case CPU_RM7000:
1402a5a4af3bSchristos     case CPU_RM9000:
1403a5a4af3bSchristos       return (mask & INSN_4650) != 0;
1404a5a4af3bSchristos 
1405a5a4af3bSchristos     case CPU_R4010:
1406a5a4af3bSchristos       return (mask & INSN_4010) != 0;
1407a5a4af3bSchristos 
1408a5a4af3bSchristos     case CPU_VR4100:
1409a5a4af3bSchristos       return (mask & INSN_4100) != 0;
1410a5a4af3bSchristos 
1411a5a4af3bSchristos     case CPU_R3900:
1412a5a4af3bSchristos       return (mask & INSN_3900) != 0;
1413a5a4af3bSchristos 
1414a5a4af3bSchristos     case CPU_R10000:
1415a5a4af3bSchristos     case CPU_R12000:
1416a5a4af3bSchristos     case CPU_R14000:
1417a5a4af3bSchristos     case CPU_R16000:
1418a5a4af3bSchristos       return (mask & INSN_10000) != 0;
1419a5a4af3bSchristos 
1420a5a4af3bSchristos     case CPU_SB1:
1421a5a4af3bSchristos       return (mask & INSN_SB1) != 0;
1422a5a4af3bSchristos 
1423a5a4af3bSchristos     case CPU_R4111:
1424a5a4af3bSchristos       return (mask & INSN_4111) != 0;
1425a5a4af3bSchristos 
1426a5a4af3bSchristos     case CPU_VR4120:
1427a5a4af3bSchristos       return (mask & INSN_4120) != 0;
1428a5a4af3bSchristos 
1429a5a4af3bSchristos     case CPU_VR5400:
1430a5a4af3bSchristos       return (mask & INSN_5400) != 0;
1431a5a4af3bSchristos 
1432a5a4af3bSchristos     case CPU_VR5500:
1433a5a4af3bSchristos       return (mask & INSN_5500) != 0;
1434a5a4af3bSchristos 
1435a5a4af3bSchristos     case CPU_R5900:
1436a5a4af3bSchristos       return (mask & INSN_5900) != 0;
1437a5a4af3bSchristos 
1438a5a4af3bSchristos     case CPU_LOONGSON_2E:
1439a5a4af3bSchristos       return (mask & INSN_LOONGSON_2E) != 0;
1440a5a4af3bSchristos 
1441a5a4af3bSchristos     case CPU_LOONGSON_2F:
1442a5a4af3bSchristos       return (mask & INSN_LOONGSON_2F) != 0;
1443a5a4af3bSchristos 
1444a5a4af3bSchristos     case CPU_OCTEON:
1445a5a4af3bSchristos       return (mask & INSN_OCTEON) != 0;
1446a5a4af3bSchristos 
1447a5a4af3bSchristos     case CPU_OCTEONP:
1448a5a4af3bSchristos       return (mask & INSN_OCTEONP) != 0;
1449a5a4af3bSchristos 
1450a5a4af3bSchristos     case CPU_OCTEON2:
1451a5a4af3bSchristos       return (mask & INSN_OCTEON2) != 0;
1452a5a4af3bSchristos 
1453a5a4af3bSchristos     case CPU_OCTEON3:
1454a5a4af3bSchristos       return (mask & INSN_OCTEON3) != 0;
1455a5a4af3bSchristos 
1456a5a4af3bSchristos     case CPU_XLR:
1457a5a4af3bSchristos       return (mask & INSN_XLR) != 0;
1458a5a4af3bSchristos 
145947c37bc2Schristos     case CPU_INTERAPTIV_MR2:
146047c37bc2Schristos       return (mask & INSN_INTERAPTIV_MR2) != 0;
146147c37bc2Schristos 
1462a5a4af3bSchristos     default:
1463*8b657b07Schristos       return false;
1464a5a4af3bSchristos     }
1465a5a4af3bSchristos }
1466a5a4af3bSchristos 
1467*8b657b07Schristos /* Return true if the given ISA is included in INSN_* mask MASK.  */
1468*8b657b07Schristos 
1469*8b657b07Schristos static inline bool
1470*8b657b07Schristos isa_is_member (int isa, unsigned int mask)
1471*8b657b07Schristos {
1472*8b657b07Schristos   isa &= INSN_ISA_MASK;
1473*8b657b07Schristos   mask &= INSN_ISA_MASK;
1474*8b657b07Schristos 
1475*8b657b07Schristos   if (isa == 0)
1476*8b657b07Schristos     return false;
1477*8b657b07Schristos 
1478*8b657b07Schristos   if (mask == 0)
1479*8b657b07Schristos     return false;
1480*8b657b07Schristos 
1481*8b657b07Schristos   if (((mips_isa_table[isa - 1] >> (mask - 1)) & 1) == 0)
1482*8b657b07Schristos     return false;
1483*8b657b07Schristos 
1484*8b657b07Schristos   return true;
1485*8b657b07Schristos }
1486*8b657b07Schristos 
1487a5a4af3bSchristos /* Test for membership in an ISA including chip specific ISAs.  INSN
1488a5a4af3bSchristos    is pointer to an element of the opcode table; ISA is the specified
1489a5a4af3bSchristos    ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
1490a5a4af3bSchristos    test, or zero if no CPU specific ISA test is desired.  Return true
1491a5a4af3bSchristos    if instruction INSN is available to the given ISA and CPU. */
1492a5a4af3bSchristos 
1493*8b657b07Schristos static inline bool
1494a5a4af3bSchristos opcode_is_member (const struct mips_opcode *insn, int isa, int ase, int cpu)
1495a5a4af3bSchristos {
1496*8b657b07Schristos   /* Test for ISA level exclusion.  */
1497*8b657b07Schristos   if (isa_is_member (isa, insn->exclusions))
1498*8b657b07Schristos     return false;
1499*8b657b07Schristos 
1500*8b657b07Schristos   /* Test for processor-specific exclusion.  */
1501*8b657b07Schristos   if (cpu_is_member (cpu, insn->exclusions))
1502*8b657b07Schristos     return false;
1503*8b657b07Schristos 
1504a5a4af3bSchristos   /* Test for ISA level compatibility.  */
1505*8b657b07Schristos   if (isa_is_member (isa, insn->membership))
1506*8b657b07Schristos     return true;
1507a5a4af3bSchristos 
1508a5a4af3bSchristos   /* Test for ASE compatibility.  */
1509a5a4af3bSchristos   if ((ase & insn->ase) != 0)
1510*8b657b07Schristos     return true;
1511a5a4af3bSchristos 
1512a5a4af3bSchristos   /* Test for processor-specific extensions.  */
1513a5a4af3bSchristos   if (cpu_is_member (cpu, insn->membership))
1514*8b657b07Schristos     return true;
1515*8b657b07Schristos 
1516*8b657b07Schristos   return false;
1517a5a4af3bSchristos }
1518a5a4af3bSchristos 
1519a5a4af3bSchristos /* This is a list of macro expanded instructions.
1520a5a4af3bSchristos 
1521a5a4af3bSchristos    _I appended means immediate
1522a5a4af3bSchristos    _A appended means target address of a jump
1523a5a4af3bSchristos    _AB appended means address with (possibly zero) base register
1524a5a4af3bSchristos    _D appended means 64 bit floating point constant
1525a5a4af3bSchristos    _S appended means 32 bit floating point constant.  */
1526a5a4af3bSchristos 
1527a5a4af3bSchristos enum
1528a5a4af3bSchristos {
1529a5a4af3bSchristos   M_ABS,
1530a5a4af3bSchristos   M_ACLR_AB,
1531a5a4af3bSchristos   M_ADD_I,
1532a5a4af3bSchristos   M_ADDU_I,
1533a5a4af3bSchristos   M_AND_I,
1534a5a4af3bSchristos   M_ASET_AB,
1535a5a4af3bSchristos   M_BALIGN,
1536a5a4af3bSchristos   M_BC1FL,
1537a5a4af3bSchristos   M_BC1TL,
1538a5a4af3bSchristos   M_BC2FL,
1539a5a4af3bSchristos   M_BC2TL,
1540a5a4af3bSchristos   M_BEQ,
1541a5a4af3bSchristos   M_BEQ_I,
1542a5a4af3bSchristos   M_BEQL,
1543a5a4af3bSchristos   M_BEQL_I,
1544a5a4af3bSchristos   M_BGE,
1545a5a4af3bSchristos   M_BGEL,
1546a5a4af3bSchristos   M_BGE_I,
1547a5a4af3bSchristos   M_BGEL_I,
1548a5a4af3bSchristos   M_BGEU,
1549a5a4af3bSchristos   M_BGEUL,
1550a5a4af3bSchristos   M_BGEU_I,
1551a5a4af3bSchristos   M_BGEUL_I,
1552a5a4af3bSchristos   M_BGEZ,
1553a5a4af3bSchristos   M_BGEZL,
1554a5a4af3bSchristos   M_BGEZALL,
1555a5a4af3bSchristos   M_BGT,
1556a5a4af3bSchristos   M_BGTL,
1557a5a4af3bSchristos   M_BGT_I,
1558a5a4af3bSchristos   M_BGTL_I,
1559a5a4af3bSchristos   M_BGTU,
1560a5a4af3bSchristos   M_BGTUL,
1561a5a4af3bSchristos   M_BGTU_I,
1562a5a4af3bSchristos   M_BGTUL_I,
1563a5a4af3bSchristos   M_BGTZ,
1564a5a4af3bSchristos   M_BGTZL,
1565a5a4af3bSchristos   M_BLE,
1566a5a4af3bSchristos   M_BLEL,
1567a5a4af3bSchristos   M_BLE_I,
1568a5a4af3bSchristos   M_BLEL_I,
1569a5a4af3bSchristos   M_BLEU,
1570a5a4af3bSchristos   M_BLEUL,
1571a5a4af3bSchristos   M_BLEU_I,
1572a5a4af3bSchristos   M_BLEUL_I,
1573a5a4af3bSchristos   M_BLEZ,
1574a5a4af3bSchristos   M_BLEZL,
1575a5a4af3bSchristos   M_BLT,
1576a5a4af3bSchristos   M_BLTL,
1577a5a4af3bSchristos   M_BLT_I,
1578a5a4af3bSchristos   M_BLTL_I,
1579a5a4af3bSchristos   M_BLTU,
1580a5a4af3bSchristos   M_BLTUL,
1581a5a4af3bSchristos   M_BLTU_I,
1582a5a4af3bSchristos   M_BLTUL_I,
1583a5a4af3bSchristos   M_BLTZ,
1584a5a4af3bSchristos   M_BLTZL,
1585a5a4af3bSchristos   M_BLTZALL,
1586a5a4af3bSchristos   M_BNE,
1587a5a4af3bSchristos   M_BNEL,
1588a5a4af3bSchristos   M_BNE_I,
1589a5a4af3bSchristos   M_BNEL_I,
1590a5a4af3bSchristos   M_CACHE_AB,
1591a5a4af3bSchristos   M_CACHEE_AB,
1592a5a4af3bSchristos   M_DABS,
1593a5a4af3bSchristos   M_DADD_I,
1594a5a4af3bSchristos   M_DADDU_I,
1595a5a4af3bSchristos   M_DDIV_3,
1596a5a4af3bSchristos   M_DDIV_3I,
1597a5a4af3bSchristos   M_DDIVU_3,
1598a5a4af3bSchristos   M_DDIVU_3I,
1599a5a4af3bSchristos   M_DIV_3,
1600a5a4af3bSchristos   M_DIV_3I,
1601a5a4af3bSchristos   M_DIVU_3,
1602a5a4af3bSchristos   M_DIVU_3I,
1603a5a4af3bSchristos   M_DLA_AB,
1604a5a4af3bSchristos   M_DLCA_AB,
1605a5a4af3bSchristos   M_DLI,
1606a5a4af3bSchristos   M_DMUL,
1607a5a4af3bSchristos   M_DMUL_I,
1608a5a4af3bSchristos   M_DMULO,
1609a5a4af3bSchristos   M_DMULO_I,
1610a5a4af3bSchristos   M_DMULOU,
1611a5a4af3bSchristos   M_DMULOU_I,
1612a5a4af3bSchristos   M_DREM_3,
1613a5a4af3bSchristos   M_DREM_3I,
1614a5a4af3bSchristos   M_DREMU_3,
1615a5a4af3bSchristos   M_DREMU_3I,
1616a5a4af3bSchristos   M_DSUB_I,
1617a5a4af3bSchristos   M_DSUBU_I,
1618a5a4af3bSchristos   M_DSUBU_I_2,
1619a5a4af3bSchristos   M_J_A,
1620a5a4af3bSchristos   M_JAL_1,
1621a5a4af3bSchristos   M_JAL_2,
1622a5a4af3bSchristos   M_JAL_A,
1623a5a4af3bSchristos   M_JALS_1,
1624a5a4af3bSchristos   M_JALS_2,
1625a5a4af3bSchristos   M_JALS_A,
1626a5a4af3bSchristos   M_JRADDIUSP,
1627a5a4af3bSchristos   M_JRC,
1628a5a4af3bSchristos   M_L_DAB,
1629a5a4af3bSchristos   M_LA_AB,
1630a5a4af3bSchristos   M_LB_AB,
1631a5a4af3bSchristos   M_LBE_AB,
1632a5a4af3bSchristos   M_LBU_AB,
1633a5a4af3bSchristos   M_LBUE_AB,
1634a5a4af3bSchristos   M_LCA_AB,
1635a5a4af3bSchristos   M_LD_AB,
1636a5a4af3bSchristos   M_LDC1_AB,
1637a5a4af3bSchristos   M_LDC2_AB,
1638a5a4af3bSchristos   M_LQC2_AB,
1639a5a4af3bSchristos   M_LDC3_AB,
1640a5a4af3bSchristos   M_LDL_AB,
1641a5a4af3bSchristos   M_LDM_AB,
1642a5a4af3bSchristos   M_LDP_AB,
1643a5a4af3bSchristos   M_LDR_AB,
1644a5a4af3bSchristos   M_LH_AB,
1645a5a4af3bSchristos   M_LHE_AB,
1646a5a4af3bSchristos   M_LHU_AB,
1647a5a4af3bSchristos   M_LHUE_AB,
1648a5a4af3bSchristos   M_LI,
1649a5a4af3bSchristos   M_LI_D,
1650a5a4af3bSchristos   M_LI_DD,
1651a5a4af3bSchristos   M_LI_S,
1652a5a4af3bSchristos   M_LI_SS,
1653a5a4af3bSchristos   M_LL_AB,
1654a5a4af3bSchristos   M_LLD_AB,
165582650ea5Schristos   M_LLDP_AB,
1656a5a4af3bSchristos   M_LLE_AB,
165782650ea5Schristos   M_LLWP_AB,
165882650ea5Schristos   M_LLWPE_AB,
1659a5a4af3bSchristos   M_LQ_AB,
1660a5a4af3bSchristos   M_LW_AB,
1661a5a4af3bSchristos   M_LWE_AB,
1662a5a4af3bSchristos   M_LWC0_AB,
1663a5a4af3bSchristos   M_LWC1_AB,
1664a5a4af3bSchristos   M_LWC2_AB,
1665a5a4af3bSchristos   M_LWC3_AB,
1666a5a4af3bSchristos   M_LWL_AB,
1667a5a4af3bSchristos   M_LWLE_AB,
1668a5a4af3bSchristos   M_LWM_AB,
1669a5a4af3bSchristos   M_LWP_AB,
1670a5a4af3bSchristos   M_LWR_AB,
1671a5a4af3bSchristos   M_LWRE_AB,
1672a5a4af3bSchristos   M_LWU_AB,
1673a5a4af3bSchristos   M_MSGSND,
1674a5a4af3bSchristos   M_MSGLD,
1675a5a4af3bSchristos   M_MSGLD_T,
1676a5a4af3bSchristos   M_MSGWAIT,
1677a5a4af3bSchristos   M_MSGWAIT_T,
1678a5a4af3bSchristos   M_MOVE,
1679a5a4af3bSchristos   M_MOVEP,
1680a5a4af3bSchristos   M_MUL,
1681a5a4af3bSchristos   M_MUL_I,
1682a5a4af3bSchristos   M_MULO,
1683a5a4af3bSchristos   M_MULO_I,
1684a5a4af3bSchristos   M_MULOU,
1685a5a4af3bSchristos   M_MULOU_I,
1686a5a4af3bSchristos   M_NOR_I,
1687a5a4af3bSchristos   M_OR_I,
1688a5a4af3bSchristos   M_PREF_AB,
1689a5a4af3bSchristos   M_PREFE_AB,
1690a5a4af3bSchristos   M_REM_3,
1691a5a4af3bSchristos   M_REM_3I,
1692a5a4af3bSchristos   M_REMU_3,
1693a5a4af3bSchristos   M_REMU_3I,
1694a5a4af3bSchristos   M_DROL,
1695a5a4af3bSchristos   M_ROL,
1696a5a4af3bSchristos   M_DROL_I,
1697a5a4af3bSchristos   M_ROL_I,
1698a5a4af3bSchristos   M_DROR,
1699a5a4af3bSchristos   M_ROR,
1700a5a4af3bSchristos   M_DROR_I,
1701a5a4af3bSchristos   M_ROR_I,
1702a5a4af3bSchristos   M_S_DA,
1703a5a4af3bSchristos   M_S_DAB,
1704a5a4af3bSchristos   M_S_S,
1705a5a4af3bSchristos   M_SAA_AB,
1706a5a4af3bSchristos   M_SAAD_AB,
1707a5a4af3bSchristos   M_SC_AB,
1708a5a4af3bSchristos   M_SCD_AB,
170982650ea5Schristos   M_SCDP_AB,
1710a5a4af3bSchristos   M_SCE_AB,
171182650ea5Schristos   M_SCWP_AB,
171282650ea5Schristos   M_SCWPE_AB,
1713a5a4af3bSchristos   M_SD_AB,
1714a5a4af3bSchristos   M_SDC1_AB,
1715a5a4af3bSchristos   M_SDC2_AB,
1716a5a4af3bSchristos   M_SQC2_AB,
1717a5a4af3bSchristos   M_SDC3_AB,
1718a5a4af3bSchristos   M_SDL_AB,
1719a5a4af3bSchristos   M_SDM_AB,
1720a5a4af3bSchristos   M_SDP_AB,
1721a5a4af3bSchristos   M_SDR_AB,
1722a5a4af3bSchristos   M_SEQ,
1723a5a4af3bSchristos   M_SEQ_I,
1724a5a4af3bSchristos   M_SGE,
1725a5a4af3bSchristos   M_SGE_I,
1726a5a4af3bSchristos   M_SGEU,
1727a5a4af3bSchristos   M_SGEU_I,
1728a5a4af3bSchristos   M_SGT,
1729a5a4af3bSchristos   M_SGT_I,
1730a5a4af3bSchristos   M_SGTU,
1731a5a4af3bSchristos   M_SGTU_I,
1732a5a4af3bSchristos   M_SLE,
1733a5a4af3bSchristos   M_SLE_I,
1734a5a4af3bSchristos   M_SLEU,
1735a5a4af3bSchristos   M_SLEU_I,
1736a5a4af3bSchristos   M_SLT_I,
1737a5a4af3bSchristos   M_SLTU_I,
1738a5a4af3bSchristos   M_SNE,
1739a5a4af3bSchristos   M_SNE_I,
1740a5a4af3bSchristos   M_SB_AB,
1741a5a4af3bSchristos   M_SBE_AB,
1742a5a4af3bSchristos   M_SH_AB,
1743a5a4af3bSchristos   M_SHE_AB,
1744a5a4af3bSchristos   M_SQ_AB,
1745a5a4af3bSchristos   M_SW_AB,
1746a5a4af3bSchristos   M_SWE_AB,
1747a5a4af3bSchristos   M_SWC0_AB,
1748a5a4af3bSchristos   M_SWC1_AB,
1749a5a4af3bSchristos   M_SWC2_AB,
1750a5a4af3bSchristos   M_SWC3_AB,
1751a5a4af3bSchristos   M_SWL_AB,
1752a5a4af3bSchristos   M_SWLE_AB,
1753a5a4af3bSchristos   M_SWM_AB,
1754a5a4af3bSchristos   M_SWP_AB,
1755a5a4af3bSchristos   M_SWR_AB,
1756a5a4af3bSchristos   M_SWRE_AB,
1757a5a4af3bSchristos   M_SUB_I,
1758a5a4af3bSchristos   M_SUBU_I,
1759a5a4af3bSchristos   M_SUBU_I_2,
1760a5a4af3bSchristos   M_TEQ_I,
1761a5a4af3bSchristos   M_TGE_I,
1762a5a4af3bSchristos   M_TGEU_I,
1763a5a4af3bSchristos   M_TLT_I,
1764a5a4af3bSchristos   M_TLTU_I,
1765a5a4af3bSchristos   M_TNE_I,
1766a5a4af3bSchristos   M_TRUNCWD,
1767a5a4af3bSchristos   M_TRUNCWS,
1768a5a4af3bSchristos   M_ULD_AB,
1769a5a4af3bSchristos   M_ULH_AB,
1770a5a4af3bSchristos   M_ULHU_AB,
1771a5a4af3bSchristos   M_ULW_AB,
1772a5a4af3bSchristos   M_USH_AB,
1773a5a4af3bSchristos   M_USW_AB,
1774a5a4af3bSchristos   M_USD_AB,
1775a5a4af3bSchristos   M_XOR_I,
1776a5a4af3bSchristos   M_COP0,
1777a5a4af3bSchristos   M_COP1,
1778a5a4af3bSchristos   M_COP2,
1779a5a4af3bSchristos   M_COP3,
1780a5a4af3bSchristos   M_NUM_MACROS
1781a5a4af3bSchristos };
1782a5a4af3bSchristos 
1783a5a4af3bSchristos 
1784a5a4af3bSchristos /* The order of overloaded instructions matters.  Label arguments and
1785a5a4af3bSchristos    register arguments look the same. Instructions that can have either
1786a5a4af3bSchristos    for arguments must apear in the correct order in this table for the
1787a5a4af3bSchristos    assembler to pick the right one. In other words, entries with
1788a5a4af3bSchristos    immediate operands must apear after the same instruction with
1789a5a4af3bSchristos    registers.
1790a5a4af3bSchristos 
1791a5a4af3bSchristos    Many instructions are short hand for other instructions (i.e., The
1792a5a4af3bSchristos    jal <register> instruction is short for jalr <register>).  */
1793a5a4af3bSchristos 
1794a5a4af3bSchristos extern const struct mips_operand mips_vu0_channel_mask;
1795a5a4af3bSchristos extern const struct mips_operand *decode_mips_operand (const char *);
1796a5a4af3bSchristos extern const struct mips_opcode mips_builtin_opcodes[];
1797a5a4af3bSchristos extern const int bfd_mips_num_builtin_opcodes;
1798a5a4af3bSchristos extern struct mips_opcode *mips_opcodes;
1799a5a4af3bSchristos extern int bfd_mips_num_opcodes;
1800a5a4af3bSchristos #define NUMOPCODES bfd_mips_num_opcodes
1801a5a4af3bSchristos 
1802a5a4af3bSchristos 
1803a5a4af3bSchristos /* The rest of this file adds definitions for the mips16 TinyRISC
1804a5a4af3bSchristos    processor.  */
1805a5a4af3bSchristos 
1806a5a4af3bSchristos /* These are the bitmasks and shift counts used for the different
1807a5a4af3bSchristos    fields in the instruction formats.  Other than OP, no masks are
1808a5a4af3bSchristos    provided for the fixed portions of an instruction, since they are
1809a5a4af3bSchristos    not needed.
1810a5a4af3bSchristos 
1811a5a4af3bSchristos    The I format uses IMM11.
1812a5a4af3bSchristos 
1813a5a4af3bSchristos    The RI format uses RX and IMM8.
1814a5a4af3bSchristos 
1815a5a4af3bSchristos    The RR format uses RX, and RY.
1816a5a4af3bSchristos 
1817a5a4af3bSchristos    The RRI format uses RX, RY, and IMM5.
1818a5a4af3bSchristos 
1819a5a4af3bSchristos    The RRR format uses RX, RY, and RZ.
1820a5a4af3bSchristos 
1821a5a4af3bSchristos    The RRI_A format uses RX, RY, and IMM4.
1822a5a4af3bSchristos 
1823a5a4af3bSchristos    The SHIFT format uses RX, RY, and SHAMT.
1824a5a4af3bSchristos 
1825a5a4af3bSchristos    The I8 format uses IMM8.
1826a5a4af3bSchristos 
1827a5a4af3bSchristos    The I8_MOVR32 format uses RY and REGR32.
1828a5a4af3bSchristos 
1829a5a4af3bSchristos    The IR_MOV32R format uses REG32R and MOV32Z.
1830a5a4af3bSchristos 
1831a5a4af3bSchristos    The I64 format uses IMM8.
1832a5a4af3bSchristos 
1833a5a4af3bSchristos    The RI64 format uses RY and IMM5.
1834a5a4af3bSchristos    */
1835a5a4af3bSchristos 
1836a5a4af3bSchristos #define MIPS16OP_MASK_OP	0x1f
1837a5a4af3bSchristos #define MIPS16OP_SH_OP		11
1838a5a4af3bSchristos #define MIPS16OP_MASK_IMM11	0x7ff
1839a5a4af3bSchristos #define MIPS16OP_SH_IMM11	0
1840a5a4af3bSchristos #define MIPS16OP_MASK_RX	0x7
1841a5a4af3bSchristos #define MIPS16OP_SH_RX		8
1842a5a4af3bSchristos #define MIPS16OP_MASK_IMM8	0xff
1843a5a4af3bSchristos #define MIPS16OP_SH_IMM8	0
1844a5a4af3bSchristos #define MIPS16OP_MASK_RY	0x7
1845a5a4af3bSchristos #define MIPS16OP_SH_RY		5
1846a5a4af3bSchristos #define MIPS16OP_MASK_IMM5	0x1f
1847a5a4af3bSchristos #define MIPS16OP_SH_IMM5	0
1848a5a4af3bSchristos #define MIPS16OP_MASK_RZ	0x7
1849a5a4af3bSchristos #define MIPS16OP_SH_RZ		2
1850a5a4af3bSchristos #define MIPS16OP_MASK_IMM4	0xf
1851a5a4af3bSchristos #define MIPS16OP_SH_IMM4	0
1852a5a4af3bSchristos #define MIPS16OP_MASK_REGR32	0x1f
1853a5a4af3bSchristos #define MIPS16OP_SH_REGR32	0
1854a5a4af3bSchristos #define MIPS16OP_MASK_REG32R	0x1f
1855a5a4af3bSchristos #define MIPS16OP_SH_REG32R	3
1856a5a4af3bSchristos #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
1857a5a4af3bSchristos #define MIPS16OP_MASK_MOVE32Z	0x7
1858a5a4af3bSchristos #define MIPS16OP_SH_MOVE32Z	0
1859a5a4af3bSchristos #define MIPS16OP_MASK_IMM6	0x3f
1860a5a4af3bSchristos #define MIPS16OP_SH_IMM6	5
1861a5a4af3bSchristos 
1862a5a4af3bSchristos /* These are the characters which may appears in the args field of a MIPS16
1863a5a4af3bSchristos    instruction.  They appear in the order in which the fields appear when the
1864a5a4af3bSchristos    instruction is used.  Commas and parentheses in the args string are ignored
1865a5a4af3bSchristos    when assembling, and written into the output when disassembling.
1866a5a4af3bSchristos 
1867a5a4af3bSchristos    "y" 3 bit register (MIPS16OP_*_RY)
1868a5a4af3bSchristos    "x" 3 bit register (MIPS16OP_*_RX)
1869a5a4af3bSchristos    "z" 3 bit register (MIPS16OP_*_RZ)
1870a5a4af3bSchristos    "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
1871a5a4af3bSchristos    "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
1872a5a4af3bSchristos    "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
187399e23f81Schristos    "." zero register ($0)
1874a5a4af3bSchristos    "S" stack pointer ($sp or $29)
1875a5a4af3bSchristos    "P" program counter
1876a5a4af3bSchristos    "R" return address register ($ra or $31)
1877a5a4af3bSchristos    "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
1878a5a4af3bSchristos    "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
187999e23f81Schristos    "0" 5-bit ASMACRO p0 immediate
188099e23f81Schristos    "1" 3-bit ASMACRO p1 immediate
188199e23f81Schristos    "2" 3-bit ASMACRO p2 immediate
188299e23f81Schristos    "3" 5-bit ASMACRO p3 immediate
188399e23f81Schristos    "4" 3-bit ASMACRO p4 immediate
1884a5a4af3bSchristos    "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
1885a5a4af3bSchristos    "a" 26 bit jump address
1886a5a4af3bSchristos    "i" likewise, but flips bit 0
1887a5a4af3bSchristos    "e" 11 bit extension value
1888a5a4af3bSchristos    "l" register list for entry instruction
1889a5a4af3bSchristos    "L" register list for exit instruction
189047c37bc2Schristos    ">" 5-bit SYNC code
189147c37bc2Schristos    "9" 9-bit signed immediate
189247c37bc2Schristos    "G" global pointer ($gp or $28)
189347c37bc2Schristos    "N" 5-bit coprocessor register
189447c37bc2Schristos    "O" 3-bit sel field for MFC0/MTC0
189547c37bc2Schristos    "Q" 5-bit hardware register
189647c37bc2Schristos    "T" 5-bit CACHE opcode or PREF hint
189747c37bc2Schristos    "b" 5-bit INS/EXT position, which becomes LSB
189847c37bc2Schristos        Enforces: 0 <= pos < 32.
189947c37bc2Schristos    "c" 5-bit INS size, which becomes MSB
190047c37bc2Schristos        Requires that "b" occurs first to set position.
190147c37bc2Schristos        Enforces: 0 < (pos+size) <= 32.
190247c37bc2Schristos    "d" 5-bit EXT size, which becomes MSBD
190347c37bc2Schristos        Requires that "b" occurs first to set position.
190447c37bc2Schristos        Enforces: 0 < (pos+size) <= 32.
190547c37bc2Schristos    "n" 2-bit immediate (1 .. 4)
190647c37bc2Schristos    "o" 5-bit unsigned immediate * 16
190747c37bc2Schristos    "r" 3-bit register
190899e23f81Schristos    "s" 3-bit ASMACRO select immediate
190947c37bc2Schristos    "u" 16-bit unsigned immediate
1910a5a4af3bSchristos 
1911a5a4af3bSchristos    "I" an immediate value used for macros
1912a5a4af3bSchristos 
1913a5a4af3bSchristos    The remaining codes may be extended.  Except as otherwise noted,
1914a5a4af3bSchristos    the full extended operand is a 16 bit signed value.
1915a5a4af3bSchristos    "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
1916a5a4af3bSchristos    "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
1917a5a4af3bSchristos    "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
1918a5a4af3bSchristos    "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
191999e23f81Schristos    "F" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
1920a5a4af3bSchristos    "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
1921a5a4af3bSchristos    "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
1922a5a4af3bSchristos    "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
1923a5a4af3bSchristos    "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
1924a5a4af3bSchristos    "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
1925a5a4af3bSchristos    "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
1926a5a4af3bSchristos    "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
1927a5a4af3bSchristos    "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
1928a5a4af3bSchristos    "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
1929a5a4af3bSchristos    "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
1930a5a4af3bSchristos    "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
1931a5a4af3bSchristos    "q" 11 bit branch address (MIPS16OP_*_IMM11)
1932a5a4af3bSchristos    "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
1933a5a4af3bSchristos    "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
1934a5a4af3bSchristos    "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
193547c37bc2Schristos    "m" 7 bit register list for SAVE/RESTORE instruction (18 bit extended)
1936e5cb852cSchristos 
1937e5cb852cSchristos    Characters used so far, for quick reference when adding more:
193847c37bc2Schristos    "0123456 89"
193947c37bc2Schristos    ".[]<>"
194047c37bc2Schristos    "ABCDEFGHI KL NOPQRSTUVWXYZ"
194147c37bc2Schristos    "abcde   ijklmnopqrs uvwxyz"
1942a5a4af3bSchristos   */
1943a5a4af3bSchristos 
1944a5a4af3bSchristos /* Save/restore encoding for the args field when all 4 registers are
1945a5a4af3bSchristos    either saved as arguments or saved/restored as statics.  */
194647c37bc2Schristos #define MIPS_SVRS_ALL_ARGS    0xe
194747c37bc2Schristos #define MIPS_SVRS_ALL_STATICS 0xb
1948a5a4af3bSchristos 
1949a5a4af3bSchristos /* The following flags have the same value for the mips16 opcode
1950a5a4af3bSchristos    table:
1951a5a4af3bSchristos 
1952a5a4af3bSchristos    INSN_ISA3
1953a5a4af3bSchristos 
1954a5a4af3bSchristos    INSN_UNCOND_BRANCH_DELAY
1955a5a4af3bSchristos    INSN_COND_BRANCH_DELAY
1956a5a4af3bSchristos    INSN_COND_BRANCH_LIKELY (never used)
1957a5a4af3bSchristos    INSN_READ_HI
1958a5a4af3bSchristos    INSN_READ_LO
1959a5a4af3bSchristos    INSN_WRITE_HI
1960a5a4af3bSchristos    INSN_WRITE_LO
1961a5a4af3bSchristos    INSN_TRAP
1962a5a4af3bSchristos    FP_D (never used)
1963a5a4af3bSchristos    */
1964a5a4af3bSchristos 
1965*8b657b07Schristos extern const struct mips_operand *decode_mips16_operand (char, bool);
1966a5a4af3bSchristos extern const struct mips_opcode mips16_opcodes[];
1967a5a4af3bSchristos extern const int bfd_mips16_num_opcodes;
1968a5a4af3bSchristos 
1969a5a4af3bSchristos /* These are the bit masks and shift counts used for the different fields
1970a5a4af3bSchristos    in the microMIPS instruction formats.  No masks are provided for the
1971a5a4af3bSchristos    fixed portions of an instruction, since they are not needed.  */
1972a5a4af3bSchristos 
1973a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMEDIATE	0xffff
1974a5a4af3bSchristos #define MICROMIPSOP_SH_IMMEDIATE	0
1975a5a4af3bSchristos #define MICROMIPSOP_MASK_DELTA		0xffff
1976a5a4af3bSchristos #define MICROMIPSOP_SH_DELTA		0
1977a5a4af3bSchristos #define MICROMIPSOP_MASK_CODE10		0x3ff
1978a5a4af3bSchristos #define MICROMIPSOP_SH_CODE10		16	/* 10-bit wait code.  */
1979a5a4af3bSchristos #define MICROMIPSOP_MASK_TRAP		0xf
1980a5a4af3bSchristos #define MICROMIPSOP_SH_TRAP		12	/* 4-bit trap code.  */
1981a5a4af3bSchristos #define MICROMIPSOP_MASK_SHAMT		0x1f
1982a5a4af3bSchristos #define MICROMIPSOP_SH_SHAMT		11
1983a5a4af3bSchristos #define MICROMIPSOP_MASK_TARGET		0x3ffffff
1984a5a4af3bSchristos #define MICROMIPSOP_SH_TARGET		0
1985a5a4af3bSchristos #define MICROMIPSOP_MASK_EXTLSB		0x1f	/* "ext" LSB.  */
1986a5a4af3bSchristos #define MICROMIPSOP_SH_EXTLSB		6
1987a5a4af3bSchristos #define MICROMIPSOP_MASK_EXTMSBD	0x1f	/* "ext" MSBD.  */
1988a5a4af3bSchristos #define MICROMIPSOP_SH_EXTMSBD		11
1989a5a4af3bSchristos #define MICROMIPSOP_MASK_INSMSB		0x1f	/* "ins" MSB.  */
1990a5a4af3bSchristos #define MICROMIPSOP_SH_INSMSB		11
1991a5a4af3bSchristos #define MICROMIPSOP_MASK_CODE		0x3ff
1992a5a4af3bSchristos #define MICROMIPSOP_SH_CODE		16	/* 10-bit higher break code. */
1993a5a4af3bSchristos #define MICROMIPSOP_MASK_CODE2		0x3ff
1994a5a4af3bSchristos #define MICROMIPSOP_SH_CODE2		6	/* 10-bit lower break code.  */
1995a5a4af3bSchristos #define MICROMIPSOP_MASK_CACHE		0x1f
1996a5a4af3bSchristos #define MICROMIPSOP_SH_CACHE		21	/* 5-bit cache op.  */
1997a5a4af3bSchristos #define MICROMIPSOP_MASK_SEL		0x7
1998a5a4af3bSchristos #define MICROMIPSOP_SH_SEL		11
1999a5a4af3bSchristos #define MICROMIPSOP_MASK_OFFSET12	0xfff
2000a5a4af3bSchristos #define MICROMIPSOP_SH_OFFSET12		0
2001a5a4af3bSchristos #define MICROMIPSOP_MASK_3BITPOS	0x7
2002a5a4af3bSchristos #define MICROMIPSOP_SH_3BITPOS		21
2003a5a4af3bSchristos #define MICROMIPSOP_MASK_STYPE		0x1f
2004a5a4af3bSchristos #define MICROMIPSOP_SH_STYPE		16
2005a5a4af3bSchristos #define MICROMIPSOP_MASK_OFFSET10	0x3ff
2006a5a4af3bSchristos #define MICROMIPSOP_SH_OFFSET10		6
2007a5a4af3bSchristos #define MICROMIPSOP_MASK_RS		0x1f
2008a5a4af3bSchristos #define MICROMIPSOP_SH_RS		16
2009a5a4af3bSchristos #define MICROMIPSOP_MASK_RT		0x1f
2010a5a4af3bSchristos #define MICROMIPSOP_SH_RT		21
2011a5a4af3bSchristos #define MICROMIPSOP_MASK_RD		0x1f
2012a5a4af3bSchristos #define MICROMIPSOP_SH_RD		11
2013a5a4af3bSchristos #define MICROMIPSOP_MASK_FS		0x1f
2014a5a4af3bSchristos #define MICROMIPSOP_SH_FS		16
2015a5a4af3bSchristos #define MICROMIPSOP_MASK_FT		0x1f
2016a5a4af3bSchristos #define MICROMIPSOP_SH_FT		21
2017a5a4af3bSchristos #define MICROMIPSOP_MASK_FD		0x1f
2018a5a4af3bSchristos #define MICROMIPSOP_SH_FD		11
2019a5a4af3bSchristos #define MICROMIPSOP_MASK_FR		0x1f
2020a5a4af3bSchristos #define MICROMIPSOP_SH_FR		6
2021a5a4af3bSchristos #define MICROMIPSOP_MASK_RS3		0x1f
2022a5a4af3bSchristos #define MICROMIPSOP_SH_RS3		6
2023a5a4af3bSchristos #define MICROMIPSOP_MASK_PREFX		0x1f
2024a5a4af3bSchristos #define MICROMIPSOP_SH_PREFX		11
2025a5a4af3bSchristos #define MICROMIPSOP_MASK_BCC		0x7
2026a5a4af3bSchristos #define MICROMIPSOP_SH_BCC		18
2027a5a4af3bSchristos #define MICROMIPSOP_MASK_CCC		0x7
2028a5a4af3bSchristos #define MICROMIPSOP_SH_CCC		13
2029a5a4af3bSchristos #define MICROMIPSOP_MASK_COPZ		0x7fffff
2030a5a4af3bSchristos #define MICROMIPSOP_SH_COPZ		3
2031a5a4af3bSchristos 
2032a5a4af3bSchristos #define MICROMIPSOP_MASK_MB		0x7
2033a5a4af3bSchristos #define MICROMIPSOP_SH_MB		23
2034a5a4af3bSchristos #define MICROMIPSOP_MASK_MC		0x7
2035a5a4af3bSchristos #define MICROMIPSOP_SH_MC		4
2036a5a4af3bSchristos #define MICROMIPSOP_MASK_MD		0x7
2037a5a4af3bSchristos #define MICROMIPSOP_SH_MD		7
2038a5a4af3bSchristos #define MICROMIPSOP_MASK_ME		0x7
2039a5a4af3bSchristos #define MICROMIPSOP_SH_ME		1
2040a5a4af3bSchristos #define MICROMIPSOP_MASK_MF		0x7
2041a5a4af3bSchristos #define MICROMIPSOP_SH_MF		3
2042a5a4af3bSchristos #define MICROMIPSOP_MASK_MG		0x7
2043a5a4af3bSchristos #define MICROMIPSOP_SH_MG		0
2044a5a4af3bSchristos #define MICROMIPSOP_MASK_MH		0x7
2045a5a4af3bSchristos #define MICROMIPSOP_SH_MH		7
2046a5a4af3bSchristos #define MICROMIPSOP_MASK_MJ		0x1f
2047a5a4af3bSchristos #define MICROMIPSOP_SH_MJ		0
2048a5a4af3bSchristos #define MICROMIPSOP_MASK_ML		0x7
2049a5a4af3bSchristos #define MICROMIPSOP_SH_ML		4
2050a5a4af3bSchristos #define MICROMIPSOP_MASK_MM		0x7
2051a5a4af3bSchristos #define MICROMIPSOP_SH_MM		1
2052a5a4af3bSchristos #define MICROMIPSOP_MASK_MN		0x7
2053a5a4af3bSchristos #define MICROMIPSOP_SH_MN		4
2054a5a4af3bSchristos #define MICROMIPSOP_MASK_MP		0x1f
2055a5a4af3bSchristos #define MICROMIPSOP_SH_MP		5
2056a5a4af3bSchristos #define MICROMIPSOP_MASK_MQ		0x7
2057a5a4af3bSchristos #define MICROMIPSOP_SH_MQ		7
2058a5a4af3bSchristos 
2059a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMA		0x7f
2060a5a4af3bSchristos #define MICROMIPSOP_SH_IMMA		0
2061a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMB		0x7
2062a5a4af3bSchristos #define MICROMIPSOP_SH_IMMB		1
2063a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMC		0xf
2064a5a4af3bSchristos #define MICROMIPSOP_SH_IMMC		0
2065a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMD		0x3ff
2066a5a4af3bSchristos #define MICROMIPSOP_SH_IMMD		0
2067a5a4af3bSchristos #define MICROMIPSOP_MASK_IMME		0x7f
2068a5a4af3bSchristos #define MICROMIPSOP_SH_IMME		0
2069a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMF		0xf
2070a5a4af3bSchristos #define MICROMIPSOP_SH_IMMF		0
2071a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMG		0xf
2072a5a4af3bSchristos #define MICROMIPSOP_SH_IMMG		0
2073a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMH		0xf
2074a5a4af3bSchristos #define MICROMIPSOP_SH_IMMH		0
2075a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMI		0x7f
2076a5a4af3bSchristos #define MICROMIPSOP_SH_IMMI		0
2077a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMJ		0xf
2078a5a4af3bSchristos #define MICROMIPSOP_SH_IMMJ		0
2079a5a4af3bSchristos #define MICROMIPSOP_MASK_IMML		0xf
2080a5a4af3bSchristos #define MICROMIPSOP_SH_IMML		0
2081a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMM		0x7
2082a5a4af3bSchristos #define MICROMIPSOP_SH_IMMM		1
2083a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMN		0x3
2084a5a4af3bSchristos #define MICROMIPSOP_SH_IMMN		4
2085a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMO		0xf
2086a5a4af3bSchristos #define MICROMIPSOP_SH_IMMO		0
2087a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMP		0x1f
2088a5a4af3bSchristos #define MICROMIPSOP_SH_IMMP		0
2089a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMQ		0x7fffff
2090a5a4af3bSchristos #define MICROMIPSOP_SH_IMMQ		0
2091a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMU		0x1f
2092a5a4af3bSchristos #define MICROMIPSOP_SH_IMMU		0
2093a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMW		0x3f
2094a5a4af3bSchristos #define MICROMIPSOP_SH_IMMW		1
2095a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMX		0xf
2096a5a4af3bSchristos #define MICROMIPSOP_SH_IMMX		1
2097a5a4af3bSchristos #define MICROMIPSOP_MASK_IMMY		0x1ff
2098a5a4af3bSchristos #define MICROMIPSOP_SH_IMMY		1
2099a5a4af3bSchristos 
2100a5a4af3bSchristos /* MIPS DSP ASE */
2101a5a4af3bSchristos #define MICROMIPSOP_MASK_DSPACC		0x3
2102a5a4af3bSchristos #define MICROMIPSOP_SH_DSPACC		14
2103a5a4af3bSchristos #define MICROMIPSOP_MASK_DSPSFT		0x3f
2104a5a4af3bSchristos #define MICROMIPSOP_SH_DSPSFT		16
2105a5a4af3bSchristos #define MICROMIPSOP_MASK_SA3		0x7
2106a5a4af3bSchristos #define MICROMIPSOP_SH_SA3		13
2107a5a4af3bSchristos #define MICROMIPSOP_MASK_SA4		0xf
2108a5a4af3bSchristos #define MICROMIPSOP_SH_SA4		12
2109a5a4af3bSchristos #define MICROMIPSOP_MASK_IMM8		0xff
2110a5a4af3bSchristos #define MICROMIPSOP_SH_IMM8		13
2111a5a4af3bSchristos #define MICROMIPSOP_MASK_IMM10		0x3ff
2112a5a4af3bSchristos #define MICROMIPSOP_SH_IMM10		16
2113a5a4af3bSchristos #define MICROMIPSOP_MASK_WRDSP		0x3f
2114a5a4af3bSchristos #define MICROMIPSOP_SH_WRDSP		14
2115a5a4af3bSchristos #define MICROMIPSOP_MASK_BP		0x3
2116a5a4af3bSchristos #define MICROMIPSOP_SH_BP		14
2117a5a4af3bSchristos 
2118a5a4af3bSchristos /* Placeholders for fields that only exist in the traditional 32-bit
2119a5a4af3bSchristos    instruction encoding; see the comment above for details.  */
2120a5a4af3bSchristos #define MICROMIPSOP_MASK_CODE20		0
2121a5a4af3bSchristos #define MICROMIPSOP_SH_CODE20		0
2122a5a4af3bSchristos #define MICROMIPSOP_MASK_PERFREG	0
2123a5a4af3bSchristos #define MICROMIPSOP_SH_PERFREG		0
2124a5a4af3bSchristos #define MICROMIPSOP_MASK_CODE19		0
2125a5a4af3bSchristos #define MICROMIPSOP_SH_CODE19		0
2126a5a4af3bSchristos #define MICROMIPSOP_MASK_ALN		0
2127a5a4af3bSchristos #define MICROMIPSOP_SH_ALN		0
2128a5a4af3bSchristos #define MICROMIPSOP_MASK_VECBYTE	0
2129a5a4af3bSchristos #define MICROMIPSOP_SH_VECBYTE		0
2130a5a4af3bSchristos #define MICROMIPSOP_MASK_VECALIGN	0
2131a5a4af3bSchristos #define MICROMIPSOP_SH_VECALIGN		0
2132a5a4af3bSchristos #define MICROMIPSOP_MASK_DSPACC_S	0
2133a5a4af3bSchristos #define MICROMIPSOP_SH_DSPACC_S	 	0
2134a5a4af3bSchristos #define MICROMIPSOP_MASK_DSPSFT_7	0
2135a5a4af3bSchristos #define MICROMIPSOP_SH_DSPSFT_7	 	0
2136a5a4af3bSchristos #define MICROMIPSOP_MASK_RDDSP		0
2137a5a4af3bSchristos #define MICROMIPSOP_SH_RDDSP		0
2138a5a4af3bSchristos #define MICROMIPSOP_MASK_MT_U		0
2139a5a4af3bSchristos #define MICROMIPSOP_SH_MT_U		0
2140a5a4af3bSchristos #define MICROMIPSOP_MASK_MT_H		0
2141a5a4af3bSchristos #define MICROMIPSOP_SH_MT_H		0
2142a5a4af3bSchristos #define MICROMIPSOP_MASK_MTACC_T	0
2143a5a4af3bSchristos #define MICROMIPSOP_SH_MTACC_T		0
2144a5a4af3bSchristos #define MICROMIPSOP_MASK_MTACC_D	0
2145a5a4af3bSchristos #define MICROMIPSOP_SH_MTACC_D		0
2146a5a4af3bSchristos #define MICROMIPSOP_MASK_BBITIND	0
2147a5a4af3bSchristos #define MICROMIPSOP_SH_BBITIND		0
2148a5a4af3bSchristos #define MICROMIPSOP_MASK_CINSPOS	0
2149a5a4af3bSchristos #define MICROMIPSOP_SH_CINSPOS		0
2150a5a4af3bSchristos #define MICROMIPSOP_MASK_CINSLM1	0
2151a5a4af3bSchristos #define MICROMIPSOP_SH_CINSLM1		0
2152a5a4af3bSchristos #define MICROMIPSOP_MASK_SEQI		0
2153a5a4af3bSchristos #define MICROMIPSOP_SH_SEQI		0
2154a5a4af3bSchristos #define MICROMIPSOP_SH_OFFSET_A		0
2155a5a4af3bSchristos #define MICROMIPSOP_MASK_OFFSET_A	0
2156a5a4af3bSchristos #define MICROMIPSOP_SH_OFFSET_B		0
2157a5a4af3bSchristos #define MICROMIPSOP_MASK_OFFSET_B	0
2158a5a4af3bSchristos #define MICROMIPSOP_SH_OFFSET_C		0
2159a5a4af3bSchristos #define MICROMIPSOP_MASK_OFFSET_C	0
2160a5a4af3bSchristos #define MICROMIPSOP_SH_RZ		0
2161a5a4af3bSchristos #define MICROMIPSOP_MASK_RZ		0
2162a5a4af3bSchristos #define MICROMIPSOP_SH_FZ		0
2163a5a4af3bSchristos #define MICROMIPSOP_MASK_FZ		0
2164a5a4af3bSchristos 
2165a5a4af3bSchristos /* microMIPS Enhanced VA Scheme */
2166a5a4af3bSchristos #define MICROMIPSOP_SH_EVAOFFSET	0
2167a5a4af3bSchristos #define MICROMIPSOP_MASK_EVAOFFSET	0x1ff
2168a5a4af3bSchristos 
2169a5a4af3bSchristos /* These are the characters which may appears in the args field of a microMIPS
2170a5a4af3bSchristos    instruction.  They appear in the order in which the fields appear
2171a5a4af3bSchristos    when the instruction is used.  Commas and parentheses in the args
2172a5a4af3bSchristos    string are ignored when assembling, and written into the output
2173a5a4af3bSchristos    when disassembling.
2174a5a4af3bSchristos 
2175a5a4af3bSchristos    The followings are for 16-bit microMIPS instructions.
2176a5a4af3bSchristos 
2177a5a4af3bSchristos    "ma" must be $28
2178a5a4af3bSchristos    "mc" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MC) at bit 4
2179a5a4af3bSchristos         The same register used as both source and target.
2180a5a4af3bSchristos    "md" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MD) at bit 7
2181a5a4af3bSchristos    "me" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ME) at bit 1
2182a5a4af3bSchristos         The same register used as both source and target.
2183a5a4af3bSchristos    "mf" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MF) at bit 3
2184a5a4af3bSchristos    "mg" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MG) at bit 0
2185a5a4af3bSchristos    "mh" 3-bit MIPS register pair (MICROMIPSOP_*_MH) at bit 7
2186a5a4af3bSchristos    "mj" 5-bit MIPS registers (MICROMIPSOP_*_MJ) at bit 0
2187a5a4af3bSchristos    "ml" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ML) at bit 4
2188a5a4af3bSchristos    "mm" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MM) at bit 1
2189a5a4af3bSchristos    "mn" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MN) at bit 4
2190a5a4af3bSchristos    "mp" 5-bit MIPS registers (MICROMIPSOP_*_MP) at bit 5
2191a5a4af3bSchristos    "mq" 3-bit MIPS registers 0, 2-7, 17 (MICROMIPSOP_*_MQ) at bit 7
2192a5a4af3bSchristos    "mr" must be program counter
2193a5a4af3bSchristos    "ms" must be $29
2194a5a4af3bSchristos    "mt" must be the same as the previous register
2195a5a4af3bSchristos    "mx" must be the same as the destination register
2196a5a4af3bSchristos    "my" must be $31
2197a5a4af3bSchristos    "mz" must be $0
2198a5a4af3bSchristos 
2199a5a4af3bSchristos    "mA" 7-bit immediate (-64 .. 63) << 2 (MICROMIPSOP_*_IMMA)
2200a5a4af3bSchristos    "mB" 3-bit immediate (-1, 1, 4, 8, 12, 16, 20, 24) (MICROMIPSOP_*_IMMB)
2201a5a4af3bSchristos    "mC" 4-bit immediate (1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64, 128, 255,
2202a5a4af3bSchristos         32768, 65535) (MICROMIPSOP_*_IMMC)
2203a5a4af3bSchristos    "mD" 10-bit branch address (-512 .. 511) << 1 (MICROMIPSOP_*_IMMD)
2204a5a4af3bSchristos    "mE" 7-bit branch address (-64 .. 63) << 1 (MICROMIPSOP_*_IMME)
2205a5a4af3bSchristos    "mF" 4-bit immediate (0 .. 15)  (MICROMIPSOP_*_IMMF)
2206a5a4af3bSchristos    "mG" 4-bit immediate (-1 .. 14) (MICROMIPSOP_*_IMMG)
2207a5a4af3bSchristos    "mH" 4-bit immediate (0 .. 15) << 1 (MICROMIPSOP_*_IMMH)
2208a5a4af3bSchristos    "mI" 7-bit immediate (-1 .. 126) (MICROMIPSOP_*_IMMI)
2209a5a4af3bSchristos    "mJ" 4-bit immediate (0 .. 15) << 2 (MICROMIPSOP_*_IMMJ)
2210a5a4af3bSchristos    "mL" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
2211a5a4af3bSchristos    "mM" 3-bit immediate (1 .. 8) (MICROMIPSOP_*_IMMM)
2212a5a4af3bSchristos    "mN" 2-bit immediate (0 .. 3) for register list (MICROMIPSOP_*_IMMN)
2213a5a4af3bSchristos    "mO" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
2214a5a4af3bSchristos    "mP" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMP)
2215a5a4af3bSchristos    "mU" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMU)
2216a5a4af3bSchristos    "mW" 6-bit immediate (0 .. 63) << 2 (MICROMIPSOP_*_IMMW)
2217a5a4af3bSchristos    "mX" 4-bit immediate (-8 .. 7) (MICROMIPSOP_*_IMMX)
2218a5a4af3bSchristos    "mY" 9-bit immediate (-258 .. -3, 2 .. 257) << 2 (MICROMIPSOP_*_IMMY)
2219a5a4af3bSchristos    "mZ" must be zero
2220a5a4af3bSchristos 
2221a5a4af3bSchristos    In most cases 32-bit microMIPS instructions use the same characters
2222a5a4af3bSchristos    as MIPS (with ADDIUPC being a notable exception, but there are some
2223a5a4af3bSchristos    others too).
2224a5a4af3bSchristos 
2225a5a4af3bSchristos    "." 10-bit signed offset/number (MICROMIPSOP_*_OFFSET10)
2226a5a4af3bSchristos    "1" 5-bit sync type (MICROMIPSOP_*_STYPE)
2227a5a4af3bSchristos    "<" 5-bit shift amount (MICROMIPSOP_*_SHAMT)
2228a5a4af3bSchristos    ">" shift amount between 32 and 63, stored after subtracting 32
2229a5a4af3bSchristos        (MICROMIPSOP_*_SHAMT)
2230a5a4af3bSchristos    "\" 3-bit position for ASET and ACLR (MICROMIPSOP_*_3BITPOS)
2231a5a4af3bSchristos    "|" 4-bit trap code (MICROMIPSOP_*_TRAP)
2232a5a4af3bSchristos    "~" 12-bit signed offset (MICROMIPSOP_*_OFFSET12)
2233a5a4af3bSchristos    "a" 26-bit target address (MICROMIPSOP_*_TARGET)
2234a5a4af3bSchristos    "+i" likewise, but flips bit 0
2235a5a4af3bSchristos    "b" 5-bit base register (MICROMIPSOP_*_RS)
2236a5a4af3bSchristos    "c" 10-bit higher breakpoint code (MICROMIPSOP_*_CODE)
2237a5a4af3bSchristos    "d" 5-bit destination register specifier (MICROMIPSOP_*_RD)
2238a5a4af3bSchristos    "h" 5-bit PREFX hint (MICROMIPSOP_*_PREFX)
2239a5a4af3bSchristos    "i" 16-bit unsigned immediate (MICROMIPSOP_*_IMMEDIATE)
2240a5a4af3bSchristos    "j" 16-bit signed immediate (MICROMIPSOP_*_DELTA)
2241a5a4af3bSchristos    "k" 5-bit cache opcode in target register position (MICROMIPSOP_*_CACHE)
2242a5a4af3bSchristos    "n" register list for 32-bit LWM/SWM instruction (MICROMIPSOP_*_RT)
2243a5a4af3bSchristos    "o" 16-bit signed offset (MICROMIPSOP_*_DELTA)
2244a5a4af3bSchristos    "p" 16-bit PC-relative branch target address (MICROMIPSOP_*_DELTA)
2245a5a4af3bSchristos    "q" 10-bit lower breakpoint code (MICROMIPSOP_*_CODE2)
2246a5a4af3bSchristos    "r" 5-bit same register used as both source and target (MICROMIPSOP_*_RS)
2247a5a4af3bSchristos    "s" 5-bit source register specifier (MICROMIPSOP_*_RS)
2248a5a4af3bSchristos    "t" 5-bit target register (MICROMIPSOP_*_RT)
2249a5a4af3bSchristos    "u" 16-bit upper 16 bits of address (MICROMIPSOP_*_IMMEDIATE)
2250a5a4af3bSchristos    "v" 5-bit same register used as both source and destination
2251a5a4af3bSchristos        (MICROMIPSOP_*_RS)
2252a5a4af3bSchristos    "w" 5-bit same register used as both target and destination
2253a5a4af3bSchristos        (MICROMIPSOP_*_RT)
2254a5a4af3bSchristos    "y" 5-bit source 3 register for ALNV.PS (MICROMIPSOP_*_RS3)
2255a5a4af3bSchristos    "z" must be zero register
2256a5a4af3bSchristos    "C" 23-bit coprocessor function code (MICROMIPSOP_*_COPZ)
2257a5a4af3bSchristos    "K" 5-bit Hardware Register (RDHWR instruction) (MICROMIPSOP_*_RS)
2258a5a4af3bSchristos 
2259a5a4af3bSchristos    "+A" 5-bit INS/EXT/DINS/DEXT/DINSM/DEXTM position, which becomes
2260a5a4af3bSchristos         LSB (MICROMIPSOP_*_EXTLSB).
2261a5a4af3bSchristos 	Enforces: 0 <= pos < 32.
2262a5a4af3bSchristos    "+B" 5-bit INS/DINS size, which becomes MSB (MICROMIPSOP_*_INSMSB).
2263a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
2264a5a4af3bSchristos 	Enforces: 0 < (pos+size) <= 32.
2265a5a4af3bSchristos    "+C" 5-bit EXT/DEXT size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
2266a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
2267a5a4af3bSchristos 	Enforces: 0 < (pos+size) <= 32.
2268a5a4af3bSchristos 	(Also used by DEXT w/ different limits, but limits for
2269a5a4af3bSchristos 	that are checked by the M_DEXT macro.)
2270a5a4af3bSchristos    "+E" 5-bit DINSU/DEXTU position, which becomes LSB-32 (MICROMIPSOP_*_EXTLSB).
2271a5a4af3bSchristos 	Enforces: 32 <= pos < 64.
2272a5a4af3bSchristos    "+F" 5-bit DINSM/DINSU size, which becomes MSB-32 (MICROMIPSOP_*_INSMSB).
2273a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
2274a5a4af3bSchristos 	Enforces: 32 < (pos+size) <= 64.
2275a5a4af3bSchristos    "+G" 5-bit DEXTM size, which becomes MSBD-32 (MICROMIPSOP_*_EXTMSBD).
2276a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
2277a5a4af3bSchristos 	Enforces: 32 < (pos+size) <= 64.
2278a5a4af3bSchristos    "+H" 5-bit DEXTU size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
2279a5a4af3bSchristos 	Requires that "+A" or "+E" occur first to set position.
2280a5a4af3bSchristos 	Enforces: 32 < (pos+size) <= 64.
2281a5a4af3bSchristos    "+J" 10-bit SYSCALL/WAIT/SDBBP/HYPCALL function code
2282a5a4af3bSchristos         (MICROMIPSOP_*_CODE10)
2283a5a4af3bSchristos 
2284a5a4af3bSchristos    PC-relative addition (ADDIUPC) instruction:
2285a5a4af3bSchristos    "mQ" 23-bit offset (-4194304 .. 4194303) << 2 (MICROMIPSOP_*_IMMQ)
2286a5a4af3bSchristos    "mb" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MB) at bit 23
2287a5a4af3bSchristos 
2288a5a4af3bSchristos    Floating point instructions:
2289a5a4af3bSchristos    "D" 5-bit destination register (MICROMIPSOP_*_FD)
2290a5a4af3bSchristos    "M" 3-bit compare condition code (MICROMIPSOP_*_CCC)
2291a5a4af3bSchristos    "N" 3-bit branch condition code (MICROMIPSOP_*_BCC)
2292a5a4af3bSchristos    "R" 5-bit fr source 3 register (MICROMIPSOP_*_FR)
2293a5a4af3bSchristos    "S" 5-bit fs source 1 register (MICROMIPSOP_*_FS)
2294a5a4af3bSchristos    "T" 5-bit ft source 2 register (MICROMIPSOP_*_FT)
2295a5a4af3bSchristos    "V" 5-bit same register used as floating source and destination or target
2296a5a4af3bSchristos        (MICROMIPSOP_*_FS)
2297a5a4af3bSchristos 
2298a5a4af3bSchristos    Coprocessor instructions:
2299a5a4af3bSchristos    "E" 5-bit target register (MICROMIPSOP_*_RT)
2300a5a4af3bSchristos    "G" 5-bit source register (MICROMIPSOP_*_RS)
2301a5a4af3bSchristos    "H" 3-bit sel field for (D)MTC* and (D)MFC* (MICROMIPSOP_*_SEL)
2302*8b657b07Schristos    "g" 5-bit control source register (MICROMIPSOP_*_RS)
2303a5a4af3bSchristos 
2304a5a4af3bSchristos    Macro instructions:
2305a5a4af3bSchristos    "A" general 32 bit expression
2306a5a4af3bSchristos    "I" 32-bit immediate (value placed in imm_expr).
2307a5a4af3bSchristos    "F" 64-bit floating point constant in .rdata
2308a5a4af3bSchristos    "L" 64-bit floating point constant in .lit8
2309a5a4af3bSchristos    "f" 32-bit floating point constant
2310a5a4af3bSchristos    "l" 32-bit floating point constant in .lit4
2311a5a4af3bSchristos 
2312a5a4af3bSchristos    DSP ASE usage:
2313a5a4af3bSchristos    "2" 2-bit unsigned immediate for byte align (MICROMIPSOP_*_BP)
2314a5a4af3bSchristos    "3" 3-bit unsigned immediate (MICROMIPSOP_*_SA3)
2315a5a4af3bSchristos    "4" 4-bit unsigned immediate (MICROMIPSOP_*_SA4)
2316a5a4af3bSchristos    "5" 8-bit unsigned immediate (MICROMIPSOP_*_IMM8)
2317a5a4af3bSchristos    "6" 5-bit unsigned immediate (MICROMIPSOP_*_RS)
2318a5a4af3bSchristos    "7" 2-bit DSP accumulator register (MICROMIPSOP_*_DSPACC)
2319a5a4af3bSchristos    "8" 6-bit unsigned immediate (MICROMIPSOP_*_WRDSP)
2320a5a4af3bSchristos    "0" 6-bit signed immediate (MICROMIPSOP_*_DSPSFT)
2321a5a4af3bSchristos    "@" 10-bit signed immediate (MICROMIPSOP_*_IMM10)
2322a5a4af3bSchristos    "^" 5-bit unsigned immediate (MICROMIPSOP_*_RD)
2323a5a4af3bSchristos 
2324a5a4af3bSchristos    microMIPS Enhanced VA Scheme:
2325a5a4af3bSchristos    "+j" 9-bit signed offset in bit 0 (OP_*_EVAOFFSET)
2326a5a4af3bSchristos 
2327a5a4af3bSchristos    MSA Extension:
2328a5a4af3bSchristos    "+d" 5-bit MSA register (FD)
2329a5a4af3bSchristos    "+e" 5-bit MSA register (FS)
2330a5a4af3bSchristos    "+h" 5-bit MSA register (FT)
2331a5a4af3bSchristos    "+k" 5-bit GPR at bit 6
2332a5a4af3bSchristos    "+l" 5-bit MSA control register at bit 6
2333a5a4af3bSchristos    "+n" 5-bit MSA control register at bit 11
2334a5a4af3bSchristos    "+o" 4-bit vector element index at bit 16
2335a5a4af3bSchristos    "+u" 3-bit vector element index at bit 16
2336a5a4af3bSchristos    "+v" 2-bit vector element index at bit 16
2337a5a4af3bSchristos    "+w" 1-bit vector element index at bit 16
2338a5a4af3bSchristos    "+x" 5-bit shift amount at bit 16
2339a5a4af3bSchristos    "+T" (-512 .. 511) << 0 at bit 16
2340a5a4af3bSchristos    "+U" (-512 .. 511) << 1 at bit 16
2341a5a4af3bSchristos    "+V" (-512 .. 511) << 2 at bit 16
2342a5a4af3bSchristos    "+W" (-512 .. 511) << 3 at bit 16
2343a5a4af3bSchristos    "+~" 2 bit LSA/DLSA shift amount from 1 to 4 at bit 6
2344a5a4af3bSchristos    "+!" 3 bit unsigned bit position at bit 16
2345a5a4af3bSchristos    "+@" 4 bit unsigned bit position at bit 16
2346a5a4af3bSchristos    "+#" 6 bit unsigned bit position at bit 16
2347a5a4af3bSchristos    "+$" 5 bit unsigned immediate at bit 16
2348a5a4af3bSchristos    "+%" 5 bit signed immediate at bit 16
2349a5a4af3bSchristos    "+^" 10 bit signed immediate at bit 11
2350a5a4af3bSchristos    "+&" 0 vector element index
2351a5a4af3bSchristos    "+*" 5-bit register vector element index at bit 16
2352a5a4af3bSchristos    "+|" 8-bit mask at bit 16
2353a5a4af3bSchristos 
2354a5a4af3bSchristos    Other:
2355a5a4af3bSchristos    "()" parens surrounding optional value
2356a5a4af3bSchristos    ","  separates operands
2357a5a4af3bSchristos    "+"  start of extension sequence
2358a5a4af3bSchristos    "m"  start of microMIPS extension sequence
2359a5a4af3bSchristos 
2360a5a4af3bSchristos    Characters used so far, for quick reference when adding more:
2361a5a4af3bSchristos    "12345678 0"
2362a5a4af3bSchristos    "<>(),+-.@\^|~"
2363a5a4af3bSchristos    "ABCDEFGHI KLMN   RST V    "
2364*8b657b07Schristos    "abcd fghijklmnopqrstuvw yz"
2365a5a4af3bSchristos 
2366a5a4af3bSchristos    Extension character sequences used so far ("+" followed by the
2367a5a4af3bSchristos    following), for quick reference when adding more:
2368a5a4af3bSchristos    ""
2369a5a4af3bSchristos    "~!@#$%^&*|"
2370a5a4af3bSchristos    "ABCEFGHJTUVW"
2371a5a4af3bSchristos    "dehijklnouvwx"
2372a5a4af3bSchristos 
2373a5a4af3bSchristos    Extension character sequences used so far ("m" followed by the
2374a5a4af3bSchristos    following), for quick reference when adding more:
2375a5a4af3bSchristos    ""
2376a5a4af3bSchristos    ""
2377a5a4af3bSchristos    " BCDEFGHIJ LMNOPQ   U WXYZ"
2378a5a4af3bSchristos    " bcdefghij lmn pq st   xyz"
2379a5a4af3bSchristos 
2380a5a4af3bSchristos    Extension character sequences used so far ("-" followed by the
2381a5a4af3bSchristos    following), for quick reference when adding more:
2382a5a4af3bSchristos    ""
2383a5a4af3bSchristos    ""
2384a5a4af3bSchristos    <none so far>
2385a5a4af3bSchristos */
2386a5a4af3bSchristos 
2387a5a4af3bSchristos extern const struct mips_operand *decode_micromips_operand (const char *);
2388a5a4af3bSchristos extern const struct mips_opcode micromips_opcodes[];
2389a5a4af3bSchristos extern const int bfd_micromips_num_opcodes;
2390a5a4af3bSchristos 
2391a5a4af3bSchristos /* A NOP insn impemented as "or at,at,zero".
2392a5a4af3bSchristos    Used to implement -mfix-loongson2f.  */
2393a5a4af3bSchristos #define LOONGSON2F_NOP_INSN	0x00200825
2394a5a4af3bSchristos 
2395e5cb852cSchristos #ifdef __cplusplus
2396e5cb852cSchristos }
2397e5cb852cSchristos #endif
2398e5cb852cSchristos 
2399a5a4af3bSchristos #endif /* _MIPS_H_ */
2400