From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21755 invoked by alias); 2 Jun 2002 17:30:59 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 21748 invoked from network); 2 Jun 2002 17:30:57 -0000 Received: from unknown (HELO localhost.redhat.com) (24.112.240.27) by sources.redhat.com with SMTP; 2 Jun 2002 17:30:57 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 0FB273E79; Sun, 2 Jun 2002 13:31:06 -0400 (EDT) Message-ID: <3CFA565A.2050609@cygnus.com> Date: Sun, 02 Jun 2002 10:30:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0rc3) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com, Christian Groessler Subject: [patch/rfc] Delete sim/z8k/list.c Content-Type: multipart/mixed; boundary="------------020508010405000302050405" X-SW-Source: 2002-06/txt/msg00025.txt.bz2 This is a multi-part message in MIME format. --------------020508010405000302050405 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1071 Following up the change: > 2002-05-07 Christian Groessler >> > >> > * list.c: Regenerated with current opcodes/z8k-opc.h. > >> >> How do I do this? I was thinking that the patch was too big but, if the >> bulk is generated then yes, it is ok. > > > It is generated. Edit sim/z8k/writecode.c and set the DIRTY_HACK > define to 1. I think it's not really needed anymore, but the old > list.c was generated with the same define. > > Then compile writecode.c (it will also be compiled if you build gdb > for z8k-coff) and do a "./writecode -m > list.c". The attached patch deletes sim/z8k/list.c instead [re]generating its contents each time writecode is run. While it might make building the z8k simulator slower, I think it makes its maintenance much easier - one less generated file to contend with. If no one sees problems, I'll commit it in a few days. The files generated by writecode appear to be identical with/without the change (but only if the before case has a freshly re-generated list.c, er, hmm .... :-). Andrew --------------020508010405000302050405 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 6299 2002-06-02 Andrew Cagney * 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. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/sim/z8k/Makefile.in,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Makefile.in --- Makefile.in 16 Apr 1999 01:35:14 -0000 1.1.1.1 +++ Makefile.in 2 Jun 2002 17:10:53 -0000 @@ -49,14 +49,11 @@ tc-genb3.h:writecode ./writecode -b3 >tc-genb3.h -writecode: writecode.o list.o bquick.o - $(CC_FOR_BUILD) -o writecode writecode.o list.o bquick.o +writecode: writecode.o bquick.o + $(CC_FOR_BUILD) -o writecode writecode.o bquick.o writecode.o: writecode.c $(CONFIG_H) $(CC_FOR_BUILD) -c $(CFLAGS) $(HDEFINES) $(CSEARCH) $(CSWITCHES) $(srcdir)/writecode.c - -list.o: list.c - $(CC_FOR_BUILD) -c $(CFLAGS) $(HDEFINES) $(CSEARCH) $(CSWITCHES) $(srcdir)/list.c # Two copies of quick.o are created. One for $build and one for $host. bquick.o: quick.c Index: writecode.c =================================================================== RCS file: /cvs/src/src/sim/z8k/writecode.c,v retrieving revision 1.2 diff -u -r1.2 writecode.c --- writecode.c 29 Apr 2002 16:50:29 -0000 1.2 +++ writecode.c 2 Jun 2002 17:16:34 -0000 @@ -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 @@ -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 @@ #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 @@ #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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ } } - 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 @@ { 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 @@ printf (","); emit ("_%d\n", i); needcomma = 1; - if ((i & 0x3f) == 0 && DIRTY_HACK) - { - printf ("#ifdef __GNUC__\n"); - printf ("};\n"); - emit ("int (*(_table%d[]))() = {\n", i); - printf ("#else\n"); - printf (",\n"); - printf ("#endif\n"); - needcomma = 0; - } } emit ("};\n"); } @@ -1854,8 +1794,7 @@ 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 @@ } 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 @@ 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"); --------------020508010405000302050405--