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