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