diff options
author | Andrew Cagney <cagney@redhat.com> | 2002-06-06 15:50:50 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2002-06-06 15:50:50 +0000 |
commit | 73fa0d3fb2d9aa3b54cb0a8c8177c40d3ae92287 (patch) | |
tree | 391c8cddb41e9bdf93651b8395d634a5c2ff5a7f /sim/z8k/writecode.c | |
parent | be26fe0d935a6576cd64b7a98950f62e1f4a2e70 (diff) | |
download | gdb-73fa0d3fb2d9aa3b54cb0a8c8177c40d3ae92287.zip gdb-73fa0d3fb2d9aa3b54cb0a8c8177c40d3ae92287.tar.gz gdb-73fa0d3fb2d9aa3b54cb0a8c8177c40d3ae92287.tar.bz2 |
* writecode.c (lookup_inst): Generate inverse table on-the-fly.
(z8k_inv_list): Delete global.
(DIRTY_HACK): Delete macro.
(makelist): Delete global.
(main): Delete code making a list. Delete dirty hack code. Use
lookup_inst instead of z8k_inv_list.
* list.c: Delete file.
* Makefile.in (writecode): Do not link in list.o.
(list.o): Delete target.
Diffstat (limited to 'sim/z8k/writecode.c')
-rw-r--r-- | sim/z8k/writecode.c | 122 |
1 files changed, 25 insertions, 97 deletions
diff --git a/sim/z8k/writecode.c b/sim/z8k/writecode.c index b398545..acff7c4 100644 --- a/sim/z8k/writecode.c +++ b/sim/z8k/writecode.c @@ -1,6 +1,6 @@ - /* generate instructions for Z8KSIM - Copyright (C) 1992, 1993 Free Software Foundation, Inc. + + Copyright 1992, 1993, 2002 Free Software Foundation, Inc. This file is part of Z8KSIM @@ -35,9 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -b3 tc-genb3.h same as -3 but for long pointers - -m regenerates list.c, which is an inverted list of opcodes to - pointers into the z8k dissassemble opcode table, it's just there - to makes things faster. */ /* steve chamberlain @@ -65,8 +62,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define NOPS 500 -#define DIRTY_HACK 0 /* Enable if your gcc can't cope with huge tables */ -extern short z8k_inv_list[]; struct opcode_value { int n; @@ -84,7 +79,6 @@ static char *reg_names[] = #define SIZE_ADDRESS (BIG ? 8 : 4) /* number of nibbles in a ptr*/ static int file; -static int makelist; static int nibs = 0; @@ -103,7 +97,16 @@ static opcode_entry_type * lookup_inst (what) int what; { - if (makelist) + static short *z8k_inv_list = NULL; + const nr_z8k_inv_list_elements = 1 << 16; + if (z8k_inv_list == NULL) + { + /* Initialize the list to 0xff == -1 */ + z8k_inv_list = calloc (nr_z8k_inv_list_elements, sizeof (short)); + memset (z8k_inv_list, 0xff, nr_z8k_inv_list_elements * sizeof (short)); + } + /* Entry empty? Fill it in. */ + if (z8k_inv_list[what] == -1) { int nibl_index; @@ -121,6 +124,9 @@ lookup_inst (what) instr_nibbles[1] = (what >> 8) & 0xf; instr_nibbles[0] = (what >> 12) & 0xf; + /* Assume it won't be found. */ + z8k_inv_list[what] = -2; + while (ptr->name) { nibl_matched = 1; @@ -181,19 +187,15 @@ lookup_inst (what) } if (nibl_matched) { - return ptr; + z8k_inv_list[what] = ptr->idx; + break; /* while */ } ptr++; } - return 0; - } - else - { - - if (z8k_inv_list[what] < 0) - return 0; - return z8k_table + z8k_inv_list[what]; } + if (z8k_inv_list[what] >= 0) + return z8k_table + z8k_inv_list[what]; + return 0; } static char * @@ -1677,12 +1679,8 @@ main (ac, av) int i; int needcomma = 0; - makelist = 0; - for (i = 1; i < ac; i++) { - if (strcmp (av[i], "-m") == 0) - makelist = 1; if (strcmp (av[i], "-1") == 0) file = 1; if (strcmp (av[i], "-2") == 0) @@ -1696,52 +1694,6 @@ main (ac, av) } } - if (makelist) - { - - int i; - needcomma = 0; - printf ("short int z8k_inv_list[] = {\n"); - - for (i = 0; i < 1 << 16; i++) - { - opcode_entry_type *p = lookup_inst (i); - - if(needcomma) - printf(","); - if ((i & 0xf) == 0) - printf ("\n"); - -#if 0 - printf ("\n /*%04x %s */", i, p ? p->nicename : ""); -#endif - - if (!p) - { - printf ("-1"); - } - else - { - printf ("%d", p->idx); - } - - if ((i & 0x3f) == 0 && DIRTY_HACK) - { - printf ("\n#ifdef __GNUC__\n"); - printf ("};\n"); - printf("short int int_list%d[] = {\n", i); - printf ("#else\n"); - printf (",\n"); - printf ("#endif\n"); - needcomma = 0; - } - else - needcomma = 1; - - } - printf ("};\n"); - return 1; - } /* First work out which opcodes use which bit patterns, build a list of all matching bit pattens */ @@ -1776,9 +1728,7 @@ main (ac, av) { int t = quick[i]; - mangle (z8k_table + z8k_inv_list[t], - 1, - t); + mangle (lookup_inst (t), 1, t); } } if (file == 3) @@ -1809,16 +1759,6 @@ main (ac, av) printf (","); emit ("<fop>_%d\n", i); needcomma = 1; - if ((i & 0x3f) == 0 && DIRTY_HACK) - { - printf ("#ifdef __GNUC__\n"); - printf ("};\n"); - emit ("int (*(<fop>_table%d[]))() = {\n", i); - printf ("#else\n"); - printf (",\n"); - printf ("#endif\n"); - needcomma = 0; - } } emit ("};\n"); } @@ -1854,8 +1794,7 @@ main (ac, av) printf ("struct op_info op_info_table[] = {\n"); for (i = 0; i < 1 << 16; i++) { - int inv = z8k_inv_list[i]; - opcode_entry_type *p = z8k_table + inv; + opcode_entry_type *p = lookup_inst (i); if (needcomma) printf (","); @@ -1866,13 +1805,13 @@ main (ac, av) } else #endif - if (inv >= 0) + if (p != NULL) { - printf ("%d", inv); + printf ("%d", p->idx); } else printf ("400"); - if (inv >= 0) + if (p != NULL) { printf (" /* %04x %s */\n", i, p->nicename); } @@ -1881,17 +1820,6 @@ main (ac, av) printf ("\n"); } needcomma = 1; - if ((i & 0x3f) == 0 && DIRTY_HACK) - { - printf ("#ifdef __GNUC__\n"); - printf ("}; \n"); - printf ("struct op_info op_info_table%d[] = {\n", i); - printf ("#else\n"); - printf (",\n"); - - printf ("#endif\n"); - needcomma = 0; - } } printf ("};\n"); |