1 /* Opcode table for the ARC.
2 Copyright (C) 1994-2016 Free Software Foundation, Inc.
4 Contributed by Claudiu Zissulescu (claziss@synopsys.com)
6 This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and
9 GAS/GDB is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
14 GAS/GDB is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GAS or GDB; see the file COPYING3. If not, write to
21 the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
28 #define MAX_INSN_ARGS 6
32 #define MAX_INSN_FLGS 3
35 /* Instruction Class. */
52 /* Instruction Subclass. */
82 /* At most one flag from the set of flags can appear in the
86 /* Exactly one from from the set of flags must appear in the
91 /* The opcode table is an array of struct arc_opcode. */
94 /* The opcode name. */
97 /* The opcode itself. Those bits which will be filled in with
98 operands are zeroes. */
101 /* The opcode mask. This is used by the disassembler. This is a
102 mask containing ones indicating those bits which must match the
103 opcode field, and zeroes indicating those bits which need not
104 match (and are presumably filled in by operands). */
107 /* One bit flags for the opcode. These are primarily used to
108 indicate specific processors and environments support the
109 instructions. The defined values are listed below. */
112 /* The instruction class. This is used by gdb. */
115 /* The instruction subclass. */
116 insn_subclass_t subclass
;
118 /* An array of operand codes. Each code is an index into the
119 operand table. They appear in the order which the operands must
120 appear in assembly code, and are terminated by a zero. */
121 unsigned char operands
[MAX_INSN_ARGS
+ 1];
123 /* An array of flag codes. Each code is an index into the flag
124 table. They appear in the order which the flags must appear in
125 assembly code, and are terminated by a zero. */
126 unsigned char flags
[MAX_INSN_FLGS
+ 1];
129 /* The table itself is sorted by major opcode number, and is otherwise
130 in the order in which the disassembler should consider
132 extern const struct arc_opcode arc_opcodes
[];
133 extern const unsigned arc_num_opcodes
;
135 /* CPU Availability. */
136 #define ARC_OPCODE_ARC600 0x0001 /* ARC 600 specific insns. */
137 #define ARC_OPCODE_ARC700 0x0002 /* ARC 700 specific insns. */
138 #define ARC_OPCODE_ARCv2EM 0x0004 /* ARCv2 EM specific insns. */
139 #define ARC_OPCODE_ARCv2HS 0x0008 /* ARCv2 HS specific insns. */
140 #define ARC_OPCODE_NPS400 0x0010 /* NPS400 specific insns. */
142 /* CPU extensions. */
143 #define ARC_EA 0x0001
144 #define ARC_CD 0x0001 /* Mutual exclusive with EA. */
145 #define ARC_LLOCK 0x0002
146 #define ARC_ATOMIC 0x0002 /* Mutual exclusive with LLOCK. */
147 #define ARC_MPY 0x0004
148 #define ARC_MULT 0x0004
150 /* Floating point support. */
151 #define ARC_DPFP 0x0010
152 #define ARC_SPFP 0x0020
153 #define ARC_FPU 0x0030
154 #define ARC_FPUDA 0x0040
157 #define ARC_SWAP 0x0100
158 #define ARC_NORM 0x0200
159 #define ARC_BSCAN 0x0200
162 #define ARC_UIX 0x1000
163 #define ARC_TSTAMP 0x1000
166 #define ARC_VBFDW 0x1000
167 #define ARC_BARREL 0x1000
168 #define ARC_DSPA 0x1000
171 #define ARC_SHIFT 0x1000
174 #define ARC_INTR 0x1000
175 #define ARC_DIV 0x1000
178 #define ARC_XMAC 0x1000
179 #define ARC_CRC 0x1000
181 /* A macro to check for short instructions. */
182 #define ARC_SHORT(mask) \
183 (((mask) & 0xFFFF0000) ? 0 : 1)
185 /* The operands table is an array of struct arc_operand. */
188 /* The number of bits in the operand. */
191 /* How far the operand is left shifted in the instruction. */
194 /* The default relocation type for this operand. */
195 signed int default_reloc
;
197 /* One bit syntax flags. */
200 /* Insertion function. This is used by the assembler. To insert an
201 operand value into an instruction, check this field.
203 If it is NULL, execute
204 i |= (op & ((1 << o->bits) - 1)) << o->shift;
205 (i is the instruction which we are filling in, o is a pointer to
206 this structure, and op is the opcode value; this assumes twos
207 complement arithmetic).
209 If this field is not NULL, then simply call it with the
210 instruction and the operand value. It will return the new value
211 of the instruction. If the ERRMSG argument is not NULL, then if
212 the operand value is illegal, *ERRMSG will be set to a warning
213 string (the operand will be inserted in any case). If the
214 operand value is legal, *ERRMSG will be unchanged (most operands
215 can accept any value). */
216 unsigned (*insert
) (unsigned instruction
, int op
, const char **errmsg
);
218 /* Extraction function. This is used by the disassembler. To
219 extract this operand type from an instruction, check this field.
221 If it is NULL, compute
222 op = ((i) >> o->shift) & ((1 << o->bits) - 1);
223 if ((o->flags & ARC_OPERAND_SIGNED) != 0
224 && (op & (1 << (o->bits - 1))) != 0)
226 (i is the instruction, o is a pointer to this structure, and op
227 is the result; this assumes twos complement arithmetic).
229 If this field is not NULL, then simply call it with the
230 instruction value. It will return the value of the operand. If
231 the INVALID argument is not NULL, *INVALID will be set to
232 TRUE if this operand type can not actually be extracted from
233 this operand (i.e., the instruction does not match). If the
234 operand is valid, *INVALID will not be changed. */
235 int (*extract
) (unsigned instruction
, bfd_boolean
*invalid
);
238 /* Elements in the table are retrieved by indexing with values from
239 the operands field of the arc_opcodes table. */
240 extern const struct arc_operand arc_operands
[];
241 extern const unsigned arc_num_operands
;
242 extern const unsigned arc_Toperand
;
243 extern const unsigned arc_NToperand
;
245 /* Values defined for the flags field of a struct arc_operand. */
247 /* This operand does not actually exist in the assembler input. This
248 is used to support extended mnemonics, for which two operands fields
249 are identical. The assembler should call the insert function with
250 any op value. The disassembler should call the extract function,
251 ignore the return value, and check the value placed in the invalid
253 #define ARC_OPERAND_FAKE 0x0001
255 /* This operand names an integer register. */
256 #define ARC_OPERAND_IR 0x0002
258 /* This operand takes signed values. */
259 #define ARC_OPERAND_SIGNED 0x0004
261 /* This operand takes unsigned values. This exists primarily so that
262 a flags value of 0 can be treated as end-of-arguments. */
263 #define ARC_OPERAND_UNSIGNED 0x0008
265 /* This operand takes long immediate values. */
266 #define ARC_OPERAND_LIMM 0x0010
268 /* This operand is identical like the previous one. */
269 #define ARC_OPERAND_DUPLICATE 0x0020
271 /* This operand is PC relative. Used for internal relocs. */
272 #define ARC_OPERAND_PCREL 0x0040
274 /* This operand is truncated. The truncation is done accordingly to
275 operand alignment attribute. */
276 #define ARC_OPERAND_TRUNCATE 0x0080
278 /* This operand is 16bit aligned. */
279 #define ARC_OPERAND_ALIGNED16 0x0100
281 /* This operand is 32bit aligned. */
282 #define ARC_OPERAND_ALIGNED32 0x0200
284 /* This operand can be ignored by matching process if it is not
286 #define ARC_OPERAND_IGNORE 0x0400
288 /* Don't check the range when matching. */
289 #define ARC_OPERAND_NCHK 0x0800
291 /* Mark the braket possition. */
292 #define ARC_OPERAND_BRAKET 0x1000
294 /* Mask for selecting the type for typecheck purposes. */
295 #define ARC_OPERAND_TYPECHECK_MASK \
297 ARC_OPERAND_LIMM | ARC_OPERAND_SIGNED | \
298 ARC_OPERAND_UNSIGNED | ARC_OPERAND_BRAKET)
300 /* The flags structure. */
301 struct arc_flag_operand
309 /* The number of bits in the operand. */
312 /* How far the operand is left shifted in the instruction. */
315 /* Available for disassembler. */
316 unsigned char favail
;
319 /* The flag operands table. */
320 extern const struct arc_flag_operand arc_flag_operands
[];
321 extern const unsigned arc_num_flag_operands
;
323 /* The flag's class structure. */
324 struct arc_flag_class
329 /* List of valid flags (codes). */
333 extern const struct arc_flag_class arc_flag_classes
[];
335 /* Structure for special cases. */
336 struct arc_flag_special
338 /* Name of special case instruction. */
341 /* List of flags applicable for special case instruction. */
345 extern const struct arc_flag_special arc_flag_special_cases
[];
346 extern const unsigned arc_num_flag_special
;
348 /* Relocation equivalence structure. */
349 struct arc_reloc_equiv_tab
351 const char * name
; /* String to lookup. */
352 const char * mnemonic
; /* Extra matching condition. */
353 unsigned flags
[32]; /* Extra matching condition. */
354 signed int oldreloc
; /* Old relocation. */
355 signed int newreloc
; /* New relocation. */
358 extern const struct arc_reloc_equiv_tab arc_reloc_equiv
[];
359 extern const unsigned arc_num_equiv_tab
;
361 /* Structure for operand operations for pseudo/alias instructions. */
362 struct arc_operand_operation
364 /* The index for operand from operand array. */
365 unsigned operand_idx
;
367 /* Defines if it needs the operand inserted by the assembler or
368 whether this operand comes from the pseudo instruction's
370 unsigned char needs_insert
;
372 /* Count we have to add to the operand. Use negative number to
373 subtract from the operand. Also use this number to add to 0 if
374 the operand needs to be inserted (i.e. needs_insert == 1). */
377 /* Index of the operand to swap with. To be done AFTER applying
379 unsigned swap_operand_idx
;
382 /* Structure for pseudo/alias instructions. */
383 struct arc_pseudo_insn
385 /* Mnemonic for pseudo/alias insn. */
386 const char *mnemonic_p
;
388 /* Mnemonic for real instruction. */
389 const char *mnemonic_r
;
391 /* Flag that will have to be added (if any). */
394 /* Amount of operands. */
395 unsigned operand_cnt
;
397 /* Array of operand operations. */
398 struct arc_operand_operation operand
[6];
401 extern const struct arc_pseudo_insn arc_pseudo_insns
[];
402 extern const unsigned arc_num_pseudo_insn
;
404 /* Structure for AUXILIARY registers. */
407 /* Register address. */
410 /* AUX register subclass. */
411 insn_subclass_t subclass
;
416 /* Size of the string. */
420 extern const struct arc_aux_reg arc_aux_regs
[];
421 extern const unsigned arc_num_aux_regs
;
423 extern const struct arc_opcode arc_relax_opcodes
[];
424 extern const unsigned arc_num_relax_opcodes
;
426 /* Macros to help generating regular pattern instructions. */
427 #define FIELDA(word) (word & 0x3F)
428 #define FIELDB(word) (((word & 0x07) << 24) | (((word >> 3) & 0x07) << 12))
429 #define FIELDC(word) ((word & 0x3F) << 6)
430 #define FIELDF (0x01 << 15)
431 #define FIELDQ (0x1F)
433 #define INSN3OP(MOP,SOP) (((MOP & 0x1F) << 27) | ((SOP & 0x3F) << 16))
434 #define INSN2OPX(MOP,SOP1,SOP2) (INSN3OP (MOP,SOP1) | (SOP2 & 0x3F))
435 #define INSN2OP(MOP,SOP) (INSN2OPX (MOP,0x2F,SOP))
437 #define INSN3OP_ABC(MOP,SOP) (INSN3OP (MOP,SOP))
438 #define INSN3OP_ALC(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDB (62))
439 #define INSN3OP_ABL(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDC (62))
440 #define INSN3OP_ALL(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDB (62) | FIELDC (62))
441 #define INSN3OP_0BC(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62))
442 #define INSN3OP_0LC(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62) | FIELDB (62))
443 #define INSN3OP_0BL(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62) | FIELDC (62))
444 #define INSN3OP_0LL(MOP,SOP) \
445 (INSN3OP (MOP,SOP) | FIELDA (62) | FIELDB (62) | FIELDC (62))
446 #define INSN3OP_ABU(MOP,SOP) (INSN3OP (MOP,SOP) | (0x01 << 22))
447 #define INSN3OP_ALU(MOP,SOP) (INSN3OP (MOP,SOP) | (0x01 << 22) | FIELDB (62))
448 #define INSN3OP_0BU(MOP,SOP) (INSN3OP (MOP,SOP) | FIELDA (62) | (0x01 << 22))
449 #define INSN3OP_0LU(MOP,SOP) \
450 (INSN3OP (MOP,SOP) | FIELDA (62) | (0x01 << 22) | FIELDB (62))
451 #define INSN3OP_BBS(MOP,SOP) (INSN3OP (MOP,SOP) | (0x02 << 22))
452 #define INSN3OP_0LS(MOP,SOP) (INSN3OP (MOP,SOP) | (0x02 << 22) | FIELDB (62))
453 #define INSN3OP_CBBC(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22))
454 #define INSN3OP_CBBL(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22) | FIELDC (62))
455 #define INSN3OP_C0LC(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22) | FIELDB (62))
456 #define INSN3OP_C0LL(MOP,SOP) \
457 (INSN3OP (MOP,SOP) | (0x03 << 22) | FIELDC (62) | FIELDB (62))
458 #define INSN3OP_CBBU(MOP,SOP) (INSN3OP (MOP,SOP) | (0x03 << 22) | (0x01 << 5))
459 #define INSN3OP_C0LU(MOP,SOP) \
460 (INSN3OP (MOP,SOP) | (0x03 << 22) | (0x01 << 5) | FIELDB (62))
462 #define MINSN3OP_ABC (~(FIELDF | FIELDA (63) | FIELDB (63) | FIELDC (63)))
463 #define MINSN3OP_ALC (~(FIELDF | FIELDA (63) | FIELDC (63)))
464 #define MINSN3OP_ABL (~(FIELDF | FIELDA (63) | FIELDB (63)))
465 #define MINSN3OP_ALL (~(FIELDF | FIELDA (63)))
466 #define MINSN3OP_0BC (~(FIELDF | FIELDB (63) | FIELDC (63)))
467 #define MINSN3OP_0LC (~(FIELDF | FIELDC (63)))
468 #define MINSN3OP_0BL (~(FIELDF | FIELDB (63)))
469 #define MINSN3OP_0LL (~(FIELDF))
470 #define MINSN3OP_ABU (~(FIELDF | FIELDA (63) | FIELDB (63) | FIELDC (63)))
471 #define MINSN3OP_ALU (~(FIELDF | FIELDA (63) | FIELDC (63)))
472 #define MINSN3OP_0BU (~(FIELDF | FIELDB (63) | FIELDC (63)))
473 #define MINSN3OP_0LU (~(FIELDF | FIELDC (63)))
474 #define MINSN3OP_BBS (~(FIELDF | FIELDA (63) | FIELDB (63) | FIELDC (63)))
475 #define MINSN3OP_0LS (~(FIELDF | FIELDA (63) | FIELDC (63)))
476 #define MINSN3OP_CBBC (~(FIELDF | FIELDQ | FIELDB (63) | FIELDC (63)))
477 #define MINSN3OP_CBBL (~(FIELDF | FIELDQ | FIELDB (63)))
478 #define MINSN3OP_C0LC (~(FIELDF | FIELDQ | FIELDC (63)))
479 #define MINSN3OP_C0LL (~(FIELDF | FIELDQ))
480 #define MINSN3OP_CBBU (~(FIELDF | FIELDQ | FIELDB (63) | FIELDC (63)))
481 #define MINSN3OP_C0LU (~(FIELDF | FIELDQ | FIELDC (63)))
483 #define INSN2OP_BC(MOP,SOP) (INSN2OP (MOP,SOP))
484 #define INSN2OP_BL(MOP,SOP) (INSN2OP (MOP,SOP) | FIELDC (62))
485 #define INSN2OP_0C(MOP,SOP) (INSN2OP (MOP,SOP) | FIELDB (62))
486 #define INSN2OP_0L(MOP,SOP) (INSN2OP (MOP,SOP) | FIELDB (62) | FIELDC (62))
487 #define INSN2OP_BU(MOP,SOP) (INSN2OP (MOP,SOP) | (0x01 << 22))
488 #define INSN2OP_0U(MOP,SOP) (INSN2OP (MOP,SOP) | (0x01 << 22) | FIELDB (62))
490 #define MINSN2OP_BC (~(FIELDF | FIELDB (63) | FIELDC (63)))
491 #define MINSN2OP_BL (~(FIELDF | FIELDB (63)))
492 #define MINSN2OP_0C (~(FIELDF | FIELDC (63)))
493 #define MINSN2OP_0L (~(FIELDF))
494 #define MINSN2OP_BU (~(FIELDF | FIELDB (63) | FIELDC (63)))
495 #define MINSN2OP_0U (~(FIELDF | FIELDC (63)))
497 #endif /* OPCODE_ARC_H */