From: Doug Evans Date: Thu, 12 Feb 1998 03:13:21 +0000 (+0000) Subject: * cgen-opc.in: New file. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab0bd0493ad0dbb544fec8f46b03a0887c594bec;p=binutils-gdb.git * cgen-opc.in: New file. * cgen.sh: Translate @ARCH@. Cat cgen-opc.in into @arch@-opc.c. * Makefile.am (CGENFILES): Add cgen-opc.in. * Makefile.in: Regenerate. * cgen-opc.c (cgen_set_cpu): Delete init of hw list `next' chain. (cgen_hw_lookup): Make result const. * cgen-dis.in (*): Use PTR instead of void *. (print_insn): Delete unused vars `i', `syntax'. * m32r-opc.h, m32r-opc.c, m32r-asm.c, m32r-dis.c: Regenerate. --- diff --git a/opcodes/.Sanitize b/opcodes/.Sanitize index b53c6507393..9cd333cf5f7 100644 --- a/opcodes/.Sanitize +++ b/opcodes/.Sanitize @@ -15,7 +15,7 @@ Do-first: -cygnus_files="cgen.sh cgen-asm.in cgen-dis.in" +cygnus_files="cgen.sh cgen-asm.in cgen-dis.in cgen-opc.in" if ( echo $* | grep keep\-cygnus > /dev/null ) ; then keep_these_too="${cygnus_files} ${keep_these_too}" diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 8bb9eab30dc..be2e312ed7f 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,7 +1,23 @@ +Wed Feb 11 18:58:34 1998 Doug Evans + + * cgen-opc.in: New file. + * cgen.sh: Translate @ARCH@. Cat cgen-opc.in into @arch@-opc.c. + * Makefile.am (CGENFILES): Add cgen-opc.in. + * Makefile.in: Regenerate. + + * cgen-opc.c (cgen_set_cpu): Delete init of hw list `next' chain. + (cgen_hw_lookup): Make result const. + + * cgen-dis.in (*): Use PTR instead of void *. + (print_insn): Delete unused vars `i', `syntax'. + + * m32r-opc.h, m32r-opc.c, m32r-asm.c, m32r-dis.c: Regenerate. + start-sanitize-sky Tue Feb 10 14:56:24 1998 Doug Evans * dvp-opc.c (*): pke,gpuif renamed to vif,gif. + (vif_opcodes): Update renamed insns. * dvp-dis.c (*): Likewise. end-sanitize-sky diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am index 570469c4767..4fc2e46361e 100644 --- a/opcodes/Makefile.am +++ b/opcodes/Makefile.am @@ -55,6 +55,7 @@ CFILES = \ sh-dis.c \ sparc-dis.c \ sparc-opc.c \ + tic30-dis.c \ w65-dis.c \ z8k-dis.c \ z8kgen.c @@ -99,6 +100,7 @@ ALL_MACHINES = \ sh-dis.lo \ sparc-dis.lo \ sparc-opc.lo \ + tic30-dis.lo \ $(start-sanitize-tic80) \ tic80-dis.lo \ tic80-opc.lo \ @@ -158,7 +160,7 @@ CGENFILES = $(CGENDIR)/object.scm $(CGENDIR)/utils.scm \ $(CGENDIR)/ifield.scm $(CGENDIR)/iformat.scm \ $(CGENDIR)/operand.scm $(CGENDIR)/insn.scm \ $(CGENDIR)/opcodes.scm $(CGENDIR)/cgen-opc.scm \ - cgen-asm.in cgen-dis.in + cgen-opc.in cgen-asm.in cgen-dis.in # The end marker is written this way to pass through automake unscathed. ENDSAN = end-sanitize-cygnus @@ -243,7 +245,8 @@ alpha-dis.lo: alpha-dis.c $(INCDIR)/ansidecl.h sysdep.h \ alpha-opc.lo: alpha-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/alpha.h \ $(BFD_H) arm-dis.lo: arm-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \ - $(INCDIR)/ansidecl.h arm-opc.h + $(INCDIR)/ansidecl.h arm-opc.h $(INCDIR)/coff/internal.h \ + $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h cgen-asm.lo: cgen-asm.c sysdep.h config.h $(INCDIR)/libiberty.h \ $(BFD_H) $(INCDIR)/opcode/cgen.h cgen-dis.lo: cgen-dis.c sysdep.h config.h $(INCDIR)/libiberty.h \ @@ -301,6 +304,8 @@ sparc-dis.lo: sparc-dis.c $(INCDIR)/ansidecl.h sysdep.h \ config.h $(INCDIR)/opcode/sparc.h $(INCDIR)/dis-asm.h \ $(BFD_H) $(INCDIR)/libiberty.h sparc-opc.lo: sparc-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/sparc.h +tic30-dis.lo: tic30-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \ + $(INCDIR)/ansidecl.h $(INCDIR)/opcode/tic30.h w65-dis.lo: w65-dis.c w65-opc.h $(INCDIR)/dis-asm.h \ $(BFD_H) $(INCDIR)/ansidecl.h z8k-dis.lo: z8k-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \ diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in index deb5f12e31a..6e55b1cd96d 100644 --- a/opcodes/Makefile.in +++ b/opcodes/Makefile.in @@ -65,6 +65,7 @@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ +NM = @NM@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ @@ -125,6 +126,7 @@ CFILES = \ sh-dis.c \ sparc-dis.c \ sparc-opc.c \ + tic30-dis.c \ w65-dis.c \ z8k-dis.c \ z8kgen.c @@ -169,6 +171,7 @@ ALL_MACHINES = \ sh-dis.lo \ sparc-dis.lo \ sparc-opc.lo \ + tic30-dis.lo \ $(start-sanitize-tic80) \ tic80-dis.lo \ tic80-opc.lo \ @@ -218,7 +221,7 @@ CGENFILES = $(CGENDIR)/object.scm $(CGENDIR)/utils.scm \ $(CGENDIR)/ifield.scm $(CGENDIR)/iformat.scm \ $(CGENDIR)/operand.scm $(CGENDIR)/insn.scm \ $(CGENDIR)/opcodes.scm $(CGENDIR)/cgen-opc.scm \ - cgen-asm.in cgen-dis.in + cgen-opc.in cgen-asm.in cgen-dis.in # The end marker is written this way to pass through automake unscathed. ENDSAN = end-sanitize-cygnus ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -599,7 +602,8 @@ alpha-dis.lo: alpha-dis.c $(INCDIR)/ansidecl.h sysdep.h \ alpha-opc.lo: alpha-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/alpha.h \ $(BFD_H) arm-dis.lo: arm-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \ - $(INCDIR)/ansidecl.h arm-opc.h + $(INCDIR)/ansidecl.h arm-opc.h $(INCDIR)/coff/internal.h \ + $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h cgen-asm.lo: cgen-asm.c sysdep.h config.h $(INCDIR)/libiberty.h \ $(BFD_H) $(INCDIR)/opcode/cgen.h cgen-dis.lo: cgen-dis.c sysdep.h config.h $(INCDIR)/libiberty.h \ @@ -657,6 +661,8 @@ sparc-dis.lo: sparc-dis.c $(INCDIR)/ansidecl.h sysdep.h \ config.h $(INCDIR)/opcode/sparc.h $(INCDIR)/dis-asm.h \ $(BFD_H) $(INCDIR)/libiberty.h sparc-opc.lo: sparc-opc.c $(INCDIR)/ansidecl.h $(INCDIR)/opcode/sparc.h +tic30-dis.lo: tic30-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \ + $(INCDIR)/ansidecl.h $(INCDIR)/opcode/tic30.h w65-dis.lo: w65-dis.c w65-opc.h $(INCDIR)/dis-asm.h \ $(BFD_H) $(INCDIR)/ansidecl.h z8k-dis.lo: z8k-dis.c sysdep.h config.h $(INCDIR)/dis-asm.h \ diff --git a/opcodes/cgen-dis.in b/opcodes/cgen-dis.in index af3dfc63e75..0724b442578 100644 --- a/opcodes/cgen-dis.in +++ b/opcodes/cgen-dis.in @@ -57,7 +57,7 @@ static void print_insn_normal static int extract_normal (buf_ctrl, insn_value, attrs, start, length, shift, total_length, valuep) - void *buf_ctrl; + PTR buf_ctrl; cgen_insn_t insn_value; unsigned int attrs; int start, length, shift, total_length; @@ -94,7 +94,7 @@ extract_normal (buf_ctrl, insn_value, attrs, start, length, shift, total_length, static void print_normal (dis_info, value, attrs, pc, length) - void *dis_info; + PTR dis_info; long value; unsigned int attrs; unsigned long pc; /* FIXME: should be bfd_vma */ @@ -121,7 +121,7 @@ print_normal (dis_info, value, attrs, pc, length) static void print_keyword (dis_info, keyword_table, value, attrs) - void *dis_info; + PTR dis_info; CGEN_KEYWORD *keyword_table; long value; CGEN_ATTR *attrs; @@ -147,7 +147,7 @@ print_keyword (dis_info, keyword_table, value, attrs) static int extract_insn_normal (insn, buf_ctrl, insn_value, fields) const CGEN_INSN *insn; - void *buf_ctrl; + PTR buf_ctrl; cgen_insn_t insn_value; CGEN_FIELDS *fields; { @@ -177,13 +177,13 @@ extract_insn_normal (insn, buf_ctrl, insn_value, fields) /* Default insn printer. - DIS_INFO is defined as `void *' so the disassembler needn't know anything + DIS_INFO is defined as `PTR' so the disassembler needn't know anything about disassemble_info. */ static void print_insn_normal (dis_info, insn, fields, pc, length) - void *dis_info; + PTR dis_info; const CGEN_INSN *insn; CGEN_FIELDS *fields; bfd_vma pc; @@ -215,7 +215,7 @@ print_insn_normal (dis_info, insn, fields, pc, length) } /* Default value for CGEN_PRINT_INSN. - Given BUFLEN bytes (target byte order) read into BUF, look up the + Given BUFLEN bits (target byte order) read into BUF, look up the insn in the instruction table and disassemble it. The result is the size of the insn in bytes. */ @@ -231,7 +231,6 @@ print_insn (pc, info, buf, buflen) char *buf; int buflen; { - int i; unsigned long insn_value; const CGEN_INSN_LIST *insn_list; @@ -257,7 +256,6 @@ print_insn (pc, info, buf, buflen) while (insn_list != NULL) { const CGEN_INSN *insn = insn_list->insn; - const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); CGEN_FIELDS fields; int length; diff --git a/opcodes/cgen-opc.in b/opcodes/cgen-opc.in new file mode 100644 index 00000000000..d88df31834f --- /dev/null +++ b/opcodes/cgen-opc.in @@ -0,0 +1,143 @@ +/* Generic opcode table support for targets using CGEN. -*- C -*- + CGEN: Cpu tools GENerator + +This file is used to generate @arch@-opc.c. + +Copyright (C) 1998 Free Software Foundation, Inc. + +This file is part of the GNU Binutils and 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 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. + +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. */ + +#include "sysdep.h" +#include +#include "ansidecl.h" +#include "libiberty.h" +#include "bfd.h" +#include "symcat.h" +#include "@arch@-opc.h" + +/* Look up instruction INSN_VALUE and extract its fields. + If non-null INSN is the insn table entry. + Otherwise INSN_VALUE is examined to compute it. + LENGTH is the bit length of INSN_VALUE if known, otherwise 0. + The result a pointer to the insn table entry, or NULL if the instruction + wasn't recognized. */ + +const CGEN_INSN * +@arch@_cgen_lookup_insn (insn, insn_value, length, fields) + const CGEN_INSN *insn; + cgen_insn_t insn_value; + int length; + CGEN_FIELDS *fields; +{ + char buf[4]; + + if (!insn) + { + const CGEN_INSN_LIST *insn_list; + +#ifdef CGEN_INT_INSN + switch (length) + { + case 8: + buf[0] = insn_value; + break; + case 16: + if (cgen_current_endian == CGEN_ENDIAN_BIG) + bfd_putb16 (insn_value, buf); + else + bfd_putl16 (insn_value, buf); + break; + case 32: + if (cgen_current_endian == CGEN_ENDIAN_BIG) + bfd_putb32 (insn_value, buf); + else + bfd_putl32 (insn_value, buf); + break; + default: + abort (); + } +#else + abort (); /* FIXME: unfinished */ +#endif + + /* The instructions are stored in hash lists. + Pick the first one and keep trying until we find the right one. */ + + insn_list = CGEN_DIS_LOOKUP_INSN (buf, insn_value); + while (insn_list != NULL) + { + insn = insn_list->insn; + + /* Basic bit mask must be correct. */ + /* ??? May wish to allow target to defer this check until the extract + handler. */ + if ((insn_value & CGEN_INSN_MASK (insn)) == CGEN_INSN_VALUE (insn)) + { + length = (*CGEN_EXTRACT_FN (insn)) (insn, NULL, insn_value, fields); + if (length > 0) + return insn; + } + + insn_list = CGEN_DIS_NEXT_INSN (insn_list); + } + } + else + { + length = (*CGEN_EXTRACT_FN (insn)) (insn, NULL, insn_value, fields); + if (length > 0) + return insn; + } + + return NULL; +} + +/* Fill in the operand instances used by insn INSN_VALUE. + If non-null INS is the insn table entry. + Otherwise INSN_VALUE is examined to compute it. + LENGTH is the number of bits in INSN_VALUE if known, otherwise 0. + INDICES is a pointer to a buffer of MAX_OPERANDS ints to be filled in. + The result a pointer to the insn table entry, or NULL if the instruction + wasn't recognized. */ + +const CGEN_INSN * +@arch@_cgen_get_insn_operands (insn, insn_value, length, indices) + const CGEN_INSN *insn; + cgen_insn_t insn_value; + int length; + int *indices; +{ + CGEN_FIELDS fields; + const CGEN_OPERAND_INSTANCE *opinst; + int i; + + insn = @arch@_cgen_lookup_insn (insn, insn_value, length, &fields); + if (! insn) + return NULL; + + for (i = 0, opinst = CGEN_INSN_OPERANDS (insn); + CGEN_OPERAND_INSTANCE_TYPE (opinst) != CGEN_OPERAND_INSTANCE_END; + ++i, ++opinst) + { + const CGEN_OPERAND *op = CGEN_OPERAND_INSTANCE_OPERAND (opinst); + if (op == NULL) + indices[i] = CGEN_OPERAND_INSTANCE_INDEX (opinst); + else + indices[i] = @arch@_cgen_get_operand (CGEN_OPERAND_INDEX (op), &fields); + } + + return insn; +} diff --git a/opcodes/m32r-asm.c b/opcodes/m32r-asm.c index ce0bef062cf..318fa2df9a6 100644 --- a/opcodes/m32r-asm.c +++ b/opcodes/m32r-asm.c @@ -304,26 +304,46 @@ m32r_cgen_parse_operand (opindex, strp, fields) case M32R_OPERAND_UIMM16 : errmsg = cgen_parse_unsigned_integer (strp, 11, 0, 65535, &fields->f_uimm16); break; +/* start-sanitize-m32rx */ + case M32R_OPERAND_IMM1 : + errmsg = cgen_parse_unsigned_integer (strp, 12, 0, 1, &fields->f_imm1); + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACCD : + errmsg = cgen_parse_keyword (strp, & m32r_cgen_opval_h_accums, & fields->f_accd); + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACCS : + errmsg = cgen_parse_keyword (strp, & m32r_cgen_opval_h_accums, & fields->f_accs); + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACC : + errmsg = cgen_parse_keyword (strp, & m32r_cgen_opval_h_accums, & fields->f_acc); + break; +/* end-sanitize-m32rx */ case M32R_OPERAND_HI16 : - errmsg = parse_h_hi16 (strp, 12, 0, 65535, &fields->f_hi16); + errmsg = parse_h_hi16 (strp, 16, 0, 65535, &fields->f_hi16); break; case M32R_OPERAND_SLO16 : - errmsg = parse_h_slo16 (strp, 13, -32768, 32767, &fields->f_simm16); + errmsg = parse_h_slo16 (strp, 17, -32768, 32767, &fields->f_simm16); break; case M32R_OPERAND_ULO16 : - errmsg = parse_h_ulo16 (strp, 14, 0, 65535, &fields->f_uimm16); + errmsg = parse_h_ulo16 (strp, 18, 0, 65535, &fields->f_uimm16); break; case M32R_OPERAND_UIMM24 : - errmsg = cgen_parse_address (strp, 15, 0, NULL, & fields->f_uimm24); + errmsg = cgen_parse_address (strp, 19, 0, NULL, & fields->f_uimm24); break; case M32R_OPERAND_DISP8 : - errmsg = cgen_parse_address (strp, 16, 0, NULL, & fields->f_disp8); + errmsg = cgen_parse_address (strp, 20, 0, NULL, & fields->f_disp8); break; case M32R_OPERAND_DISP16 : - errmsg = cgen_parse_address (strp, 17, 0, NULL, & fields->f_disp16); + errmsg = cgen_parse_address (strp, 21, 0, NULL, & fields->f_disp16); break; case M32R_OPERAND_DISP24 : - errmsg = cgen_parse_address (strp, 18, 0, NULL, & fields->f_disp24); + errmsg = cgen_parse_address (strp, 22, 0, NULL, & fields->f_disp24); break; default : @@ -390,6 +410,26 @@ m32r_cgen_insert_operand (opindex, fields, buffer) case M32R_OPERAND_UIMM16 : insert_normal (fields->f_uimm16, 0|(1<f_imm1, 0|(1<f_accd, 0|(1<f_accs, 0|(1<f_acc, 0|(1<f_hi16, 0|(1<f_uimm16, 0, 65535); break; +/* start-sanitize-m32rx */ + case M32R_OPERAND_IMM1 : + errmsg = cgen_validate_unsigned_integer (fields->f_imm1, 0, 1); + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACCD : + /* nothing to do */ + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACCS : + /* nothing to do */ + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACC : + /* nothing to do */ + break; +/* end-sanitize-m32rx */ case M32R_OPERAND_HI16 : errmsg = cgen_validate_unsigned_integer (fields->f_hi16, 0, 65535); break; diff --git a/opcodes/m32r-dis.c b/opcodes/m32r-dis.c index d0b97332b88..9b467eb0530 100644 --- a/opcodes/m32r-dis.c +++ b/opcodes/m32r-dis.c @@ -57,7 +57,7 @@ static void print_insn_normal static int extract_normal (buf_ctrl, insn_value, attrs, start, length, shift, total_length, valuep) - void *buf_ctrl; + PTR buf_ctrl; cgen_insn_t insn_value; unsigned int attrs; int start, length, shift, total_length; @@ -94,7 +94,7 @@ extract_normal (buf_ctrl, insn_value, attrs, start, length, shift, total_length, static void print_normal (dis_info, value, attrs, pc, length) - void *dis_info; + PTR dis_info; long value; unsigned int attrs; unsigned long pc; /* FIXME: should be bfd_vma */ @@ -121,7 +121,7 @@ print_normal (dis_info, value, attrs, pc, length) static void print_keyword (dis_info, keyword_table, value, attrs) - void *dis_info; + PTR dis_info; CGEN_KEYWORD *keyword_table; long value; CGEN_ATTR *attrs; @@ -197,7 +197,7 @@ my_print_insn (pc, info, buf, buflen) CGEN_INLINE int m32r_cgen_extract_operand (opindex, buf_ctrl, insn_value, fields) int opindex; - void * buf_ctrl; + PTR buf_ctrl; cgen_insn_t insn_value; CGEN_FIELDS * fields; { @@ -238,6 +238,26 @@ m32r_cgen_extract_operand (opindex, buf_ctrl, insn_value, fields) case M32R_OPERAND_UIMM16 : length = extract_normal (NULL /*FIXME*/, insn_value, 0|(1<f_uimm16); break; +/* start-sanitize-m32rx */ + case M32R_OPERAND_IMM1 : + length = extract_normal (NULL /*FIXME*/, insn_value, 0|(1<f_imm1); + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACCD : + length = extract_normal (NULL /*FIXME*/, insn_value, 0|(1<f_accd); + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACCS : + length = extract_normal (NULL /*FIXME*/, insn_value, 0|(1<f_accs); + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACC : + length = extract_normal (NULL /*FIXME*/, insn_value, 0|(1<f_acc); + break; +/* end-sanitize-m32rx */ case M32R_OPERAND_HI16 : length = extract_normal (NULL /*FIXME*/, insn_value, 0|(1<f_hi16); break; @@ -327,6 +347,26 @@ m32r_cgen_print_operand (opindex, info, fields, attrs, pc, length) case M32R_OPERAND_UIMM16 : print_normal (info, fields->f_uimm16, 0|(1<f_imm1, 0|(1<f_accd, 0|(1<f_accs, 0|(1<f_acc, 0|(1<f_hi16, 0|(1<insn; - const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); CGEN_FIELDS fields; int length; diff --git a/opcodes/m32r-opc.c b/opcodes/m32r-opc.c index 38ad0de7548..3a3227683fd 100644 --- a/opcodes/m32r-opc.c +++ b/opcodes/m32r-opc.c @@ -1,10 +1,11 @@ -/* CGEN opcode support for m32r. +/* Generic opcode table support for targets using CGEN. -*- C -*- + CGEN: Cpu tools GENerator -This file is machine generated with CGEN. +This file is used to generate m32r-opc.c. -Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +Copyright (C) 1998 Free Software Foundation, Inc. -This file is part of the GNU Binutils and/or GDB, the GNU debugger. +This file is part of the GNU Binutils and 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 @@ -16,20 +17,130 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "sysdep.h" #include #include "ansidecl.h" #include "libiberty.h" #include "bfd.h" +#include "symcat.h" #include "m32r-opc.h" +/* Look up instruction INSN_VALUE and extract its fields. + If non-null INSN is the insn table entry. + Otherwise INSN_VALUE is examined to compute it. + LENGTH is the bit length of INSN_VALUE if known, otherwise 0. + The result a pointer to the insn table entry, or NULL if the instruction + wasn't recognized. */ + +const CGEN_INSN * +m32r_cgen_lookup_insn (insn, insn_value, length, fields) + const CGEN_INSN *insn; + cgen_insn_t insn_value; + int length; + CGEN_FIELDS *fields; +{ + char buf[4]; + + if (!insn) + { + const CGEN_INSN_LIST *insn_list; + +#ifdef CGEN_INT_INSN + switch (length) + { + case 8: + buf[0] = insn_value; + break; + case 16: + if (cgen_current_endian == CGEN_ENDIAN_BIG) + bfd_putb16 (insn_value, buf); + else + bfd_putl16 (insn_value, buf); + break; + case 32: + if (cgen_current_endian == CGEN_ENDIAN_BIG) + bfd_putb32 (insn_value, buf); + else + bfd_putl32 (insn_value, buf); + break; + default: + abort (); + } +#else + abort (); /* FIXME: unfinished */ +#endif + + /* The instructions are stored in hash lists. + Pick the first one and keep trying until we find the right one. */ + + insn_list = CGEN_DIS_LOOKUP_INSN (buf, insn_value); + while (insn_list != NULL) + { + insn = insn_list->insn; + + /* Basic bit mask must be correct. */ + /* ??? May wish to allow target to defer this check until the extract + handler. */ + if ((insn_value & CGEN_INSN_MASK (insn)) == CGEN_INSN_VALUE (insn)) + { + length = (*CGEN_EXTRACT_FN (insn)) (insn, NULL, insn_value, fields); + if (length > 0) + return insn; + } + + insn_list = CGEN_DIS_NEXT_INSN (insn_list); + } + } + else + { + length = (*CGEN_EXTRACT_FN (insn)) (insn, NULL, insn_value, fields); + if (length > 0) + return insn; + } + + return NULL; +} + +/* Fill in the operand instances used by insn INSN_VALUE. + If non-null INS is the insn table entry. + Otherwise INSN_VALUE is examined to compute it. + LENGTH is the number of bits in INSN_VALUE if known, otherwise 0. + INDICES is a pointer to a buffer of MAX_OPERANDS ints to be filled in. + The result a pointer to the insn table entry, or NULL if the instruction + wasn't recognized. */ + +const CGEN_INSN * +m32r_cgen_get_insn_operands (insn, insn_value, length, indices) + const CGEN_INSN *insn; + cgen_insn_t insn_value; + int length; + int *indices; +{ + CGEN_FIELDS fields; + const CGEN_OPERAND_INSTANCE *opinst; + int i; + + insn = m32r_cgen_lookup_insn (insn, insn_value, length, &fields); + if (! insn) + return NULL; + + for (i = 0, opinst = CGEN_INSN_OPERANDS (insn); + CGEN_OPERAND_INSTANCE_TYPE (opinst) != CGEN_OPERAND_INSTANCE_END; + ++i, ++opinst) + { + const CGEN_OPERAND *op = CGEN_OPERAND_INSTANCE_OPERAND (opinst); + if (op == NULL) + indices[i] = CGEN_OPERAND_INSTANCE_INDEX (opinst); + else + indices[i] = m32r_cgen_get_operand (CGEN_OPERAND_INDEX (op), &fields); + } + + return insn; +} /* Attributes. */ static const CGEN_ATTR_ENTRY MACH_attr[] = @@ -42,6 +153,20 @@ static const CGEN_ATTR_ENTRY MACH_attr[] = { 0, 0 } }; +static const CGEN_ATTR_ENTRY WRITE_LR_attr[] = +{ + { "NO", WRITE_LR_NO }, + { "YES", WRITE_LR_YES }, + { 0, 0 } +}; + +static const CGEN_ATTR_ENTRY WRITE_SRC_attr[] = +{ + { "NO", WRITE_SRC_NO }, + { "YES", WRITE_SRC_YES }, + { 0, 0 } +}; + /* start-sanitize-m32rx */ static const CGEN_ATTR_ENTRY PIPE_attr[] = { @@ -73,6 +198,8 @@ const CGEN_ATTR_TABLE m32r_cgen_insn_attr_table[] = /* start-sanitize-m32rx */ { "PIPE", & PIPE_attr[0] }, /* end-sanitize-m32rx */ + { "WRITE_LR", & WRITE_LR_attr[0] }, + { "WRITE_SRC", & WRITE_SRC_attr[0] }, { "ALIAS", NULL }, { "COND-CTI", NULL }, { "FILL-SLOT", NULL }, @@ -149,94 +276,532 @@ CGEN_KEYWORD m32r_cgen_opval_h_accums = /* end-sanitize-m32rx */ -static CGEN_HW_ENTRY m32r_cgen_hw_entries[] = +/* The hardware table. */ + +#define HW_ENT(n) m32r_cgen_hw_entries[n] +static const 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 }, + { HW_H_PC, & HW_ENT (HW_H_PC + 1), "h-pc", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_MEMORY, & HW_ENT (HW_H_MEMORY + 1), "h-memory", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_SINT, & HW_ENT (HW_H_SINT + 1), "h-sint", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_UINT, & HW_ENT (HW_H_UINT + 1), "h-uint", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_ADDR, & HW_ENT (HW_H_ADDR + 1), "h-addr", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_IADDR, & HW_ENT (HW_H_IADDR + 1), "h-iaddr", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_HI16, & HW_ENT (HW_H_HI16 + 1), "h-hi16", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_SLO16, & HW_ENT (HW_H_SLO16 + 1), "h-slo16", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_ULO16, & HW_ENT (HW_H_ULO16 + 1), "h-ulo16", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_GR, & HW_ENT (HW_H_GR + 1), "h-gr", CGEN_ASM_KEYWORD, (PTR) & m32r_cgen_opval_h_gr }, + { HW_H_CR, & HW_ENT (HW_H_CR + 1), "h-cr", CGEN_ASM_KEYWORD, (PTR) & m32r_cgen_opval_h_cr }, + { HW_H_ACCUM, & HW_ENT (HW_H_ACCUM + 1), "h-accum", CGEN_ASM_KEYWORD, (PTR) 0 }, /* start-sanitize-m32rx */ - { "h-accums", CGEN_ASM_KEYWORD, (PTR) & m32r_cgen_opval_h_accums }, + { HW_H_ACCUMS, & HW_ENT (HW_H_ACCUMS + 1), "h-accums", CGEN_ASM_KEYWORD, (PTR) & m32r_cgen_opval_h_accums }, /* end-sanitize-m32rx */ /* start-sanitize-m32rx */ - { "h-abort", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_ABORT, & HW_ENT (HW_H_ABORT + 1), "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 }, + { HW_H_COND, & HW_ENT (HW_H_COND + 1), "h-cond", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_SM, & HW_ENT (HW_H_SM + 1), "h-sm", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_BSM, & HW_ENT (HW_H_BSM + 1), "h-bsm", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_IE, & HW_ENT (HW_H_IE + 1), "h-ie", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_BIE, & HW_ENT (HW_H_BIE + 1), "h-bie", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_BCOND, & HW_ENT (HW_H_BCOND + 1), "h-bcond", CGEN_ASM_KEYWORD, (PTR) 0 }, + { HW_H_BPC, & HW_ENT (HW_H_BPC + 1), "h-bpc", CGEN_ASM_KEYWORD, (PTR) 0 }, { 0 } }; +/* The operand table. */ + +#define OP_ENT(op) m32r_cgen_operand_table[SYMCAT2 (M32R_OPERAND_,op)] 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 }, +/* 1 */ { OP, ' ', 130, ',', 129, ',', '#', 145, 0 }, /* $dr,$sr,$slo16 */ -/* 2 */ { OP, ' ', 130, ',', 129, ',', 143, 0 }, +/* 2 */ { OP, ' ', 130, ',', 129, ',', 145, 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 }, +/* 5 */ { OP, ' ', 130, ',', 129, ',', '#', 146, 0 }, /* $dr,$sr,$ulo16 */ -/* 6 */ { OP, ' ', 130, ',', 129, ',', 144, 0 }, +/* 6 */ { OP, ' ', 130, ',', 129, ',', 146, 0 }, /* $dr,#$simm8 */ /* 7 */ { OP, ' ', 130, ',', '#', 135, 0 }, /* $dr,$simm8 */ @@ -264,13 +829,13 @@ static const CGEN_SYNTAX syntax_table[] = /* $dr,$sr,$simm16 */ /* 10 */ { OP, ' ', 130, ',', 129, ',', 136, 0 }, /* $disp8 */ -/* 11 */ { OP, ' ', 146, 0 }, +/* 11 */ { OP, ' ', 148, 0 }, /* $disp24 */ -/* 12 */ { OP, ' ', 148, 0 }, +/* 12 */ { OP, ' ', 150, 0 }, /* $src1,$src2,$disp16 */ -/* 13 */ { OP, ' ', 131, ',', 132, ',', 147, 0 }, +/* 13 */ { OP, ' ', 131, ',', 132, ',', 149, 0 }, /* $src2,$disp16 */ -/* 14 */ { OP, ' ', 132, ',', 147, 0 }, +/* 14 */ { OP, ' ', 132, ',', 149, 0 }, /* $src1,$src2 */ /* 15 */ { OP, ' ', 131, ',', 132, 0 }, /* $src2,#$simm16 */ @@ -290,137 +855,213 @@ static const CGEN_SYNTAX syntax_table[] = /* $dr,@($sr) */ /* 23 */ { OP, ' ', 130, ',', '@', '(', 129, ')', 0 }, /* $dr,@($slo16,$sr) */ -/* 24 */ { OP, ' ', 130, ',', '@', '(', 143, ',', 129, ')', 0 }, +/* 24 */ { OP, ' ', 130, ',', '@', '(', 145, ',', 129, ')', 0 }, /* $dr,@($sr,$slo16) */ -/* 25 */ { OP, ' ', 130, ',', '@', '(', 129, ',', 143, ')', 0 }, +/* 25 */ { OP, ' ', 130, ',', '@', '(', 129, ',', 145, ')', 0 }, /* $dr,@$sr+ */ /* 26 */ { OP, ' ', 130, ',', '@', 129, '+', 0 }, /* $dr,#$uimm24 */ -/* 27 */ { OP, ' ', 130, ',', '#', 145, 0 }, +/* 27 */ { OP, ' ', 130, ',', '#', 147, 0 }, /* $dr,$uimm24 */ -/* 28 */ { OP, ' ', 130, ',', 145, 0 }, +/* 28 */ { OP, ' ', 130, ',', 147, 0 }, /* $dr,$slo16 */ -/* 29 */ { OP, ' ', 130, ',', 143, 0 }, +/* 29 */ { OP, ' ', 130, ',', 145, 0 }, /* $src1,$src2,$acc */ -/* 30 */ { OP, ' ', 131, ',', 132, ',', 141, 0 }, +/* 30 */ { OP, ' ', 131, ',', 132, ',', 143, 0 }, /* $dr */ /* 31 */ { OP, ' ', 130, 0 }, /* $dr,$accs */ -/* 32 */ { OP, ' ', 130, ',', 140, 0 }, +/* 32 */ { OP, ' ', 130, ',', 142, 0 }, /* $dr,$scr */ /* 33 */ { OP, ' ', 130, ',', 133, 0 }, /* $src1 */ /* 34 */ { OP, ' ', 131, 0 }, /* $src1,$accs */ -/* 35 */ { OP, ' ', 131, ',', 140, 0 }, +/* 35 */ { OP, ' ', 131, ',', 142, 0 }, /* $sr,$dcr */ /* 36 */ { OP, ' ', 129, ',', 134, 0 }, /* */ /* 37 */ { OP, 0 }, -/* $accs */ -/* 38 */ { OP, ' ', 140, 0 }, +/* $accd */ +/* 38 */ { OP, ' ', 141, 0 }, +/* $accd,$accs */ +/* 39 */ { OP, ' ', 141, ',', 142, 0 }, +/* $accd,$accs,#$imm1 */ +/* 40 */ { OP, ' ', 141, ',', 142, ',', '#', 140, 0 }, /* $dr,#$hi16 */ -/* 39 */ { OP, ' ', 130, ',', '#', 142, 0 }, +/* 41 */ { OP, ' ', 130, ',', '#', 144, 0 }, /* $dr,$hi16 */ -/* 40 */ { OP, ' ', 130, ',', 142, 0 }, +/* 42 */ { OP, ' ', 130, ',', 144, 0 }, /* $dr,#$uimm5 */ -/* 41 */ { OP, ' ', 130, ',', '#', 138, 0 }, +/* 43 */ { OP, ' ', 130, ',', '#', 138, 0 }, /* $dr,$uimm5 */ -/* 42 */ { OP, ' ', 130, ',', 138, 0 }, +/* 44 */ { OP, ' ', 130, ',', 138, 0 }, /* $src1,@$src2 */ -/* 43 */ { OP, ' ', 131, ',', '@', 132, 0 }, +/* 45 */ { OP, ' ', 131, ',', '@', 132, 0 }, /* $src1,@($src2) */ -/* 44 */ { OP, ' ', 131, ',', '@', '(', 132, ')', 0 }, +/* 46 */ { OP, ' ', 131, ',', '@', '(', 132, ')', 0 }, /* $src1,@($slo16,$src2) */ -/* 45 */ { OP, ' ', 131, ',', '@', '(', 143, ',', 132, ')', 0 }, +/* 47 */ { OP, ' ', 131, ',', '@', '(', 145, ',', 132, ')', 0 }, /* $src1,@($src2,$slo16) */ -/* 46 */ { OP, ' ', 131, ',', '@', '(', 132, ',', 143, ')', 0 }, +/* 48 */ { OP, ' ', 131, ',', '@', '(', 132, ',', 145, ')', 0 }, /* $src1,@+$src2 */ -/* 47 */ { OP, ' ', 131, ',', '@', '+', 132, 0 }, +/* 49 */ { OP, ' ', 131, ',', '@', '+', 132, 0 }, /* $src1,@-$src2 */ -/* 48 */ { OP, ' ', 131, ',', '@', '-', 132, 0 }, +/* 50 */ { OP, ' ', 131, ',', '@', '-', 132, 0 }, /* #$uimm4 */ -/* 49 */ { OP, ' ', '#', 137, 0 }, +/* 51 */ { OP, ' ', '#', 137, 0 }, /* $uimm4 */ -/* 50 */ { OP, ' ', 137, 0 }, +/* 52 */ { OP, ' ', 137, 0 }, /* $dr,$src2 */ -/* 51 */ { OP, ' ', 130, ',', 132, 0 }, +/* 53 */ { OP, ' ', 130, ',', 132, 0 }, }; #undef OP static const CGEN_FORMAT format_table[] = { -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr. */ +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.dr.SI.sr.SI. */ /* 0 */ { 16, 16, 0xf0f0 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.slo16. */ +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.slo16.slo16.HI.sr.SI. */ /* 1 */ { 32, 32, 0xf0f00000 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-uimm16.uimm16. */ +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-uimm16.uimm16.sr.SI.uimm16.USI. */ /* 2 */ { 32, 32, 0xf0f00000 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-uimm16.ulo16. */ +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-uimm16.ulo16.sr.SI.ulo16.UHI. */ /* 3 */ { 32, 32, 0xf0f00000 }, -/* f-op1.number.f-r1.dr.f-simm8.simm8. */ +/* f-op1.number.f-r1.dr.f-simm8.simm8.dr.SI.simm8.SI. */ /* 4 */ { 16, 16, 0xf000 }, -/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.simm16. */ +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.simm16.simm16.SI.sr.SI. */ /* 5 */ { 32, 32, 0xf0f00000 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.condbit.UBI.dr.SI.sr.SI. */ +/* 6 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.number.f-disp8.disp8.condbit.UBI.disp8.VM. */ +/* 7 */ { 16, 16, 0xff00 }, /* f-op1.number.f-r1.number.f-disp8.disp8. */ -/* 6 */ { 16, 16, 0xff00 }, +/* 8 */ { 16, 16, 0xff00 }, +/* f-op1.number.f-r1.number.f-disp24.disp24.condbit.UBI.disp24.VM. */ +/* 9 */ { 32, 32, 0xff000000 }, /* 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. */ +/* 10 */ { 32, 32, 0xff000000 }, +/* f-op1.number.f-r1.src1.f-op2.number.f-r2.src2.f-disp16.disp16.disp16.VM.src1.SI.src2.SI. */ +/* 11 */ { 32, 32, 0xf0f00000 }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.src2.f-disp16.disp16.disp16.VM.src2.SI. */ /* 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-disp8.disp8.disp8.VM.pc.USI. */ +/* 13 */ { 16, 16, 0xff00 }, +/* f-op1.number.f-r1.number.f-disp24.disp24.disp24.VM.pc.USI. */ +/* 14 */ { 32, 32, 0xff000000 }, +/* f-op1.number.f-r1.number.f-disp8.disp8.condbit.UBI.disp8.VM.pc.USI. */ +/* 15 */ { 16, 16, 0xff00 }, +/* f-op1.number.f-r1.number.f-disp24.disp24.condbit.UBI.disp24.VM.pc.USI. */ +/* 16 */ { 32, 32, 0xff000000 }, +/* f-op1.number.f-r1.number.f-disp8.disp8.disp8.VM. */ +/* 17 */ { 16, 16, 0xff00 }, +/* f-op1.number.f-r1.number.f-disp24.disp24.disp24.VM. */ +/* 18 */ { 32, 32, 0xff000000 }, +/* f-op1.number.f-r1.src1.f-op2.number.f-r2.src2.src1.SI.src2.SI. */ +/* 19 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.src2.f-simm16.simm16.simm16.SI.src2.SI. */ +/* 20 */ { 32, 32, 0xfff00000 }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.src2.f-uimm16.uimm16.src2.SI.uimm16.USI. */ +/* 21 */ { 32, 32, 0xfff00000 }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.src2.src2.SI. */ +/* 22 */ { 16, 16, 0xfff0 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.number.dr.SI.sr.SI. */ +/* 23 */ { 32, 32, 0xf0f0ffff }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.sr.condbit.UBI.sr.SI. */ +/* 24 */ { 16, 16, 0xfff0 }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.sr.pc.USI.sr.SI. */ +/* 25 */ { 16, 16, 0xfff0 }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.sr.sr.SI. */ +/* 26 */ { 16, 16, 0xfff0 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.h-memory-sr.SI.sr.SI. */ +/* 27 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr. */ +/* 28 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.slo16.h-memory-add-WI-sr-slo16.SI.slo16.HI.sr.SI. */ +/* 29 */ { 32, 32, 0xf0f00000 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.slo16. */ +/* 30 */ { 32, 32, 0xf0f00000 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.h-memory-sr.QI.sr.SI. */ +/* 31 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.slo16.h-memory-add-WI-sr-slo16.QI.slo16.HI.sr.SI. */ +/* 32 */ { 32, 32, 0xf0f00000 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.h-memory-sr.HI.sr.SI. */ +/* 33 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.f-simm16.slo16.h-memory-add-WI-sr-slo16.HI.slo16.HI.sr.SI. */ +/* 34 */ { 32, 32, 0xf0f00000 }, +/* f-op1.number.f-r1.dr.f-uimm24.uimm24.uimm24.VM. */ +/* 35 */ { 32, 32, 0xf0000000 }, +/* f-op1.number.f-r1.dr.f-simm8.simm8.simm8.SI. */ +/* 36 */ { 16, 16, 0xf000 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.number.f-simm16.slo16.slo16.HI. */ +/* 37 */ { 32, 32, 0xf0ff0000 }, +/* f-op1.number.f-r1.src1.f-op2.number.f-r2.src2.accum.DI.src1.SI.src2.SI. */ +/* 38 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.src1.f-acc.acc.f-op23.number.f-r2.src2.acc.DI.src1.SI.src2.SI. */ +/* 39 */ { 16, 16, 0xf070 }, +/* f-op1.number.f-r1.src1.f-acc.acc.f-op23.number.f-r2.src2.src1.SI.src2.SI. */ +/* 40 */ { 16, 16, 0xf070 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.sr.sr.SI. */ +/* 41 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.number.accum.DI. */ +/* 42 */ { 16, 16, 0xf0ff }, +/* f-op1.number.f-r1.dr.f-op2.number.f-accs.accs.f-op3.number.accs.DI. */ +/* 43 */ { 16, 16, 0xf0f3 }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.scr.scr.SI. */ +/* 44 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.src1.f-op2.number.f-r2.number.accum.DI.src1.SI. */ +/* 45 */ { 16, 16, 0xf0ff }, +/* f-op1.number.f-r1.src1.f-op2.number.f-accs.accs.f-op3.number.accs.DI.src1.SI. */ +/* 46 */ { 16, 16, 0xf0f3 }, +/* f-op1.number.f-r1.dcr.f-op2.number.f-r2.sr.sr.SI. */ +/* 47 */ { 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 }, +/* 48 */ { 16, 16, 0xffff }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.number.accum.DI. */ +/* 49 */ { 16, 16, 0xffff }, +/* f-op1.number.f-accd.accd.f-bits67.number.f-op2.number.f-accs.number.f-bit14.number.f-imm1.number.accum.DI. */ +/* 50 */ { 16, 16, 0xf3ff }, +/* f-op1.number.f-accd.accd.f-bits67.number.f-op2.number.f-accs.accs.f-bit14.number.f-imm1.number.accs.DI. */ +/* 51 */ { 16, 16, 0xf3f3 }, +/* f-op1.number.f-accd.accd.f-bits67.number.f-op2.number.f-accs.accs.f-bit14.number.f-imm1.imm1.accs.DI.imm1.USI. */ +/* 52 */ { 16, 16, 0xf3f2 }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.number.h-bcond-0.VM.h-bie-0.VM.h-bpc-0.VM.h-bsm-0.VM. */ +/* 53 */ { 16, 16, 0xffff }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.number.f-hi16.hi16.hi16.UHI. */ +/* 54 */ { 32, 32, 0xf0ff0000 }, +/* f-op1.number.f-r1.dr.f-shift-op2.number.f-uimm5.uimm5.dr.SI.uimm5.USI. */ +/* 55 */ { 16, 16, 0xf0e0 }, +/* f-op1.number.f-r1.src1.f-op2.number.f-r2.src2. */ +/* 56 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.src1.f-op2.number.f-r2.src2.f-simm16.slo16.slo16.HI.src1.SI.src2.SI. */ +/* 57 */ { 32, 32, 0xf0f00000 }, /* 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 }, +/* 58 */ { 32, 32, 0xf0f00000 }, +/* f-op1.number.f-r1.number.f-op2.number.f-uimm4.uimm4.uimm4.USI. */ +/* 59 */ { 16, 16, 0xfff0 }, +/* f-op1.number.f-r1.src1.f-op2.number.f-r2.number. */ +/* 60 */ { 16, 16, 0xf0ff }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.number. */ +/* 61 */ { 16, 16, 0xf0ff }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.src2.f-uimm16.number.src2.SI. */ +/* 62 */ { 32, 32, 0xf0f0ffff }, +/* f-op1.number.f-r1.dr.f-op2.number.f-r2.src2.f-uimm16.number.condbit.UBI.src2.SI. */ +/* 63 */ { 32, 32, 0xf0f0ffff }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.number.h-accums-0.DI.h-accums-1.DI. */ +/* 64 */ { 16, 16, 0xffff }, +/* f-op1.number.f-r1.src1.f-op2.number.f-r2.src2.h-accums-1.DI.src1.SI.src2.SI. */ +/* 65 */ { 16, 16, 0xf0f0 }, +/* f-op1.number.f-r1.number.f-op2.number.f-r2.number.condbit.UBI. */ +/* 66 */ { 16, 16, 0xffff }, }; #define A(a) (1 << CGEN_CAT3 (CGEN_INSN,_,a)) #define SYN(n) (& syntax_table[n]) #define FMT(n) (& format_table[n]) +/* The instruction table. */ + const CGEN_INSN m32r_cgen_insn_table_entries[MAX_INSNS] = { /* null first entry, end of all hash chains */ @@ -429,1148 +1070,1373 @@ const CGEN_INSN m32r_cgen_insn_table_entries[MAX_INSNS] = { { 1, 1, 1, 1 }, "add", "add", SYN (0), FMT (0), 0xa0, - { 2, 0|A(PARALLEL), { (1<f_uimm16 = * valuep; break; +/* start-sanitize-m32rx */ + case M32R_OPERAND_IMM1 : + fields->f_imm1 = * valuep; + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACCD : + fields->f_accd = * valuep; + break; +/* end-sanitize-m32rx */ /* start-sanitize-m32rx */ case M32R_OPERAND_ACCS : fields->f_accs = * valuep; @@ -1745,6 +2621,16 @@ m32r_cgen_get_operand (opindex, fields) case M32R_OPERAND_UIMM16 : value = fields->f_uimm16; break; +/* start-sanitize-m32rx */ + case M32R_OPERAND_IMM1 : + value = fields->f_imm1; + break; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + case M32R_OPERAND_ACCD : + value = fields->f_accd; + break; +/* end-sanitize-m32rx */ /* start-sanitize-m32rx */ case M32R_OPERAND_ACCS : value = fields->f_accs; diff --git a/opcodes/m32r-opc.h b/opcodes/m32r-opc.h index 79b141507ac..90c913c74d4 100644 --- a/opcodes/m32r-opc.h +++ b/opcodes/m32r-opc.h @@ -75,6 +75,12 @@ typedef enum cgen_operand_type { M32R_OPERAND_PC, M32R_OPERAND_SR, M32R_OPERAND_DR, M32R_OPERAND_SRC1 , M32R_OPERAND_SRC2, M32R_OPERAND_SCR, M32R_OPERAND_DCR, M32R_OPERAND_SIMM8 , M32R_OPERAND_SIMM16, M32R_OPERAND_UIMM4, M32R_OPERAND_UIMM5, M32R_OPERAND_UIMM16 +/* start-sanitize-m32rx */ + , M32R_OPERAND_IMM1 +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + , M32R_OPERAND_ACCD +/* end-sanitize-m32rx */ /* start-sanitize-m32rx */ , M32R_OPERAND_ACCS /* end-sanitize-m32rx */ @@ -101,6 +107,16 @@ typedef enum mach_attr { , MACH_MAX } MACH_ATTR; +/* Enum declaration for instructions which modify the link register as a side effect. */ +typedef enum write_lr_attr { + WRITE_LR_NO, WRITE_LR_YES +} WRITE_LR_ATTR; + +/* Enum declaration for instructions which modify their source register as a side effect. */ +typedef enum write_src_attr { + WRITE_SRC_NO, WRITE_SRC_YES +} WRITE_SRC_ATTR; + /* start-sanitize-m32rx */ /* Enum declaration for parallel execution pipeline selection. */ typedef enum pipe_attr { @@ -111,9 +127,12 @@ typedef enum pipe_attr { /* Number of architecture variants. */ #define MAX_MACHS ((int) MACH_MAX) -/* Number of operands. */ +/* Number of operands types. */ #define MAX_OPERANDS ((int) M32R_OPERAND_MAX) +/* Maximum number of operands referenced by any insn. */ +#define MAX_OPERAND_INSTANCES 8 + /* Operand and instruction attribute indices. */ /* Enum declaration for cgen_operand attrs. */ @@ -132,8 +151,9 @@ typedef enum cgen_insn_attr { /* start-sanitize-m32rx */ , CGEN_INSN_PIPE /* end-sanitize-m32rx */ - , CGEN_INSN_ALIAS, CGEN_INSN_COND_CTI, CGEN_INSN_FILL_SLOT, CGEN_INSN_PARALLEL - , CGEN_INSN_RELAX, CGEN_INSN_RELAXABLE, CGEN_INSN_UNCOND_CTI + , CGEN_INSN_WRITE_LR, CGEN_INSN_WRITE_SRC, CGEN_INSN_ALIAS, CGEN_INSN_COND_CTI + , CGEN_INSN_FILL_SLOT, CGEN_INSN_PARALLEL, CGEN_INSN_RELAX, CGEN_INSN_RELAXABLE + , CGEN_INSN_UNCOND_CTI } CGEN_INSN_ATTR; /* Number of non-boolean elements in cgen_insn. */ @@ -187,6 +207,9 @@ typedef enum cgen_insn_type { , M32R_INSN_CMPZ /* end-sanitize-m32rx */ , M32R_INSN_DIV, M32R_INSN_DIVU, M32R_INSN_REM, M32R_INSN_REMU +/* start-sanitize-m32rx */ + , M32R_INSN_DIVH +/* end-sanitize-m32rx */ /* start-sanitize-m32rx */ , M32R_INSN_JC /* end-sanitize-m32rx */ @@ -240,11 +263,23 @@ typedef enum cgen_insn_type { , M32R_INSN_MVTC, M32R_INSN_NEG, M32R_INSN_NOP, M32R_INSN_NOT , M32R_INSN_RAC /* start-sanitize-m32rx */ - , M32R_INSN_RAC_A + , M32R_INSN_RAC_D +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + , M32R_INSN_RAC_DS +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + , M32R_INSN_RAC_DSI /* end-sanitize-m32rx */ , M32R_INSN_RACH /* start-sanitize-m32rx */ - , M32R_INSN_RACH_A + , M32R_INSN_RACH_D +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + , M32R_INSN_RACH_DS +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + , M32R_INSN_RACH_DSI /* end-sanitize-m32rx */ , M32R_INSN_RTE, M32R_INSN_SETH, M32R_INSN_SETH_A, M32R_INSN_SLL , M32R_INSN_SLL3, M32R_INSN_SLL3_A, M32R_INSN_SLLI, M32R_INSN_SLLI_A @@ -281,7 +316,7 @@ typedef enum cgen_insn_type { , M32R_INSN_MULWU1 /* end-sanitize-m32rx */ /* start-sanitize-m32rx */ - , M32R_INSN_MACHL1 + , M32R_INSN_MACLH1 /* end-sanitize-m32rx */ /* start-sanitize-m32rx */ , M32R_INSN_SC @@ -301,7 +336,7 @@ typedef enum cgen_insn_type { #include "opcode/cgen.h" /* This struct records data prior to insertion or after extraction. */ -typedef struct cgen_fields +struct cgen_fields { long f_nil; long f_op1; @@ -331,14 +366,45 @@ typedef struct cgen_fields /* end-sanitize-m32rx */ /* start-sanitize-m32rx */ long f_accs; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + long f_accd; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + long f_bits67; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + long f_bit14; +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + long f_imm1; /* end-sanitize-m32rx */ int length; -} CGEN_FIELDS; +}; /* Attributes. */ extern const CGEN_ATTR_TABLE m32r_cgen_operand_attr_table[]; extern const CGEN_ATTR_TABLE m32r_cgen_insn_attr_table[]; +/* Enum declaration for m32r hardware types. */ +typedef enum hw_type { + HW_H_PC, HW_H_MEMORY, HW_H_SINT, HW_H_UINT + , HW_H_ADDR, HW_H_IADDR, HW_H_HI16, HW_H_SLO16 + , HW_H_ULO16, HW_H_GR, HW_H_CR, HW_H_ACCUM +/* start-sanitize-m32rx */ + , HW_H_ACCUMS +/* end-sanitize-m32rx */ +/* start-sanitize-m32rx */ + , HW_H_ABORT +/* end-sanitize-m32rx */ + , HW_H_COND, HW_H_SM, HW_H_BSM, HW_H_IE + , HW_H_BIE, HW_H_BCOND, HW_H_BPC, HW_MAX +} HW_TYPE; + +#define MAX_HW ((int) HW_MAX) + +/* Hardware decls. */ + extern CGEN_KEYWORD m32r_cgen_opval_h_gr; extern CGEN_KEYWORD m32r_cgen_opval_h_cr; /* start-sanitize-m32rx */ @@ -368,6 +434,7 @@ extern CGEN_KEYWORD m32r_cgen_opval_h_accums; (X (buffer) | \ (X (buffer) == 0x40 || X (buffer) == 0xe0 || X (buffer) == 0x60 || X (buffer) == 0x50 ? 0 \ : X (buffer) == 0x70 || X (buffer) == 0xf0 ? (((unsigned char *) (buffer))[0] & 0xf) \ + : X (buffer) == 0x30 ? ((((unsigned char *) (buffer))[1] & 0x70) >> 4) \ : ((((unsigned char *) (buffer))[1] & 0xf0) >> 4))) /* -- */