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
296 #define OP_MASK_IMMA 0
298 #define OP_MASK_IMMB 0
300 #define OP_MASK_IMMC 0
302 #define OP_MASK_IMMF 0
304 #define OP_MASK_IMMG 0
306 #define OP_MASK_IMMH 0
308 #define OP_MASK_IMMI 0
310 #define OP_MASK_IMMJ 0
312 #define OP_MASK_IMML 0
314 #define OP_MASK_IMMM 0
316 #define OP_MASK_IMMN 0
318 #define OP_MASK_IMMO 0
320 #define OP_MASK_IMMP 0
322 #define OP_MASK_IMMQ 0
324 #define OP_MASK_IMMU 0
326 #define OP_MASK_IMMW 0
328 #define OP_MASK_IMMX 0
330 #define OP_MASK_IMMY 0
333 /* This structure holds information for a particular instruction. */
337 /* The name of the instruction. */
339 /* A string describing the arguments for this instruction. */
341 /* The basic opcode for the instruction. When assembling, this
342 opcode is modified by the arguments to produce the actual opcode
343 that is used. If pinfo is INSN_MACRO, then this is 0. */
345 /* If pinfo is not INSN_MACRO, then this is a bit mask for the
346 relevant portions of the opcode when disassembling. If the
347 actual opcode anded with the match field equals the opcode field,
348 then we have found the correct instruction. If pinfo is
349 INSN_MACRO, then this field is the macro identifier. */
351 /* For a macro, this is INSN_MACRO. Otherwise, it is a collection
352 of bits describing the instruction, notably any relevant hazard
355 /* A collection of additional bits describing the instruction. */
356 unsigned long pinfo2
;
357 /* A collection of bits describing the instruction sets of which this
358 instruction or macro is a member. */
359 unsigned long membership
;
360 /* A collection of bits describing the instruction sets of which this
361 instruction or macro is not a member. */
362 unsigned long exclusions
;
365 /* These are the characters which may appear in the args field of an
366 instruction. They appear in the order in which the fields appear
367 when the instruction is used. Commas and parentheses in the args
368 string are ignored when assembling, and written into the output
371 Each of these characters corresponds to a mask field defined above.
373 "1" 5 bit sync type (OP_*_SHAMT)
374 "<" 5 bit shift amount (OP_*_SHAMT)
375 ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
376 "a" 26 bit target address (OP_*_TARGET)
377 "b" 5 bit base register (OP_*_RS)
378 "c" 10 bit breakpoint code (OP_*_CODE)
379 "d" 5 bit destination register specifier (OP_*_RD)
380 "h" 5 bit prefx hint (OP_*_PREFX)
381 "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
382 "j" 16 bit signed immediate (OP_*_DELTA)
383 "k" 5 bit cache opcode in target register position (OP_*_CACHE)
384 Also used for immediate operands in vr5400 vector insns.
385 "o" 16 bit signed offset (OP_*_DELTA)
386 "p" 16 bit PC relative branch target address (OP_*_DELTA)
387 "q" 10 bit extra breakpoint code (OP_*_CODE2)
388 "r" 5 bit same register used as both source and target (OP_*_RS)
389 "s" 5 bit source register specifier (OP_*_RS)
390 "t" 5 bit target register (OP_*_RT)
391 "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
392 "v" 5 bit same register used as both source and destination (OP_*_RS)
393 "w" 5 bit same register used as both target and destination (OP_*_RT)
394 "U" 5 bit same destination register in both OP_*_RD and OP_*_RT
395 (used by clo and clz)
396 "C" 25 bit coprocessor function code (OP_*_COPZ)
397 "B" 20 bit syscall/breakpoint function code (OP_*_CODE20)
398 "J" 19 bit wait function code (OP_*_CODE19)
399 "x" accept and ignore register name
400 "z" must be zero register
401 "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD)
402 "+A" 5 bit ins/ext/dins/dext/dinsm/dextm position, which becomes
403 LSB (OP_*_SHAMT; OP_*_EXTLSB or OP_*_STYPE may be used for
404 microMIPS compatibility).
405 Enforces: 0 <= pos < 32.
406 "+B" 5 bit ins/dins size, which becomes MSB (OP_*_INSMSB).
407 Requires that "+A" or "+E" occur first to set position.
408 Enforces: 0 < (pos+size) <= 32.
409 "+C" 5 bit ext/dext size, which becomes MSBD (OP_*_EXTMSBD).
410 Requires that "+A" or "+E" occur first to set position.
411 Enforces: 0 < (pos+size) <= 32.
412 (Also used by "dext" w/ different limits, but limits for
413 that are checked by the M_DEXT macro.)
414 "+E" 5 bit dinsu/dextu position, which becomes LSB-32 (OP_*_SHAMT).
415 Enforces: 32 <= pos < 64.
416 "+F" 5 bit "dinsm/dinsu" size, which becomes MSB-32 (OP_*_INSMSB).
417 Requires that "+A" or "+E" occur first to set position.
418 Enforces: 32 < (pos+size) <= 64.
419 "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD).
420 Requires that "+A" or "+E" occur first to set position.
421 Enforces: 32 < (pos+size) <= 64.
422 "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD).
423 Requires that "+A" or "+E" occur first to set position.
424 Enforces: 32 < (pos+size) <= 64.
426 Floating point instructions:
427 "D" 5 bit destination register (OP_*_FD)
428 "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
429 "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
430 "S" 5 bit fs source 1 register (OP_*_FS)
431 "T" 5 bit ft source 2 register (OP_*_FT)
432 "R" 5 bit fr source 3 register (OP_*_FR)
433 "V" 5 bit same register used as floating source and destination (OP_*_FS)
434 "W" 5 bit same register used as floating target and destination (OP_*_FT)
436 Coprocessor instructions:
437 "E" 5 bit target register (OP_*_RT)
438 "G" 5 bit destination register (OP_*_RD)
439 "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL)
440 "P" 5 bit performance-monitor register (OP_*_PERFREG)
441 "e" 5 bit vector register byte specifier (OP_*_VECBYTE)
442 "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN)
444 "+D" Combined destination register ("G") and sel ("H") for CP0 ops,
445 for pretty-printing in disassembly only.
448 "A" General 32 bit expression
449 "I" 32 bit immediate (value placed in imm_expr).
450 "+I" 32 bit immediate (value placed in imm2_expr).
451 "F" 64 bit floating point constant in .rdata
452 "L" 64 bit floating point constant in .lit8
453 "f" 32 bit floating point constant
454 "l" 32 bit floating point constant in .lit4
456 MDMX instruction operands (note that while these use the FP register
457 fields, they accept both $fN and $vN names for the registers):
458 "O" MDMX alignment offset (OP_*_ALN)
459 "Q" MDMX vector/scalar/immediate source (OP_*_VSEL and OP_*_FT)
460 "X" MDMX destination register (OP_*_FD)
461 "Y" MDMX source register (OP_*_FS)
462 "Z" MDMX source register (OP_*_FT)
465 "2" 2 bit unsigned immediate for byte align (OP_*_BP)
466 "3" 3 bit unsigned immediate (OP_*_SA3)
467 "4" 4 bit unsigned immediate (OP_*_SA4)
468 "5" 8 bit unsigned immediate (OP_*_IMM8)
469 "6" 5 bit unsigned immediate (OP_*_RS)
470 "7" 2 bit dsp accumulator register (OP_*_DSPACC)
471 "8" 6 bit unsigned immediate (OP_*_WRDSP)
472 "9" 2 bit dsp accumulator register (OP_*_DSPACC_S)
473 "0" 6 bit signed immediate (OP_*_DSPSFT)
474 ":" 7 bit signed immediate (OP_*_DSPSFT_7)
475 "'" 6 bit unsigned immediate (OP_*_RDDSP)
476 "@" 10 bit signed immediate (OP_*_IMM10)
479 "!" 1 bit usermode flag (OP_*_MT_U)
480 "$" 1 bit load high flag (OP_*_MT_H)
481 "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T)
482 "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D)
483 "g" 5 bit coprocessor 1 and 2 destination register (OP_*_RD)
484 "+t" 5 bit coprocessor 0 destination register (OP_*_RT)
485 "+T" 5 bit coprocessor 0 destination register (OP_*_RT) - disassembly only
488 "~" 12 bit offset (OP_*_OFFSET12)
489 "\" 3 bit position for aset and aclr (OP_*_3BITPOS)
492 "+J" 10-bit hypcall code (OP_*CODE10)
495 "+1" UDI immediate bits 6-10
496 "+2" UDI immediate bits 6-15
497 "+3" UDI immediate bits 6-20
498 "+4" UDI immediate bits 6-25
501 "+x" Bit index field of bbit. Enforces: 0 <= index < 32.
502 "+X" Bit index field of bbit aliasing bbit32. Matches if 32 <= index < 64,
503 otherwise skips to next candidate.
504 "+p" Position field of cins/cins32/exts/exts32. Enforces 0 <= pos < 32.
505 "+P" Position field of cins/exts aliasing cins32/exts32. Matches if
506 32 <= pos < 64, otherwise skips to next candidate.
507 "+Q" Immediate field of seqi/snei. Enforces -512 <= imm < 512.
508 "+s" Length-minus-one field of cins/exts. Enforces: 0 <= lenm1 < 32.
509 "+S" Length-minus-one field of cins32/exts32 or cins/exts aliasing
510 cint32/exts32. Enforces non-negative value and that
511 pos + lenm1 < 32 or pos + lenm1 < 64 depending whether previous
512 position field is "+p" or "+P".
515 "+a" 8-bit signed offset in bit 6 (OP_*_OFFSET_A)
516 "+b" 8-bit signed offset in bit 3 (OP_*_OFFSET_B)
517 "+c" 9-bit signed offset in bit 6 (OP_*_OFFSET_C)
518 "+z" 5-bit rz register (OP_*_RZ)
519 "+Z" 5-bit fz register (OP_*_FZ)
522 "()" parens surrounding optional value
523 "," separates operands
524 "[]" brackets around index for vector-op scalar operand specifier (vr5400)
525 "+" Start of extension sequence.
527 Characters used so far, for quick reference when adding more:
530 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
531 "abcdefghijklopqrstuvwxz"
533 Extension character sequences used so far ("+" followed by the
534 following), for quick reference when adding more:
540 /* These are the bits which may be set in the pinfo field of an
541 instructions, if it is not equal to INSN_MACRO. */
543 /* Modifies the general purpose register in OP_*_RD. */
544 #define INSN_WRITE_GPR_D 0x00000001
545 /* Modifies the general purpose register in OP_*_RT. */
546 #define INSN_WRITE_GPR_T 0x00000002
547 /* Modifies general purpose register 31. */
548 #define INSN_WRITE_GPR_31 0x00000004
549 /* Modifies the floating point register in OP_*_FD. */
550 #define INSN_WRITE_FPR_D 0x00000008
551 /* Modifies the floating point register in OP_*_FS. */
552 #define INSN_WRITE_FPR_S 0x00000010
553 /* Modifies the floating point register in OP_*_FT. */
554 #define INSN_WRITE_FPR_T 0x00000020
555 /* Reads the general purpose register in OP_*_RS. */
556 #define INSN_READ_GPR_S 0x00000040
557 /* Reads the general purpose register in OP_*_RT. */
558 #define INSN_READ_GPR_T 0x00000080
559 /* Reads the floating point register in OP_*_FS. */
560 #define INSN_READ_FPR_S 0x00000100
561 /* Reads the floating point register in OP_*_FT. */
562 #define INSN_READ_FPR_T 0x00000200
563 /* Reads the floating point register in OP_*_FR. */
564 #define INSN_READ_FPR_R 0x00000400
565 /* Modifies coprocessor condition code. */
566 #define INSN_WRITE_COND_CODE 0x00000800
567 /* Reads coprocessor condition code. */
568 #define INSN_READ_COND_CODE 0x00001000
570 #define INSN_TLB 0x00002000
571 /* Reads coprocessor register other than floating point register. */
572 #define INSN_COP 0x00004000
573 /* Instruction loads value from memory, requiring delay. */
574 #define INSN_LOAD_MEMORY_DELAY 0x00008000
575 /* Instruction loads value from coprocessor, requiring delay. */
576 #define INSN_LOAD_COPROC_DELAY 0x00010000
577 /* Instruction has unconditional branch delay slot. */
578 #define INSN_UNCOND_BRANCH_DELAY 0x00020000
579 /* Instruction has conditional branch delay slot. */
580 #define INSN_COND_BRANCH_DELAY 0x00040000
581 /* Conditional branch likely: if branch not taken, insn nullified. */
582 #define INSN_COND_BRANCH_LIKELY 0x00080000
583 /* Moves to coprocessor register, requiring delay. */
584 #define INSN_COPROC_MOVE_DELAY 0x00100000
585 /* Loads coprocessor register from memory, requiring delay. */
586 #define INSN_COPROC_MEMORY_DELAY 0x00200000
587 /* Reads the HI register. */
588 #define INSN_READ_HI 0x00400000
589 /* Reads the LO register. */
590 #define INSN_READ_LO 0x00800000
591 /* Modifies the HI register. */
592 #define INSN_WRITE_HI 0x01000000
593 /* Modifies the LO register. */
594 #define INSN_WRITE_LO 0x02000000
595 /* Not to be placed in a branch delay slot, either architecturally
596 or for ease of handling (such as with instructions that take a trap). */
597 #define INSN_NO_DELAY_SLOT 0x04000000
598 /* Instruction stores value into memory. */
599 #define INSN_STORE_MEMORY 0x08000000
600 /* Instruction uses single precision floating point. */
601 #define FP_S 0x10000000
602 /* Instruction uses double precision floating point. */
603 #define FP_D 0x20000000
604 /* Instruction is part of the tx39's integer multiply family. */
605 #define INSN_MULT 0x40000000
606 /* Modifies the general purpose register in MICROMIPSOP_*_RS. */
607 #define INSN_WRITE_GPR_S 0x80000000
608 /* Instruction is actually a macro. It should be ignored by the
609 disassembler, and requires special treatment by the assembler. */
610 #define INSN_MACRO 0xffffffff
612 /* These are the bits which may be set in the pinfo2 field of an
615 /* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */
616 #define INSN2_ALIAS 0x00000001
617 /* Instruction reads MDMX accumulator. */
618 #define INSN2_READ_MDMX_ACC 0x00000002
619 /* Instruction writes MDMX accumulator. */
620 #define INSN2_WRITE_MDMX_ACC 0x00000004
621 /* Macro uses single-precision floating-point instructions. This should
622 only be set for macros. For instructions, FP_S in pinfo carries the
624 #define INSN2_M_FP_S 0x00000008
625 /* Macro uses double-precision floating-point instructions. This should
626 only be set for macros. For instructions, FP_D in pinfo carries the
628 #define INSN2_M_FP_D 0x00000010
629 /* Modifies the general purpose register in OP_*_RZ. */
630 #define INSN2_WRITE_GPR_Z 0x00000020
631 /* Modifies the floating point register in OP_*_FZ. */
632 #define INSN2_WRITE_FPR_Z 0x00000040
633 /* Reads the general purpose register in OP_*_RZ. */
634 #define INSN2_READ_GPR_Z 0x00000080
635 /* Reads the floating point register in OP_*_FZ. */
636 #define INSN2_READ_FPR_Z 0x00000100
637 /* Reads the general purpose register in OP_*_RD. */
638 #define INSN2_READ_GPR_D 0x00000200
641 /* Instruction has a branch delay slot that requires a 16-bit instruction. */
642 #define INSN2_BRANCH_DELAY_16BIT 0x00000400
643 /* Instruction has a branch delay slot that requires a 32-bit instruction. */
644 #define INSN2_BRANCH_DELAY_32BIT 0x00000800
645 /* Reads the floating point register in MICROMIPSOP_*_FD. */
646 #define INSN2_READ_FPR_D 0x00001000
647 /* Modifies the general purpose register in MICROMIPSOP_*_MB. */
648 #define INSN2_WRITE_GPR_MB 0x00002000
649 /* Reads the general purpose register in MICROMIPSOP_*_MC. */
650 #define INSN2_READ_GPR_MC 0x00004000
651 /* Reads/writes the general purpose register in MICROMIPSOP_*_MD. */
652 #define INSN2_MOD_GPR_MD 0x00008000
653 /* Reads the general purpose register in MICROMIPSOP_*_ME. */
654 #define INSN2_READ_GPR_ME 0x00010000
655 /* Reads/writes the general purpose register in MICROMIPSOP_*_MF. */
656 #define INSN2_MOD_GPR_MF 0x00020000
657 /* Reads the general purpose register in MICROMIPSOP_*_MG. */
658 #define INSN2_READ_GPR_MG 0x00040000
659 /* Reads the general purpose register in MICROMIPSOP_*_MJ. */
660 #define INSN2_READ_GPR_MJ 0x00080000
661 /* Modifies the general purpose register in MICROMIPSOP_*_MJ. */
662 #define INSN2_WRITE_GPR_MJ 0x00100000
663 /* Reads the general purpose register in MICROMIPSOP_*_MP. */
664 #define INSN2_READ_GPR_MP 0x00200000
665 /* Modifies the general purpose register in MICROMIPSOP_*_MP. */
666 #define INSN2_WRITE_GPR_MP 0x00400000
667 /* Reads the general purpose register in MICROMIPSOP_*_MQ. */
668 #define INSN2_READ_GPR_MQ 0x00800000
669 /* Reads/Writes the stack pointer ($29). */
670 #define INSN2_MOD_SP 0x01000000
671 /* Reads the RA ($31) register. */
672 #define INSN2_READ_GPR_31 0x02000000
673 /* Reads the global pointer ($28). */
674 #define INSN2_READ_GP 0x04000000
675 /* Reads the program counter ($pc). */
676 #define INSN2_READ_PC 0x08000000
677 /* Is an unconditional branch insn. */
678 #define INSN2_UNCOND_BRANCH 0x10000000
679 /* Is a conditional branch insn. */
680 #define INSN2_COND_BRANCH 0x20000000
681 /* Modifies the general purpose registers in MICROMIPSOP_*_MH/I. */
682 #define INSN2_WRITE_GPR_MHI 0x40000000
683 /* Reads the general purpose registers in MICROMIPSOP_*_MM/N. */
684 #define INSN2_READ_GPR_MMN 0x80000000
686 /* Masks used to mark instructions to indicate which MIPS ISA level
687 they were introduced in. INSN_ISA_MASK masks an enumeration that
688 specifies the base ISA level(s). The remainder of a 32-bit
689 word constructed using these macros is a bitmask of the remaining
690 INSN_* values below. */
692 #define INSN_ISA_MASK 0x0000000ful
694 /* We cannot start at zero due to ISA_UNKNOWN below. */
701 #define INSN_ISA32R2 7
703 #define INSN_ISA64R2 9
704 /* Below this point the INSN_* values correspond to combinations of ISAs.
705 They are only for use in the opcodes table to indicate membership of
706 a combination of ISAs that cannot be expressed using the usual inclusion
707 ordering on the above INSN_* values. */
708 #define INSN_ISA3_32 10
709 #define INSN_ISA3_32R2 11
710 #define INSN_ISA4_32 12
711 #define INSN_ISA4_32R2 13
712 #define INSN_ISA5_32R2 14
714 /* Given INSN_ISA* values X and Y, where X ranges over INSN_ISA1 through
715 INSN_ISA5_32R2 and Y ranges over INSN_ISA1 through INSN_ISA64R2,
716 this table describes whether at least one of the ISAs described by X
717 is/are implemented by ISA Y. (Think of Y as the ISA level supported by
718 a particular core and X as the ISA level(s) at which a certain instruction
719 is defined.) The ISA(s) described by X is/are implemented by Y iff
720 (mips_isa_table[(Y & INSN_ISA_MASK) - 1] >> ((X & INSN_ISA_MASK) - 1)) & 1
722 static const unsigned int mips_isa_table
[] =
723 { 0x0001, 0x0003, 0x0607, 0x1e0f, 0x3e1f, 0x0a23, 0x3e63, 0x3ebf, 0x3fff };
725 /* Masks used for Chip specific instructions. */
726 #define INSN_CHIP_MASK 0xc3ff0f20
728 /* Cavium Networks Octeon instructions. */
729 #define INSN_OCTEON 0x00000800
730 #define INSN_OCTEONP 0x00000200
731 #define INSN_OCTEON2 0x00000100
733 /* Masks used for MIPS-defined ASEs. */
734 #define INSN_ASE_MASK 0x3c00f0d0
737 #define INSN_DSP 0x00001000
738 #define INSN_DSP64 0x00002000
740 /* MIPS R5900 instruction */
741 #define INSN_5900 0x00004000
743 /* Virtualization ASE */
744 #define INSN_VIRT 0x00000080
745 #define INSN_VIRT64 0x00000040
748 #define INSN_MIPS3D 0x00008000
750 /* MIPS R4650 instruction. */
751 #define INSN_4650 0x00010000
752 /* LSI R4010 instruction. */
753 #define INSN_4010 0x00020000
754 /* NEC VR4100 instruction. */
755 #define INSN_4100 0x00040000
756 /* Toshiba R3900 instruction. */
757 #define INSN_3900 0x00080000
758 /* MIPS R10000 instruction. */
759 #define INSN_10000 0x00100000
760 /* Broadcom SB-1 instruction. */
761 #define INSN_SB1 0x00200000
762 /* NEC VR4111/VR4181 instruction. */
763 #define INSN_4111 0x00400000
764 /* NEC VR4120 instruction. */
765 #define INSN_4120 0x00800000
766 /* NEC VR5400 instruction. */
767 #define INSN_5400 0x01000000
768 /* NEC VR5500 instruction. */
769 #define INSN_5500 0x02000000
772 #define INSN_MDMX 0x04000000
774 #define INSN_MT 0x08000000
776 #define INSN_SMARTMIPS 0x10000000
778 #define INSN_DSPR2 0x20000000
779 /* ST Microelectronics Loongson 2E. */
780 #define INSN_LOONGSON_2E 0x40000000
781 /* ST Microelectronics Loongson 2F. */
782 #define INSN_LOONGSON_2F 0x80000000
784 #define INSN_LOONGSON_3A 0x00000400
785 /* RMI Xlr instruction */
786 #define INSN_XLR 0x00000020
788 /* MCU (MicroController) ASE */
789 #define INSN_MCU 0x00000010
791 /* MIPS ISA defines, use instead of hardcoding ISA level. */
793 #define ISA_UNKNOWN 0 /* Gas internal use. */
794 #define ISA_MIPS1 INSN_ISA1
795 #define ISA_MIPS2 INSN_ISA2
796 #define ISA_MIPS3 INSN_ISA3
797 #define ISA_MIPS4 INSN_ISA4
798 #define ISA_MIPS5 INSN_ISA5
800 #define ISA_MIPS32 INSN_ISA32
801 #define ISA_MIPS64 INSN_ISA64
803 #define ISA_MIPS32R2 INSN_ISA32R2
804 #define ISA_MIPS64R2 INSN_ISA64R2
807 /* CPU defines, use instead of hardcoding processor number. Keep this
808 in sync with bfd/archures.c in order for machine selection to work. */
809 #define CPU_UNKNOWN 0 /* Gas internal use. */
810 #define CPU_R3000 3000
811 #define CPU_R3900 3900
812 #define CPU_R4000 4000
813 #define CPU_R4010 4010
814 #define CPU_VR4100 4100
815 #define CPU_R4111 4111
816 #define CPU_VR4120 4120
817 #define CPU_R4300 4300
818 #define CPU_R4400 4400
819 #define CPU_R4600 4600
820 #define CPU_R4650 4650
821 #define CPU_R5000 5000
822 #define CPU_VR5400 5400
823 #define CPU_VR5500 5500
824 #define CPU_R5900 5900
825 #define CPU_R6000 6000
826 #define CPU_RM7000 7000
827 #define CPU_R8000 8000
828 #define CPU_RM9000 9000
829 #define CPU_R10000 10000
830 #define CPU_R12000 12000
831 #define CPU_R14000 14000
832 #define CPU_R16000 16000
833 #define CPU_MIPS16 16
834 #define CPU_MIPS32 32
835 #define CPU_MIPS32R2 33
837 #define CPU_MIPS64 64
838 #define CPU_MIPS64R2 65
839 #define CPU_SB1 12310201 /* octal 'SB', 01. */
840 #define CPU_LOONGSON_2E 3001
841 #define CPU_LOONGSON_2F 3002
842 #define CPU_LOONGSON_3A 3003
843 #define CPU_OCTEON 6501
844 #define CPU_OCTEONP 6601
845 #define CPU_OCTEON2 6502
846 #define CPU_XLR 887682 /* decimal 'XLR' */
848 /* Return true if the given CPU is included in INSN_* mask MASK. */
850 static inline bfd_boolean
851 cpu_is_member (int cpu
, unsigned int mask
)
858 return (mask
& INSN_4650
) != 0;
861 return (mask
& INSN_4010
) != 0;
864 return (mask
& INSN_4100
) != 0;
867 return (mask
& INSN_3900
) != 0;
873 return (mask
& INSN_10000
) != 0;
876 return (mask
& INSN_SB1
) != 0;
879 return (mask
& INSN_4111
) != 0;
882 return (mask
& INSN_4120
) != 0;
885 return (mask
& INSN_5400
) != 0;
888 return (mask
& INSN_5500
) != 0;
891 return (mask
& INSN_5900
) != 0;
893 case CPU_LOONGSON_2E
:
894 return (mask
& INSN_LOONGSON_2E
) != 0;
896 case CPU_LOONGSON_2F
:
897 return (mask
& INSN_LOONGSON_2F
) != 0;
899 case CPU_LOONGSON_3A
:
900 return (mask
& INSN_LOONGSON_3A
) != 0;
903 return (mask
& INSN_OCTEON
) != 0;
906 return (mask
& INSN_OCTEONP
) != 0;
909 return (mask
& INSN_OCTEON2
) != 0;
912 return (mask
& INSN_XLR
) != 0;
919 /* Test for membership in an ISA including chip specific ISAs. INSN
920 is pointer to an element of the opcode table; ISA is the specified
921 ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
922 test, or zero if no CPU specific ISA test is desired. Return true
923 if instruction INSN is available to the given ISA and CPU. */
925 static inline bfd_boolean
926 opcode_is_member (const struct mips_opcode
*insn
, int isa
, int cpu
)
928 if (!cpu_is_member (cpu
, insn
->exclusions
))
930 /* Test for ISA level compatibility. */
931 if ((isa
& INSN_ISA_MASK
) != 0
932 && (insn
->membership
& INSN_ISA_MASK
) != 0
933 && ((mips_isa_table
[(isa
& INSN_ISA_MASK
) - 1]
934 >> ((insn
->membership
& INSN_ISA_MASK
) - 1)) & 1) != 0)
937 /* Test for ASE compatibility. */
938 if (((isa
& ~INSN_ISA_MASK
) & (insn
->membership
& ~INSN_ISA_MASK
)) != 0)
941 /* Test for processor-specific extensions. */
942 if (cpu_is_member (cpu
, insn
->membership
))
948 /* This is a list of macro expanded instructions.
950 _I appended means immediate
951 _A appended means address
952 _AB appended means address with base register
953 _D appended means 64 bit floating point constant
954 _S appended means 32 bit floating point constant. */
1255 /* The order of overloaded instructions matters. Label arguments and
1256 register arguments look the same. Instructions that can have either
1257 for arguments must apear in the correct order in this table for the
1258 assembler to pick the right one. In other words, entries with
1259 immediate operands must apear after the same instruction with
1262 Many instructions are short hand for other instructions (i.e., The
1263 jal <register> instruction is short for jalr <register>). */
1265 extern const struct mips_opcode mips_builtin_opcodes
[];
1266 extern const int bfd_mips_num_builtin_opcodes
;
1267 extern struct mips_opcode
*mips_opcodes
;
1268 extern int bfd_mips_num_opcodes
;
1269 #define NUMOPCODES bfd_mips_num_opcodes
1272 /* The rest of this file adds definitions for the mips16 TinyRISC
1275 /* These are the bitmasks and shift counts used for the different
1276 fields in the instruction formats. Other than OP, no masks are
1277 provided for the fixed portions of an instruction, since they are
1280 The I format uses IMM11.
1282 The RI format uses RX and IMM8.
1284 The RR format uses RX, and RY.
1286 The RRI format uses RX, RY, and IMM5.
1288 The RRR format uses RX, RY, and RZ.
1290 The RRI_A format uses RX, RY, and IMM4.
1292 The SHIFT format uses RX, RY, and SHAMT.
1294 The I8 format uses IMM8.
1296 The I8_MOVR32 format uses RY and REGR32.
1298 The IR_MOV32R format uses REG32R and MOV32Z.
1300 The I64 format uses IMM8.
1302 The RI64 format uses RY and IMM5.
1305 #define MIPS16OP_MASK_OP 0x1f
1306 #define MIPS16OP_SH_OP 11
1307 #define MIPS16OP_MASK_IMM11 0x7ff
1308 #define MIPS16OP_SH_IMM11 0
1309 #define MIPS16OP_MASK_RX 0x7
1310 #define MIPS16OP_SH_RX 8
1311 #define MIPS16OP_MASK_IMM8 0xff
1312 #define MIPS16OP_SH_IMM8 0
1313 #define MIPS16OP_MASK_RY 0x7
1314 #define MIPS16OP_SH_RY 5
1315 #define MIPS16OP_MASK_IMM5 0x1f
1316 #define MIPS16OP_SH_IMM5 0
1317 #define MIPS16OP_MASK_RZ 0x7
1318 #define MIPS16OP_SH_RZ 2
1319 #define MIPS16OP_MASK_IMM4 0xf
1320 #define MIPS16OP_SH_IMM4 0
1321 #define MIPS16OP_MASK_REGR32 0x1f
1322 #define MIPS16OP_SH_REGR32 0
1323 #define MIPS16OP_MASK_REG32R 0x1f
1324 #define MIPS16OP_SH_REG32R 3
1325 #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
1326 #define MIPS16OP_MASK_MOVE32Z 0x7
1327 #define MIPS16OP_SH_MOVE32Z 0
1328 #define MIPS16OP_MASK_IMM6 0x3f
1329 #define MIPS16OP_SH_IMM6 5
1331 /* These are the characters which may appears in the args field of a MIPS16
1332 instruction. They appear in the order in which the fields appear when the
1333 instruction is used. Commas and parentheses in the args string are ignored
1334 when assembling, and written into the output when disassembling.
1336 "y" 3 bit register (MIPS16OP_*_RY)
1337 "x" 3 bit register (MIPS16OP_*_RX)
1338 "z" 3 bit register (MIPS16OP_*_RZ)
1339 "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
1340 "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
1341 "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
1342 "0" zero register ($0)
1343 "S" stack pointer ($sp or $29)
1345 "R" return address register ($ra or $31)
1346 "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
1347 "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
1348 "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
1349 "a" 26 bit jump address
1350 "e" 11 bit extension value
1351 "l" register list for entry instruction
1352 "L" register list for exit instruction
1354 The remaining codes may be extended. Except as otherwise noted,
1355 the full extended operand is a 16 bit signed value.
1356 "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
1357 ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned)
1358 "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
1359 "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
1360 "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
1361 "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
1362 "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
1363 "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
1364 "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
1365 "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
1366 "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
1367 "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
1368 "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
1369 "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
1370 "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
1371 "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
1372 "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
1373 "q" 11 bit branch address (MIPS16OP_*_IMM11)
1374 "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
1375 "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
1376 "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
1377 "m" 7 bit register list for save instruction (18 bit extended)
1378 "M" 7 bit register list for restore instruction (18 bit extended)
1381 /* Save/restore encoding for the args field when all 4 registers are
1382 either saved as arguments or saved/restored as statics. */
1383 #define MIPS16_ALL_ARGS 0xe
1384 #define MIPS16_ALL_STATICS 0xb
1386 /* For the mips16, we use the same opcode table format and a few of
1387 the same flags. However, most of the flags are different. */
1389 /* Modifies the register in MIPS16OP_*_RX. */
1390 #define MIPS16_INSN_WRITE_X 0x00000001
1391 /* Modifies the register in MIPS16OP_*_RY. */
1392 #define MIPS16_INSN_WRITE_Y 0x00000002
1393 /* Modifies the register in MIPS16OP_*_RZ. */
1394 #define MIPS16_INSN_WRITE_Z 0x00000004
1395 /* Modifies the T ($24) register. */
1396 #define MIPS16_INSN_WRITE_T 0x00000008
1397 /* Modifies the SP ($29) register. */
1398 #define MIPS16_INSN_WRITE_SP 0x00000010
1399 /* Modifies the RA ($31) register. */
1400 #define MIPS16_INSN_WRITE_31 0x00000020
1401 /* Modifies the general purpose register in MIPS16OP_*_REG32R. */
1402 #define MIPS16_INSN_WRITE_GPR_Y 0x00000040
1403 /* Reads the register in MIPS16OP_*_RX. */
1404 #define MIPS16_INSN_READ_X 0x00000080
1405 /* Reads the register in MIPS16OP_*_RY. */
1406 #define MIPS16_INSN_READ_Y 0x00000100
1407 /* Reads the register in MIPS16OP_*_MOVE32Z. */
1408 #define MIPS16_INSN_READ_Z 0x00000200
1409 /* Reads the T ($24) register. */
1410 #define MIPS16_INSN_READ_T 0x00000400
1411 /* Reads the SP ($29) register. */
1412 #define MIPS16_INSN_READ_SP 0x00000800
1413 /* Reads the RA ($31) register. */
1414 #define MIPS16_INSN_READ_31 0x00001000
1415 /* Reads the program counter. */
1416 #define MIPS16_INSN_READ_PC 0x00002000
1417 /* Reads the general purpose register in MIPS16OP_*_REGR32. */
1418 #define MIPS16_INSN_READ_GPR_X 0x00004000
1419 /* Is an unconditional branch insn. */
1420 #define MIPS16_INSN_UNCOND_BRANCH 0x00008000
1421 /* Is a conditional branch insn. */
1422 #define MIPS16_INSN_COND_BRANCH 0x00010000
1424 /* The following flags have the same value for the mips16 opcode
1429 INSN_UNCOND_BRANCH_DELAY
1430 INSN_COND_BRANCH_DELAY
1431 INSN_COND_BRANCH_LIKELY (never used)
1440 extern const struct mips_opcode mips16_opcodes
[];
1441 extern const int bfd_mips16_num_opcodes
;
1443 /* These are the bit masks and shift counts used for the different fields
1444 in the microMIPS instruction formats. No masks are provided for the
1445 fixed portions of an instruction, since they are not needed. */
1447 #define MICROMIPSOP_MASK_IMMEDIATE 0xffff
1448 #define MICROMIPSOP_SH_IMMEDIATE 0
1449 #define MICROMIPSOP_MASK_DELTA 0xffff
1450 #define MICROMIPSOP_SH_DELTA 0
1451 #define MICROMIPSOP_MASK_CODE10 0x3ff
1452 #define MICROMIPSOP_SH_CODE10 16 /* 10-bit wait code. */
1453 #define MICROMIPSOP_MASK_TRAP 0xf
1454 #define MICROMIPSOP_SH_TRAP 12 /* 4-bit trap code. */
1455 #define MICROMIPSOP_MASK_SHAMT 0x1f
1456 #define MICROMIPSOP_SH_SHAMT 11
1457 #define MICROMIPSOP_MASK_TARGET 0x3ffffff
1458 #define MICROMIPSOP_SH_TARGET 0
1459 #define MICROMIPSOP_MASK_EXTLSB 0x1f /* "ext" LSB. */
1460 #define MICROMIPSOP_SH_EXTLSB 6
1461 #define MICROMIPSOP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */
1462 #define MICROMIPSOP_SH_EXTMSBD 11
1463 #define MICROMIPSOP_MASK_INSMSB 0x1f /* "ins" MSB. */
1464 #define MICROMIPSOP_SH_INSMSB 11
1465 #define MICROMIPSOP_MASK_CODE 0x3ff
1466 #define MICROMIPSOP_SH_CODE 16 /* 10-bit higher break code. */
1467 #define MICROMIPSOP_MASK_CODE2 0x3ff
1468 #define MICROMIPSOP_SH_CODE2 6 /* 10-bit lower break code. */
1469 #define MICROMIPSOP_MASK_CACHE 0x1f
1470 #define MICROMIPSOP_SH_CACHE 21 /* 5-bit cache op. */
1471 #define MICROMIPSOP_MASK_SEL 0x7
1472 #define MICROMIPSOP_SH_SEL 11
1473 #define MICROMIPSOP_MASK_OFFSET12 0xfff
1474 #define MICROMIPSOP_SH_OFFSET12 0
1475 #define MICROMIPSOP_MASK_3BITPOS 0x7
1476 #define MICROMIPSOP_SH_3BITPOS 21
1477 #define MICROMIPSOP_MASK_STYPE 0x1f
1478 #define MICROMIPSOP_SH_STYPE 16
1479 #define MICROMIPSOP_MASK_OFFSET10 0x3ff
1480 #define MICROMIPSOP_SH_OFFSET10 6
1481 #define MICROMIPSOP_MASK_RS 0x1f
1482 #define MICROMIPSOP_SH_RS 16
1483 #define MICROMIPSOP_MASK_RT 0x1f
1484 #define MICROMIPSOP_SH_RT 21
1485 #define MICROMIPSOP_MASK_RD 0x1f
1486 #define MICROMIPSOP_SH_RD 11
1487 #define MICROMIPSOP_MASK_FS 0x1f
1488 #define MICROMIPSOP_SH_FS 16
1489 #define MICROMIPSOP_MASK_FT 0x1f
1490 #define MICROMIPSOP_SH_FT 21
1491 #define MICROMIPSOP_MASK_FD 0x1f
1492 #define MICROMIPSOP_SH_FD 11
1493 #define MICROMIPSOP_MASK_FR 0x1f
1494 #define MICROMIPSOP_SH_FR 6
1495 #define MICROMIPSOP_MASK_RS3 0x1f
1496 #define MICROMIPSOP_SH_RS3 6
1497 #define MICROMIPSOP_MASK_PREFX 0x1f
1498 #define MICROMIPSOP_SH_PREFX 11
1499 #define MICROMIPSOP_MASK_BCC 0x7
1500 #define MICROMIPSOP_SH_BCC 18
1501 #define MICROMIPSOP_MASK_CCC 0x7
1502 #define MICROMIPSOP_SH_CCC 13
1503 #define MICROMIPSOP_MASK_COPZ 0x7fffff
1504 #define MICROMIPSOP_SH_COPZ 3
1506 #define MICROMIPSOP_MASK_MB 0x7
1507 #define MICROMIPSOP_SH_MB 23
1508 #define MICROMIPSOP_MASK_MC 0x7
1509 #define MICROMIPSOP_SH_MC 4
1510 #define MICROMIPSOP_MASK_MD 0x7
1511 #define MICROMIPSOP_SH_MD 7
1512 #define MICROMIPSOP_MASK_ME 0x7
1513 #define MICROMIPSOP_SH_ME 1
1514 #define MICROMIPSOP_MASK_MF 0x7
1515 #define MICROMIPSOP_SH_MF 3
1516 #define MICROMIPSOP_MASK_MG 0x7
1517 #define MICROMIPSOP_SH_MG 0
1518 #define MICROMIPSOP_MASK_MH 0x7
1519 #define MICROMIPSOP_SH_MH 7
1520 #define MICROMIPSOP_MASK_MI 0x7
1521 #define MICROMIPSOP_SH_MI 7
1522 #define MICROMIPSOP_MASK_MJ 0x1f
1523 #define MICROMIPSOP_SH_MJ 0
1524 #define MICROMIPSOP_MASK_ML 0x7
1525 #define MICROMIPSOP_SH_ML 4
1526 #define MICROMIPSOP_MASK_MM 0x7
1527 #define MICROMIPSOP_SH_MM 1
1528 #define MICROMIPSOP_MASK_MN 0x7
1529 #define MICROMIPSOP_SH_MN 4
1530 #define MICROMIPSOP_MASK_MP 0x1f
1531 #define MICROMIPSOP_SH_MP 5
1532 #define MICROMIPSOP_MASK_MQ 0x7
1533 #define MICROMIPSOP_SH_MQ 7
1535 #define MICROMIPSOP_MASK_IMMA 0x7f
1536 #define MICROMIPSOP_SH_IMMA 0
1537 #define MICROMIPSOP_MASK_IMMB 0x7
1538 #define MICROMIPSOP_SH_IMMB 1
1539 #define MICROMIPSOP_MASK_IMMC 0xf
1540 #define MICROMIPSOP_SH_IMMC 0
1541 #define MICROMIPSOP_MASK_IMMD 0x3ff
1542 #define MICROMIPSOP_SH_IMMD 0
1543 #define MICROMIPSOP_MASK_IMME 0x7f
1544 #define MICROMIPSOP_SH_IMME 0
1545 #define MICROMIPSOP_MASK_IMMF 0xf
1546 #define MICROMIPSOP_SH_IMMF 0
1547 #define MICROMIPSOP_MASK_IMMG 0xf
1548 #define MICROMIPSOP_SH_IMMG 0
1549 #define MICROMIPSOP_MASK_IMMH 0xf
1550 #define MICROMIPSOP_SH_IMMH 0
1551 #define MICROMIPSOP_MASK_IMMI 0x7f
1552 #define MICROMIPSOP_SH_IMMI 0
1553 #define MICROMIPSOP_MASK_IMMJ 0xf
1554 #define MICROMIPSOP_SH_IMMJ 0
1555 #define MICROMIPSOP_MASK_IMML 0xf
1556 #define MICROMIPSOP_SH_IMML 0
1557 #define MICROMIPSOP_MASK_IMMM 0x7
1558 #define MICROMIPSOP_SH_IMMM 1
1559 #define MICROMIPSOP_MASK_IMMN 0x3
1560 #define MICROMIPSOP_SH_IMMN 4
1561 #define MICROMIPSOP_MASK_IMMO 0xf
1562 #define MICROMIPSOP_SH_IMMO 0
1563 #define MICROMIPSOP_MASK_IMMP 0x1f
1564 #define MICROMIPSOP_SH_IMMP 0
1565 #define MICROMIPSOP_MASK_IMMQ 0x7fffff
1566 #define MICROMIPSOP_SH_IMMQ 0
1567 #define MICROMIPSOP_MASK_IMMU 0x1f
1568 #define MICROMIPSOP_SH_IMMU 0
1569 #define MICROMIPSOP_MASK_IMMW 0x3f
1570 #define MICROMIPSOP_SH_IMMW 1
1571 #define MICROMIPSOP_MASK_IMMX 0xf
1572 #define MICROMIPSOP_SH_IMMX 1
1573 #define MICROMIPSOP_MASK_IMMY 0x1ff
1574 #define MICROMIPSOP_SH_IMMY 1
1577 #define MICROMIPSOP_MASK_DSPACC 0x3
1578 #define MICROMIPSOP_SH_DSPACC 14
1579 #define MICROMIPSOP_MASK_DSPSFT 0x3f
1580 #define MICROMIPSOP_SH_DSPSFT 16
1581 #define MICROMIPSOP_MASK_SA3 0x7
1582 #define MICROMIPSOP_SH_SA3 13
1583 #define MICROMIPSOP_MASK_SA4 0xf
1584 #define MICROMIPSOP_SH_SA4 12
1585 #define MICROMIPSOP_MASK_IMM8 0xff
1586 #define MICROMIPSOP_SH_IMM8 13
1587 #define MICROMIPSOP_MASK_IMM10 0x3ff
1588 #define MICROMIPSOP_SH_IMM10 16
1589 #define MICROMIPSOP_MASK_WRDSP 0x3f
1590 #define MICROMIPSOP_SH_WRDSP 14
1591 #define MICROMIPSOP_MASK_BP 0x3
1592 #define MICROMIPSOP_SH_BP 14
1594 /* Placeholders for fields that only exist in the traditional 32-bit
1595 instruction encoding; see the comment above for details. */
1596 #define MICROMIPSOP_MASK_CODE20 0
1597 #define MICROMIPSOP_SH_CODE20 0
1598 #define MICROMIPSOP_MASK_PERFREG 0
1599 #define MICROMIPSOP_SH_PERFREG 0
1600 #define MICROMIPSOP_MASK_CODE19 0
1601 #define MICROMIPSOP_SH_CODE19 0
1602 #define MICROMIPSOP_MASK_ALN 0
1603 #define MICROMIPSOP_SH_ALN 0
1604 #define MICROMIPSOP_MASK_VECBYTE 0
1605 #define MICROMIPSOP_SH_VECBYTE 0
1606 #define MICROMIPSOP_MASK_VECALIGN 0
1607 #define MICROMIPSOP_SH_VECALIGN 0
1608 #define MICROMIPSOP_MASK_DSPACC_S 0
1609 #define MICROMIPSOP_SH_DSPACC_S 0
1610 #define MICROMIPSOP_MASK_DSPSFT_7 0
1611 #define MICROMIPSOP_SH_DSPSFT_7 0
1612 #define MICROMIPSOP_MASK_RDDSP 0
1613 #define MICROMIPSOP_SH_RDDSP 0
1614 #define MICROMIPSOP_MASK_MT_U 0
1615 #define MICROMIPSOP_SH_MT_U 0
1616 #define MICROMIPSOP_MASK_MT_H 0
1617 #define MICROMIPSOP_SH_MT_H 0
1618 #define MICROMIPSOP_MASK_MTACC_T 0
1619 #define MICROMIPSOP_SH_MTACC_T 0
1620 #define MICROMIPSOP_MASK_MTACC_D 0
1621 #define MICROMIPSOP_SH_MTACC_D 0
1622 #define MICROMIPSOP_MASK_BBITIND 0
1623 #define MICROMIPSOP_SH_BBITIND 0
1624 #define MICROMIPSOP_MASK_CINSPOS 0
1625 #define MICROMIPSOP_SH_CINSPOS 0
1626 #define MICROMIPSOP_MASK_CINSLM1 0
1627 #define MICROMIPSOP_SH_CINSLM1 0
1628 #define MICROMIPSOP_MASK_SEQI 0
1629 #define MICROMIPSOP_SH_SEQI 0
1630 #define MICROMIPSOP_SH_OFFSET_A 0
1631 #define MICROMIPSOP_MASK_OFFSET_A 0
1632 #define MICROMIPSOP_SH_OFFSET_B 0
1633 #define MICROMIPSOP_MASK_OFFSET_B 0
1634 #define MICROMIPSOP_SH_OFFSET_C 0
1635 #define MICROMIPSOP_MASK_OFFSET_C 0
1636 #define MICROMIPSOP_SH_RZ 0
1637 #define MICROMIPSOP_MASK_RZ 0
1638 #define MICROMIPSOP_SH_FZ 0
1639 #define MICROMIPSOP_MASK_FZ 0
1641 /* These are the characters which may appears in the args field of a microMIPS
1642 instruction. They appear in the order in which the fields appear
1643 when the instruction is used. Commas and parentheses in the args
1644 string are ignored when assembling, and written into the output
1647 The followings are for 16-bit microMIPS instructions.
1650 "mc" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MC) at bit 4
1651 The same register used as both source and target.
1652 "md" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MD) at bit 7
1653 "me" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ME) at bit 1
1654 The same register used as both source and target.
1655 "mf" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MF) at bit 3
1656 "mg" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MG) at bit 0
1657 "mh" MIPS registers 4, 5, 6 (MICROMIPSOP_*_MH) at bit 7
1658 "mi" MIPS registers 5, 6, 7, 21, 22 (MICROMIPSOP_*_MI) at bit 7
1659 ("mh" and "mi" form a valid 3-bit register pair)
1660 "mj" 5-bit MIPS registers (MICROMIPSOP_*_MJ) at bit 0
1661 "ml" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ML) at bit 4
1662 "mm" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MM) at bit 1
1663 "mn" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MN) at bit 4
1664 "mp" 5-bit MIPS registers (MICROMIPSOP_*_MP) at bit 5
1665 "mq" 3-bit MIPS registers 0, 2-7, 17 (MICROMIPSOP_*_MQ) at bit 7
1666 "mr" must be program counter
1668 "mt" must be the same as the previous register
1669 "mx" must be the same as the destination register
1673 "mA" 7-bit immediate (-64 .. 63) << 2 (MICROMIPSOP_*_IMMA)
1674 "mB" 3-bit immediate (-1, 1, 4, 8, 12, 16, 20, 24) (MICROMIPSOP_*_IMMB)
1675 "mC" 4-bit immediate (1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64, 128, 255,
1676 32768, 65535) (MICROMIPSOP_*_IMMC)
1677 "mD" 10-bit branch address (-512 .. 511) << 1 (MICROMIPSOP_*_IMMD)
1678 "mE" 7-bit branch address (-64 .. 63) << 1 (MICROMIPSOP_*_IMME)
1679 "mF" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMMF)
1680 "mG" 4-bit immediate (-1 .. 14) (MICROMIPSOP_*_IMMG)
1681 "mH" 4-bit immediate (0 .. 15) << 1 (MICROMIPSOP_*_IMMH)
1682 "mI" 7-bit immediate (-1 .. 126) (MICROMIPSOP_*_IMMI)
1683 "mJ" 4-bit immediate (0 .. 15) << 2 (MICROMIPSOP_*_IMMJ)
1684 "mL" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
1685 "mM" 3-bit immediate (1 .. 8) (MICROMIPSOP_*_IMMM)
1686 "mN" 2-bit immediate (0 .. 3) for register list (MICROMIPSOP_*_IMMN)
1687 "mO" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
1688 "mP" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMP)
1689 "mU" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMU)
1690 "mW" 6-bit immediate (0 .. 63) << 2 (MICROMIPSOP_*_IMMW)
1691 "mX" 4-bit immediate (-8 .. 7) (MICROMIPSOP_*_IMMX)
1692 "mY" 9-bit immediate (-258 .. -3, 2 .. 257) << 2 (MICROMIPSOP_*_IMMY)
1695 In most cases 32-bit microMIPS instructions use the same characters
1696 as MIPS (with ADDIUPC being a notable exception, but there are some
1699 "." 10-bit signed offset/number (MICROMIPSOP_*_OFFSET10)
1700 "1" 5-bit sync type (MICROMIPSOP_*_SHAMT)
1701 "<" 5-bit shift amount (MICROMIPSOP_*_SHAMT)
1702 ">" shift amount between 32 and 63, stored after subtracting 32
1703 (MICROMIPSOP_*_SHAMT)
1704 "\" 3-bit position for ASET and ACLR (MICROMIPSOP_*_3BITPOS)
1705 "|" 4-bit trap code (MICROMIPSOP_*_TRAP)
1706 "~" 12-bit signed offset (MICROMIPSOP_*_OFFSET12)
1707 "a" 26-bit target address (MICROMIPSOP_*_TARGET)
1708 "b" 5-bit base register (MICROMIPSOP_*_RS)
1709 "c" 10-bit higher breakpoint code (MICROMIPSOP_*_CODE)
1710 "d" 5-bit destination register specifier (MICROMIPSOP_*_RD)
1711 "h" 5-bit PREFX hint (MICROMIPSOP_*_PREFX)
1712 "i" 16-bit unsigned immediate (MICROMIPSOP_*_IMMEDIATE)
1713 "j" 16-bit signed immediate (MICROMIPSOP_*_DELTA)
1714 "k" 5-bit cache opcode in target register position (MICROMIPSOP_*_CACHE)
1715 "n" register list for 32-bit LWM/SWM instruction (MICROMIPSOP_*_RT)
1716 "o" 16-bit signed offset (MICROMIPSOP_*_DELTA)
1717 "p" 16-bit PC-relative branch target address (MICROMIPSOP_*_DELTA)
1718 "q" 10-bit lower breakpoint code (MICROMIPSOP_*_CODE2)
1719 "r" 5-bit same register used as both source and target (MICROMIPSOP_*_RS)
1720 "s" 5-bit source register specifier (MICROMIPSOP_*_RS)
1721 "t" 5-bit target register (MICROMIPSOP_*_RT)
1722 "u" 16-bit upper 16 bits of address (MICROMIPSOP_*_IMMEDIATE)
1723 "v" 5-bit same register used as both source and destination
1725 "w" 5-bit same register used as both target and destination
1727 "y" 5-bit source 3 register for ALNV.PS (MICROMIPSOP_*_RS3)
1728 "z" must be zero register
1729 "C" 23-bit coprocessor function code (MICROMIPSOP_*_COPZ)
1730 "B" 10-bit syscall/wait function code (MICROMIPSOP_*_CODE10)
1731 "K" 5-bit Hardware Register (RDHWR instruction) (MICROMIPSOP_*_RS)
1733 "+A" 5-bit INS/EXT/DINS/DEXT/DINSM/DEXTM position, which becomes
1734 LSB (MICROMIPSOP_*_EXTLSB).
1735 Enforces: 0 <= pos < 32.
1736 "+B" 5-bit INS/DINS size, which becomes MSB (MICROMIPSOP_*_INSMSB).
1737 Requires that "+A" or "+E" occur first to set position.
1738 Enforces: 0 < (pos+size) <= 32.
1739 "+C" 5-bit EXT/DEXT size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
1740 Requires that "+A" or "+E" occur first to set position.
1741 Enforces: 0 < (pos+size) <= 32.
1742 (Also used by DEXT w/ different limits, but limits for
1743 that are checked by the M_DEXT macro.)
1744 "+E" 5-bit DINSU/DEXTU position, which becomes LSB-32 (MICROMIPSOP_*_EXTLSB).
1745 Enforces: 32 <= pos < 64.
1746 "+F" 5-bit DINSM/DINSU size, which becomes MSB-32 (MICROMIPSOP_*_INSMSB).
1747 Requires that "+A" or "+E" occur first to set position.
1748 Enforces: 32 < (pos+size) <= 64.
1749 "+G" 5-bit DEXTM size, which becomes MSBD-32 (MICROMIPSOP_*_EXTMSBD).
1750 Requires that "+A" or "+E" occur first to set position.
1751 Enforces: 32 < (pos+size) <= 64.
1752 "+H" 5-bit DEXTU size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
1753 Requires that "+A" or "+E" occur first to set position.
1754 Enforces: 32 < (pos+size) <= 64.
1756 PC-relative addition (ADDIUPC) instruction:
1757 "mQ" 23-bit offset (-4194304 .. 4194303) << 2 (MICROMIPSOP_*_IMMQ)
1758 "mb" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MB) at bit 23
1760 Floating point instructions:
1761 "D" 5-bit destination register (MICROMIPSOP_*_FD)
1762 "M" 3-bit compare condition code (MICROMIPSOP_*_CCC)
1763 "N" 3-bit branch condition code (MICROMIPSOP_*_BCC)
1764 "R" 5-bit fr source 3 register (MICROMIPSOP_*_FR)
1765 "S" 5-bit fs source 1 register (MICROMIPSOP_*_FS)
1766 "T" 5-bit ft source 2 register (MICROMIPSOP_*_FT)
1767 "V" 5-bit same register used as floating source and destination or target
1770 Coprocessor instructions:
1771 "E" 5-bit target register (MICROMIPSOP_*_RT)
1772 "G" 5-bit destination register (MICROMIPSOP_*_RD)
1773 "H" 3-bit sel field for (D)MTC* and (D)MFC* (MICROMIPSOP_*_SEL)
1774 "+D" combined destination register ("G") and sel ("H") for CP0 ops,
1775 for pretty-printing in disassembly only
1778 "A" general 32 bit expression
1779 "I" 32-bit immediate (value placed in imm_expr).
1780 "+I" 32-bit immediate (value placed in imm2_expr).
1781 "F" 64-bit floating point constant in .rdata
1782 "L" 64-bit floating point constant in .lit8
1783 "f" 32-bit floating point constant
1784 "l" 32-bit floating point constant in .lit4
1787 "2" 2-bit unsigned immediate for byte align (MICROMIPSOP_*_BP)
1788 "3" 3-bit unsigned immediate (MICROMIPSOP_*_SA3)
1789 "4" 4-bit unsigned immediate (MICROMIPSOP_*_SA4)
1790 "5" 8-bit unsigned immediate (MICROMIPSOP_*_IMM8)
1791 "6" 5-bit unsigned immediate (MICROMIPSOP_*_RS)
1792 "7" 2-bit DSP accumulator register (MICROMIPSOP_*_DSPACC)
1793 "8" 6-bit unsigned immediate (MICROMIPSOP_*_WRDSP)
1794 "0" 6-bit signed immediate (MICROMIPSOP_*_DSPSFT)
1795 "@" 10-bit signed immediate (MICROMIPSOP_*_IMM10)
1796 "^" 5-bit unsigned immediate (MICROMIPSOP_*_RD)
1799 "()" parens surrounding optional value
1800 "," separates operands
1801 "+" start of extension sequence
1802 "m" start of microMIPS extension sequence
1804 Characters used so far, for quick reference when adding more:
1807 "ABCDEFGHI KLMN RST V "
1808 "abcd f hijklmnopqrstuvw yz"
1810 Extension character sequences used so far ("+" followed by the
1811 following), for quick reference when adding more:
1817 Extension character sequences used so far ("m" followed by the
1818 following), for quick reference when adding more:
1821 " BCDEFGHIJ LMNOPQ U WXYZ"
1822 " bcdefghij lmn pq st xyz"
1825 extern const struct mips_opcode micromips_opcodes
[];
1826 extern const int bfd_micromips_num_opcodes
;
1828 /* A NOP insn impemented as "or at,at,zero".
1829 Used to implement -mfix-loongson2f. */
1830 #define LOONGSON2F_NOP_INSN 0x00200825
1832 #endif /* _MIPS_H_ */