include/opcode/
[deliverable/binutils-gdb.git] / include / opcode / mips.h
CommitLineData
252b5132 1/* mips.h. Mips opcode list for GDB, the GNU debugger.
c3aa17e9 2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
c67a084a 3 2003, 2004, 2005, 2008, 2009, 2010
4f1d9bd8 4 Free Software Foundation, Inc.
252b5132
RH
5 Contributed by Ralph Campbell and OSF
6 Commented and modified by Ian Lance Taylor, Cygnus Support
7
e4e42b45 8 This file is part of GDB, GAS, and the GNU binutils.
252b5132 9
e4e42b45
NC
10 GDB, GAS, and the GNU binutils are free software; you can redistribute
11 them and/or modify them under the terms of the GNU General Public
12 License as published by the Free Software Foundation; either version 3,
13 or (at your option) any later version.
252b5132 14
e4e42b45
NC
15 GDB, GAS, and the GNU binutils are distributed in the hope that they
16 will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
18 the GNU General Public License for more details.
252b5132 19
e4e42b45
NC
20 You should have received a copy of the GNU General Public License
21 along with this file; see the file COPYING3. If not, write to the Free
22 Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
23 MA 02110-1301, USA. */
252b5132
RH
24
25#ifndef _MIPS_H_
26#define _MIPS_H_
27
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,
8eaec934 36 of course.
252b5132 37
8eaec934 38 The 'i' format uses OP, RS, RT and IMMEDIATE.
252b5132
RH
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
4372b673
NC
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).
252b5132 57
4372b673 58 The syscall instruction uses CODE20.
252b5132
RH
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
4372b673
NC
90#define OP_MASK_CODE20 0xfffff /* 20 bit syscall/breakpoint code. */
91#define OP_SH_CODE20 6
252b5132
RH
92#define OP_MASK_SHAMT 0x1f
93#define OP_SH_SHAMT 6
94#define OP_MASK_FD 0x1f
95#define OP_SH_FD 6
96#define OP_MASK_TARGET 0x3ffffff
97#define OP_SH_TARGET 0
98#define OP_MASK_COPZ 0x1ffffff
99#define OP_SH_COPZ 0
100#define OP_MASK_IMMEDIATE 0xffff
101#define OP_SH_IMMEDIATE 0
102#define OP_MASK_DELTA 0xffff
103#define OP_SH_DELTA 0
104#define OP_MASK_FUNCT 0x3f
105#define OP_SH_FUNCT 0
106#define OP_MASK_SPEC 0x3f
107#define OP_SH_SPEC 0
4372b673
NC
108#define OP_SH_LOCC 8 /* FP condition code. */
109#define OP_SH_HICC 18 /* FP condition code. */
252b5132 110#define OP_MASK_CC 0x7
4372b673
NC
111#define OP_SH_COP1NORM 25 /* Normal COP1 encoding. */
112#define OP_MASK_COP1NORM 0x1 /* a single bit. */
113#define OP_SH_COP1SPEC 21 /* COP1 encodings. */
252b5132
RH
114#define OP_MASK_COP1SPEC 0xf
115#define OP_MASK_COP1SCLR 0x4
116#define OP_MASK_COP1CMP 0x3
117#define OP_SH_COP1CMP 4
4372b673 118#define OP_SH_FORMAT 21 /* FP short format field. */
252b5132
RH
119#define OP_MASK_FORMAT 0x7
120#define OP_SH_TRUE 16
121#define OP_MASK_TRUE 0x1
122#define OP_SH_GE 17
123#define OP_MASK_GE 0x01
124#define OP_SH_UNSIGNED 16
125#define OP_MASK_UNSIGNED 0x1
126#define OP_SH_HINT 16
127#define OP_MASK_HINT 0x1f
4372b673 128#define OP_SH_MMI 0 /* Multimedia (parallel) op. */
8eaec934 129#define OP_MASK_MMI 0x3f
252b5132
RH
130#define OP_SH_MMISUB 6
131#define OP_MASK_MMISUB 0x1f
4372b673 132#define OP_MASK_PERFREG 0x1f /* Performance monitoring. */
252b5132 133#define OP_SH_PERFREG 1
4372b673
NC
134#define OP_SH_SEL 0 /* Coprocessor select field. */
135#define OP_MASK_SEL 0x7 /* The sel field of mfcZ and mtcZ. */
136#define OP_SH_CODE19 6 /* 19 bit wait code. */
137#define OP_MASK_CODE19 0x7ffff
deec1734
CD
138#define OP_SH_ALN 21
139#define OP_MASK_ALN 0x7
140#define OP_SH_VSEL 21
141#define OP_MASK_VSEL 0x1f
9752cf1b
RS
142#define OP_MASK_VECBYTE 0x7 /* Selector field is really 4 bits,
143 but 0x8-0xf don't select bytes. */
144#define OP_SH_VECBYTE 22
145#define OP_MASK_VECALIGN 0x7 /* Vector byte-align (alni.ob) op. */
146#define OP_SH_VECALIGN 21
af7ee8bf
CD
147#define OP_MASK_INSMSB 0x1f /* "ins" MSB. */
148#define OP_SH_INSMSB 11
149#define OP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */
150#define OP_SH_EXTMSBD 11
deec1734 151
93c34b9b
CF
152/* MIPS DSP ASE */
153#define OP_SH_DSPACC 11
154#define OP_MASK_DSPACC 0x3
155#define OP_SH_DSPACC_S 21
156#define OP_MASK_DSPACC_S 0x3
157#define OP_SH_DSPSFT 20
158#define OP_MASK_DSPSFT 0x3f
159#define OP_SH_DSPSFT_7 19
160#define OP_MASK_DSPSFT_7 0x7f
161#define OP_SH_SA3 21
162#define OP_MASK_SA3 0x7
163#define OP_SH_SA4 21
164#define OP_MASK_SA4 0xf
165#define OP_SH_IMM8 16
166#define OP_MASK_IMM8 0xff
167#define OP_SH_IMM10 16
168#define OP_MASK_IMM10 0x3ff
169#define OP_SH_WRDSP 11
170#define OP_MASK_WRDSP 0x3f
171#define OP_SH_RDDSP 16
172#define OP_MASK_RDDSP 0x3f
8b082fb1
TS
173#define OP_SH_BP 11
174#define OP_MASK_BP 0x3
93c34b9b 175
089b39de
CF
176/* MIPS MT ASE */
177#define OP_SH_MT_U 5
178#define OP_MASK_MT_U 0x1
179#define OP_SH_MT_H 4
180#define OP_MASK_MT_H 0x1
181#define OP_SH_MTACC_T 18
182#define OP_MASK_MTACC_T 0x3
183#define OP_SH_MTACC_D 13
184#define OP_MASK_MTACC_D 0x3
185
640c0ccd
CD
186#define OP_OP_COP0 0x10
187#define OP_OP_COP1 0x11
188#define OP_OP_COP2 0x12
189#define OP_OP_COP3 0x13
190#define OP_OP_LWC1 0x31
191#define OP_OP_LWC2 0x32
192#define OP_OP_LWC3 0x33 /* a.k.a. pref */
193#define OP_OP_LDC1 0x35
194#define OP_OP_LDC2 0x36
195#define OP_OP_LDC3 0x37 /* a.k.a. ld */
196#define OP_OP_SWC1 0x39
197#define OP_OP_SWC2 0x3a
198#define OP_OP_SWC3 0x3b
199#define OP_OP_SDC1 0x3d
200#define OP_OP_SDC2 0x3e
201#define OP_OP_SDC3 0x3f /* a.k.a. sd */
202
deec1734
CD
203/* Values in the 'VSEL' field. */
204#define MDMX_FMTSEL_IMM_QH 0x1d
205#define MDMX_FMTSEL_IMM_OB 0x1e
206#define MDMX_FMTSEL_VEC_QH 0x15
207#define MDMX_FMTSEL_VEC_OB 0x16
4372b673 208
9bcd4f99
TS
209/* UDI */
210#define OP_SH_UDI1 6
211#define OP_MASK_UDI1 0x1f
212#define OP_SH_UDI2 6
213#define OP_MASK_UDI2 0x3ff
214#define OP_SH_UDI3 6
215#define OP_MASK_UDI3 0x7fff
216#define OP_SH_UDI4 6
217#define OP_MASK_UDI4 0xfffff
218
bb35fb24
NC
219/* Octeon */
220#define OP_SH_BBITIND 16
221#define OP_MASK_BBITIND 0x1f
222#define OP_SH_CINSPOS 6
223#define OP_MASK_CINSPOS 0x1f
224#define OP_SH_CINSLM1 11
225#define OP_MASK_CINSLM1 0x1f
dd3cbb7e
NC
226#define OP_SH_SEQI 6
227#define OP_MASK_SEQI 0x3ff
bb35fb24 228
98675402
RS
229/* Loongson */
230#define OP_SH_OFFSET_A 6
231#define OP_MASK_OFFSET_A 0xff
232#define OP_SH_OFFSET_B 3
233#define OP_MASK_OFFSET_B 0xff
234#define OP_SH_OFFSET_C 6
235#define OP_MASK_OFFSET_C 0x1ff
236#define OP_SH_RZ 0
237#define OP_MASK_RZ 0x1f
238#define OP_SH_FZ 0
239#define OP_MASK_FZ 0x1f
240
252b5132
RH
241/* This structure holds information for a particular instruction. */
242
243struct mips_opcode
244{
245 /* The name of the instruction. */
246 const char *name;
247 /* A string describing the arguments for this instruction. */
248 const char *args;
249 /* The basic opcode for the instruction. When assembling, this
250 opcode is modified by the arguments to produce the actual opcode
251 that is used. If pinfo is INSN_MACRO, then this is 0. */
252 unsigned long match;
253 /* If pinfo is not INSN_MACRO, then this is a bit mask for the
254 relevant portions of the opcode when disassembling. If the
255 actual opcode anded with the match field equals the opcode field,
256 then we have found the correct instruction. If pinfo is
257 INSN_MACRO, then this field is the macro identifier. */
258 unsigned long mask;
259 /* For a macro, this is INSN_MACRO. Otherwise, it is a collection
260 of bits describing the instruction, notably any relevant hazard
261 information. */
262 unsigned long pinfo;
dc9a9f39
FF
263 /* A collection of additional bits describing the instruction. */
264 unsigned long pinfo2;
252b5132
RH
265 /* A collection of bits describing the instruction sets of which this
266 instruction or macro is a member. */
267 unsigned long membership;
268};
269
27abff54 270/* These are the characters which may appear in the args field of an
252b5132
RH
271 instruction. They appear in the order in which the fields appear
272 when the instruction is used. Commas and parentheses in the args
273 string are ignored when assembling, and written into the output
274 when disassembling.
275
276 Each of these characters corresponds to a mask field defined above.
277
de9a3e51 278 "1" 5 bit sync type (OP_*_SHAMT)
252b5132
RH
279 "<" 5 bit shift amount (OP_*_SHAMT)
280 ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
281 "a" 26 bit target address (OP_*_TARGET)
282 "b" 5 bit base register (OP_*_RS)
283 "c" 10 bit breakpoint code (OP_*_CODE)
284 "d" 5 bit destination register specifier (OP_*_RD)
285 "h" 5 bit prefx hint (OP_*_PREFX)
286 "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
287 "j" 16 bit signed immediate (OP_*_DELTA)
288 "k" 5 bit cache opcode in target register position (OP_*_CACHE)
9752cf1b 289 Also used for immediate operands in vr5400 vector insns.
252b5132
RH
290 "o" 16 bit signed offset (OP_*_DELTA)
291 "p" 16 bit PC relative branch target address (OP_*_DELTA)
292 "q" 10 bit extra breakpoint code (OP_*_CODE2)
293 "r" 5 bit same register used as both source and target (OP_*_RS)
294 "s" 5 bit source register specifier (OP_*_RS)
295 "t" 5 bit target register (OP_*_RT)
296 "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
297 "v" 5 bit same register used as both source and destination (OP_*_RS)
298 "w" 5 bit same register used as both target and destination (OP_*_RT)
4372b673
NC
299 "U" 5 bit same destination register in both OP_*_RD and OP_*_RT
300 (used by clo and clz)
252b5132 301 "C" 25 bit coprocessor function code (OP_*_COPZ)
4372b673
NC
302 "B" 20 bit syscall/breakpoint function code (OP_*_CODE20)
303 "J" 19 bit wait function code (OP_*_CODE19)
252b5132
RH
304 "x" accept and ignore register name
305 "z" must be zero register
af7ee8bf 306 "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD)
ef0ee844
TS
307 "+A" 5 bit ins/ext/dins/dext/dinsm/dextm position, which becomes
308 LSB (OP_*_SHAMT).
071742cf 309 Enforces: 0 <= pos < 32.
ef0ee844 310 "+B" 5 bit ins/dins size, which becomes MSB (OP_*_INSMSB).
5f74bc13 311 Requires that "+A" or "+E" occur first to set position.
071742cf 312 Enforces: 0 < (pos+size) <= 32.
ef0ee844 313 "+C" 5 bit ext/dext size, which becomes MSBD (OP_*_EXTMSBD).
5f74bc13 314 Requires that "+A" or "+E" occur first to set position.
071742cf 315 Enforces: 0 < (pos+size) <= 32.
5f74bc13
CD
316 (Also used by "dext" w/ different limits, but limits for
317 that are checked by the M_DEXT macro.)
ef0ee844 318 "+E" 5 bit dinsu/dextu position, which becomes LSB-32 (OP_*_SHAMT).
5f74bc13 319 Enforces: 32 <= pos < 64.
ef0ee844 320 "+F" 5 bit "dinsm/dinsu" size, which becomes MSB-32 (OP_*_INSMSB).
5f74bc13
CD
321 Requires that "+A" or "+E" occur first to set position.
322 Enforces: 32 < (pos+size) <= 64.
323 "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD).
324 Requires that "+A" or "+E" occur first to set position.
325 Enforces: 32 < (pos+size) <= 64.
326 "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD).
327 Requires that "+A" or "+E" occur first to set position.
328 Enforces: 32 < (pos+size) <= 64.
252b5132
RH
329
330 Floating point instructions:
331 "D" 5 bit destination register (OP_*_FD)
332 "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
333 "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
334 "S" 5 bit fs source 1 register (OP_*_FS)
335 "T" 5 bit ft source 2 register (OP_*_FT)
336 "R" 5 bit fr source 3 register (OP_*_FR)
337 "V" 5 bit same register used as floating source and destination (OP_*_FS)
338 "W" 5 bit same register used as floating target and destination (OP_*_FT)
339
340 Coprocessor instructions:
341 "E" 5 bit target register (OP_*_RT)
342 "G" 5 bit destination register (OP_*_RD)
8ff529d8 343 "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL)
252b5132 344 "P" 5 bit performance-monitor register (OP_*_PERFREG)
9752cf1b
RS
345 "e" 5 bit vector register byte specifier (OP_*_VECBYTE)
346 "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN)
347 see also "k" above
bbcc0807
CD
348 "+D" Combined destination register ("G") and sel ("H") for CP0 ops,
349 for pretty-printing in disassembly only.
252b5132
RH
350
351 Macro instructions:
352 "A" General 32 bit expression
5f74bc13
CD
353 "I" 32 bit immediate (value placed in imm_expr).
354 "+I" 32 bit immediate (value placed in imm2_expr).
252b5132
RH
355 "F" 64 bit floating point constant in .rdata
356 "L" 64 bit floating point constant in .lit8
357 "f" 32 bit floating point constant
358 "l" 32 bit floating point constant in .lit4
359
deec1734
CD
360 MDMX instruction operands (note that while these use the FP register
361 fields, they accept both $fN and $vN names for the registers):
362 "O" MDMX alignment offset (OP_*_ALN)
363 "Q" MDMX vector/scalar/immediate source (OP_*_VSEL and OP_*_FT)
364 "X" MDMX destination register (OP_*_FD)
365 "Y" MDMX source register (OP_*_FS)
366 "Z" MDMX source register (OP_*_FT)
367
93c34b9b 368 DSP ASE usage:
8b082fb1 369 "2" 2 bit unsigned immediate for byte align (OP_*_BP)
93c34b9b
CF
370 "3" 3 bit unsigned immediate (OP_*_SA3)
371 "4" 4 bit unsigned immediate (OP_*_SA4)
372 "5" 8 bit unsigned immediate (OP_*_IMM8)
373 "6" 5 bit unsigned immediate (OP_*_RS)
374 "7" 2 bit dsp accumulator register (OP_*_DSPACC)
375 "8" 6 bit unsigned immediate (OP_*_WRDSP)
376 "9" 2 bit dsp accumulator register (OP_*_DSPACC_S)
377 "0" 6 bit signed immediate (OP_*_DSPSFT)
378 ":" 7 bit signed immediate (OP_*_DSPSFT_7)
379 "'" 6 bit unsigned immediate (OP_*_RDDSP)
380 "@" 10 bit signed immediate (OP_*_IMM10)
381
089b39de 382 MT ASE usage:
a9e24354
TS
383 "!" 1 bit usermode flag (OP_*_MT_U)
384 "$" 1 bit load high flag (OP_*_MT_H)
089b39de
CF
385 "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T)
386 "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D)
387 "g" 5 bit coprocessor 1 and 2 destination register (OP_*_RD)
388 "+t" 5 bit coprocessor 0 destination register (OP_*_RT)
389 "+T" 5 bit coprocessor 0 destination register (OP_*_RT) - disassembly only
390
9bcd4f99
TS
391 UDI immediates:
392 "+1" UDI immediate bits 6-10
393 "+2" UDI immediate bits 6-15
394 "+3" UDI immediate bits 6-20
395 "+4" UDI immediate bits 6-25
396
bb35fb24
NC
397 Octeon:
398 "+x" Bit index field of bbit. Enforces: 0 <= index < 32.
399 "+X" Bit index field of bbit aliasing bbit32. Matches if 32 <= index < 64,
400 otherwise skips to next candidate.
401 "+p" Position field of cins/cins32/exts/exts32. Enforces 0 <= pos < 32.
402 "+P" Position field of cins/exts aliasing cins32/exts32. Matches if
403 32 <= pos < 64, otherwise skips to next candidate.
dd3cbb7e 404 "+Q" Immediate field of seqi/snei. Enforces -512 <= imm < 512.
bb35fb24
NC
405 "+s" Length-minus-one field of cins/exts. Enforces: 0 <= lenm1 < 32.
406 "+S" Length-minus-one field of cins32/exts32 or cins/exts aliasing
407 cint32/exts32. Enforces non-negative value and that
408 pos + lenm1 < 32 or pos + lenm1 < 64 depending whether previous
409 position field is "+p" or "+P".
410
1bec78e9
RS
411 Loongson-3A:
412 "+a" 8-bit signed offset in bit 6 (OP_*_OFFSET_A)
413 "+b" 8-bit signed offset in bit 3 (OP_*_OFFSET_B)
414 "+c" 9-bit signed offset in bit 6 (OP_*_OFFSET_C)
415 "+z" 5-bit rz register (OP_*_RZ)
416 "+Z" 5-bit fz register (OP_*_FZ)
417
252b5132
RH
418 Other:
419 "()" parens surrounding optional value
420 "," separates operands
9752cf1b 421 "[]" brackets around index for vector-op scalar operand specifier (vr5400)
af7ee8bf 422 "+" Start of extension sequence.
252b5132
RH
423
424 Characters used so far, for quick reference when adding more:
de9a3e51 425 "1234567890"
089b39de 426 "%[]<>(),+:'@!$*&"
af7ee8bf 427 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
089b39de 428 "abcdefghijklopqrstuvwxz"
af7ee8bf
CD
429
430 Extension character sequences used so far ("+" followed by the
431 following), for quick reference when adding more:
9bcd4f99 432 "1234"
1bec78e9
RS
433 "ABCDEFGHIPQSTXZ"
434 "abcpstxz"
252b5132
RH
435*/
436
437/* These are the bits which may be set in the pinfo field of an
438 instructions, if it is not equal to INSN_MACRO. */
439
440/* Modifies the general purpose register in OP_*_RD. */
441#define INSN_WRITE_GPR_D 0x00000001
442/* Modifies the general purpose register in OP_*_RT. */
443#define INSN_WRITE_GPR_T 0x00000002
444/* Modifies general purpose register 31. */
445#define INSN_WRITE_GPR_31 0x00000004
446/* Modifies the floating point register in OP_*_FD. */
447#define INSN_WRITE_FPR_D 0x00000008
448/* Modifies the floating point register in OP_*_FS. */
449#define INSN_WRITE_FPR_S 0x00000010
450/* Modifies the floating point register in OP_*_FT. */
451#define INSN_WRITE_FPR_T 0x00000020
452/* Reads the general purpose register in OP_*_RS. */
453#define INSN_READ_GPR_S 0x00000040
454/* Reads the general purpose register in OP_*_RT. */
455#define INSN_READ_GPR_T 0x00000080
456/* Reads the floating point register in OP_*_FS. */
457#define INSN_READ_FPR_S 0x00000100
458/* Reads the floating point register in OP_*_FT. */
459#define INSN_READ_FPR_T 0x00000200
460/* Reads the floating point register in OP_*_FR. */
461#define INSN_READ_FPR_R 0x00000400
462/* Modifies coprocessor condition code. */
463#define INSN_WRITE_COND_CODE 0x00000800
464/* Reads coprocessor condition code. */
465#define INSN_READ_COND_CODE 0x00001000
466/* TLB operation. */
467#define INSN_TLB 0x00002000
468/* Reads coprocessor register other than floating point register. */
469#define INSN_COP 0x00004000
470/* Instruction loads value from memory, requiring delay. */
471#define INSN_LOAD_MEMORY_DELAY 0x00008000
472/* Instruction loads value from coprocessor, requiring delay. */
473#define INSN_LOAD_COPROC_DELAY 0x00010000
474/* Instruction has unconditional branch delay slot. */
475#define INSN_UNCOND_BRANCH_DELAY 0x00020000
476/* Instruction has conditional branch delay slot. */
477#define INSN_COND_BRANCH_DELAY 0x00040000
478/* Conditional branch likely: if branch not taken, insn nullified. */
479#define INSN_COND_BRANCH_LIKELY 0x00080000
480/* Moves to coprocessor register, requiring delay. */
481#define INSN_COPROC_MOVE_DELAY 0x00100000
482/* Loads coprocessor register from memory, requiring delay. */
483#define INSN_COPROC_MEMORY_DELAY 0x00200000
484/* Reads the HI register. */
485#define INSN_READ_HI 0x00400000
486/* Reads the LO register. */
487#define INSN_READ_LO 0x00800000
488/* Modifies the HI register. */
489#define INSN_WRITE_HI 0x01000000
490/* Modifies the LO register. */
491#define INSN_WRITE_LO 0x02000000
bcd530a7
RS
492/* Not to be placed in a branch delay slot, either architecturally
493 or for ease of handling (such as with instructions that take a trap). */
494#define INSN_NO_DELAY_SLOT 0x04000000
252b5132
RH
495/* Instruction stores value into memory. */
496#define INSN_STORE_MEMORY 0x08000000
497/* Instruction uses single precision floating point. */
498#define FP_S 0x10000000
499/* Instruction uses double precision floating point. */
500#define FP_D 0x20000000
501/* Instruction is part of the tx39's integer multiply family. */
502#define INSN_MULT 0x40000000
d0799671
AN
503/* Instruction is actually a macro. It should be ignored by the
504 disassembler, and requires special treatment by the assembler. */
505#define INSN_MACRO 0xffffffff
dc9a9f39
FF
506
507/* These are the bits which may be set in the pinfo2 field of an
508 instruction. */
509
510/* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */
239cb185 511#define INSN2_ALIAS 0x00000001
dc9a9f39 512/* Instruction reads MDMX accumulator. */
239cb185 513#define INSN2_READ_MDMX_ACC 0x00000002
dc9a9f39 514/* Instruction writes MDMX accumulator. */
239cb185 515#define INSN2_WRITE_MDMX_ACC 0x00000004
d0799671
AN
516/* Macro uses single-precision floating-point instructions. This should
517 only be set for macros. For instructions, FP_S in pinfo carries the
518 same information. */
519#define INSN2_M_FP_S 0x00000008
520/* Macro uses double-precision floating-point instructions. This should
521 only be set for macros. For instructions, FP_D in pinfo carries the
522 same information. */
523#define INSN2_M_FP_D 0x00000010
98675402
RS
524/* Modifies the general purpose register in OP_*_RZ. */
525#define INSN2_WRITE_GPR_Z 0x00000020
526/* Modifies the floating point register in OP_*_FZ. */
527#define INSN2_WRITE_FPR_Z 0x00000040
528/* Reads the general purpose register in OP_*_RZ. */
529#define INSN2_READ_GPR_Z 0x00000080
530/* Reads the floating point register in OP_*_FZ. */
531#define INSN2_READ_FPR_Z 0x00000100
532/* Reads the general purpose register in OP_*_RD. */
533#define INSN2_READ_GPR_D 0x00000200
534
252b5132 535
e7af610e 536/* Masks used to mark instructions to indicate which MIPS ISA level
56950294
MS
537 they were introduced in. INSN_ISA_MASK masks an enumeration that
538 specifies the base ISA level(s). The remainder of a 32-bit
539 word constructed using these macros is a bitmask of the remaining
540 INSN_* values below. */
541
542#define INSN_ISA_MASK 0x0000000ful
543
544/* We cannot start at zero due to ISA_UNKNOWN below. */
545#define INSN_ISA1 1
546#define INSN_ISA2 2
547#define INSN_ISA3 3
548#define INSN_ISA4 4
549#define INSN_ISA5 5
550#define INSN_ISA32 6
551#define INSN_ISA32R2 7
552#define INSN_ISA64 8
553#define INSN_ISA64R2 9
554/* Below this point the INSN_* values correspond to combinations of ISAs.
555 They are only for use in the opcodes table to indicate membership of
556 a combination of ISAs that cannot be expressed using the usual inclusion
557 ordering on the above INSN_* values. */
558#define INSN_ISA3_32 10
559#define INSN_ISA3_32R2 11
560#define INSN_ISA4_32 12
561#define INSN_ISA4_32R2 13
562#define INSN_ISA5_32R2 14
563
564/* Given INSN_ISA* values X and Y, where X ranges over INSN_ISA1 through
565 INSN_ISA5_32R2 and Y ranges over INSN_ISA1 through INSN_ISA64R2,
566 this table describes whether at least one of the ISAs described by X
567 is/are implemented by ISA Y. (Think of Y as the ISA level supported by
568 a particular core and X as the ISA level(s) at which a certain instruction
569 is defined.) The ISA(s) described by X is/are implemented by Y iff
570 (mips_isa_table[(Y & INSN_ISA_MASK) - 1] >> ((X & INSN_ISA_MASK) - 1)) & 1
571 is non-zero. */
572static const unsigned int mips_isa_table[] =
573 { 0x0001, 0x0003, 0x0607, 0x1e0f, 0x3e1f, 0x0a23, 0x3e63, 0x3ebf, 0x3fff };
252b5132 574
e6429699 575/* Masks used for Chip specific instructions. */
d051516a 576#define INSN_CHIP_MASK 0xc3ff0c20
e6429699
AN
577
578/* Cavium Networks Octeon instructions. */
579#define INSN_OCTEON 0x00000800
580
1f25f5d3 581/* Masks used for MIPS-defined ASEs. */
8b082fb1 582#define INSN_ASE_MASK 0x3c00f000
1f25f5d3 583
93c34b9b
CF
584/* DSP ASE */
585#define INSN_DSP 0x00001000
65263ce3 586#define INSN_DSP64 0x00002000
f79e2745
CM
587
588/* 0x00004000 is unused. */
589
1f25f5d3 590/* MIPS-3D ASE */
65263ce3 591#define INSN_MIPS3D 0x00008000
1f25f5d3 592
252b5132 593/* MIPS R4650 instruction. */
e7af610e 594#define INSN_4650 0x00010000
252b5132 595/* LSI R4010 instruction. */
e7af610e
NC
596#define INSN_4010 0x00020000
597/* NEC VR4100 instruction. */
bf40d919 598#define INSN_4100 0x00040000
252b5132 599/* Toshiba R3900 instruction. */
bf40d919 600#define INSN_3900 0x00080000
99c14723
TS
601/* MIPS R10000 instruction. */
602#define INSN_10000 0x00100000
2228315b
CD
603/* Broadcom SB-1 instruction. */
604#define INSN_SB1 0x00200000
9752cf1b
RS
605/* NEC VR4111/VR4181 instruction. */
606#define INSN_4111 0x00400000
607/* NEC VR4120 instruction. */
608#define INSN_4120 0x00800000
609/* NEC VR5400 instruction. */
610#define INSN_5400 0x01000000
611/* NEC VR5500 instruction. */
612#define INSN_5500 0x02000000
39a7806d 613
65263ce3
TS
614/* MDMX ASE */
615#define INSN_MDMX 0x04000000
089b39de 616/* MT ASE */
65263ce3 617#define INSN_MT 0x08000000
8b082fb1 618/* SmartMIPS ASE */
65263ce3 619#define INSN_SMARTMIPS 0x10000000
8b082fb1
TS
620/* DSP R2 ASE */
621#define INSN_DSPR2 0x20000000
350cc38d
MS
622/* ST Microelectronics Loongson 2E. */
623#define INSN_LOONGSON_2E 0x40000000
624/* ST Microelectronics Loongson 2F. */
435b94a4 625#define INSN_LOONGSON_2F 0x80000000
fd503541 626/* Loongson 3A. */
435b94a4 627#define INSN_LOONGSON_3A 0x00000400
52b6b6b9
JM
628/* RMI Xlr instruction */
629#define INSN_XLR 0x00000020
39a7806d 630
e7af610e
NC
631/* MIPS ISA defines, use instead of hardcoding ISA level. */
632
633#define ISA_UNKNOWN 0 /* Gas internal use. */
56950294
MS
634#define ISA_MIPS1 INSN_ISA1
635#define ISA_MIPS2 INSN_ISA2
636#define ISA_MIPS3 INSN_ISA3
637#define ISA_MIPS4 INSN_ISA4
638#define ISA_MIPS5 INSN_ISA5
af7ee8bf 639
56950294
MS
640#define ISA_MIPS32 INSN_ISA32
641#define ISA_MIPS64 INSN_ISA64
367c01af 642
56950294
MS
643#define ISA_MIPS32R2 INSN_ISA32R2
644#define ISA_MIPS64R2 INSN_ISA64R2
5f74bc13 645
af7ee8bf 646
156c2f8b
NC
647/* CPU defines, use instead of hardcoding processor number. Keep this
648 in sync with bfd/archures.c in order for machine selection to work. */
e7af610e 649#define CPU_UNKNOWN 0 /* Gas internal use. */
156c2f8b
NC
650#define CPU_R3000 3000
651#define CPU_R3900 3900
652#define CPU_R4000 4000
653#define CPU_R4010 4010
654#define CPU_VR4100 4100
655#define CPU_R4111 4111
9752cf1b 656#define CPU_VR4120 4120
156c2f8b
NC
657#define CPU_R4300 4300
658#define CPU_R4400 4400
659#define CPU_R4600 4600
660#define CPU_R4650 4650
661#define CPU_R5000 5000
9752cf1b
RS
662#define CPU_VR5400 5400
663#define CPU_VR5500 5500
156c2f8b 664#define CPU_R6000 6000
5a7ea749 665#define CPU_RM7000 7000
156c2f8b 666#define CPU_R8000 8000
98e7aba8 667#define CPU_RM9000 9000
156c2f8b 668#define CPU_R10000 10000
d1cf510e 669#define CPU_R12000 12000
3aa3176b
TS
670#define CPU_R14000 14000
671#define CPU_R16000 16000
156c2f8b
NC
672#define CPU_MIPS16 16
673#define CPU_MIPS32 32
af7ee8bf 674#define CPU_MIPS32R2 33
84ea6cf2
NC
675#define CPU_MIPS5 5
676#define CPU_MIPS64 64
5f74bc13 677#define CPU_MIPS64R2 65
c6c98b38 678#define CPU_SB1 12310201 /* octal 'SB', 01. */
350cc38d
MS
679#define CPU_LOONGSON_2E 3001
680#define CPU_LOONGSON_2F 3002
fd503541 681#define CPU_LOONGSON_3A 3003
e6429699 682#define CPU_OCTEON 6501
52b6b6b9 683#define CPU_XLR 887682 /* decimal 'XLR' */
156c2f8b 684
1f25f5d3
CD
685/* Test for membership in an ISA including chip specific ISAs. INSN
686 is pointer to an element of the opcode table; ISA is the specified
687 ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
688 test, or zero if no CPU specific ISA test is desired. */
a58ec95a
RS
689
690#define OPCODE_IS_MEMBER(insn, isa, cpu) \
56950294
MS
691 (((isa & INSN_ISA_MASK) != 0 \
692 && ((insn)->membership & INSN_ISA_MASK) != 0 \
693 && ((mips_isa_table [(isa & INSN_ISA_MASK) - 1] >> \
694 (((insn)->membership & INSN_ISA_MASK) - 1)) & 1) != 0) \
695 || ((isa & ~INSN_ISA_MASK) \
696 & ((insn)->membership & ~INSN_ISA_MASK)) != 0 \
156c2f8b 697 || (cpu == CPU_R4650 && ((insn)->membership & INSN_4650) != 0) \
5a7ea749 698 || (cpu == CPU_RM7000 && ((insn)->membership & INSN_4650) != 0) \
98e7aba8 699 || (cpu == CPU_RM9000 && ((insn)->membership & INSN_4650) != 0) \
156c2f8b 700 || (cpu == CPU_R4010 && ((insn)->membership & INSN_4010) != 0) \
9752cf1b 701 || (cpu == CPU_VR4100 && ((insn)->membership & INSN_4100) != 0) \
99c14723 702 || (cpu == CPU_R3900 && ((insn)->membership & INSN_3900) != 0) \
3aa3176b
TS
703 || ((cpu == CPU_R10000 || cpu == CPU_R12000 || cpu == CPU_R14000 \
704 || cpu == CPU_R16000) \
2228315b 705 && ((insn)->membership & INSN_10000) != 0) \
5d84d93f 706 || (cpu == CPU_SB1 && ((insn)->membership & INSN_SB1) != 0) \
9752cf1b
RS
707 || (cpu == CPU_R4111 && ((insn)->membership & INSN_4111) != 0) \
708 || (cpu == CPU_VR4120 && ((insn)->membership & INSN_4120) != 0) \
709 || (cpu == CPU_VR5400 && ((insn)->membership & INSN_5400) != 0) \
710 || (cpu == CPU_VR5500 && ((insn)->membership & INSN_5500) != 0) \
350cc38d
MS
711 || (cpu == CPU_LOONGSON_2E \
712 && ((insn)->membership & INSN_LOONGSON_2E) != 0) \
713 || (cpu == CPU_LOONGSON_2F \
714 && ((insn)->membership & INSN_LOONGSON_2F) != 0) \
fd503541
NC
715 || (cpu == CPU_LOONGSON_3A \
716 && ((insn)->membership & INSN_LOONGSON_3A) != 0) \
e6429699
AN
717 || (cpu == CPU_OCTEON \
718 && ((insn)->membership & INSN_OCTEON) != 0) \
52b6b6b9 719 || (cpu == CPU_XLR && ((insn)->membership & INSN_XLR) != 0) \
e4432525 720 || 0) /* Please keep this term for easier source merging. */
252b5132
RH
721
722/* This is a list of macro expanded instructions.
8eaec934 723
e7af610e
NC
724 _I appended means immediate
725 _A appended means address
726 _AB appended means address with base register
727 _D appended means 64 bit floating point constant
728 _S appended means 32 bit floating point constant. */
729
730enum
731{
732 M_ABS,
733 M_ADD_I,
734 M_ADDU_I,
735 M_AND_I,
8b082fb1 736 M_BALIGN,
e7af610e
NC
737 M_BEQ,
738 M_BEQ_I,
739 M_BEQL_I,
740 M_BGE,
741 M_BGEL,
742 M_BGE_I,
743 M_BGEL_I,
744 M_BGEU,
745 M_BGEUL,
746 M_BGEU_I,
747 M_BGEUL_I,
748 M_BGT,
749 M_BGTL,
750 M_BGT_I,
751 M_BGTL_I,
752 M_BGTU,
753 M_BGTUL,
754 M_BGTU_I,
755 M_BGTUL_I,
756 M_BLE,
757 M_BLEL,
758 M_BLE_I,
759 M_BLEL_I,
760 M_BLEU,
761 M_BLEUL,
762 M_BLEU_I,
763 M_BLEUL_I,
764 M_BLT,
765 M_BLTL,
766 M_BLT_I,
767 M_BLTL_I,
768 M_BLTU,
769 M_BLTUL,
770 M_BLTU_I,
771 M_BLTUL_I,
772 M_BNE,
773 M_BNE_I,
774 M_BNEL_I,
d43b4baf 775 M_CACHE_AB,
e7af610e
NC
776 M_DABS,
777 M_DADD_I,
778 M_DADDU_I,
779 M_DDIV_3,
780 M_DDIV_3I,
781 M_DDIVU_3,
782 M_DDIVU_3I,
5f74bc13
CD
783 M_DEXT,
784 M_DINS,
e7af610e
NC
785 M_DIV_3,
786 M_DIV_3I,
787 M_DIVU_3,
788 M_DIVU_3I,
789 M_DLA_AB,
1abe91b1 790 M_DLCA_AB,
e7af610e
NC
791 M_DLI,
792 M_DMUL,
8eaec934 793 M_DMUL_I,
e7af610e 794 M_DMULO,
8eaec934 795 M_DMULO_I,
e7af610e 796 M_DMULOU,
8eaec934 797 M_DMULOU_I,
e7af610e
NC
798 M_DREM_3,
799 M_DREM_3I,
800 M_DREMU_3,
801 M_DREMU_3I,
802 M_DSUB_I,
803 M_DSUBU_I,
804 M_DSUBU_I_2,
805 M_J_A,
806 M_JAL_1,
807 M_JAL_2,
808 M_JAL_A,
809 M_L_DOB,
810 M_L_DAB,
811 M_LA_AB,
812 M_LB_A,
813 M_LB_AB,
814 M_LBU_A,
815 M_LBU_AB,
1abe91b1 816 M_LCA_AB,
e7af610e
NC
817 M_LD_A,
818 M_LD_OB,
819 M_LD_AB,
820 M_LDC1_AB,
821 M_LDC2_AB,
822 M_LDC3_AB,
823 M_LDL_AB,
824 M_LDR_AB,
825 M_LH_A,
826 M_LH_AB,
827 M_LHU_A,
828 M_LHU_AB,
829 M_LI,
830 M_LI_D,
831 M_LI_DD,
832 M_LI_S,
833 M_LI_SS,
834 M_LL_AB,
835 M_LLD_AB,
836 M_LS_A,
837 M_LW_A,
838 M_LW_AB,
839 M_LWC0_A,
840 M_LWC0_AB,
841 M_LWC1_A,
842 M_LWC1_AB,
843 M_LWC2_A,
844 M_LWC2_AB,
845 M_LWC3_A,
846 M_LWC3_AB,
847 M_LWL_A,
848 M_LWL_AB,
849 M_LWR_A,
850 M_LWR_AB,
851 M_LWU_AB,
52b6b6b9
JM
852 M_MSGSND,
853 M_MSGLD,
854 M_MSGLD_T,
855 M_MSGWAIT,
856 M_MSGWAIT_T,
a58ec95a 857 M_MOVE,
e7af610e 858 M_MUL,
8eaec934 859 M_MUL_I,
e7af610e 860 M_MULO,
8eaec934 861 M_MULO_I,
e7af610e 862 M_MULOU,
8eaec934 863 M_MULOU_I,
e7af610e
NC
864 M_NOR_I,
865 M_OR_I,
3eebd5eb 866 M_PREF_AB,
e7af610e
NC
867 M_REM_3,
868 M_REM_3I,
869 M_REMU_3,
870 M_REMU_3I,
771c7ce4 871 M_DROL,
e7af610e 872 M_ROL,
771c7ce4 873 M_DROL_I,
e7af610e 874 M_ROL_I,
771c7ce4 875 M_DROR,
e7af610e 876 M_ROR,
771c7ce4 877 M_DROR_I,
e7af610e
NC
878 M_ROR_I,
879 M_S_DA,
880 M_S_DOB,
881 M_S_DAB,
882 M_S_S,
883 M_SC_AB,
884 M_SCD_AB,
885 M_SD_A,
886 M_SD_OB,
887 M_SD_AB,
888 M_SDC1_AB,
889 M_SDC2_AB,
890 M_SDC3_AB,
891 M_SDL_AB,
892 M_SDR_AB,
893 M_SEQ,
894 M_SEQ_I,
895 M_SGE,
896 M_SGE_I,
897 M_SGEU,
898 M_SGEU_I,
899 M_SGT,
900 M_SGT_I,
901 M_SGTU,
902 M_SGTU_I,
903 M_SLE,
904 M_SLE_I,
905 M_SLEU,
906 M_SLEU_I,
907 M_SLT_I,
908 M_SLTU_I,
909 M_SNE,
910 M_SNE_I,
911 M_SB_A,
912 M_SB_AB,
913 M_SH_A,
914 M_SH_AB,
915 M_SW_A,
916 M_SW_AB,
917 M_SWC0_A,
918 M_SWC0_AB,
919 M_SWC1_A,
920 M_SWC1_AB,
921 M_SWC2_A,
922 M_SWC2_AB,
923 M_SWC3_A,
924 M_SWC3_AB,
925 M_SWL_A,
926 M_SWL_AB,
927 M_SWR_A,
928 M_SWR_AB,
929 M_SUB_I,
930 M_SUBU_I,
931 M_SUBU_I_2,
932 M_TEQ_I,
933 M_TGE_I,
934 M_TGEU_I,
935 M_TLT_I,
936 M_TLTU_I,
937 M_TNE_I,
938 M_TRUNCWD,
939 M_TRUNCWS,
940 M_ULD,
941 M_ULD_A,
942 M_ULH,
943 M_ULH_A,
944 M_ULHU,
945 M_ULHU_A,
946 M_ULW,
947 M_ULW_A,
948 M_USH,
949 M_USH_A,
950 M_USW,
951 M_USW_A,
952 M_USD,
953 M_USD_A,
954 M_XOR_I,
955 M_COP0,
956 M_COP1,
957 M_COP2,
958 M_COP3,
959 M_NUM_MACROS
252b5132
RH
960};
961
962
963/* The order of overloaded instructions matters. Label arguments and
964 register arguments look the same. Instructions that can have either
965 for arguments must apear in the correct order in this table for the
966 assembler to pick the right one. In other words, entries with
967 immediate operands must apear after the same instruction with
968 registers.
969
970 Many instructions are short hand for other instructions (i.e., The
971 jal <register> instruction is short for jalr <register>). */
972
973extern const struct mips_opcode mips_builtin_opcodes[];
974extern const int bfd_mips_num_builtin_opcodes;
975extern struct mips_opcode *mips_opcodes;
976extern int bfd_mips_num_opcodes;
977#define NUMOPCODES bfd_mips_num_opcodes
978
979\f
980/* The rest of this file adds definitions for the mips16 TinyRISC
981 processor. */
982
983/* These are the bitmasks and shift counts used for the different
984 fields in the instruction formats. Other than OP, no masks are
985 provided for the fixed portions of an instruction, since they are
986 not needed.
987
988 The I format uses IMM11.
989
990 The RI format uses RX and IMM8.
991
992 The RR format uses RX, and RY.
993
994 The RRI format uses RX, RY, and IMM5.
995
996 The RRR format uses RX, RY, and RZ.
997
998 The RRI_A format uses RX, RY, and IMM4.
999
1000 The SHIFT format uses RX, RY, and SHAMT.
1001
1002 The I8 format uses IMM8.
1003
1004 The I8_MOVR32 format uses RY and REGR32.
1005
1006 The IR_MOV32R format uses REG32R and MOV32Z.
1007
1008 The I64 format uses IMM8.
1009
1010 The RI64 format uses RY and IMM5.
1011 */
1012
1013#define MIPS16OP_MASK_OP 0x1f
1014#define MIPS16OP_SH_OP 11
1015#define MIPS16OP_MASK_IMM11 0x7ff
1016#define MIPS16OP_SH_IMM11 0
1017#define MIPS16OP_MASK_RX 0x7
1018#define MIPS16OP_SH_RX 8
1019#define MIPS16OP_MASK_IMM8 0xff
1020#define MIPS16OP_SH_IMM8 0
1021#define MIPS16OP_MASK_RY 0x7
1022#define MIPS16OP_SH_RY 5
1023#define MIPS16OP_MASK_IMM5 0x1f
1024#define MIPS16OP_SH_IMM5 0
1025#define MIPS16OP_MASK_RZ 0x7
1026#define MIPS16OP_SH_RZ 2
1027#define MIPS16OP_MASK_IMM4 0xf
1028#define MIPS16OP_SH_IMM4 0
1029#define MIPS16OP_MASK_REGR32 0x1f
1030#define MIPS16OP_SH_REGR32 0
1031#define MIPS16OP_MASK_REG32R 0x1f
1032#define MIPS16OP_SH_REG32R 3
1033#define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
1034#define MIPS16OP_MASK_MOVE32Z 0x7
1035#define MIPS16OP_SH_MOVE32Z 0
1036#define MIPS16OP_MASK_IMM6 0x3f
1037#define MIPS16OP_SH_IMM6 5
1038
bb35fb24
NC
1039/* These are the characters which may appears in the args field of a MIPS16
1040 instruction. They appear in the order in which the fields appear when the
1041 instruction is used. Commas and parentheses in the args string are ignored
1042 when assembling, and written into the output when disassembling.
252b5132
RH
1043
1044 "y" 3 bit register (MIPS16OP_*_RY)
1045 "x" 3 bit register (MIPS16OP_*_RX)
1046 "z" 3 bit register (MIPS16OP_*_RZ)
1047 "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
1048 "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
1049 "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
1050 "0" zero register ($0)
1051 "S" stack pointer ($sp or $29)
1052 "P" program counter
1053 "R" return address register ($ra or $31)
1054 "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
1055 "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
1056 "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
1057 "a" 26 bit jump address
1058 "e" 11 bit extension value
1059 "l" register list for entry instruction
1060 "L" register list for exit instruction
1061
1062 The remaining codes may be extended. Except as otherwise noted,
1063 the full extended operand is a 16 bit signed value.
1064 "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
1065 ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned)
1066 "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
1067 "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
1068 "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
1069 "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
1070 "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
1071 "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
1072 "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
1073 "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
1074 "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
1075 "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
1076 "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
1077 "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
1078 "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
1079 "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
1080 "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
1081 "q" 11 bit branch address (MIPS16OP_*_IMM11)
1082 "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
1083 "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
1084 "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
0499d65b
TS
1085 "m" 7 bit register list for save instruction (18 bit extended)
1086 "M" 7 bit register list for restore instruction (18 bit extended)
1087 */
1088
1089/* Save/restore encoding for the args field when all 4 registers are
1090 either saved as arguments or saved/restored as statics. */
1091#define MIPS16_ALL_ARGS 0xe
1092#define MIPS16_ALL_STATICS 0xb
252b5132
RH
1093
1094/* For the mips16, we use the same opcode table format and a few of
1095 the same flags. However, most of the flags are different. */
1096
1097/* Modifies the register in MIPS16OP_*_RX. */
1098#define MIPS16_INSN_WRITE_X 0x00000001
1099/* Modifies the register in MIPS16OP_*_RY. */
1100#define MIPS16_INSN_WRITE_Y 0x00000002
1101/* Modifies the register in MIPS16OP_*_RZ. */
1102#define MIPS16_INSN_WRITE_Z 0x00000004
1103/* Modifies the T ($24) register. */
1104#define MIPS16_INSN_WRITE_T 0x00000008
1105/* Modifies the SP ($29) register. */
1106#define MIPS16_INSN_WRITE_SP 0x00000010
1107/* Modifies the RA ($31) register. */
1108#define MIPS16_INSN_WRITE_31 0x00000020
1109/* Modifies the general purpose register in MIPS16OP_*_REG32R. */
1110#define MIPS16_INSN_WRITE_GPR_Y 0x00000040
1111/* Reads the register in MIPS16OP_*_RX. */
1112#define MIPS16_INSN_READ_X 0x00000080
1113/* Reads the register in MIPS16OP_*_RY. */
1114#define MIPS16_INSN_READ_Y 0x00000100
1115/* Reads the register in MIPS16OP_*_MOVE32Z. */
1116#define MIPS16_INSN_READ_Z 0x00000200
1117/* Reads the T ($24) register. */
1118#define MIPS16_INSN_READ_T 0x00000400
1119/* Reads the SP ($29) register. */
1120#define MIPS16_INSN_READ_SP 0x00000800
1121/* Reads the RA ($31) register. */
1122#define MIPS16_INSN_READ_31 0x00001000
1123/* Reads the program counter. */
1124#define MIPS16_INSN_READ_PC 0x00002000
1125/* Reads the general purpose register in MIPS16OP_*_REGR32. */
1126#define MIPS16_INSN_READ_GPR_X 0x00004000
9a2c7088
MR
1127/* Is an unconditional branch insn. */
1128#define MIPS16_INSN_UNCOND_BRANCH 0x00008000
1129/* Is a conditional branch insn. */
1130#define MIPS16_INSN_COND_BRANCH 0x00010000
252b5132
RH
1131
1132/* The following flags have the same value for the mips16 opcode
1133 table:
1134 INSN_UNCOND_BRANCH_DELAY
1135 INSN_COND_BRANCH_DELAY
1136 INSN_COND_BRANCH_LIKELY (never used)
1137 INSN_READ_HI
1138 INSN_READ_LO
1139 INSN_WRITE_HI
1140 INSN_WRITE_LO
1141 INSN_TRAP
1142 INSN_ISA3
1143 */
1144
1145extern const struct mips_opcode mips16_opcodes[];
1146extern const int bfd_mips16_num_opcodes;
1147
c67a084a
NC
1148/* A NOP insn impemented as "or at,at,zero".
1149 Used to implement -mfix-loongson2f. */
1150#define LOONGSON2F_NOP_INSN 0x00200825
1151
252b5132 1152#endif /* _MIPS_H_ */
This page took 0.59761 seconds and 4 git commands to generate.