1 /* mips.h. Mips opcode list for GDB, the GNU debugger.
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005, 2008, 2009, 2010, 2013
4 Free Software Foundation, Inc.
5 Contributed by Ralph Campbell and OSF
6 Commented and modified by Ian Lance Taylor, Cygnus Support
8 This file is part of GDB, GAS, and the GNU binutils.
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.
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.
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. */
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)
37 Make sure you use fields that are appropriate for the instruction,
40 The 'i' format uses OP, RS, RT and IMMEDIATE.
42 The 'j' format uses OP and TARGET.
44 The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT.
46 The 'b' format uses OP, RS, RT and DELTA.
48 The floating point 'i' format uses OP, RS, RT and IMMEDIATE.
50 The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT.
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
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
60 The syscall instruction uses CODE20.
62 The general coprocessor instructions use COPZ. */
64 #define OP_MASK_OP 0x3f
66 #define OP_MASK_RS 0x1f
68 #define OP_MASK_FR 0x1f
70 #define OP_MASK_FMT 0x1f
72 #define OP_MASK_BCC 0x7
74 #define OP_MASK_CODE 0x3ff
76 #define OP_MASK_CODE2 0x3ff
78 #define OP_MASK_RT 0x1f
80 #define OP_MASK_FT 0x1f
82 #define OP_MASK_CACHE 0x1f
83 #define OP_SH_CACHE 16
84 #define OP_MASK_RD 0x1f
86 #define OP_MASK_FS 0x1f
88 #define OP_MASK_PREFX 0x1f
89 #define OP_SH_PREFX 11
90 #define OP_MASK_CCC 0x7
92 #define OP_MASK_CODE20 0xfffff /* 20 bit syscall/breakpoint code. */
93 #define OP_SH_CODE20 6
94 #define OP_MASK_SHAMT 0x1f
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
100 #define OP_MASK_FD 0x1f
102 #define OP_MASK_TARGET 0x3ffffff
103 #define OP_SH_TARGET 0
104 #define OP_MASK_COPZ 0x1ffffff
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
114 #define OP_SH_LOCC 8 /* FP condition code. */
115 #define OP_SH_HICC 18 /* FP condition code. */
116 #define OP_MASK_CC 0x7
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. */
120 #define OP_MASK_COP1SPEC 0xf
121 #define OP_MASK_COP1SCLR 0x4
122 #define OP_MASK_COP1CMP 0x3
123 #define OP_SH_COP1CMP 4
124 #define OP_SH_FORMAT 21 /* FP short format field. */
125 #define OP_MASK_FORMAT 0x7
126 #define OP_SH_TRUE 16
127 #define OP_MASK_TRUE 0x1
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
134 #define OP_SH_MMI 0 /* Multimedia (parallel) op. */
135 #define OP_MASK_MMI 0x3f
136 #define OP_SH_MMISUB 6
137 #define OP_MASK_MMISUB 0x1f
138 #define OP_MASK_PERFREG 0x1f /* Performance monitoring. */
139 #define OP_SH_PERFREG 1
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
145 #define OP_MASK_ALN 0x7
146 #define OP_SH_VSEL 21
147 #define OP_MASK_VSEL 0x1f
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
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
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
168 #define OP_MASK_SA3 0x7
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
180 #define OP_MASK_BP 0x3
184 #define OP_MASK_MT_U 0x1
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
193 #define OP_MASK_3BITPOS 0x7
194 #define OP_SH_3BITPOS 12
195 #define OP_MASK_OFFSET12 0xfff
196 #define OP_SH_OFFSET12 0
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 */
216 #define OP_MASK_CODE10 0x3ff
217 #define OP_SH_CODE10 11
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
227 #define OP_MASK_UDI1 0x1f
229 #define OP_MASK_UDI2 0x3ff
231 #define OP_MASK_UDI3 0x7fff
233 #define OP_MASK_UDI4 0xfffff
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
243 #define OP_MASK_SEQI 0x3ff
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
253 #define OP_MASK_RZ 0x1f
255 #define OP_MASK_FZ 0x1f
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
262 #define OP_MASK_TRAP 0
264 #define OP_MASK_OFFSET10 0
265 #define OP_SH_OFFSET10 0
266 #define OP_MASK_RS3 0
294 #define OP_MASK_IMMA 0
296 #define OP_MASK_IMMB 0
298 #define OP_MASK_IMMC 0
300 #define OP_MASK_IMMF 0
302 #define OP_MASK_IMMG 0
304 #define OP_MASK_IMMH 0
306 #define OP_MASK_IMMI 0
308 #define OP_MASK_IMMJ 0
310 #define OP_MASK_IMML 0
312 #define OP_MASK_IMMM 0
314 #define OP_MASK_IMMN 0
316 #define OP_MASK_IMMO 0
318 #define OP_MASK_IMMP 0
320 #define OP_MASK_IMMQ 0
322 #define OP_MASK_IMMU 0
324 #define OP_MASK_IMMW 0
326 #define OP_MASK_IMMX 0
328 #define OP_MASK_IMMY 0
331 /* Enhanced VA Scheme */
332 #define OP_SH_EVAOFFSET 7
333 #define OP_MASK_EVAOFFSET 0x1ff
335 /* Enumerates the various types of MIPS operand. */
336 enum mips_operand_type
{
337 /* Described by mips_int_operand. */
340 /* Described by mips_mapped_int_operand. */
343 /* Described by mips_msb_operand. */
346 /* Described by mips_reg_operand. */
349 /* Described by mips_reg_pair_operand. */
352 /* Described by mips_pcrel_operand. */
355 /* A performance register. The field is 5 bits in size, but the supported
356 values are much more restricted. */
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:
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
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. */
378 /* A 10-bit field VVVVVNNNNN used for octobyte and quadhalf instructions:
382 0EEE0 8 copies of $vN[E], OB format
383 0EE01 4 copies of $vN[E], QH format
384 10110 all 8 elements of $vN, OB format
385 10101 all 4 elements of $vN, QH format
386 11110 8 copies of immediate N, OB format
387 11101 4 copies of immediate N, QH format. */
390 /* A register operand that must match the destination register. */
393 /* A register operand that must match the previous register. */
396 /* $pc, which has no encoding in the architectural instruction. */
400 /* Enumerates the types of MIPS register. */
401 enum mips_reg_operand_type
{
402 /* General registers $0-$31. Software names like $at can also be used. */
405 /* Floating-point registers $f0-$f31. */
408 /* Coprocessor condition code registers $cc0-$cc7. FPU condition codes
409 can also be written $fcc0-$fcc7. */
412 /* FPRs used in a vector capacity. They can be written $f0-$f31
413 or $v0-$v31, although the latter form is not used for the VR5400
414 vector instructions. */
417 /* DSP accumulator registers $ac0-$ac3. */
420 /* Coprocessor registers $0-$31. Mnemonic names like c0_cause can
421 also be used in some contexts. */
424 /* Hardware registers $0-$31. Mnemonic names like hwr_cpunum can
425 also be used in some contexts. */
429 /* Base class for all operands. */
432 /* The type of the operand. */
433 enum mips_operand_type type
;
435 /* The operand occupies SIZE bits of the instruction, starting at LSB. */
440 /* Describes an integer operand with a regular encoding pattern. */
441 struct mips_int_operand
443 struct mips_operand root
;
445 /* The low ROOT.SIZE bits of MAX_VAL encodes (MAX_VAL + BIAS) << SHIFT.
446 The cyclically previous field value encodes 1 << SHIFT less than that,
449 - for { { T, 4, L }, 14, 0, 0 }, field values 0...14 encode themselves,
452 - { { T, 8, L }, 127, 0, 2 } is a normal signed 8-bit operand that is
453 shifted left two places.
455 - { { T, 3, L }, 8, 0, 0 } is a normal unsigned 3-bit operand except
458 - { { ... }, 0, 1, 3 } means that N encodes (N + 1) << 3. */
459 unsigned int max_val
;
463 /* True if the operand should be printed as hex rather than decimal. */
464 bfd_boolean print_hex
;
467 /* Uses a lookup table to describe a small integer operand. */
468 struct mips_mapped_int_operand
470 struct mips_operand root
;
472 /* Maps each encoding value to the integer that it represents. */
475 /* True if the operand should be printed as hex rather than decimal. */
476 bfd_boolean print_hex
;
479 /* An operand that encodes the most significant bit position of a bitfield.
480 Given a bitfield that spans bits [MSB, LSB], some operands of this type
481 encode MSB directly while others encode MSB - LSB. Each operand of this
482 type is preceded by an integer operand that specifies LSB.
484 The assembly form varies between instructions. For some instructions,
485 such as EXT, the operand is written as the bitfield size. For others,
486 such as EXTS, it is written in raw MSB - LSB form. */
487 struct mips_msb_operand
489 struct mips_operand root
;
491 /* The assembly-level operand encoded by a field value of 0. */
494 /* True if the operand encodes MSB directly, false if it encodes
498 /* The maximum value of MSB + 1. */
502 /* Describes a single register operand. */
503 struct mips_reg_operand
505 struct mips_operand root
;
507 /* The type of register. */
508 enum mips_reg_operand_type reg_type
;
510 /* If nonnull, REG_MAP[N] gives the register associated with encoding N,
511 otherwise the encoding is the same as the register number. */
512 const unsigned char *reg_map
;
515 /* Describes an operand that encodes a pair of registers. */
516 struct mips_reg_pair_operand
518 struct mips_operand root
;
520 /* The type of register. */
521 enum mips_reg_operand_type reg_type
;
523 /* Encoding N represents REG1_MAP[N], REG2_MAP[N]. */
524 unsigned char *reg1_map
;
525 unsigned char *reg2_map
;
528 /* Describes an operand that is calculated relative to a base PC.
529 The base PC is usually the address of the following instruction,
530 but the rules for MIPS16 instructions like ADDIUPC are more complicated. */
531 struct mips_pcrel_operand
533 struct mips_operand root
;
535 /* The low ALIGN_LOG2 bits of the base PC are cleared to give PC'. */
536 unsigned int align_log2
: 8;
538 /* The operand is shifted left SHIFT places and added to PC'.
539 The operand is signed if IS_SIGNED. */
540 unsigned int shift
: 8;
541 unsigned int is_signed
: 1;
543 /* If INCLUDE_ISA_BIT, the ISA bit of the original base PC is then
544 reinstated. This is true for jumps and branches and false for
545 PC-relative data instructions. */
546 unsigned int include_isa_bit
: 1;
548 /* If FLIP_ISA_BIT, the ISA bit of the result is inverted.
549 This is true for JALX and false otherwise. */
550 unsigned int flip_isa_bit
: 1;
553 /* Return a version of INSN in which the field specified by OPERAND
556 static inline unsigned int
557 mips_insert_operand (const struct mips_operand
*operand
, unsigned int insn
,
562 mask
= (1 << operand
->size
) - 1;
563 insn
&= ~(mask
<< operand
->lsb
);
564 insn
|= (uval
& mask
) << operand
->lsb
;
568 /* Extract OPERAND from instruction INSN. */
570 static inline unsigned int
571 mips_extract_operand (const struct mips_operand
*operand
, unsigned int insn
)
573 return (insn
>> operand
->lsb
) & ((1 << operand
->size
) - 1);
576 /* UVAL is the value encoded by OPERAND. Return it in signed form. */
579 mips_signed_operand (const struct mips_operand
*operand
, unsigned int uval
)
581 unsigned int sign_bit
, mask
;
583 mask
= (1 << operand
->size
) - 1;
584 sign_bit
= 1 << (operand
->size
- 1);
585 return ((uval
+ sign_bit
) & mask
) - sign_bit
;
588 /* Return the integer that OPERAND encodes as UVAL. */
591 mips_decode_int_operand (const struct mips_int_operand
*operand
,
594 uval
|= (operand
->max_val
- uval
) & -(1 << operand
->root
.size
);
595 uval
+= operand
->bias
;
596 uval
<<= operand
->shift
;
600 /* PC-relative operand OPERAND has value UVAL and is relative to BASE_PC.
601 Return the address that it encodes. */
603 static inline bfd_vma
604 mips_decode_pcrel_operand (const struct mips_pcrel_operand
*operand
,
605 bfd_vma base_pc
, unsigned int uval
)
609 addr
= base_pc
& -(1 << operand
->align_log2
);
610 if (operand
->is_signed
)
611 addr
+= mips_signed_operand (&operand
->root
, uval
) * (1 << operand
->shift
);
613 addr
+= uval
<< operand
->shift
;
614 if (operand
->include_isa_bit
)
616 if (operand
->flip_isa_bit
)
621 /* This structure holds information for a particular instruction. */
625 /* The name of the instruction. */
627 /* A string describing the arguments for this instruction. */
629 /* The basic opcode for the instruction. When assembling, this
630 opcode is modified by the arguments to produce the actual opcode
631 that is used. If pinfo is INSN_MACRO, then this is 0. */
633 /* If pinfo is not INSN_MACRO, then this is a bit mask for the
634 relevant portions of the opcode when disassembling. If the
635 actual opcode anded with the match field equals the opcode field,
636 then we have found the correct instruction. If pinfo is
637 INSN_MACRO, then this field is the macro identifier. */
639 /* For a macro, this is INSN_MACRO. Otherwise, it is a collection
640 of bits describing the instruction, notably any relevant hazard
643 /* A collection of additional bits describing the instruction. */
644 unsigned long pinfo2
;
645 /* A collection of bits describing the instruction sets of which this
646 instruction or macro is a member. */
647 unsigned long membership
;
648 /* A collection of bits describing the ASE of which this instruction
649 or macro is a member. */
651 /* A collection of bits describing the instruction sets of which this
652 instruction or macro is not a member. */
653 unsigned long exclusions
;
656 /* These are the characters which may appear in the args field of an
657 instruction. They appear in the order in which the fields appear
658 when the instruction is used. Commas and parentheses in the args
659 string are ignored when assembling, and written into the output
662 Each of these characters corresponds to a mask field defined above.
664 "1" 5 bit sync type (OP_*_STYPE)
665 "<" 5 bit shift amount (OP_*_SHAMT)
666 ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
667 "a" 26 bit target address (OP_*_TARGET)
668 "+i" likewise, but flips bit 0
669 "b" 5 bit base register (OP_*_RS)
670 "c" 10 bit breakpoint code (OP_*_CODE)
671 "d" 5 bit destination register specifier (OP_*_RD)
672 "h" 5 bit prefx hint (OP_*_PREFX)
673 "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
674 "j" 16 bit signed immediate (OP_*_DELTA)
675 "k" 5 bit cache opcode in target register position (OP_*_CACHE)
676 "o" 16 bit signed offset (OP_*_DELTA)
677 "p" 16 bit PC relative branch target address (OP_*_DELTA)
678 "q" 10 bit extra breakpoint code (OP_*_CODE2)
679 "r" 5 bit same register used as both source and target (OP_*_RS)
680 "s" 5 bit source register specifier (OP_*_RS)
681 "t" 5 bit target register (OP_*_RT)
682 "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
683 "v" 5 bit same register used as both source and destination (OP_*_RS)
684 "w" 5 bit same register used as both target and destination (OP_*_RT)
685 "U" 5 bit same destination register in both OP_*_RD and OP_*_RT
686 (used by clo and clz)
687 "C" 25 bit coprocessor function code (OP_*_COPZ)
688 "B" 20 bit syscall/breakpoint function code (OP_*_CODE20)
689 "J" 19 bit wait function code (OP_*_CODE19)
690 "x" accept and ignore register name
691 "z" must be zero register
692 "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD)
693 "+A" 5 bit ins/ext/dins/dext/dinsm/dextm position, which becomes
694 LSB (OP_*_SHAMT; OP_*_EXTLSB or OP_*_STYPE may be used for
695 microMIPS compatibility).
696 Enforces: 0 <= pos < 32.
697 "+B" 5 bit ins/dins size, which becomes MSB (OP_*_INSMSB).
698 Requires that "+A" or "+E" occur first to set position.
699 Enforces: 0 < (pos+size) <= 32.
700 "+C" 5 bit ext/dext size, which becomes MSBD (OP_*_EXTMSBD).
701 Requires that "+A" or "+E" occur first to set position.
702 Enforces: 0 < (pos+size) <= 32.
703 (Also used by "dext" w/ different limits, but limits for
704 that are checked by the M_DEXT macro.)
705 "+E" 5 bit dinsu/dextu position, which becomes LSB-32 (OP_*_SHAMT).
706 Enforces: 32 <= pos < 64.
707 "+F" 5 bit "dinsm/dinsu" size, which becomes MSB-32 (OP_*_INSMSB).
708 Requires that "+A" or "+E" occur first to set position.
709 Enforces: 32 < (pos+size) <= 64.
710 "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD).
711 Requires that "+A" or "+E" occur first to set position.
712 Enforces: 32 < (pos+size) <= 64.
713 "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD).
714 Requires that "+A" or "+E" occur first to set position.
715 Enforces: 32 < (pos+size) <= 64.
717 Floating point instructions:
718 "D" 5 bit destination register (OP_*_FD)
719 "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
720 "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
721 "S" 5 bit fs source 1 register (OP_*_FS)
722 "T" 5 bit ft source 2 register (OP_*_FT)
723 "R" 5 bit fr source 3 register (OP_*_FR)
724 "V" 5 bit same register used as floating source and destination (OP_*_FS)
725 "W" 5 bit same register used as floating target and destination (OP_*_FT)
727 Coprocessor instructions:
728 "E" 5 bit target register (OP_*_RT)
729 "G" 5 bit destination register (OP_*_RD)
730 "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL)
731 "P" 5 bit performance-monitor register (OP_*_PERFREG)
732 "e" 5 bit vector register byte specifier (OP_*_VECBYTE)
733 "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN)
736 "A" General 32 bit expression
737 "I" 32 bit immediate (value placed in imm_expr).
738 "+I" 32 bit immediate (value placed in imm2_expr).
739 "F" 64 bit floating point constant in .rdata
740 "L" 64 bit floating point constant in .lit8
741 "f" 32 bit floating point constant
742 "l" 32 bit floating point constant in .lit4
744 MDMX and VR5400 instruction operands (note that while these use the
745 FP register fields, the MDMX instructions accept both $fN and $vN names
747 "O" alignment offset (OP_*_ALN)
748 "Q" vector/scalar/immediate source (OP_*_VSEL and OP_*_FT)
749 "X" destination register (OP_*_FD)
750 "Y" source register (OP_*_FS)
751 "Z" source register (OP_*_FT)
754 "2" 2 bit unsigned immediate for byte align (OP_*_BP)
755 "3" 3 bit unsigned immediate (OP_*_SA3)
756 "4" 4 bit unsigned immediate (OP_*_SA4)
757 "5" 8 bit unsigned immediate (OP_*_IMM8)
758 "6" 5 bit unsigned immediate (OP_*_RS)
759 "7" 2 bit dsp accumulator register (OP_*_DSPACC)
760 "8" 6 bit unsigned immediate (OP_*_WRDSP)
761 "9" 2 bit dsp accumulator register (OP_*_DSPACC_S)
762 "0" 6 bit signed immediate (OP_*_DSPSFT)
763 ":" 7 bit signed immediate (OP_*_DSPSFT_7)
764 "'" 6 bit unsigned immediate (OP_*_RDDSP)
765 "@" 10 bit signed immediate (OP_*_IMM10)
768 "!" 1 bit usermode flag (OP_*_MT_U)
769 "$" 1 bit load high flag (OP_*_MT_H)
770 "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T)
771 "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D)
772 "g" 5 bit coprocessor 1 and 2 destination register (OP_*_RD)
773 "+t" 5 bit coprocessor 0 destination register (OP_*_RT)
776 "~" 12 bit offset (OP_*_OFFSET12)
777 "\" 3 bit position for aset and aclr (OP_*_3BITPOS)
780 "+J" 10-bit hypcall code (OP_*CODE10)
783 "+1" UDI immediate bits 6-10
784 "+2" UDI immediate bits 6-15
785 "+3" UDI immediate bits 6-20
786 "+4" UDI immediate bits 6-25
789 "+x" Bit index field of bbit. Enforces: 0 <= index < 32.
790 "+X" Bit index field of bbit aliasing bbit32. Matches if 32 <= index < 64,
791 otherwise skips to next candidate.
792 "+p" Position field of cins/cins32/exts/exts32. Enforces 0 <= pos < 32.
793 "+P" Position field of cins/exts aliasing cins32/exts32. Matches if
794 32 <= pos < 64, otherwise skips to next candidate.
795 "+Q" Immediate field of seqi/snei. Enforces -512 <= imm < 512.
796 "+s" Length-minus-one field of cins32/exts32. Requires msb position
797 of the field to be <= 31.
798 "+S" Length-minus-one field of cins/exts. Requires msb position
799 of the field to be <= 63.
802 "+a" 8-bit signed offset in bit 6 (OP_*_OFFSET_A)
803 "+b" 8-bit signed offset in bit 3 (OP_*_OFFSET_B)
804 "+c" 9-bit signed offset in bit 6 (OP_*_OFFSET_C)
805 "+z" 5-bit rz register (OP_*_RZ)
806 "+Z" 5-bit fz register (OP_*_FZ)
809 "+j" 9-bit signed offset in bit 7 (OP_*_EVAOFFSET)
812 "()" parens surrounding optional value
813 "," separates operands
814 "+" Start of extension sequence.
816 Characters used so far, for quick reference when adding more:
819 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
820 "abcdefghijklopqrstuvwxz"
822 Extension character sequences used so far ("+" followed by the
823 following), for quick reference when adding more:
829 /* These are the bits which may be set in the pinfo field of an
830 instructions, if it is not equal to INSN_MACRO. */
832 /* Modifies the general purpose register in OP_*_RD. */
833 #define INSN_WRITE_GPR_D 0x00000001
834 /* Modifies the general purpose register in OP_*_RT. */
835 #define INSN_WRITE_GPR_T 0x00000002
836 /* Modifies general purpose register 31. */
837 #define INSN_WRITE_GPR_31 0x00000004
838 /* Modifies the floating point register in OP_*_FD. */
839 #define INSN_WRITE_FPR_D 0x00000008
840 /* Modifies the floating point register in OP_*_FS. */
841 #define INSN_WRITE_FPR_S 0x00000010
842 /* Modifies the floating point register in OP_*_FT. */
843 #define INSN_WRITE_FPR_T 0x00000020
844 /* Reads the general purpose register in OP_*_RS. */
845 #define INSN_READ_GPR_S 0x00000040
846 /* Reads the general purpose register in OP_*_RT. */
847 #define INSN_READ_GPR_T 0x00000080
848 /* Reads the floating point register in OP_*_FS. */
849 #define INSN_READ_FPR_S 0x00000100
850 /* Reads the floating point register in OP_*_FT. */
851 #define INSN_READ_FPR_T 0x00000200
852 /* Reads the floating point register in OP_*_FR. */
853 #define INSN_READ_FPR_R 0x00000400
854 /* Modifies coprocessor condition code. */
855 #define INSN_WRITE_COND_CODE 0x00000800
856 /* Reads coprocessor condition code. */
857 #define INSN_READ_COND_CODE 0x00001000
859 #define INSN_TLB 0x00002000
860 /* Reads coprocessor register other than floating point register. */
861 #define INSN_COP 0x00004000
862 /* Instruction loads value from memory, requiring delay. */
863 #define INSN_LOAD_MEMORY_DELAY 0x00008000
864 /* Instruction loads value from coprocessor, requiring delay. */
865 #define INSN_LOAD_COPROC_DELAY 0x00010000
866 /* Instruction has unconditional branch delay slot. */
867 #define INSN_UNCOND_BRANCH_DELAY 0x00020000
868 /* Instruction has conditional branch delay slot. */
869 #define INSN_COND_BRANCH_DELAY 0x00040000
870 /* Conditional branch likely: if branch not taken, insn nullified. */
871 #define INSN_COND_BRANCH_LIKELY 0x00080000
872 /* Moves to coprocessor register, requiring delay. */
873 #define INSN_COPROC_MOVE_DELAY 0x00100000
874 /* Loads coprocessor register from memory, requiring delay. */
875 #define INSN_COPROC_MEMORY_DELAY 0x00200000
876 /* Reads the HI register. */
877 #define INSN_READ_HI 0x00400000
878 /* Reads the LO register. */
879 #define INSN_READ_LO 0x00800000
880 /* Modifies the HI register. */
881 #define INSN_WRITE_HI 0x01000000
882 /* Modifies the LO register. */
883 #define INSN_WRITE_LO 0x02000000
884 /* Not to be placed in a branch delay slot, either architecturally
885 or for ease of handling (such as with instructions that take a trap). */
886 #define INSN_NO_DELAY_SLOT 0x04000000
887 /* Instruction stores value into memory. */
888 #define INSN_STORE_MEMORY 0x08000000
889 /* Instruction uses single precision floating point. */
890 #define FP_S 0x10000000
891 /* Instruction uses double precision floating point. */
892 #define FP_D 0x20000000
893 /* Instruction is part of the tx39's integer multiply family. */
894 #define INSN_MULT 0x40000000
895 /* Modifies the general purpose register in MICROMIPSOP_*_RS. */
896 #define INSN_WRITE_GPR_S 0x80000000
897 /* Instruction is actually a macro. It should be ignored by the
898 disassembler, and requires special treatment by the assembler. */
899 #define INSN_MACRO 0xffffffff
901 /* These are the bits which may be set in the pinfo2 field of an
904 /* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */
905 #define INSN2_ALIAS 0x00000001
906 /* Instruction reads MDMX accumulator. */
907 #define INSN2_READ_MDMX_ACC 0x00000002
908 /* Instruction writes MDMX accumulator. */
909 #define INSN2_WRITE_MDMX_ACC 0x00000004
910 /* Macro uses single-precision floating-point instructions. This should
911 only be set for macros. For instructions, FP_S in pinfo carries the
913 #define INSN2_M_FP_S 0x00000008
914 /* Macro uses double-precision floating-point instructions. This should
915 only be set for macros. For instructions, FP_D in pinfo carries the
917 #define INSN2_M_FP_D 0x00000010
918 /* Modifies the general purpose register in OP_*_RZ. */
919 #define INSN2_WRITE_GPR_Z 0x00000020
920 /* Modifies the floating point register in OP_*_FZ. */
921 #define INSN2_WRITE_FPR_Z 0x00000040
922 /* Reads the general purpose register in OP_*_RZ. */
923 #define INSN2_READ_GPR_Z 0x00000080
924 /* Reads the floating point register in OP_*_FZ. */
925 #define INSN2_READ_FPR_Z 0x00000100
926 /* Reads the general purpose register in OP_*_RD. */
927 #define INSN2_READ_GPR_D 0x00000200
930 /* Instruction has a branch delay slot that requires a 16-bit instruction. */
931 #define INSN2_BRANCH_DELAY_16BIT 0x00000400
932 /* Instruction has a branch delay slot that requires a 32-bit instruction. */
933 #define INSN2_BRANCH_DELAY_32BIT 0x00000800
934 /* Reads the floating point register in MICROMIPSOP_*_FD. */
935 #define INSN2_READ_FPR_D 0x00001000
936 /* Modifies the general purpose register in MICROMIPSOP_*_MB. */
937 #define INSN2_WRITE_GPR_MB 0x00002000
938 /* Reads the general purpose register in MICROMIPSOP_*_MC. */
939 #define INSN2_READ_GPR_MC 0x00004000
940 /* Reads/writes the general purpose register in MICROMIPSOP_*_MD. */
941 #define INSN2_MOD_GPR_MD 0x00008000
942 /* Reads the general purpose register in MICROMIPSOP_*_ME. */
943 #define INSN2_READ_GPR_ME 0x00010000
944 /* Reads/writes the general purpose register in MICROMIPSOP_*_MF. */
945 #define INSN2_MOD_GPR_MF 0x00020000
946 /* Reads the general purpose register in MICROMIPSOP_*_MG. */
947 #define INSN2_READ_GPR_MG 0x00040000
948 /* Reads the general purpose register in MICROMIPSOP_*_MJ. */
949 #define INSN2_READ_GPR_MJ 0x00080000
950 /* Modifies the general purpose register in MICROMIPSOP_*_MJ. */
951 #define INSN2_WRITE_GPR_MJ 0x00100000
952 /* Reads the general purpose register in MICROMIPSOP_*_MP. */
953 #define INSN2_READ_GPR_MP 0x00200000
954 /* Modifies the general purpose register in MICROMIPSOP_*_MP. */
955 #define INSN2_WRITE_GPR_MP 0x00400000
956 /* Reads the general purpose register in MICROMIPSOP_*_MQ. */
957 #define INSN2_READ_GPR_MQ 0x00800000
958 /* Reads/Writes the stack pointer ($29). */
959 #define INSN2_MOD_SP 0x01000000
960 /* Reads the RA ($31) register. */
961 #define INSN2_READ_GPR_31 0x02000000
962 /* Reads the global pointer ($28). */
963 #define INSN2_READ_GP 0x04000000
964 /* Reads the program counter ($pc). */
965 #define INSN2_READ_PC 0x08000000
966 /* Is an unconditional branch insn. */
967 #define INSN2_UNCOND_BRANCH 0x10000000
968 /* Is a conditional branch insn. */
969 #define INSN2_COND_BRANCH 0x20000000
970 /* Modifies the general purpose registers in MICROMIPSOP_*_MH. */
971 #define INSN2_WRITE_GPR_MH 0x40000000
972 /* Reads the general purpose registers in MICROMIPSOP_*_MM/N. */
973 #define INSN2_READ_GPR_MMN 0x80000000
975 /* Masks used to mark instructions to indicate which MIPS ISA level
976 they were introduced in. INSN_ISA_MASK masks an enumeration that
977 specifies the base ISA level(s). The remainder of a 32-bit
978 word constructed using these macros is a bitmask of the remaining
979 INSN_* values below. */
981 #define INSN_ISA_MASK 0x0000000ful
983 /* We cannot start at zero due to ISA_UNKNOWN below. */
990 #define INSN_ISA32R2 7
992 #define INSN_ISA64R2 9
993 /* Below this point the INSN_* values correspond to combinations of ISAs.
994 They are only for use in the opcodes table to indicate membership of
995 a combination of ISAs that cannot be expressed using the usual inclusion
996 ordering on the above INSN_* values. */
997 #define INSN_ISA3_32 10
998 #define INSN_ISA3_32R2 11
999 #define INSN_ISA4_32 12
1000 #define INSN_ISA4_32R2 13
1001 #define INSN_ISA5_32R2 14
1003 /* Given INSN_ISA* values X and Y, where X ranges over INSN_ISA1 through
1004 INSN_ISA5_32R2 and Y ranges over INSN_ISA1 through INSN_ISA64R2,
1005 this table describes whether at least one of the ISAs described by X
1006 is/are implemented by ISA Y. (Think of Y as the ISA level supported by
1007 a particular core and X as the ISA level(s) at which a certain instruction
1008 is defined.) The ISA(s) described by X is/are implemented by Y iff
1009 (mips_isa_table[(Y & INSN_ISA_MASK) - 1] >> ((X & INSN_ISA_MASK) - 1)) & 1
1011 static const unsigned int mips_isa_table
[] =
1012 { 0x0001, 0x0003, 0x0607, 0x1e0f, 0x3e1f, 0x0a23, 0x3e63, 0x3ebf, 0x3fff };
1014 /* Masks used for Chip specific instructions. */
1015 #define INSN_CHIP_MASK 0xc3ff0f20
1017 /* Cavium Networks Octeon instructions. */
1018 #define INSN_OCTEON 0x00000800
1019 #define INSN_OCTEONP 0x00000200
1020 #define INSN_OCTEON2 0x00000100
1022 /* MIPS R5900 instruction */
1023 #define INSN_5900 0x00004000
1025 /* MIPS R4650 instruction. */
1026 #define INSN_4650 0x00010000
1027 /* LSI R4010 instruction. */
1028 #define INSN_4010 0x00020000
1029 /* NEC VR4100 instruction. */
1030 #define INSN_4100 0x00040000
1031 /* Toshiba R3900 instruction. */
1032 #define INSN_3900 0x00080000
1033 /* MIPS R10000 instruction. */
1034 #define INSN_10000 0x00100000
1035 /* Broadcom SB-1 instruction. */
1036 #define INSN_SB1 0x00200000
1037 /* NEC VR4111/VR4181 instruction. */
1038 #define INSN_4111 0x00400000
1039 /* NEC VR4120 instruction. */
1040 #define INSN_4120 0x00800000
1041 /* NEC VR5400 instruction. */
1042 #define INSN_5400 0x01000000
1043 /* NEC VR5500 instruction. */
1044 #define INSN_5500 0x02000000
1046 /* ST Microelectronics Loongson 2E. */
1047 #define INSN_LOONGSON_2E 0x40000000
1048 /* ST Microelectronics Loongson 2F. */
1049 #define INSN_LOONGSON_2F 0x80000000
1051 #define INSN_LOONGSON_3A 0x00000400
1052 /* RMI Xlr instruction */
1053 #define INSN_XLR 0x00000020
1056 #define ASE_DSP 0x00000001
1057 #define ASE_DSP64 0x00000002
1059 #define ASE_DSPR2 0x00000004
1060 /* Enhanced VA Scheme */
1061 #define ASE_EVA 0x00000008
1062 /* MCU (MicroController) ASE */
1063 #define ASE_MCU 0x00000010
1065 #define ASE_MDMX 0x00000020
1067 #define ASE_MIPS3D 0x00000040
1069 #define ASE_MT 0x00000080
1071 #define ASE_SMARTMIPS 0x00000100
1072 /* Virtualization ASE */
1073 #define ASE_VIRT 0x00000200
1074 #define ASE_VIRT64 0x00000400
1076 /* MIPS ISA defines, use instead of hardcoding ISA level. */
1078 #define ISA_UNKNOWN 0 /* Gas internal use. */
1079 #define ISA_MIPS1 INSN_ISA1
1080 #define ISA_MIPS2 INSN_ISA2
1081 #define ISA_MIPS3 INSN_ISA3
1082 #define ISA_MIPS4 INSN_ISA4
1083 #define ISA_MIPS5 INSN_ISA5
1085 #define ISA_MIPS32 INSN_ISA32
1086 #define ISA_MIPS64 INSN_ISA64
1088 #define ISA_MIPS32R2 INSN_ISA32R2
1089 #define ISA_MIPS64R2 INSN_ISA64R2
1092 /* CPU defines, use instead of hardcoding processor number. Keep this
1093 in sync with bfd/archures.c in order for machine selection to work. */
1094 #define CPU_UNKNOWN 0 /* Gas internal use. */
1095 #define CPU_R3000 3000
1096 #define CPU_R3900 3900
1097 #define CPU_R4000 4000
1098 #define CPU_R4010 4010
1099 #define CPU_VR4100 4100
1100 #define CPU_R4111 4111
1101 #define CPU_VR4120 4120
1102 #define CPU_R4300 4300
1103 #define CPU_R4400 4400
1104 #define CPU_R4600 4600
1105 #define CPU_R4650 4650
1106 #define CPU_R5000 5000
1107 #define CPU_VR5400 5400
1108 #define CPU_VR5500 5500
1109 #define CPU_R5900 5900
1110 #define CPU_R6000 6000
1111 #define CPU_RM7000 7000
1112 #define CPU_R8000 8000
1113 #define CPU_RM9000 9000
1114 #define CPU_R10000 10000
1115 #define CPU_R12000 12000
1116 #define CPU_R14000 14000
1117 #define CPU_R16000 16000
1118 #define CPU_MIPS16 16
1119 #define CPU_MIPS32 32
1120 #define CPU_MIPS32R2 33
1122 #define CPU_MIPS64 64
1123 #define CPU_MIPS64R2 65
1124 #define CPU_SB1 12310201 /* octal 'SB', 01. */
1125 #define CPU_LOONGSON_2E 3001
1126 #define CPU_LOONGSON_2F 3002
1127 #define CPU_LOONGSON_3A 3003
1128 #define CPU_OCTEON 6501
1129 #define CPU_OCTEONP 6601
1130 #define CPU_OCTEON2 6502
1131 #define CPU_XLR 887682 /* decimal 'XLR' */
1133 /* Return true if the given CPU is included in INSN_* mask MASK. */
1135 static inline bfd_boolean
1136 cpu_is_member (int cpu
, unsigned int mask
)
1143 return (mask
& INSN_4650
) != 0;
1146 return (mask
& INSN_4010
) != 0;
1149 return (mask
& INSN_4100
) != 0;
1152 return (mask
& INSN_3900
) != 0;
1158 return (mask
& INSN_10000
) != 0;
1161 return (mask
& INSN_SB1
) != 0;
1164 return (mask
& INSN_4111
) != 0;
1167 return (mask
& INSN_4120
) != 0;
1170 return (mask
& INSN_5400
) != 0;
1173 return (mask
& INSN_5500
) != 0;
1176 return (mask
& INSN_5900
) != 0;
1178 case CPU_LOONGSON_2E
:
1179 return (mask
& INSN_LOONGSON_2E
) != 0;
1181 case CPU_LOONGSON_2F
:
1182 return (mask
& INSN_LOONGSON_2F
) != 0;
1184 case CPU_LOONGSON_3A
:
1185 return (mask
& INSN_LOONGSON_3A
) != 0;
1188 return (mask
& INSN_OCTEON
) != 0;
1191 return (mask
& INSN_OCTEONP
) != 0;
1194 return (mask
& INSN_OCTEON2
) != 0;
1197 return (mask
& INSN_XLR
) != 0;
1204 /* Test for membership in an ISA including chip specific ISAs. INSN
1205 is pointer to an element of the opcode table; ISA is the specified
1206 ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
1207 test, or zero if no CPU specific ISA test is desired. Return true
1208 if instruction INSN is available to the given ISA and CPU. */
1210 static inline bfd_boolean
1211 opcode_is_member (const struct mips_opcode
*insn
, int isa
, int ase
, int cpu
)
1213 if (!cpu_is_member (cpu
, insn
->exclusions
))
1215 /* Test for ISA level compatibility. */
1216 if ((isa
& INSN_ISA_MASK
) != 0
1217 && (insn
->membership
& INSN_ISA_MASK
) != 0
1218 && ((mips_isa_table
[(isa
& INSN_ISA_MASK
) - 1]
1219 >> ((insn
->membership
& INSN_ISA_MASK
) - 1)) & 1) != 0)
1222 /* Test for ASE compatibility. */
1223 if ((ase
& insn
->ase
) != 0)
1226 /* Test for processor-specific extensions. */
1227 if (cpu_is_member (cpu
, insn
->membership
))
1233 /* This is a list of macro expanded instructions.
1235 _I appended means immediate
1236 _A appended means target address of a jump
1237 _AB appended means address with (possibly zero) base register
1238 _D appended means 64 bit floating point constant
1239 _S appended means 32 bit floating point constant. */
1494 /* The order of overloaded instructions matters. Label arguments and
1495 register arguments look the same. Instructions that can have either
1496 for arguments must apear in the correct order in this table for the
1497 assembler to pick the right one. In other words, entries with
1498 immediate operands must apear after the same instruction with
1501 Many instructions are short hand for other instructions (i.e., The
1502 jal <register> instruction is short for jalr <register>). */
1504 extern const struct mips_operand
*decode_mips_operand (const char *);
1505 extern const struct mips_opcode mips_builtin_opcodes
[];
1506 extern const int bfd_mips_num_builtin_opcodes
;
1507 extern struct mips_opcode
*mips_opcodes
;
1508 extern int bfd_mips_num_opcodes
;
1509 #define NUMOPCODES bfd_mips_num_opcodes
1512 /* The rest of this file adds definitions for the mips16 TinyRISC
1515 /* These are the bitmasks and shift counts used for the different
1516 fields in the instruction formats. Other than OP, no masks are
1517 provided for the fixed portions of an instruction, since they are
1520 The I format uses IMM11.
1522 The RI format uses RX and IMM8.
1524 The RR format uses RX, and RY.
1526 The RRI format uses RX, RY, and IMM5.
1528 The RRR format uses RX, RY, and RZ.
1530 The RRI_A format uses RX, RY, and IMM4.
1532 The SHIFT format uses RX, RY, and SHAMT.
1534 The I8 format uses IMM8.
1536 The I8_MOVR32 format uses RY and REGR32.
1538 The IR_MOV32R format uses REG32R and MOV32Z.
1540 The I64 format uses IMM8.
1542 The RI64 format uses RY and IMM5.
1545 #define MIPS16OP_MASK_OP 0x1f
1546 #define MIPS16OP_SH_OP 11
1547 #define MIPS16OP_MASK_IMM11 0x7ff
1548 #define MIPS16OP_SH_IMM11 0
1549 #define MIPS16OP_MASK_RX 0x7
1550 #define MIPS16OP_SH_RX 8
1551 #define MIPS16OP_MASK_IMM8 0xff
1552 #define MIPS16OP_SH_IMM8 0
1553 #define MIPS16OP_MASK_RY 0x7
1554 #define MIPS16OP_SH_RY 5
1555 #define MIPS16OP_MASK_IMM5 0x1f
1556 #define MIPS16OP_SH_IMM5 0
1557 #define MIPS16OP_MASK_RZ 0x7
1558 #define MIPS16OP_SH_RZ 2
1559 #define MIPS16OP_MASK_IMM4 0xf
1560 #define MIPS16OP_SH_IMM4 0
1561 #define MIPS16OP_MASK_REGR32 0x1f
1562 #define MIPS16OP_SH_REGR32 0
1563 #define MIPS16OP_MASK_REG32R 0x1f
1564 #define MIPS16OP_SH_REG32R 3
1565 #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
1566 #define MIPS16OP_MASK_MOVE32Z 0x7
1567 #define MIPS16OP_SH_MOVE32Z 0
1568 #define MIPS16OP_MASK_IMM6 0x3f
1569 #define MIPS16OP_SH_IMM6 5
1571 /* These are the characters which may appears in the args field of a MIPS16
1572 instruction. They appear in the order in which the fields appear when the
1573 instruction is used. Commas and parentheses in the args string are ignored
1574 when assembling, and written into the output when disassembling.
1576 "y" 3 bit register (MIPS16OP_*_RY)
1577 "x" 3 bit register (MIPS16OP_*_RX)
1578 "z" 3 bit register (MIPS16OP_*_RZ)
1579 "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
1580 "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
1581 "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
1582 "0" zero register ($0)
1583 "S" stack pointer ($sp or $29)
1585 "R" return address register ($ra or $31)
1586 "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
1587 "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
1588 "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
1589 "a" 26 bit jump address
1590 "i" likewise, but flips bit 0
1591 "e" 11 bit extension value
1592 "l" register list for entry instruction
1593 "L" register list for exit instruction
1595 "I" an immediate value used for macros
1597 The remaining codes may be extended. Except as otherwise noted,
1598 the full extended operand is a 16 bit signed value.
1599 "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
1600 ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned)
1601 "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
1602 "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
1603 "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
1604 "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
1605 "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
1606 "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
1607 "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
1608 "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
1609 "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
1610 "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
1611 "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
1612 "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
1613 "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
1614 "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
1615 "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
1616 "q" 11 bit branch address (MIPS16OP_*_IMM11)
1617 "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
1618 "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
1619 "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
1620 "m" 7 bit register list for save instruction (18 bit extended)
1621 "M" 7 bit register list for restore instruction (18 bit extended)
1624 /* Save/restore encoding for the args field when all 4 registers are
1625 either saved as arguments or saved/restored as statics. */
1626 #define MIPS16_ALL_ARGS 0xe
1627 #define MIPS16_ALL_STATICS 0xb
1629 /* For the mips16, we use the same opcode table format and a few of
1630 the same flags. However, most of the flags are different. */
1632 /* Modifies the register in MIPS16OP_*_RX. */
1633 #define MIPS16_INSN_WRITE_X 0x00000001
1634 /* Modifies the register in MIPS16OP_*_RY. */
1635 #define MIPS16_INSN_WRITE_Y 0x00000002
1636 /* Modifies the register in MIPS16OP_*_RZ. */
1637 #define MIPS16_INSN_WRITE_Z 0x00000004
1638 /* Modifies the T ($24) register. */
1639 #define MIPS16_INSN_WRITE_T 0x00000008
1640 /* Modifies the SP ($29) register. */
1641 #define MIPS16_INSN_WRITE_SP 0x00000010
1642 /* Modifies the RA ($31) register. */
1643 #define MIPS16_INSN_WRITE_31 0x00000020
1644 /* Modifies the general purpose register in MIPS16OP_*_REG32R. */
1645 #define MIPS16_INSN_WRITE_GPR_Y 0x00000040
1646 /* Reads the register in MIPS16OP_*_RX. */
1647 #define MIPS16_INSN_READ_X 0x00000080
1648 /* Reads the register in MIPS16OP_*_RY. */
1649 #define MIPS16_INSN_READ_Y 0x00000100
1650 /* Reads the register in MIPS16OP_*_MOVE32Z. */
1651 #define MIPS16_INSN_READ_Z 0x00000200
1652 /* Reads the T ($24) register. */
1653 #define MIPS16_INSN_READ_T 0x00000400
1654 /* Reads the SP ($29) register. */
1655 #define MIPS16_INSN_READ_SP 0x00000800
1656 /* Reads the RA ($31) register. */
1657 #define MIPS16_INSN_READ_31 0x00001000
1658 /* Reads the program counter. */
1659 #define MIPS16_INSN_READ_PC 0x00002000
1660 /* Reads the general purpose register in MIPS16OP_*_REGR32. */
1661 #define MIPS16_INSN_READ_GPR_X 0x00004000
1662 /* Is an unconditional branch insn. */
1663 #define MIPS16_INSN_UNCOND_BRANCH 0x00008000
1664 /* Is a conditional branch insn. */
1665 #define MIPS16_INSN_COND_BRANCH 0x00010000
1667 /* The following flags have the same value for the mips16 opcode
1672 INSN_UNCOND_BRANCH_DELAY
1673 INSN_COND_BRANCH_DELAY
1674 INSN_COND_BRANCH_LIKELY (never used)
1683 extern const struct mips_opcode mips16_opcodes
[];
1684 extern const int bfd_mips16_num_opcodes
;
1686 /* These are the bit masks and shift counts used for the different fields
1687 in the microMIPS instruction formats. No masks are provided for the
1688 fixed portions of an instruction, since they are not needed. */
1690 #define MICROMIPSOP_MASK_IMMEDIATE 0xffff
1691 #define MICROMIPSOP_SH_IMMEDIATE 0
1692 #define MICROMIPSOP_MASK_DELTA 0xffff
1693 #define MICROMIPSOP_SH_DELTA 0
1694 #define MICROMIPSOP_MASK_CODE10 0x3ff
1695 #define MICROMIPSOP_SH_CODE10 16 /* 10-bit wait code. */
1696 #define MICROMIPSOP_MASK_TRAP 0xf
1697 #define MICROMIPSOP_SH_TRAP 12 /* 4-bit trap code. */
1698 #define MICROMIPSOP_MASK_SHAMT 0x1f
1699 #define MICROMIPSOP_SH_SHAMT 11
1700 #define MICROMIPSOP_MASK_TARGET 0x3ffffff
1701 #define MICROMIPSOP_SH_TARGET 0
1702 #define MICROMIPSOP_MASK_EXTLSB 0x1f /* "ext" LSB. */
1703 #define MICROMIPSOP_SH_EXTLSB 6
1704 #define MICROMIPSOP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */
1705 #define MICROMIPSOP_SH_EXTMSBD 11
1706 #define MICROMIPSOP_MASK_INSMSB 0x1f /* "ins" MSB. */
1707 #define MICROMIPSOP_SH_INSMSB 11
1708 #define MICROMIPSOP_MASK_CODE 0x3ff
1709 #define MICROMIPSOP_SH_CODE 16 /* 10-bit higher break code. */
1710 #define MICROMIPSOP_MASK_CODE2 0x3ff
1711 #define MICROMIPSOP_SH_CODE2 6 /* 10-bit lower break code. */
1712 #define MICROMIPSOP_MASK_CACHE 0x1f
1713 #define MICROMIPSOP_SH_CACHE 21 /* 5-bit cache op. */
1714 #define MICROMIPSOP_MASK_SEL 0x7
1715 #define MICROMIPSOP_SH_SEL 11
1716 #define MICROMIPSOP_MASK_OFFSET12 0xfff
1717 #define MICROMIPSOP_SH_OFFSET12 0
1718 #define MICROMIPSOP_MASK_3BITPOS 0x7
1719 #define MICROMIPSOP_SH_3BITPOS 21
1720 #define MICROMIPSOP_MASK_STYPE 0x1f
1721 #define MICROMIPSOP_SH_STYPE 16
1722 #define MICROMIPSOP_MASK_OFFSET10 0x3ff
1723 #define MICROMIPSOP_SH_OFFSET10 6
1724 #define MICROMIPSOP_MASK_RS 0x1f
1725 #define MICROMIPSOP_SH_RS 16
1726 #define MICROMIPSOP_MASK_RT 0x1f
1727 #define MICROMIPSOP_SH_RT 21
1728 #define MICROMIPSOP_MASK_RD 0x1f
1729 #define MICROMIPSOP_SH_RD 11
1730 #define MICROMIPSOP_MASK_FS 0x1f
1731 #define MICROMIPSOP_SH_FS 16
1732 #define MICROMIPSOP_MASK_FT 0x1f
1733 #define MICROMIPSOP_SH_FT 21
1734 #define MICROMIPSOP_MASK_FD 0x1f
1735 #define MICROMIPSOP_SH_FD 11
1736 #define MICROMIPSOP_MASK_FR 0x1f
1737 #define MICROMIPSOP_SH_FR 6
1738 #define MICROMIPSOP_MASK_RS3 0x1f
1739 #define MICROMIPSOP_SH_RS3 6
1740 #define MICROMIPSOP_MASK_PREFX 0x1f
1741 #define MICROMIPSOP_SH_PREFX 11
1742 #define MICROMIPSOP_MASK_BCC 0x7
1743 #define MICROMIPSOP_SH_BCC 18
1744 #define MICROMIPSOP_MASK_CCC 0x7
1745 #define MICROMIPSOP_SH_CCC 13
1746 #define MICROMIPSOP_MASK_COPZ 0x7fffff
1747 #define MICROMIPSOP_SH_COPZ 3
1749 #define MICROMIPSOP_MASK_MB 0x7
1750 #define MICROMIPSOP_SH_MB 23
1751 #define MICROMIPSOP_MASK_MC 0x7
1752 #define MICROMIPSOP_SH_MC 4
1753 #define MICROMIPSOP_MASK_MD 0x7
1754 #define MICROMIPSOP_SH_MD 7
1755 #define MICROMIPSOP_MASK_ME 0x7
1756 #define MICROMIPSOP_SH_ME 1
1757 #define MICROMIPSOP_MASK_MF 0x7
1758 #define MICROMIPSOP_SH_MF 3
1759 #define MICROMIPSOP_MASK_MG 0x7
1760 #define MICROMIPSOP_SH_MG 0
1761 #define MICROMIPSOP_MASK_MH 0x7
1762 #define MICROMIPSOP_SH_MH 7
1763 #define MICROMIPSOP_MASK_MJ 0x1f
1764 #define MICROMIPSOP_SH_MJ 0
1765 #define MICROMIPSOP_MASK_ML 0x7
1766 #define MICROMIPSOP_SH_ML 4
1767 #define MICROMIPSOP_MASK_MM 0x7
1768 #define MICROMIPSOP_SH_MM 1
1769 #define MICROMIPSOP_MASK_MN 0x7
1770 #define MICROMIPSOP_SH_MN 4
1771 #define MICROMIPSOP_MASK_MP 0x1f
1772 #define MICROMIPSOP_SH_MP 5
1773 #define MICROMIPSOP_MASK_MQ 0x7
1774 #define MICROMIPSOP_SH_MQ 7
1776 #define MICROMIPSOP_MASK_IMMA 0x7f
1777 #define MICROMIPSOP_SH_IMMA 0
1778 #define MICROMIPSOP_MASK_IMMB 0x7
1779 #define MICROMIPSOP_SH_IMMB 1
1780 #define MICROMIPSOP_MASK_IMMC 0xf
1781 #define MICROMIPSOP_SH_IMMC 0
1782 #define MICROMIPSOP_MASK_IMMD 0x3ff
1783 #define MICROMIPSOP_SH_IMMD 0
1784 #define MICROMIPSOP_MASK_IMME 0x7f
1785 #define MICROMIPSOP_SH_IMME 0
1786 #define MICROMIPSOP_MASK_IMMF 0xf
1787 #define MICROMIPSOP_SH_IMMF 0
1788 #define MICROMIPSOP_MASK_IMMG 0xf
1789 #define MICROMIPSOP_SH_IMMG 0
1790 #define MICROMIPSOP_MASK_IMMH 0xf
1791 #define MICROMIPSOP_SH_IMMH 0
1792 #define MICROMIPSOP_MASK_IMMI 0x7f
1793 #define MICROMIPSOP_SH_IMMI 0
1794 #define MICROMIPSOP_MASK_IMMJ 0xf
1795 #define MICROMIPSOP_SH_IMMJ 0
1796 #define MICROMIPSOP_MASK_IMML 0xf
1797 #define MICROMIPSOP_SH_IMML 0
1798 #define MICROMIPSOP_MASK_IMMM 0x7
1799 #define MICROMIPSOP_SH_IMMM 1
1800 #define MICROMIPSOP_MASK_IMMN 0x3
1801 #define MICROMIPSOP_SH_IMMN 4
1802 #define MICROMIPSOP_MASK_IMMO 0xf
1803 #define MICROMIPSOP_SH_IMMO 0
1804 #define MICROMIPSOP_MASK_IMMP 0x1f
1805 #define MICROMIPSOP_SH_IMMP 0
1806 #define MICROMIPSOP_MASK_IMMQ 0x7fffff
1807 #define MICROMIPSOP_SH_IMMQ 0
1808 #define MICROMIPSOP_MASK_IMMU 0x1f
1809 #define MICROMIPSOP_SH_IMMU 0
1810 #define MICROMIPSOP_MASK_IMMW 0x3f
1811 #define MICROMIPSOP_SH_IMMW 1
1812 #define MICROMIPSOP_MASK_IMMX 0xf
1813 #define MICROMIPSOP_SH_IMMX 1
1814 #define MICROMIPSOP_MASK_IMMY 0x1ff
1815 #define MICROMIPSOP_SH_IMMY 1
1818 #define MICROMIPSOP_MASK_DSPACC 0x3
1819 #define MICROMIPSOP_SH_DSPACC 14
1820 #define MICROMIPSOP_MASK_DSPSFT 0x3f
1821 #define MICROMIPSOP_SH_DSPSFT 16
1822 #define MICROMIPSOP_MASK_SA3 0x7
1823 #define MICROMIPSOP_SH_SA3 13
1824 #define MICROMIPSOP_MASK_SA4 0xf
1825 #define MICROMIPSOP_SH_SA4 12
1826 #define MICROMIPSOP_MASK_IMM8 0xff
1827 #define MICROMIPSOP_SH_IMM8 13
1828 #define MICROMIPSOP_MASK_IMM10 0x3ff
1829 #define MICROMIPSOP_SH_IMM10 16
1830 #define MICROMIPSOP_MASK_WRDSP 0x3f
1831 #define MICROMIPSOP_SH_WRDSP 14
1832 #define MICROMIPSOP_MASK_BP 0x3
1833 #define MICROMIPSOP_SH_BP 14
1835 /* Placeholders for fields that only exist in the traditional 32-bit
1836 instruction encoding; see the comment above for details. */
1837 #define MICROMIPSOP_MASK_CODE20 0
1838 #define MICROMIPSOP_SH_CODE20 0
1839 #define MICROMIPSOP_MASK_PERFREG 0
1840 #define MICROMIPSOP_SH_PERFREG 0
1841 #define MICROMIPSOP_MASK_CODE19 0
1842 #define MICROMIPSOP_SH_CODE19 0
1843 #define MICROMIPSOP_MASK_ALN 0
1844 #define MICROMIPSOP_SH_ALN 0
1845 #define MICROMIPSOP_MASK_VECBYTE 0
1846 #define MICROMIPSOP_SH_VECBYTE 0
1847 #define MICROMIPSOP_MASK_VECALIGN 0
1848 #define MICROMIPSOP_SH_VECALIGN 0
1849 #define MICROMIPSOP_MASK_DSPACC_S 0
1850 #define MICROMIPSOP_SH_DSPACC_S 0
1851 #define MICROMIPSOP_MASK_DSPSFT_7 0
1852 #define MICROMIPSOP_SH_DSPSFT_7 0
1853 #define MICROMIPSOP_MASK_RDDSP 0
1854 #define MICROMIPSOP_SH_RDDSP 0
1855 #define MICROMIPSOP_MASK_MT_U 0
1856 #define MICROMIPSOP_SH_MT_U 0
1857 #define MICROMIPSOP_MASK_MT_H 0
1858 #define MICROMIPSOP_SH_MT_H 0
1859 #define MICROMIPSOP_MASK_MTACC_T 0
1860 #define MICROMIPSOP_SH_MTACC_T 0
1861 #define MICROMIPSOP_MASK_MTACC_D 0
1862 #define MICROMIPSOP_SH_MTACC_D 0
1863 #define MICROMIPSOP_MASK_BBITIND 0
1864 #define MICROMIPSOP_SH_BBITIND 0
1865 #define MICROMIPSOP_MASK_CINSPOS 0
1866 #define MICROMIPSOP_SH_CINSPOS 0
1867 #define MICROMIPSOP_MASK_CINSLM1 0
1868 #define MICROMIPSOP_SH_CINSLM1 0
1869 #define MICROMIPSOP_MASK_SEQI 0
1870 #define MICROMIPSOP_SH_SEQI 0
1871 #define MICROMIPSOP_SH_OFFSET_A 0
1872 #define MICROMIPSOP_MASK_OFFSET_A 0
1873 #define MICROMIPSOP_SH_OFFSET_B 0
1874 #define MICROMIPSOP_MASK_OFFSET_B 0
1875 #define MICROMIPSOP_SH_OFFSET_C 0
1876 #define MICROMIPSOP_MASK_OFFSET_C 0
1877 #define MICROMIPSOP_SH_RZ 0
1878 #define MICROMIPSOP_MASK_RZ 0
1879 #define MICROMIPSOP_SH_FZ 0
1880 #define MICROMIPSOP_MASK_FZ 0
1882 /* microMIPS Enhanced VA Scheme */
1883 #define MICROMIPSOP_SH_EVAOFFSET 0
1884 #define MICROMIPSOP_MASK_EVAOFFSET 0x1ff
1886 /* These are the characters which may appears in the args field of a microMIPS
1887 instruction. They appear in the order in which the fields appear
1888 when the instruction is used. Commas and parentheses in the args
1889 string are ignored when assembling, and written into the output
1892 The followings are for 16-bit microMIPS instructions.
1895 "mc" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MC) at bit 4
1896 The same register used as both source and target.
1897 "md" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MD) at bit 7
1898 "me" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ME) at bit 1
1899 The same register used as both source and target.
1900 "mf" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MF) at bit 3
1901 "mg" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MG) at bit 0
1902 "mh" 3-bit MIPS register pair (MICROMIPSOP_*_MH) at bit 7
1903 "mj" 5-bit MIPS registers (MICROMIPSOP_*_MJ) at bit 0
1904 "ml" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ML) at bit 4
1905 "mm" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MM) at bit 1
1906 "mn" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MN) at bit 4
1907 "mp" 5-bit MIPS registers (MICROMIPSOP_*_MP) at bit 5
1908 "mq" 3-bit MIPS registers 0, 2-7, 17 (MICROMIPSOP_*_MQ) at bit 7
1909 "mr" must be program counter
1911 "mt" must be the same as the previous register
1912 "mx" must be the same as the destination register
1916 "mA" 7-bit immediate (-64 .. 63) << 2 (MICROMIPSOP_*_IMMA)
1917 "mB" 3-bit immediate (-1, 1, 4, 8, 12, 16, 20, 24) (MICROMIPSOP_*_IMMB)
1918 "mC" 4-bit immediate (1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64, 128, 255,
1919 32768, 65535) (MICROMIPSOP_*_IMMC)
1920 "mD" 10-bit branch address (-512 .. 511) << 1 (MICROMIPSOP_*_IMMD)
1921 "mE" 7-bit branch address (-64 .. 63) << 1 (MICROMIPSOP_*_IMME)
1922 "mF" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMMF)
1923 "mG" 4-bit immediate (-1 .. 14) (MICROMIPSOP_*_IMMG)
1924 "mH" 4-bit immediate (0 .. 15) << 1 (MICROMIPSOP_*_IMMH)
1925 "mI" 7-bit immediate (-1 .. 126) (MICROMIPSOP_*_IMMI)
1926 "mJ" 4-bit immediate (0 .. 15) << 2 (MICROMIPSOP_*_IMMJ)
1927 "mL" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
1928 "mM" 3-bit immediate (1 .. 8) (MICROMIPSOP_*_IMMM)
1929 "mN" 2-bit immediate (0 .. 3) for register list (MICROMIPSOP_*_IMMN)
1930 "mO" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
1931 "mP" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMP)
1932 "mU" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMU)
1933 "mW" 6-bit immediate (0 .. 63) << 2 (MICROMIPSOP_*_IMMW)
1934 "mX" 4-bit immediate (-8 .. 7) (MICROMIPSOP_*_IMMX)
1935 "mY" 9-bit immediate (-258 .. -3, 2 .. 257) << 2 (MICROMIPSOP_*_IMMY)
1938 In most cases 32-bit microMIPS instructions use the same characters
1939 as MIPS (with ADDIUPC being a notable exception, but there are some
1942 "." 10-bit signed offset/number (MICROMIPSOP_*_OFFSET10)
1943 "1" 5-bit sync type (MICROMIPSOP_*_STYPE)
1944 "<" 5-bit shift amount (MICROMIPSOP_*_SHAMT)
1945 ">" shift amount between 32 and 63, stored after subtracting 32
1946 (MICROMIPSOP_*_SHAMT)
1947 "\" 3-bit position for ASET and ACLR (MICROMIPSOP_*_3BITPOS)
1948 "|" 4-bit trap code (MICROMIPSOP_*_TRAP)
1949 "~" 12-bit signed offset (MICROMIPSOP_*_OFFSET12)
1950 "a" 26-bit target address (MICROMIPSOP_*_TARGET)
1951 "+i" likewise, but flips bit 0
1952 "b" 5-bit base register (MICROMIPSOP_*_RS)
1953 "c" 10-bit higher breakpoint code (MICROMIPSOP_*_CODE)
1954 "d" 5-bit destination register specifier (MICROMIPSOP_*_RD)
1955 "h" 5-bit PREFX hint (MICROMIPSOP_*_PREFX)
1956 "i" 16-bit unsigned immediate (MICROMIPSOP_*_IMMEDIATE)
1957 "j" 16-bit signed immediate (MICROMIPSOP_*_DELTA)
1958 "k" 5-bit cache opcode in target register position (MICROMIPSOP_*_CACHE)
1959 "n" register list for 32-bit LWM/SWM instruction (MICROMIPSOP_*_RT)
1960 "o" 16-bit signed offset (MICROMIPSOP_*_DELTA)
1961 "p" 16-bit PC-relative branch target address (MICROMIPSOP_*_DELTA)
1962 "q" 10-bit lower breakpoint code (MICROMIPSOP_*_CODE2)
1963 "r" 5-bit same register used as both source and target (MICROMIPSOP_*_RS)
1964 "s" 5-bit source register specifier (MICROMIPSOP_*_RS)
1965 "t" 5-bit target register (MICROMIPSOP_*_RT)
1966 "u" 16-bit upper 16 bits of address (MICROMIPSOP_*_IMMEDIATE)
1967 "v" 5-bit same register used as both source and destination
1969 "w" 5-bit same register used as both target and destination
1971 "y" 5-bit source 3 register for ALNV.PS (MICROMIPSOP_*_RS3)
1972 "z" must be zero register
1973 "C" 23-bit coprocessor function code (MICROMIPSOP_*_COPZ)
1974 "B" 10-bit syscall/wait function code (MICROMIPSOP_*_CODE10)
1975 "K" 5-bit Hardware Register (RDHWR instruction) (MICROMIPSOP_*_RS)
1977 "+A" 5-bit INS/EXT/DINS/DEXT/DINSM/DEXTM position, which becomes
1978 LSB (MICROMIPSOP_*_EXTLSB).
1979 Enforces: 0 <= pos < 32.
1980 "+B" 5-bit INS/DINS size, which becomes MSB (MICROMIPSOP_*_INSMSB).
1981 Requires that "+A" or "+E" occur first to set position.
1982 Enforces: 0 < (pos+size) <= 32.
1983 "+C" 5-bit EXT/DEXT size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
1984 Requires that "+A" or "+E" occur first to set position.
1985 Enforces: 0 < (pos+size) <= 32.
1986 (Also used by DEXT w/ different limits, but limits for
1987 that are checked by the M_DEXT macro.)
1988 "+E" 5-bit DINSU/DEXTU position, which becomes LSB-32 (MICROMIPSOP_*_EXTLSB).
1989 Enforces: 32 <= pos < 64.
1990 "+F" 5-bit DINSM/DINSU size, which becomes MSB-32 (MICROMIPSOP_*_INSMSB).
1991 Requires that "+A" or "+E" occur first to set position.
1992 Enforces: 32 < (pos+size) <= 64.
1993 "+G" 5-bit DEXTM size, which becomes MSBD-32 (MICROMIPSOP_*_EXTMSBD).
1994 Requires that "+A" or "+E" occur first to set position.
1995 Enforces: 32 < (pos+size) <= 64.
1996 "+H" 5-bit DEXTU size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
1997 Requires that "+A" or "+E" occur first to set position.
1998 Enforces: 32 < (pos+size) <= 64.
2000 PC-relative addition (ADDIUPC) instruction:
2001 "mQ" 23-bit offset (-4194304 .. 4194303) << 2 (MICROMIPSOP_*_IMMQ)
2002 "mb" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MB) at bit 23
2004 Floating point instructions:
2005 "D" 5-bit destination register (MICROMIPSOP_*_FD)
2006 "M" 3-bit compare condition code (MICROMIPSOP_*_CCC)
2007 "N" 3-bit branch condition code (MICROMIPSOP_*_BCC)
2008 "R" 5-bit fr source 3 register (MICROMIPSOP_*_FR)
2009 "S" 5-bit fs source 1 register (MICROMIPSOP_*_FS)
2010 "T" 5-bit ft source 2 register (MICROMIPSOP_*_FT)
2011 "V" 5-bit same register used as floating source and destination or target
2014 Coprocessor instructions:
2015 "E" 5-bit target register (MICROMIPSOP_*_RT)
2016 "G" 5-bit source register (MICROMIPSOP_*_RS)
2017 "H" 3-bit sel field for (D)MTC* and (D)MFC* (MICROMIPSOP_*_SEL)
2020 "A" general 32 bit expression
2021 "I" 32-bit immediate (value placed in imm_expr).
2022 "+I" 32-bit immediate (value placed in imm2_expr).
2023 "F" 64-bit floating point constant in .rdata
2024 "L" 64-bit floating point constant in .lit8
2025 "f" 32-bit floating point constant
2026 "l" 32-bit floating point constant in .lit4
2029 "2" 2-bit unsigned immediate for byte align (MICROMIPSOP_*_BP)
2030 "3" 3-bit unsigned immediate (MICROMIPSOP_*_SA3)
2031 "4" 4-bit unsigned immediate (MICROMIPSOP_*_SA4)
2032 "5" 8-bit unsigned immediate (MICROMIPSOP_*_IMM8)
2033 "6" 5-bit unsigned immediate (MICROMIPSOP_*_RS)
2034 "7" 2-bit DSP accumulator register (MICROMIPSOP_*_DSPACC)
2035 "8" 6-bit unsigned immediate (MICROMIPSOP_*_WRDSP)
2036 "0" 6-bit signed immediate (MICROMIPSOP_*_DSPSFT)
2037 "@" 10-bit signed immediate (MICROMIPSOP_*_IMM10)
2038 "^" 5-bit unsigned immediate (MICROMIPSOP_*_RD)
2040 microMIPS Enhanced VA Scheme:
2041 "+j" 9-bit signed offset in bit 0 (OP_*_EVAOFFSET)
2044 "()" parens surrounding optional value
2045 "," separates operands
2046 "+" start of extension sequence
2047 "m" start of microMIPS extension sequence
2049 Characters used so far, for quick reference when adding more:
2052 "ABCDEFGHI KLMN RST V "
2053 "abcd f hijklmnopqrstuvw yz"
2055 Extension character sequences used so far ("+" followed by the
2056 following), for quick reference when adding more:
2062 Extension character sequences used so far ("m" followed by the
2063 following), for quick reference when adding more:
2066 " BCDEFGHIJ LMNOPQ U WXYZ"
2067 " bcdefghij lmn pq st xyz"
2070 extern const struct mips_operand
*decode_micromips_operand (const char *);
2071 extern const struct mips_opcode micromips_opcodes
[];
2072 extern const int bfd_micromips_num_opcodes
;
2074 /* A NOP insn impemented as "or at,at,zero".
2075 Used to implement -mfix-loongson2f. */
2076 #define LOONGSON2F_NOP_INSN 0x00200825
2078 #endif /* _MIPS_H_ */