1 /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
2 /* Instruction opcode table for lm32.
4 THIS FILE IS MACHINE GENERATED WITH CGEN.
6 Copyright (C) 1996-2018 Free Software Foundation, Inc.
8 This file is part of the GNU Binutils and/or GDB, the GNU debugger.
10 This file is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
15 It is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 License for more details.
20 You should have received a copy of the GNU General Public License along
21 with this program; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
30 #include "lm32-desc.h"
32 #include "libiberty.h"
34 /* The hash functions are recorded here to help keep assembler code out of
35 the disassembler and vice versa. */
37 static int asm_hash_insn_p (const CGEN_INSN *);
38 static unsigned int asm_hash_insn (const char *);
39 static int dis_hash_insn_p (const CGEN_INSN *);
40 static unsigned int dis_hash_insn (const char *, CGEN_INSN_INT);
42 /* Instruction formats. */
44 #define F(f) & lm32_cgen_ifld_table[LM32_##f]
45 static const CGEN_IFMT ifmt_empty ATTRIBUTE_UNUSED = {
49 static const CGEN_IFMT ifmt_add ATTRIBUTE_UNUSED = {
50 32, 32, 0xfc0007ff, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_R2) }, { F (F_RESV0) }, { 0 } }
53 static const CGEN_IFMT ifmt_addi ATTRIBUTE_UNUSED = {
54 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_IMM) }, { 0 } }
57 static const CGEN_IFMT ifmt_andi ATTRIBUTE_UNUSED = {
58 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_UIMM) }, { 0 } }
61 static const CGEN_IFMT ifmt_andhii ATTRIBUTE_UNUSED = {
62 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_UIMM) }, { 0 } }
65 static const CGEN_IFMT ifmt_b ATTRIBUTE_UNUSED = {
66 32, 32, 0xfc1fffff, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_R2) }, { F (F_RESV0) }, { 0 } }
69 static const CGEN_IFMT ifmt_bi ATTRIBUTE_UNUSED = {
70 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_CALL) }, { 0 } }
73 static const CGEN_IFMT ifmt_be ATTRIBUTE_UNUSED = {
74 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_BRANCH) }, { 0 } }
77 static const CGEN_IFMT ifmt_ori ATTRIBUTE_UNUSED = {
78 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_UIMM) }, { 0 } }
81 static const CGEN_IFMT ifmt_rcsr ATTRIBUTE_UNUSED = {
82 32, 32, 0xfc1f07ff, { { F (F_OPCODE) }, { F (F_CSR) }, { F (F_R1) }, { F (F_R2) }, { F (F_RESV0) }, { 0 } }
85 static const CGEN_IFMT ifmt_sextb ATTRIBUTE_UNUSED = {
86 32, 32, 0xfc1f07ff, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_R2) }, { F (F_RESV0) }, { 0 } }
89 static const CGEN_IFMT ifmt_user ATTRIBUTE_UNUSED = {
90 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_R2) }, { F (F_USER) }, { 0 } }
93 static const CGEN_IFMT ifmt_wcsr ATTRIBUTE_UNUSED = {
94 32, 32, 0xfc00ffff, { { F (F_OPCODE) }, { F (F_CSR) }, { F (F_R1) }, { F (F_R2) }, { F (F_RESV0) }, { 0 } }
97 static const CGEN_IFMT ifmt_break ATTRIBUTE_UNUSED = {
98 32, 32, 0xffffffff, { { F (F_OPCODE) }, { F (F_EXCEPTION) }, { 0 } }
101 static const CGEN_IFMT ifmt_bret ATTRIBUTE_UNUSED = {
102 32, 32, 0xffffffff, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_R2) }, { F (F_RESV0) }, { 0 } }
105 static const CGEN_IFMT ifmt_mvi ATTRIBUTE_UNUSED = {
106 32, 32, 0xffe00000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_IMM) }, { 0 } }
109 static const CGEN_IFMT ifmt_mvui ATTRIBUTE_UNUSED = {
110 32, 32, 0xffe00000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_UIMM) }, { 0 } }
113 static const CGEN_IFMT ifmt_mvhi ATTRIBUTE_UNUSED = {
114 32, 32, 0xffe00000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_UIMM) }, { 0 } }
117 static const CGEN_IFMT ifmt_mva ATTRIBUTE_UNUSED = {
118 32, 32, 0xffe00000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_IMM) }, { 0 } }
121 static const CGEN_IFMT ifmt_nop ATTRIBUTE_UNUSED = {
122 32, 32, 0xffffffff, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_IMM) }, { 0 } }
125 static const CGEN_IFMT ifmt_lwgotrel ATTRIBUTE_UNUSED = {
126 32, 32, 0xffe00000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_IMM) }, { 0 } }
129 static const CGEN_IFMT ifmt_orhigotoffi ATTRIBUTE_UNUSED = {
130 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_IMM) }, { 0 } }
133 static const CGEN_IFMT ifmt_addgotoff ATTRIBUTE_UNUSED = {
134 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R0) }, { F (F_R1) }, { F (F_IMM) }, { 0 } }
139 #define A(a) (1 << CGEN_INSN_##a)
140 #define OPERAND(op) LM32_OPERAND_##op
141 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
142 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
144 /* The instruction table. */
146 static const CGEN_OPCODE lm32_cgen_insn_opcode_table[MAX_INSNS] =
148 /* Special null first entry.
149 A `num' value of zero is thus invalid.
150 Also, the special `invalid' insn resides here. */
151 { { 0, 0, 0, 0 }, {{0}}, 0, {0}},
152 /* add $r2,$r0,$r1 */
155 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
156 & ifmt_add, { 0xb4000000 }
158 /* addi $r1,$r0,$imm */
161 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (IMM), 0 } },
162 & ifmt_addi, { 0x34000000 }
164 /* and $r2,$r0,$r1 */
167 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
168 & ifmt_add, { 0xa0000000 }
170 /* andi $r1,$r0,$uimm */
173 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (UIMM), 0 } },
174 & ifmt_andi, { 0x20000000 }
176 /* andhi $r1,$r0,$hi16 */
179 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (HI16), 0 } },
180 & ifmt_andhii, { 0x60000000 }
185 { { MNEM, ' ', OP (R0), 0 } },
186 & ifmt_b, { 0xc0000000 }
191 { { MNEM, ' ', OP (CALL), 0 } },
192 & ifmt_bi, { 0xe0000000 }
194 /* be $r0,$r1,$branch */
197 { { MNEM, ' ', OP (R0), ',', OP (R1), ',', OP (BRANCH), 0 } },
198 & ifmt_be, { 0x44000000 }
200 /* bg $r0,$r1,$branch */
203 { { MNEM, ' ', OP (R0), ',', OP (R1), ',', OP (BRANCH), 0 } },
204 & ifmt_be, { 0x48000000 }
206 /* bge $r0,$r1,$branch */
209 { { MNEM, ' ', OP (R0), ',', OP (R1), ',', OP (BRANCH), 0 } },
210 & ifmt_be, { 0x4c000000 }
212 /* bgeu $r0,$r1,$branch */
215 { { MNEM, ' ', OP (R0), ',', OP (R1), ',', OP (BRANCH), 0 } },
216 & ifmt_be, { 0x50000000 }
218 /* bgu $r0,$r1,$branch */
221 { { MNEM, ' ', OP (R0), ',', OP (R1), ',', OP (BRANCH), 0 } },
222 & ifmt_be, { 0x54000000 }
224 /* bne $r0,$r1,$branch */
227 { { MNEM, ' ', OP (R0), ',', OP (R1), ',', OP (BRANCH), 0 } },
228 & ifmt_be, { 0x5c000000 }
233 { { MNEM, ' ', OP (R0), 0 } },
234 & ifmt_b, { 0xd8000000 }
239 { { MNEM, ' ', OP (CALL), 0 } },
240 & ifmt_bi, { 0xf8000000 }
242 /* cmpe $r2,$r0,$r1 */
245 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
246 & ifmt_add, { 0xe4000000 }
248 /* cmpei $r1,$r0,$imm */
251 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (IMM), 0 } },
252 & ifmt_addi, { 0x64000000 }
254 /* cmpg $r2,$r0,$r1 */
257 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
258 & ifmt_add, { 0xe8000000 }
260 /* cmpgi $r1,$r0,$imm */
263 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (IMM), 0 } },
264 & ifmt_addi, { 0x68000000 }
266 /* cmpge $r2,$r0,$r1 */
269 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
270 & ifmt_add, { 0xec000000 }
272 /* cmpgei $r1,$r0,$imm */
275 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (IMM), 0 } },
276 & ifmt_addi, { 0x6c000000 }
278 /* cmpgeu $r2,$r0,$r1 */
281 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
282 & ifmt_add, { 0xf0000000 }
284 /* cmpgeui $r1,$r0,$uimm */
287 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (UIMM), 0 } },
288 & ifmt_andi, { 0x70000000 }
290 /* cmpgu $r2,$r0,$r1 */
293 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
294 & ifmt_add, { 0xf4000000 }
296 /* cmpgui $r1,$r0,$uimm */
299 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (UIMM), 0 } },
300 & ifmt_andi, { 0x74000000 }
302 /* cmpne $r2,$r0,$r1 */
305 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
306 & ifmt_add, { 0xfc000000 }
308 /* cmpnei $r1,$r0,$imm */
311 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (IMM), 0 } },
312 & ifmt_addi, { 0x7c000000 }
314 /* divu $r2,$r0,$r1 */
317 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
318 & ifmt_add, { 0x8c000000 }
320 /* lb $r1,($r0+$imm) */
323 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (IMM), ')', 0 } },
324 & ifmt_addi, { 0x10000000 }
326 /* lbu $r1,($r0+$imm) */
329 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (IMM), ')', 0 } },
330 & ifmt_addi, { 0x40000000 }
332 /* lh $r1,($r0+$imm) */
335 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (IMM), ')', 0 } },
336 & ifmt_addi, { 0x1c000000 }
338 /* lhu $r1,($r0+$imm) */
341 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (IMM), ')', 0 } },
342 & ifmt_addi, { 0x2c000000 }
344 /* lw $r1,($r0+$imm) */
347 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (IMM), ')', 0 } },
348 & ifmt_addi, { 0x28000000 }
350 /* modu $r2,$r0,$r1 */
353 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
354 & ifmt_add, { 0xc4000000 }
356 /* mul $r2,$r0,$r1 */
359 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
360 & ifmt_add, { 0x88000000 }
362 /* muli $r1,$r0,$imm */
365 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (IMM), 0 } },
366 & ifmt_addi, { 0x8000000 }
368 /* nor $r2,$r0,$r1 */
371 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
372 & ifmt_add, { 0x84000000 }
374 /* nori $r1,$r0,$uimm */
377 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (UIMM), 0 } },
378 & ifmt_andi, { 0x4000000 }
383 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
384 & ifmt_add, { 0xb8000000 }
386 /* ori $r1,$r0,$lo16 */
389 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (LO16), 0 } },
390 & ifmt_ori, { 0x38000000 }
392 /* orhi $r1,$r0,$hi16 */
395 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (HI16), 0 } },
396 & ifmt_andhii, { 0x78000000 }
401 { { MNEM, ' ', OP (R2), ',', OP (CSR), 0 } },
402 & ifmt_rcsr, { 0x90000000 }
404 /* sb ($r0+$imm),$r1 */
407 { { MNEM, ' ', '(', OP (R0), '+', OP (IMM), ')', ',', OP (R1), 0 } },
408 & ifmt_addi, { 0x30000000 }
413 { { MNEM, ' ', OP (R2), ',', OP (R0), 0 } },
414 & ifmt_sextb, { 0xb0000000 }
419 { { MNEM, ' ', OP (R2), ',', OP (R0), 0 } },
420 & ifmt_sextb, { 0xdc000000 }
422 /* sh ($r0+$imm),$r1 */
425 { { MNEM, ' ', '(', OP (R0), '+', OP (IMM), ')', ',', OP (R1), 0 } },
426 & ifmt_addi, { 0xc000000 }
431 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
432 & ifmt_add, { 0xbc000000 }
434 /* sli $r1,$r0,$imm */
437 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (IMM), 0 } },
438 & ifmt_addi, { 0x3c000000 }
443 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
444 & ifmt_add, { 0x94000000 }
446 /* sri $r1,$r0,$imm */
449 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (IMM), 0 } },
450 & ifmt_addi, { 0x14000000 }
452 /* sru $r2,$r0,$r1 */
455 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
456 & ifmt_add, { 0x80000000 }
458 /* srui $r1,$r0,$imm */
461 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (IMM), 0 } },
464 /* sub $r2,$r0,$r1 */
467 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
468 & ifmt_add, { 0xc8000000 }
470 /* sw ($r0+$imm),$r1 */
473 { { MNEM, ' ', '(', OP (R0), '+', OP (IMM), ')', ',', OP (R1), 0 } },
474 & ifmt_addi, { 0x58000000 }
476 /* user $r2,$r0,$r1,$user */
479 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), ',', OP (USER), 0 } },
480 & ifmt_user, { 0xcc000000 }
485 { { MNEM, ' ', OP (CSR), ',', OP (R1), 0 } },
486 & ifmt_wcsr, { 0xd0000000 }
488 /* xor $r2,$r0,$r1 */
491 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
492 & ifmt_add, { 0x98000000 }
494 /* xori $r1,$r0,$uimm */
497 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (UIMM), 0 } },
498 & ifmt_andi, { 0x18000000 }
500 /* xnor $r2,$r0,$r1 */
503 { { MNEM, ' ', OP (R2), ',', OP (R0), ',', OP (R1), 0 } },
504 & ifmt_add, { 0xa4000000 }
506 /* xnori $r1,$r0,$uimm */
509 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (UIMM), 0 } },
510 & ifmt_andi, { 0x24000000 }
516 & ifmt_break, { 0xac000002 }
522 & ifmt_break, { 0xac000007 }
528 & ifmt_bret, { 0xc3e00000 }
534 & ifmt_bret, { 0xc3c00000 }
540 & ifmt_bret, { 0xc3a00000 }
545 { { MNEM, ' ', OP (R2), ',', OP (R0), 0 } },
546 & ifmt_sextb, { 0xb8000000 }
551 { { MNEM, ' ', OP (R1), ',', OP (IMM), 0 } },
552 & ifmt_mvi, { 0x34000000 }
557 { { MNEM, ' ', OP (R1), ',', OP (LO16), 0 } },
558 & ifmt_mvui, { 0x38000000 }
563 { { MNEM, ' ', OP (R1), ',', OP (HI16), 0 } },
564 & ifmt_mvhi, { 0x78000000 }
569 { { MNEM, ' ', OP (R1), ',', OP (GP16), 0 } },
570 & ifmt_mva, { 0x37400000 }
575 { { MNEM, ' ', OP (R2), ',', OP (R0), 0 } },
576 & ifmt_sextb, { 0xa4000000 }
582 & ifmt_nop, { 0x34000000 }
587 { { MNEM, ' ', OP (R1), ',', OP (GP16), 0 } },
588 & ifmt_mva, { 0x13400000 }
593 { { MNEM, ' ', OP (R1), ',', OP (GP16), 0 } },
594 & ifmt_mva, { 0x43400000 }
599 { { MNEM, ' ', OP (R1), ',', OP (GP16), 0 } },
600 & ifmt_mva, { 0x1f400000 }
605 { { MNEM, ' ', OP (R1), ',', OP (GP16), 0 } },
606 & ifmt_mva, { 0x2f400000 }
611 { { MNEM, ' ', OP (R1), ',', OP (GP16), 0 } },
612 & ifmt_mva, { 0x2b400000 }
617 { { MNEM, ' ', OP (GP16), ',', OP (R1), 0 } },
618 & ifmt_mva, { 0x33400000 }
623 { { MNEM, ' ', OP (GP16), ',', OP (R1), 0 } },
624 & ifmt_mva, { 0xf400000 }
629 { { MNEM, ' ', OP (GP16), ',', OP (R1), 0 } },
630 & ifmt_mva, { 0x5b400000 }
632 /* lw $r1,(gp+$got16) */
635 { { MNEM, ' ', OP (R1), ',', '(', 'g', 'p', '+', OP (GOT16), ')', 0 } },
636 & ifmt_lwgotrel, { 0x2b400000 }
638 /* orhi $r1,$r0,$gotoffhi16 */
641 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (GOTOFFHI16), 0 } },
642 & ifmt_orhigotoffi, { 0x78000000 }
644 /* addi $r1,$r0,$gotofflo16 */
647 { { MNEM, ' ', OP (R1), ',', OP (R0), ',', OP (GOTOFFLO16), 0 } },
648 & ifmt_addgotoff, { 0x34000000 }
650 /* sw ($r0+$gotofflo16),$r1 */
653 { { MNEM, ' ', '(', OP (R0), '+', OP (GOTOFFLO16), ')', ',', OP (R1), 0 } },
654 & ifmt_addgotoff, { 0x58000000 }
656 /* lw $r1,($r0+$gotofflo16) */
659 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (GOTOFFLO16), ')', 0 } },
660 & ifmt_addgotoff, { 0x28000000 }
662 /* sh ($r0+$gotofflo16),$r1 */
665 { { MNEM, ' ', '(', OP (R0), '+', OP (GOTOFFLO16), ')', ',', OP (R1), 0 } },
666 & ifmt_addgotoff, { 0xc000000 }
668 /* lh $r1,($r0+$gotofflo16) */
671 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (GOTOFFLO16), ')', 0 } },
672 & ifmt_addgotoff, { 0x1c000000 }
674 /* lhu $r1,($r0+$gotofflo16) */
677 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (GOTOFFLO16), ')', 0 } },
678 & ifmt_addgotoff, { 0x2c000000 }
680 /* sb ($r0+$gotofflo16),$r1 */
683 { { MNEM, ' ', '(', OP (R0), '+', OP (GOTOFFLO16), ')', ',', OP (R1), 0 } },
684 & ifmt_addgotoff, { 0x30000000 }
686 /* lb $r1,($r0+$gotofflo16) */
689 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (GOTOFFLO16), ')', 0 } },
690 & ifmt_addgotoff, { 0x10000000 }
692 /* lbu $r1,($r0+$gotofflo16) */
695 { { MNEM, ' ', OP (R1), ',', '(', OP (R0), '+', OP (GOTOFFLO16), ')', 0 } },
696 & ifmt_addgotoff, { 0x40000000 }
705 /* Formats for ALIAS macro-insns. */
707 #define F(f) & lm32_cgen_ifld_table[LM32_##f]
710 /* Each non-simple macro entry points to an array of expansion possibilities. */
712 #define A(a) (1 << CGEN_INSN_##a)
713 #define OPERAND(op) LM32_OPERAND_##op
714 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
715 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
717 /* The macro instruction table. */
719 static const CGEN_IBASE lm32_cgen_macro_insn_table[] =
723 /* The macro instruction opcode table. */
725 static const CGEN_OPCODE lm32_cgen_macro_insn_opcode_table[] =
734 #ifndef CGEN_ASM_HASH_P
735 #define CGEN_ASM_HASH_P(insn) 1
738 #ifndef CGEN_DIS_HASH_P
739 #define CGEN_DIS_HASH_P(insn) 1
742 /* Return non-zero if INSN is to be added to the hash table.
743 Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file. */
746 asm_hash_insn_p (const CGEN_INSN *insn ATTRIBUTE_UNUSED)
748 return CGEN_ASM_HASH_P (insn);
752 dis_hash_insn_p (const CGEN_INSN *insn)
754 /* If building the hash table and the NO-DIS attribute is present,
756 if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS))
758 return CGEN_DIS_HASH_P (insn);
761 #ifndef CGEN_ASM_HASH
762 #define CGEN_ASM_HASH_SIZE 127
763 #ifdef CGEN_MNEMONIC_OPERANDS
764 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE)
766 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/
770 /* It doesn't make much sense to provide a default here,
771 but while this is under development we do.
772 BUFFER is a pointer to the bytes of the insn, target order.
773 VALUE is the first base_insn_bitsize bits as an int in host order. */
775 #ifndef CGEN_DIS_HASH
776 #define CGEN_DIS_HASH_SIZE 256
777 #define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf))
780 /* The result is the hash value of the insn.
781 Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file. */
784 asm_hash_insn (const char *mnem)
786 return CGEN_ASM_HASH (mnem);
789 /* BUF is a pointer to the bytes of the insn, target order.
790 VALUE is the first base_insn_bitsize bits as an int in host order. */
793 dis_hash_insn (const char *buf ATTRIBUTE_UNUSED,
794 CGEN_INSN_INT value ATTRIBUTE_UNUSED)
796 return CGEN_DIS_HASH (buf, value);
799 /* Set the recorded length of the insn in the CGEN_FIELDS struct. */
802 set_fields_bitsize (CGEN_FIELDS *fields, int size)
804 CGEN_FIELDS_BITSIZE (fields) = size;
807 /* Function to call before using the operand instance table.
808 This plugs the opcode entries and macro instructions into the cpu table. */
811 lm32_cgen_init_opcode_table (CGEN_CPU_DESC cd)
814 int num_macros = (sizeof (lm32_cgen_macro_insn_table) /
815 sizeof (lm32_cgen_macro_insn_table[0]));
816 const CGEN_IBASE *ib = & lm32_cgen_macro_insn_table[0];
817 const CGEN_OPCODE *oc = & lm32_cgen_macro_insn_opcode_table[0];
818 CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN));
820 /* This test has been added to avoid a warning generated
821 if memset is called with a third argument of value zero. */
823 memset (insns, 0, num_macros * sizeof (CGEN_INSN));
824 for (i = 0; i < num_macros; ++i)
826 insns[i].base = &ib[i];
827 insns[i].opcode = &oc[i];
828 lm32_cgen_build_insn_regex (& insns[i]);
830 cd->macro_insn_table.init_entries = insns;
831 cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE);
832 cd->macro_insn_table.num_init_entries = num_macros;
834 oc = & lm32_cgen_insn_opcode_table[0];
835 insns = (CGEN_INSN *) cd->insn_table.init_entries;
836 for (i = 0; i < MAX_INSNS; ++i)
838 insns[i].opcode = &oc[i];
839 lm32_cgen_build_insn_regex (& insns[i]);
842 cd->sizeof_fields = sizeof (CGEN_FIELDS);
843 cd->set_fields_bitsize = set_fields_bitsize;
845 cd->asm_hash_p = asm_hash_insn_p;
846 cd->asm_hash = asm_hash_insn;
847 cd->asm_hash_size = CGEN_ASM_HASH_SIZE;
849 cd->dis_hash_p = dis_hash_insn_p;
850 cd->dis_hash = dis_hash_insn;
851 cd->dis_hash_size = CGEN_DIS_HASH_SIZE;