opcode/
[deliverable/binutils-gdb.git] / include / opcode / mips.h
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
4 Free Software Foundation, Inc.
5 Contributed by Ralph Campbell and OSF
6 Commented and modified by Ian Lance Taylor, Cygnus Support
7
8 This file is part of GDB, GAS, and the GNU binutils.
9
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.
14
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.
19
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. */
24
25 #ifndef _MIPS_H_
26 #define _MIPS_H_
27
28 /* These are bit masks and shift counts to use to access the various
29 fields of an instruction. To retrieve the X field of an
30 instruction, use the expression
31 (i >> OP_SH_X) & OP_MASK_X
32 To set the same field (to j), use
33 i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X)
34
35 Make sure you use fields that are appropriate for the instruction,
36 of course.
37
38 The 'i' format uses OP, RS, RT and IMMEDIATE.
39
40 The 'j' format uses OP and TARGET.
41
42 The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT.
43
44 The 'b' format uses OP, RS, RT and DELTA.
45
46 The floating point 'i' format uses OP, RS, RT and IMMEDIATE.
47
48 The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT.
49
50 A breakpoint instruction uses OP, CODE and SPEC (10 bits of the
51 breakpoint instruction are not defined; Kane says the breakpoint
52 code field in BREAK is 20 bits; yet MIPS assemblers and debuggers
53 only use ten bits). An optional two-operand form of break/sdbbp
54 allows the lower ten bits to be set too, and MIPS32 and later
55 architectures allow 20 bits to be set with a signal operand
56 (using CODE20).
57
58 The syscall instruction uses CODE20.
59
60 The general coprocessor instructions use COPZ. */
61
62 #define OP_MASK_OP 0x3f
63 #define OP_SH_OP 26
64 #define OP_MASK_RS 0x1f
65 #define OP_SH_RS 21
66 #define OP_MASK_FR 0x1f
67 #define OP_SH_FR 21
68 #define OP_MASK_FMT 0x1f
69 #define OP_SH_FMT 21
70 #define OP_MASK_BCC 0x7
71 #define OP_SH_BCC 18
72 #define OP_MASK_CODE 0x3ff
73 #define OP_SH_CODE 16
74 #define OP_MASK_CODE2 0x3ff
75 #define OP_SH_CODE2 6
76 #define OP_MASK_RT 0x1f
77 #define OP_SH_RT 16
78 #define OP_MASK_FT 0x1f
79 #define OP_SH_FT 16
80 #define OP_MASK_CACHE 0x1f
81 #define OP_SH_CACHE 16
82 #define OP_MASK_RD 0x1f
83 #define OP_SH_RD 11
84 #define OP_MASK_FS 0x1f
85 #define OP_SH_FS 11
86 #define OP_MASK_PREFX 0x1f
87 #define OP_SH_PREFX 11
88 #define OP_MASK_CCC 0x7
89 #define OP_SH_CCC 8
90 #define OP_MASK_CODE20 0xfffff /* 20 bit syscall/breakpoint code. */
91 #define OP_SH_CODE20 6
92 #define OP_MASK_SHAMT 0x1f
93 #define OP_SH_SHAMT 6
94 #define OP_MASK_EXTLSB OP_MASK_SHAMT
95 #define OP_SH_EXTLSB OP_SH_SHAMT
96 #define OP_MASK_STYPE OP_MASK_SHAMT
97 #define OP_SH_STYPE OP_SH_SHAMT
98 #define OP_MASK_FD 0x1f
99 #define OP_SH_FD 6
100 #define OP_MASK_TARGET 0x3ffffff
101 #define OP_SH_TARGET 0
102 #define OP_MASK_COPZ 0x1ffffff
103 #define OP_SH_COPZ 0
104 #define OP_MASK_IMMEDIATE 0xffff
105 #define OP_SH_IMMEDIATE 0
106 #define OP_MASK_DELTA 0xffff
107 #define OP_SH_DELTA 0
108 #define OP_MASK_FUNCT 0x3f
109 #define OP_SH_FUNCT 0
110 #define OP_MASK_SPEC 0x3f
111 #define OP_SH_SPEC 0
112 #define OP_SH_LOCC 8 /* FP condition code. */
113 #define OP_SH_HICC 18 /* FP condition code. */
114 #define OP_MASK_CC 0x7
115 #define OP_SH_COP1NORM 25 /* Normal COP1 encoding. */
116 #define OP_MASK_COP1NORM 0x1 /* a single bit. */
117 #define OP_SH_COP1SPEC 21 /* COP1 encodings. */
118 #define OP_MASK_COP1SPEC 0xf
119 #define OP_MASK_COP1SCLR 0x4
120 #define OP_MASK_COP1CMP 0x3
121 #define OP_SH_COP1CMP 4
122 #define OP_SH_FORMAT 21 /* FP short format field. */
123 #define OP_MASK_FORMAT 0x7
124 #define OP_SH_TRUE 16
125 #define OP_MASK_TRUE 0x1
126 #define OP_SH_GE 17
127 #define OP_MASK_GE 0x01
128 #define OP_SH_UNSIGNED 16
129 #define OP_MASK_UNSIGNED 0x1
130 #define OP_SH_HINT 16
131 #define OP_MASK_HINT 0x1f
132 #define OP_SH_MMI 0 /* Multimedia (parallel) op. */
133 #define OP_MASK_MMI 0x3f
134 #define OP_SH_MMISUB 6
135 #define OP_MASK_MMISUB 0x1f
136 #define OP_MASK_PERFREG 0x1f /* Performance monitoring. */
137 #define OP_SH_PERFREG 1
138 #define OP_SH_SEL 0 /* Coprocessor select field. */
139 #define OP_MASK_SEL 0x7 /* The sel field of mfcZ and mtcZ. */
140 #define OP_SH_CODE19 6 /* 19 bit wait code. */
141 #define OP_MASK_CODE19 0x7ffff
142 #define OP_SH_ALN 21
143 #define OP_MASK_ALN 0x7
144 #define OP_SH_VSEL 21
145 #define OP_MASK_VSEL 0x1f
146 #define OP_MASK_VECBYTE 0x7 /* Selector field is really 4 bits,
147 but 0x8-0xf don't select bytes. */
148 #define OP_SH_VECBYTE 22
149 #define OP_MASK_VECALIGN 0x7 /* Vector byte-align (alni.ob) op. */
150 #define OP_SH_VECALIGN 21
151 #define OP_MASK_INSMSB 0x1f /* "ins" MSB. */
152 #define OP_SH_INSMSB 11
153 #define OP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */
154 #define OP_SH_EXTMSBD 11
155
156 /* MIPS DSP ASE */
157 #define OP_SH_DSPACC 11
158 #define OP_MASK_DSPACC 0x3
159 #define OP_SH_DSPACC_S 21
160 #define OP_MASK_DSPACC_S 0x3
161 #define OP_SH_DSPSFT 20
162 #define OP_MASK_DSPSFT 0x3f
163 #define OP_SH_DSPSFT_7 19
164 #define OP_MASK_DSPSFT_7 0x7f
165 #define OP_SH_SA3 21
166 #define OP_MASK_SA3 0x7
167 #define OP_SH_SA4 21
168 #define OP_MASK_SA4 0xf
169 #define OP_SH_IMM8 16
170 #define OP_MASK_IMM8 0xff
171 #define OP_SH_IMM10 16
172 #define OP_MASK_IMM10 0x3ff
173 #define OP_SH_WRDSP 11
174 #define OP_MASK_WRDSP 0x3f
175 #define OP_SH_RDDSP 16
176 #define OP_MASK_RDDSP 0x3f
177 #define OP_SH_BP 11
178 #define OP_MASK_BP 0x3
179
180 /* MIPS MT ASE */
181 #define OP_SH_MT_U 5
182 #define OP_MASK_MT_U 0x1
183 #define OP_SH_MT_H 4
184 #define OP_MASK_MT_H 0x1
185 #define OP_SH_MTACC_T 18
186 #define OP_MASK_MTACC_T 0x3
187 #define OP_SH_MTACC_D 13
188 #define OP_MASK_MTACC_D 0x3
189
190 /* MIPS MCU ASE */
191 #define OP_MASK_3BITPOS 0x7
192 #define OP_SH_3BITPOS 12
193 #define OP_MASK_OFFSET12 0xfff
194 #define OP_SH_OFFSET12 0
195
196 #define OP_OP_COP0 0x10
197 #define OP_OP_COP1 0x11
198 #define OP_OP_COP2 0x12
199 #define OP_OP_COP3 0x13
200 #define OP_OP_LWC1 0x31
201 #define OP_OP_LWC2 0x32
202 #define OP_OP_LWC3 0x33 /* a.k.a. pref */
203 #define OP_OP_LDC1 0x35
204 #define OP_OP_LDC2 0x36
205 #define OP_OP_LDC3 0x37 /* a.k.a. ld */
206 #define OP_OP_SWC1 0x39
207 #define OP_OP_SWC2 0x3a
208 #define OP_OP_SWC3 0x3b
209 #define OP_OP_SDC1 0x3d
210 #define OP_OP_SDC2 0x3e
211 #define OP_OP_SDC3 0x3f /* a.k.a. sd */
212
213 /* Values in the 'VSEL' field. */
214 #define MDMX_FMTSEL_IMM_QH 0x1d
215 #define MDMX_FMTSEL_IMM_OB 0x1e
216 #define MDMX_FMTSEL_VEC_QH 0x15
217 #define MDMX_FMTSEL_VEC_OB 0x16
218
219 /* UDI */
220 #define OP_SH_UDI1 6
221 #define OP_MASK_UDI1 0x1f
222 #define OP_SH_UDI2 6
223 #define OP_MASK_UDI2 0x3ff
224 #define OP_SH_UDI3 6
225 #define OP_MASK_UDI3 0x7fff
226 #define OP_SH_UDI4 6
227 #define OP_MASK_UDI4 0xfffff
228
229 /* Octeon */
230 #define OP_SH_BBITIND 16
231 #define OP_MASK_BBITIND 0x1f
232 #define OP_SH_CINSPOS 6
233 #define OP_MASK_CINSPOS 0x1f
234 #define OP_SH_CINSLM1 11
235 #define OP_MASK_CINSLM1 0x1f
236 #define OP_SH_SEQI 6
237 #define OP_MASK_SEQI 0x3ff
238
239 /* Loongson */
240 #define OP_SH_OFFSET_A 6
241 #define OP_MASK_OFFSET_A 0xff
242 #define OP_SH_OFFSET_B 3
243 #define OP_MASK_OFFSET_B 0xff
244 #define OP_SH_OFFSET_C 6
245 #define OP_MASK_OFFSET_C 0x1ff
246 #define OP_SH_RZ 0
247 #define OP_MASK_RZ 0x1f
248 #define OP_SH_FZ 0
249 #define OP_MASK_FZ 0x1f
250
251 /* Every MICROMIPSOP_X definition requires a corresponding OP_X
252 definition, and vice versa. This simplifies various parts
253 of the operand handling in GAS. The fields below only exist
254 in the microMIPS encoding, so define each one to have an empty
255 range. */
256 #define OP_MASK_CODE10 0
257 #define OP_SH_CODE10 0
258 #define OP_MASK_TRAP 0
259 #define OP_SH_TRAP 0
260 #define OP_MASK_OFFSET10 0
261 #define OP_SH_OFFSET10 0
262 #define OP_MASK_RS3 0
263 #define OP_SH_RS3 0
264 #define OP_MASK_MB 0
265 #define OP_SH_MB 0
266 #define OP_MASK_MC 0
267 #define OP_SH_MC 0
268 #define OP_MASK_MD 0
269 #define OP_SH_MD 0
270 #define OP_MASK_ME 0
271 #define OP_SH_ME 0
272 #define OP_MASK_MF 0
273 #define OP_SH_MF 0
274 #define OP_MASK_MG 0
275 #define OP_SH_MG 0
276 #define OP_MASK_MH 0
277 #define OP_SH_MH 0
278 #define OP_MASK_MI 0
279 #define OP_SH_MI 0
280 #define OP_MASK_MJ 0
281 #define OP_SH_MJ 0
282 #define OP_MASK_ML 0
283 #define OP_SH_ML 0
284 #define OP_MASK_MM 0
285 #define OP_SH_MM 0
286 #define OP_MASK_MN 0
287 #define OP_SH_MN 0
288 #define OP_MASK_MP 0
289 #define OP_SH_MP 0
290 #define OP_MASK_MQ 0
291 #define OP_SH_MQ 0
292 #define OP_MASK_IMMA 0
293 #define OP_SH_IMMA 0
294 #define OP_MASK_IMMB 0
295 #define OP_SH_IMMB 0
296 #define OP_MASK_IMMC 0
297 #define OP_SH_IMMC 0
298 #define OP_MASK_IMMF 0
299 #define OP_SH_IMMF 0
300 #define OP_MASK_IMMG 0
301 #define OP_SH_IMMG 0
302 #define OP_MASK_IMMH 0
303 #define OP_SH_IMMH 0
304 #define OP_MASK_IMMI 0
305 #define OP_SH_IMMI 0
306 #define OP_MASK_IMMJ 0
307 #define OP_SH_IMMJ 0
308 #define OP_MASK_IMML 0
309 #define OP_SH_IMML 0
310 #define OP_MASK_IMMM 0
311 #define OP_SH_IMMM 0
312 #define OP_MASK_IMMN 0
313 #define OP_SH_IMMN 0
314 #define OP_MASK_IMMO 0
315 #define OP_SH_IMMO 0
316 #define OP_MASK_IMMP 0
317 #define OP_SH_IMMP 0
318 #define OP_MASK_IMMQ 0
319 #define OP_SH_IMMQ 0
320 #define OP_MASK_IMMU 0
321 #define OP_SH_IMMU 0
322 #define OP_MASK_IMMW 0
323 #define OP_SH_IMMW 0
324 #define OP_MASK_IMMX 0
325 #define OP_SH_IMMX 0
326 #define OP_MASK_IMMY 0
327 #define OP_SH_IMMY 0
328
329 /* This structure holds information for a particular instruction. */
330
331 struct mips_opcode
332 {
333 /* The name of the instruction. */
334 const char *name;
335 /* A string describing the arguments for this instruction. */
336 const char *args;
337 /* The basic opcode for the instruction. When assembling, this
338 opcode is modified by the arguments to produce the actual opcode
339 that is used. If pinfo is INSN_MACRO, then this is 0. */
340 unsigned long match;
341 /* If pinfo is not INSN_MACRO, then this is a bit mask for the
342 relevant portions of the opcode when disassembling. If the
343 actual opcode anded with the match field equals the opcode field,
344 then we have found the correct instruction. If pinfo is
345 INSN_MACRO, then this field is the macro identifier. */
346 unsigned long mask;
347 /* For a macro, this is INSN_MACRO. Otherwise, it is a collection
348 of bits describing the instruction, notably any relevant hazard
349 information. */
350 unsigned long pinfo;
351 /* A collection of additional bits describing the instruction. */
352 unsigned long pinfo2;
353 /* A collection of bits describing the instruction sets of which this
354 instruction or macro is a member. */
355 unsigned long membership;
356 };
357
358 /* These are the characters which may appear in the args field of an
359 instruction. They appear in the order in which the fields appear
360 when the instruction is used. Commas and parentheses in the args
361 string are ignored when assembling, and written into the output
362 when disassembling.
363
364 Each of these characters corresponds to a mask field defined above.
365
366 "1" 5 bit sync type (OP_*_SHAMT)
367 "<" 5 bit shift amount (OP_*_SHAMT)
368 ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
369 "a" 26 bit target address (OP_*_TARGET)
370 "b" 5 bit base register (OP_*_RS)
371 "c" 10 bit breakpoint code (OP_*_CODE)
372 "d" 5 bit destination register specifier (OP_*_RD)
373 "h" 5 bit prefx hint (OP_*_PREFX)
374 "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
375 "j" 16 bit signed immediate (OP_*_DELTA)
376 "k" 5 bit cache opcode in target register position (OP_*_CACHE)
377 Also used for immediate operands in vr5400 vector insns.
378 "o" 16 bit signed offset (OP_*_DELTA)
379 "p" 16 bit PC relative branch target address (OP_*_DELTA)
380 "q" 10 bit extra breakpoint code (OP_*_CODE2)
381 "r" 5 bit same register used as both source and target (OP_*_RS)
382 "s" 5 bit source register specifier (OP_*_RS)
383 "t" 5 bit target register (OP_*_RT)
384 "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
385 "v" 5 bit same register used as both source and destination (OP_*_RS)
386 "w" 5 bit same register used as both target and destination (OP_*_RT)
387 "U" 5 bit same destination register in both OP_*_RD and OP_*_RT
388 (used by clo and clz)
389 "C" 25 bit coprocessor function code (OP_*_COPZ)
390 "B" 20 bit syscall/breakpoint function code (OP_*_CODE20)
391 "J" 19 bit wait function code (OP_*_CODE19)
392 "x" accept and ignore register name
393 "z" must be zero register
394 "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD)
395 "+A" 5 bit ins/ext/dins/dext/dinsm/dextm position, which becomes
396 LSB (OP_*_SHAMT; OP_*_EXTLSB or OP_*_STYPE may be used for
397 microMIPS compatibility).
398 Enforces: 0 <= pos < 32.
399 "+B" 5 bit ins/dins size, which becomes MSB (OP_*_INSMSB).
400 Requires that "+A" or "+E" occur first to set position.
401 Enforces: 0 < (pos+size) <= 32.
402 "+C" 5 bit ext/dext size, which becomes MSBD (OP_*_EXTMSBD).
403 Requires that "+A" or "+E" occur first to set position.
404 Enforces: 0 < (pos+size) <= 32.
405 (Also used by "dext" w/ different limits, but limits for
406 that are checked by the M_DEXT macro.)
407 "+E" 5 bit dinsu/dextu position, which becomes LSB-32 (OP_*_SHAMT).
408 Enforces: 32 <= pos < 64.
409 "+F" 5 bit "dinsm/dinsu" size, which becomes MSB-32 (OP_*_INSMSB).
410 Requires that "+A" or "+E" occur first to set position.
411 Enforces: 32 < (pos+size) <= 64.
412 "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD).
413 Requires that "+A" or "+E" occur first to set position.
414 Enforces: 32 < (pos+size) <= 64.
415 "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD).
416 Requires that "+A" or "+E" occur first to set position.
417 Enforces: 32 < (pos+size) <= 64.
418
419 Floating point instructions:
420 "D" 5 bit destination register (OP_*_FD)
421 "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
422 "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
423 "S" 5 bit fs source 1 register (OP_*_FS)
424 "T" 5 bit ft source 2 register (OP_*_FT)
425 "R" 5 bit fr source 3 register (OP_*_FR)
426 "V" 5 bit same register used as floating source and destination (OP_*_FS)
427 "W" 5 bit same register used as floating target and destination (OP_*_FT)
428
429 Coprocessor instructions:
430 "E" 5 bit target register (OP_*_RT)
431 "G" 5 bit destination register (OP_*_RD)
432 "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL)
433 "P" 5 bit performance-monitor register (OP_*_PERFREG)
434 "e" 5 bit vector register byte specifier (OP_*_VECBYTE)
435 "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN)
436 see also "k" above
437 "+D" Combined destination register ("G") and sel ("H") for CP0 ops,
438 for pretty-printing in disassembly only.
439
440 Macro instructions:
441 "A" General 32 bit expression
442 "I" 32 bit immediate (value placed in imm_expr).
443 "+I" 32 bit immediate (value placed in imm2_expr).
444 "F" 64 bit floating point constant in .rdata
445 "L" 64 bit floating point constant in .lit8
446 "f" 32 bit floating point constant
447 "l" 32 bit floating point constant in .lit4
448
449 MDMX instruction operands (note that while these use the FP register
450 fields, they accept both $fN and $vN names for the registers):
451 "O" MDMX alignment offset (OP_*_ALN)
452 "Q" MDMX vector/scalar/immediate source (OP_*_VSEL and OP_*_FT)
453 "X" MDMX destination register (OP_*_FD)
454 "Y" MDMX source register (OP_*_FS)
455 "Z" MDMX source register (OP_*_FT)
456
457 DSP ASE usage:
458 "2" 2 bit unsigned immediate for byte align (OP_*_BP)
459 "3" 3 bit unsigned immediate (OP_*_SA3)
460 "4" 4 bit unsigned immediate (OP_*_SA4)
461 "5" 8 bit unsigned immediate (OP_*_IMM8)
462 "6" 5 bit unsigned immediate (OP_*_RS)
463 "7" 2 bit dsp accumulator register (OP_*_DSPACC)
464 "8" 6 bit unsigned immediate (OP_*_WRDSP)
465 "9" 2 bit dsp accumulator register (OP_*_DSPACC_S)
466 "0" 6 bit signed immediate (OP_*_DSPSFT)
467 ":" 7 bit signed immediate (OP_*_DSPSFT_7)
468 "'" 6 bit unsigned immediate (OP_*_RDDSP)
469 "@" 10 bit signed immediate (OP_*_IMM10)
470
471 MT ASE usage:
472 "!" 1 bit usermode flag (OP_*_MT_U)
473 "$" 1 bit load high flag (OP_*_MT_H)
474 "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T)
475 "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D)
476 "g" 5 bit coprocessor 1 and 2 destination register (OP_*_RD)
477 "+t" 5 bit coprocessor 0 destination register (OP_*_RT)
478 "+T" 5 bit coprocessor 0 destination register (OP_*_RT) - disassembly only
479
480 MCU ASE usage:
481 "~" 12 bit offset (OP_*_OFFSET12)
482 "\" 3 bit position for aset and aclr (OP_*_3BITPOS)
483
484 UDI immediates:
485 "+1" UDI immediate bits 6-10
486 "+2" UDI immediate bits 6-15
487 "+3" UDI immediate bits 6-20
488 "+4" UDI immediate bits 6-25
489
490 Octeon:
491 "+x" Bit index field of bbit. Enforces: 0 <= index < 32.
492 "+X" Bit index field of bbit aliasing bbit32. Matches if 32 <= index < 64,
493 otherwise skips to next candidate.
494 "+p" Position field of cins/cins32/exts/exts32. Enforces 0 <= pos < 32.
495 "+P" Position field of cins/exts aliasing cins32/exts32. Matches if
496 32 <= pos < 64, otherwise skips to next candidate.
497 "+Q" Immediate field of seqi/snei. Enforces -512 <= imm < 512.
498 "+s" Length-minus-one field of cins/exts. Enforces: 0 <= lenm1 < 32.
499 "+S" Length-minus-one field of cins32/exts32 or cins/exts aliasing
500 cint32/exts32. Enforces non-negative value and that
501 pos + lenm1 < 32 or pos + lenm1 < 64 depending whether previous
502 position field is "+p" or "+P".
503
504 Loongson-3A:
505 "+a" 8-bit signed offset in bit 6 (OP_*_OFFSET_A)
506 "+b" 8-bit signed offset in bit 3 (OP_*_OFFSET_B)
507 "+c" 9-bit signed offset in bit 6 (OP_*_OFFSET_C)
508 "+z" 5-bit rz register (OP_*_RZ)
509 "+Z" 5-bit fz register (OP_*_FZ)
510
511 Other:
512 "()" parens surrounding optional value
513 "," separates operands
514 "[]" brackets around index for vector-op scalar operand specifier (vr5400)
515 "+" Start of extension sequence.
516
517 Characters used so far, for quick reference when adding more:
518 "1234567890"
519 "%[]<>(),+:'@!$*&\~"
520 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
521 "abcdefghijklopqrstuvwxz"
522
523 Extension character sequences used so far ("+" followed by the
524 following), for quick reference when adding more:
525 "1234"
526 "ABCDEFGHIPQSTXZ"
527 "abcpstxz"
528 */
529
530 /* These are the bits which may be set in the pinfo field of an
531 instructions, if it is not equal to INSN_MACRO. */
532
533 /* Modifies the general purpose register in OP_*_RD. */
534 #define INSN_WRITE_GPR_D 0x00000001
535 /* Modifies the general purpose register in OP_*_RT. */
536 #define INSN_WRITE_GPR_T 0x00000002
537 /* Modifies general purpose register 31. */
538 #define INSN_WRITE_GPR_31 0x00000004
539 /* Modifies the floating point register in OP_*_FD. */
540 #define INSN_WRITE_FPR_D 0x00000008
541 /* Modifies the floating point register in OP_*_FS. */
542 #define INSN_WRITE_FPR_S 0x00000010
543 /* Modifies the floating point register in OP_*_FT. */
544 #define INSN_WRITE_FPR_T 0x00000020
545 /* Reads the general purpose register in OP_*_RS. */
546 #define INSN_READ_GPR_S 0x00000040
547 /* Reads the general purpose register in OP_*_RT. */
548 #define INSN_READ_GPR_T 0x00000080
549 /* Reads the floating point register in OP_*_FS. */
550 #define INSN_READ_FPR_S 0x00000100
551 /* Reads the floating point register in OP_*_FT. */
552 #define INSN_READ_FPR_T 0x00000200
553 /* Reads the floating point register in OP_*_FR. */
554 #define INSN_READ_FPR_R 0x00000400
555 /* Modifies coprocessor condition code. */
556 #define INSN_WRITE_COND_CODE 0x00000800
557 /* Reads coprocessor condition code. */
558 #define INSN_READ_COND_CODE 0x00001000
559 /* TLB operation. */
560 #define INSN_TLB 0x00002000
561 /* Reads coprocessor register other than floating point register. */
562 #define INSN_COP 0x00004000
563 /* Instruction loads value from memory, requiring delay. */
564 #define INSN_LOAD_MEMORY_DELAY 0x00008000
565 /* Instruction loads value from coprocessor, requiring delay. */
566 #define INSN_LOAD_COPROC_DELAY 0x00010000
567 /* Instruction has unconditional branch delay slot. */
568 #define INSN_UNCOND_BRANCH_DELAY 0x00020000
569 /* Instruction has conditional branch delay slot. */
570 #define INSN_COND_BRANCH_DELAY 0x00040000
571 /* Conditional branch likely: if branch not taken, insn nullified. */
572 #define INSN_COND_BRANCH_LIKELY 0x00080000
573 /* Moves to coprocessor register, requiring delay. */
574 #define INSN_COPROC_MOVE_DELAY 0x00100000
575 /* Loads coprocessor register from memory, requiring delay. */
576 #define INSN_COPROC_MEMORY_DELAY 0x00200000
577 /* Reads the HI register. */
578 #define INSN_READ_HI 0x00400000
579 /* Reads the LO register. */
580 #define INSN_READ_LO 0x00800000
581 /* Modifies the HI register. */
582 #define INSN_WRITE_HI 0x01000000
583 /* Modifies the LO register. */
584 #define INSN_WRITE_LO 0x02000000
585 /* Not to be placed in a branch delay slot, either architecturally
586 or for ease of handling (such as with instructions that take a trap). */
587 #define INSN_NO_DELAY_SLOT 0x04000000
588 /* Instruction stores value into memory. */
589 #define INSN_STORE_MEMORY 0x08000000
590 /* Instruction uses single precision floating point. */
591 #define FP_S 0x10000000
592 /* Instruction uses double precision floating point. */
593 #define FP_D 0x20000000
594 /* Instruction is part of the tx39's integer multiply family. */
595 #define INSN_MULT 0x40000000
596 /* Modifies the general purpose register in MICROMIPSOP_*_RS. */
597 #define INSN_WRITE_GPR_S 0x80000000
598 /* Instruction is actually a macro. It should be ignored by the
599 disassembler, and requires special treatment by the assembler. */
600 #define INSN_MACRO 0xffffffff
601
602 /* These are the bits which may be set in the pinfo2 field of an
603 instruction. */
604
605 /* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */
606 #define INSN2_ALIAS 0x00000001
607 /* Instruction reads MDMX accumulator. */
608 #define INSN2_READ_MDMX_ACC 0x00000002
609 /* Instruction writes MDMX accumulator. */
610 #define INSN2_WRITE_MDMX_ACC 0x00000004
611 /* Macro uses single-precision floating-point instructions. This should
612 only be set for macros. For instructions, FP_S in pinfo carries the
613 same information. */
614 #define INSN2_M_FP_S 0x00000008
615 /* Macro uses double-precision floating-point instructions. This should
616 only be set for macros. For instructions, FP_D in pinfo carries the
617 same information. */
618 #define INSN2_M_FP_D 0x00000010
619 /* Modifies the general purpose register in OP_*_RZ. */
620 #define INSN2_WRITE_GPR_Z 0x00000020
621 /* Modifies the floating point register in OP_*_FZ. */
622 #define INSN2_WRITE_FPR_Z 0x00000040
623 /* Reads the general purpose register in OP_*_RZ. */
624 #define INSN2_READ_GPR_Z 0x00000080
625 /* Reads the floating point register in OP_*_FZ. */
626 #define INSN2_READ_FPR_Z 0x00000100
627 /* Reads the general purpose register in OP_*_RD. */
628 #define INSN2_READ_GPR_D 0x00000200
629
630
631 /* Instruction has a branch delay slot that requires a 16-bit instruction. */
632 #define INSN2_BRANCH_DELAY_16BIT 0x00000400
633 /* Instruction has a branch delay slot that requires a 32-bit instruction. */
634 #define INSN2_BRANCH_DELAY_32BIT 0x00000800
635 /* Reads the floating point register in MICROMIPSOP_*_FD. */
636 #define INSN2_READ_FPR_D 0x00001000
637 /* Modifies the general purpose register in MICROMIPSOP_*_MB. */
638 #define INSN2_WRITE_GPR_MB 0x00002000
639 /* Reads the general purpose register in MICROMIPSOP_*_MC. */
640 #define INSN2_READ_GPR_MC 0x00004000
641 /* Reads/writes the general purpose register in MICROMIPSOP_*_MD. */
642 #define INSN2_MOD_GPR_MD 0x00008000
643 /* Reads the general purpose register in MICROMIPSOP_*_ME. */
644 #define INSN2_READ_GPR_ME 0x00010000
645 /* Reads/writes the general purpose register in MICROMIPSOP_*_MF. */
646 #define INSN2_MOD_GPR_MF 0x00020000
647 /* Reads the general purpose register in MICROMIPSOP_*_MG. */
648 #define INSN2_READ_GPR_MG 0x00040000
649 /* Reads the general purpose register in MICROMIPSOP_*_MJ. */
650 #define INSN2_READ_GPR_MJ 0x00080000
651 /* Modifies the general purpose register in MICROMIPSOP_*_MJ. */
652 #define INSN2_WRITE_GPR_MJ 0x00100000
653 /* Reads the general purpose register in MICROMIPSOP_*_MP. */
654 #define INSN2_READ_GPR_MP 0x00200000
655 /* Modifies the general purpose register in MICROMIPSOP_*_MP. */
656 #define INSN2_WRITE_GPR_MP 0x00400000
657 /* Reads the general purpose register in MICROMIPSOP_*_MQ. */
658 #define INSN2_READ_GPR_MQ 0x00800000
659 /* Reads/Writes the stack pointer ($29). */
660 #define INSN2_MOD_SP 0x01000000
661 /* Reads the RA ($31) register. */
662 #define INSN2_READ_GPR_31 0x02000000
663 /* Reads the global pointer ($28). */
664 #define INSN2_READ_GP 0x04000000
665 /* Reads the program counter ($pc). */
666 #define INSN2_READ_PC 0x08000000
667 /* Is an unconditional branch insn. */
668 #define INSN2_UNCOND_BRANCH 0x10000000
669 /* Is a conditional branch insn. */
670 #define INSN2_COND_BRANCH 0x20000000
671 /* Modifies the general purpose registers in MICROMIPSOP_*_MH/I. */
672 #define INSN2_WRITE_GPR_MHI 0x40000000
673 /* Reads the general purpose registers in MICROMIPSOP_*_MM/N. */
674 #define INSN2_READ_GPR_MMN 0x80000000
675
676 /* Masks used to mark instructions to indicate which MIPS ISA level
677 they were introduced in. INSN_ISA_MASK masks an enumeration that
678 specifies the base ISA level(s). The remainder of a 32-bit
679 word constructed using these macros is a bitmask of the remaining
680 INSN_* values below. */
681
682 #define INSN_ISA_MASK 0x0000000ful
683
684 /* We cannot start at zero due to ISA_UNKNOWN below. */
685 #define INSN_ISA1 1
686 #define INSN_ISA2 2
687 #define INSN_ISA3 3
688 #define INSN_ISA4 4
689 #define INSN_ISA5 5
690 #define INSN_ISA32 6
691 #define INSN_ISA32R2 7
692 #define INSN_ISA64 8
693 #define INSN_ISA64R2 9
694 /* Below this point the INSN_* values correspond to combinations of ISAs.
695 They are only for use in the opcodes table to indicate membership of
696 a combination of ISAs that cannot be expressed using the usual inclusion
697 ordering on the above INSN_* values. */
698 #define INSN_ISA3_32 10
699 #define INSN_ISA3_32R2 11
700 #define INSN_ISA4_32 12
701 #define INSN_ISA4_32R2 13
702 #define INSN_ISA5_32R2 14
703
704 /* Given INSN_ISA* values X and Y, where X ranges over INSN_ISA1 through
705 INSN_ISA5_32R2 and Y ranges over INSN_ISA1 through INSN_ISA64R2,
706 this table describes whether at least one of the ISAs described by X
707 is/are implemented by ISA Y. (Think of Y as the ISA level supported by
708 a particular core and X as the ISA level(s) at which a certain instruction
709 is defined.) The ISA(s) described by X is/are implemented by Y iff
710 (mips_isa_table[(Y & INSN_ISA_MASK) - 1] >> ((X & INSN_ISA_MASK) - 1)) & 1
711 is non-zero. */
712 static const unsigned int mips_isa_table[] =
713 { 0x0001, 0x0003, 0x0607, 0x1e0f, 0x3e1f, 0x0a23, 0x3e63, 0x3ebf, 0x3fff };
714
715 /* Masks used for Chip specific instructions. */
716 #define INSN_CHIP_MASK 0xc3ff0e20
717
718 /* Cavium Networks Octeon instructions. */
719 #define INSN_OCTEON 0x00000800
720 #define INSN_OCTEONP 0x00000200
721
722 /* Masks used for MIPS-defined ASEs. */
723 #define INSN_ASE_MASK 0x3c00f010
724
725 /* DSP ASE */
726 #define INSN_DSP 0x00001000
727 #define INSN_DSP64 0x00002000
728
729 /* 0x00004000 is unused. */
730
731 /* MIPS-3D ASE */
732 #define INSN_MIPS3D 0x00008000
733
734 /* MIPS R4650 instruction. */
735 #define INSN_4650 0x00010000
736 /* LSI R4010 instruction. */
737 #define INSN_4010 0x00020000
738 /* NEC VR4100 instruction. */
739 #define INSN_4100 0x00040000
740 /* Toshiba R3900 instruction. */
741 #define INSN_3900 0x00080000
742 /* MIPS R10000 instruction. */
743 #define INSN_10000 0x00100000
744 /* Broadcom SB-1 instruction. */
745 #define INSN_SB1 0x00200000
746 /* NEC VR4111/VR4181 instruction. */
747 #define INSN_4111 0x00400000
748 /* NEC VR4120 instruction. */
749 #define INSN_4120 0x00800000
750 /* NEC VR5400 instruction. */
751 #define INSN_5400 0x01000000
752 /* NEC VR5500 instruction. */
753 #define INSN_5500 0x02000000
754
755 /* MDMX ASE */
756 #define INSN_MDMX 0x04000000
757 /* MT ASE */
758 #define INSN_MT 0x08000000
759 /* SmartMIPS ASE */
760 #define INSN_SMARTMIPS 0x10000000
761 /* DSP R2 ASE */
762 #define INSN_DSPR2 0x20000000
763 /* ST Microelectronics Loongson 2E. */
764 #define INSN_LOONGSON_2E 0x40000000
765 /* ST Microelectronics Loongson 2F. */
766 #define INSN_LOONGSON_2F 0x80000000
767 /* Loongson 3A. */
768 #define INSN_LOONGSON_3A 0x00000400
769 /* RMI Xlr instruction */
770 #define INSN_XLR 0x00000020
771
772 /* MCU (MicroController) ASE */
773 #define INSN_MCU 0x00000010
774
775 /* MIPS ISA defines, use instead of hardcoding ISA level. */
776
777 #define ISA_UNKNOWN 0 /* Gas internal use. */
778 #define ISA_MIPS1 INSN_ISA1
779 #define ISA_MIPS2 INSN_ISA2
780 #define ISA_MIPS3 INSN_ISA3
781 #define ISA_MIPS4 INSN_ISA4
782 #define ISA_MIPS5 INSN_ISA5
783
784 #define ISA_MIPS32 INSN_ISA32
785 #define ISA_MIPS64 INSN_ISA64
786
787 #define ISA_MIPS32R2 INSN_ISA32R2
788 #define ISA_MIPS64R2 INSN_ISA64R2
789
790
791 /* CPU defines, use instead of hardcoding processor number. Keep this
792 in sync with bfd/archures.c in order for machine selection to work. */
793 #define CPU_UNKNOWN 0 /* Gas internal use. */
794 #define CPU_R3000 3000
795 #define CPU_R3900 3900
796 #define CPU_R4000 4000
797 #define CPU_R4010 4010
798 #define CPU_VR4100 4100
799 #define CPU_R4111 4111
800 #define CPU_VR4120 4120
801 #define CPU_R4300 4300
802 #define CPU_R4400 4400
803 #define CPU_R4600 4600
804 #define CPU_R4650 4650
805 #define CPU_R5000 5000
806 #define CPU_VR5400 5400
807 #define CPU_VR5500 5500
808 #define CPU_R6000 6000
809 #define CPU_RM7000 7000
810 #define CPU_R8000 8000
811 #define CPU_RM9000 9000
812 #define CPU_R10000 10000
813 #define CPU_R12000 12000
814 #define CPU_R14000 14000
815 #define CPU_R16000 16000
816 #define CPU_MIPS16 16
817 #define CPU_MIPS32 32
818 #define CPU_MIPS32R2 33
819 #define CPU_MIPS5 5
820 #define CPU_MIPS64 64
821 #define CPU_MIPS64R2 65
822 #define CPU_SB1 12310201 /* octal 'SB', 01. */
823 #define CPU_LOONGSON_2E 3001
824 #define CPU_LOONGSON_2F 3002
825 #define CPU_LOONGSON_3A 3003
826 #define CPU_OCTEON 6501
827 #define CPU_OCTEONP 6601
828 #define CPU_XLR 887682 /* decimal 'XLR' */
829
830 /* Test for membership in an ISA including chip specific ISAs. INSN
831 is pointer to an element of the opcode table; ISA is the specified
832 ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
833 test, or zero if no CPU specific ISA test is desired. */
834
835 #define OPCODE_IS_MEMBER(insn, isa, cpu) \
836 (((isa & INSN_ISA_MASK) != 0 \
837 && ((insn)->membership & INSN_ISA_MASK) != 0 \
838 && ((mips_isa_table [(isa & INSN_ISA_MASK) - 1] >> \
839 (((insn)->membership & INSN_ISA_MASK) - 1)) & 1) != 0) \
840 || ((isa & ~INSN_ISA_MASK) \
841 & ((insn)->membership & ~INSN_ISA_MASK)) != 0 \
842 || (cpu == CPU_R4650 && ((insn)->membership & INSN_4650) != 0) \
843 || (cpu == CPU_RM7000 && ((insn)->membership & INSN_4650) != 0) \
844 || (cpu == CPU_RM9000 && ((insn)->membership & INSN_4650) != 0) \
845 || (cpu == CPU_R4010 && ((insn)->membership & INSN_4010) != 0) \
846 || (cpu == CPU_VR4100 && ((insn)->membership & INSN_4100) != 0) \
847 || (cpu == CPU_R3900 && ((insn)->membership & INSN_3900) != 0) \
848 || ((cpu == CPU_R10000 || cpu == CPU_R12000 || cpu == CPU_R14000 \
849 || cpu == CPU_R16000) \
850 && ((insn)->membership & INSN_10000) != 0) \
851 || (cpu == CPU_SB1 && ((insn)->membership & INSN_SB1) != 0) \
852 || (cpu == CPU_R4111 && ((insn)->membership & INSN_4111) != 0) \
853 || (cpu == CPU_VR4120 && ((insn)->membership & INSN_4120) != 0) \
854 || (cpu == CPU_VR5400 && ((insn)->membership & INSN_5400) != 0) \
855 || (cpu == CPU_VR5500 && ((insn)->membership & INSN_5500) != 0) \
856 || (cpu == CPU_LOONGSON_2E \
857 && ((insn)->membership & INSN_LOONGSON_2E) != 0) \
858 || (cpu == CPU_LOONGSON_2F \
859 && ((insn)->membership & INSN_LOONGSON_2F) != 0) \
860 || (cpu == CPU_LOONGSON_3A \
861 && ((insn)->membership & INSN_LOONGSON_3A) != 0) \
862 || (cpu == CPU_OCTEON \
863 && ((insn)->membership & INSN_OCTEON) != 0) \
864 || (cpu == CPU_OCTEONP \
865 && ((insn)->membership & INSN_OCTEONP) != 0) \
866 || (cpu == CPU_XLR && ((insn)->membership & INSN_XLR) != 0) \
867 || 0) /* Please keep this term for easier source merging. */
868
869 /* This is a list of macro expanded instructions.
870
871 _I appended means immediate
872 _A appended means address
873 _AB appended means address with base register
874 _D appended means 64 bit floating point constant
875 _S appended means 32 bit floating point constant. */
876
877 enum
878 {
879 M_ABS,
880 M_ACLR_AB,
881 M_ACLR_OB,
882 M_ADD_I,
883 M_ADDU_I,
884 M_AND_I,
885 M_ASET_AB,
886 M_ASET_OB,
887 M_BALIGN,
888 M_BC1FL,
889 M_BC1TL,
890 M_BC2FL,
891 M_BC2TL,
892 M_BEQ,
893 M_BEQ_I,
894 M_BEQL,
895 M_BEQL_I,
896 M_BGE,
897 M_BGEL,
898 M_BGE_I,
899 M_BGEL_I,
900 M_BGEU,
901 M_BGEUL,
902 M_BGEU_I,
903 M_BGEUL_I,
904 M_BGEZ,
905 M_BGEZL,
906 M_BGEZALL,
907 M_BGT,
908 M_BGTL,
909 M_BGT_I,
910 M_BGTL_I,
911 M_BGTU,
912 M_BGTUL,
913 M_BGTU_I,
914 M_BGTUL_I,
915 M_BGTZ,
916 M_BGTZL,
917 M_BLE,
918 M_BLEL,
919 M_BLE_I,
920 M_BLEL_I,
921 M_BLEU,
922 M_BLEUL,
923 M_BLEU_I,
924 M_BLEUL_I,
925 M_BLEZ,
926 M_BLEZL,
927 M_BLT,
928 M_BLTL,
929 M_BLT_I,
930 M_BLTL_I,
931 M_BLTU,
932 M_BLTUL,
933 M_BLTU_I,
934 M_BLTUL_I,
935 M_BLTZ,
936 M_BLTZL,
937 M_BLTZALL,
938 M_BNE,
939 M_BNEL,
940 M_BNE_I,
941 M_BNEL_I,
942 M_CACHE_AB,
943 M_CACHE_OB,
944 M_DABS,
945 M_DADD_I,
946 M_DADDU_I,
947 M_DDIV_3,
948 M_DDIV_3I,
949 M_DDIVU_3,
950 M_DDIVU_3I,
951 M_DEXT,
952 M_DINS,
953 M_DIV_3,
954 M_DIV_3I,
955 M_DIVU_3,
956 M_DIVU_3I,
957 M_DLA_AB,
958 M_DLCA_AB,
959 M_DLI,
960 M_DMUL,
961 M_DMUL_I,
962 M_DMULO,
963 M_DMULO_I,
964 M_DMULOU,
965 M_DMULOU_I,
966 M_DREM_3,
967 M_DREM_3I,
968 M_DREMU_3,
969 M_DREMU_3I,
970 M_DSUB_I,
971 M_DSUBU_I,
972 M_DSUBU_I_2,
973 M_J_A,
974 M_JAL_1,
975 M_JAL_2,
976 M_JAL_A,
977 M_JALS_1,
978 M_JALS_2,
979 M_JALS_A,
980 M_L_DOB,
981 M_L_DAB,
982 M_LA_AB,
983 M_LB_A,
984 M_LB_AB,
985 M_LBU_A,
986 M_LBU_AB,
987 M_LCA_AB,
988 M_LD_A,
989 M_LD_OB,
990 M_LD_AB,
991 M_LDC1_AB,
992 M_LDC2_AB,
993 M_LDC2_OB,
994 M_LDC3_AB,
995 M_LDL_AB,
996 M_LDL_OB,
997 M_LDM_AB,
998 M_LDM_OB,
999 M_LDP_AB,
1000 M_LDP_OB,
1001 M_LDR_AB,
1002 M_LDR_OB,
1003 M_LH_A,
1004 M_LH_AB,
1005 M_LHU_A,
1006 M_LHU_AB,
1007 M_LI,
1008 M_LI_D,
1009 M_LI_DD,
1010 M_LI_S,
1011 M_LI_SS,
1012 M_LL_AB,
1013 M_LL_OB,
1014 M_LLD_AB,
1015 M_LLD_OB,
1016 M_LS_A,
1017 M_LW_A,
1018 M_LW_AB,
1019 M_LWC0_A,
1020 M_LWC0_AB,
1021 M_LWC1_A,
1022 M_LWC1_AB,
1023 M_LWC2_A,
1024 M_LWC2_AB,
1025 M_LWC2_OB,
1026 M_LWC3_A,
1027 M_LWC3_AB,
1028 M_LWL_A,
1029 M_LWL_AB,
1030 M_LWL_OB,
1031 M_LWM_AB,
1032 M_LWM_OB,
1033 M_LWP_AB,
1034 M_LWP_OB,
1035 M_LWR_A,
1036 M_LWR_AB,
1037 M_LWR_OB,
1038 M_LWU_AB,
1039 M_LWU_OB,
1040 M_MSGSND,
1041 M_MSGLD,
1042 M_MSGLD_T,
1043 M_MSGWAIT,
1044 M_MSGWAIT_T,
1045 M_MOVE,
1046 M_MUL,
1047 M_MUL_I,
1048 M_MULO,
1049 M_MULO_I,
1050 M_MULOU,
1051 M_MULOU_I,
1052 M_NOR_I,
1053 M_OR_I,
1054 M_PREF_AB,
1055 M_PREF_OB,
1056 M_REM_3,
1057 M_REM_3I,
1058 M_REMU_3,
1059 M_REMU_3I,
1060 M_DROL,
1061 M_ROL,
1062 M_DROL_I,
1063 M_ROL_I,
1064 M_DROR,
1065 M_ROR,
1066 M_DROR_I,
1067 M_ROR_I,
1068 M_S_DA,
1069 M_S_DOB,
1070 M_S_DAB,
1071 M_S_S,
1072 M_SAA_AB,
1073 M_SAA_OB,
1074 M_SAAD_AB,
1075 M_SAAD_OB,
1076 M_SC_AB,
1077 M_SC_OB,
1078 M_SCD_AB,
1079 M_SCD_OB,
1080 M_SD_A,
1081 M_SD_OB,
1082 M_SD_AB,
1083 M_SDC1_AB,
1084 M_SDC2_AB,
1085 M_SDC2_OB,
1086 M_SDC3_AB,
1087 M_SDL_AB,
1088 M_SDL_OB,
1089 M_SDM_AB,
1090 M_SDM_OB,
1091 M_SDP_AB,
1092 M_SDP_OB,
1093 M_SDR_AB,
1094 M_SDR_OB,
1095 M_SEQ,
1096 M_SEQ_I,
1097 M_SGE,
1098 M_SGE_I,
1099 M_SGEU,
1100 M_SGEU_I,
1101 M_SGT,
1102 M_SGT_I,
1103 M_SGTU,
1104 M_SGTU_I,
1105 M_SLE,
1106 M_SLE_I,
1107 M_SLEU,
1108 M_SLEU_I,
1109 M_SLT_I,
1110 M_SLTU_I,
1111 M_SNE,
1112 M_SNE_I,
1113 M_SB_A,
1114 M_SB_AB,
1115 M_SH_A,
1116 M_SH_AB,
1117 M_SW_A,
1118 M_SW_AB,
1119 M_SWC0_A,
1120 M_SWC0_AB,
1121 M_SWC1_A,
1122 M_SWC1_AB,
1123 M_SWC2_A,
1124 M_SWC2_AB,
1125 M_SWC2_OB,
1126 M_SWC3_A,
1127 M_SWC3_AB,
1128 M_SWL_A,
1129 M_SWL_AB,
1130 M_SWL_OB,
1131 M_SWM_AB,
1132 M_SWM_OB,
1133 M_SWP_AB,
1134 M_SWP_OB,
1135 M_SWR_A,
1136 M_SWR_AB,
1137 M_SWR_OB,
1138 M_SUB_I,
1139 M_SUBU_I,
1140 M_SUBU_I_2,
1141 M_TEQ_I,
1142 M_TGE_I,
1143 M_TGEU_I,
1144 M_TLT_I,
1145 M_TLTU_I,
1146 M_TNE_I,
1147 M_TRUNCWD,
1148 M_TRUNCWS,
1149 M_ULD,
1150 M_ULD_A,
1151 M_ULH,
1152 M_ULH_A,
1153 M_ULHU,
1154 M_ULHU_A,
1155 M_ULW,
1156 M_ULW_A,
1157 M_USH,
1158 M_USH_A,
1159 M_USW,
1160 M_USW_A,
1161 M_USD,
1162 M_USD_A,
1163 M_XOR_I,
1164 M_COP0,
1165 M_COP1,
1166 M_COP2,
1167 M_COP3,
1168 M_NUM_MACROS
1169 };
1170
1171
1172 /* The order of overloaded instructions matters. Label arguments and
1173 register arguments look the same. Instructions that can have either
1174 for arguments must apear in the correct order in this table for the
1175 assembler to pick the right one. In other words, entries with
1176 immediate operands must apear after the same instruction with
1177 registers.
1178
1179 Many instructions are short hand for other instructions (i.e., The
1180 jal <register> instruction is short for jalr <register>). */
1181
1182 extern const struct mips_opcode mips_builtin_opcodes[];
1183 extern const int bfd_mips_num_builtin_opcodes;
1184 extern struct mips_opcode *mips_opcodes;
1185 extern int bfd_mips_num_opcodes;
1186 #define NUMOPCODES bfd_mips_num_opcodes
1187
1188 \f
1189 /* The rest of this file adds definitions for the mips16 TinyRISC
1190 processor. */
1191
1192 /* These are the bitmasks and shift counts used for the different
1193 fields in the instruction formats. Other than OP, no masks are
1194 provided for the fixed portions of an instruction, since they are
1195 not needed.
1196
1197 The I format uses IMM11.
1198
1199 The RI format uses RX and IMM8.
1200
1201 The RR format uses RX, and RY.
1202
1203 The RRI format uses RX, RY, and IMM5.
1204
1205 The RRR format uses RX, RY, and RZ.
1206
1207 The RRI_A format uses RX, RY, and IMM4.
1208
1209 The SHIFT format uses RX, RY, and SHAMT.
1210
1211 The I8 format uses IMM8.
1212
1213 The I8_MOVR32 format uses RY and REGR32.
1214
1215 The IR_MOV32R format uses REG32R and MOV32Z.
1216
1217 The I64 format uses IMM8.
1218
1219 The RI64 format uses RY and IMM5.
1220 */
1221
1222 #define MIPS16OP_MASK_OP 0x1f
1223 #define MIPS16OP_SH_OP 11
1224 #define MIPS16OP_MASK_IMM11 0x7ff
1225 #define MIPS16OP_SH_IMM11 0
1226 #define MIPS16OP_MASK_RX 0x7
1227 #define MIPS16OP_SH_RX 8
1228 #define MIPS16OP_MASK_IMM8 0xff
1229 #define MIPS16OP_SH_IMM8 0
1230 #define MIPS16OP_MASK_RY 0x7
1231 #define MIPS16OP_SH_RY 5
1232 #define MIPS16OP_MASK_IMM5 0x1f
1233 #define MIPS16OP_SH_IMM5 0
1234 #define MIPS16OP_MASK_RZ 0x7
1235 #define MIPS16OP_SH_RZ 2
1236 #define MIPS16OP_MASK_IMM4 0xf
1237 #define MIPS16OP_SH_IMM4 0
1238 #define MIPS16OP_MASK_REGR32 0x1f
1239 #define MIPS16OP_SH_REGR32 0
1240 #define MIPS16OP_MASK_REG32R 0x1f
1241 #define MIPS16OP_SH_REG32R 3
1242 #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
1243 #define MIPS16OP_MASK_MOVE32Z 0x7
1244 #define MIPS16OP_SH_MOVE32Z 0
1245 #define MIPS16OP_MASK_IMM6 0x3f
1246 #define MIPS16OP_SH_IMM6 5
1247
1248 /* These are the characters which may appears in the args field of a MIPS16
1249 instruction. They appear in the order in which the fields appear when the
1250 instruction is used. Commas and parentheses in the args string are ignored
1251 when assembling, and written into the output when disassembling.
1252
1253 "y" 3 bit register (MIPS16OP_*_RY)
1254 "x" 3 bit register (MIPS16OP_*_RX)
1255 "z" 3 bit register (MIPS16OP_*_RZ)
1256 "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
1257 "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
1258 "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
1259 "0" zero register ($0)
1260 "S" stack pointer ($sp or $29)
1261 "P" program counter
1262 "R" return address register ($ra or $31)
1263 "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
1264 "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
1265 "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
1266 "a" 26 bit jump address
1267 "e" 11 bit extension value
1268 "l" register list for entry instruction
1269 "L" register list for exit instruction
1270
1271 The remaining codes may be extended. Except as otherwise noted,
1272 the full extended operand is a 16 bit signed value.
1273 "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
1274 ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned)
1275 "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
1276 "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
1277 "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
1278 "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
1279 "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
1280 "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
1281 "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
1282 "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
1283 "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
1284 "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
1285 "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
1286 "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
1287 "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
1288 "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
1289 "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
1290 "q" 11 bit branch address (MIPS16OP_*_IMM11)
1291 "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
1292 "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
1293 "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
1294 "m" 7 bit register list for save instruction (18 bit extended)
1295 "M" 7 bit register list for restore instruction (18 bit extended)
1296 */
1297
1298 /* Save/restore encoding for the args field when all 4 registers are
1299 either saved as arguments or saved/restored as statics. */
1300 #define MIPS16_ALL_ARGS 0xe
1301 #define MIPS16_ALL_STATICS 0xb
1302
1303 /* For the mips16, we use the same opcode table format and a few of
1304 the same flags. However, most of the flags are different. */
1305
1306 /* Modifies the register in MIPS16OP_*_RX. */
1307 #define MIPS16_INSN_WRITE_X 0x00000001
1308 /* Modifies the register in MIPS16OP_*_RY. */
1309 #define MIPS16_INSN_WRITE_Y 0x00000002
1310 /* Modifies the register in MIPS16OP_*_RZ. */
1311 #define MIPS16_INSN_WRITE_Z 0x00000004
1312 /* Modifies the T ($24) register. */
1313 #define MIPS16_INSN_WRITE_T 0x00000008
1314 /* Modifies the SP ($29) register. */
1315 #define MIPS16_INSN_WRITE_SP 0x00000010
1316 /* Modifies the RA ($31) register. */
1317 #define MIPS16_INSN_WRITE_31 0x00000020
1318 /* Modifies the general purpose register in MIPS16OP_*_REG32R. */
1319 #define MIPS16_INSN_WRITE_GPR_Y 0x00000040
1320 /* Reads the register in MIPS16OP_*_RX. */
1321 #define MIPS16_INSN_READ_X 0x00000080
1322 /* Reads the register in MIPS16OP_*_RY. */
1323 #define MIPS16_INSN_READ_Y 0x00000100
1324 /* Reads the register in MIPS16OP_*_MOVE32Z. */
1325 #define MIPS16_INSN_READ_Z 0x00000200
1326 /* Reads the T ($24) register. */
1327 #define MIPS16_INSN_READ_T 0x00000400
1328 /* Reads the SP ($29) register. */
1329 #define MIPS16_INSN_READ_SP 0x00000800
1330 /* Reads the RA ($31) register. */
1331 #define MIPS16_INSN_READ_31 0x00001000
1332 /* Reads the program counter. */
1333 #define MIPS16_INSN_READ_PC 0x00002000
1334 /* Reads the general purpose register in MIPS16OP_*_REGR32. */
1335 #define MIPS16_INSN_READ_GPR_X 0x00004000
1336 /* Is an unconditional branch insn. */
1337 #define MIPS16_INSN_UNCOND_BRANCH 0x00008000
1338 /* Is a conditional branch insn. */
1339 #define MIPS16_INSN_COND_BRANCH 0x00010000
1340
1341 /* The following flags have the same value for the mips16 opcode
1342 table:
1343
1344 INSN_ISA3
1345
1346 INSN_UNCOND_BRANCH_DELAY
1347 INSN_COND_BRANCH_DELAY
1348 INSN_COND_BRANCH_LIKELY (never used)
1349 INSN_READ_HI
1350 INSN_READ_LO
1351 INSN_WRITE_HI
1352 INSN_WRITE_LO
1353 INSN_TRAP
1354 FP_D (never used)
1355 */
1356
1357 extern const struct mips_opcode mips16_opcodes[];
1358 extern const int bfd_mips16_num_opcodes;
1359
1360 /* These are the bit masks and shift counts used for the different fields
1361 in the microMIPS instruction formats. No masks are provided for the
1362 fixed portions of an instruction, since they are not needed. */
1363
1364 #define MICROMIPSOP_MASK_IMMEDIATE 0xffff
1365 #define MICROMIPSOP_SH_IMMEDIATE 0
1366 #define MICROMIPSOP_MASK_DELTA 0xffff
1367 #define MICROMIPSOP_SH_DELTA 0
1368 #define MICROMIPSOP_MASK_CODE10 0x3ff
1369 #define MICROMIPSOP_SH_CODE10 16 /* 10-bit wait code. */
1370 #define MICROMIPSOP_MASK_TRAP 0xf
1371 #define MICROMIPSOP_SH_TRAP 12 /* 4-bit trap code. */
1372 #define MICROMIPSOP_MASK_SHAMT 0x1f
1373 #define MICROMIPSOP_SH_SHAMT 11
1374 #define MICROMIPSOP_MASK_TARGET 0x3ffffff
1375 #define MICROMIPSOP_SH_TARGET 0
1376 #define MICROMIPSOP_MASK_EXTLSB 0x1f /* "ext" LSB. */
1377 #define MICROMIPSOP_SH_EXTLSB 6
1378 #define MICROMIPSOP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */
1379 #define MICROMIPSOP_SH_EXTMSBD 11
1380 #define MICROMIPSOP_MASK_INSMSB 0x1f /* "ins" MSB. */
1381 #define MICROMIPSOP_SH_INSMSB 11
1382 #define MICROMIPSOP_MASK_CODE 0x3ff
1383 #define MICROMIPSOP_SH_CODE 16 /* 10-bit higher break code. */
1384 #define MICROMIPSOP_MASK_CODE2 0x3ff
1385 #define MICROMIPSOP_SH_CODE2 6 /* 10-bit lower break code. */
1386 #define MICROMIPSOP_MASK_CACHE 0x1f
1387 #define MICROMIPSOP_SH_CACHE 21 /* 5-bit cache op. */
1388 #define MICROMIPSOP_MASK_SEL 0x7
1389 #define MICROMIPSOP_SH_SEL 11
1390 #define MICROMIPSOP_MASK_OFFSET12 0xfff
1391 #define MICROMIPSOP_SH_OFFSET12 0
1392 #define MICROMIPSOP_MASK_3BITPOS 0x7
1393 #define MICROMIPSOP_SH_3BITPOS 21
1394 #define MICROMIPSOP_MASK_STYPE 0x1f
1395 #define MICROMIPSOP_SH_STYPE 16
1396 #define MICROMIPSOP_MASK_OFFSET10 0x3ff
1397 #define MICROMIPSOP_SH_OFFSET10 6
1398 #define MICROMIPSOP_MASK_RS 0x1f
1399 #define MICROMIPSOP_SH_RS 16
1400 #define MICROMIPSOP_MASK_RT 0x1f
1401 #define MICROMIPSOP_SH_RT 21
1402 #define MICROMIPSOP_MASK_RD 0x1f
1403 #define MICROMIPSOP_SH_RD 11
1404 #define MICROMIPSOP_MASK_FS 0x1f
1405 #define MICROMIPSOP_SH_FS 16
1406 #define MICROMIPSOP_MASK_FT 0x1f
1407 #define MICROMIPSOP_SH_FT 21
1408 #define MICROMIPSOP_MASK_FD 0x1f
1409 #define MICROMIPSOP_SH_FD 11
1410 #define MICROMIPSOP_MASK_FR 0x1f
1411 #define MICROMIPSOP_SH_FR 6
1412 #define MICROMIPSOP_MASK_RS3 0x1f
1413 #define MICROMIPSOP_SH_RS3 6
1414 #define MICROMIPSOP_MASK_PREFX 0x1f
1415 #define MICROMIPSOP_SH_PREFX 11
1416 #define MICROMIPSOP_MASK_BCC 0x7
1417 #define MICROMIPSOP_SH_BCC 18
1418 #define MICROMIPSOP_MASK_CCC 0x7
1419 #define MICROMIPSOP_SH_CCC 13
1420 #define MICROMIPSOP_MASK_COPZ 0x7fffff
1421 #define MICROMIPSOP_SH_COPZ 3
1422
1423 #define MICROMIPSOP_MASK_MB 0x7
1424 #define MICROMIPSOP_SH_MB 23
1425 #define MICROMIPSOP_MASK_MC 0x7
1426 #define MICROMIPSOP_SH_MC 4
1427 #define MICROMIPSOP_MASK_MD 0x7
1428 #define MICROMIPSOP_SH_MD 7
1429 #define MICROMIPSOP_MASK_ME 0x7
1430 #define MICROMIPSOP_SH_ME 1
1431 #define MICROMIPSOP_MASK_MF 0x7
1432 #define MICROMIPSOP_SH_MF 3
1433 #define MICROMIPSOP_MASK_MG 0x7
1434 #define MICROMIPSOP_SH_MG 0
1435 #define MICROMIPSOP_MASK_MH 0x7
1436 #define MICROMIPSOP_SH_MH 7
1437 #define MICROMIPSOP_MASK_MI 0x7
1438 #define MICROMIPSOP_SH_MI 7
1439 #define MICROMIPSOP_MASK_MJ 0x1f
1440 #define MICROMIPSOP_SH_MJ 0
1441 #define MICROMIPSOP_MASK_ML 0x7
1442 #define MICROMIPSOP_SH_ML 4
1443 #define MICROMIPSOP_MASK_MM 0x7
1444 #define MICROMIPSOP_SH_MM 1
1445 #define MICROMIPSOP_MASK_MN 0x7
1446 #define MICROMIPSOP_SH_MN 4
1447 #define MICROMIPSOP_MASK_MP 0x1f
1448 #define MICROMIPSOP_SH_MP 5
1449 #define MICROMIPSOP_MASK_MQ 0x7
1450 #define MICROMIPSOP_SH_MQ 7
1451
1452 #define MICROMIPSOP_MASK_IMMA 0x7f
1453 #define MICROMIPSOP_SH_IMMA 0
1454 #define MICROMIPSOP_MASK_IMMB 0x7
1455 #define MICROMIPSOP_SH_IMMB 1
1456 #define MICROMIPSOP_MASK_IMMC 0xf
1457 #define MICROMIPSOP_SH_IMMC 0
1458 #define MICROMIPSOP_MASK_IMMD 0x3ff
1459 #define MICROMIPSOP_SH_IMMD 0
1460 #define MICROMIPSOP_MASK_IMME 0x7f
1461 #define MICROMIPSOP_SH_IMME 0
1462 #define MICROMIPSOP_MASK_IMMF 0xf
1463 #define MICROMIPSOP_SH_IMMF 0
1464 #define MICROMIPSOP_MASK_IMMG 0xf
1465 #define MICROMIPSOP_SH_IMMG 0
1466 #define MICROMIPSOP_MASK_IMMH 0xf
1467 #define MICROMIPSOP_SH_IMMH 0
1468 #define MICROMIPSOP_MASK_IMMI 0x7f
1469 #define MICROMIPSOP_SH_IMMI 0
1470 #define MICROMIPSOP_MASK_IMMJ 0xf
1471 #define MICROMIPSOP_SH_IMMJ 0
1472 #define MICROMIPSOP_MASK_IMML 0xf
1473 #define MICROMIPSOP_SH_IMML 0
1474 #define MICROMIPSOP_MASK_IMMM 0x7
1475 #define MICROMIPSOP_SH_IMMM 1
1476 #define MICROMIPSOP_MASK_IMMN 0x3
1477 #define MICROMIPSOP_SH_IMMN 4
1478 #define MICROMIPSOP_MASK_IMMO 0xf
1479 #define MICROMIPSOP_SH_IMMO 0
1480 #define MICROMIPSOP_MASK_IMMP 0x1f
1481 #define MICROMIPSOP_SH_IMMP 0
1482 #define MICROMIPSOP_MASK_IMMQ 0x7fffff
1483 #define MICROMIPSOP_SH_IMMQ 0
1484 #define MICROMIPSOP_MASK_IMMU 0x1f
1485 #define MICROMIPSOP_SH_IMMU 0
1486 #define MICROMIPSOP_MASK_IMMW 0x3f
1487 #define MICROMIPSOP_SH_IMMW 1
1488 #define MICROMIPSOP_MASK_IMMX 0xf
1489 #define MICROMIPSOP_SH_IMMX 1
1490 #define MICROMIPSOP_MASK_IMMY 0x1ff
1491 #define MICROMIPSOP_SH_IMMY 1
1492
1493 /* Placeholders for fields that only exist in the traditional 32-bit
1494 instruction encoding; see the comment above for details. */
1495 #define MICROMIPSOP_MASK_CODE20 0
1496 #define MICROMIPSOP_SH_CODE20 0
1497 #define MICROMIPSOP_MASK_PERFREG 0
1498 #define MICROMIPSOP_SH_PERFREG 0
1499 #define MICROMIPSOP_MASK_CODE19 0
1500 #define MICROMIPSOP_SH_CODE19 0
1501 #define MICROMIPSOP_MASK_ALN 0
1502 #define MICROMIPSOP_SH_ALN 0
1503 #define MICROMIPSOP_MASK_VECBYTE 0
1504 #define MICROMIPSOP_SH_VECBYTE 0
1505 #define MICROMIPSOP_MASK_VECALIGN 0
1506 #define MICROMIPSOP_SH_VECALIGN 0
1507 #define MICROMIPSOP_MASK_DSPACC 0
1508 #define MICROMIPSOP_SH_DSPACC 0
1509 #define MICROMIPSOP_MASK_DSPACC_S 0
1510 #define MICROMIPSOP_SH_DSPACC_S 0
1511 #define MICROMIPSOP_MASK_DSPSFT 0
1512 #define MICROMIPSOP_SH_DSPSFT 0
1513 #define MICROMIPSOP_MASK_DSPSFT_7 0
1514 #define MICROMIPSOP_SH_DSPSFT_7 0
1515 #define MICROMIPSOP_MASK_SA3 0
1516 #define MICROMIPSOP_SH_SA3 0
1517 #define MICROMIPSOP_MASK_SA4 0
1518 #define MICROMIPSOP_SH_SA4 0
1519 #define MICROMIPSOP_MASK_IMM8 0
1520 #define MICROMIPSOP_SH_IMM8 0
1521 #define MICROMIPSOP_MASK_IMM10 0
1522 #define MICROMIPSOP_SH_IMM10 0
1523 #define MICROMIPSOP_MASK_WRDSP 0
1524 #define MICROMIPSOP_SH_WRDSP 0
1525 #define MICROMIPSOP_MASK_RDDSP 0
1526 #define MICROMIPSOP_SH_RDDSP 0
1527 #define MICROMIPSOP_MASK_BP 0
1528 #define MICROMIPSOP_SH_BP 0
1529 #define MICROMIPSOP_MASK_MT_U 0
1530 #define MICROMIPSOP_SH_MT_U 0
1531 #define MICROMIPSOP_MASK_MT_H 0
1532 #define MICROMIPSOP_SH_MT_H 0
1533 #define MICROMIPSOP_MASK_MTACC_T 0
1534 #define MICROMIPSOP_SH_MTACC_T 0
1535 #define MICROMIPSOP_MASK_MTACC_D 0
1536 #define MICROMIPSOP_SH_MTACC_D 0
1537 #define MICROMIPSOP_MASK_BBITIND 0
1538 #define MICROMIPSOP_SH_BBITIND 0
1539 #define MICROMIPSOP_MASK_CINSPOS 0
1540 #define MICROMIPSOP_SH_CINSPOS 0
1541 #define MICROMIPSOP_MASK_CINSLM1 0
1542 #define MICROMIPSOP_SH_CINSLM1 0
1543 #define MICROMIPSOP_MASK_SEQI 0
1544 #define MICROMIPSOP_SH_SEQI 0
1545 #define MICROMIPSOP_SH_OFFSET_A 0
1546 #define MICROMIPSOP_MASK_OFFSET_A 0
1547 #define MICROMIPSOP_SH_OFFSET_B 0
1548 #define MICROMIPSOP_MASK_OFFSET_B 0
1549 #define MICROMIPSOP_SH_OFFSET_C 0
1550 #define MICROMIPSOP_MASK_OFFSET_C 0
1551 #define MICROMIPSOP_SH_RZ 0
1552 #define MICROMIPSOP_MASK_RZ 0
1553 #define MICROMIPSOP_SH_FZ 0
1554 #define MICROMIPSOP_MASK_FZ 0
1555
1556 /* These are the characters which may appears in the args field of a microMIPS
1557 instruction. They appear in the order in which the fields appear
1558 when the instruction is used. Commas and parentheses in the args
1559 string are ignored when assembling, and written into the output
1560 when disassembling.
1561
1562 The followings are for 16-bit microMIPS instructions.
1563
1564 "ma" must be $28
1565 "mc" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MC) at bit 4
1566 The same register used as both source and target.
1567 "md" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MD) at bit 7
1568 "me" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ME) at bit 1
1569 The same register used as both source and target.
1570 "mf" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MF) at bit 3
1571 "mg" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MG) at bit 0
1572 "mh" MIPS registers 4, 5, 6 (MICROMIPSOP_*_MH) at bit 7
1573 "mi" MIPS registers 5, 6, 7, 21, 22 (MICROMIPSOP_*_MI) at bit 7
1574 ("mh" and "mi" form a valid 3-bit register pair)
1575 "mj" 5-bit MIPS registers (MICROMIPSOP_*_MJ) at bit 0
1576 "ml" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ML) at bit 4
1577 "mm" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MM) at bit 1
1578 "mn" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MN) at bit 4
1579 "mp" 5-bit MIPS registers (MICROMIPSOP_*_MP) at bit 5
1580 "mq" 3-bit MIPS registers 0, 2-7, 17 (MICROMIPSOP_*_MQ) at bit 7
1581 "mr" must be program counter
1582 "ms" must be $29
1583 "mt" must be the same as the previous register
1584 "mx" must be the same as the destination register
1585 "my" must be $31
1586 "mz" must be $0
1587
1588 "mA" 7-bit immediate (-64 .. 63) << 2 (MICROMIPSOP_*_IMMA)
1589 "mB" 3-bit immediate (-1, 1, 4, 8, 12, 16, 20, 24) (MICROMIPSOP_*_IMMB)
1590 "mC" 4-bit immediate (1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64, 128, 255,
1591 32768, 65535) (MICROMIPSOP_*_IMMC)
1592 "mD" 10-bit branch address (-512 .. 511) << 1 (MICROMIPSOP_*_IMMD)
1593 "mE" 7-bit branch address (-64 .. 63) << 1 (MICROMIPSOP_*_IMME)
1594 "mF" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMMF)
1595 "mG" 4-bit immediate (-1 .. 14) (MICROMIPSOP_*_IMMG)
1596 "mH" 4-bit immediate (0 .. 15) << 1 (MICROMIPSOP_*_IMMH)
1597 "mI" 7-bit immediate (-1 .. 126) (MICROMIPSOP_*_IMMI)
1598 "mJ" 4-bit immediate (0 .. 15) << 2 (MICROMIPSOP_*_IMMJ)
1599 "mL" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
1600 "mM" 3-bit immediate (1 .. 8) (MICROMIPSOP_*_IMMM)
1601 "mN" 2-bit immediate (0 .. 3) for register list (MICROMIPSOP_*_IMMN)
1602 "mO" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML)
1603 "mP" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMP)
1604 "mU" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMU)
1605 "mW" 6-bit immediate (0 .. 63) << 2 (MICROMIPSOP_*_IMMW)
1606 "mX" 4-bit immediate (-8 .. 7) (MICROMIPSOP_*_IMMX)
1607 "mY" 9-bit immediate (-258 .. -3, 2 .. 257) << 2 (MICROMIPSOP_*_IMMY)
1608 "mZ" must be zero
1609
1610 In most cases 32-bit microMIPS instructions use the same characters
1611 as MIPS (with ADDIUPC being a notable exception, but there are some
1612 others too).
1613
1614 "." 10-bit signed offset/number (MICROMIPSOP_*_OFFSET10)
1615 "1" 5-bit sync type (MICROMIPSOP_*_SHAMT)
1616 "<" 5-bit shift amount (MICROMIPSOP_*_SHAMT)
1617 ">" shift amount between 32 and 63, stored after subtracting 32
1618 (MICROMIPSOP_*_SHAMT)
1619 "\" 3-bit position for ASET and ACLR (MICROMIPSOP_*_3BITPOS)
1620 "|" 4-bit trap code (MICROMIPSOP_*_TRAP)
1621 "~" 12-bit signed offset (MICROMIPSOP_*_OFFSET12)
1622 "a" 26-bit target address (MICROMIPSOP_*_TARGET)
1623 "b" 5-bit base register (MICROMIPSOP_*_RS)
1624 "c" 10-bit higher breakpoint code (MICROMIPSOP_*_CODE)
1625 "d" 5-bit destination register specifier (MICROMIPSOP_*_RD)
1626 "h" 5-bit PREFX hint (MICROMIPSOP_*_PREFX)
1627 "i" 16-bit unsigned immediate (MICROMIPSOP_*_IMMEDIATE)
1628 "j" 16-bit signed immediate (MICROMIPSOP_*_DELTA)
1629 "k" 5-bit cache opcode in target register position (MICROMIPSOP_*_CACHE)
1630 "n" register list for 32-bit LWM/SWM instruction (MICROMIPSOP_*_RT)
1631 "o" 16-bit signed offset (MICROMIPSOP_*_DELTA)
1632 "p" 16-bit PC-relative branch target address (MICROMIPSOP_*_DELTA)
1633 "q" 10-bit lower breakpoint code (MICROMIPSOP_*_CODE2)
1634 "r" 5-bit same register used as both source and target (MICROMIPSOP_*_RS)
1635 "s" 5-bit source register specifier (MICROMIPSOP_*_RS)
1636 "t" 5-bit target register (MICROMIPSOP_*_RT)
1637 "u" 16-bit upper 16 bits of address (MICROMIPSOP_*_IMMEDIATE)
1638 "v" 5-bit same register used as both source and destination
1639 (MICROMIPSOP_*_RS)
1640 "w" 5-bit same register used as both target and destination
1641 (MICROMIPSOP_*_RT)
1642 "y" 5-bit source 3 register for ALNV.PS (MICROMIPSOP_*_RS3)
1643 "z" must be zero register
1644 "C" 23-bit coprocessor function code (MICROMIPSOP_*_COPZ)
1645 "B" 8-bit syscall/wait function code (MICROMIPSOP_*_CODE10)
1646 "K" 5-bit Hardware Register (RDHWR instruction) (MICROMIPSOP_*_RS)
1647
1648 "+A" 5-bit INS/EXT/DINS/DEXT/DINSM/DEXTM position, which becomes
1649 LSB (MICROMIPSOP_*_EXTLSB).
1650 Enforces: 0 <= pos < 32.
1651 "+B" 5-bit INS/DINS size, which becomes MSB (MICROMIPSOP_*_INSMSB).
1652 Requires that "+A" or "+E" occur first to set position.
1653 Enforces: 0 < (pos+size) <= 32.
1654 "+C" 5-bit EXT/DEXT size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
1655 Requires that "+A" or "+E" occur first to set position.
1656 Enforces: 0 < (pos+size) <= 32.
1657 (Also used by DEXT w/ different limits, but limits for
1658 that are checked by the M_DEXT macro.)
1659 "+E" 5-bit DINSU/DEXTU position, which becomes LSB-32 (MICROMIPSOP_*_EXTLSB).
1660 Enforces: 32 <= pos < 64.
1661 "+F" 5-bit DINSM/DINSU size, which becomes MSB-32 (MICROMIPSOP_*_INSMSB).
1662 Requires that "+A" or "+E" occur first to set position.
1663 Enforces: 32 < (pos+size) <= 64.
1664 "+G" 5-bit DEXTM size, which becomes MSBD-32 (MICROMIPSOP_*_EXTMSBD).
1665 Requires that "+A" or "+E" occur first to set position.
1666 Enforces: 32 < (pos+size) <= 64.
1667 "+H" 5-bit DEXTU size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD).
1668 Requires that "+A" or "+E" occur first to set position.
1669 Enforces: 32 < (pos+size) <= 64.
1670
1671 PC-relative addition (ADDIUPC) instruction:
1672 "mQ" 23-bit offset (-4194304 .. 4194303) << 2 (MICROMIPSOP_*_IMMQ)
1673 "mb" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MB) at bit 23
1674
1675 Floating point instructions:
1676 "D" 5-bit destination register (MICROMIPSOP_*_FD)
1677 "M" 3-bit compare condition code (MICROMIPSOP_*_CCC)
1678 "N" 3-bit branch condition code (MICROMIPSOP_*_BCC)
1679 "R" 5-bit fr source 3 register (MICROMIPSOP_*_FR)
1680 "S" 5-bit fs source 1 register (MICROMIPSOP_*_FS)
1681 "T" 5-bit ft source 2 register (MICROMIPSOP_*_FT)
1682 "V" 5-bit same register used as floating source and destination or target
1683 (MICROMIPSOP_*_FS)
1684
1685 Coprocessor instructions:
1686 "E" 5-bit target register (MICROMIPSOP_*_RT)
1687 "G" 5-bit destination register (MICROMIPSOP_*_RD)
1688 "H" 3-bit sel field for (D)MTC* and (D)MFC* (MICROMIPSOP_*_SEL)
1689 "+D" combined destination register ("G") and sel ("H") for CP0 ops,
1690 for pretty-printing in disassembly only
1691
1692 Macro instructions:
1693 "A" general 32 bit expression
1694 "I" 32-bit immediate (value placed in imm_expr).
1695 "+I" 32-bit immediate (value placed in imm2_expr).
1696 "F" 64-bit floating point constant in .rdata
1697 "L" 64-bit floating point constant in .lit8
1698 "f" 32-bit floating point constant
1699 "l" 32-bit floating point constant in .lit4
1700
1701 Other:
1702 "()" parens surrounding optional value
1703 "," separates operands
1704 "+" start of extension sequence
1705 "m" start of microMIPS extension sequence
1706
1707 Characters used so far, for quick reference when adding more:
1708 "1234567890"
1709 "<>(),+.\|~"
1710 "ABCDEFGHI KLMN RST V "
1711 "abcd f hijklmnopqrstuvw yz"
1712
1713 Extension character sequences used so far ("+" followed by the
1714 following), for quick reference when adding more:
1715 ""
1716 ""
1717 "ABCDEFGHI"
1718 ""
1719
1720 Extension character sequences used so far ("m" followed by the
1721 following), for quick reference when adding more:
1722 ""
1723 ""
1724 " BCDEFGHIJ LMNOPQ U WXYZ"
1725 " bcdefghij lmn pq st xyz"
1726 */
1727
1728 extern const struct mips_opcode micromips_opcodes[];
1729 extern const int bfd_micromips_num_opcodes;
1730
1731 /* A NOP insn impemented as "or at,at,zero".
1732 Used to implement -mfix-loongson2f. */
1733 #define LOONGSON2F_NOP_INSN 0x00200825
1734
1735 #endif /* _MIPS_H_ */
This page took 0.067523 seconds and 4 git commands to generate.