Initial revision
[binutils.git] / opcodes / m32r-opc.c
blob43edf9ae1f73490c5164304cd8c4456c9987098f
1 /* Instruction opcode table for m32r.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
7 This file is part of the GNU Binutils and/or GDB, the GNU debugger.
9 This program 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 2, or (at your option)
12 any later version.
14 This program 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 along
20 with this program; if not, write to the Free Software Foundation, Inc.,
21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "sysdep.h"
26 #include "ansidecl.h"
27 #include "bfd.h"
28 #include "symcat.h"
29 #include "m32r-desc.h"
30 #include "m32r-opc.h"
32 /* The hash functions are recorded here to help keep assembler code out of
33 the disassembler and vice versa. */
35 static int asm_hash_insn_p PARAMS ((const CGEN_INSN *));
36 static unsigned int asm_hash_insn PARAMS ((const char *));
37 static int dis_hash_insn_p PARAMS ((const CGEN_INSN *));
38 static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT));
40 /* Instruction formats. */
42 #define F(f) & m32r_cgen_ifld_table[CONCAT2 (M32R_,f)]
44 static const CGEN_IFMT ifmt_empty = {
45 0, 0, 0x0, { 0 }
48 static const CGEN_IFMT ifmt_add = {
49 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
52 static const CGEN_IFMT ifmt_add3 = {
53 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
56 static const CGEN_IFMT ifmt_and3 = {
57 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_UIMM16), 0 }
60 static const CGEN_IFMT ifmt_or3 = {
61 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_UIMM16), 0 }
64 static const CGEN_IFMT ifmt_addi = {
65 16, 16, 0xf000, { F (F_OP1), F (F_R1), F (F_SIMM8), 0 }
68 static const CGEN_IFMT ifmt_addv3 = {
69 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
72 static const CGEN_IFMT ifmt_bc8 = {
73 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
76 static const CGEN_IFMT ifmt_bc24 = {
77 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
80 static const CGEN_IFMT ifmt_beq = {
81 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_DISP16), 0 }
84 static const CGEN_IFMT ifmt_beqz = {
85 32, 32, 0xfff00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_DISP16), 0 }
88 static const CGEN_IFMT ifmt_cmp = {
89 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
92 static const CGEN_IFMT ifmt_cmpi = {
93 32, 32, 0xfff00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
96 static const CGEN_IFMT ifmt_div = {
97 32, 32, 0xf0f0ffff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
100 static const CGEN_IFMT ifmt_jl = {
101 16, 16, 0xfff0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
104 static const CGEN_IFMT ifmt_ld24 = {
105 32, 32, 0xf0000000, { F (F_OP1), F (F_R1), F (F_UIMM24), 0 }
108 static const CGEN_IFMT ifmt_ldi16 = {
109 32, 32, 0xf0ff0000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
112 static const CGEN_IFMT ifmt_mvfachi = {
113 16, 16, 0xf0ff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
116 static const CGEN_IFMT ifmt_mvfc = {
117 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
120 static const CGEN_IFMT ifmt_mvtachi = {
121 16, 16, 0xf0ff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
124 static const CGEN_IFMT ifmt_mvtc = {
125 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
128 static const CGEN_IFMT ifmt_nop = {
129 16, 16, 0xffff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
132 static const CGEN_IFMT ifmt_seth = {
133 32, 32, 0xf0ff0000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_HI16), 0 }
136 static const CGEN_IFMT ifmt_slli = {
137 16, 16, 0xf0e0, { F (F_OP1), F (F_R1), F (F_SHIFT_OP2), F (F_UIMM5), 0 }
140 static const CGEN_IFMT ifmt_st_d = {
141 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
144 static const CGEN_IFMT ifmt_trap = {
145 16, 16, 0xfff0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_UIMM4), 0 }
148 #undef F
150 #define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
151 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
152 #define OPERAND(op) CONCAT2 (M32R_OPERAND_,op)
153 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
155 /* The instruction table. */
157 static const CGEN_OPCODE m32r_cgen_insn_opcode_table[MAX_INSNS] =
159 /* Special null first entry.
160 A `num' value of zero is thus invalid.
161 Also, the special `invalid' insn resides here. */
162 { { 0 } },
163 /* add $dr,$sr */
165 { 0, 0, 0, 0 },
166 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
167 & ifmt_add, { 0xa0 }
169 /* add3 $dr,$sr,$hash$slo16 */
171 { 0, 0, 0, 0 },
172 { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (HASH), OP (SLO16), 0 } },
173 & ifmt_add3, { 0x80a00000 }
175 /* and $dr,$sr */
177 { 0, 0, 0, 0 },
178 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
179 & ifmt_add, { 0xc0 }
181 /* and3 $dr,$sr,$uimm16 */
183 { 0, 0, 0, 0 },
184 { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (UIMM16), 0 } },
185 & ifmt_and3, { 0x80c00000 }
187 /* or $dr,$sr */
189 { 0, 0, 0, 0 },
190 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
191 & ifmt_add, { 0xe0 }
193 /* or3 $dr,$sr,$hash$ulo16 */
195 { 0, 0, 0, 0 },
196 { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (HASH), OP (ULO16), 0 } },
197 & ifmt_or3, { 0x80e00000 }
199 /* xor $dr,$sr */
201 { 0, 0, 0, 0 },
202 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
203 & ifmt_add, { 0xd0 }
205 /* xor3 $dr,$sr,$uimm16 */
207 { 0, 0, 0, 0 },
208 { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (UIMM16), 0 } },
209 & ifmt_and3, { 0x80d00000 }
211 /* addi $dr,$simm8 */
213 { 0, 0, 0, 0 },
214 { { MNEM, ' ', OP (DR), ',', OP (SIMM8), 0 } },
215 & ifmt_addi, { 0x4000 }
217 /* addv $dr,$sr */
219 { 0, 0, 0, 0 },
220 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
221 & ifmt_add, { 0x80 }
223 /* addv3 $dr,$sr,$simm16 */
225 { 0, 0, 0, 0 },
226 { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (SIMM16), 0 } },
227 & ifmt_addv3, { 0x80800000 }
229 /* addx $dr,$sr */
231 { 0, 0, 0, 0 },
232 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
233 & ifmt_add, { 0x90 }
235 /* bc.s $disp8 */
237 { 0, 0, 0, 0 },
238 { { MNEM, ' ', OP (DISP8), 0 } },
239 & ifmt_bc8, { 0x7c00 }
241 /* bc.l $disp24 */
243 { 0, 0, 0, 0 },
244 { { MNEM, ' ', OP (DISP24), 0 } },
245 & ifmt_bc24, { 0xfc000000 }
247 /* beq $src1,$src2,$disp16 */
249 { 0, 0, 0, 0 },
250 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), ',', OP (DISP16), 0 } },
251 & ifmt_beq, { 0xb0000000 }
253 /* beqz $src2,$disp16 */
255 { 0, 0, 0, 0 },
256 { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
257 & ifmt_beqz, { 0xb0800000 }
259 /* bgez $src2,$disp16 */
261 { 0, 0, 0, 0 },
262 { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
263 & ifmt_beqz, { 0xb0b00000 }
265 /* bgtz $src2,$disp16 */
267 { 0, 0, 0, 0 },
268 { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
269 & ifmt_beqz, { 0xb0d00000 }
271 /* blez $src2,$disp16 */
273 { 0, 0, 0, 0 },
274 { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
275 & ifmt_beqz, { 0xb0c00000 }
277 /* bltz $src2,$disp16 */
279 { 0, 0, 0, 0 },
280 { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
281 & ifmt_beqz, { 0xb0a00000 }
283 /* bnez $src2,$disp16 */
285 { 0, 0, 0, 0 },
286 { { MNEM, ' ', OP (SRC2), ',', OP (DISP16), 0 } },
287 & ifmt_beqz, { 0xb0900000 }
289 /* bl.s $disp8 */
291 { 0, 0, 0, 0 },
292 { { MNEM, ' ', OP (DISP8), 0 } },
293 & ifmt_bc8, { 0x7e00 }
295 /* bl.l $disp24 */
297 { 0, 0, 0, 0 },
298 { { MNEM, ' ', OP (DISP24), 0 } },
299 & ifmt_bc24, { 0xfe000000 }
301 /* bnc.s $disp8 */
303 { 0, 0, 0, 0 },
304 { { MNEM, ' ', OP (DISP8), 0 } },
305 & ifmt_bc8, { 0x7d00 }
307 /* bnc.l $disp24 */
309 { 0, 0, 0, 0 },
310 { { MNEM, ' ', OP (DISP24), 0 } },
311 & ifmt_bc24, { 0xfd000000 }
313 /* bne $src1,$src2,$disp16 */
315 { 0, 0, 0, 0 },
316 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), ',', OP (DISP16), 0 } },
317 & ifmt_beq, { 0xb0100000 }
319 /* bra.s $disp8 */
321 { 0, 0, 0, 0 },
322 { { MNEM, ' ', OP (DISP8), 0 } },
323 & ifmt_bc8, { 0x7f00 }
325 /* bra.l $disp24 */
327 { 0, 0, 0, 0 },
328 { { MNEM, ' ', OP (DISP24), 0 } },
329 & ifmt_bc24, { 0xff000000 }
331 /* cmp $src1,$src2 */
333 { 0, 0, 0, 0 },
334 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
335 & ifmt_cmp, { 0x40 }
337 /* cmpi $src2,$simm16 */
339 { 0, 0, 0, 0 },
340 { { MNEM, ' ', OP (SRC2), ',', OP (SIMM16), 0 } },
341 & ifmt_cmpi, { 0x80400000 }
343 /* cmpu $src1,$src2 */
345 { 0, 0, 0, 0 },
346 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
347 & ifmt_cmp, { 0x50 }
349 /* cmpui $src2,$simm16 */
351 { 0, 0, 0, 0 },
352 { { MNEM, ' ', OP (SRC2), ',', OP (SIMM16), 0 } },
353 & ifmt_cmpi, { 0x80500000 }
355 /* div $dr,$sr */
357 { 0, 0, 0, 0 },
358 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
359 & ifmt_div, { 0x90000000 }
361 /* divu $dr,$sr */
363 { 0, 0, 0, 0 },
364 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
365 & ifmt_div, { 0x90100000 }
367 /* rem $dr,$sr */
369 { 0, 0, 0, 0 },
370 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
371 & ifmt_div, { 0x90200000 }
373 /* remu $dr,$sr */
375 { 0, 0, 0, 0 },
376 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
377 & ifmt_div, { 0x90300000 }
379 /* jl $sr */
381 { 0, 0, 0, 0 },
382 { { MNEM, ' ', OP (SR), 0 } },
383 & ifmt_jl, { 0x1ec0 }
385 /* jmp $sr */
387 { 0, 0, 0, 0 },
388 { { MNEM, ' ', OP (SR), 0 } },
389 & ifmt_jl, { 0x1fc0 }
391 /* ld $dr,@$sr */
393 { 0, 0, 0, 0 },
394 { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
395 & ifmt_add, { 0x20c0 }
397 /* ld $dr,@($slo16,$sr) */
399 { 0, 0, 0, 0 },
400 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
401 & ifmt_add3, { 0xa0c00000 }
403 /* ldb $dr,@$sr */
405 { 0, 0, 0, 0 },
406 { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
407 & ifmt_add, { 0x2080 }
409 /* ldb $dr,@($slo16,$sr) */
411 { 0, 0, 0, 0 },
412 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
413 & ifmt_add3, { 0xa0800000 }
415 /* ldh $dr,@$sr */
417 { 0, 0, 0, 0 },
418 { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
419 & ifmt_add, { 0x20a0 }
421 /* ldh $dr,@($slo16,$sr) */
423 { 0, 0, 0, 0 },
424 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
425 & ifmt_add3, { 0xa0a00000 }
427 /* ldub $dr,@$sr */
429 { 0, 0, 0, 0 },
430 { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
431 & ifmt_add, { 0x2090 }
433 /* ldub $dr,@($slo16,$sr) */
435 { 0, 0, 0, 0 },
436 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
437 & ifmt_add3, { 0xa0900000 }
439 /* lduh $dr,@$sr */
441 { 0, 0, 0, 0 },
442 { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
443 & ifmt_add, { 0x20b0 }
445 /* lduh $dr,@($slo16,$sr) */
447 { 0, 0, 0, 0 },
448 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SLO16), ',', OP (SR), ')', 0 } },
449 & ifmt_add3, { 0xa0b00000 }
451 /* ld $dr,@$sr+ */
453 { 0, 0, 0, 0 },
454 { { MNEM, ' ', OP (DR), ',', '@', OP (SR), '+', 0 } },
455 & ifmt_add, { 0x20e0 }
457 /* ld24 $dr,$uimm24 */
459 { 0, 0, 0, 0 },
460 { { MNEM, ' ', OP (DR), ',', OP (UIMM24), 0 } },
461 & ifmt_ld24, { 0xe0000000 }
463 /* ldi8 $dr,$simm8 */
465 { 0, 0, 0, 0 },
466 { { MNEM, ' ', OP (DR), ',', OP (SIMM8), 0 } },
467 & ifmt_addi, { 0x6000 }
469 /* ldi16 $dr,$hash$slo16 */
471 { 0, 0, 0, 0 },
472 { { MNEM, ' ', OP (DR), ',', OP (HASH), OP (SLO16), 0 } },
473 & ifmt_ldi16, { 0x90f00000 }
475 /* lock $dr,@$sr */
477 { 0, 0, 0, 0 },
478 { { MNEM, ' ', OP (DR), ',', '@', OP (SR), 0 } },
479 & ifmt_add, { 0x20d0 }
481 /* machi $src1,$src2 */
483 { 0, 0, 0, 0 },
484 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
485 & ifmt_cmp, { 0x3040 }
487 /* maclo $src1,$src2 */
489 { 0, 0, 0, 0 },
490 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
491 & ifmt_cmp, { 0x3050 }
493 /* macwhi $src1,$src2 */
495 { 0, 0, 0, 0 },
496 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
497 & ifmt_cmp, { 0x3060 }
499 /* macwlo $src1,$src2 */
501 { 0, 0, 0, 0 },
502 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
503 & ifmt_cmp, { 0x3070 }
505 /* mul $dr,$sr */
507 { 0, 0, 0, 0 },
508 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
509 & ifmt_add, { 0x1060 }
511 /* mulhi $src1,$src2 */
513 { 0, 0, 0, 0 },
514 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
515 & ifmt_cmp, { 0x3000 }
517 /* mullo $src1,$src2 */
519 { 0, 0, 0, 0 },
520 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
521 & ifmt_cmp, { 0x3010 }
523 /* mulwhi $src1,$src2 */
525 { 0, 0, 0, 0 },
526 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
527 & ifmt_cmp, { 0x3020 }
529 /* mulwlo $src1,$src2 */
531 { 0, 0, 0, 0 },
532 { { MNEM, ' ', OP (SRC1), ',', OP (SRC2), 0 } },
533 & ifmt_cmp, { 0x3030 }
535 /* mv $dr,$sr */
537 { 0, 0, 0, 0 },
538 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
539 & ifmt_add, { 0x1080 }
541 /* mvfachi $dr */
543 { 0, 0, 0, 0 },
544 { { MNEM, ' ', OP (DR), 0 } },
545 & ifmt_mvfachi, { 0x50f0 }
547 /* mvfaclo $dr */
549 { 0, 0, 0, 0 },
550 { { MNEM, ' ', OP (DR), 0 } },
551 & ifmt_mvfachi, { 0x50f1 }
553 /* mvfacmi $dr */
555 { 0, 0, 0, 0 },
556 { { MNEM, ' ', OP (DR), 0 } },
557 & ifmt_mvfachi, { 0x50f2 }
559 /* mvfc $dr,$scr */
561 { 0, 0, 0, 0 },
562 { { MNEM, ' ', OP (DR), ',', OP (SCR), 0 } },
563 & ifmt_mvfc, { 0x1090 }
565 /* mvtachi $src1 */
567 { 0, 0, 0, 0 },
568 { { MNEM, ' ', OP (SRC1), 0 } },
569 & ifmt_mvtachi, { 0x5070 }
571 /* mvtaclo $src1 */
573 { 0, 0, 0, 0 },
574 { { MNEM, ' ', OP (SRC1), 0 } },
575 & ifmt_mvtachi, { 0x5071 }
577 /* mvtc $sr,$dcr */
579 { 0, 0, 0, 0 },
580 { { MNEM, ' ', OP (SR), ',', OP (DCR), 0 } },
581 & ifmt_mvtc, { 0x10a0 }
583 /* neg $dr,$sr */
585 { 0, 0, 0, 0 },
586 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
587 & ifmt_add, { 0x30 }
589 /* nop */
591 { 0, 0, 0, 0 },
592 { { MNEM, 0 } },
593 & ifmt_nop, { 0x7000 }
595 /* not $dr,$sr */
597 { 0, 0, 0, 0 },
598 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
599 & ifmt_add, { 0xb0 }
601 /* rac */
603 { 0, 0, 0, 0 },
604 { { MNEM, 0 } },
605 & ifmt_nop, { 0x5090 }
607 /* rach */
609 { 0, 0, 0, 0 },
610 { { MNEM, 0 } },
611 & ifmt_nop, { 0x5080 }
613 /* rte */
615 { 0, 0, 0, 0 },
616 { { MNEM, 0 } },
617 & ifmt_nop, { 0x10d6 }
619 /* seth $dr,$hash$hi16 */
621 { 0, 0, 0, 0 },
622 { { MNEM, ' ', OP (DR), ',', OP (HASH), OP (HI16), 0 } },
623 & ifmt_seth, { 0xd0c00000 }
625 /* sll $dr,$sr */
627 { 0, 0, 0, 0 },
628 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
629 & ifmt_add, { 0x1040 }
631 /* sll3 $dr,$sr,$simm16 */
633 { 0, 0, 0, 0 },
634 { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (SIMM16), 0 } },
635 & ifmt_addv3, { 0x90c00000 }
637 /* slli $dr,$uimm5 */
639 { 0, 0, 0, 0 },
640 { { MNEM, ' ', OP (DR), ',', OP (UIMM5), 0 } },
641 & ifmt_slli, { 0x5040 }
643 /* sra $dr,$sr */
645 { 0, 0, 0, 0 },
646 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
647 & ifmt_add, { 0x1020 }
649 /* sra3 $dr,$sr,$simm16 */
651 { 0, 0, 0, 0 },
652 { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (SIMM16), 0 } },
653 & ifmt_addv3, { 0x90a00000 }
655 /* srai $dr,$uimm5 */
657 { 0, 0, 0, 0 },
658 { { MNEM, ' ', OP (DR), ',', OP (UIMM5), 0 } },
659 & ifmt_slli, { 0x5020 }
661 /* srl $dr,$sr */
663 { 0, 0, 0, 0 },
664 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
665 & ifmt_add, { 0x1000 }
667 /* srl3 $dr,$sr,$simm16 */
669 { 0, 0, 0, 0 },
670 { { MNEM, ' ', OP (DR), ',', OP (SR), ',', OP (SIMM16), 0 } },
671 & ifmt_addv3, { 0x90800000 }
673 /* srli $dr,$uimm5 */
675 { 0, 0, 0, 0 },
676 { { MNEM, ' ', OP (DR), ',', OP (UIMM5), 0 } },
677 & ifmt_slli, { 0x5000 }
679 /* st $src1,@$src2 */
681 { 0, 0, 0, 0 },
682 { { MNEM, ' ', OP (SRC1), ',', '@', OP (SRC2), 0 } },
683 & ifmt_cmp, { 0x2040 }
685 /* st $src1,@($slo16,$src2) */
687 { 0, 0, 0, 0 },
688 { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SLO16), ',', OP (SRC2), ')', 0 } },
689 & ifmt_st_d, { 0xa0400000 }
691 /* stb $src1,@$src2 */
693 { 0, 0, 0, 0 },
694 { { MNEM, ' ', OP (SRC1), ',', '@', OP (SRC2), 0 } },
695 & ifmt_cmp, { 0x2000 }
697 /* stb $src1,@($slo16,$src2) */
699 { 0, 0, 0, 0 },
700 { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SLO16), ',', OP (SRC2), ')', 0 } },
701 & ifmt_st_d, { 0xa0000000 }
703 /* sth $src1,@$src2 */
705 { 0, 0, 0, 0 },
706 { { MNEM, ' ', OP (SRC1), ',', '@', OP (SRC2), 0 } },
707 & ifmt_cmp, { 0x2020 }
709 /* sth $src1,@($slo16,$src2) */
711 { 0, 0, 0, 0 },
712 { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SLO16), ',', OP (SRC2), ')', 0 } },
713 & ifmt_st_d, { 0xa0200000 }
715 /* st $src1,@+$src2 */
717 { 0, 0, 0, 0 },
718 { { MNEM, ' ', OP (SRC1), ',', '@', '+', OP (SRC2), 0 } },
719 & ifmt_cmp, { 0x2060 }
721 /* st $src1,@-$src2 */
723 { 0, 0, 0, 0 },
724 { { MNEM, ' ', OP (SRC1), ',', '@', '-', OP (SRC2), 0 } },
725 & ifmt_cmp, { 0x2070 }
727 /* sub $dr,$sr */
729 { 0, 0, 0, 0 },
730 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
731 & ifmt_add, { 0x20 }
733 /* subv $dr,$sr */
735 { 0, 0, 0, 0 },
736 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
737 & ifmt_add, { 0x0 }
739 /* subx $dr,$sr */
741 { 0, 0, 0, 0 },
742 { { MNEM, ' ', OP (DR), ',', OP (SR), 0 } },
743 & ifmt_add, { 0x10 }
745 /* trap $uimm4 */
747 { 0, 0, 0, 0 },
748 { { MNEM, ' ', OP (UIMM4), 0 } },
749 & ifmt_trap, { 0x10f0 }
751 /* unlock $src1,@$src2 */
753 { 0, 0, 0, 0 },
754 { { MNEM, ' ', OP (SRC1), ',', '@', OP (SRC2), 0 } },
755 & ifmt_cmp, { 0x2050 }
759 #undef A
760 #undef MNEM
761 #undef OPERAND
762 #undef OP
764 /* Formats for ALIAS macro-insns. */
766 #define F(f) & m32r_cgen_ifld_table[CONCAT2 (M32R_,f)]
768 static const CGEN_IFMT ifmt_bc8r = {
769 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
772 static const CGEN_IFMT ifmt_bc24r = {
773 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
776 static const CGEN_IFMT ifmt_bl8r = {
777 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
780 static const CGEN_IFMT ifmt_bl24r = {
781 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
784 static const CGEN_IFMT ifmt_bnc8r = {
785 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
788 static const CGEN_IFMT ifmt_bnc24r = {
789 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
792 static const CGEN_IFMT ifmt_bra8r = {
793 16, 16, 0xff00, { F (F_OP1), F (F_R1), F (F_DISP8), 0 }
796 static const CGEN_IFMT ifmt_bra24r = {
797 32, 32, 0xff000000, { F (F_OP1), F (F_R1), F (F_DISP24), 0 }
800 static const CGEN_IFMT ifmt_ld_2 = {
801 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
804 static const CGEN_IFMT ifmt_ld_d2 = {
805 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
808 static const CGEN_IFMT ifmt_ldb_2 = {
809 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
812 static const CGEN_IFMT ifmt_ldb_d2 = {
813 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
816 static const CGEN_IFMT ifmt_ldh_2 = {
817 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
820 static const CGEN_IFMT ifmt_ldh_d2 = {
821 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
824 static const CGEN_IFMT ifmt_ldub_2 = {
825 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
828 static const CGEN_IFMT ifmt_ldub_d2 = {
829 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
832 static const CGEN_IFMT ifmt_lduh_2 = {
833 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
836 static const CGEN_IFMT ifmt_lduh_d2 = {
837 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
840 static const CGEN_IFMT ifmt_pop = {
841 16, 16, 0xf0ff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
844 static const CGEN_IFMT ifmt_ldi8a = {
845 16, 16, 0xf000, { F (F_OP1), F (F_R1), F (F_SIMM8), 0 }
848 static const CGEN_IFMT ifmt_ldi16a = {
849 32, 32, 0xf0ff0000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
852 static const CGEN_IFMT ifmt_st_2 = {
853 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
856 static const CGEN_IFMT ifmt_st_d2 = {
857 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
860 static const CGEN_IFMT ifmt_stb_2 = {
861 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
864 static const CGEN_IFMT ifmt_stb_d2 = {
865 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
868 static const CGEN_IFMT ifmt_sth_2 = {
869 16, 16, 0xf0f0, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
872 static const CGEN_IFMT ifmt_sth_d2 = {
873 32, 32, 0xf0f00000, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), F (F_SIMM16), 0 }
876 static const CGEN_IFMT ifmt_push = {
877 16, 16, 0xf0ff, { F (F_OP1), F (F_R1), F (F_OP2), F (F_R2), 0 }
880 #undef F
882 /* Each non-simple macro entry points to an array of expansion possibilities. */
884 #define A(a) (1 << CONCAT2 (CGEN_INSN_,a))
885 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
886 #define OPERAND(op) CONCAT2 (M32R_OPERAND_,op)
887 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
889 /* The macro instruction table. */
891 static const CGEN_IBASE m32r_cgen_macro_insn_table[] =
893 /* bc $disp8 */
895 -1, "bc8r", "bc", 16,
896 { 0|A(RELAXABLE)|A(COND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
898 /* bc $disp24 */
900 -1, "bc24r", "bc", 32,
901 { 0|A(RELAX)|A(COND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
903 /* bl $disp8 */
905 -1, "bl8r", "bl", 16,
906 { 0|A(RELAXABLE)|A(FILL_SLOT)|A(UNCOND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
908 /* bl $disp24 */
910 -1, "bl24r", "bl", 32,
911 { 0|A(RELAX)|A(UNCOND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
913 /* bnc $disp8 */
915 -1, "bnc8r", "bnc", 16,
916 { 0|A(RELAXABLE)|A(COND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
918 /* bnc $disp24 */
920 -1, "bnc24r", "bnc", 32,
921 { 0|A(RELAX)|A(COND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
923 /* bra $disp8 */
925 -1, "bra8r", "bra", 16,
926 { 0|A(RELAXABLE)|A(FILL_SLOT)|A(UNCOND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
928 /* bra $disp24 */
930 -1, "bra24r", "bra", 32,
931 { 0|A(RELAX)|A(UNCOND_CTI)|A(ALIAS), { (1<<MACH_BASE) } }
933 /* ld $dr,@($sr) */
935 -1, "ld-2", "ld", 16,
936 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
938 /* ld $dr,@($sr,$slo16) */
940 -1, "ld-d2", "ld", 32,
941 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
943 /* ldb $dr,@($sr) */
945 -1, "ldb-2", "ldb", 16,
946 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
948 /* ldb $dr,@($sr,$slo16) */
950 -1, "ldb-d2", "ldb", 32,
951 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
953 /* ldh $dr,@($sr) */
955 -1, "ldh-2", "ldh", 16,
956 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
958 /* ldh $dr,@($sr,$slo16) */
960 -1, "ldh-d2", "ldh", 32,
961 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
963 /* ldub $dr,@($sr) */
965 -1, "ldub-2", "ldub", 16,
966 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
968 /* ldub $dr,@($sr,$slo16) */
970 -1, "ldub-d2", "ldub", 32,
971 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
973 /* lduh $dr,@($sr) */
975 -1, "lduh-2", "lduh", 16,
976 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
978 /* lduh $dr,@($sr,$slo16) */
980 -1, "lduh-d2", "lduh", 32,
981 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
983 /* pop $dr */
985 -1, "pop", "pop", 16,
986 { 0|A(ALIAS), { (1<<MACH_BASE) } }
988 /* ldi $dr,$simm8 */
990 -1, "ldi8a", "ldi", 16,
991 { 0|A(ALIAS), { (1<<MACH_BASE) } }
993 /* ldi $dr,$hash$slo16 */
995 -1, "ldi16a", "ldi", 32,
996 { 0|A(ALIAS), { (1<<MACH_BASE) } }
998 /* st $src1,@($src2) */
1000 -1, "st-2", "st", 16,
1001 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
1003 /* st $src1,@($src2,$slo16) */
1005 -1, "st-d2", "st", 32,
1006 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
1008 /* stb $src1,@($src2) */
1010 -1, "stb-2", "stb", 16,
1011 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
1013 /* stb $src1,@($src2,$slo16) */
1015 -1, "stb-d2", "stb", 32,
1016 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
1018 /* sth $src1,@($src2) */
1020 -1, "sth-2", "sth", 16,
1021 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
1023 /* sth $src1,@($src2,$slo16) */
1025 -1, "sth-d2", "sth", 32,
1026 { 0|A(NO_DIS)|A(ALIAS), { (1<<MACH_BASE) } }
1028 /* push $src1 */
1030 -1, "push", "push", 16,
1031 { 0|A(ALIAS), { (1<<MACH_BASE) } }
1035 /* The macro instruction opcode table. */
1037 static const CGEN_OPCODE m32r_cgen_macro_insn_opcode_table[] =
1039 /* bc $disp8 */
1041 { 0, 0, 0, 0 },
1042 { { MNEM, ' ', OP (DISP8), 0 } },
1043 & ifmt_bc8r, { 0x7c00 }
1045 /* bc $disp24 */
1047 { 0, 0, 0, 0 },
1048 { { MNEM, ' ', OP (DISP24), 0 } },
1049 & ifmt_bc24r, { 0xfc000000 }
1051 /* bl $disp8 */
1053 { 0, 0, 0, 0 },
1054 { { MNEM, ' ', OP (DISP8), 0 } },
1055 & ifmt_bl8r, { 0x7e00 }
1057 /* bl $disp24 */
1059 { 0, 0, 0, 0 },
1060 { { MNEM, ' ', OP (DISP24), 0 } },
1061 & ifmt_bl24r, { 0xfe000000 }
1063 /* bnc $disp8 */
1065 { 0, 0, 0, 0 },
1066 { { MNEM, ' ', OP (DISP8), 0 } },
1067 & ifmt_bnc8r, { 0x7d00 }
1069 /* bnc $disp24 */
1071 { 0, 0, 0, 0 },
1072 { { MNEM, ' ', OP (DISP24), 0 } },
1073 & ifmt_bnc24r, { 0xfd000000 }
1075 /* bra $disp8 */
1077 { 0, 0, 0, 0 },
1078 { { MNEM, ' ', OP (DISP8), 0 } },
1079 & ifmt_bra8r, { 0x7f00 }
1081 /* bra $disp24 */
1083 { 0, 0, 0, 0 },
1084 { { MNEM, ' ', OP (DISP24), 0 } },
1085 & ifmt_bra24r, { 0xff000000 }
1087 /* ld $dr,@($sr) */
1089 { 0, 0, 0, 0 },
1090 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
1091 & ifmt_ld_2, { 0x20c0 }
1093 /* ld $dr,@($sr,$slo16) */
1095 { 0, 0, 0, 0 },
1096 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
1097 & ifmt_ld_d2, { 0xa0c00000 }
1099 /* ldb $dr,@($sr) */
1101 { 0, 0, 0, 0 },
1102 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
1103 & ifmt_ldb_2, { 0x2080 }
1105 /* ldb $dr,@($sr,$slo16) */
1107 { 0, 0, 0, 0 },
1108 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
1109 & ifmt_ldb_d2, { 0xa0800000 }
1111 /* ldh $dr,@($sr) */
1113 { 0, 0, 0, 0 },
1114 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
1115 & ifmt_ldh_2, { 0x20a0 }
1117 /* ldh $dr,@($sr,$slo16) */
1119 { 0, 0, 0, 0 },
1120 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
1121 & ifmt_ldh_d2, { 0xa0a00000 }
1123 /* ldub $dr,@($sr) */
1125 { 0, 0, 0, 0 },
1126 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
1127 & ifmt_ldub_2, { 0x2090 }
1129 /* ldub $dr,@($sr,$slo16) */
1131 { 0, 0, 0, 0 },
1132 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
1133 & ifmt_ldub_d2, { 0xa0900000 }
1135 /* lduh $dr,@($sr) */
1137 { 0, 0, 0, 0 },
1138 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ')', 0 } },
1139 & ifmt_lduh_2, { 0x20b0 }
1141 /* lduh $dr,@($sr,$slo16) */
1143 { 0, 0, 0, 0 },
1144 { { MNEM, ' ', OP (DR), ',', '@', '(', OP (SR), ',', OP (SLO16), ')', 0 } },
1145 & ifmt_lduh_d2, { 0xa0b00000 }
1147 /* pop $dr */
1149 { 0, 0, 0, 0 },
1150 { { MNEM, ' ', OP (DR), 0 } },
1151 & ifmt_pop, { 0x20ef }
1153 /* ldi $dr,$simm8 */
1155 { 0, 0, 0, 0 },
1156 { { MNEM, ' ', OP (DR), ',', OP (SIMM8), 0 } },
1157 & ifmt_ldi8a, { 0x6000 }
1159 /* ldi $dr,$hash$slo16 */
1161 { 0, 0, 0, 0 },
1162 { { MNEM, ' ', OP (DR), ',', OP (HASH), OP (SLO16), 0 } },
1163 & ifmt_ldi16a, { 0x90f00000 }
1165 /* st $src1,@($src2) */
1167 { 0, 0, 0, 0 },
1168 { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ')', 0 } },
1169 & ifmt_st_2, { 0x2040 }
1171 /* st $src1,@($src2,$slo16) */
1173 { 0, 0, 0, 0 },
1174 { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ',', OP (SLO16), ')', 0 } },
1175 & ifmt_st_d2, { 0xa0400000 }
1177 /* stb $src1,@($src2) */
1179 { 0, 0, 0, 0 },
1180 { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ')', 0 } },
1181 & ifmt_stb_2, { 0x2000 }
1183 /* stb $src1,@($src2,$slo16) */
1185 { 0, 0, 0, 0 },
1186 { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ',', OP (SLO16), ')', 0 } },
1187 & ifmt_stb_d2, { 0xa0000000 }
1189 /* sth $src1,@($src2) */
1191 { 0, 0, 0, 0 },
1192 { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ')', 0 } },
1193 & ifmt_sth_2, { 0x2020 }
1195 /* sth $src1,@($src2,$slo16) */
1197 { 0, 0, 0, 0 },
1198 { { MNEM, ' ', OP (SRC1), ',', '@', '(', OP (SRC2), ',', OP (SLO16), ')', 0 } },
1199 & ifmt_sth_d2, { 0xa0200000 }
1201 /* push $src1 */
1203 { 0, 0, 0, 0 },
1204 { { MNEM, ' ', OP (SRC1), 0 } },
1205 & ifmt_push, { 0x207f }
1209 #undef A
1210 #undef MNEM
1211 #undef OPERAND
1212 #undef OP
1214 #ifndef CGEN_ASM_HASH_P
1215 #define CGEN_ASM_HASH_P(insn) 1
1216 #endif
1218 #ifndef CGEN_DIS_HASH_P
1219 #define CGEN_DIS_HASH_P(insn) 1
1220 #endif
1222 /* Return non-zero if INSN is to be added to the hash table.
1223 Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file. */
1225 static int
1226 asm_hash_insn_p (insn)
1227 const CGEN_INSN *insn;
1229 return CGEN_ASM_HASH_P (insn);
1232 static int
1233 dis_hash_insn_p (insn)
1234 const CGEN_INSN *insn;
1236 /* If building the hash table and the NO-DIS attribute is present,
1237 ignore. */
1238 if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS))
1239 return 0;
1240 return CGEN_DIS_HASH_P (insn);
1243 #ifndef CGEN_ASM_HASH
1244 #define CGEN_ASM_HASH_SIZE 127
1245 #ifdef CGEN_MNEMONIC_OPERANDS
1246 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE)
1247 #else
1248 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/
1249 #endif
1250 #endif
1252 /* It doesn't make much sense to provide a default here,
1253 but while this is under development we do.
1254 BUFFER is a pointer to the bytes of the insn, target order.
1255 VALUE is the first base_insn_bitsize bits as an int in host order. */
1257 #ifndef CGEN_DIS_HASH
1258 #define CGEN_DIS_HASH_SIZE 256
1259 #define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf))
1260 #endif
1262 /* The result is the hash value of the insn.
1263 Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file. */
1265 static unsigned int
1266 asm_hash_insn (mnem)
1267 const char * mnem;
1269 return CGEN_ASM_HASH (mnem);
1272 /* BUF is a pointer to the bytes of the insn, target order.
1273 VALUE is the first base_insn_bitsize bits as an int in host order. */
1275 static unsigned int
1276 dis_hash_insn (buf, value)
1277 const char * buf;
1278 CGEN_INSN_INT value;
1280 return CGEN_DIS_HASH (buf, value);
1283 /* Set the recorded length of the insn in the CGEN_FIELDS struct. */
1285 static void
1286 set_fields_bitsize (fields, size)
1287 CGEN_FIELDS *fields;
1288 int size;
1290 CGEN_FIELDS_BITSIZE (fields) = size;
1293 /* Function to call before using the operand instance table.
1294 This plugs the opcode entries and macro instructions into the cpu table. */
1296 void
1297 m32r_cgen_init_opcode_table (cd)
1298 CGEN_CPU_DESC cd;
1300 int i;
1301 int num_macros = (sizeof (m32r_cgen_macro_insn_table) /
1302 sizeof (m32r_cgen_macro_insn_table[0]));
1303 const CGEN_IBASE *ib = & m32r_cgen_macro_insn_table[0];
1304 const CGEN_OPCODE *oc = & m32r_cgen_macro_insn_opcode_table[0];
1305 CGEN_INSN *insns = (CGEN_INSN *) xmalloc (num_macros * sizeof (CGEN_INSN));
1306 memset (insns, 0, num_macros * sizeof (CGEN_INSN));
1307 for (i = 0; i < num_macros; ++i)
1309 insns[i].base = &ib[i];
1310 insns[i].opcode = &oc[i];
1312 cd->macro_insn_table.init_entries = insns;
1313 cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE);
1314 cd->macro_insn_table.num_init_entries = num_macros;
1316 oc = & m32r_cgen_insn_opcode_table[0];
1317 insns = (CGEN_INSN *) cd->insn_table.init_entries;
1318 for (i = 0; i < MAX_INSNS; ++i)
1319 insns[i].opcode = &oc[i];
1321 cd->sizeof_fields = sizeof (CGEN_FIELDS);
1322 cd->set_fields_bitsize = set_fields_bitsize;
1324 cd->asm_hash_p = asm_hash_insn_p;
1325 cd->asm_hash = asm_hash_insn;
1326 cd->asm_hash_size = CGEN_ASM_HASH_SIZE;
1328 cd->dis_hash_p = dis_hash_insn_p;
1329 cd->dis_hash = dis_hash_insn;
1330 cd->dis_hash_size = CGEN_DIS_HASH_SIZE;