]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - include/opcode/mips.h
objc-exp.y (parse_number): Cast sscanf arguments to proper type.
[thirdparty/binutils-gdb.git] / include / opcode / mips.h
CommitLineData
252b5132 1/* mips.h. Mips opcode list for GDB, the GNU debugger.
4f1d9bd8
NC
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
252b5132
RH
4 Contributed by Ralph Campbell and OSF
5 Commented and modified by Ian Lance Taylor, Cygnus Support
6
7This file is part of GDB, GAS, and the GNU binutils.
8
9GDB, GAS, and the GNU binutils are free software; you can redistribute
10them and/or modify them under the terms of the GNU General Public
11License as published by the Free Software Foundation; either version
121, or (at your option) any later version.
13
14GDB, GAS, and the GNU binutils are distributed in the hope that they
15will be useful, but WITHOUT ANY WARRANTY; without even the implied
16warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this file; see the file COPYING. If not, write to the Free
21Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23#ifndef _MIPS_H_
24#define _MIPS_H_
25
26/* These are bit masks and shift counts to use to access the various
27 fields of an instruction. To retrieve the X field of an
28 instruction, use the expression
29 (i >> OP_SH_X) & OP_MASK_X
30 To set the same field (to j), use
31 i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X)
32
33 Make sure you use fields that are appropriate for the instruction,
8eaec934 34 of course.
252b5132 35
8eaec934 36 The 'i' format uses OP, RS, RT and IMMEDIATE.
252b5132
RH
37
38 The 'j' format uses OP and TARGET.
39
40 The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT.
41
42 The 'b' format uses OP, RS, RT and DELTA.
43
44 The floating point 'i' format uses OP, RS, RT and IMMEDIATE.
45
46 The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT.
47
48 A breakpoint instruction uses OP, CODE and SPEC (10 bits of the
49 breakpoint instruction are not defined; Kane says the breakpoint
50 code field in BREAK is 20 bits; yet MIPS assemblers and debuggers
51 only use ten bits). An optional two-operand form of break/sdbbp
4372b673
NC
52 allows the lower ten bits to be set too, and MIPS32 and later
53 architectures allow 20 bits to be set with a signal operand
54 (using CODE20).
252b5132 55
4372b673 56 The syscall instruction uses CODE20.
252b5132
RH
57
58 The general coprocessor instructions use COPZ. */
59
60#define OP_MASK_OP 0x3f
61#define OP_SH_OP 26
62#define OP_MASK_RS 0x1f
63#define OP_SH_RS 21
64#define OP_MASK_FR 0x1f
65#define OP_SH_FR 21
66#define OP_MASK_FMT 0x1f
67#define OP_SH_FMT 21
68#define OP_MASK_BCC 0x7
69#define OP_SH_BCC 18
70#define OP_MASK_CODE 0x3ff
71#define OP_SH_CODE 16
72#define OP_MASK_CODE2 0x3ff
73#define OP_SH_CODE2 6
74#define OP_MASK_RT 0x1f
75#define OP_SH_RT 16
76#define OP_MASK_FT 0x1f
77#define OP_SH_FT 16
78#define OP_MASK_CACHE 0x1f
79#define OP_SH_CACHE 16
80#define OP_MASK_RD 0x1f
81#define OP_SH_RD 11
82#define OP_MASK_FS 0x1f
83#define OP_SH_FS 11
84#define OP_MASK_PREFX 0x1f
85#define OP_SH_PREFX 11
86#define OP_MASK_CCC 0x7
87#define OP_SH_CCC 8
4372b673
NC
88#define OP_MASK_CODE20 0xfffff /* 20 bit syscall/breakpoint code. */
89#define OP_SH_CODE20 6
252b5132
RH
90#define OP_MASK_SHAMT 0x1f
91#define OP_SH_SHAMT 6
92#define OP_MASK_FD 0x1f
93#define OP_SH_FD 6
94#define OP_MASK_TARGET 0x3ffffff
95#define OP_SH_TARGET 0
96#define OP_MASK_COPZ 0x1ffffff
97#define OP_SH_COPZ 0
98#define OP_MASK_IMMEDIATE 0xffff
99#define OP_SH_IMMEDIATE 0
100#define OP_MASK_DELTA 0xffff
101#define OP_SH_DELTA 0
102#define OP_MASK_FUNCT 0x3f
103#define OP_SH_FUNCT 0
104#define OP_MASK_SPEC 0x3f
105#define OP_SH_SPEC 0
4372b673
NC
106#define OP_SH_LOCC 8 /* FP condition code. */
107#define OP_SH_HICC 18 /* FP condition code. */
252b5132 108#define OP_MASK_CC 0x7
4372b673
NC
109#define OP_SH_COP1NORM 25 /* Normal COP1 encoding. */
110#define OP_MASK_COP1NORM 0x1 /* a single bit. */
111#define OP_SH_COP1SPEC 21 /* COP1 encodings. */
252b5132
RH
112#define OP_MASK_COP1SPEC 0xf
113#define OP_MASK_COP1SCLR 0x4
114#define OP_MASK_COP1CMP 0x3
115#define OP_SH_COP1CMP 4
4372b673 116#define OP_SH_FORMAT 21 /* FP short format field. */
252b5132
RH
117#define OP_MASK_FORMAT 0x7
118#define OP_SH_TRUE 16
119#define OP_MASK_TRUE 0x1
120#define OP_SH_GE 17
121#define OP_MASK_GE 0x01
122#define OP_SH_UNSIGNED 16
123#define OP_MASK_UNSIGNED 0x1
124#define OP_SH_HINT 16
125#define OP_MASK_HINT 0x1f
4372b673 126#define OP_SH_MMI 0 /* Multimedia (parallel) op. */
8eaec934 127#define OP_MASK_MMI 0x3f
252b5132
RH
128#define OP_SH_MMISUB 6
129#define OP_MASK_MMISUB 0x1f
4372b673 130#define OP_MASK_PERFREG 0x1f /* Performance monitoring. */
252b5132 131#define OP_SH_PERFREG 1
4372b673
NC
132#define OP_SH_SEL 0 /* Coprocessor select field. */
133#define OP_MASK_SEL 0x7 /* The sel field of mfcZ and mtcZ. */
134#define OP_SH_CODE19 6 /* 19 bit wait code. */
135#define OP_MASK_CODE19 0x7ffff
deec1734
CD
136#define OP_SH_ALN 21
137#define OP_MASK_ALN 0x7
138#define OP_SH_VSEL 21
139#define OP_MASK_VSEL 0x1f
9752cf1b
RS
140#define OP_MASK_VECBYTE 0x7 /* Selector field is really 4 bits,
141 but 0x8-0xf don't select bytes. */
142#define OP_SH_VECBYTE 22
143#define OP_MASK_VECALIGN 0x7 /* Vector byte-align (alni.ob) op. */
144#define OP_SH_VECALIGN 21
deec1734 145
640c0ccd
CD
146#define OP_OP_COP0 0x10
147#define OP_OP_COP1 0x11
148#define OP_OP_COP2 0x12
149#define OP_OP_COP3 0x13
150#define OP_OP_LWC1 0x31
151#define OP_OP_LWC2 0x32
152#define OP_OP_LWC3 0x33 /* a.k.a. pref */
153#define OP_OP_LDC1 0x35
154#define OP_OP_LDC2 0x36
155#define OP_OP_LDC3 0x37 /* a.k.a. ld */
156#define OP_OP_SWC1 0x39
157#define OP_OP_SWC2 0x3a
158#define OP_OP_SWC3 0x3b
159#define OP_OP_SDC1 0x3d
160#define OP_OP_SDC2 0x3e
161#define OP_OP_SDC3 0x3f /* a.k.a. sd */
162
deec1734
CD
163/* Values in the 'VSEL' field. */
164#define MDMX_FMTSEL_IMM_QH 0x1d
165#define MDMX_FMTSEL_IMM_OB 0x1e
166#define MDMX_FMTSEL_VEC_QH 0x15
167#define MDMX_FMTSEL_VEC_OB 0x16
4372b673 168
252b5132
RH
169/* This structure holds information for a particular instruction. */
170
171struct mips_opcode
172{
173 /* The name of the instruction. */
174 const char *name;
175 /* A string describing the arguments for this instruction. */
176 const char *args;
177 /* The basic opcode for the instruction. When assembling, this
178 opcode is modified by the arguments to produce the actual opcode
179 that is used. If pinfo is INSN_MACRO, then this is 0. */
180 unsigned long match;
181 /* If pinfo is not INSN_MACRO, then this is a bit mask for the
182 relevant portions of the opcode when disassembling. If the
183 actual opcode anded with the match field equals the opcode field,
184 then we have found the correct instruction. If pinfo is
185 INSN_MACRO, then this field is the macro identifier. */
186 unsigned long mask;
187 /* For a macro, this is INSN_MACRO. Otherwise, it is a collection
188 of bits describing the instruction, notably any relevant hazard
189 information. */
190 unsigned long pinfo;
191 /* A collection of bits describing the instruction sets of which this
192 instruction or macro is a member. */
193 unsigned long membership;
194};
195
196/* These are the characters which may appears in the args field of an
197 instruction. They appear in the order in which the fields appear
198 when the instruction is used. Commas and parentheses in the args
199 string are ignored when assembling, and written into the output
200 when disassembling.
201
202 Each of these characters corresponds to a mask field defined above.
203
204 "<" 5 bit shift amount (OP_*_SHAMT)
205 ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT)
206 "a" 26 bit target address (OP_*_TARGET)
207 "b" 5 bit base register (OP_*_RS)
208 "c" 10 bit breakpoint code (OP_*_CODE)
209 "d" 5 bit destination register specifier (OP_*_RD)
210 "h" 5 bit prefx hint (OP_*_PREFX)
211 "i" 16 bit unsigned immediate (OP_*_IMMEDIATE)
212 "j" 16 bit signed immediate (OP_*_DELTA)
213 "k" 5 bit cache opcode in target register position (OP_*_CACHE)
9752cf1b 214 Also used for immediate operands in vr5400 vector insns.
252b5132
RH
215 "o" 16 bit signed offset (OP_*_DELTA)
216 "p" 16 bit PC relative branch target address (OP_*_DELTA)
217 "q" 10 bit extra breakpoint code (OP_*_CODE2)
218 "r" 5 bit same register used as both source and target (OP_*_RS)
219 "s" 5 bit source register specifier (OP_*_RS)
220 "t" 5 bit target register (OP_*_RT)
221 "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE)
222 "v" 5 bit same register used as both source and destination (OP_*_RS)
223 "w" 5 bit same register used as both target and destination (OP_*_RT)
4372b673
NC
224 "U" 5 bit same destination register in both OP_*_RD and OP_*_RT
225 (used by clo and clz)
252b5132 226 "C" 25 bit coprocessor function code (OP_*_COPZ)
4372b673
NC
227 "B" 20 bit syscall/breakpoint function code (OP_*_CODE20)
228 "J" 19 bit wait function code (OP_*_CODE19)
252b5132
RH
229 "x" accept and ignore register name
230 "z" must be zero register
231
232 Floating point instructions:
233 "D" 5 bit destination register (OP_*_FD)
234 "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up)
235 "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up)
236 "S" 5 bit fs source 1 register (OP_*_FS)
237 "T" 5 bit ft source 2 register (OP_*_FT)
238 "R" 5 bit fr source 3 register (OP_*_FR)
239 "V" 5 bit same register used as floating source and destination (OP_*_FS)
240 "W" 5 bit same register used as floating target and destination (OP_*_FT)
241
242 Coprocessor instructions:
243 "E" 5 bit target register (OP_*_RT)
244 "G" 5 bit destination register (OP_*_RD)
8ff529d8 245 "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL)
252b5132 246 "P" 5 bit performance-monitor register (OP_*_PERFREG)
9752cf1b
RS
247 "e" 5 bit vector register byte specifier (OP_*_VECBYTE)
248 "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN)
249 see also "k" above
252b5132
RH
250
251 Macro instructions:
252 "A" General 32 bit expression
253 "I" 32 bit immediate
254 "F" 64 bit floating point constant in .rdata
255 "L" 64 bit floating point constant in .lit8
256 "f" 32 bit floating point constant
257 "l" 32 bit floating point constant in .lit4
258
deec1734
CD
259 MDMX instruction operands (note that while these use the FP register
260 fields, they accept both $fN and $vN names for the registers):
261 "O" MDMX alignment offset (OP_*_ALN)
262 "Q" MDMX vector/scalar/immediate source (OP_*_VSEL and OP_*_FT)
263 "X" MDMX destination register (OP_*_FD)
264 "Y" MDMX source register (OP_*_FS)
265 "Z" MDMX source register (OP_*_FT)
266
252b5132
RH
267 Other:
268 "()" parens surrounding optional value
269 "," separates operands
9752cf1b 270 "[]" brackets around index for vector-op scalar operand specifier (vr5400)
252b5132
RH
271
272 Characters used so far, for quick reference when adding more:
9752cf1b 273 "%[]<>(),"
deec1734 274 "ABCDEFGHIJLMNOPQRSTUVWXYZ"
9752cf1b 275 "abcdefhijklopqrstuvwxz"
252b5132
RH
276*/
277
278/* These are the bits which may be set in the pinfo field of an
279 instructions, if it is not equal to INSN_MACRO. */
280
281/* Modifies the general purpose register in OP_*_RD. */
282#define INSN_WRITE_GPR_D 0x00000001
283/* Modifies the general purpose register in OP_*_RT. */
284#define INSN_WRITE_GPR_T 0x00000002
285/* Modifies general purpose register 31. */
286#define INSN_WRITE_GPR_31 0x00000004
287/* Modifies the floating point register in OP_*_FD. */
288#define INSN_WRITE_FPR_D 0x00000008
289/* Modifies the floating point register in OP_*_FS. */
290#define INSN_WRITE_FPR_S 0x00000010
291/* Modifies the floating point register in OP_*_FT. */
292#define INSN_WRITE_FPR_T 0x00000020
293/* Reads the general purpose register in OP_*_RS. */
294#define INSN_READ_GPR_S 0x00000040
295/* Reads the general purpose register in OP_*_RT. */
296#define INSN_READ_GPR_T 0x00000080
297/* Reads the floating point register in OP_*_FS. */
298#define INSN_READ_FPR_S 0x00000100
299/* Reads the floating point register in OP_*_FT. */
300#define INSN_READ_FPR_T 0x00000200
301/* Reads the floating point register in OP_*_FR. */
302#define INSN_READ_FPR_R 0x00000400
303/* Modifies coprocessor condition code. */
304#define INSN_WRITE_COND_CODE 0x00000800
305/* Reads coprocessor condition code. */
306#define INSN_READ_COND_CODE 0x00001000
307/* TLB operation. */
308#define INSN_TLB 0x00002000
309/* Reads coprocessor register other than floating point register. */
310#define INSN_COP 0x00004000
311/* Instruction loads value from memory, requiring delay. */
312#define INSN_LOAD_MEMORY_DELAY 0x00008000
313/* Instruction loads value from coprocessor, requiring delay. */
314#define INSN_LOAD_COPROC_DELAY 0x00010000
315/* Instruction has unconditional branch delay slot. */
316#define INSN_UNCOND_BRANCH_DELAY 0x00020000
317/* Instruction has conditional branch delay slot. */
318#define INSN_COND_BRANCH_DELAY 0x00040000
319/* Conditional branch likely: if branch not taken, insn nullified. */
320#define INSN_COND_BRANCH_LIKELY 0x00080000
321/* Moves to coprocessor register, requiring delay. */
322#define INSN_COPROC_MOVE_DELAY 0x00100000
323/* Loads coprocessor register from memory, requiring delay. */
324#define INSN_COPROC_MEMORY_DELAY 0x00200000
325/* Reads the HI register. */
326#define INSN_READ_HI 0x00400000
327/* Reads the LO register. */
328#define INSN_READ_LO 0x00800000
329/* Modifies the HI register. */
330#define INSN_WRITE_HI 0x01000000
331/* Modifies the LO register. */
332#define INSN_WRITE_LO 0x02000000
333/* Takes a trap (easier to keep out of delay slot). */
334#define INSN_TRAP 0x04000000
335/* Instruction stores value into memory. */
336#define INSN_STORE_MEMORY 0x08000000
337/* Instruction uses single precision floating point. */
338#define FP_S 0x10000000
339/* Instruction uses double precision floating point. */
340#define FP_D 0x20000000
341/* Instruction is part of the tx39's integer multiply family. */
342#define INSN_MULT 0x40000000
343/* Instruction synchronize shared memory. */
344#define INSN_SYNC 0x80000000
deec1734
CD
345/* Instruction reads MDMX accumulator. XXX FIXME: No bits left! */
346#define INSN_READ_MDMX_ACC 0
347/* Instruction writes MDMX accumulator. XXX FIXME: No bits left! */
348#define INSN_WRITE_MDMX_ACC 0
252b5132
RH
349
350/* Instruction is actually a macro. It should be ignored by the
351 disassembler, and requires special treatment by the assembler. */
352#define INSN_MACRO 0xffffffff
353
e7af610e
NC
354/* Masks used to mark instructions to indicate which MIPS ISA level
355 they were introduced in. ISAs, as defined below, are logical
356 ORs of these bits, indicatingthat they support the instructions
357 defined at the given level. */
358
92714f94 359#define INSN_ISA_MASK 0x00000fff
e7af610e
NC
360#define INSN_ISA1 0x00000010
361#define INSN_ISA2 0x00000020
362#define INSN_ISA3 0x00000040
363#define INSN_ISA4 0x00000080
364#define INSN_ISA5 0x00000100
365#define INSN_ISA32 0x00000200
84ea6cf2 366#define INSN_ISA64 0x00000400
252b5132 367
1f25f5d3 368/* Masks used for MIPS-defined ASEs. */
aec421e0 369#define INSN_ASE_MASK 0x0000f000
1f25f5d3 370
aec421e0
TS
371/* MIPS 16 ASE */
372#define INSN_MIPS16 0x00002000
1f25f5d3
CD
373/* MIPS-3D ASE */
374#define INSN_MIPS3D 0x00004000
deec1734
CD
375/* MDMX ASE */
376#define INSN_MDMX 0x00008000
1f25f5d3 377
252b5132 378/* Chip specific instructions. These are bitmasks. */
e7af610e 379
252b5132 380/* MIPS R4650 instruction. */
e7af610e 381#define INSN_4650 0x00010000
252b5132 382/* LSI R4010 instruction. */
e7af610e
NC
383#define INSN_4010 0x00020000
384/* NEC VR4100 instruction. */
bf40d919 385#define INSN_4100 0x00040000
252b5132 386/* Toshiba R3900 instruction. */
bf40d919 387#define INSN_3900 0x00080000
99c14723
TS
388/* MIPS R10000 instruction. */
389#define INSN_10000 0x00100000
2228315b
CD
390/* Broadcom SB-1 instruction. */
391#define INSN_SB1 0x00200000
9752cf1b
RS
392/* NEC VR4111/VR4181 instruction. */
393#define INSN_4111 0x00400000
394/* NEC VR4120 instruction. */
395#define INSN_4120 0x00800000
396/* NEC VR5400 instruction. */
397#define INSN_5400 0x01000000
398/* NEC VR5500 instruction. */
399#define INSN_5500 0x02000000
e7af610e
NC
400
401/* MIPS ISA defines, use instead of hardcoding ISA level. */
402
403#define ISA_UNKNOWN 0 /* Gas internal use. */
404#define ISA_MIPS1 (INSN_ISA1)
405#define ISA_MIPS2 (ISA_MIPS1 | INSN_ISA2)
406#define ISA_MIPS3 (ISA_MIPS2 | INSN_ISA3)
407#define ISA_MIPS4 (ISA_MIPS3 | INSN_ISA4)
84ea6cf2 408#define ISA_MIPS5 (ISA_MIPS4 | INSN_ISA5)
e7af610e 409#define ISA_MIPS32 (ISA_MIPS2 | INSN_ISA32)
84ea6cf2 410#define ISA_MIPS64 (ISA_MIPS5 | INSN_ISA32 | INSN_ISA64)
367c01af 411
156c2f8b
NC
412/* CPU defines, use instead of hardcoding processor number. Keep this
413 in sync with bfd/archures.c in order for machine selection to work. */
e7af610e 414#define CPU_UNKNOWN 0 /* Gas internal use. */
156c2f8b
NC
415#define CPU_R3000 3000
416#define CPU_R3900 3900
417#define CPU_R4000 4000
418#define CPU_R4010 4010
419#define CPU_VR4100 4100
420#define CPU_R4111 4111
9752cf1b 421#define CPU_VR4120 4120
156c2f8b
NC
422#define CPU_R4300 4300
423#define CPU_R4400 4400
424#define CPU_R4600 4600
425#define CPU_R4650 4650
426#define CPU_R5000 5000
9752cf1b
RS
427#define CPU_VR5400 5400
428#define CPU_VR5500 5500
156c2f8b
NC
429#define CPU_R6000 6000
430#define CPU_R8000 8000
431#define CPU_R10000 10000
d1cf510e 432#define CPU_R12000 12000
156c2f8b
NC
433#define CPU_MIPS16 16
434#define CPU_MIPS32 32
84ea6cf2
NC
435#define CPU_MIPS5 5
436#define CPU_MIPS64 64
c6c98b38 437#define CPU_SB1 12310201 /* octal 'SB', 01. */
156c2f8b 438
1f25f5d3
CD
439/* Test for membership in an ISA including chip specific ISAs. INSN
440 is pointer to an element of the opcode table; ISA is the specified
441 ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
442 test, or zero if no CPU specific ISA test is desired. */
a58ec95a
RS
443
444#define OPCODE_IS_MEMBER(insn, isa, cpu) \
445 (((insn)->membership & isa) != 0 \
156c2f8b
NC
446 || (cpu == CPU_R4650 && ((insn)->membership & INSN_4650) != 0) \
447 || (cpu == CPU_R4010 && ((insn)->membership & INSN_4010) != 0) \
9752cf1b 448 || (cpu == CPU_VR4100 && ((insn)->membership & INSN_4100) != 0) \
99c14723
TS
449 || (cpu == CPU_R3900 && ((insn)->membership & INSN_3900) != 0) \
450 || ((cpu == CPU_R10000 || cpu == CPU_R12000) \
2228315b 451 && ((insn)->membership & INSN_10000) != 0) \
5d84d93f 452 || (cpu == CPU_SB1 && ((insn)->membership & INSN_SB1) != 0) \
9752cf1b
RS
453 || (cpu == CPU_R4111 && ((insn)->membership & INSN_4111) != 0) \
454 || (cpu == CPU_VR4120 && ((insn)->membership & INSN_4120) != 0) \
455 || (cpu == CPU_VR5400 && ((insn)->membership & INSN_5400) != 0) \
456 || (cpu == CPU_VR5500 && ((insn)->membership & INSN_5500) != 0) \
e4432525 457 || 0) /* Please keep this term for easier source merging. */
252b5132
RH
458
459/* This is a list of macro expanded instructions.
8eaec934 460
e7af610e
NC
461 _I appended means immediate
462 _A appended means address
463 _AB appended means address with base register
464 _D appended means 64 bit floating point constant
465 _S appended means 32 bit floating point constant. */
466
467enum
468{
469 M_ABS,
470 M_ADD_I,
471 M_ADDU_I,
472 M_AND_I,
473 M_BEQ,
474 M_BEQ_I,
475 M_BEQL_I,
476 M_BGE,
477 M_BGEL,
478 M_BGE_I,
479 M_BGEL_I,
480 M_BGEU,
481 M_BGEUL,
482 M_BGEU_I,
483 M_BGEUL_I,
484 M_BGT,
485 M_BGTL,
486 M_BGT_I,
487 M_BGTL_I,
488 M_BGTU,
489 M_BGTUL,
490 M_BGTU_I,
491 M_BGTUL_I,
492 M_BLE,
493 M_BLEL,
494 M_BLE_I,
495 M_BLEL_I,
496 M_BLEU,
497 M_BLEUL,
498 M_BLEU_I,
499 M_BLEUL_I,
500 M_BLT,
501 M_BLTL,
502 M_BLT_I,
503 M_BLTL_I,
504 M_BLTU,
505 M_BLTUL,
506 M_BLTU_I,
507 M_BLTUL_I,
508 M_BNE,
509 M_BNE_I,
510 M_BNEL_I,
511 M_DABS,
512 M_DADD_I,
513 M_DADDU_I,
514 M_DDIV_3,
515 M_DDIV_3I,
516 M_DDIVU_3,
517 M_DDIVU_3I,
518 M_DIV_3,
519 M_DIV_3I,
520 M_DIVU_3,
521 M_DIVU_3I,
522 M_DLA_AB,
523 M_DLI,
524 M_DMUL,
8eaec934 525 M_DMUL_I,
e7af610e 526 M_DMULO,
8eaec934 527 M_DMULO_I,
e7af610e 528 M_DMULOU,
8eaec934 529 M_DMULOU_I,
e7af610e
NC
530 M_DREM_3,
531 M_DREM_3I,
532 M_DREMU_3,
533 M_DREMU_3I,
534 M_DSUB_I,
535 M_DSUBU_I,
536 M_DSUBU_I_2,
537 M_J_A,
538 M_JAL_1,
539 M_JAL_2,
540 M_JAL_A,
541 M_L_DOB,
542 M_L_DAB,
543 M_LA_AB,
544 M_LB_A,
545 M_LB_AB,
546 M_LBU_A,
547 M_LBU_AB,
548 M_LD_A,
549 M_LD_OB,
550 M_LD_AB,
551 M_LDC1_AB,
552 M_LDC2_AB,
553 M_LDC3_AB,
554 M_LDL_AB,
555 M_LDR_AB,
556 M_LH_A,
557 M_LH_AB,
558 M_LHU_A,
559 M_LHU_AB,
560 M_LI,
561 M_LI_D,
562 M_LI_DD,
563 M_LI_S,
564 M_LI_SS,
565 M_LL_AB,
566 M_LLD_AB,
567 M_LS_A,
568 M_LW_A,
569 M_LW_AB,
570 M_LWC0_A,
571 M_LWC0_AB,
572 M_LWC1_A,
573 M_LWC1_AB,
574 M_LWC2_A,
575 M_LWC2_AB,
576 M_LWC3_A,
577 M_LWC3_AB,
578 M_LWL_A,
579 M_LWL_AB,
580 M_LWR_A,
581 M_LWR_AB,
582 M_LWU_AB,
a58ec95a 583 M_MOVE,
e7af610e 584 M_MUL,
8eaec934 585 M_MUL_I,
e7af610e 586 M_MULO,
8eaec934 587 M_MULO_I,
e7af610e 588 M_MULOU,
8eaec934 589 M_MULOU_I,
e7af610e
NC
590 M_NOR_I,
591 M_OR_I,
592 M_REM_3,
593 M_REM_3I,
594 M_REMU_3,
595 M_REMU_3I,
771c7ce4 596 M_DROL,
e7af610e 597 M_ROL,
771c7ce4 598 M_DROL_I,
e7af610e 599 M_ROL_I,
771c7ce4 600 M_DROR,
e7af610e 601 M_ROR,
771c7ce4 602 M_DROR_I,
e7af610e
NC
603 M_ROR_I,
604 M_S_DA,
605 M_S_DOB,
606 M_S_DAB,
607 M_S_S,
608 M_SC_AB,
609 M_SCD_AB,
610 M_SD_A,
611 M_SD_OB,
612 M_SD_AB,
613 M_SDC1_AB,
614 M_SDC2_AB,
615 M_SDC3_AB,
616 M_SDL_AB,
617 M_SDR_AB,
618 M_SEQ,
619 M_SEQ_I,
620 M_SGE,
621 M_SGE_I,
622 M_SGEU,
623 M_SGEU_I,
624 M_SGT,
625 M_SGT_I,
626 M_SGTU,
627 M_SGTU_I,
628 M_SLE,
629 M_SLE_I,
630 M_SLEU,
631 M_SLEU_I,
632 M_SLT_I,
633 M_SLTU_I,
634 M_SNE,
635 M_SNE_I,
636 M_SB_A,
637 M_SB_AB,
638 M_SH_A,
639 M_SH_AB,
640 M_SW_A,
641 M_SW_AB,
642 M_SWC0_A,
643 M_SWC0_AB,
644 M_SWC1_A,
645 M_SWC1_AB,
646 M_SWC2_A,
647 M_SWC2_AB,
648 M_SWC3_A,
649 M_SWC3_AB,
650 M_SWL_A,
651 M_SWL_AB,
652 M_SWR_A,
653 M_SWR_AB,
654 M_SUB_I,
655 M_SUBU_I,
656 M_SUBU_I_2,
657 M_TEQ_I,
658 M_TGE_I,
659 M_TGEU_I,
660 M_TLT_I,
661 M_TLTU_I,
662 M_TNE_I,
663 M_TRUNCWD,
664 M_TRUNCWS,
665 M_ULD,
666 M_ULD_A,
667 M_ULH,
668 M_ULH_A,
669 M_ULHU,
670 M_ULHU_A,
671 M_ULW,
672 M_ULW_A,
673 M_USH,
674 M_USH_A,
675 M_USW,
676 M_USW_A,
677 M_USD,
678 M_USD_A,
679 M_XOR_I,
680 M_COP0,
681 M_COP1,
682 M_COP2,
683 M_COP3,
684 M_NUM_MACROS
252b5132
RH
685};
686
687
688/* The order of overloaded instructions matters. Label arguments and
689 register arguments look the same. Instructions that can have either
690 for arguments must apear in the correct order in this table for the
691 assembler to pick the right one. In other words, entries with
692 immediate operands must apear after the same instruction with
693 registers.
694
695 Many instructions are short hand for other instructions (i.e., The
696 jal <register> instruction is short for jalr <register>). */
697
698extern const struct mips_opcode mips_builtin_opcodes[];
699extern const int bfd_mips_num_builtin_opcodes;
700extern struct mips_opcode *mips_opcodes;
701extern int bfd_mips_num_opcodes;
702#define NUMOPCODES bfd_mips_num_opcodes
703
704\f
705/* The rest of this file adds definitions for the mips16 TinyRISC
706 processor. */
707
708/* These are the bitmasks and shift counts used for the different
709 fields in the instruction formats. Other than OP, no masks are
710 provided for the fixed portions of an instruction, since they are
711 not needed.
712
713 The I format uses IMM11.
714
715 The RI format uses RX and IMM8.
716
717 The RR format uses RX, and RY.
718
719 The RRI format uses RX, RY, and IMM5.
720
721 The RRR format uses RX, RY, and RZ.
722
723 The RRI_A format uses RX, RY, and IMM4.
724
725 The SHIFT format uses RX, RY, and SHAMT.
726
727 The I8 format uses IMM8.
728
729 The I8_MOVR32 format uses RY and REGR32.
730
731 The IR_MOV32R format uses REG32R and MOV32Z.
732
733 The I64 format uses IMM8.
734
735 The RI64 format uses RY and IMM5.
736 */
737
738#define MIPS16OP_MASK_OP 0x1f
739#define MIPS16OP_SH_OP 11
740#define MIPS16OP_MASK_IMM11 0x7ff
741#define MIPS16OP_SH_IMM11 0
742#define MIPS16OP_MASK_RX 0x7
743#define MIPS16OP_SH_RX 8
744#define MIPS16OP_MASK_IMM8 0xff
745#define MIPS16OP_SH_IMM8 0
746#define MIPS16OP_MASK_RY 0x7
747#define MIPS16OP_SH_RY 5
748#define MIPS16OP_MASK_IMM5 0x1f
749#define MIPS16OP_SH_IMM5 0
750#define MIPS16OP_MASK_RZ 0x7
751#define MIPS16OP_SH_RZ 2
752#define MIPS16OP_MASK_IMM4 0xf
753#define MIPS16OP_SH_IMM4 0
754#define MIPS16OP_MASK_REGR32 0x1f
755#define MIPS16OP_SH_REGR32 0
756#define MIPS16OP_MASK_REG32R 0x1f
757#define MIPS16OP_SH_REG32R 3
758#define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18))
759#define MIPS16OP_MASK_MOVE32Z 0x7
760#define MIPS16OP_SH_MOVE32Z 0
761#define MIPS16OP_MASK_IMM6 0x3f
762#define MIPS16OP_SH_IMM6 5
763
764/* These are the characters which may appears in the args field of an
765 instruction. They appear in the order in which the fields appear
766 when the instruction is used. Commas and parentheses in the args
767 string are ignored when assembling, and written into the output
768 when disassembling.
769
770 "y" 3 bit register (MIPS16OP_*_RY)
771 "x" 3 bit register (MIPS16OP_*_RX)
772 "z" 3 bit register (MIPS16OP_*_RZ)
773 "Z" 3 bit register (MIPS16OP_*_MOVE32Z)
774 "v" 3 bit same register as source and destination (MIPS16OP_*_RX)
775 "w" 3 bit same register as source and destination (MIPS16OP_*_RY)
776 "0" zero register ($0)
777 "S" stack pointer ($sp or $29)
778 "P" program counter
779 "R" return address register ($ra or $31)
780 "X" 5 bit MIPS register (MIPS16OP_*_REGR32)
781 "Y" 5 bit MIPS register (MIPS16OP_*_REG32R)
782 "6" 6 bit unsigned break code (MIPS16OP_*_IMM6)
783 "a" 26 bit jump address
784 "e" 11 bit extension value
785 "l" register list for entry instruction
786 "L" register list for exit instruction
787
788 The remaining codes may be extended. Except as otherwise noted,
789 the full extended operand is a 16 bit signed value.
790 "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned)
791 ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned)
792 "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned)
793 "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned)
794 "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed)
795 "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5)
796 "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5)
797 "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5)
798 "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5)
799 "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5)
800 "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8)
801 "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8)
802 "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8)
803 "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned)
804 "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8)
805 "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8)
806 "p" 8 bit conditional branch address (MIPS16OP_*_IMM8)
807 "q" 11 bit branch address (MIPS16OP_*_IMM11)
808 "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8)
809 "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5)
810 "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5)
811 */
812
813/* For the mips16, we use the same opcode table format and a few of
814 the same flags. However, most of the flags are different. */
815
816/* Modifies the register in MIPS16OP_*_RX. */
817#define MIPS16_INSN_WRITE_X 0x00000001
818/* Modifies the register in MIPS16OP_*_RY. */
819#define MIPS16_INSN_WRITE_Y 0x00000002
820/* Modifies the register in MIPS16OP_*_RZ. */
821#define MIPS16_INSN_WRITE_Z 0x00000004
822/* Modifies the T ($24) register. */
823#define MIPS16_INSN_WRITE_T 0x00000008
824/* Modifies the SP ($29) register. */
825#define MIPS16_INSN_WRITE_SP 0x00000010
826/* Modifies the RA ($31) register. */
827#define MIPS16_INSN_WRITE_31 0x00000020
828/* Modifies the general purpose register in MIPS16OP_*_REG32R. */
829#define MIPS16_INSN_WRITE_GPR_Y 0x00000040
830/* Reads the register in MIPS16OP_*_RX. */
831#define MIPS16_INSN_READ_X 0x00000080
832/* Reads the register in MIPS16OP_*_RY. */
833#define MIPS16_INSN_READ_Y 0x00000100
834/* Reads the register in MIPS16OP_*_MOVE32Z. */
835#define MIPS16_INSN_READ_Z 0x00000200
836/* Reads the T ($24) register. */
837#define MIPS16_INSN_READ_T 0x00000400
838/* Reads the SP ($29) register. */
839#define MIPS16_INSN_READ_SP 0x00000800
840/* Reads the RA ($31) register. */
841#define MIPS16_INSN_READ_31 0x00001000
842/* Reads the program counter. */
843#define MIPS16_INSN_READ_PC 0x00002000
844/* Reads the general purpose register in MIPS16OP_*_REGR32. */
845#define MIPS16_INSN_READ_GPR_X 0x00004000
846/* Is a branch insn. */
847#define MIPS16_INSN_BRANCH 0x00010000
848
849/* The following flags have the same value for the mips16 opcode
850 table:
851 INSN_UNCOND_BRANCH_DELAY
852 INSN_COND_BRANCH_DELAY
853 INSN_COND_BRANCH_LIKELY (never used)
854 INSN_READ_HI
855 INSN_READ_LO
856 INSN_WRITE_HI
857 INSN_WRITE_LO
858 INSN_TRAP
859 INSN_ISA3
860 */
861
862extern const struct mips_opcode mips16_opcodes[];
863extern const int bfd_mips16_num_opcodes;
864
865#endif /* _MIPS_H_ */