1 /* mips.h. Mips opcode list for GDB, the GNU debugger.
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
4 Contributed by Ralph Campbell and OSF
5 Commented and modified by Ian Lance Taylor, Cygnus Support
7 This file is part of GDB, GAS, and the GNU binutils.
9 GDB, GAS, and the GNU binutils are free software; you can redistribute
10 them and/or modify them under the terms of the GNU General Public
11 License as published by the Free Software Foundation; either version
12 1, or (at your option) any later version.
14 GDB, GAS, and the GNU binutils are distributed in the hope that they
15 will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 the GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this file; see the file COPYING. If not, write to the Free
21 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 /* These are bit masks and shift counts to use to access the various
27 fields of an instruction. To retrieve the X field of an
28 instruction, use the expression
29 (i >> OP_SH_X) & OP_MASK_X
30 To set the same field (to j), use
31 i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X)
33 Make sure you use fields that are appropriate for the instruction,
36 The 'i' format uses OP, RS, RT and IMMEDIATE.
38 The 'j' format uses OP and TARGET.
40 The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT.
42 The 'b' format uses OP, RS, RT and DELTA.
44 The floating point 'i' format uses OP, RS, RT and IMMEDIATE.
46 The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT.
48 A breakpoint instruction uses OP, CODE and SPEC (10 bits of the
49 breakpoint instruction are not defined; Kane says the breakpoint
50 code field in BREAK is 20 bits; yet MIPS assemblers and debuggers
51 only use ten bits). An optional two-operand form of break/sdbbp
52 allows the lower ten bits to be set too, and MIPS32 and later
53 architectures allow 20 bits to be set with a signal operand
56 The syscall instruction uses CODE20.
58 The general coprocessor instructions use COPZ. */
60 #define OP_MASK_OP 0x3f
62 #define OP_MASK_RS 0x1f
64 #define OP_MASK_FR 0x1f
66 #define OP_MASK_FMT 0x1f
68 #define OP_MASK_BCC 0x7
70 #define OP_MASK_CODE 0x3ff
72 #define OP_MASK_CODE2 0x3ff
74 #define OP_MASK_RT 0x1f
76 #define OP_MASK_FT 0x1f
78 #define OP_MASK_CACHE 0x1f
79 #define OP_SH_CACHE 16
80 #define OP_MASK_RD 0x1f
82 #define OP_MASK_FS 0x1f
84 #define OP_MASK_PREFX 0x1f
85 #define OP_SH_PREFX 11
86 #define OP_MASK_CCC 0x7
88 #define OP_MASK_CODE20 0xfffff /* 20 bit syscall/breakpoint code. */
89 #define OP_SH_CODE20 6
90 #define OP_MASK_SHAMT 0x1f
92 #define OP_MASK_FD 0x1f
94 #define OP_MASK_TARGET 0x3ffffff
95 #define OP_SH_TARGET 0
96 #define OP_MASK_COPZ 0x1ffffff
98 #define OP_MASK_IMMEDIATE 0xffff
99 #define OP_SH_IMMEDIATE 0
100 #define OP_MASK_DELTA 0xffff
101 #define OP_SH_DELTA 0
102 #define OP_MASK_FUNCT 0x3f
103 #define OP_SH_FUNCT 0
104 #define OP_MASK_SPEC 0x3f
106 #define OP_SH_LOCC 8 /* FP condition code. */
107 #define OP_SH_HICC 18 /* FP condition code. */
108 #define OP_MASK_CC 0x7
109 #define OP_SH_COP1NORM 25 /* Normal COP1 encoding. */
110 #define OP_MASK_COP1NORM 0x1 /* a single bit. */
111 #define OP_SH_COP1SPEC 21 /* COP1 encodings. */
112 #define OP_MASK_COP1SPEC 0xf
113 #define OP_MASK_COP1SCLR 0x4
114 #define OP_MASK_COP1CMP 0x3
115 #define OP_SH_COP1CMP 4
116 #define OP_SH_FORMAT 21 /* FP short format field. */
117 #define OP_MASK_FORMAT 0x7
118 #define OP_SH_TRUE 16
119 #define OP_MASK_TRUE 0x1
121 #define OP_MASK_GE 0x01
122 #define OP_SH_UNSIGNED 16
123 #define OP_MASK_UNSIGNED 0x1
124 #define OP_SH_HINT 16
125 #define OP_MASK_HINT 0x1f
126 #define OP_SH_MMI 0 /* Multimedia (parallel) op. */
127 #define OP_MASK_MMI 0x3f
128 #define OP_SH_MMISUB 6
129 #define OP_MASK_MMISUB 0x1f
130 #define OP_MASK_PERFREG 0x1f /* Performance monitoring. */
131 #define OP_SH_PERFREG 1
132 #define OP_SH_SEL 0 /* Coprocessor select field. */
133 #define OP_MASK_SEL 0x7 /* The sel field of mfcZ and mtcZ. */
134 #define OP_SH_CODE19 6 /* 19 bit wait code. */
135 #define OP_MASK_CODE19 0x7ffff
137 #define OP_MASK_ALN 0x7
138 #define OP_SH_VSEL 21
139 #define OP_MASK_VSEL 0x1f
140 #define OP_MASK_VECBYTE 0x7 /* Selector field is really 4 bits,
141 but 0x8-0xf don't select bytes. */
142 #define OP_SH_VECBYTE 22
143 #define OP_MASK_VECALIGN 0x7 /* Vector byte-align (alni.ob) op. */
144 #define OP_SH_VECALIGN 21
145 #define OP_MASK_INSMSB 0x1f /* "ins" MSB. */
146 #define OP_SH_INSMSB 11
147 #define OP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */
148 #define OP_SH_EXTMSBD 11
150 #define OP_OP_COP0 0x10
151 #define OP_OP_COP1 0x11
152 #define OP_OP_COP2 0x12
153 #define OP_OP_COP3 0x13
154 #define OP_OP_LWC1 0x31
155 #define OP_OP_LWC2 0x32
156 #define OP_OP_LWC3 0x33 /* a.k.a. pref */
157 #define OP_OP_LDC1 0x35
158 #define OP_OP_LDC2 0x36
159 #define OP_OP_LDC3 0x37 /* a.k.a. ld */
160 #define OP_OP_SWC1 0x39
161 #define OP_OP_SWC2 0x3a
162 #define OP_OP_SWC3 0x3b
163 #define OP_OP_SDC1 0x3d
164 #define OP_OP_SDC2 0x3e
165 #define OP_OP_SDC3 0x3f /* a.k.a. sd */
167 /* Values in the 'VSEL' field. */
168 #define MDMX_FMTSEL_IMM_QH 0x1d
169 #define MDMX_FMTSEL_IMM_OB 0x1e
170 #define MDMX_FMTSEL_VEC_QH 0x15
171 #define MDMX_FMTSEL_VEC_OB 0x16
173 /* This structure holds information for a particular instruction. */
177 /* The name of the instruction. */
179 /* A string describing the arguments for this instruction. */
181 /* The basic opcode for the instruction. When assembling, this
182 opcode is modified by the arguments to produce the actual opcode
183 that is used. If pinfo is INSN_MACRO, then this is 0. */
185 /* If pinfo is not INSN_MACRO, then this is a bit mask for the
186 relevant portions of the opcode when disassembling. If the
187 actual opcode anded with the match field equals the opcode field,
188 then we have found the correct instruction. If pinfo is
189 INSN_MACRO, then this field is the macro identifier. */
191 /* For a macro, this is INSN_MACRO. Otherwise, it is a collection
192 of bits describing the instruction, notably any relevant hazard
195 /* A collection of additional bits describing the instruction. */
196 unsigned long pinfo2
;
197 /* A collection of bits describing the instruction sets of which this
198 instruction or macro is a member. */
199 unsigned long membership
;
202 /* These are the characters which may appear in the args field of an
203 instruction. They appear in the order in which the fields appear
204 when the instruction is used. Commas and parentheses in the args
205 string are ignored when assembling, and written into the output
208 Each of these characters corresponds to a mask field defined above.
210 "<" 5 bit shift amount (OP_*_SHAMT)
211 ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
212 "a" 26 bit target address (OP_*_TARGET)
213 "b" 5 bit base register (OP_*_RS)
214 "c" 10 bit breakpoint code (OP_*_CODE)
215 "d" 5 bit destination register specifier (OP_*_RD)
216 "h" 5 bit prefx hint (OP_*_PREFX)
217 "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
218 "j" 16 bit signed immediate (OP_*_DELTA)
219 "k" 5 bit cache opcode in target register position (OP_*_CACHE)
220 Also used for immediate operands in vr5400 vector insns.
221 "o" 16 bit signed offset (OP_*_DELTA)
222 "p" 16 bit PC relative branch target address (OP_*_DELTA)
223 "q" 10 bit extra breakpoint code (OP_*_CODE2)
224 "r" 5 bit same register used as both source and target (OP_*_RS)
225 "s" 5 bit source register specifier (OP_*_RS)
226 "t" 5 bit target register (OP_*_RT)
227 "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
228 "v" 5 bit same register used as both source and destination (OP_*_RS)
229 "w" 5 bit same register used as both target and destination (OP_*_RT)
230 "U" 5 bit same destination register in both OP_*_RD and OP_*_RT
231 (used by clo and clz)
232 "C" 25 bit coprocessor function code (OP_*_COPZ)
233 "B" 20 bit syscall/breakpoint function code (OP_*_CODE20)
234 "J" 19 bit wait function code (OP_*_CODE19)
235 "x" accept and ignore register name
236 "z" must be zero register
237 "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD)
238 "+A" 5 bit ins/ext position, which becomes LSB (OP_*_SHAMT).
239 Enforces: 0 <= pos < 32.
240 "+B" 5 bit ins size, which becomes MSB (OP_*_INSMSB).
241 Requires that "+A" or "+E" occur first to set position.
242 Enforces: 0 < (pos+size) <= 32.
243 "+C" 5 bit ext size, which becomes MSBD (OP_*_EXTMSBD).
244 Requires that "+A" or "+E" occur first to set position.
245 Enforces: 0 < (pos+size) <= 32.
246 (Also used by "dext" w/ different limits, but limits for
247 that are checked by the M_DEXT macro.)
248 "+E" 5 bit dins/dext position, which becomes LSB-32 (OP_*_SHAMT).
249 Enforces: 32 <= pos < 64.
250 "+F" 5 bit "dinsm" size, which becomes MSB-32 (OP_*_INSMSB).
251 Requires that "+A" or "+E" occur first to set position.
252 Enforces: 32 < (pos+size) <= 64.
253 "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD).
254 Requires that "+A" or "+E" occur first to set position.
255 Enforces: 32 < (pos+size) <= 64.
256 "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD).
257 Requires that "+A" or "+E" occur first to set position.
258 Enforces: 32 < (pos+size) <= 64.
260 Floating point instructions:
261 "D" 5 bit destination register (OP_*_FD)
262 "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
263 "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
264 "S" 5 bit fs source 1 register (OP_*_FS)
265 "T" 5 bit ft source 2 register (OP_*_FT)
266 "R" 5 bit fr source 3 register (OP_*_FR)
267 "V" 5 bit same register used as floating source and destination (OP_*_FS)
268 "W" 5 bit same register used as floating target and destination (OP_*_FT)
270 Coprocessor instructions:
271 "E" 5 bit target register (OP_*_RT)
272 "G" 5 bit destination register (OP_*_RD)
273 "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL)
274 "P" 5 bit performance-monitor register (OP_*_PERFREG)
275 "e" 5 bit vector register byte specifier (OP_*_VECBYTE)
276 "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN)
278 "+D" Combined destination register ("G") and sel ("H") for CP0 ops,
279 for pretty-printing in disassembly only.
282 "A" General 32 bit expression
283 "I" 32 bit immediate (value placed in imm_expr).
284 "+I" 32 bit immediate (value placed in imm2_expr).
285 "F" 64 bit floating point constant in .rdata
286 "L" 64 bit floating point constant in .lit8
287 "f" 32 bit floating point constant
288 "l" 32 bit floating point constant in .lit4
290 MDMX instruction operands (note that while these use the FP register
291 fields, they accept both $fN and $vN names for the registers):
292 "O" MDMX alignment offset (OP_*_ALN)
293 "Q" MDMX vector/scalar/immediate source (OP_*_VSEL and OP_*_FT)
294 "X" MDMX destination register (OP_*_FD)
295 "Y" MDMX source register (OP_*_FS)
296 "Z" MDMX source register (OP_*_FT)
299 "()" parens surrounding optional value
300 "," separates operands
301 "[]" brackets around index for vector-op scalar operand specifier (vr5400)
302 "+" Start of extension sequence.
304 Characters used so far, for quick reference when adding more:
306 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
307 "abcdefhijklopqrstuvwxz"
309 Extension character sequences used so far ("+" followed by the
310 following), for quick reference when adding more:
314 /* These are the bits which may be set in the pinfo field of an
315 instructions, if it is not equal to INSN_MACRO. */
317 /* Modifies the general purpose register in OP_*_RD. */
318 #define INSN_WRITE_GPR_D 0x00000001
319 /* Modifies the general purpose register in OP_*_RT. */
320 #define INSN_WRITE_GPR_T 0x00000002
321 /* Modifies general purpose register 31. */
322 #define INSN_WRITE_GPR_31 0x00000004
323 /* Modifies the floating point register in OP_*_FD. */
324 #define INSN_WRITE_FPR_D 0x00000008
325 /* Modifies the floating point register in OP_*_FS. */
326 #define INSN_WRITE_FPR_S 0x00000010
327 /* Modifies the floating point register in OP_*_FT. */
328 #define INSN_WRITE_FPR_T 0x00000020
329 /* Reads the general purpose register in OP_*_RS. */
330 #define INSN_READ_GPR_S 0x00000040
331 /* Reads the general purpose register in OP_*_RT. */
332 #define INSN_READ_GPR_T 0x00000080
333 /* Reads the floating point register in OP_*_FS. */
334 #define INSN_READ_FPR_S 0x00000100
335 /* Reads the floating point register in OP_*_FT. */
336 #define INSN_READ_FPR_T 0x00000200
337 /* Reads the floating point register in OP_*_FR. */
338 #define INSN_READ_FPR_R 0x00000400
339 /* Modifies coprocessor condition code. */
340 #define INSN_WRITE_COND_CODE 0x00000800
341 /* Reads coprocessor condition code. */
342 #define INSN_READ_COND_CODE 0x00001000
344 #define INSN_TLB 0x00002000
345 /* Reads coprocessor register other than floating point register. */
346 #define INSN_COP 0x00004000
347 /* Instruction loads value from memory, requiring delay. */
348 #define INSN_LOAD_MEMORY_DELAY 0x00008000
349 /* Instruction loads value from coprocessor, requiring delay. */
350 #define INSN_LOAD_COPROC_DELAY 0x00010000
351 /* Instruction has unconditional branch delay slot. */
352 #define INSN_UNCOND_BRANCH_DELAY 0x00020000
353 /* Instruction has conditional branch delay slot. */
354 #define INSN_COND_BRANCH_DELAY 0x00040000
355 /* Conditional branch likely: if branch not taken, insn nullified. */
356 #define INSN_COND_BRANCH_LIKELY 0x00080000
357 /* Moves to coprocessor register, requiring delay. */
358 #define INSN_COPROC_MOVE_DELAY 0x00100000
359 /* Loads coprocessor register from memory, requiring delay. */
360 #define INSN_COPROC_MEMORY_DELAY 0x00200000
361 /* Reads the HI register. */
362 #define INSN_READ_HI 0x00400000
363 /* Reads the LO register. */
364 #define INSN_READ_LO 0x00800000
365 /* Modifies the HI register. */
366 #define INSN_WRITE_HI 0x01000000
367 /* Modifies the LO register. */
368 #define INSN_WRITE_LO 0x02000000
369 /* Takes a trap (easier to keep out of delay slot). */
370 #define INSN_TRAP 0x04000000
371 /* Instruction stores value into memory. */
372 #define INSN_STORE_MEMORY 0x08000000
373 /* Instruction uses single precision floating point. */
374 #define FP_S 0x10000000
375 /* Instruction uses double precision floating point. */
376 #define FP_D 0x20000000
377 /* Instruction is part of the tx39's integer multiply family. */
378 #define INSN_MULT 0x40000000
379 /* Instruction synchronize shared memory. */
380 #define INSN_SYNC 0x80000000
382 /* These are the bits which may be set in the pinfo2 field of an
385 /* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */
386 #define INSN2_ALIAS 0x00000001
387 /* Instruction reads MDMX accumulator. */
388 #define INSN2_READ_MDMX_ACC 0x00000002
389 /* Instruction writes MDMX accumulator. */
390 #define INSN2_WRITE_MDMX_ACC 0x00000004
392 /* Instruction is actually a macro. It should be ignored by the
393 disassembler, and requires special treatment by the assembler. */
394 #define INSN_MACRO 0xffffffff
396 /* Masks used to mark instructions to indicate which MIPS ISA level
397 they were introduced in. ISAs, as defined below, are logical
398 ORs of these bits, indicating that they support the instructions
399 defined at the given level. */
401 #define INSN_ISA_MASK 0x00000fff
402 #define INSN_ISA1 0x00000001
403 #define INSN_ISA2 0x00000002
404 #define INSN_ISA3 0x00000004
405 #define INSN_ISA4 0x00000008
406 #define INSN_ISA5 0x00000010
407 #define INSN_ISA32 0x00000020
408 #define INSN_ISA64 0x00000040
409 #define INSN_ISA32R2 0x00000080
410 #define INSN_ISA64R2 0x00000100
412 /* Masks used for MIPS-defined ASEs. */
413 #define INSN_ASE_MASK 0x0000f000
416 #define INSN_MIPS16 0x00002000
418 #define INSN_MIPS3D 0x00004000
420 #define INSN_MDMX 0x00008000
422 /* Chip specific instructions. These are bitmasks. */
424 /* MIPS R4650 instruction. */
425 #define INSN_4650 0x00010000
426 /* LSI R4010 instruction. */
427 #define INSN_4010 0x00020000
428 /* NEC VR4100 instruction. */
429 #define INSN_4100 0x00040000
430 /* Toshiba R3900 instruction. */
431 #define INSN_3900 0x00080000
432 /* MIPS R10000 instruction. */
433 #define INSN_10000 0x00100000
434 /* Broadcom SB-1 instruction. */
435 #define INSN_SB1 0x00200000
436 /* NEC VR4111/VR4181 instruction. */
437 #define INSN_4111 0x00400000
438 /* NEC VR4120 instruction. */
439 #define INSN_4120 0x00800000
440 /* NEC VR5400 instruction. */
441 #define INSN_5400 0x01000000
442 /* NEC VR5500 instruction. */
443 #define INSN_5500 0x02000000
445 /* MIPS ISA defines, use instead of hardcoding ISA level. */
447 #define ISA_UNKNOWN 0 /* Gas internal use. */
448 #define ISA_MIPS1 (INSN_ISA1)
449 #define ISA_MIPS2 (ISA_MIPS1 | INSN_ISA2)
450 #define ISA_MIPS3 (ISA_MIPS2 | INSN_ISA3)
451 #define ISA_MIPS4 (ISA_MIPS3 | INSN_ISA4)
452 #define ISA_MIPS5 (ISA_MIPS4 | INSN_ISA5)
454 #define ISA_MIPS32 (ISA_MIPS2 | INSN_ISA32)
455 #define ISA_MIPS64 (ISA_MIPS5 | INSN_ISA32 | INSN_ISA64)
457 #define ISA_MIPS32R2 (ISA_MIPS32 | INSN_ISA32R2)
458 #define ISA_MIPS64R2 (ISA_MIPS64 | INSN_ISA32R2 | INSN_ISA64R2)
461 /* CPU defines, use instead of hardcoding processor number. Keep this
462 in sync with bfd/archures.c in order for machine selection to work. */
463 #define CPU_UNKNOWN 0 /* Gas internal use. */
464 #define CPU_R3000 3000
465 #define CPU_R3900 3900
466 #define CPU_R4000 4000
467 #define CPU_R4010 4010
468 #define CPU_VR4100 4100
469 #define CPU_R4111 4111
470 #define CPU_VR4120 4120
471 #define CPU_R4300 4300
472 #define CPU_R4400 4400
473 #define CPU_R4600 4600
474 #define CPU_R4650 4650
475 #define CPU_R5000 5000
476 #define CPU_VR5400 5400
477 #define CPU_VR5500 5500
478 #define CPU_R6000 6000
479 #define CPU_RM7000 7000
480 #define CPU_R8000 8000
481 #define CPU_RM9000 9000
482 #define CPU_R10000 10000
483 #define CPU_R12000 12000
484 #define CPU_MIPS16 16
485 #define CPU_MIPS32 32
486 #define CPU_MIPS32R2 33
488 #define CPU_MIPS64 64
489 #define CPU_MIPS64R2 65
490 #define CPU_SB1 12310201 /* octal 'SB', 01. */
492 /* Test for membership in an ISA including chip specific ISAs. INSN
493 is pointer to an element of the opcode table; ISA is the specified
494 ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
495 test, or zero if no CPU specific ISA test is desired. */
497 #define OPCODE_IS_MEMBER(insn, isa, cpu) \
498 (((insn)->membership & isa) != 0 \
499 || (cpu == CPU_R4650 && ((insn)->membership & INSN_4650) != 0) \
500 || (cpu == CPU_RM7000 && ((insn)->membership & INSN_4650) != 0) \
501 || (cpu == CPU_RM9000 && ((insn)->membership & INSN_4650) != 0) \
502 || (cpu == CPU_R4010 && ((insn)->membership & INSN_4010) != 0) \
503 || (cpu == CPU_VR4100 && ((insn)->membership & INSN_4100) != 0) \
504 || (cpu == CPU_R3900 && ((insn)->membership & INSN_3900) != 0) \
505 || ((cpu == CPU_R10000 || cpu == CPU_R12000) \
506 && ((insn)->membership & INSN_10000) != 0) \
507 || (cpu == CPU_SB1 && ((insn)->membership & INSN_SB1) != 0) \
508 || (cpu == CPU_R4111 && ((insn)->membership & INSN_4111) != 0) \
509 || (cpu == CPU_VR4120 && ((insn)->membership & INSN_4120) != 0) \
510 || (cpu == CPU_VR5400 && ((insn)->membership & INSN_5400) != 0) \
511 || (cpu == CPU_VR5500 && ((insn)->membership & INSN_5500) != 0) \
512 || 0) /* Please keep this term for easier source merging. */
514 /* This is a list of macro expanded instructions.
516 _I appended means immediate
517 _A appended means address
518 _AB appended means address with base register
519 _D appended means 64 bit floating point constant
520 _S appended means 32 bit floating point constant. */
747 /* The order of overloaded instructions matters. Label arguments and
748 register arguments look the same. Instructions that can have either
749 for arguments must apear in the correct order in this table for the
750 assembler to pick the right one. In other words, entries with
751 immediate operands must apear after the same instruction with
754 Many instructions are short hand for other instructions (i.e., The
755 jal <register> instruction is short for jalr <register>). */
757 extern const struct mips_opcode mips_builtin_opcodes
[];
758 extern const int bfd_mips_num_builtin_opcodes
;
759 extern struct mips_opcode
*mips_opcodes
;
760 extern int bfd_mips_num_opcodes
;
761 #define NUMOPCODES bfd_mips_num_opcodes
764 /* The rest of this file adds definitions for the mips16 TinyRISC
767 /* These are the bitmasks and shift counts used for the different
768 fields in the instruction formats. Other than OP, no masks are
769 provided for the fixed portions of an instruction, since they are
772 The I format uses IMM11.
774 The RI format uses RX and IMM8.
776 The RR format uses RX, and RY.
778 The RRI format uses RX, RY, and IMM5.
780 The RRR format uses RX, RY, and RZ.
782 The RRI_A format uses RX, RY, and IMM4.
784 The SHIFT format uses RX, RY, and SHAMT.
786 The I8 format uses IMM8.
788 The I8_MOVR32 format uses RY and REGR32.
790 The IR_MOV32R format uses REG32R and MOV32Z.
792 The I64 format uses IMM8.
794 The RI64 format uses RY and IMM5.
797 #define MIPS16OP_MASK_OP 0x1f
798 #define MIPS16OP_SH_OP 11
799 #define MIPS16OP_MASK_IMM11 0x7ff
800 #define MIPS16OP_SH_IMM11 0
801 #define MIPS16OP_MASK_RX 0x7
802 #define MIPS16OP_SH_RX 8
803 #define MIPS16OP_MASK_IMM8 0xff
804 #define MIPS16OP_SH_IMM8 0
805 #define MIPS16OP_MASK_RY 0x7
806 #define MIPS16OP_SH_RY 5
807 #define MIPS16OP_MASK_IMM5 0x1f
808 #define MIPS16OP_SH_IMM5 0
809 #define MIPS16OP_MASK_RZ 0x7
810 #define MIPS16OP_SH_RZ 2
811 #define MIPS16OP_MASK_IMM4 0xf
812 #define MIPS16OP_SH_IMM4 0
813 #define MIPS16OP_MASK_REGR32 0x1f
814 #define MIPS16OP_SH_REGR32 0
815 #define MIPS16OP_MASK_REG32R 0x1f
816 #define MIPS16OP_SH_REG32R 3
817 #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
818 #define MIPS16OP_MASK_MOVE32Z 0x7
819 #define MIPS16OP_SH_MOVE32Z 0
820 #define MIPS16OP_MASK_IMM6 0x3f
821 #define MIPS16OP_SH_IMM6 5
823 /* These are the characters which may appears in the args field of an
824 instruction. They appear in the order in which the fields appear
825 when the instruction is used. Commas and parentheses in the args
826 string are ignored when assembling, and written into the output
829 "y" 3 bit register (MIPS16OP_*_RY)
830 "x" 3 bit register (MIPS16OP_*_RX)
831 "z" 3 bit register (MIPS16OP_*_RZ)
832 "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
833 "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
834 "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
835 "0" zero register ($0)
836 "S" stack pointer ($sp or $29)
838 "R" return address register ($ra or $31)
839 "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
840 "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
841 "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
842 "a" 26 bit jump address
843 "e" 11 bit extension value
844 "l" register list for entry instruction
845 "L" register list for exit instruction
847 The remaining codes may be extended. Except as otherwise noted,
848 the full extended operand is a 16 bit signed value.
849 "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
850 ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned)
851 "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
852 "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
853 "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
854 "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
855 "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
856 "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
857 "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
858 "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
859 "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
860 "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
861 "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
862 "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
863 "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
864 "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
865 "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
866 "q" 11 bit branch address (MIPS16OP_*_IMM11)
867 "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
868 "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
869 "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
872 /* For the mips16, we use the same opcode table format and a few of
873 the same flags. However, most of the flags are different. */
875 /* Modifies the register in MIPS16OP_*_RX. */
876 #define MIPS16_INSN_WRITE_X 0x00000001
877 /* Modifies the register in MIPS16OP_*_RY. */
878 #define MIPS16_INSN_WRITE_Y 0x00000002
879 /* Modifies the register in MIPS16OP_*_RZ. */
880 #define MIPS16_INSN_WRITE_Z 0x00000004
881 /* Modifies the T ($24) register. */
882 #define MIPS16_INSN_WRITE_T 0x00000008
883 /* Modifies the SP ($29) register. */
884 #define MIPS16_INSN_WRITE_SP 0x00000010
885 /* Modifies the RA ($31) register. */
886 #define MIPS16_INSN_WRITE_31 0x00000020
887 /* Modifies the general purpose register in MIPS16OP_*_REG32R. */
888 #define MIPS16_INSN_WRITE_GPR_Y 0x00000040
889 /* Reads the register in MIPS16OP_*_RX. */
890 #define MIPS16_INSN_READ_X 0x00000080
891 /* Reads the register in MIPS16OP_*_RY. */
892 #define MIPS16_INSN_READ_Y 0x00000100
893 /* Reads the register in MIPS16OP_*_MOVE32Z. */
894 #define MIPS16_INSN_READ_Z 0x00000200
895 /* Reads the T ($24) register. */
896 #define MIPS16_INSN_READ_T 0x00000400
897 /* Reads the SP ($29) register. */
898 #define MIPS16_INSN_READ_SP 0x00000800
899 /* Reads the RA ($31) register. */
900 #define MIPS16_INSN_READ_31 0x00001000
901 /* Reads the program counter. */
902 #define MIPS16_INSN_READ_PC 0x00002000
903 /* Reads the general purpose register in MIPS16OP_*_REGR32. */
904 #define MIPS16_INSN_READ_GPR_X 0x00004000
905 /* Is a branch insn. */
906 #define MIPS16_INSN_BRANCH 0x00010000
908 /* The following flags have the same value for the mips16 opcode
910 INSN_UNCOND_BRANCH_DELAY
911 INSN_COND_BRANCH_DELAY
912 INSN_COND_BRANCH_LIKELY (never used)
921 extern const struct mips_opcode mips16_opcodes
[];
922 extern const int bfd_mips16_num_opcodes
;
924 #endif /* _MIPS_H_ */