diff options
author | Dave Brolley <brolley@redhat.com> | 2001-03-05 15:55:01 +0000 |
---|---|---|
committer | Dave Brolley <brolley@redhat.com> | 2001-03-05 15:55:01 +0000 |
commit | b3466c39bc29323e1912f5fa17c70e63af56e001 (patch) | |
tree | a14bfd8c10860de783fdc96506fb1a033cb925e6 | |
parent | 1c7566d1677731631c070b1e30d80ad5b97ed8d5 (diff) | |
download | gdb-b3466c39bc29323e1912f5fa17c70e63af56e001.zip gdb-b3466c39bc29323e1912f5fa17c70e63af56e001.tar.gz gdb-b3466c39bc29323e1912f5fa17c70e63af56e001.tar.bz2 |
2001-03-05 Dave Brolley <brolley@redhat.co
* opcodes/fr30-asm.c: Regenerate.
* opcodes/fr30-desc.c: Regenerate.
* opcodes/fr30-desc.h: Regenerate.
* opcodes/fr30-dis.c: Regenerate.
* opcodes/fr30-ibld.c: Regenerate.
* opcodes/fr30-opc.c: Regenerate.
* opcodes/fr30-opc.h: Regenerate.
* opcodes/m32r-asm.c: Regenerate.
* opcodes/m32r-desc.c: Regenerate.
* opcodes/m32r-desc.h: Regenerate.
* opcodes/m32r-dis.c: Regenerate.
* opcodes/m32r-ibld.c: Regenerate.
* opcodes/m32r-opc.c: Regenerate.
* opcodes/m32r-opc.h: Regenerate.
* opcodes/m32r-opinst.c: Regenerate.
-rw-r--r-- | opcodes/ChangeLog | 18 | ||||
-rw-r--r-- | opcodes/fr30-asm.c | 46 | ||||
-rw-r--r-- | opcodes/fr30-desc.c | 41 | ||||
-rw-r--r-- | opcodes/fr30-desc.h | 11 | ||||
-rw-r--r-- | opcodes/fr30-dis.c | 68 | ||||
-rw-r--r-- | opcodes/fr30-ibld.c | 126 | ||||
-rw-r--r-- | opcodes/fr30-opc.c | 44 | ||||
-rw-r--r-- | opcodes/fr30-opc.h | 2 | ||||
-rw-r--r-- | opcodes/m32r-asm.c | 46 | ||||
-rw-r--r-- | opcodes/m32r-desc.c | 41 | ||||
-rw-r--r-- | opcodes/m32r-desc.h | 11 | ||||
-rw-r--r-- | opcodes/m32r-dis.c | 80 | ||||
-rw-r--r-- | opcodes/m32r-ibld.c | 126 | ||||
-rw-r--r-- | opcodes/m32r-opc.c | 44 | ||||
-rw-r--r-- | opcodes/m32r-opc.h | 2 | ||||
-rw-r--r-- | opcodes/m32r-opinst.c | 10 |
16 files changed, 327 insertions, 389 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 37aabe8..b39bc61 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,21 @@ +2001-03-05 Dave Brolley <brolley@redhat.com> + + * opcodes/fr30-asm.c: Regenerate. + * opcodes/fr30-desc.c: Regenerate. + * opcodes/fr30-desc.h: Regenerate. + * opcodes/fr30-dis.c: Regenerate. + * opcodes/fr30-ibld.c: Regenerate. + * opcodes/fr30-opc.c: Regenerate. + * opcodes/fr30-opc.h: Regenerate. + * opcodes/m32r-asm.c: Regenerate. + * opcodes/m32r-desc.c: Regenerate. + * opcodes/m32r-desc.h: Regenerate. + * opcodes/m32r-dis.c: Regenerate. + * opcodes/m32r-ibld.c: Regenerate. + * opcodes/m32r-opc.c: Regenerate. + * opcodes/m32r-opc.h: Regenerate. + * opcodes/m32r-opinst.c: Regenerate. + 2001-02-28 Igor Shevlyakov <igor@windriver.com> * m68k-opc.c: fix cpushl according to Motorola. Enable diff --git a/opcodes/fr30-asm.c b/opcodes/fr30-asm.c index 08092af..05e72aa 100644 --- a/opcodes/fr30-asm.c +++ b/opcodes/fr30-asm.c @@ -4,7 +4,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. - the resultant file is machine generated, cgen-asm.in isn't -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -351,7 +351,7 @@ parse_insn_normal (cd, insn, strp, fields) const char *str = *strp; const char *errmsg; const char *p; - const unsigned char * syn; + const CGEN_SYNTAX_CHAR_TYPE * syn; #ifdef CGEN_MNEMONIC_OPERANDS /* FIXME: wip */ int past_opcode_p; @@ -401,19 +401,28 @@ parse_insn_normal (cd, insn, strp, fields) if (tolower (*str) == tolower (CGEN_SYNTAX_CHAR (* syn))) { #ifdef CGEN_MNEMONIC_OPERANDS - if (* syn == ' ') + if (CGEN_SYNTAX_CHAR(* syn) == ' ') past_opcode_p = 1; #endif ++ syn; ++ str; } - else + else if (*str) { /* Syntax char didn't match. Can't be this insn. */ static char msg [80]; /* xgettext:c-format */ sprintf (msg, _("syntax error (expected char `%c', found `%c')"), - *syn, *str); + CGEN_SYNTAX_CHAR(*syn), *str); + return msg; + } + else + { + /* Ran out of input. */ + static char msg [80]; + /* xgettext:c-format */ + sprintf (msg, _("syntax error (expected char `%c', found end of instruction)"), + CGEN_SYNTAX_CHAR(*syn)); return msg; } continue; @@ -430,7 +439,7 @@ parse_insn_normal (cd, insn, strp, fields) } /* If we're at the end of the syntax string, we're done. */ - if (* syn == '\0') + if (* syn == 0) { /* FIXME: For the moment we assume a valid `str' can only contain blanks now. IE: We needn't try again with a longer version of @@ -480,7 +489,8 @@ fr30_cgen_assemble_insn (cd, str, fields, buf, errmsg) { const char *start; CGEN_INSN_LIST *ilist; - const char *tmp_errmsg = NULL; + const char *parse_errmsg = NULL; + const char *insert_errmsg = NULL; /* Skip leading white space. */ while (isspace (* str)) @@ -515,14 +525,14 @@ fr30_cgen_assemble_insn (cd, str, fields, buf, errmsg) /* Allow parse/insert handlers to obtain length of insn. */ CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); - tmp_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields); - if (tmp_errmsg != NULL) + parse_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields); + if (parse_errmsg != NULL) continue; /* ??? 0 is passed for `pc' */ - tmp_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf, - (bfd_vma) 0); - if (tmp_errmsg != NULL) + insert_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf, + (bfd_vma) 0); + if (insert_errmsg != NULL) continue; /* It is up to the caller to actually output the insn and any @@ -530,15 +540,17 @@ fr30_cgen_assemble_insn (cd, str, fields, buf, errmsg) return insn; } - /* Make sure we leave this with something at this point. */ - if (tmp_errmsg == NULL) - tmp_errmsg = "unknown mnemonic"; - { static char errbuf[150]; + const char *tmp_errmsg; #ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS - /* if verbose error messages, use errmsg from CGEN_PARSE_FN */ + /* If requesting verbose error messages, use insert_errmsg. + Failing that, use parse_errmsg */ + tmp_errmsg = (insert_errmsg ? insert_errmsg : + parse_errmsg ? parse_errmsg : + _("unrecognized instruction")); + if (strlen (start) > 50) /* xgettext:c-format */ sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start); diff --git a/opcodes/fr30-desc.c b/opcodes/fr30-desc.c index 42561ed..0d07146 100644 --- a/opcodes/fr30-desc.c +++ b/opcodes/fr30-desc.c @@ -2,7 +2,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. @@ -249,10 +249,13 @@ CGEN_KEYWORD fr30_cgen_opval_h_r15 = }; - /* The hardware table. */ -#define A(a) (1 << CONCAT2 (CGEN_HW_,a)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_HW_##a) +#else +#define A(a) (1 << CGEN_HW_/**/a) +#endif const CGEN_HW_ENTRY fr30_cgen_hw_table[] = { @@ -286,9 +289,14 @@ const CGEN_HW_ENTRY fr30_cgen_hw_table[] = #undef A + /* The instruction field table. */ -#define A(a) (1 << CONCAT2 (CGEN_IFLD_,a)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_IFLD_##a) +#else +#define A(a) (1 << CGEN_IFLD_/**/a) +#endif const CGEN_IFLD fr30_cgen_ifld_table[] = { @@ -338,10 +346,19 @@ const CGEN_IFLD fr30_cgen_ifld_table[] = #undef A + /* The operand table. */ -#define A(a) (1 << CONCAT2 (CGEN_OPERAND_,a)) -#define OPERAND(op) CONCAT2 (FR30_OPERAND_,op) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_OPERAND_##a) +#else +#define A(a) (1 << CGEN_OPERAND_/**/a) +#endif +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define OPERAND(op) FR30_OPERAND_##op +#else +#define OPERAND(op) FR30_OPERAND_/**/op +#endif const CGEN_OPERAND fr30_cgen_operand_table[] = { @@ -497,11 +514,16 @@ const CGEN_OPERAND fr30_cgen_operand_table[] = #undef A -#define A(a) (1 << CONCAT2 (CGEN_INSN_,a)) -#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) /* The instruction table. */ +#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_INSN_##a) +#else +#define A(a) (1 << CGEN_INSN_/**/a) +#endif + static const CGEN_IBASE fr30_cgen_insn_table[MAX_INSNS] = { /* Special null first entry. @@ -1335,9 +1357,8 @@ static const CGEN_IBASE fr30_cgen_insn_table[MAX_INSNS] = }, }; -#undef A -#undef MNEM #undef OP +#undef A /* Initialize anything needed to be done once, before any cpu_open call. */ diff --git a/opcodes/fr30-desc.h b/opcodes/fr30-desc.h index 27b4db5..98405b2 100644 --- a/opcodes/fr30-desc.h +++ b/opcodes/fr30-desc.h @@ -2,7 +2,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. @@ -28,7 +28,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #define CGEN_ARCH fr30 /* Given symbol S, return fr30_cgen_<S>. */ -#define CGEN_SYM(s) CONCAT3 (fr30,_cgen_,s) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define CGEN_SYM(s) fr30##_cgen_##s +#else +#define CGEN_SYM(s) fr30/**/_cgen_/**/s +#endif + /* Selected cpu families. */ #define HAVE_CPU_FR30BF @@ -43,7 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define CGEN_INT_INSN_P 0 -/* Maximum nymber of syntax bytes in an instruction. */ +/* Maximum number of syntax elements in an instruction. */ #define CGEN_ACTUAL_MAX_SYNTAX_ELEMENTS 15 /* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands. diff --git a/opcodes/fr30-dis.c b/opcodes/fr30-dis.c index bd5946f..c330078 100644 --- a/opcodes/fr30-dis.c +++ b/opcodes/fr30-dis.c @@ -4,7 +4,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. - the resultant file is machine generated, cgen-dis.in isn't -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -96,60 +96,60 @@ print_register_list (dis_info, value, offset, load_store) static void print_hi_register_list_ld (cd, dis_info, value, attrs, pc, length) - CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; + CGEN_CPU_DESC cd; PTR dis_info; long value; - unsigned int attrs ATTRIBUTE_UNUSED; - bfd_vma pc ATTRIBUTE_UNUSED; - int length ATTRIBUTE_UNUSED; + unsigned int attrs; + bfd_vma pc; + int length; { print_register_list (dis_info, value, 8, 0/*load*/); } static void print_low_register_list_ld (cd, dis_info, value, attrs, pc, length) - CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; + CGEN_CPU_DESC cd; PTR dis_info; long value; - unsigned int attrs ATTRIBUTE_UNUSED; - bfd_vma pc ATTRIBUTE_UNUSED; - int length ATTRIBUTE_UNUSED; + unsigned int attrs; + bfd_vma pc; + int length; { print_register_list (dis_info, value, 0, 0/*load*/); } static void print_hi_register_list_st (cd, dis_info, value, attrs, pc, length) - CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; + CGEN_CPU_DESC cd; PTR dis_info; long value; - unsigned int attrs ATTRIBUTE_UNUSED; - bfd_vma pc ATTRIBUTE_UNUSED; - int length ATTRIBUTE_UNUSED; + unsigned int attrs; + bfd_vma pc; + int length; { print_register_list (dis_info, value, 8, 1/*store*/); } static void print_low_register_list_st (cd, dis_info, value, attrs, pc, length) - CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; + CGEN_CPU_DESC cd; PTR dis_info; long value; - unsigned int attrs ATTRIBUTE_UNUSED; - bfd_vma pc ATTRIBUTE_UNUSED; - int length ATTRIBUTE_UNUSED; + unsigned int attrs; + bfd_vma pc; + int length; { print_register_list (dis_info, value, 0, 1/*store*/); } static void print_m4 (cd, dis_info, value, attrs, pc, length) - CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; + CGEN_CPU_DESC cd; PTR dis_info; long value; - unsigned int attrs ATTRIBUTE_UNUSED; - bfd_vma pc ATTRIBUTE_UNUSED; - int length ATTRIBUTE_UNUSED; + unsigned int attrs; + bfd_vma pc; + int length; { disassemble_info *info = (disassemble_info *) dis_info; (*info->fprintf_func) (info->stream, "%ld", value); @@ -178,7 +178,7 @@ fr30_cgen_print_operand (cd, opindex, xinfo, fields, attrs, pc, length) int opindex; PTR xinfo; CGEN_FIELDS *fields; - void const *attrs ATTRIBUTE_UNUSED; + void const *attrs; bfd_vma pc; int length; { @@ -430,7 +430,7 @@ print_insn_normal (cd, dis_info, insn, fields, pc, length) { const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); disassemble_info *info = (disassemble_info *) dis_info; - const unsigned char *syn; + const CGEN_SYNTAX_CHAR_TYPE *syn; CGEN_INIT_PRINT (cd); @@ -458,7 +458,7 @@ print_insn_normal (cd, dis_info, insn, fields, pc, length) Returns 0 if all is well, non-zero otherwise. */ static int read_insn (cd, pc, info, buf, buflen, ex_info, insn_value) - CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; + CGEN_CPU_DESC cd; bfd_vma pc; disassemble_info *info; char *buf; @@ -477,21 +477,7 @@ read_insn (cd, pc, info, buf, buflen, ex_info, insn_value) ex_info->valid = (1 << buflen) - 1; ex_info->insn_bytes = buf; - switch (buflen) - { - case 1: - *insn_value = buf[0]; - break; - case 2: - *insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb16 (buf) : bfd_getl16 (buf); - break; - case 4: - *insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb32 (buf) : bfd_getl32 (buf); - break; - default: - abort (); - } - + *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG); return 0; } @@ -549,8 +535,8 @@ print_insn (cd, pc, info, buf, buflen) /* Make sure the entire insn is loaded into insn_value, if it can fit. */ - if ((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize && - (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) + if (CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize && + (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) { unsigned long full_insn_value; int rc = read_insn (cd, pc, info, buf, diff --git a/opcodes/fr30-ibld.c b/opcodes/fr30-ibld.c index a29ce3e..c37095f 100644 --- a/opcodes/fr30-ibld.c +++ b/opcodes/fr30-ibld.c @@ -3,7 +3,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't -Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -78,34 +78,7 @@ insert_1 (cd, value, start, length, word_length, bufp) int shift; int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG; - switch (word_length) - { - case 8: - x = *bufp; - break; - case 16: - if (big_p) - x = bfd_getb16 (bufp); - else - x = bfd_getl16 (bufp); - break; - case 24: - /* ??? This may need reworking as these cases don't necessarily - want the first byte and the last two bytes handled like this. */ - if (big_p) - x = (bufp[0] << 16) | bfd_getb16 (bufp + 1); - else - x = bfd_getl16 (bufp) | (bufp[2] << 16); - break; - case 32: - if (big_p) - x = bfd_getb32 (bufp); - else - x = bfd_getl32 (bufp); - break; - default : - abort (); - } + x = bfd_get_bits (bufp, word_length, big_p); /* Written this way to avoid undefined behaviour. */ mask = (((1L << (length - 1)) - 1) << 1) | 1; @@ -115,40 +88,7 @@ insert_1 (cd, value, start, length, word_length, bufp) shift = (word_length - (start + length)); x = (x & ~(mask << shift)) | ((value & mask) << shift); - switch (word_length) - { - case 8: - *bufp = x; - break; - case 16: - if (big_p) - bfd_putb16 (x, bufp); - else - bfd_putl16 (x, bufp); - break; - case 24: - /* ??? This may need reworking as these cases don't necessarily - want the first byte and the last two bytes handled like this. */ - if (big_p) - { - bufp[0] = x >> 16; - bfd_putb16 (x, bufp + 1); - } - else - { - bfd_putl16 (x, bufp); - bufp[2] = x >> 16; - } - break; - case 32: - if (big_p) - bfd_putb32 (x, bufp); - else - bfd_putl32 (x, bufp); - break; - default : - abort (); - } + bfd_put_bits ((bfd_vma) x, bufp, word_length, big_p); } #endif /* ! CGEN_INT_INSN_P */ @@ -278,7 +218,7 @@ insert_insn_normal (cd, insn, fields, buffer, pc) { const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); unsigned long value; - const unsigned char * syn; + const CGEN_SYNTAX_CHAR_TYPE * syn; CGEN_INIT_INSERT (cd); value = CGEN_INSN_BASE_VALUE (insn); @@ -304,7 +244,7 @@ insert_insn_normal (cd, insn, fields, buffer, pc) e.g. storing a branch displacement that got resolved later. Needs more thought first. */ - for (syn = CGEN_SYNTAX_STRING (syntax); * syn != '\0'; ++ syn) + for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn) { const char *errmsg; @@ -406,46 +346,17 @@ extract_1 (cd, ex_info, start, length, word_length, bufp, pc) unsigned char *bufp; bfd_vma pc; { - unsigned long x,mask; + unsigned long x; int shift; int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG; - switch (word_length) - { - case 8: - x = *bufp; - break; - case 16: - if (big_p) - x = bfd_getb16 (bufp); - else - x = bfd_getl16 (bufp); - break; - case 24: - /* ??? This may need reworking as these cases don't necessarily - want the first byte and the last two bytes handled like this. */ - if (big_p) - x = (bufp[0] << 16) | bfd_getb16 (bufp + 1); - else - x = bfd_getl16 (bufp) | (bufp[2] << 16); - break; - case 32: - if (big_p) - x = bfd_getb32 (bufp); - else - x = bfd_getl32 (bufp); - break; - default : - abort (); - } + x = bfd_get_bits (bufp, word_length, big_p); - /* Written this way to avoid undefined behaviour. */ - mask = (((1L << (length - 1)) - 1) << 1) | 1; if (CGEN_INSN_LSB0_P) shift = (start + 1) - length; else shift = (word_length - (start + length)); - return (x >> shift) & mask; + return x >> shift; } #endif /* ! CGEN_INT_INSN_P */ @@ -489,7 +400,7 @@ extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length, #endif long *valuep; { - CGEN_INSN_INT value; + CGEN_INSN_INT value, mask; /* If LENGTH is zero, this operand doesn't contribute to the value so give it a standard value of zero. */ @@ -521,18 +432,10 @@ extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length, if (CGEN_INT_INSN_P || word_offset == 0) { - /* Written this way to avoid undefined behaviour. */ - CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1; - if (CGEN_INSN_LSB0_P) value = insn_value >> ((word_offset + start + 1) - length); else value = insn_value >> (total_length - ( word_offset + start + length)); - value &= mask; - /* sign extend? */ - if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) - && (value & (1L << (length - 1)))) - value |= ~mask; } #if ! CGEN_INT_INSN_P @@ -552,6 +455,15 @@ extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length, #endif /* ! CGEN_INT_INSN_P */ + /* Written this way to avoid undefined behaviour. */ + mask = (((1L << (length - 1)) - 1) << 1) | 1; + + value &= mask; + /* sign extend? */ + if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) + && (value & (1L << (length - 1)))) + value |= ~mask; + *valuep = value; return 1; @@ -576,7 +488,7 @@ extract_insn_normal (cd, insn, ex_info, insn_value, fields, pc) bfd_vma pc; { const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); - const unsigned char *syn; + const CGEN_SYNTAX_CHAR_TYPE *syn; CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); diff --git a/opcodes/fr30-opc.c b/opcodes/fr30-opc.c index 3b37dcb..5541f13 100644 --- a/opcodes/fr30-opc.c +++ b/opcodes/fr30-opc.c @@ -2,7 +2,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. @@ -40,8 +40,11 @@ static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT)); /* Instruction formats. */ -#define F(f) & fr30_cgen_ifld_table[CONCAT2 (FR30_,f)] - +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define F(f) & fr30_cgen_ifld_table[FR30_##f] +#else +#define F(f) & fr30_cgen_ifld_table[FR30_/**/f] +#endif static const CGEN_IFMT ifmt_empty = { 0, 0, 0x0, { { 0 } } }; @@ -164,9 +167,17 @@ static const CGEN_IFMT ifmt_enter = { #undef F -#define A(a) (1 << CONCAT2 (CGEN_INSN_,a)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_INSN_##a) +#else +#define A(a) (1 << CGEN_INSN_/**/a) +#endif +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define OPERAND(op) FR30_OPERAND_##op +#else +#define OPERAND(op) FR30_OPERAND_/**/op +#endif #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ -#define OPERAND(op) CONCAT2 (FR30_OPERAND_,op) #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) /* The instruction table. */ @@ -1170,14 +1181,17 @@ static const CGEN_OPCODE fr30_cgen_insn_opcode_table[MAX_INSNS] = }; #undef A -#undef MNEM #undef OPERAND +#undef MNEM #undef OP /* Formats for ALIAS macro-insns. */ -#define F(f) & fr30_cgen_ifld_table[CONCAT2 (FR30_,f)] - +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define F(f) & fr30_cgen_ifld_table[FR30_##f] +#else +#define F(f) & fr30_cgen_ifld_table[FR30_/**/f] +#endif static const CGEN_IFMT ifmt_ldi8m = { 16, 16, 0xf000, { { F (F_OP1) }, { F (F_I8) }, { F (F_RI) }, { 0 } } }; @@ -1194,9 +1208,17 @@ static const CGEN_IFMT ifmt_ldi32m = { /* Each non-simple macro entry points to an array of expansion possibilities. */ -#define A(a) (1 << CONCAT2 (CGEN_INSN_,a)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_INSN_##a) +#else +#define A(a) (1 << CGEN_INSN_/**/a) +#endif +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define OPERAND(op) FR30_OPERAND_##op +#else +#define OPERAND(op) FR30_OPERAND_/**/op +#endif #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ -#define OPERAND(op) CONCAT2 (FR30_OPERAND_,op) #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) /* The macro instruction table. */ @@ -1245,8 +1267,8 @@ static const CGEN_OPCODE fr30_cgen_macro_insn_opcode_table[] = }; #undef A -#undef MNEM #undef OPERAND +#undef MNEM #undef OP #ifndef CGEN_ASM_HASH_P diff --git a/opcodes/fr30-opc.h b/opcodes/fr30-opc.h index 4dda89c..1b5a954 100644 --- a/opcodes/fr30-opc.h +++ b/opcodes/fr30-opc.h @@ -2,7 +2,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. diff --git a/opcodes/m32r-asm.c b/opcodes/m32r-asm.c index 5dba005..f790df6 100644 --- a/opcodes/m32r-asm.c +++ b/opcodes/m32r-asm.c @@ -4,7 +4,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. - the resultant file is machine generated, cgen-asm.in isn't -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -359,7 +359,7 @@ parse_insn_normal (cd, insn, strp, fields) const char *str = *strp; const char *errmsg; const char *p; - const unsigned char * syn; + const CGEN_SYNTAX_CHAR_TYPE * syn; #ifdef CGEN_MNEMONIC_OPERANDS /* FIXME: wip */ int past_opcode_p; @@ -409,19 +409,28 @@ parse_insn_normal (cd, insn, strp, fields) if (tolower (*str) == tolower (CGEN_SYNTAX_CHAR (* syn))) { #ifdef CGEN_MNEMONIC_OPERANDS - if (* syn == ' ') + if (CGEN_SYNTAX_CHAR(* syn) == ' ') past_opcode_p = 1; #endif ++ syn; ++ str; } - else + else if (*str) { /* Syntax char didn't match. Can't be this insn. */ static char msg [80]; /* xgettext:c-format */ sprintf (msg, _("syntax error (expected char `%c', found `%c')"), - *syn, *str); + CGEN_SYNTAX_CHAR(*syn), *str); + return msg; + } + else + { + /* Ran out of input. */ + static char msg [80]; + /* xgettext:c-format */ + sprintf (msg, _("syntax error (expected char `%c', found end of instruction)"), + CGEN_SYNTAX_CHAR(*syn)); return msg; } continue; @@ -438,7 +447,7 @@ parse_insn_normal (cd, insn, strp, fields) } /* If we're at the end of the syntax string, we're done. */ - if (* syn == '\0') + if (* syn == 0) { /* FIXME: For the moment we assume a valid `str' can only contain blanks now. IE: We needn't try again with a longer version of @@ -488,7 +497,8 @@ m32r_cgen_assemble_insn (cd, str, fields, buf, errmsg) { const char *start; CGEN_INSN_LIST *ilist; - const char *tmp_errmsg = NULL; + const char *parse_errmsg = NULL; + const char *insert_errmsg = NULL; /* Skip leading white space. */ while (isspace (* str)) @@ -523,14 +533,14 @@ m32r_cgen_assemble_insn (cd, str, fields, buf, errmsg) /* Allow parse/insert handlers to obtain length of insn. */ CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); - tmp_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields); - if (tmp_errmsg != NULL) + parse_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields); + if (parse_errmsg != NULL) continue; /* ??? 0 is passed for `pc' */ - tmp_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf, - (bfd_vma) 0); - if (tmp_errmsg != NULL) + insert_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf, + (bfd_vma) 0); + if (insert_errmsg != NULL) continue; /* It is up to the caller to actually output the insn and any @@ -538,15 +548,17 @@ m32r_cgen_assemble_insn (cd, str, fields, buf, errmsg) return insn; } - /* Make sure we leave this with something at this point. */ - if (tmp_errmsg == NULL) - tmp_errmsg = "unknown mnemonic"; - { static char errbuf[150]; + const char *tmp_errmsg; #ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS - /* if verbose error messages, use errmsg from CGEN_PARSE_FN */ + /* If requesting verbose error messages, use insert_errmsg. + Failing that, use parse_errmsg */ + tmp_errmsg = (insert_errmsg ? insert_errmsg : + parse_errmsg ? parse_errmsg : + _("unrecognized instruction")); + if (strlen (start) > 50) /* xgettext:c-format */ sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start); diff --git a/opcodes/m32r-desc.c b/opcodes/m32r-desc.c index a13d083..86d47b6 100644 --- a/opcodes/m32r-desc.c +++ b/opcodes/m32r-desc.c @@ -2,7 +2,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. @@ -219,10 +219,13 @@ CGEN_KEYWORD m32r_cgen_opval_h_accums = }; - /* The hardware table. */ -#define A(a) (1 << CONCAT2 (CGEN_HW_,a)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_HW_##a) +#else +#define A(a) (1 << CGEN_HW_/**/a) +#endif const CGEN_HW_ENTRY m32r_cgen_hw_table[] = { @@ -249,9 +252,14 @@ const CGEN_HW_ENTRY m32r_cgen_hw_table[] = #undef A + /* The instruction field table. */ -#define A(a) (1 << CONCAT2 (CGEN_IFLD_,a)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_IFLD_##a) +#else +#define A(a) (1 << CGEN_IFLD_/**/a) +#endif const CGEN_IFLD m32r_cgen_ifld_table[] = { @@ -286,10 +294,19 @@ const CGEN_IFLD m32r_cgen_ifld_table[] = #undef A + /* The operand table. */ -#define A(a) (1 << CONCAT2 (CGEN_OPERAND_,a)) -#define OPERAND(op) CONCAT2 (M32R_OPERAND_,op) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_OPERAND_##a) +#else +#define A(a) (1 << CGEN_OPERAND_/**/a) +#endif +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define OPERAND(op) M32R_OPERAND_##op +#else +#define OPERAND(op) M32R_OPERAND_/**/op +#endif const CGEN_OPERAND m32r_cgen_operand_table[] = { @@ -376,11 +393,16 @@ const CGEN_OPERAND m32r_cgen_operand_table[] = #undef A -#define A(a) (1 << CONCAT2 (CGEN_INSN_,a)) -#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) /* The instruction table. */ +#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_INSN_##a) +#else +#define A(a) (1 << CGEN_INSN_/**/a) +#endif + static const CGEN_IBASE m32r_cgen_insn_table[MAX_INSNS] = { /* Special null first entry. @@ -1059,9 +1081,8 @@ static const CGEN_IBASE m32r_cgen_insn_table[MAX_INSNS] = }, }; -#undef A -#undef MNEM #undef OP +#undef A /* Initialize anything needed to be done once, before any cpu_open call. */ diff --git a/opcodes/m32r-desc.h b/opcodes/m32r-desc.h index 9fe57ab..13de889 100644 --- a/opcodes/m32r-desc.h +++ b/opcodes/m32r-desc.h @@ -2,7 +2,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. @@ -28,7 +28,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #define CGEN_ARCH m32r /* Given symbol S, return m32r_cgen_<S>. */ -#define CGEN_SYM(s) CONCAT3 (m32r,_cgen_,s) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define CGEN_SYM(s) m32r##_cgen_##s +#else +#define CGEN_SYM(s) m32r/**/_cgen_/**/s +#endif + /* Selected cpu families. */ #define HAVE_CPU_M32RBF @@ -44,7 +49,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define CGEN_INT_INSN_P 1 -/* Maximum nymber of syntax bytes in an instruction. */ +/* Maximum number of syntax elements in an instruction. */ #define CGEN_ACTUAL_MAX_SYNTAX_ELEMENTS 15 /* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands. diff --git a/opcodes/m32r-dis.c b/opcodes/m32r-dis.c index ed99320..455f8a3 100644 --- a/opcodes/m32r-dis.c +++ b/opcodes/m32r-dis.c @@ -4,7 +4,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. - the resultant file is machine generated, cgen-dis.in isn't -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -68,12 +68,12 @@ do { \ static void print_hash (cd, dis_info, value, attrs, pc, length) - CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; + CGEN_CPU_DESC cd; PTR dis_info; - long value ATTRIBUTE_UNUSED; - unsigned int attrs ATTRIBUTE_UNUSED; - bfd_vma pc ATTRIBUTE_UNUSED; - int length ATTRIBUTE_UNUSED; + long value; + unsigned int attrs; + bfd_vma pc; + int length; { disassemble_info *info = (disassemble_info *) dis_info; (*info->fprintf_func) (info->stream, "#"); @@ -156,7 +156,7 @@ m32r_cgen_print_operand (cd, opindex, xinfo, fields, attrs, pc, length) int opindex; PTR xinfo; CGEN_FIELDS *fields; - void const *attrs ATTRIBUTE_UNUSED; + void const *attrs; bfd_vma pc; int length; { @@ -263,12 +263,21 @@ m32r_cgen_init_dis (cd) static void print_normal (cd, dis_info, value, attrs, pc, length) +#ifdef CGEN_PRINT_NORMAL + CGEN_CPU_DESC cd; +#else CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; +#endif PTR dis_info; long value; unsigned int attrs; +#ifdef CGEN_PRINT_NORMAL + bfd_vma pc; + int length; +#else bfd_vma pc ATTRIBUTE_UNUSED; int length ATTRIBUTE_UNUSED; +#endif { disassemble_info *info = (disassemble_info *) dis_info; @@ -289,12 +298,21 @@ print_normal (cd, dis_info, value, attrs, pc, length) static void print_address (cd, dis_info, value, attrs, pc, length) +#ifdef CGEN_PRINT_NORMAL + CGEN_CPU_DESC cd; +#else CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; +#endif PTR dis_info; bfd_vma value; unsigned int attrs; +#ifdef CGEN_PRINT_NORMAL + bfd_vma pc; + int length; +#else bfd_vma pc ATTRIBUTE_UNUSED; int length ATTRIBUTE_UNUSED; +#endif { disassemble_info *info = (disassemble_info *) dis_info; @@ -351,7 +369,7 @@ print_insn_normal (cd, dis_info, insn, fields, pc, length) { const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); disassemble_info *info = (disassemble_info *) dis_info; - const unsigned char *syn; + const CGEN_SYNTAX_CHAR_TYPE *syn; CGEN_INIT_PRINT (cd); @@ -379,7 +397,7 @@ print_insn_normal (cd, dis_info, insn, fields, pc, length) Returns 0 if all is well, non-zero otherwise. */ static int read_insn (cd, pc, info, buf, buflen, ex_info, insn_value) - CGEN_CPU_DESC cd ATTRIBUTE_UNUSED; + CGEN_CPU_DESC cd; bfd_vma pc; disassemble_info *info; char *buf; @@ -398,21 +416,7 @@ read_insn (cd, pc, info, buf, buflen, ex_info, insn_value) ex_info->valid = (1 << buflen) - 1; ex_info->insn_bytes = buf; - switch (buflen) - { - case 1: - *insn_value = buf[0]; - break; - case 2: - *insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb16 (buf) : bfd_getl16 (buf); - break; - case 4: - *insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb32 (buf) : bfd_getl32 (buf); - break; - default: - abort (); - } - + *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG); return 0; } @@ -433,30 +437,11 @@ print_insn (cd, pc, info, buf, buflen) unsigned long insn_value; const CGEN_INSN_LIST *insn_list; CGEN_EXTRACT_INFO ex_info; -#if 0 + int rc = read_insn (cd, pc, info, buf, buflen, & ex_info, & insn_value); if (rc != 0) return rc; -#else - ex_info.dis_info = info; - ex_info.valid = (1 << buflen) - 1; - ex_info.insn_bytes = buf; - switch (buflen) - { - case 1: - insn_value = buf[0]; - break; - case 2: - insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb16 (buf) : bfd_getl16 (buf); - break; - case 4: - insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb32 (buf) : bfd_getl32 (buf); - break; - default: - abort (); - } -#endif /* The instructions are stored in hash lists. Pick the first one and keep trying until we find the right one. */ @@ -489,8 +474,8 @@ print_insn (cd, pc, info, buf, buflen) /* Make sure the entire insn is loaded into insn_value, if it can fit. */ - if ((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize && - (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) + if (CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize && + (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) { unsigned long full_insn_value; int rc = read_insn (cd, pc, info, buf, @@ -504,6 +489,7 @@ print_insn (cd, pc, info, buf, buflen) else length = CGEN_EXTRACT_FN (cd, insn) (cd, insn, &ex_info, insn_value, &fields, pc); + /* length < 0 -> error */ if (length < 0) return length; @@ -527,6 +513,7 @@ print_insn (cd, pc, info, buf, buflen) #ifndef CGEN_PRINT_INSN #define CGEN_PRINT_INSN default_print_insn +#endif static int default_print_insn (cd, pc, info) @@ -548,7 +535,6 @@ default_print_insn (cd, pc, info) return print_insn (cd, pc, info, buf, cd->base_insn_bitsize / 8); } -#endif /* Main entry point. Print one instruction from PC on INFO->STREAM. diff --git a/opcodes/m32r-ibld.c b/opcodes/m32r-ibld.c index 9920380..3110a7b 100644 --- a/opcodes/m32r-ibld.c +++ b/opcodes/m32r-ibld.c @@ -3,7 +3,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't -Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -78,34 +78,7 @@ insert_1 (cd, value, start, length, word_length, bufp) int shift; int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG; - switch (word_length) - { - case 8: - x = *bufp; - break; - case 16: - if (big_p) - x = bfd_getb16 (bufp); - else - x = bfd_getl16 (bufp); - break; - case 24: - /* ??? This may need reworking as these cases don't necessarily - want the first byte and the last two bytes handled like this. */ - if (big_p) - x = (bufp[0] << 16) | bfd_getb16 (bufp + 1); - else - x = bfd_getl16 (bufp) | (bufp[2] << 16); - break; - case 32: - if (big_p) - x = bfd_getb32 (bufp); - else - x = bfd_getl32 (bufp); - break; - default : - abort (); - } + x = bfd_get_bits (bufp, word_length, big_p); /* Written this way to avoid undefined behaviour. */ mask = (((1L << (length - 1)) - 1) << 1) | 1; @@ -115,40 +88,7 @@ insert_1 (cd, value, start, length, word_length, bufp) shift = (word_length - (start + length)); x = (x & ~(mask << shift)) | ((value & mask) << shift); - switch (word_length) - { - case 8: - *bufp = x; - break; - case 16: - if (big_p) - bfd_putb16 (x, bufp); - else - bfd_putl16 (x, bufp); - break; - case 24: - /* ??? This may need reworking as these cases don't necessarily - want the first byte and the last two bytes handled like this. */ - if (big_p) - { - bufp[0] = x >> 16; - bfd_putb16 (x, bufp + 1); - } - else - { - bfd_putl16 (x, bufp); - bufp[2] = x >> 16; - } - break; - case 32: - if (big_p) - bfd_putb32 (x, bufp); - else - bfd_putl32 (x, bufp); - break; - default : - abort (); - } + bfd_put_bits ((bfd_vma) x, bufp, word_length, big_p); } #endif /* ! CGEN_INT_INSN_P */ @@ -278,7 +218,7 @@ insert_insn_normal (cd, insn, fields, buffer, pc) { const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); unsigned long value; - const unsigned char * syn; + const CGEN_SYNTAX_CHAR_TYPE * syn; CGEN_INIT_INSERT (cd); value = CGEN_INSN_BASE_VALUE (insn); @@ -304,7 +244,7 @@ insert_insn_normal (cd, insn, fields, buffer, pc) e.g. storing a branch displacement that got resolved later. Needs more thought first. */ - for (syn = CGEN_SYNTAX_STRING (syntax); * syn != '\0'; ++ syn) + for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn) { const char *errmsg; @@ -406,46 +346,17 @@ extract_1 (cd, ex_info, start, length, word_length, bufp, pc) unsigned char *bufp; bfd_vma pc; { - unsigned long x,mask; + unsigned long x; int shift; int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG; - switch (word_length) - { - case 8: - x = *bufp; - break; - case 16: - if (big_p) - x = bfd_getb16 (bufp); - else - x = bfd_getl16 (bufp); - break; - case 24: - /* ??? This may need reworking as these cases don't necessarily - want the first byte and the last two bytes handled like this. */ - if (big_p) - x = (bufp[0] << 16) | bfd_getb16 (bufp + 1); - else - x = bfd_getl16 (bufp) | (bufp[2] << 16); - break; - case 32: - if (big_p) - x = bfd_getb32 (bufp); - else - x = bfd_getl32 (bufp); - break; - default : - abort (); - } + x = bfd_get_bits (bufp, word_length, big_p); - /* Written this way to avoid undefined behaviour. */ - mask = (((1L << (length - 1)) - 1) << 1) | 1; if (CGEN_INSN_LSB0_P) shift = (start + 1) - length; else shift = (word_length - (start + length)); - return (x >> shift) & mask; + return x >> shift; } #endif /* ! CGEN_INT_INSN_P */ @@ -489,7 +400,7 @@ extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length, #endif long *valuep; { - CGEN_INSN_INT value; + CGEN_INSN_INT value, mask; /* If LENGTH is zero, this operand doesn't contribute to the value so give it a standard value of zero. */ @@ -521,18 +432,10 @@ extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length, if (CGEN_INT_INSN_P || word_offset == 0) { - /* Written this way to avoid undefined behaviour. */ - CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1; - if (CGEN_INSN_LSB0_P) value = insn_value >> ((word_offset + start + 1) - length); else value = insn_value >> (total_length - ( word_offset + start + length)); - value &= mask; - /* sign extend? */ - if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) - && (value & (1L << (length - 1)))) - value |= ~mask; } #if ! CGEN_INT_INSN_P @@ -552,6 +455,15 @@ extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length, #endif /* ! CGEN_INT_INSN_P */ + /* Written this way to avoid undefined behaviour. */ + mask = (((1L << (length - 1)) - 1) << 1) | 1; + + value &= mask; + /* sign extend? */ + if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) + && (value & (1L << (length - 1)))) + value |= ~mask; + *valuep = value; return 1; @@ -576,7 +488,7 @@ extract_insn_normal (cd, insn, ex_info, insn_value, fields, pc) bfd_vma pc; { const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); - const unsigned char *syn; + const CGEN_SYNTAX_CHAR_TYPE *syn; CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); diff --git a/opcodes/m32r-opc.c b/opcodes/m32r-opc.c index a0753f3..44d5437 100644 --- a/opcodes/m32r-opc.c +++ b/opcodes/m32r-opc.c @@ -2,7 +2,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. @@ -40,8 +40,11 @@ static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT)); /* Instruction formats. */ -#define F(f) & m32r_cgen_ifld_table[CONCAT2 (M32R_,f)] - +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define F(f) & m32r_cgen_ifld_table[M32R_##f] +#else +#define F(f) & m32r_cgen_ifld_table[M32R_/**/f] +#endif static const CGEN_IFMT ifmt_empty = { 0, 0, 0x0, { { 0 } } }; @@ -172,9 +175,17 @@ static const CGEN_IFMT ifmt_satb = { #undef F -#define A(a) (1 << CONCAT2 (CGEN_INSN_,a)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_INSN_##a) +#else +#define A(a) (1 << CGEN_INSN_/**/a) +#endif +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define OPERAND(op) M32R_OPERAND_##op +#else +#define OPERAND(op) M32R_OPERAND_/**/op +#endif #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ -#define OPERAND(op) CONCAT2 (M32R_OPERAND_,op) #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) /* The instruction table. */ @@ -992,14 +1003,17 @@ static const CGEN_OPCODE m32r_cgen_insn_opcode_table[MAX_INSNS] = }; #undef A -#undef MNEM #undef OPERAND +#undef MNEM #undef OP /* Formats for ALIAS macro-insns. */ -#define F(f) & m32r_cgen_ifld_table[CONCAT2 (M32R_,f)] - +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define F(f) & m32r_cgen_ifld_table[M32R_##f] +#else +#define F(f) & m32r_cgen_ifld_table[M32R_/**/f] +#endif static const CGEN_IFMT ifmt_bc8r = { 16, 16, 0xff00, { { F (F_OP1) }, { F (F_R1) }, { F (F_DISP8) }, { 0 } } }; @@ -1148,9 +1162,17 @@ static const CGEN_IFMT ifmt_push = { /* Each non-simple macro entry points to an array of expansion possibilities. */ -#define A(a) (1 << CONCAT2 (CGEN_INSN_,a)) +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define A(a) (1 << CGEN_INSN_##a) +#else +#define A(a) (1 << CGEN_INSN_/**/a) +#endif +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define OPERAND(op) M32R_OPERAND_##op +#else +#define OPERAND(op) M32R_OPERAND_/**/op +#endif #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ -#define OPERAND(op) CONCAT2 (M32R_OPERAND_,op) #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) /* The macro instruction table. */ @@ -1562,8 +1584,8 @@ static const CGEN_OPCODE m32r_cgen_macro_insn_opcode_table[] = }; #undef A -#undef MNEM #undef OPERAND +#undef MNEM #undef OP #ifndef CGEN_ASM_HASH_P diff --git a/opcodes/m32r-opc.h b/opcodes/m32r-opc.h index b98c5f9..3f6802d 100644 --- a/opcodes/m32r-opc.h +++ b/opcodes/m32r-opc.h @@ -2,7 +2,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. diff --git a/opcodes/m32r-opinst.c b/opcodes/m32r-opinst.c index 269651f..969d77f 100644 --- a/opcodes/m32r-opinst.c +++ b/opcodes/m32r-opinst.c @@ -2,7 +2,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU Binutils and/or GDB, the GNU debugger. @@ -31,11 +31,15 @@ with this program; if not, write to the Free Software Foundation, Inc., /* Operand references. */ +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#define OP_ENT(op) M32R_OPERAND_##op +#else +#define OP_ENT(op) M32R_OPERAND_/**/op +#endif #define INPUT CGEN_OPINST_INPUT #define OUTPUT CGEN_OPINST_OUTPUT #define END CGEN_OPINST_END #define COND_REF CGEN_OPINST_COND_REF -#define OP_ENT(op) CONCAT2 (M32R_OPERAND_,op) static const CGEN_OPINST sfmt_empty_ops[] = { { END } @@ -513,11 +517,11 @@ static const CGEN_OPINST sfmt_sc_ops[] = { { END } }; +#undef OP_ENT #undef INPUT #undef OUTPUT #undef END #undef COND_REF -#undef OP_ENT /* Operand instance lookup table. */ |