diff options
Diffstat (limited to 'contrib/binutils/opcodes/ia64-gen.c')
-rw-r--r-- | contrib/binutils/opcodes/ia64-gen.c | 77 |
1 files changed, 64 insertions, 13 deletions
diff --git a/contrib/binutils/opcodes/ia64-gen.c b/contrib/binutils/opcodes/ia64-gen.c index a4e2cec..5562283 100644 --- a/contrib/binutils/opcodes/ia64-gen.c +++ b/contrib/binutils/opcodes/ia64-gen.c @@ -1,5 +1,6 @@ /* ia64-gen.c -- Generate a shrunk set of opcode tables - Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006 + Free Software Foundation, Inc. Written by Bob Manson, Cygnus Solutions, <manson@cygnus.com> This file is part of GDB, GAS, and the GNU binutils. @@ -16,8 +17,8 @@ You should have received a copy of the GNU General Public License along with this file; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ /* While the ia64-opc-* set of opcode tables are easy to maintain, they waste a tremendous amount of space. ia64-gen rearranges the @@ -53,9 +54,19 @@ #include <libintl.h> #define _(String) gettext (String) +/* This is a copy of fprintf_vma from bfd/bfd-in2.h. We have to use this + always, because we might be compiled without BFD64 defined, if configured + for a 32-bit target and --enable-targets=all is used. This will work for + both 32-bit and 64-bit hosts. */ +#define _opcode_int64_low(x) ((unsigned long) (((x) & 0xffffffff))) +#define _opcode_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff)) +#define opcode_fprintf_vma(s,x) \ + fprintf ((s), "%08lx%08lx", _opcode_int64_high (x), _opcode_int64_low (x)) + const char * program_name = NULL; int debug = 0; +#define NELEMS(a) (sizeof (a) / sizeof ((a)[0])) #define tmalloc(X) (X *) xmalloc (sizeof (X)) /* The main opcode table entry. Each entry is a unique combination of @@ -237,8 +248,8 @@ static int dlistlen = 0; static int dlisttotlen = 0; -static void fail (const char *, ...); -static void warn (const char *, ...); +static void fail (const char *, ...) ATTRIBUTE_PRINTF_1; +static void warn (const char *, ...) ATTRIBUTE_PRINTF_1; static struct rdep * insert_resource (const char *, enum ia64_dependency_mode); static int deplist_equals (struct deplist *, struct deplist *); static short insert_deplist (int, unsigned short *); @@ -1134,7 +1145,13 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic, else if (strcmp (ic->name, "invala") == 0) resolved = strcmp (idesc->name, ic->name) == 0; else if (strncmp (idesc->name, "st", 2) == 0 - && strstr (format, "M5") != NULL) + && (strstr (format, "M5") != NULL + || strstr (format, "M10") != NULL)) + resolved = idesc->flags & IA64_OPCODE_POSTINC; + else if (strncmp (idesc->name, "ld", 2) == 0 + && (strstr (format, "M2 M3") != NULL + || strstr (format, "M12") != NULL + || strstr (format, "M7 M8") != NULL)) resolved = idesc->flags & IA64_OPCODE_POSTINC; else resolved = 0; @@ -1392,6 +1409,8 @@ lookup_regindex (const char *name, int specifier) return 44; else if (strstr (name, ".ia")) return 45; + else if (strstr (name, ".vm")) + return 46; else abort (); default: @@ -1552,7 +1571,20 @@ print_dependency_table () rdeps[i]->name, specifier, (int)rdeps[i]->mode, (int)rdeps[i]->semantics, regindex); if (rdeps[i]->semantics == IA64_DVS_OTHER) - printf ("\"%s\", ", rdeps[i]->extra); + { + const char *quote, *rest; + + putchar ('\"'); + rest = rdeps[i]->extra; + quote = strchr (rest, '\"'); + while (quote != NULL) + { + printf ("%.*s\\\"", (int) (quote - rest), rest); + rest = quote + 1; + quote = strchr (rest, '\"'); + } + printf ("%s\", ", rest); + } else printf ("NULL, "); printf("},\n"); @@ -1563,7 +1595,7 @@ print_dependency_table () for (i=0;i < dlistlen;i++) { int len = 2; - printf ("static const short dep%d[] = {\n ", i); + printf ("static const unsigned short dep%d[] = {\n ", i); for (j=0;j < dlists[i]->len; j++) { len += printf ("%d, ", dlists[i]->deps[j]); @@ -1906,7 +1938,7 @@ gen_dis_table (ent) if ((needed_bytes + insn_list_len) > tot_insn_list_len) { tot_insn_list_len += 256; - insn_list = (char *) xrealloc (insn_list, tot_insn_list_len); + insn_list = (unsigned char *) xrealloc (insn_list, tot_insn_list_len); } our_offset = insn_list_len; insn_list_len += needed_bytes; @@ -2057,7 +2089,7 @@ gen_dis_table (ent) /* Store the address of the entry being branched to. */ while (currbits >= 0) { - char *byte = insn_list + our_offset + bitsused / 8; + unsigned char *byte = insn_list + our_offset + bitsused / 8; if (idest & (1 << currbits)) *byte |= (1 << (7 - (bitsused % 8))); @@ -2693,9 +2725,9 @@ print_main_table (void) ptr->name->num, ptr->opcode->type, ptr->opcode->num_outputs); - fprintf_vma (stdout, ptr->opcode->opcode); + opcode_fprintf_vma (stdout, ptr->opcode->opcode); printf ("ull, 0x"); - fprintf_vma (stdout, ptr->opcode->mask); + opcode_fprintf_vma (stdout, ptr->opcode->mask); printf ("ull, { %d, %d, %d, %d, %d }, 0x%x, %d, },\n", ptr->opcode->operands[0], ptr->opcode->operands[1], @@ -2719,7 +2751,26 @@ shrink (table) int curr_opcode; for (curr_opcode = 0; table[curr_opcode].name != NULL; curr_opcode++) - add_opcode_entry (table + curr_opcode); + { + add_opcode_entry (table + curr_opcode); + if (table[curr_opcode].num_outputs == 2 + && ((table[curr_opcode].operands[0] == IA64_OPND_P1 + && table[curr_opcode].operands[1] == IA64_OPND_P2) + || (table[curr_opcode].operands[0] == IA64_OPND_P2 + && table[curr_opcode].operands[1] == IA64_OPND_P1))) + { + struct ia64_opcode *alias = tmalloc(struct ia64_opcode); + unsigned i; + + *alias = table[curr_opcode]; + for (i = 2; i < NELEMS (alias->operands); ++i) + alias->operands[i - 1] = alias->operands[i]; + alias->operands[NELEMS (alias->operands) - 1] = IA64_OPND_NIL; + --alias->num_outputs; + alias->flags |= PSEUDO; + add_opcode_entry (alias); + } + } } |