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