X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=opcodes%2Fm32r-opc.c;h=c6a9d98b6114c5b1ecee2693daa457f17a6dd994;hb=ac4eb736520174305bf6e691827f7473b858cff1;hp=38ad0de7548de114057d0f772b4d7877a57aeb71;hpb=7c26196f5afeb25656f8c013a2ef13faeee25849;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/m32r-opc.c b/opcodes/m32r-opc.c index 38ad0de754..c6a9d98b61 100644 --- a/opcodes/m32r-opc.c +++ b/opcodes/m32r-opc.c @@ -1,1788 +1,1808 @@ -/* CGEN opcode support for m32r. +/* Instruction opcode table for m32r. -This file is machine generated with CGEN. +THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. + This file is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ - #include "sysdep.h" -#include #include "ansidecl.h" -#include "libiberty.h" #include "bfd.h" +#include "symcat.h" +#include "m32r-desc.h" #include "m32r-opc.h" +#include "libiberty.h" -/* Attributes. */ - -static const CGEN_ATTR_ENTRY MACH_attr[] = +/* -- opc.c */ +unsigned int +m32r_cgen_dis_hash (const char * buf ATTRIBUTE_UNUSED, CGEN_INSN_INT value) { - { "m32r", MACH_M32R }, -/* start-sanitize-m32rx */ - { "m32rx", MACH_M32RX }, -/* end-sanitize-m32rx */ - { "max", MACH_MAX }, - { 0, 0 } + unsigned int x; + + if (value & 0xffff0000) /* 32bit instructions. */ + value = (value >> 16) & 0xffff; + + x = (value >> 8) & 0xf0; + if (x == 0x40 || x == 0xe0 || x == 0x60 || x == 0x50) + return x; + + if (x == 0x70 || x == 0xf0) + return x | ((value >> 8) & 0x0f); + + if (x == 0x30) + return x | ((value & 0x70) >> 4); + else + return x | ((value & 0xf0) >> 4); +} + +/* -- */ +/* The hash functions are recorded here to help keep assembler code out of + the disassembler and vice versa. */ + +static int asm_hash_insn_p (const CGEN_INSN *); +static unsigned int asm_hash_insn (const char *); +static int dis_hash_insn_p (const CGEN_INSN *); +static unsigned int dis_hash_insn (const char *, CGEN_INSN_INT); + +/* Instruction formats. */ + +#define F(f) & m32r_cgen_ifld_table[M32R_##f] +static const CGEN_IFMT ifmt_empty ATTRIBUTE_UNUSED = { + 0, 0, 0x0, { { 0 } } }; -/* start-sanitize-m32rx */ -static const CGEN_ATTR_ENTRY PIPE_attr[] = -{ - { "NONE", PIPE_NONE }, - { "O", PIPE_O }, - { "S", PIPE_S }, - { "OS", PIPE_OS }, - { 0, 0 } +static const CGEN_IFMT ifmt_add ATTRIBUTE_UNUSED = { + 16, 16, 0xf0f0, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } }; -/* end-sanitize-m32rx */ -const CGEN_ATTR_TABLE m32r_cgen_operand_attr_table[] = -{ - { "ABS-ADDR", NULL }, - { "FAKE", NULL }, - { "NEGATIVE", NULL }, - { "PC", NULL }, - { "PCREL-ADDR", NULL }, - { "RELAX", NULL }, - { "RELOC", NULL }, - { "SIGN-OPT", NULL }, - { "UNSIGNED", NULL }, - { 0, 0 } -}; - -const CGEN_ATTR_TABLE m32r_cgen_insn_attr_table[] = -{ - { "MACH", & MACH_attr[0] }, -/* start-sanitize-m32rx */ - { "PIPE", & PIPE_attr[0] }, -/* end-sanitize-m32rx */ - { "ALIAS", NULL }, - { "COND-CTI", NULL }, - { "FILL-SLOT", NULL }, - { "PARALLEL", NULL }, - { "RELAX", NULL }, - { "RELAXABLE", NULL }, - { "UNCOND-CTI", NULL }, - { 0, 0 } -}; - -CGEN_KEYWORD_ENTRY m32r_cgen_opval_h_gr_entries[] = -{ - { "fp", 13 }, - { "lr", 14 }, - { "sp", 15 }, - { "r0", 0 }, - { "r1", 1 }, - { "r2", 2 }, - { "r3", 3 }, - { "r4", 4 }, - { "r5", 5 }, - { "r6", 6 }, - { "r7", 7 }, - { "r8", 8 }, - { "r9", 9 }, - { "r10", 10 }, - { "r11", 11 }, - { "r12", 12 }, - { "r13", 13 }, - { "r14", 14 }, - { "r15", 15 } -}; - -CGEN_KEYWORD m32r_cgen_opval_h_gr = -{ - & m32r_cgen_opval_h_gr_entries[0], - 19 +static const CGEN_IFMT ifmt_add3 ATTRIBUTE_UNUSED = { + 32, 32, 0xf0f00000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } }; -CGEN_KEYWORD_ENTRY m32r_cgen_opval_h_cr_entries[] = -{ - { "psw", 0 }, - { "cbr", 1 }, - { "spi", 2 }, - { "spu", 3 }, - { "bpc", 6 }, - { "cr0", 0 }, - { "cr1", 1 }, - { "cr2", 2 }, - { "cr3", 3 }, - { "cr4", 4 }, - { "cr5", 5 }, - { "cr6", 6 } -}; - -CGEN_KEYWORD m32r_cgen_opval_h_cr = -{ - & m32r_cgen_opval_h_cr_entries[0], - 12 +static const CGEN_IFMT ifmt_and3 ATTRIBUTE_UNUSED = { + 32, 32, 0xf0f00000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } }; -/* start-sanitize-m32rx */ -CGEN_KEYWORD_ENTRY m32r_cgen_opval_h_accums_entries[] = -{ - { "a0", 0 }, - { "a1", 1 } +static const CGEN_IFMT ifmt_or3 ATTRIBUTE_UNUSED = { + 32, 32, 0xf0f00000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } }; -CGEN_KEYWORD m32r_cgen_opval_h_accums = -{ - & m32r_cgen_opval_h_accums_entries[0], - 2 +static const CGEN_IFMT ifmt_addi ATTRIBUTE_UNUSED = { + 16, 16, 0xf000, { { F (F_OP1) }, { F (F_R1) }, { F (F_SIMM8) }, { 0 } } }; -/* end-sanitize-m32rx */ +static const CGEN_IFMT ifmt_addv3 ATTRIBUTE_UNUSED = { + 32, 32, 0xf0f00000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } +}; -static CGEN_HW_ENTRY m32r_cgen_hw_entries[] = -{ - { "h-pc", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-memory", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-sint", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-uint", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-addr", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-iaddr", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-hi16", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-slo16", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-ulo16", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-gr", CGEN_ASM_KEYWORD, (PTR) & m32r_cgen_opval_h_gr }, - { "h-cr", CGEN_ASM_KEYWORD, (PTR) & m32r_cgen_opval_h_cr }, - { "h-accum", CGEN_ASM_KEYWORD, (PTR) 0 }, -/* start-sanitize-m32rx */ - { "h-accums", CGEN_ASM_KEYWORD, (PTR) & m32r_cgen_opval_h_accums }, -/* end-sanitize-m32rx */ -/* start-sanitize-m32rx */ - { "h-abort", CGEN_ASM_KEYWORD, (PTR) 0 }, -/* end-sanitize-m32rx */ - { "h-cond", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-sm", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-bsm", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-ie", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-bie", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-bcond", CGEN_ASM_KEYWORD, (PTR) 0 }, - { "h-bpc", CGEN_ASM_KEYWORD, (PTR) 0 }, - { 0 } -}; - -const CGEN_OPERAND m32r_cgen_operand_table[MAX_OPERANDS] = -{ -/* pc: program counter */ - { "pc", 0, 0, { 0, 0|(1< $dr,$sr */ -/* 0 */ { OP, ' ', 130, ',', 129, 0 }, -/* $dr,$sr,#$slo16 */ -/* 1 */ { OP, ' ', 130, ',', 129, ',', '#', 143, 0 }, -/* $dr,$sr,$slo16 */ -/* 2 */ { OP, ' ', 130, ',', 129, ',', 143, 0 }, -/* $dr,$sr,#$uimm16 */ -/* 3 */ { OP, ' ', 130, ',', 129, ',', '#', 139, 0 }, -/* $dr,$sr,$uimm16 */ -/* 4 */ { OP, ' ', 130, ',', 129, ',', 139, 0 }, -/* $dr,$sr,#$ulo16 */ -/* 5 */ { OP, ' ', 130, ',', 129, ',', '#', 144, 0 }, -/* $dr,$sr,$ulo16 */ -/* 6 */ { OP, ' ', 130, ',', 129, ',', 144, 0 }, -/* $dr,#$simm8 */ -/* 7 */ { OP, ' ', 130, ',', '#', 135, 0 }, -/* $dr,$simm8 */ -/* 8 */ { OP, ' ', 130, ',', 135, 0 }, -/* $dr,$sr,#$simm16 */ -/* 9 */ { OP, ' ', 130, ',', 129, ',', '#', 136, 0 }, -/* $dr,$sr,$simm16 */ -/* 10 */ { OP, ' ', 130, ',', 129, ',', 136, 0 }, -/* $disp8 */ -/* 11 */ { OP, ' ', 146, 0 }, -/* $disp24 */ -/* 12 */ { OP, ' ', 148, 0 }, -/* $src1,$src2,$disp16 */ -/* 13 */ { OP, ' ', 131, ',', 132, ',', 147, 0 }, -/* $src2,$disp16 */ -/* 14 */ { OP, ' ', 132, ',', 147, 0 }, -/* $src1,$src2 */ -/* 15 */ { OP, ' ', 131, ',', 132, 0 }, -/* $src2,#$simm16 */ -/* 16 */ { OP, ' ', 132, ',', '#', 136, 0 }, -/* $src2,$simm16 */ -/* 17 */ { OP, ' ', 132, ',', 136, 0 }, -/* $src2,#$uimm16 */ -/* 18 */ { OP, ' ', 132, ',', '#', 139, 0 }, -/* $src2,$uimm16 */ -/* 19 */ { OP, ' ', 132, ',', 139, 0 }, -/* $src2 */ -/* 20 */ { OP, ' ', 132, 0 }, -/* $sr */ -/* 21 */ { OP, ' ', 129, 0 }, -/* $dr,@$sr */ -/* 22 */ { OP, ' ', 130, ',', '@', 129, 0 }, -/* $dr,@($sr) */ -/* 23 */ { OP, ' ', 130, ',', '@', '(', 129, ')', 0 }, -/* $dr,@($slo16,$sr) */ -/* 24 */ { OP, ' ', 130, ',', '@', '(', 143, ',', 129, ')', 0 }, -/* $dr,@($sr,$slo16) */ -/* 25 */ { OP, ' ', 130, ',', '@', '(', 129, ',', 143, ')', 0 }, -/* $dr,@$sr+ */ -/* 26 */ { OP, ' ', 130, ',', '@', 129, '+', 0 }, -/* $dr,#$uimm24 */ -/* 27 */ { OP, ' ', 130, ',', '#', 145, 0 }, -/* $dr,$uimm24 */ -/* 28 */ { OP, ' ', 130, ',', 145, 0 }, -/* $dr,$slo16 */ -/* 29 */ { OP, ' ', 130, ',', 143, 0 }, -/* $src1,$src2,$acc */ -/* 30 */ { OP, ' ', 131, ',', 132, ',', 141, 0 }, -/* $dr */ -/* 31 */ { OP, ' ', 130, 0 }, -/* $dr,$accs */ -/* 32 */ { OP, ' ', 130, ',', 140, 0 }, -/* $dr,$scr */ -/* 33 */ { OP, ' ', 130, ',', 133, 0 }, -/* $src1 */ -/* 34 */ { OP, ' ', 131, 0 }, -/* $src1,$accs */ -/* 35 */ { OP, ' ', 131, ',', 140, 0 }, -/* $sr,$dcr */ -/* 36 */ { OP, ' ', 129, ',', 134, 0 }, -/* */ -/* 37 */ { OP, 0 }, -/* $accs */ -/* 38 */ { OP, ' ', 140, 0 }, -/* $dr,#$hi16 */ -/* 39 */ { OP, ' ', 130, ',', '#', 142, 0 }, -/* $dr,$hi16 */ -/* 40 */ { OP, ' ', 130, ',', 142, 0 }, -/* $dr,#$uimm5 */ -/* 41 */ { OP, ' ', 130, ',', '#', 138, 0 }, -/* $dr,$uimm5 */ -/* 42 */ { OP, ' ', 130, ',', 138, 0 }, -/* $src1,@$src2 */ -/* 43 */ { OP, ' ', 131, ',', '@', 132, 0 }, -/* $src1,@($src2) */ -/* 44 */ { OP, ' ', 131, ',', '@', '(', 132, ')', 0 }, -/* $src1,@($slo16,$src2) */ -/* 45 */ { OP, ' ', 131, ',', '@', '(', 143, ',', 132, ')', 0 }, -/* $src1,@($src2,$slo16) */ -/* 46 */ { OP, ' ', 131, ',', '@', '(', 132, ',', 143, ')', 0 }, -/* $src1,@+$src2 */ -/* 47 */ { OP, ' ', 131, ',', '@', '+', 132, 0 }, -/* $src1,@-$src2 */ -/* 48 */ { OP, ' ', 131, ',', '@', '-', 132, 0 }, -/* #$uimm4 */ -/* 49 */ { OP, ' ', '#', 137, 0 }, -/* $uimm4 */ -/* 50 */ { OP, ' ', 137, 0 }, -/* $dr,$src2 */ -/* 51 */ { OP, ' ', 130, ',', 132, 0 }, +static const CGEN_IFMT ifmt_bc8 ATTRIBUTE_UNUSED = { + 16, 16, 0xff00, { { F (F_OP1) }, { F (F_R1) }, { F (F_DISP8) }, { 0 } } }; -#undef OP +static const CGEN_IFMT ifmt_bc24 ATTRIBUTE_UNUSED = { + 32, 32, 0xff000000, { { F (F_OP1) }, { F (F_R1) }, { F (F_DISP24) }, { 0 } } +}; -static const CGEN_FORMAT format_table[] = -{ -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr. */ -/* 0 */ { 16, 16, 0xf0f0 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.slo16. */ -/* 1 */ { 32, 32, 0xf0f00000 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-uimm16.uimm16. */ -/* 2 */ { 32, 32, 0xf0f00000 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-uimm16.ulo16. */ -/* 3 */ { 32, 32, 0xf0f00000 }, -/* f-op1.number.f-r1.dr.f-simm8.simm8. */ -/* 4 */ { 16, 16, 0xf000 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.simm16. */ -/* 5 */ { 32, 32, 0xf0f00000 }, -/* f-op1.number.f-r1.number.f-disp8.disp8. */ -/* 6 */ { 16, 16, 0xff00 }, -/* f-op1.number.f-r1.number.f-disp24.disp24. */ -/* 7 */ { 32, 32, 0xff000000 }, -/* f-op1.number.f-r1.src1.f-op2.number.f-r2.src2.f-disp16.disp16. */ -/* 8 */ { 32, 32, 0xf0f00000 }, -/* f-op1.number.f-r1.number.f-op2.number.f-r2.src2.f-disp16.disp16. */ -/* 9 */ { 32, 32, 0xfff00000 }, -/* f-op1.number.f-r1.src1.f-op2.number.f-r2.src2. */ -/* 10 */ { 16, 16, 0xf0f0 }, -/* f-op1.number.f-r1.number.f-op2.number.f-r2.src2.f-simm16.simm16. */ -/* 11 */ { 32, 32, 0xfff00000 }, -/* f-op1.number.f-r1.number.f-op2.number.f-r2.src2.f-uimm16.uimm16. */ -/* 12 */ { 32, 32, 0xfff00000 }, -/* f-op1.number.f-r1.number.f-op2.number.f-r2.src2. */ -/* 13 */ { 16, 16, 0xfff0 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.number. */ -/* 14 */ { 32, 32, 0xf0f0ffff }, -/* f-op1.number.f-r1.number.f-op2.number.f-r2.sr. */ -/* 15 */ { 16, 16, 0xfff0 }, -/* f-op1.number.f-r1.dr.f-uimm24.uimm24. */ -/* 16 */ { 32, 32, 0xf0000000 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.number.f-simm16.slo16. */ -/* 17 */ { 32, 32, 0xf0ff0000 }, -/* f-op1.number.f-r1.src1.f-acc.acc.f-op23.number.f-r2.src2. */ -/* 18 */ { 16, 16, 0xf070 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.number. */ -/* 19 */ { 16, 16, 0xf0ff }, -/* f-op1.number.f-r1.dr.f-op2.number.f-accs.accs.f-op3.number. */ -/* 20 */ { 16, 16, 0xf0f3 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.scr. */ -/* 21 */ { 16, 16, 0xf0f0 }, -/* f-op1.number.f-r1.src1.f-op2.number.f-r2.number. */ -/* 22 */ { 16, 16, 0xf0ff }, -/* f-op1.number.f-r1.src1.f-op2.number.f-accs.accs.f-op3.number. */ -/* 23 */ { 16, 16, 0xf0f3 }, -/* f-op1.number.f-r1.dcr.f-op2.number.f-r2.sr. */ -/* 24 */ { 16, 16, 0xf0f0 }, -/* f-op1.number.f-r1.number.f-op2.number.f-r2.number. */ -/* 25 */ { 16, 16, 0xffff }, -/* f-op1.number.f-r1.number.f-op2.number.f-accs.accs.f-op3.number. */ -/* 26 */ { 16, 16, 0xfff3 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.number.f-hi16.hi16. */ -/* 27 */ { 32, 32, 0xf0ff0000 }, -/* f-op1.number.f-r1.dr.f-shift-op2.number.f-uimm5.uimm5. */ -/* 28 */ { 16, 16, 0xf0e0 }, -/* f-op1.number.f-r1.src1.f-op2.number.f-r2.src2.f-simm16.slo16. */ -/* 29 */ { 32, 32, 0xf0f00000 }, -/* f-op1.number.f-r1.number.f-op2.number.f-uimm4.uimm4. */ -/* 30 */ { 16, 16, 0xfff0 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.src2.f-uimm16.number. */ -/* 31 */ { 32, 32, 0xf0f0ffff }, -}; - -#define A(a) (1 << CGEN_CAT3 (CGEN_INSN,_,a)) -#define SYN(n) (& syntax_table[n]) -#define FMT(n) (& format_table[n]) - -const CGEN_INSN m32r_cgen_insn_table_entries[MAX_INSNS] = +static const CGEN_IFMT ifmt_beq ATTRIBUTE_UNUSED = { + 32, 32, 0xf0f00000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_DISP16) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_beqz ATTRIBUTE_UNUSED = { + 32, 32, 0xfff00000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_DISP16) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_cmp ATTRIBUTE_UNUSED = { + 16, 16, 0xf0f0, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_cmpi ATTRIBUTE_UNUSED = { + 32, 32, 0xfff00000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_cmpz ATTRIBUTE_UNUSED = { + 16, 16, 0xfff0, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_div ATTRIBUTE_UNUSED = { + 32, 32, 0xf0f0ffff, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_jc ATTRIBUTE_UNUSED = { + 16, 16, 0xfff0, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_ld24 ATTRIBUTE_UNUSED = { + 32, 32, 0xf0000000, { { F (F_OP1) }, { F (F_R1) }, { F (F_UIMM24) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_ldi16 ATTRIBUTE_UNUSED = { + 32, 32, 0xf0ff0000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_machi_a ATTRIBUTE_UNUSED = { + 16, 16, 0xf070, { { F (F_OP1) }, { F (F_R1) }, { F (F_ACC) }, { F (F_OP23) }, { F (F_R2) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mvfachi ATTRIBUTE_UNUSED = { + 16, 16, 0xf0ff, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mvfachi_a ATTRIBUTE_UNUSED = { + 16, 16, 0xf0f3, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_ACCS) }, { F (F_OP3) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mvfc ATTRIBUTE_UNUSED = { + 16, 16, 0xf0f0, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mvtachi ATTRIBUTE_UNUSED = { + 16, 16, 0xf0ff, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mvtachi_a ATTRIBUTE_UNUSED = { + 16, 16, 0xf0f3, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_ACCS) }, { F (F_OP3) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mvtc ATTRIBUTE_UNUSED = { + 16, 16, 0xf0f0, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_nop ATTRIBUTE_UNUSED = { + 16, 16, 0xffff, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_rac_dsi ATTRIBUTE_UNUSED = { + 16, 16, 0xf3f2, { { F (F_OP1) }, { F (F_ACCD) }, { F (F_BITS67) }, { F (F_OP2) }, { F (F_ACCS) }, { F (F_BIT14) }, { F (F_IMM1) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_seth ATTRIBUTE_UNUSED = { + 32, 32, 0xf0ff0000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_HI16) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_slli ATTRIBUTE_UNUSED = { + 16, 16, 0xf0e0, { { F (F_OP1) }, { F (F_R1) }, { F (F_SHIFT_OP2) }, { F (F_UIMM5) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_st_d ATTRIBUTE_UNUSED = { + 32, 32, 0xf0f00000, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_trap ATTRIBUTE_UNUSED = { + 16, 16, 0xfff0, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_UIMM4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_satb ATTRIBUTE_UNUSED = { + 32, 32, 0xf0f0ffff, { { F (F_OP1) }, { F (F_R1) }, { F (F_OP2) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_clrpsw ATTRIBUTE_UNUSED = { + 16, 16, 0xff00, { { F (F_OP1) }, { F (F_R1) }, { F (F_UIMM8) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_bset ATTRIBUTE_UNUSED = { + 32, 32, 0xf8f00000, { { F (F_OP1) }, { F (F_BIT4) }, { F (F_UIMM3) }, { F (F_OP2) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_btst ATTRIBUTE_UNUSED = { + 16, 16, 0xf8f0, { { F (F_OP1) }, { F (F_BIT4) }, { F (F_UIMM3) }, { F (F_OP2) }, { F (F_R2) }, { 0 } } +}; + +#undef F + +#define A(a) (1 << CGEN_INSN_##a) +#define OPERAND(op) M32R_OPERAND_##op +#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ +#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) + +/* The instruction table. */ + +static const CGEN_OPCODE m32r_cgen_insn_opcode_table[MAX_INSNS] = { - /* null first entry, end of all hash chains */ - { { 0 }, 0 }, + /* Special null first entry. + A `num' value of zero is thus invalid. + Also, the special `invalid' insn resides here. */ + { { 0, 0, 0, 0 }, {{0}}, 0, {0}}, /* add $dr,$sr */ { - { 1, 1, 1, 1 }, - "add", "add", SYN (0), FMT (0), 0xa0, - { 2, 0|A(PARALLEL), { (1<f_r2 = * valuep; - break; - case M32R_OPERAND_DR : - fields->f_r1 = * valuep; - break; - case M32R_OPERAND_SRC1 : - fields->f_r1 = * valuep; - break; - case M32R_OPERAND_SRC2 : - fields->f_r2 = * valuep; - break; - case M32R_OPERAND_SCR : - fields->f_r2 = * valuep; - break; - case M32R_OPERAND_DCR : - fields->f_r1 = * valuep; - break; - case M32R_OPERAND_SIMM8 : - fields->f_simm8 = * valuep; - break; - case M32R_OPERAND_SIMM16 : - fields->f_simm16 = * valuep; - break; - case M32R_OPERAND_UIMM4 : - fields->f_uimm4 = * valuep; - break; - case M32R_OPERAND_UIMM5 : - fields->f_uimm5 = * valuep; - break; - case M32R_OPERAND_UIMM16 : - fields->f_uimm16 = * valuep; - break; -/* start-sanitize-m32rx */ - case M32R_OPERAND_ACCS : - fields->f_accs = * valuep; - break; -/* end-sanitize-m32rx */ -/* start-sanitize-m32rx */ - case M32R_OPERAND_ACC : - fields->f_acc = * valuep; - break; -/* end-sanitize-m32rx */ - case M32R_OPERAND_HI16 : - fields->f_hi16 = * valuep; - break; - case M32R_OPERAND_SLO16 : - fields->f_simm16 = * valuep; - break; - case M32R_OPERAND_ULO16 : - fields->f_uimm16 = * valuep; - break; - case M32R_OPERAND_UIMM24 : - fields->f_uimm24 = * valuep; - break; - case M32R_OPERAND_DISP8 : - fields->f_disp8 = * valuep; - break; - case M32R_OPERAND_DISP16 : - fields->f_disp16 = * valuep; - break; - case M32R_OPERAND_DISP24 : - fields->f_disp24 = * valuep; - break; - - default : - fprintf (stderr, "Unrecognized field %d while setting operand.\n", - opindex); - abort (); - } + return CGEN_DIS_HASH (buf, value); } -/* Main entry point for getting values from cgen_fields. */ +/* Set the recorded length of the insn in the CGEN_FIELDS struct. */ -CGEN_INLINE long -m32r_cgen_get_operand (opindex, fields) - int opindex; - const CGEN_FIELDS * fields; +static void +set_fields_bitsize (CGEN_FIELDS *fields, int size) { - long value; + CGEN_FIELDS_BITSIZE (fields) = size; +} + +/* Function to call before using the operand instance table. + This plugs the opcode entries and macro instructions into the cpu table. */ - switch (opindex) +void +m32r_cgen_init_opcode_table (CGEN_CPU_DESC cd) +{ + int i; + int num_macros = (sizeof (m32r_cgen_macro_insn_table) / + sizeof (m32r_cgen_macro_insn_table[0])); + const CGEN_IBASE *ib = & m32r_cgen_macro_insn_table[0]; + const CGEN_OPCODE *oc = & m32r_cgen_macro_insn_opcode_table[0]; + CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN)); + + /* This test has been added to avoid a warning generated + if memset is called with a third argument of value zero. */ + if (num_macros >= 1) + memset (insns, 0, num_macros * sizeof (CGEN_INSN)); + for (i = 0; i < num_macros; ++i) { - case M32R_OPERAND_SR : - value = fields->f_r2; - break; - case M32R_OPERAND_DR : - value = fields->f_r1; - break; - case M32R_OPERAND_SRC1 : - value = fields->f_r1; - break; - case M32R_OPERAND_SRC2 : - value = fields->f_r2; - break; - case M32R_OPERAND_SCR : - value = fields->f_r2; - break; - case M32R_OPERAND_DCR : - value = fields->f_r1; - break; - case M32R_OPERAND_SIMM8 : - value = fields->f_simm8; - break; - case M32R_OPERAND_SIMM16 : - value = fields->f_simm16; - break; - case M32R_OPERAND_UIMM4 : - value = fields->f_uimm4; - break; - case M32R_OPERAND_UIMM5 : - value = fields->f_uimm5; - break; - case M32R_OPERAND_UIMM16 : - value = fields->f_uimm16; - break; -/* start-sanitize-m32rx */ - case M32R_OPERAND_ACCS : - value = fields->f_accs; - break; -/* end-sanitize-m32rx */ -/* start-sanitize-m32rx */ - case M32R_OPERAND_ACC : - value = fields->f_acc; - break; -/* end-sanitize-m32rx */ - case M32R_OPERAND_HI16 : - value = fields->f_hi16; - break; - case M32R_OPERAND_SLO16 : - value = fields->f_simm16; - break; - case M32R_OPERAND_ULO16 : - value = fields->f_uimm16; - break; - case M32R_OPERAND_UIMM24 : - value = fields->f_uimm24; - break; - case M32R_OPERAND_DISP8 : - value = fields->f_disp8; - break; - case M32R_OPERAND_DISP16 : - value = fields->f_disp16; - break; - case M32R_OPERAND_DISP24 : - value = fields->f_disp24; - break; - - default : - fprintf (stderr, "Unrecognized field %d while getting operand.\n", - opindex); - abort (); - } - - return value; -} + insns[i].base = &ib[i]; + insns[i].opcode = &oc[i]; + m32r_cgen_build_insn_regex (& insns[i]); + } + cd->macro_insn_table.init_entries = insns; + cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE); + cd->macro_insn_table.num_init_entries = num_macros; + oc = & m32r_cgen_insn_opcode_table[0]; + insns = (CGEN_INSN *) cd->insn_table.init_entries; + for (i = 0; i < MAX_INSNS; ++i) + { + insns[i].opcode = &oc[i]; + m32r_cgen_build_insn_regex (& insns[i]); + } + + cd->sizeof_fields = sizeof (CGEN_FIELDS); + cd->set_fields_bitsize = set_fields_bitsize; + + cd->asm_hash_p = asm_hash_insn_p; + cd->asm_hash = asm_hash_insn; + cd->asm_hash_size = CGEN_ASM_HASH_SIZE; + + cd->dis_hash_p = dis_hash_insn_p; + cd->dis_hash = dis_hash_insn; + cd->dis_hash_size = CGEN_DIS_HASH_SIZE; +}